repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
reznikmm/matreshka | Ada | 4,959 | 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.
------------------------------------------------------------------------------
-- The most general class for Styles in UML.
------------------------------------------------------------------------------
with AMF.DI.Styles;
with AMF.UML.Packageable_Elements;
package AMF.UMLDI.UML_Styles is
pragma Preelaborate;
type UMLDI_UML_Style is limited interface
and AMF.UML.Packageable_Elements.UML_Packageable_Element
and AMF.DI.Styles.DI_Style;
type UMLDI_UML_Style_Access is
access all UMLDI_UML_Style'Class;
for UMLDI_UML_Style_Access'Storage_Size use 0;
not overriding function Get_Font_Name
(Self : not null access constant UMLDI_UML_Style)
return AMF.Optional_String is abstract;
-- Getter of UMLStyle::fontName.
--
-- Name of a font used to render strings.
not overriding procedure Set_Font_Name
(Self : not null access UMLDI_UML_Style;
To : AMF.Optional_String) is abstract;
-- Setter of UMLStyle::fontName.
--
-- Name of a font used to render strings.
not overriding function Get_Font_Size
(Self : not null access constant UMLDI_UML_Style)
return AMF.Optional_Real is abstract;
-- Getter of UMLStyle::fontSize.
--
-- Size of a font for rendering strings, given in typographical points.
not overriding procedure Set_Font_Size
(Self : not null access UMLDI_UML_Style;
To : AMF.Optional_Real) is abstract;
-- Setter of UMLStyle::fontSize.
--
-- Size of a font for rendering strings, given in typographical points.
end AMF.UMLDI.UML_Styles;
|
faelys/natools | Ada | 2,334 | ads | ------------------------------------------------------------------------------
-- Copyright (c) 2016-2017, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Natools.Smaz_4096 provides the subprograms needed to instantiate --
-- Natools.Smaz_Generic into a variant of the Smaz compression algorithm --
-- that output directly base-64 printable symbols, but with a dictionary --
-- indexed by two symbols, allowing a maximum size of 4095 entries. --
------------------------------------------------------------------------------
with Natools.Smaz_Generic;
with Natools.Smaz_Implementations.Base_4096;
package Natools.Smaz_4096 is new Natools.Smaz_Generic
(Dictionary_Code => Natools.Smaz_Implementations.Base_4096.Base_4096_Digit,
Read_Code => Natools.Smaz_Implementations.Base_4096.Read_Code,
Read_Verbatim => Natools.Smaz_Implementations.Base_4096.Read_Verbatim,
Skip_Verbatim => Natools.Smaz_Implementations.Base_4096.Skip_Verbatim,
Verbatim_Size => Natools.Smaz_Implementations.Base_4096.Verbatim_Size,
Write_Code => Natools.Smaz_Implementations.Base_4096.Write_Code,
Write_Verbatim => Natools.Smaz_Implementations.Base_4096.Write_Verbatim);
pragma Pure (Natools.Smaz_4096);
|
zhmu/ananas | Ada | 375 | adb | package body Array39_Pkg is
task Body Tsk is
begin
select
accept E (R : out Rec2; L : Index2) do
declare
A : Arr2 (Index2);
LL : Index2 := L;
begin
for I in 1 .. LL loop
A (I) := Val;
end loop;
R := (D => LL, A => A (1 .. LL));
end;
end E;
end select;
end Tsk;
end Array39_Pkg;
|
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.Chart_Minimum_Attributes is
pragma Preelaborate;
type ODF_Chart_Minimum_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Chart_Minimum_Attribute_Access is
access all ODF_Chart_Minimum_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Chart_Minimum_Attributes;
|
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.Meta_Creation_Date_Elements is
pragma Preelaborate;
type ODF_Meta_Creation_Date is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Meta_Creation_Date_Access is
access all ODF_Meta_Creation_Date'Class
with Storage_Size => 0;
end ODF.DOM.Meta_Creation_Date_Elements;
|
godunko/adawebpack | Ada | 2,935 | ads | ------------------------------------------------------------------------------
-- --
-- AdaWebPack --
-- --
------------------------------------------------------------------------------
-- Copyright © 2020, Vadim Godunko --
-- 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. --
------------------------------------------------------------------------------
-- Root package for WASM interface support.
------------------------------------------------------------------------------
package WASM is
pragma Pure;
end WASM;
|
AdaCore/training_material | Ada | 24,026 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with System;
with stddef_h;
with Interfaces.C.Strings;
package intrin_h is
-- unsupported macro: WINAPI __stdcall
--*
-- * This file has no copyright assigned and is placed in the Public Domain.
-- * This file is part of the mingw-w64 runtime package.
-- * No warranty is given; refer to the file DISCLAIMER.PD within this package.
--
-- The purpose of this file is to provide support for MSVC's intrinsics (what gcc calls
-- Builtins) in gcc. In MSVC, there are several features for intrinsics:
-- - Intrinsics can either be implemented inline (via the compiler), or implemented as functions.
-- - You can specify which approach you prefer either globally (via compile switch /Oi) or
-- on a function by function basis via pragmas.
-- - Before you can use any of the intrinsics, they must be declared via a prototype. For
-- whatever reason, MS has decided to put all the intrinsics in one file (intrin.h) AND
-- to put duplicate copies of some of these prototypes in various platform sdk headers.
-- In gcc, this is implemented as follows:
-- - The inline implementations for the intrinsics are located in intrin-impl.h. This file
-- is included by intrin.h, as well as various platform sdk headers.
-- - Including intrin.h will create definitions/implementations for all available MSVC intrinsics.
-- - Including various platforms sdk headers will only include the intrinsics defined in that
-- header. As of this writing, only winnt.h and winbase.h use this approach.
-- - If an application defines its own prototypes for intrinsics (ie without including any
-- platform header or intrin.h), the symbols will be resolved from the library. Since this
-- will likely result in the code being invoked via 'call', performance may be degraded.
-- If you wish to implement intrinsic functions that are defined in intrin.h but are not
-- yet implemented in mingw-w64, see the comments at the top of intrin-impl.h.
--
-- * Intrins shiped with GCC conflict with our versions in C++, because they don't use extern "C"
-- * linkage while our variants use them. We try to work around this by including those headers
-- * here wrapped in extern "C" block. It's still possible that those intrins will get default
-- * C++ linkage (when GCC headers are explicitly included before intrin.h), but at least their
-- * guards will prevent duplicated declarations and avoid conflicts.
-- *
-- * On GCC 4.9 we may always include those headers. On older GCCs, we may do it only if CPU
-- * features used by them are enabled, so we need to check macros like __SSE__ or __MMX__ first.
--
-- Make sure _mm_malloc and _mm_free are defined.
-- NOTE: it's not included by MS version, but we do it to try work around C++/C linkage differences
-- Put all declarations potentially colliding with POSIX headers here.
-- So far, Cygwin is the only POSIX system using this header file.
-- If that ever changes, make sure to tweak the guarding ifndef.
function c_abs (u_X : int) return int; -- d:\install\gpl2018\x86_64-pc-mingw32\include\intrin.h:242
pragma Import (C, c_abs, "abs");
function ceil (arg1 : double) return double; -- d:\install\gpl2018\x86_64-pc-mingw32\include\intrin.h:243
pragma Import (C, ceil, "ceil");
function labs (u_X : long) return long; -- d:\install\gpl2018\x86_64-pc-mingw32\include\intrin.h:244
pragma Import (C, labs, "labs");
function memcmp
(arg1 : System.Address;
arg2 : System.Address;
arg3 : stddef_h.size_t) return int; -- d:\install\gpl2018\x86_64-pc-mingw32\include\intrin.h:246
pragma Import (C, memcmp, "memcmp");
function memcpy
(arg1 : System.Address;
arg2 : System.Address;
arg3 : stddef_h.size_t) return System.Address; -- d:\install\gpl2018\x86_64-pc-mingw32\include\intrin.h:247
pragma Import (C, memcpy, "memcpy");
function memset
(arg1 : System.Address;
arg2 : int;
arg3 : stddef_h.size_t) return System.Address; -- d:\install\gpl2018\x86_64-pc-mingw32\include\intrin.h:248
pragma Import (C, memset, "memset");
function strcat (arg1 : Interfaces.C.Strings.chars_ptr; arg2 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr; -- d:\install\gpl2018\x86_64-pc-mingw32\include\intrin.h:249
pragma Import (C, strcat, "strcat");
function strcmp (arg1 : Interfaces.C.Strings.chars_ptr; arg2 : Interfaces.C.Strings.chars_ptr) return int; -- d:\install\gpl2018\x86_64-pc-mingw32\include\intrin.h:250
pragma Import (C, strcmp, "strcmp");
function strcpy (arg1 : Interfaces.C.Strings.chars_ptr; arg2 : Interfaces.C.Strings.chars_ptr) return Interfaces.C.Strings.chars_ptr; -- d:\install\gpl2018\x86_64-pc-mingw32\include\intrin.h:251
pragma Import (C, strcpy, "strcpy");
function strlen (arg1 : Interfaces.C.Strings.chars_ptr) return stddef_h.size_t; -- d:\install\gpl2018\x86_64-pc-mingw32\include\intrin.h:252
pragma Import (C, strlen, "strlen");
function wcscat (arg1 : access wchar_t; arg2 : access wchar_t) return access wchar_t; -- d:\install\gpl2018\x86_64-pc-mingw32\include\intrin.h:255
pragma Import (C, wcscat, "wcscat");
function wcscmp (arg1 : access wchar_t; arg2 : access wchar_t) return int; -- d:\install\gpl2018\x86_64-pc-mingw32\include\intrin.h:256
pragma Import (C, wcscmp, "wcscmp");
function wcscpy (arg1 : access wchar_t; arg2 : access wchar_t) return access wchar_t; -- d:\install\gpl2018\x86_64-pc-mingw32\include\intrin.h:257
pragma Import (C, wcscpy, "wcscpy");
function wcslen (arg1 : access wchar_t) return stddef_h.size_t; -- d:\install\gpl2018\x86_64-pc-mingw32\include\intrin.h:258
pragma Import (C, wcslen, "wcslen");
-- skipped func _byteswap_ushort
-- skipped func _byteswap_ulong
-- skipped func _byteswap_uint64
-- skipped func _disable
-- skipped func __emul
-- skipped func __emulu
-- skipped func _enable
-- __MACHINEI(__LONG32 __cdecl _InterlockedDecrement(__LONG32 volatile *)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(__MINGW_EXTENSION __int64 _InterlockedDecrement64(__int64 volatile *)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(__LONG32 _InterlockedExchange(__LONG32 volatile *,__LONG32)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(__MINGW_EXTENSION __int64 _InterlockedExchange64(__int64 volatile *,__int64)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(void *_InterlockedExchangePointer(void *volatile *,void *)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(__LONG32 _InterlockedExchangeAdd(__LONG32 volatile *,__LONG32)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(__MINGW_EXTENSION __int64 _InterlockedExchangeAdd64(__int64 volatile *,__int64)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(__LONG32 _InterlockedCompareExchange (__LONG32 volatile *,__LONG32,__LONG32)) moved to psdk_inc/intrin-impl.h
-- skipped func _InterlockedCompare64Exchange128
-- skipped func _InterlockedCompare64Exchange128_acq
-- skipped func _InterlockedCompare64Exchange128_rel
-- __MACHINEI(__MINGW_EXTENSION __int64 _InterlockedCompareExchange64(__int64 volatile *,__int64,__int64)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(void *_InterlockedCompareExchangePointer (void *volatile *,void *,void *)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(__LONG32 __cdecl _InterlockedIncrement(__LONG32 volatile *)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(__MINGW_EXTENSION __int64 _InterlockedIncrement64(__int64 volatile *)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIW64(__LONG32 _InterlockedOr(__LONG32 volatile *,__LONG32)) moved to psdk_inc/intrin-impl.h
-- skipped func _InterlockedOr8
-- skipped func _InterlockedOr16
-- __MACHINEW64(__MINGW_EXTENSION __int64 _InterlockedOr64(__int64 volatile *,__int64)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIW64(__LONG32 _InterlockedXor(__LONG32 volatile *,__LONG32)) moved to psdk_inc/intrin-impl.h
-- skipped func _InterlockedXor8
-- skipped func _InterlockedXor16
-- __MACHINEW64(__MINGW_EXTENSION __int64 _InterlockedXor64(__int64 volatile *,__int64)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIW64(__LONG32 _InterlockedAnd(__LONG32 volatile *,__LONG32)) moved to psdk_inc/intrin-impl.h
-- skipped func _InterlockedAnd8
-- skipped func _InterlockedAnd16
-- __MACHINEW64(__MINGW_EXTENSION __int64 _InterlockedAnd64(__int64 volatile *,__int64)) moved to psdk_inc/intrin-impl.h
-- skipped func _inp
function inp (arg1 : unsigned_short) return int; -- d:\install\gpl2018\x86_64-pc-mingw32\include\intrin.h:400
pragma Import (C, inp, "inp");
-- skipped func _inpd
function inpd (arg1 : unsigned_short) return unsigned_long; -- d:\install\gpl2018\x86_64-pc-mingw32\include\intrin.h:402
pragma Import (C, inpd, "inpd");
-- skipped func _inpw
function inpw (arg1 : unsigned_short) return unsigned_short; -- d:\install\gpl2018\x86_64-pc-mingw32\include\intrin.h:404
pragma Import (C, inpw, "inpw");
-- skipped func _lrotl
-- skipped func _lrotr
-- skipped func __ll_lshift
-- skipped func __ll_rshift
-- skipped func _outp
function outp (arg1 : unsigned_short; arg2 : int) return int; -- d:\install\gpl2018\x86_64-pc-mingw32\include\intrin.h:479
pragma Import (C, outp, "outp");
-- skipped func _outpd
function outpd (arg1 : unsigned_short; arg2 : unsigned_long) return unsigned_long; -- d:\install\gpl2018\x86_64-pc-mingw32\include\intrin.h:481
pragma Import (C, outpd, "outpd");
-- skipped func _outpw
function outpw (arg1 : unsigned_short; arg2 : unsigned_short) return unsigned_short; -- d:\install\gpl2018\x86_64-pc-mingw32\include\intrin.h:483
pragma Import (C, outpw, "outpw");
-- __MACHINECE(void _ReadWriteBarrier(void)) moved to psdk_inc/intrin-impl.h
-- skipped func _ReturnAddress
-- skipped func _rotl
-- skipped func _rotr
-- skipped func _rotl64
-- skipped func _rotr64
-- skipped func _setjmp
-- skipped func _setjmpex
-- skipped func _strset
function strset (arg1 : Interfaces.C.Strings.chars_ptr; arg2 : int) return Interfaces.C.Strings.chars_ptr; -- d:\install\gpl2018\x86_64-pc-mingw32\include\intrin.h:535
pragma Import (C, strset, "strset");
-- skipped func __ull_rshift
-- __MACHINECE(void _WriteBarrier(void)) moved to psdk_inc/intrin-impl.h
-- skipped func _AddressOfReturnAddress
-- __MACHINEX86X_NOIA64(void _mm_prefetch(char const*,int))
-- __MACHINEX86X(__m128d _mm_shuffle_pd(__m128d,__m128d,int))
-- __MACHINEX86X(__m128i _mm_slli_si128(__m128i,int))
-- __MACHINEX86X(__m128i _mm_slli_epi16(__m128i,int))
-- __MACHINEX86X(__m128i _mm_slli_epi32(__m128i,int))
-- __MACHINEX86X(__m128i _mm_slli_epi64(__m128i,int))
-- __MACHINEX86X(__m128i _mm_srai_epi16(__m128i,int))
-- __MACHINEX86X(__m128i _mm_srai_epi32(__m128i,int))
-- __MACHINEX86X(__m128i _mm_srli_si128(__m128i,int))
-- __MACHINEX86X(__m128i _mm_srli_epi16(__m128i,int))
-- __MACHINEX86X(__m128i _mm_srli_epi32(__m128i,int))
-- __MACHINEX86X(__m128i _mm_srli_epi64(__m128i,int))
-- __MACHINEX86X(int _mm_extract_epi16(__m128i,int))
-- __MACHINEX86X(__m128i _mm_insert_epi16(__m128i,int,int))
-- __MACHINEX86X(__m128i _mm_shuffle_epi32(__m128i,int))
-- __MACHINEX86X(__m128i _mm_shufflehi_epi16(__m128i,int))
-- __MACHINEX86X(__m128i _mm_shufflelo_epi16(__m128i,int))
-- __MACHINEI(void _WriteBarrier(void)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(void _ReadWriteBarrier(void)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIA64(void _WriteBarrier(void)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIA64(void _ReadWriteBarrier(void)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(void __faststorefence(void)) moved to psdk_inc/intrin-impl.h
-- skipped func __mulh
-- skipped func __umulh
-- __MACHINEX64(__MINGW_EXTENSION unsigned __int64 __readcr0(void)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(__MINGW_EXTENSION unsigned __int64 __readcr2(void)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(__MINGW_EXTENSION unsigned __int64 __readcr3(void)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(__MINGW_EXTENSION unsigned __int64 __readcr4(void)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(__MINGW_EXTENSION unsigned __int64 __readcr8(void)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIA32(unsigned __LONG32 __readcr0(void)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIA32(unsigned __LONG32 __readcr2(void)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIA32(unsigned __LONG32 __readcr3(void)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIA32(unsigned __LONG32 __readcr4(void)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIA32(unsigned __LONG32 __readcr8(void)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(__MINGW_EXTENSION void __writecr0(unsigned __int64)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(__MINGW_EXTENSION void __writecr3(unsigned __int64)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(__MINGW_EXTENSION void __writecr4(unsigned __int64)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(__MINGW_EXTENSION void __writecr8(unsigned __int64)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIA32(void __writecr0(unsigned)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIA32(void __writecr3(unsigned)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIA32(void __writecr4(unsigned)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIA32(void __writecr8(unsigned)) moved to psdk_inc/intrin-impl.h
-- skipped func __wbinvd
-- skipped func __invlpg
-- __MACHINEI(__MINGW_EXTENSION unsigned __int64 __readmsr(unsigned __LONG32)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(__MINGW_EXTENSION void __writemsr(unsigned __LONG32,unsigned __int64)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(void __movsb(unsigned char *,unsigned char const *,size_t)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(void __movsw(unsigned short *,unsigned short const *,size_t)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(void __movsd(unsigned __LONG32 *,unsigned __LONG32 const *,size_t)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(__MINGW_EXTENSION void __movsq(unsigned long long *,unsigned long long const *,size_t)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(unsigned char __readgsbyte(unsigned __LONG32 Offset)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(unsigned short __readgsword(unsigned __LONG32 Offset)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(unsigned __LONG32 __readgsdword(unsigned __LONG32 Offset)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(__MINGW_EXTENSION unsigned __int64 __readgsqword(unsigned __LONG32 Offset)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(void __writegsbyte(unsigned __LONG32 Offset,unsigned char Data)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(void __writegsword(unsigned __LONG32 Offset,unsigned short Data)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(void __writegsdword(unsigned __LONG32 Offset,unsigned __LONG32 Data)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(__MINGW_EXTENSION void __writegsqword(unsigned __LONG32 Offset,unsigned __int64 Data)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(unsigned char __inbyte(unsigned short Port)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(unsigned short __inword(unsigned short Port)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(unsigned __LONG32 __indword(unsigned short Port)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(void __outbyte(unsigned short Port,unsigned char Data)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(void __outword(unsigned short Port,unsigned short Data)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(void __outdword(unsigned short Port,unsigned __LONG32 Data)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(void __inbytestring(unsigned short Port,unsigned char *Buffer,unsigned __LONG32 Count)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(void __inwordstring(unsigned short Port,unsigned short *Buffer,unsigned __LONG32 Count)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(void __indwordstring(unsigned short Port,unsigned __LONG32 *Buffer,unsigned __LONG32 Count)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(void __outbytestring(unsigned short Port,unsigned char *Buffer,unsigned __LONG32 Count)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(void __outwordstring(unsigned short Port,unsigned short *Buffer,unsigned __LONG32 Count)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(void __outdwordstring(unsigned short Port,unsigned __LONG32 *Buffer,unsigned __LONG32 Count)) moved to psdk_inc/intrin-impl.h
-- skipped func __getcallerseflags
-- skipped func _mm_stream_si64x
-- __MACHINEI(void __stosb(unsigned char *,unsigned char,size_t)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(void __stosw(unsigned short *,unsigned short,size_t)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(void __stosd(unsigned __LONG32 *,unsigned __LONG32,size_t)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(__MINGW_EXTENSION void __stosq(unsigned __int64 *,unsigned __int64,size_t)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIW64(unsigned char _bittest(__LONG32 const *a,__LONG32 b)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIW64(unsigned char _bittestandset(__LONG32 *a,__LONG32 b)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIW64(unsigned char _bittestandreset(__LONG32 *a,__LONG32 b)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIW64(unsigned char _bittestandcomplement(__LONG32 *a,__LONG32 b)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(unsigned char InterlockedBitTestAndSet(volatile __LONG32 *a,__LONG32 b)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(unsigned char InterlockedBitTestAndReset(volatile __LONG32 *a,__LONG32 b)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(unsigned char InterlockedBitTestAndComplement(volatile __LONG32 *a,__LONG32 b)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(unsigned char _interlockedbittestandset(__LONG32 *a,__LONG32 b)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(unsigned char _interlockedbittestandreset(__LONG32 *a,__LONG32 b)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(unsigned char _interlockedbittestandcomplement(__LONG32 *a,__LONG32 b)) moved to psdk_inc/intrin-impl.h
-- __MACHINEW64(__MINGW_EXTENSION unsigned char _bittest64(__int64 const *a,__int64 b)) moved to psdk_inc/intrin-impl.h
-- __MACHINEW64(__MINGW_EXTENSION unsigned char _bittestandset64(__int64 *a,__int64 b)) moved to psdk_inc/intrin-impl.h
-- __MACHINEW64(__MINGW_EXTENSION unsigned char _bittestandreset64(__int64 *a,__int64 b)) moved to psdk_inc/intrin-impl.h
-- __MACHINEW64(__MINGW_EXTENSION unsigned char _bittestandcomplement64(__int64 *a,__int64 b)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(__MINGW_EXTENSION unsigned char InterlockedBitTestAndSet64(volatile __int64 *a,__int64 b)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(__MINGW_EXTENSION unsigned char InterlockedBitTestAndReset64(volatile __int64 *a,__int64 b)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(__MINGW_EXTENSION unsigned char InterlockedBitTestAndComplement64(volatile __int64 *a,__int64 b)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(__MINGW_EXTENSION unsigned char _interlockedbittestandset64(__int64 *a,__int64 b)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(__MINGW_EXTENSION unsigned char _interlockedbittestandreset64(__int64 *a,__int64 b)) moved to psdk_inc/intrin-impl.h
-- __MACHINEX64(__MINGW_EXTENSION unsigned char _interlockedbittestandcomplement64(__int64 *a,__int64 b)) moved to psdk_inc/intrin-impl.h
-- skipped func __readpmc
-- skipped func __segmentlimit
-- __MACHINEIA32(unsigned char __readfsbyte(unsigned __LONG32 Offset)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIA32(unsigned short __readfsword(unsigned __LONG32 Offset)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIA32(unsigned __LONG32 __readfsdword(unsigned __LONG32 Offset)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIA32(__MINGW_EXTENSION unsigned __int64 __readfsqword(unsigned __LONG32 Offset)) intrinsic doesn't actually exist
-- __MACHINEIA32(void __writefsbyte(unsigned __LONG32 Offset,unsigned char Data)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIA32(void __writefsword(unsigned __LONG32 Offset,unsigned short Data)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIA32(void __writefsdword(unsigned __LONG32 Offset,unsigned __LONG32 Data)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIA32(__MINGW_EXTENSION void __writefsqword(unsigned __LONG32 Offset,unsigned __int64 Data)) intrinsic doesn't actually exist
-- __MACHINEIW64(unsigned char _BitScanForward(unsigned __LONG32 *Index,unsigned __LONG32 Mask)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIW64(unsigned char _BitScanReverse(unsigned __LONG32 *Index,unsigned __LONG32 Mask)) moved to psdk_inc/intrin-impl.h
-- __MACHINEW64(__MINGW_EXTENSION unsigned char _BitScanForward64(unsigned __LONG32 *Index,unsigned __int64 Mask)) moved to psdk_inc/intrin-impl.h
-- __MACHINEW64(__MINGW_EXTENSION unsigned char _BitScanReverse64(unsigned __LONG32 *Index,unsigned __int64 Mask)) moved to psdk_inc/intrin-impl.h
-- skipped func _wcsset
-- __MACHINEW64(__MINGW_EXTENSION unsigned __int64 __shiftleft128(unsigned __int64 LowPart,unsigned __int64 HighPart,unsigned char Shift)) moved to psdk_inc/intrin-impl.h
-- __MACHINEW64(__MINGW_EXTENSION unsigned __int64 __shiftright128(unsigned __int64 LowPart,unsigned __int64 HighPart,unsigned char Shift)) moved to psdk_inc/intrin-impl.h
-- __MACHINEW64(__MINGW_EXTENSION unsigned __int64 _umul128(unsigned __int64 multiplier,unsigned __int64 multiplicand,unsigned __int64 *highproduct)) moved to psdk_inc/intrin-impl.h
-- __MACHINEW64(__MINGW_EXTENSION __int64 _mul128(__int64 multiplier,__int64 multiplicand,__int64 *highproduct)) moved to psdk_inc/intrin-impl.h
-- __MACHINEI(void __int2c(void)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIW64(void _ReadBarrier(void)) moved to psdk_inc/intrin-impl.h
-- skipped func _rotr8
-- skipped func _rotr16
-- skipped func _rotl8
-- skipped func _rotl16
-- __MACHINEIW64(short _InterlockedIncrement16(short volatile *Addend)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIW64(short _InterlockedDecrement16(short volatile *Addend)) moved to psdk_inc/intrin-impl.h
-- __MACHINEIW64(short _InterlockedCompareExchange16(short volatile *Destination,short Exchange,short Comparand)) moved to psdk_inc/intrin-impl.h
-- skipped func __nvreg_save_fence
-- skipped func __nvreg_restore_fence
-- skipped func _InterlockedCompareExchange16_np
-- skipped func _InterlockedCompareExchange_np
-- skipped func _InterlockedCompareExchange64_np
-- skipped func _InterlockedCompareExchangePointer_np
-- skipped func _InterlockedCompare64Exchange128_np
-- skipped func _InterlockedCompare64Exchange128_acq_np
-- skipped func _InterlockedCompare64Exchange128_rel_np
-- skipped func _InterlockedAnd_np
-- skipped func _InterlockedAnd8_np
-- skipped func _InterlockedAnd16_np
-- skipped func _InterlockedAnd64_np
-- skipped func _InterlockedOr_np
-- skipped func _InterlockedOr8_np
-- skipped func _InterlockedOr16_np
-- skipped func _InterlockedOr64_np
-- skipped func _InterlockedXor_np
-- skipped func _InterlockedXor8_np
-- skipped func _InterlockedXor16_np
-- skipped func _InterlockedXor64_np
end intrin_h;
|
zhmu/ananas | Ada | 3,110 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- A D A . I N T E R R U P T S . N A M E S --
-- --
-- S p e c --
-- (No Tasking Version) --
-- --
-- Copyright (C) 1991-2022, Free Software Foundation, Inc. --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- The standard implementation of this spec contains only dummy interrupt
-- names. These dummy entries permit checking out code for correctness of
-- semantics, even if interrupts are not supported.
-- For specific implementations that fully support interrupts, this package
-- spec is replaced by an implementation dependent version that defines the
-- interrupts available on the system.
package Ada.Interrupts.Names is
-- All identifiers in this unit are implementation defined
pragma Implementation_Defined;
DUMMY_INTERRUPT_1 : constant Interrupt_ID := 1;
DUMMY_INTERRUPT_2 : constant Interrupt_ID := 2;
end Ada.Interrupts.Names;
|
reznikmm/matreshka | Ada | 4,667 | 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$
------------------------------------------------------------------------------
with AMF.MOF.Tags;
with AMF.UML.Extensions;
with AMF.UML.Extension_Ends;
with AMF.UML.Properties;
with AMF.Visitors.MOF_Visitors;
with AMF.Visitors.UML_Visitors;
with AMF.Transformations.UML_Profile_To_CMOF.Contexts;
private package AMF.Transformations.UML_Profile_To_CMOF.Stage_2 is
type Transformer
(Context : not null access Contexts.Transformation_Context) is
limited new AMF.Visitors.MOF_Visitors.MOF_Visitor
and AMF.Visitors.UML_Visitors.UML_Visitor with null record;
overriding procedure Enter_Extension
(Self : in out Transformer;
Element : not null AMF.UML.Extensions.UML_Extension_Access;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Enter_Extension_End
(Self : in out Transformer;
Element : not null AMF.UML.Extension_Ends.UML_Extension_End_Access;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Enter_Property
(Self : in out Transformer;
Element : not null AMF.UML.Properties.UML_Property_Access;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Enter_Tag
(Self : in out Transformer;
Element : not null AMF.MOF.Tags.MOF_Tag_Access;
Control : in out AMF.Visitors.Traverse_Control);
end AMF.Transformations.UML_Profile_To_CMOF.Stage_2;
|
yannickmoy/atomic | Ada | 118 | ads | with Interfaces;
with Atomic.Generic32;
package Atomic.Unsigned_32 is new Atomic.Generic32 (Interfaces.Unsigned_32);
|
msrLi/portingSources | Ada | 832 | adb | -- Copyright 2012-2014 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package body Pck is
procedure Do_Nothing (A : System.Address) is
begin
null;
end Do_Nothing;
end Pck;
|
michael-hardeman/contacts_app | Ada | 8,607 | adb | -- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../../License.txt
with Ada.Strings.Fixed;
with Ada.Strings.Wide_Fixed;
with Ada.Strings.Wide_Wide_Fixed;
with Ada.Characters.Conversions;
with Ada.Strings.UTF_Encoding.Strings;
package body AdaBase.Results.Generic_Converters is
package AS renames Ada.Strings;
package ACC renames Ada.Characters.Conversions;
--------------------------
-- GENERIC convertstr --
--------------------------
function convertstr (nv : Textual) return IntType
is
nverr : constant String := CT.USS (nv);
begin
return IntType'Value (nverr);
exception
when others =>
raise CONVERSION_FAILED with "Tried to convert '" & nverr & "' (S/I)";
end convertstr;
--------------------------
-- GENERIC convertst2 --
--------------------------
function convertst2 (nv : Textual) return RealType
is
nverr : constant String := CT.USS (nv);
begin
return RealType'Value (nverr);
exception
when others =>
raise CONVERSION_FAILED with "Tried to convert '" & nverr & "' (S/R)";
end convertst2;
--------------------------
-- GENERIC convertst3 --
--------------------------
function convertst3 (nv : Textwide) return IntType
is
wstr : constant Wide_String := SUW.To_Wide_String (Source => nv);
str : constant String := ACC.To_String (Item => wstr);
begin
return IntType'Value (str);
exception
when others =>
raise CONVERSION_FAILED with "Tried to convert '" & str & "' (WS/I)";
end convertst3;
--------------------------
-- GENERIC convertst4 --
--------------------------
function convertst4 (nv : Textwide) return RealType
is
wstr : constant Wide_String := SUW.To_Wide_String (Source => nv);
str : constant String := ACC.To_String (Item => wstr);
begin
return RealType'Value (str);
exception
when others =>
raise CONVERSION_FAILED with "Tried to convert '" & str & "' (WS/R)";
end convertst4;
--------------------------
-- GENERIC convertst5 --
--------------------------
function convertst5 (nv : Textsuper) return IntType
is
wwstr : constant Wide_Wide_String := SUWW.To_Wide_Wide_String (nv);
str : constant String := ACC.To_String (Item => wwstr);
begin
return IntType'Value (str);
exception
when others =>
raise CONVERSION_FAILED with "Tried to convert '" & str & "' (WWS/I)";
end convertst5;
--------------------------
-- GENERIC convertst6 --
--------------------------
function convertst6 (nv : Textsuper) return RealType
is
wwstr : constant Wide_Wide_String := SUWW.To_Wide_Wide_String (nv);
str : constant String := ACC.To_String (Item => wwstr);
begin
return RealType'Value (str);
exception
when others =>
raise CONVERSION_FAILED with "Tried to convert '" & str & "' (WWS/R)";
end convertst6;
--------------------
-- convert2utf8 --
--------------------
function convert2utf8 (nv : IntType) return Text_UTF8 is
begin
return SUTF.Strings.Encode (Item => ctrim (nv'Img));
end convert2utf8;
----------------------------
-- GENERIC convert2str1 --
----------------------------
function convert2str1 (nv : IntType) return String is
begin
return ctrim (nv'Img);
end convert2str1;
----------------------------
-- GENERIC convert2str2 --
----------------------------
function convert2str2 (nv : IntType) return Wide_String is
begin
return wtrim (nv'Img);
end convert2str2;
----------------------------
-- GENERIC convert2str3 --
----------------------------
function convert2str3 (nv : IntType) return Wide_Wide_String is
begin
return strim (nv'Img);
end convert2str3;
--------------------
-- convert3utf8 --
--------------------
function convert3utf8 (nv : RealType) return Text_UTF8 is
begin
return SUTF.Strings.Encode (Item => ctrim (nv'Img));
end convert3utf8;
----------------------------
-- GENERIC convert3str1 --
----------------------------
function convert3str1 (nv : RealType) return String is
begin
return ctrim (nv'Img);
end convert3str1;
----------------------------
-- GENERIC convert3str2 --
----------------------------
function convert3str2 (nv : RealType) return Wide_String is
begin
return wtrim (nv'Img);
end convert3str2;
----------------------------
-- GENERIC convert3str3 --
----------------------------
function convert3str3 (nv : RealType) return Wide_Wide_String is
begin
return strim (nv'Img);
end convert3str3;
---------------------------
-- GENERIC convert4str --
---------------------------
function convert4str (nv : String) return IntType is
begin
return IntType'Value (nv);
exception
when others =>
raise CONVERSION_FAILED with "Tried to convert '" & nv & "' (ST/I)";
end convert4str;
---------------------------
-- GENERIC convert4st2 --
---------------------------
function convert4st2 (nv : String) return RealType is
begin
return RealType'Value (nv);
exception
when others =>
raise CONVERSION_FAILED with "Tried to convert '" & nv & "' (ST/R)";
end convert4st2;
--------------------
-- convert2bits --
--------------------
function convert2bits (nv : ModType) return Bits
is
result : Bits (0 .. width) := (others => 0);
mask : ModType;
begin
for x in result'Range loop
mask := 2 ** x;
if (nv and mask) > 0 then
result (x) := 1;
end if;
end loop;
return result;
end convert2bits;
---------------------
-- convert2chain --
---------------------
function convert2chain (nv : ModType) return Chain
is
bitwidth : constant Natural := (width * 8) - 1;
result : Chain (1 .. width) := (others => 0);
asbits : Bits (0 .. bitwidth) := (others => 0);
arrow : Natural := 0;
mask : ModType;
submask : constant array (0 .. 7) of NByte1 := (2 ** 0, 2 ** 1,
2 ** 2, 2 ** 3,
2 ** 4, 2 ** 5,
2 ** 6, 2 ** 7);
begin
-- convert to bits first
for x in asbits'Range loop
mask := 2 ** x;
if (nv and mask) > 0 then
result (x) := 1;
end if;
end loop;
-- convert from bits to nbyte1
for x in result'Range loop
for y in submask'Range loop
if asbits (arrow + y) = 1 then
result (x) := result (x) + submask (y);
end if;
end loop;
arrow := arrow + 8;
end loop;
return result;
end convert2chain;
--------------------
-- convert_bits --
--------------------
function convert_bits (nv : Bits) return ModType
is
numbits : Natural := nv'Length;
asbits : Bits (0 .. numbits - 1) := nv;
result : ModType := 0;
begin
if asbits'Last > MSB then
raise TARGET_TYPE_TOO_NARROW;
end if;
for x in asbits'Range loop
if asbits (x) > 0 then
result := result + (2 ** x);
end if;
end loop;
return result;
end convert_bits;
---------------------
-- convert_chain --
---------------------
function convert_chain (nv : Chain) return ModType
is
link : NByte1;
counter : Natural := 0;
result : ModType := 0;
begin
if nv'Length > width then
raise TARGET_TYPE_TOO_NARROW;
end if;
for x in nv'Range loop
link := nv (x);
result := result + ModType (link * (2 ** counter));
counter := counter + 8;
end loop;
return result;
end convert_chain;
------------------------------
-- PRIVATE TRIM FUNCTIONS --
------------------------------
function ctrim (raw : String) return String is
begin
return AS.Fixed.Trim (raw, AS.Left);
end ctrim;
function wtrim (raw : String) return Wide_String is
begin
return ACC.To_Wide_String (AS.Fixed.Trim (raw, AS.Left));
end wtrim;
function strim (raw : String) return Wide_Wide_String is
begin
return ACC.To_Wide_Wide_String (AS.Fixed.Trim (raw, AS.Left));
end strim;
end AdaBase.Results.Generic_Converters;
|
AdaCore/spat | Ada | 5,244 | ads | ------------------------------------------------------------------------------
-- Copyright (C) 2020 by Heisenbug Ltd. ([email protected])
--
-- This work is free. You can redistribute it and/or modify it under the
-- terms of the Do What The Fuck You Want To Public License, Version 2,
-- as published by Sam Hocevar. See the LICENSE file for more details.
------------------------------------------------------------------------------
pragma License (Unrestricted);
------------------------------------------------------------------------------
--
-- SPARK Proof Analysis Tool
--
-- S.P.A.T. - Object representing the "timing" JSON object.
--
------------------------------------------------------------------------------
private with Ada.Tags;
with SPAT.Entity;
with SPAT.Field_Names;
with SPAT.Preconditions;
package SPAT.Timing_Item is
use all type GNATCOLL.JSON.JSON_Value_Type;
---------------------------------------------------------------------------
-- Has_Required_Fields
---------------------------------------------------------------------------
function Has_Required_Fields (Object : in JSON_Value;
Version : in File_Version) return Boolean
is
((case Version is
when GNAT_CE_2019 =>
Preconditions.Ensure_Field (Object => Object,
Field => Field_Names.Proof,
Kind => JSON_Float_Type),
-- Here, we don't really check for required fields anymore, there
-- is a whole bunch of items starting with "gnatwhy3.". If they are not
-- present that means the "corresponding phase wasn't run at all" (@kanigsson)
-- and we just assume 0.0 s.
when GNAT_CE_2020 =>
True) and
Preconditions.Ensure_Field (Object => Object,
Field => Field_Names.Flow_Analysis,
Kind => JSON_Float_Type));
-- Information obtained from the timing section of a .spark file.
type T is new Entity.T with private;
---------------------------------------------------------------------------
-- Create
---------------------------------------------------------------------------
not overriding
function Create (Object : in JSON_Value;
Version : in File_Version) return T with
Pre => Has_Required_Fields (Object => Object,
Version => Version);
---------------------------------------------------------------------------
-- Flow
---------------------------------------------------------------------------
not overriding
function Flow (This : in T) return Duration;
---------------------------------------------------------------------------
-- Proof
---------------------------------------------------------------------------
not overriding
function Proof (This : in T) return Duration;
---------------------------------------------------------------------------
-- Version
---------------------------------------------------------------------------
not overriding
function Version (This : in T) return File_Version;
None : constant T;
private
type T is new Entity.T with
record
Version : File_Version; -- version of file encountered.
-- FIXME: Storing the version here is a bit stupid. The only time
-- we need this, we also have a file name and makes much
-- more sense to store the version information there,
-- albeit maybe slightly more inefficient.
Proof : Duration; -- Total time the prover spent.
Flow : Duration; -- Total time of flow analysis.
end record;
---------------------------------------------------------------------------
-- Image
---------------------------------------------------------------------------
overriding
function Image (This : in T) return String is
(Ada.Tags.External_Tag (T'Class (This)'Tag) & ": (" &
"Version => " & This.Version'Image &
", Proof => " & This.Proof'Image &
", Flow => " & This.Flow'Image & ")");
None : constant T := T'(Entity.T with
Version => File_Version'First,
Proof => 0.0,
Flow => 0.0);
---------------------------------------------------------------------------
-- Flow
---------------------------------------------------------------------------
not overriding
function Flow (This : in T) return Duration is
(This.Flow);
---------------------------------------------------------------------------
-- Proof
---------------------------------------------------------------------------
not overriding
function Proof (This : in T) return Duration is
(This.Proof);
---------------------------------------------------------------------------
-- Version
---------------------------------------------------------------------------
not overriding
function Version (This : in T) return File_Version is
(This.Version);
end SPAT.Timing_Item;
|
zhmu/ananas | Ada | 16,880 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- E X P _ C O D E --
-- --
-- B o d y --
-- --
-- Copyright (C) 1996-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 Einfo; use Einfo;
with Einfo.Entities; use Einfo.Entities;
with Einfo.Utils; use Einfo.Utils;
with Errout; use Errout;
with Lib; use Lib;
with Namet; use Namet;
with Nlists; use Nlists;
with Nmake; use Nmake;
with Opt; use Opt;
with Rtsfind; use Rtsfind;
with Sem_Aux; use Sem_Aux;
with Sem_Eval; use Sem_Eval;
with Sem_Util; use Sem_Util;
with Sem_Warn; use Sem_Warn;
with Sinfo; use Sinfo;
with Sinfo.Nodes; use Sinfo.Nodes;
with Sinfo.Utils; use Sinfo.Utils;
with Stringt; use Stringt;
with Tbuild; use Tbuild;
package body Exp_Code is
-----------------------
-- Local_Subprograms --
-----------------------
function Asm_Constraint (Operand_Var : Node_Id) return Node_Id;
-- Common processing for Asm_Input_Constraint and Asm_Output_Constraint.
-- Obtains the constraint argument from the global operand variable
-- Operand_Var, which must be non-Empty.
function Asm_Operand (Operand_Var : Node_Id) return Node_Id;
-- Common processing for Asm_Input_Value and Asm_Output_Variable. Obtains
-- the value/variable argument from Operand_Var, the global operand
-- variable. Returns Empty if no operand available.
function Get_String_Node (S : Node_Id) return Node_Id;
-- Given S, a static expression node of type String, returns the
-- string literal node. This is needed to deal with the use of constants
-- for these expressions, which is perfectly permissible.
procedure Next_Asm_Operand (Operand_Var : in out Node_Id);
-- Common processing for Next_Asm_Input and Next_Asm_Output, updates
-- the value of the global operand variable Operand_Var appropriately.
procedure Setup_Asm_IO_Args (Arg : Node_Id; Operand_Var : out Node_Id);
-- Common processing for Setup_Asm_Inputs and Setup_Asm_Outputs. Arg
-- is the actual parameter from the call, and Operand_Var is the global
-- operand variable to be initialized to the first operand.
----------------------
-- Global Variables --
----------------------
Current_Input_Operand : Node_Id := Empty;
-- Points to current Asm_Input_Operand attribute reference. Initialized
-- by Setup_Asm_Inputs, updated by Next_Asm_Input, and referenced by
-- Asm_Input_Constraint and Asm_Input_Value.
Current_Output_Operand : Node_Id := Empty;
-- Points to current Asm_Output_Operand attribute reference. Initialized
-- by Setup_Asm_Outputs, updated by Next_Asm_Output, and referenced by
-- Asm_Output_Constraint and Asm_Output_Variable.
--------------------
-- Asm_Constraint --
--------------------
function Asm_Constraint (Operand_Var : Node_Id) return Node_Id is
begin
pragma Assert (Present (Operand_Var));
return Get_String_Node (First (Expressions (Operand_Var)));
end Asm_Constraint;
--------------------------
-- Asm_Input_Constraint --
--------------------------
-- Note: error checking on Asm_Input attribute done in Sem_Attr
function Asm_Input_Constraint return Node_Id is
begin
return Get_String_Node (Asm_Constraint (Current_Input_Operand));
end Asm_Input_Constraint;
---------------------
-- Asm_Input_Value --
---------------------
-- Note: error checking on Asm_Input attribute done in Sem_Attr
function Asm_Input_Value return Node_Id is
begin
return Asm_Operand (Current_Input_Operand);
end Asm_Input_Value;
-----------------
-- Asm_Operand --
-----------------
function Asm_Operand (Operand_Var : Node_Id) return Node_Id is
begin
if No (Operand_Var) then
return Empty;
elsif Error_Posted (Operand_Var) then
return Error;
else
return Next (First (Expressions (Operand_Var)));
end if;
end Asm_Operand;
---------------------------
-- Asm_Output_Constraint --
---------------------------
-- Note: error checking on Asm_Output attribute done in Sem_Attr
function Asm_Output_Constraint return Node_Id is
begin
return Asm_Constraint (Current_Output_Operand);
end Asm_Output_Constraint;
-------------------------
-- Asm_Output_Variable --
-------------------------
-- Note: error checking on Asm_Output attribute done in Sem_Attr
function Asm_Output_Variable return Node_Id is
begin
return Asm_Operand (Current_Output_Operand);
end Asm_Output_Variable;
------------------
-- Asm_Template --
------------------
function Asm_Template (N : Node_Id) return Node_Id is
Call : constant Node_Id := Expression (Expression (N));
Temp : constant Node_Id := First_Actual (Call);
begin
-- Require static expression for template. We also allow a string
-- literal (this is useful for Ada 83 mode where string expressions
-- are never static).
if Is_OK_Static_Expression (Temp)
or else (Ada_Version = Ada_83
and then Nkind (Temp) = N_String_Literal)
then
return Get_String_Node (Temp);
else
Flag_Non_Static_Expr ("asm template argument is not static!", Temp);
return Empty;
end if;
end Asm_Template;
----------------------
-- Clobber_Get_Next --
----------------------
Clobber_Node : Node_Id;
-- String literal node for clobber string. Initialized by Clobber_Setup,
-- and not modified by Clobber_Get_Next. Empty if clobber string was in
-- error (resulting in no clobber arguments being returned).
Clobber_Ptr : Pos;
-- Pointer to current character of string. Initialized to 1 by the call
-- to Clobber_Setup, and then updated by Clobber_Get_Next.
function Clobber_Get_Next return Address is
Str : constant String_Id := Strval (Clobber_Node);
Len : constant Nat := String_Length (Str);
C : Character;
begin
if No (Clobber_Node) then
return Null_Address;
end if;
-- Skip spaces and commas before next register name
loop
-- Return null string if no more names
if Clobber_Ptr > Len then
return Null_Address;
end if;
C := Get_Character (Get_String_Char (Str, Clobber_Ptr));
exit when C /= ',' and then C /= ' ';
Clobber_Ptr := Clobber_Ptr + 1;
end loop;
-- Acquire next register name
Name_Len := 0;
loop
Add_Char_To_Name_Buffer (C);
Clobber_Ptr := Clobber_Ptr + 1;
exit when Clobber_Ptr > Len;
C := Get_Character (Get_String_Char (Str, Clobber_Ptr));
exit when C = ',' or else C = ' ';
end loop;
Name_Buffer (Name_Len + 1) := ASCII.NUL;
return Name_Buffer'Address;
end Clobber_Get_Next;
-------------------
-- Clobber_Setup --
-------------------
procedure Clobber_Setup (N : Node_Id) is
Call : constant Node_Id := Expression (Expression (N));
Clob : constant Node_Id := Next_Actual (
Next_Actual (
Next_Actual (
First_Actual (Call))));
begin
if not Is_OK_Static_Expression (Clob) then
Flag_Non_Static_Expr ("asm clobber argument is not static!", Clob);
Clobber_Node := Empty;
else
Clobber_Node := Get_String_Node (Clob);
Clobber_Ptr := 1;
end if;
end Clobber_Setup;
---------------------
-- Expand_Asm_Call --
---------------------
procedure Expand_Asm_Call (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N);
procedure Check_IO_Operand (N : Node_Id);
-- Check for incorrect input or output operand
----------------------
-- Check_IO_Operand --
----------------------
procedure Check_IO_Operand (N : Node_Id) is
Err : Node_Id := N;
begin
-- The only identifier allowed is No_xxput_Operands. Since we
-- know the type is right, it is sufficient to see if the
-- referenced entity is in a runtime routine.
if Is_Entity_Name (N)
and then Is_Predefined_Unit (Get_Source_Unit (Entity (N)))
then
return;
-- An attribute reference is fine, again the analysis reasonably
-- guarantees that the attribute must be subtype'Asm_??put.
elsif Nkind (N) = N_Attribute_Reference then
return;
-- The only other allowed form is an array aggregate in which
-- all the entries are positional and are attribute references.
elsif Nkind (N) = N_Aggregate then
if Present (Component_Associations (N)) then
Err := First (Component_Associations (N));
elsif Present (Expressions (N)) then
Err := First (Expressions (N));
while Present (Err) loop
exit when Nkind (Err) /= N_Attribute_Reference;
Next (Err);
end loop;
if No (Err) then
return;
end if;
end if;
end if;
-- If we fall through, Err is pointing to the bad node
Error_Msg_N ("Asm operand has wrong form", Err);
end Check_IO_Operand;
-- Start of processing for Expand_Asm_Call
begin
-- Check that the input and output operands have the right
-- form, as required by the documentation of the Asm feature:
-- OUTPUT_OPERAND_LIST ::=
-- No_Output_Operands
-- | OUTPUT_OPERAND_ATTRIBUTE
-- | (OUTPUT_OPERAND_ATTRIBUTE @{,OUTPUT_OPERAND_ATTRIBUTE@})
-- OUTPUT_OPERAND_ATTRIBUTE ::=
-- SUBTYPE_MARK'Asm_Output (static_string_EXPRESSION, NAME)
-- INPUT_OPERAND_LIST ::=
-- No_Input_Operands
-- | INPUT_OPERAND_ATTRIBUTE
-- | (INPUT_OPERAND_ATTRIBUTE @{,INPUT_OPERAND_ATTRIBUTE@})
-- INPUT_OPERAND_ATTRIBUTE ::=
-- SUBTYPE_MARK'Asm_Input (static_string_EXPRESSION, EXPRESSION)
declare
Arg_Output : constant Node_Id := Next_Actual (First_Actual (N));
Arg_Input : constant Node_Id := Next_Actual (Arg_Output);
begin
Check_IO_Operand (Arg_Output);
Check_IO_Operand (Arg_Input);
end;
-- If we have the function call case, we are inside a code statement,
-- and the tree is already in the necessary form for gigi.
if Nkind (N) = N_Function_Call then
null;
-- For the procedure case, we convert the call into a code statement
else
pragma Assert (Nkind (N) = N_Procedure_Call_Statement);
-- Note: strictly we should change the procedure call to a function
-- call in the qualified expression, but since we are not going to
-- reanalyze (see below), and the interface subprograms in this
-- package don't care, we can leave it as a procedure call.
Rewrite (N,
Make_Code_Statement (Loc,
Expression =>
Make_Qualified_Expression (Loc,
Subtype_Mark => New_Occurrence_Of (RTE (RE_Asm_Insn), Loc),
Expression => Relocate_Node (N))));
-- There is no need to reanalyze this node, it is completely analyzed
-- already, at least sufficiently for the purposes of the abstract
-- procedural interface defined in this package. Furthermore if we
-- let it go through the normal analysis, that would include some
-- inappropriate checks that apply only to explicit code statements
-- in the source, and not to calls to intrinsics.
Set_Analyzed (N);
Check_Code_Statement (N);
end if;
end Expand_Asm_Call;
---------------------
-- Get_String_Node --
---------------------
function Get_String_Node (S : Node_Id) return Node_Id is
begin
if Nkind (S) = N_String_Literal then
return S;
else
pragma Assert (Ekind (Entity (S)) = E_Constant);
return Get_String_Node (Constant_Value (Entity (S)));
end if;
end Get_String_Node;
---------------------
-- Is_Asm_Volatile --
---------------------
function Is_Asm_Volatile (N : Node_Id) return Boolean is
Call : constant Node_Id := Expression (Expression (N));
Vol : constant Node_Id :=
Next_Actual (
Next_Actual (
Next_Actual (
Next_Actual (
First_Actual (Call)))));
begin
if not Is_OK_Static_Expression (Vol) then
Flag_Non_Static_Expr ("asm volatile argument is not static!", Vol);
return False;
else
return Is_True (Expr_Value (Vol));
end if;
end Is_Asm_Volatile;
--------------------
-- Next_Asm_Input --
--------------------
procedure Next_Asm_Input is
begin
Next_Asm_Operand (Current_Input_Operand);
end Next_Asm_Input;
----------------------
-- Next_Asm_Operand --
----------------------
procedure Next_Asm_Operand (Operand_Var : in out Node_Id) is
begin
pragma Assert (Present (Operand_Var));
if Nkind (Parent (Operand_Var)) = N_Aggregate then
Operand_Var := Next (Operand_Var);
else
Operand_Var := Empty;
end if;
end Next_Asm_Operand;
---------------------
-- Next_Asm_Output --
---------------------
procedure Next_Asm_Output is
begin
Next_Asm_Operand (Current_Output_Operand);
end Next_Asm_Output;
----------------------
-- Setup_Asm_Inputs --
----------------------
procedure Setup_Asm_Inputs (N : Node_Id) is
Call : constant Node_Id := Expression (Expression (N));
begin
Setup_Asm_IO_Args
(Next_Actual (Next_Actual (First_Actual (Call))),
Current_Input_Operand);
end Setup_Asm_Inputs;
-----------------------
-- Setup_Asm_IO_Args --
-----------------------
procedure Setup_Asm_IO_Args (Arg : Node_Id; Operand_Var : out Node_Id) is
begin
-- Case of single argument
if Nkind (Arg) = N_Attribute_Reference then
Operand_Var := Arg;
-- Case of list of arguments
elsif Nkind (Arg) = N_Aggregate then
if Expressions (Arg) = No_List then
Operand_Var := Empty;
else
Operand_Var := First (Expressions (Arg));
end if;
-- Otherwise must be default (no operands) case
else
Operand_Var := Empty;
end if;
end Setup_Asm_IO_Args;
-----------------------
-- Setup_Asm_Outputs --
-----------------------
procedure Setup_Asm_Outputs (N : Node_Id) is
Call : constant Node_Id := Expression (Expression (N));
begin
Setup_Asm_IO_Args
(Next_Actual (First_Actual (Call)),
Current_Output_Operand);
end Setup_Asm_Outputs;
end Exp_Code;
|
reznikmm/matreshka | Ada | 3,669 | 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 League.Holders.Generic_Holders;
package AMF.DG.Holders.Cubic_Curve_Tos is
new League.Holders.Generic_Holders
(AMF.DG.DG_Cubic_Curve_To);
pragma Preelaborate (AMF.DG.Holders.Cubic_Curve_Tos);
|
redparavoz/ada-wiki | Ada | 2,832 | ads | -----------------------------------------------------------------------
-- wiki-plugins-conditions -- Condition Plugin
-- Copyright (C) 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.
-----------------------------------------------------------------------
with Wiki.Strings;
-- === Conditions Plugins ===
-- The <b>Wiki.Plugins.Conditions</b> package defines a set of conditional plugins
-- to show or hide wiki content according to some conditions evaluated during the parsing phase.
--
package Wiki.Plugins.Conditions is
MAX_CONDITION_DEPTH : constant Natural := 31;
type Condition_Depth is new Natural range 0 .. MAX_CONDITION_DEPTH;
type Condition_Type is (CONDITION_IF, CONDITION_ELSIF, CONDITION_ELSE, CONDITION_END);
type Condition_Plugin is new Wiki_Plugin with private;
-- Evaluate the condition and return it as a boolean status.
function Evaluate (Plugin : in Condition_Plugin;
Params : in Wiki.Attributes.Attribute_List) return Boolean;
-- Get the type of condition (IF, ELSE, ELSIF, END) represented by the plugin.
function Get_Condition_Kind (Plugin : in Condition_Plugin;
Params : in Wiki.Attributes.Attribute_List)
return Condition_Type;
-- Evaluate the condition described by the parameters and hide or show the wiki
-- content.
overriding
procedure Expand (Plugin : in out Condition_Plugin;
Document : in out Wiki.Documents.Document;
Params : in out Wiki.Attributes.Attribute_List;
Context : in Plugin_Context);
-- Append the attribute name/value to the condition plugin parameter list.
procedure Append (Plugin : in out Condition_Plugin;
Name : in Wiki.Strings.WString;
Value : in Wiki.Strings.WString);
private
type Boolean_Array is array (Condition_Depth) of Boolean;
pragma Pack (Boolean_Array);
type Condition_Plugin is new Wiki_Plugin with record
Depth : Condition_Depth := 1;
Values : Boolean_Array := (others => False);
Params : Wiki.Attributes.Attribute_List;
end record;
end Wiki.Plugins.Conditions;
|
AdaCore/gpr | Ada | 1,754 | ads | ------------------------------------------------------------------------------
-- --
-- GPR2 PROJECT MANAGER --
-- --
-- Copyright (C) 2019-2023, AdaCore --
-- --
-- This 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. This software 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. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with GNAT; see file COPYING. If not, --
-- see <http://www.gnu.org/licenses/>. --
-- --
------------------------------------------------------------------------------
package GPRtools is
type Which is (Build, Clean, Ls, Install, Name, Remote, Inspect);
-- Names of the supported tools
type Verbosity_Level is (Quiet, Regular, Verbose, Very_Verbose);
-- Verbosilty level of logging to standard and/or error/warning output
type Display_Kind is (K_JSON_Compact, K_JSON, K_Textual_IO);
-- Kind of display to be used by any tool that uses it.
end GPRtools;
|
sudoadminservices/bugbountyservices | Ada | 793 | ads | -- Copyright 2017 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
local url = require("url")
name = "Yahoo"
type = "scrape"
function start()
setratelimit(1)
end
function vertical(ctx, domain)
for i=0,10 do
local ok = scrape(ctx, {['url']=buildurl(domain, i)})
if not ok then
break
end
checkratelimit()
end
end
function buildurl(domain, pagenum)
local next = tostring((pagenum * 10) + 1)
local query = "site:" .. domain .. " -domain:www." .. domain
local params = {
p=query,
b=next,
pz="10",
bct="0",
xargs="0",
}
return "https://search.yahoo.com/search?" .. url.build_query_string(params)
end
|
optikos/oasis | Ada | 4,471 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Expressions;
with Program.Elements.Derived_Types;
with Program.Element_Visitors;
package Program.Nodes.Derived_Types is
pragma Preelaborate;
type Derived_Type is
new Program.Nodes.Node and Program.Elements.Derived_Types.Derived_Type
and Program.Elements.Derived_Types.Derived_Type_Text
with private;
function Create
(Abstract_Token : Program.Lexical_Elements.Lexical_Element_Access;
Limited_Token : Program.Lexical_Elements.Lexical_Element_Access;
New_Token : not null Program.Lexical_Elements.Lexical_Element_Access;
Parent : not null Program.Elements.Expressions.Expression_Access)
return Derived_Type;
type Implicit_Derived_Type is
new Program.Nodes.Node and Program.Elements.Derived_Types.Derived_Type
with private;
function Create
(Parent : 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;
Has_Abstract : Boolean := False;
Has_Limited : Boolean := False)
return Implicit_Derived_Type
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Derived_Type is
abstract new Program.Nodes.Node
and Program.Elements.Derived_Types.Derived_Type
with record
Parent : not null Program.Elements.Expressions.Expression_Access;
end record;
procedure Initialize (Self : aliased in out Base_Derived_Type'Class);
overriding procedure Visit
(Self : not null access Base_Derived_Type;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Parent
(Self : Base_Derived_Type)
return not null Program.Elements.Expressions.Expression_Access;
overriding function Is_Derived_Type_Element
(Self : Base_Derived_Type)
return Boolean;
overriding function Is_Type_Definition_Element
(Self : Base_Derived_Type)
return Boolean;
overriding function Is_Definition_Element
(Self : Base_Derived_Type)
return Boolean;
type Derived_Type is
new Base_Derived_Type and Program.Elements.Derived_Types.Derived_Type_Text
with record
Abstract_Token : Program.Lexical_Elements.Lexical_Element_Access;
Limited_Token : Program.Lexical_Elements.Lexical_Element_Access;
New_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
end record;
overriding function To_Derived_Type_Text
(Self : aliased in out Derived_Type)
return Program.Elements.Derived_Types.Derived_Type_Text_Access;
overriding function Abstract_Token
(Self : Derived_Type)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Limited_Token
(Self : Derived_Type)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function New_Token
(Self : Derived_Type)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Has_Abstract (Self : Derived_Type) return Boolean;
overriding function Has_Limited (Self : Derived_Type) return Boolean;
type Implicit_Derived_Type is
new Base_Derived_Type
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
Has_Abstract : Boolean;
Has_Limited : Boolean;
end record;
overriding function To_Derived_Type_Text
(Self : aliased in out Implicit_Derived_Type)
return Program.Elements.Derived_Types.Derived_Type_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Derived_Type)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Derived_Type)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Derived_Type)
return Boolean;
overriding function Has_Abstract
(Self : Implicit_Derived_Type)
return Boolean;
overriding function Has_Limited
(Self : Implicit_Derived_Type)
return Boolean;
end Program.Nodes.Derived_Types;
|
reznikmm/matreshka | Ada | 4,073 | 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.Presentation_Node_Type_Attributes;
package Matreshka.ODF_Presentation.Node_Type_Attributes is
type Presentation_Node_Type_Attribute_Node is
new Matreshka.ODF_Presentation.Abstract_Presentation_Attribute_Node
and ODF.DOM.Presentation_Node_Type_Attributes.ODF_Presentation_Node_Type_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Presentation_Node_Type_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Presentation_Node_Type_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Presentation.Node_Type_Attributes;
|
reznikmm/matreshka | Ada | 6,881 | 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.Filter_And_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Table_Filter_And_Element_Node is
begin
return Self : Table_Filter_And_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_Filter_And_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_Filter_And
(ODF.DOM.Table_Filter_And_Elements.ODF_Table_Filter_And_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_Filter_And_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Filter_And_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Table_Filter_And_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_Filter_And
(ODF.DOM.Table_Filter_And_Elements.ODF_Table_Filter_And_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_Filter_And_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_Filter_And
(Visitor,
ODF.DOM.Table_Filter_And_Elements.ODF_Table_Filter_And_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.Filter_And_Element,
Table_Filter_And_Element_Node'Tag);
end Matreshka.ODF_Table.Filter_And_Elements;
|
VMika/DES_Ada | Ada | 4,607 | adb | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
package body P_StepHandler.KeyHandler is
function Make (Self : in out KeyHandler) return KeyHandler is
begin
Self.Ptr_Key := null;
Self.Ptr_SubKeyArray := null;
return Self;
end;
overriding
procedure Handle (Self : in out KeyHandler) is
InitialBinaryKey : T_BinaryKey;
TmpFormattedKey : T_BinaryFormattedKey;
SubKey : T_BinarySubKey;
begin
InitialBinaryKey := TextBlock_To_Binary(Self.Ptr_Key.all);
TmpFormattedKey := PermutationChoice1_Key(InitialBinaryKey);
for Round in 1..16 loop
KeyShift(TmpFormattedKey, Round);
SubKey := PermutationChoice2_Key(TmpFormattedKey);
Self.Ptr_SubKeyArray.all(Round) := SubKey;
end loop;
if Self.NextHandler /= null then
Self.NextHandler.Handle;
end if;
end;
function PermutationChoice1_Key (BinaryKey : in out T_BinaryKey)
return T_BinaryFormattedKey is
PermIndex : Integer;
P1BinaryKey : T_BinaryFormattedKey;
begin
PermIndex := 57;
for BitIndex in 1..28 loop
P1BinaryKey(BitIndex) := BinaryKey(PermIndex);
if (PermIndex-8 > 0) then
PermIndex := PermIndex-8;
else
PermIndex := PermIndex + 57 ;
end if;
end loop;
PermIndex := 63;
for BitIndex in 29..52 loop
P1BinaryKey(BitIndex) := BinaryKey(PermIndex);
if (PermIndex-8 > 0) then
PermIndex := PermIndex-8;
else
PermIndex := PermIndex + 55;
end if;
end loop;
PermIndex := 28;
for BitIndex in 53..56 loop
P1BinaryKey(BitIndex) := BinaryKey(PermIndex);
PermIndex := PermIndex-8;
end loop;
return P1BinaryKey;
end;
procedure KeyShift (Key : in out T_BinaryFormattedKey;
Round : in Positive) is
HalfLeft, HalfRight : T_BinaryHalfFormattedKey;
Iteration : Integer;
begin
HalfLeft := Key(1..28);
HalfRight := Key(29..56);
if Round = 1 or Round = 2 or Round = 9 or Round = 16 then
Iteration := 1;
else
Iteration := 2;
end if;
Left_Shift (HalfLeft, Iteration);
Left_Shift (HalfRight, Iteration);
Key(1..28) := HalfLeft;
Key(29..56) := HalfRight;
end;
function PermutationChoice2_Key (Key : in out T_BinaryFormattedKey)
return T_BinarySubKey is
SubKey : T_BinarySubKey;
begin
SubKey(1) := Key(14);
SubKey(2) := Key(17);
SubKey(3) := Key(11);
SubKey(4) := Key(24);
SubKey(5) := Key(1);
SubKey(6) := Key(5);
SubKey(7) := Key(3);
SubKey(8) := Key(28);
SubKey(9) := Key(15);
SubKey(10) := Key(6);
SubKey(11) := Key(21);
SubKey(12) := Key(10);
SubKey(13) := Key(23);
SubKey(14) := Key(19);
SubKey(15) := Key(12);
SubKey(16) := Key(4);
SubKey(17) := Key(26);
SubKey(18) := Key(8);
SubKey(19) := Key(16);
SubKey(20) := Key(7);
SubKey(21) := Key(27);
SubKey(22) := Key(20);
SubKey(23) := Key(13);
SubKey(24) := Key(2);
SubKey(25) := Key(41);
SubKey(26) := Key(52);
SubKey(27) := Key(31);
SubKey(28) := Key(37);
SubKey(29) := Key(47);
SubKey(30) := Key(55);
SubKey(31) := Key(30);
SubKey(32) := Key(40);
SubKey(33) := Key(51);
SubKey(34) := Key(45);
SubKey(35) := Key(33);
SubKey(36) := Key(48);
SubKey(37) := Key(44);
SubKey(38) := Key(49);
SubKey(39) := Key(39);
SubKey(40) := Key(56);
SubKey(41) := Key(34);
SubKey(42) := Key(53);
SubKey(43) := Key(46);
SubKey(44) := Key(42);
SubKey(45) := Key(50);
SubKey(46) := Key(36);
SubKey(47) := Key(29);
SubKey(48) := Key(32);
return SubKey;
end;
procedure Set_SubKeyArrayAccess (Self : in out KeyHandler ;
Ptr_SubKeyAray : in BinarySubKeyArray_Access) is
begin
Self.Ptr_SubKeyArray := Ptr_SubKeyAray;
end;
procedure Set_KeyAccess (Self : in out KeyHandler;
Ptr_Key : in Key_Access) is
begin
Self.Ptr_Key := Ptr_Key;
end;
end P_StepHandler.KeyHandler;
|
stcarrez/ada-enet | Ada | 2,490 | ads | -----------------------------------------------------------------------
-- net-protos-Ipv4 -- IPv4 Network protocol
-- Copyright (C) 2016, 2017, 2018 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 Net.Headers;
with Net.Interfaces;
with Net.Buffers;
package Net.Protos.IPv4 is
P_ICMP : constant Net.Uint8 := 1;
P_IGMP : constant Net.Uint8 := 2;
P_TCP : constant Net.Uint8 := 6;
P_UDP : constant Net.Uint8 := 17;
-- Make an IP packet identifier.
procedure Make_Ident (Ip : in Net.Headers.IP_Header_Access);
-- Make the IPv4 header for the source and destination IP addresses and protocol.
procedure Make_Header (Ip : in Net.Headers.IP_Header_Access;
Src : in Ip_Addr;
Dst : in Ip_Addr;
Proto : in Uint8;
Length : in Uint16);
-- Send the raw IPv4 packet to the interface. The destination Ethernet address is
-- resolved from the ARP table and the packet Ethernet header updated. The packet
-- is send immediately when the destination Ethernet address is known, otherwise
-- it is queued and sent when the ARP resolution is successful.
procedure Send_Raw (Ifnet : in out Net.Interfaces.Ifnet_Type'Class;
Target_Ip : in Ip_Addr;
Packet : in out Net.Buffers.Buffer_Type;
Status : out Error_Code) with
Pre => not Packet.Is_Null,
Post => Packet.Is_Null;
procedure Send (Ifnet : in out Net.Interfaces.Ifnet_Type'Class;
Target_Ip : in Ip_Addr;
Packet : in out Net.Buffers.Buffer_Type;
Status : out Error_Code) with
Pre => not Packet.Is_Null,
Post => Packet.Is_Null;
end Net.Protos.IPv4;
|
joakim-strandberg/wayland_ada_binding | Ada | 3,765 | ads | with Interfaces.C.Strings;
private with Ada.Finalization;
-- Udev is "abbreviation" of Userspace /dev and libudev is the name of a
-- Linux specific library written in C that gives access to Linux
-- device and hardware management. By using libudev an application
-- can find out about:
--
-- - Installed hardware
-- - When a USB device is inserted or removed
-- - When a network cable is inserted or removed
--
package C_Binding.Linux.Udev is
pragma Elaborate_Body;
pragma Linker_Options ("-L/lib/x86_64-linux-gnu/");
pragma Linker_Options ("-ludev");
type Context_Base is abstract tagged limited private;
type Device_Base is abstract tagged limited private;
type Enumerate_Base is abstract tagged limited private;
type Monitor_Base is abstract tagged limited private;
type List_Entry_Base is abstract tagged limited private;
type Queue_Base is abstract tagged limited private;
type Hwdb_Base is abstract tagged limited private;
-- Abbreviations are generally avoided when working with Ada,
-- but hwdb (short for hardware database) is used here because this type
-- can never used directly by a user of this API.
subtype Success_Flag is C_Binding.Success_Flag;
private
function Get_String_Result
(Text : Interfaces.C.Strings.Chars_Ptr;
Error : String) return String_Result;
type Udev_Context is null record;
-- Opaque object representing the udev library context.
type Udev_Ptr is access Udev_Context;
type Udev_List_Entry is null record;
type Udev_List_Entry_Ptr is access Udev_List_Entry;
type Udev_Device is null record;
-- This object is opaque and must not be accessed by the caller via
-- different means than functions provided by libudev.
-- Initially, the reference count of the device is 1.
-- You can acquire further references, and drop gained references via
-- udev_device_ref() and udev_device_unref(). Once the reference count
-- hits 0, the device object is destroyed and freed.
type Udev_Device_Ptr is access Udev_Device;
type Udev_Enumerate is null record;
type Udev_Enumerate_Ptr is access Udev_Enumerate;
type Udev_Monitor is null record;
type Udev_Monitor_Ptr is access Udev_Monitor;
type Udev_Queue is null record;
type Udev_Queue_Ptr is access Udev_Queue;
type Udev_Hwdb is null record;
-- Opaque object representing the hardware database.
type Udev_Hwdb_Ptr is access Udev_Hwdb;
function Udev_Util_Encode_String
(Arg1 : Interfaces.C.Strings.Chars_Ptr;
Arg2 : Interfaces.C.Strings.Chars_Ptr;
Arg3 : Unsigned_Long) return Int;
pragma Import (C, Udev_Util_Encode_String, "udev_util_encode_string");
-- Encode all potentially unsafe characters of a string to
-- the corresponding 2 char hex value prefixed by '\x'.
--
-- What to do with this C-function?
type Monitor_Base is new Ada.Finalization.Limited_Controlled with record
My_Ptr : Udev_Monitor_Ptr;
end record;
type Context_Base is new Ada.Finalization.Limited_Controlled with record
My_Ptr : Udev_Ptr;
end record;
type Device_Base is new Ada.Finalization.Limited_Controlled with record
My_Ptr : Udev_Device_Ptr;
end record;
type Enumerate_Base is new Ada.Finalization.Limited_Controlled with record
My_Ptr : Udev_Enumerate_Ptr;
end record;
type List_Entry_Base is tagged limited record
My_Ptr : Udev_List_Entry_Ptr;
end record;
type Queue_Base is new Ada.Finalization.Limited_Controlled with record
My_Ptr : Udev_Queue_Ptr;
end record;
type Hwdb_Base is new Ada.Finalization.Limited_Controlled with record
My_Ptr : Udev_Hwdb_Ptr;
end record;
end C_Binding.Linux.Udev;
|
dan76/Amass | Ada | 1,201 | 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
local url = require("url")
name = "Bing"
type = "scrape"
function start()
set_rate_limit(1)
end
function vertical(ctx, domain)
for i=1,20 do
local ok = scrape(ctx, {['url']=domain_url(domain, i)})
if not ok then
break
end
end
end
function domain_url(domain, pagenum)
local query = "domain:" .. domain .. " -www." .. domain
local params = {
['q']=query,
['first']=pagenum,
['go']="Submit",
}
return "https://www.bing.com/search?" .. url.build_query_string(params)
end
function address(ctx, addr)
for i=1,20 do
local ok = scrape(ctx, {['url']=addr_url(addr, i)})
if not ok then
break
end
end
end
function addr_url(addr, pagenum)
local query = "ip%3A" .. addr
local params = {
['q']=query,
['qs']="n",
['FORM']="PERE",
['first']=pagenum,
}
return "https://www.bing.com/search?" .. url.build_query_string(params)
end
|
ashleygay/adaboy | Ada | 4,447 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with array_hpp;
with Interfaces.C.Extensions;
limited with processor_hpp;
with cartridge_hpp;
with video_hpp;
with word_operations_hpp;
package memory_hpp is
-- This class abstracts any memory access done by the processor, it will find
-- out which type of memory and what it must be done depending on the address
-- Rebuild a cartridge with a new rom
--Resets memory values to their default state
package Class_Memory is
type Memory is limited record
memory : aliased array_hpp.template_array_unsigned_char_65536.instance; -- ./memory.hpp:53
u_ready : aliased Extensions.bool; -- ./memory.hpp:55
processor : aliased access processor_hpp.Class_Processor.Processor; -- ./memory.hpp:57
the_cartridge : aliased cartridge_hpp.Class_Cartridge.Cartridge; -- ./memory.hpp:58
the_video : aliased video_hpp.Class_Video.Video; -- ./memory.hpp:59
end record;
pragma Import (CPP, Memory);
function New_Memory (proc : access processor_hpp.Class_Processor.Processor) return Memory; -- ./memory.hpp:15
pragma CPP_Constructor (New_Memory, "_ZN6MemoryC1ER9Processor");
function read (this : access Memory; address : word_operations_hpp.uint16_t) return word_operations_hpp.uint8_t; -- ./memory.hpp:17
pragma Import (CPP, read, "_ZN6Memory4readEt");
procedure write
(this : access Memory;
byte : word_operations_hpp.uint8_t;
address : word_operations_hpp.uint16_t); -- ./memory.hpp:18
pragma Import (CPP, write, "_ZN6Memory5writeEht");
function simple_read (this : access Memory; address : word_operations_hpp.uint16_t) return word_operations_hpp.uint8_t; -- ./memory.hpp:20
pragma Import (CPP, simple_read, "_ZN6Memory11simple_readEt");
procedure simple_write
(this : access Memory;
byte : word_operations_hpp.uint8_t;
address : word_operations_hpp.uint16_t); -- ./memory.hpp:21
pragma Import (CPP, simple_write, "_ZN6Memory12simple_writeEht");
procedure change_game (this : access Memory; cart : access word_operations_hpp.uint8_t); -- ./memory.hpp:24
pragma Import (CPP, change_game, "_ZN6Memory11change_gameEPh");
procedure resetMemory (this : access Memory); -- ./memory.hpp:27
pragma Import (CPP, resetMemory, "_ZN6Memory11resetMemoryEv");
function get_video (this : access Memory) return access video_hpp.Class_Video.Video; -- ./memory.hpp:29
pragma Import (CPP, get_video, "_ZN6Memory9get_videoEv");
function get_cartridge (this : access Memory) return access cartridge_hpp.Class_Cartridge.Cartridge; -- ./memory.hpp:30
pragma Import (CPP, get_cartridge, "_ZN6Memory13get_cartridgeEv");
function is_ready (this : access Memory) return Extensions.bool; -- ./memory.hpp:32
pragma Import (CPP, is_ready, "_ZN6Memory8is_readyEv");
procedure reset (this : access Memory); -- ./memory.hpp:34
pragma Import (CPP, reset, "_ZN6Memory5resetEv");
procedure set_interrupt_flag (this : access Memory; interrupt : unsigned); -- ./memory.hpp:39
pragma Import (CPP, set_interrupt_flag, "_ZN6Memory18set_interrupt_flagEj");
procedure reset_interrupt_flag (this : access Memory; interrupt : unsigned); -- ./memory.hpp:43
pragma Import (CPP, reset_interrupt_flag, "_ZN6Memory20reset_interrupt_flagEj");
function get_interrupt_flags (this : access Memory) return word_operations_hpp.uint8_t; -- ./memory.hpp:46
pragma Import (CPP, get_interrupt_flags, "_ZN6Memory19get_interrupt_flagsEv");
function get_interrupt_enable (this : access Memory) return word_operations_hpp.uint8_t; -- ./memory.hpp:47
pragma Import (CPP, get_interrupt_enable, "_ZN6Memory20get_interrupt_enableEv");
function get_joypad (this : access Memory) return word_operations_hpp.uint8_t; -- ./memory.hpp:48
pragma Import (CPP, get_joypad, "_ZN6Memory10get_joypadEv");
procedure set_joypad (this : access Memory; byte : word_operations_hpp.uint8_t); -- ./memory.hpp:49
pragma Import (CPP, set_joypad, "_ZN6Memory10set_joypadEh");
end;
use Class_Memory;
-- Zeroes the desired interrupt to enable it
-- Set the desired interrupt to 1
-- Called from interrupt handler to "consume" the interrupt
-- Get specific values in memory
end memory_hpp;
|
charlie5/cBound | Ada | 1,504 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_grab_keyboard_reply_t is
-- Item
--
type Item is record
response_type : aliased Interfaces.Unsigned_8;
status : aliased Interfaces.Unsigned_8;
sequence : aliased Interfaces.Unsigned_16;
length : aliased Interfaces.Unsigned_32;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_grab_keyboard_reply_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_grab_keyboard_reply_t.Item,
Element_Array => xcb.xcb_grab_keyboard_reply_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_grab_keyboard_reply_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_grab_keyboard_reply_t.Pointer,
Element_Array => xcb.xcb_grab_keyboard_reply_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_grab_keyboard_reply_t;
|
thierr26/ada-apsepp | Ada | 438 | adb | -- Copyright (C) 2019 Thierry Rascle <[email protected]>
-- MIT license. Please refer to the LICENSE file.
with Ada.Text_IO;
package body Apsepp.Output is
----------------------------------------------------------------------------
procedure Put_Line (S : String) is
begin
Ada.Text_IO.Put_Line (S);
end Put_Line;
----------------------------------------------------------------------------
end Apsepp.Output;
|
stcarrez/etherscope | Ada | 884 | ads | -----------------------------------------------------------------------
-- ui -- User Interface Framework
-- Copyright (C) 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.
-----------------------------------------------------------------------
package UI is
pragma Pure;
end UI;
|
reznikmm/matreshka | Ada | 3,498 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2018, 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 Core.Connectables.Slots_0.Slots_1;
with WUI.Widgets;
package WUI.Slots.Widgets is
new Core.Connectables.Slots_0.Slots_1 (WUI.Widgets.Widget_Access);
|
AdaCore/langkit | Ada | 3,430 | adb | -- Test that lookups on orphaned lexical envs works correctly
with Ada.Exceptions; use Ada.Exceptions;
with Ada.Text_IO; use Ada.Text_IO;
with Langkit_Support.Errors; use Langkit_Support.Errors;
with Langkit_Support.Lexical_Envs; use Langkit_Support.Lexical_Envs;
with Langkit_Support.Symbols; use Langkit_Support.Symbols;
with Support; use Support;
use Support.Envs;
procedure Main is
Symbols : Symbol_Table := Create_Symbol_Table;
Key_A : constant Symbol_Type := Find (Symbols, "A");
Key_B : constant Symbol_Type := Find (Symbols, "B");
Old_Env : Lexical_Env := Create_Lexical_Env
(Null_Lexical_Env, 'O', Owner => No_Generic_Unit);
New_Env : Lexical_Env := Create_Lexical_Env
(Null_Lexical_Env, 'N', Owner => No_Generic_Unit);
Rebindings : Env_Rebindings := Append (null, Old_Env, New_Env);
Root : Lexical_Env := Create_Lexical_Env
(Null_Lexical_Env, 'R', Owner => No_Generic_Unit);
Child : Lexical_Env := Create_Lexical_Env
(Root, 'C', Owner => No_Generic_Unit);
Orphaned : Lexical_Env := Orphan (Child);
begin
Add (Root, Key_A, '1');
Add (Child, Key_B, '2');
Put_Line ("Looking for A in Child:");
Put_Line (Get (Child, Key_A));
Put_Line ("Looking for B in Child:");
Put_Line (Get (Child, Key_B));
Put_Line ("Looking for A in Orphaned:");
Put_Line (Get (Orphaned, Key_A));
Put_Line ("Looking for B in Orphaned:");
Put_Line (Get (Orphaned, Key_B));
declare
Transitive_Child : Lexical_Env := Create_Lexical_Env
(Root, 'C', True, No_Generic_Unit);
Grouped : Lexical_Env := Group ((Root, Child));
Rebound_TC : Lexical_Env := Rebind_Env (Transitive_Child, Rebindings);
Rebound_OK : Lexical_Env := Rebind_Env (Child, Rebindings);
E : Lexical_Env;
begin
Put_Line ("Trying to build an orphan with transitive parent...");
begin
E := Orphan (Transitive_Child);
Put_Line (" No error raised");
Dec_Ref (E);
exception
when Exc : Property_Error =>
Put_Line (" Got a property error: " & Exception_Message (Exc));
end;
Put_Line ("Trying to build an orphan with grouped env...");
begin
E := Orphan (Grouped);
Put_Line (" No error raised");
Dec_Ref (E);
exception
when Exc : Property_Error =>
Put_Line (" Got a property error: " & Exception_Message (Exc));
end;
Put_Line ("Trying to build an orphan with rebound transitive parent...");
begin
E := Orphan (Rebound_TC);
Put_Line (" No error raised");
Dec_Ref (E);
exception
when Exc : Property_Error =>
Put_Line (" Got a property error: " & Exception_Message (Exc));
end;
Put_Line
("Trying to build an orphan with rebound non-transitive parent...");
begin
E := Orphan (Rebound_OK);
Put_Line (" No error raised");
Dec_Ref (E);
exception
when Exc : Property_Error =>
Put_Line (" Got a property error: " & Exception_Message (Exc));
end;
Dec_Ref (Grouped);
Dec_Ref (Rebound_TC);
Dec_Ref (Rebound_OK);
Destroy (Transitive_Child);
end;
Dec_Ref (Orphaned);
Destroy (Old_Env);
Destroy (New_Env);
Destroy (Rebindings);
Destroy (Root);
Destroy (Child);
Destroy (Symbols);
end Main;
|
burratoo/Acton | Ada | 1,275 | ads | ------------------------------------------------------------------------------------------
-- --
-- OAK PROCESSOR SUPPORT PACKAGE --
-- ATMEL AT91SAM7S --
-- --
-- OAK.PROCESSOR_SUPPORT_PACKAGE.TIME.INTERRUPT --
-- --
-- Copyright (C) 2014-2021, Patrick Bernardi --
-- --
------------------------------------------------------------------------------------------
-- In a seperate file so register restrictions can be placed on the FIQ
-- handler.
package Oak.Processor_Support_Package.Time.Interrupt with Preelaborate is
procedure Update_Clock
with Export, Convention => Ada, External_Name => "fiq_handler";
pragma Machine_Attribute
(Update_Clock, "naked");
end Oak.Processor_Support_Package.Time.Interrupt;
|
charlie5/lace | Ada | 6,907 | adb | with
openGL.Geometry.lit_textured,
openGL.Primitive.indexed;
package body openGL.Model.sphere.lit_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
--
-- 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 (Fonts);
use Geometry.lit_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_textured.Vertex_array := [1 .. vertex_Count => <>];
the_Sites : aliased Sites := [1 .. vertex_Count => <>];
the_Indices : aliased Indices := [1 .. indices_Count => <>];
the_Geometry : constant Geometry.lit_textured.view := Geometry.lit_textured.new_Geometry;
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).Coords := (S => 0.5, T => 1.0);
the_Vertices (the_Vertices'First).Shine := 0.5;
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).Coords := (S => 0.5, T => 0.0);
the_Vertices (the_Vertices'Last).Shine := 0.5;
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).Coords := (S => a / Degrees_360,
T => 1.0 - b / Degrees_180);
the_Vertices (vert_Id).Shine := 0.5;
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).Coords := (S => a / Degrees_360,
T => 1.0 - b / Degrees_180);
the_Vertices (vert_Id).Shine := 0.5;
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
then
the_Geometry.Texture_is (Textures.fetch (Self.Image));
the_Geometry.is_Transparent (now => the_Geometry.Texture.is_Transparent);
end if;
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_textured;
|
twdroeger/ada-awa | Ada | 1,292 | adb | -----------------------------------------------------------------------
-- awa-events-configs -- Event configuration
-- Copyright (C) 2012, 2013, 2017, 2018 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 AWA.Events.Queues;
with AWA.Services.Contexts;
package body AWA.Events.Configs.Reader_Config is
procedure Initialize is
begin
Add_Mapping (Mapper, Config'Unchecked_Access);
Config.Manager := Manager;
Config.Context := Context;
Config.Session := AWA.Services.Contexts.Get_Session (AWA.Services.Contexts.Current);
end Initialize;
end AWA.Events.Configs.Reader_Config;
|
optikos/oasis | Ada | 5,873 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Subtype_Indications;
with Program.Elements.Object_Access_Types;
with Program.Element_Visitors;
package Program.Nodes.Object_Access_Types is
pragma Preelaborate;
type Object_Access_Type is
new Program.Nodes.Node
and Program.Elements.Object_Access_Types.Object_Access_Type
and Program.Elements.Object_Access_Types.Object_Access_Type_Text
with private;
function Create
(Not_Token : Program.Lexical_Elements.Lexical_Element_Access;
Null_Token : Program.Lexical_Elements.Lexical_Element_Access;
Access_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
All_Token : Program.Lexical_Elements.Lexical_Element_Access;
Constant_Token : Program.Lexical_Elements.Lexical_Element_Access;
Subtype_Indication : not null Program.Elements.Subtype_Indications
.Subtype_Indication_Access)
return Object_Access_Type;
type Implicit_Object_Access_Type is
new Program.Nodes.Node
and Program.Elements.Object_Access_Types.Object_Access_Type
with private;
function Create
(Subtype_Indication : not null Program.Elements.Subtype_Indications
.Subtype_Indication_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False;
Has_Not_Null : Boolean := False;
Has_All : Boolean := False;
Has_Constant : Boolean := False)
return Implicit_Object_Access_Type
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Object_Access_Type is
abstract new Program.Nodes.Node
and Program.Elements.Object_Access_Types.Object_Access_Type
with record
Subtype_Indication : not null Program.Elements.Subtype_Indications
.Subtype_Indication_Access;
end record;
procedure Initialize (Self : aliased in out Base_Object_Access_Type'Class);
overriding procedure Visit
(Self : not null access Base_Object_Access_Type;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Subtype_Indication
(Self : Base_Object_Access_Type)
return not null Program.Elements.Subtype_Indications
.Subtype_Indication_Access;
overriding function Is_Object_Access_Type_Element
(Self : Base_Object_Access_Type)
return Boolean;
overriding function Is_Access_Type_Element
(Self : Base_Object_Access_Type)
return Boolean;
overriding function Is_Type_Definition_Element
(Self : Base_Object_Access_Type)
return Boolean;
overriding function Is_Definition_Element
(Self : Base_Object_Access_Type)
return Boolean;
type Object_Access_Type is
new Base_Object_Access_Type
and Program.Elements.Object_Access_Types.Object_Access_Type_Text
with record
Not_Token : Program.Lexical_Elements.Lexical_Element_Access;
Null_Token : Program.Lexical_Elements.Lexical_Element_Access;
Access_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
All_Token : Program.Lexical_Elements.Lexical_Element_Access;
Constant_Token : Program.Lexical_Elements.Lexical_Element_Access;
end record;
overriding function To_Object_Access_Type_Text
(Self : aliased in out Object_Access_Type)
return Program.Elements.Object_Access_Types
.Object_Access_Type_Text_Access;
overriding function Not_Token
(Self : Object_Access_Type)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Null_Token
(Self : Object_Access_Type)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Access_Token
(Self : Object_Access_Type)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function All_Token
(Self : Object_Access_Type)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Constant_Token
(Self : Object_Access_Type)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Has_Not_Null (Self : Object_Access_Type) return Boolean;
overriding function Has_All (Self : Object_Access_Type) return Boolean;
overriding function Has_Constant (Self : Object_Access_Type) return Boolean;
type Implicit_Object_Access_Type is
new Base_Object_Access_Type
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
Has_Not_Null : Boolean;
Has_All : Boolean;
Has_Constant : Boolean;
end record;
overriding function To_Object_Access_Type_Text
(Self : aliased in out Implicit_Object_Access_Type)
return Program.Elements.Object_Access_Types
.Object_Access_Type_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Object_Access_Type)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Object_Access_Type)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Object_Access_Type)
return Boolean;
overriding function Has_Not_Null
(Self : Implicit_Object_Access_Type)
return Boolean;
overriding function Has_All
(Self : Implicit_Object_Access_Type)
return Boolean;
overriding function Has_Constant
(Self : Implicit_Object_Access_Type)
return Boolean;
end Program.Nodes.Object_Access_Types;
|
glencornell/ada-object-framework | Ada | 81 | ads | package Callbacks is
procedure On_Change (Value : in Integer);
end Callbacks;
|
reznikmm/gela | Ada | 951 | adb |
with League.Application;
with League.Strings;
with League.String_Vectors;
with Gela.Contexts;
with Gela.Context_Factories;
procedure Parser_Test is
Hash : League.Hash_Type;
pragma Unreferenced (Hash);
Env : constant League.Strings.Universal_String :=
League.Strings.To_Universal_String ("GELA_INCLUDE_PATH");
Args : League.String_Vectors.Universal_String_Vector;
Context : Gela.Contexts.Context_Access;
pragma Unreferenced (Context);
begin
-- Command line: "-IDIR1" "-IDIR2" "FILE" "HASH"
for J in 1 .. League.Application.Arguments.Length - 1 loop
Args.Append (League.Application.Arguments.Element (J));
end loop;
Hash := League.Hash_Type'Wide_Wide_Value
(League.Application.Arguments.Element
(League.Application.Arguments.Length).To_Wide_Wide_String);
Context := Gela.Context_Factories.Create_Context
(Args, League.Application.Environment.Value (Env));
end Parser_Test;
|
AdaCore/training_material | Ada | 459 | adb | with GNAT.Random_Numbers;
package body Random_Numbers
with SPARK_Mode => Off
is
Gen : GNAT.Random_Numbers.Generator;
procedure Random (From, To : Integer; Result : out Integer) is
Candidate : Integer;
begin
loop
Candidate := GNAT.Random_Numbers.Random (Gen);
exit when Candidate in From .. To;
end loop;
Result := Candidate;
end Random;
begin
GNAT.Random_Numbers.Reset (Gen);
end Random_Numbers;
|
ftigeot/ravensource | Ada | 3,023 | adb | --- src/anet-sockets-inet.adb.orig 2018-02-20 13:29:18 UTC
+++ src/anet-sockets-inet.adb
@@ -69,7 +69,7 @@ package body Anet.Sockets.Inet is
Res : C.int;
Sock : Thin.Inet.Sockaddr_In_Type
(Family => Socket_Families.Family_Inet);
- Len : aliased C.int := Sock'Size / 8;
+ Len : aliased C.int := Thin.Inet.Sockaddr_In_Size;
begin
New_Socket.Sock_FD := -1;
Src := (Addr => Any_Addr,
@@ -116,7 +116,7 @@ package body Anet.Sockets.Inet is
Res : C.int;
Sock : Thin.Inet.Sockaddr_In_Type
(Family => Socket_Families.Family_Inet6);
- Len : aliased C.int := Sock'Size / 8;
+ Len : aliased C.int := Thin.Inet.Sockaddr_In6_Size;
begin
New_Socket.Sock_FD := -1;
Src := (Addr => Any_Addr_V6,
@@ -170,7 +170,7 @@ package body Anet.Sockets.Inet is
(Result => Thin.C_Bind
(S => Socket.Sock_FD,
Name => Sockaddr'Address,
- Namelen => Sockaddr'Size / 8),
+ Namelen => Thin.Inet.Sockaddr_In_Size),
Message => "Unable to bind IPv4 socket to " & To_String
(Address => Address) & "," & Port'Img);
end Bind;
@@ -194,7 +194,7 @@ package body Anet.Sockets.Inet is
(Result => Thin.C_Bind
(S => Socket.Sock_FD,
Name => Sockaddr'Address,
- Namelen => Sockaddr'Size / 8),
+ Namelen => Thin.Inet.Sockaddr_In6_Size),
Message => "Unable to bind IPv6 socket to " & To_String
(Address => Address) & "," & Port'Img);
end Bind;
@@ -214,7 +214,7 @@ package body Anet.Sockets.Inet is
(Result => Thin.C_Connect
(S => Socket.Sock_FD,
Name => Dst'Address,
- Namelen => Dst'Size / 8),
+ Namelen => Thin.Inet.Sockaddr_In_Size),
Message => "Unable to connect socket to address " & To_String
(Address => Address) & " (" & Port'Img & " )");
end Connect;
@@ -234,7 +234,7 @@ package body Anet.Sockets.Inet is
(Result => Thin.C_Connect
(S => Socket.Sock_FD,
Name => Dst'Address,
- Namelen => Dst'Size / 8),
+ Namelen => Thin.Inet.Sockaddr_In6_Size),
Message => "Unable to connect socket to address " & To_String
(Address => Address) & " (" & Port'Img & " )");
end Connect;
@@ -472,7 +472,7 @@ package body Anet.Sockets.Inet is
Len => Item'Length,
Flags => Constants.Sys.MSG_NOSIGNAL,
To => Dst'Address,
- Tolen => Dst'Size / 8);
+ Tolen => Thin.Inet.Sockaddr_In_Size);
Errno.Check_Or_Raise
(Result => C.int (Res),
@@ -504,7 +504,7 @@ package body Anet.Sockets.Inet is
Len => Item'Length,
Flags => Constants.Sys.MSG_NOSIGNAL,
To => Dst'Address,
- Tolen => Dst'Size / 8);
+ Tolen => Thin.Inet.Sockaddr_In6_Size);
Errno.Check_Or_Raise
(Result => C.int (Res),
|
persan/AdaYaml | Ada | 632 | ads | -- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
with System;
with Yaml.C;
package Yaml.Destination.C_Handler is
type Instance is new Destination.Instance with private;
function As_Destination (Handler : Yaml.C.Write_Handler;
Data : System.Address) return Pointer;
overriding procedure Write_Data (Object : in out Instance; Buffer : String);
private
type Instance is new Destination.Instance with record
Handler : Yaml.C.Write_Handler;
Data : System.Address;
end record;
end Yaml.Destination.C_Handler;
|
rveenker/sdlada | Ada | 1,412 | 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.
--------------------------------------------------------------------------------------------------------------------
-- Android implementation.
--------------------------------------------------------------------------------------------------------------------
separate (SDL.Platform)
function Get return Platforms is
begin
return Android;
end Get;
|
twdroeger/ada-awa | Ada | 66,477 | adb | -----------------------------------------------------------------------
-- AWA.Questions.Models -- AWA.Questions.Models
-----------------------------------------------------------------------
-- File generated by ada-gen DO NOT MODIFY
-- Template used: templates/model/package-body.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.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Util.Beans.Objects.Time;
with ASF.Events.Faces.Actions;
package body AWA.Questions.Models is
use type ADO.Objects.Object_Record_Access;
use type ADO.Objects.Object_Ref;
pragma Warnings (Off, "formal parameter * is not referenced");
function Question_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => QUESTION_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Question_Key;
function Question_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => QUESTION_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Question_Key;
function "=" (Left, Right : Question_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Question_Ref'Class;
Impl : out Question_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Question_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
procedure Allocate (Object : in out Question_Ref) is
Impl : Question_Access;
begin
Impl := new Question_Impl;
Impl.Create_Date := ADO.DEFAULT_TIME;
Impl.Edit_Date.Is_Null := True;
Impl.Rating := 0;
Impl.Version := 0;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Question
-- ----------------------------------------
procedure Set_Create_Date (Object : in out Question_Ref;
Value : in Ada.Calendar.Time) is
Impl : Question_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Time (Impl.all, 1, Impl.Create_Date, Value);
end Set_Create_Date;
function Get_Create_Date (Object : in Question_Ref)
return Ada.Calendar.Time is
Impl : constant Question_Access
:= Question_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Create_Date;
end Get_Create_Date;
procedure Set_Title (Object : in out Question_Ref;
Value : in String) is
Impl : Question_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 2, Impl.Title, Value);
end Set_Title;
procedure Set_Title (Object : in out Question_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Question_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 2, Impl.Title, Value);
end Set_Title;
function Get_Title (Object : in Question_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Title);
end Get_Title;
function Get_Title (Object : in Question_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Question_Access
:= Question_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Title;
end Get_Title;
procedure Set_Description (Object : in out Question_Ref;
Value : in String) is
Impl : Question_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 3, Impl.Description, Value);
end Set_Description;
procedure Set_Description (Object : in out Question_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Question_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 3, Impl.Description, Value);
end Set_Description;
function Get_Description (Object : in Question_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Description);
end Get_Description;
function Get_Description (Object : in Question_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Question_Access
:= Question_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Description;
end Get_Description;
procedure Set_Edit_Date (Object : in out Question_Ref;
Value : in ADO.Nullable_Time) is
Impl : Question_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Time (Impl.all, 4, Impl.Edit_Date, Value);
end Set_Edit_Date;
function Get_Edit_Date (Object : in Question_Ref)
return ADO.Nullable_Time is
Impl : constant Question_Access
:= Question_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Edit_Date;
end Get_Edit_Date;
procedure Set_Short_Description (Object : in out Question_Ref;
Value : in String) is
Impl : Question_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 5, Impl.Short_Description, Value);
end Set_Short_Description;
procedure Set_Short_Description (Object : in out Question_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Question_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 5, Impl.Short_Description, Value);
end Set_Short_Description;
function Get_Short_Description (Object : in Question_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Short_Description);
end Get_Short_Description;
function Get_Short_Description (Object : in Question_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Question_Access
:= Question_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Short_Description;
end Get_Short_Description;
procedure Set_Rating (Object : in out Question_Ref;
Value : in Integer) is
Impl : Question_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Integer (Impl.all, 6, Impl.Rating, Value);
end Set_Rating;
function Get_Rating (Object : in Question_Ref)
return Integer is
Impl : constant Question_Access
:= Question_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Rating;
end Get_Rating;
procedure Set_Id (Object : in out Question_Ref;
Value : in ADO.Identifier) is
Impl : Question_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 7, Value);
end Set_Id;
function Get_Id (Object : in Question_Ref)
return ADO.Identifier is
Impl : constant Question_Access
:= Question_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
function Get_Version (Object : in Question_Ref)
return Integer is
Impl : constant Question_Access
:= Question_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Version;
end Get_Version;
procedure Set_Author (Object : in out Question_Ref;
Value : in AWA.Users.Models.User_Ref'Class) is
Impl : Question_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 9, Impl.Author, Value);
end Set_Author;
function Get_Author (Object : in Question_Ref)
return AWA.Users.Models.User_Ref'Class is
Impl : constant Question_Access
:= Question_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Author;
end Get_Author;
procedure Set_Workspace (Object : in out Question_Ref;
Value : in AWA.Workspaces.Models.Workspace_Ref'Class) is
Impl : Question_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 10, Impl.Workspace, Value);
end Set_Workspace;
function Get_Workspace (Object : in Question_Ref)
return AWA.Workspaces.Models.Workspace_Ref'Class is
Impl : constant Question_Access
:= Question_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Workspace;
end Get_Workspace;
procedure Set_Accepted_Answer (Object : in out Question_Ref;
Value : in AWA.Questions.Models.Answer_Ref'Class) is
Impl : Question_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 11, Impl.Accepted_Answer, Value);
end Set_Accepted_Answer;
function Get_Accepted_Answer (Object : in Question_Ref)
return AWA.Questions.Models.Answer_Ref'Class is
Impl : constant Question_Access
:= Question_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Accepted_Answer;
end Get_Accepted_Answer;
-- Copy of the object.
procedure Copy (Object : in Question_Ref;
Into : in out Question_Ref) is
Result : Question_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Question_Access
:= Question_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Question_Access
:= new Question_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Create_Date := Impl.Create_Date;
Copy.Title := Impl.Title;
Copy.Description := Impl.Description;
Copy.Edit_Date := Impl.Edit_Date;
Copy.Short_Description := Impl.Short_Description;
Copy.Rating := Impl.Rating;
Copy.Version := Impl.Version;
Copy.Author := Impl.Author;
Copy.Workspace := Impl.Workspace;
Copy.Accepted_Answer := Impl.Accepted_Answer;
end;
end if;
Into := Result;
end Copy;
procedure Find (Object : in out Question_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Question_Access := new Question_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Question_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Question_Access := new Question_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Question_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Question_Access := new Question_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
procedure Save (Object : in out Question_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Question_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
procedure Delete (Object : in out Question_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
procedure Destroy (Object : access Question_Impl) is
type Question_Impl_Ptr is access all Question_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Question_Impl, Question_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Question_Impl_Ptr := Question_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
procedure Find (Object : in out Question_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, QUESTION_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Question_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
procedure Save (Object : in out Question_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (QUESTION_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_1_NAME, -- create_date
Value => Object.Create_Date);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (2) then
Stmt.Save_Field (Name => COL_1_1_NAME, -- title
Value => Object.Title);
Object.Clear_Modified (2);
end if;
if Object.Is_Modified (3) then
Stmt.Save_Field (Name => COL_2_1_NAME, -- description
Value => Object.Description);
Object.Clear_Modified (3);
end if;
if Object.Is_Modified (4) then
Stmt.Save_Field (Name => COL_3_1_NAME, -- edit_date
Value => Object.Edit_Date);
Object.Clear_Modified (4);
end if;
if Object.Is_Modified (5) then
Stmt.Save_Field (Name => COL_4_1_NAME, -- short_description
Value => Object.Short_Description);
Object.Clear_Modified (5);
end if;
if Object.Is_Modified (6) then
Stmt.Save_Field (Name => COL_5_1_NAME, -- rating
Value => Object.Rating);
Object.Clear_Modified (6);
end if;
if Object.Is_Modified (7) then
Stmt.Save_Field (Name => COL_6_1_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (7);
end if;
if Object.Is_Modified (9) then
Stmt.Save_Field (Name => COL_8_1_NAME, -- author_id
Value => Object.Author);
Object.Clear_Modified (9);
end if;
if Object.Is_Modified (10) then
Stmt.Save_Field (Name => COL_9_1_NAME, -- workspace_id
Value => Object.Workspace);
Object.Clear_Modified (10);
end if;
if Object.Is_Modified (11) then
Stmt.Save_Field (Name => COL_10_1_NAME, -- accepted_answer_id
Value => Object.Accepted_Answer);
Object.Clear_Modified (11);
end if;
if Stmt.Has_Save_Fields then
Object.Version := Object.Version + 1;
Stmt.Save_Field (Name => "version",
Value => Object.Version);
Stmt.Set_Filter (Filter => "id = ? and version = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Add_Param (Value => Object.Version - 1);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
else
raise ADO.Objects.LAZY_LOCK;
end if;
end if;
end;
end if;
end Save;
procedure Create (Object : in out Question_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (QUESTION_DEF'Access);
Result : Integer;
begin
Object.Version := 1;
Query.Save_Field (Name => COL_0_1_NAME, -- create_date
Value => Object.Create_Date);
Query.Save_Field (Name => COL_1_1_NAME, -- title
Value => Object.Title);
Query.Save_Field (Name => COL_2_1_NAME, -- description
Value => Object.Description);
Query.Save_Field (Name => COL_3_1_NAME, -- edit_date
Value => Object.Edit_Date);
Query.Save_Field (Name => COL_4_1_NAME, -- short_description
Value => Object.Short_Description);
Query.Save_Field (Name => COL_5_1_NAME, -- rating
Value => Object.Rating);
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_6_1_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_7_1_NAME, -- version
Value => Object.Version);
Query.Save_Field (Name => COL_8_1_NAME, -- author_id
Value => Object.Author);
Query.Save_Field (Name => COL_9_1_NAME, -- workspace_id
Value => Object.Workspace);
Query.Save_Field (Name => COL_10_1_NAME, -- accepted_answer_id
Value => Object.Accepted_Answer);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
procedure Delete (Object : in out Question_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (QUESTION_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Question_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Question_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Question_Impl (Obj.all)'Access;
if Name = "create_date" then
return Util.Beans.Objects.Time.To_Object (Impl.Create_Date);
elsif Name = "title" then
return Util.Beans.Objects.To_Object (Impl.Title);
elsif Name = "description" then
return Util.Beans.Objects.To_Object (Impl.Description);
elsif Name = "edit_date" then
if Impl.Edit_Date.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.Time.To_Object (Impl.Edit_Date.Value);
end if;
elsif Name = "short_description" then
return Util.Beans.Objects.To_Object (Impl.Short_Description);
elsif Name = "rating" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Rating));
elsif Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Question_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.Create_Date := Stmt.Get_Time (0);
Object.Title := Stmt.Get_Unbounded_String (1);
Object.Description := Stmt.Get_Unbounded_String (2);
Object.Edit_Date := Stmt.Get_Nullable_Time (3);
Object.Short_Description := Stmt.Get_Unbounded_String (4);
Object.Rating := Stmt.Get_Integer (5);
Object.Set_Key_Value (Stmt.Get_Identifier (6));
if not Stmt.Is_Null (8) then
Object.Author.Set_Key_Value (Stmt.Get_Identifier (8), Session);
end if;
if not Stmt.Is_Null (9) then
Object.Workspace.Set_Key_Value (Stmt.Get_Identifier (9), Session);
end if;
if not Stmt.Is_Null (10) then
Object.Accepted_Answer.Set_Key_Value (Stmt.Get_Identifier (10), Session);
end if;
Object.Version := Stmt.Get_Integer (7);
ADO.Objects.Set_Created (Object);
end Load;
function Answer_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => ANSWER_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Answer_Key;
function Answer_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => ANSWER_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Answer_Key;
function "=" (Left, Right : Answer_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Answer_Ref'Class;
Impl : out Answer_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Answer_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
procedure Allocate (Object : in out Answer_Ref) is
Impl : Answer_Access;
begin
Impl := new Answer_Impl;
Impl.Create_Date := ADO.DEFAULT_TIME;
Impl.Edit_Date.Is_Null := True;
Impl.Rank := 0;
Impl.Version := 0;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Answer
-- ----------------------------------------
procedure Set_Create_Date (Object : in out Answer_Ref;
Value : in Ada.Calendar.Time) is
Impl : Answer_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Time (Impl.all, 1, Impl.Create_Date, Value);
end Set_Create_Date;
function Get_Create_Date (Object : in Answer_Ref)
return Ada.Calendar.Time is
Impl : constant Answer_Access
:= Answer_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Create_Date;
end Get_Create_Date;
procedure Set_Edit_Date (Object : in out Answer_Ref;
Value : in ADO.Nullable_Time) is
Impl : Answer_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Time (Impl.all, 2, Impl.Edit_Date, Value);
end Set_Edit_Date;
function Get_Edit_Date (Object : in Answer_Ref)
return ADO.Nullable_Time is
Impl : constant Answer_Access
:= Answer_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Edit_Date;
end Get_Edit_Date;
procedure Set_Answer (Object : in out Answer_Ref;
Value : in String) is
Impl : Answer_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 3, Impl.Answer, Value);
end Set_Answer;
procedure Set_Answer (Object : in out Answer_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Answer_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 3, Impl.Answer, Value);
end Set_Answer;
function Get_Answer (Object : in Answer_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Answer);
end Get_Answer;
function Get_Answer (Object : in Answer_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Answer_Access
:= Answer_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Answer;
end Get_Answer;
procedure Set_Rank (Object : in out Answer_Ref;
Value : in Integer) is
Impl : Answer_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Integer (Impl.all, 4, Impl.Rank, Value);
end Set_Rank;
function Get_Rank (Object : in Answer_Ref)
return Integer is
Impl : constant Answer_Access
:= Answer_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Rank;
end Get_Rank;
procedure Set_Id (Object : in out Answer_Ref;
Value : in ADO.Identifier) is
Impl : Answer_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 5, Value);
end Set_Id;
function Get_Id (Object : in Answer_Ref)
return ADO.Identifier is
Impl : constant Answer_Access
:= Answer_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
function Get_Version (Object : in Answer_Ref)
return Integer is
Impl : constant Answer_Access
:= Answer_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Version;
end Get_Version;
procedure Set_Author (Object : in out Answer_Ref;
Value : in AWA.Users.Models.User_Ref'Class) is
Impl : Answer_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 7, Impl.Author, Value);
end Set_Author;
function Get_Author (Object : in Answer_Ref)
return AWA.Users.Models.User_Ref'Class is
Impl : constant Answer_Access
:= Answer_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Author;
end Get_Author;
procedure Set_Question (Object : in out Answer_Ref;
Value : in AWA.Questions.Models.Question_Ref'Class) is
Impl : Answer_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 8, Impl.Question, Value);
end Set_Question;
function Get_Question (Object : in Answer_Ref)
return AWA.Questions.Models.Question_Ref'Class is
Impl : constant Answer_Access
:= Answer_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Question;
end Get_Question;
-- Copy of the object.
procedure Copy (Object : in Answer_Ref;
Into : in out Answer_Ref) is
Result : Answer_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Answer_Access
:= Answer_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Answer_Access
:= new Answer_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Create_Date := Impl.Create_Date;
Copy.Edit_Date := Impl.Edit_Date;
Copy.Answer := Impl.Answer;
Copy.Rank := Impl.Rank;
Copy.Version := Impl.Version;
Copy.Author := Impl.Author;
Copy.Question := Impl.Question;
end;
end if;
Into := Result;
end Copy;
procedure Find (Object : in out Answer_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Answer_Access := new Answer_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Answer_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Answer_Access := new Answer_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Answer_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Answer_Access := new Answer_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
procedure Save (Object : in out Answer_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Answer_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
procedure Delete (Object : in out Answer_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
procedure Destroy (Object : access Answer_Impl) is
type Answer_Impl_Ptr is access all Answer_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Answer_Impl, Answer_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Answer_Impl_Ptr := Answer_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
procedure Find (Object : in out Answer_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, ANSWER_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Answer_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
procedure Save (Object : in out Answer_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (ANSWER_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_2_NAME, -- create_date
Value => Object.Create_Date);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (2) then
Stmt.Save_Field (Name => COL_1_2_NAME, -- edit_date
Value => Object.Edit_Date);
Object.Clear_Modified (2);
end if;
if Object.Is_Modified (3) then
Stmt.Save_Field (Name => COL_2_2_NAME, -- answer
Value => Object.Answer);
Object.Clear_Modified (3);
end if;
if Object.Is_Modified (4) then
Stmt.Save_Field (Name => COL_3_2_NAME, -- rank
Value => Object.Rank);
Object.Clear_Modified (4);
end if;
if Object.Is_Modified (5) then
Stmt.Save_Field (Name => COL_4_2_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (5);
end if;
if Object.Is_Modified (7) then
Stmt.Save_Field (Name => COL_6_2_NAME, -- author_id
Value => Object.Author);
Object.Clear_Modified (7);
end if;
if Object.Is_Modified (8) then
Stmt.Save_Field (Name => COL_7_2_NAME, -- question_id
Value => Object.Question);
Object.Clear_Modified (8);
end if;
if Stmt.Has_Save_Fields then
Object.Version := Object.Version + 1;
Stmt.Save_Field (Name => "version",
Value => Object.Version);
Stmt.Set_Filter (Filter => "id = ? and version = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Add_Param (Value => Object.Version - 1);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
else
raise ADO.Objects.LAZY_LOCK;
end if;
end if;
end;
end if;
end Save;
procedure Create (Object : in out Answer_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (ANSWER_DEF'Access);
Result : Integer;
begin
Object.Version := 1;
Query.Save_Field (Name => COL_0_2_NAME, -- create_date
Value => Object.Create_Date);
Query.Save_Field (Name => COL_1_2_NAME, -- edit_date
Value => Object.Edit_Date);
Query.Save_Field (Name => COL_2_2_NAME, -- answer
Value => Object.Answer);
Query.Save_Field (Name => COL_3_2_NAME, -- rank
Value => Object.Rank);
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_4_2_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_5_2_NAME, -- version
Value => Object.Version);
Query.Save_Field (Name => COL_6_2_NAME, -- author_id
Value => Object.Author);
Query.Save_Field (Name => COL_7_2_NAME, -- question_id
Value => Object.Question);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
procedure Delete (Object : in out Answer_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (ANSWER_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Answer_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Answer_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Answer_Impl (Obj.all)'Access;
if Name = "create_date" then
return Util.Beans.Objects.Time.To_Object (Impl.Create_Date);
elsif Name = "edit_date" then
if Impl.Edit_Date.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.Time.To_Object (Impl.Edit_Date.Value);
end if;
elsif Name = "answer" then
return Util.Beans.Objects.To_Object (Impl.Answer);
elsif Name = "rank" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Rank));
elsif Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Answer_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.Create_Date := Stmt.Get_Time (0);
Object.Edit_Date := Stmt.Get_Nullable_Time (1);
Object.Answer := Stmt.Get_Unbounded_String (2);
Object.Rank := Stmt.Get_Integer (3);
Object.Set_Key_Value (Stmt.Get_Identifier (4));
if not Stmt.Is_Null (6) then
Object.Author.Set_Key_Value (Stmt.Get_Identifier (6), Session);
end if;
if not Stmt.Is_Null (7) then
Object.Question.Set_Key_Value (Stmt.Get_Identifier (7), Session);
end if;
Object.Version := Stmt.Get_Integer (5);
ADO.Objects.Set_Created (Object);
end Load;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Answer_Info;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id));
elsif Name = "create_date" then
return Util.Beans.Objects.Time.To_Object (From.Create_Date);
elsif Name = "edit_date" then
if From.Edit_Date.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.Time.To_Object (From.Edit_Date.Value);
end if;
elsif Name = "answer" then
return Util.Beans.Objects.To_Object (From.Answer);
elsif Name = "rank" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Rank));
elsif Name = "user_rating" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.User_Rating));
elsif Name = "author_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Author_Id));
elsif Name = "author_name" then
return Util.Beans.Objects.To_Object (From.Author_Name);
elsif Name = "author_email" then
return Util.Beans.Objects.To_Object (From.Author_Email);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Answer_Info;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "id" then
Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "create_date" then
Item.Create_Date := Util.Beans.Objects.Time.To_Time (Value);
elsif Name = "edit_date" then
Item.Edit_Date.Is_Null := Util.Beans.Objects.Is_Null (Value);
if not Item.Edit_Date.Is_Null then
Item.Edit_Date.Value := Util.Beans.Objects.Time.To_Time (Value);
end if;
elsif Name = "answer" then
Item.Answer := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "rank" then
Item.Rank := Util.Beans.Objects.To_Integer (Value);
elsif Name = "user_rating" then
Item.User_Rating := Util.Beans.Objects.To_Integer (Value);
elsif Name = "author_id" then
Item.Author_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "author_name" then
Item.Author_Name := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "author_email" then
Item.Author_Email := Util.Beans.Objects.To_Unbounded_String (Value);
end if;
end Set_Value;
-- --------------------
-- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>.
-- --------------------
procedure List (Object : in out Answer_Info_List_Bean'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
begin
List (Object.List, Session, Context);
end List;
-- --------------------
-- The list of answers.
-- --------------------
procedure List (Object : in out Answer_Info_Vector;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
procedure Read (Into : in out Answer_Info);
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Context);
Pos : Positive := 1;
procedure Read (Into : in out Answer_Info) is
begin
Into.Id := Stmt.Get_Identifier (0);
Into.Create_Date := Stmt.Get_Time (1);
Into.Edit_Date := Stmt.Get_Nullable_Time (2);
Into.Answer := Stmt.Get_Unbounded_String (3);
Into.Rank := Stmt.Get_Integer (4);
Into.User_Rating := Stmt.Get_Integer (5);
Into.Author_Id := Stmt.Get_Identifier (6);
Into.Author_Name := Stmt.Get_Unbounded_String (7);
Into.Author_Email := Stmt.Get_Unbounded_String (8);
end Read;
begin
Stmt.Execute;
Answer_Info_Vectors.Clear (Object);
while Stmt.Has_Elements loop
Object.Insert_Space (Before => Pos);
Object.Update_Element (Index => Pos, Process => Read'Access);
Pos := Pos + 1;
Stmt.Next;
end loop;
end List;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Question_Display_Info;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id));
elsif Name = "title" then
return Util.Beans.Objects.To_Object (From.Title);
elsif Name = "create_date" then
return Util.Beans.Objects.Time.To_Object (From.Create_Date);
elsif Name = "edit_date" then
if From.Edit_Date.Is_Null then
return Util.Beans.Objects.Null_Object;
else
return Util.Beans.Objects.Time.To_Object (From.Edit_Date.Value);
end if;
elsif Name = "description" then
return Util.Beans.Objects.To_Object (From.Description);
elsif Name = "rating" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Rating));
elsif Name = "user_rating" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.User_Rating));
elsif Name = "author_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Author_Id));
elsif Name = "author_name" then
return Util.Beans.Objects.To_Object (From.Author_Name);
elsif Name = "author_email" then
return Util.Beans.Objects.To_Object (From.Author_Email);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Question_Display_Info;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "id" then
Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "title" then
Item.Title := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "create_date" then
Item.Create_Date := Util.Beans.Objects.Time.To_Time (Value);
elsif Name = "edit_date" then
Item.Edit_Date.Is_Null := Util.Beans.Objects.Is_Null (Value);
if not Item.Edit_Date.Is_Null then
Item.Edit_Date.Value := Util.Beans.Objects.Time.To_Time (Value);
end if;
elsif Name = "description" then
Item.Description := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "rating" then
Item.Rating := Util.Beans.Objects.To_Integer (Value);
elsif Name = "user_rating" then
Item.User_Rating := Util.Beans.Objects.To_Integer (Value);
elsif Name = "author_id" then
Item.Author_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "author_name" then
Item.Author_Name := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "author_email" then
Item.Author_Email := Util.Beans.Objects.To_Unbounded_String (Value);
end if;
end Set_Value;
-- --------------------
-- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>.
-- --------------------
procedure List (Object : in out Question_Display_Info_List_Bean'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
begin
List (Object.List, Session, Context);
end List;
-- --------------------
-- The list of questions.
-- --------------------
procedure List (Object : in out Question_Display_Info_Vector;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
procedure Read (Into : in out Question_Display_Info);
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Context);
Pos : Positive := 1;
procedure Read (Into : in out Question_Display_Info) is
begin
Into.Id := Stmt.Get_Identifier (0);
Into.Title := Stmt.Get_Unbounded_String (1);
Into.Create_Date := Stmt.Get_Time (2);
Into.Edit_Date := Stmt.Get_Nullable_Time (3);
Into.Description := Stmt.Get_Unbounded_String (4);
Into.Rating := Stmt.Get_Integer (5);
Into.User_Rating := Stmt.Get_Integer (6);
Into.Author_Id := Stmt.Get_Identifier (7);
Into.Author_Name := Stmt.Get_Unbounded_String (8);
Into.Author_Email := Stmt.Get_Unbounded_String (9);
end Read;
begin
Stmt.Execute;
Question_Display_Info_Vectors.Clear (Object);
while Stmt.Has_Elements loop
Object.Insert_Space (Before => Pos);
Object.Update_Element (Index => Pos, Process => Read'Access);
Pos := Pos + 1;
Stmt.Next;
end loop;
end List;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Question_Info;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id));
elsif Name = "title" then
return Util.Beans.Objects.To_Object (From.Title);
elsif Name = "create_date" then
return Util.Beans.Objects.Time.To_Object (From.Create_Date);
elsif Name = "description" then
return Util.Beans.Objects.To_Object (From.Description);
elsif Name = "rating" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Rating));
elsif Name = "answer_count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Answer_Count));
elsif Name = "author_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Author_Id));
elsif Name = "author_name" then
return Util.Beans.Objects.To_Object (From.Author_Name);
elsif Name = "author_email" then
return Util.Beans.Objects.To_Object (From.Author_Email);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Question_Info;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "id" then
Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "title" then
Item.Title := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "create_date" then
Item.Create_Date := Util.Beans.Objects.Time.To_Time (Value);
elsif Name = "description" then
Item.Description := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "rating" then
Item.Rating := Util.Beans.Objects.To_Integer (Value);
elsif Name = "answer_count" then
Item.Answer_Count := Util.Beans.Objects.To_Integer (Value);
elsif Name = "author_id" then
Item.Author_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "author_name" then
Item.Author_Name := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "author_email" then
Item.Author_Email := Util.Beans.Objects.To_Unbounded_String (Value);
end if;
end Set_Value;
-- --------------------
-- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>.
-- --------------------
procedure List (Object : in out Question_Info_List_Bean'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
begin
List (Object.List, Session, Context);
end List;
-- --------------------
-- The list of questions.
-- --------------------
procedure List (Object : in out Question_Info_Vector;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
procedure Read (Into : in out Question_Info);
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Context);
Pos : Positive := 1;
procedure Read (Into : in out Question_Info) is
begin
Into.Id := Stmt.Get_Identifier (0);
Into.Title := Stmt.Get_Unbounded_String (1);
Into.Create_Date := Stmt.Get_Time (2);
Into.Description := Stmt.Get_Unbounded_String (3);
Into.Rating := Stmt.Get_Integer (4);
Into.Answer_Count := Stmt.Get_Integer (5);
Into.Author_Id := Stmt.Get_Identifier (6);
Into.Author_Name := Stmt.Get_Unbounded_String (7);
Into.Author_Email := Stmt.Get_Unbounded_String (8);
end Read;
begin
Stmt.Execute;
Question_Info_Vectors.Clear (Object);
while Stmt.Has_Elements loop
Object.Insert_Space (Before => Pos);
Object.Update_Element (Index => Pos, Process => Read'Access);
Pos := Pos + 1;
Stmt.Next;
end loop;
end List;
procedure Op_Save (Bean : in out Question_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Save (Bean : in out Question_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Question_Bean'Class (Bean).Save (Outcome);
end Op_Save;
package Binding_Question_Bean_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Question_Bean,
Method => Op_Save,
Name => "save");
procedure Op_Delete (Bean : in out Question_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Delete (Bean : in out Question_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Question_Bean'Class (Bean).Delete (Outcome);
end Op_Delete;
package Binding_Question_Bean_2 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Question_Bean,
Method => Op_Delete,
Name => "delete");
procedure Op_Load (Bean : in out Question_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load (Bean : in out Question_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Question_Bean'Class (Bean).Load (Outcome);
end Op_Load;
package Binding_Question_Bean_3 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Question_Bean,
Method => Op_Load,
Name => "load");
Binding_Question_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Question_Bean_1.Proxy'Access,
2 => Binding_Question_Bean_2.Proxy'Access,
3 => Binding_Question_Bean_3.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Question_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Question_Bean_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Question_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "create_date" then
Item.Set_Create_Date (Util.Beans.Objects.Time.To_Time (Value));
elsif Name = "title" then
Item.Set_Title (Util.Beans.Objects.To_String (Value));
elsif Name = "description" then
Item.Set_Description (Util.Beans.Objects.To_String (Value));
elsif Name = "edit_date" then
if Util.Beans.Objects.Is_Null (Value) then
Item.Set_Edit_Date (ADO.Nullable_Time '(Is_Null => True, others => <>));
else
Item.Set_Edit_Date (ADO.Nullable_Time '(Is_Null => False,
Value => Util.Beans.Objects.Time.To_Time (Value)));
end if;
elsif Name = "short_description" then
Item.Set_Short_Description (Util.Beans.Objects.To_String (Value));
elsif Name = "rating" then
Item.Set_Rating (Util.Beans.Objects.To_Integer (Value));
end if;
end Set_Value;
procedure Op_Save (Bean : in out Answer_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Save (Bean : in out Answer_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Answer_Bean'Class (Bean).Save (Outcome);
end Op_Save;
package Binding_Answer_Bean_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Answer_Bean,
Method => Op_Save,
Name => "save");
procedure Op_Delete (Bean : in out Answer_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Delete (Bean : in out Answer_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Answer_Bean'Class (Bean).Delete (Outcome);
end Op_Delete;
package Binding_Answer_Bean_2 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Answer_Bean,
Method => Op_Delete,
Name => "delete");
procedure Op_Load (Bean : in out Answer_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load (Bean : in out Answer_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Answer_Bean'Class (Bean).Load (Outcome);
end Op_Load;
package Binding_Answer_Bean_3 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Answer_Bean,
Method => Op_Load,
Name => "load");
Binding_Answer_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Answer_Bean_1.Proxy'Access,
2 => Binding_Answer_Bean_2.Proxy'Access,
3 => Binding_Answer_Bean_3.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Answer_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Answer_Bean_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Answer_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "create_date" then
Item.Set_Create_Date (Util.Beans.Objects.Time.To_Time (Value));
elsif Name = "edit_date" then
if Util.Beans.Objects.Is_Null (Value) then
Item.Set_Edit_Date (ADO.Nullable_Time '(Is_Null => True, others => <>));
else
Item.Set_Edit_Date (ADO.Nullable_Time '(Is_Null => False,
Value => Util.Beans.Objects.Time.To_Time (Value)));
end if;
elsif Name = "answer" then
Item.Set_Answer (Util.Beans.Objects.To_String (Value));
elsif Name = "rank" then
Item.Set_Rank (Util.Beans.Objects.To_Integer (Value));
end if;
end Set_Value;
procedure Op_Load (Bean : in out Question_List_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load (Bean : in out Question_List_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Question_List_Bean'Class (Bean).Load (Outcome);
end Op_Load;
package Binding_Question_List_Bean_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Question_List_Bean,
Method => Op_Load,
Name => "load");
Binding_Question_List_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Question_List_Bean_1.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Question_List_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Question_List_Bean_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Question_List_Bean;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "tag" then
return Util.Beans.Objects.To_Object (From.Tag);
elsif Name = "page" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page));
elsif Name = "page_size" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page_Size));
elsif Name = "count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Count));
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Question_List_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "tag" then
Item.Tag := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "page" then
Item.Page := Util.Beans.Objects.To_Integer (Value);
elsif Name = "page_size" then
Item.Page_Size := Util.Beans.Objects.To_Integer (Value);
elsif Name = "count" then
Item.Count := Util.Beans.Objects.To_Integer (Value);
end if;
end Set_Value;
procedure Op_Load (Bean : in out Question_Display_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load (Bean : in out Question_Display_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Question_Display_Bean'Class (Bean).Load (Outcome);
end Op_Load;
package Binding_Question_Display_Bean_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Question_Display_Bean,
Method => Op_Load,
Name => "load");
Binding_Question_Display_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Question_Display_Bean_1.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Question_Display_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Question_Display_Bean_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Question_Display_Bean;
Name : in String) return Util.Beans.Objects.Object is
begin
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Question_Display_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
null;
end Set_Value;
end AWA.Questions.Models;
|
zhmu/ananas | Ada | 103,926 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- P A R _ S C O --
-- --
-- B o d y --
-- --
-- Copyright (C) 2009-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 Aspects; use Aspects;
with Atree; use Atree;
with Debug; use Debug;
with Errout; use Errout;
with Lib; use Lib;
with Lib.Util; use Lib.Util;
with Namet; use Namet;
with Nlists; use Nlists;
with Opt; use Opt;
with Output; use Output;
with Put_SCOs;
with SCOs; use SCOs;
with Sem; use Sem;
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 Table;
with GNAT.HTable; use GNAT.HTable;
with GNAT.Heap_Sort_G;
package body Par_SCO is
--------------------------
-- First-pass SCO table --
--------------------------
-- The Short_Circuit_And_Or pragma enables one to use AND and OR operators
-- in source code while the ones used with booleans will be interpreted as
-- their short circuit alternatives (AND THEN and OR ELSE). Thus, the true
-- meaning of these operators is known only after the semantic analysis.
-- However, decision SCOs include short circuit operators only. The SCO
-- information generation pass must be done before expansion, hence before
-- the semantic analysis. Because of this, the SCO information generation
-- is done in two passes.
-- The first one (SCO_Record_Raw, before semantic analysis) completes the
-- SCO_Raw_Table assuming all AND/OR operators are short circuit ones.
-- Then, the semantic analysis determines which operators are promoted to
-- short circuit ones. Finally, the second pass (SCO_Record_Filtered)
-- translates the SCO_Raw_Table to SCO_Table, taking care of removing the
-- remaining AND/OR operators and of adjusting decisions accordingly
-- (splitting decisions, removing empty ones, etc.).
type SCO_Generation_State_Type is (None, Raw, Filtered);
SCO_Generation_State : SCO_Generation_State_Type := None;
-- Keep track of the SCO generation state: this will prevent us from
-- running some steps multiple times (the second pass has to be started
-- from multiple places).
package SCO_Raw_Table is new Table.Table
(Table_Component_Type => SCO_Table_Entry,
Table_Index_Type => Nat,
Table_Low_Bound => 1,
Table_Initial => 500,
Table_Increment => 300,
Table_Name => "Raw_Table");
-----------------------
-- Unit Number Table --
-----------------------
-- This table parallels the SCO_Unit_Table, keeping track of the unit
-- numbers corresponding to the entries made in this table, so that before
-- writing out the SCO information to the ALI file, we can fill in the
-- proper dependency numbers and file names.
-- Note that the zeroth entry is here for convenience in sorting the table;
-- the real lower bound is 1.
package SCO_Unit_Number_Table is new Table.Table
(Table_Component_Type => Unit_Number_Type,
Table_Index_Type => SCO_Unit_Index,
Table_Low_Bound => 0, -- see note above on sort
Table_Initial => 20,
Table_Increment => 200,
Table_Name => "SCO_Unit_Number_Entry");
------------------------------------------
-- Condition/Operator/Pragma Hash Table --
------------------------------------------
-- We need to be able to get to conditions quickly for handling the calls
-- to Set_SCO_Condition efficiently, and similarly to get to pragmas to
-- handle calls to Set_SCO_Pragma_Enabled (the same holds for operators and
-- Set_SCO_Logical_Operator). For this purpose we identify the conditions,
-- operators and pragmas in the table by their starting sloc, and use this
-- hash table to map from these sloc values to SCO_Table indexes.
type Header_Num is new Integer range 0 .. 996;
-- Type for hash table headers
function Hash (F : Source_Ptr) return Header_Num;
-- Function to Hash source pointer value
function Equal (F1 : Source_Ptr; F2 : Source_Ptr) return Boolean;
-- Function to test two keys for equality
function "<" (S1 : Source_Location; S2 : Source_Location) return Boolean;
-- Function to test for source locations order
package SCO_Raw_Hash_Table is new Simple_HTable
(Header_Num, Int, 0, Source_Ptr, Hash, Equal);
-- The actual hash table
--------------------------
-- Internal Subprograms --
--------------------------
function Has_Decision (N : Node_Id) return Boolean;
-- N is the node for a subexpression. Returns True if the subexpression
-- contains a nested decision (i.e. either is a logical operator, or
-- contains a logical operator in its subtree).
--
-- This must be used in the first pass (SCO_Record_Raw) only: here AND/OR
-- operators are considered as short circuit, just in case the
-- Short_Circuit_And_Or pragma is used: only real short circuit operations
-- will be kept in the secord pass.
type Tristate is (False, True, Unknown);
function Is_Logical_Operator (N : Node_Id) return Tristate;
-- N is the node for a subexpression. This procedure determines whether N
-- is a logical operator: True for short circuit conditions, Unknown for OR
-- and AND (the Short_Circuit_And_Or pragma may be used) and False
-- otherwise. Note that in cases where True is returned, callers assume
-- Nkind (N) in N_Op.
function To_Source_Location (S : Source_Ptr) return Source_Location;
-- Converts Source_Ptr value to Source_Location (line/col) format
procedure Process_Decisions
(N : Node_Id;
T : Character;
Pragma_Sloc : Source_Ptr);
-- If N is Empty, has no effect. Otherwise scans the tree for the node N,
-- to output any decisions it contains. T is one of IEGPWX (for context of
-- expression: if/exit when/entry guard/pragma/while/expression). If T is
-- other than X, the node N is the if expression involved, and a decision
-- is always present (at the very least a simple decision is present at the
-- top level).
procedure Process_Decisions
(L : List_Id;
T : Character;
Pragma_Sloc : Source_Ptr);
-- Calls above procedure for each element of the list L
procedure Set_Raw_Table_Entry
(C1 : Character;
C2 : Character;
From : Source_Ptr;
To : Source_Ptr;
Last : Boolean;
Pragma_Sloc : Source_Ptr := No_Location;
Pragma_Aspect_Name : Name_Id := No_Name);
-- Append an entry to SCO_Raw_Table with fields set as per arguments
type Dominant_Info is record
K : Character;
-- F/T/S/E for a valid dominance marker, or ' ' for no dominant
N : Node_Id;
-- Node providing the Sloc(s) for the dominance marker
end record;
No_Dominant : constant Dominant_Info := (' ', Empty);
procedure Record_Instance (Id : Instance_Id; Inst_Sloc : Source_Ptr);
-- Add one entry from the instance table to the corresponding SCO table
procedure Traverse_Declarations_Or_Statements
(L : List_Id;
D : Dominant_Info := No_Dominant;
P : Node_Id := Empty);
-- Process L, a list of statements or declarations dominated by D. If P is
-- present, it is processed as though it had been prepended to L.
function Traverse_Declarations_Or_Statements
(L : List_Id;
D : Dominant_Info := No_Dominant;
P : Node_Id := Empty) return Dominant_Info;
-- Same as above, and returns dominant information corresponding to the
-- last node with SCO in L.
-- The following Traverse_* routines perform appropriate calls to
-- Traverse_Declarations_Or_Statements to traverse specific node kinds.
-- Parameter D, when present, indicates the dominant of the first
-- declaration or statement within N.
procedure Traverse_Generic_Package_Declaration (N : Node_Id);
procedure Traverse_Handled_Statement_Sequence
(N : Node_Id;
D : Dominant_Info := No_Dominant);
procedure Traverse_Package_Body (N : Node_Id);
procedure Traverse_Package_Declaration
(N : Node_Id;
D : Dominant_Info := No_Dominant);
procedure Traverse_Subprogram_Or_Task_Body
(N : Node_Id;
D : Dominant_Info := No_Dominant);
procedure Traverse_Protected_Or_Task_Definition (N : Node_Id);
-- Note regarding traversals: In a few cases where an Alternatives list is
-- involved, pragmas such as "pragma Page" may show up before the first
-- alternative. We skip them because we're out of statement or declaration
-- context, so these can't be pragmas of interest for SCO purposes, and
-- the regular alternative processing typically involves attribute queries
-- which aren't valid for a pragma.
procedure Write_SCOs_To_ALI_File is new Put_SCOs;
-- Write SCO information to the ALI file using routines in Lib.Util
----------
-- dsco --
----------
procedure dsco is
procedure Dump_Entry (Index : Nat; T : SCO_Table_Entry);
-- Dump a SCO table entry
----------------
-- Dump_Entry --
----------------
procedure Dump_Entry (Index : Nat; T : SCO_Table_Entry) is
begin
Write_Str (" ");
Write_Int (Index);
Write_Char ('.');
if T.C1 /= ' ' then
Write_Str (" C1 = '");
Write_Char (T.C1);
Write_Char (''');
end if;
if T.C2 /= ' ' then
Write_Str (" C2 = '");
Write_Char (T.C2);
Write_Char (''');
end if;
if T.From /= No_Source_Location then
Write_Str (" From = ");
Write_Int (Int (T.From.Line));
Write_Char (':');
Write_Int (Int (T.From.Col));
end if;
if T.To /= No_Source_Location then
Write_Str (" To = ");
Write_Int (Int (T.To.Line));
Write_Char (':');
Write_Int (Int (T.To.Col));
end if;
if T.Last then
Write_Str (" True");
else
Write_Str (" False");
end if;
Write_Eol;
end Dump_Entry;
-- Start of processing for dsco
begin
-- Dump SCO unit table
Write_Line ("SCO Unit Table");
Write_Line ("--------------");
for Index in 1 .. SCO_Unit_Table.Last loop
declare
UTE : SCO_Unit_Table_Entry renames SCO_Unit_Table.Table (Index);
begin
Write_Str (" ");
Write_Int (Int (Index));
Write_Str (" Dep_Num = ");
Write_Int (Int (UTE.Dep_Num));
Write_Str (" From = ");
Write_Int (Int (UTE.From));
Write_Str (" To = ");
Write_Int (Int (UTE.To));
Write_Str (" File_Name = """);
if UTE.File_Name /= null then
Write_Str (UTE.File_Name.all);
end if;
Write_Char ('"');
Write_Eol;
end;
end loop;
-- Dump SCO Unit number table if it contains any entries
if SCO_Unit_Number_Table.Last >= 1 then
Write_Eol;
Write_Line ("SCO Unit Number Table");
Write_Line ("---------------------");
for Index in 1 .. SCO_Unit_Number_Table.Last loop
Write_Str (" ");
Write_Int (Int (Index));
Write_Str (". Unit_Number = ");
Write_Int (Int (SCO_Unit_Number_Table.Table (Index)));
Write_Eol;
end loop;
end if;
-- Dump SCO raw-table
Write_Eol;
Write_Line ("SCO Raw Table");
Write_Line ("---------");
if SCO_Generation_State = Filtered then
Write_Line ("Empty (free'd after second pass)");
else
for Index in 1 .. SCO_Raw_Table.Last loop
Dump_Entry (Index, SCO_Raw_Table.Table (Index));
end loop;
end if;
-- Dump SCO table itself
Write_Eol;
Write_Line ("SCO Filtered Table");
Write_Line ("---------");
for Index in 1 .. SCO_Table.Last loop
Dump_Entry (Index, SCO_Table.Table (Index));
end loop;
end dsco;
-----------
-- Equal --
-----------
function Equal (F1 : Source_Ptr; F2 : Source_Ptr) return Boolean is
begin
return F1 = F2;
end Equal;
-------
-- < --
-------
function "<" (S1 : Source_Location; S2 : Source_Location) return Boolean is
begin
return S1.Line < S2.Line
or else (S1.Line = S2.Line and then S1.Col < S2.Col);
end "<";
------------------
-- Has_Decision --
------------------
function Has_Decision (N : Node_Id) return Boolean is
function Check_Node (N : Node_Id) return Traverse_Result;
-- Determine if Nkind (N) indicates the presence of a decision (i.e. N
-- is a logical operator, which is a decision in itself, or an
-- IF-expression whose Condition attribute is a decision).
----------------
-- Check_Node --
----------------
function Check_Node (N : Node_Id) return Traverse_Result is
begin
-- If we are not sure this is a logical operator (AND and OR may be
-- turned into logical operators with the Short_Circuit_And_Or
-- pragma), assume it is. Putative decisions will be discarded if
-- needed in the secord pass.
if Is_Logical_Operator (N) /= False
or else Nkind (N) = N_If_Expression
then
return Abandon;
else
return OK;
end if;
end Check_Node;
function Traverse is new Traverse_Func (Check_Node);
-- Start of processing for Has_Decision
begin
return Traverse (N) = Abandon;
end Has_Decision;
----------
-- Hash --
----------
function Hash (F : Source_Ptr) return Header_Num is
begin
return Header_Num (Nat (F) mod 997);
end Hash;
----------------
-- Initialize --
----------------
procedure Initialize is
begin
SCO_Unit_Number_Table.Init;
-- The SCO_Unit_Number_Table entry with index 0 is intentionally set
-- aside to be used as temporary for sorting.
SCO_Unit_Number_Table.Increment_Last;
end Initialize;
-------------------------
-- Is_Logical_Operator --
-------------------------
function Is_Logical_Operator (N : Node_Id) return Tristate is
begin
if Nkind (N) in N_And_Then | N_Op_Not | N_Or_Else then
return True;
elsif Nkind (N) in N_Op_And | N_Op_Or then
return Unknown;
else
return False;
end if;
end Is_Logical_Operator;
-----------------------
-- Process_Decisions --
-----------------------
-- Version taking a list
procedure Process_Decisions
(L : List_Id;
T : Character;
Pragma_Sloc : Source_Ptr)
is
N : Node_Id;
begin
if L /= No_List then
N := First (L);
while Present (N) loop
Process_Decisions (N, T, Pragma_Sloc);
Next (N);
end loop;
end if;
end Process_Decisions;
-- Version taking a node
Current_Pragma_Sloc : Source_Ptr := No_Location;
-- While processing a pragma, this is set to the sloc of the N_Pragma node
procedure Process_Decisions
(N : Node_Id;
T : Character;
Pragma_Sloc : Source_Ptr)
is
Mark : Nat;
-- This is used to mark the location of a decision sequence in the SCO
-- table. We use it for backing out a simple decision in an expression
-- context that contains only NOT operators.
Mark_Hash : Nat;
-- Likewise for the putative SCO_Raw_Hash_Table entries: see below
type Hash_Entry is record
Sloc : Source_Ptr;
SCO_Index : Nat;
end record;
-- We must register all conditions/pragmas in SCO_Raw_Hash_Table.
-- However we cannot register them in the same time we are adding the
-- corresponding SCO entries to the raw table since we may discard them
-- later on. So instead we put all putative conditions into Hash_Entries
-- (see below) and register them once we are sure we keep them.
--
-- This data structure holds the conditions/pragmas to register in
-- SCO_Raw_Hash_Table.
package Hash_Entries is new Table.Table
(Table_Component_Type => Hash_Entry,
Table_Index_Type => Nat,
Table_Low_Bound => 1,
Table_Initial => 10,
Table_Increment => 10,
Table_Name => "Hash_Entries");
-- Hold temporarily (i.e. free'd before returning) the Hash_Entry before
-- they are registered in SCO_Raw_Hash_Table.
X_Not_Decision : Boolean;
-- This flag keeps track of whether a decision sequence in the SCO table
-- contains only NOT operators, and is for an expression context (T=X).
-- The flag will be set False if T is other than X, or if an operator
-- other than NOT is in the sequence.
procedure Output_Decision_Operand (N : Node_Id);
-- The node N is the top level logical operator of a decision, or it is
-- one of the operands of a logical operator belonging to a single
-- complex decision. This routine outputs the sequence of table entries
-- corresponding to the node. Note that we do not process the sub-
-- operands to look for further decisions, that processing is done in
-- Process_Decision_Operand, because we can't get decisions mixed up in
-- the global table. Call has no effect if N is Empty.
procedure Output_Element (N : Node_Id);
-- Node N is an operand of a logical operator that is not itself a
-- logical operator, or it is a simple decision. This routine outputs
-- the table entry for the element, with C1 set to ' '. Last is set
-- False, and an entry is made in the condition hash table.
procedure Output_Header (T : Character);
-- Outputs a decision header node. T is I/W/E/P for IF/WHILE/EXIT WHEN/
-- PRAGMA, and 'X' for the expression case.
procedure Process_Decision_Operand (N : Node_Id);
-- This is called on node N, the top level node of a decision, or on one
-- of its operands or suboperands after generating the full output for
-- the complex decision. It process the suboperands of the decision
-- looking for nested decisions.
function Process_Node (N : Node_Id) return Traverse_Result;
-- Processes one node in the traversal, looking for logical operators,
-- and if one is found, outputs the appropriate table entries.
-----------------------------
-- Output_Decision_Operand --
-----------------------------
procedure Output_Decision_Operand (N : Node_Id) is
C1 : Character;
C2 : Character;
-- C1 holds a character that identifies the operation while C2
-- indicates whether we are sure (' ') or not ('?') this operation
-- belongs to the decision. '?' entries will be filtered out in the
-- second (SCO_Record_Filtered) pass.
L : Node_Id;
T : Tristate;
begin
if No (N) then
return;
end if;
T := Is_Logical_Operator (N);
-- Logical operator
if T /= False then
if Nkind (N) = N_Op_Not then
C1 := '!';
L := Empty;
else
L := Left_Opnd (N);
if Nkind (N) in N_Op_Or | N_Or_Else then
C1 := '|';
else pragma Assert (Nkind (N) in N_Op_And | N_And_Then);
C1 := '&';
end if;
end if;
if T = True then
C2 := ' ';
else
C2 := '?';
end if;
Set_Raw_Table_Entry
(C1 => C1,
C2 => C2,
From => Sloc (N),
To => No_Location,
Last => False);
Hash_Entries.Append ((Sloc (N), SCO_Raw_Table.Last));
Output_Decision_Operand (L);
Output_Decision_Operand (Right_Opnd (N));
-- Not a logical operator
else
Output_Element (N);
end if;
end Output_Decision_Operand;
--------------------
-- Output_Element --
--------------------
procedure Output_Element (N : Node_Id) is
FSloc : Source_Ptr;
LSloc : Source_Ptr;
begin
Sloc_Range (N, FSloc, LSloc);
Set_Raw_Table_Entry
(C1 => ' ',
C2 => 'c',
From => FSloc,
To => LSloc,
Last => False);
Hash_Entries.Append ((FSloc, SCO_Raw_Table.Last));
end Output_Element;
-------------------
-- Output_Header --
-------------------
procedure Output_Header (T : Character) is
Loc : Source_Ptr := No_Location;
-- Node whose Sloc is used for the decision
Nam : Name_Id := No_Name;
-- For the case of an aspect, aspect name
begin
case T is
when 'I' | 'E' | 'W' | 'a' | 'A' =>
-- For IF, EXIT, WHILE, or aspects, the token SLOC is that of
-- the parent of the expression.
Loc := Sloc (Parent (N));
if T = 'a' or else T = 'A' then
Nam := Chars (Identifier (Parent (N)));
end if;
when 'G' | 'P' =>
-- For entry guard, the token sloc is from the N_Entry_Body.
-- For PRAGMA, we must get the location from the pragma node.
-- Argument N is the pragma argument, and we have to go up
-- two levels (through the pragma argument association) to
-- get to the pragma node itself. For the guard on a select
-- alternative, we do not have access to the token location for
-- the WHEN, so we use the first sloc of the condition itself.
-- First_Sloc gives the most sensible result, but we have to
-- beware of also using it when computing the dominance marker
-- sloc (in the Set_Statement_Entry procedure), as this is not
-- fully equivalent to the "To" sloc computed by
-- Sloc_Range (Guard, To, From).
if Nkind (Parent (N)) in N_Accept_Alternative
| N_Delay_Alternative
| N_Terminate_Alternative
then
Loc := First_Sloc (N);
else
Loc := Sloc (Parent (Parent (N)));
end if;
when 'X' =>
-- For an expression, no Sloc
null;
-- No other possibilities
when others =>
raise Program_Error;
end case;
Set_Raw_Table_Entry
(C1 => T,
C2 => ' ',
From => Loc,
To => No_Location,
Last => False,
Pragma_Sloc => Pragma_Sloc,
Pragma_Aspect_Name => Nam);
-- For an aspect specification, which will be rewritten into a
-- pragma, enter a hash table entry now.
if T = 'a' then
Hash_Entries.Append ((Loc, SCO_Raw_Table.Last));
end if;
end Output_Header;
------------------------------
-- Process_Decision_Operand --
------------------------------
procedure Process_Decision_Operand (N : Node_Id) is
begin
if Is_Logical_Operator (N) /= False then
if Nkind (N) /= N_Op_Not then
Process_Decision_Operand (Left_Opnd (N));
X_Not_Decision := False;
end if;
Process_Decision_Operand (Right_Opnd (N));
else
Process_Decisions (N, 'X', Pragma_Sloc);
end if;
end Process_Decision_Operand;
------------------
-- Process_Node --
------------------
function Process_Node (N : Node_Id) return Traverse_Result is
begin
case Nkind (N) is
-- Logical operators, output table entries and then process
-- operands recursively to deal with nested conditions.
when N_And_Then
| N_Op_And
| N_Op_Not
| N_Op_Or
| N_Or_Else
=>
declare
T : Character;
begin
-- If outer level, then type comes from call, otherwise it
-- is more deeply nested and counts as X for expression.
if N = Process_Decisions.N then
T := Process_Decisions.T;
else
T := 'X';
end if;
-- Output header for sequence
X_Not_Decision := T = 'X' and then Nkind (N) = N_Op_Not;
Mark := SCO_Raw_Table.Last;
Mark_Hash := Hash_Entries.Last;
Output_Header (T);
-- Output the decision
Output_Decision_Operand (N);
-- If the decision was in an expression context (T = 'X')
-- and contained only NOT operators, then we don't output
-- it, so delete it.
if X_Not_Decision then
SCO_Raw_Table.Set_Last (Mark);
Hash_Entries.Set_Last (Mark_Hash);
-- Otherwise, set Last in last table entry to mark end
else
SCO_Raw_Table.Table (SCO_Raw_Table.Last).Last := True;
end if;
-- Process any embedded decisions
Process_Decision_Operand (N);
return Skip;
end;
-- Case expression
-- Really hard to believe this is correct given the special
-- handling for if expressions below ???
when N_Case_Expression =>
return OK; -- ???
-- If expression, processed like an if statement
when N_If_Expression =>
declare
Cond : constant Node_Id := First (Expressions (N));
Thnx : constant Node_Id := Next (Cond);
Elsx : constant Node_Id := Next (Thnx);
begin
Process_Decisions (Cond, 'I', Pragma_Sloc);
Process_Decisions (Thnx, 'X', Pragma_Sloc);
Process_Decisions (Elsx, 'X', Pragma_Sloc);
return Skip;
end;
when N_Quantified_Expression =>
declare
Cond : constant Node_Id := Condition (N);
begin
Process_Decisions (Cond, 'W', Pragma_Sloc);
return Skip;
end;
-- All other cases, continue scan
when others =>
return OK;
end case;
end Process_Node;
procedure Traverse is new Traverse_Proc (Process_Node);
-- Start of processing for Process_Decisions
begin
if No (N) then
return;
end if;
Hash_Entries.Init;
-- See if we have simple decision at outer level and if so then
-- generate the decision entry for this simple decision. A simple
-- decision is a boolean expression (which is not a logical operator
-- or short circuit form) appearing as the operand of an IF, WHILE,
-- EXIT WHEN, or special PRAGMA construct.
if T /= 'X' and then Is_Logical_Operator (N) = False then
Output_Header (T);
Output_Element (N);
-- Change Last in last table entry to True to mark end of
-- sequence, which is this case is only one element long.
SCO_Raw_Table.Table (SCO_Raw_Table.Last).Last := True;
end if;
Traverse (N);
-- Now we have the definitive set of SCO entries, register them in the
-- corresponding hash table.
for J in 1 .. Hash_Entries.Last loop
SCO_Raw_Hash_Table.Set
(Hash_Entries.Table (J).Sloc,
Hash_Entries.Table (J).SCO_Index);
end loop;
Hash_Entries.Free;
end Process_Decisions;
-----------
-- pscos --
-----------
procedure pscos is
procedure Write_Info_Char (C : Character) renames Write_Char;
-- Write one character;
procedure Write_Info_Initiate (Key : Character) renames Write_Char;
-- Start new one and write one character;
procedure Write_Info_Nat (N : Nat);
-- Write value of N
procedure Write_Info_Terminate renames Write_Eol;
-- Terminate current line
--------------------
-- Write_Info_Nat --
--------------------
procedure Write_Info_Nat (N : Nat) is
begin
Write_Int (N);
end Write_Info_Nat;
procedure Debug_Put_SCOs is new Put_SCOs;
-- Start of processing for pscos
begin
Debug_Put_SCOs;
end pscos;
---------------------
-- Record_Instance --
---------------------
procedure Record_Instance (Id : Instance_Id; Inst_Sloc : Source_Ptr) is
Inst_Src : constant Source_File_Index :=
Get_Source_File_Index (Inst_Sloc);
begin
SCO_Instance_Table.Append
((Inst_Dep_Num => Dependency_Num (Unit (Inst_Src)),
Inst_Loc => To_Source_Location (Inst_Sloc),
Enclosing_Instance => SCO_Instance_Index (Instance (Inst_Src))));
pragma Assert
(SCO_Instance_Table.Last = SCO_Instance_Index (Id));
end Record_Instance;
----------------
-- SCO_Output --
----------------
procedure SCO_Output is
procedure Populate_SCO_Instance_Table is
new Sinput.Iterate_On_Instances (Record_Instance);
begin
pragma Assert (SCO_Generation_State = Filtered);
if Debug_Flag_Dot_OO then
dsco;
end if;
Populate_SCO_Instance_Table;
-- Sort the unit tables based on dependency numbers
Unit_Table_Sort : declare
function Lt (Op1 : Natural; Op2 : Natural) return Boolean;
-- Comparison routine for sort call
procedure Move (From : Natural; To : Natural);
-- Move routine for sort call
--------
-- Lt --
--------
function Lt (Op1 : Natural; Op2 : Natural) return Boolean is
begin
return
Dependency_Num
(SCO_Unit_Number_Table.Table (SCO_Unit_Index (Op1)))
<
Dependency_Num
(SCO_Unit_Number_Table.Table (SCO_Unit_Index (Op2)));
end Lt;
----------
-- Move --
----------
procedure Move (From : Natural; To : Natural) is
begin
SCO_Unit_Table.Table (SCO_Unit_Index (To)) :=
SCO_Unit_Table.Table (SCO_Unit_Index (From));
SCO_Unit_Number_Table.Table (SCO_Unit_Index (To)) :=
SCO_Unit_Number_Table.Table (SCO_Unit_Index (From));
end Move;
package Sorting is new GNAT.Heap_Sort_G (Move, Lt);
-- Start of processing for Unit_Table_Sort
begin
Sorting.Sort (Integer (SCO_Unit_Table.Last));
end Unit_Table_Sort;
-- Loop through entries in the unit table to set file name and
-- dependency number entries.
for J in 1 .. SCO_Unit_Table.Last loop
declare
U : constant Unit_Number_Type := SCO_Unit_Number_Table.Table (J);
UTE : SCO_Unit_Table_Entry renames SCO_Unit_Table.Table (J);
begin
Get_Name_String (Reference_Name (Source_Index (U)));
UTE.File_Name := new String'(Name_Buffer (1 .. Name_Len));
UTE.Dep_Num := Dependency_Num (U);
end;
end loop;
-- Now the tables are all setup for output to the ALI file
Write_SCOs_To_ALI_File;
end SCO_Output;
-------------------------
-- SCO_Pragma_Disabled --
-------------------------
function SCO_Pragma_Disabled (Loc : Source_Ptr) return Boolean is
Index : Nat;
begin
if Loc = No_Location then
return False;
end if;
Index := SCO_Raw_Hash_Table.Get (Loc);
-- The test here for zero is to deal with possible previous errors, and
-- for the case of pragma statement SCOs, for which we always set the
-- Pragma_Sloc even if the particular pragma cannot be specifically
-- disabled.
if Index /= 0 then
declare
T : SCO_Table_Entry renames SCO_Raw_Table.Table (Index);
begin
case T.C1 is
when 'S' =>
-- Pragma statement
return T.C2 = 'p';
when 'A' =>
-- Aspect decision (enabled)
return False;
when 'a' =>
-- Aspect decision (not enabled)
return True;
when ASCII.NUL =>
-- Nullified disabled SCO
return True;
when others =>
raise Program_Error;
end case;
end;
else
return False;
end if;
end SCO_Pragma_Disabled;
--------------------
-- SCO_Record_Raw --
--------------------
procedure SCO_Record_Raw (U : Unit_Number_Type) is
procedure Traverse_Aux_Decls (N : Node_Id);
-- Traverse the Aux_Decls_Node of compilation unit N
------------------------
-- Traverse_Aux_Decls --
------------------------
procedure Traverse_Aux_Decls (N : Node_Id) is
ADN : constant Node_Id := Aux_Decls_Node (N);
begin
Traverse_Declarations_Or_Statements (Config_Pragmas (ADN));
Traverse_Declarations_Or_Statements (Pragmas_After (ADN));
-- Declarations and Actions do not correspond to source constructs,
-- they contain only nodes from expansion, so at this point they
-- should still be empty:
pragma Assert (No (Declarations (ADN)));
pragma Assert (No (Actions (ADN)));
end Traverse_Aux_Decls;
-- Local variables
From : Nat;
Lu : Node_Id;
-- Start of processing for SCO_Record_Raw
begin
-- It is legitimate to run this pass multiple times (once per unit) so
-- run it even if it was already run before.
pragma Assert (SCO_Generation_State in None .. Raw);
SCO_Generation_State := Raw;
-- Ignore call if not generating code and generating SCO's
if not (Generate_SCO and then Operating_Mode = Generate_Code) then
return;
end if;
-- Ignore call if this unit already recorded
for J in 1 .. SCO_Unit_Number_Table.Last loop
if U = SCO_Unit_Number_Table.Table (J) then
return;
end if;
end loop;
-- Otherwise record starting entry
From := SCO_Raw_Table.Last + 1;
-- Get Unit (checking case of subunit)
Lu := Unit (Cunit (U));
if Nkind (Lu) = N_Subunit then
Lu := Proper_Body (Lu);
end if;
-- Traverse the unit
Traverse_Aux_Decls (Cunit (U));
case Nkind (Lu) is
when N_Generic_Instantiation
| N_Generic_Package_Declaration
| N_Package_Body
| N_Package_Declaration
| N_Protected_Body
| N_Subprogram_Body
| N_Subprogram_Declaration
| N_Task_Body
=>
Traverse_Declarations_Or_Statements (L => No_List, P => Lu);
-- All other cases of compilation units (e.g. renamings), generate no
-- SCO information.
when others =>
null;
end case;
-- Make entry for new unit in unit tables, we will fill in the file
-- name and dependency numbers later.
SCO_Unit_Table.Append (
(Dep_Num => 0,
File_Name => null,
File_Index => Get_Source_File_Index (Sloc (Lu)),
From => From,
To => SCO_Raw_Table.Last));
SCO_Unit_Number_Table.Append (U);
end SCO_Record_Raw;
-----------------------
-- Set_SCO_Condition --
-----------------------
procedure Set_SCO_Condition (Cond : Node_Id; Val : Boolean) is
-- SCO annotations are not processed after the filtering pass
pragma Assert (not Generate_SCO or else SCO_Generation_State = Raw);
Constant_Condition_Code : constant array (Boolean) of Character :=
(False => 'f', True => 't');
Orig : constant Node_Id := Original_Node (Cond);
Dummy : Source_Ptr;
Index : Nat;
Start : Source_Ptr;
begin
Sloc_Range (Orig, Start, Dummy);
Index := SCO_Raw_Hash_Table.Get (Start);
-- Index can be zero for boolean expressions that do not have SCOs
-- (simple decisions outside of a control flow structure), or in case
-- of a previous error.
if Index = 0 then
return;
else
pragma Assert (SCO_Raw_Table.Table (Index).C1 = ' ');
SCO_Raw_Table.Table (Index).C2 := Constant_Condition_Code (Val);
end if;
end Set_SCO_Condition;
------------------------------
-- Set_SCO_Logical_Operator --
------------------------------
procedure Set_SCO_Logical_Operator (Op : Node_Id) is
-- SCO annotations are not processed after the filtering pass
pragma Assert (not Generate_SCO or else SCO_Generation_State = Raw);
Orig : constant Node_Id := Original_Node (Op);
Orig_Sloc : constant Source_Ptr := Sloc (Orig);
Index : constant Nat := SCO_Raw_Hash_Table.Get (Orig_Sloc);
begin
-- All (putative) logical operators are supposed to have their own entry
-- in the SCOs table. However, the semantic analysis may invoke this
-- subprogram with nodes that are out of the SCO generation scope.
if Index /= 0 then
SCO_Raw_Table.Table (Index).C2 := ' ';
end if;
end Set_SCO_Logical_Operator;
----------------------------
-- Set_SCO_Pragma_Enabled --
----------------------------
procedure Set_SCO_Pragma_Enabled (Loc : Source_Ptr) is
-- SCO annotations are not processed after the filtering pass
pragma Assert (not Generate_SCO or else SCO_Generation_State = Raw);
Index : Nat;
begin
-- Nothing to do if not generating SCO, or if we're not processing the
-- original source occurrence of the pragma.
if not (Generate_SCO
and then In_Extended_Main_Source_Unit (Loc)
and then not (In_Instance or In_Inlined_Body))
then
return;
end if;
-- Note: the reason we use the Sloc value as the key is that in the
-- generic case, the call to this procedure is made on a copy of the
-- original node, so we can't use the Node_Id value.
Index := SCO_Raw_Hash_Table.Get (Loc);
-- A zero index here indicates that semantic analysis found an
-- activated pragma at Loc which does not have a corresponding pragma
-- or aspect at the syntax level. This may occur in legitimate cases
-- because of expanded code (such are Pre/Post conditions generated for
-- formal parameter validity checks), or as a consequence of a previous
-- error.
if Index = 0 then
return;
else
declare
T : SCO_Table_Entry renames SCO_Raw_Table.Table (Index);
begin
-- Note: may be called multiple times for the same sloc, so
-- account for the fact that the entry may already have been
-- marked enabled.
case T.C1 is
-- Aspect (decision SCO)
when 'a' =>
T.C1 := 'A';
when 'A' =>
null;
-- Pragma (statement SCO)
when 'S' =>
pragma Assert (T.C2 = 'p' or else T.C2 = 'P');
T.C2 := 'P';
when others =>
raise Program_Error;
end case;
end;
end if;
end Set_SCO_Pragma_Enabled;
-------------------------
-- Set_Raw_Table_Entry --
-------------------------
procedure Set_Raw_Table_Entry
(C1 : Character;
C2 : Character;
From : Source_Ptr;
To : Source_Ptr;
Last : Boolean;
Pragma_Sloc : Source_Ptr := No_Location;
Pragma_Aspect_Name : Name_Id := No_Name)
is
pragma Assert (SCO_Generation_State = Raw);
begin
SCO_Raw_Table.Append
((C1 => C1,
C2 => C2,
From => To_Source_Location (From),
To => To_Source_Location (To),
Last => Last,
Pragma_Sloc => Pragma_Sloc,
Pragma_Aspect_Name => Pragma_Aspect_Name));
end Set_Raw_Table_Entry;
------------------------
-- To_Source_Location --
------------------------
function To_Source_Location (S : Source_Ptr) return Source_Location is
begin
if S = No_Location then
return No_Source_Location;
else
return
(Line => Get_Logical_Line_Number (S),
Col => Get_Column_Number (S));
end if;
end To_Source_Location;
-----------------------------------------
-- Traverse_Declarations_Or_Statements --
-----------------------------------------
-- Tables used by Traverse_Declarations_Or_Statements for temporarily
-- holding statement and decision entries. These are declared globally
-- since they are shared by recursive calls to this procedure.
type SC_Entry is record
N : Node_Id;
From : Source_Ptr;
To : Source_Ptr;
Typ : Character;
end record;
-- Used to store a single entry in the following table, From:To represents
-- the range of entries in the CS line entry, and typ is the type, with
-- space meaning that no type letter will accompany the entry.
package SC is new Table.Table
(Table_Component_Type => SC_Entry,
Table_Index_Type => Nat,
Table_Low_Bound => 1,
Table_Initial => 1000,
Table_Increment => 200,
Table_Name => "SCO_SC");
-- Used to store statement components for a CS entry to be output as a
-- result of the call to this procedure. SC.Last is the last entry stored,
-- so the current statement sequence is represented by SC_Array (SC_First
-- .. SC.Last), where SC_First is saved on entry to each recursive call to
-- the routine.
--
-- Extend_Statement_Sequence adds an entry to this array, and then
-- Set_Statement_Entry clears the entries starting with SC_First, copying
-- these entries to the main SCO output table. The reason that we do the
-- temporary caching of results in this array is that we want the SCO table
-- entries for a given CS line to be contiguous, and the processing may
-- output intermediate entries such as decision entries.
type SD_Entry is record
Nod : Node_Id;
Lst : List_Id;
Typ : Character;
Plo : Source_Ptr;
end record;
-- Used to store a single entry in the following table. Nod is the node to
-- be searched for decisions for the case of Process_Decisions_Defer with a
-- node argument (with Lst set to No_List. Lst is the list to be searched
-- for decisions for the case of Process_Decisions_Defer with a List
-- argument (in which case Nod is set to Empty). Plo is the sloc of the
-- enclosing pragma, if any.
package SD is new Table.Table
(Table_Component_Type => SD_Entry,
Table_Index_Type => Nat,
Table_Low_Bound => 1,
Table_Initial => 1000,
Table_Increment => 200,
Table_Name => "SCO_SD");
-- Used to store possible decision information. Instead of calling the
-- Process_Decisions procedures directly, we call Process_Decisions_Defer,
-- which simply stores the arguments in this table. Then when we clear
-- out a statement sequence using Set_Statement_Entry, after generating
-- the CS lines for the statements, the entries in this table result in
-- calls to Process_Decision. The reason for doing things this way is to
-- ensure that decisions are output after the CS line for the statements
-- in which the decisions occur.
procedure Traverse_Declarations_Or_Statements
(L : List_Id;
D : Dominant_Info := No_Dominant;
P : Node_Id := Empty)
is
Discard_Dom : Dominant_Info;
pragma Warnings (Off, Discard_Dom);
begin
Discard_Dom := Traverse_Declarations_Or_Statements (L, D, P);
end Traverse_Declarations_Or_Statements;
function Traverse_Declarations_Or_Statements
(L : List_Id;
D : Dominant_Info := No_Dominant;
P : Node_Id := Empty) return Dominant_Info
is
Current_Dominant : Dominant_Info := D;
-- Dominance information for the current basic block
Current_Test : Node_Id;
-- Conditional node (N_If_Statement or N_Elsif being processed)
N : Node_Id;
SC_First : constant Nat := SC.Last + 1;
SD_First : constant Nat := SD.Last + 1;
-- Record first entries used in SC/SD at this recursive level
procedure Extend_Statement_Sequence (N : Node_Id; Typ : Character);
-- Extend the current statement sequence to encompass the node N. Typ is
-- the letter that identifies the type of statement/declaration that is
-- being added to the sequence.
procedure Process_Decisions_Defer (N : Node_Id; T : Character);
pragma Inline (Process_Decisions_Defer);
-- This routine is logically the same as Process_Decisions, except that
-- the arguments are saved in the SD table for later processing when
-- Set_Statement_Entry is called, which goes through the saved entries
-- making the corresponding calls to Process_Decision. Note: the
-- enclosing statement must have already been added to the current
-- statement sequence, so that nested decisions are properly
-- identified as such.
procedure Process_Decisions_Defer (L : List_Id; T : Character);
pragma Inline (Process_Decisions_Defer);
-- Same case for list arguments, deferred call to Process_Decisions
procedure Set_Statement_Entry;
-- Output CS entries for all statements saved in table SC, and end the
-- current CS sequence. Then output entries for all decisions nested in
-- these statements, which have been deferred so far.
procedure Traverse_One (N : Node_Id);
-- Traverse one declaration or statement
procedure Traverse_Aspects (N : Node_Id);
-- Helper for Traverse_One: traverse N's aspect specifications
procedure Traverse_Degenerate_Subprogram (N : Node_Id);
-- Common code to handle null procedures and expression functions. Emit
-- a SCO of the given Kind and N outside of the dominance flow.
-------------------------------
-- Extend_Statement_Sequence --
-------------------------------
procedure Extend_Statement_Sequence (N : Node_Id; Typ : Character) is
Dummy : Source_Ptr;
F : Source_Ptr;
T : Source_Ptr;
To_Node : Node_Id := Empty;
begin
Sloc_Range (N, F, T);
case Nkind (N) is
when N_Accept_Statement =>
if Present (Parameter_Specifications (N)) then
To_Node := Last (Parameter_Specifications (N));
elsif Present (Entry_Index (N)) then
To_Node := Entry_Index (N);
else
To_Node := Entry_Direct_Name (N);
end if;
when N_Case_Statement =>
To_Node := Expression (N);
when N_Elsif_Part
| N_If_Statement
=>
To_Node := Condition (N);
when N_Extended_Return_Statement =>
To_Node := Last (Return_Object_Declarations (N));
when N_Loop_Statement =>
To_Node := Iteration_Scheme (N);
when N_Asynchronous_Select
| N_Conditional_Entry_Call
| N_Selective_Accept
| N_Single_Protected_Declaration
| N_Single_Task_Declaration
| N_Timed_Entry_Call
=>
T := F;
when N_Protected_Type_Declaration
| N_Task_Type_Declaration
=>
if Has_Aspects (N) then
To_Node := Last (Aspect_Specifications (N));
elsif Present (Discriminant_Specifications (N)) then
To_Node := Last (Discriminant_Specifications (N));
else
To_Node := Defining_Identifier (N);
end if;
when N_Subexpr =>
To_Node := N;
when others =>
null;
end case;
if Present (To_Node) then
Sloc_Range (To_Node, Dummy, T);
end if;
SC.Append ((N, F, T, Typ));
end Extend_Statement_Sequence;
-----------------------------
-- Process_Decisions_Defer --
-----------------------------
procedure Process_Decisions_Defer (N : Node_Id; T : Character) is
begin
SD.Append ((N, No_List, T, Current_Pragma_Sloc));
end Process_Decisions_Defer;
procedure Process_Decisions_Defer (L : List_Id; T : Character) is
begin
SD.Append ((Empty, L, T, Current_Pragma_Sloc));
end Process_Decisions_Defer;
-------------------------
-- Set_Statement_Entry --
-------------------------
procedure Set_Statement_Entry is
SC_Last : constant Int := SC.Last;
SD_Last : constant Int := SD.Last;
begin
-- Output statement entries from saved entries in SC table
for J in SC_First .. SC_Last loop
if J = SC_First then
if Current_Dominant /= No_Dominant then
declare
From : Source_Ptr;
To : Source_Ptr;
begin
Sloc_Range (Current_Dominant.N, From, To);
if Current_Dominant.K /= 'E' then
To := No_Location;
end if;
-- Be consistent with the location determined in
-- Output_Header.
if Current_Dominant.K = 'T'
and then Nkind (Parent (Current_Dominant.N))
in N_Accept_Alternative
| N_Delay_Alternative
| N_Terminate_Alternative
then
From := First_Sloc (Current_Dominant.N);
end if;
Set_Raw_Table_Entry
(C1 => '>',
C2 => Current_Dominant.K,
From => From,
To => To,
Last => False,
Pragma_Sloc => No_Location,
Pragma_Aspect_Name => No_Name);
end;
end if;
end if;
declare
SCE : SC_Entry renames SC.Table (J);
Pragma_Sloc : Source_Ptr := No_Location;
Pragma_Aspect_Name : Name_Id := No_Name;
begin
-- For the case of a statement SCO for a pragma controlled by
-- Set_SCO_Pragma_Enabled, set Pragma_Sloc so that the SCO (and
-- those of any nested decision) is emitted only if the pragma
-- is enabled.
if SCE.Typ = 'p' then
Pragma_Sloc := SCE.From;
SCO_Raw_Hash_Table.Set
(Pragma_Sloc, SCO_Raw_Table.Last + 1);
Pragma_Aspect_Name := Pragma_Name_Unmapped (SCE.N);
pragma Assert (Pragma_Aspect_Name /= No_Name);
elsif SCE.Typ = 'P' then
Pragma_Aspect_Name := Pragma_Name_Unmapped (SCE.N);
pragma Assert (Pragma_Aspect_Name /= No_Name);
end if;
Set_Raw_Table_Entry
(C1 => 'S',
C2 => SCE.Typ,
From => SCE.From,
To => SCE.To,
Last => (J = SC_Last),
Pragma_Sloc => Pragma_Sloc,
Pragma_Aspect_Name => Pragma_Aspect_Name);
end;
end loop;
-- Last statement of basic block, if present, becomes new current
-- dominant.
if SC_Last >= SC_First then
Current_Dominant := ('S', SC.Table (SC_Last).N);
end if;
-- Clear out used section of SC table
SC.Set_Last (SC_First - 1);
-- Output any embedded decisions
for J in SD_First .. SD_Last loop
declare
SDE : SD_Entry renames SD.Table (J);
begin
if Present (SDE.Nod) then
Process_Decisions (SDE.Nod, SDE.Typ, SDE.Plo);
else
Process_Decisions (SDE.Lst, SDE.Typ, SDE.Plo);
end if;
end;
end loop;
-- Clear out used section of SD table
SD.Set_Last (SD_First - 1);
end Set_Statement_Entry;
----------------------
-- Traverse_Aspects --
----------------------
procedure Traverse_Aspects (N : Node_Id) is
AE : Node_Id;
AN : Node_Id;
C1 : Character;
begin
AN := First (Aspect_Specifications (N));
while Present (AN) loop
AE := Expression (AN);
-- SCOs are generated before semantic analysis/expansion:
-- PPCs are not split yet.
pragma Assert (not Split_PPC (AN));
C1 := ASCII.NUL;
case Get_Aspect_Id (AN) is
-- Aspects rewritten into pragmas controlled by a Check_Policy:
-- Current_Pragma_Sloc must be set to the sloc of the aspect
-- specification. The corresponding pragma will have the same
-- sloc. Note that Invariant, Pre, and Post will be enabled if
-- the policy is Check; on the other hand, predicate aspects
-- will be enabled for Check and Ignore (when Add_Predicate
-- is called) because the actual checks occur in client units.
-- When the assertion policy for Predicate is Disable, the
-- SCO remains disabled, because Add_Predicate is never called.
-- Pre/post can have checks in client units too because of
-- inheritance, so should they receive the same treatment???
when Aspect_Dynamic_Predicate
| Aspect_Invariant
| Aspect_Post
| Aspect_Postcondition
| Aspect_Pre
| Aspect_Precondition
| Aspect_Predicate
| Aspect_Static_Predicate
| Aspect_Type_Invariant
=>
C1 := 'a';
-- Other aspects: just process any decision nested in the
-- aspect expression.
when others =>
if Has_Decision (AE) then
C1 := 'X';
end if;
end case;
if C1 /= ASCII.NUL then
pragma Assert (Current_Pragma_Sloc = No_Location);
if C1 = 'a' or else C1 = 'A' then
Current_Pragma_Sloc := Sloc (AN);
end if;
Process_Decisions_Defer (AE, C1);
Current_Pragma_Sloc := No_Location;
end if;
Next (AN);
end loop;
end Traverse_Aspects;
------------------------------------
-- Traverse_Degenerate_Subprogram --
------------------------------------
procedure Traverse_Degenerate_Subprogram (N : Node_Id) is
begin
-- Complete current sequence of statements
Set_Statement_Entry;
declare
Saved_Dominant : constant Dominant_Info := Current_Dominant;
-- Save last statement in current sequence as dominant
begin
-- Output statement SCO for degenerate subprogram body (null
-- statement or freestanding expression) outside of the dominance
-- chain.
Current_Dominant := No_Dominant;
Extend_Statement_Sequence (N, Typ => 'X');
-- For the case of an expression-function, collect decisions
-- embedded in the expression now.
if Nkind (N) in N_Subexpr then
Process_Decisions_Defer (N, 'X');
end if;
Set_Statement_Entry;
-- Restore current dominant information designating last statement
-- in previous sequence (i.e. make the dominance chain skip over
-- the degenerate body).
Current_Dominant := Saved_Dominant;
end;
end Traverse_Degenerate_Subprogram;
------------------
-- Traverse_One --
------------------
procedure Traverse_One (N : Node_Id) is
begin
-- Initialize or extend current statement sequence. Note that for
-- special cases such as IF and Case statements we will modify
-- the range to exclude internal statements that should not be
-- counted as part of the current statement sequence.
case Nkind (N) is
-- Package declaration
when N_Package_Declaration =>
Set_Statement_Entry;
Traverse_Package_Declaration (N, Current_Dominant);
-- Generic package declaration
when N_Generic_Package_Declaration =>
Set_Statement_Entry;
Traverse_Generic_Package_Declaration (N);
-- Package body
when N_Package_Body =>
Set_Statement_Entry;
Traverse_Package_Body (N);
-- Subprogram declaration or subprogram body stub
when N_Expression_Function
| N_Subprogram_Body_Stub
| N_Subprogram_Declaration
=>
declare
Spec : constant Node_Id := Specification (N);
begin
Process_Decisions_Defer
(Parameter_Specifications (Spec), 'X');
-- Case of a null procedure: generate SCO for fictitious
-- NULL statement located at the NULL keyword in the
-- procedure specification.
if Nkind (N) = N_Subprogram_Declaration
and then Nkind (Spec) = N_Procedure_Specification
and then Null_Present (Spec)
then
Traverse_Degenerate_Subprogram (Null_Statement (Spec));
-- Case of an expression function: generate a statement SCO
-- for the expression (and then decision SCOs for any nested
-- decisions).
elsif Nkind (N) = N_Expression_Function then
Traverse_Degenerate_Subprogram (Expression (N));
end if;
end;
-- Entry declaration
when N_Entry_Declaration =>
Process_Decisions_Defer (Parameter_Specifications (N), 'X');
-- Generic subprogram declaration
when N_Generic_Subprogram_Declaration =>
Process_Decisions_Defer
(Generic_Formal_Declarations (N), 'X');
Process_Decisions_Defer
(Parameter_Specifications (Specification (N)), 'X');
-- Task or subprogram body
when N_Subprogram_Body
| N_Task_Body
=>
Set_Statement_Entry;
Traverse_Subprogram_Or_Task_Body (N);
-- Entry body
when N_Entry_Body =>
declare
Cond : constant Node_Id :=
Condition (Entry_Body_Formal_Part (N));
Inner_Dominant : Dominant_Info := No_Dominant;
begin
Set_Statement_Entry;
if Present (Cond) then
Process_Decisions_Defer (Cond, 'G');
-- For an entry body with a barrier, the entry body
-- is dominated by a True evaluation of the barrier.
Inner_Dominant := ('T', N);
end if;
Traverse_Subprogram_Or_Task_Body (N, Inner_Dominant);
end;
-- Protected body
when N_Protected_Body =>
Set_Statement_Entry;
Traverse_Declarations_Or_Statements (Declarations (N));
-- Exit statement, which is an exit statement in the SCO sense,
-- so it is included in the current statement sequence, but
-- then it terminates this sequence. We also have to process
-- any decisions in the exit statement expression.
when N_Exit_Statement =>
Extend_Statement_Sequence (N, 'E');
Process_Decisions_Defer (Condition (N), 'E');
Set_Statement_Entry;
-- If condition is present, then following statement is
-- only executed if the condition evaluates to False.
if Present (Condition (N)) then
Current_Dominant := ('F', N);
else
Current_Dominant := No_Dominant;
end if;
-- Label, which breaks the current statement sequence, but the
-- label itself is not included in the next statement sequence,
-- since it generates no code.
when N_Label =>
Set_Statement_Entry;
Current_Dominant := No_Dominant;
-- Block statement, which breaks the current statement sequence
when N_Block_Statement =>
Set_Statement_Entry;
-- The first statement in the handled sequence of statements
-- is dominated by the elaboration of the last declaration.
Current_Dominant := Traverse_Declarations_Or_Statements
(L => Declarations (N),
D => Current_Dominant);
Traverse_Handled_Statement_Sequence
(N => Handled_Statement_Sequence (N),
D => Current_Dominant);
-- If statement, which breaks the current statement sequence,
-- but we include the condition in the current sequence.
when N_If_Statement =>
Current_Test := N;
Extend_Statement_Sequence (N, 'I');
Process_Decisions_Defer (Condition (N), 'I');
Set_Statement_Entry;
-- Now we traverse the statements in the THEN part
Traverse_Declarations_Or_Statements
(L => Then_Statements (N),
D => ('T', N));
-- Loop through ELSIF parts if present
if Present (Elsif_Parts (N)) then
declare
Saved_Dominant : constant Dominant_Info :=
Current_Dominant;
Elif : Node_Id := First (Elsif_Parts (N));
begin
while Present (Elif) loop
-- An Elsif is executed only if the previous test
-- got a FALSE outcome.
Current_Dominant := ('F', Current_Test);
-- Now update current test information
Current_Test := Elif;
-- We generate a statement sequence for the
-- construct "ELSIF condition", so that we have
-- a statement for the resulting decisions.
Extend_Statement_Sequence (Elif, 'I');
Process_Decisions_Defer (Condition (Elif), 'I');
Set_Statement_Entry;
-- An ELSIF part is never guaranteed to have
-- been executed, following statements are only
-- dominated by the initial IF statement.
Current_Dominant := Saved_Dominant;
-- Traverse the statements in the ELSIF
Traverse_Declarations_Or_Statements
(L => Then_Statements (Elif),
D => ('T', Elif));
Next (Elif);
end loop;
end;
end if;
-- Finally traverse the ELSE statements if present
Traverse_Declarations_Or_Statements
(L => Else_Statements (N),
D => ('F', Current_Test));
-- CASE statement, which breaks the current statement sequence,
-- but we include the expression in the current sequence.
when N_Case_Statement =>
Extend_Statement_Sequence (N, 'C');
Process_Decisions_Defer (Expression (N), 'X');
Set_Statement_Entry;
-- Process case branches, all of which are dominated by the
-- CASE statement.
declare
Alt : Node_Id;
begin
Alt := First_Non_Pragma (Alternatives (N));
while Present (Alt) loop
Traverse_Declarations_Or_Statements
(L => Statements (Alt),
D => Current_Dominant);
Next (Alt);
end loop;
end;
-- ACCEPT statement
when N_Accept_Statement =>
Extend_Statement_Sequence (N, 'A');
Set_Statement_Entry;
-- Process sequence of statements, dominant is the ACCEPT
-- statement.
Traverse_Handled_Statement_Sequence
(N => Handled_Statement_Sequence (N),
D => Current_Dominant);
-- SELECT
when N_Selective_Accept =>
Extend_Statement_Sequence (N, 'S');
Set_Statement_Entry;
-- Process alternatives
declare
Alt : Node_Id;
Guard : Node_Id;
S_Dom : Dominant_Info;
begin
Alt := First (Select_Alternatives (N));
while Present (Alt) loop
S_Dom := Current_Dominant;
Guard := Condition (Alt);
if Present (Guard) then
Process_Decisions
(Guard,
'G',
Pragma_Sloc => No_Location);
Current_Dominant := ('T', Guard);
end if;
Traverse_One (Alt);
Current_Dominant := S_Dom;
Next (Alt);
end loop;
end;
Traverse_Declarations_Or_Statements
(L => Else_Statements (N),
D => Current_Dominant);
when N_Conditional_Entry_Call
| N_Timed_Entry_Call
=>
Extend_Statement_Sequence (N, 'S');
Set_Statement_Entry;
-- Process alternatives
Traverse_One (Entry_Call_Alternative (N));
if Nkind (N) = N_Timed_Entry_Call then
Traverse_One (Delay_Alternative (N));
else
Traverse_Declarations_Or_Statements
(L => Else_Statements (N),
D => Current_Dominant);
end if;
when N_Asynchronous_Select =>
Extend_Statement_Sequence (N, 'S');
Set_Statement_Entry;
Traverse_One (Triggering_Alternative (N));
Traverse_Declarations_Or_Statements
(L => Statements (Abortable_Part (N)),
D => Current_Dominant);
when N_Accept_Alternative =>
Traverse_Declarations_Or_Statements
(L => Statements (N),
D => Current_Dominant,
P => Accept_Statement (N));
when N_Entry_Call_Alternative =>
Traverse_Declarations_Or_Statements
(L => Statements (N),
D => Current_Dominant,
P => Entry_Call_Statement (N));
when N_Delay_Alternative =>
Traverse_Declarations_Or_Statements
(L => Statements (N),
D => Current_Dominant,
P => Delay_Statement (N));
when N_Triggering_Alternative =>
Traverse_Declarations_Or_Statements
(L => Statements (N),
D => Current_Dominant,
P => Triggering_Statement (N));
when N_Terminate_Alternative =>
-- It is dubious to emit a statement SCO for a TERMINATE
-- alternative, since no code is actually executed if the
-- alternative is selected -- the tasking runtime call just
-- never returns???
Extend_Statement_Sequence (N, ' ');
Set_Statement_Entry;
-- Unconditional exit points, which are included in the current
-- statement sequence, but then terminate it
when N_Goto_Statement
| N_Raise_Statement
| N_Requeue_Statement
=>
Extend_Statement_Sequence (N, ' ');
Set_Statement_Entry;
Current_Dominant := No_Dominant;
-- Simple return statement. which is an exit point, but we
-- have to process the return expression for decisions.
when N_Simple_Return_Statement =>
Extend_Statement_Sequence (N, ' ');
Process_Decisions_Defer (Expression (N), 'X');
Set_Statement_Entry;
Current_Dominant := No_Dominant;
-- Extended return statement
when N_Extended_Return_Statement =>
Extend_Statement_Sequence (N, 'R');
Process_Decisions_Defer (Return_Object_Declarations (N), 'X');
Set_Statement_Entry;
Traverse_Handled_Statement_Sequence
(N => Handled_Statement_Sequence (N),
D => Current_Dominant);
Current_Dominant := No_Dominant;
-- Loop ends the current statement sequence, but we include
-- the iteration scheme if present in the current sequence.
-- But the body of the loop starts a new sequence, since it
-- may not be executed as part of the current sequence.
when N_Loop_Statement =>
declare
ISC : constant Node_Id := Iteration_Scheme (N);
Inner_Dominant : Dominant_Info := No_Dominant;
begin
if Present (ISC) then
-- If iteration scheme present, extend the current
-- statement sequence to include the iteration scheme
-- and process any decisions it contains.
-- While loop
if Present (Condition (ISC)) then
Extend_Statement_Sequence (N, 'W');
Process_Decisions_Defer (Condition (ISC), 'W');
-- Set more specific dominant for inner statements
-- (the control sloc for the decision is that of
-- the WHILE token).
Inner_Dominant := ('T', ISC);
-- For loop
else
Extend_Statement_Sequence (N, 'F');
Process_Decisions_Defer
(Loop_Parameter_Specification (ISC), 'X');
end if;
end if;
Set_Statement_Entry;
if Inner_Dominant = No_Dominant then
Inner_Dominant := Current_Dominant;
end if;
Traverse_Declarations_Or_Statements
(L => Statements (N),
D => Inner_Dominant);
end;
-- Pragma
when N_Pragma =>
-- Record sloc of pragma (pragmas don't nest)
pragma Assert (Current_Pragma_Sloc = No_Location);
Current_Pragma_Sloc := Sloc (N);
-- Processing depends on the kind of pragma
declare
Nam : constant Name_Id := Pragma_Name_Unmapped (N);
Arg : Node_Id :=
First (Pragma_Argument_Associations (N));
Typ : Character;
begin
case Nam is
when Name_Assert
| Name_Assert_And_Cut
| Name_Assume
| Name_Check
| Name_Loop_Invariant
| Name_Postcondition
| Name_Precondition
| Name_Type_Invariant
| Name_Invariant
=>
-- For Assert/Check/Precondition/Postcondition, we
-- must generate a P entry for the decision. Note
-- that this is done unconditionally at this stage.
-- Output for disabled pragmas is suppressed later
-- on when we output the decision line in Put_SCOs,
-- depending on setting by Set_SCO_Pragma_Enabled.
if Nam = Name_Check
or else Nam = Name_Type_Invariant
or else Nam = Name_Invariant
then
Next (Arg);
end if;
Process_Decisions_Defer (Expression (Arg), 'P');
Typ := 'p';
-- Pre/postconditions can be inherited so SCO should
-- never be deactivated???
when Name_Debug =>
if Present (Arg) and then Present (Next (Arg)) then
-- Case of a dyadic pragma Debug: first argument
-- is a P decision, any nested decision in the
-- second argument is an X decision.
Process_Decisions_Defer (Expression (Arg), 'P');
Next (Arg);
end if;
Process_Decisions_Defer (Expression (Arg), 'X');
Typ := 'p';
-- For all other pragmas, we generate decision entries
-- for any embedded expressions, and the pragma is
-- never disabled.
-- Should generate P decisions (not X) for assertion
-- related pragmas: [{Static,Dynamic}_]Predicate???
when others =>
Process_Decisions_Defer (N, 'X');
Typ := 'P';
end case;
-- Add statement SCO
Extend_Statement_Sequence (N, Typ);
Current_Pragma_Sloc := No_Location;
end;
-- Object declaration. Ignored if Prev_Ids is set, since the
-- parser generates multiple instances of the whole declaration
-- if there is more than one identifier declared, and we only
-- want one entry in the SCOs, so we take the first, for which
-- Prev_Ids is False.
when N_Number_Declaration
| N_Object_Declaration
=>
if not Prev_Ids (N) then
Extend_Statement_Sequence (N, 'o');
if Has_Decision (N) then
Process_Decisions_Defer (N, 'X');
end if;
end if;
-- All other cases, which extend the current statement sequence
-- but do not terminate it, even if they have nested decisions.
when N_Protected_Type_Declaration
| N_Task_Type_Declaration
=>
Extend_Statement_Sequence (N, 't');
Process_Decisions_Defer (Discriminant_Specifications (N), 'X');
Set_Statement_Entry;
Traverse_Protected_Or_Task_Definition (N);
when N_Single_Protected_Declaration
| N_Single_Task_Declaration
=>
Extend_Statement_Sequence (N, 'o');
Set_Statement_Entry;
Traverse_Protected_Or_Task_Definition (N);
when others =>
-- Determine required type character code, or ASCII.NUL if
-- no SCO should be generated for this node.
declare
NK : constant Node_Kind := Nkind (N);
Typ : Character;
begin
case NK is
when N_Full_Type_Declaration
| N_Incomplete_Type_Declaration
| N_Private_Extension_Declaration
| N_Private_Type_Declaration
=>
Typ := 't';
when N_Subtype_Declaration =>
Typ := 's';
when N_Renaming_Declaration =>
Typ := 'r';
when N_Generic_Instantiation =>
Typ := 'i';
when N_Package_Body_Stub
| N_Protected_Body_Stub
| N_Representation_Clause
| N_Task_Body_Stub
| N_Use_Package_Clause
| N_Use_Type_Clause
=>
Typ := ASCII.NUL;
when N_Procedure_Call_Statement =>
Typ := ' ';
when others =>
if NK in N_Statement_Other_Than_Procedure_Call then
Typ := ' ';
else
Typ := 'd';
end if;
end case;
if Typ /= ASCII.NUL then
Extend_Statement_Sequence (N, Typ);
end if;
end;
-- Process any embedded decisions
if Has_Decision (N) then
Process_Decisions_Defer (N, 'X');
end if;
end case;
-- Process aspects if present
Traverse_Aspects (N);
end Traverse_One;
-- Start of processing for Traverse_Declarations_Or_Statements
begin
-- Process single prefixed node
if Present (P) then
Traverse_One (P);
end if;
-- Loop through statements or declarations
N := First (L);
while Present (N) loop
-- Note: For separate bodies, we see the tree after Par.Labl has
-- introduced implicit labels, so we need to ignore those nodes.
if Nkind (N) /= N_Implicit_Label_Declaration then
Traverse_One (N);
end if;
Next (N);
end loop;
-- End sequence of statements and flush deferred decisions
if Present (P) or else Is_Non_Empty_List (L) then
Set_Statement_Entry;
end if;
return Current_Dominant;
end Traverse_Declarations_Or_Statements;
------------------------------------------
-- Traverse_Generic_Package_Declaration --
------------------------------------------
procedure Traverse_Generic_Package_Declaration (N : Node_Id) is
begin
Process_Decisions (Generic_Formal_Declarations (N), 'X', No_Location);
Traverse_Package_Declaration (N);
end Traverse_Generic_Package_Declaration;
-----------------------------------------
-- Traverse_Handled_Statement_Sequence --
-----------------------------------------
procedure Traverse_Handled_Statement_Sequence
(N : Node_Id;
D : Dominant_Info := No_Dominant)
is
Handler : Node_Id;
begin
-- For package bodies without a statement part, the parser adds an empty
-- one, to normalize the representation. The null statement therein,
-- which does not come from source, does not get a SCO.
if Present (N) and then Comes_From_Source (N) then
Traverse_Declarations_Or_Statements (Statements (N), D);
if Present (Exception_Handlers (N)) then
Handler := First_Non_Pragma (Exception_Handlers (N));
while Present (Handler) loop
Traverse_Declarations_Or_Statements
(L => Statements (Handler),
D => ('E', Handler));
Next (Handler);
end loop;
end if;
end if;
end Traverse_Handled_Statement_Sequence;
---------------------------
-- Traverse_Package_Body --
---------------------------
procedure Traverse_Package_Body (N : Node_Id) is
Dom : Dominant_Info;
begin
-- The first statement in the handled sequence of statements is
-- dominated by the elaboration of the last declaration.
Dom := Traverse_Declarations_Or_Statements (Declarations (N));
Traverse_Handled_Statement_Sequence
(Handled_Statement_Sequence (N), Dom);
end Traverse_Package_Body;
----------------------------------
-- Traverse_Package_Declaration --
----------------------------------
procedure Traverse_Package_Declaration
(N : Node_Id;
D : Dominant_Info := No_Dominant)
is
Spec : constant Node_Id := Specification (N);
Dom : Dominant_Info;
begin
Dom :=
Traverse_Declarations_Or_Statements (Visible_Declarations (Spec), D);
-- First private declaration is dominated by last visible declaration
Traverse_Declarations_Or_Statements (Private_Declarations (Spec), Dom);
end Traverse_Package_Declaration;
-------------------------------------------
-- Traverse_Protected_Or_Task_Definition --
-------------------------------------------
procedure Traverse_Protected_Or_Task_Definition (N : Node_Id) is
Dom_Info : Dominant_Info := ('S', N);
-- The first declaration is dominated by the protected or task [type]
-- declaration.
Sync_Def : Node_Id;
-- N's protected or task definition
Priv_Decl : List_Id;
Vis_Decl : List_Id;
-- Sync_Def's Visible_Declarations and Private_Declarations
begin
case Nkind (N) is
when N_Protected_Type_Declaration
| N_Single_Protected_Declaration
=>
Sync_Def := Protected_Definition (N);
when N_Single_Task_Declaration
| N_Task_Type_Declaration
=>
Sync_Def := Task_Definition (N);
when others =>
raise Program_Error;
end case;
-- Sync_Def may be Empty at least for empty Task_Type_Declarations.
-- Querying Visible or Private_Declarations is invalid in this case.
if Present (Sync_Def) then
Vis_Decl := Visible_Declarations (Sync_Def);
Priv_Decl := Private_Declarations (Sync_Def);
else
Vis_Decl := No_List;
Priv_Decl := No_List;
end if;
Dom_Info := Traverse_Declarations_Or_Statements
(L => Vis_Decl,
D => Dom_Info);
-- If visible declarations are present, the first private declaration
-- is dominated by the last visible declaration.
Traverse_Declarations_Or_Statements
(L => Priv_Decl,
D => Dom_Info);
end Traverse_Protected_Or_Task_Definition;
--------------------------------------
-- Traverse_Subprogram_Or_Task_Body --
--------------------------------------
procedure Traverse_Subprogram_Or_Task_Body
(N : Node_Id;
D : Dominant_Info := No_Dominant)
is
Decls : constant List_Id := Declarations (N);
Dom_Info : Dominant_Info := D;
begin
-- If declarations are present, the first statement is dominated by the
-- last declaration.
Dom_Info := Traverse_Declarations_Or_Statements
(L => Decls, D => Dom_Info);
Traverse_Handled_Statement_Sequence
(N => Handled_Statement_Sequence (N),
D => Dom_Info);
end Traverse_Subprogram_Or_Task_Body;
-------------------------
-- SCO_Record_Filtered --
-------------------------
procedure SCO_Record_Filtered is
type Decision is record
Kind : Character;
-- Type of the SCO decision (see comments for SCO_Table_Entry.C1)
Sloc : Source_Location;
Top : Nat;
-- Index in the SCO_Raw_Table for the root operator/condition for the
-- expression that controls the decision.
end record;
-- Decision descriptor: used to gather information about a candidate
-- SCO decision.
package Pending_Decisions is new Table.Table
(Table_Component_Type => Decision,
Table_Index_Type => Nat,
Table_Low_Bound => 1,
Table_Initial => 1000,
Table_Increment => 200,
Table_Name => "Filter_Pending_Decisions");
-- Table used to hold decisions to process during the collection pass
procedure Add_Expression_Tree (Idx : in out Nat);
-- Add SCO raw table entries for the decision controlling expression
-- tree starting at Idx to the filtered SCO table.
procedure Collect_Decisions
(D : Decision;
Next : out Nat);
-- Collect decisions to add to the filtered SCO table starting at the
-- D decision (including it and its nested operators/conditions). Set
-- Next to the first node index passed the whole decision.
procedure Compute_Range
(Idx : in out Nat;
From : out Source_Location;
To : out Source_Location);
-- Compute the source location range for the expression tree starting at
-- Idx in the SCO raw table. Store its bounds in From and To.
function Is_Decision (Idx : Nat) return Boolean;
-- Return if the expression tree starting at Idx has adjacent nested
-- nodes that make a decision.
procedure Process_Pending_Decisions
(Original_Decision : SCO_Table_Entry);
-- Complete the filtered SCO table using collected decisions. Output
-- decisions inherit the pragma information from the original decision.
procedure Search_Nested_Decisions (Idx : in out Nat);
-- Collect decisions to add to the filtered SCO table starting at the
-- node at Idx in the SCO raw table. This node must not be part of an
-- already-processed decision. Set Idx to the first node index passed
-- the whole expression tree.
procedure Skip_Decision
(Idx : in out Nat;
Process_Nested_Decisions : Boolean);
-- Skip all the nodes that belong to the decision starting at Idx. If
-- Process_Nested_Decision, call Search_Nested_Decisions on the first
-- nested nodes that do not belong to the decision. Set Idx to the first
-- node index passed the whole expression tree.
-------------------------
-- Add_Expression_Tree --
-------------------------
procedure Add_Expression_Tree (Idx : in out Nat) is
Node_Idx : constant Nat := Idx;
T : SCO_Table_Entry renames SCO_Raw_Table.Table (Node_Idx);
From : Source_Location;
To : Source_Location;
begin
case T.C1 is
when ' ' =>
-- This is a single condition. Add an entry for it and move on
SCO_Table.Append (T);
Idx := Idx + 1;
when '!' =>
-- This is a NOT operator: add an entry for it and browse its
-- only child.
SCO_Table.Append (T);
Idx := Idx + 1;
Add_Expression_Tree (Idx);
when others =>
-- This must be an AND/OR/AND THEN/OR ELSE operator
if T.C2 = '?' then
-- This is not a short circuit operator: consider this one
-- and all its children as a single condition.
Compute_Range (Idx, From, To);
SCO_Table.Append
((From => From,
To => To,
C1 => ' ',
C2 => 'c',
Last => False,
Pragma_Sloc => No_Location,
Pragma_Aspect_Name => No_Name));
else
-- This is a real short circuit operator: add an entry for
-- it and browse its children.
SCO_Table.Append (T);
Idx := Idx + 1;
Add_Expression_Tree (Idx);
Add_Expression_Tree (Idx);
end if;
end case;
end Add_Expression_Tree;
-----------------------
-- Collect_Decisions --
-----------------------
procedure Collect_Decisions
(D : Decision;
Next : out Nat)
is
Idx : Nat := D.Top;
begin
if D.Kind /= 'X' or else Is_Decision (D.Top) then
Pending_Decisions.Append (D);
end if;
Skip_Decision (Idx, True);
Next := Idx;
end Collect_Decisions;
-------------------
-- Compute_Range --
-------------------
procedure Compute_Range
(Idx : in out Nat;
From : out Source_Location;
To : out Source_Location)
is
Sloc_F : Source_Location := No_Source_Location;
Sloc_T : Source_Location := No_Source_Location;
procedure Process_One;
-- Process one node of the tree, and recurse over children. Update
-- Idx during the traversal.
-----------------
-- Process_One --
-----------------
procedure Process_One is
begin
if Sloc_F = No_Source_Location
or else
SCO_Raw_Table.Table (Idx).From < Sloc_F
then
Sloc_F := SCO_Raw_Table.Table (Idx).From;
end if;
if Sloc_T = No_Source_Location
or else
Sloc_T < SCO_Raw_Table.Table (Idx).To
then
Sloc_T := SCO_Raw_Table.Table (Idx).To;
end if;
if SCO_Raw_Table.Table (Idx).C1 = ' ' then
-- This is a condition: nothing special to do
Idx := Idx + 1;
elsif SCO_Raw_Table.Table (Idx).C1 = '!' then
-- The "not" operator has only one operand
Idx := Idx + 1;
Process_One;
else
-- This is an AND THEN or OR ELSE logical operator: follow the
-- left, then the right operands.
Idx := Idx + 1;
Process_One;
Process_One;
end if;
end Process_One;
-- Start of processing for Compute_Range
begin
Process_One;
From := Sloc_F;
To := Sloc_T;
end Compute_Range;
-----------------
-- Is_Decision --
-----------------
function Is_Decision (Idx : Nat) return Boolean is
Index : Nat := Idx;
begin
loop
declare
T : SCO_Table_Entry renames SCO_Raw_Table.Table (Index);
begin
case T.C1 is
when ' ' =>
return False;
when '!' =>
-- This is a decision iff the only operand of the NOT
-- operator could be a standalone decision.
Index := Idx + 1;
when others =>
-- This node is a logical operator (and thus could be a
-- standalone decision) iff it is a short circuit
-- operator.
return T.C2 /= '?';
end case;
end;
end loop;
end Is_Decision;
-------------------------------
-- Process_Pending_Decisions --
-------------------------------
procedure Process_Pending_Decisions
(Original_Decision : SCO_Table_Entry)
is
begin
for Index in 1 .. Pending_Decisions.Last loop
declare
D : Decision renames Pending_Decisions.Table (Index);
Idx : Nat := D.Top;
begin
-- Add a SCO table entry for the decision itself
pragma Assert (D.Kind /= ' ');
SCO_Table.Append
((To => No_Source_Location,
From => D.Sloc,
C1 => D.Kind,
C2 => ' ',
Last => False,
Pragma_Sloc => Original_Decision.Pragma_Sloc,
Pragma_Aspect_Name =>
Original_Decision.Pragma_Aspect_Name));
-- Then add ones for its nested operators/operands. Do not
-- forget to tag its *last* entry as such.
Add_Expression_Tree (Idx);
SCO_Table.Table (SCO_Table.Last).Last := True;
end;
end loop;
-- Clear the pending decisions list
Pending_Decisions.Set_Last (0);
end Process_Pending_Decisions;
-----------------------------
-- Search_Nested_Decisions --
-----------------------------
procedure Search_Nested_Decisions (Idx : in out Nat) is
begin
loop
declare
T : SCO_Table_Entry renames SCO_Raw_Table.Table (Idx);
begin
case T.C1 is
when ' ' =>
Idx := Idx + 1;
exit;
when '!' =>
Collect_Decisions
((Kind => 'X',
Sloc => T.From,
Top => Idx),
Idx);
exit;
when others =>
if T.C2 = '?' then
-- This is not a logical operator: start looking for
-- nested decisions from here. Recurse over the left
-- child and let the loop take care of the right one.
Idx := Idx + 1;
Search_Nested_Decisions (Idx);
else
-- We found a nested decision
Collect_Decisions
((Kind => 'X',
Sloc => T.From,
Top => Idx),
Idx);
exit;
end if;
end case;
end;
end loop;
end Search_Nested_Decisions;
-------------------
-- Skip_Decision --
-------------------
procedure Skip_Decision
(Idx : in out Nat;
Process_Nested_Decisions : Boolean)
is
begin
loop
declare
T : SCO_Table_Entry renames SCO_Raw_Table.Table (Idx);
begin
Idx := Idx + 1;
case T.C1 is
when ' ' =>
exit;
when '!' =>
-- This NOT operator belongs to the outside decision:
-- just skip it.
null;
when others =>
if T.C2 = '?' and then Process_Nested_Decisions then
-- This is not a logical operator: start looking for
-- nested decisions from here. Recurse over the left
-- child and let the loop take care of the right one.
Search_Nested_Decisions (Idx);
else
-- This is a logical operator, so it belongs to the
-- outside decision: skip its left child, then let the
-- loop take care of the right one.
Skip_Decision (Idx, Process_Nested_Decisions);
end if;
end case;
end;
end loop;
end Skip_Decision;
-- Start of processing for SCO_Record_Filtered
begin
-- Filtering must happen only once: do nothing if it this pass was
-- already run.
if SCO_Generation_State = Filtered then
return;
else
pragma Assert (SCO_Generation_State = Raw);
SCO_Generation_State := Filtered;
end if;
-- Loop through all SCO entries under SCO units
for Unit_Idx in 1 .. SCO_Unit_Table.Last loop
declare
Unit : SCO_Unit_Table_Entry
renames SCO_Unit_Table.Table (Unit_Idx);
Idx : Nat := Unit.From;
-- Index of the current SCO raw table entry
New_From : constant Nat := SCO_Table.Last + 1;
-- After copying SCO enties of interest to the final table, we
-- will have to change the From/To indexes this unit targets.
-- This constant keeps track of the new From index.
begin
while Idx <= Unit.To loop
declare
T : SCO_Table_Entry renames SCO_Raw_Table.Table (Idx);
begin
case T.C1 is
-- Decision (of any kind, including pragmas and aspects)
when 'E' | 'G' | 'I' | 'W' | 'X' | 'P' | 'a' | 'A' =>
if SCO_Pragma_Disabled (T.Pragma_Sloc) then
-- Skip SCO entries for decisions in disabled
-- constructs (pragmas or aspects).
Idx := Idx + 1;
Skip_Decision (Idx, False);
else
Collect_Decisions
((Kind => T.C1,
Sloc => T.From,
Top => Idx + 1),
Idx);
Process_Pending_Decisions (T);
end if;
-- There is no translation/filtering to do for other kind
-- of SCO items (statements, dominance markers, etc.).
when '|' | '&' | '!' | ' ' =>
-- SCO logical operators and conditions cannot exist
-- on their own: they must be inside a decision (such
-- entries must have been skipped by
-- Collect_Decisions).
raise Program_Error;
when others =>
SCO_Table.Append (T);
Idx := Idx + 1;
end case;
end;
end loop;
-- Now, update the SCO entry indexes in the unit entry
Unit.From := New_From;
Unit.To := SCO_Table.Last;
end;
end loop;
-- Then clear the raw table to free bytes
SCO_Raw_Table.Free;
end SCO_Record_Filtered;
end Par_SCO;
|
Rodeo-McCabe/orka | Ada | 1,200 | 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.
with Ahven.Framework;
package Test_SIMD_AVX_Arithmetic is
type Test is new Ahven.Framework.Test_Case with null record;
overriding
procedure Initialize (T : in out Test);
private
procedure Test_Multiply;
procedure Test_Divide;
procedure Test_Divide_By_Zero;
procedure Test_Divide_Or_Zero;
procedure Test_Add;
procedure Test_Subtract;
procedure Test_Minus;
procedure Test_Multiply_Vector;
procedure Test_Multiply_Matrices;
procedure Test_Abs;
procedure Test_Sum;
end Test_SIMD_AVX_Arithmetic;
|
zhmu/ananas | Ada | 164 | adb | -- { dg-options "-gnat95 -gnatws" }
package body overload2_p is
function "=" (this, that: t) return boolean is begin return True; end;
this, that : t;
end;
|
RREE/ada-util | Ada | 2,285 | ads | -- Generated by utildgen.c from system includes
with Interfaces.C;
package Util.Systems.Types is
subtype dev_t is Long_Long_Integer;
subtype ino_t is Long_Long_Integer;
subtype off_t is Long_Long_Integer;
subtype blksize_t is Interfaces.C.int;
subtype blkcnt_t is Long_Long_Integer;
subtype uid_t is Interfaces.C.unsigned;
subtype gid_t is Interfaces.C.unsigned;
subtype nlink_t is Long_Long_Integer;
subtype mode_t is Interfaces.C.unsigned_short;
S_IFMT : constant mode_t := 8#00170000#;
S_IFDIR : constant mode_t := 8#00040000#;
S_IFCHR : constant mode_t := 8#00020000#;
S_IFBLK : constant mode_t := 8#00060000#;
S_IFREG : constant mode_t := 8#00100000#;
S_IFIFO : constant mode_t := 8#00010000#;
S_IFLNK : constant mode_t := 8#00120000#;
S_IFSOCK : constant mode_t := 8#00140000#;
S_ISUID : constant mode_t := 8#00004000#;
S_ISGID : constant mode_t := 8#00002000#;
S_IREAD : constant mode_t := 8#00000400#;
S_IWRITE : constant mode_t := 8#00000200#;
S_IEXEC : constant mode_t := 8#00000100#;
type File_Type is new Interfaces.C.int;
subtype Time_Type is Long_Long_Integer;
type Timespec is record
tv_sec : Time_Type;
tv_nsec : Long_Long_Integer;
end record;
pragma Convention (C_Pass_By_Copy, Timespec);
type Seek_Mode is (SEEK_SET, SEEK_CUR, SEEK_END);
for Seek_Mode use (SEEK_SET => 0, SEEK_CUR => 1, SEEK_END => 2);
subtype fflags_t is Interfaces.C.unsigned;
STAT_NAME : constant String := "stat";
FSTAT_NAME : constant String := "fstat";
type Stat_Type is record
st_dev : dev_t;
st_ino : ino_t;
st_nlink : nlink_t;
st_mode : mode_t;
st_padding0 : Interfaces.C.unsigned_short;
st_uid : uid_t;
st_gid : gid_t;
st_padding1 : Interfaces.C.unsigned;
st_rdev : dev_t;
st_atim : Timespec;
st_mtim : Timespec;
st_ctim : Timespec;
st_birthtim : Timespec;
st_size : off_t;
st_blocks : blkcnt_t;
st_blksize : blksize_t;
st_flags : fflags_t;
st_gen : Long_Long_Integer;
end record;
pragma Convention (C_Pass_By_Copy, Stat_Type);
for Stat_Type'Size use 1792;
end Util.Systems.Types;
|
AdaCore/training_material | Ada | 2,898 | adb | -----------------------------------------------------------------------
-- Ada Labs --
-- --
-- Copyright (C) 2008-2009, AdaCore --
-- --
-- Labs is free software; you can redistribute it and/or modify it --
-- under the terms of the GNU General Public License as published by --
-- the Free Software Foundation; either version 2 of the License, or --
-- (at your option) any later version. --
-- --
-- This program is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. You should have received --
-- a copy of the GNU General Public License along with this program; --
-- if not, write to the Free Software Foundation, Inc., 59 Temple --
-- Place - Suite 330, Boston, MA 02111-1307, USA. --
-----------------------------------------------------------------------
with Libm_Single; use Libm_Single;
package body Solar_System is
-- implement a function to compute the X coordinate
-- x of the reference + distance * cos(angle)
function Compute_X
(Body_To_Move : Body_T;
Turns_Around : Body_T) return Float;
-- implement a function to compute the Y coordinate
-- y of the reference + distance * sin(angle)
function Compute_Y
(Body_To_Move : Body_T;
Turns_Around : Body_T) return Float;
function Compute_X
(Body_To_Move : Body_T;
Turns_Around : Body_T) return Float
is
begin
return Turns_Around.X + Body_To_Move.Distance * Cos (Body_To_Move.Angle);
end Compute_X;
function Compute_Y
(Body_To_Move : Body_T;
Turns_Around : Body_T) return Float
is
begin
return Turns_Around.Y + Body_To_Move.Distance * Sin (Body_To_Move.Angle);
end Compute_Y;
procedure Move (Body_To_Move : in out Body_T; Bodies : Bodies_Array_T);
procedure Move (Body_To_Move : in out Body_T; Bodies : Bodies_Array_T) is
begin
Body_To_Move.X :=
Compute_X (Body_To_Move, Bodies (Body_To_Move.Turns_Around));
Body_To_Move.Y :=
Compute_Y (Body_To_Move, Bodies (Body_To_Move.Turns_Around));
Body_To_Move.Angle := Body_To_Move.Angle + Body_To_Move.Speed;
end Move;
procedure Move_All (Bodies : in out Bodies_Array_T) is
begin
-- loop over all bodies and call Move procedure
for B of Bodies loop
-- call the move procedure for each body
Move (B, Bodies);
end loop;
end Move_All;
end Solar_System;
|
positivevaib/nyu-archive | Ada | 1,068 | adb | package body Matrix_Mult is
procedure Mat_Mult(A: in Mat; B: in Mat; C: out Mat) is
task type Dot_Product is
entry Dot(Row_Index: Integer; Col_Index: Integer);
entry Dot_Done;
end Dot_Product;
task body Dot_Product is
Row: Integer;
Col: Integer;
begin
accept Dot(Row_Index: Integer; Col_Index: Integer) do
Row := Row_Index;
Col := Col_Index;
end Dot;
C(Row, Col) := 0;
for i in 1..Size loop
C(Row, Col) := C(Row, Col) + A(Row, i)*B(i, Col);
end loop;
accept Dot_Done do
null;
end Dot_Done;
end Dot_Product;
Tasks_Mat: array(1..Size, 1..Size) of Dot_Product;
begin
for i in 1..Size loop
for j in 1..Size loop
Tasks_Mat(i, j).Dot(i, j);
end loop;
end loop;
for i in 1..Size loop
for j in 1..Size loop
Tasks_Mat(i, j).Dot_Done;
end loop;
end loop;
end Mat_Mult;
end Matrix_Mult;
|
jdgoal512/life | Ada | 4,374 | adb | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure Life is
-- D: Die, S: Stay the same, G: Grow a new cell
type Rules_Type is (D, S, G);
type Rule_Set is array (Natural range 0 .. 8) of Rules_Type;
type Grid_Type is array (Natural range <>, Natural range <>) of Boolean;
type Points_Type is array(Natural range <>, Natural range <>) of Natural;
type Life (Width : Natural := 10;
Height : Natural := 10) is
record
Generation : Natural := 0;
Rules : Rule_Set := (D, D, S, G, D, D, D, D, D);
Grid : Grid_Type (1 .. Width, 1 .. Height) := (others => (others => false));
Next_Grid : Grid_Type (1 .. Width, 1 .. Height) := (others => (others => false));
end record;
function Get(Self : Life;
X : Natural;
Y : Natural) return Boolean is
begin
if X > 0 and X <= Self.Width and Y > 0 and Y <= Self.Height then
return Self.Grid (X, Y);
end if;
return false;
end get;
function Get_Neighbors(Self : Life;
X : Natural;
Y : Natural) return Natural is
Neighbors: Natural;
begin
Neighbors := 0;
for X_Offset in Integer range -1 .. 1 loop
for Y_Offset in Integer range -1 .. 1 loop
-- Don't count the offset 0, 0
if X_Offset /= 0 or Y_Offset /= 0 then
if get(Self, X+X_Offset, Y+Y_Offset) then
Neighbors := Neighbors + 1;
end if;
end if;
end loop;
end loop;
return Neighbors;
end Get_Neighbors;
procedure Print_Grid(Self : Life) is
begin
Put ("Generation ");
Put (Self.Generation);
Put_Line("");
Put ("+");
for X in Self.Grid'Range (1) loop
Put ("-");
end loop;
Put_Line ("+");
for Y in Self.Grid'Range (2) loop
Put ("|");
for X in Self.Grid'Range (1) loop
if Get(Self, X, Y) then
Put("0");
else
Put(" ");
end if;
end loop;
Put_Line ("|");
end loop;
Put ("+");
for X in Self.Grid'Range (1) loop
Put ("-");
end loop;
Put_Line ("+");
end Print_Grid;
procedure Next_Generation(Self : out Life) is
Neighbors : Natural;
Next_State : Rules_Type;
begin
for X in Integer range 1 .. Self.Width loop
for Y in Integer range 1 .. Self.Height loop
Neighbors := Get_Neighbors(Self, x, y);
Next_State := Self.Rules (Neighbors);
if Next_State = G then
Self.Next_Grid (X, Y) := TRUE;
elsif Next_State = D then
Self.Next_Grid (X, Y) := FALSE;
end if;
end loop;
end loop;
Self.Generation := Self.Generation + 1;
for X in Integer range 1 .. Self.Width loop
for Y in Integer range 1 .. Self.Height loop
Self.Grid (X, Y) := Self.Next_Grid(X, Y);
end loop;
end loop;
end Next_Generation;
procedure Add_Figure(Self : out Life;
X : in Natural;
Y : in Natural;
Points : in Points_Type) is
begin
for I in points'Range loop
Self.Grid(X+Points(I, 0), Y+Points(I, 1)) := TRUE;
Self.Next_Grid(X+Points(I, 0), Y+Points(I, 1)) := TRUE;
end loop;
end Add_Figure;
Rpentomino : Points_Type := ((1, 0), (2, 0), (0, 1), (1, 1), (1, 2));
Block : Points_Type := ((0, 0), (1, 0), (0, 1), (1, 1));
Blinker : Points_Type := ((1, 0), (1, 1), (1, 2));
Beacon : Points_Type := ((0, 0), (0, 1), (1, 0), (2, 3), (3, 2), (3, 3));
Rules : Rule_Set := (D, D, S, G, D, D, D, D, D);
Game : Life(Width => 20, Height => 10);
begin
Add_Figure(Game, 15, 3, BEACON);
Add_Figure(Game, 5, 5, Rpentomino);
loop
Print_Grid(Game);
Next_Generation(Game);
delay(1.0);
end loop;
end Life;
|
Fabien-Chouteau/shoot-n-loot | Ada | 120 | ads | -- Shoot'n'loot
-- Copyright (c) 2020 Fabien Chouteau
package Menus is
procedure Run with No_Return;
end Menus;
|
stcarrez/ada-asf | Ada | 6,436 | ads | -----------------------------------------------------------------------
-- applications -- Ada Web Application
-- Copyright (C) 2009, 2010, 2013, 2015, 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 Util.Strings;
with Util.Properties;
package ASF.Applications is
use Util.Properties;
type Config is new Util.Properties.Manager with private;
type Config_Param is private;
-- Directory where the facelet files are stored.
VIEW_DIR_PARAM : constant Config_Param;
VIEW_DIR : aliased constant String := "view.dir";
DEF_VIEW_DIR : aliased constant String := "web";
-- Extension used by requests
VIEW_EXT_PARAM : constant Config_Param;
VIEW_EXT : aliased constant String := "view.ext";
DEF_VIEW_EXT : aliased constant String := "";
-- Extension used by facelet files
VIEW_FILE_EXT_PARAM : constant Config_Param;
VIEW_FILE_EXT : aliased constant String := "view.file_ext";
DEF_VIEW_FILE_EXT : aliased constant String := ".xhtml";
-- Whether white spaces in XHTML files are ignored.
VIEW_IGNORE_WHITE_SPACES_PARAM : constant Config_Param;
VIEW_IGNORE_WHITE_SPACES : aliased constant String := "view.ignore_white_spaces";
DEF_IGNORE_WHITE_SPACES : aliased constant String := "false";
-- Whether empty lines in XHTML files are ignored.
VIEW_IGNORE_EMPTY_LINES_PARAM : constant Config_Param;
VIEW_IGNORE_EMPTY_LINES : aliased constant String := "view.ignore_empty_lines";
DEF_IGNORE_EMPTY_LINES : aliased constant String := "false";
-- Whether the unknown tags are escaped in the output
VIEW_ESCAPE_UNKNOWN_TAGS_PARAM : constant Config_Param;
VIEW_ESCAPE_UNKNOWN_TAGS : aliased constant String := "view.escape_unknown_tags";
DEF_ESCAPE_UNKNOWN_TAGS : aliased constant String := "false";
-- Extensions used by static pages
VIEW_STATIC_EXT_PARAM : constant Config_Param;
VIEW_STATIC_EXT : aliased constant String := "view.static.ext";
DEF_STATIC_EXT : aliased constant String := "";
-- Directories which contain static pages
VIEW_STATIC_DIR_PARAM : constant Config_Param;
VIEW_STATIC_DIR : aliased constant String := "view.static.dir";
DEF_STATIC_DIR : aliased constant String := "css,js,scripts,themes";
-- The 404 error page to render
ERROR_404_PARAM : constant Config_Param;
ERROR_404_PAGE : aliased constant String := "view.error.404";
DEF_ERROR_404 : aliased constant String := "errors/404";
-- The 500 error page to render
ERROR_500_PARAM : constant Config_Param;
ERROR_500_PAGE : aliased constant String := "view.error.500";
DEF_ERROR_500 : aliased constant String := "errors/500";
-- Get the configuration parameter;
function Get (Self : Config;
Param : Config_Param) return String;
-- Get the configuration parameter;
function Get (Self : Config;
Param : Config_Param) return Ada.Strings.Unbounded.Unbounded_String;
-- Get the configuration parameter;
function Get (Self : Config;
Param : Config_Param) return Boolean;
function Get (Self : Config;
Param : Config_Param) return Integer;
-- Create the configuration parameter definition instance.
generic
-- The parameter name.
Name : in String;
-- The default value.
Default : in String;
package Parameter is
-- Returns the configuration parameter.
function P return Config_Param;
pragma Inline_Always (P);
PARAM_NAME : aliased constant String := Name;
PARAM_VALUE : aliased constant String := Default;
end Parameter;
private
type Config_Param is record
Name : Util.Strings.Name_Access;
Default : Util.Strings.Name_Access;
end record;
subtype P is Config_Param;
VIEW_DIR_PARAM : constant Config_Param := P '(Name => VIEW_DIR'Access,
Default => DEF_VIEW_DIR'Access);
VIEW_EXT_PARAM : constant Config_Param := P '(Name => VIEW_EXT'Access,
Default => DEF_VIEW_EXT'Access);
VIEW_FILE_EXT_PARAM : constant Config_Param := P '(Name => VIEW_FILE_EXT'Access,
Default => DEF_VIEW_FILE_EXT'Access);
VIEW_IGNORE_WHITE_SPACES_PARAM : constant Config_Param
:= P '(Name => VIEW_IGNORE_WHITE_SPACES'Access,
Default => DEF_IGNORE_WHITE_SPACES'Access);
VIEW_IGNORE_EMPTY_LINES_PARAM : constant Config_Param
:= P '(Name => VIEW_IGNORE_EMPTY_LINES'Access,
Default => DEF_IGNORE_EMPTY_LINES'Access);
VIEW_ESCAPE_UNKNOWN_TAGS_PARAM : constant Config_Param
:= P '(Name => VIEW_ESCAPE_UNKNOWN_TAGS'Access,
Default => DEF_ESCAPE_UNKNOWN_TAGS'Access);
VIEW_STATIC_EXT_PARAM : constant Config_Param := P '(Name => VIEW_STATIC_EXT'Access,
Default => DEF_STATIC_EXT'Access);
VIEW_STATIC_DIR_PARAM : constant Config_Param := P '(Name => VIEW_STATIC_DIR'Access,
Default => DEF_STATIC_DIR'Access);
ERROR_404_PARAM : constant Config_Param := P '(Name => ERROR_404_PAGE'Access,
Default => DEF_ERROR_404'Access);
ERROR_500_PARAM : constant Config_Param := P '(Name => ERROR_500_PAGE'Access,
Default => DEF_ERROR_500'Access);
type Config is new Util.Properties.Manager with null record;
end ASF.Applications;
|
stcarrez/ada-util | Ada | 1,573 | ads | -----------------------------------------------------------------------
-- util-mail -- Mail Utility Library
-- Copyright (C) 2017, 2018 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;
-- == Introduction ==
-- The <tt>Util.Mail</tt> package provides various operations related to sending email.
package Util.Mail is
type Email_Address is record
Name : Ada.Strings.Unbounded.Unbounded_String;
Address : Ada.Strings.Unbounded.Unbounded_String;
end record;
-- Parse the email address and separate the name from the address.
function Parse_Address (E_Mail : in String) return Email_Address;
-- Extract a first name from the email address.
function Get_First_Name (From : in Email_Address) return String;
-- Extract a last name from the email address.
function Get_Last_Name (From : in Email_Address) return String;
end Util.Mail;
|
gspu/synth | Ada | 1,587 | ads | -- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
package Definitions is
pragma Pure;
synth_version_major : constant String := "2";
synth_version_minor : constant String := "13";
copyright_years : constant String := "2015-2023";
host_localbase : constant String := "/usr/local";
host_make : constant String := "/usr/bin/make";
host_pkg8 : constant String := host_localbase & "/sbin/pkg";
host_bmake : constant String := host_localbase & "/bin/bmake";
host_make_program : constant String := host_make;
chroot_make : constant String := "/usr/bin/make";
chroot_bmake : constant String := "/usr/pkg/bin/bmake -m /usr/pkg/share/mk";
chroot_make_program : constant String := chroot_make;
jobs_per_cpu : constant := 2;
type cpu_range is range 1 .. 64;
type scanners is range cpu_range'First .. cpu_range'Last;
type builders is range cpu_range'First .. cpu_range'Last * jobs_per_cpu;
type package_system is (ports_collection, pkgsrc);
software_framework : constant package_system := ports_collection;
-- Notes for tailoring Synth. Use sed to:
-- 1. Modify host_localbase to value of LOCALBASE
-- 2. Change software_framework to "pkgsrc" for pkgsrc version
-- 3. Change host_make_program to "host_bmake" for Non-NetBSD pkgsrc platforms
-- 4. Change chroot_make_program to "chroot_bmake" for pkgsrc version
-- 5. On replicant.ads, change "/usr/local" to "/usr/pkg" on pkgsrc
end Definitions;
|
reznikmm/matreshka | Ada | 4,673 | 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.Dr3d_Rotate_Elements;
package Matreshka.ODF_Dr3d.Rotate_Elements is
type Dr3d_Rotate_Element_Node is
new Matreshka.ODF_Dr3d.Abstract_Dr3d_Element_Node
and ODF.DOM.Dr3d_Rotate_Elements.ODF_Dr3d_Rotate
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Dr3d_Rotate_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Dr3d_Rotate_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Dr3d_Rotate_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 Dr3d_Rotate_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 Dr3d_Rotate_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_Dr3d.Rotate_Elements;
|
G-P-S/freetype-gopro-mac | Ada | 4,250 | adb | ----------------------------------------------------------------
-- ZLib for Ada thick binding. --
-- --
-- Copyright (C) 2002-2003 Dmitriy Anisimkov --
-- --
-- Open source license information is in the zlib.ads file. --
----------------------------------------------------------------
-- $Id: read.adb,v 1.1 2009/10/28 06:31:01 dnewman Exp $
-- Test/demo program for the generic read interface.
with Ada.Numerics.Discrete_Random;
with Ada.Streams;
with Ada.Text_IO;
with ZLib;
procedure Read is
use Ada.Streams;
------------------------------------
-- Test configuration parameters --
------------------------------------
File_Size : Stream_Element_Offset := 100_000;
Continuous : constant Boolean := False;
-- If this constant is True, the test would be repeated again and again,
-- with increment File_Size for every iteration.
Header : constant ZLib.Header_Type := ZLib.Default;
-- Do not use Header other than Default in ZLib versions 1.1.4 and older.
Init_Random : constant := 8;
-- We are using the same random sequence, in case of we catch bug,
-- so we would be able to reproduce it.
-- End --
Pack_Size : Stream_Element_Offset;
Offset : Stream_Element_Offset;
Filter : ZLib.Filter_Type;
subtype Visible_Symbols
is Stream_Element range 16#20# .. 16#7E#;
package Random_Elements is new
Ada.Numerics.Discrete_Random (Visible_Symbols);
Gen : Random_Elements.Generator;
Period : constant Stream_Element_Offset := 200;
-- Period constant variable for random generator not to be very random.
-- Bigger period, harder random.
Read_Buffer : Stream_Element_Array (1 .. 2048);
Read_First : Stream_Element_Offset;
Read_Last : Stream_Element_Offset;
procedure Reset;
procedure Read
(Item : out Stream_Element_Array;
Last : out Stream_Element_Offset);
-- this procedure is for generic instantiation of
-- ZLib.Read
-- reading data from the File_In.
procedure Read is new ZLib.Read
(Read,
Read_Buffer,
Rest_First => Read_First,
Rest_Last => Read_Last);
----------
-- Read --
----------
procedure Read
(Item : out Stream_Element_Array;
Last : out Stream_Element_Offset) is
begin
Last := Stream_Element_Offset'Min
(Item'Last,
Item'First + File_Size - Offset);
for J in Item'First .. Last loop
if J < Item'First + Period then
Item (J) := Random_Elements.Random (Gen);
else
Item (J) := Item (J - Period);
end if;
Offset := Offset + 1;
end loop;
end Read;
-----------
-- Reset --
-----------
procedure Reset is
begin
Random_Elements.Reset (Gen, Init_Random);
Pack_Size := 0;
Offset := 1;
Read_First := Read_Buffer'Last + 1;
Read_Last := Read_Buffer'Last;
end Reset;
begin
Ada.Text_IO.Put_Line ("ZLib " & ZLib.Version);
loop
for Level in ZLib.Compression_Level'Range loop
Ada.Text_IO.Put ("Level ="
& ZLib.Compression_Level'Image (Level));
-- Deflate using generic instantiation.
ZLib.Deflate_Init
(Filter,
Level,
Header => Header);
Reset;
Ada.Text_IO.Put
(Stream_Element_Offset'Image (File_Size) & " ->");
loop
declare
Buffer : Stream_Element_Array (1 .. 1024);
Last : Stream_Element_Offset;
begin
Read (Filter, Buffer, Last);
Pack_Size := Pack_Size + Last - Buffer'First + 1;
exit when Last < Buffer'Last;
end;
end loop;
Ada.Text_IO.Put_Line (Stream_Element_Offset'Image (Pack_Size));
ZLib.Close (Filter);
end loop;
exit when not Continuous;
File_Size := File_Size + 1;
end loop;
end Read;
|
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_Text.Main_Entry_Style_Name_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Main_Entry_Style_Name_Attribute_Node is
begin
return Self : Text_Main_Entry_Style_Name_Attribute_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Main_Entry_Style_Name_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Main_Entry_Style_Name_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Main_Entry_Style_Name_Attribute,
Text_Main_Entry_Style_Name_Attribute_Node'Tag);
end Matreshka.ODF_Text.Main_Entry_Style_Name_Attributes;
|
stcarrez/bbox-ada-api | Ada | 7,992 | adb | -----------------------------------------------------------------------
-- bbox -- Bbox API
-- Copyright (C) 2017, 2019, 2023 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.Properties.JSON;
with Util.Log.Loggers;
with Util.Strings;
with Util.Properties.Basic;
package body Bbox.API is
use Ada.Strings.Unbounded;
package Int_Property renames Util.Properties.Basic.Integer_Property;
package Bool_Property renames Util.Properties.Basic.Boolean_Property;
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Bbox.API");
function Strip_Unecessary_Array (Content : in String) return String;
-- ------------------------------
-- Set the server IP address.
-- ------------------------------
procedure Set_Server (Client : in out Client_Type;
Server : in String) is
begin
Log.Debug ("Using bbox server {0}", Server);
Client.Server := Ada.Strings.Unbounded.To_Unbounded_String (Server);
end Set_Server;
-- ------------------------------
-- Internal operation to get the URI based on the operation being called.
-- ------------------------------
function Get_URI (Client : in Client_Type;
Operation : in String) return String is
begin
return "https://" & To_String (Client.Server) & "/api/v1/" & Operation;
end Get_URI;
-- ------------------------------
-- Login to the server Bbox API with the password.
-- ------------------------------
procedure Login (Client : in out Client_Type;
Password : in String) is
procedure Process (Name, Value : in String);
URI : constant String := Client.Get_URI ("login");
Response : Util.Http.Clients.Response;
procedure Process (Name, Value : in String) is
Pos, Last : Natural;
begin
if Name = "Set-Cookie" then
Pos := Util.Strings.Index (Value, '=');
if Pos = 0 then
return;
end if;
Last := Util.Strings.Index (Value, ';');
if Last = 0 or else Last < Pos then
return;
end if;
Client.Http.Set_Header ("Cookie", Value (Value'First .. Last - 1));
Client.Is_Logged := True;
end if;
end Process;
begin
Log.Debug ("Login to {0}", URI);
Client.Is_Logged := False;
Client.Http.Set_Header ("Cookie", "");
Client.Http.Add_Header ("X-Requested-By", "Bbox Ada Api");
Client.Http.Set_Timeout (10.0);
Client.Http.Post (URI, "password=" & Password, Response);
if Response.Get_Status = Util.Http.SC_OK then
Response.Iterate_Headers (Process'Access);
else
Log.Error ("Connection and login to {0} failed", URI);
end if;
end Login;
-- ------------------------------
-- Strip [] for some Json content.
-- We did a mistake when we designed the Bbox API and used '[' ... ']' arrays
-- for most of the JSON result. Strip that unecessary array.
-- ------------------------------
function Strip_Unecessary_Array (Content : in String) return String is
Last : Natural := Content'Last;
begin
if Content'Length = 0 then
return Content;
end if;
while Last > Content'First and then Content (Last) = ASCII.LF loop
Last := Last - 1;
end loop;
if Content (Content'First) = '[' and Content (Last) = ']' then
return Content (Content'First + 1 .. Last - 1);
else
return Content;
end if;
end Strip_Unecessary_Array;
-- ------------------------------
-- Execute a GET operation on the Bbox API to retrieve the result into the property list.
-- ------------------------------
procedure Get (Client : in out Client_Type;
Operation : in String;
Result : in out Util.Properties.Manager) is
URI : constant String := Client.Get_URI (Operation);
Response : Util.Http.Clients.Response;
begin
Log.Debug ("Get {0}", URI);
Client.Http.Set_Timeout (10.0);
Client.Http.Get (URI, Response);
if Response.Get_Status = 200 then
Util.Properties.JSON.Parse_JSON (Result, Strip_Unecessary_Array (Response.Get_Body));
end if;
end Get;
-- ------------------------------
-- Execute a GET operation on the Bbox API to retrieve the JSON result and return it.
-- ------------------------------
function Get (Client : in out Client_Type;
Operation : in String) return String is
URI : constant String := Client.Get_URI (Operation);
Response : Util.Http.Clients.Response;
begin
Log.Debug ("Get {0}", URI);
Client.Http.Set_Timeout (10.0);
Client.Http.Get (URI, Response);
return Response.Get_Body;
end Get;
-- ------------------------------
-- Execute a PUT operation on the Bbox API to change some parameter.
-- ------------------------------
procedure Put (Client : in out Client_Type;
Operation : in String;
Params : in String) is
URI : constant String := Client.Get_URI (Operation);
Response : Util.Http.Clients.Response;
begin
Log.Debug ("Put {0}", URI);
Client.Http.Set_Timeout (10.0);
Client.Http.Put (URI, Params, Response);
end Put;
procedure Refresh_Token (Client : in out Client_Type) is
use type Ada.Calendar.Time;
Now : constant Ada.Calendar.Time := Ada.Calendar.Clock;
Response : Util.Http.Clients.Response;
Tokens : Util.Properties.Manager;
begin
if Length (Client.Token) /= 0 and then Client.Expires > Now then
return;
end if;
Log.Debug ("Get bbox token");
Client.Http.Set_Timeout (10.0);
Client.Http.Get (Client.Get_URI ("device/token"), Response);
Util.Properties.JSON.Parse_JSON (Tokens, Strip_Unecessary_Array (Response.Get_Body));
Client.Token := To_Unbounded_String (Tokens.Get ("device.token", ""));
Client.Expires := Ada.Calendar.Clock + 60.0;
end Refresh_Token;
-- Execute a POST operation on the Bbox API to change some parameter.
procedure Post (Client : in out Client_Type;
Operation : in String;
Params : in String) is
URI : constant String := Client.Get_URI (Operation);
Response : Util.Http.Clients.Response;
begin
Log.Debug ("Post {0}", URI);
Client.Refresh_Token;
Client.Http.Set_Timeout (10.0);
Client.Http.Post (URI & "?btoken=" & To_String (Client.Token), Params, Response);
end Post;
-- Iterate over a JSON array flattened in the properties.
procedure Iterate (Props : in Util.Properties.Manager;
Name : in String;
Process : access procedure (P : in Util.Properties.Manager;
Base : in String)) is
Count : constant Integer := Int_Property.Get (Props, Name & ".length", 0);
begin
for I in 0 .. Count loop
declare
Base : constant String := Name & "." & Util.Strings.Image (I);
begin
Process (Props, Base);
end;
end loop;
end Iterate;
end Bbox.API;
|
sungyeon/drake | Ada | 9,986 | ads | pragma License (Unrestricted);
-- Ada 2005
with Ada.Iterator_Interfaces;
private with Ada.Containers.Binary_Trees;
private with Ada.Containers.Binary_Trees.Arne_Andersson;
private with Ada.Containers.Copy_On_Write;
private with Ada.Finalization;
private with Ada.Streams;
generic
type Key_Type (<>) is private;
type Element_Type (<>) is private;
with function "<" (Left, Right : Key_Type) return Boolean is <>;
with function "=" (Left, Right : Element_Type) return Boolean is <>;
package Ada.Containers.Indefinite_Ordered_Maps is
pragma Preelaborate;
pragma Remote_Types;
function Equivalent_Keys (Left, Right : Key_Type) return Boolean;
type Map is tagged private
with
Constant_Indexing => Constant_Reference,
Variable_Indexing => Reference,
Default_Iterator => Iterate,
Iterator_Element => Element_Type;
pragma Preelaborable_Initialization (Map);
type Cursor is private;
pragma Preelaborable_Initialization (Cursor);
-- modified
-- Empty_Map : constant Map;
function Empty_Map return Map;
No_Element : constant Cursor;
function Has_Element (Position : Cursor) return Boolean;
package Map_Iterator_Interfaces is
new Iterator_Interfaces (Cursor, Has_Element);
overriding function "=" (Left, Right : Map) return Boolean;
function Length (Container : Map) return Count_Type;
function Is_Empty (Container : Map) return Boolean;
procedure Clear (Container : in out Map);
function Key (Position : Cursor) return Key_Type;
-- diff
-- diff
-- diff
function Element (Position : Cursor) return Element_Type;
procedure Replace_Element (
Container : in out Map;
Position : Cursor;
New_Item : Element_Type);
procedure Query_Element (
Position : Cursor;
Process : not null access procedure (
Key : Key_Type;
Element : Element_Type));
-- modified
procedure Update_Element (
Container : in out Map'Class; -- not primitive
Position : Cursor;
Process : not null access procedure (
Key : Key_Type;
Element : in out Element_Type));
type Constant_Reference_Type (
Element : not null access constant Element_Type) is private
with Implicit_Dereference => Element;
type Reference_Type (Element : not null access Element_Type) is private
with Implicit_Dereference => Element;
function Constant_Reference (Container : aliased Map; Position : Cursor)
return Constant_Reference_Type;
function Reference (Container : aliased in out Map; Position : Cursor)
return Reference_Type;
function Constant_Reference (Container : aliased Map; Key : Key_Type)
return Constant_Reference_Type;
function Reference (Container : aliased in out Map; Key : Key_Type)
return Reference_Type;
procedure Assign (Target : in out Map; Source : Map);
function Copy (Source : Map) return Map;
procedure Move (Target : in out Map; Source : in out Map);
procedure Insert (
Container : in out Map;
Key : Key_Type;
New_Item : Element_Type;
Position : out Cursor;
Inserted : out Boolean);
-- diff (Insert)
--
--
--
--
procedure Insert (
Container : in out Map;
Key : Key_Type;
New_Item : Element_Type);
procedure Include (
Container : in out Map;
Key : Key_Type;
New_Item : Element_Type);
procedure Replace (
Container : in out Map;
Key : Key_Type;
New_Item : Element_Type);
procedure Exclude (Container : in out Map; Key : Key_Type);
procedure Delete (Container : in out Map; Key : Key_Type);
procedure Delete (Container : in out Map; Position : in out Cursor);
-- modified
procedure Delete_First (Container : in out Map'Class); -- not primitive
-- modified
procedure Delete_Last (Container : in out Map'Class); -- not primitive
function First (Container : Map) return Cursor;
-- modified
function First_Element (Container : Map'Class) -- not primitive
return Element_Type;
-- modified
function First_Key (Container : Map'Class) -- not primitive
return Key_Type;
function Last (Container : Map) return Cursor;
-- modified
function Last_Element (Container : Map'Class) -- not primitive
return Element_Type;
-- modified
function Last_Key (Container : Map'Class) -- not primitive
return Key_Type;
function Next (Position : Cursor) return Cursor;
procedure Next (Position : in out Cursor);
function Previous (Position : Cursor) return Cursor;
procedure Previous (Position : in out Cursor);
function Find (Container : Map; Key : Key_Type) return Cursor;
-- modified
function Element (
Container : Map'Class; -- not primitive
Key : Key_Type)
return Element_Type;
function Floor (Container : Map; Key : Key_Type) return Cursor;
function Ceiling (Container : Map; Key : Key_Type) return Cursor;
function Contains (Container : Map; Key : Key_Type) return Boolean;
function "<" (Left, Right : Cursor) return Boolean;
function ">" (Left, Right : Cursor) return Boolean;
function "<" (Left : Cursor; Right : Key_Type) return Boolean;
function ">" (Left : Cursor; Right : Key_Type) return Boolean;
function "<" (Left : Key_Type; Right : Cursor) return Boolean;
function ">" (Left : Key_Type; Right : Cursor) return Boolean;
-- modified
procedure Iterate (
Container : Map'Class; -- not primitive
Process : not null access procedure (Position : Cursor));
-- modified
procedure Reverse_Iterate (
Container : Map'Class; -- not primitive
Process : not null access procedure (Position : Cursor));
-- modified
function Iterate (Container : Map'Class) -- not primitive
return Map_Iterator_Interfaces.Reversible_Iterator'Class;
-- extended
function Iterate (Container : Map'Class; First, Last : Cursor)
return Map_Iterator_Interfaces.Reversible_Iterator'Class;
-- diff (Equivalents)
--
--
--
--
--
private
package Base renames Binary_Trees.Arne_Andersson;
type Key_Access is access Key_Type;
type Element_Access is access Element_Type;
type Node is limited record
Super : aliased Base.Node;
Key : Key_Access;
Element : Element_Access;
end record;
-- place Super at first whether Element_Type is controlled-type
for Node use record
Super at 0 range 0 .. Base.Node_Size - 1;
end record;
type Data is limited record
Super : aliased Copy_On_Write.Data;
Root : Binary_Trees.Node_Access := null;
Length : Count_Type := 0;
end record;
type Data_Access is access Data;
type Map is new Finalization.Controlled with record
Super : aliased Copy_On_Write.Container;
-- diff
end record;
overriding procedure Adjust (Object : in out Map);
overriding procedure Finalize (Object : in out Map)
renames Clear;
type Cursor is access Node;
-- diff (Key_Reference_Type)
--
type Constant_Reference_Type (
Element : not null access constant Element_Type) is null record;
type Reference_Type (Element : not null access Element_Type) is null record;
type Map_Access is access constant Map;
for Map_Access'Storage_Size use 0;
type Map_Iterator is
new Map_Iterator_Interfaces.Reversible_Iterator with
record
First : Cursor;
Last : Cursor;
end record;
overriding function First (Object : Map_Iterator) return Cursor;
overriding function Next (Object : Map_Iterator; Position : Cursor)
return Cursor;
overriding function Last (Object : Map_Iterator) return Cursor;
overriding function Previous (Object : Map_Iterator; Position : Cursor)
return Cursor;
package Streaming is
procedure Read (
Stream : not null access Streams.Root_Stream_Type'Class;
Item : out Map);
procedure Write (
Stream : not null access Streams.Root_Stream_Type'Class;
Item : Map);
procedure Missing_Read (
Stream : access Streams.Root_Stream_Type'Class;
Item : out Cursor)
with Import,
Convention => Ada, External_Name => "__drake_program_error";
procedure Missing_Write (
Stream : access Streams.Root_Stream_Type'Class;
Item : Cursor)
with Import,
Convention => Ada, External_Name => "__drake_program_error";
-- diff (Missing_Read)
--
--
--
--
-- diff (Missing_Write)
--
--
--
--
procedure Missing_Read (
Stream : access Streams.Root_Stream_Type'Class;
Item : out Constant_Reference_Type)
with Import,
Convention => Ada, External_Name => "__drake_program_error";
procedure Missing_Write (
Stream : access Streams.Root_Stream_Type'Class;
Item : Constant_Reference_Type)
with Import,
Convention => Ada, External_Name => "__drake_program_error";
procedure Missing_Read (
Stream : access Streams.Root_Stream_Type'Class;
Item : out Reference_Type)
with Import,
Convention => Ada, External_Name => "__drake_program_error";
procedure Missing_Write (
Stream : access Streams.Root_Stream_Type'Class;
Item : Reference_Type)
with Import,
Convention => Ada, External_Name => "__drake_program_error";
end Streaming;
for Map'Read use Streaming.Read;
for Map'Write use Streaming.Write;
for Cursor'Read use Streaming.Missing_Read;
for Cursor'Write use Streaming.Missing_Write;
-- diff ('Read)
-- diff ('Write)
for Constant_Reference_Type'Read use Streaming.Missing_Read;
for Constant_Reference_Type'Write use Streaming.Missing_Write;
for Reference_Type'Read use Streaming.Missing_Read;
for Reference_Type'Write use Streaming.Missing_Write;
No_Element : constant Cursor := null;
end Ada.Containers.Indefinite_Ordered_Maps;
|
optikos/oasis | Ada | 7,319 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Lexical_Elements;
with Program.Elements.Defining_Names;
with Program.Elements.Expressions;
with Program.Elements.Parameter_Associations;
with Program.Elements.Aspect_Specifications;
with Program.Elements.Package_Instantiations;
with Program.Element_Visitors;
package Program.Nodes.Package_Instantiations is
pragma Preelaborate;
type Package_Instantiation is
new Program.Nodes.Node
and Program.Elements.Package_Instantiations.Package_Instantiation
and Program.Elements.Package_Instantiations.Package_Instantiation_Text
with private;
function Create
(Package_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Name : not null Program.Elements.Defining_Names
.Defining_Name_Access;
Is_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
New_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Generic_Package_Name : not null Program.Elements.Expressions
.Expression_Access;
Left_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access;
Parameters : Program.Elements.Parameter_Associations
.Parameter_Association_Vector_Access;
Right_Bracket_Token : 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 Package_Instantiation;
type Implicit_Package_Instantiation is
new Program.Nodes.Node
and Program.Elements.Package_Instantiations.Package_Instantiation
with private;
function Create
(Name : not null Program.Elements.Defining_Names
.Defining_Name_Access;
Generic_Package_Name : not null Program.Elements.Expressions
.Expression_Access;
Parameters : Program.Elements.Parameter_Associations
.Parameter_Association_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)
return Implicit_Package_Instantiation
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Package_Instantiation is
abstract new Program.Nodes.Node
and Program.Elements.Package_Instantiations.Package_Instantiation
with record
Name : not null Program.Elements.Defining_Names
.Defining_Name_Access;
Generic_Package_Name : not null Program.Elements.Expressions
.Expression_Access;
Parameters : Program.Elements.Parameter_Associations
.Parameter_Association_Vector_Access;
Aspects : Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
end record;
procedure Initialize
(Self : aliased in out Base_Package_Instantiation'Class);
overriding procedure Visit
(Self : not null access Base_Package_Instantiation;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Name
(Self : Base_Package_Instantiation)
return not null Program.Elements.Defining_Names.Defining_Name_Access;
overriding function Generic_Package_Name
(Self : Base_Package_Instantiation)
return not null Program.Elements.Expressions.Expression_Access;
overriding function Parameters
(Self : Base_Package_Instantiation)
return Program.Elements.Parameter_Associations
.Parameter_Association_Vector_Access;
overriding function Aspects
(Self : Base_Package_Instantiation)
return Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access;
overriding function Is_Package_Instantiation_Element
(Self : Base_Package_Instantiation)
return Boolean;
overriding function Is_Declaration_Element
(Self : Base_Package_Instantiation)
return Boolean;
type Package_Instantiation is
new Base_Package_Instantiation
and Program.Elements.Package_Instantiations.Package_Instantiation_Text
with record
Package_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Is_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
New_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Left_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access;
Right_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access;
With_Token : Program.Lexical_Elements.Lexical_Element_Access;
Semicolon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
end record;
overriding function To_Package_Instantiation_Text
(Self : aliased in out Package_Instantiation)
return Program.Elements.Package_Instantiations
.Package_Instantiation_Text_Access;
overriding function Package_Token
(Self : Package_Instantiation)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Is_Token
(Self : Package_Instantiation)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function New_Token
(Self : Package_Instantiation)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Left_Bracket_Token
(Self : Package_Instantiation)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Right_Bracket_Token
(Self : Package_Instantiation)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function With_Token
(Self : Package_Instantiation)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Semicolon_Token
(Self : Package_Instantiation)
return not null Program.Lexical_Elements.Lexical_Element_Access;
type Implicit_Package_Instantiation is
new Base_Package_Instantiation
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
end record;
overriding function To_Package_Instantiation_Text
(Self : aliased in out Implicit_Package_Instantiation)
return Program.Elements.Package_Instantiations
.Package_Instantiation_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Package_Instantiation)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Package_Instantiation)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Package_Instantiation)
return Boolean;
end Program.Nodes.Package_Instantiations;
|
twinbee/lamportsBakery | Ada | 8,214 | adb | -- With in my Text io package for put/get
With Text_IO; Use Text_IO;
-- With in Random float package for my random number generator
With Ada.Numerics.Float_Random; Use Ada.Numerics.Float_Random;
-- With in Unbounded strings for my string monipulation
With Ada.Strings.Unbounded; Use Ada.Strings.Unbounded;
-- Begining of lamport_algorithm code
Procedure zo is
type type_message is (req, ack, rel);
-- Instantiating integer IO.
Package INT_IO is new Integer_IO(Integer); Use INT_IO;
Package MSG_IO is new Enumeration_IO(type_message); Use MSG_IO;
-- This is my random variable.
G: Generator;
-- random seed
seed: Integer;
type receiver;
-- This is the type for my pointer variable for my receiver process.
type rec is Access receiver;
type rec_array_type is array (0..20) of rec;
all_systems_go, all_dead: boolean := false;
-- This is the declaration for my receiver type task.
task type receiver(id: Integer; n: Integer) is
Entry start(friend_array: rec_array_type);
Entry RX(dest: Integer; msg: type_message; k: Integer; j: Integer);
Entry kill;
end receiver;
-- This is the intialization or body of the receiver type and
-- this is the code that the processeses will be excuting.
task Body receiver is
type message;
type message is
record
mestype: type_message := rel;
clock: Integer := 0;
id: Integer;
end record;
task type transmit(dest: Integer; mess: type_message; clock:
Integer; i: Integer) is
end transmit;
friends: rec_array_type;
st: Unbounded_String := Null_Unbounded_String;
--mestype: type_message;
type TX is access transmit;
tsk_TX: TX;
osn, local_clock: Integer := 0;
q: array (0 .. n) of message;
temp1, temp2: message;
for_all: boolean := true;
dead: boolean := false;
task algorithm;
task body algorithm is
begin
loop
for index in 0 .. n loop
q(index).id := index;
end loop;
exit when (all_systems_go = true);
end loop;
loop
--broadcast
for I in 0..n loop
if(I /= id)then
tsk_TX := new transmit(I, req, local_clock, id);
end if;
end loop;
q(id) := (req, local_clock, id);
osn := osn + 1;
local_clock := osn;
wait:
loop
for j in 0..n loop
if j /= id then
if((q(id).clock < q(j).clock)or((q(id).clock =
q(j).clock)and(q(id).id < q(j).id)))then
null;
else
for_all := false;
end if;
end if;
end loop;
exit wait when (for_all = true);
for_all := true;
end loop wait;
exit when dead = true;
-- This is my CS. Which ever process made it to this section will
-- get to do all of this wonderful stuff. I am cating my string for
-- printing. After that small section I basicly do the samething
-- again but this time i print process # " out CS". I also have a
-- delay in there just to add more randomness.
st := (((80/(n+1))*id) * " ") & Integer'Image(id) & " in CS.";
Put(To_String(st)); New_line;
delay Duration(float(random(G)) + float(10));
st := (((80/(n+1))*id) * " ") & Integer'Image(id) & " out CS.";
Put_line(To_String(st));
-- broadcast
local_clock := osn;
for I in 0..n loop
if(I /= id)then
tsk_TX := new transmit(I, rel, local_clock, id);
end if;
end loop;
q(id) := (rel, local_clock, id);
osn := osn + 1;
local_clock := osn;
exit when dead = true;
end loop;
end algorithm;
task body transmit is
Begin
friends(dest).RX(dest, mess, clock, i);
st := ((((80/(n+1))*id)* " ") & Integer'Image(i) & "TX " &
type_message'image(mess) & integer'image(dest));
Put_line(to_string(st));
end transmit;
Begin
loop
select
accept start(friend_array: rec_array_type)do
friends := friend_array;
end start;
or
accept RX (dest: Integer; msg: type_message; k: Integer; j:Integer) do
if(dest /= id)then
st := ((((80/(n+1))*id)*" ")&integer'image(id)&"FWD "
&type_message'image(msg) & integer'image(dest)&" FROM "&integer'image(j));
put_line(to_string(st));
tsk_TX := new transmit(dest, msg, k, j);
else
if(osn < k)then
osn := k;
end if;
osn := osn + 1;
if(msg = req)then
q(j) := (req, k, j);
tsk_TX := new transmit(j, ack, osn, id);
elsif (msg = rel)then
q(j) := (rel, k, j);
elsif(msg = ack)then
if (q(j).mestype /= req) then
q(j) := (ack, k, j);
end if;
end if;
st := ((((80/(n+1))*id)*" ")&integer'image(id) & "RX " &
type_message'image(msg) & integer'image(j));
put_line(to_string(st));
end if;
end RX;
or
accept kill do
st := ((((80/(n+1))*id)*" ")&integer'image(id)&" DIE");
put_line(to_string(st));
dead := true;
-- broadcast
local_clock := osn;
for I in 0..n loop
if(I /= id)then
tsk_TX := new transmit(I, rel, local_clock, id);
end if;
end loop;
st := (((80/(n+1))*id*" ")&integer'image(id)&" DED");
put_line(to_string(st));
end kill;
end select;
exit when all_dead = true;
end loop;
end receiver;
-------------------------------------------------------------------------------
type FILE_MODE is (IN_FILE, OUT_FILE);
-- This variable is used to send the number of processes.
p_count: Integer;
pro_array: array(0..20) of rec;
friend_array: rec_array_type;
friend_file: FILE_TYPE;
-- number to keep the for loops correct
n: Integer;
index, victim, buddy: Integer;
clock: Integer := 0;
toKill : Integer;
--assigned a random ID to determine which process to kill next
dead : ARRAY (0..20) of Boolean := (Others => FALSE);
--keeps track of which processes have been slain, so we dont try to kill a
--process twice , which would raise an exception
-- to hold number of victim
--victim: Integer;
-- This is the start of my main section of code that does the prompt for how
-- many loops, what process to turn is set to and how many processes. This
-- is also the section for the process calls.
Begin -- lamport_algorithm
open(friend_file, IN_FILE, "star1");
seed := 997;
get(friend_file, p_count);
skip_line(friend_file);
reset(G, seed);
n := p_count - 1;
-- Loop to create the total number of processes that were put in.
for pid in 0 .. n loop
pro_array(pid) := new receiver(pid, n);
end loop;
for I in 0 .. n loop
while (not(END_OF_LINE(friend_file))) loop
get(friend_file, index);
get(friend_file, buddy);
friend_array(index) := pro_array(buddy);
end loop;
skip_line(friend_file);
pro_array(I).start(friend_array);
end loop;
all_systems_go := true;
FOR kill_index IN 1 .. (p_count) --for as many as there are tasks
LOOP
delay (60.0);
Put ("Going to kill random process ... ");
toKill := (Integer(random(g)) MOD p_count);
WHILE (dead(toKill))
LOOP --iterate until process toKill isn't one that is already dead!
toKill := (toKill + 1) MOD p_count; --random didnt cut it, try the next one
END LOOP;
Put (toKill); new_line;
pro_Array(toKill).kill; --kill off our random process
dead(toKill) := TRUE;
END LOOP; --end loop to kill out all processes
all_dead := true;
close(friend_file);
end zo; -- lamport_algorithm
|
kjseefried/coreland-cgbc | Ada | 1,081 | adb | with CGBC.Bounded_Strings;
with Test;
procedure T_Bstr_Init_01 is
package BS renames CGBC.Bounded_Strings;
TC : Test.Context_t;
S1 : BS.Bounded_String (8);
begin
Test.Initialize
(Test_Context => TC,
Program => "t_bstr_init_01",
Test_DB => "TEST_DB",
Test_Results => "TEST_RESULTS");
-- "Referenced before value"
pragma Warnings (Off);
Test.Check (TC, 227, BS.To_String (S1) = "", "BS.To_String (S1) = """"");
pragma Warnings (On);
Test.Check (TC, 228, BS.Length (S1) = 0, "BS.Length (S1) = 0");
Test.Check (TC, 229, BS.Maximum_Length (S1) = 8, "BS.Maximum_Length (S1) = 8");
BS.Append (S1, "ABCD");
Test.Check (TC, 230, BS.Length (S1) = 4, "BS.Length (S1) = 4");
Test.Check (TC, 231, BS.Maximum_Length (S1) = 8, "BS.Maximum_Length (S1) = 8");
declare
S2 : constant BS.Bounded_String := BS.To_Bounded_String ("ABCD");
begin
Test.Check (TC, 232, BS.Equivalent (S1, S2), "BS.Equivalent (S1, S2)");
Test.Check (TC, 233, BS.To_String (S2) = "ABCD", "BS.To_String (S2) = ""ABCD""");
end;
end T_Bstr_Init_01;
|
DrenfongWong/tkm-rpc | Ada | 1,000 | adb | with Tkmrpc.Servers.Ike;
with Tkmrpc.Results;
with Tkmrpc.Request.Ike.Dh_Reset.Convert;
with Tkmrpc.Response.Ike.Dh_Reset.Convert;
package body Tkmrpc.Operation_Handlers.Ike.Dh_Reset is
-------------------------------------------------------------------------
procedure Handle (Req : Request.Data_Type; Res : out Response.Data_Type) is
Specific_Req : Request.Ike.Dh_Reset.Request_Type;
Specific_Res : Response.Ike.Dh_Reset.Response_Type;
begin
Specific_Res := Response.Ike.Dh_Reset.Null_Response;
Specific_Req := Request.Ike.Dh_Reset.Convert.From_Request (S => Req);
if Specific_Req.Data.Dh_Id'Valid then
Servers.Ike.Dh_Reset
(Result => Specific_Res.Header.Result,
Dh_Id => Specific_Req.Data.Dh_Id);
Res := Response.Ike.Dh_Reset.Convert.To_Response (S => Specific_Res);
else
Res.Header.Result := Results.Invalid_Parameter;
end if;
end Handle;
end Tkmrpc.Operation_Handlers.Ike.Dh_Reset;
|
reznikmm/matreshka | Ada | 4,755 | 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.Presentation_Play_Elements;
package Matreshka.ODF_Presentation.Play_Elements is
type Presentation_Play_Element_Node is
new Matreshka.ODF_Presentation.Abstract_Presentation_Element_Node
and ODF.DOM.Presentation_Play_Elements.ODF_Presentation_Play
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Presentation_Play_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Presentation_Play_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Presentation_Play_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 Presentation_Play_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 Presentation_Play_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_Presentation.Play_Elements;
|
zhmu/ananas | Ada | 113 | ads | package Predicate7_Pkg is
subtype My_Int is Integer with Dynamic_Predicate => My_Int /= 0;
end Predicate7_Pkg;
|
Rodeo-McCabe/orka | Ada | 1,827 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 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 Orka.Cameras.Rotate_Around_Cameras is
pragma Preelaborate;
type Rotate_Around_Camera is new Third_Person_Camera with private;
procedure Set_Angles
(Object : in out Rotate_Around_Camera;
Alpha : Angle;
Beta : Angle);
procedure Set_Radius
(Object : in out Rotate_Around_Camera;
Radius : Distance);
overriding
function View_Matrix (Object : Rotate_Around_Camera) return Transforms.Matrix4;
overriding
function View_Matrix_Inverse (Object : Rotate_Around_Camera) return Transforms.Matrix4;
overriding
function View_Position (Object : Rotate_Around_Camera) return Vector4;
overriding
procedure Update (Object : in out Rotate_Around_Camera; Delta_Time : Duration);
overriding
function Create_Camera
(Input : Inputs.Pointers.Pointer_Input_Ptr;
Lens : Lens_Ptr;
FB : aliased Rendering.Framebuffers.Framebuffer) return Rotate_Around_Camera;
private
type Rotate_Around_Camera is new Third_Person_Camera with record
Alpha : Angle := 0.0;
Beta : Angle := 0.0;
Radius : Distance := 1.0;
end record;
end Orka.Cameras.Rotate_Around_Cameras;
|
reznikmm/matreshka | Ada | 5,396 | 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.Generic_Collections;
package AMF.Standard_Profile_L2.Libraries.Collections is
pragma Preelaborate;
package Standard_Profile_L2_Library_Collections is
new AMF.Generic_Collections
(Standard_Profile_L2_Library,
Standard_Profile_L2_Library_Access);
type Set_Of_Standard_Profile_L2_Library is
new Standard_Profile_L2_Library_Collections.Set with null record;
Empty_Set_Of_Standard_Profile_L2_Library : constant Set_Of_Standard_Profile_L2_Library;
type Ordered_Set_Of_Standard_Profile_L2_Library is
new Standard_Profile_L2_Library_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_Standard_Profile_L2_Library : constant Ordered_Set_Of_Standard_Profile_L2_Library;
type Bag_Of_Standard_Profile_L2_Library is
new Standard_Profile_L2_Library_Collections.Bag with null record;
Empty_Bag_Of_Standard_Profile_L2_Library : constant Bag_Of_Standard_Profile_L2_Library;
type Sequence_Of_Standard_Profile_L2_Library is
new Standard_Profile_L2_Library_Collections.Sequence with null record;
Empty_Sequence_Of_Standard_Profile_L2_Library : constant Sequence_Of_Standard_Profile_L2_Library;
private
Empty_Set_Of_Standard_Profile_L2_Library : constant Set_Of_Standard_Profile_L2_Library
:= (Standard_Profile_L2_Library_Collections.Set with null record);
Empty_Ordered_Set_Of_Standard_Profile_L2_Library : constant Ordered_Set_Of_Standard_Profile_L2_Library
:= (Standard_Profile_L2_Library_Collections.Ordered_Set with null record);
Empty_Bag_Of_Standard_Profile_L2_Library : constant Bag_Of_Standard_Profile_L2_Library
:= (Standard_Profile_L2_Library_Collections.Bag with null record);
Empty_Sequence_Of_Standard_Profile_L2_Library : constant Sequence_Of_Standard_Profile_L2_Library
:= (Standard_Profile_L2_Library_Collections.Sequence with null record);
end AMF.Standard_Profile_L2.Libraries.Collections;
|
zhmu/ananas | Ada | 3,615 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- H O S T P A R M --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
-- This package defines some system dependent parameters for GNAT. These
-- are parameters that are relevant to the host machine on which the
-- compiler is running, and thus this package is part of the compiler.
with Types;
package Hostparm is
---------------------
-- HOST Parameters --
---------------------
Direct_Separator : constant Character;
pragma Import (C, Direct_Separator, "__gnat_dir_separator");
Normalized_CWD : constant String := "." & Direct_Separator;
-- Normalized string to access current directory
Max_Line_Length : constant :=
Types.Column_Number'Pred (Types.Column_Number'Last);
-- Maximum source line length. By default we set it to the maximum
-- value that can be supported, which is given by the range of the
-- Column_Number type. We subtract 1 because need to be able to
-- have a valid Column_Number equal to Max_Line_Length to represent
-- the location of a "line too long" error.
--
-- 200 is the minimum value required (RM 2.2(15)). The value set here
-- can be reduced by the explicit use of the -gnatyM style switch.
Max_Name_Length : constant := 1024;
-- Maximum length of unit name (including all dots, and " (spec)") and
-- of file names in the library, must be at least Max_Line_Length, but
-- can be larger.
Tag_Errors : constant Boolean := True;
-- If set to true, then brief form error messages will be prefaced by
-- the string "error:". Used as default for Opt.Unique_Error_Tag. Disabled
-- by gnatd_U.
Exclude_Missing_Objects : constant Boolean := True;
-- If set to true, gnatbind will exclude from consideration all
-- non-existent .o files.
end Hostparm;
|
reznikmm/matreshka | Ada | 3,663 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, 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.Attributes.Style.Vertical_Align is
type ODF_Style_Vertical_Align is
new XML.DOM.Attributes.DOM_Attribute with private;
private
type ODF_Style_Vertical_Align is
new XML.DOM.Attributes.DOM_Attribute with null record;
end ODF.DOM.Attributes.Style.Vertical_Align;
|
optikos/oasis | Ada | 6,254 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Defining_Identifiers;
with Program.Lexical_Elements;
with Program.Elements.Subtype_Indications;
with Program.Elements.Expressions;
with Program.Elements.Element_Iterator_Specifications;
with Program.Element_Visitors;
package Program.Nodes.Element_Iterator_Specifications is
pragma Preelaborate;
type Element_Iterator_Specification is
new Program.Nodes.Node
and Program.Elements.Element_Iterator_Specifications
.Element_Iterator_Specification
and Program.Elements.Element_Iterator_Specifications
.Element_Iterator_Specification_Text
with private;
function Create
(Name : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
Colon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Subtype_Indication : not null Program.Elements.Subtype_Indications
.Subtype_Indication_Access;
Of_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Reverse_Token : Program.Lexical_Elements.Lexical_Element_Access;
Iterable_Name : not null Program.Elements.Expressions
.Expression_Access)
return Element_Iterator_Specification;
type Implicit_Element_Iterator_Specification is
new Program.Nodes.Node
and Program.Elements.Element_Iterator_Specifications
.Element_Iterator_Specification
with private;
function Create
(Name : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
Subtype_Indication : not null Program.Elements.Subtype_Indications
.Subtype_Indication_Access;
Iterable_Name : 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;
Has_Reverse : Boolean := False)
return Implicit_Element_Iterator_Specification
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Element_Iterator_Specification is
abstract new Program.Nodes.Node
and Program.Elements.Element_Iterator_Specifications
.Element_Iterator_Specification
with record
Name : not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
Subtype_Indication : not null Program.Elements.Subtype_Indications
.Subtype_Indication_Access;
Iterable_Name : not null Program.Elements.Expressions
.Expression_Access;
end record;
procedure Initialize
(Self : aliased in out Base_Element_Iterator_Specification'Class);
overriding procedure Visit
(Self : not null access Base_Element_Iterator_Specification;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Name
(Self : Base_Element_Iterator_Specification)
return not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access;
overriding function Subtype_Indication
(Self : Base_Element_Iterator_Specification)
return not null Program.Elements.Subtype_Indications
.Subtype_Indication_Access;
overriding function Iterable_Name
(Self : Base_Element_Iterator_Specification)
return not null Program.Elements.Expressions.Expression_Access;
overriding function Is_Element_Iterator_Specification_Element
(Self : Base_Element_Iterator_Specification)
return Boolean;
overriding function Is_Declaration_Element
(Self : Base_Element_Iterator_Specification)
return Boolean;
type Element_Iterator_Specification is
new Base_Element_Iterator_Specification
and Program.Elements.Element_Iterator_Specifications
.Element_Iterator_Specification_Text
with record
Colon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Of_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Reverse_Token : Program.Lexical_Elements.Lexical_Element_Access;
end record;
overriding function To_Element_Iterator_Specification_Text
(Self : aliased in out Element_Iterator_Specification)
return Program.Elements.Element_Iterator_Specifications
.Element_Iterator_Specification_Text_Access;
overriding function Colon_Token
(Self : Element_Iterator_Specification)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Of_Token
(Self : Element_Iterator_Specification)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Reverse_Token
(Self : Element_Iterator_Specification)
return Program.Lexical_Elements.Lexical_Element_Access;
overriding function Has_Reverse
(Self : Element_Iterator_Specification)
return Boolean;
type Implicit_Element_Iterator_Specification is
new Base_Element_Iterator_Specification
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
Has_Reverse : Boolean;
end record;
overriding function To_Element_Iterator_Specification_Text
(Self : aliased in out Implicit_Element_Iterator_Specification)
return Program.Elements.Element_Iterator_Specifications
.Element_Iterator_Specification_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Element_Iterator_Specification)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Element_Iterator_Specification)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Element_Iterator_Specification)
return Boolean;
overriding function Has_Reverse
(Self : Implicit_Element_Iterator_Specification)
return Boolean;
end Program.Nodes.Element_Iterator_Specifications;
|
reznikmm/matreshka | Ada | 3,679 | 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.Form_Image_Frame_Elements is
pragma Preelaborate;
type ODF_Form_Image_Frame is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Form_Image_Frame_Access is
access all ODF_Form_Image_Frame'Class
with Storage_Size => 0;
end ODF.DOM.Form_Image_Frame_Elements;
|
davidkristola/vole | Ada | 12,248 | adb | with Ada.Exceptions; use Ada.Exceptions;
with Ada.Text_IO;
with kv.avm.Log; use kv.avm.Log;
with kv.avm.Messages;
with kv.avm.Actor_Pool;
with kv.avm.Executables;
with kv.avm.Clients;
with kv.avm.Transactions.Basic;
package body kv.avm.Routers is
use Interfaces;
use kv.avm.Control;
-----------------------------------------------------------------------------
procedure Initialize
(Self : in out Router_Type;
Machine : in kv.avm.Control.Control_Access) is
My_Data : Router_Data_Access := Self.Ref.Get;
begin
My_Data.Machine := Machine;
end Initialize;
-----------------------------------------------------------------------------
function Get_Queue_Size(Self : Router_Type) return Natural is
My_Data : Router_Data_Access := Self.Ref.Get;
begin
return Natural(My_Data.Queue.Length);
end Get_Queue_Size;
-----------------------------------------------------------------------------
procedure Set_Queue_Limit(Self : in out Router_Type; Queue_Limit : in Natural) is
My_Data : Router_Data_Access := Self.Ref.Get;
begin
My_Data.Queue_Limit := Queue_Limit;
end Set_Queue_Limit;
-----------------------------------------------------------------------------
procedure Deliver_Local_Message
(My_Data : in Router_Data_Access;
Message : in kv.avm.Messages.Message_Type;
Instance : in kv.avm.Executables.Executable_Access;
Status : out kv.avm.Control.Status_Type) is
begin
Status := kv.avm.Control.Active;
--Put_Line("Machine Message Queue: expediting "&Message.Get_Name);
Instance.Process_Message(Message);
My_Data.Machine.Activate_Instance(Message.Get_Destination);
exception
when Error: others =>
Put_Error("EXCEPTION (in Deliver_Local_Message): " & Exception_Information(Error));
raise;
end Deliver_Local_Message;
-----------------------------------------------------------------------------
function Is_Queue_Too_Full(My_Data : Router_Data_Access) return Boolean is
begin
return (Natural(My_Data.Queue.Length) >= My_Data.Queue_Limit);
end Is_Queue_Too_Full;
-----------------------------------------------------------------------------
procedure Queue_Message
(My_Data : in Router_Data_Access;
Message : in kv.avm.Messages.Message_Type;
Instance : in kv.avm.Executables.Executable_Access;
Status : out kv.avm.Control.Status_Type) is
begin
if Is_Queue_Too_Full(My_Data) then
-- By refusing to queue the message (and setting the status to Deferred),
-- we will cause the machine to suspend execution of the actor instance
-- until such time that it can attempt to post the message again.
--
--Put_Line("Machine Message Queue: refusing " & Message.Get_Name);
Status := kv.avm.Control.Deferred;
else
--Put_Line("Machine Message Queue: queueing " & Message.Get_Name);
My_Data.Queue.Append((Message => Message, Instance => Instance));
Status := kv.avm.Control.Active;
end if;
exception
when Error: others =>
Put_Error("EXCEPTION (in Queue_Message): " & Exception_Information(Error));
raise;
end Queue_Message;
-----------------------------------------------------------------------------
procedure Post_Local_Message
(My_Data : in Router_Data_Access;
Message : in kv.avm.Messages.Message_Type;
Status : out kv.avm.Control.Status_Type) is
Instance : kv.avm.Executables.Executable_Access;
begin
Instance := kv.avm.Actor_Pool.Resolve(Message.Get_Destination);
if Instance.Can_Accept_Message_Now(Message) then
Deliver_Local_Message(My_Data, Message, Instance, Status);
else
Queue_Message(My_Data, Message, Instance, Status);
end if;
exception
when Error: others =>
Put_Error("EXCEPTION (in Post_Local_Message): " & Exception_Information(Error));
raise;
end Post_Local_Message;
-----------------------------------------------------------------------------
procedure Post_Remote_Message
(My_Data : in Router_Data_Access;
Message : in kv.avm.Messages.Message_Type;
Status : out kv.avm.Control.Status_Type) is
Destination : kv.avm.Actor_References.Actor_Reference_Type;
Domain : Interfaces.Unsigned_32;
Domain_Client : kv.avm.Clients.Client_Access;
Send_Transaction : kv.avm.Transactions.Basic.Send_Message_Type;
use kv.avm.Clients;
begin
Put_Line("Post_Remote_Message " & Message.Debug);
--!@#$ find the domain's affiliate, create a transaction, send
Status := kv.avm.Control.Active;
Destination := Message.Get_Destination;
Domain := Destination.Get_Domain;
Domain_Client := My_Data.Affiliator.Get_Domain_Client(Domain);
if Domain_Client = null then
Put_Error("ERROR: Could not find client for" & Destination.Image);
Status := kv.avm.Control.Error;
return;
end if;
Send_Transaction.Set_Message(Message);
Domain_Client.Send_Transaction(Send_Transaction);
exception
when Error: others =>
Put_Error("EXCEPTION (in Post_Remote_Message): " & Exception_Information(Error));
raise;
end Post_Remote_Message;
-----------------------------------------------------------------------------
procedure Post_Message
(Self : in out Router_Type;
Message : in kv.avm.Messages.Message_Type;
Status : out kv.avm.Control.Status_Type) is
My_Data : Router_Data_Access := Self.Ref.Get;
begin
if Message.Get_Destination.Is_Local then
Post_Local_Message(My_Data, Message, Status);
else
Post_Remote_Message(My_Data, Message, Status);
end if;
exception
when Error: others =>
Put_Error("EXCEPTION (in Post_Message): " & Exception_Information(Error));
raise;
end Post_Message;
-----------------------------------------------------------------------------
procedure Post_Local_Response
(My_Data : in Router_Data_Access;
Reply_To : in kv.avm.Actor_References.Actor_Reference_Type;
Answer : in kv.avm.Tuples.Tuple_Type;
Future : in Interfaces.Unsigned_32) is
Instance : kv.avm.Executables.Executable_Access;
begin
Instance := kv.avm.actor_pool.Resolve(Reply_To);
Put_Line("Sending Future=" & Interfaces.Unsigned_32'IMAGE(Future) & " to local instance=" & Instance.Image);
Instance.Resolve_Future(Answer, Future);
My_Data.Machine.Activate_Instance(Reply_To);
exception
when Error: others =>
Put_Error("EXCEPTION (in Post_Local_Response): " & Exception_Information(Error));
raise;
end Post_Local_Response;
-----------------------------------------------------------------------------
procedure Post_Remote_Response
(My_Data : in Router_Data_Access;
Reply_To : in kv.avm.Actor_References.Actor_Reference_Type;
Answer : in kv.avm.Tuples.Tuple_Type;
Future : in Interfaces.Unsigned_32) is
Domain : Interfaces.Unsigned_32;
Domain_Client : kv.avm.Clients.Client_Access;
Response_Transaction : kv.avm.Transactions.Basic.Reply_Transaction_Type;
use kv.avm.Clients;
begin
Put_Line("Sending Future=" & Interfaces.Unsigned_32'IMAGE(Future) & " to remote actor=" & Reply_To.Image);
Domain := Reply_To.Get_Domain;
Domain_Client := My_Data.Affiliator.Get_Domain_Client(Domain);
if Domain_Client = null then
Put_Error("ERROR: Could not find client for" & Reply_To.Image);
return;
end if;
Response_Transaction.Set_Reply_To(Reply_To);
Response_Transaction.Set_Data(Answer);
Response_Transaction.Set_Future(Future);
Domain_Client.Send_Transaction(Response_Transaction);
exception
when Error: others =>
Put_Error("EXCEPTION (in Post_Remote_Response): " & Exception_Information(Error));
raise;
end Post_Remote_Response;
-----------------------------------------------------------------------------
procedure Post_Response
(Self : in out Router_Type;
Reply_To : in kv.avm.Actor_References.Actor_Reference_Type;
Answer : in kv.avm.Tuples.Tuple_Type;
Future : in Interfaces.Unsigned_32) is
My_Data : Router_Data_Access := Self.Ref.Get;
use kv.avm.Actor_References;
begin
Put_Line("kv.avm.machine.Post_Response "&Reply_To.Image);
if Future = kv.avm.control.NO_FUTURE then
Put_Line("Dropping unwanted response.");
return;
end if;
if Reply_To = kv.avm.Actor_References.Null_Reference then
Put_Line("Dropping unaddressed response.");
return;
end if;
if Reply_To.Is_Local then
Post_Local_Response(My_Data, Reply_To, Answer, Future);
else
Post_Remote_Response(My_Data, Reply_To, Answer, Future);
end if;
exception
when Error: others =>
Put_Error("EXCEPTION (in Post_Response): " & Exception_Information(Error));
raise;
end Post_Response;
-----------------------------------------------------------------------------
procedure Deliver_Messages
(Self : in out Router_Type) is
My_Data : Router_Data_Access := Self.Ref.Get;
Current : Message_Queue.Cursor;
Go_Next : Message_Queue.Cursor;
Data : Message_Control_Type;
use Message_Queue;
begin
--!@#$ need to refactor this because it takes much too much time
--!@#$ idea: keep a map of queues indexed by recipient
--!@#$ check first Can_Accept_Some_Message_Now and if true try the messages
--!@#$ else skip rest of messages queued to this instance
Current := My_Data.Queue.First;
loop
exit when Current = No_Element;
Data := Element(Current);
--!@#$ Message.Get_Destination.Is_Local
if Data.Instance.Can_Accept_Message_Now(Data.Message) then
Put_Line("Machine Message Queue: delivering " & Data.Message.Get_Name & ", leaving " & Natural'IMAGE(Natural(My_Data.Queue.Length)-1) & " in the queue.");
Data.Instance.Process_Message(Data.Message);
My_Data.Machine.Activate_Instance(Data.Message.Get_Destination); -- Data.Instance);
Go_Next := Next(Current);
My_Data.Queue.Delete(Current);
else
Put_Line("Machine Message Queue: holding "&Data.Message.Get_Name);
Go_Next := Next(Current);
end if;
Current := Go_Next;
end loop;
exception
when Error: others =>
Put_Error("EXCEPTION (in Deliver_Messages): " & Exception_Information(Error));
raise;
end Deliver_Messages;
-----------------------------------------------------------------------------
function Reachable_From_Messages(Self : Router_Type) return kv.avm.Actor_References.Sets.Set is
My_Data : Router_Data_Access := Self.Ref.Get;
use kv.avm.Actor_References.Sets;
use Message_Queue;
Could_Run : Set := Empty_Set;
Message : Message_Queue.Cursor;
begin
Message := My_Data.Queue.First;
while Message /= Message_Queue.No_Element loop
Could_Run.Include(Element(Message).Message.Get_Source);
Could_Run.Include(Element(Message).Message.Get_Reply_To);
Could_Run.Include(Element(Message).Message.Get_Destination);
Could_Run.Union(Element(Message).Message.Reachable);
Next(Message);
end loop;
return Could_Run;
exception
when Error: others =>
Put_Error("EXCEPTION (in Reachable_From_Messages): " & Exception_Information(Error));
raise;
end Reachable_From_Messages;
-----------------------------------------------------------------------------
function Get_Affiliator(Self : Router_Type) return kv.avm.Affiliates.Affiliates_Type is
My_Data : Router_Data_Access := Self.Ref.Get;
begin
return My_Data.Affiliator;
end Get_Affiliator;
end kv.avm.Routers;
|
ohenley/black | Ada | 793 | ads | package Black.HTTP is
pragma Pure;
Version : constant String;
type Methods is (Options, Get, Head, Post, Put, Delete, Trace, Connect);
type Statuses is (Switching_Protocols,
OK,
No_Content,
Moved_Permanently,
Moved_Temporarily,
Bad_Request,
Unauthorized,
Forbidden,
Not_Found,
Server_Error);
function Status_Line (Status : in Statuses) return String;
type Header_Key is new String;
overriding
function "=" (Left, Right : in Header_Key) return Boolean;
type Websocket_Accept_Key is new String (1 .. 28);
private
Version : constant String := "HTTP/1.1";
end Black.HTTP;
|
reznikmm/matreshka | Ada | 4,261 | 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.Definitions;
package body Properties.Definitions.Simple_Expression_Range is
-----------
-- Lower --
-----------
function Lower
(Engine : access Engines.Contexts.Context;
Element : Asis.Expression;
Name : Engines.Text_Property) return League.Strings.Universal_String
is
pragma Unreferenced (Name);
begin
return Engine.Text.Get_Property
(Asis.Definitions.Lower_Bound (Element), Engines.Code);
end Lower;
-----------
-- Upper --
-----------
function Upper
(Engine : access Engines.Contexts.Context;
Element : Asis.Expression;
Name : Engines.Text_Property) return League.Strings.Universal_String
is
pragma Unreferenced (Name);
begin
return Engine.Text.Get_Property
(Asis.Definitions.Upper_Bound (Element), Engines.Code);
end Upper;
end Properties.Definitions.Simple_Expression_Range;
|
AdaCore/Ada-IntelliJ | Ada | 1,638 | adb |
with AWS.Config.Set;
with AWS.Server;
with AWS.Services.Dispatchers.URI;
with AWS.Services.Web_Block.Registry;
with @[email protected];
with WBlocks;
procedure @[email protected] is
use AWS;
Web_Server : Server.HTTP;
Web_Config : Config.Object;
Web_Dispatcher : Services.Dispatchers.URI.Handler;
Default_Dispatcher : Dispatchers.Default;
CSS_Dispatcher : Dispatchers.CSS;
JS_Dispatcher : Dispatchers.JS;
Image_Dispatcher : Dispatchers.Image;
begin
-- Setup server
Config.Set.Server_Host (Web_Config, Host);
Config.Set.Server_Port (Web_Config, Port);
-- Setup dispatchers
Dispatchers.Initialize (Web_Config);
Services.Dispatchers.URI.Register
(Web_Dispatcher,
URI => "/css/",
Action => CSS_Dispatcher,
Prefix => True);
Services.Dispatchers.URI.Register
(Web_Dispatcher,
URI => "/js/",
Action => JS_Dispatcher,
Prefix => True);
Services.Dispatchers.URI.Register
(Web_Dispatcher,
URI => "/img/",
Action => Image_Dispatcher,
Prefix => True);
Services.Dispatchers.URI.Register_Default_Callback
(Web_Dispatcher,
Action => Default_Dispatcher);
-- Register Web blocks
WBlocks.Lazy.Register;
-- Register all Web pages
Services.Web_Block.Registry.Register
("/", "tmplt/main.thtml", null);
-- Start the server
Server.Start (Web_Server, Web_Dispatcher, Web_Config);
-- Wait for the Q key
Server.Wait (Server.Q_Key_Pressed);
-- Stop the server
Server.Shutdown (Web_Server);
end @[email protected];
|
stcarrez/ada-css | Ada | 3,151 | ads | -----------------------------------------------------------------------
-- css-core-sheets -- CSS stylesheet representation
-- Copyright (C) 2017, 2023 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 CSS.Core.Styles;
with CSS.Core.Vectors;
with CSS.Core.Values;
with CSS.Core.Properties;
with CSS.Core.Medias;
package CSS.Core.Sheets is
type CSSStylesheet is new CSS.Core.Stylesheet with record
Rules : CSS.Core.Vectors.Vector;
Values : CSS.Core.Values.Repository_Type;
end record;
type CSSStylesheet_Access is access all CSSStylesheet'Class;
-- Create a CSS rule.
function Create_Rule (Document : in CSSStylesheet) return Styles.CSSStyleRule_Access;
-- Create a CSS font-face rule.
function Create_Rule (Document : in CSSStylesheet) return Styles.CSSFontfaceRule_Access;
-- Create a CSS media rule.
function Create_Rule (Document : in CSSStylesheet) return Medias.CSSMediaRule_Access;
-- Append the CSS rule to the document.
procedure Append (Document : in out CSSStylesheet;
Rule : in Styles.CSSStyleRule_Access;
Line : in Natural;
Column : in Natural);
-- Append the media rule to the document.
procedure Append (Document : in out CSSStylesheet;
Rule : in Medias.CSSMediaRule_Access;
Line : in Natural;
Column : in Natural);
-- Append the font-face rule to the document.
procedure Append (Document : in out CSSStylesheet;
Rule : in Styles.CSSFontfaceRule_Access;
Line : in Natural;
Column : in Natural);
-- Append the CSS rule to the media.
procedure Append (Document : in out CSSStylesheet;
Media : in Medias.CSSMediaRule_Access;
Rule : in Styles.CSSStyleRule_Access;
Line : in Natural;
Column : in Natural);
-- Iterate over the properties of each CSS rule. The <tt>Process</tt> procedure
-- is called with the CSS rule and the property as parameter.
procedure Iterate_Properties (Document : in CSSStylesheet;
Process : not null access
procedure (Rule : in Styles.CSSStyleRule'Class;
Property : in Properties.CSSProperty));
end CSS.Core.Sheets;
|
mirror/ncurses | Ada | 10,740 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- Sample.Form_Demo.Aux --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright 2020 Thomas E. Dickey --
-- Copyright 1998-2004,2009 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.18 $
-- $Date: 2020/02/02 23:34:34 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
with Sample.Manifest; use Sample.Manifest;
with Sample.Helpers; use Sample.Helpers;
with Sample.Keyboard_Handler; use Sample.Keyboard_Handler;
with Sample.Explanation; use Sample.Explanation;
package body Sample.Form_Demo.Aux is
procedure Geometry (F : Form;
L : out Line_Count; -- Lines used for menu
C : out Column_Count; -- Columns used for menu
Y : out Line_Position; -- Proposed Line for menu
X : out Column_Position) -- Proposed Column for menu
is
begin
Scale (F, L, C);
L := L + 2; -- count for frame at top and bottom
C := C + 2; -- "
-- Calculate horizontal coordinate at the screen center
X := (Columns - C) / 2;
Y := 1; -- start always in line 1
end Geometry;
function Create (F : Form;
Title : String;
Lin : Line_Position;
Col : Column_Position) return Panel
is
W, S : Window;
L : Line_Count;
C : Column_Count;
Y : Line_Position;
X : Column_Position;
Pan : Panel;
begin
Geometry (F, L, C, Y, X);
W := New_Window (L, C, Lin, Col);
Set_Meta_Mode (W);
Set_KeyPad_Mode (W);
if Has_Colors then
Set_Background (Win => W,
Ch => (Ch => ' ',
Color => Default_Colors,
Attr => Normal_Video));
Set_Character_Attributes (Win => W,
Color => Default_Colors,
Attr => Normal_Video);
Erase (W);
end if;
S := Derived_Window (W, L - 2, C - 2, 1, 1);
Set_Meta_Mode (S);
Set_KeyPad_Mode (S);
Box (W);
Set_Window (F, W);
Set_Sub_Window (F, S);
if Title'Length > 0 then
Window_Title (W, Title);
end if;
Pan := New_Panel (W);
Post (F);
return Pan;
end Create;
procedure Destroy (F : Form;
P : in out Panel)
is
W, S : Window;
begin
W := Get_Window (F);
S := Get_Sub_Window (F);
Post (F, False);
Erase (W);
Delete (P);
Set_Window (F, Null_Window);
Set_Sub_Window (F, Null_Window);
Delete (S);
Delete (W);
Update_Panels;
end Destroy;
function Get_Request (F : Form;
P : Panel;
Handle_CRLF : Boolean := True) return Key_Code
is
W : constant Window := Get_Window (F);
K : Real_Key_Code;
Ch : Character;
begin
Top (P);
loop
K := Get_Key (W);
if K in Special_Key_Code'Range then
case K is
when HELP_CODE => Explain_Context;
when EXPLAIN_CODE => Explain ("FORMKEYS");
when Key_Home => return F_First_Field;
when Key_End => return F_Last_Field;
when QUIT_CODE => return QUIT;
when Key_Cursor_Down => return F_Down_Char;
when Key_Cursor_Up => return F_Up_Char;
when Key_Cursor_Left => return F_Previous_Char;
when Key_Cursor_Right => return F_Next_Char;
when Key_Next_Page => return F_Next_Page;
when Key_Previous_Page => return F_Previous_Page;
when Key_Backspace => return F_Delete_Previous;
when Key_Clear_Screen => return F_Clear_Field;
when Key_Clear_End_Of_Line => return F_Clear_EOF;
when others => return K;
end case;
elsif K in Normal_Key_Code'Range then
Ch := Character'Val (K);
case Ch is
when CAN => return QUIT; -- CTRL-X
when ACK => return F_Next_Field; -- CTRL-F
when STX => return F_Previous_Field; -- CTRL-B
when FF => return F_Left_Field; -- CTRL-L
when DC2 => return F_Right_Field; -- CTRL-R
when NAK => return F_Up_Field; -- CTRL-U
when EOT => return F_Down_Field; -- CTRL-D
when ETB => return F_Next_Word; -- CTRL-W
when DC4 => return F_Previous_Word; -- CTRL-T
when SOH => return F_Begin_Field; -- CTRL-A
when ENQ => return F_End_Field; -- CTRL-E
when HT => return F_Insert_Char; -- CTRL-I
when SI => return F_Insert_Line; -- CTRL-O
when SYN => return F_Delete_Char; -- CTRL-V
when BS => return F_Delete_Previous; -- CTRL-H
when EM => return F_Delete_Line; -- CTRL-Y
when BEL => return F_Delete_Word; -- CTRL-G
when VT => return F_Clear_EOF; -- CTRL-K
when SO => return F_Next_Choice; -- CTRL-N
when DLE => return F_Previous_Choice; -- CTRL-P
when CR | LF =>
if Handle_CRLF then
return F_New_Line;
else
return K;
end if;
when others => return K;
end case;
else
return K;
end if;
end loop;
end Get_Request;
function Make (Top : Line_Position;
Left : Column_Position;
Text : String) return Field
is
Fld : Field;
C : constant Column_Count := Column_Count (Text'Length);
begin
Fld := New_Field (1, C, Top, Left);
Set_Buffer (Fld, 0, Text);
Switch_Options (Fld, (Active => True, others => False), False);
if Has_Colors then
Set_Background (Fld => Fld, Color => Default_Colors);
end if;
return Fld;
end Make;
function Make (Height : Line_Count := 1;
Width : Column_Count;
Top : Line_Position;
Left : Column_Position;
Off_Screen : Natural := 0) return Field
is
Fld : constant Field := New_Field (Height, Width, Top, Left, Off_Screen);
begin
if Has_Colors then
Set_Foreground (Fld => Fld, Color => Form_Fore_Color);
Set_Background (Fld => Fld, Color => Form_Back_Color);
else
Set_Background (Fld, (Reverse_Video => True, others => False));
end if;
return Fld;
end Make;
function Default_Driver (F : Form;
K : Key_Code;
P : Panel) return Boolean
is
begin
if P = Null_Panel then
raise Panel_Exception;
end if;
if K in User_Key_Code'Range and then K = QUIT then
if Driver (F, F_Validate_Field) = Form_Ok then
return True;
end if;
end if;
return False;
end Default_Driver;
function Count_Active (F : Form) return Natural
is
N : Natural := 0;
O : Field_Option_Set;
H : constant Natural := Field_Count (F);
begin
if H > 0 then
for I in 1 .. H loop
Get_Options (Fields (F, I), O);
if O.Active then
N := N + 1;
end if;
end loop;
end if;
return N;
end Count_Active;
end Sample.Form_Demo.Aux;
|
damaki/libkeccak | Ada | 9,679 | adb | -------------------------------------------------------------------------------
-- Copyright (c) 2019, Daniel King
-- 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.
-- * The name of the copyright holder may not 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 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 Interfaces; use Interfaces;
package body Keccak.Generic_KeccakF.Bit_Lanes
is
---------------------------
-- XOR_Bits_Into_State --
---------------------------
procedure XOR_Bits_Into_State (A : in out State;
Data : in Keccak.Types.Byte_Array;
Bit_Len : in Natural)
is
X : X_Coord := 0;
Y : Y_Coord := 0;
Remaining_Bits : Natural := Bit_Len;
Offset : Natural := 0;
Initial_Byte_Len : constant Natural := (Bit_Len + 7) / 8 with Ghost;
begin
while Remaining_Bits >= 8 loop
pragma Loop_Variant (Increases => Offset,
Decreases => Remaining_Bits);
pragma Loop_Invariant (Offset + ((Remaining_Bits + 7) / 8) = Initial_Byte_Len);
declare
Byte : constant Keccak.Types.Byte := Data (Data'First + Offset);
Lane : Lane_Type;
begin
for I in Natural range 0 .. (8 / Lane_Size_Bits) - 1 loop
Lane := Lane_Type (Shift_Right (Byte,
I * Lane_Size_Bits) and (2**Lane_Size_Bits - 1));
A (X, Y) := A (X, Y) xor Lane;
X := X + 1;
if X = 0 then
Y := Y + 1;
end if;
end loop;
end;
Remaining_Bits := Remaining_Bits - 8;
Offset := Offset + 1;
end loop;
if Remaining_Bits > 0 then
declare
Byte : Keccak.Types.Byte;
Lane : Lane_Type;
begin
Byte := Data (Data'First + Offset) and (2**Remaining_Bits - 1);
for I in Natural range 0 .. (8 / Lane_Size_Bits) - 1 loop
Lane := Lane_Type (Shift_Right (Byte,
I * Lane_Size_Bits) and (2**Lane_Size_Bits - 1));
A (X, Y) := A (X, Y) xor Lane;
X := X + 1;
if X = 0 then
Y := Y + 1;
end if;
exit when X = 0 and Y = 0;
end loop;
end;
end if;
end XOR_Bits_Into_State;
---------------------------
-- XOR_Bits_Into_State --
---------------------------
procedure XOR_Bits_Into_State (A : in out Lane_Complemented_State;
Data : in Keccak.Types.Byte_Array;
Bit_Len : in Natural)
is
begin
XOR_Bits_Into_State
(A => State (A),
Data => Data,
Bit_Len => Bit_Len);
end XOR_Bits_Into_State;
---------------------
-- Extract_Bytes --
---------------------
procedure Extract_Bytes (A : in State;
Data : out Keccak.Types.Byte_Array)
is
X : X_Coord := 0;
Y : Y_Coord := 0;
Remaining_Bytes : Natural := Data'Length;
Offset : Natural := 0;
Byte : Keccak.Types.Byte;
begin
Data := (others => 0); -- workaround for flow analysis.
-- Process entire bytes
while Remaining_Bytes > 0 and Offset < State_Size_Bits / 8 loop
pragma Loop_Variant (Increases => Offset,
Decreases => Remaining_Bytes);
pragma Loop_Invariant (Offset + Remaining_Bytes = Data'Length);
Byte := 0;
for I in Natural range 0 .. (8 / Lane_Size_Bits) - 1 loop
Byte := Byte or Shift_Left (Keccak.Types.Byte (A (X, Y)),
I * Lane_Size_Bits);
X := X + 1;
if X = 0 then
Y := Y + 1;
end if;
end loop;
Data (Data'First + Offset) := Byte;
Remaining_Bytes := Remaining_Bytes - 1;
Offset := Offset + 1;
end loop;
if Remaining_Bytes > 0 then
pragma Assert (Remaining_Bytes = 1);
Byte := 0;
for I in Natural range 0 .. (8 / Lane_Size_Bits) - 1 loop
Byte := Byte or Shift_Left (Keccak.Types.Byte (A (X, Y)),
I * Lane_Size_Bits);
X := X + 1;
if X = 0 then
Y := Y + 1;
end if;
exit when X = 0 and Y = 0;
end loop;
Data (Data'First + Offset) := Byte;
end if;
end Extract_Bytes;
---------------------
-- Extract_Bytes --
---------------------
procedure Extract_Bytes (A : in Lane_Complemented_State;
Data : out Keccak.Types.Byte_Array)
is
Complement_Mask : constant Lane_Complemented_State :=
(0 => (4 => Lane_Type'Last,
others => 0),
1 => (0 => Lane_Type'Last,
others => 0),
2 => (0 | 2 | 3 => Lane_Type'Last,
others => 0),
3 => (1 => Lane_Type'Last,
others => 0),
4 => (others => 0));
X : X_Coord := 0;
Y : Y_Coord := 0;
Remaining_Bytes : Natural := Data'Length;
Offset : Natural := 0;
Byte : Keccak.Types.Byte;
Lane : Lane_Type;
begin
Data := (others => 0); -- workaround for flow analysis.
-- Process entire bytes
while Remaining_Bytes > 0 and Offset < State_Size_Bits / 8 loop
pragma Loop_Variant (Increases => Offset,
Decreases => Remaining_Bytes);
pragma Loop_Invariant (Offset + Remaining_Bytes = Data'Length);
Byte := 0;
for I in Natural range 0 .. (8 / Lane_Size_Bits) - 1 loop
Lane := A (X, Y) xor Complement_Mask (X, Y);
Byte := Byte or Shift_Left (Keccak.Types.Byte (Lane), I * Lane_Size_Bits);
X := X + 1;
if X = 0 then
Y := Y + 1;
end if;
end loop;
Data (Data'First + Offset) := Byte;
Remaining_Bytes := Remaining_Bytes - 1;
Offset := Offset + 1;
end loop;
if Remaining_Bytes > 0 then
pragma Assert (Remaining_Bytes = 1);
Byte := 0;
for I in Natural range 0 .. (8 / Lane_Size_Bits) - 1 loop
Lane := A (X, Y) xor Complement_Mask (X, Y);
Byte := Byte or Shift_Left (Keccak.Types.Byte (Lane), I * Lane_Size_Bits);
X := X + 1;
if X = 0 then
Y := Y + 1;
end if;
exit when X = 0 and Y = 0;
end loop;
Data (Data'First + Offset) := Byte;
end if;
end Extract_Bytes;
--------------------
-- Extract_Bits --
--------------------
procedure Extract_Bits (A : in State;
Data : out Keccak.Types.Byte_Array;
Bit_Len : in Natural)
is
begin
Extract_Bytes (A, Data);
-- Avoid exposing more bits than requested by masking away higher bits
-- in the last byte.
if Bit_Len > 0 and Bit_Len mod 8 /= 0 then
Data (Data'Last) := Data (Data'Last) and (2**(Bit_Len mod 8) - 1);
end if;
end Extract_Bits;
--------------------
-- Extract_Bits --
--------------------
procedure Extract_Bits (A : in Lane_Complemented_State;
Data : out Keccak.Types.Byte_Array;
Bit_Len : in Natural)
is
begin
Extract_Bytes (A, Data);
-- Avoid exposing more bits than requested by masking away higher bits
-- in the last byte.
if Bit_Len > 0 and Bit_Len mod 8 /= 0 then
Data (Data'Last) := Data (Data'Last) and (2**(Bit_Len mod 8) - 1);
end if;
end Extract_Bits;
end Keccak.Generic_KeccakF.Bit_Lanes;
|
gitter-badger/libAnne | Ada | 127 | ads | package Containers.Lists with Pure is
--@description Base package for various lists
--@version 1.0.0
end Containers.Lists;
|
zhmu/ananas | Ada | 327 | adb | -- { dg-do run }
-- { dg-options "-gnatws" }
with Discr32_Pkg; use Discr32_Pkg;
procedure Discr32 is
begin
if R1'Object_Size /= 32 then
raise Program_Error;
end if;
if R2'Object_Size /= R'Object_Size then
raise Program_Error;
end if;
if R3'Object_Size /= 64 then
raise Program_Error;
end if;
end;
|
charlie5/cBound | Ada | 1,806 | ads | -- This file is generated by SWIG. Please do *not* modify by hand.
--
with Interfaces.C;
with clib.lconv;
with Interfaces.C.Pointers;
with Interfaces.C.Strings;
with System;
package clib.Binding is
function setlocale
(a_a_category : in Interfaces.C.int;
a_a_locale : in Interfaces.C.Strings.chars_ptr)
return Interfaces.C.Strings.chars_ptr;
function localeconv return access clib.lconv.Item;
function lc_CTYPE return Interfaces.C.int;
function lc_NUMERIC return Interfaces.C.int;
function lc_TIME return Interfaces.C.int;
function lc_COLLATE return Interfaces.C.int;
function lc_MONETARY return Interfaces.C.int;
function lc_MESSAGES return Interfaces.C.int;
function lc_ALL return Interfaces.C.int;
function lc_PAPER return Interfaces.C.int;
function lc_NAME return Interfaces.C.int;
function lc_ADDRESS return Interfaces.C.int;
function lc_TELEPHONE return Interfaces.C.int;
function lc_MEASUREMENT return Interfaces.C.int;
function lc_IDENTIFICATION return Interfaces.C.int;
private
pragma Import (C, setlocale, "setlocale");
pragma Import (C, localeconv, "localeconv");
pragma Import (C, lc_CTYPE, "lc_CTYPE");
pragma Import (C, lc_NUMERIC, "lc_NUMERIC");
pragma Import (C, lc_TIME, "lc_TIME");
pragma Import (C, lc_COLLATE, "lc_COLLATE");
pragma Import (C, lc_MONETARY, "lc_MONETARY");
pragma Import (C, lc_MESSAGES, "lc_MESSAGES");
pragma Import (C, lc_ALL, "lc_ALL");
pragma Import (C, lc_PAPER, "lc_PAPER");
pragma Import (C, lc_NAME, "lc_NAME");
pragma Import (C, lc_ADDRESS, "lc_ADDRESS");
pragma Import (C, lc_TELEPHONE, "lc_TELEPHONE");
pragma Import (C, lc_MEASUREMENT, "lc_MEASUREMENT");
pragma Import (C, lc_IDENTIFICATION, "lc_IDENTIFICATION");
end clib.Binding;
|
adamnemecek/GA_Ada | Ada | 14,931 | adb |
with Ada.Exceptions; use Ada.Exceptions;
with Ada.Strings.Unbounded;
with Ada.Text_IO; use Ada.Text_IO;
with GL.Attributes;
with GL.Buffers;
with GL.Culling;
with GL.Immediate;
with GL.Objects.Buffers;
with GL.Objects.Programs;
with GL.Objects.Vertex_Arrays;
with GL.Objects.Shaders.Lists;
with GL.Raster;
with GL.Rasterization;
with GL.Text;
with GL.Toggles;
with GL.Types; use GL.Types;
with GL.Types.Colors;
with GL.Uniforms;
with Glfw;
with Glfw.Input;
with Glfw.Input.Keys;
with Glfw.Input.Mouse;
with GL.Window;
with Glfw.Windows.Context;
with Glfw.Windows.Hints;
with Maths;
with Program_Loader;
with Utilities;
with Blade;
with GA_Draw;
with GL_Util;
with E2GA;
with E2GA_Draw;
with E3GA;
with GA_Maths;
with Multivector;
with Silo;
with Text_Management;
procedure Main_Loop (Main_Window : in out Glfw.Windows.Window) is
subtype tVec4f is Singles.Vector4;
Black : constant Colors.Color := (0.0, 0.0, 0.0, 1.0);
Red : constant Colors.Color := (1.0, 0.0, 0.0, 1.0);
Green : constant Colors.Color := (0.0, 1.0, 0.0, 1.0);
Blue : constant Colors.Color := (0.0, 0.0, 1.0, 1.0);
Yellow : constant Colors.Color := (1.0, 1.0, 0.0, 1.0);
Back_Colour : constant Colors.Color := (1.0, 1.0, 1.0, 0.0);
Key_Pressed : boolean := False;
Parallelogram : boolean := True;
procedure Draw_Parallelogram (Render_Program : GL.Objects.Programs.Program;
MV_Matrix : GL.Types.Singles.Matrix4;
V2, V3, V4 : Multivector.Vector;
Colour : GL.Types.Colors.Color);
procedure Draw_Text (Window_Width, Window_Height : Glfw.Size;
theText : String;
Render_Program : GL.Objects.Programs.Program;
Text_X, Text_Y : GL.Types.Single;
Text_Scale : GL.Types.Single);
procedure Text_Shader_Locations (Render_Text_Program : GL.Objects.Programs.Program;
Projection_Matrix_ID, Texture_ID, Text_Dimesions_ID,
Colour_ID : out GL.Uniforms.Uniform);
-- -------------------------------------------------------------------------
procedure Display (Window : in out Glfw.Windows.Window;
Render_Graphic_Program : GL.Objects.Programs.Program;
Render_Text_Program : GL.Objects.Programs.Program) is
use GL.Objects.Buffers;
use GL.Types.Colors;
use GL.Types.Singles; -- for matrix multiplication
use Maths.Single_Math_Functions;
use GA_Maths;
use GA_Maths.Float_Functions;
use Multivector;
Label : Silo.Label_Data;
Label_Position : GL.Types.Singles.Vector2;
-- How many bivectors? what spacing between them?:
Entry_Width : constant single := 2.8;
Entry_Height : constant single := 3.5;
Num_Bivector_X : constant integer := 6;
Num_Bivector_Y : constant integer := 4;
Scale : constant float := 40.0;
Scale_S : constant single := single (Scale);
Text_Scale : constant single := 0.12;
Position_X : integer := 0;
Position_Y : single := 100.0;
A : float := 0.0;
BV : Multivector.Bivector;
Step : constant float :=
GA_Maths.Two_Pi / float (Num_Bivector_X * Num_Bivector_Y);
V1 : constant Vector := E2GA.e1; -- 2D vector (0, 0), (1, 0)
V2 : Vector;
Text_Coords : GA_Maths.Array_3D := (0.0, 0.0, 0.0);
Window_Width : Glfw.Size;
Window_Height : Glfw.Size;
Translation_Matrix : GL.Types.Singles.Matrix4;
BV_Translation_Matrix : GL.Types.Singles.Matrix4 := GL.Types.Singles.Identity4;
Model_View_Matrix : GL.Types.Singles.Matrix4;
Projection_Matrix : GL.Types.Singles.Matrix4;
Vertex_Buffer : GL.Objects.Buffers.Buffer;
Text : Ada.Strings.Unbounded.Unbounded_String;
Text_X : GL.Types.Single := 50.0;
Text_Y : GL.Types.Single := 50.0;
begin
Window.Get_Framebuffer_Size (Window_Width, Window_Height);
GL.Window.Set_Viewport (0, 0, Int (Window_Width),
GL.Types.Int (Window_Height));
Utilities.Clear_Background_Colour_And_Depth (Back_Colour);
-- Set scale and position of first diagram
Translation_Matrix := Maths.Translation_Matrix
((Entry_Width * Scale_S / 2.0,
(Single (Num_Bivector_Y)) * Entry_Height * Scale_S / 2.0 - Position_Y, 0.0));
Model_View_Matrix := Maths.Scaling_Matrix ((Scale_S, Scale_S, Scale_S));
GA_Draw.Set_Projection_Matrix (Projection_Matrix);
-- The final MVP matrix is set up in the draw routines
while A < Two_Pi - 0.1 loop
V2 := Cos (A) * E2GA.e1 + Sin (A) * E2GA.e2;
Model_View_Matrix := Translation_Matrix * Model_View_Matrix;
E2GA_Draw.Draw_Vector (Render_Graphic_Program, Model_View_Matrix,
V1, Red, Scale);
E2GA_Draw.Draw_Vector (Render_Graphic_Program, Model_View_Matrix,
V2, Green, Scale);
BV := Outer_Product (V1, V2);
if Parallelogram then
-- Draw Quad with vertices: origin -> V1 -> V1+V2 -> V2
Draw_Parallelogram (Render_Graphic_Program, Model_View_Matrix,
V1, V1 + V2, V2, Blue);
else
BV_Translation_Matrix := Translation_Matrix * BV_Translation_Matrix;
E2GA_Draw.Draw_Bivector (Render_Graphic_Program, BV_Translation_Matrix,
BV, Yellow);
end if;
if A < Pi - 0.1 then
Text_Coords (2) := 0.35 * float (Entry_Height);
else
Text_Coords (1) := - 0.25 * float (Entry_Height);
Text_Coords (2) := 0.4 * float (Entry_Height);
end if;
GL_Util.Viewport_Coordinates (Text_Coords, Model_View_Matrix,
Projection_Matrix, Label_Position);
-- store bivector label:
Label := Silo.Set_Data (Ada.Strings.Unbounded.To_Unbounded_String
(E2GA.Bivector_String (BV)), Label_Position);
Silo.Push (Label);
-- Set X position of next diagram
Translation_Matrix := Maths.Translation_Matrix ((Entry_Width * Scale_S,
0.0, 0.0));
if Position_X < Num_Bivector_X - 1 then
Position_X := Position_X + 1;
else
-- Set X and Y positions of next diagram
Position_X := 0;
Position_Y := Position_Y + Entry_Height;
Translation_Matrix := Maths.Translation_Matrix
((-Single (Num_Bivector_X) * Entry_Width * Scale_S,
Position_Y, 0.0)) * Translation_Matrix;
end if;
A := A + Step;
end loop;
for i in 1 .. Silo.Size loop
Silo.Get_Data (Text, Label_Position);
Draw_Text (Window_Width, Window_Height,
Ada.Strings.Unbounded.To_String (Text), Render_Text_Program,
Label_Position (GL.X), Label_Position (GL.Y), Text_Scale);
end loop;
exception
when anError : others =>
Put_Line ("An exception occurred in Main_Loop.Display.");
raise;
end Display;
-- ------------------------------------------------------------------------
procedure Draw_Parallelogram (Render_Program : GL.Objects.Programs.Program;
MV_Matrix : GL.Types.Singles.Matrix4;
V2, V3, V4 : Multivector.Vector;
Colour : GL.Types.Colors.Color) is
use GL.Objects.Buffers;
use GL.Types.Colors;
Colour_Location : GL.Uniforms.Uniform;
MV_Matrix_ID : GL.Uniforms.Uniform;
Projection_Matrix_ID : GL.Uniforms.Uniform;
Projection_Matrix : GL.Types.Singles.Matrix4;
Vertex_Array_Object : GL.Objects.Vertex_Arrays.Vertex_Array_Object;
Vertex_Buffer : Buffer;
Element_Buffer : Buffer;
Vertices : Singles.Vector3_Array (1 .. 4) :=
((0.0, 0.0, 0.0), -- Bottom-left
GL_Util.To_GL (V2), -- Bottom-right,
GL_Util.To_GL (V3), -- Top-right,
GL_Util.To_GL (V4)); -- Top-left
Elements : GL.Types.Int_Array (1 .. 6) := (0, 1, 2,
2, 3, 0);
begin
GL.Objects.Programs.Use_Program (Render_Program);
Vertex_Array_Object.Initialize_Id;
Vertex_Array_Object.Bind;
GA_Draw.Set_Projection_Matrix (Projection_Matrix );
GA_Draw.Graphic_Shader_Locations (Render_Program, MV_Matrix_ID, Projection_Matrix_ID,
Colour_Location);
GL.Uniforms.Set_Single (Projection_Matrix_ID, Projection_Matrix);
Vertex_Buffer.Initialize_Id;
Array_Buffer.Bind (Vertex_Buffer);
Utilities.Load_Vertex_Buffer (Array_Buffer, Vertices, Static_Draw);
Element_Buffer.Initialize_Id;
Element_Array_Buffer.Bind (Element_Buffer);
Utilities.Load_Element_Buffer (Element_Array_Buffer, Elements, Static_Draw);
GL.Uniforms.Set_Single (Colour_Location, Colour (R), Colour (G), Colour (B));
GL.Uniforms.Set_Single (MV_Matrix_ID, MV_Matrix);
GL.Uniforms.Set_Single (Projection_Matrix_ID, Projection_Matrix);
GL.Attributes.Set_Vertex_Attrib_Pointer (0, 3, Single_Type, 0, 0);
GL.Attributes.Enable_Vertex_Attrib_Array (0);
GL.Toggles.Disable (GL.Toggles.Cull_Face);
GL.Objects.Buffers.Draw_Elements (Triangles, 6, UInt_Type);
GL.Attributes.Disable_Vertex_Attrib_Array (0);
exception
when anError : others =>
Put_Line ("An exception occurred in Main_Loop.Draw_Parallelogram.");
raise;
end Draw_Parallelogram;
-- ------------------------------------------------------------------------
procedure Draw_Text (Window_Width, Window_Height : Glfw.Size;
theText : String;
Render_Program : GL.Objects.Programs.Program;
Text_X, Text_Y : GL.Types.Single;
Text_Scale : GL.Types.Single) is
Text_Dimesions_ID : GL.Uniforms.Uniform;
Text_Proj_Matrix_ID : GL.Uniforms.Uniform;
Text_Texture_ID : GL.Uniforms.Uniform;
Text_Colour_ID : GL.Uniforms.Uniform;
Text_Projection_Matrix : GL.Types.Singles.Matrix4;
Text_Colour : constant Colors.Color := Black;
begin
Text_Shader_Locations (Render_Program, Text_Proj_Matrix_ID,
Text_Texture_ID, Text_Dimesions_ID, Text_Colour_ID);
Maths.Init_Orthographic_Transform (Single (Window_Height), 0.0, 0.0,
Single (Window_Width), 0.1, -100.0,
Text_Projection_Matrix);
Text_Management.Render_Text (Render_Program, theText, Text_X, Text_Y,
Text_Scale, Text_Colour, Text_Texture_ID,
Text_Proj_Matrix_ID, Text_Dimesions_ID,
Text_Colour_ID, Text_Projection_Matrix);
exception
when anError : others =>
Put_Line ("An exception occurred in Main_Loop.Draw_Text.");
raise;
end Draw_Text;
-- ------------------------------------------------------------------------
procedure Setup_Graphic (Window : in out Glfw.Windows.Window;
Render_Graphic_Program : out GL.Objects.Programs.Program;
Render_Text_Program : out GL.Objects.Programs.Program) is
use Glfw.Input;
use GL.Objects.Buffers;
use GL.Objects.Shaders;
use Program_Loader;
Font_File : string := "../fonts/Helvetica.ttc";
begin
Render_Graphic_Program := Program_Loader.Program_From
((Src ("src/shaders/vertex_shader.glsl", Vertex_Shader),
Src ("src/shaders/fragment_shader.glsl", Fragment_Shader)));
Render_Text_Program := Program_Loader.Program_From
((Src ("src/shaders/text_vertex_shader.glsl", Vertex_Shader),
Src ("src/shaders/text_fragment_shader.glsl", Fragment_Shader)));
Text_Management.Setup (Font_File);
GA_Draw.Set_Point_Size (0.005);
exception
when anError : others =>
Put_Line ("An exception occurred in Main_Loop.Setup_Graphic.");
raise;
end Setup_Graphic;
-- ----------------------------------------------------------------------------
procedure Text_Shader_Locations (Render_Text_Program : GL.Objects.Programs.Program;
Projection_Matrix_ID, Texture_ID,
Text_Dimesions_ID, Colour_ID : out GL.Uniforms.Uniform) is
begin
Projection_Matrix_ID := GL.Objects.Programs.Uniform_Location
(Render_Text_Program, "mvp_matrix");
Texture_ID := GL.Objects.Programs.Uniform_Location
(Render_Text_Program, "text_sampler");
Text_Dimesions_ID := GL.Objects.Programs.Uniform_Location
(Render_Text_Program, "dimensions");
Colour_ID := GL.Objects.Programs.Uniform_Location
(Render_Text_Program, "text_colour");
end Text_Shader_Locations;
-- -------------------------------------------------------------------------
use Glfw.Input;
Render_Graphic_Program : GL.Objects.Programs.Program;
Render_Text_Program : GL.Objects.Programs.Program;
Running : Boolean := True;
Key_Now : Button_State;
begin
Main_Window.Set_Input_Toggle (Sticky_Keys, True);
Glfw.Input.Poll_Events;
GL.Toggles.Disable (GL.Toggles.Cull_Face);
Setup_Graphic (Main_Window, Render_Graphic_Program, Render_Text_Program);
while Running loop
Display (Main_Window, Render_Graphic_Program, Render_Text_Program);
Glfw.Windows.Context.Swap_Buffers (Main_Window'Access);
Glfw.Input.Poll_Events;
Key_Now := Main_Window.Key_State (Glfw.Input.Keys.Space);
if not Key_Pressed and Key_Now = Glfw.Input.Pressed then
Parallelogram := not Parallelogram;
Key_Pressed := True;
else
Key_Pressed := Key_Now = Glfw.Input.Pressed;
end if;
Running := Running and then
not (Main_Window.Key_State (Glfw.Input.Keys.Escape) = Glfw.Input.Pressed);
Running := Running and then not Main_Window.Should_Close;
end loop;
end Main_Loop;
|
reznikmm/matreshka | Ada | 3,739 | 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.Draw_Glue_Point_Type_Attributes is
pragma Preelaborate;
type ODF_Draw_Glue_Point_Type_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Draw_Glue_Point_Type_Attribute_Access is
access all ODF_Draw_Glue_Point_Type_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Glue_Point_Type_Attributes;
|
zhmu/ananas | Ada | 1,548 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- A D A . U N C H E C K E D _ D E A L L O C A T I O N --
-- --
-- S p e c --
-- --
-- This specification is derived from the Ada Reference Manual 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. --
-- --
------------------------------------------------------------------------------
generic
type Object (<>) is limited private;
type Name is access Object;
procedure Ada.Unchecked_Deallocation (X : in out Name) with
Depends => (X => null, -- X on exit does not depend on its input value
null => X), -- X's input value has no effect
Post => X = null; -- X's output value is null
pragma Preelaborate (Unchecked_Deallocation);
pragma Import (Intrinsic, Ada.Unchecked_Deallocation);
|
reznikmm/gela | Ada | 59,990 | ads | ------------------------------------------------------------------------------
-- G E L A A S I S --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- --
-- This specification is derived from the Ada Semantic Interface --
-- Specification Standard (ISO/IEC 15291) and ASIS 1999 Issues. --
-- --
-- The copyright notice and the license provisions that follow apply to the --
-- part following the private keyword. --
-- --
-- Read copyright and license at the end of this file --
------------------------------------------------------------------------------
-- $Revision$ $Date$
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- 16 package Asis.Definitions
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
package Asis.Definitions is
-- pragma Preelaborate;
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- Asis.Definitions encapsulates a set of queries that operate on
-- A_Definition and An_Association elements.
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
-- 16.1 function Corresponding_Type_Operators
-------------------------------------------------------------------------------
-- |ER A_Type_Definition - 3.2.1
-------------------------------------------------------------------------------
function Corresponding_Type_Operators
(Type_Definition : in Asis.Type_Definition)
return Asis.Declaration_List;
-------------------------------------------------------------------------------
-- Type_Definition - Specifies the type to query
--
-- Returns a list of operators. These include all predefined operators, and
-- all user-defined operator overloads, that have been implicitly or
-- explicitly declared for the type. (Reference Manual 7.3.1(2))
--
-- This list includes only operators appropriate for the type, from the set:
-- and or xor = /= < <= > >= + - & * / mod rem ** abs not
--
-- Returns a Nil_Element_List if there are no predefined or overloaded
-- operators for the type.
--
-- Returns a Nil_Element_List if the implementation does not provide
-- such implicit declarations.
--
-- The Enclosing_Element for each implicit declaration is the declaration
-- (type or object) that declared the type.
--
-- If a user-defined equality operator has
-- been defined, an Ada implementation has two choices when dealing with an
-- instance of the "/=" operator. a) treat A/=B as NOT(A=B), b) implicitly
-- create a "/=" operator. Implementations that take the second alternative
-- will include this implicit inequality operation in their result.
-- Implementations that choose the first alternative are encouraged to hide
-- this choice beneath the ASIS interface and to "fake" an inequality
-- operation. Failing that, the function call, representing the NOT
-- operation, must have Is_Part_Of_Implicit = True so that an ASIS application
-- can tell the difference between a user-specified NOT(A=B) and an
-- implementation-specific A/=B transformation.
--
-- Appropriate Definition_Kinds:
-- A_Type_Definition
-- A_Private_Type_Definition
-- A_Tagged_Private_Type_Definition
-- A_Private_Extension_Definition
-- A_Task_Definition
-- A_Protected_Definition
-- A_Formal_Type_Definition
--
-- Returns Declaration_Kinds:
-- A_Function_Declaration
-- A_Function_Body_Declaration
-- A_Function_Body_Stub
-- A_Function_Renaming_Declaration
-- A_Function_Instantiation
-- A_Formal_Function_Declaration
--
-- |IP Implementation Permissions:
-- |IP
-- |IP The result may or may not include language defined operators that have
-- |IP been overridden by user-defined overloads. Operators that are totally
-- |IP hidden, in all contexts, by user-defined operators may be omitted from
-- |IP the list.
-- |IP
-- |IP Some implementations do not represent all forms of implicit
-- |IP declarations such that elements representing them can be easily
-- |IP provided. An implementation can choose whether or not to construct
-- |IP and provide artificial declarations for implicitly declared elements.
--
-- |ER------------------------------------------------------------------------
-- |ER A_Derived_Type_Definition - 3.4
-- |CR
-- |CR Child elements returned by:
-- |CR function Parent_Subtype_Indication
-- |ER------------------------------------------------------------------------
-- |ER A_Derived_Record_Extension_Definition - 3.4
-- |CR
-- |CR Child elements returned by:
-- |CR function Parent_Subtype_Indication
-- |CR function Record_Definition
--
-------------------------------------------------------------------------------
-- 16.2 function Parent_Subtype_Indication
-------------------------------------------------------------------------------
function Parent_Subtype_Indication
(Type_Definition : in Asis.Type_Definition)
return Asis.Subtype_Indication;
-------------------------------------------------------------------------------
-- Type_Definition - Specifies the derived_type_definition to query
--
-- Returns the parent_subtype_indication following the reserved word "new".
--
-- Appropriate Type_Kinds:
-- A_Derived_Type_Definition
-- A_Derived_Record_Extension_Definition
--
-- Returns Definition_Kinds:
-- A_Subtype_Indication
--
-------------------------------------------------------------------------------
-- 16.3 function Record_Definition
-------------------------------------------------------------------------------
function Record_Definition (Type_Definition : in Asis.Type_Definition)
return Asis.Definition;
-------------------------------------------------------------------------------
-- Type_Definition - Specifies the definition to query
--
-- Returns the record definition of the type_definition.
--
-- Appropriate Type_Kinds:
-- A_Derived_Record_Extension_Definition
-- A_Record_Type_Definition
-- A_Tagged_Record_Type_Definition
--
-- Returns Definition_Kinds:
-- A_Record_Definition
-- A_Null_Record_Definition
--
-------------------------------------------------------------------------------
-- 16.4 function Implicit_Inherited_Declarations
-------------------------------------------------------------------------------
function Implicit_Inherited_Declarations
(Definition : in Asis.Definition)
return Asis.Declaration_List;
-------------------------------------------------------------------------------
-- Definition - Specifies the derived type to query
--
-- Returns a list of Is_Part_Of_Implicit inherited enumeration literals,
-- discriminants, components, protected subprograms, or entries of a
-- derived_type_definition whose parent type is an enumeration type, or a
-- composite type other than an array type. See Reference Manual 3.4(10-14).
--
-- Returns a Nil_Element_List if the root type of derived_type_definition is
-- not an enumeration, record, task, or protected type.
--
-- Returns a Nil_Element_List if the implementation does not provide
-- such implicit declarations.
--
-- The Enclosing_Element for each of the implicit declarations is the
-- Declaration argument.
--
-- Appropriate Definition_Kinds:
-- A_Type_Definition
-- A_Private_Extension_Definition
-- A_Formal_Type_Definition
--
-- Appropriate Type_Kinds:
-- A_Derived_Type_Definition
-- A_Derived_Record_Extension_Definition
--
-- Appropriate Formal_Type_Kinds:
-- A_Formal_Derived_Type_Definition
--
-- Returns Declaration_Kinds:
--
-- An_Enumeration_Literal_Specification
-- A_Discriminant_Specification
-- A_Component_Declaration
-- A_Procedure_Declaration
-- A_Function_Declaration
-- An_Entry_Declaration
--
-- |IP Implementation Permissions:
-- |IP
-- |IP Some implementations do not represent all forms of implicit
-- |IP declarations such that elements representing them can be easily
-- |IP provided. An implementation can choose whether or not to construct
-- |IP and provide artificial declarations for implicitly declared elements.
--
-- |AN Application Note:
-- |AN
-- |AN This query returns only implicit inherited entry declarations for
-- |AN derived task types. All representation clauses and pragmas associated
-- |AN with the entries of the original task type (the root type of the
-- |AN derived task type) apply to the inherited entries. Those are available
-- |AN by examining the original type or by calling Corresponding_Pragmas and
-- |AN Corresponding_Representation_Clauses. These functions will return the
-- |AN pragmas and clauses from the original type.
--
-------------------------------------------------------------------------------
-- 16.5 function Implicit_Inherited_Subprograms
-------------------------------------------------------------------------------
function Implicit_Inherited_Subprograms
(Definition : in Asis.Definition)
return Asis.Declaration_List;
-------------------------------------------------------------------------------
-- Definition - Specifies the derived type to query
--
-- Returns the list of user-defined inherited primitive subprograms that have
-- been implicitly declared for the derived_type_definition.
--
-- The list result does not include hidden inherited subprograms (Reference
-- Manual 8.3).
--
-- Returns a Nil_Element_List if there are no inherited subprograms for the
-- derived type.
--
-- Returns a Nil_Element_List if the implementation does not provide
-- such implicit declarations.
--
-- The Enclosing_Element for each of the subprogram declarations is the
-- Definition argument.
--
-- Appropriate Definition_Kinds:
-- A_Type_Definition
-- A_Private_Extension_Definition
-- A_Formal_Type_Definition
--
-- Appropriate Type_Kinds:
-- A_Derived_Type_Definition
-- A_Derived_Record_Extension_Definition
-- An_Interface_Type_Definition (by Gela)
--
-- Appropriate Formal_Type_Kinds:
-- A_Formal_Derived_Type_Definition
-- A_Formal_Interface_Type_Definition (by Gela)
--
-- Returns Declaration_Kinds:
-- A_Function_Declaration
-- A_Procedure_Declaration
--
-- |IP Implementation Permissions:
-- |IP
-- |IP Some implementations do not represent all forms of implicit
-- |IP declarations such that elements representing them can be easily
-- |IP provided. An implementation can choose whether or not to construct
-- |IP and provide artificial declarations for implicitly declared elements.
--
-------------------------------------------------------------------------------
-- 16.6 function Corresponding_Parent_Subtype
-------------------------------------------------------------------------------
function Corresponding_Parent_Subtype
(Type_Definition : in Asis.Type_Definition)
return Asis.Declaration;
-------------------------------------------------------------------------------
-- Type_Definition - Specifies the derived_type_definition to query
--
-- Returns the parent subtype declaration of the derived_type_definition.
-- The parent subtype is defined by the parent_subtype_indication.
--
-- Appropriate Type_Kinds:
-- A_Derived_Type_Definition
-- A_Derived_Record_Extension_Definition
--
-- Returns Declaration_Kinds:
-- An_Ordinary_Type_Declaration
-- A_Task_Type_Declaration
-- A_Protected_Type_Declaration
-- A_Subtype_Declaration
-- A_Formal_Type_Declaration
-- An_Incomplete_Type_Declaration
-- A_Private_Type_Declaration
-- A_Private_Extension_Declaration
--
-------------------------------------------------------------------------------
-- 16.7 function Corresponding_Root_Type
-------------------------------------------------------------------------------
function Corresponding_Root_Type
(Type_Definition : in Asis.Type_Definition)
return Asis.Declaration;
-------------------------------------------------------------------------------
-- Type_Definition - Specifies the derived_type_definition to query
--
-- This function recursively unwinds all type derivations and subtyping to
-- arrive at a full_type_declaration that is neither a derived type nor a
-- subtype.
--
-- In case of numeric types, this function always returns some user-defined
-- type, not an implicitly defined root type corresponding to
-- A_Root_Type_Definition. The only ways to get implicitly declared numeric
-- root or universal types are to ask for the type of a universal expression
-- or from the parameter and result profile of a predefined operation working
-- with numeric types.
--
-- Appropriate Type_Kinds:
-- A_Derived_Type_Definition
-- A_Derived_Record_Extension_Definition
--
-- Returns Declaration_Kinds:
-- An_Ordinary_Type_Declaration
-- A_Task_Type_Declaration
-- A_Protected_Type_Declaration
-- A_Formal_Type_Declaration
-- A_Private_Type_Declaration
-- A_Private_Extension_Declaration
--
-------------------------------------------------------------------------------
-- 16.8 function Corresponding_Type_Structure
-------------------------------------------------------------------------------
function Corresponding_Type_Structure
(Type_Definition : in Asis.Type_Definition)
return Asis.Declaration;
-------------------------------------------------------------------------------
-- Type_Definition - Specifies the derived_type_definition to query
--
-- Returns the type structure from which the specified type definition has
-- been derived. This function will recursively unwind derivations and
-- subtyping until the type_declaration derives a change of representation or
-- is no longer derived. See Reference Manual 13.6.
--
-- Appropriate Type_Kinds:
-- A_Derived_Type_Definition
-- A_Derived_Record_Extension_Definition
--
-- Returns Declaration_Kinds:
-- An_Ordinary_Type_Declaration
-- A_Task_Type_Declaration
-- A_Protected_Type_Declaration
-- A_Formal_Type_Declaration
-- A_Private_Type_Declaration
-- A_Private_Extension_Declaration
--
-- |ER------------------------------------------------------------------------
-- |ER An_Enumeration_Type_Definition - 3.5.1
-- |CR
-- |CR Child elements returned by:
-- |CR function Enumeration_Literal_Declarations
--
-------------------------------------------------------------------------------
-- 16.9 function Enumeration_Literal_Declarations
-------------------------------------------------------------------------------
function Enumeration_Literal_Declarations
(Type_Definition : in Asis.Type_Definition)
return Asis.Declaration_List;
-------------------------------------------------------------------------------
-- Type_Definition - Specifies the enumeration type definition to query
--
-- Returns a list of the literals declared in an enumeration_type_definition,
-- in their order of appearance.
--
-- Appropriate Type_Kinds:
-- An_Enumeration_Type_Definition
--
-- Returns Declaration_Kinds:
-- An_Enumeration_Literal_Specification
--
-- |ER------------------------------------------------------------------------
-- |ER A_Signed_Integer_Type_Definition - 3.5.4
-- |CR
-- |CR Child elements returned by:
-- |CR function Integer_Constraint
--
-------------------------------------------------------------------------------
-- 16.10 function Integer_Constraint
-------------------------------------------------------------------------------
function Integer_Constraint
(Type_Definition : in Asis.Type_Definition)
return Asis.Range_Constraint;
-------------------------------------------------------------------------------
-- Type_Definition - Specifies the signed_integer_type_definition to query
--
-- Returns the range_constraint of the signed_integer_type_definition.
--
-- Appropriate Type_Kinds:
-- A_Signed_Integer_Type_Definition
--
-- Returns Constraint_Kinds:
-- A_Simple_Expression_Range
--
-- |ER------------------------------------------------------------------------
-- |ER A_Modular_Type_Definition - 3.5.4
-- |CR
-- |CR Child elements returned by:
-- |CR function Mod_Static_Expression
--
-------------------------------------------------------------------------------
-- 16.11 function Mod_Static_Expression
-------------------------------------------------------------------------------
function Mod_Static_Expression
(Type_Definition : in Asis.Type_Definition)
return Asis.Expression;
-------------------------------------------------------------------------------
-- Type_Definition - Specifies the modular_type_definition to query
--
-- Returns the static_expression following the reserved word "mod".
--
-- Appropriate Type_Kinds:
-- A_Modular_Type_Definition
--
-- Returns Element_Kinds:
-- An_Expression
--
-- |ER------------------------------------------------------------------------
-- |ER A_Floating_Point_Definition - 3.5.7
-- |CR
-- |CR Child elements returned by:
-- |CR functions Digits_Expression and Real_Range_Constraint
--
-- |ER------------------------------------------------------------------------
-- |ER A_Decimal_Fixed_Point_Definition - 3.5.9
-- |CR
-- |CR Child elements returned by:
-- |CR functions Digits_Expression, Delta_Expression, and
-- |CR Real_Range_Constraint
--
-------------------------------------------------------------------------------
-- 16.12 function Digits_Expression
-------------------------------------------------------------------------------
function Digits_Expression (Definition : in Asis.Definition)
return Asis.Expression;
-------------------------------------------------------------------------------
-- Definition - Specifies the definition to query
--
-- Returns the static_expression following the reserved word "digits".
--
-- Appropriate Type_Kinds:
-- A_Floating_Point_Definition
-- A_Decimal_Fixed_Point_Definition
--
-- Appropriate Definition_Kinds:
-- A_Constraint
-- Appropriate Constraint_Kinds:
-- A_Digits_Constraint
--
-- Returns Element_Kinds:
-- An_Expression
--
-- |ER------------------------------------------------------------------------
-- |ER An_Ordinary_Fixed_Point_Definition - 3.5.9
-- |CR
-- |CR Child elements returned by:
-- |CR function Delta_Expression
--
-------------------------------------------------------------------------------
-- 16.13 function Delta_Expression
-------------------------------------------------------------------------------
function Delta_Expression (Definition : in Asis.Definition)
return Asis.Expression;
-------------------------------------------------------------------------------
-- Definition - Specifies the definition to query
--
-- Returns the static_expression following the reserved word "delta".
--
-- Appropriate Type_Kinds:
-- An_Ordinary_Fixed_Point_Definition
-- A_Decimal_Fixed_Point_Definition
--
-- Appropriate Definition_Kinds:
-- A_Constraint
-- Appropriate Constraint_Kinds:
-- A_Delta_Constraint
--
-- Returns Element_Kinds:
-- An_Expression
--
-------------------------------------------------------------------------------
-- 16.14 function Real_Range_Constraint
-------------------------------------------------------------------------------
function Real_Range_Constraint
(Definition : in Asis.Definition) return Asis.Range_Constraint;
-------------------------------------------------------------------------------
-- Definition - Specifies the definition to query
--
-- Returns the real_range_specification range_constraint of the definition.
--
-- Returns a Nil_Element if there is no explicit range_constraint.
--
-- Appropriate Type_Kinds:
-- A_Floating_Point_Definition
-- An_Ordinary_Fixed_Point_Definition
-- A_Decimal_Fixed_Point_Definition
--
-- Appropriate Definition_Kinds:
-- A_Constraint
-- Appropriate Constraint_Kinds:
-- A_Digits_Constraint
-- A_Delta_Constraint
--
-- Returns Constraint_Kinds:
-- Not_A_Constraint
-- A_Simple_Expression_Range
--
-- |ER------------------------------------------------------------------------
-- |ER An_Unconstrained_Array_Definition 3.6
-- |CR
-- |CR Child elements returned by:
-- |CR functions Index_Subtype_Definitions and Array_Component_Definition
--
-------------------------------------------------------------------------------
-- 16.15 function Index_Subtype_Definitions
-------------------------------------------------------------------------------
function Index_Subtype_Definitions
(Type_Definition : in Asis.Type_Definition)
return Asis.Expression_List;
-------------------------------------------------------------------------------
-- Type_Definition - Specifies the array_type_definition to query
--
-- Returns a list of the index_subtype_definition subtype mark names for
-- an unconstrained_array_definition, in their order of appearance.
--
-- Appropriate Type_Kinds:
-- An_Unconstrained_Array_Definition
--
-- Appropriate Formal_Type_Kinds:
-- A_Formal_Unconstrained_Array_Definition
--
-- Returns Expression_Kinds:
-- An_Identifier
-- A_Selected_Component
--
-- |ER------------------------------------------------------------------------
-- |ER A_Constrained_Array_Definition 3.6
-- |CR
-- |CR Child elements returned by:
-- |CR function Discrete_Subtype_Definitions
-- |CR function Array_Component_Definition
--
-------------------------------------------------------------------------------
-- 16.16 function Discrete_Subtype_Definitions
-------------------------------------------------------------------------------
function Discrete_Subtype_Definitions
(Type_Definition : in Asis.Type_Definition)
return Asis.Definition_List;
-------------------------------------------------------------------------------
-- Type_Definition - Specifies the array_type_definition to query
--
-- Returns the list of Discrete_Subtype_Definition elements of a
-- constrained_array_definition, in their order of appearance.
--
-- Appropriate Type_Kinds:
-- A_Constrained_Array_Definition
--
-- Appropriate Formal_Type_Kinds:
-- A_Formal_Constrained_Array_Definition
--
-- Returns Definition_Kinds:
-- A_Discrete_Subtype_Definition
--
-------------------------------------------------------------------------------
-- 16.17 function Array_Component_Definition
-------------------------------------------------------------------------------
function Array_Component_Definition
(Type_Definition : in Asis.Type_Definition)
return Asis.Component_Definition;
-------------------------------------------------------------------------------
-- Type_Definition - Specifies the array_type_definition to query
--
-- Returns the Component_Definition of the array_type_definition.
--
-- Appropriate Type_Kinds:
-- An_Unconstrained_Array_Definition
-- A_Constrained_Array_Definition
--
-- Appropriate Formal_Type_Kinds:
-- A_Formal_Unconstrained_Array_Definition
-- A_Formal_Constrained_Array_Definition
--
-- Returns Definition_Kinds:
-- A_Component_Definition
--
-- |ER------------------------------------------------------------------------
-- |ER A_Record_Type_Definition - 3.8
-- |ER A_Tagged_Record_Type_Definition - 3.8
-- |CR
-- |CR Child elements returned by:
-- |CR function Record_Definition
-- |ER------------------------------------------------------------------------
-- |ER An_Access_Type_Definition - 3.10
-- |CR
-- |CR Child elements returned by:
-- |CR function Access_To_Object_Definition
-- |CR function Access_To_Subprogram_Parameter_Profile
-- |CR function Access_To_Function_Result_Profile (obsolete)
--
-------------------------------------------------------------------------------
-- 16.18 function Access_To_Object_Definition
-------------------------------------------------------------------------------
function Access_To_Object_Definition
(Type_Definition : in Asis.Type_Definition)
return Asis.Subtype_Indication;
-------------------------------------------------------------------------------
-- Type_Definition - Specifies the Access_Type_Definition to query
--
-- Returns the subtype_indication following the reserved word "access".
--
-- Appropriate Type_Kinds:
-- An_Access_Type_Definition.
--
-- Appropriate Formal_Type_Kinds:
-- A_Formal_Access_Type_Definition
--
-- Appropriate Access_Type_Kinds:
-- A_Pool_Specific_Access_To_Variable
-- An_Access_To_Variable
-- An_Access_To_Constant
--
-- Returns Element_Kinds:
-- A_Subtype_Indication
--
-------------------------------------------------------------------------------
-- 16.xx function Anonymous_Access_To_Object_Subtype_Mark
-------------------------------------------------------------------------------
function Anonymous_Access_To_Object_Subtype_Mark
(Definition : Asis.Definition)
return Asis.Name;
-------------------------------------------------------------------------------
-- Definition - Specifies the anonymous access definition to query.
--
-- Returns the subtype_mark following the reserved word(s) "access" or
-- "access constant".
--
-- Appropriate Definition_Kinds:
-- An_Access_Definition.
--
-- Appropriate Access_Definition_Kinds:
-- An_Anonymous_Access_To_Variable
-- An_Anonymous_Access_To_Constant
--
-- Returns Expression_Kinds:
-- An_Identifier
-- A_Selected_Component
-- An_Attribute_Reference
--
-------------------------------------------------------------------------------
-- 16.19 function Access_To_Subprogram_Parameter_Profile
-------------------------------------------------------------------------------
function Access_To_Subprogram_Parameter_Profile
(Type_Definition : in Asis.Type_Definition)
return Asis.Parameter_Specification_List;
-------------------------------------------------------------------------------
-- Type_Definition - Specifies the Access_Type_Definition to query
--
-- Returns a list of parameter_specification elements in the formal part of
-- the parameter_profile in the access_to_subprogram_definition.
--
-- Returns a Nil_Element_List if the parameter_profile has no formal part.
--
-- Results of this query may vary across ASIS implementations. Some
-- implementations normalize all multiple name parameter_specification
-- elements into an equivalent sequence of corresponding single name
-- parameter_specification elements. See Reference Manual 3.3.1(7).
--
-- Appropriate Type_Kinds:
-- An_Access_Type_Definition.
-- A_Formal_Access_Type_Definition.
--
--
-- Appropriate Access_Type_Kinds:
-- An_Access_To_Procedure
-- An_Access_To_Protected_Procedure
-- An_Access_To_Function
-- An_Access_To_Protected_Function
--
-- Appropriate Access_Definition_Kinds
-- An_Anonymous_Access_To_Procedure
-- An_Anonymous_Access_To_Protected_Procedure
-- An_Anonymous_Access_To_Function
-- An_Anonymous_Access_To_Protected_Function
--
-- Returns Declaration_Kinds:
-- A_Parameter_Specification
--
-------------------------------------------------------------------------------
-- 16.20 function Access_To_Function_Result_Subtype
-------------------------------------------------------------------------------
function Access_To_Function_Result_Subtype
(Definition : in Asis.Definition)
return Asis.Definition;
-------------------------------------------------------------------------------
-- Definition specifies the Access_Type_Definition or
-- Access_Definition to query.
--
-- Returns a definition that corresponds to the result subtype of the
-- access-to-function type, as specified by a subtype_indication (with
-- no specified constraint) or an access_definition.
--
-- Appropriate Definition_Kinds:
-- A_Type_Definition
-- An_Access_Definition
--
-- Appropriate Type_Kinds:
-- An_Access_Type_Definition
-- A_Formal_Access_Type_Definition
--
-- Appropriate Access_Type_Kinds:
-- An_Access_To_Function
-- An_Access_To_Protected_Function
--
-- Appropriate Access_Definition_Kinds:
-- An_Anonymous_Access_To_Function
-- An_Anonymous_Access_To_Protected_Function
--
-- Returns Definition_Kinds:
-- A_Subtype_Indication
-- An_Access_Definition
--
-------------------------------------------------------------------------------
-- 16.20 function Access_To_Function_Result_Profile (obsolete)
-------------------------------------------------------------------------------
function Access_To_Function_Result_Profile
(Type_Definition : in Asis.Type_Definition)
return Asis.Expression;
-------------------------------------------------------------------------------
-- Type_Definition - Specifies the Access_Type_Definition to query
--
-- Returns the subtype_mark expression for the return type for the access
-- function.
--
-- Appropriate Type_Kinds:
-- An_Access_Type_Definition
-- A_Formal_Access_Type_Definition
--
-- Appropriate Access_Type_Kinds:
-- An_Access_To_Function
-- An_Access_To_Protected_Function
--
-- Returns Expression_Kinds:
-- An_Identifier
-- A_Selected_Component
--
-- |ER------------------------------------------------------------------------
-- |ER A_Root_Type_Definition - 3.5.4(9), 3.5.6(2) - No child elements
-- |ER------------------------------------------------------------------------
-- |ER A_Subtype_Indication - 3.3.2
-- |CR
-- |CR Child elements returned by:
-- |CR function Subtype_Mark
-- |CR function Subtype_Constraint
--
-------------------------------------------------------------------------------
-- 16.21 function Subtype_Mark
-------------------------------------------------------------------------------
function Subtype_Mark (Definition : in Asis.Definition)
return Asis.Expression;
-------------------------------------------------------------------------------
-- Definition - Specifies the definition to query
--
-- Returns the subtype_mark expression of the definition.
--
-- Appropriate Definition_Kinds:
-- A_Subtype_Indication
-- A_Discrete_Subtype_Definition
-- Appropriate Discrete_Range_Kinds:
-- A_Discrete_Subtype_Indication
-- A_Discrete_Range
-- Appropriate Discrete_Range_Kinds:
-- A_Discrete_Subtype_Indication
-- A_Formal_Type_Definition
-- Appropriate Formal_Type_Kinds:
-- A_Formal_Derived_Type_Definition
--
-- Returns Expression_Kinds:
-- An_Identifier
-- A_Selected_Component
-- An_Attribute_Reference
--
-------------------------------------------------------------------------------
-- 16.22 function Subtype_Constraint
-------------------------------------------------------------------------------
function Subtype_Constraint (Definition : in Asis.Definition)
return Asis.Constraint;
-------------------------------------------------------------------------------
-- Definition - Specifies the definition to query
--
-- Returns the constraint of the subtype_indication.
--
-- Returns a Nil_Element if no explicit constraint is present.
--
-- Appropriate Definition_Kinds:
-- A_Subtype_Indication
-- A_Discrete_Subtype_Definition
-- Appropriate Discrete_Range_Kinds:
-- A_Discrete_Subtype_Indication
-- A_Discrete_Range
-- Appropriate Discrete_Range_Kinds:
-- A_Discrete_Subtype_Indication
--
-- Returns Definition_Kinds:
-- Not_A_Definition
-- A_Constraint
--
-- |AN Application Note:
-- |AN
-- |AN When an unconstrained subtype indication for a type having
-- |AN discriminants with default values is used, a Nil_Element is
-- |AN returned by this function. Use the queries Subtype_Mark, and
-- |AN Corresponding_Name_Declaration [, and Corresponding_First_Subtype]
-- |AN to obtain the declaration defining the defaults.
--
-- |ER------------------------------------------------------------------------
-- |ER A_Constraint - 3.2.2
-- |ER
-- |ER A_Simple_Expression_Range - 3.5
-- |CR
-- |CR Child elements returned by:
-- |CR function Lower_Bound
-- |CR function Upper_Bound
--
-------------------------------------------------------------------------------
-- 16.23 function Lower_Bound
-------------------------------------------------------------------------------
function Lower_Bound (Constraint : in Asis.Range_Constraint)
return Asis.Expression;
-------------------------------------------------------------------------------
-- Constraint - Specifies the range_constraint or discrete_range to query
--
-- Returns the simple_expression for the lower bound of the range.
--
-- Appropriate Constraint_Kinds:
-- A_Simple_Expression_Range
--
-- Appropriate Discrete_Range_Kinds:
-- A_Discrete_Simple_Expression_Range
--
-- Returns Element_Kinds:
-- An_Expression
--
-------------------------------------------------------------------------------
-- 16.24 function Upper_Bound
-------------------------------------------------------------------------------
function Upper_Bound (Constraint : in Asis.Range_Constraint)
return Asis.Expression;
-------------------------------------------------------------------------------
-- Constraint - Specifies the range_constraint or discrete_range to query
--
-- Returns the simple_expression for the upper bound of the range.
--
-- Appropriate Constraint_Kinds:
-- A_Simple_Expression_Range
--
-- Appropriate Discrete_Range_Kinds:
-- A_Discrete_Simple_Expression_Range
--
-- Returns Element_Kinds:
-- An_Expression
--
-- |ER------------------------------------------------------------------------
-- |ER A_Range_Attribute_Reference - 3.5
-- |CR
-- |CR Child elements returned by:
-- |CR function Range_Attribute
--
-------------------------------------------------------------------------------
-- 16.25 function Range_Attribute
-------------------------------------------------------------------------------
function Range_Attribute (Constraint : in Asis.Range_Constraint)
return Asis.Expression;
-------------------------------------------------------------------------------
-- Constraint - Specifies the range_attribute_reference or
-- discrete_range attribute_reference to query
--
-- Returns the range_attribute_reference expression of the range.
--
-- Appropriate Constraint_Kinds:
-- A_Range_Attribute_Reference
--
-- Appropriate Discrete_Range_Kinds:
-- A_Discrete_Range_Attribute_Reference
--
-- Returns Expression_Kinds:
-- An_Attribute_Reference
--
-- |ER------------------------------------------------------------------------
-- |ER A_Digits_Constraint - 3.5.9
-- |CR
-- |CR Child elements returned by:
-- |CR function Digits_Expression
-- |CR function Real_Range_Constraint
-- |ER------------------------------------------------------------------------
-- |ER A_Delta_Constraint - J.3
-- |CR
-- |CR Child elements returned by:
-- |CR function Delta_Expression
-- |CR function Real_Range_Constraint
-- |CR------------------------------------------------------------------------
-- |ER An_Index_Constraint - 3.6.1
-- |CR
-- |CR Child elements returned by:
-- |CR function Discrete_Ranges
--
-------------------------------------------------------------------------------
-- 16.26 function Discrete_Ranges
-------------------------------------------------------------------------------
function Discrete_Ranges (Constraint : in Asis.Constraint)
return Asis.Discrete_Range_List;
-------------------------------------------------------------------------------
-- Constraint - Specifies the array index_constraint to query
--
-- Returns the list of discrete_range components for an index_constraint,
-- in their order of appearance.
--
-- Appropriate Constraint_Kinds:
-- An_Index_Constraint
--
-- Returns Definition_Kinds:
-- A_Discrete_Range
--
-- |ER------------------------------------------------------------------------
-- |ER A_Discriminant_Constraint - 3.7.1
-- |CR
-- |CR Child elements returned by:
-- |CR function Discriminant_Associations
--
-------------------------------------------------------------------------------
-- 16.27 function Discriminant_Associations
-------------------------------------------------------------------------------
function Discriminant_Associations
(Constraint : in Asis.Constraint;
Normalized : in Boolean := False)
return Asis.Discriminant_Association_List;
-------------------------------------------------------------------------------
-- Constraint - Specifies the discriminant_constraint to query
-- Normalized - Specifies whether the normalized form is desired
--
-- Returns a list of the discriminant_association elements of the
-- discriminant_constraint.
--
-- Returns a Nil_Element_List if there are no discriminant_association
-- elements.
--
-- An unnormalized list contains only explicit associations ordered as they
-- appear in the program text. Each unnormalized association has a list of
-- discriminant_selector_name elements and an explicit expression.
--
-- A normalized list contains artificial associations representing all
-- explicit associations. It has a length equal to the number of
-- discriminant_specification elements of the known_discriminant_part.
-- The order of normalized associations matches the order of
-- discriminant_specification elements.
--
-- Each normalized association represents a one on one mapping of a
-- discriminant_specification to the explicit expression. A normalized
-- association has one A_Defining_Name component that denotes the
-- discriminant_specification, and one An_Expression component that is the
-- explicit expression.
--
-- Appropriate Constraint_Kinds:
-- A_Discriminant_Constraint
--
-- Returns Association_Kinds:
-- A_Discriminant_Association
--
-- |IR Implementation Requirements:
-- |IR
-- |IR Normalized associations are Is_Normalized and Is_Part_Of_Implicit.
-- |IR Normalized associations are never Is_Equal to unnormalized
-- |IR associations.
--
-- |IP Implementation Permissions:
-- |IP
-- |IP An implementation may choose to normalize its internal representation
-- |IP to use the defining_identifier element instead of the
-- |IP discriminant_selector_name element.
-- |IP
-- |IP If so, this query will return Is_Normalized associations even if
-- |IP Normalized is False, and the query Discriminant_Associations_Normalized
-- |IP will return True.
--
-- |AN Application Note:
-- |AN
-- |AN It is not possible to obtain either a normalized or unnormalized
-- |AN Discriminant_Association list for an unconstrained record or derived
-- |AN subtype_indication where the discriminant_association elements are
-- |AN supplied by default; there is no constraint to query, and a
-- |AN Nil_Element is returned from the query Subtype_Constraint.
--
-- |ER------------------------------------------------------------------------
-- |ER A_Component_Definition - 3.6
-- |CR
-- |CR Child elements returned by:
-- |CR function Component_Subtype_Indication
--
-------------------------------------------------------------------------------
-- 16.28 function Component_Subtype_Indication
-------------------------------------------------------------------------------
function Component_Subtype_Indication
(Component_Definition : in Asis.Component_Definition)
return Asis.Subtype_Indication;
-------------------------------------------------------------------------------
-- Component_Definition - Specifies the Component_Definition to query
--
-- Returns the subtype_indication of the Component_Definition.
--
-- Appropriate Definition_Kinds:
-- A_Component_Definition
--
-- Returns Definition_Kinds:
-- A_Subtype_Indication
--
-- |ER------------------------------------------------------------------------
-- |ER A_Discrete_Subtype_Definition - 3.6
-- |ER A_Discrete_Range - 3.6.1
-- |ER
-- |ER A_Discrete_Subtype_Indication
-- |CR
-- |CR Child elements returned by:
-- |CR function Subtype_Mark
-- |CR function Subtype_Constraint
-- |CR
-- |CR A_Discrete_Simple_Expression_Range
-- |CR
-- |CR Child elements returned by:
-- |CR function Lower_Bound
-- |CR function Upper_Bound
-- |ER
-- |ER------------------------------------------------------------------------
-- |ER A_Discrete_Range_Attribute_Reference - 3.5
-- |CR
-- |CR Child elements returned by:
-- |CR function Range_Attribute
-- |ER------------------------------------------------------------------------
-- |ER An_Unknown_Discriminant_Part - 3.7 - No child elements
-- |ER------------------------------------------------------------------------
-- |ER A_Known_Discriminant_Part - 3.7
-- |CR
-- |CR Child elements returned by:
-- |CR function Discriminants
--
-------------------------------------------------------------------------------
-- 16.29 function Discriminants
-------------------------------------------------------------------------------
function Discriminants (Definition : in Asis.Definition)
return Asis.Discriminant_Specification_List;
-------------------------------------------------------------------------------
-- Definition - Specifies the known_discriminant_part to query
--
-- Returns a list of discriminant_specification elements, in their order
-- of appearance.
--
-- Results of this query may vary across ASIS implementations. Some
-- implementations normalize all multi-name discriminant_specification
-- elements into an equivalent sequence of single name
-- discriminant_specification elements. See Reference Manual 3.3.1(7).
--
-- Appropriate Definition_Kinds:
-- A_Known_Discriminant_Part
--
-- Returns Declaration_Kinds:
-- A_Discriminant_Specification
--
-- |ER------------------------------------------------------------------------
-- |ER A_Record_Definition - 3.8
-- |CR
-- |CR Child elements returned by:
-- |CR function Record_Components
-- |CR function Implicit_Components
--
-------------------------------------------------------------------------------
-- 16.30 function Record_Components
-------------------------------------------------------------------------------
function Record_Components (Definition : in Asis.Definition;
Include_Pragmas : in Boolean := False)
return Asis.Record_Component_List;
-------------------------------------------------------------------------------
-- Definition - Specifies the record_definition or variant to query
-- Include_Pragmas - Specifies whether pragmas are to be returned
--
-- Returns a list of the components and pragmas of the record_definition or
-- variant, in their order of appearance.
--
-- Declarations are not returned for implementation-defined components of the
-- record_definition. See Reference Manual 13.5.1 (15). These components are
-- not normally visible to the ASIS application. However, they can be
-- obtained with the query Implicit_Components.
--
-- Appropriate Definition_Kinds:
-- A_Record_Definition
-- A_Variant
--
-- Returns Element_Kinds:
-- A_Pragma
-- A_Declaration
-- A_Definition
-- A_Clause
--
-- Returns Declaration_Kinds:
-- A_Component_Declaration
--
-- Returns Definition_Kinds:
-- A_Null_Component
-- A_Variant_Part
--
-- Returns Representation_Clause_Kinds:
-- An_Attribute_Definition_Clause
--
-------------------------------------------------------------------------------
-- 16.31 function Implicit_Components
-------------------------------------------------------------------------------
function Implicit_Components
(Definition : in Asis.Definition)
return Asis.Record_Component_List;
-------------------------------------------------------------------------------
-- Definition - Specifies the record_definition or variant to query
--
-- Returns a list of all implicit implementation-defined components of the
-- record_definition or variant. The Enclosing_Element of each component is
-- the Definition argument. Each component is Is_Part_Of_Implicit.
--
-- Returns a Nil_Element_List if there are no implicit implementation-defined
-- components or if the ASIS implementation does not support such
-- implicit declarations.
--
-- Appropriate Definition_Kinds:
-- A_Record_Definition
-- A_Variant
--
-- Returns Element_Kinds:
-- A_Declaration
--
-- Returns Declaration_Kinds:
-- A_Component_Declaration
--
-- |IP Implementation Permissions:
-- |IP
-- |IP Some implementations do not represent all forms of implicit
-- |IP declarations such that elements representing them can be easily
-- |IP provided. An implementation can choose whether or not to construct
-- |IP and provide artificial declarations for implicitly declared elements.
-- |IP
-- |IP Use the query Implicit_Components_Supported to determine if the
-- |IP implementation provides implicit record components.
--
-- |ER------------------------------------------------------------------------
-- |ER A_Null_Record_Definition - 3.8 - No child elements
-- |ER------------------------------------------------------------------------
-- |ER A_Variant_Part - 3.8.1
-- |CR
-- |CR Child elements returned by:
-- |CR function Discriminant_Direct_Name
-- |CR function Variants
--
-------------------------------------------------------------------------------
-- 16.32 function Discriminant_Direct_Name
-------------------------------------------------------------------------------
function Discriminant_Direct_Name
(Variant_Part : in Asis.Record_Component)
return Asis.Name;
-------------------------------------------------------------------------------
-- Variant_Part - Specifies the variant_part to query
--
-- Returns the Discriminant_Direct_Name of the variant_part.
--
-- Appropriate Definition_Kinds:
-- A_Variant_Part
--
-- Returns Expression_Kinds:
-- An_Identifier
--
-------------------------------------------------------------------------------
-- 16.33 function Variants
-------------------------------------------------------------------------------
function Variants (Variant_Part : in Asis.Record_Component;
Include_Pragmas : in Boolean := False)
return Asis.Variant_List;
-------------------------------------------------------------------------------
-- Variant_Part - Specifies the variant_part to query
-- Include_Pragmas - Specifies whether pragmas are to be returned
--
-- Returns a list of variants that make up the record component, in their
-- order of appearance.
--
-- The only pragmas returned are those following the reserved word "is"
-- and preceding the reserved word "when" of first variant, and those between
-- following variants.
--
-- Appropriate Definition_Kinds:
-- A_Variant_Part
--
-- Returns Element_Kinds:
-- A_Pragma
-- A_Definition
--
-- Returns Definition_Kinds:
-- A_Variant
--
-- |ER------------------------------------------------------------------------
-- |ER A_Variant - 3.8.1
-- |CR
-- |CR Child elements returned by:
-- |CR function Variant_Choices
-- |CR function Record_Components
-- |CR function Implicit_Components
--
-------------------------------------------------------------------------------
-- 16.34 function Variant_Choices
-------------------------------------------------------------------------------
function Variant_Choices (Variant : in Asis.Variant)
return Asis.Element_List;
-------------------------------------------------------------------------------
-- Variant - Specifies the variant to query
--
-- Returns the discrete_choice_list elements, in their order of appearance.
-- Choices are either an expression, a discrete range, or an others choice.
--
-- Appropriate Definition_Kinds:
-- A_Variant
--
-- Returns Element_Kinds:
-- An_Expression
-- A_Definition
--
-- Returns Definition_Kinds:
-- A_Discrete_Range
-- An_Others_Choice
--
-- |ER------------------------------------------------------------------------
-- |ER A_Private_Type_Definition - 7.3 - No child elements
-- |ER A_Tagged_Private_Type_Definition - 7.3 - No child elements
-- |ER------------------------------------------------------------------------
-- |ER A_Private_Extension_Definition - 7.3
-- |CR
-- |CR Child elements returned by:
-- |CR function Ancestor_Subtype_Indication
--
-------------------------------------------------------------------------------
-- 16.35 function Ancestor_Subtype_Indication
-------------------------------------------------------------------------------
function Ancestor_Subtype_Indication
(Definition : in Asis.Definition)
return Asis.Subtype_Indication;
-------------------------------------------------------------------------------
-- Definition - Specifies the definition to query
--
-- Returns the ancestor_subtype_indication following the reserved word "new"
-- in the private_extension_declaration.
--
-- Appropriate Definition_Kinds:
-- A_Private_Extension_Definition
--
-- Returns Definition_Kinds:
-- A_Subtype_Indication
--
-- |ER------------------------------------------------------------------------
-- |ER A_Task_Definition - 9.1
-- |ER A_Protected_Definition - 9.4
-- |CR
-- |CR Child elements returned by:
-- |CR functions Visible_Part_Items and Private_Part_Items
--
-------------------------------------------------------------------------------
-- 16.36 function Visible_Part_Items
-------------------------------------------------------------------------------
function Visible_Part_Items
(Definition : in Asis.Definition;
Include_Pragmas : in Boolean := False)
return Asis.Declarative_Item_List;
-------------------------------------------------------------------------------
-- Type_Definition - Specifies the type_definition to query
-- Include_Pragmas - Specifies whether pragmas are to be returned
--
-- Returns a list of declarations, representation clauses, and pragmas
-- in the visible part of the task or protected definition, in their order
-- of appearance. The list does not include discriminant_specification
-- elements of the known_discriminant_part, if any, of the protected type
-- or task type declaration.
--
-- Returns a Nil_Element_List if there are no items.
--
-- Appropriate Definition_Kinds:
-- A_Task_Definition
-- A_Protected_Definition
--
-- Returns Element_Kinds:
-- A_Pragma
-- A_Declaration
-- A_Clause
--
-------------------------------------------------------------------------------
-- 16.37 function Private_Part_Items
-------------------------------------------------------------------------------
function Private_Part_Items
(Definition : in Asis.Definition;
Include_Pragmas : in Boolean := False)
return Asis.Declarative_Item_List;
-------------------------------------------------------------------------------
-- Type_Definition - Specifies the task type definition to query
-- Include_Pragmas - Specifies whether pragmas are to be returned
--
-- Returns a list of declarations, representation clauses, and pragmas in
-- the private part of the task or protected definition, in their order
-- of appearance.
--
-- Returns a Nil_Element_List if there are no items.
--
-- Appropriate Definition_Kinds:
-- A_Task_Definition
-- A_Protected_Definition
--
-- Returns Element_Kinds:
-- A_Pragma
-- A_Declaration
-- A_Clause
--
-------------------------------------------------------------------------------
-- 16.38 function Is_Private_Present
-------------------------------------------------------------------------------
function Is_Private_Present
(Definition : in Asis.Definition) return Boolean;
-------------------------------------------------------------------------------
-- Definition - Specifies the definition to query
--
-- Returns True if the argument is a task_definition or a protected_definition
-- that has a reserved word "private" marking the beginning of a
-- (possibly empty) private part.
--
-- Returns False for any definition without a private part.
-- Returns False for any unexpected Element.
--
-- Expected Definition_Kinds:
-- A_Task_Definition
-- A_Protected_Definition
--
-- |ER------------------------------------------------------------------------
-- |ER A_Formal_Type_Definition - 12.5
-- |ER
-- |ER A_Formal_Private_Type_Definition - 12.5.1 - No child elements
-- |ER A_Formal_Tagged_Private_Type_Definition - 12.5.1 - No child elements
-- |ER
-- |ER A_Formal_Derived_Type_Definition
-- |CR Child elements returned by:
-- |CR function Subtype_Mark
--
-- |ER------------------------------------------------------------------------
-- |ER A_Formal_Discrete_Type_Definition - 12.5.2 - No child elements
-- |ER A_Formal_Signed_Integer_Type_Definition - 12.5.2 - No child elements
-- |ER A_Formal_Modular_Type_Definition - 12.5.2 - No child elements
-- |ER A_Formal_Floating_Point_Definition - 12.5.2 - No child elements
-- |ER A_Formal_Ordinary_Fixed_Point_Definition - 12.5.2 - No child elements
-- |ER A_Formal_Decimal_Fixed_Point_Definition - 12.5.2 - No child elements
-- |ER------------------------------------------------------------------------
-- |ER A_Formal_Unconstrained_Array_Definition - 12.5.3
-- |CR
-- |CR Child elements returned by:
-- |CR function Index_Subtype_Definitions
-- |CR function Array_Component_Definition
-- |ER------------------------------------------------------------------------
-- |ER A_Formal_Constrained_Array_Definition - 12.5.3
-- |CR
-- |CR Child elements returned by:
-- |CR function Discrete_Subtype_Definitions
-- |CR function Array_Component_Definition
-- |ER------------------------------------------------------------------------
-- |ER A_Formal_Access_Type_Definition - 12.5.4
-- |CR
-- |CR Child elements returned by:
-- |CR function Access_To_Object_Definition
-- |CR function Access_To_Subprogram_Parameter_Profile
-- |CR function Access_To_Function_Result_Profile
--
-------------------------------------------------------------------------------
-- 16.xx function Progenitor_List
-------------------------------------------------------------------------------
function Progenitor_List
(Type_Definition : Asis.Definition)
return Asis.Name_List;
-------------------------------------------------------------------------------
-- Type_Definition - specifies the definition to query.
--
-- Returns a list of subtype marks making up the interface_list in the
-- argument definition, in their order of appearance.
--
-- Appropriate Type_Kinds:
-- A_Derived_Record_Extension_Definition
-- An_Interface_Type_Definition
--
-- Appropriate Formal_Type_Kinds:
-- A_Formal_Derived_Type_Definition
-- A_Formal_Interface_Type_Definition
--
-- Returns Expression_Kinds:
-- An_Identifier
-- A_Selected_Component
--
-------------------------------------------------------------------------------
-- 16.xx function Is_Task_Definition_Present
-------------------------------------------------------------------------------
function Is_Task_Definition_Present
(Definition : in Asis.Definition)
return Boolean;
-------------------------------------------------------------------------------
-- Definition specifies the definition element to query.
--
-- Returns True if the element has a task_definition that is given explicitly.
--
-- Returns False for any other Element including a Nil_Element.
--
-- Note: Is_Task_Definition_Present is used to determine whether the
-- original text was "Task T;" (for which it returns False) or
-- "Task T is end T;" (for which it returns True).
--
-- Expected Definition_Kinds:
-- A_Task_Definition
--
-------------------------------------------------------------------------------
end Asis.Definitions;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, Maxim Reznik
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * Neither the name of the Maxim Reznik, IE nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
|
sungyeon/drake | Ada | 4,950 | adb | with System.Debug; -- assertions
with C.errno;
with C.sched;
with C.signal;
package body System.Native_Tasks is
use type C.signed_int;
use type C.unsigned_int;
type sigaction_Wrapper is record -- ??? for No_Elaboration_Code
Handle : aliased C.signal.struct_sigaction;
end record;
pragma Suppress_Initialization (sigaction_Wrapper);
Old_SIGTERM_Action : aliased sigaction_Wrapper; -- uninitialized
Installed_Abort_Handler : Abort_Handler;
procedure SIGTERM_Handler (
Signal_Number : C.signed_int;
Info : access C.signal.siginfo_t;
Context : C.void_ptr)
with Convention => C;
procedure SIGTERM_Handler (
Signal_Number : C.signed_int;
Info : access C.signal.siginfo_t;
Context : C.void_ptr)
is
pragma Unreferenced (Signal_Number);
pragma Unreferenced (Info);
pragma Unreferenced (Context);
begin
Installed_Abort_Handler.all;
end SIGTERM_Handler;
procedure Mask_SIGTERM (How : C.signed_int);
procedure Mask_SIGTERM (How : C.signed_int) is
Mask : aliased C.signal.sigset_t;
errno : C.signed_int;
Dummy_R : C.signed_int;
begin
Dummy_R := C.signal.sigemptyset (Mask'Access);
Dummy_R := C.signal.sigaddset (Mask'Access, C.signal.SIGTERM);
errno := C.pthread.pthread_sigmask (How, Mask'Access, null);
pragma Check (Debug,
Check =>
errno = 0 or else Debug.Runtime_Error ("pthread_sigmask failed"));
end Mask_SIGTERM;
-- implementation of thread
procedure Create (
Handle : aliased out Handle_Type;
Parameter : Parameter_Type;
Thread_Body : Thread_Body_Type;
Error : out Boolean) is
begin
Error := C.pthread.pthread_create (
Handle'Access,
null,
Thread_Body.all'Access, -- type is different between platforms
Parameter) /= 0;
end Create;
procedure Join (
Handle : Handle_Type; -- of target thread
Current_Abort_Event : access Synchronous_Objects.Event;
Result : aliased out Result_Type;
Error : out Boolean)
is
pragma Unreferenced (Current_Abort_Event);
begin
Error := C.pthread.pthread_join (Handle, Result'Access) /= 0;
end Join;
procedure Detach (
Handle : Handle_Type;
Error : out Boolean) is
begin
Error := C.pthread.pthread_detach (Handle) /= 0;
end Detach;
-- implementation of stack
function Info_Block (Handle : Handle_Type) return C.pthread.pthread_t is
begin
return Handle;
end Info_Block;
-- implementation of signals
procedure Install_Abort_Handler (Handler : Abort_Handler) is
act : aliased C.signal.struct_sigaction := (
(Unchecked_Tag => 1, sa_sigaction => SIGTERM_Handler'Access),
others => <>); -- uninitialized
R : C.signed_int;
Dummy_R : C.signed_int;
begin
Installed_Abort_Handler := Handler;
act.sa_flags := C.signal.SA_SIGINFO;
Dummy_R := C.signal.sigemptyset (act.sa_mask'Access);
R := C.signal.sigaction (
C.signal.SIGTERM,
act'Access,
Old_SIGTERM_Action.Handle'Access);
pragma Check (Debug,
Check =>
not (R < 0) or else Debug.Runtime_Error ("sigaction failed"));
end Install_Abort_Handler;
procedure Uninstall_Abort_Handler is
R : C.signed_int;
begin
R := C.signal.sigaction (
C.signal.SIGTERM,
Old_SIGTERM_Action.Handle'Access,
null);
pragma Check (Debug,
Check =>
not (R < 0) or else Debug.Runtime_Error ("sigaction failed"));
end Uninstall_Abort_Handler;
procedure Send_Abort_Signal (
Handle : Handle_Type;
Abort_Event : in out Synchronous_Objects.Event;
Error : out Boolean) is
begin
-- write to the pipe
Synchronous_Objects.Set (Abort_Event);
-- send SIGTERM
Resend_Abort_Signal (Handle, Error => Error);
end Send_Abort_Signal;
procedure Resend_Abort_Signal (Handle : Handle_Type; Error : out Boolean) is
begin
case C.pthread.pthread_kill (Handle, C.signal.SIGTERM) is
when 0 =>
Yield;
Error := False;
when C.errno.ESRCH =>
Error := False; -- it is already terminated, C9A003A
when others =>
Error := True;
end case;
end Resend_Abort_Signal;
procedure Block_Abort_Signal (Abort_Event : Synchronous_Objects.Event) is
pragma Unreferenced (Abort_Event);
begin
Mask_SIGTERM (C.signal.SIG_BLOCK);
end Block_Abort_Signal;
procedure Unblock_Abort_Signal is
begin
Mask_SIGTERM (C.signal.SIG_UNBLOCK);
end Unblock_Abort_Signal;
procedure Yield is
R : C.signed_int;
begin
R := C.sched.sched_yield;
pragma Check (Debug,
Check =>
not (R < 0) or else Debug.Runtime_Error ("sched_yield failed"));
end Yield;
end System.Native_Tasks;
|
reznikmm/matreshka | Ada | 4,019 | 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.Table_Layout_Mode_Attributes;
package Matreshka.ODF_Table.Layout_Mode_Attributes is
type Table_Layout_Mode_Attribute_Node is
new Matreshka.ODF_Table.Abstract_Table_Attribute_Node
and ODF.DOM.Table_Layout_Mode_Attributes.ODF_Table_Layout_Mode_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Table_Layout_Mode_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Table_Layout_Mode_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Table.Layout_Mode_Attributes;
|
msrLi/portingSources | Ada | 801 | ads | -- Copyright 2007-2014 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
procedure Do_Nothing (A : System.Address);
end Pck;
|
veyselharun/ABench2020 | Ada | 3,477 | adb | --
-- ABench2020 Benchmark Suite
--
-- Sample Correlation Coefficient Calculation Program
--
-- Licensed under the MIT License. See LICENSE file in the ABench root
-- directory for license information.
--
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Numerics.Elementary_Functions; use Ada.Numerics.Elementary_Functions;
procedure Correlation_FI is
type Float_Array is array (1..10) of Float;
Sample_X : Float_Array;
Sample_Y : Float_Array;
procedure Read_File is
Input_File : File_Type;
Start : Integer;
Location : Integer;
Value : Float;
Arr_Index : Integer;
begin
Open (File => Input_File, Mode => In_File, Name => "input.txt");
declare
Line1 : String := Get_Line (Input_File);
Line2 : String := Get_Line (Input_File);
begin
Arr_Index := 1;
Start := Line1'First;
loop
Location := Index (Line1, ",", From => Start);
exit when Location = 0;
Value := Float'Value (Line1 (Start..Location - 1));
Sample_X (Arr_Index) := Value;
Start := Location + 1;
Arr_Index := Arr_Index + 1;
end loop;
Value := Float'Value (Line1 (Start..Line1'Last));
Sample_X (Arr_Index) := Value;
Arr_Index := 1;
Start := Line2'First;
loop
Location := Index (Line2, ",", From => Start);
exit when Location = 0;
Value := Float'Value (Line2 (Start..Location - 1));
Sample_Y (Arr_Index) := Value;
Start := Location + 1;
Arr_Index := Arr_Index + 1;
end loop;
Value := Float'Value (Line2 (Start..Line2'Last));
Sample_Y (Arr_Index) := Value;
end;
Close (Input_File);
exception
when End_Error =>
if Is_Open(Input_File) then
Close (Input_File);
end if;
end;
function Calc_Coefficient (Sample_X, Sample_Y : in Float_Array) return Float is
Coefficient : Float := 0.0;
Sum_X, Sum_Y, Sum_XY : Float := 0.0;
Square_Sum_X, Square_Sum_Y : Float := 0.0;
Avg_X, Avg_Y : Float := 0.0;
begin
for I in Sample_X'First..Sample_X'Last loop
Sum_X := Sum_X + Sample_X (I);
end loop;
Avg_X := Sum_X / Float(Sample_X'Length);
for I in Sample_Y'First..Sample_Y'Last loop
Sum_Y := Sum_Y + Sample_Y (I);
end loop;
Avg_Y := Sum_Y / Float(Sample_Y'Length);
for I in Sample_X'First..Sample_X'Last loop
Sum_XY := Sum_XY + ((Sample_X (I) - Avg_X) * (Sample_Y (I) - Avg_Y));
end loop;
for I in Sample_X'First..Sample_X'Last loop
Square_Sum_X := Square_Sum_X + ((Sample_X (I) - Avg_X) * (Sample_X (I) - Avg_X));
Square_Sum_Y := Square_Sum_Y + ((Sample_Y (I) - Avg_Y) * (Sample_Y (I) - Avg_Y));
end loop;
Coefficient := Sum_XY / Sqrt (Square_Sum_X * Square_Sum_Y);
return Coefficient;
end;
Result : Float;
begin
Read_File;
Result := Calc_Coefficient (Sample_X, Sample_Y);
-- Uncomment the line below to print the result.
-- Put_Line (Float'Image (Result));
end;
|
ohenley/ada-util | Ada | 5,702 | adb | -----------------------------------------------------------------------
-- util-events-timers-tests -- Unit tests for timers
-- Copyright (C) 2017 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;
package body Util.Events.Timers.Tests is
use Util.Tests;
use type Ada.Real_Time.Time;
package Caller is new Util.Test_Caller (Test, "Events.Timers");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Util.Events.Timers.Is_Scheduled",
Test_Empty_Timer'Access);
Caller.Add_Test (Suite, "Test Util.Events.Timers.Process",
Test_Timer_Event'Access);
Caller.Add_Test (Suite, "Test Util.Events.Timers.Repeat",
Test_Repeat_Timer'Access);
Caller.Add_Test (Suite, "Test Util.Events.Timers.Repeat+Process",
Test_Many_Timers'Access);
end Add_Tests;
overriding
procedure Time_Handler (Sub : in out Test;
Event : in out Timer_Ref'Class) is
begin
Sub.Count := Sub.Count + 1;
if Sub.Repeat > 1 then
Sub.Repeat := Sub.Repeat - 1;
Event.Repeat (Ada.Real_Time.Milliseconds (1));
end if;
end Time_Handler;
-- -----------------------
-- Test empty timers.
-- -----------------------
procedure Test_Empty_Timer (T : in out Test) is
M : Timer_List;
R : Timer_Ref;
Deadline : Ada.Real_Time.Time;
begin
T.Assert (not R.Is_Scheduled, "Empty timer should not be scheduled");
T.Assert (R.Time_Of_Event = Ada.Real_Time.Time_Last, "Time_Of_Event returned invalid value");
R.Cancel;
M.Process (Deadline);
T.Assert (Deadline = Ada.Real_Time.Time_Last,
"The Process operation returned invalid deadline");
end Test_Empty_Timer;
procedure Test_Timer_Event (T : in out Test) is
M : Timer_List;
R : Timer_Ref;
Start : constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
Deadline : Ada.Real_Time.Time;
Now : Ada.Real_Time.Time;
begin
for Retry in 1 .. 10 loop
M.Set_Timer (T'Unchecked_Access, R, Start + Ada.Real_Time.Milliseconds (10));
M.Process (Deadline);
Now := Ada.Real_Time.Clock;
exit when Now < Deadline;
end loop;
T.Assert (Now < Deadline, "The timer deadline is not correct");
delay until Deadline;
M.Process (Deadline);
Assert_Equals (T, 1, T.Count, "The timer handler was not called");
end Test_Timer_Event;
-- -----------------------
-- Test repeating timers.
-- -----------------------
procedure Test_Repeat_Timer (T : in out Test) is
M : Timer_List;
R : Timer_Ref;
Start : constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
Deadline : Ada.Real_Time.Time;
Now : Ada.Real_Time.Time;
begin
T.Count := 0;
T.Repeat := 5;
for Retry in 1 .. 10 loop
M.Set_Timer (T'Unchecked_Access, R, Start + Ada.Real_Time.Milliseconds (10));
M.Process (Deadline);
Now := Ada.Real_Time.Clock;
exit when Now < Deadline;
end loop;
T.Assert (Now < Deadline, "The timer deadline is not correct");
loop
delay until Deadline;
M.Process (Deadline);
exit when Deadline >= Now + Ada.Real_Time.Seconds (1);
end loop;
Assert_Equals (T, 5, T.Count, "The timer handler was not repeated");
end Test_Repeat_Timer;
-- -----------------------
-- Test executing several timers.
-- -----------------------
procedure Test_Many_Timers (T : in out Test) is
Timer_Count : constant Positive := 30;
type Timer_Ref_Array is array (1 .. Timer_Count) of Timer_Ref;
type Test_Ref_Array is array (1 .. Timer_Count) of aliased Test;
M : Timer_List;
Start : constant Ada.Real_Time.Time := Ada.Real_Time.Clock;
Deadline : Ada.Real_Time.Time;
R : Timer_Ref_Array;
D : Test_Ref_Array;
Dt : Ada.Real_Time.Time_Span;
Count : Natural := 0;
begin
for I in R'Range loop
D (I).Count := 0;
D (I).Repeat := 4;
if I mod 2 = 0 then
Dt := Ada.Real_Time.Milliseconds (40);
else
Dt := Ada.Real_Time.Milliseconds (20);
end if;
M.Set_Timer (D (I)'Unchecked_Access, R (I), Start + Dt);
end loop;
loop
M.Process (Deadline);
exit when Deadline >= Start + Ada.Real_Time.Seconds (10);
Count := Count + 1;
delay until Deadline;
end loop;
Util.Tests.Assert_Equals (T, 8, Count, "Count of Process");
for I in D'Range loop
Util.Tests.Assert_Equals (T, 4, D (I).Count, "Invalid count for timer at "
& Natural'Image (I) & " " & Natural'Image (Count));
end loop;
end Test_Many_Timers;
end Util.Events.Timers.Tests;
|
reznikmm/matreshka | Ada | 7,249 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2015-2018, 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.Definitions;
with Asis.Elements;
with Properties.Tools;
package body Properties.Definitions.Unconstrained_Array_Type is
----------
-- Code --
----------
function Code
(Engine : access Engines.Contexts.Context;
Element : Asis.Definition;
Name : Engines.Text_Property) return League.Strings.Universal_String
is
Decl : constant Asis.Declaration :=
Asis.Elements.Enclosing_Element (Element);
Is_Array_Buffer : constant Boolean :=
Properties.Tools.Is_Array_Buffer (Decl);
Is_Array_Of_Simple : constant Boolean :=
Engine.Boolean.Get_Property (Element, Engines.Is_Array_Of_Simple);
Result : League.Strings.Universal_String;
Text : League.Strings.Universal_String;
begin
Result.Append ("(function (){"); -- Wrapper
Result.Append ("var _result = function (_from,_to){"); -- Constructor
Result.Append ("var _first=_from.map (_ec._pos);");
Result.Append ("var _len=_to.map (function (_to, i)" &
"{ return _ec._pos(_to) - _first[i] + 1; });");
Result.Append ("var _length=_len.reduce (function (a, b)" &
"{ return a * b; }, 1);");
if Is_Array_Buffer then
declare
Comp : constant Asis.Component_Definition :=
Asis.Definitions.Array_Component_Definition (Element);
View : constant Asis.Definition :=
Asis.Definitions.Component_Definition_View (Comp);
Size : constant League.Strings.Universal_String :=
Engine.Text.Get_Property (View, Engines.Size);
Align : constant Integer :=
Engine.Integer.Get_Property (View, Engines.Alignment);
Image : constant Wide_Wide_String :=
Integer'Wide_Wide_Image (Align - 1);
begin
Result.Append ("this._element_size =");
Result.Append (Size); -- Size always x8 for TypedArray
Result.Append ("/8;");
Result.Append
("this._ArrayBuffer(_length * ((this._element_size + ");
Result.Append (Image (2 .. Image'Last));
Result.Append (") & ~");
Result.Append (Image (2 .. Image'Last));
Result.Append ("));");
if not Is_Array_Of_Simple then
Text := Engine.Text.Get_Property
(Asis.Definitions.Array_Component_Definition (Element),
Name);
Result.Append ("this._element_type = ");
Result.Append (Text);
Result.Append (";");
end if;
end;
else
Result.Append ("var _data=Array(_length);");
Result.Append ("for (var _j=0;_j<_length;_j++)");
Result.Append ("_data[_j] = ");
Text := Engine.Text.Get_Property
(Asis.Definitions.Array_Component_Definition (Element),
Engines.Initialize);
Result.Append (Text);
Result.Append (";");
Result.Append ("this.A=_data;");
end if;
Result.Append ("this._first=_from;");
Result.Append ("this._last=_to;");
Result.Append ("this._length=_len;");
Result.Append ("this._offset=0;");
Result.Append ("};"); -- End of Constructor
Result.Append ("_result.prototype=");
if Is_Array_Buffer then
Result.Append ("Object.create(_ec._ada_array_ta.prototype);");
else
Result.Append ("_ec.");
if Is_Array_Of_Simple then
Result.Append ("_ada_array_simple");
else
Result.Append ("_ada_array");
end if;
Result.Append (".prototype;");
end if;
Result.Append ("return _result;");
Result.Append ("})();"); -- End of Wrapper and call it
return Result;
end Code;
end Properties.Definitions.Unconstrained_Array_Type;
|
reznikmm/slimp | Ada | 5,492 | adb | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Ada.Wide_Wide_Text_IO;
with Slim.Menu_Commands.Play_File_Commands;
package body Slim.Menu_Models.Play_Lists is
function Create_Play_Command
(Self : Play_List_Menu_Model'Class;
Path : Menu_Path;
Skip : Natural := 0) return Slim.Menu_Commands.Menu_Command_Access;
-------------
-- Collect --
-------------
procedure Collect
(Self : Play_List_Menu_Model'Class;
Path_List : in out League.String_Vectors.Universal_String_Vector;
Title_List : in out League.String_Vectors.Universal_String_Vector)
is
use type League.Strings.Universal_String;
begin
for J in 1 .. Self.Items.Last_Index loop
declare
Item : constant Play_List_Item := Self.Items (J);
begin
Path_List.Append (Self.Path & Item.URI);
Title_List.Append (Item.Label);
end;
end loop;
end Collect;
-------------------------
-- Create_Play_Command --
-------------------------
function Create_Play_Command
(Self : Play_List_Menu_Model'Class;
Path : Menu_Path;
Skip : Natural := 0) return Slim.Menu_Commands.Menu_Command_Access
is
use type League.Strings.Universal_String;
use Slim.Menu_Commands.Play_File_Commands;
Result : constant Play_File_Command_Access :=
new Play_File_Command (Self.Player);
begin
Result.Root := Self.Root;
Result.M3U_Name := Self.M3U;
Result.Start := Path.List (1);
Result.Skip := Skip;
for J in 1 .. Self.Items.Last_Index loop
declare
Item : constant Play_List_Item := Self.Items (J);
begin
Result.Relative_Path_List.Append (Self.Path & Item.URI);
Result.Title_List.Append (Item.Label);
end;
end loop;
return Slim.Menu_Commands.Menu_Command_Access (Result);
end Create_Play_Command;
-------------------
-- Enter_Command --
-------------------
overriding function Enter_Command
(Self : Play_List_Menu_Model;
Path : Menu_Path) return Slim.Menu_Commands.Menu_Command_Access is
begin
return Self.Create_Play_Command (Path);
end Enter_Command;
----------------
-- Initialize --
----------------
procedure Initialize
(Self : in out Play_List_Menu_Model'Class;
Label : League.Strings.Universal_String;
Root : League.Strings.Universal_String;
File : League.Strings.Universal_String)
is
Name : constant String := File.To_UTF_8_String;
Input : Ada.Wide_Wide_Text_IO.File_Type;
Next : League.Strings.Universal_String;
begin
Self.Label := Label;
Self.M3U := File;
Self.Root := Root;
Self.Path := File.Tail_From (Root.Length + 1);
Self.Path := Self.Path.Head (Self.Path.Last_Index ('/'));
Ada.Wide_Wide_Text_IO.Open
(Input, Ada.Wide_Wide_Text_IO.In_File, Name);
while not Ada.Wide_Wide_Text_IO.End_Of_File (Input) loop
declare
Line : constant League.Strings.Universal_String :=
League.Strings.To_Universal_String
(Ada.Wide_Wide_Text_IO.Get_Line (Input));
begin
if Line.Starts_With ("#EXTINF:") then
declare
List : constant League.String_Vectors.Universal_String_Vector
:= Line.Split (',');
begin
if List.Length > 1 then
Next := List.Element (2);
end if;
end;
elsif Line.Is_Empty or else Line.Starts_With ("#") then
null; -- Skip other tags
else
if Next.Is_Empty then
Next := Line;
end if;
Self.Items.Append ((URI => Line, Label => Next));
Next.Clear;
end if;
end;
end loop;
Ada.Wide_Wide_Text_IO.Close (Input);
end Initialize;
----------------
-- Item_Count --
----------------
overriding function Item_Count
(Self : Play_List_Menu_Model;
Path : Slim.Menu_Models.Menu_Path) return Natural
is
begin
if Path.Length = 0 then
return Self.Items.Last_Index;
else
return 0; -- No nested items in a play list
end if;
end Item_Count;
-----------
-- Label --
-----------
overriding function Label
(Self : Play_List_Menu_Model;
Path : Slim.Menu_Models.Menu_Path)
return League.Strings.Universal_String is
begin
if Path.Length = 0 then
return Self.Label;
else
return Self.Items (Path.List (1)).Label;
end if;
end Label;
------------------
-- Play_Command --
------------------
overriding function Play_Command
(Self : Play_List_Menu_Model;
Path : Menu_Path) return Slim.Menu_Commands.Menu_Command_Access
is
Index : Positive;
Skip : Natural;
begin
if Path.Length = 0 then
Self.Player.Get_Position (Self.M3U, Index, Skip);
-- Try to continue from saved prosition
return Self.Create_Play_Command
((Length => 1, List => (1 => Index)), Skip);
else
return Self.Create_Play_Command (Path);
end if;
end Play_Command;
end Slim.Menu_Models.Play_Lists;
|
sungyeon/drake | Ada | 25 | adb | ../../../zcx/s-unocse.adb |
stcarrez/dynamo | Ada | 12,726 | ads | ------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A 4 G . C O N T T . T T --
-- --
-- S p e c --
-- --
-- Copyright (C) 1995-2011, Free Software Foundation, Inc. --
-- --
-- ASIS-for-GNAT is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 2, or (at your option) any later --
-- version. ASIS-for-GNAT is distributed in the hope that it will be use- --
-- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- --
-- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details. You should have received a copy of the --
-- GNU General Public License distributed with ASIS-for-GNAT; see file --
-- COPYING. If not, write to the Free Software Foundation, 51 Franklin --
-- Street, Fifth Floor, Boston, MA 02110-1301, USA. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the --
-- Software Engineering Laboratory of the Swiss Federal Institute of --
-- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the --
-- Scientific Research Computer Center of Moscow State University (SRCC --
-- MSU), Russia, with funding partially provided by grants from the Swiss --
-- National Science Foundation and the Swiss Academy of Engineering --
-- Sciences. ASIS-for-GNAT is now maintained by AdaCore. --
-- (http://www.adacore.com). --
-- --
------------------------------------------------------------------------------
-- This package defines for each ASIS Context the corresponding Tree Table,
-- which contains the information about the tree output files needed for
-- handling and swapping the ASTs represented by the tree output files
-- accessed by ASIS.
with Asis;
package A4G.Contt.TT is -- Context_Table.Tree_Tables
----------------
-- Tree Table --
----------------
-- The tree table has an entry for each AST ( = tree output file)
-- created and read at least once for this run of ASIS application.
-- The entries in the table are accessing using a Tree_Id which
-- ranges from Nil_Tree (a special value using for initializing
-- ASIS Nil_Element and ASIS Nil_Compilation_Unit) to Last_Tree.
-- Each entry has the following fields:
---------------------
-- Tree Name Table --
---------------------
procedure Get_Name_String (C : Context_Id; Id : Tree_Id);
-- Get_Name_String is used to retrieve the string associated with
-- an entry in the name table. The resulting string is stored in
-- Name_Buffer and Name_Len is set.
function Get_Tree_Name (C : Context_Id; Id : Tree_Id) return String;
-- Returns the full name of the tree file.
function Allocate_Tree_Entry return Tree_Id; -- #####
-- Allocates the new entry in the Tree Table for the tree output file
-- name stored in the A_Name_Buffer (A_Name_Len should be set
-- in a proper way).
------------------------------
-- Internal Tree Attributes --
------------------------------
-- Each Tree entry contains the following fields, representing the Tree
-- attributes needed to organize tree processing inside ASIS
-- implementation:
-- Enclosing_Lib : Context_Id; --##
-- Context Id of the ASIS Context for which the tree has been
-- created.
-- Main_Unit_Id : Unit_Id;
-- The ASIS Compilation Unit, corresponding to the main unit in
-- the tree
-- Main_Top : Node_Id;
-- The top node (having N_Compilation_Unit Node Kind) of Main_Unit
-- Units : Elist_Id;
-- The list of all the Units (or all the Units except Main_Unit?)
-- which may be processed on the base of this tree, [each Unit
-- is accompanied by its top node, which it has in the given tree
-- ??? Not implemented for now!]
---------------------------------------------------------------
-- Internal Tree Unit Attributes Access and Update Routines --
---------------------------------------------------------------
function Main_Unit_Id (T : Tree_Id) return Unit_Id;
function Main_Unit_Id return Unit_Id;
-- Returns the Id of the main unit in Current_Tree
procedure Set_Main_Unit_Id (T : Tree_Id; U : Unit_Id);
procedure Set_Main_Top (T : Tree_Id; N : Node_Id);
-- Do we really need Set procedures having a Tree (and its "enclosing"
-- Context) as a parameter? Now it seems, that all settings will be
-- done for the currently accessing Tree only.
procedure Set_Main_Unit_Id (U : Unit_Id);
procedure Set_Main_Top (N : Node_Id);
-----------------------------------
-- Subprograms for Tree Swapping --
-----------------------------------
function Unit_In_Current_Tree (C : Context_Id; U : Unit_Id) return Boolean;
-- Checks if the subtree for a given Unit defined by C and U, is
-- contained in the currently accessed tree.
procedure Reset_Tree (Context : Context_Id; Tree : Tree_Id);
-- Resets the currently accessed tree to the tree identified by
-- the Context and Tree parameters
procedure Reset_Tree_For_Unit (C : Context_Id; U : Unit_Id);
procedure Reset_Tree_For_Unit (Unit : Asis.Compilation_Unit);
-- Resets the currently accessed tree to some tree containing
-- the subtree for a given unit. For now, there is no special
-- strategy for choosing the tree among all the trees containing
-- the given unit
procedure Reset_Tree_For_Element (E : Asis.Element);
-- Resets the currently accessed tree to the tree containing the node(s)
-- of the argument Element.
procedure Reset_Instance_Tree
(Lib_Level_Instance : Asis.Compilation_Unit;
Decl_Node : in out Node_Id);
-- Given Lib_Level_Instance as ASIS Compilation Unit being a library-level
-- instantiation, or a package or generic package containing
-- an instantiation of some library-level generic unit, and Decl_Node as
-- the node representing some declaration in the corresponding spec (which
-- can be either expanded generics spec if Lib_Level_Instance is a library-
-- level instantiation or a normal spec in case of a (generic) package);
-- it is an error to call this procedure with other arguments), this
-- procedure resets the currently accessed tree to the main tree for
-- Lib_Level_Instance (it may be the tree created for the body of
-- Lib_Level_Instance in case if Lib_Level_Instance is a package
-- declaration) and resets Decl_Node to point to the same construct in
-- this tree.
--
-- If the corresponding ASIS Context does not contain the main tree for
-- this library-level instantiation, the procedure does nothing.
-- Also does nothing if Lib_Level_Instance is a package body
function Restore_Node_From_Trace
(In_Body : Boolean := False;
CU : Asis.Compilation_Unit := Asis.Nil_Compilation_Unit)
return Node_Id;
-- Taking the node trace stored in Node_Trace table, tries to find the
-- construct corresponding to the beginning of the trace in the currently
-- accessed tree. By default we consider that we are in the package spec,
-- unless In_Body is set ON.
procedure Append_Full_View_Tree_To_Unit (C : Context_Id; U : Unit_Id);
procedure Append_Limited_View_Tree_To_Unit (C : Context_Id; U : Unit_Id);
-- Appends the currently accessed tree to the list of the (consistent)
-- trees containing a given Unit (this tree list belongs to the unit U).
procedure Reorder_Trees (C : Context_Id);
-- This procedure is called in the very end of opening the context C, when
-- all the information is already set in the Context Unit table. It
-- reorders the tree lists associated with units according to the
-- following rules (note, that currently the first tree in the tree list
-- is used by Element gateway queries to get into the unit structure:
--
-- (1) for a subunit, the tree for its ancestor body is moved into the
-- first position in the tree list;
--
-- (2) for a package declaration or generic package declaration, if this
-- package requires a body, the tree for the body is moved into the
-- first position in the tree list;
--
-- (3) for package or generic package declaration which does not require a
-- body, the tree created for the given (generic) package is moved
-- into the first position in the tree list;
--
-- (4) for a library-level instantiation, the tree created for the
-- instantiation is moved into the first position in the tree list;
--
-- (5) for a (generic) subprogram declaration, the tree for the
-- corresponding body is moved into the first position in the tree
-- list;
--
-- (6) for the bodies, we may also need to set the main tree first, because
-- according to Lib (h), the body may be compiled as being needed for
-- some spec (or other body unit)
--
-- For -CA Context, if the tree to be moved into the first position in
-- the tree list does not exist, the corresponding warning is generated,
-- except if the corresponding unit is of A_Predefined_Unit or
-- An_Implementation_Unit origin
---------------------------------
-- General-Purpose Subprograms --
---------------------------------
function Present (Tree : Tree_Id) return Boolean;
-- Tests given Tree Id for non-equality with No_Tree_Name.
-- This allows notations like "if Present (Tree)" as opposed to
-- "if Tree /= No_Tree_Name"
function No (Tree : Tree_Id) return Boolean;
-- Tests given Tree Id for equality with No_Tree_Name. This allows
-- notations like "if No (Tree)" as opposed to
-- "if Tree = No_Tree_Name"
function Last_Tree (C : Context_Id) return Tree_Id;
-- Returns the Tree_Id of the last tree which has been allocated
-- in the Tree Table.
procedure Output_Tree (C : Context_Id; Tree : Tree_Id);
-- Produces the debug output of the Tree Table entry corresponding
-- to Tree
procedure Print_Trees (C : Context_Id);
-- Produces the debug output from the Tree table for the Context C.
function Tree_Consistent_With_Sources
(E : Asis.Element)
return Boolean;
function Tree_Consistent_With_Sources
(CU : Asis.Compilation_Unit)
return Boolean;
-- These functions are supposed to be used for Incremental Context mode.
-- They check that the tree from which their argument Element or Unit has
-- been obtained is still consistent with all the sources from which
-- the tree was generated (and that all these sources are available)
-- This function supposes that its argument is not null and that the tree
-- to check is available.
function Current_Tree_Consistent_With_Sources return Boolean;
-- Checks that for the current tree all the sources from which it has been
-- obtained are still available and that the tree is consistent with
-- these sources. The caller is responsible for setting as the current
-- tree the tree he would like to check
end A4G.Contt.TT;
|
shintakezou/langkit | Ada | 5,261 | ads | --
-- Copyright (C) 2014-2022, AdaCore
-- SPDX-License-Identifier: Apache-2.0
--
with Ada.Containers; use Ada.Containers;
with System;
with Langkit_Support.Hashes; use Langkit_Support.Hashes;
with Langkit_Support.Lexical_Envs; use Langkit_Support.Lexical_Envs;
with Langkit_Support.Token_Data_Handlers;
use Langkit_Support.Token_Data_Handlers;
with Langkit_Support.Types; use Langkit_Support.Types;
-- This package provides common implementation details for Langkit-generated
-- libraries. Even though it is not private (to allow Langkit-generated
-- libraries to use it), it is not meant to be used beyond this. As such, this
-- API is considered unsafe and unstable.
package Langkit_Support.Internal.Analysis is
-- Bare pointers to library-specific resources. For contexts, units and
-- nodes, these correspond to the access types defined in $.Implementation.
type Internal_Context is new System.Address;
type Internal_Unit is new System.Address;
type Internal_Node is new System.Address;
No_Internal_Context : constant Internal_Context :=
Internal_Context (System.Null_Address);
No_Internal_Unit : constant Internal_Unit :=
Internal_Unit (System.Null_Address);
No_Internal_Node : constant Internal_Node :=
Internal_Node (System.Null_Address);
type Internal_Node_Metadata is new System.Address;
-- The contents and size of the node metadata record is different from one
-- Langkit-generated library to another, so this generic API needs to refer
-- to it by reference, with ref-counting for lifetime handling. Null
-- addresses mean "default metadata", and the language descriptor table
-- provides ref-counting primitives.
No_Internal_Node_Metadata : constant Internal_Node_Metadata :=
Internal_Node_Metadata (System.Null_Address);
-- As everywhere else, entities are made up of bare nodes and entity
-- information, with regular types from Langkit_Support.Lexical_Envs. The
-- metadata has a special representation: see above (Internal_Node_Metadata
-- type).
type Internal_Entity is record
Node : Internal_Node;
Rebindings : Env_Rebindings;
From_Rebound : Boolean;
Metadata : Internal_Node_Metadata;
end record;
No_Internal_Entity : constant Internal_Entity :=
(No_Internal_Node, null, False, No_Internal_Node_Metadata);
type Internal_Entity_Array is array (Positive range <>) of Internal_Entity;
type Internal_Token is record
TDH : Token_Data_Handler_Access;
Index : Token_Or_Trivia_Index;
end record;
-- Safety nets keep track of information at "public reference value"
-- creation so that later use can check whether the reference is still
-- valid (used to ensure memory safety).
type Node_Safety_Net is record
Context : Internal_Context;
Context_Version : Version_Number;
-- Analysis context and version number at the time this safety net was
-- produced.
Unit : Internal_Unit;
Unit_Version : Version_Number;
-- Analysis unit and unit version at the time this safety net was
-- produced.
Rebindings_Version : Version_Number;
-- Version of the associated rebinding at the time this safety net was
-- procuded.
end record;
No_Node_Safety_Net : constant Node_Safety_Net :=
(No_Internal_Context, 0, No_Internal_Unit, 0, 0);
function Create_Node_Safety_Net
(Id : Language_Id;
Context : Internal_Context;
Unit : Internal_Unit;
Rebindings : Env_Rebindings) return Node_Safety_Net;
-- Return the safety net for a node given its owning context and unit, and
-- its rebindings.
type Token_Safety_Net is record
Context : Internal_Context;
Context_Version : Version_Number;
-- Analysis context and version number at the time this safety net was
-- produced.
TDH_Version : Version_Number;
-- Version of the token data handler at the time this safety net was
-- produced.
end record;
No_Token_Safety_Net : constant Token_Safety_Net :=
(No_Internal_Context, 0, 0);
-- Contexts, units and token data handlers are implementing with big
-- records, at least 256 bytes long, so we can ignore the 8 least
-- significant bits of their addresses. Nodes can be much smaller, but
-- they are still at least 32 bytes long, so ignore the 5 least significant
-- bits of their addresses.
function Hash_Context is new Hash_Address (8);
function Hash_Unit is new Hash_Address (8);
function Hash_Node is new Hash_Address (5);
function Hash_TDH is new Hash_Address (8);
function Hash (Self : Internal_Context) return Hash_Type
is (Hash_Context (System.Address (Self)));
function Hash (Self : Internal_Unit) return Hash_Type
is (Hash_Unit (System.Address (Self)));
function Hash (Self : Internal_Node) return Hash_Type
is (Hash_Node (System.Address (Self)));
function Hash (Self : Token_Data_Handler_Access) return Hash_Type
is (Hash_TDH (if Self = null
then System.Null_Address
else Self.all'Address));
end Langkit_Support.Internal.Analysis;
|
charlie5/aShell | Ada | 503 | adb | with
Shell,
Ada.Text_IO;
procedure Test_Wait_On_Process
is
use Ada.Text_IO;
begin
Put_Line ("Begin 'Wait_On_Process' test.");
New_Line (2);
declare
use Shell;
Sleep : Shell.Process := Start (Program => "sleep",
Arguments => (1 => (+"3")));
begin
Put_Line ("Waiting on process ('sleep 3') ...");
Wait_On (Sleep);
end;
New_Line (2);
Put_Line ("End 'Wait_On_Process' test.");
end Test_Wait_On_Process;
|
ytomino/vampire | Ada | 51,074 | adb | -- The Village of Vampire by YT, このソースコードはNYSLです
package body Vampire.Villages is
use Messages;
use Person_Records;
use People;
use type Ada.Calendar.Time;
use type Ada.Strings.Unbounded.Unbounded_String;
function Equivalent_Messages (Left, Right : Message) return Boolean is
begin
return Left.Day = Right.Day
and then abs (Left.Time - Right.Time) < 1.0 -- 一秒未満は記録されないため
and then Left.Kind = Right.Kind
and then Left.Subject = Right.Subject
and then Left.Target = Right.Target
and then Left.Text = Right.Text;
end Equivalent_Messages;
function Preliminary_Voted (Village : Village_Type) return Boolean is
begin
for I in reverse
Message_Index'First .. Village.Messages.Last_Index
loop
declare
It : Message renames Village.Messages.Constant_Reference (I);
begin
exit when It.Day /= Village.Today;
if It.Kind = Preliminary_Vote then
return True;
end if;
end;
end loop;
return False;
end Preliminary_Voted;
function Unfortunate (Village : Village_Type) return Boolean is
The_Unfortunate_Inhabitant : constant Person_Index'Base :=
Find_Superman (Village, Unfortunate_Inhabitant);
begin
if The_Unfortunate_Inhabitant < 0 then
return False;
else
for I in 1 .. Village.Today loop
if Village.People.Constant_Reference (The_Unfortunate_Inhabitant).Records
.Constant_Reference (I).State /=
Normal
then
return False;
end if;
end loop;
if Village.Today > 1 then
declare
Counts : Message_Counts renames Count_Messages(Village, Village.Today - 1);
begin
if Counts(The_Unfortunate_Inhabitant).Speech = 0 then
return False;
end if;
end;
end if;
return True;
end if;
end Unfortunate;
-- implementation
function Create (
Name : String;
By : String;
Term : Village_Term;
Time : Ada.Calendar.Time)
return Village_Type
is
Day_Duration : Duration;
begin
case Term is
when Short => Day_Duration := Default_Short_Day_Duration;
when Long => Day_Duration := Default_Long_Day_Duration;
end case;
return (
Name => +Name,
By => +By,
Face_Group => 0,
Face_Width => 0,
Face_Height => 0,
State => Prologue,
Today => 0,
Time => Daytime,
Dawn => Time,
Day_Duration => Day_Duration,
Night_Duration => Default_Night_Duration,
Vote => Initial_Vote,
Execution => Initial_Execution,
Formation => Initial_Formation,
Monster_Side => Initial_Monster_Side,
Attack => Initial_Attack,
Vampire_Action_Set => Initial_Vampire_Action_Set,
Servant_Knowing => Initial_Servant_Knowing,
Daytime_Preview => Initial_Daytime_Preview,
Doctor_Infected => Initial_Doctor_Infected,
Hunter_Silver_Bullet => Initial_Hunter_Silver_Bullet,
Unfortunate => Initial_Unfortunate,
Obsolete_Teaming => Initial_Obsolete_Teaming,
Appearance => (others => Random),
Dummy_Role => Inhabitant,
People => People.Empty_Vector,
Escaped_People => People.Empty_Vector,
Messages => Messages.Empty_Vector);
end Create;
function Count_Messages (Village : Village_Type; Day : Natural)
return Message_Counts
is
Result : Message_Counts (
Person_Index'First .. Village.People.Last_Index) := (
others => (
Speech => 0, Monologue => 0, Ghost => 0,
Wake => 0, Encourage => 0, Encouraged => 0, Vampire_Gaze => 0,
Vampire_Cancel => 0,
Last_Action_Time => Calendar.Null_Time));
begin
for Position in Message_Index'First .. Village.Messages.Last_Index loop
declare
Current : Message renames Village.Messages.Constant_Reference(Position);
begin
if Current.Day = Day then
case Current.Kind is
when Join =>
Result(Current.Subject).Last_Action_Time := Current.Time;
when Speech =>
Result(Current.Subject).Speech := Result(Current.Subject).Speech + 1;
Result(Current.Subject).Last_Action_Time := Current.Time;
when Escaped_Speech =>
declare
Rejoined : constant Person_Index'Base :=
Village.Joined (
Village.Escaped_People.Constant_Reference (Current.Subject).Id
.Constant_Reference);
begin
if Rejoined /= No_Person
and then Same_Id_And_Figure (
Village.Escaped_People.Constant_Reference (Current.Subject),
Village.People.Constant_Reference (Rejoined))
then
Result (Rejoined).Speech := Result (Rejoined).Speech + 1;
end if;
end;
when Monologue =>
Result(Current.Subject).Monologue := Result(Current.Subject).Monologue + 1;
when Ghost =>
Result(Current.Subject).Ghost := Result(Current.Subject).Ghost + 1;
when Action_Wake =>
Result(Current.Subject).Wake := Result(Current.Subject).Wake + 1;
when Action_Encourage =>
Result(Current.Subject).Encourage := Result(Current.Subject).Encourage + 1;
Result(Current.Target).Encouraged := Result(Current.Target).Encouraged + 1;
when Action_Vampire_Gaze | Action_Vampire_Gaze_Blocked =>
Result (Current.Subject).Vampire_Gaze :=
Result (Current.Subject).Vampire_Gaze + 1;
when Action_Vampire_Cancel =>
Result (Current.Subject).Vampire_Cancel :=
Result (Current.Subject).Vampire_Cancel + 1;
when others =>
null;
end case;
end if;
end;
end loop;
return Result;
end Count_Messages;
function Night_To_Daytime (Village : Village_Type) return Ada.Calendar.Time is
begin
return Village.Dawn + Village.Night_Duration;
end Night_To_Daytime;
function Infection_In_First_Time (Village : Village_Type)
return Ada.Calendar.Time is
begin
return Village.Night_To_Daytime + Village.Day_Duration / 2; -- 24h
end Infection_In_First_Time;
function Preliminary_Vote_Time (Village : Village_Type)
return Ada.Calendar.Time is
begin
if Village.Today = 1
and then Village.Vote = Preliminary_And_Final
and then Village.Execution /= From_Second
then
return Village.Night_To_Daytime + Village.Day_Duration; -- 48h
else
return Village.Night_To_Daytime + Village.Day_Duration / 2; -- 24h
end if;
end Preliminary_Vote_Time;
function Daytime_To_Vote (Village : Village_Type) return Ada.Calendar.Time is
begin
if Village.Today = 1
and then Village.Vote = Preliminary_And_Final
and then Village.Execution /= From_Second
then
return Village.Night_To_Daytime + Village.Day_Duration * 3 / 2; -- 72h
else
return Village.Night_To_Daytime + Village.Day_Duration; -- 48h
end if;
end Daytime_To_Vote;
function Vote_To_Night (Village : Village_Type) return Ada.Calendar.Time is
begin
return Village.Daytime_To_Vote + Vote_Duration;
end Vote_To_Night;
function No_Commit (Village : Village_Type) return Boolean is
begin
for I in Person_Index'First .. Village.People.Last_Index loop
if Village.People.Constant_Reference (I).Records
.Constant_Reference (Village.Today).State /=
Died
then
if Village.People.Constant_Reference(I).Commited then
return False;
end if;
end if;
end loop;
return True;
end No_Commit;
function Commit_Finished(Village : Village_Type) return Boolean is
Count : Integer := 0;
Commited_Count : Integer := 0;
begin
for I in Person_Index'First .. Village.People.Last_Index loop
if Village.People.Constant_Reference (I).Records
.Constant_Reference (Village.Today).State /=
Died
then
Count := Count + 1;
if Village.People.Constant_Reference(I).Commited then
Commited_Count := Commited_Count + 1;
end if;
end if;
end loop;
return (Count >= Minimum_Number_Of_Persons or else Village.State /= Prologue)
and then Commited_Count = Count;
end Commit_Finished;
procedure Join (
Village : in out Village_Type;
Id : in String;
Group : in Casts.Group;
Figure : in Casts.Person;
Work : in Casts.Work;
Request : in Requested_Role;
Ignore_Request : in Boolean;
Time : in Ada.Calendar.Time)
is
pragma Assert (Figure.Group = Group.Group);
begin
Village.Face_Group := Group.Group;
Village.Face_Width := Group.Width;
Village.Face_Height := Group.Height;
Append (
Village.People,
Villages.Person_Type'(
Name => Figure.Name,
Image => Figure.Image,
Sex => Figure.Sex,
Group => Figure.Group,
Work => Work.Name,
Request => Request,
Ignore_Request => Ignore_Request,
Role => Inhabitant,
Id => +Id,
Commited => False,
Records => To_Vector (Default_Person_Record, Length => 1)));
Append (
Village.Messages,
Message'(
Kind => Join,
Day => Village.Today,
Time => Time,
Subject => Village.People.Last_Index,
Target => People.No_Index,
Text => Ada.Strings.Unbounded.Null_Unbounded_String));
end Join;
function Escape_Duration(Village : Village_Type) return Duration is
begin
case Village.Term is
when Short => return 12 * 60 * 60 * 1.0;
when Long => return 7 * 24 * 60 * 60 * 1.0;
end case;
end Escape_Duration;
procedure Escape (
Village : in out Village_Type;
Subject : in Person_Index;
Time : Ada.Calendar.Time)
is
Escaped_Index : Person_Index;
begin
Append (Village.Escaped_People, Village.People.Constant_Reference (Subject));
declare
Position : People.Cursor := People.To_Cursor (Village.People, Subject);
begin
Delete (Village.People, Position);
end;
Escaped_Index := Village.Escaped_People.Last_Index;
for I in Message_Index'First .. Village.Messages.Last_Index loop
declare
Kind : constant Villages.Message_Kind :=
Village.Messages.Constant_Reference (I).Kind;
begin
if Kind = Escaped_Join then
null;
elsif Kind = Escaped_Speech then
null;
elsif Kind = Escape then
null;
elsif Kind = Speech
and then Village.Messages.Constant_Reference (I).Subject = Subject
then
Village.Messages.Reference (I).Kind := Escaped_Speech;
Village.Messages.Reference (I).Subject := Escaped_Index;
elsif Kind = Join
and then Village.Messages.Constant_Reference (I).Subject = Subject
then
Village.Messages.Reference (I).Kind := Escaped_Join;
Village.Messages.Reference (I).Subject := Escaped_Index;
elsif Village.Messages.Constant_Reference (I).Subject > Subject then
declare
Shifted_Subject : constant Person_Index'Base :=
Village.Messages.Constant_Reference (I).Subject - 1;
begin
Village.Messages.Reference (I).Subject := Shifted_Subject;
end;
end if;
end;
end loop;
Append (
Village.Messages,
Message'(
Kind => Escape,
Day => Village.Today,
Time => Time,
Subject => Escaped_Index,
Target => People.No_Index,
Text => Ada.Strings.Unbounded.Null_Unbounded_String));
end Escape;
function Vote_State (Village : Village_Type) return Vote_State_Type is
begin
if Village.State /= Playing then
return Disallowed;
else
case Village.Execution is
when Dummy_Killed_And_From_First | From_First =>
null;
when Infection_And_From_First =>
if Village.Today = 1 and then not Village.Infected_In_First then
return Disallowed;
end if;
when From_Second =>
if Village.Today < 2 then
return Disallowed;
end if;
end case;
if Village.Time = Night then
return Disallowed;
elsif Village.Vote = Preliminary_And_Final
and then not Preliminary_Voted (Village)
then
return Allowed_For_Preliminary;
else
return Allowed;
end if;
end if;
end Vote_State;
function Vote_Finished(Village : Village_Type) return Boolean is
begin
for I in Person_Index'First .. Village.People.Last_Index loop
declare
P : Person_Type renames Village.People.Constant_Reference(I);
begin
if P.Records.Constant_Reference(Village.Today).State /= Died
and then not P.Commited
and then P.Records.Constant_Reference (Village.Today).Vote < 0
then
return False;
end if;
end;
end loop;
return True;
end Vote_Finished;
function Voted_Count (
Village : Village_Type;
Day : Natural;
Preliminary : Boolean)
return Voted_Count_Info is
begin
return Result : Voted_Count_Info := (
Last => Village.People.Last_Index,
Max => 0,
Counts => (Person_Index'First .. Village.People.Last_Index => 0))
do
for I in Result.Counts'Range loop
declare
P : Person_Type renames Village.People.Constant_Reference (I);
V : Person_Index'Base;
begin
if Preliminary then
V := P.Records.Constant_Reference (Day).Provisional_Vote;
else
V := P.Records.Constant_Reference (Day).Vote;
end if;
if V in Result.Counts'Range then
Result.Counts (V) := Result.Counts (V) + 1;
if Result.Counts (V) > Result.Max then
Result.Max := Result.Counts (V);
end if;
end if;
end;
end loop;
end return;
end Voted_Count;
procedure Vote (
Village : in out Village_Type;
Subject : in Person_Index;
Target : in Person_Index'Base)
is
Rec : Person_Record
renames Village.People.Reference (Subject).Records.Reference (Village.Today);
begin
pragma Assert (
Target < 0
or else Village.People.Constant_Reference (Target).Records
.Constant_Reference (Village.Today).Candidate);
Rec.Vote := Target;
if not Preliminary_Voted (Village)
and then Village.Time = Daytime -- 短期の投票延長期間は仮投票は発生させない
then
Rec.Provisional_Vote := Target;
end if;
end Vote;
procedure Wake (
Village : in out Village_Type;
Subject : in Person_Index;
Target : in Person_Index;
Time : in Ada.Calendar.Time) is
begin
Village.People.Reference (Target).Commited := False;
Append (
Village.Messages,
Message'(
Kind => Action_Wake,
Day => Village.Today,
Time => Time,
Subject => Subject,
Target => Target,
Text => Ada.Strings.Unbounded.Null_Unbounded_String));
end Wake;
procedure Encourage (
Village : in out Village_Type;
Subject : in Person_Index;
Target : in Person_Index;
Time : in Ada.Calendar.Time) is
begin
Append (
Village.Messages,
Message'(
Kind => Action_Encourage,
Day => Village.Today,
Time => Time,
Subject => Subject,
Target => Target,
Text => Ada.Strings.Unbounded.Null_Unbounded_String));
end Encourage;
function Can_Gaze (Village : Village_Type) return Boolean is
begin
if Village.Time = Night then
return False; -- 夜は直接会話できるので視線を使うまでもない
elsif Village.Today = 1
and then Village.Execution = Infection_And_From_First
then
return Village.Infected_In_First; -- 初回感染後のみ
else
return True; -- 2日目以降はOK
end if;
end Can_Gaze;
procedure Vampire_Gaze (
Village : in out Village_Type;
Subject : in Person_Index;
Target : in Person_Index;
Time : in Ada.Calendar.Time)
is
Kind : Message_Kind;
begin
if Unfortunate (Village) then
Kind := Action_Vampire_Gaze_Blocked;
else
Kind := Action_Vampire_Gaze;
end if;
Append (
Village.Messages,
Message'(
Kind => Kind,
Day => Village.Today,
Time => Time,
Subject => Subject,
Target => Target,
Text => Ada.Strings.Unbounded.Null_Unbounded_String));
end Vampire_Gaze;
procedure Vampire_Cancel (
Village : in out Village_Type;
Subject : in Person_Index;
Target : in Person_Index;
Time : in Ada.Calendar.Time) is
begin
Append (
Village.Messages,
Message'(
Kind => Action_Vampire_Cancel,
Day => Village.Today,
Time => Time,
Subject => Subject,
Target => Target,
Text => Ada.Strings.Unbounded.Null_Unbounded_String));
-- 吸血鬼同士は即座に通知、反映する
for I in Person_Index'First .. Village.People.Last_Index loop
declare
Person : Person_Type renames Village.People.Reference (I);
begin
if Person.Role in Vampire_Role
and then I /= Subject -- 自分以外
and then Person.Records.Constant_Reference (Village.Today).Target = Target
then
Person.Records.Reference (Village.Today).Target := No_Person;
Append (
Village.Messages,
Message'(
Kind => Action_Vampire_Canceled,
Day => Village.Today,
Time => Time,
Subject => I,
Target => Target,
Text => Ada.Strings.Unbounded.Null_Unbounded_String));
end if;
end;
end loop;
end Vampire_Cancel;
function Infected_In_First (Village : Village_Type) return Boolean is
pragma Assert (Village.Today = 1);
begin
for I in reverse Message_Index'First .. Village.Messages.Last_Index loop
declare
It : Message renames Village.Messages.Constant_Reference (I);
begin
exit when It.Day /= Village.Today;
if It.Kind = Foreboding then
return True;
end if;
end;
end loop;
return False;
end Infected_In_First;
function Is_Anyone_Died (Village : Village_Type; Day : Natural)
return Boolean is
begin
for I in Person_Index'First .. Village.People.Last_Index loop
if Village.People.Constant_Reference (I).Records.Constant_Reference (Day)
.State =
Died
then
return True;
end if;
end loop;
return False;
end Is_Anyone_Died;
function Find_Superman (Village : Village_Type; Role : Person_Role)
return Person_Index'Base is
begin
for I in Person_Index'First .. Village.People.Last_Index loop
if Village.People.Constant_Reference(I).Role = Role then
return I;
end if;
end loop;
return No_Person;
end Find_Superman;
function Target_Day (Village : Village_Type) return Integer is
begin
if Village.Time = Night
or else (
Village.Execution = Infection_And_From_First
and then Village.Today = 1
and then not Village.Infected_In_First)
then
return Village.Today - 1; -- 夜(と初日感染用)の能力は前日分を使用する
else
return Village.Today;
end if;
end Target_Day;
function Astronomer_Target_Day (Village : Village_Type) return Integer is
begin
-- 天文家は初日感染とか気にせず日課の観測をする
if Village.Time = Night then
return Village.Today - 1; -- 夜の能力は前日分を使用する
else
return Village.Today;
end if;
end Astronomer_Target_Day;
function Already_Used_Special (Village : Village_Type; Subject : Person_Index)
return Boolean is
begin
for I in 1 .. Village.Target_Day - 1 loop
-- 今日の設定は変えられるので昨日の分まで
if Village.People.Constant_Reference (Subject).Records.Constant_Reference (I)
.Special
then
return True;
end if;
end loop;
return False;
end Already_Used_Special;
function Detective_State (Village : Village_Type; Subject : Person_Index)
return Ability_State
is
Subject_Person : Person_Type
renames Village.People.Constant_Reference (Subject);
pragma Assert (Subject_Person.Role = Detective);
begin
if Village.Daytime_Preview /= None
and then Subject_Person.Records.Constant_Reference (Village.Today).Target /=
No_Person
then
return Already_Used;
elsif Village.Time /= Night
and then Village.Is_Anyone_Died (Village.Today)
then
return Allowed;
else
return Disallowed;
end if;
end Detective_State;
function Doctor_State (Village : Village_Type; Subject : Person_Index)
return Ability_State
is
Subject_Person : Person_Type
renames Village.People.Constant_Reference (Subject);
pragma Assert (Subject_Person.Role = Doctor);
begin
if Village.Daytime_Preview /= None
and then Subject_Person.Records.Constant_Reference (Village.Today).Target /=
No_Person
then
return Already_Used;
elsif Village.Time /= Night
and then (
Village.Today >= 2
or else (Village.Today = 1 and then Village.Infected_In_First))
then
return Allowed;
else
return Disallowed;
end if;
end Doctor_State;
function Superman_State (Village : Village_Type; Subject : Person_Index)
return Ability_State
is
Subject_Person : Person_Type
renames Village.People.Constant_Reference (Subject);
begin
case Subject_Person.Role is
when Detective => return Village.Detective_State (Subject);
when Doctor => return Village.Doctor_State (Subject);
when others => return Allowed;
end case;
end Superman_State;
function Silver_Bullet_State (Village : Village_Type; Subject : Person_Index)
return Ability_State
is
pragma Assert (Village.People.Constant_Reference (Subject).Role = Hunter);
begin
if Village.Already_Used_Special (Subject) then
return Already_Used;
elsif Village.Execution = Infection_And_From_First
and then Village.Today = 1
and then not Village.Infected_In_First
then
return Disallowed;
else
return Allowed;
end if;
end Silver_Bullet_State;
procedure Select_Target (
Village : in out Village_Type;
Subject : in Person_Index;
Target : in Person_Index'Base;
Special : in Boolean := False;
Time : in Ada.Calendar.Time)
is
Target_Day : Natural := Village.Target_Day;
begin
case Village.People.Constant_Reference (Subject).Role is
when Doctor =>
if Village.Daytime_Preview /= None and then Target /= No_Person then
declare
Result : Message_Kind;
begin
if Village.People.Constant_Reference (Target).Role = Gremlin then
-- 妖魔発見
Result := Doctor_Found_Gremlin_Preview;
elsif Village.People.Constant_Reference (Target).Records
.Constant_Reference (Target_Day).State =
Infected
then
-- 感染者発見
if Village.Doctor_Infected = Find_Infection
and then Village.People.Constant_Reference (Subject).Records
.Constant_Reference (Target_Day).State =
Infected
then
Result := Doctor_Found_Infection_Preview;
else
Result := Doctor_Cure_Preview;
end if;
else
Result := Doctor_Failed_Preview;
end if;
Append (
Village.Messages,
Message'(
Kind => Result,
Day => Village.Today,
Time => Time,
Subject => Subject,
Target => Target,
Text => Ada.Strings.Unbounded.Null_Unbounded_String));
end;
end if;
Village.People.Reference (Subject).Records.Reference (Target_Day).Target :=
Target;
when Detective =>
if Village.Daytime_Preview /= None and then Target /= No_Person then
Append (
Village.Messages,
Message'(
Kind => Detective_Survey_Preview,
Day => Village.Today,
Time => Time,
Subject => Subject,
Target => Target,
Text =>
Village.People.Constant_Reference (Target).Records
.Constant_Reference (Village.Today).Note));
end if;
Village.People.Reference (Subject).Records.Reference (Target_Day).Target :=
Target;
when Astronomer =>
Target_Day := Village.Astronomer_Target_Day;
Village.People.Reference (Subject).Records.Reference (Target_Day).Target :=
Target;
when others =>
Village.People.Reference (Subject).Records.Reference (Target_Day).Target :=
Target;
Village.People.Reference (Subject).Records.Reference (Target_Day).Special :=
Special;
end case;
end Select_Target;
procedure Night_Talk (
Village : in out Village_Type;
Subject : in Person_Index;
Text : in String;
Time : in Ada.Calendar.Time) is
begin
if Unfortunate (Village) then
for I in reverse
Message_Index'First .. Village.Messages.Last_Index
loop
declare
Message : Villages.Message renames Village.Messages.Constant_Reference (I);
begin
if Message.Day < Village.Today then
Append (
Village.Messages,
Villages.Message'(
Kind => Howling_Blocked,
Day => Village.Today,
Time => Time,
Subject => No_Person,
Target => No_Person,
Text => Ada.Strings.Unbounded.Null_Unbounded_String));
exit;
end if;
exit when Message.Kind = Howling_Blocked;
end;
end loop;
-- 夜明け時に1発言はできるので記録しておく
Village.People.Reference (Subject).Records.Reference (Village.Today - 1)
.Note :=
+Text;
else
Append (
Village.Messages,
Message'(
Kind => Howling,
Day => Village.Today,
Time => Time,
Subject => Subject,
Target => No_Person,
Text => +Text));
Village.People.Reference (Subject).Records.Reference (Village.Today - 1)
.Note :=
Ada.Strings.Unbounded.Null_Unbounded_String;
end if;
end Night_Talk;
procedure Speech (
Village : in out Village_Type;
Subject : in Person_Index;
Text : in String;
Time : in Ada.Calendar.Time)
is
New_Item : constant Message := (
Kind => Speech,
Day => Village.Today,
Time => Time,
Subject => Subject,
Target => No_Person,
Text => +Text);
begin
if Village.Messages.Is_Empty
or else not Equivalent_Messages (
New_Item,
Village.Messages (Village.Messages.Last))
then
Append (Village.Messages, New_Item);
end if;
end Speech;
procedure Monologue (
Village : in out Village_Type;
Subject : in Person_Index;
Text : in String;
Time : in Ada.Calendar.Time)
is
New_Item : constant Message := (
Kind => Monologue,
Day => Village.Today,
Time => Time,
Subject => Subject,
Target => No_Person,
Text => +Text);
begin
if Village.Messages.Is_Empty
or else not Equivalent_Messages (
New_Item,
Village.Messages (Village.Messages.Last))
then
Append (Village.Messages, New_Item);
end if;
end Monologue;
procedure Ghost (
Village : in out Village_Type;
Subject : in Person_Index;
Text : in String;
Time : in Ada.Calendar.Time)
is
New_Item : constant Message := (
Kind => Ghost,
Day => Village.Today,
Time => Time,
Subject => Subject,
Target => No_Person,
Text => +Text);
begin
if Village.Messages.Is_Empty
or else not Equivalent_Messages (
New_Item,
Village.Messages (Village.Messages.Last))
then
Append (Village.Messages, New_Item);
end if;
end Ghost;
procedure Narration (
Village : in out Village_Type;
Text : in String;
Time : in Ada.Calendar.Time)
is
New_Item : constant Message := (
Kind => Narration,
Day => Village.Today,
Time => Time,
Subject => No_Person,
Target => No_Person,
Text => +Text);
begin
if Village.Messages.Is_Empty
or else not Equivalent_Messages (
New_Item,
Village.Messages (Village.Messages.Last))
then
Append (Village.Messages, New_Item);
end if;
end Narration;
overriding function Term (Village : Village_Type) return Village_Term is
begin
if Village.Day_Duration < 24 * 60 * 60.0 then
return Short;
else
return Long;
end if;
end Term;
overriding procedure Get_State (
Village : in Village_Type;
State : out Village_State;
Today : out Natural) is
begin
State := Village.State;
Today := Village.Today;
end Get_State;
overriding procedure Iterate_People (
Village : in Village_Type;
Process : not null access procedure (
Index : Person_Index;
Item : in Tabula.Villages.Person_Type'Class)) is
begin
for I in Person_Index'First .. Village.People.Last_Index loop
Process (I, Village.People.Constant_Reference (I));
end loop;
end Iterate_People;
overriding procedure Iterate_Escaped_People (
Village : in Village_Type;
Process : not null access procedure (
Index : Person_Index;
Item : in Tabula.Villages.Person_Type'Class)) is
begin
for I in Person_Index'First .. Village.Escaped_People.Last_Index loop
Process (I, Village.Escaped_People.Constant_Reference (I));
end loop;
end Iterate_Escaped_People;
function Speech_Range (
Village : Village_Type;
Day : Natural)
return Speech_Range_Type
is
First : Speech_Index := 0;
Last : Speech_Index'Base := -1;
begin
for Position in Message_Index'First .. Village.Messages.Last_Index loop
declare
Current : Message renames Village.Messages.Constant_Reference (Position);
begin
if Current.Day = Day
and then (Current.Kind = Speech or else Current.Kind = Escaped_Speech)
then
Last := Last + 1;
end if;
end;
end loop;
return (First, Last);
end Speech_Range;
overriding function Recent_Only_Speech_Range (
Village : Village_Type;
Day : Natural;
Now : Ada.Calendar.Time)
return Speech_Range_Type
is
function Escaped (Village : Village_Type; Message : Villages.Message)
return Boolean is
begin
case Message.Kind is
when Introduction | Narration =>
return True;
when Escaped_Join | Escaped_Speech | Escape =>
declare
Rejoined : Person_Index'Base :=
Village.Joined (
Village.Escaped_People.Constant_Reference (Message.Subject).Id
.Constant_Reference);
begin
return Rejoined = No_Person
or else not Same_Id_And_Figure (
Village.Escaped_People.Constant_Reference (Message.Subject),
Village.People.Constant_Reference (Rejoined));
end;
when others =>
return False;
end case;
end Escaped;
Result : Speech_Range_Type := Village.Speech_Range (Day);
begin
if Village.State = Prologue and then Day = 0 then
for Index in Message_Index'First .. Village.Messages.Last_Index loop
declare
Item : Message
renames Village.Messages.Constant_Reference (Index);
begin
exit when not Escaped (Village, Item)
and then Now - Item.Time <= 180 * 24 * 60 * 60.0;
case Item.Kind is
when Speech | Escaped_Speech =>
Result.First := Result.First + 1;
when others =>
null;
end case;
end;
end loop;
end if;
return Result;
end Recent_Only_Speech_Range;
overriding procedure Iterate_Options (
Village : in Village_Type;
Process : not null access procedure (Item : in Root_Option_Item'Class)) is
begin
Process (Options.Day_Duration.Option_Item'(Village => Village'Access));
Process (Options.Night_Duration.Option_Item'(Village => Village'Access));
Process (Options.Vote.Option_Item'(Village => Village'Access));
Process (Options.Execution.Option_Item'(Village => Village'Access));
Process (Options.Formation.Option_Item'(Village => Village'Access));
Process (Options.Monster_Side.Option_Item'(Village => Village'Access));
Process (Options.Attack.Option_Item'(Village => Village'Access));
Process (Options.Vampire_Action_Set.Option_Item'(Village => Village'Access));
Process (Options.Servant_Knowing.Option_Item'(Village => Village'Access));
Process (Options.Daytime_Preview.Option_Item'(Village => Village'Access));
Process (Options.Doctor_Infected.Option_Item'(Village => Village'Access));
Process (Options.Hunter_Silver_Bullet.Option_Item'(Village => Village'Access));
Process (Options.Unfortunate.Option_Item'(Village => Village'Access));
end Iterate_Options;
package body Options is
package body Day_Duration is
overriding function Available (Item : Option_Item) return Boolean is
begin
return Item.Village.Term = Short;
end Available;
overriding function Name (Item : Option_Item) return String is
begin
return "day-duration";
end Name;
overriding function Changed (Item : Option_Item) return Boolean is
begin
return True;
end Changed;
overriding procedure Iterate (
Item : in Option_Item;
Process : not null access procedure (
Value : in String;
Selected : in Boolean;
Message : in String;
Unrecommended : in Boolean)) is
begin
Process (
Duration'Image (15 * 60.0),
Item.Village.Day_Duration = 15 * 60.0,
"ゲームの1日は実時間の15分です。",
False);
Process (
Duration'Image (20 * 60.0),
Item.Village.Day_Duration = 20 * 60.0,
"ゲームの1日は実時間の20分です。",
False);
Process (
Duration'Image (25 * 60.0),
Item.Village.Day_Duration = 25 * 60.0,
"ゲームの1日は実時間の25分です。",
False);
Process (
Duration'Image (30 * 60.0),
Item.Village.Day_Duration = 30 * 60.0,
"ゲームの1日は実時間の30分です。",
False);
end Iterate;
overriding procedure Change (
Village : in out Tabula.Villages.Village_Type'Class;
Item : in Option_Item;
Value : in String)
is
V : Village_Type renames Village_Type (Village);
begin
pragma Assert (V'Access = Item.Village);
if Value'Length /= 0 and then Available (Item) then
V.Day_Duration := Duration'Value (Value);
end if;
end Change;
end Day_Duration;
package body Night_Duration is
overriding function Available (Item : Option_Item) return Boolean is
begin
return Item.Village.Term = Short;
end Available;
overriding function Name (Item : Option_Item) return String is
begin
return "night-duration";
end Name;
overriding function Changed (Item : Option_Item) return Boolean is
begin
return True;
end Changed;
overriding procedure Iterate (
Item : in Option_Item;
Process : not null access procedure (
Value : in String;
Selected : in Boolean;
Message : in String;
Unrecommended : in Boolean)) is
begin
Process (
Duration'Image (0 * 60.0),
Item.Village.Night_Duration = 0 * 60.0,
"夜はありません。",
False);
Process (
Duration'Image (5 * 60.0),
Item.Village.Night_Duration = 5 * 60.0,
"夜は5分です。",
False);
end Iterate;
overriding procedure Change (
Village : in out Tabula.Villages.Village_Type'Class;
Item : in Option_Item;
Value : in String)
is
V : Village_Type renames Village_Type (Village);
begin
pragma Assert (V'Access = Item.Village);
if Value'Length /= 0 and then Available (Item) then
V.Night_Duration := Duration'Value (Value);
end if;
end Change;
end Night_Duration;
package body Vote is
overriding function Available (Item : Option_Item) return Boolean is
begin
return True;
end Available;
overriding function Name (Item : Option_Item) return String is
begin
return "vote";
end Name;
overriding function Changed (Item : Option_Item) return Boolean is
begin
return Item.Village.Vote /= Initial_Vote;
end Changed;
overriding procedure Iterate (
Item : in Option_Item;
Process : not null access procedure (
Value : in String;
Selected : in Boolean;
Message : in String;
Unrecommended : in Boolean)) is
begin
Process (
Vote_Mode'Image (Unsigned),
Item.Village.Vote = Unsigned,
"無記名投票で処刑を行います。",
False);
Process (
Vote_Mode'Image (Preliminary_And_Final),
Item.Village.Vote = Preliminary_And_Final,
"仮投票と本投票で処刑を行います。",
False);
end Iterate;
overriding procedure Change (
Village : in out Tabula.Villages.Village_Type'Class;
Item : in Option_Item;
Value : in String)
is
V : Village_Type renames Village_Type (Village);
begin
pragma Assert (V'Access = Item.Village);
V.Vote := Vote_Mode'Value (Value);
end Change;
end Vote;
package body Execution is
overriding function Available (Item : Option_Item) return Boolean is
begin
return True;
end Available;
overriding function Name (Item : Option_Item) return String is
begin
return "execution";
end Name;
overriding function Changed (Item : Option_Item) return Boolean is
begin
return Item.Village.Execution /= Initial_Execution;
end Changed;
overriding procedure Iterate (
Item : in Option_Item;
Process : not null access procedure (
Value : in String;
Selected : in Boolean;
Message : in String;
Unrecommended : in Boolean)) is
begin
Process (
Execution_Mode'Image (Dummy_Killed_And_From_First),
Item.Village.Execution = Dummy_Killed_And_From_First,
"能力者が死亡済みの可能性があります。",
False);
Process (
Execution_Mode'Image (Infection_And_From_First),
Item.Village.Execution = Infection_And_From_First,
"誰かが感染させられ、初日から処刑を行います。",
False);
Process (
Execution_Mode'Image (From_First),
Item.Village.Execution = From_First,
"初日から処刑を行います。",
False);
Process (
Execution_Mode'Image (From_Second),
Item.Village.Execution = From_Second,
"2日目から処刑を行います。",
False);
end Iterate;
overriding procedure Change (
Village : in out Tabula.Villages.Village_Type'Class;
Item : in Option_Item;
Value : in String)
is
V : Village_Type renames Village_Type (Village);
begin
pragma Assert (V'Access = Item.Village);
V.Execution := Execution_Mode'Value (Value);
-- 記録用
case V.Execution is
when Dummy_Killed_And_From_First | From_First | From_Second =>
V.Obsolete_Teaming := Shuffling;
when Infection_And_From_First =>
V.Obsolete_Teaming := Liner_2;
end case;
end Change;
end Execution;
package body Formation is
overriding function Available (Item : Option_Item) return Boolean is
begin
return True;
end Available;
overriding function Name (Item : Option_Item) return String is
begin
return "teaming";
end Name;
overriding function Changed (Item : Option_Item) return Boolean is
begin
return Item.Village.Formation /= Initial_Formation;
end Changed;
overriding procedure Iterate (
Item : in Option_Item;
Process : not null access procedure (
Value : in String;
Selected : in Boolean;
Message : in String;
Unrecommended : in Boolean)) is
begin
Process (
Formation_Mode'Image (Public),
Item.Village.Formation = Public,
"村側能力者の構成を公開します。",
False);
Process (
Formation_Mode'Image (Hidden),
Item.Village.Formation = Hidden,
"村側能力者の構成はわかりません。",
False);
end Iterate;
overriding procedure Change (
Village : in out Tabula.Villages.Village_Type'Class;
Item : in Option_Item;
Value : in String)
is
V : Village_Type renames Village_Type (Village);
begin
pragma Assert (V'Access = Item.Village);
V.Formation := Formation_Mode'Value (Value);
end Change;
end Formation;
package body Monster_Side is
overriding function Available (Item : Option_Item) return Boolean is
begin
return True;
end Available;
overriding function Name (Item : Option_Item) return String is
begin
return "monster-side";
end Name;
overriding function Changed (Item : Option_Item) return Boolean is
begin
return Item.Village.Monster_Side /= Initial_Monster_Side;
end Changed;
overriding procedure Iterate (
Item : in Option_Item;
Process : not null access procedure (
Value : in String;
Selected : in Boolean;
Message : in String;
Unrecommended : in Boolean)) is
begin
Process (
Monster_Side_Mode'Image (Fixed),
Item.Village.Monster_Side = Fixed,
"吸血鬼が襲ってきます。",
False);
Process (
Monster_Side_Mode'Image (Shuffling),
Item.Village.Monster_Side = Shuffling,
"吸血鬼の全貌はわかりません。",
Unrecommended => True);
Process (
Monster_Side_Mode'Image (Gremlin),
Item.Village.Monster_Side = Gremlin,
"使徒よりも妖魔が先に現れます。",
False);
end Iterate;
overriding procedure Change (
Village : in out Tabula.Villages.Village_Type'Class;
Item : in Option_Item;
Value : in String)
is
V : Village_Type renames Village_Type (Village);
begin
pragma Assert (V'Access = Item.Village);
V.Monster_Side := Monster_Side_Mode'Value (Value);
end Change;
end Monster_Side;
package body Attack is
overriding function Available (Item : Option_Item) return Boolean is
begin
return True;
end Available;
overriding function Name (Item : Option_Item) return String is
begin
return "attack";
end Name;
overriding function Changed (Item : Option_Item) return Boolean is
begin
return Item.Village.Attack /= Initial_Attack;
end Changed;
overriding procedure Iterate (
Item : in Option_Item;
Process : not null access procedure (
Value : in String;
Selected : in Boolean;
Message : in String;
Unrecommended : in Boolean)) is
begin
Process (
Attack_Mode'Image (Two),
Item.Village.Attack = Two,
"吸血鬼ふたり以上に襲われると死亡します。",
False);
Process (
Attack_Mode'Image (Nocturnal_Chain_Infecting),
Item.Village.Attack = Nocturnal_Chain_Infecting,
"天文家と猟師は感染したら襲撃を行います。",
False);
Process (
Attack_Mode'Image (Unanimity),
Item.Village.Attack = Unanimity,
"すべての吸血鬼に襲われると死亡します。",
False);
end Iterate;
overriding procedure Change (
Village : in out Tabula.Villages.Village_Type'Class;
Item : in Option_Item;
Value : in String)
is
V : Village_Type renames Village_Type (Village);
begin
pragma Assert (V'Access = Item.Village);
V.Attack := Attack_Mode'Value (Value);
end Change;
end Attack;
package body Vampire_Action_Set is
overriding function Available (Item : Option_Item) return Boolean is
begin
return True;
end Available;
overriding function Name (Item : Option_Item) return String is
begin
return "vampire-action-set";
end Name;
overriding function Changed (Item : Option_Item) return Boolean is
begin
return Item.Village.Vampire_Action_Set /= Initial_Vampire_Action_Set;
end Changed;
overriding procedure Iterate (
Item : in Option_Item;
Process : not null access procedure (
Value : in String;
Selected : in Boolean;
Message : in String;
Unrecommended : in Boolean)) is
begin
Process (
Vampire_Action_Set_Mode'Image (None),
Item.Village.Vampire_Action_Set = None,
"吸血鬼には特別なアクションはありません。",
Unrecommended => True);
Process (
Vampire_Action_Set_Mode'Image (Gaze),
Item.Village.Vampire_Action_Set = Gaze,
"視線「こっそり見つめる」が使えます。",
False);
Process (
Vampire_Action_Set_Mode'Image (Gaze_And_Cancel),
Item.Village.Vampire_Action_Set = Gaze_And_Cancel,
"視線と襲撃取り消し「襲うのをやめさせる」が使えます。",
False);
end Iterate;
overriding procedure Change (
Village : in out Tabula.Villages.Village_Type'Class;
Item : in Option_Item;
Value : in String)
is
V : Village_Type renames Village_Type (Village);
begin
pragma Assert (V'Access = Item.Village);
V.Vampire_Action_Set := Vampire_Action_Set_Mode'Value (Value);
end Change;
end Vampire_Action_Set;
package body Servant_Knowing is
overriding function Available (Item : Option_Item) return Boolean is
begin
return True;
end Available;
overriding function Name (Item : Option_Item) return String is
begin
return "servant-knowing";
end Name;
overriding function Changed (Item : Option_Item) return Boolean is
begin
return Item.Village.Servant_Knowing /= Initial_Servant_Knowing;
end Changed;
overriding procedure Iterate (
Item : in Option_Item;
Process : not null access procedure (
Value : in String;
Selected : in Boolean;
Message : in String;
Unrecommended : in Boolean)) is
begin
Process (
Servant_Knowing_Mode'Image (None),
Item.Village.Servant_Knowing = None,
"使徒は吸血鬼の正体を知りません。",
False);
Process (
Servant_Knowing_Mode'Image (Vampire_K),
Item.Village.Servant_Knowing = Vampire_K,
"使徒は吸血鬼の王を知っています。",
False);
Process (
Servant_Knowing_Mode'Image (All_Vampires),
Item.Village.Servant_Knowing = All_Vampires,
"使徒は吸血鬼を知っています。",
False);
end Iterate;
overriding procedure Change (
Village : in out Tabula.Villages.Village_Type'Class;
Item : in Option_Item;
Value : in String)
is
V : Village_Type renames Village_Type (Village);
begin
pragma Assert (V'Access = Item.Village);
V.Servant_Knowing := Servant_Knowing_Mode'Value (Value);
end Change;
end Servant_Knowing;
package body Daytime_Preview is
overriding function Available (Item : Option_Item) return Boolean is
begin
return True;
end Available;
overriding function Name (Item : Option_Item) return String is
begin
return "daytime-preview";
end Name;
overriding function Changed (Item : Option_Item) return Boolean is
begin
return Item.Village.Daytime_Preview /= Initial_Daytime_Preview;
end Changed;
overriding procedure Iterate (
Item : in Option_Item;
Process : not null access procedure (
Value : in String;
Selected : in Boolean;
Message : in String;
Unrecommended : in Boolean)) is
begin
Process (
Daytime_Preview_Mode'Image (None),
Item.Village.Daytime_Preview = None,
"探偵と医者は翌日まで結果がわかりません。",
Unrecommended => True);
Process (
Daytime_Preview_Mode'Image (Role_Only),
Item.Village.Daytime_Preview = Role_Only,
"探偵は日中に正体を調べ翌日までに遺言を調べます。",
False);
Process (
Daytime_Preview_Mode'Image (Message_Only),
Item.Village.Daytime_Preview = Message_Only,
"探偵は日中に遺言を調べ翌日までに正体を調べます。",
False);
Process (
Daytime_Preview_Mode'Image (Role_And_Message),
Item.Village.Daytime_Preview = Role_And_Message,
"探偵は日中に正体と遺言を調べます。",
False);
end Iterate;
overriding procedure Change (
Village : in out Tabula.Villages.Village_Type'Class;
Item : in Option_Item;
Value : in String)
is
V : Village_Type renames Village_Type (Village);
begin
pragma Assert (V'Access = Item.Village);
V.Daytime_Preview := Daytime_Preview_Mode'Value (Value);
end Change;
end Daytime_Preview;
package body Doctor_Infected is
overriding function Available (Item : Option_Item) return Boolean is
begin
return True;
end Available;
overriding function Name (Item : Option_Item) return String is
begin
return "doctor-infected";
end Name;
overriding function Changed (Item : Option_Item) return Boolean is
begin
return Item.Village.Doctor_Infected /= Initial_Doctor_Infected;
end Changed;
overriding procedure Iterate (
Item : in Option_Item;
Process : not null access procedure (
Value : in String;
Selected : in Boolean;
Message : in String;
Unrecommended : in Boolean)) is
begin
Process (
Doctor_Infected_Mode'Image (Cure),
Item.Village.Doctor_Infected = Cure,
"医者自身の感染は治療に影響しません。",
False);
Process (
Doctor_Infected_Mode'Image (Find_Infection),
Item.Village.Doctor_Infected = Find_Infection,
"医者自身が感染していると治療の効果はありません。",
False);
end Iterate;
overriding procedure Change (
Village : in out Tabula.Villages.Village_Type'Class;
Item : in Option_Item;
Value : in String)
is
V : Village_Type renames Village_Type (Village);
begin
pragma Assert (V'Access = Item.Village);
V.Doctor_Infected := Doctor_Infected_Mode'Value (Value);
end Change;
end Doctor_Infected;
package body Hunter_Silver_Bullet is
overriding function Available (Item : Option_Item) return Boolean is
begin
return True;
end Available;
overriding function Name (Item : Option_Item) return String is
begin
return "hunter-silver-bullet";
end Name;
overriding function Changed (Item : Option_Item) return Boolean is
begin
return Item.Village.Hunter_Silver_Bullet /= Initial_Hunter_Silver_Bullet;
end Changed;
overriding procedure Iterate (
Item : in Option_Item;
Process : not null access procedure (
Value : in String;
Selected : in Boolean;
Message : in String;
Unrecommended : in Boolean)) is
begin
Process (
Hunter_Silver_Bullet_Mode'Image (Target),
Item.Village.Hunter_Silver_Bullet = Target,
"護衛対象が襲われたときのみ銀の弾丸は吸血鬼を殺します。",
False);
Process (
Hunter_Silver_Bullet_Mode'Image (Target_And_Self),
Item.Village.Hunter_Silver_Bullet = Target_And_Self,
"猟師自身が襲われたときも銀の弾丸は吸血鬼を殺します。",
False);
end Iterate;
overriding procedure Change (
Village : in out Tabula.Villages.Village_Type'Class;
Item : in Option_Item;
Value : in String)
is
V : Village_Type renames Village_Type (Village);
begin
pragma Assert (V'Access = Item.Village);
V.Hunter_Silver_Bullet := Hunter_Silver_Bullet_Mode'Value (Value);
end Change;
end Hunter_Silver_Bullet;
package body Unfortunate is
overriding function Available (Item : Option_Item) return Boolean is
begin
return True;
end Available;
overriding function Name (Item : Option_Item) return String is
begin
return "unfortunate";
end Name;
overriding function Changed (Item : Option_Item) return Boolean is
begin
return Item.Village.Unfortunate /= Initial_Unfortunate;
end Changed;
overriding procedure Iterate (
Item : in Option_Item;
Process : not null access procedure (
Value : in String;
Selected : in Boolean;
Message : in String;
Unrecommended : in Boolean)) is
begin
Process (
Unfortunate_Mode'Image (None),
Item.Village.Unfortunate = None,
"数奇な運命の村人はいません。",
False);
Process (
Unfortunate_Mode'Image (Appear),
Item.Village.Unfortunate = Appear,
"数奇な運命の村人がいるかもしれません。",
Unrecommended => True);
Process (
Unfortunate_Mode'Image (Infected_Only),
Item.Village.Unfortunate = Infected_Only,
"数奇な運命の村人は襲撃では殺されません。",
False);
end Iterate;
overriding procedure Change (
Village : in out Tabula.Villages.Village_Type'Class;
Item : in Option_Item;
Value : in String)
is
V : Village_Type renames Village_Type (Village);
begin
pragma Assert (V'Access = Item.Village);
V.Unfortunate := Unfortunate_Mode'Value (Value);
end Change;
end Unfortunate;
end Options;
end Vampire.Villages;
|
stcarrez/mat | Ada | 2,432 | ads | -----------------------------------------------------------------------
-- mat-consoles-text - Text console interface
-- Copyright (C) 2014, 2021, 2023 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.Text_IO;
package MAT.Consoles.Text is
type Console_Type is new MAT.Consoles.Console_Type with private;
-- Report an error message.
overriding
procedure Error (Console : in out Console_Type;
Message : in String);
-- Report a notice message.
overriding
procedure Notice (Console : in out Console_Type;
Kind : in Notice_Type;
Message : in String);
-- Print the field value for the given field.
overriding
procedure Print_Field (Console : in out Console_Type;
Field : in Field_Type;
Value : in String;
Justify : in Justify_Type := J_LEFT);
-- Print the title for the given field.
overriding
procedure Print_Title (Console : in out Console_Type;
Field : in Field_Type;
Title : in String);
-- Start a new title in a report.
overriding
procedure Start_Title (Console : in out Console_Type);
-- Finish a new title in a report.
procedure End_Title (Console : in out Console_Type);
-- Start a new row in a report.
overriding
procedure Start_Row (Console : in out Console_Type);
-- Finish a new row in a report.
overriding
procedure End_Row (Console : in out Console_Type);
private
type Console_Type is new MAT.Consoles.Console_Type with record
File : Ada.Text_IO.File_Type;
Cur_Col : Ada.Text_IO.Count := 0;
end record;
end MAT.Consoles.Text;
|
fractal-mind/Amass | Ada | 1,304 | ads | -- Copyright 2022 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
local json = require("json")
name = "Netlas"
type = "api"
function start()
set_rate_limit(1)
end
function check()
local c
local cfg = datasrc_config()
if cfg ~= nil then
c = cfg.credentials
end
if (c ~= nil and c.key ~= nil and c.key ~= "") then
return true
end
return false
end
function vertical(ctx, domain)
local c
local cfg = datasrc_config()
if cfg ~= nil then
c = cfg.credentials
end
if (c == nil or c.key == nil or c.key == "") then
return
end
local resp, err = request(ctx, {
url=build_url(domain),
headers={
['Accept']="application/json",
['X-API-Key']=c.key,
},
})
if (err ~= nil and err ~= "") then
log(ctx, "vertical request to service failed: " .. err)
return
end
local j = json.decode(resp)
if (j == nil or j.items == nil or #j.items == 0) then
return
end
for _, item in pairs(j.items) do
new_name(ctx, item['data'].domain)
end
end
function build_url(domain)
return "https://app.netlas.io/api/domains/?q=*." .. domain
end
|
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_Leader_Width_Attributes;
package Matreshka.ODF_Style.Leader_Width_Attributes is
type Style_Leader_Width_Attribute_Node is
new Matreshka.ODF_Style.Abstract_Style_Attribute_Node
and ODF.DOM.Style_Leader_Width_Attributes.ODF_Style_Leader_Width_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Leader_Width_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Style_Leader_Width_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Style.Leader_Width_Attributes;
|
rveenker/sdlada | Ada | 6,284 | ads | --------------------------------------------------------------------------------------------------------------------
-- 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.
--------------------------------------------------------------------------------------------------------------------
-- SDL.Events.Touches
--
-- WARNING!! A lot of the data bindings in this specification is guess-work, especially the ranges for things. There
-- also an inconsistency in the usage of Fingers_Touching within SDL itself.
--
-- See:
-- https://bugzilla.libsdl.org/show_bug.cgi?id=3060
-- http://lists.libsdl.org/pipermail/sdl-libsdl.org/2015-July/098468.html
--------------------------------------------------------------------------------------------------------------------
with Interfaces.C;
package SDL.Events.Touches is
-- Touch events.
Finger_Down : constant Event_Types := 16#0000_0700#;
Finger_Up : constant Event_Types := Finger_Down + 1;
Finger_Motion : constant Event_Types := Finger_Down + 2;
-- Gesture events.
Dollar_Gesture : constant Event_Types := 16#0000_0800#;
Dollar_Record : constant Event_Types := Dollar_Gesture + 1;
Dollar_Multi_Gesture : constant Event_Types := Dollar_Gesture + 2;
-- TODO: Find out if these really should be signed or not, the C version uses Sint64 for both.
type Touch_IDs is range -1 .. 2 ** 63 - 1 with
Convention => C,
Size => 64;
type Finger_IDs is range 0 .. 2 ** 63 - 1 with
Convention => C,
Size => 64;
type Gesture_IDs is range 0 .. 2 ** 63 - 1 with
Convention => C,
Size => 64;
type Touch_Locations is digits 3 range 0.0 .. 1.0 with
Convention => C,
Size => 32;
type Touch_Distances is digits 3 range -1.0 .. 1.0 with
Convention => C,
Size => 32;
type Touch_Pressures is digits 3 range 0.0 .. 1.0 with
Convention => C,
Size => 32;
type Finger_Events is
record
Event_Type : Event_Types; -- Will be set to Finger_Down, Finger_Up or Finger_Motion.
Time_Stamp : Time_Stamps;
Touch_ID : Touch_IDs;
Finger_ID : Finger_IDs;
X : Touch_Locations;
Y : Touch_Locations;
Delta_X : Touch_Distances;
Delta_Y : Touch_Distances;
Pressure : Touch_Pressures;
end record with
Convention => C;
type Finger_Rotations is digits 3 range -360.0 .. 360.0 with
Convention => C,
Size => 32;
subtype Finger_Pinches is Interfaces.C.C_float;
type Fingers_Touching is range 0 .. 2 ** 16 - 1 with
Convention => C,
Size => 16;
type Multi_Gesture_Events is
record
Event_Type : Event_Types; -- Will be set to Dollar_Multi_Gesture.
Time_Stamp : Time_Stamps;
Touch_ID : Touch_IDs;
Theta : Finger_Rotations;
Distance : Finger_Pinches;
Centre_X : Touch_Locations;
Centre_Y : Touch_Locations;
Fingers : Fingers_Touching;
Padding : Padding_16;
end record with
Convention => C;
subtype Dollar_Errors is Interfaces.C.C_float;
type Dollar_Events is
record
Event_Type : Event_Types; -- Will be set to Dollar_Gesture or Dollar_Record.
Time_Stamp : Time_Stamps;
Touch_ID : Touch_IDs;
Gesture_ID : Gesture_IDs;
Fingers : Fingers_Touching;
Error : Dollar_Errors;
Centre_X : Touch_Locations;
Centre_Y : Touch_Locations;
end record with
Convention => C;
private
for Finger_Events use
record
Event_Type at 0 * SDL.Word range 0 .. 31;
Time_Stamp at 1 * SDL.Word range 0 .. 31;
Touch_ID at 2 * SDL.Word range 0 .. 63;
Finger_ID at 4 * SDL.Word range 0 .. 63;
X at 6 * SDL.Word range 0 .. 31;
Y at 7 * SDL.Word range 0 .. 31;
Delta_X at 8 * SDL.Word range 0 .. 31;
Delta_Y at 9 * SDL.Word range 0 .. 31;
Pressure at 10 * SDL.Word range 0 .. 31;
end record;
for Multi_Gesture_Events use
record
Event_Type at 0 * SDL.Word range 0 .. 31;
Time_Stamp at 1 * SDL.Word range 0 .. 31;
Touch_ID at 2 * SDL.Word range 0 .. 63;
Theta at 4 * SDL.Word range 0 .. 31;
Distance at 5 * SDL.Word range 0 .. 31;
Centre_X at 6 * SDL.Word range 0 .. 31;
Centre_Y at 7 * SDL.Word range 0 .. 31;
Fingers at 8 * SDL.Word range 0 .. 15;
Padding at 8 * SDL.Word range 16 .. 31;
end record;
for Dollar_Events use
record
Event_Type at 0 * SDL.Word range 0 .. 31;
Time_Stamp at 1 * SDL.Word range 0 .. 31;
Touch_ID at 2 * SDL.Word range 0 .. 63;
Gesture_ID at 4 * SDL.Word range 0 .. 63;
Fingers at 6 * SDL.Word range 0 .. 31; -- Inconsistent, type is 16 bits, but SDL uses 32 here.
Error at 7 * SDL.Word range 0 .. 31;
Centre_X at 8 * SDL.Word range 0 .. 31;
Centre_Y at 9 * SDL.Word range 0 .. 31;
end record;
end SDL.Events.Touches;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.