content
stringlengths
23
1.05M
with Irc.Bot; with Irc.Commands; with Irc.Message; with Ada.Strings.Unbounded; with GNAT.Sockets; package Commands is -- for host_bot.adb procedure Host (Bot : in out Irc.Bot.Connection; Msg : Irc.Message.Message); end Commands;
pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; package avx512vlintrin_h is -- Copyright (C) 2014-2017 Free Software Foundation, Inc. -- This file is part of GCC. -- GCC is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3, or (at your option) -- any later version. -- GCC is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- Under Section 7 of GPL version 3, you are granted additional -- permissions described in the GCC Runtime Library Exception, version -- 3.1, as published by the Free Software Foundation. -- You should have received a copy of the GNU General Public License and -- a copy of the GCC Runtime Library Exception along with this program; -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- <http://www.gnu.org/licenses/>. -- Internal data types for implementing the intrinsics. subtype uu_mmask32 is unsigned; -- d:\install\gpl2018\lib\gcc\x86_64-pc-mingw32\7.3.1\include\avx512vlintrin.h:38 -- skipped func _mm256_mask_mov_pd -- skipped func _mm256_maskz_mov_pd -- skipped func _mm_mask_mov_pd -- skipped func _mm_maskz_mov_pd -- skipped func _mm256_mask_load_pd -- skipped func _mm256_maskz_load_pd -- skipped func _mm_mask_load_pd -- skipped func _mm_maskz_load_pd -- skipped func _mm256_mask_store_pd -- skipped func _mm_mask_store_pd -- skipped func _mm256_mask_mov_ps -- skipped func _mm256_maskz_mov_ps -- skipped func _mm_mask_mov_ps -- skipped func _mm_maskz_mov_ps -- skipped func _mm256_mask_load_ps -- skipped func _mm256_maskz_load_ps -- skipped func _mm_mask_load_ps -- skipped func _mm_maskz_load_ps -- skipped func _mm256_mask_store_ps -- skipped func _mm_mask_store_ps -- skipped func _mm256_mask_mov_epi64 -- skipped func _mm256_maskz_mov_epi64 -- skipped func _mm_mask_mov_epi64 -- skipped func _mm_maskz_mov_epi64 -- skipped func _mm256_mask_load_epi64 -- skipped func _mm256_maskz_load_epi64 -- skipped func _mm_mask_load_epi64 -- skipped func _mm_maskz_load_epi64 -- skipped func _mm256_mask_store_epi64 -- skipped func _mm_mask_store_epi64 -- skipped func _mm256_mask_mov_epi32 -- skipped func _mm256_maskz_mov_epi32 -- skipped func _mm_mask_mov_epi32 -- skipped func _mm_maskz_mov_epi32 -- skipped func _mm256_mask_load_epi32 -- skipped func _mm256_maskz_load_epi32 -- skipped func _mm_mask_load_epi32 -- skipped func _mm_maskz_load_epi32 -- skipped func _mm256_mask_store_epi32 -- skipped func _mm_mask_store_epi32 -- skipped func _mm_mask_add_pd -- skipped func _mm_maskz_add_pd -- skipped func _mm256_mask_add_pd -- skipped func _mm256_maskz_add_pd -- skipped func _mm_mask_add_ps -- skipped func _mm_maskz_add_ps -- skipped func _mm256_mask_add_ps -- skipped func _mm256_maskz_add_ps -- skipped func _mm_mask_sub_pd -- skipped func _mm_maskz_sub_pd -- skipped func _mm256_mask_sub_pd -- skipped func _mm256_maskz_sub_pd -- skipped func _mm_mask_sub_ps -- skipped func _mm_maskz_sub_ps -- skipped func _mm256_mask_sub_ps -- skipped func _mm256_maskz_sub_ps -- skipped func _mm256_store_epi64 -- skipped func _mm_store_epi64 -- skipped func _mm256_mask_loadu_pd -- skipped func _mm256_maskz_loadu_pd -- skipped func _mm_mask_loadu_pd -- skipped func _mm_maskz_loadu_pd -- skipped func _mm256_mask_storeu_pd -- skipped func _mm_mask_storeu_pd -- skipped func _mm256_mask_loadu_ps -- skipped func _mm256_maskz_loadu_ps -- skipped func _mm_mask_loadu_ps -- skipped func _mm_maskz_loadu_ps -- skipped func _mm256_mask_storeu_ps -- skipped func _mm_mask_storeu_ps -- skipped func _mm256_mask_loadu_epi64 -- skipped func _mm256_maskz_loadu_epi64 -- skipped func _mm_mask_loadu_epi64 -- skipped func _mm_maskz_loadu_epi64 -- skipped func _mm256_mask_storeu_epi64 -- skipped func _mm_mask_storeu_epi64 -- skipped func _mm256_mask_loadu_epi32 -- skipped func _mm256_maskz_loadu_epi32 -- skipped func _mm_mask_loadu_epi32 -- skipped func _mm_maskz_loadu_epi32 -- skipped func _mm256_mask_storeu_epi32 -- skipped func _mm_mask_storeu_epi32 -- skipped func _mm256_mask_abs_epi32 -- skipped func _mm256_maskz_abs_epi32 -- skipped func _mm_mask_abs_epi32 -- skipped func _mm_maskz_abs_epi32 -- skipped func _mm256_abs_epi64 -- skipped func _mm256_mask_abs_epi64 -- skipped func _mm256_maskz_abs_epi64 -- skipped func _mm_abs_epi64 -- skipped func _mm_mask_abs_epi64 -- skipped func _mm_maskz_abs_epi64 -- skipped func _mm256_cvtpd_epu32 -- skipped func _mm256_mask_cvtpd_epu32 -- skipped func _mm256_maskz_cvtpd_epu32 -- skipped func _mm_cvtpd_epu32 -- skipped func _mm_mask_cvtpd_epu32 -- skipped func _mm_maskz_cvtpd_epu32 -- skipped func _mm256_mask_cvttps_epi32 -- skipped func _mm256_maskz_cvttps_epi32 -- skipped func _mm_mask_cvttps_epi32 -- skipped func _mm_maskz_cvttps_epi32 -- skipped func _mm256_cvttps_epu32 -- skipped func _mm256_mask_cvttps_epu32 -- skipped func _mm256_maskz_cvttps_epu32 -- skipped func _mm_cvttps_epu32 -- skipped func _mm_mask_cvttps_epu32 -- skipped func _mm_maskz_cvttps_epu32 -- skipped func _mm256_mask_cvttpd_epi32 -- skipped func _mm256_maskz_cvttpd_epi32 -- skipped func _mm_mask_cvttpd_epi32 -- skipped func _mm_maskz_cvttpd_epi32 -- skipped func _mm256_cvttpd_epu32 -- skipped func _mm256_mask_cvttpd_epu32 -- skipped func _mm256_maskz_cvttpd_epu32 -- skipped func _mm_cvttpd_epu32 -- skipped func _mm_mask_cvttpd_epu32 -- skipped func _mm_maskz_cvttpd_epu32 -- skipped func _mm256_mask_cvtpd_epi32 -- skipped func _mm256_maskz_cvtpd_epi32 -- skipped func _mm_mask_cvtpd_epi32 -- skipped func _mm_maskz_cvtpd_epi32 -- skipped func _mm256_mask_cvtepi32_pd -- skipped func _mm256_maskz_cvtepi32_pd -- skipped func _mm_mask_cvtepi32_pd -- skipped func _mm_maskz_cvtepi32_pd -- skipped func _mm256_cvtepu32_pd -- skipped func _mm256_mask_cvtepu32_pd -- skipped func _mm256_maskz_cvtepu32_pd -- skipped func _mm_cvtepu32_pd -- skipped func _mm_mask_cvtepu32_pd -- skipped func _mm_maskz_cvtepu32_pd -- skipped func _mm256_mask_cvtepi32_ps -- skipped func _mm256_maskz_cvtepi32_ps -- skipped func _mm_mask_cvtepi32_ps -- skipped func _mm_maskz_cvtepi32_ps -- skipped func _mm256_cvtepu32_ps -- skipped func _mm256_mask_cvtepu32_ps -- skipped func _mm256_maskz_cvtepu32_ps -- skipped func _mm_cvtepu32_ps -- skipped func _mm_mask_cvtepu32_ps -- skipped func _mm_maskz_cvtepu32_ps -- skipped func _mm256_mask_cvtps_pd -- skipped func _mm256_maskz_cvtps_pd -- skipped func _mm_mask_cvtps_pd -- skipped func _mm_maskz_cvtps_pd -- skipped func _mm_cvtepi32_epi8 -- skipped func _mm_mask_cvtepi32_storeu_epi8 -- skipped func _mm_mask_cvtepi32_epi8 -- skipped func _mm_maskz_cvtepi32_epi8 -- skipped func _mm256_cvtepi32_epi8 -- skipped func _mm256_mask_cvtepi32_epi8 -- skipped func _mm256_mask_cvtepi32_storeu_epi8 -- skipped func _mm256_maskz_cvtepi32_epi8 -- skipped func _mm_cvtsepi32_epi8 -- skipped func _mm_mask_cvtsepi32_storeu_epi8 -- skipped func _mm_mask_cvtsepi32_epi8 -- skipped func _mm_maskz_cvtsepi32_epi8 -- skipped func _mm256_cvtsepi32_epi8 -- skipped func _mm256_mask_cvtsepi32_storeu_epi8 -- skipped func _mm256_mask_cvtsepi32_epi8 -- skipped func _mm256_maskz_cvtsepi32_epi8 -- skipped func _mm_cvtusepi32_epi8 -- skipped func _mm_mask_cvtusepi32_storeu_epi8 -- skipped func _mm_mask_cvtusepi32_epi8 -- skipped func _mm_maskz_cvtusepi32_epi8 -- skipped func _mm256_cvtusepi32_epi8 -- skipped func _mm256_mask_cvtusepi32_storeu_epi8 -- skipped func _mm256_mask_cvtusepi32_epi8 -- skipped func _mm256_maskz_cvtusepi32_epi8 -- skipped func _mm_cvtepi32_epi16 -- skipped func _mm_mask_cvtepi32_storeu_epi16 -- skipped func _mm_mask_cvtepi32_epi16 -- skipped func _mm_maskz_cvtepi32_epi16 -- skipped func _mm256_cvtepi32_epi16 -- skipped func _mm256_mask_cvtepi32_storeu_epi16 -- skipped func _mm256_mask_cvtepi32_epi16 -- skipped func _mm256_maskz_cvtepi32_epi16 -- skipped func _mm_cvtsepi32_epi16 -- skipped func _mm_mask_cvtsepi32_storeu_epi16 -- skipped func _mm_mask_cvtsepi32_epi16 -- skipped func _mm_maskz_cvtsepi32_epi16 -- skipped func _mm256_cvtsepi32_epi16 -- skipped func _mm256_mask_cvtsepi32_storeu_epi16 -- skipped func _mm256_mask_cvtsepi32_epi16 -- skipped func _mm256_maskz_cvtsepi32_epi16 -- skipped func _mm_cvtusepi32_epi16 -- skipped func _mm_mask_cvtusepi32_storeu_epi16 -- skipped func _mm_mask_cvtusepi32_epi16 -- skipped func _mm_maskz_cvtusepi32_epi16 -- skipped func _mm256_cvtusepi32_epi16 -- skipped func _mm256_mask_cvtusepi32_storeu_epi16 -- skipped func _mm256_mask_cvtusepi32_epi16 -- skipped func _mm256_maskz_cvtusepi32_epi16 -- skipped func _mm_cvtepi64_epi8 -- skipped func _mm_mask_cvtepi64_storeu_epi8 -- skipped func _mm_mask_cvtepi64_epi8 -- skipped func _mm_maskz_cvtepi64_epi8 -- skipped func _mm256_cvtepi64_epi8 -- skipped func _mm256_mask_cvtepi64_storeu_epi8 -- skipped func _mm256_mask_cvtepi64_epi8 -- skipped func _mm256_maskz_cvtepi64_epi8 -- skipped func _mm_cvtsepi64_epi8 -- skipped func _mm_mask_cvtsepi64_storeu_epi8 -- skipped func _mm_mask_cvtsepi64_epi8 -- skipped func _mm_maskz_cvtsepi64_epi8 -- skipped func _mm256_cvtsepi64_epi8 -- skipped func _mm256_mask_cvtsepi64_storeu_epi8 -- skipped func _mm256_mask_cvtsepi64_epi8 -- skipped func _mm256_maskz_cvtsepi64_epi8 -- skipped func _mm_cvtusepi64_epi8 -- skipped func _mm_mask_cvtusepi64_storeu_epi8 -- skipped func _mm_mask_cvtusepi64_epi8 -- skipped func _mm_maskz_cvtusepi64_epi8 -- skipped func _mm256_cvtusepi64_epi8 -- skipped func _mm256_mask_cvtusepi64_storeu_epi8 -- skipped func _mm256_mask_cvtusepi64_epi8 -- skipped func _mm256_maskz_cvtusepi64_epi8 -- skipped func _mm_cvtepi64_epi16 -- skipped func _mm_mask_cvtepi64_storeu_epi16 -- skipped func _mm_mask_cvtepi64_epi16 -- skipped func _mm_maskz_cvtepi64_epi16 -- skipped func _mm256_cvtepi64_epi16 -- skipped func _mm256_mask_cvtepi64_storeu_epi16 -- skipped func _mm256_mask_cvtepi64_epi16 -- skipped func _mm256_maskz_cvtepi64_epi16 -- skipped func _mm_cvtsepi64_epi16 -- skipped func _mm_mask_cvtsepi64_storeu_epi16 -- skipped func _mm_mask_cvtsepi64_epi16 -- skipped func _mm_maskz_cvtsepi64_epi16 -- skipped func _mm256_cvtsepi64_epi16 -- skipped func _mm256_mask_cvtsepi64_storeu_epi16 -- skipped func _mm256_mask_cvtsepi64_epi16 -- skipped func _mm256_maskz_cvtsepi64_epi16 -- skipped func _mm_cvtusepi64_epi16 -- skipped func _mm_mask_cvtusepi64_storeu_epi16 -- skipped func _mm_mask_cvtusepi64_epi16 -- skipped func _mm_maskz_cvtusepi64_epi16 -- skipped func _mm256_cvtusepi64_epi16 -- skipped func _mm256_mask_cvtusepi64_storeu_epi16 -- skipped func _mm256_mask_cvtusepi64_epi16 -- skipped func _mm256_maskz_cvtusepi64_epi16 -- skipped func _mm_cvtepi64_epi32 -- skipped func _mm_mask_cvtepi64_storeu_epi32 -- skipped func _mm_mask_cvtepi64_epi32 -- skipped func _mm_maskz_cvtepi64_epi32 -- skipped func _mm256_cvtepi64_epi32 -- skipped func _mm256_mask_cvtepi64_storeu_epi32 -- skipped func _mm256_mask_cvtepi64_epi32 -- skipped func _mm256_maskz_cvtepi64_epi32 -- skipped func _mm_cvtsepi64_epi32 -- skipped func _mm_mask_cvtsepi64_storeu_epi32 -- skipped func _mm_mask_cvtsepi64_epi32 -- skipped func _mm_maskz_cvtsepi64_epi32 -- skipped func _mm256_cvtsepi64_epi32 -- skipped func _mm256_mask_cvtsepi64_storeu_epi32 -- skipped func _mm256_mask_cvtsepi64_epi32 -- skipped func _mm256_maskz_cvtsepi64_epi32 -- skipped func _mm_cvtusepi64_epi32 -- skipped func _mm_mask_cvtusepi64_storeu_epi32 -- skipped func _mm_mask_cvtusepi64_epi32 -- skipped func _mm_maskz_cvtusepi64_epi32 -- skipped func _mm256_cvtusepi64_epi32 -- skipped func _mm256_mask_cvtusepi64_storeu_epi32 -- skipped func _mm256_mask_cvtusepi64_epi32 -- skipped func _mm256_maskz_cvtusepi64_epi32 -- skipped func _mm256_mask_broadcastss_ps -- skipped func _mm256_maskz_broadcastss_ps -- skipped func _mm_mask_broadcastss_ps -- skipped func _mm_maskz_broadcastss_ps -- skipped func _mm256_mask_broadcastsd_pd -- skipped func _mm256_maskz_broadcastsd_pd -- skipped func _mm256_mask_broadcastd_epi32 -- skipped func _mm256_maskz_broadcastd_epi32 -- skipped func _mm256_mask_set1_epi32 -- skipped func _mm256_maskz_set1_epi32 -- skipped func _mm_mask_broadcastd_epi32 -- skipped func _mm_maskz_broadcastd_epi32 -- skipped func _mm_mask_set1_epi32 -- skipped func _mm_maskz_set1_epi32 -- skipped func _mm256_mask_broadcastq_epi64 -- skipped func _mm256_maskz_broadcastq_epi64 -- skipped func _mm256_mask_set1_epi64 -- skipped func _mm256_maskz_set1_epi64 -- skipped func _mm_mask_broadcastq_epi64 -- skipped func _mm_maskz_broadcastq_epi64 -- skipped func _mm_mask_set1_epi64 -- skipped func _mm_maskz_set1_epi64 -- skipped func _mm256_broadcast_f32x4 -- skipped func _mm256_mask_broadcast_f32x4 -- skipped func _mm256_maskz_broadcast_f32x4 -- skipped func _mm256_broadcast_i32x4 -- skipped func _mm256_mask_broadcast_i32x4 -- skipped func _mm256_maskz_broadcast_i32x4 -- skipped func _mm256_mask_cvtepi8_epi32 -- skipped func _mm256_maskz_cvtepi8_epi32 -- skipped func _mm_mask_cvtepi8_epi32 -- skipped func _mm_maskz_cvtepi8_epi32 -- skipped func _mm256_mask_cvtepi8_epi64 -- skipped func _mm256_maskz_cvtepi8_epi64 -- skipped func _mm_mask_cvtepi8_epi64 -- skipped func _mm_maskz_cvtepi8_epi64 -- skipped func _mm256_mask_cvtepi16_epi32 -- skipped func _mm256_maskz_cvtepi16_epi32 -- skipped func _mm_mask_cvtepi16_epi32 -- skipped func _mm_maskz_cvtepi16_epi32 -- skipped func _mm256_mask_cvtepi16_epi64 -- skipped func _mm256_maskz_cvtepi16_epi64 -- skipped func _mm_mask_cvtepi16_epi64 -- skipped func _mm_maskz_cvtepi16_epi64 -- skipped func _mm256_mask_cvtepi32_epi64 -- skipped func _mm256_maskz_cvtepi32_epi64 -- skipped func _mm_mask_cvtepi32_epi64 -- skipped func _mm_maskz_cvtepi32_epi64 -- skipped func _mm256_mask_cvtepu8_epi32 -- skipped func _mm256_maskz_cvtepu8_epi32 -- skipped func _mm_mask_cvtepu8_epi32 -- skipped func _mm_maskz_cvtepu8_epi32 -- skipped func _mm256_mask_cvtepu8_epi64 -- skipped func _mm256_maskz_cvtepu8_epi64 -- skipped func _mm_mask_cvtepu8_epi64 -- skipped func _mm_maskz_cvtepu8_epi64 -- skipped func _mm256_mask_cvtepu16_epi32 -- skipped func _mm256_maskz_cvtepu16_epi32 -- skipped func _mm_mask_cvtepu16_epi32 -- skipped func _mm_maskz_cvtepu16_epi32 -- skipped func _mm256_mask_cvtepu16_epi64 -- skipped func _mm256_maskz_cvtepu16_epi64 -- skipped func _mm_mask_cvtepu16_epi64 -- skipped func _mm_maskz_cvtepu16_epi64 -- skipped func _mm256_mask_cvtepu32_epi64 -- skipped func _mm256_maskz_cvtepu32_epi64 -- skipped func _mm_mask_cvtepu32_epi64 -- skipped func _mm_maskz_cvtepu32_epi64 -- skipped func _mm256_rcp14_pd -- skipped func _mm256_mask_rcp14_pd -- skipped func _mm256_maskz_rcp14_pd -- skipped func _mm_rcp14_pd -- skipped func _mm_mask_rcp14_pd -- skipped func _mm_maskz_rcp14_pd -- skipped func _mm256_rcp14_ps -- skipped func _mm256_mask_rcp14_ps -- skipped func _mm256_maskz_rcp14_ps -- skipped func _mm_rcp14_ps -- skipped func _mm_mask_rcp14_ps -- skipped func _mm_maskz_rcp14_ps -- skipped func _mm256_rsqrt14_pd -- skipped func _mm256_mask_rsqrt14_pd -- skipped func _mm256_maskz_rsqrt14_pd -- skipped func _mm_rsqrt14_pd -- skipped func _mm_mask_rsqrt14_pd -- skipped func _mm_maskz_rsqrt14_pd -- skipped func _mm256_rsqrt14_ps -- skipped func _mm256_mask_rsqrt14_ps -- skipped func _mm256_maskz_rsqrt14_ps -- skipped func _mm_rsqrt14_ps -- skipped func _mm_mask_rsqrt14_ps -- skipped func _mm_maskz_rsqrt14_ps -- skipped func _mm256_mask_sqrt_pd -- skipped func _mm256_maskz_sqrt_pd -- skipped func _mm_mask_sqrt_pd -- skipped func _mm_maskz_sqrt_pd -- skipped func _mm256_mask_sqrt_ps -- skipped func _mm256_maskz_sqrt_ps -- skipped func _mm_mask_sqrt_ps -- skipped func _mm_maskz_sqrt_ps -- skipped func _mm256_mask_add_epi32 -- skipped func _mm256_maskz_add_epi32 -- skipped func _mm256_mask_add_epi64 -- skipped func _mm256_maskz_add_epi64 -- skipped func _mm256_mask_sub_epi32 -- skipped func _mm256_maskz_sub_epi32 -- skipped func _mm256_mask_sub_epi64 -- skipped func _mm256_maskz_sub_epi64 -- skipped func _mm_mask_add_epi32 -- skipped func _mm_maskz_add_epi32 -- skipped func _mm_mask_add_epi64 -- skipped func _mm_maskz_add_epi64 -- skipped func _mm_mask_sub_epi32 -- skipped func _mm_maskz_sub_epi32 -- skipped func _mm_mask_sub_epi64 -- skipped func _mm_maskz_sub_epi64 -- skipped func _mm256_getexp_ps -- skipped func _mm256_mask_getexp_ps -- skipped func _mm256_maskz_getexp_ps -- skipped func _mm256_getexp_pd -- skipped func _mm256_mask_getexp_pd -- skipped func _mm256_maskz_getexp_pd -- skipped func _mm_getexp_ps -- skipped func _mm_mask_getexp_ps -- skipped func _mm_maskz_getexp_ps -- skipped func _mm_getexp_pd -- skipped func _mm_mask_getexp_pd -- skipped func _mm_maskz_getexp_pd -- skipped func _mm256_mask_srl_epi32 -- skipped func _mm256_maskz_srl_epi32 -- skipped func _mm_mask_srl_epi32 -- skipped func _mm_maskz_srl_epi32 -- skipped func _mm256_mask_srl_epi64 -- skipped func _mm256_maskz_srl_epi64 -- skipped func _mm_mask_srl_epi64 -- skipped func _mm_maskz_srl_epi64 -- skipped func _mm256_mask_and_epi32 -- skipped func _mm256_maskz_and_epi32 -- skipped func _mm256_scalef_pd -- skipped func _mm256_mask_scalef_pd -- skipped func _mm256_maskz_scalef_pd -- skipped func _mm256_scalef_ps -- skipped func _mm256_mask_scalef_ps -- skipped func _mm256_maskz_scalef_ps -- skipped func _mm_scalef_pd -- skipped func _mm_mask_scalef_pd -- skipped func _mm_maskz_scalef_pd -- skipped func _mm_scalef_ps -- skipped func _mm_mask_scalef_ps -- skipped func _mm_maskz_scalef_ps -- skipped func _mm256_mask_fmadd_pd -- skipped func _mm256_mask3_fmadd_pd -- skipped func _mm256_maskz_fmadd_pd -- skipped func _mm_mask_fmadd_pd -- skipped func _mm_mask3_fmadd_pd -- skipped func _mm_maskz_fmadd_pd -- skipped func _mm256_mask_fmadd_ps -- skipped func _mm256_mask3_fmadd_ps -- skipped func _mm256_maskz_fmadd_ps -- skipped func _mm_mask_fmadd_ps -- skipped func _mm_mask3_fmadd_ps -- skipped func _mm_maskz_fmadd_ps -- skipped func _mm256_mask_fmsub_pd -- skipped func _mm256_mask3_fmsub_pd -- skipped func _mm256_maskz_fmsub_pd -- skipped func _mm_mask_fmsub_pd -- skipped func _mm_mask3_fmsub_pd -- skipped func _mm_maskz_fmsub_pd -- skipped func _mm256_mask_fmsub_ps -- skipped func _mm256_mask3_fmsub_ps -- skipped func _mm256_maskz_fmsub_ps -- skipped func _mm_mask_fmsub_ps -- skipped func _mm_mask3_fmsub_ps -- skipped func _mm_maskz_fmsub_ps -- skipped func _mm256_mask_fmaddsub_pd -- skipped func _mm256_mask3_fmaddsub_pd -- skipped func _mm256_maskz_fmaddsub_pd -- skipped func _mm_mask_fmaddsub_pd -- skipped func _mm_mask3_fmaddsub_pd -- skipped func _mm_maskz_fmaddsub_pd -- skipped func _mm256_mask_fmaddsub_ps -- skipped func _mm256_mask3_fmaddsub_ps -- skipped func _mm256_maskz_fmaddsub_ps -- skipped func _mm_mask_fmaddsub_ps -- skipped func _mm_mask3_fmaddsub_ps -- skipped func _mm_maskz_fmaddsub_ps -- skipped func _mm256_mask_fmsubadd_pd -- skipped func _mm256_mask3_fmsubadd_pd -- skipped func _mm256_maskz_fmsubadd_pd -- skipped func _mm_mask_fmsubadd_pd -- skipped func _mm_mask3_fmsubadd_pd -- skipped func _mm_maskz_fmsubadd_pd -- skipped func _mm256_mask_fmsubadd_ps -- skipped func _mm256_mask3_fmsubadd_ps -- skipped func _mm256_maskz_fmsubadd_ps -- skipped func _mm_mask_fmsubadd_ps -- skipped func _mm_mask3_fmsubadd_ps -- skipped func _mm_maskz_fmsubadd_ps -- skipped func _mm256_mask_fnmadd_pd -- skipped func _mm256_mask3_fnmadd_pd -- skipped func _mm256_maskz_fnmadd_pd -- skipped func _mm_mask_fnmadd_pd -- skipped func _mm_mask3_fnmadd_pd -- skipped func _mm_maskz_fnmadd_pd -- skipped func _mm256_mask_fnmadd_ps -- skipped func _mm256_mask3_fnmadd_ps -- skipped func _mm256_maskz_fnmadd_ps -- skipped func _mm_mask_fnmadd_ps -- skipped func _mm_mask3_fnmadd_ps -- skipped func _mm_maskz_fnmadd_ps -- skipped func _mm256_mask_fnmsub_pd -- skipped func _mm256_mask3_fnmsub_pd -- skipped func _mm256_maskz_fnmsub_pd -- skipped func _mm_mask_fnmsub_pd -- skipped func _mm_mask3_fnmsub_pd -- skipped func _mm_maskz_fnmsub_pd -- skipped func _mm256_mask_fnmsub_ps -- skipped func _mm256_mask3_fnmsub_ps -- skipped func _mm256_maskz_fnmsub_ps -- skipped func _mm_mask_fnmsub_ps -- skipped func _mm_mask3_fnmsub_ps -- skipped func _mm_maskz_fnmsub_ps -- skipped func _mm_mask_and_epi32 -- skipped func _mm_maskz_and_epi32 -- skipped func _mm256_mask_andnot_epi32 -- skipped func _mm256_maskz_andnot_epi32 -- skipped func _mm_mask_andnot_epi32 -- skipped func _mm_maskz_andnot_epi32 -- skipped func _mm256_mask_or_epi32 -- skipped func _mm256_maskz_or_epi32 -- skipped func _mm_mask_or_epi32 -- skipped func _mm_maskz_or_epi32 -- skipped func _mm256_mask_xor_epi32 -- skipped func _mm256_maskz_xor_epi32 -- skipped func _mm_mask_xor_epi32 -- skipped func _mm_maskz_xor_epi32 -- skipped func _mm_mask_cvtpd_ps -- skipped func _mm_maskz_cvtpd_ps -- skipped func _mm256_mask_cvtpd_ps -- skipped func _mm256_maskz_cvtpd_ps -- skipped func _mm256_mask_cvtps_epi32 -- skipped func _mm256_maskz_cvtps_epi32 -- skipped func _mm_mask_cvtps_epi32 -- skipped func _mm_maskz_cvtps_epi32 -- skipped func _mm256_cvtps_epu32 -- skipped func _mm256_mask_cvtps_epu32 -- skipped func _mm256_maskz_cvtps_epu32 -- skipped func _mm_cvtps_epu32 -- skipped func _mm_mask_cvtps_epu32 -- skipped func _mm_maskz_cvtps_epu32 -- skipped func _mm256_mask_movedup_pd -- skipped func _mm256_maskz_movedup_pd -- skipped func _mm_mask_movedup_pd -- skipped func _mm_maskz_movedup_pd -- skipped func _mm256_mask_movehdup_ps -- skipped func _mm256_maskz_movehdup_ps -- skipped func _mm_mask_movehdup_ps -- skipped func _mm_maskz_movehdup_ps -- skipped func _mm256_mask_moveldup_ps -- skipped func _mm256_maskz_moveldup_ps -- skipped func _mm_mask_moveldup_ps -- skipped func _mm_maskz_moveldup_ps -- skipped func _mm_mask_unpackhi_epi32 -- skipped func _mm_maskz_unpackhi_epi32 -- skipped func _mm256_mask_unpackhi_epi32 -- skipped func _mm256_maskz_unpackhi_epi32 -- skipped func _mm_mask_unpackhi_epi64 -- skipped func _mm_maskz_unpackhi_epi64 -- skipped func _mm256_mask_unpackhi_epi64 -- skipped func _mm256_maskz_unpackhi_epi64 -- skipped func _mm_mask_unpacklo_epi32 -- skipped func _mm_maskz_unpacklo_epi32 -- skipped func _mm256_mask_unpacklo_epi32 -- skipped func _mm256_maskz_unpacklo_epi32 -- skipped func _mm_mask_unpacklo_epi64 -- skipped func _mm_maskz_unpacklo_epi64 -- skipped func _mm256_mask_unpacklo_epi64 -- skipped func _mm256_maskz_unpacklo_epi64 -- skipped func _mm_cmpeq_epu32_mask -- skipped func _mm_cmpeq_epi32_mask -- skipped func _mm_mask_cmpeq_epu32_mask -- skipped func _mm_mask_cmpeq_epi32_mask -- skipped func _mm256_cmpeq_epu32_mask -- skipped func _mm256_cmpeq_epi32_mask -- skipped func _mm256_mask_cmpeq_epu32_mask -- skipped func _mm256_mask_cmpeq_epi32_mask -- skipped func _mm_cmpeq_epu64_mask -- skipped func _mm_cmpeq_epi64_mask -- skipped func _mm_mask_cmpeq_epu64_mask -- skipped func _mm_mask_cmpeq_epi64_mask -- skipped func _mm256_cmpeq_epu64_mask -- skipped func _mm256_cmpeq_epi64_mask -- skipped func _mm256_mask_cmpeq_epu64_mask -- skipped func _mm256_mask_cmpeq_epi64_mask -- skipped func _mm_cmpgt_epu32_mask -- skipped func _mm_cmpgt_epi32_mask -- skipped func _mm_mask_cmpgt_epu32_mask -- skipped func _mm_mask_cmpgt_epi32_mask -- skipped func _mm256_cmpgt_epu32_mask -- skipped func _mm256_cmpgt_epi32_mask -- skipped func _mm256_mask_cmpgt_epu32_mask -- skipped func _mm256_mask_cmpgt_epi32_mask -- skipped func _mm_cmpgt_epu64_mask -- skipped func _mm_cmpgt_epi64_mask -- skipped func _mm_mask_cmpgt_epu64_mask -- skipped func _mm_mask_cmpgt_epi64_mask -- skipped func _mm256_cmpgt_epu64_mask -- skipped func _mm256_cmpgt_epi64_mask -- skipped func _mm256_mask_cmpgt_epu64_mask -- skipped func _mm256_mask_cmpgt_epi64_mask -- skipped func _mm_test_epi32_mask -- skipped func _mm_mask_test_epi32_mask -- skipped func _mm256_test_epi32_mask -- skipped func _mm256_mask_test_epi32_mask -- skipped func _mm_test_epi64_mask -- skipped func _mm_mask_test_epi64_mask -- skipped func _mm256_test_epi64_mask -- skipped func _mm256_mask_test_epi64_mask -- skipped func _mm_testn_epi32_mask -- skipped func _mm_mask_testn_epi32_mask -- skipped func _mm256_testn_epi32_mask -- skipped func _mm256_mask_testn_epi32_mask -- skipped func _mm_testn_epi64_mask -- skipped func _mm_mask_testn_epi64_mask -- skipped func _mm256_testn_epi64_mask -- skipped func _mm256_mask_testn_epi64_mask -- skipped func _mm256_mask_compress_pd -- skipped func _mm256_maskz_compress_pd -- skipped func _mm256_mask_compressstoreu_pd -- skipped func _mm_mask_compress_pd -- skipped func _mm_maskz_compress_pd -- skipped func _mm_mask_compressstoreu_pd -- skipped func _mm256_mask_compress_ps -- skipped func _mm256_maskz_compress_ps -- skipped func _mm256_mask_compressstoreu_ps -- skipped func _mm_mask_compress_ps -- skipped func _mm_maskz_compress_ps -- skipped func _mm_mask_compressstoreu_ps -- skipped func _mm256_mask_compress_epi64 -- skipped func _mm256_maskz_compress_epi64 -- skipped func _mm256_mask_compressstoreu_epi64 -- skipped func _mm_mask_compress_epi64 -- skipped func _mm_maskz_compress_epi64 -- skipped func _mm_mask_compressstoreu_epi64 -- skipped func _mm256_mask_compress_epi32 -- skipped func _mm256_maskz_compress_epi32 -- skipped func _mm256_mask_compressstoreu_epi32 -- skipped func _mm_mask_compress_epi32 -- skipped func _mm_maskz_compress_epi32 -- skipped func _mm_mask_compressstoreu_epi32 -- skipped func _mm256_mask_expand_pd -- skipped func _mm256_maskz_expand_pd -- skipped func _mm256_mask_expandloadu_pd -- skipped func _mm256_maskz_expandloadu_pd -- skipped func _mm_mask_expand_pd -- skipped func _mm_maskz_expand_pd -- skipped func _mm_mask_expandloadu_pd -- skipped func _mm_maskz_expandloadu_pd -- skipped func _mm256_mask_expand_ps -- skipped func _mm256_maskz_expand_ps -- skipped func _mm256_mask_expandloadu_ps -- skipped func _mm256_maskz_expandloadu_ps -- skipped func _mm_mask_expand_ps -- skipped func _mm_maskz_expand_ps -- skipped func _mm_mask_expandloadu_ps -- skipped func _mm_maskz_expandloadu_ps -- skipped func _mm256_mask_expand_epi64 -- skipped func _mm256_maskz_expand_epi64 -- skipped func _mm256_mask_expandloadu_epi64 -- skipped func _mm256_maskz_expandloadu_epi64 -- skipped func _mm_mask_expand_epi64 -- skipped func _mm_maskz_expand_epi64 -- skipped func _mm_mask_expandloadu_epi64 -- skipped func _mm_maskz_expandloadu_epi64 -- skipped func _mm256_mask_expand_epi32 -- skipped func _mm256_maskz_expand_epi32 -- skipped func _mm256_mask_expandloadu_epi32 -- skipped func _mm256_maskz_expandloadu_epi32 -- skipped func _mm_mask_expand_epi32 -- skipped func _mm_maskz_expand_epi32 -- skipped func _mm_mask_expandloadu_epi32 -- skipped func _mm_maskz_expandloadu_epi32 -- skipped func _mm256_permutex2var_pd -- idx -- skipped func _mm256_mask_permutex2var_pd -- idx -- skipped func _mm256_mask2_permutex2var_pd -- idx -- skipped func _mm256_maskz_permutex2var_pd -- idx -- skipped func _mm256_permutex2var_ps -- idx -- skipped func _mm256_mask_permutex2var_ps -- idx -- skipped func _mm256_mask2_permutex2var_ps -- idx -- skipped func _mm256_maskz_permutex2var_ps -- idx -- skipped func _mm_permutex2var_epi64 -- idx -- skipped func _mm_mask_permutex2var_epi64 -- idx -- skipped func _mm_mask2_permutex2var_epi64 -- idx -- skipped func _mm_maskz_permutex2var_epi64 -- idx -- skipped func _mm_permutex2var_epi32 -- idx -- skipped func _mm_mask_permutex2var_epi32 -- idx -- skipped func _mm_mask2_permutex2var_epi32 -- idx -- skipped func _mm_maskz_permutex2var_epi32 -- idx -- skipped func _mm256_permutex2var_epi64 -- idx -- skipped func _mm256_mask_permutex2var_epi64 -- idx -- skipped func _mm256_mask2_permutex2var_epi64 -- idx -- skipped func _mm256_maskz_permutex2var_epi64 -- idx -- skipped func _mm256_permutex2var_epi32 -- idx -- skipped func _mm256_mask_permutex2var_epi32 -- idx -- skipped func _mm256_mask2_permutex2var_epi32 -- idx -- skipped func _mm256_maskz_permutex2var_epi32 -- idx -- skipped func _mm_permutex2var_pd -- idx -- skipped func _mm_mask_permutex2var_pd -- idx -- skipped func _mm_mask2_permutex2var_pd -- idx -- skipped func _mm_maskz_permutex2var_pd -- idx -- skipped func _mm_permutex2var_ps -- idx -- skipped func _mm_mask_permutex2var_ps -- idx -- skipped func _mm_mask2_permutex2var_ps -- idx -- skipped func _mm_maskz_permutex2var_ps -- idx -- skipped func _mm_srav_epi64 -- skipped func _mm_mask_srav_epi64 -- skipped func _mm_maskz_srav_epi64 -- skipped func _mm256_mask_sllv_epi32 -- skipped func _mm256_maskz_sllv_epi32 -- skipped func _mm_mask_sllv_epi32 -- skipped func _mm_maskz_sllv_epi32 -- skipped func _mm256_mask_sllv_epi64 -- skipped func _mm256_maskz_sllv_epi64 -- skipped func _mm_mask_sllv_epi64 -- skipped func _mm_maskz_sllv_epi64 -- skipped func _mm256_mask_srav_epi32 -- skipped func _mm256_maskz_srav_epi32 -- skipped func _mm_mask_srav_epi32 -- skipped func _mm_maskz_srav_epi32 -- skipped func _mm256_mask_srlv_epi32 -- skipped func _mm256_maskz_srlv_epi32 -- skipped func _mm_mask_srlv_epi32 -- skipped func _mm_maskz_srlv_epi32 -- skipped func _mm256_mask_srlv_epi64 -- skipped func _mm256_maskz_srlv_epi64 -- skipped func _mm_mask_srlv_epi64 -- skipped func _mm_maskz_srlv_epi64 -- skipped func _mm256_rolv_epi32 -- skipped func _mm256_mask_rolv_epi32 -- skipped func _mm256_maskz_rolv_epi32 -- skipped func _mm_rolv_epi32 -- skipped func _mm_mask_rolv_epi32 -- skipped func _mm_maskz_rolv_epi32 -- skipped func _mm256_rorv_epi32 -- skipped func _mm256_mask_rorv_epi32 -- skipped func _mm256_maskz_rorv_epi32 -- skipped func _mm_rorv_epi32 -- skipped func _mm_mask_rorv_epi32 -- skipped func _mm_maskz_rorv_epi32 -- skipped func _mm256_rolv_epi64 -- skipped func _mm256_mask_rolv_epi64 -- skipped func _mm256_maskz_rolv_epi64 -- skipped func _mm_rolv_epi64 -- skipped func _mm_mask_rolv_epi64 -- skipped func _mm_maskz_rolv_epi64 -- skipped func _mm256_rorv_epi64 -- skipped func _mm256_mask_rorv_epi64 -- skipped func _mm256_maskz_rorv_epi64 -- skipped func _mm_rorv_epi64 -- skipped func _mm_mask_rorv_epi64 -- skipped func _mm_maskz_rorv_epi64 -- skipped func _mm256_srav_epi64 -- skipped func _mm256_mask_srav_epi64 -- skipped func _mm256_maskz_srav_epi64 -- skipped func _mm256_mask_and_epi64 -- skipped func _mm256_maskz_and_epi64 -- skipped func _mm_mask_and_epi64 -- skipped func _mm_maskz_and_epi64 -- skipped func _mm256_mask_andnot_epi64 -- skipped func _mm256_maskz_andnot_epi64 -- skipped func _mm_mask_andnot_epi64 -- skipped func _mm_maskz_andnot_epi64 -- skipped func _mm256_mask_or_epi64 -- skipped func _mm256_maskz_or_epi64 -- skipped func _mm_mask_or_epi64 -- skipped func _mm_maskz_or_epi64 -- skipped func _mm256_mask_xor_epi64 -- skipped func _mm256_maskz_xor_epi64 -- skipped func _mm_mask_xor_epi64 -- skipped func _mm_maskz_xor_epi64 -- skipped func _mm256_mask_max_pd -- skipped func _mm256_maskz_max_pd -- skipped func _mm256_mask_max_ps -- skipped func _mm256_maskz_max_ps -- skipped func _mm_mask_div_ps -- skipped func _mm_maskz_div_ps -- skipped func _mm_mask_div_pd -- skipped func _mm_maskz_div_pd -- skipped func _mm256_mask_min_pd -- skipped func _mm256_mask_div_pd -- skipped func _mm256_maskz_min_pd -- skipped func _mm256_mask_min_ps -- skipped func _mm256_maskz_div_pd -- skipped func _mm256_mask_div_ps -- skipped func _mm256_maskz_min_ps -- skipped func _mm256_maskz_div_ps -- skipped func _mm_mask_min_ps -- skipped func _mm_mask_mul_ps -- skipped func _mm_maskz_min_ps -- skipped func _mm_maskz_mul_ps -- skipped func _mm_mask_max_ps -- skipped func _mm_maskz_max_ps -- skipped func _mm_mask_min_pd -- skipped func _mm_maskz_min_pd -- skipped func _mm_mask_max_pd -- skipped func _mm_maskz_max_pd -- skipped func _mm_mask_mul_pd -- skipped func _mm_maskz_mul_pd -- skipped func _mm256_mask_mul_ps -- skipped func _mm256_maskz_mul_ps -- skipped func _mm256_mask_mul_pd -- skipped func _mm256_maskz_mul_pd -- skipped func _mm256_maskz_max_epi64 -- skipped func _mm256_mask_max_epi64 -- skipped func _mm256_min_epi64 -- skipped func _mm256_mask_min_epi64 -- skipped func _mm256_maskz_min_epi64 -- skipped func _mm256_maskz_max_epu64 -- skipped func _mm256_max_epi64 -- skipped func _mm256_max_epu64 -- skipped func _mm256_mask_max_epu64 -- skipped func _mm256_min_epu64 -- skipped func _mm256_mask_min_epu64 -- skipped func _mm256_maskz_min_epu64 -- skipped func _mm256_maskz_max_epi32 -- skipped func _mm256_mask_max_epi32 -- skipped func _mm256_maskz_min_epi32 -- skipped func _mm256_mask_min_epi32 -- skipped func _mm256_maskz_max_epu32 -- skipped func _mm256_mask_max_epu32 -- skipped func _mm256_maskz_min_epu32 -- skipped func _mm256_mask_min_epu32 -- skipped func _mm_maskz_max_epi64 -- skipped func _mm_mask_max_epi64 -- skipped func _mm_min_epi64 -- skipped func _mm_mask_min_epi64 -- skipped func _mm_maskz_min_epi64 -- skipped func _mm_maskz_max_epu64 -- skipped func _mm_max_epi64 -- skipped func _mm_max_epu64 -- skipped func _mm_mask_max_epu64 -- skipped func _mm_min_epu64 -- skipped func _mm_mask_min_epu64 -- skipped func _mm_maskz_min_epu64 -- skipped func _mm_maskz_max_epi32 -- skipped func _mm_mask_max_epi32 -- skipped func _mm_maskz_min_epi32 -- skipped func _mm_mask_min_epi32 -- skipped func _mm_maskz_max_epu32 -- skipped func _mm_mask_max_epu32 -- skipped func _mm_maskz_min_epu32 -- skipped func _mm_mask_min_epu32 -- skipped func _mm_broadcastmb_epi64 -- skipped func _mm256_broadcastmb_epi64 -- skipped func _mm_broadcastmw_epi32 -- skipped func _mm256_broadcastmw_epi32 -- skipped func _mm256_lzcnt_epi32 -- skipped func _mm256_mask_lzcnt_epi32 -- skipped func _mm256_maskz_lzcnt_epi32 -- skipped func _mm256_lzcnt_epi64 -- skipped func _mm256_mask_lzcnt_epi64 -- skipped func _mm256_maskz_lzcnt_epi64 -- skipped func _mm256_conflict_epi64 -- skipped func _mm256_mask_conflict_epi64 -- skipped func _mm256_maskz_conflict_epi64 -- skipped func _mm256_conflict_epi32 -- skipped func _mm256_mask_conflict_epi32 -- skipped func _mm256_maskz_conflict_epi32 -- skipped func _mm_lzcnt_epi32 -- skipped func _mm_mask_lzcnt_epi32 -- skipped func _mm_maskz_lzcnt_epi32 -- skipped func _mm_lzcnt_epi64 -- skipped func _mm_mask_lzcnt_epi64 -- skipped func _mm_maskz_lzcnt_epi64 -- skipped func _mm_conflict_epi64 -- skipped func _mm_mask_conflict_epi64 -- skipped func _mm_maskz_conflict_epi64 -- skipped func _mm_conflict_epi32 -- skipped func _mm_mask_conflict_epi32 -- skipped func _mm_maskz_conflict_epi32 -- skipped func _mm256_mask_unpacklo_pd -- skipped func _mm256_maskz_unpacklo_pd -- skipped func _mm_mask_unpacklo_pd -- skipped func _mm_maskz_unpacklo_pd -- skipped func _mm256_mask_unpacklo_ps -- skipped func _mm256_mask_unpackhi_pd -- skipped func _mm256_maskz_unpackhi_pd -- skipped func _mm_mask_unpackhi_pd -- skipped func _mm_maskz_unpackhi_pd -- skipped func _mm256_mask_unpackhi_ps -- skipped func _mm256_maskz_unpackhi_ps -- skipped func _mm_mask_unpackhi_ps -- skipped func _mm_maskz_unpackhi_ps -- skipped func _mm_mask_cvtph_ps -- skipped func _mm_maskz_cvtph_ps -- skipped func _mm256_maskz_unpacklo_ps -- skipped func _mm256_mask_cvtph_ps -- skipped func _mm256_maskz_cvtph_ps -- skipped func _mm_mask_unpacklo_ps -- skipped func _mm_maskz_unpacklo_ps -- skipped func _mm256_mask_sra_epi32 -- skipped func _mm256_maskz_sra_epi32 -- skipped func _mm_mask_sra_epi32 -- skipped func _mm_maskz_sra_epi32 -- skipped func _mm256_sra_epi64 -- skipped func _mm256_mask_sra_epi64 -- skipped func _mm256_maskz_sra_epi64 -- skipped func _mm_sra_epi64 -- skipped func _mm_mask_sra_epi64 -- skipped func _mm_maskz_sra_epi64 -- skipped func _mm_mask_sll_epi32 -- skipped func _mm_maskz_sll_epi32 -- skipped func _mm_mask_sll_epi64 -- skipped func _mm_maskz_sll_epi64 -- skipped func _mm256_mask_sll_epi32 -- skipped func _mm256_maskz_sll_epi32 -- skipped func _mm256_mask_sll_epi64 -- skipped func _mm256_maskz_sll_epi64 -- skipped func _mm256_mask_permutexvar_ps -- skipped func _mm256_maskz_permutexvar_ps -- skipped func _mm256_permutexvar_pd -- skipped func _mm256_mask_permutexvar_pd -- skipped func _mm256_maskz_permutexvar_pd -- skipped func _mm256_mask_permutevar_pd -- skipped func _mm256_maskz_permutevar_pd -- skipped func _mm256_mask_permutevar_ps -- skipped func _mm256_maskz_permutevar_ps -- skipped func _mm_mask_permutevar_pd -- skipped func _mm_maskz_permutevar_pd -- skipped func _mm_mask_permutevar_ps -- skipped func _mm_maskz_permutevar_ps -- skipped func _mm256_maskz_mullo_epi32 -- skipped func _mm256_maskz_permutexvar_epi64 -- skipped func _mm256_mask_mullo_epi32 -- skipped func _mm_maskz_mullo_epi32 -- skipped func _mm_mask_mullo_epi32 -- skipped func _mm256_mask_mul_epi32 -- skipped func _mm256_maskz_mul_epi32 -- skipped func _mm_mask_mul_epi32 -- skipped func _mm_maskz_mul_epi32 -- skipped func _mm256_permutexvar_epi64 -- skipped func _mm256_mask_permutexvar_epi64 -- skipped func _mm256_mask_mul_epu32 -- skipped func _mm256_maskz_permutexvar_epi32 -- skipped func _mm256_maskz_mul_epu32 -- skipped func _mm_mask_mul_epu32 -- skipped func _mm_maskz_mul_epu32 -- skipped func _mm256_permutexvar_epi32 -- skipped func _mm256_mask_permutexvar_epi32 -- skipped func _mm256_mask_cmpneq_epu32_mask -- skipped func _mm256_cmpneq_epu32_mask -- skipped func _mm256_mask_cmplt_epu32_mask -- skipped func _mm256_cmplt_epu32_mask -- skipped func _mm256_mask_cmpge_epu32_mask -- skipped func _mm256_cmpge_epu32_mask -- skipped func _mm256_mask_cmple_epu32_mask -- skipped func _mm256_cmple_epu32_mask -- skipped func _mm256_mask_cmpneq_epu64_mask -- skipped func _mm256_cmpneq_epu64_mask -- skipped func _mm256_mask_cmplt_epu64_mask -- skipped func _mm256_cmplt_epu64_mask -- skipped func _mm256_mask_cmpge_epu64_mask -- skipped func _mm256_cmpge_epu64_mask -- skipped func _mm256_mask_cmple_epu64_mask -- skipped func _mm256_cmple_epu64_mask -- skipped func _mm256_mask_cmpneq_epi32_mask -- skipped func _mm256_cmpneq_epi32_mask -- skipped func _mm256_mask_cmplt_epi32_mask -- skipped func _mm256_cmplt_epi32_mask -- skipped func _mm256_mask_cmpge_epi32_mask -- skipped func _mm256_cmpge_epi32_mask -- skipped func _mm256_mask_cmple_epi32_mask -- skipped func _mm256_cmple_epi32_mask -- skipped func _mm256_mask_cmpneq_epi64_mask -- skipped func _mm256_cmpneq_epi64_mask -- skipped func _mm256_mask_cmplt_epi64_mask -- skipped func _mm256_cmplt_epi64_mask -- skipped func _mm256_mask_cmpge_epi64_mask -- skipped func _mm256_cmpge_epi64_mask -- skipped func _mm256_mask_cmple_epi64_mask -- skipped func _mm256_cmple_epi64_mask -- skipped func _mm_mask_cmpneq_epu32_mask -- skipped func _mm_cmpneq_epu32_mask -- skipped func _mm_mask_cmplt_epu32_mask -- skipped func _mm_cmplt_epu32_mask -- skipped func _mm_mask_cmpge_epu32_mask -- skipped func _mm_cmpge_epu32_mask -- skipped func _mm_mask_cmple_epu32_mask -- skipped func _mm_cmple_epu32_mask -- skipped func _mm_mask_cmpneq_epu64_mask -- skipped func _mm_cmpneq_epu64_mask -- skipped func _mm_mask_cmplt_epu64_mask -- skipped func _mm_cmplt_epu64_mask -- skipped func _mm_mask_cmpge_epu64_mask -- skipped func _mm_cmpge_epu64_mask -- skipped func _mm_mask_cmple_epu64_mask -- skipped func _mm_cmple_epu64_mask -- skipped func _mm_mask_cmpneq_epi32_mask -- skipped func _mm_cmpneq_epi32_mask -- skipped func _mm_mask_cmplt_epi32_mask -- skipped func _mm_cmplt_epi32_mask -- skipped func _mm_mask_cmpge_epi32_mask -- skipped func _mm_cmpge_epi32_mask -- skipped func _mm_mask_cmple_epi32_mask -- skipped func _mm_cmple_epi32_mask -- skipped func _mm_mask_cmpneq_epi64_mask -- skipped func _mm_cmpneq_epi64_mask -- skipped func _mm_mask_cmplt_epi64_mask -- skipped func _mm_cmplt_epi64_mask -- skipped func _mm_mask_cmpge_epi64_mask -- skipped func _mm_cmpge_epi64_mask -- skipped func _mm_mask_cmple_epi64_mask -- skipped func _mm_cmple_epi64_mask end avx512vlintrin_h;
-- This file is generated by SWIG. Please do *not* modify by hand. -- with c_math_c.Pointers; with Interfaces.C; package c_math_c.pointer_Pointers is -- Real_Pointer_Pointer -- type Real_Pointer_Pointer is access all c_math_c.Pointers.Real_Pointer; -- Index_Pointer_Pointer -- type Index_Pointer_Pointer is access all c_math_c.Pointers.Index_Pointer; end c_math_c.pointer_Pointers;
.-- Copyright 2021 (C) Holger Rodriguez -- -- SPDX-License-Identifier: BSD-3-Clause -- with RP.Device; with RP.GPIO; with ItsyBitsy; package body LED_Control is subtype LED_Type is RP.GPIO.GPIO_Point; ----------------------------------------------------------------------- -- All Red LED related definitions ----------------------------------------------------------------------- LED_0_Red : LED_Type renames ItsyBitsy.GP26; procedure LED_0_Red_Off is begin LED_0_Red.Clear; end LED_0_Red_Off; procedure LED_0_Red_On is begin LED_0_Red.Set; end LED_0_Red_On; procedure LED_0_Red_Toggle is begin LED_0_Red.Toggle; end LED_0_Red_Toggle; ----------------------------------------------------------------------- -- All Amber LED related definitions ----------------------------------------------------------------------- LED_0_Amber : LED_Type renames ItsyBitsy.GP27; procedure LED_0_Amber_Off is begin LED_0_Amber.Clear; end LED_0_Amber_Off; procedure LED_0_Amber_On is begin LED_0_Amber.Set; end LED_0_Amber_On; procedure LED_0_Amber_Toggle is begin LED_0_Amber.Toggle; end LED_0_Amber_Toggle; ----------------------------------------------------------------------- -- All Green LED related definitions ----------------------------------------------------------------------- LED_0_Green : LED_Type renames ItsyBitsy.GP28; procedure LED_0_Green_Off is begin LED_0_Green.Clear; end LED_0_Green_Off; procedure LED_0_Green_On is begin LED_0_Green.Set; end LED_0_Green_On; procedure LED_0_Green_Toggle is begin LED_0_Green.Toggle; end LED_0_Green_Toggle; ----------------------------------------------------------------------- -- All White LED related definitions ----------------------------------------------------------------------- LED_0_White : LED_Type renames ItsyBitsy.GP29; procedure LED_0_White_Off is begin LED_0_White.Clear; end LED_0_White_Off; procedure LED_0_White_On is begin LED_0_White.Set; end LED_0_White_On; procedure LED_0_White_Toggle is begin LED_0_White.Toggle; end LED_0_White_Toggle; ----------------------------------------------------------------------- -- All Blue LED related definitions ----------------------------------------------------------------------- LED_0_Blue : LED_Type renames ItsyBitsy.GP24; procedure LED_0_Blue_Off is begin LED_0_Blue.Clear; end LED_0_Blue_Off; procedure LED_0_Blue_On is begin LED_0_Blue.Set; end LED_0_Blue_On; procedure LED_0_Blue_Toggle is begin LED_0_Blue.Toggle; end LED_0_Blue_Toggle; ----------------------------------------------------------------------- -- see .ads ----------------------------------------------------------------------- procedure Toggle_All_LEDs (Delay_Between_In_Milliseconds : Integer := WAIT_FOR_NEXT_LED) is begin LED_0_Red_Toggle; RP.Device.Timer.Delay_Milliseconds (Delay_Between_In_Milliseconds); LED_0_Amber_Toggle; RP.Device.Timer.Delay_Milliseconds (Delay_Between_In_Milliseconds); LED_0_Green_Toggle; RP.Device.Timer.Delay_Milliseconds (Delay_Between_In_Milliseconds); LED_0_White_Toggle; RP.Device.Timer.Delay_Milliseconds (Delay_Between_In_Milliseconds); LED_0_Blue_Toggle; RP.Device.Timer.Delay_Milliseconds (Delay_Between_In_Milliseconds); end Toggle_All_LEDs; begin LED_0_Red.Configure (RP.GPIO.Output); LED_0_Amber.Configure (RP.GPIO.Output); LED_0_Green.Configure (RP.GPIO.Output); LED_0_White.Configure (RP.GPIO.Output); LED_0_Blue.Configure (RP.GPIO.Output); end LED_Control;
with Interfaces; use Interfaces; package body Natools.Static_Maps.S_Expressions.Templates.Dates.Zones is P : constant array (0 .. 3) of Natural := (1, 2, 3, 4); T1 : constant array (0 .. 3) of Unsigned_16 := (174, 296, 87, 202); T2 : constant array (0 .. 3) of Unsigned_16 := (5, 119, 245, 172); G : constant array (0 .. 332) of Unsigned_8 := (0, 85, 0, 0, 71, 0, 0, 104, 0, 149, 0, 0, 145, 0, 100, 51, 134, 3, 0, 0, 136, 22, 0, 43, 0, 133, 0, 0, 0, 0, 0, 0, 18, 106, 87, 110, 0, 48, 0, 0, 63, 0, 52, 0, 0, 83, 42, 0, 0, 66, 0, 0, 0, 0, 0, 72, 0, 83, 0, 36, 33, 157, 0, 41, 0, 156, 0, 0, 116, 11, 4, 0, 129, 125, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 4, 61, 0, 0, 80, 7, 35, 0, 0, 0, 0, 0, 30, 5, 140, 81, 111, 74, 0, 76, 0, 0, 0, 0, 0, 0, 0, 0, 153, 0, 0, 45, 16, 2, 108, 149, 109, 0, 0, 1, 0, 0, 158, 0, 164, 0, 139, 40, 0, 0, 0, 0, 0, 116, 0, 0, 64, 129, 39, 159, 0, 0, 75, 5, 0, 0, 0, 55, 0, 106, 24, 154, 0, 67, 86, 0, 9, 0, 65, 0, 50, 0, 0, 94, 47, 0, 0, 86, 6, 0, 61, 0, 0, 75, 0, 38, 73, 30, 16, 120, 0, 0, 0, 16, 0, 0, 80, 0, 140, 44, 146, 0, 0, 0, 0, 0, 27, 0, 0, 0, 90, 83, 32, 28, 0, 0, 104, 0, 83, 0, 0, 0, 109, 16, 0, 112, 0, 0, 0, 66, 37, 0, 25, 70, 59, 70, 0, 24, 0, 131, 0, 0, 0, 0, 45, 0, 0, 4, 0, 41, 97, 0, 0, 0, 17, 21, 0, 0, 0, 69, 160, 5, 0, 0, 46, 64, 0, 68, 0, 5, 142, 8, 0, 0, 7, 79, 103, 77, 0, 0, 138, 0, 163, 0, 43, 74, 0, 0, 134, 13, 54, 114, 51, 44, 0, 131, 32, 13, 15, 148, 35, 94, 0, 31, 0, 0, 0, 144, 0, 84, 39, 0, 0, 125, 58, 0, 0, 4, 12, 0, 0, 60, 11, 64, 0, 0, 0, 34, 14, 158, 145, 0, 23, 0, 143, 163, 0, 96); function Hash (S : String) return Natural is F : constant Natural := S'First - 1; L : constant Natural := S'Length; F1, F2 : Natural := 0; J : Natural; begin for K in P'Range loop exit when L < P (K); J := Character'Pos (S (P (K) + F)); F1 := (F1 + Natural (T1 (K)) * J) mod 333; F2 := (F2 + Natural (T2 (K)) * J) mod 333; end loop; return (Natural (G (F1)) + Natural (G (F2))) mod 166; end Hash; end Natools.Static_Maps.S_Expressions.Templates.Dates.Zones;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2009-2017, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.Internals.Strings.Configuration; with Matreshka.Internals.Strings.Operations; with Matreshka.Internals.Unicode.Ucd.Properties; with Matreshka.Internals.Utf16; package body Matreshka.Internals.Unicode.Casing is use Matreshka.Internals.Strings; use Matreshka.Internals.Strings.Configuration; use Matreshka.Internals.Strings.Operations; use Matreshka.Internals.Unicode.Ucd; use Matreshka.Internals.Unicode.Ucd.Properties; use Matreshka.Internals.Utf16; ------------------ -- Convert_Case -- ------------------ procedure Convert_Case (Locale : not null Matreshka.Internals.Locales.Locale_Data_Access; Source : not null Matreshka.Internals.Strings.Shared_String_Access; Kind : Matreshka.Internals.Unicode.Ucd.Case_Mapping_Kinds; Property : Matreshka.Internals.Unicode.Ucd.Boolean_Properties; Destination : in out Matreshka.Internals.Strings.Shared_String_Access) is Source_Current : Utf16_String_Index := 0; Source_Code : Code_Point; Converted : Boolean; function Is_Preceded_By_Final_Sigma_Context return Boolean; function Is_Followed_By_Final_Sigma_Context return Boolean; function Is_Preceded_By_After_Soft_Dotted_Context return Boolean; function Is_Followed_By_More_Above_Context return Boolean; function Is_Followed_By_Before_Dot_Context return Boolean; function Is_Preceded_By_After_I_Context return Boolean; --------------------------------------- -- Is_Followed_By_Before_Dot_Context -- --------------------------------------- function Is_Followed_By_Before_Dot_Context return Boolean is Current : Utf16_String_Index := Source_Current; Code : Code_Point; begin while Current < Source.Unused loop Unchecked_Next (Source.Value, Current, Code); declare CCC : constant Canonical_Combining_Class := Get_CCC (Code); begin if CCC = 0 or else CCC = 230 then return False; elsif Code = 16#0307# then return True; end if; end; end loop; return False; end Is_Followed_By_Before_Dot_Context; ---------------------------------------- -- Is_Followed_By_Final_Sigma_Context -- ---------------------------------------- function Is_Followed_By_Final_Sigma_Context return Boolean is Current : Utf16_String_Index := Source_Current; Code : Code_Point; begin while Current < Source.Unused loop Unchecked_Next (Source.Value, Current, Code); declare R : constant Core_Values := Locale.Get_Core (Code); begin if not R.B (Case_Ignorable) then return not R.B (Cased); end if; end; end loop; return True; end Is_Followed_By_Final_Sigma_Context; --------------------------------------- -- Is_Followed_By_More_Above_Context -- --------------------------------------- function Is_Followed_By_More_Above_Context return Boolean is Current : Utf16_String_Index := Source_Current; Code : Code_Point; begin while Current < Source.Unused loop Unchecked_Next (Source.Value, Current, Code); declare CCC : constant Canonical_Combining_Class := Get_CCC (Code); begin if CCC = 0 then return False; elsif CCC = 230 then return True; end if; end; end loop; return False; end Is_Followed_By_More_Above_Context; ------------------------------------ -- Is_Preceded_By_After_I_Context -- ------------------------------------ function Is_Preceded_By_After_I_Context return Boolean is Current : Utf16_String_Index := Source_Current; Code : Code_Point; begin Unchecked_Previous (Source.Value, Current, Code); while Current /= 0 loop Unchecked_Previous (Source.Value, Current, Code); declare CCC : constant Canonical_Combining_Class := Get_CCC (Code); begin if CCC = 0 or else CCC = 230 then return False; elsif Code = Wide_Wide_Character'Pos ('I') then return True; end if; end; end loop; return False; end Is_Preceded_By_After_I_Context; ---------------------------------------------- -- Is_Preceded_By_After_Soft_Dotted_Context -- ---------------------------------------------- function Is_Preceded_By_After_Soft_Dotted_Context return Boolean is Current : Utf16_String_Index := Source_Current; Code : Code_Point; begin Unchecked_Previous (Source.Value, Current, Code); while Current /= 0 loop Unchecked_Previous (Source.Value, Current, Code); declare CCC : constant Canonical_Combining_Class := Get_CCC (Code); R : constant Core_Values := Locale.Get_Core (Code); begin if CCC = 0 or else CCC = 230 then return False; elsif R.B (Soft_Dotted) then return True; end if; end; end loop; return False; end Is_Preceded_By_After_Soft_Dotted_Context; ---------------------------------------- -- Is_Preceded_By_Final_Sigma_Context -- ---------------------------------------- function Is_Preceded_By_Final_Sigma_Context return Boolean is Current : Utf16_String_Index := Source_Current; Code : Code_Point; begin Unchecked_Previous (Source.Value, Current, Code); while Current /= 0 loop Unchecked_Previous (Source.Value, Current, Code); declare R : constant Core_Values := Locale.Get_Core (Code); begin if not R.B (Case_Ignorable) then return R.B (Cased); end if; end; end loop; return False; end Is_Preceded_By_Final_Sigma_Context; begin Destination.Unused := 0; Destination.Length := 0; while Source_Current < Source.Unused loop Unchecked_Next (Source.Value, Source_Current, Source_Code); if Locale.Get_Core (Source_Code).B (Property) then declare Mapping : constant Case_Mapping := Locale.Casing.Mapping (First_Stage_Index (Source_Code / 16#100#)) (Second_Stage_Index (Source_Code mod 16#100#)); begin Converted := False; if Kind /= Folding -- Ignore casing context mappings in the case folding mode. and then Mapping.Context_First /= 0 then -- Character is casing context sensitive. for J in Mapping.Context_First .. Mapping.Context_Last loop declare Context : constant Casing_Context_Mapping := Locale.Casing.Context (J); begin if Context.Ranges (Kind).First /= 0 then case Context.Context is when Final_Sigma => if (Is_Preceded_By_Final_Sigma_Context and then Is_Followed_By_Final_Sigma_Context) xor Context.Negative then for J in Context.Ranges (Kind).First .. Context.Ranges (Kind).Last loop Append (Destination, Locale.Casing.Expansion (J)); end loop; Converted := True; exit; end if; when After_Soft_Dotted => if Is_Preceded_By_After_Soft_Dotted_Context xor Context.Negative then null; end if; when More_Above => if Is_Followed_By_More_Above_Context xor Context.Negative then null; end if; when Before_Dot => if Is_Followed_By_Before_Dot_Context xor Context.Negative then null; end if; when After_I => if Is_Preceded_By_After_I_Context xor Context.Negative then null; end if; end case; end if; end; end loop; end if; if not Converted then for J in Mapping.Ranges (Kind).First .. Mapping.Ranges (Kind).Last loop Append (Destination, Locale.Casing.Expansion (J)); end loop; end if; end; else Append (Destination, Source_Code); end if; end loop; String_Handler.Fill_Null_Terminator (Destination); end Convert_Case; ------------------------- -- Simple_Convert_Case -- ------------------------- procedure Simple_Convert_Case (Locale : not null Matreshka.Internals.Locales.Locale_Data_Access; Source : not null Matreshka.Internals.Strings.Shared_String_Access; Kind : Matreshka.Internals.Unicode.Ucd.Case_Mapping_Kinds; Property : Matreshka.Internals.Unicode.Ucd.Boolean_Properties; Destination : in out Matreshka.Internals.Strings.Shared_String_Access) is Source_Current : Utf16_String_Index := 0; Source_Code : Code_Point; begin Destination.Unused := 0; Destination.Length := 0; while Source_Current < Source.Unused loop Unchecked_Next (Source.Value, Source_Current, Source_Code); if Locale.Get_Core (Source_Code).B (Property) then declare Mapping : constant Case_Mapping := Locale.Casing.Mapping (First_Stage_Index (Source_Code / 16#100#)) (Second_Stage_Index (Source_Code mod 16#100#)); begin if Mapping.Simple (Kind) /= 0 then Append (Destination, Mapping.Simple (Kind)); else Append (Destination, Source_Code); end if; end; else Append (Destination, Source_Code); end if; end loop; String_Handler.Fill_Null_Terminator (Destination); end Simple_Convert_Case; end Matreshka.Internals.Unicode.Casing;
-- { dg-do compile } package Noinline1 is procedure Proc1; pragma Inline (Proc1); pragma No_Inline (Proc1); -- { dg-warning "both specified" } procedure Proc2; pragma No_Inline (Proc2); pragma Inline (Proc2); -- { dg-warning "both specified" } procedure Proc3; pragma Inline_Always (Proc3); pragma No_Inline (Proc3); -- { dg-error "mutually exclusive" } procedure Proc4; pragma No_Inline (Proc4); pragma Inline_Always (Proc4); -- { dg-error "mutually exclusive" } end Noinline1;
with Ada.Text_IO; use Ada.Text_IO; procedure Test_Combinations is generic type Integers is range <>; package Combinations is type Combination is array (Positive range <>) of Integers; procedure First (X : in out Combination); procedure Next (X : in out Combination); procedure Put (X : Combination); end Combinations; package body Combinations is procedure First (X : in out Combination) is begin X (1) := Integers'First; for I in 2..X'Last loop X (I) := X (I - 1) + 1; end loop; end First; procedure Next (X : in out Combination) is begin for I in reverse X'Range loop if X (I) < Integers'Val (Integers'Pos (Integers'Last) - X'Last + I) then X (I) := X (I) + 1; for J in I + 1..X'Last loop X (J) := X (J - 1) + 1; end loop; return; end if; end loop; raise Constraint_Error; end Next; procedure Put (X : Combination) is begin for I in X'Range loop Put (Integers'Image (X (I))); end loop; end Put; end Combinations; type Five is range 0..4; package Fives is new Combinations (Five); use Fives; X : Combination (1..3); begin First (X); loop Put (X); New_Line; Next (X); end loop; exception when Constraint_Error => null; end Test_Combinations;
with TEXT_IO; with DEVELOPER_PARAMETERS; use DEVELOPER_PARAMETERS; procedure PUT_STAT(S : STRING) is begin if TEXT_IO.IS_OPEN(STATS) then TEXT_IO.PUT_LINE(STATS, S); end if; end PUT_STAT;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- G N A T . S E R I A L _ C O M M U N I C A T I O N S -- -- -- -- B o d y -- -- -- -- Copyright (C) 2007-2020, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This is the GNU/Linux implementation of this package with Ada.Streams; use Ada.Streams; with Ada; use Ada; with System; use System; with System.Communication; use System.Communication; with System.CRTL; use System.CRTL; with GNAT.OS_Lib; use GNAT.OS_Lib; package body GNAT.Serial_Communications is package OSC renames System.OS_Constants; use type Interfaces.C.unsigned; subtype unsigned is Interfaces.C.unsigned; subtype char is Interfaces.C.char; subtype unsigned_char is Interfaces.C.unsigned_char; function fcntl (fd : int; cmd : int; value : int) return int; pragma Import (C, fcntl, "fcntl"); C_Data_Rate : constant array (Data_Rate) of unsigned := (B75 => OSC.B75, B110 => OSC.B110, B150 => OSC.B150, B300 => OSC.B300, B600 => OSC.B600, B1200 => OSC.B1200, B2400 => OSC.B2400, B4800 => OSC.B4800, B9600 => OSC.B9600, B19200 => OSC.B19200, B38400 => OSC.B38400, B57600 => OSC.B57600, B115200 => OSC.B115200, B230400 => OSC.B230400, B460800 => OSC.B460800, B500000 => OSC.B500000, B576000 => OSC.B576000, B921600 => OSC.B921600, B1000000 => OSC.B1000000, B1152000 => OSC.B1152000, B1500000 => OSC.B1500000, B2000000 => OSC.B2000000, B2500000 => OSC.B2500000, B3000000 => OSC.B3000000, B3500000 => OSC.B3500000, B4000000 => OSC.B4000000); C_Bits : constant array (Data_Bits) of unsigned := (CS7 => OSC.CS7, CS8 => OSC.CS8); C_Stop_Bits : constant array (Stop_Bits_Number) of unsigned := (One => 0, Two => OSC.CSTOPB); C_Parity : constant array (Parity_Check) of unsigned := (None => 0, Odd => OSC.PARENB or OSC.PARODD, Even => OSC.PARENB); procedure Raise_Error (Message : String; Error : Integer := Errno); pragma No_Return (Raise_Error); ---------- -- Name -- ---------- function Name (Number : Positive) return Port_Name is N : constant Natural := Number - 1; N_Img : constant String := Natural'Image (N); begin return Port_Name ("/dev/ttyS" & N_Img (N_Img'First + 1 .. N_Img'Last)); end Name; ---------- -- Open -- ---------- procedure Open (Port : out Serial_Port; Name : Port_Name) is use OSC; C_Name : constant String := String (Name) & ASCII.NUL; Res : int; begin Port.H := Serial_Port_Descriptor (open (C_Name (C_Name'First)'Address, int (O_RDWR + O_NOCTTY + O_NDELAY))); if Port.H = -1 then Raise_Error ("open: open failed"); end if; -- By default we are in blocking mode Res := fcntl (int (Port.H), F_SETFL, 0); if Res = -1 then Raise_Error ("open: fcntl failed"); end if; end Open; ----------------- -- Raise_Error -- ----------------- procedure Raise_Error (Message : String; Error : Integer := Errno) is begin raise Serial_Error with Message & (if Error /= 0 then " (" & Errno_Message (Err => Error) & ')' else ""); end Raise_Error; ---------- -- Read -- ---------- overriding procedure Read (Port : in out Serial_Port; Buffer : out Stream_Element_Array; Last : out Stream_Element_Offset) is Len : constant size_t := Buffer'Length; Res : ssize_t; begin if Port.H = -1 then Raise_Error ("read: port not opened", 0); end if; Res := read (Integer (Port.H), Buffer'Address, Len); if Res = -1 then Raise_Error ("read failed"); end if; Last := Last_Index (Buffer'First, size_t (Res)); end Read; --------- -- Set -- --------- procedure Set (Port : Serial_Port; Rate : Data_Rate := B9600; Bits : Data_Bits := CS8; Stop_Bits : Stop_Bits_Number := One; Parity : Parity_Check := None; Block : Boolean := True; Local : Boolean := True; Flow : Flow_Control := None; Timeout : Duration := 10.0) is use OSC; type termios is record c_iflag : unsigned; c_oflag : unsigned; c_cflag : unsigned; c_lflag : unsigned; c_line : unsigned_char; c_cc : Interfaces.C.char_array (0 .. 31); c_ispeed : unsigned; c_ospeed : unsigned; end record; pragma Convention (C, termios); function tcgetattr (fd : int; termios_p : Address) return int; pragma Import (C, tcgetattr, "tcgetattr"); function tcsetattr (fd : int; action : int; termios_p : Address) return int; pragma Import (C, tcsetattr, "tcsetattr"); function tcflush (fd : int; queue_selector : int) return int; pragma Import (C, tcflush, "tcflush"); Current : termios; Res : int; pragma Warnings (Off, Res); -- Warnings off, since we don't always test the result begin if Port.H = -1 then Raise_Error ("set: port not opened", 0); end if; -- Get current port settings Res := tcgetattr (int (Port.H), Current'Address); -- Change settings now Current.c_cflag := C_Data_Rate (Rate) or C_Bits (Bits) or C_Stop_Bits (Stop_Bits) or C_Parity (Parity) or CREAD; Current.c_iflag := 0; Current.c_lflag := 0; Current.c_oflag := 0; if Local then Current.c_cflag := Current.c_cflag or CLOCAL; end if; case Flow is when None => null; when RTS_CTS => Current.c_cflag := Current.c_cflag or CRTSCTS; when Xon_Xoff => Current.c_iflag := Current.c_iflag or IXON; end case; Current.c_ispeed := Data_Rate_Value (Rate); Current.c_ospeed := Data_Rate_Value (Rate); Current.c_cc (VMIN) := char'Val (0); Current.c_cc (VTIME) := char'Val (Natural (Timeout * 10)); -- Set port settings Res := tcflush (int (Port.H), TCIFLUSH); Res := tcsetattr (int (Port.H), TCSANOW, Current'Address); -- Block Res := fcntl (int (Port.H), F_SETFL, (if Block then 0 else FNDELAY)); if Res = -1 then Raise_Error ("set: fcntl failed"); end if; end Set; ------------ -- To_Ada -- ------------ procedure To_Ada (Port : out Serial_Port; Fd : Serial_Port_Descriptor) is begin Port.H := Fd; end To_Ada; ----------- -- Write -- ----------- overriding procedure Write (Port : in out Serial_Port; Buffer : Stream_Element_Array) is Len : constant size_t := Buffer'Length; Res : ssize_t; begin if Port.H = -1 then Raise_Error ("write: port not opened", 0); end if; Res := write (int (Port.H), Buffer'Address, Len); if Res = -1 then Raise_Error ("write failed"); end if; pragma Assert (size_t (Res) = Len); end Write; ----------- -- Close -- ----------- procedure Close (Port : in out Serial_Port) is Res : int; pragma Unreferenced (Res); begin if Port.H /= -1 then Res := close (int (Port.H)); end if; end Close; end GNAT.Serial_Communications;
----------------------------------------------------------------------- -- openapi -- Support library for OpenAPI code generator -- Copyright (C) 2017, 2022 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Ada.Calendar; with Ada.Strings.Hash; with Ada.Iterator_Interfaces; with Ada.Containers.Vectors; with Ada.Containers.Indefinite_Hashed_Maps; with Util.Beans.Objects.Vectors; with Util.Beans.Objects.Maps; with Util.Strings.Vectors; with Util.Nullables; -- == OpenAPI Introduction == -- The OpenAPI Ada library provides a small runtime for use by the OpenAPI Codegen -- REST API generator. The library provides operations that are used by the generated -- REST client and servers to: -- -- * serialize and deserialize the data in JSON or XML, -- * make the client REST operation and retrieve the result, -- * let a server receive a REST operation, handle it and return the result -- -- The <tt>Swagger</tt> root package defines the global types that are used by -- the generator to represent values such as strings, integers, dates. -- -- @include openapi-clients.ads -- @include openapi-servers.ads -- @include openapi-streams.ads package OpenAPI is subtype UString is Ada.Strings.Unbounded.Unbounded_String; subtype Nullable_UString is Util.Nullables.Nullable_String; function To_String (S : in UString) return String renames Ada.Strings.Unbounded.To_String; function To_UString (S : in String) return UString renames Ada.Strings.Unbounded.To_Unbounded_String; subtype Date is Ada.Calendar.Time; subtype Nullable_Date is Util.Nullables.Nullable_Time; subtype Datetime is Ada.Calendar.Time; subtype Vector is Util.Beans.Objects.Vectors.Vector; subtype Long is Long_Long_Integer; subtype Nullable_Long is Util.Nullables.Nullable_Long; subtype Nullable_Integer is Util.Nullables.Nullable_Integer; subtype Nullable_Boolean is Util.Nullables.Nullable_Boolean; subtype Http_Content_Type is UString; subtype File_Part_Type is UString; subtype Number is Natural; subtype Object is Util.Beans.Objects.Object; subtype Value_Type is Util.Beans.Objects.Object; package UString_Vectors renames Util.Strings.Vectors; subtype Object_Map is Util.Beans.Objects.Maps.Map; package Nullable_UString_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Nullable_UString, "=" => Util.Nullables."="); -- Convert the long value into a string. function To_String (Value : in Long) return String; package Integer_Maps is new Ada.Containers.Indefinite_Hashed_Maps (Key_Type => String, Element_Type => Integer, Hash => Ada.Strings.Hash, Equivalent_Keys => "="); subtype Integer_Map is Integer_Maps.Map; use Util.Nullables; package Nullable_Integer_Maps is new Ada.Containers.Indefinite_Hashed_Maps (Key_Type => String, Element_Type => Nullable_Integer, Hash => Ada.Strings.Hash, Equivalent_Keys => "="); subtype Nullable_Integer_Map is Nullable_Integer_Maps.Map; type Value_Array_Type is tagged private with Constant_Indexing => Element_Value, Default_Iterator => Iterate, Iterator_Element => Value_Type; type Value_Cursor is private; function Has_Element (Pos : in Value_Cursor) return Boolean; package Value_Iterator is new Ada.Iterator_Interfaces (Cursor => Value_Cursor, Has_Element => Has_Element); function Element_Value (List : in Value_Array_Type; Pos : in Value_Cursor) return Value_Type; function Iterate (List : in Value_Array_Type) return Value_Iterator.Forward_Iterator'Class; private type Value_Array_Type is tagged record A : Util.Beans.Objects.Object; end record; type Value_Cursor is record List : Util.Beans.Objects.Object; Pos : Natural := 0; end record; type Iterator is new Value_Iterator.Forward_Iterator with record List : Util.Beans.Objects.Object; Pos : Natural := 0; end record; overriding function First (Iter : in Iterator) return Value_Cursor; overriding function Next (Object : in Iterator; Position : in Value_Cursor) return Value_Cursor; end OpenAPI;
package GESTE_Fonts.FreeSansOblique12pt7b is Font : constant Bitmap_Font_Ref; private FreeSansOblique12pt7bBitmaps : aliased constant Font_Bitmap := ( 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#60#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#04#, 16#00#, 16#00#, 16#08#, 16#00#, 16#00#, 16#10#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#30#, 16#00#, 16#0E#, 16#E0#, 16#00#, 16#19#, 16#80#, 16#00#, 16#33#, 16#00#, 16#00#, 16#66#, 16#00#, 16#00#, 16#88#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#31#, 16#80#, 16#00#, 16#63#, 16#00#, 16#00#, 16#CC#, 16#00#, 16#03#, 16#18#, 16#00#, 16#06#, 16#30#, 16#00#, 16#7F#, 16#F0#, 16#00#, 16#FF#, 16#E0#, 16#00#, 16#63#, 16#00#, 16#01#, 16#8C#, 16#00#, 16#03#, 16#18#, 16#00#, 16#04#, 16#60#, 16#00#, 16#7F#, 16#F0#, 16#01#, 16#FF#, 16#E0#, 16#00#, 16#46#, 16#00#, 16#01#, 16#8C#, 16#00#, 16#03#, 16#10#, 16#00#, 16#0C#, 16#60#, 16#00#, 16#18#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#08#, 16#00#, 16#00#, 16#FC#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#0C#, 16#9C#, 16#00#, 16#31#, 16#18#, 16#00#, 16#62#, 16#30#, 16#00#, 16#CC#, 16#00#, 16#01#, 16#98#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#03#, 16#38#, 16#00#, 16#C4#, 16#70#, 16#01#, 16#88#, 16#C0#, 16#03#, 16#31#, 16#80#, 16#07#, 16#66#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#07#, 16#E0#, 16#00#, 16#02#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#10#, 16#03#, 16#C0#, 16#60#, 16#0F#, 16#C1#, 16#80#, 16#31#, 16#C6#, 16#00#, 16#C1#, 16#88#, 16#01#, 16#82#, 16#30#, 16#03#, 16#0C#, 16#C0#, 16#03#, 16#F3#, 16#00#, 16#03#, 16#C4#, 16#00#, 16#00#, 16#10#, 16#F0#, 16#00#, 16#63#, 16#F0#, 16#01#, 16#8C#, 16#60#, 16#02#, 16#30#, 16#40#, 16#08#, 16#60#, 16#80#, 16#30#, 16#C7#, 16#00#, 16#C0#, 16#FC#, 16#03#, 16#00#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#3C#, 16#00#, 16#01#, 16#FC#, 16#00#, 16#07#, 16#18#, 16#00#, 16#0C#, 16#30#, 16#00#, 16#18#, 16#60#, 16#00#, 16#31#, 16#80#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#70#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#0E#, 16#E6#, 16#00#, 16#30#, 16#EC#, 16#00#, 16#C0#, 16#F0#, 16#01#, 16#81#, 16#C0#, 16#03#, 16#03#, 16#80#, 16#07#, 16#0F#, 16#80#, 16#07#, 16#F3#, 16#00#, 16#07#, 16#C7#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#00#, 16#00#, 16#0E#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#10#, 16#00#, 16#00#, 16#60#, 16#00#, 16#01#, 16#80#, 16#00#, 16#02#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#04#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#20#, 16#00#, 16#00#, 16#40#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#02#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#04#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#40#, 16#00#, 16#01#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#20#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#05#, 16#A0#, 16#00#, 16#1F#, 16#C0#, 16#00#, 16#0E#, 16#00#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#6C#, 16#00#, 16#00#, 16#90#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#80#, 16#00#, 16#7F#, 16#F8#, 16#00#, 16#FF#, 16#F0#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#20#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0E#, 16#00#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#20#, 16#00#, 16#00#, 16#40#, 16#00#, 16#03#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#00#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0E#, 16#00#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#10#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#04#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#20#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#00#, 16#00#, 16#04#, 16#00#, 16#00#, 16#08#, 16#00#, 16#00#, 16#20#, 16#00#, 16#00#, 16#40#, 16#00#, 16#01#, 16#00#, 16#00#, 16#02#, 16#00#, 16#00#, 16#08#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#40#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#78#, 16#00#, 16#03#, 16#F8#, 16#00#, 16#0E#, 16#38#, 16#00#, 16#18#, 16#30#, 16#00#, 16#60#, 16#60#, 16#00#, 16#C0#, 16#C0#, 16#03#, 16#01#, 16#80#, 16#06#, 16#03#, 16#00#, 16#0C#, 16#06#, 16#00#, 16#18#, 16#0C#, 16#00#, 16#70#, 16#38#, 16#00#, 16#E0#, 16#60#, 16#01#, 16#80#, 16#C0#, 16#03#, 16#83#, 16#00#, 16#03#, 16#0E#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#03#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#01#, 16#C0#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#3F#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#07#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#01#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FC#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#0E#, 16#1C#, 16#00#, 16#30#, 16#18#, 16#00#, 16#60#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#01#, 16#80#, 16#00#, 16#07#, 16#00#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#07#, 16#80#, 16#00#, 16#3C#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#03#, 16#80#, 16#00#, 16#06#, 16#00#, 16#00#, 16#1F#, 16#FC#, 16#00#, 16#3F#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#F8#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#0E#, 16#18#, 16#00#, 16#30#, 16#30#, 16#00#, 16#60#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#03#, 16#00#, 16#00#, 16#7C#, 16#00#, 16#00#, 16#F8#, 16#00#, 16#00#, 16#38#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#01#, 16#80#, 16#C0#, 16#03#, 16#03#, 16#80#, 16#07#, 16#0E#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#70#, 16#00#, 16#01#, 16#E0#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#1B#, 16#00#, 16#00#, 16#66#, 16#00#, 16#01#, 16#8C#, 16#00#, 16#06#, 16#18#, 16#00#, 16#18#, 16#70#, 16#00#, 16#60#, 16#C0#, 16#00#, 16#FF#, 16#F0#, 16#01#, 16#FF#, 16#C0#, 16#00#, 16#06#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#DE#, 16#00#, 16#01#, 16#FF#, 16#00#, 16#07#, 16#0E#, 16#00#, 16#0C#, 16#0E#, 16#00#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#38#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#03#, 16#03#, 16#00#, 16#07#, 16#0E#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#7C#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#0E#, 16#18#, 16#00#, 16#18#, 16#38#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#03#, 16#3C#, 16#00#, 16#06#, 16#FE#, 16#00#, 16#0F#, 16#1C#, 16#00#, 16#18#, 16#1C#, 16#00#, 16#70#, 16#38#, 16#00#, 16#C0#, 16#60#, 16#01#, 16#80#, 16#C0#, 16#03#, 16#83#, 16#80#, 16#03#, 16#0E#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#03#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#FF#, 16#80#, 16#0F#, 16#FF#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#60#, 16#00#, 16#01#, 16#C0#, 16#00#, 16#03#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#38#, 16#00#, 16#00#, 16#60#, 16#00#, 16#01#, 16#C0#, 16#00#, 16#03#, 16#00#, 16#00#, 16#0E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#7C#, 16#00#, 16#03#, 16#FC#, 16#00#, 16#0E#, 16#18#, 16#00#, 16#38#, 16#30#, 16#00#, 16#60#, 16#60#, 16#00#, 16#C0#, 16#C0#, 16#01#, 16#C3#, 16#00#, 16#01#, 16#FC#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#1C#, 16#38#, 16#00#, 16#70#, 16#30#, 16#00#, 16#C0#, 16#60#, 16#01#, 16#80#, 16#C0#, 16#03#, 16#03#, 16#80#, 16#07#, 16#0E#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#F8#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#0C#, 16#38#, 16#00#, 16#30#, 16#30#, 16#00#, 16#E0#, 16#60#, 16#01#, 16#80#, 16#C0#, 16#03#, 16#01#, 16#80#, 16#06#, 16#07#, 16#00#, 16#0E#, 16#1E#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#0F#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#01#, 16#C0#, 16#03#, 16#03#, 16#00#, 16#07#, 16#1C#, 16#00#, 16#07#, 16#F0#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#70#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#00#, 16#00#, 16#0E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#70#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#00#, 16#00#, 16#0E#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#10#, 16#00#, 16#00#, 16#20#, 16#00#, 16#01#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#C0#, 16#00#, 16#0F#, 16#00#, 16#00#, 16#F8#, 16#00#, 16#07#, 16#80#, 16#00#, 16#7C#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#00#, 16#F0#, 16#00#, 16#00#, 16#7C#, 16#00#, 16#00#, 16#3E#, 16#00#, 16#00#, 16#0E#, 16#00#, 16#00#, 16#04#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#FF#, 16#00#, 16#1F#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#E0#, 16#03#, 16#FF#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#02#, 16#00#, 16#00#, 16#07#, 16#00#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#00#, 16#F0#, 16#00#, 16#00#, 16#70#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#1E#, 16#00#, 16#01#, 16#F0#, 16#00#, 16#0F#, 16#00#, 16#00#, 16#38#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#3E#, 16#00#, 16#01#, 16#FE#, 16#00#, 16#07#, 16#0E#, 16#00#, 16#0C#, 16#0C#, 16#00#, 16#18#, 16#18#, 16#00#, 16#00#, 16#70#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#03#, 16#80#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#70#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#FC#, 16#00#, 16#1F#, 16#FE#, 16#00#, 16#F8#, 16#1E#, 16#03#, 16#80#, 16#0C#, 16#0E#, 16#00#, 16#08#, 16#38#, 16#3C#, 16#10#, 16#E1#, 16#FB#, 16#01#, 16#87#, 16#1E#, 16#06#, 16#1C#, 16#38#, 16#0C#, 16#70#, 16#70#, 16#30#, 16#C0#, 16#C2#, 16#61#, 16#83#, 16#84#, 16#C7#, 16#06#, 16#19#, 16#8E#, 16#1C#, 16#73#, 16#0C#, 16#71#, 16#C6#, 16#1F#, 16#FF#, 16#06#, 16#1C#, 16#78#, 16#0E#, 16#00#, 16#00#, 16#0F#, 16#00#, 16#00#, 16#0F#, 16#FF#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0E#, 16#00#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#7C#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#03#, 16#30#, 16#00#, 16#0E#, 16#60#, 16#00#, 16#18#, 16#C0#, 16#00#, 16#71#, 16#80#, 16#00#, 16#C3#, 16#00#, 16#03#, 16#86#, 16#00#, 16#06#, 16#0E#, 16#00#, 16#1F#, 16#FC#, 16#00#, 16#7F#, 16#F8#, 16#00#, 16#C0#, 16#30#, 16#03#, 16#80#, 16#60#, 16#06#, 16#00#, 16#C0#, 16#1C#, 16#01#, 16#80#, 16#30#, 16#03#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#03#, 16#FF#, 16#80#, 16#06#, 16#03#, 16#80#, 16#0C#, 16#03#, 16#00#, 16#18#, 16#06#, 16#00#, 16#70#, 16#0C#, 16#00#, 16#E0#, 16#30#, 16#01#, 16#80#, 16#E0#, 16#03#, 16#FF#, 16#00#, 16#07#, 16#FF#, 16#00#, 16#1C#, 16#07#, 16#00#, 16#38#, 16#06#, 16#00#, 16#60#, 16#0C#, 16#00#, 16#C0#, 16#18#, 16#01#, 16#80#, 16#70#, 16#07#, 16#01#, 16#C0#, 16#0F#, 16#FF#, 16#00#, 16#1F#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#FF#, 16#C0#, 16#03#, 16#C3#, 16#C0#, 16#0E#, 16#03#, 16#80#, 16#18#, 16#03#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#38#, 16#00#, 16#00#, 16#70#, 16#00#, 16#00#, 16#E0#, 16#06#, 16#00#, 16#C0#, 16#1C#, 16#01#, 16#C0#, 16#70#, 16#03#, 16#C1#, 16#C0#, 16#03#, 16#FF#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#03#, 16#FF#, 16#80#, 16#06#, 16#03#, 16#80#, 16#0C#, 16#03#, 16#80#, 16#18#, 16#07#, 16#00#, 16#70#, 16#06#, 16#00#, 16#E0#, 16#0C#, 16#01#, 16#80#, 16#18#, 16#03#, 16#00#, 16#70#, 16#06#, 16#00#, 16#E0#, 16#1C#, 16#01#, 16#80#, 16#38#, 16#03#, 16#00#, 16#60#, 16#0C#, 16#00#, 16#C0#, 16#18#, 16#01#, 16#80#, 16#60#, 16#07#, 16#03#, 16#C0#, 16#0F#, 16#FE#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#F0#, 16#03#, 16#FF#, 16#C0#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#70#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#FF#, 16#C0#, 16#07#, 16#FF#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#38#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#07#, 16#00#, 16#00#, 16#0F#, 16#FF#, 16#80#, 16#1F#, 16#FF#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#E0#, 16#03#, 16#FF#, 16#C0#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#70#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#FF#, 16#80#, 16#07#, 16#FE#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#38#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#07#, 16#00#, 16#00#, 16#0E#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#7F#, 16#E0#, 16#01#, 16#C1#, 16#E0#, 16#06#, 16#00#, 16#C0#, 16#18#, 16#01#, 16#80#, 16#70#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#03#, 16#80#, 16#00#, 16#06#, 16#03#, 16#F8#, 16#0C#, 16#0F#, 16#F0#, 16#18#, 16#00#, 16#60#, 16#30#, 16#01#, 16#80#, 16#60#, 16#03#, 16#00#, 16#C0#, 16#0E#, 16#01#, 16#C0#, 16#3C#, 16#01#, 16#C1#, 16#D8#, 16#01#, 16#FF#, 16#20#, 16#01#, 16#F8#, 16#40#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#C0#, 16#18#, 16#03#, 16#80#, 16#30#, 16#06#, 16#00#, 16#E0#, 16#0C#, 16#01#, 16#80#, 16#18#, 16#03#, 16#00#, 16#70#, 16#06#, 16#00#, 16#E0#, 16#0C#, 16#01#, 16#80#, 16#38#, 16#03#, 16#FF#, 16#E0#, 16#07#, 16#FF#, 16#C0#, 16#1C#, 16#01#, 16#80#, 16#38#, 16#07#, 16#00#, 16#60#, 16#0E#, 16#00#, 16#C0#, 16#18#, 16#01#, 16#80#, 16#30#, 16#07#, 16#00#, 16#60#, 16#0E#, 16#01#, 16#C0#, 16#18#, 16#03#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#0E#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#03#, 16#80#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#00#, 16#00#, 16#0E#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#03#, 16#80#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#E0#, 16#01#, 16#C1#, 16#80#, 16#03#, 16#83#, 16#00#, 16#06#, 16#0E#, 16#00#, 16#0E#, 16#38#, 16#00#, 16#0F#, 16#F0#, 16#00#, 16#0F#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#C0#, 16#38#, 16#03#, 16#80#, 16#E0#, 16#06#, 16#03#, 16#80#, 16#0C#, 16#0C#, 16#00#, 16#18#, 16#70#, 16#00#, 16#71#, 16#C0#, 16#00#, 16#E7#, 16#00#, 16#01#, 16#9C#, 16#00#, 16#03#, 16#78#, 16#00#, 16#07#, 16#B8#, 16#00#, 16#1E#, 16#30#, 16#00#, 16#38#, 16#70#, 16#00#, 16#60#, 16#60#, 16#00#, 16#C0#, 16#E0#, 16#01#, 16#80#, 16#C0#, 16#07#, 16#01#, 16#C0#, 16#0C#, 16#01#, 16#80#, 16#18#, 16#03#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#03#, 16#80#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#70#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#38#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#07#, 16#00#, 16#00#, 16#0F#, 16#FE#, 16#00#, 16#1F#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#E0#, 16#07#, 16#03#, 16#C0#, 16#1E#, 16#07#, 16#80#, 16#3C#, 16#0F#, 16#00#, 16#F0#, 16#1E#, 16#01#, 16#E0#, 16#7C#, 16#06#, 16#C0#, 16#EC#, 16#1D#, 16#81#, 16#98#, 16#37#, 16#03#, 16#30#, 16#EC#, 16#06#, 16#61#, 16#98#, 16#1C#, 16#C6#, 16#30#, 16#31#, 16#8C#, 16#60#, 16#63#, 16#31#, 16#C0#, 16#C6#, 16#63#, 16#01#, 16#87#, 16#86#, 16#07#, 16#0F#, 16#0C#, 16#0C#, 16#1C#, 16#18#, 16#18#, 16#38#, 16#70#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#C0#, 16#18#, 16#03#, 16#C0#, 16#30#, 16#07#, 16#80#, 16#60#, 16#0F#, 16#81#, 16#C0#, 16#1F#, 16#03#, 16#00#, 16#76#, 16#06#, 16#00#, 16#EE#, 16#0C#, 16#01#, 16#8C#, 16#18#, 16#03#, 16#1C#, 16#70#, 16#06#, 16#38#, 16#C0#, 16#1C#, 16#31#, 16#80#, 16#30#, 16#73#, 16#00#, 16#60#, 16#66#, 16#00#, 16#C0#, 16#FC#, 16#01#, 16#80#, 16#F0#, 16#07#, 16#01#, 16#E0#, 16#0C#, 16#03#, 16#C0#, 16#18#, 16#03#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#7F#, 16#E0#, 16#03#, 16#C1#, 16#E0#, 16#0E#, 16#01#, 16#C0#, 16#18#, 16#01#, 16#80#, 16#60#, 16#03#, 16#81#, 16#C0#, 16#07#, 16#03#, 16#00#, 16#0E#, 16#06#, 16#00#, 16#1C#, 16#0C#, 16#00#, 16#30#, 16#38#, 16#00#, 16#60#, 16#70#, 16#00#, 16#C0#, 16#E0#, 16#03#, 16#00#, 16#C0#, 16#0E#, 16#01#, 16#C0#, 16#38#, 16#01#, 16#C0#, 16#E0#, 16#01#, 16#FF#, 16#80#, 16#01#, 16#FC#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#80#, 16#03#, 16#FF#, 16#C0#, 16#06#, 16#03#, 16#80#, 16#0C#, 16#03#, 16#00#, 16#18#, 16#06#, 16#00#, 16#70#, 16#0C#, 16#00#, 16#E0#, 16#38#, 16#01#, 16#80#, 16#E0#, 16#03#, 16#FF#, 16#80#, 16#07#, 16#FE#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#07#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#7F#, 16#E0#, 16#03#, 16#C1#, 16#E0#, 16#0E#, 16#01#, 16#C0#, 16#18#, 16#01#, 16#C0#, 16#60#, 16#03#, 16#81#, 16#C0#, 16#07#, 16#03#, 16#00#, 16#0E#, 16#06#, 16#00#, 16#1C#, 16#0C#, 16#00#, 16#30#, 16#38#, 16#00#, 16#60#, 16#70#, 16#01#, 16#C0#, 16#60#, 16#03#, 16#00#, 16#C0#, 16#4E#, 16#01#, 16#C0#, 16#F8#, 16#01#, 16#C1#, 16#E0#, 16#01#, 16#FF#, 16#C0#, 16#01#, 16#F8#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FF#, 16#C0#, 16#03#, 16#FF#, 16#E0#, 16#06#, 16#01#, 16#C0#, 16#0C#, 16#01#, 16#80#, 16#18#, 16#03#, 16#00#, 16#70#, 16#06#, 16#00#, 16#E0#, 16#18#, 16#01#, 16#80#, 16#70#, 16#03#, 16#FF#, 16#80#, 16#07#, 16#FF#, 16#80#, 16#1C#, 16#07#, 16#00#, 16#38#, 16#06#, 16#00#, 16#60#, 16#0C#, 16#00#, 16#C0#, 16#18#, 16#01#, 16#80#, 16#70#, 16#07#, 16#00#, 16#E0#, 16#0C#, 16#01#, 16#C0#, 16#18#, 16#03#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#3F#, 16#00#, 16#01#, 16#FF#, 16#80#, 16#07#, 16#87#, 16#80#, 16#0C#, 16#03#, 16#00#, 16#38#, 16#06#, 16#00#, 16#60#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#01#, 16#E0#, 16#00#, 16#01#, 16#FC#, 16#00#, 16#00#, 16#FE#, 16#00#, 16#00#, 16#1E#, 16#00#, 16#00#, 16#0E#, 16#00#, 16#C0#, 16#0C#, 16#01#, 16#80#, 16#38#, 16#03#, 16#00#, 16#60#, 16#07#, 16#83#, 16#80#, 16#07#, 16#FE#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#FF#, 16#F0#, 16#07#, 16#FF#, 16#E0#, 16#00#, 16#70#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#07#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#01#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#C0#, 16#18#, 16#03#, 16#80#, 16#30#, 16#06#, 16#00#, 16#E0#, 16#0C#, 16#01#, 16#80#, 16#18#, 16#03#, 16#00#, 16#30#, 16#06#, 16#00#, 16#E0#, 16#0C#, 16#01#, 16#80#, 16#38#, 16#03#, 16#00#, 16#60#, 16#06#, 16#00#, 16#C0#, 16#0C#, 16#01#, 16#80#, 16#38#, 16#07#, 16#00#, 16#60#, 16#0E#, 16#00#, 16#C0#, 16#18#, 16#01#, 16#80#, 16#70#, 16#03#, 16#C1#, 16#C0#, 16#03#, 16#FF#, 16#00#, 16#01#, 16#F8#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#00#, 16#38#, 16#07#, 16#00#, 16#60#, 16#0E#, 16#01#, 16#C0#, 16#0C#, 16#03#, 16#00#, 16#18#, 16#0C#, 16#00#, 16#30#, 16#18#, 16#00#, 16#60#, 16#60#, 16#00#, 16#C1#, 16#C0#, 16#01#, 16#C3#, 16#00#, 16#03#, 16#8E#, 16#00#, 16#03#, 16#18#, 16#00#, 16#06#, 16#70#, 16#00#, 16#0C#, 16#C0#, 16#00#, 16#1B#, 16#80#, 16#00#, 16#36#, 16#00#, 16#00#, 16#78#, 16#00#, 16#00#, 16#F0#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#80#, 16#C0#, 16#07#, 16#03#, 16#80#, 16#0E#, 16#07#, 16#02#, 16#1C#, 16#1E#, 16#04#, 16#38#, 16#3C#, 16#18#, 16#70#, 16#D8#, 16#30#, 16#E1#, 16#B0#, 16#61#, 16#C6#, 16#31#, 16#83#, 16#8C#, 16#63#, 16#07#, 16#30#, 16#CE#, 16#06#, 16#61#, 16#98#, 16#0D#, 16#83#, 16#70#, 16#1B#, 16#06#, 16#C0#, 16#3E#, 16#0D#, 16#80#, 16#78#, 16#1E#, 16#00#, 16#F0#, 16#3C#, 16#01#, 16#C0#, 16#70#, 16#03#, 16#80#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#C0#, 16#38#, 16#03#, 16#80#, 16#E0#, 16#03#, 16#03#, 16#80#, 16#07#, 16#0E#, 16#00#, 16#06#, 16#38#, 16#00#, 16#0E#, 16#60#, 16#00#, 16#0D#, 16#80#, 16#00#, 16#1E#, 16#00#, 16#00#, 16#3C#, 16#00#, 16#00#, 16#78#, 16#00#, 16#01#, 16#F0#, 16#00#, 16#07#, 16#70#, 16#00#, 16#1C#, 16#E0#, 16#00#, 16#70#, 16#C0#, 16#00#, 16#C1#, 16#C0#, 16#03#, 16#01#, 16#80#, 16#0E#, 16#03#, 16#80#, 16#38#, 16#03#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#03#, 16#80#, 16#18#, 16#03#, 16#00#, 16#60#, 16#07#, 16#01#, 16#C0#, 16#0E#, 16#07#, 16#00#, 16#0C#, 16#1C#, 16#00#, 16#1C#, 16#30#, 16#00#, 16#18#, 16#C0#, 16#00#, 16#3B#, 16#80#, 16#00#, 16#7E#, 16#00#, 16#00#, 16#78#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#01#, 16#C0#, 16#00#, 16#03#, 16#80#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#70#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#FF#, 16#F0#, 16#03#, 16#FF#, 16#C0#, 16#00#, 16#03#, 16#80#, 16#00#, 16#0E#, 16#00#, 16#00#, 16#38#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#03#, 16#80#, 16#00#, 16#0E#, 16#00#, 16#00#, 16#38#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#03#, 16#80#, 16#00#, 16#0E#, 16#00#, 16#00#, 16#38#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#06#, 16#00#, 16#00#, 16#1F#, 16#FF#, 16#00#, 16#3F#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#F0#, 16#00#, 16#03#, 16#C0#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#07#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#02#, 16#00#, 16#00#, 16#04#, 16#00#, 16#00#, 16#08#, 16#00#, 16#00#, 16#10#, 16#00#, 16#00#, 16#20#, 16#00#, 16#00#, 16#40#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#02#, 16#00#, 16#00#, 16#04#, 16#00#, 16#00#, 16#08#, 16#00#, 16#00#, 16#10#, 16#00#, 16#00#, 16#20#, 16#00#, 16#00#, 16#40#, 16#00#, 16#00#, 16#80#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#80#, 16#00#, 16#0F#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#03#, 16#80#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#60#, 16#00#, 16#01#, 16#C0#, 16#00#, 16#03#, 16#C0#, 16#00#, 16#0D#, 16#80#, 16#00#, 16#13#, 16#00#, 16#00#, 16#62#, 16#00#, 16#01#, 16#84#, 16#00#, 16#03#, 16#0C#, 16#00#, 16#0C#, 16#18#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#FF#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#03#, 16#00#, 16#00#, 16#02#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#7F#, 16#80#, 16#01#, 16#C3#, 16#80#, 16#03#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#38#, 16#00#, 16#1F#, 16#F0#, 16#00#, 16#78#, 16#60#, 16#01#, 16#81#, 16#80#, 16#03#, 16#03#, 16#00#, 16#06#, 16#1E#, 16#00#, 16#0F#, 16#EE#, 16#00#, 16#0F#, 16#9C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#67#, 16#80#, 16#00#, 16#FF#, 16#80#, 16#01#, 16#C3#, 16#80#, 16#07#, 16#03#, 16#00#, 16#0E#, 16#06#, 16#00#, 16#18#, 16#0C#, 16#00#, 16#30#, 16#18#, 16#00#, 16#60#, 16#30#, 16#01#, 16#C0#, 16#C0#, 16#03#, 16#81#, 16#80#, 16#07#, 16#8E#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#13#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#00#, 16#00#, 16#7F#, 16#80#, 16#01#, 16#C7#, 16#00#, 16#07#, 16#06#, 16#00#, 16#0C#, 16#0C#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#03#, 16#00#, 16#07#, 16#0E#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#1F#, 16#30#, 16#00#, 16#7F#, 16#C0#, 16#01#, 16#C7#, 16#80#, 16#06#, 16#07#, 16#00#, 16#0C#, 16#0E#, 16#00#, 16#30#, 16#1C#, 16#00#, 16#60#, 16#30#, 16#00#, 16#C0#, 16#60#, 16#01#, 16#80#, 16#C0#, 16#03#, 16#03#, 16#80#, 16#07#, 16#0E#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#07#, 16#98#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#00#, 16#00#, 16#7F#, 16#80#, 16#01#, 16#C3#, 16#00#, 16#06#, 16#07#, 16#00#, 16#0C#, 16#06#, 16#00#, 16#3F#, 16#FC#, 16#00#, 16#7F#, 16#F0#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#03#, 16#80#, 16#07#, 16#0E#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#60#, 16#00#, 16#01#, 16#C0#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#38#, 16#00#, 16#00#, 16#F8#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#0E#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#20#, 16#00#, 16#7F#, 16#C0#, 16#01#, 16#C7#, 16#80#, 16#07#, 16#07#, 16#00#, 16#0C#, 16#0E#, 16#00#, 16#30#, 16#18#, 16#00#, 16#60#, 16#30#, 16#00#, 16#C0#, 16#60#, 16#01#, 16#81#, 16#C0#, 16#03#, 16#03#, 16#00#, 16#07#, 16#1E#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#07#, 16#98#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#01#, 16#83#, 16#00#, 16#03#, 16#FE#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#67#, 16#80#, 16#00#, 16#FF#, 16#80#, 16#01#, 16#C3#, 16#00#, 16#07#, 16#07#, 16#00#, 16#0C#, 16#0C#, 16#00#, 16#18#, 16#18#, 16#00#, 16#30#, 16#30#, 16#00#, 16#60#, 16#60#, 16#01#, 16#81#, 16#C0#, 16#03#, 16#03#, 16#00#, 16#06#, 16#06#, 16#00#, 16#0C#, 16#0C#, 16#00#, 16#18#, 16#18#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#01#, 16#C0#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#03#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#01#, 16#C0#, 16#00#, 16#07#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#C0#, 16#00#, 16#C3#, 16#00#, 16#01#, 16#9C#, 16#00#, 16#06#, 16#70#, 16#00#, 16#0D#, 16#C0#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#3B#, 16#80#, 16#00#, 16#63#, 16#00#, 16#01#, 16#86#, 16#00#, 16#03#, 16#0E#, 16#00#, 16#06#, 16#0C#, 16#00#, 16#0C#, 16#18#, 16#00#, 16#18#, 16#18#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#6F#, 16#8F#, 16#00#, 16#FF#, 16#3F#, 16#01#, 16#C7#, 16#86#, 16#07#, 16#06#, 16#0C#, 16#0C#, 16#0C#, 16#18#, 16#18#, 16#30#, 16#30#, 16#30#, 16#60#, 16#E0#, 16#60#, 16#C1#, 16#81#, 16#81#, 16#83#, 16#03#, 16#03#, 16#06#, 16#06#, 16#0C#, 16#0C#, 16#0C#, 16#18#, 16#30#, 16#18#, 16#30#, 16#60#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#6F#, 16#80#, 16#00#, 16#FF#, 16#80#, 16#01#, 16#C3#, 16#00#, 16#07#, 16#07#, 16#00#, 16#0C#, 16#0C#, 16#00#, 16#18#, 16#18#, 16#00#, 16#30#, 16#30#, 16#00#, 16#60#, 16#60#, 16#01#, 16#81#, 16#C0#, 16#03#, 16#03#, 16#00#, 16#06#, 16#06#, 16#00#, 16#0C#, 16#0C#, 16#00#, 16#18#, 16#18#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#0F#, 16#00#, 16#00#, 16#7F#, 16#80#, 16#01#, 16#C3#, 16#00#, 16#07#, 16#07#, 16#00#, 16#0C#, 16#06#, 16#00#, 16#38#, 16#0C#, 16#00#, 16#60#, 16#38#, 16#00#, 16#C0#, 16#60#, 16#01#, 16#80#, 16#C0#, 16#03#, 16#03#, 16#00#, 16#07#, 16#0E#, 16#00#, 16#07#, 16#F8#, 16#00#, 16#07#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#67#, 16#80#, 16#00#, 16#FF#, 16#80#, 16#01#, 16#C3#, 16#80#, 16#07#, 16#03#, 16#00#, 16#0E#, 16#06#, 16#00#, 16#18#, 16#0C#, 16#00#, 16#30#, 16#18#, 16#00#, 16#60#, 16#30#, 16#01#, 16#C0#, 16#E0#, 16#03#, 16#81#, 16#80#, 16#07#, 16#8E#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#3B#, 16#E0#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#20#, 16#00#, 16#7F#, 16#C0#, 16#01#, 16#C7#, 16#80#, 16#06#, 16#07#, 16#00#, 16#0C#, 16#0E#, 16#00#, 16#30#, 16#18#, 16#00#, 16#60#, 16#30#, 16#00#, 16#C0#, 16#60#, 16#01#, 16#81#, 16#C0#, 16#03#, 16#03#, 16#80#, 16#07#, 16#0E#, 16#00#, 16#07#, 16#FC#, 16#00#, 16#07#, 16#98#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#6E#, 16#00#, 16#00#, 16#FC#, 16#00#, 16#01#, 16#C0#, 16#00#, 16#07#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#1F#, 16#00#, 16#00#, 16#FF#, 16#00#, 16#03#, 16#86#, 16#00#, 16#06#, 16#0C#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#1E#, 16#00#, 16#00#, 16#1F#, 16#80#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#03#, 16#80#, 16#07#, 16#03#, 16#00#, 16#06#, 16#0C#, 16#00#, 16#0F#, 16#F8#, 16#00#, 16#0F#, 16#C0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#F8#, 16#00#, 16#03#, 16#F0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#03#, 16#80#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0F#, 16#00#, 16#00#, 16#0E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#60#, 16#60#, 16#00#, 16#C0#, 16#C0#, 16#01#, 16#81#, 16#80#, 16#06#, 16#06#, 16#00#, 16#0C#, 16#0C#, 16#00#, 16#18#, 16#18#, 16#00#, 16#30#, 16#30#, 16#00#, 16#60#, 16#60#, 16#01#, 16#81#, 16#80#, 16#03#, 16#03#, 16#00#, 16#07#, 16#1E#, 16#00#, 16#0F#, 16#FC#, 16#00#, 16#0F#, 16#98#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#C0#, 16#60#, 16#01#, 16#81#, 16#C0#, 16#03#, 16#03#, 16#00#, 16#07#, 16#0C#, 16#00#, 16#06#, 16#18#, 16#00#, 16#0C#, 16#60#, 16#00#, 16#18#, 16#C0#, 16#00#, 16#33#, 16#00#, 16#00#, 16#6C#, 16#00#, 16#00#, 16#D8#, 16#00#, 16#01#, 16#E0#, 16#00#, 16#01#, 16#C0#, 16#00#, 16#03#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#C1#, 16#C3#, 16#81#, 16#87#, 16#86#, 16#03#, 16#0F#, 16#1C#, 16#06#, 16#16#, 16#30#, 16#0C#, 16#6C#, 16#E0#, 16#18#, 16#D9#, 16#80#, 16#33#, 16#33#, 16#00#, 16#66#, 16#6C#, 16#00#, 16#58#, 16#D8#, 16#00#, 16#F1#, 16#E0#, 16#01#, 16#C3#, 16#C0#, 16#03#, 16#87#, 16#00#, 16#06#, 16#0E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#60#, 16#E0#, 16#00#, 16#C3#, 16#80#, 16#01#, 16#C6#, 16#00#, 16#01#, 16#98#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#03#, 16#80#, 16#00#, 16#06#, 16#00#, 16#00#, 16#1E#, 16#00#, 16#00#, 16#7C#, 16#00#, 16#01#, 16#CC#, 16#00#, 16#03#, 16#18#, 16#00#, 16#0C#, 16#38#, 16#00#, 16#30#, 16#30#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#C0#, 16#E0#, 16#01#, 16#81#, 16#80#, 16#03#, 16#07#, 16#00#, 16#06#, 16#0C#, 16#00#, 16#0E#, 16#30#, 16#00#, 16#0C#, 16#60#, 16#00#, 16#19#, 16#80#, 16#00#, 16#33#, 16#00#, 16#00#, 16#6C#, 16#00#, 16#00#, 16#D0#, 16#00#, 16#01#, 16#E0#, 16#00#, 16#03#, 16#80#, 16#00#, 16#07#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#60#, 16#00#, 16#07#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#7F#, 16#C0#, 16#00#, 16#FF#, 16#80#, 16#00#, 16#07#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#60#, 16#00#, 16#01#, 16#80#, 16#00#, 16#06#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#60#, 16#00#, 16#01#, 16#80#, 16#00#, 16#06#, 16#00#, 16#00#, 16#1F#, 16#F8#, 16#00#, 16#3F#, 16#F0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#10#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#70#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#00#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#20#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#E0#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#80#, 16#00#, 16#01#, 16#00#, 16#00#, 16#02#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#20#, 16#00#, 16#00#, 16#40#, 16#00#, 16#00#, 16#80#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#08#, 16#00#, 16#00#, 16#10#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#02#, 16#00#, 16#00#, 16#04#, 16#00#, 16#00#, 16#18#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#40#, 16#00#, 16#00#, 16#80#, 16#00#, 16#01#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#07#, 16#00#, 16#00#, 16#0F#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#08#, 16#00#, 16#00#, 16#30#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#02#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0E#, 16#00#, 16#00#, 16#1C#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#03#, 16#00#, 16#00#, 16#06#, 16#00#, 16#00#, 16#0C#, 16#00#, 16#00#, 16#10#, 16#00#, 16#00#, 16#60#, 16#00#, 16#00#, 16#C0#, 16#00#, 16#01#, 16#80#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#E0#, 16#00#, 16#03#, 16#E0#, 16#00#, 16#0C#, 16#E2#, 16#00#, 16#00#, 16#FC#, 16#00#, 16#00#, 16#70#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#); Font_D : aliased constant Bitmap_Font := ( Bytes_Per_Glyph => 81, Glyph_Width => 23, Glyph_Height => 28, Data => FreeSansOblique12pt7bBitmaps'Access); Font : constant Bitmap_Font_Ref := Font_D'Access; end GESTE_Fonts.FreeSansOblique12pt7b;
----------------------------------------------------------------------- -- Generic Quicksort procedure ----------------------------------------------------------------------- procedure Sort (Item : in out Element_Array) is procedure Swap(Left, Right : in out Element_Type) is Temp : Element_Type := Left; begin Left := Right; Right := Temp; end Swap; Pivot_Index : Index_Type; Pivot_Value : Element_Type; Right : Index_Type := Item'Last; Left : Index_Type := Item'First; begin if Item'Length > 1 then Pivot_Index := Index_Type'Val((Index_Type'Pos(Item'Last) + 1 + Index_Type'Pos(Item'First)) / 2); Pivot_Value := Item(Pivot_Index); Left := Item'First; Right := Item'Last; loop while Left < Item'Last and then Item(Left) < Pivot_Value loop Left := Index_Type'Succ(Left); end loop; while Right > Item'First and then Item(Right) > Pivot_Value loop Right := Index_Type'Pred(Right); end loop; exit when Left >= Right; Swap(Item(Left), Item(Right)); if Left < Item'Last then Left := Index_Type'Succ(Left); end if; if Right > Item'First then Right := Index_Type'Pred(Right); end if; end loop; if Right > Item'First then Sort(Item(Item'First..Index_Type'Pred(Right))); end if; if Left < Item'Last then Sort(Item(Left..Item'Last)); end if; end if; end Sort;
-- Program Circle -- Author Roger Mc Murtrie -- Created 16 November 2017 with Ada.Exceptions; use Ada.Exceptions; with Ada.Text_IO; use Ada.Text_IO; with Glfw; with Glfw.Windows; with Initialize; with Main_Loop; procedure Circle is Main_Window : Glfw.Windows.Window; Window_Title : constant String := "GA for Computer Scientists Example 1.1 An Example in Geometric Algebra"; begin Glfw.Init; Initialize (Main_Window, Window_Title); Main_Loop (Main_Window); Glfw.Shutdown; exception when anError : Constraint_Error => Put ("Circle returned constraint error: "); Put_Line (Exception_Information (anError)); when anError : others => Put_Line ("An exception occurred in Circle."); Put_Line (Exception_Information (anError)); end Circle;
with agar.core.types; with agar.gui.rect; with agar.gui.widget; with agar.gui.window; with interfaces.c.strings; package agar.gui.style is package cs renames interfaces.c.strings; type version_t is record major : c.int; minor : c.int; end record; type version_access_t is access all version_t; pragma convention (c, version_t); pragma convention (c, version_access_t); type style_t; type style_access_t is access all style_t; type style_t is record name : cs.chars_ptr; version : version_t; init : access procedure (style : style_access_t); destroy : access procedure (style : style_access_t); window : access procedure (window : agar.gui.window.window_access_t); titlebar_background : access procedure (widget : agar.gui.widget.widget_access_t; is_pressed : c.int; is_focused : c.int); button_background : access procedure (widget : agar.gui.widget.widget_access_t; is_pressed : c.int); button_text_offset : access procedure (widget : agar.gui.widget.widget_access_t; is_pressed : c.int; x : access c.int; y : access c.int); box_frame : access procedure (widget : agar.gui.widget.widget_access_t; depth : c.int); checkbox_button : access procedure (widget : agar.gui.widget.widget_access_t; state : c.int); console_background : access procedure (widget : agar.gui.widget.widget_access_t; bg : agar.core.types.uint32_t); fixed_plotter_background : access procedure (widget : agar.gui.widget.widget_access_t; show_axis : c.int; y_offset : agar.core.types.uint32_t); menu_root_background : access procedure (widget : agar.gui.widget.widget_access_t); menu_root_selected_item_background : access procedure (widget : agar.gui.widget.widget_access_t; rect : agar.gui.rect.rect_t); menu_background : access procedure (widget : agar.gui.widget.widget_access_t; rect : agar.gui.rect.rect_t); menu_item_background : access procedure (widget : agar.gui.widget.widget_access_t; rect : agar.gui.rect.rect_t; x_icon : c.int; icon_obj : agar.gui.widget.widget_access_t; icon : c.int; is_selected : c.int; bool_state : c.int); menu_item_separator : access procedure (widget : agar.gui.widget.widget_access_t; x1 : c.int; x2 : c.int; y : c.int; h : c.int); notebook_background : access procedure (widget : agar.gui.widget.widget_access_t; rect : agar.gui.rect.rect_t); notebook_tab_background : access procedure (widget : agar.gui.widget.widget_access_t; rect : agar.gui.rect.rect_t; index : c.int; is_selected : c.int); pane_horizontal_divider : access procedure (widget : agar.gui.widget.widget_access_t; x : c.int; y : c.int; w : c.int; h : c.int; is_moving : c.int); pane_vertical_divider : access procedure (widget : agar.gui.widget.widget_access_t; x : c.int; y : c.int; w : c.int; h : c.int; is_moving : c.int); radio_group_background : access procedure (widget : agar.gui.widget.widget_access_t; rect : agar.gui.rect.rect_t); radio_button : access procedure (widget : agar.gui.widget.widget_access_t; -- XXX: AG_Radio * x : c.int; y : c.int; selected : c.int; over : c.int); progress_bar_background : access procedure (widget : agar.gui.widget.widget_access_t); scrollbar_vertical : access procedure (widget : agar.gui.widget.widget_access_t; -- XXX: AG_Scrollbar * y : c.int; h : c.int); scrollbar_horizontal : access procedure (widget : agar.gui.widget.widget_access_t; -- XXX: AG_Scrollbar * x : c.int; w : c.int); slider_background_horizontal : access procedure (widget : agar.gui.widget.widget_access_t); slider_background_vertical : access procedure (widget : agar.gui.widget.widget_access_t); slider_control_horizontal : access procedure (widget : agar.gui.widget.widget_access_t; x : c.int; y : c.int); slider_control_vertical : access procedure (widget : agar.gui.widget.widget_access_t; y : c.int; h : c.int); separator_horizontal : access procedure (widget : agar.gui.widget.widget_access_t); -- XXX: AG_Separator * separator_vertical : access procedure (widget : agar.gui.widget.widget_access_t); -- XXX: AG_Separator * socket_background : access procedure (widget : agar.gui.widget.widget_access_t); -- XXX: AG_Socket * socket_overlay : access procedure (widget : agar.gui.widget.widget_access_t; -- XXX: AG_Socket * highlight : c.int); table_background : access procedure (widget : agar.gui.widget.widget_access_t; rect : agar.gui.rect.rect_t); table_column_header_background : access procedure (widget : agar.gui.widget.widget_access_t; index : c.int; rect : agar.gui.rect.rect_t; is_selected : c.int); table_selected_column_background : access procedure (widget : agar.gui.widget.widget_access_t; index : c.int; rect : agar.gui.rect.rect_t); table_row_background : access procedure (widget : agar.gui.widget.widget_access_t; rect : agar.gui.rect.rect_t; is_selected : c.int); textbox_background : access procedure (widget : agar.gui.widget.widget_access_t; rect : agar.gui.rect.rect_t; is_combo : c.int); list_background : access procedure (widget : agar.gui.widget.widget_access_t; rect : agar.gui.rect.rect_t); list_item_background : access procedure (widget : agar.gui.widget.widget_access_t; rect : agar.gui.rect.rect_t; is_selected : c.int); tree_subnode_indicator : access procedure (widget : agar.gui.widget.widget_access_t; rect : agar.gui.rect.rect_t; is_expanded : c.int); end record; pragma convention (c, style_t); pragma convention (c, style_access_t); procedure set_style (widget : agar.gui.widget.widget_access_t; style : style_access_t); procedure set_style (widget : agar.gui.window.window_access_t; style : style_access_t); pragma import (c, set_style, "AG_SetStyle"); end agar.gui.style;
-- The Village of Vampire by YT, このソースコードはNYSLです with Ada.Calendar; with Ada.Strings.Unbounded; with Tabula.Casts; package Tabula.Villages is -- 村のID subtype Village_Id is String (1 .. 4); Invalid_Village_Id : constant Village_Id := "****"; -- 村の状態 type Village_Term is (Short, Long); -- 短期 or 長期 type Village_State is (Prologue, Playing, Epilogue, Closed); -- 参加者 type Person_Type is new Casts.Person with record Id : aliased Ada.Strings.Unbounded.Unbounded_String; end record; subtype Person_Index is Natural; No_Person : constant Person_Index'Base := -1; function Same_Id_And_Figure (Left, Right : Person_Type'Class) return Boolean; -- メッセージ subtype Message_Index is Natural; subtype Speech_Index is Natural; -- count only speeches type Speech_Range_Type is record First : Speech_Index; Last : Speech_Index'Base; end record; subtype Speech_Positive_Count is Speech_Index range 1 .. Speech_Index'Last; -- オプション type Village_Type is tagged; type Root_Option_Item is abstract tagged limited null record; function Available (Item : Root_Option_Item) return Boolean is abstract; function Name (Item : Root_Option_Item) return String is abstract; function Changed (Item : Root_Option_Item) return Boolean is abstract; procedure Iterate ( Item : in Root_Option_Item; Process : not null access procedure ( Value : in String; Selected : in Boolean; Message : in String; Unrecommended : in Boolean)) is abstract; procedure Change ( Village : in out Village_Type'Class; Item : in Root_Option_Item; Value : in String) is abstract; -- 村 type Village_Type is abstract tagged limited record Name : aliased Ada.Strings.Unbounded.Unbounded_String; By : aliased Ada.Strings.Unbounded.Unbounded_String; -- 作成者 Face_Group : Integer := 0; -- 顔絵セット Face_Width : Integer := 0; Face_Height : Integer := 0; end record; function Term (Village : Village_Type) return Village_Term is abstract; procedure Get_State ( Village : in Village_Type; State : out Village_State; Today : out Natural) is abstract; -- Prologue = 0 procedure Iterate_People ( Village : in Village_Type; Process : not null access procedure ( Index : Person_Index; Item : in Person_Type'Class)) is abstract; procedure Iterate_Escaped_People ( Village : in Village_Type; Process : not null access procedure ( Index : Person_Index; Item : in Person_Type'Class)) is abstract; function Speech_Range ( Village : Village_Type; Day : Natural) return Speech_Range_Type is abstract; function Recent_Only_Speech_Range ( Village : Village_Type; Day : Natural; Now : Ada.Calendar.Time) return Speech_Range_Type is abstract; procedure Iterate_Options ( Village : in Village_Type; Process : not null access procedure (Item : in Root_Option_Item'Class)) is abstract; function Option_Changed (Village : Village_Type) return Boolean; -- 参加状況 function Joined (Village : Village_Type; User_Id : String) return Person_Index'Base; function Already_Joined_As_Another_Sex ( Village : Village_Type; User_Id : String; Sex : Casts.Person_Sex) return Boolean; function Male_And_Female (Village : Village_Type) return Boolean; -- 既に取られているものを除外 procedure Exclude_Taken ( Cast : in out Casts.Cast_Collection; Village : in Village_Type); end Tabula.Villages;
with System; package Stream is type Unsigned is mod 2 ** Integer'Size; type Stream is interface; procedure Put_String (S : Stream; Val : String) is abstract; procedure Put_Integer (S : Stream; Val : Integer; Width : Integer := 0; Base : Integer := 10) is abstract; procedure Put_Unsigned (S : Stream; Val : Unsigned; Width : Integer := 0; Base : Integer := 10) is abstract; end Stream;
pragma Ada_2012; package body DDS.Request_Reply.Connext_C_Replier is -------------------------------- -- RTI_Connext_Replier_Delete -- -------------------------------- function RTI_Connext_Replier_Delete (Self : RTI_Connext_Replier_Access) return DDS.ReturnCode_T is begin return raise Program_Error with "Unimplemented function RTI_Connext_Replier_Delete"; end RTI_Connext_Replier_Delete; ------------------------------------------- -- RTI_Connext_Replier_Wait_For_Requests -- ------------------------------------------- function RTI_Connext_Replier_Wait_For_Requests (Self : access RTI_Connext_Replier; Min_Count : DDS.Integer; Max_Wait : DDS.Duration_T) return DDS.ReturnCode_T is begin return raise Program_Error with "Unimplemented function RTI_Connext_Replier_Wait_For_Requests"; end RTI_Connext_Replier_Wait_For_Requests; ------------------------------------------- -- RTI_Connext_ReplierUntypedImpl_create -- ------------------------------------------- function RTI_Connext_ReplierUntypedImpl_create return RTI_Connext_ReplierUntypedImpl_Access is begin return raise Program_Error with "Unimplemented function RTI_Connext_ReplierUntypedImpl_create"; end RTI_Connext_ReplierUntypedImpl_create; ----------------------------------------------- -- RTI_Connext_ReplierUntypedImpl_Initialize -- ----------------------------------------------- function RTI_Connext_ReplierUntypedImpl_Initialize (Self : RTI_Connext_ReplierUntypedImpl; Params : RTI_Connext_EntityParams; Request_Type_Name : DDS.String; Reply_Type_Name : DDS.String; Request_Size : DDS.Integer; Reader_Listener : DDS.DataReaderListener.Ref_Access) return DDS .ReturnCode_T is begin return raise Program_Error with "Unimplemented function RTI_Connext_ReplierUntypedImpl_Initialize"; end RTI_Connext_ReplierUntypedImpl_Initialize; ------------------------------------------------ -- RTI_Connext_ReplierUntypedImpl_send_sample -- ------------------------------------------------ function RTI_Connext_ReplierUntypedImpl_send_sample (Self : RTI_Connext_ReplierUntypedImpl; Data : Interfaces.C.Extensions.Void_Ptr; Related_Request_Info : DDS.SampleIdentity_T; WriteParams : DDS.WriteParams_T) return DDS.ReturnCode_T is begin return raise Program_Error with "Unimplemented function RTI_Connext_ReplierUntypedImpl_send_sample"; end RTI_Connext_ReplierUntypedImpl_send_sample; ---------------------------------------------- -- RTI_Connext_ReplierParams_toEntityParams -- ---------------------------------------------- function RTI_Connext_ReplierParams_toEntityParams (Self : not null access RTI_Connext_ReplierParams; ToParams : out RTI_Connext_EntityParams) return DDS.ReturnCode_T is pragma Unreferenced (ToParams); begin return raise Program_Error with "Unimplemented function RTI_Connext_ReplierParams_toEntityParams"; end RTI_Connext_ReplierParams_toEntityParams; end DDS.Request_Reply.Connext_C_Replier;
with Ada.Assertions; use Ada.Assertions; with Ada.Strings; use Ada.Strings; with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Langkit_Support.Text; use Langkit_Support.Text; package body Rejuvenation.Indentation is function Node_On_Separate_Lines (Node : Ada_Node'Class) return Boolean is function First_Token_On_Line (Token : Token_Reference) return Boolean; function First_Token_On_Line (Token : Token_Reference) return Boolean is function Previous_Token_Not_On_Line (Token : Token_Reference) return Boolean; function Previous_Token_Not_On_Line (Token : Token_Reference) return Boolean is begin if Token = No_Token then return True; elsif Kind (Data (Token)) = Ada_Whitespace then declare Token_Text : constant String := Encode (Text (Token), Node.Unit.Get_Charset); begin return Index (Token_Text, (1 => ASCII.LF)) > 0 or else Previous_Token_Not_On_Line (Previous (Token)); end; else Assert (Check => Kind (Data (Token)) /= Ada_Comment, Message => "Comment is terminated by line end. " & "So no token can follow it on the same line"); return False; end if; end Previous_Token_Not_On_Line; begin return Previous_Token_Not_On_Line (Previous (Token)); end First_Token_On_Line; function Last_Token_On_Line (Token : Token_Reference) return Boolean; function Last_Token_On_Line (Token : Token_Reference) return Boolean is function Next_Token_Not_On_Line (Token : Token_Reference) return Boolean; function Next_Token_Not_On_Line (Token : Token_Reference) return Boolean is begin case Kind (Data (Token)) is when Ada_Termination => return True; when Ada_Comment => return Next_Token_Not_On_Line (Next (Token)); -- really checking on new line might not be needed, -- since comment in Ada is always terminated by a new line. when Ada_Whitespace => declare Token_Text : constant String := Encode (Text (Token), Node.Unit.Get_Charset); begin return Index (Token_Text, (1 => ASCII.LF)) > 0 or else Next_Token_Not_On_Line (Next (Token)); end; when others => return False; end case; end Next_Token_Not_On_Line; begin return Next_Token_Not_On_Line (Next (Token)); end Last_Token_On_Line; begin return First_Token_On_Line (Node.Token_Start) and then Last_Token_On_Line (Node.Token_End); end Node_On_Separate_Lines; function Indentation_Of_Node (Node : Ada_Node'Class) return Integer is function Indentatation_Of_Token (Token : Token_Reference; Nr : Integer) return Integer; function Indentatation_Of_Token (Token : Token_Reference; Nr : Integer) return Integer is begin if Token = No_Token then return Nr; elsif Kind (Data (Token)) = Ada_Whitespace then declare Token_Text : constant String := Encode (Text (Token), Node.Unit.Get_Charset); Pos : constant Natural := Index (Token_Text, (1 => ASCII.LF), Going => Backward); begin if Pos = 0 then return Indentatation_Of_Token (Previous (Token), Nr + Token_Text'Length); else return Nr + Token_Text'Last - Pos; end if; end; else return No_Indentation; end if; end Indentatation_Of_Token; begin return Indentatation_Of_Token (Previous (Node.Token_Start), 0); end Indentation_Of_Node; end Rejuvenation.Indentation;
-------------------------------------------------------------------------------- -- MIT License -- -- Copyright (c) 2020 Zane Myers -- -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to deal -- in the Software without restriction, including without limitation the rights -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the Software is -- furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in all -- copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -- SOFTWARE. -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- --< @group Vulkan Math Numerics -------------------------------------------------------------------------------- --< @summary --< This package instantiates Ada generic numerical operations for use by the --< Vulkan Math Library. --< --< @description --< The Ada Numerics Generic Elementary Functions are instantiated for the Vkm_Double --< and Vkm_Float types. Additional generic algorithms for Ada floating point types --< are provided. -------------------------------------------------------------------------------- package Vulkan.Math.Numerics is pragma Preelaborate; pragma Pure; ---------------------------------------------------------------------------- --< @summary --< Algorithm for computing the "modf" for a floating point type. --< --< @description --< This operation separates the floating point into its integer part and its --< fraction part. --< --< @param x --< Mixed integer and fraction number. --< --< @param i --< The integer part of 'x'. --< --< @return --< The fraction part of 'x' ---------------------------------------------------------------------------- generic type Floating_Point is digits <>; function Compute_Modf (x : in Floating_Point; i : out Floating_Point) return Floating_Point; ---------------------------------------------------------------------------- --< @summary --< Algorithm for computing a smooth step function. --< --< @description --< Computes smooth step as follows: --< t = Clamp((x - edge0) / (edge1 - edge0), 0, 1) --< t = t * t * (3 - 2 * t) --< return t --< --< @param edge0 --< The first edge to interpolate between. --< --< @param edge1 --< The second edge to interpolate between. --< --< @param x --< The value to apply the step function to. --< --< @return --< The smooth step function of x. ---------------------------------------------------------------------------- generic type Floating_Point is digits <>; with function Clamp (edge0, edge1, x : in Floating_Point) return Floating_Point; function Smooth_Step (edge0, edge1, x : in Floating_Point) return Floating_Point; ---------------------------------------------------------------------------- --< @summary --< Determine whether the input holds an Inf. --< --< @description --< Determine whether the input holds an Inf. Always returns false. --< --< @param x --< The value to test. --< --< @return --< False, always. ---------------------------------------------------------------------------- generic type Floating_Point is digits <>; function Is_Inf (x : in Floating_Point) return Vkm_Bool; ---------------------------------------------------------------------------- --< @summary --< Determine whether the input holds a NaN. --< --< @description --< Determine whether the input holds a NaN. Always returns false. --< --< @param x --< The value to test. --< --< @return --< False, always. ---------------------------------------------------------------------------- generic type Floating_Point is digits <>; function Is_Nan (x : in Floating_Point) return Vkm_Bool; ---------------------------------------------------------------------------- --< @summary --< Break a floating point value into its significand and exponent parts. --< --< @description --< Break a floating point value into its significand and exponent parts. --< --< @param x --< The input parameter.. --< --< @param exponent --< The exponent part of x. --< --< @return --< The significand part of x. ---------------------------------------------------------------------------- generic type Floating_Point is digits <>; function Frexp (x : in Floating_Point; exponent : out Vkm_Int) return Floating_Point; ---------------------------------------------------------------------------- --< @summary --< Form a floating point value from a significand and exponent. --< --< @description --< Form a floating point value from a significand and exponent. --< --< @param significand --< The significand. --< --< @param exponent --< The exponent. --< --< @return --< x = significand * 2^exponent. ---------------------------------------------------------------------------- generic type Floating_Point is digits <>; function Ldexp (significand : in Floating_Point; exponent : in Vkm_Int) return Floating_Point; end Vulkan.Math.Numerics;
-- -- ABench2020 Benchmark Suite -- -- Factorial Program -- -- Licensed under the MIT License. See LICENSE file in the ABench root -- directory for license information. -- -- Uncomment the line below to print the result. -- with Ada.Text_IO; use Ada.Text_IO; with Ada.Command_Line; use Ada.Command_Line; procedure Factorial is function Calculate_Factorial (Start_Value : Long_Integer; End_Value : Long_Integer) return Long_Integer is Result : Long_Integer := 1; begin for I in Long_Integer range Start_Value .. End_Value loop Result := Result * I; end loop; return Result; end; External_Value : Long_Integer := Long_Integer'Value (Ada.Command_Line.Argument (1)); Result : Long_Integer; begin loop Result := Calculate_Factorial (1, External_Value); end loop; -- Uncomment the line below to print the result. -- Put_Line (Integer'Image (Result)); end;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- M L I B . T G T -- -- (AIX Version) -- -- -- -- B o d y -- -- -- -- Copyright (C) 2003-2005, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package provides a set of target dependent routines to build -- static, dynamic or relocatable libraries. -- This is the AIX version of the body with Ada.Strings.Fixed; use Ada.Strings.Fixed; with MLib.Fil; with MLib.Utl; with Namet; use Namet; with Opt; with Output; use Output; with Prj.Com; with Prj.Util; use Prj.Util; package body MLib.Tgt is No_Arguments : aliased Argument_List := (1 .. 0 => null); Empty_Argument_List : constant Argument_List_Access := No_Arguments'Access; Bexpall : aliased String := "-Wl,-bexpall"; Bexpall_Option : constant String_Access := Bexpall'Access; -- The switch to export all symbols Lpthreads : aliased String := "-lpthreads"; Native_Thread_Options : aliased Argument_List := (1 => Lpthreads'Access); -- The switch to use when linking a library against libgnarl when using -- Native threads. Lgthreads : aliased String := "-lgthreads"; Lmalloc : aliased String := "-lmalloc"; FSU_Thread_Options : aliased Argument_List := (1 => Lgthreads'Access, 2 => Lmalloc'Access); -- The switches to use when linking a library against libgnarl when using -- FSU threads. Thread_Options : Argument_List_Access := Empty_Argument_List; -- Designate the thread switches to used when linking a library against -- libgnarl. Depends on the thread library (Native or FSU). Resolved for -- the first library linked against libgnarl. --------------------- -- Archive_Builder -- --------------------- function Archive_Builder return String is begin return "ar"; end Archive_Builder; ----------------------------- -- Archive_Builder_Options -- ----------------------------- function Archive_Builder_Options return String_List_Access is begin return new String_List'(1 => new String'("cr")); end Archive_Builder_Options; ----------------- -- Archive_Ext -- ----------------- function Archive_Ext return String is begin return "a"; end Archive_Ext; --------------------- -- Archive_Indexer -- --------------------- function Archive_Indexer return String is begin return "ranlib"; end Archive_Indexer; ----------------------------- -- Archive_Indexer_Options -- ----------------------------- function Archive_Indexer_Options return String_List_Access is begin return new String_List (1 .. 0); end Archive_Indexer_Options; --------------------------- -- Build_Dynamic_Library -- --------------------------- procedure Build_Dynamic_Library (Ofiles : Argument_List; Foreign : Argument_List; Afiles : Argument_List; Options : Argument_List; Options_2 : Argument_List; Interfaces : Argument_List; Lib_Filename : String; Lib_Dir : String; Symbol_Data : Symbol_Record; Driver_Name : Name_Id := No_Name; Lib_Version : String := ""; Auto_Init : Boolean := False) is pragma Unreferenced (Foreign); pragma Unreferenced (Afiles); pragma Unreferenced (Interfaces); pragma Unreferenced (Symbol_Data); pragma Unreferenced (Lib_Version); pragma Unreferenced (Auto_Init); Lib_File : constant String := Lib_Dir & Directory_Separator & "lib" & MLib.Fil.Ext_To (Lib_Filename, DLL_Ext); -- The file name of the library Thread_Opts : Argument_List_Access := Empty_Argument_List; -- Set to Thread_Options if -lgnarl is found in the Options begin if Opt.Verbose_Mode then Write_Str ("building relocatable shared library "); Write_Line (Lib_File); end if; -- Look for -lgnarl in Options. If found, set the thread options for J in Options'Range loop if Options (J).all = "-lgnarl" then -- If Thread_Options is null, read s-osinte.ads to discover the -- thread library and set Thread_Options accordingly. if Thread_Options = null then declare File : Text_File; Line : String (1 .. 100); Last : Natural; begin Open (File, Include_Dir_Default_Prefix & "/s-osinte.ads"); while not End_Of_File (File) loop Get_Line (File, Line, Last); if Index (Line (1 .. Last), "-lpthreads") /= 0 then Thread_Options := Native_Thread_Options'Access; exit; elsif Index (Line (1 .. Last), "-lgthreads") /= 0 then Thread_Options := FSU_Thread_Options'Access; exit; end if; end loop; Close (File); if Thread_Options = null then Prj.Com.Fail ("cannot find the thread library in use"); end if; exception when others => Prj.Com.Fail ("cannot open s-osinte.ads"); end; end if; Thread_Opts := Thread_Options; exit; end if; end loop; -- Finally, call GCC (or the driver specified) to build the library MLib.Utl.Gcc (Output_File => Lib_File, Objects => Ofiles, Options => Options & Bexpall_Option, Driver_Name => Driver_Name, Options_2 => Options_2 & Thread_Opts.all); end Build_Dynamic_Library; ------------- -- DLL_Ext -- ------------- function DLL_Ext return String is begin return "a"; end DLL_Ext; ---------------- -- DLL_Prefix -- ---------------- function DLL_Prefix return String is begin return "lib"; end DLL_Prefix; -------------------- -- Dynamic_Option -- -------------------- function Dynamic_Option return String is begin return "-shared"; end Dynamic_Option; ------------------- -- Is_Object_Ext -- ------------------- function Is_Object_Ext (Ext : String) return Boolean is begin return Ext = ".o"; end Is_Object_Ext; -------------- -- Is_C_Ext -- -------------- function Is_C_Ext (Ext : String) return Boolean is begin return Ext = ".c"; end Is_C_Ext; -------------------- -- Is_Archive_Ext -- -------------------- function Is_Archive_Ext (Ext : String) return Boolean is begin return Ext = ".a"; end Is_Archive_Ext; ------------- -- Libgnat -- ------------- function Libgnat return String is begin return "libgnat.a"; end Libgnat; ------------------------ -- Library_Exists_For -- ------------------------ function Library_Exists_For (Project : Project_Id; In_Tree : Project_Tree_Ref) return Boolean is begin if not In_Tree.Projects.Table (Project).Library then Prj.Com.Fail ("INTERNAL ERROR: Library_Exists_For called " & "for non library project"); return False; else declare Lib_Dir : constant String := Get_Name_String (In_Tree.Projects.Table (Project).Library_Dir); Lib_Name : constant String := Get_Name_String (In_Tree.Projects.Table (Project).Library_Name); begin if In_Tree.Projects.Table (Project).Library_Kind = Static then return Is_Regular_File (Lib_Dir & Directory_Separator & "lib" & Fil.Ext_To (Lib_Name, Archive_Ext)); else return Is_Regular_File (Lib_Dir & Directory_Separator & "lib" & Fil.Ext_To (Lib_Name, DLL_Ext)); end if; end; end if; end Library_Exists_For; --------------------------- -- Library_File_Name_For -- --------------------------- function Library_File_Name_For (Project : Project_Id; In_Tree : Project_Tree_Ref) return Name_Id is begin if not In_Tree.Projects.Table (Project).Library then Prj.Com.Fail ("INTERNAL ERROR: Library_File_Name_For called " & "for non library project"); return No_Name; else declare Lib_Name : constant String := Get_Name_String (In_Tree.Projects.Table (Project).Library_Name); begin Name_Len := 3; Name_Buffer (1 .. Name_Len) := "lib"; if In_Tree.Projects.Table (Project).Library_Kind = Static then Add_Str_To_Name_Buffer (Fil.Ext_To (Lib_Name, Archive_Ext)); else Add_Str_To_Name_Buffer (Fil.Ext_To (Lib_Name, DLL_Ext)); end if; return Name_Find; end; end if; end Library_File_Name_For; ---------------- -- Object_Ext -- ---------------- function Object_Ext return String is begin return "o"; end Object_Ext; ---------------- -- PIC_Option -- ---------------- function PIC_Option return String is begin return "-fPIC"; end PIC_Option; ----------------------------------------------- -- Standalone_Library_Auto_Init_Is_Supported -- ----------------------------------------------- function Standalone_Library_Auto_Init_Is_Supported return Boolean is begin return True; end Standalone_Library_Auto_Init_Is_Supported; --------------------------- -- Support_For_Libraries -- --------------------------- function Support_For_Libraries return Library_Support is begin return Static_Only; end Support_For_Libraries; end MLib.Tgt;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- A D A . R E A L _ T I M E -- -- -- -- B o d y -- -- -- -- Copyright (C) 1991-2017, Florida State University -- -- Copyright (C) 1995-2020, AdaCore -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ with System.Tasking; with Unchecked_Conversion; package body Ada.Real_Time with SPARK_Mode => Off is --------- -- "*" -- --------- -- Note that Constraint_Error may be propagated function "*" (Left : Time_Span; Right : Integer) return Time_Span is pragma Unsuppress (Overflow_Check); begin return Time_Span (Duration (Left) * Right); end "*"; function "*" (Left : Integer; Right : Time_Span) return Time_Span is pragma Unsuppress (Overflow_Check); begin return Time_Span (Left * Duration (Right)); end "*"; --------- -- "+" -- --------- -- Note that Constraint_Error may be propagated function "+" (Left : Time; Right : Time_Span) return Time is pragma Unsuppress (Overflow_Check); begin return Time (Duration (Left) + Duration (Right)); end "+"; function "+" (Left : Time_Span; Right : Time) return Time is pragma Unsuppress (Overflow_Check); begin return Time (Duration (Left) + Duration (Right)); end "+"; function "+" (Left, Right : Time_Span) return Time_Span is pragma Unsuppress (Overflow_Check); begin return Time_Span (Duration (Left) + Duration (Right)); end "+"; --------- -- "-" -- --------- -- Note that Constraint_Error may be propagated function "-" (Left : Time; Right : Time_Span) return Time is pragma Unsuppress (Overflow_Check); begin return Time (Duration (Left) - Duration (Right)); end "-"; function "-" (Left, Right : Time) return Time_Span is pragma Unsuppress (Overflow_Check); begin return Time_Span (Duration (Left) - Duration (Right)); end "-"; function "-" (Left, Right : Time_Span) return Time_Span is pragma Unsuppress (Overflow_Check); begin return Time_Span (Duration (Left) - Duration (Right)); end "-"; function "-" (Right : Time_Span) return Time_Span is pragma Unsuppress (Overflow_Check); begin return Time_Span_Zero - Right; end "-"; --------- -- "/" -- --------- -- Note that Constraint_Error may be propagated function "/" (Left, Right : Time_Span) return Integer is pragma Unsuppress (Overflow_Check); pragma Unsuppress (Division_Check); -- RM D.8 (27) specifies the effects of operators on Time_Span, and -- rounding of the division operator in particular, to be the same as -- effects on integer types. To get the correct rounding we first -- convert Time_Span to its root type Duration, which is represented as -- a 64-bit signed integer, and then use integer division. type Duration_Rep is range -(2 ** 63) .. +((2 ** 63 - 1)); function To_Integer is new Unchecked_Conversion (Duration, Duration_Rep); begin return Integer (To_Integer (Duration (Left)) / To_Integer (Duration (Right))); end "/"; function "/" (Left : Time_Span; Right : Integer) return Time_Span is pragma Unsuppress (Overflow_Check); pragma Unsuppress (Division_Check); begin -- Even though checks are unsuppressed, we need an explicit check for -- the case of largest negative integer divided by minus one, since -- some library routines we use fail to catch this case. This will be -- fixed at the compiler level in the future, at which point this test -- can be removed. if Left = Time_Span_First and then Right = -1 then raise Constraint_Error with "overflow"; end if; return Time_Span (Duration (Left) / Right); end "/"; ----------- -- Clock -- ----------- function Clock return Time is begin return Time (System.Task_Primitives.Operations.Monotonic_Clock); end Clock; ------------------ -- Microseconds -- ------------------ function Microseconds (US : Integer) return Time_Span is begin return Time_Span_Unit * US * 1_000; end Microseconds; ------------------ -- Milliseconds -- ------------------ function Milliseconds (MS : Integer) return Time_Span is begin return Time_Span_Unit * MS * 1_000_000; end Milliseconds; ------------- -- Minutes -- ------------- function Minutes (M : Integer) return Time_Span is begin return Milliseconds (M) * Integer'(60_000); end Minutes; ----------------- -- Nanoseconds -- ----------------- function Nanoseconds (NS : Integer) return Time_Span is begin return Time_Span_Unit * NS; end Nanoseconds; ------------- -- Seconds -- ------------- function Seconds (S : Integer) return Time_Span is begin return Milliseconds (S) * Integer'(1000); end Seconds; ----------- -- Split -- ----------- procedure Split (T : Time; SC : out Seconds_Count; TS : out Time_Span) is T_Val : Time; begin -- Special-case for Time_First, whose absolute value is anomalous, -- courtesy of two's complement. T_Val := (if T = Time_First then abs (Time_Last) else abs (T)); -- Extract the integer part of T, truncating towards zero SC := (if T_Val < 0.5 then 0 else Seconds_Count (Time_Span'(T_Val - 0.5))); if T < 0.0 then SC := -SC; end if; -- If original time is negative, need to truncate towards negative -- infinity, to make TS non-negative, as per ARM. if Time (SC) > T then SC := SC - 1; end if; TS := Time_Span (Duration (T) - Duration (SC)); end Split; ------------- -- Time_Of -- ------------- function Time_Of (SC : Seconds_Count; TS : Time_Span) return Time is pragma Suppress (Overflow_Check); pragma Suppress (Range_Check); -- We do all our own checks for this function -- This is not such a simple case, since TS is already 64 bits, and -- so we can't just promote everything to a wider type to ensure proper -- testing for overflow. The situation is that Seconds_Count is a MUCH -- wider type than Time_Span and Time (both of which have the underlying -- type Duration). -- <------------------- Seconds_Count --------------------> -- <-- Duration --> -- Now it is possible for an SC value outside the Duration range to -- be "brought back into range" by an appropriate TS value, but there -- are also clearly SC values that are completely out of range. Note -- that the above diagram is wildly out of scale, the difference in -- ranges is much greater than shown. -- We can't just go generating out of range Duration values to test for -- overflow, since Duration is a full range type, so we follow the steps -- shown below. SC_Lo : constant Seconds_Count := Seconds_Count (Duration (Time_Span_First) + Duration'(0.5)); SC_Hi : constant Seconds_Count := Seconds_Count (Duration (Time_Span_Last) - Duration'(0.5)); -- These are the maximum values of the seconds (integer) part of the -- Duration range. Used to compute and check the seconds in the result. TS_SC : Seconds_Count; -- Seconds part of input value TS_Fraction : Duration; -- Fractional part of input value, may be negative Result_SC : Seconds_Count; -- Seconds value for result Fudge : constant Seconds_Count := 10; -- Fudge value used to do end point checks far from end point FudgeD : constant Duration := Duration (Fudge); -- Fudge value as Duration Fudged_Result : Duration; -- Result fudged up or down by FudgeD procedure Out_Of_Range; pragma No_Return (Out_Of_Range); -- Raise exception for result out of range ------------------ -- Out_Of_Range -- ------------------ procedure Out_Of_Range is begin raise Constraint_Error with "result for Ada.Real_Time.Time_Of is out of range"; end Out_Of_Range; -- Start of processing for Time_Of begin -- If SC is so far out of range that there is no possibility of the -- addition of TS getting it back in range, raise an exception right -- away. That way we don't have to worry about SC values overflowing. if SC < 3 * SC_Lo or else SC > 3 * SC_Hi then Out_Of_Range; end if; -- Decompose input TS value TS_SC := Seconds_Count (Duration (TS)); TS_Fraction := Duration (TS) - Duration (TS_SC); -- Compute result seconds. If clearly out of range, raise error now Result_SC := SC + TS_SC; if Result_SC < (SC_Lo - 1) or else Result_SC > (SC_Hi + 1) then Out_Of_Range; end if; -- Now the result is simply Result_SC + TS_Fraction, but we can't just -- go computing that since it might be out of range. So what we do is -- to compute a value fudged down or up by 10.0 (arbitrary value, but -- that will do fine), and check that fudged value, and if in range -- unfudge it and return the result. -- Fudge positive result down, and check high bound if Result_SC > 0 then Fudged_Result := Duration (Result_SC - Fudge) + TS_Fraction; if Fudged_Result <= Duration'Last - FudgeD then return Time (Fudged_Result + FudgeD); else Out_Of_Range; end if; -- Same for negative values of seconds, fudge up and check low bound else Fudged_Result := Duration (Result_SC + Fudge) + TS_Fraction; if Fudged_Result >= Duration'First + FudgeD then return Time (Fudged_Result - FudgeD); else Out_Of_Range; end if; end if; end Time_Of; ----------------- -- To_Duration -- ----------------- function To_Duration (TS : Time_Span) return Duration is begin return Duration (TS); end To_Duration; ------------------ -- To_Time_Span -- ------------------ function To_Time_Span (D : Duration) return Time_Span is begin -- Note regarding AI-00432 requiring range checking on this conversion. -- In almost all versions of GNAT (and all to which this version of the -- Ada.Real_Time package apply), the range of Time_Span and Duration are -- the same, so there is no issue of overflow. return Time_Span (D); end To_Time_Span; begin -- Ensure that the tasking run time is initialized when using clock and/or -- delay operations. The initialization routine has the required machinery -- to prevent multiple calls to Initialize. System.Tasking.Initialize; end Ada.Real_Time;
-- SPDX-FileCopyrightText: 2020 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ---------------------------------------------------------------- with Ada.Containers.Generic_Anonymous_Array_Sort; with Ada.Iterator_Interfaces; with League.Characters; with League.Regexps; with Markdown.Common_Patterns; with Markdown.Inline_Parsers.Autolinks; with Markdown.Inline_Parsers.Code_Spans; with Markdown.Inline_Parsers.Raw_HTML; package body Markdown.Inline_Parsers is function "+" (Text : Wide_Wide_String) return League.Regexps.Regexp_Pattern is (League.Regexps.Compile (League.Strings.To_Universal_String (Text))); Link_Title : Wide_Wide_String renames Markdown.Common_Patterns.Link_Title; -- Groups: 4 Link_Start_Pattern : constant League.Regexps.Regexp_Pattern := +("^\([\ \t\n\v\f\r\>]*"); Title_Pattern : constant League.Regexps.Regexp_Pattern := +("^[\ \t\n\v\f\r\>]*(" & Link_Title & ")?([\ \t\n\v\f\r\>]*\))?"); -- Groups: 1 2,3,4,5 6 Title_Close_Group : constant array (Positive range 1 .. 3) of Positive := (2, 3, 5); -- Close title group numbers package body Plain_Texts is function First (Self : Plain_Text'Class) return Position is (Self.From); procedure Initialize (Self : in out Plain_Text'Class; Text : League.String_Vectors.Universal_String_Vector; From : Position := (1, 1); To : Position := (Positive'Last, Positive'Last)) is begin Self.Data := Text; Self.From := From; if To.Line > Text.Length then Self.To := (Text.Length, Text (Text.Length).Length); else Self.To := To; end if; end Initialize; procedure Initialize (Self : in out Plain_Text'Class; Text : Plain_Text'Class; From : Position; To : Position := (Positive'Last, Positive'Last)) is begin Self.Data := Text.Data; Self.From := From; if To > Text.To then Self.To := Text.To; elsif To.Column = 1 then Self.To := (To.Line - 1, Text.Data (To.Line - 1).Length); else Self.To := (To.Line, To.Column - 1); end if; end Initialize; function Join (Self : Plain_Text'Class; From : Position; Char : Wide_Wide_Character) return League.Strings.Universal_String is Nested : Plain_Text; List : League.String_Vectors.Universal_String_Vector := Self.Data; begin Nested.Initialize (Self, From); if From.Line > 1 or Self.To.Line < Self.Data.Length then List := List.Slice (From.Line, Self.To.Line); end if; if From.Column > 1 then List.Replace (1, Nested.Line (From.Line)); end if; if Self.To.Column < List (List.Length).Length then List.Replace (List.Length, List (List.Length).Head_To (Self.To.Column)); end if; return List.Join (Char); end Join; function Last (Self : Plain_Text'Class) return Position is (Self.To); function Line (Self : Plain_Text'Class; Index : Positive) return League.Strings.Universal_String is use type League.Strings.Universal_String; function Space (Count : Positive) return League.Strings.Universal_String; ----------- -- Space -- ----------- function Space (Count : Positive) return League.Strings.Universal_String is Blank : constant Wide_Wide_String (1 .. 80) := (others => ' '); begin if Count <= Blank'Last then return League.Strings.To_Universal_String (Blank (1 .. Count)); else return Blank & Space (Count - Blank'Last); end if; end Space; Result : League.Strings.Universal_String := Self.Data (Index); begin if Index = Self.From.Line and Self.From.Column > 1 then Result := Space (Self.From.Column - 1) & Result.Tail_From (Self.From.Column); end if; if Index = Self.To.Line and Self.To.Column < Result.Length then Result := Result.Head_To (Self.To.Column); end if; return Result; end Line; ---------- -- Line -- ---------- function Line (Self : Plain_Text'Class; From : Position) return League.Strings.Universal_String is begin return Self.Data (From.Line).Tail_From (From.Column); end Line; function Lines (Self : Plain_Text'Class) return Positive is begin return Self.To.Line - Self.From.Line + 1; end Lines; procedure Step (Self : Plain_Text'Class; Value : Natural; Cursor : in out Position) is Line : League.Strings.Universal_String renames Self.Data (Cursor.Line); begin if Cursor.Column + Value > Line.Length then Cursor := (Cursor.Line + 1, 1); else Cursor.Column := Cursor.Column + Value; end if; end Step; end Plain_Texts; type Delimiter_Kind is ('*', '_', '[', ']'); subtype Emphasis_Kind is Delimiter_Kind range '*' .. '_'; type Delimiter (Kind : Delimiter_Kind := '*') is record From : Position; Is_Deleted : Boolean := False; case Kind is when '*' | '_' => Count : Positive; Is_Active : Boolean; Can_Open : Boolean; Can_Close : Boolean; when '[' => null; when ']' => To : Position; end case; end record; type Markup_Kind is (Emphasis, Link); type Markup (Kind : Markup_Kind := Emphasis) is record From : Position; Length : Positive; case Kind is when Link => URL : League.Strings.Universal_String; Title : League.String_Vectors.Universal_String_Vector; when Emphasis => null; end case; end record; type Markup_Index is new Positive; package Markup_Vectors is new Ada.Containers.Vectors (Markup_Index, Markup); procedure Find_Markup (Register : Markdown.Link_Registers.Link_Register'Class; Text : Plain_Texts.Plain_Text; Markup : in out Markup_Vectors.Vector); type Scanner_State is record Is_White_Space : Boolean := True; Is_Punctuation : Boolean := False; end record; procedure Read_Delimiter (Text : Plain_Texts.Plain_Text; Cursor : in out Position; State : in out Scanner_State; Item : out Delimiter; Is_Delimiter : out Boolean); procedure Read_Character (Text : Plain_Texts.Plain_Text; Cursor : in out Position; Result : in out League.Strings.Universal_String); function Get_State (Text : Plain_Texts.Plain_Text; Cursor : Position) return Scanner_State; function To_Annotation (Item : Markup; Pos : Positive) return Annotation; function To_Annotated_Text (Text : Plain_Texts.Plain_Text; Markup : Markup_Vectors.Vector) return Annotated_Text; function Count_Character (Line : League.Strings.Universal_String; From : Positive) return Positive; type Inline_Kind is new Positive; -- Top priority inline kinds. type Inline_Parser_State is array (Inline_Kind range <>) of Optional_Inline_State; Known_Inline : constant array (Inline_Kind range 1 .. 3) of access procedure (Text : Plain_Texts.Plain_Text; Cursor : Position; State : in out Optional_Inline_State) := (Markdown.Inline_Parsers.Code_Spans.Find'Access, Markdown.Inline_Parsers.Autolinks.Find'Access, Markdown.Inline_Parsers.Raw_HTML.Find'Access); procedure Parse_Inline (Text : Plain_Texts.Plain_Text; State : in out Inline_Parser_State; Result : out Optional_Inline_State); procedure Find_All_Inlines (Text : Plain_Texts.Plain_Text; Cursor : Position; State : out Inline_Parser_State); procedure Append (Self : in out Annotated_Text; Value : Annotated_Text); procedure Append (Self : in out Annotated_Text; Value : Annotated_Text) is Offset : constant Natural := Self.Plain_Text.Length; begin Self.Plain_Text.Append (Value.Plain_Text); for X of Value.Annotation loop declare Shifted : Annotation := X; begin Shifted.From := Shifted.From + Offset; Shifted.To := Shifted.To + Offset; Self.Annotation.Append (Shifted); end; end loop; end Append; --------------------- -- Count_Character -- --------------------- function Count_Character (Line : League.Strings.Universal_String; From : Positive) return Positive is use type League.Characters.Universal_Character; Char : constant League.Characters.Universal_Character := Line (From); Result : Positive := 1; begin for J in From + 1 .. Line.Length loop exit when Line (J) /= Char; Result := Result + 1; end loop; return Result; end Count_Character; --------------------- -- Delimiter_Lists -- --------------------- package Delimiter_Lists is type Delimiter_List is tagged private with Variable_Indexing => Reference, Default_Iterator => Iterate, Iterator_Element => Delimiter; type Delimiter_Index is new Positive; subtype Extended_Delimiter_Index is Delimiter_Index'Base range 0 .. Delimiter_Index'Last; function Has_Element (Cursor : Extended_Delimiter_Index) return Boolean is (Cursor > 0); package Delimiter_Iterator_Interfaces is new Ada.Iterator_Interfaces (Extended_Delimiter_Index, Has_Element); type Reference_Type (Element : not null access Delimiter) is null record with Implicit_Dereference => Element; function Reference (Self : aliased in out Delimiter_List'Class; Cursor : Delimiter_Index) return Reference_Type with Inline; function Iterate (Self : aliased Delimiter_List'Class) return Delimiter_Iterator_Interfaces.Reversible_Iterator'Class; type Delimiter_Filter_Kind is (Any_Element, Kind_Of, Emphasis_Close, Emphasis_Open); type Delimiter_Filter (Kind : Delimiter_Filter_Kind := Any_Element) is record case Kind is when Any_Element | Emphasis_Close => null; when Kind_Of => Given_Kind : Delimiter_Kind; when Emphasis_Open => Emphasis : Emphasis_Kind; end case; end record; function Each (Self : aliased Delimiter_List'Class; Filter : Delimiter_Filter := (Kind => Any_Element); From : Delimiter_Index := 1; To : Extended_Delimiter_Index := Delimiter_Index'Last) return Delimiter_Iterator_Interfaces.Reversible_Iterator'Class; procedure Append (Self : in out Delimiter_List'Class; Item : Delimiter); private package Delimiter_Vectors is new Ada.Containers.Vectors (Delimiter_Index, Delimiter); type Delimiter_List is tagged record Data : Delimiter_Vectors.Vector; end record; end Delimiter_Lists; package body Delimiter_Lists is type Iterator is limited new Delimiter_Iterator_Interfaces.Reversible_Iterator with record List : not null access constant Delimiter_List; Filter : Delimiter_Filter; First : Delimiter_Index; Last : Extended_Delimiter_Index; end record; overriding function First (Self : Iterator) return Extended_Delimiter_Index; overriding function Last (Self : Iterator) return Extended_Delimiter_Index; overriding function Next (Self : Iterator; Index : Extended_Delimiter_Index) return Extended_Delimiter_Index; overriding function Previous (Self : Iterator; Index : Extended_Delimiter_Index) return Extended_Delimiter_Index; function Check (Item : Delimiter; Filter : Delimiter_Filter) return Boolean; ------------ -- Append -- ------------ procedure Append (Self : in out Delimiter_List'Class; Item : Delimiter) is begin Self.Data.Append (Item); end Append; ----------- -- Check -- ----------- function Check (Item : Delimiter; Filter : Delimiter_Filter) return Boolean is begin if not Item.Is_Deleted then case Filter.Kind is when Emphasis_Open => if Item.Kind = Filter.Emphasis and then Item.Can_Open then return True; end if; when Emphasis_Close => if Item.Kind in Emphasis_Kind and then Item.Can_Close then return True; end if; when Kind_Of => if Item.Kind = Filter.Given_Kind then return True; end if; when Any_Element => return True; end case; end if; return False; end Check; ---------- -- Each -- ---------- function Each (Self : aliased Delimiter_List'Class; Filter : Delimiter_Filter := (Kind => Any_Element); From : Delimiter_Index := 1; To : Extended_Delimiter_Index := Delimiter_Index'Last) return Delimiter_Iterator_Interfaces.Reversible_Iterator'Class is begin return Iterator'(Self'Access, Filter, From, Delimiter_Index'Min (To, Self.Data.Last_Index)); end Each; ----------- -- First -- ----------- overriding function First (Self : Iterator) return Extended_Delimiter_Index is begin for J in Self.First .. Self.Last loop if Check (Self.List.Data (J), Self.Filter) then return J; end if; end loop; return 0; end First; function Iterate (Self : aliased Delimiter_List'Class) return Delimiter_Iterator_Interfaces.Reversible_Iterator'Class is (Self.Each); overriding function Last (Self : Iterator) return Extended_Delimiter_Index is (Self.Previous (Self.Last + 1)); ---------- -- Next -- ---------- overriding function Next (Self : Iterator; Index : Extended_Delimiter_Index) return Extended_Delimiter_Index is begin if Index > 0 then for J in Index + 1 .. Self.Last loop if Check (Self.List.Data (J), Self.Filter) then return J; end if; end loop; end if; return 0; end Next; -------------- -- Previous -- -------------- overriding function Previous (Self : Iterator; Index : Extended_Delimiter_Index) return Extended_Delimiter_Index is begin if Index > 0 then for J in reverse Self.First .. Index - 1 loop if Check (Self.List.Data (J), Self.Filter) then return J; end if; end loop; end if; return 0; end Previous; function Reference (Self : aliased in out Delimiter_List'Class; Cursor : Delimiter_Index) return Reference_Type is begin return (Element => Self.Data.Reference (Cursor).Element); end Reference; end Delimiter_Lists; procedure Process_Emphasis (DL : in out Delimiter_Lists.Delimiter_List; Markup : in out Markup_Vectors.Vector; From : Delimiter_Lists.Delimiter_Index := 1; To : Delimiter_Lists.Delimiter_Index := Delimiter_Lists.Delimiter_Index'Last); procedure Process_Links (Register : Markdown.Link_Registers.Link_Register'Class; Text : Plain_Texts.Plain_Text; DL : in out Delimiter_Lists.Delimiter_List; Markup : in out Markup_Vectors.Vector; Bottom : Delimiter_Lists.Delimiter_Index := 1); procedure Parse_Link_Ahead (Register : Markdown.Link_Registers.Link_Register'Class; Text : Plain_Texts.Plain_Text; DL : in out Delimiter_Lists.Delimiter_List; Open : Delimiter_Lists.Delimiter_Index; Close : Delimiter_Lists.Delimiter_Index; URL : out League.Strings.Universal_String; Title : out League.String_Vectors.Universal_String_Vector; Ok : out Boolean); ---------------------- -- Find_All_Inlines -- ---------------------- procedure Find_All_Inlines (Text : Plain_Texts.Plain_Text; Cursor : Position; State : out Inline_Parser_State) is begin for Kind in State'Range loop Known_Inline (Kind) (Text, Cursor, State (Kind)); end loop; end Find_All_Inlines; ------------------ -- Parse_Inline -- ------------------ procedure Parse_Inline (Text : Plain_Texts.Plain_Text; State : in out Inline_Parser_State; Result : out Optional_Inline_State) is begin Result := (Is_Set => False); for X of State loop if X.Is_Set then if Result.Is_Set then if X.Span.From < Result.Span.From then Result := X; end if; else Result := X; end if; end if; end loop; if Result.Is_Set then declare Next : Position := Result.Span.To; begin Text.Step (1, Next); for Kind in State'Range loop if State (Kind).Is_Set and then State (Kind).Span.From <= Result.Span.To then if Next <= Text.Last then Known_Inline (Kind) (Text, Next, State (Kind)); else State (Kind) := (Is_Set => False); end if; end if; end loop; end; end if; end Parse_Inline; ---------------------- -- Parse_Link_Ahead -- ---------------------- procedure Parse_Link_Ahead (Register : Markdown.Link_Registers.Link_Register'Class; Text : Plain_Texts.Plain_Text; DL : in out Delimiter_Lists.Delimiter_List; Open : Delimiter_Lists.Delimiter_Index; Close : Delimiter_Lists.Delimiter_Index; URL : out League.Strings.Universal_String; Title : out League.String_Vectors.Universal_String_Vector; Ok : out Boolean) is procedure To_Link_Label (Text : Plain_Texts.Plain_Text; Open : Position; Close : Position; Label : out League.Strings.Universal_String; Ok : out Boolean); procedure To_Inline_Link (Text : Plain_Texts.Plain_Text; From : Position; To : in out Position; Ok : out Boolean); -------------------- -- To_Inline_Link -- -------------------- procedure To_Inline_Link (Text : Plain_Texts.Plain_Text; From : Position; To : in out Position; Ok : out Boolean) is Start : Wide_Wide_Character; -- Title quote character pragma Unreferenced (Start); Skip : Positive := From.Column; Last : Natural; Line : League.Strings.Universal_String := Text.Line ((From.Line, Skip + 1)); Match : League.Regexps.Regexp_Match := Link_Start_Pattern.Find_Match (Line); Complete : Boolean; -- We have whole inline_link matched Has_Title : Boolean; -- Is title complete begin if not Match.Is_Matched then Ok := False; -- No '(' return; end if; Skip := Skip + Match.Last_Index; Line := Line.Tail_From (Match.Last_Index + 1); -- drop '(' Markdown.Common_Patterns.Parse_Link_Destination (Line, Last, URL); if Last > 0 then Skip := Skip + Last; Line := Line.Tail_From (Last + 1); -- drop link destination end if; Match := Title_Pattern.Find_Match (Line); Complete := Match.Last_Index (6) >= Match.First_Index (6); if not Complete and Match.Last_Index /= Line.Length then Ok := False; -- unmatched text before ')' return; elsif Last > 0 and Match.Last_Index (1) >= Match.First_Index (1) and Match.First_Index (1) = 1 then Ok := False; -- No space between destinationa and title return; end if; Has_Title := (for some J of Title_Close_Group => Match.Last_Index (J) >= Match.First_Index (J)); Line := Match.Capture (1); if Has_Title then Title.Append (Line.Slice (2, Line.Length - 1)); elsif not Line.Is_Empty then if Complete then Ok := False; -- No closing ', " or ')' in link title return; end if; Start := Line (1).To_Wide_Wide_Character; Title.Append (Line.Tail_From (2)); end if; if Complete then To.Column := Skip + Match.Last_Index; Ok := True; return; end if; -- for J in To.Line + 1 .. Text.Length loop -- Line := Text (J); -- end loop; Ok := False; end To_Inline_Link; ------------------- -- To_Link_Label -- ------------------- procedure To_Link_Label (Text : Plain_Texts.Plain_Text; Open : Position; Close : Position; Label : out League.Strings.Universal_String; Ok : out Boolean) is Line : constant League.Strings.Universal_String := Text.Line (Open.Line); begin if Open.Line = Close.Line then Label := Line.Slice (Open.Column, Close.Column); Ok := True; else Ok := False; end if; end To_Link_Label; Label : League.Strings.Universal_String; begin To_Inline_Link (Text, DL (Close).From, DL (Close).To, Ok); if not Ok then To_Link_Label (Text, DL (Open).From, DL (Close).From, Label, Ok); if Ok then Register.Resolve (Label, Ok, URL, Title); end if; end if; end Parse_Link_Ahead; ---------------------- -- Process_Emphasis -- ---------------------- procedure Process_Emphasis (DL : in out Delimiter_Lists.Delimiter_List; Markup : in out Markup_Vectors.Vector; From : Delimiter_Lists.Delimiter_Index := 1; To : Delimiter_Lists.Delimiter_Index := Delimiter_Lists.Delimiter_Index'Last) is use Delimiter_Lists; Openers_Bottom : array (Emphasis_Kind, Natural range 0 .. 2) of Extended_Delimiter_Index := (others => (others => 0)); begin for J in DL.Each ((Kind => Emphasis_Close), From, To) loop declare Closer : Delimiter renames DL (J); Found : Boolean := False; begin Each_Open_Emphasis : for K in reverse DL.Each ((Emphasis_Open, Closer.Kind), From => Delimiter_Index'Max (From, Openers_Bottom (Closer.Kind, Closer.Count mod 3)), To => J - 1) loop declare Opener : Delimiter renames DL (K); Count : Positive range 1 .. 2; begin while not Opener.Is_Deleted and then -- If one of the delimiters can both open and close -- emphasis, then the sum of the lengths of the -- delimiter runs containing the opening and closing -- delimiters must not be a multiple of 3 unless both -- lengths are multiples of 3. (not ((Opener.Can_Open and Opener.Can_Close) or (Closer.Can_Open and Closer.Can_Close)) or else (Opener.Count + Closer.Count) mod 3 /= 0 or else (Opener.Count mod 3 = 0 and Closer.Count mod 3 = 0)) loop Found := True; Count := Positive'Min (2, Positive'Min (Opener.Count, Closer.Count)); Markup.Append ((Emphasis, Opener.From + (Opener.Count - Count), Count)); Markup.Append ((Emphasis, Closer.From, Count)); for M in K + 1 .. J - 1 loop DL (M).Is_Deleted := True; end loop; if Opener.Count = Count then Opener.Is_Deleted := True; else Opener.Count := Opener.Count - Count; end if; if Closer.Count = Count then Closer.Is_Deleted := True; exit Each_Open_Emphasis; else Closer.Count := Closer.Count - Count; Closer.From := Closer.From + Count; end if; end loop; end; end loop Each_Open_Emphasis; if not Found then if not Closer.Can_Open then Closer.Is_Deleted := True; end if; Openers_Bottom (Closer.Kind, Closer.Count mod 3) := J; end if; end; end loop; end Process_Emphasis; ------------------- -- Process_Links -- ------------------- procedure Process_Links (Register : Markdown.Link_Registers.Link_Register'Class; Text : Plain_Texts.Plain_Text; DL : in out Delimiter_Lists.Delimiter_List; Markup : in out Markup_Vectors.Vector; Bottom : Delimiter_Lists.Delimiter_Index := 1) is use Delimiter_Lists; begin for J in DL.Each ((Kind_Of, ']')) loop declare Closer : Delimiter renames DL (J); begin for K in reverse DL.Each ((Kind_Of, '['), From => Bottom, To => J - 1) loop declare Opener : Delimiter renames DL (K); URL : League.Strings.Universal_String; Title : League.String_Vectors.Universal_String_Vector; Ok : Boolean; begin Parse_Link_Ahead (Register, Text, DL, K, J, URL, Title, Ok); if Ok then Markup.Append ((Link, Opener.From, 1, URL, Title)); Markup.Append ((Link, Closer.From, Closer.To.Column - Closer.From.Column + 1, URL, Title)); Process_Emphasis (DL, Markup, K + 1, J - 1); for M in DL.Each ((Kind_Of, '['), From => Bottom, To => J - 1) loop DL (M).Is_Deleted := True; end loop; end if; end; end loop; Closer.Is_Deleted := True; end; end loop; end Process_Links; ----------------- -- Find_Markup -- ----------------- procedure Find_Markup (Register : Markdown.Link_Registers.Link_Register'Class; Text : Plain_Texts.Plain_Text; Markup : in out Markup_Vectors.Vector) is State : Scanner_State; List : Delimiter_Lists.Delimiter_List; Cursor : Position := Text.First; Item : Delimiter; Is_Delimiter : Boolean; begin while Cursor <= Text.Last loop Read_Delimiter (Text, Cursor, State, Item, Is_Delimiter); if Is_Delimiter then List.Append (Item); end if; end loop; Process_Links (Register, Text, List, Markup); Process_Emphasis (List, Markup); end Find_Markup; --------------- -- Get_State -- --------------- function Get_State (Text : Plain_Texts.Plain_Text; Cursor : Position) return Scanner_State is Line : League.Strings.Universal_String; -- FIXME: use Zs and Pc, Pd, Pe, Pf, Pi, Po, or Ps begin if Cursor > Text.Last or else Text.Line (Cursor.Line).Is_Empty then return (Is_White_Space => True, Is_Punctuation => False); else Line := Text.Line (Cursor.Line); end if; if Line (Cursor.Column).To_Wide_Wide_Character in ' ' then return (Is_White_Space => True, Is_Punctuation => False); elsif Line (Cursor.Column).To_Wide_Wide_Character in '!' | '"' | '#' | '$' | '%' | '&' | ''' | '(' | ')' | '*' | '+' | ',' | '-' | '.' | '/' | ':' | ';' | '<' | '=' | '>' | '?' | '@' | '[' | '\' | ']' | '^' | '_' | '`' | '{' | '|' | '}' | '~' then return (Is_White_Space => False, Is_Punctuation => True); else return (Is_White_Space => False, Is_Punctuation => False); end if; end Get_State; ----------- -- Parse -- ----------- function Parse (Register : Markdown.Link_Registers.Link_Register'Class; Lines : League.String_Vectors.Universal_String_Vector) return Annotated_Text is Result : Annotated_Text; Text : Plain_Texts.Plain_Text; State : Inline_Parser_State := (Known_Inline'Range => <>); Cursor : Position; begin Text.Initialize (Lines); Cursor := Text.First; Find_All_Inlines (Text, Cursor, State); while Cursor <= Text.Last loop declare Markup : Markup_Vectors.Vector; Value : Optional_Inline_State; begin Parse_Inline (Text, State, Value); if Value.Is_Set then if Cursor /= Value.Span.From then declare Nested : Plain_Texts.Plain_Text; begin Nested.Initialize (Text, Cursor, Value.Span.From); Find_Markup (Register, Nested, Markup); Append (Result, To_Annotated_Text (Nested, Markup)); end; end if; Append (Result, Value.Value); Cursor := Value.Span.To; Text.Step (1, Cursor); else declare Nested : Plain_Texts.Plain_Text; begin Nested.Initialize (Text, Cursor); Find_Markup (Register, Nested, Markup); Append (Result, To_Annotated_Text (Nested, Markup)); Cursor := Text.Last; Text.Step (1, Cursor); end; end if; end; end loop; return Result; end Parse; -------------------- -- Read_Character -- -------------------- procedure Read_Character (Text : Plain_Texts.Plain_Text; Cursor : in out Position; Result : in out League.Strings.Universal_String) is Line : constant League.Strings.Universal_String := Text.Line (Cursor.Line); begin if Line.Is_Empty then Text.Step (1, Cursor); return; end if; case Line (Cursor.Column).To_Wide_Wide_Character is when '\' => Text.Step (1, Cursor); if Cursor > Text.Last then Result.Append ('\'); elsif Get_State (Text, Cursor).Is_Punctuation then Result.Append (Line (Cursor.Column)); Text.Step (1, Cursor); else Result.Append ('\'); end if; when others => Result.Append (Line (Cursor.Column)); Text.Step (1, Cursor); end case; end Read_Character; -------------------- -- Read_Delimiter -- -------------------- procedure Read_Delimiter (Text : Plain_Texts.Plain_Text; Cursor : in out Position; State : in out Scanner_State; Item : out Delimiter; Is_Delimiter : out Boolean) is function Get_Follow_State (Cursor : Position) return Scanner_State; ---------------------- -- Get_Follow_State -- ---------------------- function Get_Follow_State (Cursor : Position) return Scanner_State is begin if Cursor.Column = 1 then return (Is_White_Space => True, Is_Punctuation => False); else return Get_State (Text, Cursor); end if; end Get_Follow_State; Line : constant League.Strings.Universal_String := Text.Line (Cursor.Line); Follow : Scanner_State; begin if Line.Is_Empty then State := Get_State (Text, Cursor); Text.Step (1, Cursor); Is_Delimiter := False; return; end if; case Line (Cursor.Column).To_Wide_Wide_Character is when '*' => declare Next : Delimiter := (Kind => '*', From => Cursor, Count => Count_Character (Line, Cursor.Column), others => False); begin Text.Step (Next.Count, Cursor); Follow := Get_Follow_State (Cursor); -- Left flanking Next.Can_Open := not Follow.Is_White_Space and then (not Follow.Is_Punctuation or else (State.Is_White_Space or State.Is_Punctuation)); -- Right flanking Next.Can_Close := not State.Is_White_Space and then (not State.Is_Punctuation or else (Follow.Is_White_Space or Follow.Is_Punctuation)); State := Follow; Item := Next; Is_Delimiter := True; end; when '_' => declare Left_Flanking : Boolean; Right_Flanking : Boolean; Next : Delimiter := (Kind => '_', From => Cursor, Count => Count_Character (Line, Cursor.Column), others => False); begin Text.Step (Next.Count, Cursor); Follow := Get_Follow_State (Cursor); Left_Flanking := not Follow.Is_White_Space and then (not Follow.Is_Punctuation or else (State.Is_White_Space or State.Is_Punctuation)); -- Right flanking Right_Flanking := not State.Is_White_Space and then (not State.Is_Punctuation or else (Follow.Is_White_Space or Follow.Is_Punctuation)); Next.Can_Open := Left_Flanking and (not Right_Flanking or else State.Is_Punctuation); Next.Can_Close := Right_Flanking and (not Left_Flanking or else Follow.Is_Punctuation); State := Follow; Item := Next; Is_Delimiter := True; end; when '[' => State := Get_State (Text, Cursor); Item := (Kind => '[', From => Cursor, Is_Deleted => False); Text.Step (1, Cursor); Is_Delimiter := True; when ']' => State := Get_State (Text, Cursor); Item := (Kind => ']', From => Cursor, To => Cursor, Is_Deleted => False); Text.Step (1, Cursor); Is_Delimiter := True; when '\' => State := Get_State (Text, Cursor); Text.Step (2, Cursor); Is_Delimiter := False; when others => State := Get_State (Text, Cursor); Text.Step (1, Cursor); Is_Delimiter := False; end case; if Cursor.Column = 1 then State := (Is_White_Space => True, Is_Punctuation => False); end if; end Read_Delimiter; ----------------------- -- To_Annotated_Text -- ----------------------- function To_Annotated_Text (Text : Plain_Texts.Plain_Text; Markup : Markup_Vectors.Vector) return Annotated_Text is function Less (Left, Right : Positive) return Boolean; procedure Swap (Left, Right : Positive); Map : array (Positive range 1 .. Natural (Markup.Length)) of Markup_Index; Annotation_Map : array (Markup_Index range 1 .. Markup.Last_Index / 2) of Natural := (others => 0); ---------- -- Less -- ---------- function Less (Left, Right : Positive) return Boolean is L : Inline_Parsers.Markup renames Markup (Map (Left)); R : Inline_Parsers.Markup renames Markup (Map (Right)); begin return L.From.Line < R.From.Line or (L.From.Line = R.From.Line and L.From.Column < R.From.Column); end Less; ---------- -- Swap -- ---------- procedure Swap (Left, Right : Positive) is Temp : constant Markup_Index := Map (Left); begin Map (Left) := Map (Right); Map (Right) := Temp; end Swap; procedure Sort is new Ada.Containers.Generic_Anonymous_Array_Sort (Index_Type => Positive, Less => Less, Swap => Swap); Result : League.Strings.Universal_String; Cursor : Position := Text.First; Index : Positive := Map'First; Annotation : Annotation_Vectors.Vector; begin for J in 1 .. Map'Last loop Map (J) := Markup_Index (J); end loop; Sort (1, Map'Last); while Cursor <= Text.Last loop if Index in Map'Range and then Cursor = Markup (Map (Index)).From then declare Item : Inline_Parsers.Markup renames Markup (Map (Index)); begin if Map (Index) mod 2 = 1 then -- Open markup Annotation.Append (To_Annotation (Item, Result.Length + 1)); Annotation_Map ((Map (Index) + 1) / 2) := Annotation.Last_Index; else -- Close markup Annotation (Annotation_Map ((Map (Index)) / 2)).To := Result.Length; end if; Text.Step (Item.Length, Cursor); Index := Index + 1; end; else Read_Character (Text, Cursor, Result); end if; if Cursor <= Text.Last and Cursor.Column = 1 then Result.Append (' '); Annotation.Append ((Soft_Line_Break, Result.Length, Result.Length)); end if; end loop; return (Result, Annotation); end To_Annotated_Text; ------------------- -- To_Annotation -- ------------------- function To_Annotation (Item : Markup; Pos : Positive) return Annotation is begin if Item.Kind = Link then return (Link, Pos, Pos, Item.URL, Item.Title); elsif Item.Length = 1 then return (Emphasis, Pos, Pos); else return (Strong, Pos, Pos); end if; end To_Annotation; end Markdown.Inline_Parsers;
private package P.Q is ... -- Visible to the siblings only private ... -- Visible to the children only end P.Q;
-- part of AdaYaml, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "copying.txt" generic type Instance is limited new Refcount_Base with private; type Reference is tagged private; type Accessor (Data : not null access Instance) is limited private; with function Value (Object : Reference) return Accessor; with function Next (Object : in out Instance) return Event; package Yaml.Stream_Concept is pragma Warnings (Off, Next); pragma Warnings (Off, Value); -- to not burden ourselves with too much dynamic dispatching, we define a -- Stream as anything that is able to instantiate this package. any consumer -- of a stream shall take as generic parameter an instance of this package. end Yaml.Stream_Concept;
-- Generated at 2017-03-10 17:26:29 +0000 by Natools.Static_Hash_Maps -- from src/natools-web-simple_pages-maps.sx with Natools.Static_Maps.Web.Simple_Pages.Commands; with Natools.Static_Maps.Web.Simple_Pages.Components; package body Natools.Static_Maps.Web.Simple_Pages is function To_Command (Key : String) return Command is N : constant Natural := Natools.Static_Maps.Web.Simple_Pages.Commands.Hash (Key); begin if Map_1_Keys (N).all = Key then return Map_1_Elements (N); else return Unknown_Command; end if; end To_Command; function To_Component (Key : String) return Component is N : constant Natural := Natools.Static_Maps.Web.Simple_Pages.Components.Hash (Key); begin if Map_2_Keys (N).all = Key then return Map_2_Elements (N); else return Error; end if; end To_Component; end Natools.Static_Maps.Web.Simple_Pages;
with HAL.I2C; package BB_Pico_Bsp.I2C is function Port return not null HAL.I2C.Any_I2C_Port; end BB_Pico_Bsp.I2C;
with openGL.Font, freetype_c.Binding, freetype_c.FT_GlyphSlot, freetype_c.Pointers, freetype_c.FT_Size_Metrics, ada.unchecked_Deallocation; package body openGL.FontImpl is use freetype_c.Pointers; ----------- -- Utility -- procedure deallocate is new ada.unchecked_Deallocation (Glyph.Container.item'Class, glyph_Container_view); --------- -- Forge -- procedure define (Self : access Item; ftFont : access Font.item'Class; fontFilePath : in String) is use freetype.Face, openGL.Glyph.container, Freetype_C, Freetype_C.Binding; use type FT_Error; begin Self.Face := Forge.to_Face (fontFilePath, precomputeKerning => True); Self.load_Flags := FT_Int (FT_LOAD_DEFAULT_flag); Self.Intf := ftFont; Self.Err := Self.face.Error; if Self.Err = 0 then Self.glyphList := new Glyph.Container.item' (to_glyph_Container (Self.Face'Access)); else raise Error with "Unable to create face for font '" & fontFilePath & "'."; end if; end define; procedure define (Self : access Item; ftFont : access Font.item'Class; pBufferBytes : access C.unsigned_char; bufferSizeInBytes : in Integer) is use freetype.Face, openGL.Glyph.container, Freetype_C, Freetype_c.Binding; use type FT_Error; begin Self.Face := Forge.to_Face (pBufferBytes, bufferSizeInBytes, precomputeKerning => True); Self.load_Flags := FT_Int (FT_LOAD_DEFAULT_flag); Self.Intf := ftFont; Self.Err := Self.face.Error; if Self.Err = 0 then Self.glyphList := new Glyph.Container.item' (to_glyph_Container (Self.Face'Access)); end if; end define; procedure destruct (Self : in out Item) is begin if Self.glyphList /= null then Self.glyphList.destruct; deallocate (Self.glyphList); end if; end destruct; -------------- -- Attributes -- function Err (Self : in Item) return freetype_c.FT_Error is begin return Self.Err; end Err; function attach (Self : access Item; fontFilePath : in String) return Boolean is begin if not Self.Face.attach (fontFilePath) then Self.Err := Self.Face.Error; return False; end if; Self.Err := 0; return True; end attach; function attach (Self : access Item; pBufferBytes : access C.unsigned_char; bufferSizeInBytes : in Integer) return Boolean is begin if not Self.Face.attach (pBufferBytes, bufferSizeInBytes) then Self.Err := Self.Face.Error; return False; end if; Self.Err := 0; return True; end attach; procedure GlyphLoadFlags (Self : in out Item; Flags : in freetype_c.FT_Int) is begin Self.load_Flags := Flags; end GlyphLoadFlags; function CharMap (Self : access Item; Encoding : in freetype_c.FT_Encoding) return Boolean is Result : constant Boolean := Self.glyphList.CharMap (Encoding); begin Self.Err := Self.glyphList.Error; return Result; end CharMap; function CharMapCount (Self : in Item) return Natural is begin return Self.Face.CharMapCount; end CharMapCount; function CharMapList (Self : access Item) return freetype.face.FT_Encodings_view is begin return Self.Face.CharMapList; end CharMapList; function Ascender (Self : in Item) return Real is begin return Self.charSize.Ascender; end Ascender; function Descender (Self : in Item) return Real is begin return Self.charSize.Descender; end Descender; function LineHeight (Self : in Item) return Real is begin return Self.charSize.Height; end LineHeight; function FaceSize (Self : access Item; Size : in Natural; x_Res, y_Res : in Natural) return Boolean is use Glyph.Container; use type freetype_c.FT_Error; begin if Self.glyphList /= null then Self.glyphList.destruct; deallocate (Self.glyphList); end if; Self.charSize := Self.Face.Size (Size, x_Res, y_Res); Self.Err := Self.Face.Error; if Self.Err /= 0 then return False; end if; Self.glyphList := new Glyph.Container.item' (to_glyph_Container (Self.Face'unchecked_Access)); return True; end FaceSize; function FaceSize (Self : in Item) return Natural is begin return Self.charSize.CharSize; end FaceSize; procedure Depth (Self : in out Item; Depth : in Real) is begin null; -- NB: This is 'null' in FTGL also. end Depth; procedure Outset (Self : in out Item; Outset : in Real) is begin null; -- NB: This is 'null' in FTGL also. end Outset; procedure Outset (Self : in out Item; Front : in Real; Back : in Real) is begin null; -- NB: This is 'null' in FTGL also. end Outset; function CheckGlyph (Self : access Item; Character : in freetype.charmap.CharacterCode) return Boolean is use type Glyph.Container.Glyph_view, freetype_c.FT_Error; glyphIndex : freetype.charMap.glyphIndex; ftSlot : freetype_c.FT_GlyphSlot.item; tempGlyph : glyph.Container.Glyph_view; begin if Self.glyphList.Glyph (Character) /= null then return True; end if; glyphIndex := freetype.charMap.glyphIndex (Self.glyphList.FontIndex (Character)); ftSlot := Self.Face.Glyph (glyphIndex, Self.load_flags); if ftSlot = null then Self.Err := Self.Face.Error; return False; end if; if Self.Intf = null then raise Error with "CheckGlyph ~ Self.Intf = null"; end if; tempGlyph := Self.Intf.MakeGlyph (ftSlot); if tempGlyph = null then if Self.Err = 0 then Self.Err := 16#13#; end if; return False; end if; if Self.glyphList.Glyph (character) = null then Self.glyphList.add (tempGlyph, Character); end if; return True; end CheckGlyph; function BBox (Self : access Item; Text : in String; Length : in Integer; Position : in Vector_3; Spacing : in Vector_3) return Bounds is pragma unreferenced (Length); use freetype.charMap, Geometry_3d; Pos : Vector_3 := Position; totalBBox : Bounds := null_Bounds; begin if Text = "" then totalBBox.Box := totalBBox.Box or Pos; set_Ball_from_Box (totalBBox); return totalBBox; end if; -- Only compute the bounds if string is non-empty. -- if Text'Length > 0 -- TODO: Rid this useless check. then -- For multibyte, we can't rely on sizeof (T) == character -- declare use type freetype.charMap.characterCode; thisChar : Character; nextChar : Character; begin -- Expand totalBox by each glyph in string -- for i in Text'Range loop thisChar := Text (i); if i /= Text'Last then nextChar := Text (i + 1); else nextChar := ' '; end if; if Self.CheckGlyph (to_characterCode (thisChar)) then declare tempBBox : Bounds := Self.glyphList.BBox (to_characterCode (thisChar)); begin tempBBox.Box := tempBBox.Box + Pos; totalBBox.Box := totalBBox.Box or tempBBox.Box; Pos := Pos + spacing; Pos := Pos + Vector_3' (Self.glyphList.Advance (to_characterCode (thisChar), to_characterCode (nextChar)), 0.0, 0.0); end; end if; end loop; end; end if; set_Ball_from_Box (totalBBox); return totalBBox; end BBox; function kern_Advance (Self : in Item; From, To : in Character) return Real is use freetype.charMap; begin return Self.glyphList.Advance (to_characterCode (From), to_characterCode (To)); end kern_Advance; function x_PPEM (Self : in Item) return Real is use freetype_c.Binding; ft_Size : constant FT_SizeRec_Pointer := FT_Face_Get_Size (Self.Face.freetype_Face); ft_Metrics : constant freetype_c.FT_Size_Metrics.item := FT_Size_Get_Metrics (ft_Size); begin return Real (ft_Metrics.x_PPEM); end x_PPEM; function x_Scale (Self : in Item) return Real is use freetype_c.Binding; ft_Size : constant FT_SizeRec_Pointer := FT_Face_Get_Size (Self.Face.freetype_Face); ft_Metrics : constant freetype_c.FT_Size_Metrics.item := FT_Size_Get_Metrics (ft_Size); begin return Real (ft_Metrics.x_Scale); end x_Scale; function y_Scale (Self : in Item) return Real is use freetype_c.Binding; ft_Size : constant FT_SizeRec_Pointer := FT_Face_Get_Size (Self.Face.freetype_Face); ft_Metrics : constant freetype_c.FT_Size_Metrics.item := FT_Size_Get_Metrics (ft_Size); begin return Real (ft_Metrics.y_Scale); end y_Scale; function Advance (Self : access Item; Text : in String; Length : in Integer; Spacing : in Vector_3) return Real is pragma unreferenced (Length); Advance : Real := 0.0; ustr : Integer := 1; i : Integer := 0; begin while i < Text'Length loop declare use freetype.charMap; use type freetype.charmap.characterCode; thisChar : constant Character := Text (ustr); nextChar : Character; begin ustr := ustr + 1; if ustr <= Text'Length then nextChar := Text (ustr); else nextChar := Character'Val (0); end if; if nextChar /= Character'Val (0) and then Self.CheckGlyph (to_characterCode (thisChar)) then Advance := Advance + Self.glyphList.Advance (to_characterCode (thisChar), to_characterCode (nextChar)); end if; if nextChar /= Character'Val (0) then Advance := Advance + Spacing (1); end if; i := i + 1; end; end loop; return advance; end Advance; -------------- --- Operations -- function render (Self : access Item; Text : in String; Length : in Integer; Position : in Vector_3; Spacing : in Vector_3; renderMode : in Integer) return Vector_3 is use type freetype.charMap.characterCode; ustr : Integer := 1; i : Integer := 0; Pos : Vector_3 := Position; begin while (Length < 0 and then i < Text'Length) or else (Length >= 0 and then i < Length) loop declare use freetype.charMap; thisChar : constant Character := Text (ustr); nextChar : Character; begin ustr := ustr + 1; if ustr <= Text'Length then nextChar := Text (ustr); else nextChar := Character'Val (0); end if; if nextChar /= Character'Val (0) and then Self.CheckGlyph (to_characterCode (thisChar)) then Pos := Pos + Self.glyphList.render (to_characterCode (thisChar), to_characterCode (nextChar), Position, renderMode); end if; if nextChar /= Character'Val (0) then Pos := Pos + Spacing; end if; i := i + 1; end; end loop; return Pos; end Render; end openGL.FontImpl;
pragma License (Unrestricted); -- implementation unit with Ada.Interrupts; package System.Interrupt_Handlers is -- pragma Interrupt_Handler is required to Attach_Handler, CXC3001. procedure Register_Interrupt_Handler ( Code_Address : Address); procedure Register_Interrupt_Handler ( Handler : Ada.Interrupts.Parameterless_Handler); procedure Set_Static_Handler ( Code_Address : Address); procedure Set_Static_Handler ( Handler : Ada.Interrupts.Parameterless_Handler); function Is_Static_Handler ( Code_Address : Address) return Boolean; function Is_Static_Handler ( Handler : Ada.Interrupts.Parameterless_Handler) return Boolean; end System.Interrupt_Handlers;
----------------------------------------------------------------------- -- volume_servlet -- Servlet example to compute some volumes -- Copyright (C) 2010, 2015, 2018 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Numerics; with Servlet.Streams; package body Volume_Servlet is procedure Write (Response : in out Responses.Response'Class; Message : in String; Height : in String; Radius : in String); -- ------------------------------ -- Write the volume form page with an optional response message. -- ------------------------------ procedure Write (Response : in out Responses.Response'Class; Message : in String; Height : in String; Radius : in String) is Output : Streams.Print_Stream := Response.Get_Output_Stream; begin Output.Write ("<html><head><title>Volume servlet example</title></head>" & "<style></style>" & "<body>" & "<h1>Compute the volume of a cylinder</h1>"); -- Display the response or some error. if Message /= "" then Output.Write ("<h2>" & Message & "</h2>"); end if; -- Render the form. If we have some existing Radius or Height -- use them to set the initial values. Output.Write ("<p>Enter the height and radius of the cylinder</p>" & "<form method='post'>" & "<table>" & "<tr><td>Height</td>" & "<td><input type='text' size='10' name='height'"); if Height /= "" then Output.Write (" value='" & Height & "'"); end if; Output.Write ("></input></td></tr>" & "<tr><td>Radius</td>" & "<td><input type='text' size='10' name='radius'"); if Radius /= "" then Output.Write (" value='" & Radius & "'"); end if; Output.Write ("></input></td></tr>" & "<tr><td></td><td><input type='submit' value='Compute'></input></td></tr>" & "</table></form>" & "</body></html>"); Response.Set_Status (Responses.SC_OK); end Write; -- ------------------------------ -- Called by the servlet container when a GET request is received. -- Display the volume form page. -- ------------------------------ procedure Do_Get (Server : in Servlet; Request : in out Requests.Request'Class; Response : in out Responses.Response'Class) is pragma Unreferenced (Server, Request); begin Write (Response, "", "", ""); end Do_Get; -- ------------------------------ -- Called by the servlet container when a POST request is received. -- Computes the cylinder volume and display the result page. -- ------------------------------ procedure Do_Post (Server : in Servlet; Request : in out Requests.Request'Class; Response : in out Responses.Response'Class) is pragma Unreferenced (Server); Height : constant String := Request.Get_Parameter ("height"); Radius : constant String := Request.Get_Parameter ("radius"); begin declare H : constant Float := Float'Value (Height); R : constant Float := Float'Value (Radius); V : constant Float := Ada.Numerics.Pi * R * R * H; begin Write (Response, "The cylinder volume is: " & Float'Image (V), Height, Radius); end; exception when others => Write (Response, "Invalid height or radius. Please, enter a number", Height, Radius); end Do_Post; end Volume_Servlet;
----------------------------------------------------------------------- -- util-events-channel -- Event Channels -- Copyright (C) 2001, 2002, 2003, 2009, 2010, 2018 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Strings; package body Util.Events.Channels is use Containers; use Ada.Strings.Unbounded; use Util.Strings; type Factory_Line is record Name : Name_Access; Creator : Channel_Creator; end record; type Factory_Table is array (Natural range <>) of Factory_Line; DIRECT_NAME : aliased constant String := "direct"; Factory : constant Factory_Table (1 .. 1) := (1 => (Name => DIRECT_NAME'Access, Creator => Create_Direct_Channel'Access)); -- ----------------------- -- Get the name of this event channel. -- ----------------------- function Get_Name (C : Channel) return String is begin return To_String (C.Name); end Get_Name; -- ----------------------- -- Post an event and dispatch it immediately. -- ----------------------- procedure Post (To : in out Channel; Item : in Event'Class) is Iter : Cursor := First (To.Clients); begin -- Dispatch_One makes the connection between the common implementation -- and the generics while Has_Element (Iter) loop declare Client : constant Subscriber_Access := Element (Iter); begin Client.Receive_Event (Item); end; Iter := Next (Iter); end loop; end Post; -- ----------------------- -- Subscribe to events sent on the event channel. -- ----------------------- procedure Subscribe (To : in out Channel; Client : in Subscriber_Access) is begin pragma Assert (Client /= null, "Client subscriber must not be null"); Append (To.Clients, Client); end Subscribe; -- ----------------------- -- Unsubscribe to events sent on the event channel. -- ----------------------- procedure Unsubscribe (To : in out Channel; Client : in Subscriber_Access) is Iter : Cursor := First (To.Clients); begin while Has_Element (Iter) loop if Element (Iter) = Client then Delete (To.Clients, Iter); return; end if; Iter := Next (Iter); end loop; end Unsubscribe; -- ----------------------- -- Create an event channel with the given name. The type of channel -- is controlled by <b>Kind</b>. -- ----------------------- function Create (Name : String; Kind : String) return Channel_Access is begin for I in Factory'Range loop if Factory (I).Name.all = Kind then return Factory (I).Creator (Name); end if; end loop; return Create_Direct_Channel (Name); end Create; -- ----------------------- -- Create an event channel that post the event immediately. -- ----------------------- function Create_Direct_Channel (Name : String) return Channel_Access is Result : constant Channel_Access := new Channel; begin Result.Name := To_Unbounded_String (Name); return Result; end Create_Direct_Channel; end Util.Events.Channels;
-- This package is intended to set up and tear down the test environment. -- Once created by GNATtest, this package will never be overwritten -- automatically. Contents of this package can be modified in any way -- except for sections surrounded by a 'read only' marker. with AUnit.Test_Fixtures; with GNATtest_Generated; package Tk.Image.Image_Options_Test_Data is type Image_Options_Access is access all GNATtest_Generated.GNATtest_Standard.Tk.Image.Image_Options' Class; -- begin read only type Test_Image_Options is abstract new AUnit.Test_Fixtures .Test_Fixture -- end read only with record Fixture: Image_Options_Access; end record; end Tk.Image.Image_Options_Test_Data;
-- -- Color tables, known as "palettes" -- private package GID.Color_tables is -- Load a palette on its defined range, according to -- the format and subformats loaded by initial -- steps in GID.Load_image_header procedure Load_palette (image: in out Image_descriptor); -- if image.palette = null, nothing happens. -- Convert a RGB value packed in 2 bytes -- (15 bit, 5 bit each channel) into a RGB_Color -- This is for the TGA format. procedure Convert(c, d: in U8; rgb: out RGB_color); end GID.Color_tables;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S E M _ S C I L -- -- -- -- S p e c -- -- -- -- Copyright (C) 2009-2020, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package contains routines involved in the frontend addition and -- verification of SCIL nodes. with Atree; use Atree; with Types; use Types; package Sem_SCIL is -- SCIL (Statically Checkable Intermediate Language) is produced by the -- CodePeer back end (aka gnat2scil). For some constructs (tagged type -- declarations, dispatching calls, classwide membership tests), the -- CodePeer back end needs to locate certain nodes in the tree. To allow -- CodePeer to do this without introducing unwanted dependencies on the -- details of the FE's expansion strategies, SCIL_Nodes are generated. -- For example, a dispatching call in the Ada source will, if CodePeer mode -- is enabled, result in the FE's generation of an N_Scil_Dispatching_Call -- node decorated with semantic attributes which identify the call itself, -- the primitive operation being called, the tagged type to which the -- operation belongs, and the controlling tag value of the call. If the FE -- implements some new expansion strategy for dispatching calls but this -- interface is preserved, the CodePeer back end should be unaffected. function Check_SCIL_Node (N : Node_Id) return Traverse_Result; -- Process a single node during the tree traversal. Done to verify that -- SCIL nodes decoration fulfill the requirements of the SCIL backend. procedure Check_SCIL_Nodes is new Traverse_Proc (Check_SCIL_Node); -- The traversal procedure itself function First_Non_SCIL_Node (L : List_Id) return Node_Id; -- Returns the first non-SCIL node of list L function Next_Non_SCIL_Node (N : Node_Id) return Node_Id; -- N must be a member of a list. Returns the next non SCIL node in the list -- containing N, or Empty if this is the last non SCIL node in the list. end Sem_SCIL;
----------------------------------------------------------------------- -- csv_city -- Read CSV file which contains city mapping -- Copyright (C) 2011, 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Text_IO; with Ada.Command_Line; with Ada.Containers; with Ada.Strings.Unbounded; with Util.Log.Loggers; with Util.Serialize.IO.CSV; with Util.Serialize.Mappers; with City_Mapping; procedure CSV_City is use Ada.Containers; use Ada.Strings.Unbounded; use Ada.Text_IO; use Util.Serialize.IO.CSV; Count : constant Natural := Ada.Command_Line.Argument_Count; begin Util.Log.Loggers.Initialize ("samples/log4j.properties"); if Count = 0 then Ada.Text_IO.Put_Line ("Usage: csv_city file [city...]"); Ada.Text_IO.Put_Line ("Example: csv_city samples/cities.csv albertville"); return; end if; declare File : constant String := Ada.Command_Line.Argument (1); List : aliased City_Mapping.City_Vector.Vector; Mapper : aliased Util.Serialize.Mappers.Processing; Reader : Util.Serialize.IO.CSV.Parser; begin Mapper.Add_Mapping ("", City_Mapping.Get_City_Vector_Mapper.all'Access); City_Mapping.City_Vector_Mapper.Set_Context (Mapper, List'Unchecked_Access); Reader.Parse (File, Mapper); if List.Length = 0 then Ada.Text_IO.Put_Line ("No city found."); elsif List.Length = 1 then Ada.Text_IO.Put_Line ("Found only one city."); else Ada.Text_IO.Put_Line ("Found " & Count_Type'Image (List.Length) & " cities"); end if; for I in 2 .. Count loop declare Name : constant String := Ada.Command_Line.Argument (I); Found : Boolean := False; procedure Print (City : in City_Mapping.City); procedure Print (City : in City_Mapping.City) is begin Found := City.City = Name; if Found then Ada.Text_IO.Put_Line ("City : " & To_String (City.Name)); Ada.Text_IO.Put_Line ("Country code: " & To_String (City.Country)); Ada.Text_IO.Put_Line ("Region : " & To_String (City.Region)); Ada.Text_IO.Put_Line ("Latitude : " & Float'Image (City.Latitude)); Ada.Text_IO.Put_Line ("Longitude : " & Float'Image (City.Longitude)); end if; end Print; begin for J in 1 .. Positive (List.Length) loop List.Query_Element (J, Print'Access); exit when Found; end loop; if not Found then Ada.Text_IO.Put_Line ("City '" & Name & "' not found"); end if; end; end loop; end; end CSV_City;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E X P _ C H 1 1 -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2005, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- 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 Casing; use Casing; with Debug; use Debug; with Einfo; use Einfo; with Errout; use Errout; with Exp_Ch7; use Exp_Ch7; with Exp_Util; use Exp_Util; with Hostparm; use Hostparm; with Namet; use Namet; with Nlists; use Nlists; with Nmake; use Nmake; with Opt; use Opt; with Rtsfind; use Rtsfind; with Restrict; use Restrict; with Rident; use Rident; with Sem; use Sem; with Sem_Ch8; use Sem_Ch8; with Sem_Res; use Sem_Res; with Sem_Util; use Sem_Util; with Sinfo; use Sinfo; with Sinput; use Sinput; with Snames; use Snames; with Stand; use Stand; with Stringt; use Stringt; with Targparm; use Targparm; with Tbuild; use Tbuild; with Uintp; use Uintp; package body Exp_Ch11 is --------------------------- -- Expand_At_End_Handler -- --------------------------- -- For a handled statement sequence that has a cleanup (At_End_Proc -- field set), an exception handler of the following form is required: -- exception -- when all others => -- cleanup call -- raise; -- Note: this exception handler is treated rather specially by -- subsequent expansion in two respects: -- The normal call to Undefer_Abort is omitted -- The raise call does not do Defer_Abort -- This is because the current tasking code seems to assume that -- the call to the cleanup routine that is made from an exception -- handler for the abort signal is called with aborts deferred. -- This expansion is only done if we have front end exception handling. -- If we have back end exception handling, then the AT END handler is -- left alone, and cleanups (including the exceptional case) are handled -- by the back end. -- In the front end case, the exception handler described above handles -- the exceptional case. The AT END handler is left in the generated tree -- and the code generator (e.g. gigi) must still handle proper generation -- of cleanup calls for the non-exceptional case. procedure Expand_At_End_Handler (HSS : Node_Id; Block : Node_Id) is Clean : constant Entity_Id := Entity (At_End_Proc (HSS)); Loc : constant Source_Ptr := Sloc (Clean); Ohandle : Node_Id; Stmnts : List_Id; begin pragma Assert (Present (Clean)); pragma Assert (No (Exception_Handlers (HSS))); -- Don't expand if back end exception handling active if Exception_Mechanism = Back_End_Exceptions then return; end if; -- Don't expand an At End handler if we have already had configurable -- run-time violations, since likely this will just be a matter of -- generating useless cascaded messages if Configurable_Run_Time_Violations > 0 then return; end if; if Restriction_Active (No_Exception_Handlers) then return; end if; if Present (Block) then New_Scope (Block); end if; Ohandle := Make_Others_Choice (Loc); Set_All_Others (Ohandle); Stmnts := New_List ( Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (Clean, Loc)), Make_Raise_Statement (Loc)); Set_Exception_Handlers (HSS, New_List ( Make_Exception_Handler (Loc, Exception_Choices => New_List (Ohandle), Statements => Stmnts))); Analyze_List (Stmnts, Suppress => All_Checks); Expand_Exception_Handlers (HSS); if Present (Block) then Pop_Scope; end if; end Expand_At_End_Handler; ------------------------------- -- Expand_Exception_Handlers -- ------------------------------- procedure Expand_Exception_Handlers (HSS : Node_Id) is Handlrs : constant List_Id := Exception_Handlers (HSS); Loc : Source_Ptr; Handler : Node_Id; Others_Choice : Boolean; Obj_Decl : Node_Id; procedure Prepend_Call_To_Handler (Proc : RE_Id; Args : List_Id := No_List); -- Routine to prepend a call to the procedure referenced by Proc at -- the start of the handler code for the current Handler. ----------------------------- -- Prepend_Call_To_Handler -- ----------------------------- procedure Prepend_Call_To_Handler (Proc : RE_Id; Args : List_Id := No_List) is Ent : constant Entity_Id := RTE (Proc); begin -- If we have no Entity, then we are probably in no run time mode -- or some weird error has occured. In either case do do nothing! if Present (Ent) then declare Call : constant Node_Id := Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (Proc), Loc), Parameter_Associations => Args); begin Prepend_To (Statements (Handler), Call); Analyze (Call, Suppress => All_Checks); end; end if; end Prepend_Call_To_Handler; -- Start of processing for Expand_Exception_Handlers begin -- Loop through handlers Handler := First_Non_Pragma (Handlrs); Handler_Loop : while Present (Handler) loop Loc := Sloc (Handler); -- Remove source handler if gnat debug flag N is set if Debug_Flag_Dot_X and then Comes_From_Source (Handler) then declare H : constant Node_Id := Handler; begin Next_Non_Pragma (Handler); Remove (H); goto Continue_Handler_Loop; end; end if; -- If an exception occurrence is present, then we must declare it -- and initialize it from the value stored in the TSD -- declare -- name : Exception_Occurrence; -- -- begin -- Save_Occurrence (name, Get_Current_Excep.all) -- ... -- end; if Present (Choice_Parameter (Handler)) then declare Cparm : constant Entity_Id := Choice_Parameter (Handler); Clc : constant Source_Ptr := Sloc (Cparm); Save : Node_Id; begin Save := Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Save_Occurrence), Loc), Parameter_Associations => New_List ( New_Occurrence_Of (Cparm, Clc), Make_Explicit_Dereference (Loc, Make_Function_Call (Loc, Name => Make_Explicit_Dereference (Loc, New_Occurrence_Of (RTE (RE_Get_Current_Excep), Loc)))))); Mark_Rewrite_Insertion (Save); Prepend (Save, Statements (Handler)); Obj_Decl := Make_Object_Declaration (Clc, Defining_Identifier => Cparm, Object_Definition => New_Occurrence_Of (RTE (RE_Exception_Occurrence), Clc)); Set_No_Initialization (Obj_Decl, True); Rewrite (Handler, Make_Exception_Handler (Loc, Exception_Choices => Exception_Choices (Handler), Statements => New_List ( Make_Block_Statement (Loc, Declarations => New_List (Obj_Decl), Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => Statements (Handler)))))); Analyze_List (Statements (Handler), Suppress => All_Checks); end; end if; -- The processing at this point is rather different for the -- JVM case, so we completely separate the processing. -- For the JVM case, we unconditionally call Update_Exception, -- passing a call to the intrinsic function Current_Target_Exception -- (see JVM version of Ada.Exceptions in 4jexcept.adb for details). if Hostparm.Java_VM then declare Arg : constant Node_Id := Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_Current_Target_Exception), Loc)); begin Prepend_Call_To_Handler (RE_Update_Exception, New_List (Arg)); end; -- For the normal case, we have to worry about the state of abort -- deferral. Generally, we defer abort during runtime handling of -- exceptions. When control is passed to the handler, then in the -- normal case we undefer aborts. In any case this entire handling -- is relevant only if aborts are allowed! elsif Abort_Allowed then -- There are some special cases in which we do not do the -- undefer. In particular a finalization (AT END) handler -- wants to operate with aborts still deferred. -- We also suppress the call if this is the special handler -- for Abort_Signal, since if we are aborting, we want to keep -- aborts deferred (one abort is enough thank you very much :-) -- If abort really needs to be deferred the expander must add -- this call explicitly, see Exp_Ch9.Expand_N_Asynchronous_Select. Others_Choice := Nkind (First (Exception_Choices (Handler))) = N_Others_Choice; if (Others_Choice or else Entity (First (Exception_Choices (Handler))) /= Stand.Abort_Signal) and then not (Others_Choice and then All_Others (First (Exception_Choices (Handler)))) and then Abort_Allowed then Prepend_Call_To_Handler (RE_Abort_Undefer); end if; end if; Next_Non_Pragma (Handler); <<Continue_Handler_Loop>> null; end loop Handler_Loop; -- If all handlers got removed by gnatdN, then remove the list if Debug_Flag_Dot_X and then Is_Empty_List (Exception_Handlers (HSS)) then Set_Exception_Handlers (HSS, No_List); end if; end Expand_Exception_Handlers; ------------------------------------ -- Expand_N_Exception_Declaration -- ------------------------------------ -- Generates: -- exceptE : constant String := "A.B.EXCEP"; -- static data -- except : exception_data := ( -- Handled_By_Other => False, -- Lang => 'A', -- Name_Length => exceptE'Length, -- Full_Name => exceptE'Address, -- HTable_Ptr => null, -- Import_Code => 0, -- Raise_Hook => null, -- ); -- (protecting test only needed if not at library level) -- -- exceptF : Boolean := True -- static data -- if exceptF then -- exceptF := False; -- Register_Exception (except'Unchecked_Access); -- end if; procedure Expand_N_Exception_Declaration (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Id : constant Entity_Id := Defining_Identifier (N); L : List_Id := New_List; Flag_Id : Entity_Id; Name_Exname : constant Name_Id := New_External_Name (Chars (Id), 'E'); Exname : constant Node_Id := Make_Defining_Identifier (Loc, Name_Exname); begin -- There is no expansion needed when compiling for the JVM since the -- JVM has a built-in exception mechanism. See 4jexcept.ads for details. if Hostparm.Java_VM then return; end if; -- Definition of the external name: nam : constant String := "A.B.NAME"; Insert_Action (N, Make_Object_Declaration (Loc, Defining_Identifier => Exname, Constant_Present => True, Object_Definition => New_Occurrence_Of (Standard_String, Loc), Expression => Make_String_Literal (Loc, Full_Qualified_Name (Id)))); Set_Is_Statically_Allocated (Exname); -- Create the aggregate list for type Standard.Exception_Type: -- Handled_By_Other component: False Append_To (L, New_Occurrence_Of (Standard_False, Loc)); -- Lang component: 'A' Append_To (L, Make_Character_Literal (Loc, Chars => Name_uA, Char_Literal_Value => UI_From_Int (Character'Pos ('A')))); -- Name_Length component: Nam'Length Append_To (L, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Exname, Loc), Attribute_Name => Name_Length)); -- Full_Name component: Standard.A_Char!(Nam'Address) Append_To (L, Unchecked_Convert_To (Standard_A_Char, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Exname, Loc), Attribute_Name => Name_Address))); -- HTable_Ptr component: null Append_To (L, Make_Null (Loc)); -- Import_Code component: 0 Append_To (L, Make_Integer_Literal (Loc, 0)); -- Raise_Hook component: null Append_To (L, Make_Null (Loc)); Set_Expression (N, Make_Aggregate (Loc, Expressions => L)); Analyze_And_Resolve (Expression (N), Etype (Id)); -- Register_Exception (except'Unchecked_Access); if not Restriction_Active (No_Exception_Handlers) and then not Restriction_Active (No_Exception_Registration) then L := New_List ( Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Register_Exception), Loc), Parameter_Associations => New_List ( Unchecked_Convert_To (RTE (RE_Exception_Data_Ptr), Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Id, Loc), Attribute_Name => Name_Unrestricted_Access))))); Set_Register_Exception_Call (Id, First (L)); if not Is_Library_Level_Entity (Id) then Flag_Id := Make_Defining_Identifier (Loc, New_External_Name (Chars (Id), 'F')); Insert_Action (N, Make_Object_Declaration (Loc, Defining_Identifier => Flag_Id, Object_Definition => New_Occurrence_Of (Standard_Boolean, Loc), Expression => New_Occurrence_Of (Standard_True, Loc))); Set_Is_Statically_Allocated (Flag_Id); Append_To (L, Make_Assignment_Statement (Loc, Name => New_Occurrence_Of (Flag_Id, Loc), Expression => New_Occurrence_Of (Standard_False, Loc))); Insert_After_And_Analyze (N, Make_Implicit_If_Statement (N, Condition => New_Occurrence_Of (Flag_Id, Loc), Then_Statements => L)); else Insert_List_After_And_Analyze (N, L); end if; end if; end Expand_N_Exception_Declaration; --------------------------------------------- -- Expand_N_Handled_Sequence_Of_Statements -- --------------------------------------------- procedure Expand_N_Handled_Sequence_Of_Statements (N : Node_Id) is begin if Present (Exception_Handlers (N)) and then not Restriction_Active (No_Exception_Handlers) then Expand_Exception_Handlers (N); end if; -- The following code needs comments ??? if Nkind (Parent (N)) /= N_Package_Body and then Nkind (Parent (N)) /= N_Accept_Statement and then not Delay_Cleanups (Current_Scope) then Expand_Cleanup_Actions (Parent (N)); else Set_First_Real_Statement (N, First (Statements (N))); end if; end Expand_N_Handled_Sequence_Of_Statements; ------------------------------------- -- Expand_N_Raise_Constraint_Error -- ------------------------------------- -- The only processing required is to adjust the condition to deal -- with the C/Fortran boolean case. This may well not be necessary, -- as all such conditions are generated by the expander and probably -- are all standard boolean, but who knows what strange optimization -- in future may require this adjustment! procedure Expand_N_Raise_Constraint_Error (N : Node_Id) is begin Adjust_Condition (Condition (N)); end Expand_N_Raise_Constraint_Error; ---------------------------------- -- Expand_N_Raise_Program_Error -- ---------------------------------- -- The only processing required is to adjust the condition to deal -- with the C/Fortran boolean case. This may well not be necessary, -- as all such conditions are generated by the expander and probably -- are all standard boolean, but who knows what strange optimization -- in future may require this adjustment! procedure Expand_N_Raise_Program_Error (N : Node_Id) is begin Adjust_Condition (Condition (N)); end Expand_N_Raise_Program_Error; ------------------------------ -- Expand_N_Raise_Statement -- ------------------------------ procedure Expand_N_Raise_Statement (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); Ehand : Node_Id; E : Entity_Id; Str : String_Id; begin -- If a string expression is present, then the raise statement is -- converted to a call: -- Raise_Exception (exception-name'Identity, string); -- and there is nothing else to do if Present (Expression (N)) then Rewrite (N, Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Raise_Exception), Loc), Parameter_Associations => New_List ( Make_Attribute_Reference (Loc, Prefix => Name (N), Attribute_Name => Name_Identity), Expression (N)))); Analyze (N); return; end if; -- Remaining processing is for the case where no string expression -- is present. -- There is no expansion needed for statement "raise <exception>;" when -- compiling for the JVM since the JVM has a built-in exception -- mechanism. However we need the keep the expansion for "raise;" -- statements. See 4jexcept.ads for details. if Present (Name (N)) and then Hostparm.Java_VM then return; end if; -- Don't expand a raise statement that does not come from source -- if we have already had configurable run-time violations, since -- most likely it will be junk cascaded nonsense. if Configurable_Run_Time_Violations > 0 and then not Comes_From_Source (N) then return; end if; -- Convert explicit raise of Program_Error, Constraint_Error, and -- Storage_Error into the corresponding raise (in High_Integrity_Mode -- all other raises will get normal expansion and be disallowed, -- but this is also faster in all modes). if Present (Name (N)) and then Nkind (Name (N)) = N_Identifier then if Entity (Name (N)) = Standard_Constraint_Error then Rewrite (N, Make_Raise_Constraint_Error (Loc, Reason => CE_Explicit_Raise)); Analyze (N); return; elsif Entity (Name (N)) = Standard_Program_Error then Rewrite (N, Make_Raise_Program_Error (Loc, Reason => PE_Explicit_Raise)); Analyze (N); return; elsif Entity (Name (N)) = Standard_Storage_Error then Rewrite (N, Make_Raise_Storage_Error (Loc, Reason => SE_Explicit_Raise)); Analyze (N); return; end if; end if; -- Case of name present, in this case we expand raise name to -- Raise_Exception (name'Identity, location_string); -- where location_string identifies the file/line of the raise if Present (Name (N)) then declare Id : Entity_Id := Entity (Name (N)); begin Build_Location_String (Loc); -- If the exception is a renaming, use the exception that it -- renames (which might be a predefined exception, e.g.). if Present (Renamed_Object (Id)) then Id := Renamed_Object (Id); end if; -- Build a C-compatible string in case of no exception handlers, -- since this is what the last chance handler is expecting. if Restriction_Active (No_Exception_Handlers) then -- Generate an empty message if configuration pragma -- Suppress_Exception_Locations is set for this unit. if Opt.Exception_Locations_Suppressed then Name_Len := 1; else Name_Len := Name_Len + 1; end if; Name_Buffer (Name_Len) := ASCII.NUL; end if; if Opt.Exception_Locations_Suppressed then Name_Len := 0; end if; Str := String_From_Name_Buffer; -- For VMS exceptions, convert the raise into a call to -- lib$stop so it will be handled by __gnat_error_handler. if Is_VMS_Exception (Id) then declare Excep_Image : String_Id; Cond : Node_Id; begin if Present (Interface_Name (Id)) then Excep_Image := Strval (Interface_Name (Id)); else Get_Name_String (Chars (Id)); Set_All_Upper_Case; Excep_Image := String_From_Name_Buffer; end if; if Exception_Code (Id) /= No_Uint then Cond := Make_Integer_Literal (Loc, Exception_Code (Id)); else Cond := Unchecked_Convert_To (Standard_Integer, Make_Function_Call (Loc, Name => New_Occurrence_Of (RTE (RE_Import_Value), Loc), Parameter_Associations => New_List (Make_String_Literal (Loc, Strval => Excep_Image)))); end if; Rewrite (N, Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Lib_Stop), Loc), Parameter_Associations => New_List (Cond))); Analyze_And_Resolve (Cond, Standard_Integer); end; -- Not VMS exception case, convert raise to call to the -- Raise_Exception routine. else Rewrite (N, Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (RTE (RE_Raise_Exception), Loc), Parameter_Associations => New_List ( Make_Attribute_Reference (Loc, Prefix => Name (N), Attribute_Name => Name_Identity), Make_String_Literal (Loc, Strval => Str)))); end if; end; -- Case of no name present (reraise). We rewrite the raise to: -- Reraise_Occurrence_Always (EO); -- where EO is the current exception occurrence. If the current handler -- does not have a choice parameter specification, then we provide one. else -- Find innermost enclosing exception handler (there must be one, -- since the semantics has already verified that this raise statement -- is valid, and a raise with no arguments is only permitted in the -- context of an exception handler. Ehand := Parent (N); while Nkind (Ehand) /= N_Exception_Handler loop Ehand := Parent (Ehand); end loop; -- Make exception choice parameter if none present. Note that we do -- not need to put the entity on the entity chain, since no one will -- be referencing this entity by normal visibility methods. if No (Choice_Parameter (Ehand)) then E := Make_Defining_Identifier (Loc, New_Internal_Name ('E')); Set_Choice_Parameter (Ehand, E); Set_Ekind (E, E_Variable); Set_Etype (E, RTE (RE_Exception_Occurrence)); Set_Scope (E, Current_Scope); end if; -- Now rewrite the raise as a call to Reraise. A special case arises -- if this raise statement occurs in the context of a handler for -- all others (i.e. an at end handler). in this case we avoid -- the call to defer abort, cleanup routines are expected to be -- called in this case with aborts deferred. declare Ech : constant Node_Id := First (Exception_Choices (Ehand)); Ent : Entity_Id; begin if Nkind (Ech) = N_Others_Choice and then All_Others (Ech) then Ent := RTE (RE_Reraise_Occurrence_No_Defer); else Ent := RTE (RE_Reraise_Occurrence_Always); end if; Rewrite (N, Make_Procedure_Call_Statement (Loc, Name => New_Occurrence_Of (Ent, Loc), Parameter_Associations => New_List ( New_Occurrence_Of (Choice_Parameter (Ehand), Loc)))); end; end if; Analyze (N); end Expand_N_Raise_Statement; ---------------------------------- -- Expand_N_Raise_Storage_Error -- ---------------------------------- -- The only processing required is to adjust the condition to deal -- with the C/Fortran boolean case. This may well not be necessary, -- as all such conditions are generated by the expander and probably -- are all standard boolean, but who knows what strange optimization -- in future may require this adjustment! procedure Expand_N_Raise_Storage_Error (N : Node_Id) is begin Adjust_Condition (Condition (N)); end Expand_N_Raise_Storage_Error; ------------------------------ -- Expand_N_Subprogram_Info -- ------------------------------ procedure Expand_N_Subprogram_Info (N : Node_Id) is Loc : constant Source_Ptr := Sloc (N); begin -- For now, we replace an Expand_N_Subprogram_Info node with an -- attribute reference that gives the address of the procedure. -- This is because gigi does not yet recognize this node, and -- for the initial targets, this is the right value anyway. Rewrite (N, Make_Attribute_Reference (Loc, Prefix => Identifier (N), Attribute_Name => Name_Code_Address)); Analyze_And_Resolve (N, RTE (RE_Code_Loc)); end Expand_N_Subprogram_Info; ---------------------- -- Is_Non_Ada_Error -- ---------------------- function Is_Non_Ada_Error (E : Entity_Id) return Boolean is begin if not OpenVMS_On_Target then return False; end if; Get_Name_String (Chars (E)); -- Note: it is a little irregular for the body of exp_ch11 to know -- the details of the encoding scheme for names, but on the other -- hand, gigi knows them, and this is for gigi's benefit anyway! if Name_Buffer (1 .. 30) /= "system__aux_dec__non_ada_error" then return False; end if; return True; end Is_Non_Ada_Error; end Exp_Ch11;
-- Copyright (c) 2021 Devin Hill -- zlib License -- see LICENSE for details. with GBA.Numerics.Vectors; generic with package V is new GBA.Numerics.Vectors(<>); package GBA.Numerics.Matrices is subtype Dim is V.Dim; subtype Vec is V.Vec; subtype Element is V.Element; type Mat is array (Dim, Dim) of Element; function From_Cols (C0, C1 : Vec) return Mat with Pure_Function, Inline; function From_Rows (R0, R1 : Vec) return Mat with Pure_Function, Inline; function Col (M : Mat; C : Dim) return Vec with Pure_Function, Inline; function Row (M : Mat; R : Dim) return Vec with Pure_Function, Inline; function To_Affine_Transform (M : Mat) return Affine_Transform_Matrix with Pure_Function, Inline; generic with function Operator (X, Y : Element) return Element; function Pointwise (N, M : Mat) return Mat; generic with function Operator (X, Y : Element) return Element; function Scalar (M : Mat; E : Element) return Mat; function "+" (M, N : Mat) return Mat with Pure_Function, Inline; function "-" (M, N : Mat) return Mat with Pure_Function, Inline; function "*" (M, N : Mat) return Mat with Pure_Function, Inline; function "/" (M, N : Mat) return Mat with Pure_Function, Inline; function "+" (M : Mat; E : Element) return Mat with Pure_Function, Inline; function "-" (M : Mat; E : Element) return Mat with Pure_Function, Inline; function "*" (M : Mat; E : Element) return Mat with Pure_Function, Inline; function "/" (M : Mat; E : Element) return Mat with Pure_Function, Inline; function Mul (M, N : Mat) return Mat with Pure_Function, Inline; function Mul (M : Mat; V : Vec) return Vec with Pure_Function, Inline; function Determinant (M : Mat) return Element with Pure_Function, Inline; function Inverse (M : Mat) return Mat with Pure_Function, Inline; end GBA.Numerics.Matrices;
-- bkp-files -- File and directories ----------------------------------------------------------------------- -- Copyright (C) 2014 Stephane.Carrez -- Written by Stephane.Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Calendar.Conversions; with Interfaces.C; with Util.Log.Loggers; with Util.Files; with Util.Encoders.Base16; package body Babel.Files is Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Bkp.Files"); Hex_Encoder : Util.Encoders.Base16.Encoder; -- ------------------------------ -- Compare two files on their name and directory. -- ------------------------------ function "<" (Left, Right : in File_Type) return Boolean is use type Ada.Strings.Unbounded.Unbounded_String; begin if Left = NO_FILE then return False; elsif Right = NO_FILE then return True; elsif Left.Dir = Right.Dir then return Left.Name < Right.Name; elsif Left.Dir = NO_DIRECTORY then return True; elsif Right.Dir = NO_DIRECTORY then return False; else return Left.Dir.Name.all < Right.Dir.Name.all; end if; end "<"; -- ------------------------------ -- Allocate a File_Type entry with the given name for the directory. -- ------------------------------ function Allocate (Name : in String; Dir : in Directory_Type) return File_Type is use Ada.Strings.Unbounded; Result : constant File_Type := new File '(Len => Name'Length, Id => NO_IDENTIFIER, Dir => Dir, Name => Name, others => <>); begin return Result; end Allocate; -- ------------------------------ -- Allocate a Directory_Type entry with the given name for the directory. -- ------------------------------ function Allocate (Name : in String; Dir : in Directory_Type) return Directory_Type is Path : String_Access; Result : constant Directory_Type := new Directory '(Id => NO_IDENTIFIER, Parent => Dir, others => <>); begin if Dir /= null then Path := new String '(Util.Files.Compose (Dir.Name.all, Name)); Result.Name_Pos := Dir.Name'Length + 1; else Path := new String '(Name); Result.Name_Pos := 1; end if; Result.Name := Path; return Result; end Allocate; -- ------------------------------ -- Return true if the file was modified and need a backup. -- ------------------------------ function Is_Modified (Element : in File_Type) return Boolean is use type ADO.Identifier; begin if Element.Id = NO_IDENTIFIER then return True; elsif (Element.Status and FILE_MODIFIED) /= 0 then return True; else return False; end if; end Is_Modified; -- ------------------------------ -- Return true if the file is a new file. -- ------------------------------ function Is_New (Element : in File_Type) return Boolean is use type ADO.Identifier; begin return Element.Id = NO_IDENTIFIER; end Is_New; -- ------------------------------ -- Set the file as modified. -- ------------------------------ procedure Set_Modified (Element : in File_Type) is begin Element.Status := Element.Status or FILE_MODIFIED; end Set_Modified; -- ------------------------------ -- Set the SHA1 signature that was computed for this file. -- If the computed signature is different from the current signature, -- the FILE_MODIFIED flag is set on the file. The FILE_HAS_SHA1 flag -- is set on the file. -- ------------------------------ procedure Set_Signature (Element : in File_Type; Signature : in Util.Encoders.SHA1.Hash_Array) is use type Util.Encoders.SHA1.Hash_Array; begin if (Element.Status and FILE_HAS_SHA1) /= 0 and then Element.SHA1 /= Signature then Element.Status := Element.Status or FILE_MODIFIED; end if; Element.Status := Element.Status or FILE_HAS_SHA1; Element.SHA1 := Signature; end Set_Signature; -- ------------------------------ -- Set the file size. If the new size is different, the FILE_MODIFIED -- flag is set on the file. -- ------------------------------ procedure Set_Size (Element : in File_Type; Size : in File_Size) is begin if Element.Size /= Size then Element.Size := Size; Element.Status := Element.Status or FILE_MODIFIED; end if; end Set_Size; -- ------------------------------ -- Set the owner and group of the file. -- ------------------------------ procedure Set_Owner (Element : in File_Type; User : in Uid_Type; Group : in Gid_Type) is begin Element.User := User; Element.Group := Group; end Set_Owner; -- ------------------------------ -- Set the file modification date. -- ------------------------------ procedure Set_Date (Element : in File_Type; Date : in Util.Systems.Types.Timespec) is begin Set_Date (Element, Ada.Calendar.Conversions.To_Ada_Time (Interfaces.C.long (Date.tv_sec))); end Set_Date; procedure Set_Date (Element : in File_Type; Date : in Ada.Calendar.Time) is use type Ada.Calendar.Time; begin if Element.Date /= Date then Element.Date := Date; Element.Status := Element.Status or FILE_MODIFIED; end if; end Set_Date; -- ------------------------------ -- Return the path for the file. -- ------------------------------ function Get_Path (Element : in File_Type) return String is begin if Element.Dir = null then return Element.Name; else return Util.Files.Compose (Get_Path (Element.Dir), Element.Name); end if; end Get_Path; -- ------------------------------ -- Return the path for the directory. -- ------------------------------ function Get_Path (Element : in Directory_Type) return String is begin return Element.Name.all; end Get_Path; -- ------------------------------ -- Return the SHA1 signature computed for the file. -- ------------------------------ function Get_SHA1 (Element : in File_Type) return String is begin return Hex_Encoder.Transform (Element.SHA1); end Get_SHA1; -- ------------------------------ -- Return the file size. -- ------------------------------ function Get_Size (Element : in File_Type) return File_Size is begin return Element.Size; end Get_Size; -- ------------------------------ -- Return the file modification date. -- ------------------------------ function Get_Date (Element : in File_Type) return Ada.Calendar.Time is begin return Element.Date; end Get_Date; -- ------------------------------ -- Return the user uid. -- ------------------------------ function Get_User (Element : in File_Type) return Uid_Type is begin return Element.User; end Get_User; -- ------------------------------ -- Return the group gid. -- ------------------------------ function Get_Group (Element : in File_Type) return Gid_Type is begin return Element.Group; end Get_Group; -- ------------------------------ -- Return the file unix mode. -- ------------------------------ function Get_Mode (Element : in File_Type) return File_Mode is begin return Element.Mode; end Get_Mode; -- ------------------------------ -- Add the file with the given name in the container. -- ------------------------------ overriding procedure Add_File (Into : in out Default_Container; Element : in File_Type) is begin Into.Files.Append (Element); end Add_File; -- ------------------------------ -- Add the directory with the given name in the container. -- ------------------------------ overriding procedure Add_Directory (Into : in out Default_Container; Element : in Directory_Type) is begin Into.Dirs.Append (Element); end Add_Directory; -- ------------------------------ -- Create a new file instance with the given name in the container. -- ------------------------------ overriding function Create (Into : in Default_Container; Name : in String) return File_Type is begin return Allocate (Name => Name, Dir => Into.Current); end Create; -- ------------------------------ -- Create a new directory instance with the given name in the container. -- ------------------------------ overriding function Create (Into : in Default_Container; Name : in String) return Directory_Type is begin return Allocate (Name => Name, Dir => Into.Current); end Create; -- ------------------------------ -- Find the file with the given name in this file container. -- Returns NO_FILE if the file was not found. -- ------------------------------ overriding function Find (From : in Default_Container; Name : in String) return File_Type is pragma Unreferenced (From, Name); begin return NO_FILE; end Find; -- ------------------------------ -- Find the directory with the given name in this file container. -- Returns NO_DIRECTORY if the directory was not found. -- ------------------------------ overriding function Find (From : in Default_Container; Name : in String) return Directory_Type is pragma Unreferenced (From, Name); begin return NO_DIRECTORY; end Find; -- ------------------------------ -- Set the directory object associated with the container. -- ------------------------------ procedure Set_Directory (Into : in out Default_Container; Directory : in Directory_Type) is begin Into.Current := Directory; Into.Files.Clear; Into.Dirs.Clear; end Set_Directory; -- ------------------------------ -- Execute the Process procedure on each directory found in the container. -- ------------------------------ overriding procedure Each_Directory (Container : in Default_Container; Process : not null access procedure (Dir : in Directory_Type)) is Iter : Directory_Vectors.Cursor := Container.Dirs.First; begin while Directory_Vectors.Has_Element (Iter) loop Process (Directory_Vectors.Element (Iter)); Directory_Vectors.Next (Iter); end loop; end Each_Directory; -- ------------------------------ -- Execute the Process procedure on each file found in the container. -- ------------------------------ overriding procedure Each_File (Container : in Default_Container; Process : not null access procedure (F : in File_Type)) is Iter : File_Vectors.Cursor := Container.Files.First; begin while File_Vectors.Has_Element (Iter) loop Process (File_Vectors.Element (Iter)); File_Vectors.Next (Iter); end loop; end Each_File; end Babel.Files;
-- BinToAsc_Suite.Base16_Tests -- Unit tests for BinToAsc -- Copyright (c) 2015, James Humphry - see LICENSE file for details with Ada.Assertions; with AUnit.Assertions; with System.Storage_Elements; with String_To_Storage_Array; package body BinToAsc_Suite.Base16_Tests is use AUnit.Assertions; use System.Storage_Elements; use RFC4648; use type RFC4648.Codec_State; function STSA (X : String) return Storage_Array renames String_To_Storage_Array; -------------------- -- Register_Tests -- -------------------- procedure Register_Tests (T: in out Base16_Test) is use AUnit.Test_Cases.Registration; begin Register_Routine (T, Check_Symmetry'Access, "Check the Encoder and Decoder are a symmetrical pair"); Register_Routine (T, Check_Length'Access, "Check the Encoder and Decoder handle variable-length input successfully"); Register_Routine (T, Check_Test_Vectors_To_String'Access, "Check test vectors from RFC4648, binary -> string"); Register_Routine (T, Check_Test_Vectors_To_Bin'Access, "Check test vectors from RFC4648, string -> binary"); Register_Routine (T, Check_Test_Vectors_Incremental_To_String'Access, "Check test vectors from RFC4648, incrementally, binary -> string"); Register_Routine (T, Check_Test_Vectors_Incremental_To_Bin'Access, "Check test vectors from RFC4648, incrementally, string -> binary"); Register_Routine (T, Check_Test_Vectors_By_Char_To_String'Access, "Check test vectors from RFC4648, character-by-character, binary -> string"); Register_Routine (T, Check_Test_Vectors_By_Char_To_Bin'Access, "Check test vectors from RFC4648, character-by-character, string -> binary"); Register_Routine (T, Check_Junk_Rejection'Access, "Check Base16 decoder will reject junk input"); Register_Routine (T, Check_Junk_Rejection_By_Char'Access, "Check Base16 decoder will reject junk input (single character)"); Register_Routine (T, Check_Incomplete_Group_Rejection'Access, "Check Base16 decoder will reject incomplete groups in input"); Register_Routine (T, Check_Case_Insensitive'Access, "Check Base16_Case_Insensitive decoder will accept mixed-case input"); end Register_Tests; ---------- -- Name -- ---------- function Name (T : Base16_Test) return Test_String is pragma Unreferenced (T); begin return Format ("Tests of Base16 codec from RFC4648"); end Name; ------------ -- Set_Up -- ------------ procedure Set_Up (T : in out Base16_Test) is begin null; end Set_Up; -------------------------- -- Check_Junk_Rejection -- -------------------------- -- This procedure cannot be nested inside Check_Junk_Rejection due to access -- level restrictions procedure Should_Raise_Exception_From_Junk is Discard : Storage_Array(1..6); begin Discard := RFC4648.Base16.To_Bin("666F6F6Z6172"); end; procedure Check_Junk_Rejection (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced (T); Base16_Decoder : RFC4648.Base16.Base16_To_Bin; Result_Bin : Storage_Array(1..20); Result_Length : Storage_Offset; begin Assert_Exception(Should_Raise_Exception_From_Junk'Access, "Base16 decoder did not reject junk input."); Base16_Decoder.Reset; Base16_Decoder.Process(Input => "666F6F6Z6172", Output => Result_Bin, Output_Length => Result_Length); Assert(Base16_Decoder.State = Failed, "Base16 decoder did not reject junk input."); Assert(Result_Length = 0, "Base16 decoder rejected junk input but did not return 0 " & "length output."); begin Base16_Decoder.Process(Input => "66", Output => Result_Bin, Output_Length => Result_Length); exception when Ada.Assertions.Assertion_Error => null; -- Preconditions (if active) will not allow Process to be run -- on a codec with state /= Ready. end; Assert(Base16_Decoder.State = Failed, "Base16 decoder reset its state on valid input after junk input."); Assert(Result_Length = 0, "Base16 decoder rejected input after a junk input but did " & "not return 0 length output."); begin Base16_Decoder.Complete(Output => Result_Bin, Output_Length => Result_Length); exception when Ada.Assertions.Assertion_Error => null; -- Preconditions (if active) will not allow Completed to be run -- on a codec with state /= Ready. end; Assert(Base16_Decoder.State = Failed, "Base16 decoder allowed successful completion after junk input."); Assert(Result_Length = 0, "Base16 decoder completed after a junk input did " & "not return 0 length output."); end Check_Junk_Rejection; ---------------------------------- -- Check_Junk_Rejection_By_Char -- ---------------------------------- procedure Check_Junk_Rejection_By_Char (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced (T); Base16_Decoder : RFC4648.Base16.Base16_To_Bin; Result_Bin : Storage_Array(1..20); Result_Length : Storage_Offset; begin Base16_Decoder.Reset; Base16_Decoder.Process(Input => 'Y', Output => Result_Bin, Output_Length => Result_Length); Assert(Base16_Decoder.State = Failed, "Base16 decoder did not reject junk input character."); Assert(Result_Length = 0, "Base16 decoder rejected junk input but did not return 0 " & "length output."); begin Base16_Decoder.Process(Input => '6', Output => Result_Bin, Output_Length => Result_Length); exception when Ada.Assertions.Assertion_Error => null; -- Preconditions (if active) will not allow Process to be run -- on a codec with state /= Ready. end; Assert(Base16_Decoder.State = Failed, "Base16 decoder reset its state on valid input after junk input " & "character."); Assert(Result_Length = 0, "Base16 decoder rejected input after a junk input char but did " & "not return 0 length output."); begin Base16_Decoder.Complete(Output => Result_Bin, Output_Length => Result_Length); exception when Ada.Assertions.Assertion_Error => null; -- Preconditions (if active) will not allow Completed to be run -- on a codec with state /= Ready. end; Assert(Base16_Decoder.State = Failed, "Base16 decoder allowed successful completion after junk input " & "char."); Assert(Result_Length = 0, "Base16 decoder completed after a junk input char did " & "not return 0 length output."); end Check_Junk_Rejection_By_Char; -------------------------------------- -- Check_Incomplete_Group_Rejection -- -------------------------------------- procedure Check_Incomplete_Group_Rejection (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced (T); Base16_Decoder : RFC4648.Base16.Base16_To_Bin; Result_Bin : Storage_Array (1..20); Result_Length : Storage_Offset; begin Base16_Decoder.Reset; Base16_Decoder.Process(Input => "666F6F6", Output => Result_Bin, Output_Length => Result_Length); Base16_Decoder.Complete(Output => Result_Bin, Output_Length => Result_Length); Assert(Base16_Decoder.State = Failed, "Base16 decoder did not complain " & "about receiving an incomplete group."); end Check_Incomplete_Group_Rejection; ---------------------------- -- Check_Case_Insensitive -- ---------------------------- procedure Check_Case_Insensitive (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced(T); Test_Input : constant Storage_Array := STSA("foobar"); Encoded : constant String := "666F6F626172"; Encoded_Mixed_Case : constant String := "666F6f626172"; Base16_Decoder : RFC4648.Base16.Base16_To_Bin; Buffer : Storage_Array(1..7); Buffer_Used : Storage_Offset; begin Assert(Test_Input = RFC4648.Base16.To_Bin(Encoded), "Base16 case-sensitive decoder not working"); Base16_Decoder.Reset; Base16_Decoder.Process(Encoded_Mixed_Case, Buffer, Buffer_Used); Assert(Base16_Decoder.State = Failed and Buffer_Used = 0, "Base16 case-sensitive decoder did not reject mixed-case input"); Assert(Test_Input = RFC4648.Base16_Case_Insensitive.To_Bin(Encoded_Mixed_Case), "Base16 case-insensitive decoder not working"); end Check_Case_Insensitive; end BinToAsc_Suite.Base16_Tests;
with Ada.Text_IO; use Ada.Text_IO; package body Metric is C3_M : constant GA_Maths.Float_Matrix (1 .. 5, 1 .. 5) := ((0.0, 0.0, 0.0, 0.0, -1.0), (0.0, 1.0, 0.0, 0.0, 0.0), (0.0, 0.0, 1.0, 0.0, 0.0), (0.0, 0.0, 0.0, 1.0, 0.0), (-1.0, 0.0, 0.0, 0.0, 0.0)); E3_M : constant GA_Maths.Float_Matrix (1 .. 3, 1 .. 3) := ((1.0, 0.0, 0.0), (0.0, 1.0, 0.0), (0.0, 0.0, 1.0)); Metric_C3 : Metric_Record (C3_M'Length(1)); Metric_E3 : Metric_Record (E3_M'Length(1)); -- -------------------------------------------------------------------- function C3_Eigen_Matrix return Metric_Matrix is begin return Metric_C3.Matrix; end C3_Eigen_Matrix; -- -------------------------------------------------------------------- function C3_Inv_Eigen_Matrix return Metric_Matrix is begin return Metric_C3.Inv_Eigen_Matrix; end C3_Inv_Eigen_Matrix; -- -------------------------------------------------------------------- function E3_Eigen_Matrix return Metric_Matrix is begin return Metric_E3.Matrix; end E3_Eigen_Matrix; -- -------------------------------------------------------------------- function E3_Inv_Eigen_Matrix return Metric_Matrix is begin return Metric_E3.Inv_Eigen_Matrix; end E3_Inv_Eigen_Matrix; -- -------------------------------------------------------------------- function Eigen_Values (Met : Metric_Record) return Real_Vector is begin return Met.Eigen_Values; end Eigen_Values; -- -------------------------------------------------------------------- function Eigen_Vectors (Met : Metric_Record) return Metric_Matrix is begin return Met.Eigen_Vectors; end Eigen_Vectors; -- -------------------------------------------------------------------- function Inv_Eigen_Matrix (Met : Metric_Record) return Metric_Matrix is begin return Met.Inv_Eigen_Matrix; end Inv_Eigen_Matrix; -- -------------------------------------------------------------------- function Is_Anti_Euclidean (Met : Metric_Record) return Boolean is begin return Met.Anti_Euclidean; end Is_Anti_Euclidean; -- -------------------------------------------------------------------- function Is_Diagonal (Met : Metric_Record) return Boolean is begin return Met.Diagonal; end Is_Diagonal; -- -------------------------------------------------------------------- function Is_Euclidean (Met : Metric_Record) return Boolean is begin return Met.Euclidean; end Is_Euclidean; -- -------------------------------------------------------------------- function Matrix (Met : Metric_Record) return Metric_Matrix is begin return Met.Matrix; end Matrix; -- -------------------------------------------------------------------- function C3_Metric return Metric_Record is begin return Metric_C3; end C3_Metric; -- -------------------------------------------------------------------- function E3_Metric return Metric_Record is begin return Metric_E3; end E3_Metric; -- -------------------------------------------------------------------- function New_Metric (Dimension : Integer) return Metric_Matrix is theMetric : constant Metric_Matrix (1 .. Dimension, 1 .. Dimension) := (others => (others => 0.0)); begin return theMetric; end New_Metric; -- ------------------------------------------------------------------------ function New_Metric (Dimension : Integer; Data : Metric_Data) return Metric_Matrix is theMetric : Metric_Matrix (1 .. Dimension, 1 .. Dimension) := (others => (others => 0.0)); begin for Index in 1 .. Dimension loop theMetric (Index, Index) := Data (Index); end loop; return theMetric; end New_Metric; -- ------------------------------------------------------------------------ function New_Metric (Met : Metric_Matrix) return Metric_Record is use GA_Maths; Values : Real_Vector (Met'Range); -- m_eigenMetric Vectors : Float_Matrix (Met'Range, Met'Range); aVector : Real_Vector (Met'Range); State : Metric_Record (Met'Length (1)); begin if not Is_Symetric (Met) then raise Metric_Exception with "Metric.New_Metric cannot process non-symmetric matrices."; else Eigensystem (Real_Matrix (Met), Values, Vectors); -- m_eig State.Eigen_Values := Values; -- Columns of Eigen_Vectors are the eigenvectors State.Inv_Eigen_Matrix := Metric_Matrix (Vectors); State.Eigen_Vectors := Metric_Matrix (Transpose (Vectors)); For col in 1 .. State.Eigen_Vectors'Length(2) loop For row in 1 .. State.Eigen_Vectors'Length(1) loop aVector(row) := State.Eigen_Vectors (row, col); end loop; aVector := aVector / abs(aVector); For row in 1 .. State.Eigen_Vectors'Length(1) loop State.Eigen_Vectors (row, col) := aVector(row); end loop; end loop; State.Matrix := Met; State.Diagonal := Is_Diagonal (Met); if not State.Diagonal then State.Euclidean := False; State.Anti_Euclidean := False; else State.Euclidean := True; State.Anti_Euclidean := True; For col in Met'Range (2) loop if Met (col, col) /= 1.0 then State.Euclidean := False; end if; if Met (col, col) /= -1.0 then State.Anti_Euclidean := False; end if; end loop; end if; end if; return State; exception when others => Put_Line ("An exception occurred in Metric.New_Metric 4"); raise; end New_Metric; begin Metric_C3 := New_Metric (C3_M); Metric_E3 := New_Metric (E3_M); end Metric;
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2020, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- -- -- -- This is a driver for the PCD8544 monochrome LCD controller -- -- -- -- Datasheet: -- -- https://www.sparkfun.com/datasheets/LCD/Monochrome/Nokia5110.pdf -- -- -- -- Use a SPI clock of 4 MHz or less. The SPI peripheral should be -- -- configured to transmit MSB-first, 8 bit data size, CPOL=0, CPHA=1 -- -- This is sometimes referred to as a "Mode 1" SPI configuration. -- -- -- -- Minimum transition time for RST, CS, and DC is 100ns. HAL.Time doesn't -- -- support nanosecond delays, so this module uses a delay of 1 microsecond -- -- instead. -- -- -- -- CS may be null if it's connected to the SPI controller or tied to -- -- ground. -- -- -- -- RST may be null if it's controlled externally or you only expect to -- -- Initialize once per power cycle. -- ------------------------------------------------------------------------------ with HAL; use HAL; with HAL.GPIO; use HAL.GPIO; with HAL.SPI; use HAL.SPI; with HAL.Framebuffer; use HAL.Framebuffer; with HAL.Bitmap; use HAL.Bitmap; with HAL.Time; use HAL.Time; with Memory_Mapped_Bitmap; use Memory_Mapped_Bitmap; with PCD8544_Reg; use PCD8544_Reg; package PCD8544 is type PCD8544_Device (Port : not null Any_SPI_Port; DC : not null Any_GPIO_Point; RST, CS : Any_GPIO_Point; Time : not null HAL.Time.Any_Delays) is limited new HAL.Framebuffer.Frame_Buffer_Display with private; type Any_PCD8544_Device is access all PCD8544_Device'Class; -- See datasheet section 8.9 for contrast (Vop) values subtype PCD8544_Contrast is UInt8 range 0 .. 127; PCD8544_Default_Contrast : constant PCD8544_Contrast := 48; -- See datasheet Table 4 for bias mux rate values. We default to 1:48 as -- that reportedly works well on most LCDs. subtype PCD8544_Bias is UInt8 range 0 .. 4; PCD8544_Default_Bias : constant PCD8544_Bias := 3; -- See datasheet Figure 7 for TC values. Use higher values at lower -- temperatures. subtype PCD8544_Temperature_Coefficient is UInt8 range 0 .. 3; PCD8544_Default_Temperature_Coefficient : constant PCD8544_Temperature_Coefficient := 0; SPI_Error : exception; Device_Width : constant := 48; Device_Height : constant := 84; procedure Initialize (This : in out PCD8544_Device); procedure Set_Contrast (This : in out PCD8544_Device; Contrast : in PCD8544_Contrast); procedure Set_Bias (This : in out PCD8544_Device; Bias : in PCD8544_Bias); procedure Set_Temperature (This : in out PCD8544_Device; TC : in PCD8544_Temperature_Coefficient); procedure Set_Display_Mode (This : in out PCD8544_Device; Enable : in Boolean; Invert : in Boolean); overriding function Max_Layers (This : PCD8544_Device) return Positive; overriding function Supported (This : PCD8544_Device; Mode : FB_Color_Mode) return Boolean; overriding procedure Set_Orientation (This : in out PCD8544_Device; Orientation : Display_Orientation); overriding procedure Set_Mode (This : in out PCD8544_Device; Mode : Wait_Mode); overriding function Initialized (This : PCD8544_Device) return Boolean; overriding function Width (This : PCD8544_Device) return Positive; overriding function Height (This : PCD8544_Device) return Positive; overriding function Swapped (This : PCD8544_Device) return Boolean; overriding procedure Set_Background (This : PCD8544_Device; R, G, B : UInt8); overriding procedure Initialize_Layer (This : in out PCD8544_Device; Layer : Positive; Mode : FB_Color_Mode; X, Y : Natural := 0; Width, Height : Positive := Positive'Last); overriding function Initialized (This : PCD8544_Device; Layer : Positive) return Boolean; overriding procedure Update_Layer (This : in out PCD8544_Device; Layer : Positive; Copy_Back : Boolean := False); overriding procedure Update_Layers (This : in out PCD8544_Device); overriding function Color_Mode (This : PCD8544_Device; Layer : Positive) return FB_Color_Mode; overriding function Hidden_Buffer (This : in out PCD8544_Device; Layer : Positive) return not null HAL.Bitmap.Any_Bitmap_Buffer; overriding function Pixel_Size (Display : PCD8544_Device; Layer : Positive) return Positive; private type PCD8544_Bitmap_Buffer is new Memory_Mapped_Bitmap_Buffer with record Data : UInt8_Array (1 .. ((Device_Width * Device_Height) / UInt8'Size)); end record; type PCD8544_Device (Port : not null Any_SPI_Port; DC : not null Any_GPIO_Point; RST, CS : Any_GPIO_Point; Time : not null HAL.Time.Any_Delays) is limited new HAL.Framebuffer.Frame_Buffer_Display with record Memory_Layer : aliased PCD8544_Bitmap_Buffer; Device_Initialized : Boolean := False; Layer_Initialized : Boolean := False; FR : PCD8544_Function_Register; DR : PCD8544_Display_Register; end record; procedure Chip_Select (This : PCD8544_Device; Enabled : in Boolean); procedure Reset (This : in out PCD8544_Device); procedure Transmit (This : PCD8544_Device; Data : in UInt8); procedure Transmit (This : PCD8544_Device; Data : in UInt8_Array); procedure Extended_Mode (This : in out PCD8544_Device); procedure Basic_Mode (This : in out PCD8544_Device); procedure Write_Raw_Pixels (This : in out PCD8544_Device; Data : in UInt8_Array); end PCD8544;
----------------------------------------------------------------------- -- util-http-clients-tests -- Unit tests for HTTP client -- Copyright (C) 2012, 2020 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Util.Tests; with Util.Tests.Servers; with Util.Streams.Texts; with Util.Streams.Sockets; package Util.Http.Clients.Tests is type Method_Type is (OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, PATCH, CONNECT, UNKNOWN); type Test_Server is new Util.Tests.Servers.Server with record Method : Method_Type := UNKNOWN; Result : Ada.Strings.Unbounded.Unbounded_String; Content_Type : Ada.Strings.Unbounded.Unbounded_String; Length : Natural := 0; Test_Timeout : Boolean := False; end record; type Test_Server_Access is access all Test_Server'Class; -- Process the line received by the server. overriding procedure Process_Line (Into : in out Test_Server; Line : in Ada.Strings.Unbounded.Unbounded_String; Stream : in out Util.Streams.Texts.Reader_Stream'Class; Client : in out Util.Streams.Sockets.Socket_Stream'Class); type Test is new Util.Tests.Test with record Server : Test_Server_Access := null; end record; -- Test the http Get operation. procedure Test_Http_Get (T : in out Test); -- Test the http HEAD operation. procedure Test_Http_Head (T : in out Test); -- Test the http POST operation. procedure Test_Http_Post (T : in out Test); -- Test the http PUT operation. procedure Test_Http_Put (T : in out Test); -- Test the http DELETE operation. procedure Test_Http_Delete (T : in out Test); -- Test the http OPTIONS operation. procedure Test_Http_Options (T : in out Test); -- Test the http PATCH operation. procedure Test_Http_Patch (T : in out Test); -- Test the http timeout. procedure Test_Http_Timeout (T : in out Test); overriding procedure Set_Up (T : in out Test); overriding procedure Tear_Down (T : in out Test); -- Get the test server base URI. function Get_Uri (T : in Test) return String; -- The <b>Http_Tests</b> package must be instantiated with one of the HTTP implementation. -- The <b>Register</b> procedure configures the Http.Client to use the given HTTP -- implementation before running the test. generic with procedure Register; NAME : in String; package Http_Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Http_Test is new Test with null record; overriding procedure Set_Up (T : in out Http_Test); end Http_Tests; end Util.Http.Clients.Tests;
-- This spec has been automatically generated from STM32F40x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; with HAL; with System; package STM32_SVD.IWDG is pragma Preelaborate; --------------- -- Registers -- --------------- ----------------- -- KR_Register -- ----------------- subtype KR_KEY_Field is HAL.Short; -- Key register type KR_Register is record -- Write-only. Key value (write only, read 0000h) KEY : KR_KEY_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.Short := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for KR_Register use record KEY at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; ----------------- -- PR_Register -- ----------------- subtype PR_PR_Field is HAL.UInt3; -- Prescaler register type PR_Register is record -- Prescaler divider PR : PR_PR_Field := 16#0#; -- unspecified Reserved_3_31 : HAL.UInt29 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for PR_Register use record PR at 0 range 0 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; ------------------ -- RLR_Register -- ------------------ subtype RLR_RL_Field is HAL.UInt12; -- Reload register type RLR_Register is record -- Watchdog counter reload value RL : RLR_RL_Field := 16#FFF#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for RLR_Register use record RL at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; ----------------- -- SR_Register -- ----------------- -- Status register type SR_Register is record -- Read-only. Watchdog prescaler value update PVU : Boolean; -- Read-only. Watchdog counter reload value update RVU : Boolean; -- unspecified Reserved_2_31 : HAL.UInt30; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for SR_Register use record PVU at 0 range 0 .. 0; RVU at 0 range 1 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Independent watchdog type IWDG_Peripheral is record -- Key register KR : KR_Register; -- Prescaler register PR : PR_Register; -- Reload register RLR : RLR_Register; -- Status register SR : SR_Register; end record with Volatile; for IWDG_Peripheral use record KR at 0 range 0 .. 31; PR at 4 range 0 .. 31; RLR at 8 range 0 .. 31; SR at 12 range 0 .. 31; end record; -- Independent watchdog IWDG_Periph : aliased IWDG_Peripheral with Import, Address => IWDG_Base; end STM32_SVD.IWDG;
-- Abstract : -- -- Support for an enumerated token type -- -- Copyright (C) 2017 - 2019 Free Software Foundation, Inc. -- -- This library is free software; you can redistribute it and/or modify it -- under terms of the GNU General Public License as published by the Free -- Software Foundation; either version 3, or (at your option) any later -- version. This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- As a special exception under Section 7 of GPL version 3, you are granted -- additional permissions described in the GCC Runtime Library Exception, -- version 3.1, as published by the Free Software Foundation. pragma License (GPL); with WisiToken.Lexer.Regexp; with WisiToken.Productions; with WisiToken.Syntax_Trees; generic type Token_Enum_ID is (<>); First_Terminal : Token_Enum_ID; Last_Terminal : Token_Enum_ID; First_Nonterminal : Token_Enum_ID; Last_Nonterminal : Token_Enum_ID; EOF_ID : Token_Enum_ID; Accept_ID : Token_Enum_ID; Case_Insensitive : Boolean; package WisiToken.Gen_Token_Enum is function "+" (Item : in Token_Enum_ID) return Token_ID is (Token_ID'First + Token_Enum_ID'Pos (Item)); function "-" (Item : in Token_ID) return Token_Enum_ID is (Token_Enum_ID'Val (Item - Token_ID'First)); function Token_Enum_Image return Token_ID_Array_String; subtype Terminal_Enum_ID is Token_Enum_ID range First_Terminal .. Last_Terminal; subtype Nonterminal_Enum_ID is Token_Enum_ID range First_Nonterminal .. Last_Nonterminal; LR1_Descriptor : aliased WisiToken.Descriptor := (First_Terminal => +First_Terminal, Last_Terminal => +Last_Terminal, First_Nonterminal => +First_Nonterminal, Last_Nonterminal => +Last_Nonterminal, EOI_ID => +EOF_ID, Accept_ID => +Accept_ID, Case_Insensitive => Case_Insensitive, New_Line_ID => Invalid_Token_ID, String_1_ID => Invalid_Token_ID, String_2_ID => Invalid_Token_ID, Image => (others => null), -- set in body elaboration time code Terminal_Image_Width => Terminal_Enum_ID'Width, Image_Width => Token_Enum_ID'Width, Last_Lookahead => +Last_Terminal); LALR_Descriptor : aliased WisiToken.Descriptor := (First_Terminal => +First_Terminal, Last_Terminal => +Last_Terminal, First_Nonterminal => +First_Nonterminal, Last_Nonterminal => +Last_Nonterminal, EOI_ID => +EOF_ID, Accept_ID => +Accept_ID, Case_Insensitive => Case_Insensitive, New_Line_ID => Invalid_Token_ID, String_1_ID => Invalid_Token_ID, String_2_ID => Invalid_Token_ID, Image => (others => null), Terminal_Image_Width => Terminal_Enum_ID'Width, Image_Width => Token_Enum_ID'Width, Last_Lookahead => +First_Nonterminal); type Enum_Syntax is array (Token_Enum_ID range Token_Enum_ID'First .. Last_Terminal) of WisiToken.Lexer.Regexp.Syntax_Item; function To_Syntax (Item : in Enum_Syntax) return WisiToken.Lexer.Regexp.Syntax; function "&" (Left, Right : in Token_Enum_ID) return Token_ID_Arrays.Vector; function "&" (Left : in Token_ID_Arrays.Vector; Right : in Token_Enum_ID) return Token_ID_Arrays.Vector; function "+" (Left : in Token_Enum_ID; Right : in Syntax_Trees.Semantic_Action) return Productions.Right_Hand_Side; function "<=" (Left : in Token_Enum_ID; Right : in WisiToken.Productions.Right_Hand_Side) return WisiToken.Productions.Instance; ---------- -- For unit tests subtype Terminal_ID is Token_Enum_ID range First_Terminal .. Last_Terminal; subtype Nonterminal_ID is Token_Enum_ID range First_Nonterminal .. Last_Nonterminal; subtype Grammar_ID is Token_Enum_ID range First_Terminal .. Last_Nonterminal; type Nonterminal_Array_Token_Set is array (Nonterminal_ID, Grammar_ID) of Boolean; function To_Nonterminal_Array_Token_Set (Item : in Nonterminal_Array_Token_Set) return WisiToken.Token_Array_Token_Set; type Nonterminal_Array_Terminal_Set is array (Nonterminal_ID, Terminal_ID) of Boolean; function To_Nonterminal_Array_Terminal_Set (Item : in Nonterminal_Array_Terminal_Set) return WisiToken.Token_Array_Token_Set; type Nonterminal_ID_Set is array (Nonterminal_ID) of Boolean; type Token_Array is array (Positive range <>) of Token_Enum_ID; function "+" (Item : in Token_Array) return WisiToken.Token_ID_Set; function "+" (Item : in Token_Enum_ID) return WisiToken.Token_ID_Set; end WisiToken.Gen_Token_Enum;
package body Calculate1 is procedure Update_Result(Value: NaturalDouble; Result: in out NaturalDouble; Operation: OperationMethod) is begin if Result = -1 then Result := Value; else Result := Operation(Result, Value); end if; end Update_Result; function Execute(Value: String; Current_Index: in out Integer) return NaturalDouble is Current_Element: Character; Result: NaturalDouble; Value_String : string(1..1); Current_Operation: OperationMethod; begin Result := -1; Current_Operation := Add'Access; if Current_Index > Value'Length then return Result; end if; while Current_Index <= Value'Length loop Current_Element := Value(Current_Index); Current_Index := Current_Index + 1; if Current_Element /= ' ' then case Current_Element is when '(' => Update_Result(Execute(Value, Current_Index), Result, Current_Operation); when ')' => return Result; when '+' => Current_Operation := Add'Access; when '*' => Current_Operation := Multiple'Access; when others => Value_String(1) := Current_Element; Update_Result(NaturalDouble'Value (Value_String), Result, Current_Operation); end case; end if; end loop; return Result; end Execute; end Calculate1;
-- package Orthogonal_Polys -- -- Generates orthogonal polynomials on dicrete grid points using the -- Gram-Schmidt method. The package also provides a routine for -- polynomial least-squares curve fitting: procedure Poly_Fit. -- -- The least-squares curve fitting routine could have been defined in -- another package, but it turned out to be useful in the test procedures, -- and least-squares curve fitting is the primary application of the code. -- The algorithm is due to Shampine (1), who was the first to show how -- high order least squares polynomial fits could be performed on arbitrary -- data sets. -- -- Given a set of X-axis grid points {X_0, ..., X_m} and a set of weights -- associated with those points {W_0, ..., W_m} there is a unique set of -- Gram-Schmidt orthogonal polynomials {Q_0(X), ..., Q_m(X)} that range in -- degree from 0 to m, where m is one less than the number of distinct -- data points. -- -- This package defines routines for generating the polynomials Q_j(X) -- and routines for calculating values, derivatives, and integrals of -- functions F(X) composed of linear combinations of these polynomials: -- F(X) = SUM [C_j * Q_j(X)]. The Clenshaw summation formula is used -- for most of the work. -- -- The polynomials generated are Legendre polynomials if the weights -- are constant. If the weights go like W_j = Sqrt (1 - X_j**2) on -- X in [-1,1], then Tchebychev polys are generated. Other well-known -- polys are associated with other weights and intervals on X. These -- polys are not identical to the kind associated with continuous -- intervals of X, (although they agree in the limit of large data sets.) -- The continuous kind are orthogonal respect integration: -- Integral_Of [Q_j(X) * Q_k(X) * W(X) * dX] = 0 if j /= k. -- The discrete -- polys are orthogonal respect an inner product, a summation over -- discrete data points SUM [Q_j(X_i) * Q_k(X_i) * W_i] = 0 if j /= k. -- (A different package provides routines that generate values of the -- continuous polys. It also uses the Clenshaw summation formula.) -- -- Notes On Use -- -- The procedure Poly_Fit fits a polynomial in variable X to a -- function F(X) defined by a set of points in the form (X_i, F(X_i)). -- The fit minimizes the sum of the squares of the residuals, -- the error terms Error_i in the equation: -- -- N -- F (X_i) = SUM ( C_m * Q_m(X_i) ) + Error_i -- m=0 -- -- where the functions Q are orthogonal polynomials, and N is the -- order of the polynomial we are fitting to F. -- A linear combination of Q_m, with coefficients C_m is the best fit: -- -- N -- Best_Fit_Poly (X) = SUM ( C_m * Q_m (X) ) -- m=0 -- -- The procedure returns this sum, and also the coefficients C_m. -- -- C(i) is the array of coefficients of the orthogonal Polynomials -- that are fit to the data. Alpha(i) and Beta(i) are returned in the -- record Poly_Set of type Polynomial. These are -- used to generate the orthogonal polynomials via the recurrence relations -- given below. -- -- If the user wants the values of the best fit polynomial at values -- of X not among those in the data set, then one uses function -- Poly_Value to sum the polynomial at X via the recurrence relation -- defined by Alpha, Beta and C. -- -- Often one wants the coefficients of the powers of X in the -- least-squares polynomial, instead of the coefficients of the -- orthogonal polynomials Q_m. For example, one commonly want -- the best linear fit to the data, or the best parabolic fit -- to the data, F = E_0 + E_1 * X + E_2 * X**2, -- and so one wants the coefficients E_m in the sum: -- -- N -- Best_Fit_Poly (X) = SUM ( E_m * X**m ). -- m=0 -- -- The coefficients E_m are returned in the array Poly_Coeffients by -- the procedure Get_Coeffs_Of_Powers_Of_X. -- -- The procedure Poly_Fit also returns: -- -- Mean_Square_Error = SUM (Error_i * Error_i) / Number_Of_Data_Points. -- -- If the data set is noisy, then it often happens that as you raise the -- order polynomial, the Mean_Square_Error quickly reaches some minimum. -- On the other hand, if you are fitting to a noiseless function, say -- to calculate its derivatives numerically, then one can often see -- continued improvement in the fit even as the order of the polynomial -- becomes very large. -- -- Notes On the Algorithm -- -- Take any set of orthogonal functions, {Q_n}, project them one by one -- onto a data set exactly as you would construct a Fourier series, -- and you have performed a linear least squares fit to the data. -- More precisely, you have found coefficients C_n such that the -- function formed by summing the orthogonal functions Q_n with -- coefficients C_n has minimum distance from the data in the least -- squares sense. No matrix inversion is required because the -- functions Q_n are orthogonal. -- A more rigorous definition: Given functions -- Q_0, Q_1, ... Q_n, ...we want to find coefficients C_0, C_1, ... -- C_n,... such that the sum of the squares of the errors Error_i are -- minimized in the equation: -- -- N -- F (X_i) = SUM ( C_m * Q_m(X_i) ) + Error_i, -- m=0 -- -- where the functions Q will be orthogonal in this package, and N is the -- order of the polynomial we are fitting to F. The problem is best -- formulated in terms of inner products with respect weights -- W(X_i). Inner product is defined (A, B) = SUM (A(X_i)*B(X_i)*W(X_i)). -- You get the formula for the least squares fit by setting the gradiant -- of the sum of the squares of Error_i to zero and solving for the -- coefficients C_n. The equation to solve for C_n turns out to be: -- -- N -- (Q_n, F) = SUM ( C_m * (Q_n, Q_m) ). -- m=0 -- -- This is a matrix equation whose solution requires an LU decomposition -- or the like when the basis functions Q are not orthogonal. But -- when the basis functions Q are orthogonal, the solution of this -- set of simultaneous equations is trivial: -- -- C_n = (Q_n, F) / (Q_n, Q_n), -- -- since the matrix on the RHS of the matrix equation is diagonal. -- -- Here is the algorithm. First we construct the orthogonal polynomials -- Q with respect to the weights W_i as follows: -- -- Q_0 = 1 -- Q_m = x*Q_m-1 - SUM (B_mj * Q_j ) -- j<k -- -- The sum on the RHS is there only to make Q_m orthogonal to all previous -- Q's. The coefficients Beta_mj that achieve this are -- -- Beta_mj = (x*Q_m-1, Q_j) / (Q_j, Q_j). -- -- To see this take the inner product of the equation for Q_m with Q_j, -- j<k, set it equal to zero, use recursion. The form given above is the -- one that generalizes to many dimensions. In one dimension the formula -- simplifies so that only two of the Beta coefficients are nonzero. -- We call these two Alpha and Beta: -- -- Q_0 = 1 -- Q_1 = (X - Alpha_1) -- Q_m = (X - Alpha_m) * Q_m-1 - Beta_m*Q_m-2 -- where -- Alpha_m = (X*Q_m-1, Q_m-1) / (Q_m-1, Q_m-1) -- Beta_m = (X*Q_m-1, Q_m-2) / (Q_m-2, Q_m-2) -- -- Can be shown: Beta_m = (Q_m-1, Q_m-1) / (Q_m-2, Q_m-2) which is -- the form used below. (Just use X*Q_m-2 = (X-Alpha)*Q_m-2 + ... = Q_m-1 + ...). -- -- function Poly_Value: -- -- So now we've calculated coefficients A_m and B_m which, via the -- recurrence relation given above, generate the orthogonal polynomials -- Q_m. Along the way we calculated the coefficients C_m which -- sum the Q_m's to give a least-squares fit to the function F. Now -- to make use of these coefficients to calculate the value of the -- the least-squares polynomial at any X, we use Clenshaw's formula. -- Clenshaw's method is a well known algorithm for summing any -- series C_m*Q_m(X) where Q_m is defined by a recurrence relation. -- Clenshaw's recurrence formula is used in everything that follows, -- so we review it next in its most general form. -- -- Clenshaw's formula is an algorithm for evaluating sums over -- functions Q_m (X) that are defined by recurrence relations of the sort: -- -- Q_0 = some given function of X -- Q_1 = Alpha (1, X) * Q_0 (X) -- Q_m = Alpha (m, X) * Q_m-1 (X) + Beta (m, X) * Q_m-2 (X) -- -- The procedure here evaluates the sum -- n -- F_n(X) = SUM ( C_m * Q_m(X) ) -- m=0 -- -- where the coefficients C_m are given quantities, as are Alpha and -- Beta. The scheme implemented here is stabler and more accurate -- than attempts to directly perform the sum for F_n. -- -- Clenshaw proved that F_n is given by the following formula -- -- (*) F_n(X) = D_0*Q_0(X) + D_1*(Q_1(X) - Alpha(1,X)*Q_0(X)). -- -- where the D_m are functions of X that satisfy: -- -- D_n+2 = 0 -- D_n+1 = 0 -- D_m = C_m + Alpha(m+1,X) * D_m+1(X) + Beta(m+2,X) * D_m+2(X) -- -- The proof of (*) is straightforward. Solve for C_m in the equation for -- D_m above and plug it into the sum that defines F_n to get -- -- n -- F_n = SUM (D_m - Alpha(m+1)*D_m+1 - Beta(m+1)*D_m+2 ) * Q_m -- k=0 -- n -- F_n = D_0*Q_0 + D_1*Q_1 + SUM ( D_m*Q_m ) -- m=2 -- n -- -Alpha(1)*D_1*Q_0 + SUM (-Alpha(m)*D_m*Q_m-1 ) -- m=2 -- n -- + SUM (-Beta(m) *D_m*Q_m-2 ). -- m=2 -- -- Now factor out D_m from the three SUM terms above, and notice -- that what remains is just the recurrance relation that defines -- Q_m for m > 1. It evaluates to zero, leaving -- -- F_n(X) = D_0*Q_0(X) + D_1*(Q_1(X) - Alpha(1,X)*Q_0(X)). -- -- In the special case of Othogonal polynomials, where Q_0 = 1, and -- Q_1(X) = Alpha(1,X)*Q_0(X), we have that F_n(X) = D_0. -- -- -- procedure Poly_Derivatives: -- -- How do we get the derivatives of the best-fit polynomial? Just -- take the derivative of the Clenshaw recurrence formula given above. -- In the special case of orthogonal polynomials it is particulary -- easy. By differentiating the formula given above p times it's easy -- to see that the p-th derivative of the D_m functions of X satisfy: -- -- D_n+2(p,X) = 0 -- D_n+1(p,X) = 0 -- D_m(p,X) -- = p*D_m+1(p-1,X) + (X - Alpha_m)*D_m+1(p,X) - Beta_m*D_m+2(p,X) -- -- where D(p,X) is the pth derivative of D(X). It follows that the -- p-th derivative of the sum of C_m*Q_m(X) equals D_0(p,X). -- -- -- procedure Get_Coefficients_Of_Powers_Of_X: -- -- Clenshaw's formula is used to get Coeffs. The -- coefficients of the following D polynomials are put into arrays -- D_0, D_1, and D_2, and advanced recursively until the final -- D_0 = SUM {C_k * Q_k} is found. This will be named Poly_Coefficients. -- -- D_n+2(X) = 0 -- D_n+1(X) = 0 -- D_m(X) = C_m + (X - Alpha_m+1)*D_m+1(X) - Beta_m+2*D_m+2(X) -- -- where n = Desired_Poly_Degree and m is in 0..n. -- The arrays D_0, D_1, and D_2 are already initialized. -- They contain the coeff's of powers of X in the orthogonal -- polynomials D_m, D_m+1, D_m+2. The formulas above -- imply: for m in Desired_Poly_Degree .. 0: -- -- D_0(k) := D_1(k-1) - Alpha(m)*D_1(k) - Beta(m)*D_2(k) -- D_0(0) := D_0(0) + C(m) -- -- where k goes from 1 to Desired_Poly_Degree in the first equation. -- Notice that the above formula must be modified at m = n and m = n-1. -- This gives the Poly coefficients for X in the range [-2,2]. Some -- poly shifting has to be done to get the coefficients in the the -- true range. (Common source of floating point overflow.) -- -- The algorithm can be generalized to functions F of many variables (2). -- -- (1) Forsythe, G. E., J. SIAM 5 (1957), 74-87. -- This package follows Shampine: -- Shampine and Allen, Numerical Computing, An Introduction,(1973). -- (2) Bartels and Jezioranski, ACM Transactions on Math. Software, -- Vol. 11 (1985), p. 201-217. -- generic type Real is private; -- The package can be instantiated with either conventional Floats, -- or with an abstract (extended precision) floating point. type Points_Index is range <>; type Data is array (Points_Index) of Real; Zero : Real; One : Real; -- For initializing objects of private type Real. 'Real' can be -- an extended precision abstract float type. with function "*" (X : Real; Y : Real) return Real is <>; with function "+" (X : Real; Y : Real) return Real is <>; with function "-" (X : Real; Y : Real) return Real is <>; with function "/" (X : Real; Y : Real) return Real is <>; with function "<" (X : Real; Y : Real) return Boolean is <>; with function "**" (X : Real; N : Integer) return Real is <>; with function "-" (X : Real) return Real is <>; package Orthogonal_Polys is type Integer32 is range -2**31 .. 2**31-1; Max_Order_Of_Poly : constant Integer32 := Integer32 (Data'Length - 1); -- May want to set this to a smaller value if the number of -- data points is >> the max order of polys. In any case, -- this constant cannot be greater than Data'Length - 1. -- Section 1. -- -- Data structures for polynomials. -- Type Poly_Data holds the actual values of individual Polys at X-axis -- grid points X_j. Also holds a normalization factor for the Poly. -- Type Polynomial holds coefficients Alpha and Beta for generating -- Polys recursively via the Gram-Schmidt method. (Plus other things.) subtype Coeff_Index is Integer32 range 0..Max_Order_Of_Poly; -- Index for array of polynomial coefficients. The Max_Order must be -- less than the number of data points. An assertion verifies this. -- (The max number if data points is taken to be Data'Length.) type Poly_Data is record Points : Data := (others => Zero); First : Points_Index := Points_Index'First; Last : Points_Index := Points_Index'Last; Squared : Real := Zero; Degree : Coeff_Index := Coeff_Index'First; end record; -- Value of the polynomial at the X axis grid points. Squared will -- contain a factor for normalizing the polys. The Polys are not -- contained in normalized form in the field Points. Squared will -- contain Inner_Product (Poly, Poly, First, Last, Weights). -- Poly_data.Points holds the explicit Y values of the poly defined at -- points X_j .. X_k, where j and k are Data_First amd Data_Last as -- stored in Points. These end points are input by the user on -- a call to Start_Gram_Schmidt_Poly_Recursion. This is where the -- Data_First and Data_Last, (start and end of the Polys) are input, -- nowhere else. After this, all operations on this data are in -- the range Data_First..Data_Last. To turn off data points in that -- range you set their associated weights to 0.0. type Recursion_Coeffs is array (Coeff_Index) of Real; -- The Alpha and Beta coefficients for generating polynomial recursively. -- These are calculated in calls to Get_Next_Poly and -- Start_Gram_Schmidt_Poly_Recursion. type Polynomials is limited private; -- Contains the Gram_Schmidt recursion coefficients Alpha and Beta -- for generating polynomials up to some order. That order is given -- by Degree_Of_Poly, also contained in Polynomials. The only way -- to use type Polynomials is to initialize it with a call to -- Start_Gram_Schmidt_Poly_Recursion, and to update it with calls -- to Get_Next_Poly. -- Section 2. -- -- Construct the unique set of orthogonal polys associated with -- X-axis grid points "X_axis" and weights "Weights", on range -- First .. Last of Points_Index. procedure Start_Gram_Schmidt_Poly_Recursion (X_axis : in Data; Weights : in Data; First, Last : in Points_Index; Poly_0, Poly_1 : in out Poly_Data; Poly_Set : out Polynomials); -- Starts off the process of generating polys. All computation -- is henceforth done on interval First..Last of Points_Index. -- If you want to leave out point (X(i), Y(i)) during the fitting, -- then set the corresponding weight to -- Weight(i) := Zero; -- Typical setting for Weights is simply Weights := (others => 1.0). -- This is the only place that First, Last, and X_axis are input. They -- are stored in Poly_Set and Poly_N, and subsequent operations -- read them from these objects. -- The in out parameters (Poly_O and Poly_1) need no initialization. procedure Get_Next_Poly (Poly_0, Poly_1 : in Poly_Data; Weights : in Data; Poly_2 : in out Poly_Data; Poly_Set : in out Polynomials); -- Generate successive polys given the 2 previous polys. -- This procedure creates Poly_2, and updates Poly_Set so that it -- includes recursion coefficients for generating Poly_2. -- "Weights" must contain the same weights used in the call to -- Start_Gram_Schmidt_Poly_Recursion that started off the -- process of creating poly_0 and poly_1. -- Section 3. -- -- Section contains procedures that operate on type Polynomial. -- The procedures sum linear combinations of orthogonal polynomials, and -- calculate values, derivatives and integrals of these sums. -- The coefficients -- of the polynomials in the linear combinations, called C_k, -- will be stored in array C of type Poly_Sum_Coeffs. -- If you want the value of a single Poly, its derivatives, or -- integrals, then you use a delta-function for C_k: let C_k = 0.0 -- everywhere except at the index of the desired Poly, which you set to -- 1.0. Can also get coefficients of powers of X, but be aware that -- this is an error prone process. function Max_Permissable_Degree_Of (P : Polynomials) return Coeff_Index; -- P is the unique set of (GS) orthogonal polys associated with a set -- of grid points {X_j} and a set of weights {W_j}. The max degree -- of this set of orthogonal polys is limited by the number of distinct -- points in set {X_j}, (the number that have nonzero weight). That -- number is returned by this function. subtype Poly_Sum_Coeffs is Recursion_Coeffs; -- Multiply these coefficients by polynomials, sum to make linear -- combinations. These sums (usually Least squares -- fits) are evaluated by calls to Poly_Value, Derivatives_Of etc. function Poly_Value (X : in Real; C : in Poly_Sum_Coeffs; Poly_Set : in Polynomials) return Real; -- Returns the value of poly Q(X) = SUM {C_m * Q_m(X) }, at arbitrary X. -- The orthogonal polys Q_m are defined by Poly_Set. Uses the Clenshaw -- summation formula. -- (The procedure Polynomial_Fit, by the way, only calculates -- Q for values of X that are in the data set (X_j), and returns them in -- the array Best_Fit_Poly.) function Poly_Integral (X : in Real; C : in Poly_Sum_Coeffs; Poly_Set : in Polynomials; Order_Of_Integration : in Coeff_Index := 1) return Real; -- Returns the indefinite integral of poly Q(X) = SUM [ C_k * Q_k(X) ]. -- The orthogonal polys Q_k are defined by Poly_Set. To get the -- integral of Q on [A, B] use Integral(B) - Integral(A). Uses Clenshaw -- summation formula to get coefficients of powers of X, then integrates -- by summing the poly with Horner's rule. Not the best way to do -- quadrature in general, but it's a good way to get integrals of -- polynomial least-square fits to data. subtype Derivative_List is Recursion_Coeffs; subtype Derivatives_Index is Coeff_Index; -- Starts at 0. procedure Poly_Derivatives (Derivatives : in out Derivative_List; X : in Real; Order_Of_Deriv : in Derivatives_Index; C : in Poly_Sum_Coeffs; Poly_Set : in Polynomials); -- Returns the derivative of the polynomial -- Q(X) = SUM [ C_k * Q_k(X) ]. The m-th derivative is returned -- as the m-th component of the array Derivatives. All lower order -- derivatives are return also, since they must be calculated along -- along the way. You may not need them, but when you do, it is -- better not to call the procedure m times (when you can call it -- only once). -- -- Procedure Poly_Derivatives provides another way of -- of getting the coefficients (E) of powers of X. The m-th derivative -- of the polynomial, evaluated at X = 0, equals E_m multiplied -- by m!. In many ways this method may be superior to that used in -- in procedure Get_Coefficients_Of_Powers_Of_X. It's likely -- to work in situations where Get_Coeffs... fails, (and vice-versa). -- Also, if you calculate a high degree polynomial fit, you may use -- Poly_Derivative to get just the first few E_m, rather than all -- of them, which is what Get_Coeffs_Of_Powers_Of_X does, and which -- may lead to floating point exceptions. type Powers_Of_X_Coeffs is array (Coeff_Index) of Real; procedure Get_Coeffs_Of_Powers_Of_X (Coeffs : out Powers_Of_X_Coeffs; C : in Poly_Sum_Coeffs; Poly_Set : in Polynomials); -- Often one wants the coefficients of the powers of X in the -- least-squares polynomial, instead of the coefficients C_m of the -- orthogonal polynomials Q_m. For example, one commonly wants -- the best linear fit to the data, or the best parabolic fit -- to the data, F = E_0 + E_1 * X + E_2 * X**2, -- and so one wants the coefficients E_m in the sum: -- -- N -- Best_Fit_Poly (X) = SUM ( E_m * X**m ). -- m=0 -- -- The coefficients E_m are returned in the array Coeffs. -- This procedure attempts to get all of the coefficients of the powers -- of X up to the degree of the polynomial that is contained in -- the Data structure Poly_Set. This polynomial degree is usually, -- but not always, the degree set by the parameter Desired_Poly_Degree -- in the procedure Poly_Fit. -- If you calculate a high order polynomial least squares fit, -- it may not be a good idea the use this routine. This is a common -- source of floating point overflow, catastrophic loss of precision, -- etc. These problems depend on a lot of things, so you can give it -- a try if you want, but this routine is really mostly for -- getting the best fit line, or parabola. In these cases set -- Desired_Poly_Degree to 1 or 2 in procedure polynomial_fit to get -- the polynomial fit Poly_Set. Then send Poly_Set into this routine. -- -- The procedure Poly_Derivatives above provides another way of -- of getting the coefficients of powers of X. See the above note. function Inner_Product (X, Y : in Data; First, Last : in Points_Index; Weights : in Data) return Real; -- Usually you project the polynomials onto the data with the -- function Inner_Product in order to make least squares fits. -- Also useful in testing orthogonality of polys. This is the -- weighted inner product over which the polynomials (calculated -- below) are orthogonal. procedure Poly_Fit (Data_To_Fit : in Data; X_axis, Weights : in Data; First, Last : in Points_Index; Desired_Poly_Degree : in Coeff_Index; Best_Fit_Poly : in out Poly_Data; Best_Fit_Coeffs : in out Poly_Sum_Coeffs; Poly_Set : in out Polynomials; Mean_Square_Error : out Real); private Two : constant Real := One + One; Four : constant Real := Two + Two; Smallest_Delta_X : constant Real := Two ** (-128); -- Some arbitrary small number. Another choice might be: -- Smallest_Delta_X : constant Real := 2.0**(-Real'Safe_Emax / 2); -- If Data points are not separated by greater than Smallest_Delta_X, -- then an exception will be raised. -- Prevents some of the more immediate of the possible overflows. -- This number is comparable to the square root of Real'Safe_Small -- because Safe_Small is 2.0**(-Safe_Emax-1). (Safe_Emin = -Safe_Emax.) -- A typical Safe_Small for IEEE 754 is 10**(-308). The number -- here would be approximately 10**(-154). Smallest_Weight : constant Real := Two ** (-256); -- Set it to some arbitrary small number. Another choice -- might be Smallest_Weight : constant Real := Real'Safe_Small; -- If a weight is set below this value, then we pretend -- that the data point is not in the set. Max_No_Of_Data_Points : constant Integer32 := Integer32 (Data'Length); -- So can verify that polynomial degree is less than -- the number of data points. type X_Axis_Scale is record Slope : Real := One; Const : Real := Zero; end record; type Polynomials is record Alpha : Recursion_Coeffs := (others => Zero); Beta : Recursion_Coeffs := (others => Zero); Scale_Factors : X_Axis_Scale; X_scaled : Data := (others => Zero); Degree_Of_Poly : Coeff_Index := Coeff_Index'First; Max_Permissable_Degree_Of_Poly : Coeff_Index := Coeff_Index'First; end record; pragma Assert (Coeff_Index'First = 0); pragma Assert (Coeff_Index'Last >= 3); end Orthogonal_Polys;
with freetype_c.FT_CharMapRec; package freetype_c.FT_CharMap is subtype Item is FT_CharMapRec.Pointer; type Item_array is array (interfaces.C.Size_t range <>) of aliased FT_CharMap.Item; type Pointer is access all FT_CharMap.Item; type Pointer_array is array (C.Size_t range <>) of aliased FT_CharMap.Pointer; type pointer_Pointer is access all freetype_c.FT_CharMap.Pointer; end freetype_c.FT_CharMap;
-- part of AdaYaml, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "copying.txt" package Yaml.Tags is Question_Mark : constant Text.Reference; -- "?" Exclamation_Mark : constant Text.Reference; -- "!" Mapping : constant Text.Reference; -- "!!map" Sequence : constant Text.Reference; -- "!!seq" String : constant Text.Reference; -- "!!str" Boolean : constant Text.Reference; -- "!!bool" Null_Tag : constant Text.Reference; -- "!!null" private Question_Mark_Holder : constant Text.Constant_Instance := Text.Hold ("?"); Exclamation_Mark_Holder : constant Text.Constant_Instance := Text.Hold ("!"); Mapping_Holder : constant Text.Constant_Instance := Text.Hold ("tag:yaml.org,2002:map"); Sequence_Holder : constant Text.Constant_Instance := Text.Hold ("tag:yaml.org,2002:seq"); String_Holder : constant Text.Constant_Instance := Text.Hold ("tag:yaml.org,2002:str"); Boolean_Holder : constant Text.Constant_Instance := Text.Hold ("tag:yaml.org,2002:bool"); Null_Holder : constant Text.Constant_Instance := Text.Hold ("tag:yaml.org,2002:null"); Question_Mark : constant Text.Reference := Text.Held (Question_Mark_Holder); Exclamation_Mark : constant Text.Reference := Text.Held (Exclamation_Mark_Holder); Mapping : constant Text.Reference := Text.Held (Mapping_Holder); Sequence : constant Text.Reference := Text.Held (Sequence_Holder); String : constant Text.Reference := Text.Held (String_Holder); Boolean : constant Text.Reference := Text.Held (Boolean_Holder); Null_Tag : constant Text.Reference := Text.Held (Null_Holder); end Yaml.Tags;
with Test_Report; use Test_Report; with Symbolic_Expressions.Solving; with Ada.Strings.Unbounded; procedure Test.Solving is use Ada.Strings.Unbounded; function "+" (X : String) return Unbounded_String renames To_Unbounded_String; function "+" (X : Unbounded_String) return String renames To_String; type Equation_Type is record Var : Unbounded_String; Expr : Unbounded_String; end record; -- Type representing an equation <var> = <expr> type System is array (Positive range <>) of Equation_Type; -- System of many equations type System_Access is access System; type Var_Value_Pair is record Var : Unbounded_String; Value : Integer; end record; type Solution is array (Positive range <>) of Var_Value_Pair; type Solution_Access is access Solution; type Test_Case is record Equations : System_Access; Result : Solution_Access; -- Set Result to null if the system is supposed to be not solvable end record; type Test_Case_Array is array (Positive range <>) of Test_Case; Test_Cases : constant Test_Case_Array := ((Equations => new System' ((+"y", +"x*u-3"), (+"u", +"42"), (+"x", +"u/2")), Result => new Solution' ((+"u", 42), (+"x", 21), (+"y", 879))), (Equations => new System' ((+"y", +"x*u-3"), (+"u", +"42")), Result => null)); package Solving is new Int_Expr.Solving; function Check (This : Test_Case) return Boolean is use Int_Expr.Variable_Tables; use Int_Expr; Equations : Solving.Equation_Tables.Map; Result : Int_Expr.Variable_Tables.Map; Success : Boolean; Pos : Int_Expr.Variable_Tables.Cursor; Expected : Int_Expr.Variable_Tables.Map; begin for I in This.Equations'Range loop Equations.Insert (Key => +This.Equations (I).Var, New_Item => Parse (+This.Equations (I).Expr)); end loop; if This.Result /= null then for I in This.Result'Range loop Expected.Insert (Key => +This.Result (I).Var, New_Item => This.Result (I).Value); end loop; end if; Solving.Triangular_Solve (What => Equations, Result => Result, Success => Success); if not Success then -- Return true if and only if we expected that the system was not -- solvable return This.Result = null; end if; if This.Result = null then -- Here Success=True, but we expected a non-solvable system return False; end if; pragma Assert (Success and This.Result /= null); Pos := Expected.First; while Pos /= No_Element loop if not Result.Contains (Key (Pos)) then return False; end if; if Result.Element (Key (Pos)) /= Element (Pos) then return False; end if; Next (Pos); end loop; Pos := Result.First; while Pos /= No_Element loop if not Expected.Contains (Key (Pos)) then return False; end if; Next (Pos); end loop; return True; end Check; procedure Do_Solving_Checks is new Do_Suite (Test_Case => Test_Case, Test_Case_Array => Test_Case_Array, Check => Check); Reporter : Reporter_Type; begin Do_Solving_Checks (Reporter, Test_Cases); Final (Reporter); end Test.Solving;
------------------------------------------------------------------------------ -- G P S -- -- -- -- Copyright (C) 2007-2016, 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 this software; see file -- -- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy -- -- of the license. -- ------------------------------------------------------------------------------ -- This package provides a set of high-level subprograms for handling UTF8 -- encoding with Basic_Types; use Basic_Types; with GNAT.Strings; use GNAT.Strings; with GNATCOLL.Iconv; use GNATCOLL.Iconv; package UTF8_Utils is function Unknown_To_UTF8 (Input : String; Success : access Boolean) return UTF8_String; -- Transform a string of unknown encoding to UTF-8. -- The heuristics used is the following: -- - if S already contains valid UTF-8, assume it is already encoded -- in UTF8 (the statistical chances for this are very high) -- - if S does not contain valid UTF-8, assume it is encoded using the -- locale, and attempt to convert it from the locale to UTF-8. -- Success is set to False if the conversion failed. function Unknown_To_UTF8 (Input : String) return UTF8_String; -- Same as above, but return "<could not convert to UTF8>" if the -- conversion could not be done. procedure Unknown_To_UTF8 (Input : String; Output : out String_Access; Success : out Boolean); -- Same as above, but return Output as Unchecked_String_Access for -- efficiency. Output is still in UTF8 format, and the caller is -- responsible for freeing it. -- In addition, if Input is already a valid UTF8 string, then Output -- will be set to null: you should use Input in this case. -- If Success is set to False, Output will also be set to null. -- Warning: Never reference Output (Output'Range) or Output'Last, -- use Output (1 .. Len) and Len instead. function UTF8_To_Locale (Input : UTF8_String) return String; -- Convert Input to the GPS locale (ie, the contents of the environment -- variable CHARSET, defaulting to ISO-8859-1). -- If Input could not be converted, Input is returned as-is. function Locale_To_UTF8 (Input : String) return UTF8_String; -- Convert Input from the GPS locale (ie, the contents of the environment -- variable CHARSET, defaulting to ISO-8859-1). -- If Input could not be converted, Input is returned as-is. function UTF8_Next_Char (Str : UTF8_String; Index : Positive) return Positive; function UTF8_Next_Char (Str : UTF8_Unbounded_String; Index : Positive) return Positive; -- Find the start of the next UTF8 character after the Index-th byte. -- Index has to be on the start of a character. -- Index is set to a value greater than Str'Last if there is no more -- character. function UTF8_Prev_Char (Str : UTF8_String; Index : Natural) return Natural; -- Find the start of the previous UTF8 character before the Index-th byte. -- Index has to be on the start of a character. -- Index is set to 0 if there is no more character. function UTF8_Get_Char (Input : UTF8_String) return Wide_Wide_Character; -- Return first character of UTF8_String function Latin_1_To_UTF8 (Input : String) return UTF8_String; -- Convert Latin_1 string to UTF-8. function Column_To_Index (Buffer : UTF8_String; Column : Character_Offset_Type) return Natural; -- Return index of first byte of UTF8 character in given Column -- Return 0 in Column <= 0. Return Buffer'First when Column = 1 function UTF8_Length (Item : UTF8_String) return Natural; -- Returns number of user visible characters in UTF8 encoded string. function Validate (Object : Iconv_T; Input : Byte_Sequence) return Boolean; -- Check if convertion of Text is possible using given Object function Validate_UTF_8 (Input : Byte_Sequence) return Boolean; -- Check whether Input is valid UTF-8 end UTF8_Utils;
with AUnit.Test_Fixtures; with AUnit.Test_Suites; package SHA2_Streams_Tests is function Suite return AUnit.Test_Suites.Access_Test_Suite; private type Fixture is new AUnit.Test_Fixtures.Test_Fixture with null record; procedure SHA2_224_Test (Object : in out Fixture); procedure SHA2_224_One_Million_Test (Object : in out Fixture); procedure SHA2_224_Extremely_Long_Test (Object : in out Fixture); procedure SHA2_256_Test (Object : in out Fixture); procedure SHA2_256_One_Million_Test (Object : in out Fixture); procedure SHA2_256_Extremely_Long_Test (Object : in out Fixture); procedure SHA2_384_Test (Object : in out Fixture); procedure SHA2_384_One_Million_Test (Object : in out Fixture); procedure SHA2_384_Extremely_Long_Test (Object : in out Fixture); procedure SHA2_512_Test (Object : in out Fixture); procedure SHA2_512_One_Million_Test (Object : in out Fixture); procedure SHA2_512_Extremely_Long_Test (Object : in out Fixture); procedure SHA2_512_224_Test (Object : in out Fixture); procedure SHA2_512_224_One_Million_Test (Object : in out Fixture); procedure SHA2_512_256_Test (Object : in out Fixture); procedure SHA2_512_256_One_Million_Test (Object : in out Fixture); end SHA2_Streams_Tests;
pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with Interfaces.C.Strings; package SDL_SDL_error_h is -- arg-macro: procedure SDL_OutOfMemory () -- SDL_Error(SDL_ENOMEM) -- arg-macro: procedure SDL_Unsupported () -- SDL_Error(SDL_UNSUPPORTED) procedure SDL_SetError (fmt : Interfaces.C.Strings.chars_ptr -- , ... ); -- ../include/SDL/SDL_error.h:43 pragma Import (C, SDL_SetError, "SDL_SetError"); function SDL_GetError return Interfaces.C.Strings.chars_ptr; -- ../include/SDL/SDL_error.h:44 pragma Import (C, SDL_GetError, "SDL_GetError"); procedure SDL_ClearError; -- ../include/SDL/SDL_error.h:45 pragma Import (C, SDL_ClearError, "SDL_ClearError"); type SDL_errorcode is (SDL_ENOMEM, SDL_EFREAD, SDL_EFWRITE, SDL_EFSEEK, SDL_UNSUPPORTED, SDL_LASTERROR); pragma Convention (C, SDL_errorcode); -- ../include/SDL/SDL_error.h:62 procedure SDL_Error (code : SDL_errorcode); -- ../include/SDL/SDL_error.h:63 pragma Import (C, SDL_Error, "SDL_Error"); end SDL_SDL_error_h;
----------------------------------------------------------------------- -- awa-oauth-filters -- OAuth filter -- Copyright (C) 2017, 2020 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Security; with Security.OAuth.Servers; with Util.Beans.Objects; with ASF.Sessions; with AWA.Services.Contexts; package body AWA.OAuth.Filters is function Get_Access_Token (Req : in ASF.Requests.Request'Class) return String; -- Initialize the filter. overriding procedure Initialize (Filter : in out Auth_Filter; Config : in ASF.Servlets.Filter_Config) is pragma Unreferenced (Filter, Config); begin null; end Initialize; function Get_Access_Token (Req : in ASF.Requests.Request'Class) return String is pragma Unreferenced (Req); begin return ""; end Get_Access_Token; -- The Do_Filter method of the Filter is called by the container each time -- a request/response pair is passed through the chain due to a client request -- for a resource at the end of the chain. The Filter_Chain passed in to this -- method allows the Filter to pass on the request and response to the next -- entity in the chain. -- -- Before passing the control to the next filter, initialize the service -- context to give access to the current application, current user and -- manage possible transaction rollbacks. overriding procedure Do_Filter (F : in Auth_Filter; Request : in out ASF.Requests.Request'Class; Response : in out ASF.Responses.Response'Class; Chain : in out ASF.Servlets.Filter_Chain) is use type AWA.OAuth.Services.Auth_Manager_Access; type Context_Type is new AWA.Services.Contexts.Service_Context with null record; -- Get the attribute registered under the given name in the HTTP session. overriding function Get_Session_Attribute (Ctx : in Context_Type; Name : in String) return Util.Beans.Objects.Object; -- Set the attribute registered under the given name in the HTTP session. overriding procedure Set_Session_Attribute (Ctx : in out Context_Type; Name : in String; Value : in Util.Beans.Objects.Object); overriding function Get_Session_Attribute (Ctx : in Context_Type; Name : in String) return Util.Beans.Objects.Object is pragma Unreferenced (Ctx); begin return Request.Get_Session.Get_Attribute (Name); end Get_Session_Attribute; -- Set the attribute registered under the given name in the HTTP session. overriding procedure Set_Session_Attribute (Ctx : in out Context_Type; Name : in String; Value : in Util.Beans.Objects.Object) is pragma Unreferenced (Ctx); S : ASF.Sessions.Session := Request.Get_Session; begin S.Set_Attribute (Name, Value); end Set_Session_Attribute; -- App : constant ASF.Servlets.Servlet_Registry_Access -- := ASF.Servlets.Get_Servlet_Context (Chain); Bearer : constant String := Get_Access_Token (Request); Grant : Security.OAuth.Servers.Grant_Type; begin if F.Realm = null then return; end if; F.Realm.Authenticate (Bearer, Grant); -- declare -- Context : aliased Context_Type; -- Application : AWA.Applications.Application_Access; begin -- Get the application -- if App.all in AWA.Applications.Application'Class then -- Application := AWA.Applications.Application'Class (App.all)'Access; -- else -- Application := null; -- end if; -- Context.Set_Context (Application, Grant.Auth); -- Give the control to the next chain up to the servlet. ASF.Servlets.Do_Filter (Chain => Chain, Request => Request, Response => Response); -- By leaving this scope, the active database transactions are rollbacked -- (finalization of Service_Context) end; end Do_Filter; end AWA.OAuth.Filters;
package Multiplicative_Order is type Positive_Array is array (Positive range <>) of Positive; function Find_Order(Element, Modulus: Positive) return Positive; -- naive algorithm -- returns the smallest I such that (Element**I) mod Modulus = 1 function Find_Order(Element: Positive; Coprime_Factors: Positive_Array) return Positive; -- faster algorithm for the same task -- computes the order of all Coprime_Factors(I) -- and returns their least common multiple -- this gives the same result as Find_Order(Element, Modulus) -- with Modulus being the product of all the Coprime_Factors(I) -- -- preconditions: (1) 1 = GCD(Coprime_Factors(I), Coprime_Factors(J)) -- for all pairs I, J with I /= J -- (2) 1 < Coprime_Factors(I) for all I end Multiplicative_Order;
with Ada.Strings.Hash; package body L_Strings with SPARK_Mode is function "=" (Left, Right : L_String) return Boolean is begin return Left.Length = Right.Length and then Left.Data = Right.Data; end "="; function "=" (Left : L_String; Right : String) return Boolean is begin return Left.Length = Right'Length and then Left.Data (Left.Data'First .. Left.Data'First + Right'Length - 1) = Right; end "="; function Hash (S : L_String) return Ada.Containers.Hash_Type is begin if S.Length = 0 then return Ada.Strings.Hash (""); else return Ada.Strings.Hash (S.Data (1 .. Positive (S.Length))); end if; end Hash; procedure Init (S : out L_String) is begin S.Data := (others => ' '); S.Length := 0; end Init; function To_Bounded_String (Source : String; Drop : Truncation := Right) return L_String is Result : L_String; Len : constant Natural := Source'Length; begin Init (Result); if Len <= Max then Result.Data (1 .. Len) := Source; Result.Length := Length_T (Len); elsif Drop = Left then Result.Data := Source (Source'Last - Max + 1 .. Source'Last); Result.Length := Length_T (Max); elsif Drop = Right then Result.Data := Source (Source'First .. Source'First + Max - 1); Result.Length := Length_T (Max); else raise Program_Error; end if; return Result; end To_Bounded_String; function To_String (Source : L_String) return String is begin return Source.Data (1 .. Natural (Source.Length)); end To_String; end L_Strings;
with ada.strings.unbounded; use ada.strings.unbounded; package imagemagick is imagemagick_failure : exception; -- transforme l'image passée en chaine base64 et obtient ses dimensions procedure get_base64(file : string; base64 : out unbounded_string; width, height : out integer); private base64_temp_file : constant string := "base64.txt"; end imagemagick;
with Ada.Characters.Wide_Wide_Latin_1; with Ada.Integer_Wide_Wide_Text_IO; with Ada.Strings.Wide_Wide_Unbounded; with Ada.Wide_Wide_Text_IO; with misc_defs, misc, sym; use misc_defs; with Matreshka.Internals.Unicode.Ucd; with Unicode; with scanner.DFA; use scanner.DFA; with scanner.IO; use scanner.IO; package body scanner is use Ada.Integer_Wide_Wide_Text_IO; use Ada.Strings.Wide_Wide_Unbounded; use Ada.Wide_Wide_Text_IO; use Parser_Tokens; use Unicode; function "+" (Item : Wide_Wide_String) return Unbounded_Wide_Wide_String renames To_Unbounded_Wide_Wide_String; beglin : boolean := false; i, bracelevel: integer; function YYLex return Token is toktype : Token; didadef, indented_code : boolean; cclval : Integer; nmdefptr : Unbounded_Wide_Wide_String; nmdef : Unbounded_Wide_Wide_String; tmpbuf : Unbounded_Wide_Wide_String; procedure ACTION_ECHO is begin Put (temp_action_file, YYText (1 .. YYLength)); end ACTION_ECHO; procedure MARK_END_OF_PROLOG is begin Put (temp_action_file, "%%%% end of prolog"); New_Line (temp_action_file); end MARK_END_OF_PROLOG; --------------------- -- Put_Back_String -- --------------------- procedure Put_Back_String (Str : Unbounded_Wide_Wide_String; Start : Integer) is begin for J in reverse Start + 1 .. Length (Str) loop unput (Element (Str, J)); end loop; end Put_Back_String; function check_yylex_here return boolean is begin return yytext'length >= 2 and then ((yytext(1) = '#') and (yytext(2) = '#')); end check_yylex_here; function YYLex return Token is subtype short is Integer range -32768..32767; yy_act : Integer; yy_c : short; -- returned upon end-of-file YY_END_TOK : constant Integer := 0; YY_END_OF_BUFFER : constant := 84; YY_JAMSTATE : constant := 331; YY_FIRST_TEMPLATE : constant := 332; YY_Current_State : YY_State_Type; INITIAL : constant YY_State_Type := 0; SECT2 : constant YY_State_Type := 1; SECT2PROLOG : constant YY_State_Type := 2; SECT3 : constant YY_State_Type := 3; PICKUPDEF : constant YY_State_Type := 4; SC : constant YY_State_Type := 5; CARETISBOL : constant YY_State_Type := 6; NUM : constant YY_State_Type := 7; QUOTE : constant YY_State_Type := 8; FIRSTCCL : constant YY_State_Type := 9; CCL : constant YY_State_Type := 10; ACTION : constant YY_State_Type := 11; RECOVER : constant YY_State_Type := 12; BRACEERROR : constant YY_State_Type := 13; ACTION_STRING : constant YY_State_Type := 14; yy_accept : constant array(0..331) of short := ( 0, 0, 0, 0, 0, 0, 0, 82, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 84, 13, 6, 12, 10, 1, 11, 13, 13, 13, 9, 40, 31, 32, 25, 40, 39, 23, 40, 40, 40, 31, 21, 40, 40, 24, 83, 19, 82, 82, 15, 14, 16, 46, 83, 42, 43, 45, 47, 61, 62, 59, 58, 60, 48, 50, 49, 48, 54, 53, 54, 54, 56, 56, 56, 57, 67, 72, 71, 73, 67, 73, 68, 65, 66, 83, 17, 64, 63, 74, 76, 77, 78, 6, 12, 10, 1, 11, 0, 0, 2, 0, 7, 4, 5, 0, 9, 31, 32, 0, 28, 0, 0, 0, 79, 79, 79, 79, 27, 26, 27, 0, 31, 21, 0, 0, 35, 0, 0, 19, 18, 82, 82, 15, 14, 44, 45, 58, 80, 80, 80, 80, 51, 52, 55, 67, 0, 70, 0, 67, 68, 0, 17, 74, 75, 0, 7, 0, 0, 3, 0, 29, 0, 36, 0, 0, 0, 79, 0, 0, 27, 27, 38, 0, 0, 0, 35, 0, 30, 80, 0, 0, 67, 69, 0, 0, 8, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 22, 0, 22, 0, 22, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 79, 0, 0, 80, 34, 0, 0, 0, 0, 0, 79, 0, 0, 80, 0, 0, 0, 0, 0, 79, 0, 0, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 37, 0, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ); type Secondary_Stage_Index is range 0 .. 16#FF#; type Primary_Stage_Index is range 0 .. 16#10FF#; type Secondary_Stage_Array is array (Secondary_Stage_Index) of Short; type Secondary_Stage_Array_Access is access constant Secondary_Stage_Array; yy_ec_0 : aliased constant Secondary_Stage_Array := ( 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 5, 1, 6, 7, 8, 9, 1, 10, 11, 11, 11, 11, 12, 13, 11, 14, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 1, 1, 16, 1, 17, 11, 1, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 32, 32, 32, 33, 34, 35, 32, 36, 37, 38, 39, 32, 40, 41, 42, 32, 18, 19, 20, 21, 22, 1, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 32, 32, 32, 33, 34, 35, 32, 36, 37, 38, 39, 32, 40, 41, 42, 32, 43, 44, 45, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ); yy_ec_1 : aliased constant Secondary_Stage_Array := ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 ); yy_ec_base : constant array (Primary_Stage_Index) of Secondary_Stage_Array_Access := ( 0 => yy_ec_0'Access, others => yy_ec_1'Access); function yy_ec (Item : Wide_Wide_Character) return short is Code : constant Integer := Wide_Wide_Character'Pos (Item); Group : constant Primary_Stage_Index := Primary_Stage_Index (Code / 256); Offset : constant Secondary_Stage_Index := Secondary_Stage_Index (Code mod 256); begin return yy_ec_base (Group) (Offset); end yy_ec; yy_meta : constant array(0..45) of short := ( 0, 1, 2, 3, 2, 2, 4, 1, 1, 1, 5, 1, 1, 6, 5, 7, 1, 1, 1, 8, 9, 1, 10, 11, 11, 11, 11, 11, 11, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 5, 1, 12 ); yy_base : constant array(0..385) of short := ( 0, 0, 45, 89, 132, 1244, 1243, 1242, 1241, 107, 111, 176, 0, 1222, 1221, 114, 115, 125, 136, 144, 149, 153, 219, 239, 0, 1237, 1236, 116, 119, 282, 283, 1238, 1248, 221, 1248, 0, 290, 1248, 1232, 278, 1221, 0, 1248, 294, 1248, 1248, 96, 1248, 1217, 1211, 275, 338, 382, 1248, 1220, 1215, 1248, 1222, 0, 1221, 1248, 0, 119, 1248, 1248, 1248, 1248, 1202, 0, 1248, 1248, 1248, 1248, 1205, 1248, 1248, 1248, 1248, 81, 1248, 1248, 285, 1206, 1248, 0, 290, 1248, 0, 1248, 1248, 139, 1205, 1248, 0, 1248, 1248, 1212, 1248, 1248, 1248, 0, 1248, 1248, 0, 225, 1248, 0, 304, 1248, 1201, 1210, 1248, 1205, 0, 1171, 1248, 1205, 0, 386, 1248, 1166, 1248, 1141, 214, 296, 1248, 1152, 1121, 0, 0, 1248, 430, 1150, 474, 1248, 1149, 309, 0, 1156, 1155, 0, 1248, 1154, 1248, 0, 328, 1248, 0, 1127, 1248, 1126, 1097, 0, 1248, 1248, 1248, 0, 294, 1248, 0, 518, 0, 1114, 1248, 0, 1248, 1103, 0, 1079, 1098, 1248, 1097, 1248, 1031, 1248, 216, 373, 549, 1038, 139, 0, 0, 0, 1248, 1033, 315, 323, 0, 1039, 1248, 1026, 364, 0, 0, 1248, 577, 1021, 1248, 987, 983, 381, 378, 607, 977, 980, 0, 999, 993, 987, 951, 943, 0, 923, 943, 383, 385, 387, 621, 907, 886, 0, 920, 1248, 885, 1248, 879, 1248, 835, 833, 0, 1248, 853, 461, 395, 635, 819, 802, 0, 682, 665, 0, 1248, 398, 463, 649, 676, 672, 0, 659, 657, 0, 402, 465, 663, 652, 646, 1248, 638, 632, 1248, 469, 471, 404, 638, 624, 626, 610, 474, 476, 610, 607, 597, 604, 479, 486, 581, 297, 577, 474, 580, 583, 567, 559, 557, 538, 538, 541, 546, 585, 587, 1248, 537, 536, 1248, 484, 484, 591, 594, 466, 459, 448, 391, 618, 632, 404, 398, 396, 384, 493, 589, 368, 319, 286, 301, 660, 620, 284, 254, 634, 202, 136, 646, 144, 131, 673, 100, 81, 675, 77, 75, 678, 1248, 705, 717, 729, 741, 753, 765, 777, 789, 801, 813, 825, 832, 843, 855, 862, 873, 885, 897, 909, 921, 933, 945, 952, 963, 975, 987, 999, 1008, 1015, 1026, 1038, 1050, 1062, 1074, 1086, 1092, 1103, 1114, 1126, 1132, 1143, 1149, 1154, 1159, 1170, 1182, 1194, 1200, 1205, 1210, 1215, 1220, 1225, 1230 ); yy_def : constant array(0..385) of short := ( 0, 331, 331, 332, 332, 333, 333, 334, 334, 335, 335, 331, 11, 336, 336, 337, 337, 338, 338, 339, 339, 340, 340, 331, 23, 341, 341, 336, 336, 342, 342, 331, 331, 331, 331, 343, 331, 331, 344, 345, 331, 346, 331, 331, 331, 331, 331, 331, 331, 347, 348, 331, 349, 331, 331, 331, 331, 350, 351, 352, 331, 353, 331, 331, 331, 331, 331, 331, 354, 331, 331, 331, 331, 331, 331, 331, 331, 331, 348, 331, 331, 355, 356, 331, 357, 348, 331, 358, 331, 331, 359, 358, 331, 360, 331, 331, 361, 331, 331, 331, 362, 331, 331, 363, 331, 331, 343, 331, 331, 331, 344, 331, 331, 364, 331, 331, 365, 346, 331, 331, 366, 331, 331, 347, 347, 331, 331, 331, 367, 368, 331, 331, 331, 349, 331, 331, 366, 369, 370, 350, 351, 331, 352, 331, 353, 331, 331, 354, 331, 331, 331, 331, 371, 331, 331, 331, 358, 359, 331, 359, 331, 360, 361, 331, 362, 331, 372, 364, 331, 365, 331, 366, 331, 331, 331, 347, 347, 347, 331, 331, 373, 368, 131, 331, 331, 370, 366, 369, 370, 331, 331, 331, 374, 160, 331, 160, 372, 331, 331, 331, 347, 347, 177, 331, 331, 375, 376, 377, 378, 331, 331, 379, 331, 331, 347, 347, 347, 177, 331, 331, 380, 376, 331, 377, 331, 378, 331, 331, 331, 381, 331, 331, 347, 347, 177, 331, 331, 382, 331, 331, 383, 331, 347, 347, 177, 331, 331, 384, 331, 331, 385, 347, 347, 177, 331, 331, 331, 331, 331, 331, 347, 347, 347, 331, 331, 331, 331, 347, 347, 331, 331, 331, 331, 347, 347, 331, 331, 331, 331, 347, 347, 331, 331, 331, 331, 331, 331, 347, 347, 347, 331, 331, 331, 331, 331, 331, 347, 347, 331, 331, 331, 331, 347, 347, 331, 331, 331, 331, 347, 347, 331, 331, 331, 331, 347, 347, 331, 331, 347, 331, 331, 347, 331, 331, 347, 331, 331, 347, 331, 331, 347, 0, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331 ); yy_nxt : constant array(0..1293) of short := ( 0, 32, 33, 34, 33, 33, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 32, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 32, 32, 32, 32, 36, 37, 36, 36, 32, 38, 32, 39, 32, 32, 32, 40, 32, 32, 32, 32, 32, 32, 32, 32, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 41, 32, 32, 32, 43, 44, 43, 43, 45, 126, 46, 121, 121, 47, 121, 284, 47, 281, 48, 329, 49, 50, 62, 63, 62, 62, 62, 63, 62, 62, 71, 71, 98, 128, 145, 98, 145, 145, 328, 72, 72, 76, 73, 73, 77, 51, 47, 52, 53, 52, 52, 45, 76, 46, 54, 77, 47, 78, 55, 47, 65, 48, 158, 49, 50, 65, 56, 326, 78, 65, 80, 159, 74, 74, 99, 80, 81, 99, 82, 84, 325, 81, 203, 82, 323, 85, 86, 204, 51, 47, 64, 64, 65, 64, 64, 64, 64, 64, 64, 64, 64, 66, 64, 64, 64, 64, 67, 64, 64, 64, 64, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 68, 64, 64, 64, 65, 104, 105, 104, 104, 104, 105, 104, 104, 200, 84, 124, 174, 124, 174, 322, 85, 86, 87, 87, 88, 87, 87, 89, 87, 87, 87, 90, 87, 87, 91, 92, 87, 87, 87, 87, 87, 87, 87, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 93, 94, 87, 95, 101, 101, 113, 102, 102, 126, 320, 107, 108, 107, 107, 118, 119, 118, 118, 150, 103, 103, 109, 158, 126, 107, 108, 107, 107, 127, 175, 172, 159, 128, 114, 123, 109, 189, 115, 151, 319, 186, 317, 152, 127, 172, 284, 207, 128, 145, 176, 145, 145, 282, 177, 208, 283, 120, 129, 129, 316, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 129, 130, 129, 129, 129, 129, 129, 129, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 129, 129, 129, 133, 134, 133, 133, 118, 119, 118, 118, 124, 174, 209, 135, 214, 124, 174, 210, 124, 174, 124, 174, 124, 174, 124, 174, 215, 281, 233, 313, 232, 216, 124, 174, 201, 124, 174, 312, 251, 124, 174, 124, 174, 311, 136, 310, 260, 307, 120, 181, 181, 243, 181, 181, 181, 181, 181, 181, 181, 181, 181, 182, 181, 182, 181, 181, 181, 181, 181, 181, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 182, 181, 181, 183, 133, 134, 133, 133, 124, 174, 124, 174, 124, 174, 306, 135, 124, 174, 124, 174, 261, 124, 174, 124, 174, 305, 124, 174, 267, 252, 242, 273, 304, 124, 174, 268, 280, 274, 279, 285, 124, 174, 286, 301, 314, 300, 136, 193, 193, 194, 193, 193, 195, 193, 193, 193, 195, 193, 193, 193, 195, 193, 193, 193, 193, 193, 193, 193, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 195, 193, 195, 202, 124, 174, 299, 124, 174, 298, 295, 202, 202, 202, 202, 202, 202, 195, 195, 294, 195, 195, 293, 195, 195, 195, 292, 195, 195, 195, 214, 195, 195, 195, 195, 195, 195, 195, 124, 174, 291, 124, 174, 124, 174, 124, 174, 124, 174, 124, 174, 290, 124, 174, 284, 315, 297, 287, 281, 288, 195, 217, 289, 302, 303, 278, 296, 277, 276, 217, 217, 217, 217, 217, 217, 234, 124, 174, 124, 174, 275, 318, 272, 234, 234, 234, 234, 234, 234, 244, 124, 174, 124, 174, 271, 308, 270, 244, 244, 244, 244, 244, 244, 253, 124, 174, 269, 266, 265, 309, 321, 253, 253, 253, 253, 253, 253, 262, 124, 174, 324, 264, 263, 258, 257, 262, 262, 262, 262, 262, 262, 124, 174, 124, 174, 327, 124, 174, 255, 330, 287, 254, 249, 248, 287, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 42, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 57, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 59, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 61, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 65, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 70, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 75, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 79, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 83, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 96, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 106, 106, 246, 245, 106, 106, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 110, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 112, 117, 117, 241, 239, 117, 117, 123, 123, 238, 123, 123, 123, 123, 123, 226, 123, 123, 123, 125, 125, 224, 125, 125, 125, 125, 125, 125, 125, 125, 125, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 132, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 139, 141, 222, 236, 141, 141, 141, 141, 141, 141, 141, 141, 141, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 142, 144, 144, 235, 144, 144, 144, 144, 144, 144, 144, 144, 144, 147, 147, 231, 230, 147, 147, 149, 149, 228, 149, 149, 149, 149, 149, 149, 149, 149, 149, 153, 153, 227, 153, 153, 153, 153, 153, 153, 153, 153, 153, 155, 155, 226, 155, 155, 155, 155, 155, 224, 155, 155, 155, 156, 156, 222, 219, 218, 156, 156, 156, 156, 157, 157, 213, 157, 157, 157, 157, 157, 157, 157, 157, 157, 161, 161, 212, 197, 161, 161, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 162, 164, 164, 149, 189, 164, 164, 164, 206, 164, 164, 164, 164, 165, 165, 125, 165, 165, 165, 165, 165, 165, 165, 165, 165, 167, 167, 199, 167, 167, 167, 167, 167, 167, 167, 167, 167, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 169, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 171, 180, 172, 170, 198, 180, 181, 181, 197, 181, 181, 181, 181, 181, 181, 181, 181, 187, 187, 163, 187, 187, 187, 187, 187, 187, 187, 187, 187, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 188, 192, 191, 190, 148, 192, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 196, 205, 143, 140, 189, 205, 211, 185, 184, 179, 211, 220, 178, 173, 172, 220, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 221, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 223, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 225, 229, 170, 168, 166, 229, 237, 111, 116, 163, 237, 240, 160, 154, 148, 240, 247, 146, 143, 140, 247, 250, 138, 137, 124, 250, 256, 122, 116, 111, 256, 259, 331, 97, 97, 259, 69, 69, 60, 60, 58, 58, 31, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331 ); yy_chk : constant array(0..1293) of short := ( 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 78, 3, 46, 46, 3, 46, 329, 3, 328, 3, 326, 3, 3, 9, 9, 9, 9, 10, 10, 10, 10, 15, 16, 27, 78, 62, 28, 62, 62, 325, 15, 16, 17, 15, 16, 17, 3, 3, 4, 4, 4, 4, 4, 18, 4, 4, 18, 4, 17, 4, 4, 19, 4, 90, 4, 4, 20, 4, 323, 18, 21, 19, 90, 15, 16, 27, 20, 19, 28, 19, 21, 322, 20, 179, 20, 320, 21, 21, 179, 4, 4, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 22, 33, 33, 33, 33, 104, 104, 104, 104, 175, 22, 123, 123, 175, 175, 319, 22, 22, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 29, 30, 39, 29, 30, 50, 317, 36, 36, 36, 36, 43, 43, 43, 43, 81, 29, 30, 36, 157, 85, 107, 107, 107, 107, 50, 124, 136, 157, 50, 39, 124, 107, 185, 39, 81, 316, 136, 313, 81, 85, 186, 312, 185, 85, 145, 124, 145, 145, 276, 124, 186, 276, 43, 51, 51, 311, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 51, 52, 52, 52, 52, 118, 118, 118, 118, 176, 176, 191, 52, 200, 201, 201, 191, 200, 200, 214, 214, 215, 215, 216, 216, 201, 310, 216, 307, 215, 201, 233, 233, 176, 242, 242, 306, 242, 251, 251, 262, 262, 305, 52, 304, 251, 301, 118, 131, 131, 233, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 131, 133, 133, 133, 133, 232, 232, 243, 243, 252, 252, 300, 133, 260, 260, 261, 261, 252, 267, 267, 268, 268, 299, 273, 273, 260, 243, 232, 267, 298, 274, 274, 261, 274, 268, 273, 278, 308, 308, 278, 295, 308, 294, 133, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 177, 287, 287, 292, 177, 177, 291, 286, 177, 177, 177, 177, 177, 177, 195, 195, 285, 195, 195, 284, 195, 195, 195, 283, 195, 195, 195, 287, 195, 195, 195, 195, 195, 195, 195, 279, 279, 282, 280, 280, 288, 288, 289, 289, 309, 309, 296, 296, 281, 297, 297, 277, 309, 289, 279, 275, 280, 195, 202, 280, 296, 297, 272, 288, 271, 270, 202, 202, 202, 202, 202, 202, 217, 302, 302, 315, 315, 269, 315, 266, 217, 217, 217, 217, 217, 217, 234, 303, 303, 318, 318, 265, 302, 264, 234, 234, 234, 234, 234, 234, 244, 321, 321, 263, 258, 257, 303, 318, 244, 244, 244, 244, 244, 244, 253, 314, 314, 321, 255, 254, 249, 248, 253, 253, 253, 253, 253, 253, 324, 324, 327, 327, 324, 330, 330, 246, 327, 314, 245, 239, 238, 330, 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, 332, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 333, 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, 334, 335, 335, 335, 335, 335, 335, 335, 335, 335, 335, 335, 335, 336, 336, 336, 336, 336, 336, 336, 336, 336, 336, 336, 336, 337, 337, 337, 337, 337, 337, 337, 337, 337, 337, 337, 337, 338, 338, 338, 338, 338, 338, 338, 338, 338, 338, 338, 338, 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, 339, 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, 340, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 341, 342, 342, 342, 342, 342, 342, 342, 342, 342, 342, 342, 342, 343, 343, 236, 235, 343, 343, 344, 344, 344, 344, 344, 344, 344, 344, 344, 344, 344, 344, 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, 345, 346, 346, 231, 228, 346, 346, 347, 347, 227, 347, 347, 347, 347, 347, 225, 347, 347, 347, 348, 348, 223, 348, 348, 348, 348, 348, 348, 348, 348, 348, 349, 349, 349, 349, 349, 349, 349, 349, 349, 349, 349, 349, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 350, 351, 221, 219, 351, 351, 351, 351, 351, 351, 351, 351, 351, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 352, 353, 353, 218, 353, 353, 353, 353, 353, 353, 353, 353, 353, 354, 354, 213, 212, 354, 354, 355, 355, 210, 355, 355, 355, 355, 355, 355, 355, 355, 355, 356, 356, 209, 356, 356, 356, 356, 356, 356, 356, 356, 356, 357, 357, 208, 357, 357, 357, 357, 357, 207, 357, 357, 357, 358, 358, 206, 204, 203, 358, 358, 358, 358, 359, 359, 199, 359, 359, 359, 359, 359, 359, 359, 359, 359, 360, 360, 198, 196, 360, 360, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 361, 362, 362, 190, 188, 362, 362, 362, 184, 362, 362, 362, 362, 363, 363, 178, 363, 363, 363, 363, 363, 363, 363, 363, 363, 364, 364, 173, 364, 364, 364, 364, 364, 364, 364, 364, 364, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 365, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 366, 367, 171, 169, 168, 367, 368, 368, 166, 368, 368, 368, 368, 368, 368, 368, 368, 369, 369, 162, 369, 369, 369, 369, 369, 369, 369, 369, 369, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 370, 371, 151, 150, 148, 371, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 372, 373, 142, 139, 138, 373, 374, 135, 132, 127, 374, 375, 126, 122, 120, 375, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 376, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 377, 378, 378, 378, 378, 378, 378, 378, 378, 378, 378, 378, 378, 379, 116, 114, 112, 379, 380, 110, 109, 96, 380, 381, 91, 82, 73, 381, 382, 67, 59, 57, 382, 383, 55, 54, 49, 383, 384, 48, 40, 38, 384, 385, 31, 26, 25, 385, 14, 13, 8, 7, 6, 5, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331, 331 ); -- copy whatever the last rule matched to the standard output procedure ECHO is begin if Ada.Wide_Wide_Text_IO.Is_Open (User_Output_File) then Ada.Wide_Wide_Text_IO.Put (User_Output_File, YYText); else Ada.Wide_Wide_Text_IO.Put (YYText); end if; end ECHO; -- enter a start condition. -- Using procedure requires a () after the ENTER, but makes -- everything much neater. procedure ENTER (State : Integer) is begin YY_Start := 1 + 2 * State; end ENTER; pragma Inline (ENTER); -- action number for EOF rule of a given start state function YY_STATE_EOF(state : Integer) return Integer is begin return YY_END_OF_BUFFER + state + 1; end YY_STATE_EOF; pragma Inline (YY_STATE_EOF); -- return all but the first 'n' matched characters back to the input stream procedure yyless(n : Integer) is begin yy_cp := yy_bp + n; yy_c_buf_p := yy_cp; YY_DO_BEFORE_ACTION; -- set up yytext again end yyless; pragma Inline (yyless); -- redefine this if you have something you want each time. procedure YY_USER_ACTION is begin null; end; pragma Inline (YY_USER_ACTION); -- yy_get_previous_state - get the state just before the EOB char -- was reached function YY_Get_Previous_State return YY_State_Type is YY_Current_State : YY_State_Type; YY_C : Short; Index : Integer; Code : Wide_Wide_Character; yy_bp : integer := yytext_ptr; begin yy_current_state := yy_start; if Previous (yy_ch_buf, yy_bp) = Ada.Characters.Wide_Wide_Latin_1.LF then yy_current_state := yy_current_state + 1; end if; declare yy_cp : integer := yytext_ptr; begin while yy_cp < yy_c_buf_p loop Index := yy_cp; Index := yy_cp; Next (yy_ch_buf, Index, Code); yy_c := yy_ec(Code); if (yy_accept(yy_current_state) /= 0 ) then yy_last_accepting_state := yy_current_state; yy_last_accepting_cpos := yy_cp; end if; while ( yy_chk(yy_base(yy_current_state) + yy_c) /= yy_current_state ) loop yy_current_state := yy_def(yy_current_state); if yy_current_state >= YY_FIRST_TEMPLATE then yy_c := yy_meta(yy_c); end if; end loop; yy_current_state := yy_nxt(yy_base(yy_current_state) + yy_c); yy_cp := Index; end loop; end; return yy_current_state; end yy_get_previous_state; procedure YYRestart (Input_File : Ada.Wide_Wide_Text_IO.File_Type) is begin Open_Input (Ada.Wide_Wide_Text_IO.Name (Input_File)); end YYRestart; Index : Integer; Code : Wide_Wide_Character; begin -- of YYLex <<new_file>> -- This is where we enter upon encountering an end-of-file and -- yywrap() indicating that we should continue processing if ( yy_init ) then if ( yy_start = 0 ) then yy_start := 1; -- first start state end if; -- we put in the '\n' and start reading from [1] so that an -- initial match-at-newline will be true. yy_ch_buf.data (0) := Ada.Characters.Wide_Wide_Latin_1.LF; yy_n_chars := 1; -- we always need two end-of-buffer characters. The first causes -- a transition to the end-of-buffer state. The second causes -- a jam in that state. yy_ch_buf.data (yy_n_chars) := YY_END_OF_BUFFER_CHAR; yy_ch_buf.data (yy_n_chars + 1) := YY_END_OF_BUFFER_CHAR; yy_eof_has_been_seen := false; yytext_ptr := 1; yy_c_buf_p := yytext_ptr; yy_init := false; end if; -- yy_init loop -- loops until end-of-file is reached yy_cp := yy_c_buf_p; -- yy_bp points to the position in yy_ch_buf of the start of the -- current run. yy_bp := yy_cp; yy_current_state := yy_start; if Previous (yy_ch_buf, yy_bp) = Ada.Characters.Wide_Wide_Latin_1.LF then yy_current_state := yy_current_state + 1; end if; loop Index := yy_cp; Next (yy_ch_buf, Index, Code); yy_c := yy_ec(Code); if (yy_accept(yy_current_state) /= 0 ) then yy_last_accepting_state := yy_current_state; yy_last_accepting_cpos := yy_cp; end if; while ( yy_chk(yy_base(yy_current_state) + yy_c) /= yy_current_state ) loop yy_current_state := yy_def(yy_current_state); if yy_current_state >= YY_FIRST_TEMPLATE then yy_c := yy_meta(yy_c); end if; end loop; yy_current_state := yy_nxt(yy_base(yy_current_state) + yy_c); yy_cp := Index; exit when yy_current_state = YY_JAMSTATE; end loop; yy_cp := yy_last_accepting_cpos; yy_current_state := yy_last_accepting_state; <<next_action>> yy_act := yy_accept(yy_current_state); YY_DO_BEFORE_ACTION; YY_USER_ACTION; if Aflex_Debug then -- output acceptance info. for (-d) debug mode Ada.Wide_Wide_Text_IO.Put (Ada.Wide_Wide_Text_IO.Standard_Error, "--accepting rule #" ); Ada.Wide_Wide_Text_IO.Put (Ada.Wide_Wide_Text_IO.Standard_Error, Integer'Wide_Wide_Image (YY_Act)); Ada.Wide_Wide_Text_IO.Put_Line (Ada.Wide_Wide_Text_IO.Standard_Error, "(""" & yytext & """)"); end if; <<do_action>> -- this label is used only to access EOF actions case yy_act is when 0 => -- must backtrack yy_cp := yy_last_accepting_cpos; yy_current_state := yy_last_accepting_state; goto next_action; when 1 => --# line 47 "scanner.l" indented_code := true; when 2 => --# line 48 "scanner.l" linenum := linenum + 1; ECHO; -- treat as a comment; when 3 => --# line 51 "scanner.l" linenum := linenum + 1; ECHO; when 4 => --# line 52 "scanner.l" return ( SCDECL ); when 5 => --# line 53 "scanner.l" return ( XSCDECL ); when 6 => --# line 55 "scanner.l" return ( WHITESPACE ); when 7 => --# line 57 "scanner.l" sectnum := 2; misc.line_directive_out; ENTER(SECT2PROLOG); return ( SECTEND ); when 8 => --# line 64 "scanner.l" Put (Standard_Error, "old-style lex command at line "); Put (Standard_Error, Linenum); Put (Standard_Error, "ignored:"); New_Line (Standard_Error ); Put (Standard_Error, Unicode.HT ); Put (Standard_Error, YYText (1 .. YYLength)); Linenum := Linenum + 1; when 9 => --# line 74 "scanner.l" nmstr := +YYText (1 .. YYLength); didadef := false; ENTER(PICKUPDEF); when 10 => --# line 80 "scanner.l" nmstr := +YYText (1 .. YYLength); return NAME; when 11 => --# line 83 "scanner.l" linenum := linenum + 1; -- allows blank lines in section 1; when 12 => --# line 86 "scanner.l" linenum := linenum + 1; return Newline; when 13 => --# line 87 "scanner.l" misc.synerr( "illegal character" );ENTER(RECOVER); when 14 => --# line 89 "scanner.l" null; -- separates name and definition; when 15 => --# line 93 "scanner.l" nmdef := +YYText (1 .. YYLength); i := length (nmdef); while i >= 1 loop if Element (nmdef, i) /= ' ' and Element (nmdef, i) /= Unicode.HT then exit; end if; i := i - 1; end loop; sym.ndinstal (nmstr, Unbounded_Slice (nmdef, 1, i)); didadef := true; when 16 => --# line 110 "scanner.l" if ( not didadef ) then misc.synerr( "incomplete name definition" ); end if; ENTER(0); linenum := linenum + 1; when 17 => --# line 118 "scanner.l" linenum := linenum + 1; ENTER(0); nmstr := +YYText (1 .. YYLength); return NAME; when 18 => yy_cp := yy_cp - 1; yy_c_buf_p := yy_cp; YY_DO_BEFORE_ACTION; -- set up yytext again --# line 124 "scanner.l" linenum := linenum + 1; ACTION_ECHO; MARK_END_OF_PROLOG; ENTER(SECT2); when 19 => --# line 131 "scanner.l" linenum := linenum + 1; ACTION_ECHO; when YY_END_OF_BUFFER +SECT2PROLOG + 1 => --# line 133 "scanner.l" MARK_END_OF_PROLOG; return End_Of_Input; when 21 => --# line 137 "scanner.l" linenum := linenum + 1; -- allow blank lines in sect2; -- this rule matches indented lines which -- are not comments. when 22 => --# line 142 "scanner.l" misc.synerr("indented code found outside of action"); linenum := linenum + 1; when 23 => --# line 147 "scanner.l" ENTER(SC); return ( '<' ); when 24 => --# line 148 "scanner.l" return ( '^' ); when 25 => --# line 149 "scanner.l" ENTER(QUOTE); return ( '"' ); when 26 => yy_cp := yy_bp + 1; yy_c_buf_p := yy_cp; YY_DO_BEFORE_ACTION; -- set up yytext again --# line 150 "scanner.l" ENTER(NUM); return ( '{' ); when 27 => --# line 151 "scanner.l" ENTER(BRACEERROR); when 28 => yy_cp := yy_bp + 1; yy_c_buf_p := yy_cp; YY_DO_BEFORE_ACTION; -- set up yytext again --# line 152 "scanner.l" return ( '$' ); when 29 => --# line 154 "scanner.l" continued_action := true; linenum := linenum + 1; return Newline; when 30 => --# line 159 "scanner.l" linenum := linenum + 1; ACTION_ECHO; when 31 => --# line 161 "scanner.l" -- this rule is separate from the one below because -- otherwise we get variable trailing context, so -- we can't build the scanner using -f,F bracelevel := 0; continued_action := false; ENTER(ACTION); return Newline; when 32 => yy_cp := yy_cp - 1; yy_c_buf_p := yy_cp; YY_DO_BEFORE_ACTION; -- set up yytext again --# line 172 "scanner.l" bracelevel := 0; continued_action := false; ENTER(ACTION); return Newline; when 33 => --# line 179 "scanner.l" linenum := linenum + 1; return Newline; when 34 => --# line 181 "scanner.l" return ( EOF_OP ); when 35 => --# line 183 "scanner.l" sectnum := 3; ENTER(SECT3); return ( End_Of_Input ); -- to stop the parser when 36 => --# line 190 "scanner.l" nmstr := +YYText (1 .. YYLength); -- check to see if we've already encountered this ccl cclval := sym.ccllookup (nmstr); if ( cclval /= 0 ) then yylval := cclval; cclreuse := cclreuse + 1; return ( PREVCCL ); else -- we fudge a bit. We know that this ccl will -- soon be numbered as lastccl + 1 by cclinit sym.cclinstal (nmstr, lastccl + 1); -- push back everything but the leading bracket -- so the ccl can be rescanned Put_Back_String (nmstr, 1); ENTER(FIRSTCCL); return ( '[' ); end if; when 37 => --# line 215 "scanner.l" declare Image : constant Wide_Wide_String := YYText; begin YYLVal := Matreshka.Internals.Unicode.Ucd.Boolean_Properties'Pos (Matreshka.Internals.Unicode.Ucd.Boolean_Properties'Wide_Wide_Value (Image (Image'First + 3 .. Image'Last - 1))) + 1; if Image (Image'First + 1) = 'P' then YYLVal := -YYLVal; end if; return PROP; end; when 38 => --# line 233 "scanner.l" nmstr := +YYText (1 .. YYLength); -- chop leading and trailing brace tmpbuf := Unbounded_Slice (+yytext (1 .. YYLength), 2, YYLength - 1); nmdefptr := sym.ndlookup (tmpbuf); if nmdefptr = Null_Unbounded_Wide_Wide_String then misc.synerr( "undefined {name}" ); else -- push back name surrounded by ()'s unput(')'); Put_Back_String (nmdefptr, 0); unput('('); end if; when 39 => --# line 250 "scanner.l" tmpbuf := +YYText (1 .. YYLength); case Element (tmpbuf, 1) is when '/' => return '/'; when '|' => return '|'; when '*' => return '*'; when '+' => return '+'; when '?' => return '?'; when '.' => return '.'; when '(' => return '('; when ')' => return ')'; when others => Misc.Aflex_Error ("error in aflex case"); end case; when 40 => --# line 264 "scanner.l" tmpbuf := +YYText (1 .. YYLength); yylval := Wide_Wide_Character'Pos (Element (tmpbuf, 1)); return CHAR; when 41 => --# line 268 "scanner.l" linenum := linenum + 1; return Newline; when 42 => --# line 271 "scanner.l" return ( ',' ); when 43 => --# line 272 "scanner.l" ENTER(SECT2); return ( '>' ); when 44 => yy_cp := yy_bp + 1; yy_c_buf_p := yy_cp; YY_DO_BEFORE_ACTION; -- set up yytext again --# line 273 "scanner.l" ENTER(CARETISBOL); return ( '>' ); when 45 => --# line 274 "scanner.l" nmstr := +YYText (1 .. YYLength); return NAME; when 46 => --# line 277 "scanner.l" misc.synerr( "bad start condition name" ); when 47 => --# line 279 "scanner.l" ENTER(SECT2); return ( '^' ); when 48 => --# line 282 "scanner.l" tmpbuf := +YYText (1 .. YYLength); yylval := Wide_Wide_Character'Pos (Element (tmpbuf, 1)); return CHAR; when 49 => --# line 286 "scanner.l" ENTER(SECT2); return ( '"' ); when 50 => --# line 288 "scanner.l" misc.synerr( "missing quote" ); ENTER(SECT2); linenum := linenum + 1; return ( '"' ); when 51 => yy_cp := yy_bp + 1; yy_c_buf_p := yy_cp; YY_DO_BEFORE_ACTION; -- set up yytext again --# line 296 "scanner.l" ENTER(CCL); return ( '^' ); when 52 => yy_cp := yy_bp + 1; yy_c_buf_p := yy_cp; YY_DO_BEFORE_ACTION; -- set up yytext again --# line 297 "scanner.l" return ( '^' ); when 53 => --# line 298 "scanner.l" ENTER(CCL); yylval := Wide_Wide_Character'Pos('-'); return ( CHAR ); when 54 => --# line 299 "scanner.l" ENTER(CCL); tmpbuf := +YYText (1 .. YYLength); yylval := Wide_Wide_Character'Pos (Element (tmpbuf, 1)); return CHAR; when 55 => yy_cp := yy_bp + 1; yy_c_buf_p := yy_cp; YY_DO_BEFORE_ACTION; -- set up yytext again --# line 305 "scanner.l" return ( '-' ); when 56 => --# line 306 "scanner.l" tmpbuf := +YYText (1 .. YYLength); yylval := Wide_Wide_Character'Pos (Element (tmpbuf, 1)); return CHAR; when 57 => --# line 310 "scanner.l" ENTER(SECT2); return ( ']' ); when 58 => --# line 313 "scanner.l" yylval := misc.myctoi (+YYText (1 .. YYLength)); return ( NUMBER ); when 59 => --# line 318 "scanner.l" return ( ',' ); when 60 => --# line 319 "scanner.l" ENTER(SECT2); return ( '}' ); when 61 => --# line 321 "scanner.l" misc.synerr( "bad character inside {}'s" ); ENTER(SECT2); return ( '}' ); when 62 => --# line 327 "scanner.l" misc.synerr( "missing }" ); ENTER(SECT2); linenum := linenum + 1; return ( '}' ); when 63 => --# line 335 "scanner.l" misc.synerr( "bad name in {}'s" ); ENTER(SECT2); when 64 => --# line 336 "scanner.l" misc.synerr( "missing }" ); linenum := linenum + 1; ENTER(SECT2); when 65 => --# line 341 "scanner.l" bracelevel := bracelevel + 1; when 66 => --# line 342 "scanner.l" bracelevel := bracelevel - 1; when 67 => --# line 343 "scanner.l" ACTION_ECHO; when 68 => --# line 344 "scanner.l" ACTION_ECHO; when 69 => --# line 345 "scanner.l" linenum := linenum + 1; ACTION_ECHO; when 70 => --# line 346 "scanner.l" ACTION_ECHO; -- character constant; when 71 => --# line 350 "scanner.l" ACTION_ECHO; ENTER(ACTION_STRING); when 72 => --# line 352 "scanner.l" linenum := linenum + 1; ACTION_ECHO; if ( bracelevel = 0 ) then New_Line (Temp_Action_File); ENTER(SECT2); end if; when 73 => --# line 360 "scanner.l" ACTION_ECHO; when 74 => --# line 362 "scanner.l" ACTION_ECHO; when 75 => --# line 363 "scanner.l" ACTION_ECHO; when 76 => --# line 364 "scanner.l" linenum := linenum + 1; ACTION_ECHO; when 77 => --# line 365 "scanner.l" ACTION_ECHO; ENTER(ACTION); when 78 => --# line 366 "scanner.l" ACTION_ECHO; when 79 => --# line 369 "scanner.l" yylval := Unicode_Character'Pos (Misc.MYESC (+YYText (1 .. YYLength))); return CHAR; when 80 => --# line 377 "scanner.l" yylval := Unicode_Character'Pos (misc.myesc (+YYText (1 .. YYLength))); ENTER(CCL); return ( CHAR ); when 81 => --# line 385 "scanner.l" declare Image : constant Wide_Wide_String := YYText; begin YYLVal := Matreshka.Internals.Unicode.Ucd.Boolean_Properties'Pos (Matreshka.Internals.Unicode.Ucd.Boolean_Properties'Wide_Wide_Value (Image (Image'First + 3 .. Image'Last - 1))) + 1; if Image (Image'First + 1) = 'P' then YYLVal := -YYLVal; end if; ENTER(CCL); return PROP; end; when 82 => --# line 406 "scanner.l" if ( check_yylex_here ) then return End_Of_Input; else ECHO; end if; when 83 => --# line 412 "scanner.l" raise AFLEX_SCANNER_JAMMED; when YY_END_OF_BUFFER + INITIAL + 1 | YY_END_OF_BUFFER + SECT2 + 1 | YY_END_OF_BUFFER + SECT3 + 1 | YY_END_OF_BUFFER + PICKUPDEF + 1 | YY_END_OF_BUFFER + SC + 1 | YY_END_OF_BUFFER + CARETISBOL + 1 | YY_END_OF_BUFFER + NUM + 1 | YY_END_OF_BUFFER + QUOTE + 1 | YY_END_OF_BUFFER + FIRSTCCL + 1 | YY_END_OF_BUFFER + CCL + 1 | YY_END_OF_BUFFER + ACTION + 1 | YY_END_OF_BUFFER + RECOVER + 1 | YY_END_OF_BUFFER + BRACEERROR + 1 | YY_END_OF_BUFFER + ACTION_STRING + 1 => return End_Of_Input; when YY_END_OF_BUFFER => yytext_ptr := yy_bp; case yy_get_next_buffer is when EOB_ACT_END_OF_FILE => begin if yywrap then -- note: because we've taken care in -- yy_get_next_buffer() to have set up yytext, -- we can now set up yy_c_buf_p so that if some -- total hoser (like aflex itself) wants -- to call the scanner after we return the -- End_Of_Input, it'll still work - another -- End_Of_Input will get returned. yy_c_buf_p := yytext_ptr; yy_act := YY_STATE_EOF ((yy_start - 1) / 2); goto do_action; else -- start processing a new file yy_init := true; goto new_file; end if; end; when EOB_ACT_RESTART_SCAN => yy_c_buf_p := yytext_ptr; when EOB_ACT_LAST_MATCH => yy_c_buf_p := yy_n_chars; yy_current_state := yy_get_previous_state; yy_cp := yy_c_buf_p; yy_bp := yytext_ptr; goto next_action; end case; -- case yy_get_next_buffer() when others => Ada.Wide_Wide_Text_IO.Put ("action # "); Ada.Wide_Wide_Text_IO.Put (Integer'Wide_Wide_Image (yy_act)); Ada.Wide_Wide_Text_IO.New_Line; raise AFLEX_INTERNAL_ERROR; end case; -- case (yy_act) end loop; -- end of loop waiting for end of file end YYLex; --# line 412 "scanner.l" begin if (call_yylex) then toktype := YYLex; call_yylex := false; return toktype; end if; if eofseen then toktype := End_Of_Input; else toktype := YYLex; end if; -- this tracing code allows easy tracing of aflex runs if trace then New_Line (Standard_Error); Put (Standard_Error, "toktype = :"); Put (Standard_Error, Token'Wide_Wide_Image (toktype)); Put_line (Standard_Error, ":"); end if; if toktype = End_Of_Input then eofseen := true; if sectnum = 1 then misc.synerr( "unexpected EOF" ); sectnum := 2; toktype := SECTEND; elsif sectnum = 2 then sectnum := 3; toktype := SECTEND; end if; end if; if trace then if ( beglin ) then Put (Standard_Error, Num_Rules + 1); Put (Standard_Error, Unicode.HT); Beglin := False; end if; case toktype is when '<' | '>'|'^'|'$'|'"'|'['|']'|'{'|'}'|'|'|'('| ')'|'-'|'/'|'?'|'.'|'*'|'+'|',' => Put (Standard_Error, Token'Wide_Wide_Image (Toktype)); when NEWLINE => New_Line (Standard_Error); if sectnum = 2 then beglin := true; end if; when SCDECL => Put (Standard_Error, "%s"); when XSCDECL => Put (Standard_Error, "%x"); when WHITESPACE => Put (Standard_Error, " "); when SECTEND => Put_Line (Standard_Error, "%%"); -- we set beglin to be true so we'll start -- writing out numbers as we echo rules. aflexscan() has -- already assigned sectnum if sectnum = 2 then beglin := true; end if; when NAME => Put (Standard_Error, '''); Put (Standard_Error, YYText); Put (Standard_Error, '''); when CHAR => if ( (yylval < Wide_Wide_Character'Pos (' ')) or (yylval = Wide_Wide_Character'Pos (Unicode.DEL)) ) then Put (Standard_Error, '\'); Put (Standard_Error, YYLVal); Put (Standard_Error, '\'); else Put (Standard_Error, Token'Wide_Wide_Image (toktype)); end if; when NUMBER => Put (Standard_Error, YYLVal); when PREVCCL => Put (Standard_Error, '['); Put (Standard_Error, YYLVal); Put (Standard_Error, ']'); when End_Of_Input => Put (Standard_Error, "End Marker"); when others => Put (Standard_Error, "Something weird:"); Put_Line (Standard_Error, Token'Wide_Wide_Image (toktype)); end case; end if; return toktype; end YYLex; end scanner;
-- This spec has been automatically generated from STM32F429x.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package STM32_SVD.DMA is pragma Preelaborate; --------------- -- Registers -- --------------- -- low interrupt status register type LISR_Register is record -- Read-only. Stream x FIFO error interrupt flag (x=3..0) FEIF0 : Boolean; -- unspecified Reserved_1_1 : HAL.Bit; -- Read-only. Stream x direct mode error interrupt flag (x=3..0) DMEIF0 : Boolean; -- Read-only. Stream x transfer error interrupt flag (x=3..0) TEIF0 : Boolean; -- Read-only. Stream x half transfer interrupt flag (x=3..0) HTIF0 : Boolean; -- Read-only. Stream x transfer complete interrupt flag (x = 3..0) TCIF0 : Boolean; -- Read-only. Stream x FIFO error interrupt flag (x=3..0) FEIF1 : Boolean; -- unspecified Reserved_7_7 : HAL.Bit; -- Read-only. Stream x direct mode error interrupt flag (x=3..0) DMEIF1 : Boolean; -- Read-only. Stream x transfer error interrupt flag (x=3..0) TEIF1 : Boolean; -- Read-only. Stream x half transfer interrupt flag (x=3..0) HTIF1 : Boolean; -- Read-only. Stream x transfer complete interrupt flag (x = 3..0) TCIF1 : Boolean; -- unspecified Reserved_12_15 : HAL.UInt4; -- Read-only. Stream x FIFO error interrupt flag (x=3..0) FEIF2 : Boolean; -- unspecified Reserved_17_17 : HAL.Bit; -- Read-only. Stream x direct mode error interrupt flag (x=3..0) DMEIF2 : Boolean; -- Read-only. Stream x transfer error interrupt flag (x=3..0) TEIF2 : Boolean; -- Read-only. Stream x half transfer interrupt flag (x=3..0) HTIF2 : Boolean; -- Read-only. Stream x transfer complete interrupt flag (x = 3..0) TCIF2 : Boolean; -- Read-only. Stream x FIFO error interrupt flag (x=3..0) FEIF3 : Boolean; -- unspecified Reserved_23_23 : HAL.Bit; -- Read-only. Stream x direct mode error interrupt flag (x=3..0) DMEIF3 : Boolean; -- Read-only. Stream x transfer error interrupt flag (x=3..0) TEIF3 : Boolean; -- Read-only. Stream x half transfer interrupt flag (x=3..0) HTIF3 : Boolean; -- Read-only. Stream x transfer complete interrupt flag (x = 3..0) TCIF3 : Boolean; -- unspecified Reserved_28_31 : HAL.UInt4; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for LISR_Register use record FEIF0 at 0 range 0 .. 0; Reserved_1_1 at 0 range 1 .. 1; DMEIF0 at 0 range 2 .. 2; TEIF0 at 0 range 3 .. 3; HTIF0 at 0 range 4 .. 4; TCIF0 at 0 range 5 .. 5; FEIF1 at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; DMEIF1 at 0 range 8 .. 8; TEIF1 at 0 range 9 .. 9; HTIF1 at 0 range 10 .. 10; TCIF1 at 0 range 11 .. 11; Reserved_12_15 at 0 range 12 .. 15; FEIF2 at 0 range 16 .. 16; Reserved_17_17 at 0 range 17 .. 17; DMEIF2 at 0 range 18 .. 18; TEIF2 at 0 range 19 .. 19; HTIF2 at 0 range 20 .. 20; TCIF2 at 0 range 21 .. 21; FEIF3 at 0 range 22 .. 22; Reserved_23_23 at 0 range 23 .. 23; DMEIF3 at 0 range 24 .. 24; TEIF3 at 0 range 25 .. 25; HTIF3 at 0 range 26 .. 26; TCIF3 at 0 range 27 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; -- high interrupt status register type HISR_Register is record -- Read-only. Stream x FIFO error interrupt flag (x=7..4) FEIF4 : Boolean; -- unspecified Reserved_1_1 : HAL.Bit; -- Read-only. Stream x direct mode error interrupt flag (x=7..4) DMEIF4 : Boolean; -- Read-only. Stream x transfer error interrupt flag (x=7..4) TEIF4 : Boolean; -- Read-only. Stream x half transfer interrupt flag (x=7..4) HTIF4 : Boolean; -- Read-only. Stream x transfer complete interrupt flag (x=7..4) TCIF4 : Boolean; -- Read-only. Stream x FIFO error interrupt flag (x=7..4) FEIF5 : Boolean; -- unspecified Reserved_7_7 : HAL.Bit; -- Read-only. Stream x direct mode error interrupt flag (x=7..4) DMEIF5 : Boolean; -- Read-only. Stream x transfer error interrupt flag (x=7..4) TEIF5 : Boolean; -- Read-only. Stream x half transfer interrupt flag (x=7..4) HTIF5 : Boolean; -- Read-only. Stream x transfer complete interrupt flag (x=7..4) TCIF5 : Boolean; -- unspecified Reserved_12_15 : HAL.UInt4; -- Read-only. Stream x FIFO error interrupt flag (x=7..4) FEIF6 : Boolean; -- unspecified Reserved_17_17 : HAL.Bit; -- Read-only. Stream x direct mode error interrupt flag (x=7..4) DMEIF6 : Boolean; -- Read-only. Stream x transfer error interrupt flag (x=7..4) TEIF6 : Boolean; -- Read-only. Stream x half transfer interrupt flag (x=7..4) HTIF6 : Boolean; -- Read-only. Stream x transfer complete interrupt flag (x=7..4) TCIF6 : Boolean; -- Read-only. Stream x FIFO error interrupt flag (x=7..4) FEIF7 : Boolean; -- unspecified Reserved_23_23 : HAL.Bit; -- Read-only. Stream x direct mode error interrupt flag (x=7..4) DMEIF7 : Boolean; -- Read-only. Stream x transfer error interrupt flag (x=7..4) TEIF7 : Boolean; -- Read-only. Stream x half transfer interrupt flag (x=7..4) HTIF7 : Boolean; -- Read-only. Stream x transfer complete interrupt flag (x=7..4) TCIF7 : Boolean; -- unspecified Reserved_28_31 : HAL.UInt4; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for HISR_Register use record FEIF4 at 0 range 0 .. 0; Reserved_1_1 at 0 range 1 .. 1; DMEIF4 at 0 range 2 .. 2; TEIF4 at 0 range 3 .. 3; HTIF4 at 0 range 4 .. 4; TCIF4 at 0 range 5 .. 5; FEIF5 at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; DMEIF5 at 0 range 8 .. 8; TEIF5 at 0 range 9 .. 9; HTIF5 at 0 range 10 .. 10; TCIF5 at 0 range 11 .. 11; Reserved_12_15 at 0 range 12 .. 15; FEIF6 at 0 range 16 .. 16; Reserved_17_17 at 0 range 17 .. 17; DMEIF6 at 0 range 18 .. 18; TEIF6 at 0 range 19 .. 19; HTIF6 at 0 range 20 .. 20; TCIF6 at 0 range 21 .. 21; FEIF7 at 0 range 22 .. 22; Reserved_23_23 at 0 range 23 .. 23; DMEIF7 at 0 range 24 .. 24; TEIF7 at 0 range 25 .. 25; HTIF7 at 0 range 26 .. 26; TCIF7 at 0 range 27 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; -- low interrupt flag clear register type LIFCR_Register is record -- Stream x clear FIFO error interrupt flag (x = 3..0) CFEIF0 : Boolean := False; -- unspecified Reserved_1_1 : HAL.Bit := 16#0#; -- Stream x clear direct mode error interrupt flag (x = 3..0) CDMEIF0 : Boolean := False; -- Stream x clear transfer error interrupt flag (x = 3..0) CTEIF0 : Boolean := False; -- Stream x clear half transfer interrupt flag (x = 3..0) CHTIF0 : Boolean := False; -- Stream x clear transfer complete interrupt flag (x = 3..0) CTCIF0 : Boolean := False; -- Stream x clear FIFO error interrupt flag (x = 3..0) CFEIF1 : Boolean := False; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- Stream x clear direct mode error interrupt flag (x = 3..0) CDMEIF1 : Boolean := False; -- Stream x clear transfer error interrupt flag (x = 3..0) CTEIF1 : Boolean := False; -- Stream x clear half transfer interrupt flag (x = 3..0) CHTIF1 : Boolean := False; -- Stream x clear transfer complete interrupt flag (x = 3..0) CTCIF1 : Boolean := False; -- unspecified Reserved_12_15 : HAL.UInt4 := 16#0#; -- Stream x clear FIFO error interrupt flag (x = 3..0) CFEIF2 : Boolean := False; -- unspecified Reserved_17_17 : HAL.Bit := 16#0#; -- Stream x clear direct mode error interrupt flag (x = 3..0) CDMEIF2 : Boolean := False; -- Stream x clear transfer error interrupt flag (x = 3..0) CTEIF2 : Boolean := False; -- Stream x clear half transfer interrupt flag (x = 3..0) CHTIF2 : Boolean := False; -- Stream x clear transfer complete interrupt flag (x = 3..0) CTCIF2 : Boolean := False; -- Stream x clear FIFO error interrupt flag (x = 3..0) CFEIF3 : Boolean := False; -- unspecified Reserved_23_23 : HAL.Bit := 16#0#; -- Stream x clear direct mode error interrupt flag (x = 3..0) CDMEIF3 : Boolean := False; -- Stream x clear transfer error interrupt flag (x = 3..0) CTEIF3 : Boolean := False; -- Stream x clear half transfer interrupt flag (x = 3..0) CHTIF3 : Boolean := False; -- Stream x clear transfer complete interrupt flag (x = 3..0) CTCIF3 : Boolean := False; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for LIFCR_Register use record CFEIF0 at 0 range 0 .. 0; Reserved_1_1 at 0 range 1 .. 1; CDMEIF0 at 0 range 2 .. 2; CTEIF0 at 0 range 3 .. 3; CHTIF0 at 0 range 4 .. 4; CTCIF0 at 0 range 5 .. 5; CFEIF1 at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; CDMEIF1 at 0 range 8 .. 8; CTEIF1 at 0 range 9 .. 9; CHTIF1 at 0 range 10 .. 10; CTCIF1 at 0 range 11 .. 11; Reserved_12_15 at 0 range 12 .. 15; CFEIF2 at 0 range 16 .. 16; Reserved_17_17 at 0 range 17 .. 17; CDMEIF2 at 0 range 18 .. 18; CTEIF2 at 0 range 19 .. 19; CHTIF2 at 0 range 20 .. 20; CTCIF2 at 0 range 21 .. 21; CFEIF3 at 0 range 22 .. 22; Reserved_23_23 at 0 range 23 .. 23; CDMEIF3 at 0 range 24 .. 24; CTEIF3 at 0 range 25 .. 25; CHTIF3 at 0 range 26 .. 26; CTCIF3 at 0 range 27 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; -- high interrupt flag clear register type HIFCR_Register is record -- Stream x clear FIFO error interrupt flag (x = 7..4) CFEIF4 : Boolean := False; -- unspecified Reserved_1_1 : HAL.Bit := 16#0#; -- Stream x clear direct mode error interrupt flag (x = 7..4) CDMEIF4 : Boolean := False; -- Stream x clear transfer error interrupt flag (x = 7..4) CTEIF4 : Boolean := False; -- Stream x clear half transfer interrupt flag (x = 7..4) CHTIF4 : Boolean := False; -- Stream x clear transfer complete interrupt flag (x = 7..4) CTCIF4 : Boolean := False; -- Stream x clear FIFO error interrupt flag (x = 7..4) CFEIF5 : Boolean := False; -- unspecified Reserved_7_7 : HAL.Bit := 16#0#; -- Stream x clear direct mode error interrupt flag (x = 7..4) CDMEIF5 : Boolean := False; -- Stream x clear transfer error interrupt flag (x = 7..4) CTEIF5 : Boolean := False; -- Stream x clear half transfer interrupt flag (x = 7..4) CHTIF5 : Boolean := False; -- Stream x clear transfer complete interrupt flag (x = 7..4) CTCIF5 : Boolean := False; -- unspecified Reserved_12_15 : HAL.UInt4 := 16#0#; -- Stream x clear FIFO error interrupt flag (x = 7..4) CFEIF6 : Boolean := False; -- unspecified Reserved_17_17 : HAL.Bit := 16#0#; -- Stream x clear direct mode error interrupt flag (x = 7..4) CDMEIF6 : Boolean := False; -- Stream x clear transfer error interrupt flag (x = 7..4) CTEIF6 : Boolean := False; -- Stream x clear half transfer interrupt flag (x = 7..4) CHTIF6 : Boolean := False; -- Stream x clear transfer complete interrupt flag (x = 7..4) CTCIF6 : Boolean := False; -- Stream x clear FIFO error interrupt flag (x = 7..4) CFEIF7 : Boolean := False; -- unspecified Reserved_23_23 : HAL.Bit := 16#0#; -- Stream x clear direct mode error interrupt flag (x = 7..4) CDMEIF7 : Boolean := False; -- Stream x clear transfer error interrupt flag (x = 7..4) CTEIF7 : Boolean := False; -- Stream x clear half transfer interrupt flag (x = 7..4) CHTIF7 : Boolean := False; -- Stream x clear transfer complete interrupt flag (x = 7..4) CTCIF7 : Boolean := False; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for HIFCR_Register use record CFEIF4 at 0 range 0 .. 0; Reserved_1_1 at 0 range 1 .. 1; CDMEIF4 at 0 range 2 .. 2; CTEIF4 at 0 range 3 .. 3; CHTIF4 at 0 range 4 .. 4; CTCIF4 at 0 range 5 .. 5; CFEIF5 at 0 range 6 .. 6; Reserved_7_7 at 0 range 7 .. 7; CDMEIF5 at 0 range 8 .. 8; CTEIF5 at 0 range 9 .. 9; CHTIF5 at 0 range 10 .. 10; CTCIF5 at 0 range 11 .. 11; Reserved_12_15 at 0 range 12 .. 15; CFEIF6 at 0 range 16 .. 16; Reserved_17_17 at 0 range 17 .. 17; CDMEIF6 at 0 range 18 .. 18; CTEIF6 at 0 range 19 .. 19; CHTIF6 at 0 range 20 .. 20; CTCIF6 at 0 range 21 .. 21; CFEIF7 at 0 range 22 .. 22; Reserved_23_23 at 0 range 23 .. 23; CDMEIF7 at 0 range 24 .. 24; CTEIF7 at 0 range 25 .. 25; CHTIF7 at 0 range 26 .. 26; CTCIF7 at 0 range 27 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; subtype S0CR_DIR_Field is HAL.UInt2; subtype S0CR_PSIZE_Field is HAL.UInt2; subtype S0CR_MSIZE_Field is HAL.UInt2; subtype S0CR_PL_Field is HAL.UInt2; subtype S0CR_PBURST_Field is HAL.UInt2; subtype S0CR_MBURST_Field is HAL.UInt2; subtype S0CR_CHSEL_Field is HAL.UInt3; -- stream x configuration register type S0CR_Register is record -- Stream enable / flag stream ready when read low EN : Boolean := False; -- Direct mode error interrupt enable DMEIE : Boolean := False; -- Transfer error interrupt enable TEIE : Boolean := False; -- Half transfer interrupt enable HTIE : Boolean := False; -- Transfer complete interrupt enable TCIE : Boolean := False; -- Peripheral flow controller PFCTRL : Boolean := False; -- Data transfer direction DIR : S0CR_DIR_Field := 16#0#; -- Circular mode CIRC : Boolean := False; -- Peripheral increment mode PINC : Boolean := False; -- Memory increment mode MINC : Boolean := False; -- Peripheral data size PSIZE : S0CR_PSIZE_Field := 16#0#; -- Memory data size MSIZE : S0CR_MSIZE_Field := 16#0#; -- Peripheral increment offset size PINCOS : Boolean := False; -- Priority level PL : S0CR_PL_Field := 16#0#; -- Double buffer mode DBM : Boolean := False; -- Current target (only in double buffer mode) CT : Boolean := False; -- unspecified Reserved_20_20 : HAL.Bit := 16#0#; -- Peripheral burst transfer configuration PBURST : S0CR_PBURST_Field := 16#0#; -- Memory burst transfer configuration MBURST : S0CR_MBURST_Field := 16#0#; -- Channel selection CHSEL : S0CR_CHSEL_Field := 16#0#; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for S0CR_Register use record EN at 0 range 0 .. 0; DMEIE at 0 range 1 .. 1; TEIE at 0 range 2 .. 2; HTIE at 0 range 3 .. 3; TCIE at 0 range 4 .. 4; PFCTRL at 0 range 5 .. 5; DIR at 0 range 6 .. 7; CIRC at 0 range 8 .. 8; PINC at 0 range 9 .. 9; MINC at 0 range 10 .. 10; PSIZE at 0 range 11 .. 12; MSIZE at 0 range 13 .. 14; PINCOS at 0 range 15 .. 15; PL at 0 range 16 .. 17; DBM at 0 range 18 .. 18; CT at 0 range 19 .. 19; Reserved_20_20 at 0 range 20 .. 20; PBURST at 0 range 21 .. 22; MBURST at 0 range 23 .. 24; CHSEL at 0 range 25 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; subtype S0NDTR_NDT_Field is HAL.UInt16; -- stream x number of data register type S0NDTR_Register is record -- Number of data items to transfer NDT : S0NDTR_NDT_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for S0NDTR_Register use record NDT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype S0FCR_FTH_Field is HAL.UInt2; subtype S0FCR_FS_Field is HAL.UInt3; -- stream x FIFO control register type S0FCR_Register is record -- FIFO threshold selection FTH : S0FCR_FTH_Field := 16#1#; -- Direct mode disable DMDIS : Boolean := False; -- Read-only. FIFO status FS : S0FCR_FS_Field := 16#4#; -- unspecified Reserved_6_6 : HAL.Bit := 16#0#; -- FIFO error interrupt enable FEIE : Boolean := False; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for S0FCR_Register use record FTH at 0 range 0 .. 1; DMDIS at 0 range 2 .. 2; FS at 0 range 3 .. 5; Reserved_6_6 at 0 range 6 .. 6; FEIE at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype S1CR_DIR_Field is HAL.UInt2; subtype S1CR_PSIZE_Field is HAL.UInt2; subtype S1CR_MSIZE_Field is HAL.UInt2; subtype S1CR_PL_Field is HAL.UInt2; subtype S1CR_PBURST_Field is HAL.UInt2; subtype S1CR_MBURST_Field is HAL.UInt2; subtype S1CR_CHSEL_Field is HAL.UInt3; -- stream x configuration register type S1CR_Register is record -- Stream enable / flag stream ready when read low EN : Boolean := False; -- Direct mode error interrupt enable DMEIE : Boolean := False; -- Transfer error interrupt enable TEIE : Boolean := False; -- Half transfer interrupt enable HTIE : Boolean := False; -- Transfer complete interrupt enable TCIE : Boolean := False; -- Peripheral flow controller PFCTRL : Boolean := False; -- Data transfer direction DIR : S1CR_DIR_Field := 16#0#; -- Circular mode CIRC : Boolean := False; -- Peripheral increment mode PINC : Boolean := False; -- Memory increment mode MINC : Boolean := False; -- Peripheral data size PSIZE : S1CR_PSIZE_Field := 16#0#; -- Memory data size MSIZE : S1CR_MSIZE_Field := 16#0#; -- Peripheral increment offset size PINCOS : Boolean := False; -- Priority level PL : S1CR_PL_Field := 16#0#; -- Double buffer mode DBM : Boolean := False; -- Current target (only in double buffer mode) CT : Boolean := False; -- ACK ACK : Boolean := False; -- Peripheral burst transfer configuration PBURST : S1CR_PBURST_Field := 16#0#; -- Memory burst transfer configuration MBURST : S1CR_MBURST_Field := 16#0#; -- Channel selection CHSEL : S1CR_CHSEL_Field := 16#0#; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for S1CR_Register use record EN at 0 range 0 .. 0; DMEIE at 0 range 1 .. 1; TEIE at 0 range 2 .. 2; HTIE at 0 range 3 .. 3; TCIE at 0 range 4 .. 4; PFCTRL at 0 range 5 .. 5; DIR at 0 range 6 .. 7; CIRC at 0 range 8 .. 8; PINC at 0 range 9 .. 9; MINC at 0 range 10 .. 10; PSIZE at 0 range 11 .. 12; MSIZE at 0 range 13 .. 14; PINCOS at 0 range 15 .. 15; PL at 0 range 16 .. 17; DBM at 0 range 18 .. 18; CT at 0 range 19 .. 19; ACK at 0 range 20 .. 20; PBURST at 0 range 21 .. 22; MBURST at 0 range 23 .. 24; CHSEL at 0 range 25 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; subtype S1NDTR_NDT_Field is HAL.UInt16; -- stream x number of data register type S1NDTR_Register is record -- Number of data items to transfer NDT : S1NDTR_NDT_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for S1NDTR_Register use record NDT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype S1FCR_FTH_Field is HAL.UInt2; subtype S1FCR_FS_Field is HAL.UInt3; -- stream x FIFO control register type S1FCR_Register is record -- FIFO threshold selection FTH : S1FCR_FTH_Field := 16#1#; -- Direct mode disable DMDIS : Boolean := False; -- Read-only. FIFO status FS : S1FCR_FS_Field := 16#4#; -- unspecified Reserved_6_6 : HAL.Bit := 16#0#; -- FIFO error interrupt enable FEIE : Boolean := False; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for S1FCR_Register use record FTH at 0 range 0 .. 1; DMDIS at 0 range 2 .. 2; FS at 0 range 3 .. 5; Reserved_6_6 at 0 range 6 .. 6; FEIE at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype S2CR_DIR_Field is HAL.UInt2; subtype S2CR_PSIZE_Field is HAL.UInt2; subtype S2CR_MSIZE_Field is HAL.UInt2; subtype S2CR_PL_Field is HAL.UInt2; subtype S2CR_PBURST_Field is HAL.UInt2; subtype S2CR_MBURST_Field is HAL.UInt2; subtype S2CR_CHSEL_Field is HAL.UInt3; -- stream x configuration register type S2CR_Register is record -- Stream enable / flag stream ready when read low EN : Boolean := False; -- Direct mode error interrupt enable DMEIE : Boolean := False; -- Transfer error interrupt enable TEIE : Boolean := False; -- Half transfer interrupt enable HTIE : Boolean := False; -- Transfer complete interrupt enable TCIE : Boolean := False; -- Peripheral flow controller PFCTRL : Boolean := False; -- Data transfer direction DIR : S2CR_DIR_Field := 16#0#; -- Circular mode CIRC : Boolean := False; -- Peripheral increment mode PINC : Boolean := False; -- Memory increment mode MINC : Boolean := False; -- Peripheral data size PSIZE : S2CR_PSIZE_Field := 16#0#; -- Memory data size MSIZE : S2CR_MSIZE_Field := 16#0#; -- Peripheral increment offset size PINCOS : Boolean := False; -- Priority level PL : S2CR_PL_Field := 16#0#; -- Double buffer mode DBM : Boolean := False; -- Current target (only in double buffer mode) CT : Boolean := False; -- ACK ACK : Boolean := False; -- Peripheral burst transfer configuration PBURST : S2CR_PBURST_Field := 16#0#; -- Memory burst transfer configuration MBURST : S2CR_MBURST_Field := 16#0#; -- Channel selection CHSEL : S2CR_CHSEL_Field := 16#0#; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for S2CR_Register use record EN at 0 range 0 .. 0; DMEIE at 0 range 1 .. 1; TEIE at 0 range 2 .. 2; HTIE at 0 range 3 .. 3; TCIE at 0 range 4 .. 4; PFCTRL at 0 range 5 .. 5; DIR at 0 range 6 .. 7; CIRC at 0 range 8 .. 8; PINC at 0 range 9 .. 9; MINC at 0 range 10 .. 10; PSIZE at 0 range 11 .. 12; MSIZE at 0 range 13 .. 14; PINCOS at 0 range 15 .. 15; PL at 0 range 16 .. 17; DBM at 0 range 18 .. 18; CT at 0 range 19 .. 19; ACK at 0 range 20 .. 20; PBURST at 0 range 21 .. 22; MBURST at 0 range 23 .. 24; CHSEL at 0 range 25 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; subtype S2NDTR_NDT_Field is HAL.UInt16; -- stream x number of data register type S2NDTR_Register is record -- Number of data items to transfer NDT : S2NDTR_NDT_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for S2NDTR_Register use record NDT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype S2FCR_FTH_Field is HAL.UInt2; subtype S2FCR_FS_Field is HAL.UInt3; -- stream x FIFO control register type S2FCR_Register is record -- FIFO threshold selection FTH : S2FCR_FTH_Field := 16#1#; -- Direct mode disable DMDIS : Boolean := False; -- Read-only. FIFO status FS : S2FCR_FS_Field := 16#4#; -- unspecified Reserved_6_6 : HAL.Bit := 16#0#; -- FIFO error interrupt enable FEIE : Boolean := False; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for S2FCR_Register use record FTH at 0 range 0 .. 1; DMDIS at 0 range 2 .. 2; FS at 0 range 3 .. 5; Reserved_6_6 at 0 range 6 .. 6; FEIE at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype S3CR_DIR_Field is HAL.UInt2; subtype S3CR_PSIZE_Field is HAL.UInt2; subtype S3CR_MSIZE_Field is HAL.UInt2; subtype S3CR_PL_Field is HAL.UInt2; subtype S3CR_PBURST_Field is HAL.UInt2; subtype S3CR_MBURST_Field is HAL.UInt2; subtype S3CR_CHSEL_Field is HAL.UInt3; -- stream x configuration register type S3CR_Register is record -- Stream enable / flag stream ready when read low EN : Boolean := False; -- Direct mode error interrupt enable DMEIE : Boolean := False; -- Transfer error interrupt enable TEIE : Boolean := False; -- Half transfer interrupt enable HTIE : Boolean := False; -- Transfer complete interrupt enable TCIE : Boolean := False; -- Peripheral flow controller PFCTRL : Boolean := False; -- Data transfer direction DIR : S3CR_DIR_Field := 16#0#; -- Circular mode CIRC : Boolean := False; -- Peripheral increment mode PINC : Boolean := False; -- Memory increment mode MINC : Boolean := False; -- Peripheral data size PSIZE : S3CR_PSIZE_Field := 16#0#; -- Memory data size MSIZE : S3CR_MSIZE_Field := 16#0#; -- Peripheral increment offset size PINCOS : Boolean := False; -- Priority level PL : S3CR_PL_Field := 16#0#; -- Double buffer mode DBM : Boolean := False; -- Current target (only in double buffer mode) CT : Boolean := False; -- ACK ACK : Boolean := False; -- Peripheral burst transfer configuration PBURST : S3CR_PBURST_Field := 16#0#; -- Memory burst transfer configuration MBURST : S3CR_MBURST_Field := 16#0#; -- Channel selection CHSEL : S3CR_CHSEL_Field := 16#0#; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for S3CR_Register use record EN at 0 range 0 .. 0; DMEIE at 0 range 1 .. 1; TEIE at 0 range 2 .. 2; HTIE at 0 range 3 .. 3; TCIE at 0 range 4 .. 4; PFCTRL at 0 range 5 .. 5; DIR at 0 range 6 .. 7; CIRC at 0 range 8 .. 8; PINC at 0 range 9 .. 9; MINC at 0 range 10 .. 10; PSIZE at 0 range 11 .. 12; MSIZE at 0 range 13 .. 14; PINCOS at 0 range 15 .. 15; PL at 0 range 16 .. 17; DBM at 0 range 18 .. 18; CT at 0 range 19 .. 19; ACK at 0 range 20 .. 20; PBURST at 0 range 21 .. 22; MBURST at 0 range 23 .. 24; CHSEL at 0 range 25 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; subtype S3NDTR_NDT_Field is HAL.UInt16; -- stream x number of data register type S3NDTR_Register is record -- Number of data items to transfer NDT : S3NDTR_NDT_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for S3NDTR_Register use record NDT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype S3FCR_FTH_Field is HAL.UInt2; subtype S3FCR_FS_Field is HAL.UInt3; -- stream x FIFO control register type S3FCR_Register is record -- FIFO threshold selection FTH : S3FCR_FTH_Field := 16#1#; -- Direct mode disable DMDIS : Boolean := False; -- Read-only. FIFO status FS : S3FCR_FS_Field := 16#4#; -- unspecified Reserved_6_6 : HAL.Bit := 16#0#; -- FIFO error interrupt enable FEIE : Boolean := False; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for S3FCR_Register use record FTH at 0 range 0 .. 1; DMDIS at 0 range 2 .. 2; FS at 0 range 3 .. 5; Reserved_6_6 at 0 range 6 .. 6; FEIE at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype S4CR_DIR_Field is HAL.UInt2; subtype S4CR_PSIZE_Field is HAL.UInt2; subtype S4CR_MSIZE_Field is HAL.UInt2; subtype S4CR_PL_Field is HAL.UInt2; subtype S4CR_PBURST_Field is HAL.UInt2; subtype S4CR_MBURST_Field is HAL.UInt2; subtype S4CR_CHSEL_Field is HAL.UInt3; -- stream x configuration register type S4CR_Register is record -- Stream enable / flag stream ready when read low EN : Boolean := False; -- Direct mode error interrupt enable DMEIE : Boolean := False; -- Transfer error interrupt enable TEIE : Boolean := False; -- Half transfer interrupt enable HTIE : Boolean := False; -- Transfer complete interrupt enable TCIE : Boolean := False; -- Peripheral flow controller PFCTRL : Boolean := False; -- Data transfer direction DIR : S4CR_DIR_Field := 16#0#; -- Circular mode CIRC : Boolean := False; -- Peripheral increment mode PINC : Boolean := False; -- Memory increment mode MINC : Boolean := False; -- Peripheral data size PSIZE : S4CR_PSIZE_Field := 16#0#; -- Memory data size MSIZE : S4CR_MSIZE_Field := 16#0#; -- Peripheral increment offset size PINCOS : Boolean := False; -- Priority level PL : S4CR_PL_Field := 16#0#; -- Double buffer mode DBM : Boolean := False; -- Current target (only in double buffer mode) CT : Boolean := False; -- ACK ACK : Boolean := False; -- Peripheral burst transfer configuration PBURST : S4CR_PBURST_Field := 16#0#; -- Memory burst transfer configuration MBURST : S4CR_MBURST_Field := 16#0#; -- Channel selection CHSEL : S4CR_CHSEL_Field := 16#0#; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for S4CR_Register use record EN at 0 range 0 .. 0; DMEIE at 0 range 1 .. 1; TEIE at 0 range 2 .. 2; HTIE at 0 range 3 .. 3; TCIE at 0 range 4 .. 4; PFCTRL at 0 range 5 .. 5; DIR at 0 range 6 .. 7; CIRC at 0 range 8 .. 8; PINC at 0 range 9 .. 9; MINC at 0 range 10 .. 10; PSIZE at 0 range 11 .. 12; MSIZE at 0 range 13 .. 14; PINCOS at 0 range 15 .. 15; PL at 0 range 16 .. 17; DBM at 0 range 18 .. 18; CT at 0 range 19 .. 19; ACK at 0 range 20 .. 20; PBURST at 0 range 21 .. 22; MBURST at 0 range 23 .. 24; CHSEL at 0 range 25 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; subtype S4NDTR_NDT_Field is HAL.UInt16; -- stream x number of data register type S4NDTR_Register is record -- Number of data items to transfer NDT : S4NDTR_NDT_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for S4NDTR_Register use record NDT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype S4FCR_FTH_Field is HAL.UInt2; subtype S4FCR_FS_Field is HAL.UInt3; -- stream x FIFO control register type S4FCR_Register is record -- FIFO threshold selection FTH : S4FCR_FTH_Field := 16#1#; -- Direct mode disable DMDIS : Boolean := False; -- Read-only. FIFO status FS : S4FCR_FS_Field := 16#4#; -- unspecified Reserved_6_6 : HAL.Bit := 16#0#; -- FIFO error interrupt enable FEIE : Boolean := False; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for S4FCR_Register use record FTH at 0 range 0 .. 1; DMDIS at 0 range 2 .. 2; FS at 0 range 3 .. 5; Reserved_6_6 at 0 range 6 .. 6; FEIE at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype S5CR_DIR_Field is HAL.UInt2; subtype S5CR_PSIZE_Field is HAL.UInt2; subtype S5CR_MSIZE_Field is HAL.UInt2; subtype S5CR_PL_Field is HAL.UInt2; subtype S5CR_PBURST_Field is HAL.UInt2; subtype S5CR_MBURST_Field is HAL.UInt2; subtype S5CR_CHSEL_Field is HAL.UInt3; -- stream x configuration register type S5CR_Register is record -- Stream enable / flag stream ready when read low EN : Boolean := False; -- Direct mode error interrupt enable DMEIE : Boolean := False; -- Transfer error interrupt enable TEIE : Boolean := False; -- Half transfer interrupt enable HTIE : Boolean := False; -- Transfer complete interrupt enable TCIE : Boolean := False; -- Peripheral flow controller PFCTRL : Boolean := False; -- Data transfer direction DIR : S5CR_DIR_Field := 16#0#; -- Circular mode CIRC : Boolean := False; -- Peripheral increment mode PINC : Boolean := False; -- Memory increment mode MINC : Boolean := False; -- Peripheral data size PSIZE : S5CR_PSIZE_Field := 16#0#; -- Memory data size MSIZE : S5CR_MSIZE_Field := 16#0#; -- Peripheral increment offset size PINCOS : Boolean := False; -- Priority level PL : S5CR_PL_Field := 16#0#; -- Double buffer mode DBM : Boolean := False; -- Current target (only in double buffer mode) CT : Boolean := False; -- ACK ACK : Boolean := False; -- Peripheral burst transfer configuration PBURST : S5CR_PBURST_Field := 16#0#; -- Memory burst transfer configuration MBURST : S5CR_MBURST_Field := 16#0#; -- Channel selection CHSEL : S5CR_CHSEL_Field := 16#0#; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for S5CR_Register use record EN at 0 range 0 .. 0; DMEIE at 0 range 1 .. 1; TEIE at 0 range 2 .. 2; HTIE at 0 range 3 .. 3; TCIE at 0 range 4 .. 4; PFCTRL at 0 range 5 .. 5; DIR at 0 range 6 .. 7; CIRC at 0 range 8 .. 8; PINC at 0 range 9 .. 9; MINC at 0 range 10 .. 10; PSIZE at 0 range 11 .. 12; MSIZE at 0 range 13 .. 14; PINCOS at 0 range 15 .. 15; PL at 0 range 16 .. 17; DBM at 0 range 18 .. 18; CT at 0 range 19 .. 19; ACK at 0 range 20 .. 20; PBURST at 0 range 21 .. 22; MBURST at 0 range 23 .. 24; CHSEL at 0 range 25 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; subtype S5NDTR_NDT_Field is HAL.UInt16; -- stream x number of data register type S5NDTR_Register is record -- Number of data items to transfer NDT : S5NDTR_NDT_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for S5NDTR_Register use record NDT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype S5FCR_FTH_Field is HAL.UInt2; subtype S5FCR_FS_Field is HAL.UInt3; -- stream x FIFO control register type S5FCR_Register is record -- FIFO threshold selection FTH : S5FCR_FTH_Field := 16#1#; -- Direct mode disable DMDIS : Boolean := False; -- Read-only. FIFO status FS : S5FCR_FS_Field := 16#4#; -- unspecified Reserved_6_6 : HAL.Bit := 16#0#; -- FIFO error interrupt enable FEIE : Boolean := False; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for S5FCR_Register use record FTH at 0 range 0 .. 1; DMDIS at 0 range 2 .. 2; FS at 0 range 3 .. 5; Reserved_6_6 at 0 range 6 .. 6; FEIE at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype S6CR_DIR_Field is HAL.UInt2; subtype S6CR_PSIZE_Field is HAL.UInt2; subtype S6CR_MSIZE_Field is HAL.UInt2; subtype S6CR_PL_Field is HAL.UInt2; subtype S6CR_PBURST_Field is HAL.UInt2; subtype S6CR_MBURST_Field is HAL.UInt2; subtype S6CR_CHSEL_Field is HAL.UInt3; -- stream x configuration register type S6CR_Register is record -- Stream enable / flag stream ready when read low EN : Boolean := False; -- Direct mode error interrupt enable DMEIE : Boolean := False; -- Transfer error interrupt enable TEIE : Boolean := False; -- Half transfer interrupt enable HTIE : Boolean := False; -- Transfer complete interrupt enable TCIE : Boolean := False; -- Peripheral flow controller PFCTRL : Boolean := False; -- Data transfer direction DIR : S6CR_DIR_Field := 16#0#; -- Circular mode CIRC : Boolean := False; -- Peripheral increment mode PINC : Boolean := False; -- Memory increment mode MINC : Boolean := False; -- Peripheral data size PSIZE : S6CR_PSIZE_Field := 16#0#; -- Memory data size MSIZE : S6CR_MSIZE_Field := 16#0#; -- Peripheral increment offset size PINCOS : Boolean := False; -- Priority level PL : S6CR_PL_Field := 16#0#; -- Double buffer mode DBM : Boolean := False; -- Current target (only in double buffer mode) CT : Boolean := False; -- ACK ACK : Boolean := False; -- Peripheral burst transfer configuration PBURST : S6CR_PBURST_Field := 16#0#; -- Memory burst transfer configuration MBURST : S6CR_MBURST_Field := 16#0#; -- Channel selection CHSEL : S6CR_CHSEL_Field := 16#0#; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for S6CR_Register use record EN at 0 range 0 .. 0; DMEIE at 0 range 1 .. 1; TEIE at 0 range 2 .. 2; HTIE at 0 range 3 .. 3; TCIE at 0 range 4 .. 4; PFCTRL at 0 range 5 .. 5; DIR at 0 range 6 .. 7; CIRC at 0 range 8 .. 8; PINC at 0 range 9 .. 9; MINC at 0 range 10 .. 10; PSIZE at 0 range 11 .. 12; MSIZE at 0 range 13 .. 14; PINCOS at 0 range 15 .. 15; PL at 0 range 16 .. 17; DBM at 0 range 18 .. 18; CT at 0 range 19 .. 19; ACK at 0 range 20 .. 20; PBURST at 0 range 21 .. 22; MBURST at 0 range 23 .. 24; CHSEL at 0 range 25 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; subtype S6NDTR_NDT_Field is HAL.UInt16; -- stream x number of data register type S6NDTR_Register is record -- Number of data items to transfer NDT : S6NDTR_NDT_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for S6NDTR_Register use record NDT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype S6FCR_FTH_Field is HAL.UInt2; subtype S6FCR_FS_Field is HAL.UInt3; -- stream x FIFO control register type S6FCR_Register is record -- FIFO threshold selection FTH : S6FCR_FTH_Field := 16#1#; -- Direct mode disable DMDIS : Boolean := False; -- Read-only. FIFO status FS : S6FCR_FS_Field := 16#4#; -- unspecified Reserved_6_6 : HAL.Bit := 16#0#; -- FIFO error interrupt enable FEIE : Boolean := False; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for S6FCR_Register use record FTH at 0 range 0 .. 1; DMDIS at 0 range 2 .. 2; FS at 0 range 3 .. 5; Reserved_6_6 at 0 range 6 .. 6; FEIE at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype S7CR_DIR_Field is HAL.UInt2; subtype S7CR_PSIZE_Field is HAL.UInt2; subtype S7CR_MSIZE_Field is HAL.UInt2; subtype S7CR_PL_Field is HAL.UInt2; subtype S7CR_PBURST_Field is HAL.UInt2; subtype S7CR_MBURST_Field is HAL.UInt2; subtype S7CR_CHSEL_Field is HAL.UInt3; -- stream x configuration register type S7CR_Register is record -- Stream enable / flag stream ready when read low EN : Boolean := False; -- Direct mode error interrupt enable DMEIE : Boolean := False; -- Transfer error interrupt enable TEIE : Boolean := False; -- Half transfer interrupt enable HTIE : Boolean := False; -- Transfer complete interrupt enable TCIE : Boolean := False; -- Peripheral flow controller PFCTRL : Boolean := False; -- Data transfer direction DIR : S7CR_DIR_Field := 16#0#; -- Circular mode CIRC : Boolean := False; -- Peripheral increment mode PINC : Boolean := False; -- Memory increment mode MINC : Boolean := False; -- Peripheral data size PSIZE : S7CR_PSIZE_Field := 16#0#; -- Memory data size MSIZE : S7CR_MSIZE_Field := 16#0#; -- Peripheral increment offset size PINCOS : Boolean := False; -- Priority level PL : S7CR_PL_Field := 16#0#; -- Double buffer mode DBM : Boolean := False; -- Current target (only in double buffer mode) CT : Boolean := False; -- ACK ACK : Boolean := False; -- Peripheral burst transfer configuration PBURST : S7CR_PBURST_Field := 16#0#; -- Memory burst transfer configuration MBURST : S7CR_MBURST_Field := 16#0#; -- Channel selection CHSEL : S7CR_CHSEL_Field := 16#0#; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for S7CR_Register use record EN at 0 range 0 .. 0; DMEIE at 0 range 1 .. 1; TEIE at 0 range 2 .. 2; HTIE at 0 range 3 .. 3; TCIE at 0 range 4 .. 4; PFCTRL at 0 range 5 .. 5; DIR at 0 range 6 .. 7; CIRC at 0 range 8 .. 8; PINC at 0 range 9 .. 9; MINC at 0 range 10 .. 10; PSIZE at 0 range 11 .. 12; MSIZE at 0 range 13 .. 14; PINCOS at 0 range 15 .. 15; PL at 0 range 16 .. 17; DBM at 0 range 18 .. 18; CT at 0 range 19 .. 19; ACK at 0 range 20 .. 20; PBURST at 0 range 21 .. 22; MBURST at 0 range 23 .. 24; CHSEL at 0 range 25 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; subtype S7NDTR_NDT_Field is HAL.UInt16; -- stream x number of data register type S7NDTR_Register is record -- Number of data items to transfer NDT : S7NDTR_NDT_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for S7NDTR_Register use record NDT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype S7FCR_FTH_Field is HAL.UInt2; subtype S7FCR_FS_Field is HAL.UInt3; -- stream x FIFO control register type S7FCR_Register is record -- FIFO threshold selection FTH : S7FCR_FTH_Field := 16#1#; -- Direct mode disable DMDIS : Boolean := False; -- Read-only. FIFO status FS : S7FCR_FS_Field := 16#4#; -- unspecified Reserved_6_6 : HAL.Bit := 16#0#; -- FIFO error interrupt enable FEIE : Boolean := False; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for S7FCR_Register use record FTH at 0 range 0 .. 1; DMDIS at 0 range 2 .. 2; FS at 0 range 3 .. 5; Reserved_6_6 at 0 range 6 .. 6; FEIE at 0 range 7 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- DMA controller type DMA_Peripheral is record -- low interrupt status register LISR : aliased LISR_Register; -- high interrupt status register HISR : aliased HISR_Register; -- low interrupt flag clear register LIFCR : aliased LIFCR_Register; -- high interrupt flag clear register HIFCR : aliased HIFCR_Register; -- stream x configuration register S0CR : aliased S0CR_Register; -- stream x number of data register S0NDTR : aliased S0NDTR_Register; -- stream x peripheral address register S0PAR : aliased HAL.UInt32; -- stream x memory 0 address register S0M0AR : aliased HAL.UInt32; -- stream x memory 1 address register S0M1AR : aliased HAL.UInt32; -- stream x FIFO control register S0FCR : aliased S0FCR_Register; -- stream x configuration register S1CR : aliased S1CR_Register; -- stream x number of data register S1NDTR : aliased S1NDTR_Register; -- stream x peripheral address register S1PAR : aliased HAL.UInt32; -- stream x memory 0 address register S1M0AR : aliased HAL.UInt32; -- stream x memory 1 address register S1M1AR : aliased HAL.UInt32; -- stream x FIFO control register S1FCR : aliased S1FCR_Register; -- stream x configuration register S2CR : aliased S2CR_Register; -- stream x number of data register S2NDTR : aliased S2NDTR_Register; -- stream x peripheral address register S2PAR : aliased HAL.UInt32; -- stream x memory 0 address register S2M0AR : aliased HAL.UInt32; -- stream x memory 1 address register S2M1AR : aliased HAL.UInt32; -- stream x FIFO control register S2FCR : aliased S2FCR_Register; -- stream x configuration register S3CR : aliased S3CR_Register; -- stream x number of data register S3NDTR : aliased S3NDTR_Register; -- stream x peripheral address register S3PAR : aliased HAL.UInt32; -- stream x memory 0 address register S3M0AR : aliased HAL.UInt32; -- stream x memory 1 address register S3M1AR : aliased HAL.UInt32; -- stream x FIFO control register S3FCR : aliased S3FCR_Register; -- stream x configuration register S4CR : aliased S4CR_Register; -- stream x number of data register S4NDTR : aliased S4NDTR_Register; -- stream x peripheral address register S4PAR : aliased HAL.UInt32; -- stream x memory 0 address register S4M0AR : aliased HAL.UInt32; -- stream x memory 1 address register S4M1AR : aliased HAL.UInt32; -- stream x FIFO control register S4FCR : aliased S4FCR_Register; -- stream x configuration register S5CR : aliased S5CR_Register; -- stream x number of data register S5NDTR : aliased S5NDTR_Register; -- stream x peripheral address register S5PAR : aliased HAL.UInt32; -- stream x memory 0 address register S5M0AR : aliased HAL.UInt32; -- stream x memory 1 address register S5M1AR : aliased HAL.UInt32; -- stream x FIFO control register S5FCR : aliased S5FCR_Register; -- stream x configuration register S6CR : aliased S6CR_Register; -- stream x number of data register S6NDTR : aliased S6NDTR_Register; -- stream x peripheral address register S6PAR : aliased HAL.UInt32; -- stream x memory 0 address register S6M0AR : aliased HAL.UInt32; -- stream x memory 1 address register S6M1AR : aliased HAL.UInt32; -- stream x FIFO control register S6FCR : aliased S6FCR_Register; -- stream x configuration register S7CR : aliased S7CR_Register; -- stream x number of data register S7NDTR : aliased S7NDTR_Register; -- stream x peripheral address register S7PAR : aliased HAL.UInt32; -- stream x memory 0 address register S7M0AR : aliased HAL.UInt32; -- stream x memory 1 address register S7M1AR : aliased HAL.UInt32; -- stream x FIFO control register S7FCR : aliased S7FCR_Register; end record with Volatile; for DMA_Peripheral use record LISR at 16#0# range 0 .. 31; HISR at 16#4# range 0 .. 31; LIFCR at 16#8# range 0 .. 31; HIFCR at 16#C# range 0 .. 31; S0CR at 16#10# range 0 .. 31; S0NDTR at 16#14# range 0 .. 31; S0PAR at 16#18# range 0 .. 31; S0M0AR at 16#1C# range 0 .. 31; S0M1AR at 16#20# range 0 .. 31; S0FCR at 16#24# range 0 .. 31; S1CR at 16#28# range 0 .. 31; S1NDTR at 16#2C# range 0 .. 31; S1PAR at 16#30# range 0 .. 31; S1M0AR at 16#34# range 0 .. 31; S1M1AR at 16#38# range 0 .. 31; S1FCR at 16#3C# range 0 .. 31; S2CR at 16#40# range 0 .. 31; S2NDTR at 16#44# range 0 .. 31; S2PAR at 16#48# range 0 .. 31; S2M0AR at 16#4C# range 0 .. 31; S2M1AR at 16#50# range 0 .. 31; S2FCR at 16#54# range 0 .. 31; S3CR at 16#58# range 0 .. 31; S3NDTR at 16#5C# range 0 .. 31; S3PAR at 16#60# range 0 .. 31; S3M0AR at 16#64# range 0 .. 31; S3M1AR at 16#68# range 0 .. 31; S3FCR at 16#6C# range 0 .. 31; S4CR at 16#70# range 0 .. 31; S4NDTR at 16#74# range 0 .. 31; S4PAR at 16#78# range 0 .. 31; S4M0AR at 16#7C# range 0 .. 31; S4M1AR at 16#80# range 0 .. 31; S4FCR at 16#84# range 0 .. 31; S5CR at 16#88# range 0 .. 31; S5NDTR at 16#8C# range 0 .. 31; S5PAR at 16#90# range 0 .. 31; S5M0AR at 16#94# range 0 .. 31; S5M1AR at 16#98# range 0 .. 31; S5FCR at 16#9C# range 0 .. 31; S6CR at 16#A0# range 0 .. 31; S6NDTR at 16#A4# range 0 .. 31; S6PAR at 16#A8# range 0 .. 31; S6M0AR at 16#AC# range 0 .. 31; S6M1AR at 16#B0# range 0 .. 31; S6FCR at 16#B4# range 0 .. 31; S7CR at 16#B8# range 0 .. 31; S7NDTR at 16#BC# range 0 .. 31; S7PAR at 16#C0# range 0 .. 31; S7M0AR at 16#C4# range 0 .. 31; S7M1AR at 16#C8# range 0 .. 31; S7FCR at 16#CC# range 0 .. 31; end record; -- DMA controller DMA1_Periph : aliased DMA_Peripheral with Import, Address => System'To_Address (16#40026000#); -- DMA controller DMA2_Periph : aliased DMA_Peripheral with Import, Address => System'To_Address (16#40026400#); end STM32_SVD.DMA;
----------------------------------------------------------------------- -- ado-parameters-tests -- Test query parameters and SQL expansion -- Copyright (C) 2011 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Test_Caller; with Util.Measures; package body ADO.Parameters.Tests is use Util.Tests; -- Test the Add_Param operation for various types. generic type T (<>) is private; with procedure Add_Param (L : in out ADO.Parameters.Abstract_List; V : in T) is <>; Value : T; Name : String; procedure Test_Add_Param_T (Tst : in out Test); -- Test the Bind_Param operation for various types. generic type T (<>) is private; with procedure Bind_Param (L : in out ADO.Parameters.Abstract_List; N : in String; V : in T) is <>; Value : T; Name : String; procedure Test_Bind_Param_T (Tst : in out Test); -- Test the Add_Param operation for various types. procedure Test_Add_Param_T (Tst : in out Test) is Count : constant Positive := 100; SQL : ADO.Parameters.List; S : Util.Measures.Stamp; begin for I in 1 .. Count loop Add_Param (ADO.Parameters.Abstract_List (SQL), Value); end loop; Util.Measures.Report (S, "Add_Param " & Name & "(" & Positive'Image (Count) & " calls)"); Util.Tests.Assert_Equals (Tst, Count, SQL.Length, "Invalid param list for " & Name); end Test_Add_Param_T; -- Test the Bind_Param operation for various types. procedure Test_Bind_Param_T (Tst : in out Test) is Count : constant Positive := 100; SQL : ADO.Parameters.List; S : Util.Measures.Stamp; begin for I in 1 .. Count loop Bind_Param (ADO.Parameters.Abstract_List (SQL), "a_parameter_name", Value); end loop; Util.Measures.Report (S, "Bind_Param " & Name & "(" & Positive'Image (Count) & " calls)"); Util.Tests.Assert_Equals (Tst, Count, SQL.Length, "Invalid param list for " & Name); end Test_Bind_Param_T; procedure Test_Add_Param_Integer is new Test_Add_Param_T (Integer, Add_Param, 10, "Integer"); procedure Test_Add_Param_Identifier is new Test_Add_Param_T (Identifier, Add_Param, 100, "Identifier"); procedure Test_Add_Param_Boolean is new Test_Add_Param_T (Boolean, Add_Param, False, "Boolean"); procedure Test_Add_Param_String is new Test_Add_Param_T (String, Add_Param, "0123456789ABCDEF", "String"); procedure Test_Add_Param_Calendar is new Test_Add_Param_T (Ada.Calendar.Time, Add_Param, Ada.Calendar.Clock, "Time"); procedure Test_Add_Param_Unbounded_String is new Test_Add_Param_T (Unbounded_String, Add_Param, To_Unbounded_String ("0123456789ABCDEF"), "Unbounded_String"); procedure Test_Bind_Param_Integer is new Test_Bind_Param_T (Integer, Bind_Param, 10, "Integer"); procedure Test_Bind_Param_Identifier is new Test_Bind_Param_T (Identifier, Bind_Param, 100, "Identifier"); procedure Test_Bind_Param_Boolean is new Test_Bind_Param_T (Boolean, Bind_Param, False, "Boolean"); procedure Test_Bind_Param_String is new Test_Bind_Param_T (String, Bind_Param, "0123456789ABCDEF", "String"); procedure Test_Bind_Param_Calendar is new Test_Bind_Param_T (Ada.Calendar.Time, Bind_Param, Ada.Calendar.Clock, "Time"); procedure Test_Bind_Param_Unbounded_String is new Test_Bind_Param_T (Unbounded_String, Bind_Param, To_Unbounded_String ("0123456789ABCDEF"), "Unbounded_String"); package Caller is new Util.Test_Caller (Test, "ADO.Parameters"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test ADO.Parameters.Expand", Test_Expand_Sql'Access); Caller.Add_Test (Suite, "Test ADO.Parameters.Expand (invalid params)", Test_Expand_Error'Access); Caller.Add_Test (Suite, "Test ADO.Parameters.Expand (perf)", Test_Expand_Perf'Access); Caller.Add_Test (Suite, "Test ADO.Parameters.Add_Param (Boolean)", Test_Add_Param_Boolean'Access); Caller.Add_Test (Suite, "Test ADO.Parameters.Add_Param (Integer)", Test_Add_Param_Integer'Access); Caller.Add_Test (Suite, "Test ADO.Parameters.Add_Param (Identifier)", Test_Add_Param_Identifier'Access); Caller.Add_Test (Suite, "Test ADO.Parameters.Add_Param (Calendar)", Test_Add_Param_Calendar'Access); Caller.Add_Test (Suite, "Test ADO.Parameters.Add_Param (String)", Test_Add_Param_String'Access); Caller.Add_Test (Suite, "Test ADO.Parameters.Add_Param (Unbounded_String)", Test_Add_Param_Unbounded_String'Access); Caller.Add_Test (Suite, "Test ADO.Parameters.Bind_Param (Boolean)", Test_Bind_Param_Boolean'Access); Caller.Add_Test (Suite, "Test ADO.Parameters.Bind_Param (Integer)", Test_Bind_Param_Integer'Access); Caller.Add_Test (Suite, "Test ADO.Parameters.Bind_Param (Identifier)", Test_Bind_Param_Identifier'Access); Caller.Add_Test (Suite, "Test ADO.Parameters.Bind_Param (Calendar)", Test_Bind_Param_Calendar'Access); Caller.Add_Test (Suite, "Test ADO.Parameters.Bind_Param (String)", Test_Bind_Param_String'Access); Caller.Add_Test (Suite, "Test ADO.Parameters.Bind_Param (Unbounded_String)", Test_Bind_Param_Unbounded_String'Access); end Add_Tests; -- ------------------------------ -- Test expand SQL with parameters. -- ------------------------------ procedure Test_Expand_Sql (T : in out Test) is SQL : ADO.Parameters.List; D : aliased ADO.Drivers.Dialects.Dialect; procedure Check (Pattern : in String; Expect : in String); procedure Check (Pattern : in String; Expect : in String) is Result : constant String := SQL.Expand (Pattern); begin Assert_Equals (T, Expect, Result, "Invalid SQL expansion"); end Check; begin SQL.Set_Dialect (D'Unchecked_Access); SQL.Bind_Param (1, "select '"); SQL.Bind_Param (2, "from"); SQL.Bind_Param ("user_id", String '("23")); SQL.Bind_Param ("object_23_identifier", Integer (44)); SQL.Bind_Param ("bool", True); SQL.Bind_Param (6, False); SQL.Bind_Param ("_date", Ada.Calendar.Clock); SQL.Bind_Null_Param ("_null"); Check ("?", "'select '''"); Check (":2", "'from'"); Check (":6", "0"); Check (":user_id", "'23'"); Check (":bool", "1"); Check (":_null", "NULL"); Check ("select :1 :2 :3 :4 :5 :6", "select 'select ''' 'from' '23' 44 1 0"); Check ("select ? ? ? ? ? ?", "select 'select ''' 'from' '23' 44 1 0"); Check ("select ? :2 :user_id :object_23_identifier :bool :6", "select 'select ''' 'from' '23' 44 1 0"); end Test_Expand_Sql; -- ------------------------------ -- Test expand with invalid parameters. -- ------------------------------ procedure Test_Expand_Error (T : in out Test) is SQL : ADO.Parameters.List; procedure Check (Pattern : in String; Expect : in String); procedure Check (Pattern : in String; Expect : in String) is Result : constant String := SQL.Expand (Pattern); begin Assert_Equals (T, Expect, Result, "Invalid SQL expansion"); end Check; begin Check (":<", "<"); Check (":234", ""); Check (":name", ""); Check ("select :", "select :"); end Test_Expand_Error; -- ------------------------------ -- Test expand performance. -- ------------------------------ procedure Test_Expand_Perf (T : in out Test) is pragma Unreferenced (T); SQL : ADO.Parameters.List; D : aliased ADO.Drivers.Dialects.Dialect; begin SQL.Set_Dialect (D'Unchecked_Access); declare T : Util.Measures.Stamp; begin for I in 1 .. 1_000 loop SQL.Bind_Param (I, I); end loop; Util.Measures.Report (T, "Bind_Param (1000 calls)"); end; declare B : constant Unbounded_String := To_Unbounded_String ("select t.a, t.b, t.c, t.d, t.e, t.f " & "from T where t.b = 23"); T : Util.Measures.Stamp; begin for I in 1 .. 1_000 loop declare S : constant String := To_String (B); pragma Unreferenced (S); begin null; end; end loop; Util.Measures.Report (T, "Expand reference To_String"); end; declare T : Util.Measures.Stamp; begin for I in 1 .. 1_000 loop declare S : constant String := SQL.Expand ("select t.a, t.b, t.c, t.d, t.e, t.f " & "from T where t.b = 23"); pragma Unreferenced (S); begin null; end; end loop; Util.Measures.Report (T, "Expand (1000 calls with 0 parameter)"); end; declare T : Util.Measures.Stamp; begin for I in 1 .. 1_000 loop declare S : constant String := SQL.Expand ("select t.a, t.b, t.c, t.d, t.e, t.f " & "from T where t.b = :10"); pragma Unreferenced (S); begin null; end; end loop; Util.Measures.Report (T, "Expand (1000 calls with 1 parameter)"); end; declare T : Util.Measures.Stamp; begin for I in 1 .. 1_000 loop declare S : constant String := SQL.Expand (":10 :20 :30 :40 :50 :60 :70 :80 :90 :100"); pragma Unreferenced (S); begin null; end; end loop; Util.Measures.Report (T, "Expand (1000 calls with 10 parameters)"); end; end Test_Expand_Perf; end ADO.Parameters.Tests;
-- Copyright 2016,2017 Steven Stewart-Gallus -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -- implied. See the License for the specific language governing -- permissions and limitations under the License. with Linted.IO_Pool; with Linted.KOs; with Linted.Triggers; package Linted.Poller is subtype Event is Linted.IO_Pool.Poller_Event; subtype Event_Type is Linted.IO_Pool.Poller_Event_Type; subtype Event_Set is Linted.IO_Pool.Poller_Event_Set; Readable : Event_Type renames Linted.IO_Pool.Readable; Writable : Event_Type renames Linted.IO_Pool.Writable; subtype Future is Linted.IO_Pool.Poll_Future; function Future_Is_Live (F : Future) return Boolean renames IO_Pool.Poll_Future_Is_Live; procedure Poll (Object : Linted.KOs.KO; Events : Event_Set; Signaller : Triggers.Signaller; F : out Future) renames IO_Pool.Poll; procedure Poll_Wait (F : in out Future; E : out Event) renames IO_Pool.Poll_Wait; procedure Poll_Poll (F : in out Future; E : out Event; Init : out Boolean) renames IO_Pool.Poll_Poll; end Linted.Poller;
-- MP: a Music Player -- Copyright (C) 2021 by PragmAda Software Engineering. All rights reserved. -- Released under the terms of the BSD 3-Clause license; see https://opensource.org/licenses -- -- 2021-06-01 Use new Enpty_Options procedure from Gnoga 1.6a to clear Sel -- 2021-04-01 Adapted to Ada-12 version of PragmARCs -- 2020-09-15 Initial version -- with Ada.Containers.Vectors; with Ada.Directories; with Ada.Exceptions; with Ada.Numerics.Discrete_Random; with Ada.Strings.Bounded; with Ada.Strings.Unbounded; with Gnoga.Application.Singleton; with Gnoga.Gui.Base; with Gnoga.Gui.Element.Common; with Gnoga.Gui.Element.Form; with Gnoga.Gui.Element.Multimedia; with Gnoga.Gui.View; with Gnoga.Gui.Window; with Gnoga_File_Selection; with PragmARC.Persistent_Skip_List_Unbounded; package body MP.UI is package B_Strings is new Ada.Strings.Bounded.Generic_Bounded_Length (Max => 400); use B_Strings; subtype Path_Name is Bounded_String; function Less (Left : Path_Name; Right : Path_Name) return Boolean; -- Files in the working directory are < files in subdirectories package Path_Lists is new PragmARC.Persistent_Skip_List_Unbounded (Element => Path_Name, "<" => Less); Window : Gnoga.Gui.Window.Window_Type; View : Gnoga.Gui.View.View_Type; Player : Gnoga.Gui.Element.Multimedia.Audio_Type; Form : Gnoga.Gui.Element.Form.Form_Type; Sel : Gnoga.Gui.Element.Form.Selection_Type; Count : Gnoga.Gui.Element.Form.Number_Type; Cnt_Lbl : Gnoga.Gui.Element.Form.Label_Type; Delete : Gnoga.Gui.Element.Common.Button_Type; Path : Gnoga.Gui.Element.Form.Text_Type; Browse : Gnoga.Gui.Element.Common.Button_Type; Add : Gnoga.Gui.Element.Common.Button_Type; Play : Gnoga.Gui.Element.Common.Button_Type; Skip : Gnoga.Gui.Element.Common.Button_Type; Quit : Gnoga.Gui.Element.Common.Button_Type; Quit_After : Gnoga.Gui.Element.Form.Check_Box_Type; QA_LbL : Gnoga.Gui.Element.Form.Label_Type; function Less (Left : Path_Name; Right : Path_Name) return Boolean is function Slash_Count (Path : Path_Name) return Natural; function Slash_Count (Path : Path_Name) return Natural is Result : Natural := 0; Path_S : constant String := To_String (Path); begin -- Slash_Count All_Chars : for I in Path_S'Range loop if Path_S (I) = '/' then Result := Result + 1; end if; end loop All_Chars; return Result; end Slash_Count; Count_L : constant Natural := Slash_Count (Left); Count_R : constant Natural := Slash_Count (Right); begin -- Less if Count_L = 0 and Count_R > 0 then return True; end if; if Count_R = 0 and Count_L > 0 then return False; end if; return Left < Right; end Less; task DJ is entry Start; entry Play; entry Skip; entry Quit; end DJ; procedure Play_Selected (Object : in out Gnoga.Gui.Base.Base_Type'Class) is -- Empty; begin -- Play_Selected DJ.Play; exception -- Play_Selected when E : others => Gnoga.Log (Message => "Play_Selected: " & Ada.Exceptions.Exception_Information (E) ); end Play_Selected; procedure Skip_To_Next (Object : in out Gnoga.Gui.Base.Base_Type'Class) is -- Empty; begin -- Skip_To_Next DJ.Skip; exception -- Skip_To_Next when E : others => Gnoga.Log (Message => "Skip_To_Next: " & Ada.Exceptions.Exception_Information (E) ); end Skip_To_Next; procedure Quit_Now (Object : in out Gnoga.Gui.Base.Base_Type'Class) is -- Empty; begin -- Quit_Now DJ.Quit; delay 0.1; Gnoga.Application.Singleton.End_Application; exception -- Quit_Now when E : others => Gnoga.Log (Message => "Quit_Now: " & Ada.Exceptions.Exception_Information (E) ); end Quit_Now; type Song_Info is record Position : Positive; Path : Path_Name; end record; package Song_Lists is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Song_Info); List : Path_Lists.Persistent_Skip_List := Path_Lists.Open_List ("playlist.mpl"); Song : Song_Lists.Vector; procedure Make_Song_List (List : in out Song_Lists.Vector) is Position : Natural := 0; procedure Add_One (Item : in Path_Name) is -- Empty; begin -- Add_One Position := Position + 1; List.Append (New_Item => (Position => Position, Path => Item) ); Sel.Add_Option (Value => To_String (Item), Text => To_String (Item) ); end Add_One; procedure Add_All is new Path_Lists.Iterate (Action => Add_One); begin -- Make_Song_List List.Clear; Add_All (List => UI.List); end Make_Song_List; procedure Shuffle (List : in out Song_Lists.Vector) is subtype Index is Integer range 1 .. List.Last_Index; package Index_Random is new Ada.Numerics.Discrete_Random (Result_Subtype => Index); Gen : Index_Random.Generator; J : Index; T : Song_Info; begin -- Shuffle Index_Random.Reset (Gen => Gen); Swap_All : for I in 1 .. List.Last_Index loop J := Index_Random.Random (Gen); T := List.Element (I); List.Replace_Element (Index => I, New_Item => List.Element (J) ); List.Replace_Element (Index => J, New_Item => T); end loop Swap_All; end Shuffle; procedure Refresh is -- Empty; begin -- Refresh Sel.Empty_Options; Make_Song_List (List => Song); Count.Value (Value => Sel.Length); Shuffle (List => Song); end Refresh; procedure Delete_Song (Object : in out Gnoga.Gui.Base.Base_Type'Class) is Index : constant Natural := Sel.Selected_Index; Path : Path_Name; Paused : Boolean := False; begin -- Delete_Song if Index = 0 then return; end if; if not Player.Playback_Ended then Paused := True; Player.Pause; end if; Path := To_Bounded_String (Sel.Text (Index) ); List.Delete (Item => Path); Refresh; if Paused then Player.Play; end if; exception -- Delete_Song when E : others => Gnoga.Log (Message => "Delete_Song: " & Ada.Exceptions.Exception_Information (E) ); end Delete_Song; Current_Directory : constant String := Ada.Directories.Current_Directory; procedure Browse_Songs (Object : in out Gnoga.Gui.Base.Base_Type'Class) is Result : constant Gnoga_File_Selection.Result_Info := Gnoga_File_Selection.Select_File (Window, Current_Directory); begin -- Browse_Songs if Result.Picked then Get_Name : declare Name : constant String := Ada.Strings.Unbounded.To_String (Result.Value); begin -- Get_Name if Name'Length > Current_Directory'Length and then Name (Name'First .. Name'First + Current_Directory'Length - 1) = Current_Directory then Path.Value (Value => Name (Name'First + Current_Directory'Length + 1 .. Name'Last) ); end if; end Get_Name; end if; end Browse_Songs; procedure Add_Song (Object : in out Gnoga.Gui.Base.Base_Type'Class) is Name : constant String := Path.Value; Path : Path_Name; Paused : Boolean := False; begin -- Add_Song if Name'Length = 0 then return; end if; if not Player.Playback_Ended then Paused := True; Player.Pause; end if; Path := To_Bounded_String (Name); List.Insert (Item => Path); Refresh; UI.Path.Value (Value => ""); if Paused then Player.Play; end if; exception -- Add_Song when E : others => Gnoga.Log (Message => "Add_Song: " & Ada.Exceptions.Exception_Information (E) ); end Add_Song; Title : constant String := "MP"; task body DJ is function Start (Song : in String) return Boolean is -- Returns True if Song started; False otherwise -- Empty; begin -- Start Player.Media_Source (Source => Song); Window.Document.Title (Value => Title & ' ' & Song); Wait_For_Ready : for I in 1 .. 10 loop if Player.Ready_To_Play then Player.Play; return True; end if; delay 0.01; end loop Wait_For_Ready; return False; end Start; Current : Song_Info; Index : Positive := 1; Run : Boolean := True; begin -- DJ Wait_For_Song : loop exit Wait_For_Song when Song.Last_Index > 0; select accept Quit; Window.Document.Title (Value => Title); Run := False; or delay 1.0; end select; end loop Wait_For_Song; if Run then accept Start; Forever : loop Current := Song.Element (Index); Sel.Selected (Index => Current.Position); if Start (To_String (Current.Path) ) then Wait_For_End : loop select accept Play; exit Wait_For_End when not Start (Sel.Text (Sel.Selected_Index) ); or accept Skip; Window.Document.Title (Value => Title); exit Wait_For_End; or accept Quit; Window.Document.Title (Value => Title); exit Forever; or delay 1.0; exit Wait_For_End when Player.Playback_Ended; end select; end loop Wait_For_End; end if; exit Forever when Quit_After.Checked; Index := Index + 1; if Index > Song.Last_Index then Index := 1; end if; end loop Forever; if Quit_After.Checked then Window.Document.Title (Value => Title); Gnoga.Application.Singleton.End_Application; end if; end if; exception -- DJ when E : others => Gnoga.Log (Message => "DJ: " & Ada.Exceptions.Exception_Information (E) ); end DJ; begin -- MP.UI Gnoga.Application.Title (Name => Title); Gnoga.Application.HTML_On_Close (HTML => Title & " ended."); Gnoga.Application.Open_URL (url => "http://localhost:8089/"); Gnoga.Application.Singleton.Initialize (Main_Window => Window, Port => 8089); View.Create (Parent => Window); View.Text_Alignment (Value => Gnoga.Gui.Element.Center); Player.Create (Parent => View, Preload => True); View.New_Line; Form.Create (Parent => View); Form.Text_Alignment (Value => Gnoga.Gui.Element.Center); Sel.Create (Form => Form, Visible_Lines => 30); Form.New_Line; Count.Create (Form => Form); Count.Editable (Value => False); Count.Read_Only; Cnt_Lbl.Create (Form => Form, Label_For => Count, Content => "Number of songs:"); Form.New_Line; Delete.Create (Parent => Form, Content => "Delete"); Delete.On_Click_Handler (Handler => Delete_Song'Access); Path.Create (Form => Form, Size => 100); Browse.Create (Parent => Form, Content => "Browse"); Browse.On_Click_Handler (Handler => Browse_Songs'Access); Add.Create (Parent => Form, Content => "Add"); Add.On_Click_Handler (Handler => Add_Song'Access); Form.New_Line; Play.Create (Parent => Form, Content => "Play"); Play.On_Click_Handler (Handler => Play_Selected'Access); Skip.Create (Parent => Form, Content => "Skip"); Skip.On_Click_Handler (Handler => Skip_To_Next'Access); Quit.Create (Parent => Form, Content => "Quit"); Quit.On_Click_Handler (Handler => Quit_Now'Access); Quit_After.Create (Form => Form); QA_LbL.Create (Form => Form, Label_For => Quit_After, Content => "Quit after this song", Auto_Place => False); Refresh; DJ.Start; Gnoga.Application.Singleton.Message_Loop; exception -- MP.UI when E : others => Gnoga.Log (Message => Ada.Exceptions.Exception_Information (E) ); end MP.UI;
with System.Address_To_Named_Access_Conversions; with C.dlfcn; with C.sys.link_elf; package body System.Storage_Map is pragma Suppress (All_Checks); use type C.signed_int; package char_ptr_Conv is new Address_To_Named_Access_Conversions (C.char, C.char_ptr); -- implementation function Load_Address return Address is type Link_map_ptr is access all C.sys.link_elf.Link_map with Convention => C; for Link_map_ptr'Storage_Size use 0; Map : aliased Link_map_ptr; begin if C.dlfcn.dlinfo ( C.dlfcn.RTLD_SELF, C.dlfcn.RTLD_DI_LINKMAP, C.void_ptr (Map'Address)) < 0 then return Null_Address; -- ??? end if; return char_ptr_Conv.To_Address (Map.l_addr); end Load_Address; end System.Storage_Map;
with STM32GD.Startup; package body STM32GD.Board is procedure Init is begin null; end Init; end STM32GD.Board;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Exceptions; -- Lecteurs concurrents, approche serveur. Pas de politique d'accès. package body LR.Synchro.Serveur is function Nom_Strategie return String is begin return "Serveur, lecteurs concurrents, sans politique d'accès"; end Nom_Strategie; task LectRedTask is entry Demander_Lecture; entry Demander_Ecriture; entry Terminer_Lecture; entry Terminer_Ecriture; end LectRedTask; task body LectRedTask is reader : Integer := 0; writer : Integer := 0; begin loop select when writer = 0 => accept Demander_Lecture; reader := reader + 1; or when reader > 0 => accept Terminer_Lecture; reader := reader - 1; or when reader = 0 and writer = 0 => accept Demander_Ecriture; writer := writer + 1; or when writer > 0 => accept Terminer_Ecriture; writer := writer - 1; or terminate; end select; end loop; end LectRedTask; procedure Demander_Lecture is begin LectRedTask.Demander_Lecture; end Demander_Lecture; procedure Demander_Ecriture is begin LectRedTask.Demander_Ecriture; end Demander_Ecriture; procedure Terminer_Lecture is begin LectRedTask.Terminer_Lecture; end Terminer_Lecture; procedure Terminer_Ecriture is begin LectRedTask.Terminer_Ecriture; end Terminer_Ecriture; end LR.Synchro.Serveur;
--:::::::::: --io_libs.ada --:::::::::: -- Precompiled instantiations of Integer_IO and -- Float_IO for the predefined Integer and Float types WITH Text_IO; PACKAGE My_Int_IO IS NEW Text_IO.Integer_IO (Num => Integer); WITH Text_IO; PACKAGE My_Flt_IO IS NEW Text_IO.Float_IO (Num => Float); --:::::::::: --random.ads --:::::::::: PACKAGE Random IS -- Simple pseudo-random number generator package. -- Adapated from the Ada literature by -- Michael B. Feldman, The George Washington University, November 1990. PROCEDURE Set_Seed (N : Positive); FUNCTION Unit_Random RETURN Float; --returns a float >=0.0 and <1.0 FUNCTION Random_Int (N : Positive) RETURN Positive; --return a random integer in the range 1..N END Random; --:::::::::: --chop.ads --:::::::::: PACKAGE Chop IS TASK TYPE Stick IS ENTRY Pick_Up; ENTRY Put_Down; END Stick; END Chop; --:::::::::: --phil.ads --:::::::::: PACKAGE Phil IS TASK TYPE Philosopher IS ENTRY Come_To_Life (My_ID : Positive; Chopstick1 : Positive; Chopstick2 : Positive); END Philosopher; TYPE States IS (Breathing, Thinking, Eating, Done_Eating, Got_One_Stick, Got_Other_Stick); END Phil; --:::::::::: --room.ads --:::::::::: WITH Chop; WITH Phil; PACKAGE Room IS Table_Size: CONSTANT := 5; SUBTYPE Table_Type IS Positive RANGE 1..Table_Size; Sticks: ARRAY(Table_Type) OF Chop.Stick; TASK Head_Waiter IS ENTRY Open_The_Room; ENTRY Report_State(Which_Phil: Table_Type; State: Phil.States; How_Long: Natural := 0); END Head_Waiter; END Room; --:::::::::: --diners.ada --:::::::::: WITH Room; PROCEDURE Diners IS BEGIN Room.Head_Waiter.Open_The_Room; LOOP DELAY 20.0; END LOOP; END Diners; --:::::::::: --random.adb --:::::::::: WITH Calendar; USE Calendar; PACKAGE BODY Random IS -- Body of random number generator package. -- Adapted from the Ada literature by -- Michael B. Feldman, The George Washington University, November 1990. Modulus : CONSTANT := 9317; TYPE Int_16 IS RANGE - 2 ** 15 .. 2 ** 15 - 1; TYPE Int_32 IS RANGE - 2 ** 31 .. 2 ** 31 - 1; SUBTYPE Seed_Range IS Int_16 RANGE 0 .. (Modulus - 1); Seed, Default_Seed : Seed_Range; PROCEDURE Set_Seed (N : Positive) IS SEPARATE; FUNCTION Unit_Random RETURN Float IS SEPARATE; FUNCTION Random_Int (N : Positive) RETURN Positive IS SEPARATE; BEGIN Default_Seed := Int_16 (Int_32 (Seconds (Clock)) MOD Modulus); Seed := Default_Seed; END Random; SEPARATE (Random) PROCEDURE Set_Seed (N : Positive) IS BEGIN Seed := Seed_Range (N); END Set_Seed; SEPARATE (Random) FUNCTION Unit_Random RETURN Float IS Multiplier : CONSTANT := 421; Increment : CONSTANT := 2073; Result : Float; BEGIN Seed := (Multiplier * Seed + Increment) MOD Modulus; Result := Float (Seed) / Float (Modulus); RETURN Result; EXCEPTION WHEN Constraint_Error | Numeric_Error => Seed := Int_16 ((Multiplier * Int_32 (Seed) + Increment) MOD Modulus); Result := Float (Seed) / Float (Modulus); RETURN Result; END Unit_Random; SEPARATE (Random) FUNCTION Random_Int (N : Positive) RETURN Positive IS Result : Integer RANGE 1 .. N; BEGIN Result := Integer (Float (N) * Unit_Random + 0.5); RETURN Result; EXCEPTION WHEN Constraint_Error | Numeric_Error => RETURN 1; END Random_Int; --:::::::::: --chop.adb --:::::::::: PACKAGE BODY Chop IS TASK BODY Stick IS BEGIN LOOP SELECT ACCEPT Pick_Up; ACCEPT Put_Down; OR TERMINATE; END SELECT; END LOOP; END Stick; END Chop; --:::::::::: --phil.adb --:::::::::: WITH Room; WITH Random; PACKAGE BODY Phil IS TASK BODY Philosopher IS Who_Am_I : Positive; First_Grab : Positive; Second_Grab: Positive; Meal_Time : Natural; Think_Time : Natural; BEGIN ACCEPT Come_To_Life (My_ID : Positive; Chopstick1 : Positive; Chopstick2 : Positive) DO Who_Am_I := My_ID; First_Grab := Chopstick1; Second_Grab := Chopstick2; END Come_To_Life; Room.Head_Waiter.Report_State(Who_Am_I, Breathing); LOOP Room.Sticks(First_Grab).Pick_Up; Room.Head_Waiter.Report_State(Who_Am_I, Got_One_Stick, First_Grab); Room.Sticks(Second_Grab).Pick_Up; Room.Head_Waiter.Report_State(Who_Am_I, Got_Other_Stick, Second_Grab); Meal_Time := Random.Random_Int(10); Room.Head_Waiter.Report_State(Who_Am_I, Eating, Meal_Time); DELAY Duration(Meal_Time); Room.Head_Waiter.Report_State(Who_Am_I, Done_Eating); Room.Sticks(First_Grab).Put_Down; Room.Sticks(Second_Grab).Put_Down; Think_Time := Random.Random_Int(10); Room.Head_Waiter.Report_State(Who_Am_I, Thinking, Think_Time); DELAY Duration(Think_Time); END LOOP; END Philosopher; END Phil; --:::::::::: --roomline.adb --:::::::::: WITH Text_IO; WITH Chop; WITH Phil; WITH Calendar; PRAGMA Elaborate(Phil); PACKAGE BODY Room IS -- A line-oriented version of the Room package, for line-oriented -- terminals like IBM 3270's where the user cannot do ASCII screen control. -- This is the only file in the dining philosophers system that needs -- changing to use in a line-oriented environment. -- Michael B. Feldman, The George Washington University, November 1990. Phils: ARRAY(Table_Type) OF Phil.Philosopher; TYPE Phil_Names IS (Dijkstra, Texel, Booch, Ichbiah, Stroustrup); TASK BODY Head_Waiter IS T : Integer; Start_Time: Calendar.Time; Phil_Names: CONSTANT ARRAY(1..5) OF String(1..18) := ("Eddy Dijkstra ", "Putnam Texel ", "Grady Booch ", "Jean Ichbiah ", "Bjarne Stroustrup "); Blanks : CONSTANT String := " "; BEGIN ACCEPT Open_The_Room; Start_Time := Calendar.Clock; Phils(1).Come_To_Life(1,1,2); Phils(3).Come_To_Life(3,3,4); Phils(2).Come_To_Life(2,2,3); Phils(5).Come_To_Life(5,1,5); Phils(4).Come_To_Life(4,4,5); LOOP SELECT ACCEPT Report_State(Which_Phil: Table_Type; State: Phil.States; How_Long: Natural := 0) DO T := Integer(Calendar."-"(Calendar.Clock,Start_Time)); Text_IO.Put( "T=" & Integer'Image(T) & " " & Blanks(1..Which_Phil) & Phil_Names(Which_Phil)); CASE State IS WHEN Phil.Breathing => Text_IO.Put("Breathing"); WHEN Phil.Thinking => Text_IO.Put( "Thinking" & Integer'Image(How_Long) & " seconds."); WHEN Phil.Eating => Text_IO.Put( "Eating" & Integer'Image(How_Long) & " seconds."); WHEN Phil.Done_Eating => Text_IO.Put("Yum-yum (burp)"); WHEN Phil.Got_One_Stick => Text_IO.Put( "First chopstick" & Integer'Image(How_Long)); WHEN Phil.Got_Other_Stick => Text_IO.Put( "Second chopstick" & Integer'Image(How_Long)); END CASE; Text_IO.New_Line; END Report_State; OR TERMINATE; END SELECT; END LOOP; END Head_Waiter; END Room;
-- { dg-do compile } -- { dg-options "-gnat12 -gnata" } package body Discr40 is procedure Push (S: in out Stack; E : Element) is begin S.Length := S.Length + 1; S.Data(S.Length) := E; end Push; end Discr40;
-- { dg-do run } with System, Ada.Unchecked_Conversion; use System; procedure BLKextract_From_Reg is type Byte is range 0 .. +255; for Byte'size use 8; type RGB is array (1 .. 3) of Byte; for RGB'Size use 24; type RAW_Packet is range 0 .. 2 ** 32 - 1; for RAW_Packet'Size use 32; type Composite_Packet is record Values : RGB; Pad : Byte; end record; for Composite_Packet use record Values at 0 range 0 .. 23; Pad at 3 range 0 .. 7; end record; for Composite_Packet'Size use 32; function To_Composite_Packet is new Ada.Unchecked_Conversion (RAW_Packet, Composite_Packet); function Blob return RGB is RAW_Blob : RAW_Packet := 16#01020304#; begin return To_Composite_Packet (RAW_Blob).Values; end; Blob_Color : RGB := Blob; Expected_Color : RGB; begin if System.Default_Bit_Order = High_Order_First then Expected_Color := (1 => 1, 2 => 2, 3 => 3); else Expected_Color := (1 => 4, 2 => 3, 3 => 2); end if; for I in Blob_Color'Range loop if Blob_Color (I) /= Expected_Color (I) then raise Program_Error; end if; end loop; end;
package Hide.BMP is type Header is record Signature_1 : Integer_8; Signature_2 : Integer_8; Size : Integer_32; -- File size in bytes Reserved1 : Integer_16; Reserved2 : Integer_16; Offset : Integer_32; -- Start address in bytes where the image data can be found. end record with Pack => True; type Info is record Header : BMP.Header; Struct_Size : Integer_32; Width : Integer_32; -- Image width in pixels Height : Integer_32; -- Image hieght in pixels Planes : Integer_16; Pixel_Size : Integer_16; -- Bits per pixel Compression : Integer_32; -- Zero means no compression Image_Size : Integer_32; -- Size of the image data in bytes PPMX : Integer_32; -- Pixels per meter in x led PPMY : Integer_32; -- Pixels per meter in y led Palette_Size : Integer_32; -- Number of colors Important : Integer_32; end record with Pack => True; function Image ( Item : Info ) return String ; type Pixel_G8 is new Integer_8; -- 8 bit pixel grayscale type Image_G8 is array (Integer range <>) of Pixel_G8; type Byte_As_Bit_Array is array (1 .. 8) of Boolean with Pack => True; type Chanels is (Alpha, Red, Gren, Blue); type Pixel_ARGB32 is array (Chanels) of Byte_As_Bit_Array with Pack => True; type Image_ARGB32 is array (Integer range <>) of Pixel_ARGB32; procedure Encode (Image_Info : Info; Image : in out Image_ARGB32; Offset : Natural; Text : in String); function Decode (Image_Info : Info; Image : in Image_ARGB32) return String; end Hide.BMP;
pragma SPARK_Mode; with Types; use Types; -- @summary -- Control for the robot's motors -- -- @description -- This package exposes on interface to control the robot's motors -- package Zumo_Motors is -- True if the package has been init'd Initd : Boolean := False; -- Whether to reverse the left motor FlipLeft : Boolean := False; -- Whether to reverse the right motor FlipRight : Boolean := False; -- Init the package. pin mux and whatnot procedure Init with Global => (In_Out => Initd), Pre => not Initd, Post => Initd; -- Flip the direction of the left motor -- @param Flip if true, flip the direction procedure FlipLeftMotor (Flip : Boolean) with Global => (Output => (FlipLeft)), Post => FlipLeft = Flip; -- Flip the direction of the right motor -- @param Flip if tru,. flip the direction procedure FlipRightMotor (Flip : Boolean) with Global => (Output => (FlipRight)), Post => FlipRight = Flip; -- Set the speed of the left motor -- @param Velocity the speed to set the motor at procedure SetLeftSpeed (Velocity : Motor_Speed) with Global => (Proof_In => Initd, Input => FlipLeft), -- Output => (Pwm.Register_State)), Pre => Initd; -- Set the speed of the right motor -- @param Velocity the speed to set the motor at procedure SetRightSpeed (Velocity : Motor_Speed) with Global => (Proof_In => Initd, Input => FlipRight), -- Output => (Pwm.Register_State)), Pre => Initd; -- Set the speed of both the left and right motors -- @param LeftVelocity the left motor velocity to set -- @param RightVelocity the right motor velocity to set procedure SetSpeed (LeftVelocity : Motor_Speed; RightVelocity : Motor_Speed) with Global => (Proof_In => Initd, Input => (FlipLeft, FlipRight)), -- Output => (Pwm.Register_State)), Pre => Initd; end Zumo_Motors;
with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO; with X86Parser; use X86Parser; package X86Writer is procedure assemble(instr_list : Instr_Vector.Vector; writer : Stream_Access); end X86Writer;
-- -- Copyright (C) 2019, AdaCore -- -- Copyright (c) 2010 - 2018, Nordic Semiconductor ASA -- -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- 1. Redistributions of source code must retain the above copyright notice, -- this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form, except as embedded into a Nordic -- Semiconductor ASA integrated circuit in a product or a software update -- for such product, must reproduce the above copyright notice, this list -- of conditions and the following disclaimer in the documentation and/or -- other materials provided with the distribution. -- -- 3. Neither the name of Nordic Semiconductor ASA nor the names of its -- contributors may be used to endorse or promote products derived from -- this software without specific prior written permission. -- -- 4. This software, with or without modification, must only be used with a -- Nordic Semiconductor ASA integrated circuit. -- -- 5. Any software provided in binary form under this license must not be -- reverse engineered, decompiled, modified and/or disassembled. -- -- THIS SOFTWARE IS PROVIDED BY NORDIC SEMICONDUCTOR ASA "AS IS" AND ANY -- EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -- WARRANTIES OF MERCHANTABILITY, NONINFRINGEMENT, AND FITNESS FOR A -- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL NORDIC SEMICONDUCTOR -- ASA OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- This spec has been automatically generated from nrf52840.svd pragma Ada_2012; pragma Style_Checks (Off); with System; package Interfaces.NRF52.UICR is pragma Preelaborate; pragma No_Elaboration_Code_All; --------------- -- Registers -- --------------- -- Description collection[n]: Reserved for Nordic firmware design -- Description collection[n]: Reserved for Nordic firmware design type NRFFW_Registers is array (0 .. 14) of Interfaces.NRF52.UInt32; -- Description collection[n]: Reserved for Nordic hardware design -- Description collection[n]: Reserved for Nordic hardware design type NRFHW_Registers is array (0 .. 11) of Interfaces.NRF52.UInt32; -- Description collection[n]: Reserved for customer -- Description collection[n]: Reserved for customer type CUSTOMER_Registers is array (0 .. 31) of Interfaces.NRF52.UInt32; subtype PSELRESET_PIN_Field is Interfaces.NRF52.UInt5; subtype PSELRESET_PORT_Field is Interfaces.NRF52.Bit; -- Connection type PSELRESET_CONNECT_Field is (-- Connect Connected, -- Disconnect Disconnected) with Size => 1; for PSELRESET_CONNECT_Field use (Connected => 0, Disconnected => 1); -- Description collection[n]: Mapping of the nRESET function type PSELRESET_Register is record -- Pin number of PORT onto which nRESET is exposed PIN : PSELRESET_PIN_Field := 16#1F#; -- Port number onto which nRESET is exposed PORT : PSELRESET_PORT_Field := 16#1#; -- unspecified Reserved_6_30 : Interfaces.NRF52.UInt25 := 16#1FFFFFF#; -- Connection CONNECT : PSELRESET_CONNECT_Field := Interfaces.NRF52.UICR.Disconnected; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for PSELRESET_Register use record PIN at 0 range 0 .. 4; PORT at 0 range 5 .. 5; Reserved_6_30 at 0 range 6 .. 30; CONNECT at 0 range 31 .. 31; end record; -- Description collection[n]: Mapping of the nRESET function type PSELRESET_Registers is array (0 .. 1) of PSELRESET_Register; -- Enable or disable access port protection. type APPROTECT_PALL_Field is (-- Enable Enabled, -- Disable Disabled) with Size => 8; for APPROTECT_PALL_Field use (Enabled => 0, Disabled => 255); -- Access port protection type APPROTECT_Register is record -- Enable or disable access port protection. PALL : APPROTECT_PALL_Field := Interfaces.NRF52.UICR.Disabled; -- unspecified Reserved_8_31 : Interfaces.NRF52.UInt24 := 16#FFFFFF#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for APPROTECT_Register use record PALL at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; -- Setting of pins dedicated to NFC functionality type NFCPINS_PROTECT_Field is (-- Operation as GPIO pins. Same protection as normal GPIO pins Disabled, -- Operation as NFC antenna pins. Configures the protection for NFC operation Nfc) with Size => 1; for NFCPINS_PROTECT_Field use (Disabled => 0, Nfc => 1); -- Setting of pins dedicated to NFC functionality: NFC antenna or GPIO type NFCPINS_Register is record -- Setting of pins dedicated to NFC functionality PROTECT : NFCPINS_PROTECT_Field := Interfaces.NRF52.UICR.Nfc; -- unspecified Reserved_1_31 : Interfaces.NRF52.UInt31 := 16#7FFFFFFF#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for NFCPINS_Register use record PROTECT at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- Configure CPU non-intrusive debug features type DEBUGCTRL_CPUNIDEN_Field is (-- Disable CPU ITM and ETM functionality Disabled, -- Enable CPU ITM and ETM functionality (default behavior) Enabled) with Size => 8; for DEBUGCTRL_CPUNIDEN_Field use (Disabled => 0, Enabled => 255); -- Configure CPU flash patch and breakpoint (FPB) unit behavior type DEBUGCTRL_CPUFPBEN_Field is (-- Disable CPU FPB unit. Writes into the FPB registers will be ignored. Disabled, -- Enable CPU FPB unit (default behavior) Enabled) with Size => 8; for DEBUGCTRL_CPUFPBEN_Field use (Disabled => 0, Enabled => 255); -- Processor debug control type DEBUGCTRL_Register is record -- Configure CPU non-intrusive debug features CPUNIDEN : DEBUGCTRL_CPUNIDEN_Field := Interfaces.NRF52.UICR.Enabled; -- Configure CPU flash patch and breakpoint (FPB) unit behavior CPUFPBEN : DEBUGCTRL_CPUFPBEN_Field := Interfaces.NRF52.UICR.Enabled; -- unspecified Reserved_16_31 : Interfaces.NRF52.UInt16 := 16#FFFF#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for DEBUGCTRL_Register use record CPUNIDEN at 0 range 0 .. 7; CPUFPBEN at 0 range 8 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; -- Output voltage from of REG0 regulator stage. The maximum output voltage -- from this stage is given as VDDH - VEXDIF. type REGOUT0_VOUT_Field is (-- 1.8 V Val_1V8, -- 2.1 V Val_2V1, -- 2.4 V Val_2V4, -- 2.7 V Val_2V7, -- 3.0 V Val_3V0, -- 3.3 V Val_3V3, -- Default voltage: 1.8 V Default) with Size => 3; for REGOUT0_VOUT_Field use (Val_1V8 => 0, Val_2V1 => 1, Val_2V4 => 2, Val_2V7 => 3, Val_3V0 => 4, Val_3V3 => 5, Default => 7); -- GPIO reference voltage / external output supply voltage in high voltage -- mode type REGOUT0_Register is record -- Output voltage from of REG0 regulator stage. The maximum output -- voltage from this stage is given as VDDH - VEXDIF. VOUT : REGOUT0_VOUT_Field := Interfaces.NRF52.UICR.Default; -- unspecified Reserved_3_31 : Interfaces.NRF52.UInt29 := 16#1FFFFFFF#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for REGOUT0_Register use record VOUT at 0 range 0 .. 2; Reserved_3_31 at 0 range 3 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- User information configuration registers type UICR_Peripheral is record -- Unspecified UNUSED0 : aliased Interfaces.NRF52.UInt32; -- Unspecified UNUSED1 : aliased Interfaces.NRF52.UInt32; -- Unspecified UNUSED2 : aliased Interfaces.NRF52.UInt32; -- Unspecified UNUSED3 : aliased Interfaces.NRF52.UInt32; -- Description collection[n]: Reserved for Nordic firmware design NRFFW : aliased NRFFW_Registers; -- Description collection[n]: Reserved for Nordic hardware design NRFHW : aliased NRFHW_Registers; -- Description collection[n]: Reserved for customer CUSTOMER : aliased CUSTOMER_Registers; -- Description collection[n]: Mapping of the nRESET function PSELRESET : aliased PSELRESET_Registers; -- Access port protection APPROTECT : aliased APPROTECT_Register; -- Setting of pins dedicated to NFC functionality: NFC antenna or GPIO NFCPINS : aliased NFCPINS_Register; -- Processor debug control DEBUGCTRL : aliased DEBUGCTRL_Register; -- GPIO reference voltage / external output supply voltage in high -- voltage mode REGOUT0 : aliased REGOUT0_Register; end record with Volatile; for UICR_Peripheral use record UNUSED0 at 16#0# range 0 .. 31; UNUSED1 at 16#4# range 0 .. 31; UNUSED2 at 16#8# range 0 .. 31; UNUSED3 at 16#10# range 0 .. 31; NRFFW at 16#14# range 0 .. 479; NRFHW at 16#50# range 0 .. 383; CUSTOMER at 16#80# range 0 .. 1023; PSELRESET at 16#200# range 0 .. 63; APPROTECT at 16#208# range 0 .. 31; NFCPINS at 16#20C# range 0 .. 31; DEBUGCTRL at 16#210# range 0 .. 31; REGOUT0 at 16#304# range 0 .. 31; end record; -- User information configuration registers UICR_Periph : aliased UICR_Peripheral with Import, Address => UICR_Base; end Interfaces.NRF52.UICR;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . T A S K I N G . S T A G E S -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2016, 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. -- -- -- ------------------------------------------------------------------------------ pragma Polling (Off); -- Turn off polling, we do not want ATC polling to take place during tasking -- operations. It causes infinite loops and other problems. pragma Partition_Elaboration_Policy (Concurrent); -- This package only implements the concurrent elaboration policy. This pragma -- will enforce it (and detect conflicts with user specified policy). with Ada.Exceptions; with Ada.Unchecked_Deallocation; with System.Interrupt_Management; with System.Tasking.Debug; with System.Address_Image; with System.Task_Primitives; with System.Task_Primitives.Operations; with System.Tasking.Utilities; with System.Tasking.Queuing; with System.Tasking.Rendezvous; with System.OS_Primitives; with System.Secondary_Stack; with System.Restrictions; with System.Standard_Library; with System.Traces.Tasking; with System.Stack_Usage; with System.Storage_Elements; with System.Soft_Links; -- These are procedure pointers to non-tasking routines that use task -- specific data. In the absence of tasking, these routines refer to global -- data. In the presence of tasking, they must be replaced with pointers to -- task-specific versions. Also used for Create_TSD, Destroy_TSD, Get_Current -- _Excep, Finalize_Library_Objects, Task_Termination, Handler. with System.Tasking.Initialization; pragma Elaborate_All (System.Tasking.Initialization); -- This insures that tasking is initialized if any tasks are created package body System.Tasking.Stages is package STPO renames System.Task_Primitives.Operations; package SSL renames System.Soft_Links; package SSE renames System.Storage_Elements; package SST renames System.Secondary_Stack; use Ada.Exceptions; use Parameters; use Task_Primitives; use Task_Primitives.Operations; use Task_Info; use System.Traces; use System.Traces.Tasking; ----------------------- -- Local Subprograms -- ----------------------- procedure Free is new Ada.Unchecked_Deallocation (Ada_Task_Control_Block, Task_Id); procedure Trace_Unhandled_Exception_In_Task (Self_Id : Task_Id); -- This procedure outputs the task specific message for exception -- tracing purposes. procedure Task_Wrapper (Self_ID : Task_Id); pragma Convention (C, Task_Wrapper); -- This is the procedure that is called by the GNULL from the new context -- when a task is created. It waits for activation and then calls the task -- body procedure. When the task body procedure completes, it terminates -- the task. -- -- The Task_Wrapper's address will be provided to the underlying threads -- library as the task entry point. Convention C is what makes most sense -- for that purpose (Export C would make the function globally visible, -- and affect the link name on which GDB depends). This will in addition -- trigger an automatic stack alignment suitable for GCC's assumptions if -- need be. -- "Vulnerable_..." in the procedure names below means they must be called -- with abort deferred. procedure Vulnerable_Complete_Task (Self_ID : Task_Id); -- Complete the calling task. This procedure must be called with -- abort deferred. It should only be called by Complete_Task and -- Finalize_Global_Tasks (for the environment task). procedure Vulnerable_Complete_Master (Self_ID : Task_Id); -- Complete the current master of the calling task. This procedure -- must be called with abort deferred. It should only be called by -- Vulnerable_Complete_Task and Complete_Master. procedure Vulnerable_Complete_Activation (Self_ID : Task_Id); -- Signal to Self_ID's activator that Self_ID has completed activation. -- This procedure must be called with abort deferred. procedure Abort_Dependents (Self_ID : Task_Id); -- Abort all the direct dependents of Self at its current master nesting -- level, plus all of their dependents, transitively. RTS_Lock should be -- locked by the caller. procedure Vulnerable_Free_Task (T : Task_Id); -- Recover all runtime system storage associated with the task T. This -- should only be called after T has terminated and will no longer be -- referenced. -- -- For tasks created by an allocator that fails, due to an exception, it is -- called from Expunge_Unactivated_Tasks. -- -- Different code is used at master completion, in Terminate_Dependents, -- due to a need for tighter synchronization with the master. ---------------------- -- Abort_Dependents -- ---------------------- procedure Abort_Dependents (Self_ID : Task_Id) is C : Task_Id; P : Task_Id; -- Each task C will take care of its own dependents, so there is no -- need to worry about them here. In fact, it would be wrong to abort -- indirect dependents here, because we can't distinguish between -- duplicate master ids. For example, suppose we have three nested -- task bodies T1,T2,T3. And suppose T1 also calls P which calls Q (and -- both P and Q are task masters). Q will have the same master id as -- Master_of_Task of T3. Previous versions of this would abort T3 when -- Q calls Complete_Master, which was completely wrong. begin C := All_Tasks_List; while C /= null loop P := C.Common.Parent; if P = Self_ID then if C.Master_of_Task = Self_ID.Master_Within then pragma Debug (Debug.Trace (Self_ID, "Aborting", 'X', C)); Utilities.Abort_One_Task (Self_ID, C); C.Dependents_Aborted := True; end if; end if; C := C.Common.All_Tasks_Link; end loop; Self_ID.Dependents_Aborted := True; end Abort_Dependents; ----------------- -- Abort_Tasks -- ----------------- procedure Abort_Tasks (Tasks : Task_List) is begin Utilities.Abort_Tasks (Tasks); end Abort_Tasks; -------------------- -- Activate_Tasks -- -------------------- -- Note that locks of activator and activated task are both locked here. -- This is necessary because C.Common.State and Self.Common.Wait_Count have -- to be synchronized. This is safe from deadlock because the activator is -- always created before the activated task. That satisfies our -- in-order-of-creation ATCB locking policy. -- At one point, we may also lock the parent, if the parent is different -- from the activator. That is also consistent with the lock ordering -- policy, since the activator cannot be created before the parent. -- Since we are holding both the activator's lock, and Task_Wrapper locks -- that before it does anything more than initialize the low-level ATCB -- components, it should be safe to wait to update the counts until we see -- that the thread creation is successful. -- If the thread creation fails, we do need to close the entries of the -- task. The first phase, of dequeuing calls, only requires locking the -- acceptor's ATCB, but the waking up of the callers requires locking the -- caller's ATCB. We cannot safely do this while we are holding other -- locks. Therefore, the queue-clearing operation is done in a separate -- pass over the activation chain. procedure Activate_Tasks (Chain_Access : Activation_Chain_Access) is Self_ID : constant Task_Id := STPO.Self; P : Task_Id; C : Task_Id; Next_C, Last_C : Task_Id; Activate_Prio : System.Any_Priority; Success : Boolean; All_Elaborated : Boolean := True; begin -- If pragma Detect_Blocking is active, then we must check whether this -- potentially blocking operation is called from a protected action. if System.Tasking.Detect_Blocking and then Self_ID.Common.Protected_Action_Nesting > 0 then raise Program_Error with "potentially blocking operation"; end if; pragma Debug (Debug.Trace (Self_ID, "Activate_Tasks", 'C')); Initialization.Defer_Abort_Nestable (Self_ID); pragma Assert (Self_ID.Common.Wait_Count = 0); -- Lock RTS_Lock, to prevent activated tasks from racing ahead before -- we finish activating the chain. Lock_RTS; -- Check that all task bodies have been elaborated C := Chain_Access.T_ID; Last_C := null; while C /= null loop if C.Common.Elaborated /= null and then not C.Common.Elaborated.all then All_Elaborated := False; end if; -- Reverse the activation chain so that tasks are activated in the -- same order they're declared. Next_C := C.Common.Activation_Link; C.Common.Activation_Link := Last_C; Last_C := C; C := Next_C; end loop; Chain_Access.T_ID := Last_C; if not All_Elaborated then Unlock_RTS; Initialization.Undefer_Abort_Nestable (Self_ID); raise Program_Error with "Some tasks have not been elaborated"; end if; -- Activate all the tasks in the chain. Creation of the thread of -- control was deferred until activation. So create it now. C := Chain_Access.T_ID; while C /= null loop if C.Common.State /= Terminated then pragma Assert (C.Common.State = Unactivated); P := C.Common.Parent; Write_Lock (P); Write_Lock (C); Activate_Prio := (if C.Common.Base_Priority < Get_Priority (Self_ID) then Get_Priority (Self_ID) else C.Common.Base_Priority); System.Task_Primitives.Operations.Create_Task (C, Task_Wrapper'Address, Parameters.Size_Type (C.Common.Compiler_Data.Pri_Stack_Info.Size), Activate_Prio, Success); -- There would be a race between the created task and the creator -- to do the following initialization, if we did not have a -- Lock/Unlock_RTS pair in the task wrapper to prevent it from -- racing ahead. if Success then C.Common.State := Activating; C.Awake_Count := 1; C.Alive_Count := 1; P.Awake_Count := P.Awake_Count + 1; P.Alive_Count := P.Alive_Count + 1; if P.Common.State = Master_Completion_Sleep and then C.Master_of_Task = P.Master_Within then pragma Assert (Self_ID /= P); P.Common.Wait_Count := P.Common.Wait_Count + 1; end if; for J in System.Tasking.Debug.Known_Tasks'Range loop if System.Tasking.Debug.Known_Tasks (J) = null then System.Tasking.Debug.Known_Tasks (J) := C; C.Known_Tasks_Index := J; exit; end if; end loop; if Global_Task_Debug_Event_Set then Debug.Signal_Debug_Event (Debug.Debug_Event_Activating, C); end if; C.Common.State := Runnable; Unlock (C); Unlock (P); else -- No need to set Awake_Count, State, etc. here since the loop -- below will do that for any Unactivated tasks. Unlock (C); Unlock (P); Self_ID.Common.Activation_Failed := True; end if; end if; C := C.Common.Activation_Link; end loop; if not Single_Lock then Unlock_RTS; end if; -- Close the entries of any tasks that failed thread creation, and count -- those that have not finished activation. Write_Lock (Self_ID); Self_ID.Common.State := Activator_Sleep; C := Chain_Access.T_ID; while C /= null loop Write_Lock (C); if C.Common.State = Unactivated then C.Common.Activator := null; C.Common.State := Terminated; C.Callable := False; Utilities.Cancel_Queued_Entry_Calls (C); elsif C.Common.Activator /= null then Self_ID.Common.Wait_Count := Self_ID.Common.Wait_Count + 1; end if; Unlock (C); P := C.Common.Activation_Link; C.Common.Activation_Link := null; C := P; end loop; -- Wait for the activated tasks to complete activation. It is -- unsafe to abort any of these tasks until the count goes to zero. loop exit when Self_ID.Common.Wait_Count = 0; Sleep (Self_ID, Activator_Sleep); end loop; Self_ID.Common.State := Runnable; Unlock (Self_ID); if Single_Lock then Unlock_RTS; end if; -- Remove the tasks from the chain Chain_Access.T_ID := null; Initialization.Undefer_Abort_Nestable (Self_ID); if Self_ID.Common.Activation_Failed then Self_ID.Common.Activation_Failed := False; raise Tasking_Error with "Failure during activation"; end if; end Activate_Tasks; ------------------------- -- Complete_Activation -- ------------------------- procedure Complete_Activation is Self_ID : constant Task_Id := STPO.Self; begin Initialization.Defer_Abort_Nestable (Self_ID); if Single_Lock then Lock_RTS; end if; Vulnerable_Complete_Activation (Self_ID); if Single_Lock then Unlock_RTS; end if; Initialization.Undefer_Abort_Nestable (Self_ID); -- ??? Why do we need to allow for nested deferral here? if Runtime_Traces then Send_Trace_Info (T_Activate); end if; end Complete_Activation; --------------------- -- Complete_Master -- --------------------- procedure Complete_Master is Self_ID : constant Task_Id := STPO.Self; begin pragma Assert (Self_ID.Deferral_Level > 0 or else not System.Restrictions.Abort_Allowed); Vulnerable_Complete_Master (Self_ID); end Complete_Master; ------------------- -- Complete_Task -- ------------------- -- See comments on Vulnerable_Complete_Task for details procedure Complete_Task is Self_ID : constant Task_Id := STPO.Self; begin pragma Assert (Self_ID.Deferral_Level > 0 or else not System.Restrictions.Abort_Allowed); Vulnerable_Complete_Task (Self_ID); -- All of our dependents have terminated, never undefer abort again end Complete_Task; ----------------- -- Create_Task -- ----------------- -- Compiler interface only. Do not call from within the RTS. This must be -- called to create a new task. procedure Create_Task (Priority : Integer; Size : System.Parameters.Size_Type; Secondary_Stack_Size : System.Parameters.Size_Type; Task_Info : System.Task_Info.Task_Info_Type; CPU : Integer; Relative_Deadline : Ada.Real_Time.Time_Span; Domain : Dispatching_Domain_Access; Num_Entries : Task_Entry_Index; Master : Master_Level; State : Task_Procedure_Access; Discriminants : System.Address; Elaborated : Access_Boolean; Chain : in out Activation_Chain; Task_Image : String; Created_Task : out Task_Id) is T, P : Task_Id; Self_ID : constant Task_Id := STPO.Self; Success : Boolean; Base_Priority : System.Any_Priority; Len : Natural; Base_CPU : System.Multiprocessors.CPU_Range; use type System.Multiprocessors.CPU_Range; pragma Unreferenced (Relative_Deadline); -- EDF scheduling is not supported by any of the target platforms so -- this parameter is not passed any further. begin -- If Master is greater than the current master, it means that Master -- has already awaited its dependent tasks. This raises Program_Error, -- by 4.8(10.3/2). See AI-280. Ignore this check for foreign threads. if Self_ID.Master_of_Task /= Foreign_Task_Level and then Master > Self_ID.Master_Within then raise Program_Error with "create task after awaiting termination"; end if; -- If pragma Detect_Blocking is active must be checked whether this -- potentially blocking operation is called from a protected action. if System.Tasking.Detect_Blocking and then Self_ID.Common.Protected_Action_Nesting > 0 then raise Program_Error with "potentially blocking operation"; end if; pragma Debug (Debug.Trace (Self_ID, "Create_Task", 'C')); Base_Priority := (if Priority = Unspecified_Priority then Self_ID.Common.Base_Priority else System.Any_Priority (Priority)); -- Legal values of CPU are the special Unspecified_CPU value which is -- inserted by the compiler for tasks without CPU aspect, and those in -- the range of CPU_Range but no greater than Number_Of_CPUs. Otherwise -- the task is defined to have failed, and it becomes a completed task -- (RM D.16(14/3)). if CPU /= Unspecified_CPU and then (CPU < Integer (System.Multiprocessors.CPU_Range'First) or else CPU > Integer (System.Multiprocessors.Number_Of_CPUs)) then raise Tasking_Error with "CPU not in range"; -- Normal CPU affinity else -- When the application code says nothing about the task affinity -- (task without CPU aspect) then the compiler inserts the value -- Unspecified_CPU which indicates to the run-time library that -- the task will activate and execute on the same processor as its -- activating task if the activating task is assigned a processor -- (RM D.16(14/3)). Base_CPU := (if CPU = Unspecified_CPU then Self_ID.Common.Base_CPU else System.Multiprocessors.CPU_Range (CPU)); end if; -- Find parent P of new Task, via master level number. Independent -- tasks should have Parent = Environment_Task, and all tasks created -- by independent tasks are also independent. See, for example, -- s-interr.adb, where Interrupt_Manager does "new Server_Task". The -- access type is at library level, so the parent of the Server_Task -- is Environment_Task. P := Self_ID; if P.Master_of_Task <= Independent_Task_Level then P := Environment_Task; else while P /= null and then P.Master_of_Task >= Master loop P := P.Common.Parent; end loop; end if; Initialization.Defer_Abort_Nestable (Self_ID); begin T := New_ATCB (Num_Entries); exception when others => Initialization.Undefer_Abort_Nestable (Self_ID); raise Storage_Error with "Cannot allocate task"; end; -- RTS_Lock is used by Abort_Dependents and Abort_Tasks. Up to this -- point, it is possible that we may be part of a family of tasks that -- is being aborted. Lock_RTS; Write_Lock (Self_ID); -- Now, we must check that we have not been aborted. If so, we should -- give up on creating this task, and simply return. if not Self_ID.Callable then pragma Assert (Self_ID.Pending_ATC_Level = 0); pragma Assert (Self_ID.Pending_Action); pragma Assert (Chain.T_ID = null or else Chain.T_ID.Common.State = Unactivated); Unlock (Self_ID); Unlock_RTS; Initialization.Undefer_Abort_Nestable (Self_ID); -- ??? Should never get here pragma Assert (False); raise Standard'Abort_Signal; end if; Initialize_ATCB (Self_ID, State, Discriminants, P, Elaborated, Base_Priority, Base_CPU, Domain, Task_Info, Size, Secondary_Stack_Size, T, Success); if not Success then Free (T); Unlock (Self_ID); Unlock_RTS; Initialization.Undefer_Abort_Nestable (Self_ID); raise Storage_Error with "Failed to initialize task"; end if; if Master = Foreign_Task_Level + 2 then -- This should not happen, except when a foreign task creates non -- library-level Ada tasks. In this case, we pretend the master is -- a regular library level task, otherwise the run-time will get -- confused when waiting for these tasks to terminate. T.Master_of_Task := Library_Task_Level; else T.Master_of_Task := Master; end if; T.Master_Within := T.Master_of_Task + 1; for L in T.Entry_Calls'Range loop T.Entry_Calls (L).Self := T; T.Entry_Calls (L).Level := L; end loop; if Task_Image'Length = 0 then T.Common.Task_Image_Len := 0; else Len := 1; T.Common.Task_Image (1) := Task_Image (Task_Image'First); -- Remove unwanted blank space generated by 'Image for J in Task_Image'First + 1 .. Task_Image'Last loop if Task_Image (J) /= ' ' or else Task_Image (J - 1) /= '(' then Len := Len + 1; T.Common.Task_Image (Len) := Task_Image (J); exit when Len = T.Common.Task_Image'Last; end if; end loop; T.Common.Task_Image_Len := Len; end if; -- Note: we used to have code here to initialize T.Commmon.Domain, but -- that is not needed, since this is initialized in System.Tasking. Unlock (Self_ID); Unlock_RTS; -- The CPU associated to the task (if any) must belong to the -- dispatching domain. if Base_CPU /= System.Multiprocessors.Not_A_Specific_CPU and then (Base_CPU not in T.Common.Domain'Range or else not T.Common.Domain (Base_CPU)) then Initialization.Undefer_Abort_Nestable (Self_ID); raise Tasking_Error with "CPU not in dispatching domain"; end if; -- To handle the interaction between pragma CPU and dispatching domains -- we need to signal that this task is being allocated to a processor. -- This is needed only for tasks belonging to the system domain (the -- creation of new dispatching domains can only take processors from the -- system domain) and only before the environment task calls the main -- procedure (dispatching domains cannot be created after this). if Base_CPU /= System.Multiprocessors.Not_A_Specific_CPU and then T.Common.Domain = System.Tasking.System_Domain and then not System.Tasking.Dispatching_Domains_Frozen then -- Increase the number of tasks attached to the CPU to which this -- task is being moved. Dispatching_Domain_Tasks (Base_CPU) := Dispatching_Domain_Tasks (Base_CPU) + 1; end if; -- Create TSD as early as possible in the creation of a task, since it -- may be used by the operation of Ada code within the task. SSL.Create_TSD (T.Common.Compiler_Data); T.Common.Activation_Link := Chain.T_ID; Chain.T_ID := T; Created_Task := T; Initialization.Undefer_Abort_Nestable (Self_ID); if Runtime_Traces then Send_Trace_Info (T_Create, T); end if; pragma Debug (Debug.Trace (Self_ID, "Created task in " & T.Master_of_Task'Img, 'C', T)); end Create_Task; -------------------- -- Current_Master -- -------------------- function Current_Master return Master_Level is begin return STPO.Self.Master_Within; end Current_Master; ------------------ -- Enter_Master -- ------------------ procedure Enter_Master is Self_ID : constant Task_Id := STPO.Self; begin Self_ID.Master_Within := Self_ID.Master_Within + 1; pragma Debug (Debug.Trace (Self_ID, "Enter_Master ->" & Self_ID.Master_Within'Img, 'M')); end Enter_Master; ------------------------------- -- Expunge_Unactivated_Tasks -- ------------------------------- -- See procedure Close_Entries for the general case procedure Expunge_Unactivated_Tasks (Chain : in out Activation_Chain) is Self_ID : constant Task_Id := STPO.Self; C : Task_Id; Call : Entry_Call_Link; Temp : Task_Id; begin pragma Debug (Debug.Trace (Self_ID, "Expunge_Unactivated_Tasks", 'C')); Initialization.Defer_Abort_Nestable (Self_ID); -- ??? -- Experimentation has shown that abort is sometimes (but not always) -- already deferred when this is called. -- That may indicate an error. Find out what is going on C := Chain.T_ID; while C /= null loop pragma Assert (C.Common.State = Unactivated); Temp := C.Common.Activation_Link; if C.Common.State = Unactivated then Lock_RTS; Write_Lock (C); for J in 1 .. C.Entry_Num loop Queuing.Dequeue_Head (C.Entry_Queues (J), Call); pragma Assert (Call = null); end loop; Unlock (C); Initialization.Remove_From_All_Tasks_List (C); Unlock_RTS; Vulnerable_Free_Task (C); C := Temp; end if; end loop; Chain.T_ID := null; Initialization.Undefer_Abort_Nestable (Self_ID); end Expunge_Unactivated_Tasks; --------------------------- -- Finalize_Global_Tasks -- --------------------------- -- ??? -- We have a potential problem here if finalization of global objects does -- anything with signals or the timer server, since by that time those -- servers have terminated. -- It is hard to see how that would occur -- However, a better solution might be to do all this finalization -- using the global finalization chain. procedure Finalize_Global_Tasks is Self_ID : constant Task_Id := STPO.Self; Ignore_1 : Boolean; Ignore_2 : Boolean; function State (Int : System.Interrupt_Management.Interrupt_ID) return Character; pragma Import (C, State, "__gnat_get_interrupt_state"); -- Get interrupt state for interrupt number Int. Defined in init.c Default : constant Character := 's'; -- 's' Interrupt_State pragma set state to System (use "default" -- system handler) begin if Self_ID.Deferral_Level = 0 then -- ??? -- In principle, we should be able to predict whether abort is -- already deferred here (and it should not be deferred yet but in -- practice it seems Finalize_Global_Tasks is being called sometimes, -- from RTS code for exceptions, with abort already deferred. Initialization.Defer_Abort_Nestable (Self_ID); -- Never undefer again end if; -- This code is only executed by the environment task pragma Assert (Self_ID = Environment_Task); -- Set Environment_Task'Callable to false to notify library-level tasks -- that it is waiting for them. Self_ID.Callable := False; -- Exit level 2 master, for normal tasks in library-level packages Complete_Master; -- Force termination of "independent" library-level server tasks Lock_RTS; Abort_Dependents (Self_ID); if not Single_Lock then Unlock_RTS; end if; -- We need to explicitly wait for the task to be terminated here -- because on true concurrent system, we may end this procedure before -- the tasks are really terminated. Write_Lock (Self_ID); -- If the Abort_Task signal is set to system, it means that we may -- not have been able to abort all independent tasks (in particular, -- Server_Task may be blocked, waiting for a signal), in which case, do -- not wait for Independent_Task_Count to go down to 0. We arbitrarily -- limit the number of loop iterations; if an independent task does not -- terminate, we do not want to hang here. In that case, the thread will -- be terminated when the process exits. if State (System.Interrupt_Management.Abort_Task_Interrupt) /= Default then for J in 1 .. 10 loop exit when Utilities.Independent_Task_Count = 0; -- We used to yield here, but this did not take into account low -- priority tasks that would cause dead lock in some cases (true -- FIFO scheduling). Timed_Sleep (Self_ID, 0.01, System.OS_Primitives.Relative, Self_ID.Common.State, Ignore_1, Ignore_2); end loop; end if; -- ??? On multi-processor environments, it seems that the above loop -- isn't sufficient, so we need to add an additional delay. Timed_Sleep (Self_ID, 0.01, System.OS_Primitives.Relative, Self_ID.Common.State, Ignore_1, Ignore_2); Unlock (Self_ID); if Single_Lock then Unlock_RTS; end if; -- Complete the environment task Vulnerable_Complete_Task (Self_ID); -- Handle normal task termination by the environment task, but only -- for the normal task termination. In the case of Abnormal and -- Unhandled_Exception they must have been handled before, and the -- task termination soft link must have been changed so the task -- termination routine is not executed twice. SSL.Task_Termination_Handler.all (Ada.Exceptions.Null_Occurrence); -- Finalize all library-level controlled objects if not SSL."=" (SSL.Finalize_Library_Objects, null) then SSL.Finalize_Library_Objects.all; end if; -- Reset the soft links to non-tasking SSL.Abort_Defer := SSL.Abort_Defer_NT'Access; SSL.Abort_Undefer := SSL.Abort_Undefer_NT'Access; SSL.Lock_Task := SSL.Task_Lock_NT'Access; SSL.Unlock_Task := SSL.Task_Unlock_NT'Access; SSL.Get_Jmpbuf_Address := SSL.Get_Jmpbuf_Address_NT'Access; SSL.Set_Jmpbuf_Address := SSL.Set_Jmpbuf_Address_NT'Access; SSL.Get_Sec_Stack_Addr := SSL.Get_Sec_Stack_Addr_NT'Access; SSL.Set_Sec_Stack_Addr := SSL.Set_Sec_Stack_Addr_NT'Access; SSL.Check_Abort_Status := SSL.Check_Abort_Status_NT'Access; SSL.Get_Stack_Info := SSL.Get_Stack_Info_NT'Access; -- Don't bother trying to finalize Initialization.Global_Task_Lock -- and System.Task_Primitives.RTS_Lock. end Finalize_Global_Tasks; --------------- -- Free_Task -- --------------- procedure Free_Task (T : Task_Id) is Self_Id : constant Task_Id := Self; begin if T.Common.State = Terminated then -- It is not safe to call Abort_Defer or Write_Lock at this stage Initialization.Task_Lock (Self_Id); Lock_RTS; Initialization.Finalize_Attributes (T); Initialization.Remove_From_All_Tasks_List (T); Unlock_RTS; Initialization.Task_Unlock (Self_Id); System.Task_Primitives.Operations.Finalize_TCB (T); else -- If the task is not terminated, then mark the task as to be freed -- upon termination. T.Free_On_Termination := True; end if; end Free_Task; --------------------------- -- Move_Activation_Chain -- --------------------------- procedure Move_Activation_Chain (From, To : Activation_Chain_Access; New_Master : Master_ID) is Self_ID : constant Task_Id := STPO.Self; C : Task_Id; begin pragma Debug (Debug.Trace (Self_ID, "Move_Activation_Chain", 'C')); -- Nothing to do if From is empty, and we can check that without -- deferring aborts. C := From.all.T_ID; if C = null then return; end if; Initialization.Defer_Abort_Nestable (Self_ID); -- Loop through the From chain, changing their Master_of_Task fields, -- and to find the end of the chain. loop C.Master_of_Task := New_Master; exit when C.Common.Activation_Link = null; C := C.Common.Activation_Link; end loop; -- Hook From in at the start of To C.Common.Activation_Link := To.all.T_ID; To.all.T_ID := From.all.T_ID; -- Set From to empty From.all.T_ID := null; Initialization.Undefer_Abort_Nestable (Self_ID); end Move_Activation_Chain; ------------------ -- Task_Wrapper -- ------------------ -- The task wrapper is a procedure that is called first for each task body -- and which in turn calls the compiler-generated task body procedure. -- The wrapper's main job is to do initialization for the task. It also -- has some locally declared objects that serve as per-task local data. -- Task finalization is done by Complete_Task, which is called from an -- at-end handler that the compiler generates. procedure Task_Wrapper (Self_ID : Task_Id) is use type SSE.Storage_Offset; use System.Standard_Library; use System.Stack_Usage; Bottom_Of_Stack : aliased Integer; Task_Alternate_Stack : aliased SSE.Storage_Array (1 .. Alternate_Stack_Size); -- The alternate signal stack for this task, if any Use_Alternate_Stack : constant Boolean := Alternate_Stack_Size /= 0; -- Whether to use above alternate signal stack for stack overflows function Secondary_Stack_Size return Storage_Elements.Storage_Offset; -- Returns the size of the secondary stack for the task. For fixed -- secondary stacks, the function will return the ATCB field -- Secondary_Stack_Size if it is not set to Unspecified_Size, -- otherwise a percentage of the stack is reserved using the -- System.Parameters.Sec_Stack_Percentage property. -- Dynamic secondary stacks are allocated in System.Soft_Links. -- Create_TSD and thus the function returns 0 to suppress the -- creation of the fixed secondary stack in the primary stack. -------------------------- -- Secondary_Stack_Size -- -------------------------- function Secondary_Stack_Size return Storage_Elements.Storage_Offset is use System.Storage_Elements; use System.Secondary_Stack; begin if Parameters.Sec_Stack_Dynamic then return 0; elsif Self_ID.Common.Secondary_Stack_Size = Unspecified_Size then return (Self_ID.Common.Compiler_Data.Pri_Stack_Info.Size * SSE.Storage_Offset (Sec_Stack_Percentage) / 100); else -- Use the size specified by aspect Secondary_Stack_Size padded -- by the amount of space used by the stack data structure. return Storage_Offset (Self_ID.Common.Secondary_Stack_Size) + Storage_Offset (SST.Minimum_Secondary_Stack_Size); end if; end Secondary_Stack_Size; Secondary_Stack : aliased Storage_Elements.Storage_Array (1 .. Secondary_Stack_Size); for Secondary_Stack'Alignment use Standard'Maximum_Alignment; -- Actual area allocated for secondary stack. Note that it is critical -- that this have maximum alignment, since any kind of data can be -- allocated here. Secondary_Stack_Address : System.Address := Secondary_Stack'Address; -- Address of secondary stack. In the fixed secondary stack case, this -- value is not modified, causing a warning, hence the bracketing with -- Warnings (Off/On). But why is so much *more* bracketed??? SEH_Table : aliased SSE.Storage_Array (1 .. 8); -- Structured Exception Registration table (2 words) procedure Install_SEH_Handler (Addr : System.Address); pragma Import (C, Install_SEH_Handler, "__gnat_install_SEH_handler"); -- Install the SEH (Structured Exception Handling) handler Cause : Cause_Of_Termination := Normal; -- Indicates the reason why this task terminates. Normal corresponds to -- a task terminating due to completing the last statement of its body, -- or as a result of waiting on a terminate alternative. If the task -- terminates because it is being aborted then Cause will be set -- to Abnormal. If the task terminates because of an exception -- raised by the execution of its task body, then Cause is set -- to Unhandled_Exception. EO : Exception_Occurrence; -- If the task terminates because of an exception raised by the -- execution of its task body, then EO will contain the associated -- exception occurrence. Otherwise, it will contain Null_Occurrence. TH : Termination_Handler := null; -- Pointer to the protected procedure to be executed upon task -- termination. procedure Search_Fall_Back_Handler (ID : Task_Id); -- Procedure that searches recursively a fall-back handler through the -- master relationship. If the handler is found, its pointer is stored -- in TH. It stops when the handler is found or when the ID is null. ------------------------------ -- Search_Fall_Back_Handler -- ------------------------------ procedure Search_Fall_Back_Handler (ID : Task_Id) is begin -- A null Task_Id indicates that we have reached the root of the -- task hierarchy and no handler has been found. if ID = null then return; -- If there is a fall back handler, store its pointer for later -- execution. elsif ID.Common.Fall_Back_Handler /= null then TH := ID.Common.Fall_Back_Handler; -- Otherwise look for a fall back handler in the parent else Search_Fall_Back_Handler (ID.Common.Parent); end if; end Search_Fall_Back_Handler; -- Start of processing for Task_Wrapper begin pragma Assert (Self_ID.Deferral_Level = 1); Debug.Master_Hook (Self_ID, Self_ID.Common.Parent, Self_ID.Master_of_Task); -- Assume a size of the stack taken at this stage if not Parameters.Sec_Stack_Dynamic then Self_ID.Common.Compiler_Data.Sec_Stack_Addr := Secondary_Stack'Address; SST.SS_Init (Secondary_Stack_Address, Integer (Secondary_Stack'Last)); end if; if Use_Alternate_Stack then Self_ID.Common.Task_Alternate_Stack := Task_Alternate_Stack'Address; end if; -- Set the guard page at the bottom of the stack. The call to unprotect -- the page is done in Terminate_Task Stack_Guard (Self_ID, True); -- Initialize low-level TCB components, that cannot be initialized by -- the creator. Enter_Task sets Self_ID.LL.Thread. Enter_Task (Self_ID); -- Initialize dynamic stack usage if System.Stack_Usage.Is_Enabled then declare Guard_Page_Size : constant := 16 * 1024; -- Part of the stack used as a guard page. This is an OS dependent -- value, so we need to use the maximum. This value is only used -- when the stack address is known, that is currently Windows. Small_Overflow_Guard : constant := 12 * 1024; -- Note: this used to be 4K, but was changed to 12K, since -- smaller values resulted in segmentation faults from dynamic -- stack analysis. Big_Overflow_Guard : constant := 64 * 1024 + 8 * 1024; Small_Stack_Limit : constant := 64 * 1024; -- ??? These three values are experimental, and seem to work on -- most platforms. They still need to be analyzed further. They -- also need documentation, what are they and why does the logic -- differ depending on whether the stack is large or small??? Pattern_Size : Natural := Natural (Self_ID.Common. Compiler_Data.Pri_Stack_Info.Size); -- Size of the pattern Stack_Base : Address; -- Address of the base of the stack begin Stack_Base := Self_ID.Common.Compiler_Data.Pri_Stack_Info.Base; if Stack_Base = Null_Address then -- On many platforms, we don't know the real stack base -- address. Estimate it using an address in the frame. Stack_Base := Bottom_Of_Stack'Address; -- Also reduce the size of the stack to take into account the -- secondary stack array declared in this frame. This is for -- sure very conservative. if not Parameters.Sec_Stack_Dynamic then Pattern_Size := Pattern_Size - Natural (Secondary_Stack_Size); end if; -- Adjustments for inner frames Pattern_Size := Pattern_Size - (if Pattern_Size < Small_Stack_Limit then Small_Overflow_Guard else Big_Overflow_Guard); else -- Reduce by the size of the final guard page Pattern_Size := Pattern_Size - Guard_Page_Size; end if; STPO.Lock_RTS; Initialize_Analyzer (Self_ID.Common.Analyzer, Self_ID.Common.Task_Image (1 .. Self_ID.Common.Task_Image_Len), Natural (Self_ID.Common.Compiler_Data.Pri_Stack_Info.Size), SSE.To_Integer (Stack_Base), Pattern_Size); STPO.Unlock_RTS; Fill_Stack (Self_ID.Common.Analyzer); end; end if; -- We setup the SEH (Structured Exception Handling) handler if supported -- on the target. Install_SEH_Handler (SEH_Table'Address); -- Initialize exception occurrence Save_Occurrence (EO, Ada.Exceptions.Null_Occurrence); -- We lock RTS_Lock to wait for activator to finish activating the rest -- of the chain, so that everyone in the chain comes out in priority -- order. -- This also protects the value of -- Self_ID.Common.Activator.Common.Wait_Count. Lock_RTS; Unlock_RTS; if not System.Restrictions.Abort_Allowed then -- If Abort is not allowed, reset the deferral level since it will -- not get changed by the generated code. Keeping a default value -- of one would prevent some operations (e.g. select or delay) to -- proceed successfully. Self_ID.Deferral_Level := 0; end if; if Global_Task_Debug_Event_Set then Debug.Signal_Debug_Event (Debug.Debug_Event_Run, Self_ID); end if; begin -- We are separating the following portion of the code in order to -- place the exception handlers in a different block. In this way, -- we do not call Set_Jmpbuf_Address (which needs Self) before we -- set Self in Enter_Task -- Call the task body procedure -- The task body is called with abort still deferred. That -- eliminates a dangerous window, for which we had to patch-up in -- Terminate_Task. -- During the expansion of the task body, we insert an RTS-call -- to Abort_Undefer, at the first point where abort should be -- allowed. Self_ID.Common.Task_Entry_Point (Self_ID.Common.Task_Arg); Initialization.Defer_Abort_Nestable (Self_ID); exception -- We can't call Terminate_Task in the exception handlers below, -- since there may be (e.g. in the case of GCC exception handling) -- clean ups associated with the exception handler that need to -- access task specific data. -- Defer abort so that this task can't be aborted while exiting when Standard'Abort_Signal => Initialization.Defer_Abort_Nestable (Self_ID); -- Update the cause that motivated the task termination so that -- the appropriate information is passed to the task termination -- procedure. Task termination as a result of waiting on a -- terminate alternative is a normal termination, although it is -- implemented using the abort mechanisms. if Self_ID.Terminate_Alternative then Cause := Normal; if Global_Task_Debug_Event_Set then Debug.Signal_Debug_Event (Debug.Debug_Event_Terminated, Self_ID); end if; else Cause := Abnormal; if Global_Task_Debug_Event_Set then Debug.Signal_Debug_Event (Debug.Debug_Event_Abort_Terminated, Self_ID); end if; end if; when others => -- ??? Using an E : others here causes CD2C11A to fail on Tru64 Initialization.Defer_Abort_Nestable (Self_ID); -- Perform the task specific exception tracing duty. We handle -- these outputs here and not in the common notification routine -- because we need access to tasking related data and we don't -- want to drag dependencies against tasking related units in the -- the common notification units. Additionally, no trace is ever -- triggered from the common routine for the Unhandled_Raise case -- in tasks, since an exception never appears unhandled in this -- context because of this handler. if Exception_Trace = Unhandled_Raise then Trace_Unhandled_Exception_In_Task (Self_ID); end if; -- Update the cause that motivated the task termination so that -- the appropriate information is passed to the task termination -- procedure, as well as the associated Exception_Occurrence. Cause := Unhandled_Exception; Save_Occurrence (EO, SSL.Get_Current_Excep.all.all); if Global_Task_Debug_Event_Set then Debug.Signal_Debug_Event (Debug.Debug_Event_Exception_Terminated, Self_ID); end if; end; -- Look for a task termination handler. This code is for all tasks but -- the environment task. The task termination code for the environment -- task is executed by SSL.Task_Termination_Handler. if Single_Lock then Lock_RTS; end if; Write_Lock (Self_ID); if Self_ID.Common.Specific_Handler /= null then TH := Self_ID.Common.Specific_Handler; -- Independent tasks should not call the Fall_Back_Handler (of the -- environment task), because they are implementation artifacts that -- should be invisible to Ada programs. elsif Self_ID.Master_of_Task /= Independent_Task_Level then -- Look for a fall-back handler following the master relationship -- for the task. As specified in ARM C.7.3 par. 9/2, "the fall-back -- handler applies only to the dependent tasks of the task". Hence, -- if the terminating tasks (Self_ID) had a fall-back handler, it -- would not apply to itself, so we start the search with the parent. Search_Fall_Back_Handler (Self_ID.Common.Parent); end if; Unlock (Self_ID); if Single_Lock then Unlock_RTS; end if; -- Execute the task termination handler if we found it if TH /= null then begin TH.all (Cause, Self_ID, EO); exception -- RM-C.7.3 requires all exceptions raised here to be ignored when others => null; end; end if; if System.Stack_Usage.Is_Enabled then Compute_Result (Self_ID.Common.Analyzer); Report_Result (Self_ID.Common.Analyzer); end if; Terminate_Task (Self_ID); end Task_Wrapper; -------------------- -- Terminate_Task -- -------------------- -- Before we allow the thread to exit, we must clean up. This is a delicate -- job. We must wake up the task's master, who may immediately try to -- deallocate the ATCB from the current task WHILE IT IS STILL EXECUTING. -- To avoid this, the parent task must be blocked up to the latest -- statement executed. The trouble is that we have another step that we -- also want to postpone to the very end, i.e., calling SSL.Destroy_TSD. -- We have to postpone that until the end because compiler-generated code -- is likely to try to access that data at just about any point. -- We can't call Destroy_TSD while we are holding any other locks, because -- it locks Global_Task_Lock, and our deadlock prevention rules require -- that to be the outermost lock. Our first "solution" was to just lock -- Global_Task_Lock in addition to the other locks, and force the parent to -- also lock this lock between its wakeup and its freeing of the ATCB. See -- Complete_Task for the parent-side of the code that has the matching -- calls to Task_Lock and Task_Unlock. That was not really a solution, -- since the operation Task_Unlock continued to access the ATCB after -- unlocking, after which the parent was observed to race ahead, deallocate -- the ATCB, and then reallocate it to another task. The call to -- Undefer_Abort in Task_Unlock by the "terminated" task was overwriting -- the data of the new task that reused the ATCB. To solve this problem, we -- introduced the new operation Final_Task_Unlock. procedure Terminate_Task (Self_ID : Task_Id) is Environment_Task : constant Task_Id := STPO.Environment_Task; Master_of_Task : Integer; Deallocate : Boolean; begin Debug.Task_Termination_Hook; if Runtime_Traces then Send_Trace_Info (T_Terminate); end if; -- Since GCC cannot allocate stack chunks efficiently without reordering -- some of the allocations, we have to handle this unexpected situation -- here. Normally we never have to call Vulnerable_Complete_Task here. if Self_ID.Common.Activator /= null then Vulnerable_Complete_Task (Self_ID); end if; Initialization.Task_Lock (Self_ID); if Single_Lock then Lock_RTS; end if; Master_of_Task := Self_ID.Master_of_Task; -- Check if the current task is an independent task If so, decrement -- the Independent_Task_Count value. if Master_of_Task = Independent_Task_Level then if Single_Lock then Utilities.Independent_Task_Count := Utilities.Independent_Task_Count - 1; else Write_Lock (Environment_Task); Utilities.Independent_Task_Count := Utilities.Independent_Task_Count - 1; Unlock (Environment_Task); end if; end if; -- Unprotect the guard page if needed Stack_Guard (Self_ID, False); Utilities.Make_Passive (Self_ID, Task_Completed => True); Deallocate := Self_ID.Free_On_Termination; if Single_Lock then Unlock_RTS; end if; pragma Assert (Check_Exit (Self_ID)); SSL.Destroy_TSD (Self_ID.Common.Compiler_Data); Initialization.Final_Task_Unlock (Self_ID); -- WARNING: past this point, this thread must assume that the ATCB has -- been deallocated, and can't access it anymore (which is why we have -- saved the Free_On_Termination flag in a temporary variable). if Deallocate then Free_Task (Self_ID); end if; if Master_of_Task > 0 then STPO.Exit_Task; end if; end Terminate_Task; ---------------- -- Terminated -- ---------------- function Terminated (T : Task_Id) return Boolean is Self_ID : constant Task_Id := STPO.Self; Result : Boolean; begin Initialization.Defer_Abort_Nestable (Self_ID); if Single_Lock then Lock_RTS; end if; Write_Lock (T); Result := T.Common.State = Terminated; Unlock (T); if Single_Lock then Unlock_RTS; end if; Initialization.Undefer_Abort_Nestable (Self_ID); return Result; end Terminated; ---------------------------------------- -- Trace_Unhandled_Exception_In_Task -- ---------------------------------------- procedure Trace_Unhandled_Exception_In_Task (Self_Id : Task_Id) is procedure To_Stderr (S : String); pragma Import (Ada, To_Stderr, "__gnat_to_stderr"); use System.Soft_Links; use System.Standard_Library; function To_Address is new Ada.Unchecked_Conversion (Task_Id, System.Task_Primitives.Task_Address); Excep : constant Exception_Occurrence_Access := SSL.Get_Current_Excep.all; begin -- This procedure is called by the task outermost handler in -- Task_Wrapper below, so only once the task stack has been fully -- unwound. The common notification routine has been called at the -- raise point already. -- Lock to prevent unsynchronized output Initialization.Task_Lock (Self_Id); To_Stderr ("task "); if Self_Id.Common.Task_Image_Len /= 0 then To_Stderr (Self_Id.Common.Task_Image (1 .. Self_Id.Common.Task_Image_Len)); To_Stderr ("_"); end if; To_Stderr (System.Address_Image (To_Address (Self_Id))); To_Stderr (" terminated by unhandled exception"); To_Stderr ((1 => ASCII.LF)); To_Stderr (Exception_Information (Excep.all)); Initialization.Task_Unlock (Self_Id); end Trace_Unhandled_Exception_In_Task; ------------------------------------ -- Vulnerable_Complete_Activation -- ------------------------------------ -- As in several other places, the locks of the activator and activated -- task are both locked here. This follows our deadlock prevention lock -- ordering policy, since the activated task must be created after the -- activator. procedure Vulnerable_Complete_Activation (Self_ID : Task_Id) is Activator : constant Task_Id := Self_ID.Common.Activator; begin pragma Debug (Debug.Trace (Self_ID, "V_Complete_Activation", 'C')); Write_Lock (Activator); Write_Lock (Self_ID); pragma Assert (Self_ID.Common.Activator /= null); -- Remove dangling reference to Activator, since a task may outlive its -- activator. Self_ID.Common.Activator := null; -- Wake up the activator, if it is waiting for a chain of tasks to -- activate, and we are the last in the chain to complete activation. if Activator.Common.State = Activator_Sleep then Activator.Common.Wait_Count := Activator.Common.Wait_Count - 1; if Activator.Common.Wait_Count = 0 then Wakeup (Activator, Activator_Sleep); end if; end if; -- The activator raises a Tasking_Error if any task it is activating -- is completed before the activation is done. However, if the reason -- for the task completion is an abort, we do not raise an exception. -- See RM 9.2(5). if not Self_ID.Callable and then Self_ID.Pending_ATC_Level /= 0 then Activator.Common.Activation_Failed := True; end if; Unlock (Self_ID); Unlock (Activator); -- After the activation, active priority should be the same as base -- priority. We must unlock the Activator first, though, since it -- should not wait if we have lower priority. if Get_Priority (Self_ID) /= Self_ID.Common.Base_Priority then Write_Lock (Self_ID); Set_Priority (Self_ID, Self_ID.Common.Base_Priority); Unlock (Self_ID); end if; end Vulnerable_Complete_Activation; -------------------------------- -- Vulnerable_Complete_Master -- -------------------------------- procedure Vulnerable_Complete_Master (Self_ID : Task_Id) is C : Task_Id; P : Task_Id; CM : constant Master_Level := Self_ID.Master_Within; T : aliased Task_Id; To_Be_Freed : Task_Id; -- This is a list of ATCBs to be freed, after we have released all RTS -- locks. This is necessary because of the locking order rules, since -- the storage manager uses Global_Task_Lock. pragma Warnings (Off); function Check_Unactivated_Tasks return Boolean; pragma Warnings (On); -- Temporary error-checking code below. This is part of the checks -- added in the new run time. Call it only inside a pragma Assert. ----------------------------- -- Check_Unactivated_Tasks -- ----------------------------- function Check_Unactivated_Tasks return Boolean is begin if not Single_Lock then Lock_RTS; end if; Write_Lock (Self_ID); C := All_Tasks_List; while C /= null loop if C.Common.Activator = Self_ID and then C.Master_of_Task = CM then return False; end if; if C.Common.Parent = Self_ID and then C.Master_of_Task = CM then Write_Lock (C); if C.Common.State = Unactivated then return False; end if; Unlock (C); end if; C := C.Common.All_Tasks_Link; end loop; Unlock (Self_ID); if not Single_Lock then Unlock_RTS; end if; return True; end Check_Unactivated_Tasks; -- Start of processing for Vulnerable_Complete_Master begin pragma Debug (Debug.Trace (Self_ID, "V_Complete_Master(" & CM'Img & ")", 'C')); pragma Assert (Self_ID.Common.Wait_Count = 0); pragma Assert (Self_ID.Deferral_Level > 0 or else not System.Restrictions.Abort_Allowed); -- Count how many active dependent tasks this master currently has, and -- record this in Wait_Count. -- This count should start at zero, since it is initialized to zero for -- new tasks, and the task should not exit the sleep-loops that use this -- count until the count reaches zero. -- While we're counting, if we run across any unactivated tasks that -- belong to this master, we summarily terminate them as required by -- RM-9.2(6). Lock_RTS; Write_Lock (Self_ID); C := All_Tasks_List; while C /= null loop -- Terminate unactivated (never-to-be activated) tasks if C.Common.Activator = Self_ID and then C.Master_of_Task = CM then -- Usually, C.Common.Activator = Self_ID implies C.Master_of_Task -- = CM. The only case where C is pending activation by this -- task, but the master of C is not CM is in Ada 2005, when C is -- part of a return object of a build-in-place function. pragma Assert (C.Common.State = Unactivated); Write_Lock (C); C.Common.Activator := null; C.Common.State := Terminated; C.Callable := False; Utilities.Cancel_Queued_Entry_Calls (C); Unlock (C); end if; -- Count it if directly dependent on this master if C.Common.Parent = Self_ID and then C.Master_of_Task = CM then Write_Lock (C); if C.Awake_Count /= 0 then Self_ID.Common.Wait_Count := Self_ID.Common.Wait_Count + 1; end if; Unlock (C); end if; C := C.Common.All_Tasks_Link; end loop; Self_ID.Common.State := Master_Completion_Sleep; Unlock (Self_ID); if not Single_Lock then Unlock_RTS; end if; -- Wait until dependent tasks are all terminated or ready to terminate. -- While waiting, the task may be awakened if the task's priority needs -- changing, or this master is aborted. In the latter case, we abort the -- dependents, and resume waiting until Wait_Count goes to zero. Write_Lock (Self_ID); loop exit when Self_ID.Common.Wait_Count = 0; -- Here is a difference as compared to Complete_Master if Self_ID.Pending_ATC_Level < Self_ID.ATC_Nesting_Level and then not Self_ID.Dependents_Aborted then if Single_Lock then Abort_Dependents (Self_ID); else Unlock (Self_ID); Lock_RTS; Abort_Dependents (Self_ID); Unlock_RTS; Write_Lock (Self_ID); end if; else pragma Debug (Debug.Trace (Self_ID, "master_completion_sleep", 'C')); Sleep (Self_ID, Master_Completion_Sleep); end if; end loop; Self_ID.Common.State := Runnable; Unlock (Self_ID); -- Dependents are all terminated or on terminate alternatives. Now, -- force those on terminate alternatives to terminate, by aborting them. pragma Assert (Check_Unactivated_Tasks); if Self_ID.Alive_Count > 1 then -- ??? -- Consider finding a way to skip the following extra steps if there -- are no dependents with terminate alternatives. This could be done -- by adding another count to the ATCB, similar to Awake_Count, but -- keeping track of tasks that are on terminate alternatives. pragma Assert (Self_ID.Common.Wait_Count = 0); -- Force any remaining dependents to terminate by aborting them if not Single_Lock then Lock_RTS; end if; Abort_Dependents (Self_ID); -- Above, when we "abort" the dependents we are simply using this -- operation for convenience. We are not required to support the full -- abort-statement semantics; in particular, we are not required to -- immediately cancel any queued or in-service entry calls. That is -- good, because if we tried to cancel a call we would need to lock -- the caller, in order to wake the caller up. Our anti-deadlock -- rules prevent us from doing that without releasing the locks on C -- and Self_ID. Releasing and retaking those locks would be wasteful -- at best, and should not be considered further without more -- detailed analysis of potential concurrent accesses to the ATCBs -- of C and Self_ID. -- Count how many "alive" dependent tasks this master currently has, -- and record this in Wait_Count. This count should start at zero, -- since it is initialized to zero for new tasks, and the task should -- not exit the sleep-loops that use this count until the count -- reaches zero. pragma Assert (Self_ID.Common.Wait_Count = 0); Write_Lock (Self_ID); C := All_Tasks_List; while C /= null loop if C.Common.Parent = Self_ID and then C.Master_of_Task = CM then Write_Lock (C); pragma Assert (C.Awake_Count = 0); if C.Alive_Count > 0 then pragma Assert (C.Terminate_Alternative); Self_ID.Common.Wait_Count := Self_ID.Common.Wait_Count + 1; end if; Unlock (C); end if; C := C.Common.All_Tasks_Link; end loop; Self_ID.Common.State := Master_Phase_2_Sleep; Unlock (Self_ID); if not Single_Lock then Unlock_RTS; end if; -- Wait for all counted tasks to finish terminating themselves Write_Lock (Self_ID); loop exit when Self_ID.Common.Wait_Count = 0; Sleep (Self_ID, Master_Phase_2_Sleep); end loop; Self_ID.Common.State := Runnable; Unlock (Self_ID); end if; -- We don't wake up for abort here. We are already terminating just as -- fast as we can, so there is no point. -- Remove terminated tasks from the list of Self_ID's dependents, but -- don't free their ATCBs yet, because of lock order restrictions, which -- don't allow us to call "free" or "malloc" while holding any other -- locks. Instead, we put those ATCBs to be freed onto a temporary list, -- called To_Be_Freed. if not Single_Lock then Lock_RTS; end if; C := All_Tasks_List; P := null; while C /= null loop -- If Free_On_Termination is set, do nothing here, and let the -- task free itself if not already done, otherwise we risk a race -- condition where Vulnerable_Free_Task is called in the loop below, -- while the task calls Free_Task itself, in Terminate_Task. if C.Common.Parent = Self_ID and then C.Master_of_Task >= CM and then not C.Free_On_Termination then if P /= null then P.Common.All_Tasks_Link := C.Common.All_Tasks_Link; else All_Tasks_List := C.Common.All_Tasks_Link; end if; T := C.Common.All_Tasks_Link; C.Common.All_Tasks_Link := To_Be_Freed; To_Be_Freed := C; C := T; else P := C; C := C.Common.All_Tasks_Link; end if; end loop; Unlock_RTS; -- Free all the ATCBs on the list To_Be_Freed -- The ATCBs in the list are no longer in All_Tasks_List, and after -- any interrupt entries are detached from them they should no longer -- be referenced. -- Global_Task_Lock (Task_Lock/Unlock) is locked in the loop below to -- avoid a race between a terminating task and its parent. The parent -- might try to deallocate the ACTB out from underneath the exiting -- task. Note that Free will also lock Global_Task_Lock, but that is -- OK, since this is the *one* lock for which we have a mechanism to -- support nested locking. See Task_Wrapper and its finalizer for more -- explanation. -- ??? -- The check "T.Common.Parent /= null ..." below is to prevent dangling -- references to terminated library-level tasks, which could otherwise -- occur during finalization of library-level objects. A better solution -- might be to hook task objects into the finalization chain and -- deallocate the ATCB when the task object is deallocated. However, -- this change is not likely to gain anything significant, since all -- this storage should be recovered en-masse when the process exits. while To_Be_Freed /= null loop T := To_Be_Freed; To_Be_Freed := T.Common.All_Tasks_Link; -- ??? On SGI there is currently no Interrupt_Manager, that's why we -- need to check if the Interrupt_Manager_ID is null. if T.Interrupt_Entry and then Interrupt_Manager_ID /= null then declare Detach_Interrupt_Entries_Index : constant Task_Entry_Index := 1; -- Corresponds to the entry index of System.Interrupts. -- Interrupt_Manager.Detach_Interrupt_Entries. Be sure -- to update this value when changing Interrupt_Manager specs. type Param_Type is access all Task_Id; Param : aliased Param_Type := T'Access; begin System.Tasking.Rendezvous.Call_Simple (Interrupt_Manager_ID, Detach_Interrupt_Entries_Index, Param'Address); end; end if; if (T.Common.Parent /= null and then T.Common.Parent.Common.Parent /= null) or else T.Master_of_Task > Library_Task_Level then Initialization.Task_Lock (Self_ID); -- If Sec_Stack_Addr is not null, it means that Destroy_TSD -- has not been called yet (case of an unactivated task). if T.Common.Compiler_Data.Sec_Stack_Addr /= Null_Address then SSL.Destroy_TSD (T.Common.Compiler_Data); end if; Vulnerable_Free_Task (T); Initialization.Task_Unlock (Self_ID); end if; end loop; -- It might seem nice to let the terminated task deallocate its own -- ATCB. That would not cover the case of unactivated tasks. It also -- would force us to keep the underlying thread around past termination, -- since references to the ATCB are possible past termination. -- Currently, we get rid of the thread as soon as the task terminates, -- and let the parent recover the ATCB later. -- Some day, if we want to recover the ATCB earlier, at task -- termination, we could consider using "fat task IDs", that include the -- serial number with the ATCB pointer, to catch references to tasks -- that no longer have ATCBs. It is not clear how much this would gain, -- since the user-level task object would still be occupying storage. -- Make next master level up active. We don't need to lock the ATCB, -- since the value is only updated by each task for itself. Self_ID.Master_Within := CM - 1; Debug.Master_Completed_Hook (Self_ID, CM); end Vulnerable_Complete_Master; ------------------------------ -- Vulnerable_Complete_Task -- ------------------------------ -- Complete the calling task -- This procedure must be called with abort deferred. It should only be -- called by Complete_Task and Finalize_Global_Tasks (for the environment -- task). -- The effect is similar to that of Complete_Master. Differences include -- the closing of entries here, and computation of the number of active -- dependent tasks in Complete_Master. -- We don't lock Self_ID before the call to Vulnerable_Complete_Activation, -- because that does its own locking, and because we do not need the lock -- to test Self_ID.Common.Activator. That value should only be read and -- modified by Self. procedure Vulnerable_Complete_Task (Self_ID : Task_Id) is begin pragma Assert (Self_ID.Deferral_Level > 0 or else not System.Restrictions.Abort_Allowed); pragma Assert (Self_ID = Self); pragma Assert (Self_ID.Master_Within in Self_ID.Master_of_Task + 1 .. Self_ID.Master_of_Task + 3); pragma Assert (Self_ID.Common.Wait_Count = 0); pragma Assert (Self_ID.Open_Accepts = null); pragma Assert (Self_ID.ATC_Nesting_Level = 1); pragma Debug (Debug.Trace (Self_ID, "V_Complete_Task", 'C')); if Single_Lock then Lock_RTS; end if; Write_Lock (Self_ID); Self_ID.Callable := False; -- In theory, Self should have no pending entry calls left on its -- call-stack. Each async. select statement should clean its own call, -- and blocking entry calls should defer abort until the calls are -- cancelled, then clean up. Utilities.Cancel_Queued_Entry_Calls (Self_ID); Unlock (Self_ID); if Self_ID.Common.Activator /= null then Vulnerable_Complete_Activation (Self_ID); end if; if Single_Lock then Unlock_RTS; end if; -- If Self_ID.Master_Within = Self_ID.Master_of_Task + 2 we may have -- dependent tasks for which we need to wait. Otherwise we just exit. if Self_ID.Master_Within = Self_ID.Master_of_Task + 2 then Vulnerable_Complete_Master (Self_ID); end if; end Vulnerable_Complete_Task; -------------------------- -- Vulnerable_Free_Task -- -------------------------- -- Recover all runtime system storage associated with the task T. This -- should only be called after T has terminated and will no longer be -- referenced. -- For tasks created by an allocator that fails, due to an exception, it -- is called from Expunge_Unactivated_Tasks. -- For tasks created by elaboration of task object declarations it is -- called from the finalization code of the Task_Wrapper procedure. procedure Vulnerable_Free_Task (T : Task_Id) is begin pragma Debug (Debug.Trace (Self, "Vulnerable_Free_Task", 'C', T)); if Single_Lock then Lock_RTS; end if; Write_Lock (T); Initialization.Finalize_Attributes (T); Unlock (T); if Single_Lock then Unlock_RTS; end if; System.Task_Primitives.Operations.Finalize_TCB (T); end Vulnerable_Free_Task; -- Package elaboration code begin -- Establish the Adafinal softlink -- This is not done inside the central RTS initialization routine -- to avoid with'ing this package from System.Tasking.Initialization. SSL.Adafinal := Finalize_Global_Tasks'Access; -- Establish soft links for subprograms that manipulate master_id's. -- This cannot be done when the RTS is initialized, because of various -- elaboration constraints. SSL.Current_Master := Stages.Current_Master'Access; SSL.Enter_Master := Stages.Enter_Master'Access; SSL.Complete_Master := Stages.Complete_Master'Access; end System.Tasking.Stages;
------------------------------------------------------------------------------ -- -- -- GNAT ncurses Binding Samples -- -- -- -- ncurses -- -- -- -- B O D Y -- -- -- ------------------------------------------------------------------------------ -- Copyright (c) 2000-2004,2008 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: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000 -- Version Control -- $Revision: 1.7 $ -- $Date: 2008/07/26 18:46:44 $ -- Binding Version 01.00 ------------------------------------------------------------------------------ -- A simplified version of the GNU getopt function -- copyright Free Software Foundtion with Ada.Strings.Fixed; with Ada.Strings.Bounded; with Ada.Text_IO; use Ada.Text_IO; package body ncurses2.getopt is nextchar : Natural := 0; -- Ncurses doesn't use the non option elements so we are spared -- the job of computing those. -- also the user is not allowed to modify argv or argc -- Doing so is Erroneous execution. -- longoptions are not handled. procedure Qgetopt (retval : out Integer; argc : Integer; argv : stringfunc; -- argv will be the Argument function. optstring : String; optind : in out Integer; -- ignored for ncurses, must be initialized to 1 by -- the caller Optarg : out stringa -- a garbage colector would be useful here. ) is package BS is new Ada.Strings.Bounded.Generic_Bounded_Length (200); use BS; optargx : Bounded_String; begin if argc < optind then retval := -1; return; end if; optargx := To_Bounded_String (""); if nextchar = 0 then if argv (optind) = "--" then -- the rest are non-options, we ignore them retval := -1; return; end if; if argv (optind)(1) /= '-' or argv (optind)'Length = 1 then optind := optind + 1; Optarg := new String'(argv (optind)); retval := 1; return; end if; nextchar := 2; -- skip the one hyphen. end if; -- Look at and handle the next short option-character. declare c : Character := argv (optind) (nextchar); temp : constant Natural := Ada.Strings.Fixed.Index (optstring, String'(1 => c)); begin if temp = 0 or c = ':' then Put_Line (Standard_Error, argv (optind) & ": invalid option -- " & c); c := '?'; return; end if; if optstring (temp + 1) = ':' then if optstring (temp + 2) = ':' then -- This is an option that accepts an argument optionally. if nextchar /= argv (optind)'Length then optargx := To_Bounded_String (argv (optind) (nextchar .. argv (optind)'Length)); else Optarg := null; end if; else -- This is an option that requires an argument. if nextchar /= argv (optind)'Length then optargx := To_Bounded_String (argv (optind) (nextchar .. argv (optind)'Length)); optind := optind + 1; elsif optind = argc then Put_Line (Standard_Error, argv (optind) & ": option requires an argument -- " & c); if optstring (optstring'First) = ':' then c := ':'; else c := '?'; end if; else -- increment it again when taking next ARGV-elt as argument. optind := optind + 1; optargx := To_Bounded_String (argv (optind)); optind := optind + 1; end if; end if; nextchar := 0; else -- no argument for the option if nextchar = argv (optind)'Length then optind := optind + 1; nextchar := 0; else nextchar := nextchar + 1; end if; end if; retval := Character'Pos (c); Optarg := new String'(To_String (optargx)); return; end; end Qgetopt; end ncurses2.getopt;
-- SPDX-FileCopyrightText: 2021 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Ada.Finalization; generic type Resolve_Element is private; -- Type for reolving a promise type Reject_Element is private; -- Type for rejecting a promise package Network.Generic_Promises is pragma Preelaborate; type Listener is limited interface; -- A listener on promise events type Listener_Access is access all Listener'Class with Storage_Size => 0; not overriding procedure On_Resolve (Self : in out Listener; Value : Resolve_Element) is abstract; -- The promise is resolved with a Value not overriding procedure On_Reject (Self : in out Listener; Value : Reject_Element) is abstract; -- The promise is rejected with a value type Promise is tagged private; -- Promise is an object to be resolved or rejected with some value function Is_Attached (Self : Promise'Class) return Boolean; -- The promise has a corresponding controlling part function Is_Pending (Self : Promise'Class) return Boolean with Pre => Self.Is_Attached; -- The promise has not resolved nor rejected yet function Is_Resolved (Self : Promise'Class) return Boolean with Pre => Self.Is_Attached; -- The promise has been resolved function Is_Rejected (Self : Promise'Class) return Boolean with Pre => Self.Is_Attached; -- The promise has been rejected procedure Add_Listener (Self : in out Promise'Class; Value : not null Listener_Access); -- Let a listener to be notified when the promise is settled procedure Remove_Listener (Self : in out Promise'Class; Value : not null Listener_Access); -- Let a listener to be notified when the promise is settled type Controller is tagged limited private; -- Controlling part of the promise function Is_Pending (Self : Controller'Class) return Boolean; -- The promise has not resolved nor rejected yet function Is_Resolved (Self : Controller'Class) return Boolean; -- The promise has been resolved function Is_Rejected (Self : Controller'Class) return Boolean; -- The promise has been rejected function To_Promise (Self : access Controller'Class) return Promise with Post => To_Promise'Result.Is_Attached; procedure Resolve (Self : in out Controller'Class; Value : Resolve_Element) with Pre => Self.To_Promise.Is_Pending, Post => Self.To_Promise.Is_Resolved; -- Resolve the promise and notify listeners procedure Reject (Self : in out Controller'Class; Value : Reject_Element) with Pre => Self.To_Promise.Is_Pending, Post => Self.To_Promise.Is_Rejected; -- Reject the promise. This will notify the listener private type List_Node; type List_Node_Access is access List_Node; type List_Node is record Item : not null Listener_Access; Next : List_Node_Access; end record; type Promise_State is (Pending, Resolved, Rejected); type Promise_Data (State : Promise_State := Pending) is record case State is when Pending => Listeners : List_Node_Access; Callback : Listener_Access; when Resolved => Resolve_Value : Resolve_Element; when Rejected => Reject_Value : Reject_Element; end case; end record; type Controller is new Ada.Finalization.Limited_Controlled with record Data : Promise_Data; end record; overriding procedure Finalize (Self : in out Controller); type Controller_Access is access all Controller'Class with Storage_Size => 0; type Promise is tagged record Parent : Controller_Access; end record; end Network.Generic_Promises;
------------------------------------------------------------------------------ -- Copyright (c) 2014-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. -- ------------------------------------------------------------------------------ package body Natools.Constant_Indefinite_Ordered_Maps is -------------------------- -- Sorted Array Backend -- -------------------------- function Create (Size : Index_Type; Key_Factory : not null access function (Index : Index_Type) return Key_Type; Element_Factory : not null access function (Index : Index_Type) return Element_Type) return Backend_Array is function Node_Factory (Index : Index_Type) return Node with Inline; function Node_Factory (Index : Index_Type) return Node is begin return (Key => new Key_Type'(Key_Factory (Index)), Element => new Element_Type'(Element_Factory (Index))); end Node_Factory; First_Node : constant Node := Node_Factory (1); begin return Result : Backend_Array := (Ada.Finalization.Limited_Controlled with Size => Size, Nodes => (others => First_Node), Finalized => False) do if Size >= 2 then for I in 2 .. Size loop Result.Nodes (I) := Node_Factory (I); end loop; end if; end return; end Create; function Make_Backend (Size : Count_Type; Key_Factory : not null access function (Index : Index_Type) return Key_Type; Element_Factory : not null access function (Index : Index_Type) return Element_Type) return Backend_Refs.Immutable_Reference is function Create return Backend_Array; function Create return Backend_Array is begin return Create (Size, Key_Factory, Element_Factory); end Create; begin if Size = 0 then return Backend_Refs.Null_Immutable_Reference; else return Backend_Refs.Create (Create'Access); end if; end Make_Backend; function Make_Backend (Map : Unsafe_Maps.Map) return Backend_Refs.Immutable_Reference is function Create return Backend_Array; function Element (Index : Index_Type) return Element_Type; function Key (Index : Index_Type) return Key_Type; procedure Update_Cursor (Index : in Index_Type); function Is_Valid (Nodes : Node_Array) return Boolean; Length : constant Count_Type := Map.Length; Cursor : Unsafe_Maps.Cursor := Map.First; I : Index_Type := 1; function Create return Backend_Array is begin return Create (Length, Key'Access, Element'Access); end Create; function Element (Index : Index_Type) return Element_Type is begin Update_Cursor (Index); return Unsafe_Maps.Element (Cursor); end Element; function Is_Valid (Nodes : Node_Array) return Boolean is begin return (for all J in Nodes'First + 1 .. Nodes'Last => Nodes (J - 1).Key.all < Nodes (J).Key.all); end Is_Valid; function Key (Index : Index_Type) return Key_Type is begin Update_Cursor (Index); pragma Assert (Unsafe_Maps.Has_Element (Cursor)); return Unsafe_Maps.Key (Cursor); end Key; procedure Update_Cursor (Index : in Index_Type) is begin if Index = I + 1 then Unsafe_Maps.Next (Cursor); I := I + 1; elsif Index /= I then raise Program_Error with "Unexpected index value" & Index_Type'Image (Index) & " (previous value" & Index_Type'Image (I) & ')'; end if; end Update_Cursor; Result : Backend_Refs.Immutable_Reference; begin if Length = 0 then return Backend_Refs.Null_Immutable_Reference; end if; Result := Backend_Refs.Create (Create'Access); pragma Assert (I = Length); pragma Assert (Unsafe_Maps."=" (Cursor, Map.Last)); pragma Assert (Is_Valid (Result.Query.Data.Nodes)); return Result; end Make_Backend; overriding procedure Finalize (Object : in out Backend_Array) is Key : Key_Access; Element : Element_Access; begin if not Object.Finalized then for I in Object.Nodes'Range loop Key := Object.Nodes (I).Key; Element := Object.Nodes (I).Element; Free (Key); Free (Element); end loop; Object.Finalized := True; end if; end Finalize; procedure Search (Nodes : in Node_Array; Key : in Key_Type; Floor : out Count_Type; Ceiling : out Count_Type) is Middle : Index_Type; begin Floor := 0; Ceiling := 0; if Nodes'Length = 0 then return; end if; Floor := Nodes'First; if Key < Nodes (Floor).Key.all then Ceiling := Floor; Floor := 0; return; elsif not (Nodes (Floor).Key.all < Key) then Ceiling := Floor; return; end if; Ceiling := Nodes'Last; if Nodes (Ceiling).Key.all < Key then Floor := Ceiling; Ceiling := 0; return; elsif not (Key < Nodes (Ceiling).Key.all) then Floor := Ceiling; return; end if; while Ceiling - Floor >= 2 loop Middle := Floor + (Ceiling - Floor) / 2; if Nodes (Middle).Key.all < Key then Floor := Middle; elsif Key < Nodes (Middle).Key.all then Ceiling := Middle; else Floor := Middle; Ceiling := Middle; return; end if; end loop; return; end Search; ----------------------- -- Cursor Operations -- ----------------------- function "<" (Left, Right : Cursor) return Boolean is begin return Key (Left) < Key (Right); end "<"; function ">" (Left, Right : Cursor) return Boolean is begin return Key (Right) < Key (Left); end ">"; function "<" (Left : Cursor; Right : Key_Type) return Boolean is begin return Key (Left) < Right; end "<"; function ">" (Left : Cursor; Right : Key_Type) return Boolean is begin return Right < Key (Left); end ">"; function "<" (Left : Key_Type; Right : Cursor) return Boolean is begin return Left < Key (Right); end "<"; function ">" (Left : Key_Type; Right : Cursor) return Boolean is begin return Key (Right) < Left; end ">"; procedure Clear (Position : in out Cursor) is begin Position := No_Element; end Clear; function Element (Position : Cursor) return Element_Type is begin return Position.Backend.Query.Data.Nodes (Position.Index).Element.all; end Element; function Key (Position : Cursor) return Key_Type is begin return Position.Backend.Query.Data.Nodes (Position.Index).Key.all; end Key; function Next (Position : Cursor) return Cursor is begin if Position.Is_Empty or else Position.Index >= Position.Backend.Query.Data.Size then return No_Element; else return (Is_Empty => False, Backend => Position.Backend, Index => Position.Index + 1); end if; end Next; procedure Next (Position : in out Cursor) is begin if Position.Is_Empty then null; elsif Position.Index >= Position.Backend.Query.Data.Size then Position := No_Element; else Position.Index := Position.Index + 1; end if; end Next; function Previous (Position : Cursor) return Cursor is begin if Position.Is_Empty or else Position.Index = 1 then return No_Element; else return (Is_Empty => False, Backend => Position.Backend, Index => Position.Index - 1); end if; end Previous; procedure Previous (Position : in out Cursor) is begin if Position.Is_Empty then null; elsif Position.Index = 1 then Position := No_Element; else Position.Index := Position.Index - 1; end if; end Previous; procedure Query_Element (Position : in Cursor; Process : not null access procedure (Key : in Key_Type; Element : in Element_Type)) is Accessor : constant Backend_Refs.Accessor := Position.Backend.Query; begin Process.all (Accessor.Data.Nodes (Position.Index).Key.all, Accessor.Data.Nodes (Position.Index).Element.all); end Query_Element; function Rank (Position : Cursor) return Ada.Containers.Count_Type is begin case Position.Is_Empty is when True => return 0; when False => return Position.Index; end case; end Rank; ----------------------------- -- Non-Standard Operations -- ----------------------------- function Create (Source : Unsafe_Maps.Map) return Constant_Map is begin return (Backend => Make_Backend (Source)); end Create; procedure Replace (Container : in out Constant_Map; New_Items : in Unsafe_Maps.Map) is begin Container.Backend := Make_Backend (New_Items); end Replace; function To_Unsafe_Map (Container : Constant_Map) return Unsafe_Maps.Map is Result : Unsafe_Maps.Map; begin if Container.Backend.Is_Empty then return Result; end if; declare Accessor : constant Backend_Refs.Accessor := Container.Backend.Query; begin for I in Accessor.Data.Nodes'Range loop Result.Insert (Accessor.Data.Nodes (I).Key.all, Accessor.Data.Nodes (I).Element.all); end loop; end; return Result; end To_Unsafe_Map; ----------------------------- -- Constant Map Operations -- ----------------------------- function "=" (Left, Right : Constant_Map) return Boolean is use type Backend_Refs.Immutable_Reference; begin return Left.Backend = Right.Backend; end "="; function Ceiling (Container : Constant_Map; Key : Key_Type) return Cursor is Floor, Ceiling : Count_Type; begin if Container.Is_Empty then return No_Element; end if; Search (Container.Backend.Query.Data.Nodes, Key, Floor, Ceiling); if Ceiling > 0 then return (Is_Empty => False, Backend => Container.Backend, Index => Ceiling); else return No_Element; end if; end Ceiling; procedure Clear (Container : in out Constant_Map) is begin Container.Backend.Reset; end Clear; function Constant_Reference (Container : aliased in Constant_Map; Position : in Cursor) return Constant_Reference_Type is use type Backend_Refs.Immutable_Reference; begin if Position.Is_Empty then raise Constraint_Error with "Constant_Reference called with empty Position"; end if; if Container.Backend /= Position.Backend then raise Program_Error with "Constant_Reference called" & " with unrelated Container and Position"; end if; return (Backend => Container.Backend, Element => Container.Backend.Query.Data.all.Nodes (Position.Index).Element); end Constant_Reference; function Constant_Reference (Container : aliased in Constant_Map; Key : in Key_Type) return Constant_Reference_Type is Position : constant Cursor := Container.Find (Key); begin if Position.Is_Empty then raise Constraint_Error with "Constant_Reference called with Key not in map"; end if; return (Backend => Container.Backend, Element => Container.Backend.Query.Data.Nodes (Position.Index).Element); end Constant_Reference; function Contains (Container : Constant_Map; Key : Key_Type) return Boolean is Floor, Ceiling : Count_Type; begin if Container.Is_Empty then return False; end if; Search (Container.Backend.Query.Data.Nodes, Key, Floor, Ceiling); return Floor = Ceiling; end Contains; function Element (Container : Constant_Map; Key : Key_Type) return Element_Type is begin return Element (Find (Container, Key)); end Element; function Find (Container : Constant_Map; Key : Key_Type) return Cursor is Floor, Ceiling : Count_Type; begin if Container.Is_Empty then return No_Element; end if; Search (Container.Backend.Query.Data.Nodes, Key, Floor, Ceiling); if Floor = Ceiling then return (Is_Empty => False, Backend => Container.Backend, Index => Floor); else return No_Element; end if; end Find; function First (Container : Constant_Map) return Cursor is begin if Container.Is_Empty then return No_Element; else return (Is_Empty => False, Backend => Container.Backend, Index => 1); end if; end First; function First_Element (Container : Constant_Map) return Element_Type is Accessor : constant Backend_Refs.Accessor := Container.Backend.Query; begin return Accessor.Data.Nodes (1).Element.all; end First_Element; function First_Key (Container : Constant_Map) return Key_Type is Accessor : constant Backend_Refs.Accessor := Container.Backend.Query; begin return Accessor.Data.Nodes (1).Key.all; end First_Key; function Floor (Container : Constant_Map; Key : Key_Type) return Cursor is Floor, Ceiling : Count_Type; begin if Container.Is_Empty then return No_Element; end if; Search (Container.Backend.Query.Data.Nodes, Key, Floor, Ceiling); if Floor > 0 then return (Is_Empty => False, Backend => Container.Backend, Index => Floor); else return No_Element; end if; end Floor; procedure Iterate (Container : in Constant_Map; Process : not null access procedure (Position : in Cursor)) is Position : Cursor := (Is_Empty => False, Backend => Container.Backend, Index => 1); begin if Container.Backend.Is_Empty then return; end if; for I in Container.Backend.Query.Data.Nodes'Range loop Position.Index := I; Process.all (Position); end loop; end Iterate; function Iterate (Container : in Constant_Map) return Map_Iterator_Interfaces.Reversible_Iterator'Class is begin return Iterator'(Backend => Container.Backend, Start => No_Element); end Iterate; function Iterate (Container : in Constant_Map; Start : in Cursor) return Map_Iterator_Interfaces.Reversible_Iterator'Class is begin return Iterator'(Backend => Container.Backend, Start => Start); end Iterate; function Iterate (Container : in Constant_Map; First, Last : in Cursor) return Map_Iterator_Interfaces.Reversible_Iterator'Class is begin if Is_Empty (Container) or else not Has_Element (First) or else not Has_Element (Last) or else First > Last then return Iterator'(Backend => Backend_Refs.Null_Immutable_Reference, Start => No_Element); else return Range_Iterator'(Backend => Container.Backend, First_Position => First, Last_Position => Last); end if; end Iterate; function Last (Container : Constant_Map) return Cursor is begin if Container.Is_Empty then return No_Element; else return (Is_Empty => False, Backend => Container.Backend, Index => Container.Backend.Query.Data.Size); end if; end Last; function Last_Element (Container : Constant_Map) return Element_Type is Accessor : constant Backend_Refs.Accessor := Container.Backend.Query; begin return Accessor.Data.Nodes (Accessor.Data.Size).Element.all; end Last_Element; function Last_Key (Container : Constant_Map) return Key_Type is Accessor : constant Backend_Refs.Accessor := Container.Backend.Query; begin return Accessor.Data.Nodes (Accessor.Data.Size).Key.all; end Last_Key; function Length (Container : Constant_Map) return Ada.Containers.Count_Type is begin if Container.Backend.Is_Empty then return 0; else return Container.Backend.Query.Data.Size; end if; end Length; procedure Move (Target, Source : in out Constant_Map) is begin Target.Backend := Source.Backend; Source.Backend.Reset; end Move; procedure Reverse_Iterate (Container : in Constant_Map; Process : not null access procedure (Position : in Cursor)) is Position : Cursor := (Is_Empty => False, Backend => Container.Backend, Index => 1); begin if Container.Backend.Is_Empty then return; end if; for I in reverse Container.Backend.Query.Data.Nodes'Range loop Position.Index := I; Process.all (Position); end loop; end Reverse_Iterate; ---------------------------------------- -- Constant Map "Update" Constructors -- ---------------------------------------- function Insert (Source : in Constant_Map; Key : in Key_Type; New_Item : in Element_Type; Position : out Cursor; Inserted : out Boolean) return Constant_Map is Floor, Ceiling : Count_Type; begin if Source.Is_Empty then declare Backend : constant Backend_Refs.Data_Access := new Backend_Array' (Ada.Finalization.Limited_Controlled with Size => 1, Nodes => (1 => (Key => new Key_Type'(Key), Element => new Element_Type'(New_Item))), Finalized => False); Result : constant Constant_Map := (Backend => Backend_Refs.Create (Backend)); begin Position := (Is_Empty => False, Backend => Result.Backend, Index => 1); Inserted := True; return Result; end; end if; Search (Source.Backend.Query.Data.Nodes, Key, Floor, Ceiling); if Floor = Ceiling then Position := (Is_Empty => False, Backend => Source.Backend, Index => Floor); Inserted := False; return Source; end if; declare function Key_Factory (Index : Index_Type) return Key_Type; function Element_Factory (Index : Index_Type) return Element_Type; Accessor : constant Backend_Refs.Accessor := Source.Backend.Query; function Key_Factory (Index : Index_Type) return Key_Type is begin if Index <= Floor then return Accessor.Nodes (Index).Key.all; elsif Index = Floor + 1 then return Key; else return Accessor.Nodes (Index - 1).Key.all; end if; end Key_Factory; function Element_Factory (Index : Index_Type) return Element_Type is begin if Index <= Floor then return Accessor.Nodes (Index).Element.all; elsif Index = Floor + 1 then return New_Item; else return Accessor.Nodes (Index - 1).Element.all; end if; end Element_Factory; Result : constant Constant_Map := (Backend => Make_Backend (Accessor.Size + 1, Key_Factory'Access, Element_Factory'Access)); begin Position := (Is_Empty => False, Backend => Result.Backend, Index => Floor + 1); Inserted := True; return Result; end; end Insert; function Insert (Source : in Constant_Map; Key : in Key_Type; New_Item : in Element_Type) return Constant_Map is Position : Cursor; Inserted : Boolean; Result : constant Constant_Map := Insert (Source, Key, New_Item, Position, Inserted); begin if not Inserted then raise Constraint_Error with "Inserted key already in Constant_Map"; end if; return Result; end Insert; function Include (Source : in Constant_Map; Key : in Key_Type; New_Item : in Element_Type) return Constant_Map is Position : Cursor; Inserted : Boolean; Result : constant Constant_Map := Insert (Source, Key, New_Item, Position, Inserted); begin if Inserted then return Result; end if; declare function Key_Factory (Index : Index_Type) return Key_Type; function Element_Factory (Index : Index_Type) return Element_Type; Accessor : constant Backend_Refs.Accessor := Source.Backend.Query; function Key_Factory (Index : Index_Type) return Key_Type is begin if Index = Position.Index then return Key; else return Accessor.Nodes (Index).Key.all; end if; end Key_Factory; function Element_Factory (Index : Index_Type) return Element_Type is begin if Index = Position.Index then return New_Item; else return Accessor.Nodes (Index).Element.all; end if; end Element_Factory; Result : constant Constant_Map := (Backend => Make_Backend (Accessor.Size, Key_Factory'Access, Element_Factory'Access)); begin return Result; end; end Include; function Replace (Source : in Constant_Map; Key : in Key_Type; New_Item : in Element_Type) return Constant_Map is Floor, Ceiling : Count_Type; begin if Source.Is_Empty then raise Constraint_Error with "Replace called on empty Constant_Map"; end if; Search (Source.Backend.Query.Data.Nodes, Key, Floor, Ceiling); if Floor /= Ceiling then raise Constraint_Error with "Replace called with key not in Constant_Map"; end if; return Replace_Element (Source => Source, Position => (Is_Empty => False, Backend => Source.Backend, Index => Floor), New_Item => New_Item); end Replace; function Replace_Element (Source : in Constant_Map; Position : in Cursor; New_Item : in Element_Type) return Constant_Map is use type Backend_Refs.Immutable_Reference; begin if Position.Is_Empty then raise Constraint_Error with "Constant_Map.Replace_Element called with empty cursor"; end if; if Source.Backend /= Position.Backend then raise Program_Error with "Constant_Map.Replace_Element " & "with unrelated container and cursor"; end if; declare function Key_Factory (Index : Index_Type) return Key_Type; function Element_Factory (Index : Index_Type) return Element_Type; Accessor : constant Backend_Refs.Accessor := Source.Backend.Query; function Key_Factory (Index : Index_Type) return Key_Type is begin return Accessor.Nodes (Index).Key.all; end Key_Factory; function Element_Factory (Index : Index_Type) return Element_Type is begin if Index = Position.Index then return New_Item; else return Accessor.Nodes (Index).Element.all; end if; end Element_Factory; Result : constant Constant_Map := (Backend => Make_Backend (Accessor.Size, Key_Factory'Access, Element_Factory'Access)); begin return Result; end; end Replace_Element; function Replace_Element (Source : in Constant_Map; Position : in Cursor; New_Item : in Element_Type; New_Position : out Cursor) return Constant_Map is Result : constant Constant_Map := Replace_Element (Source, Position, New_Item); begin New_Position := (Is_Empty => False, Backend => Result.Backend, Index => Position.Index); return Result; end Replace_Element; function Exclude (Source : in Constant_Map; Key : in Key_Type) return Constant_Map is Floor, Ceiling : Count_Type; begin if Source.Is_Empty then return Source; end if; Search (Source.Backend.Query.Data.Nodes, Key, Floor, Ceiling); if Floor = Ceiling then return Delete (Source, Cursor'(Is_Empty => False, Backend => Source.Backend, Index => Floor)); else return Source; end if; end Exclude; function Delete (Source : in Constant_Map; Key : in Key_Type) return Constant_Map is Floor, Ceiling : Count_Type; begin if Source.Is_Empty then raise Constraint_Error with "Delete called on empty Constant_Map"; end if; Search (Source.Backend.Query.Data.Nodes, Key, Floor, Ceiling); if Floor /= Ceiling then raise Constraint_Error with "Deleted key not in Constant_Map"; end if; return Delete (Source, (Is_Empty => False, Backend => Source.Backend, Index => Floor)); end Delete; function Delete (Source : in Constant_Map; Position : in Cursor) return Constant_Map is use type Backend_Refs.Immutable_Reference; begin if Position.Is_Empty then raise Constraint_Error with "Constant_Map.Delete with empty cursor"; end if; if Source.Backend /= Position.Backend then raise Program_Error with "Constant_Map.Delete with unrelated container and cursor"; end if; declare function Key_Factory (Index : Index_Type) return Key_Type; function Element_Factory (Index : Index_Type) return Element_Type; Accessor : constant Backend_Refs.Accessor := Source.Backend.Query; function Key_Factory (Index : Index_Type) return Key_Type is begin if Index < Position.Index then return Accessor.Nodes (Index).Key.all; else return Accessor.Nodes (Index + 1).Key.all; end if; end Key_Factory; function Element_Factory (Index : Index_Type) return Element_Type is begin if Index < Position.Index then return Accessor.Nodes (Index).Element.all; else return Accessor.Nodes (Index + 1).Element.all; end if; end Element_Factory; Result : constant Constant_Map := (Backend => Make_Backend (Accessor.Size - 1, Key_Factory'Access, Element_Factory'Access)); begin return Result; end; end Delete; ------------------------------ -- Updatable Map Operations -- ------------------------------ function Constant_Reference_For_Bugged_GNAT (Container : aliased in Updatable_Map; Position : in Cursor) return Constant_Reference_Type is begin return Constant_Reference (Constant_Map (Container), Position); end Constant_Reference_For_Bugged_GNAT; function Constant_Reference_For_Bugged_GNAT (Container : aliased in Updatable_Map; Key : in Key_Type) return Constant_Reference_Type is begin return Constant_Reference (Constant_Map (Container), Key); end Constant_Reference_For_Bugged_GNAT; function Reference (Container : aliased in out Updatable_Map; Position : in Cursor) return Reference_Type is use type Backend_Refs.Immutable_Reference; begin if Position.Is_Empty then raise Constraint_Error with "Reference called with empty Position"; end if; if Container.Backend /= Position.Backend then raise Program_Error with "Reference called with unrelated Container and Position"; end if; return (Backend => Container.Backend, Element => Container.Backend.Query.Data.Nodes (Position.Index).Element); end Reference; function Reference (Container : aliased in out Updatable_Map; Key : in Key_Type) return Reference_Type is Position : constant Cursor := Container.Find (Key); begin if Position.Is_Empty then raise Constraint_Error with "Reference called with Key not in map"; end if; return (Backend => Container.Backend, Element => Container.Backend.Query.Data.Nodes (Position.Index).Element); end Reference; procedure Update_Element (Container : in out Updatable_Map; Position : in Cursor; Process : not null access procedure (Key : in Key_Type; Element : in out Element_Type)) is pragma Unreferenced (Container); Accessor : constant Backend_Refs.Accessor := Position.Backend.Query; begin Process.all (Accessor.Data.Nodes (Position.Index).Key.all, Accessor.Data.Nodes (Position.Index).Element.all); end Update_Element; ------------------------- -- Iterator Operations -- ------------------------- overriding function First (Object : Iterator) return Cursor is begin if Has_Element (Object.Start) then return Object.Start; elsif Object.Backend.Is_Empty then return No_Element; else return (Is_Empty => False, Backend => Object.Backend, Index => 1); end if; end First; overriding function Last (Object : Iterator) return Cursor is begin if Has_Element (Object.Start) then return Object.Start; elsif Object.Backend.Is_Empty then return No_Element; else return (Is_Empty => False, Backend => Object.Backend, Index => Object.Backend.Query.Data.Size); end if; end Last; overriding function First (Object : Range_Iterator) return Cursor is begin return Object.First_Position; end First; overriding function Last (Object : Range_Iterator) return Cursor is begin return Object.Last_Position; end Last; overriding function Next (Object : Range_Iterator; Position : Cursor) return Cursor is begin if Has_Element (Position) and then Position < Object.Last_Position then return Next (Position); else return No_Element; end if; end Next; overriding function Previous (Object : Range_Iterator; Position : Cursor) return Cursor is begin if Has_Element (Position) and then Position > Object.First_Position then return Previous (Position); else return No_Element; end if; end Previous; end Natools.Constant_Indefinite_Ordered_Maps;
----------------------------------------------------------------------- -- stemmer -- Multi-language stemmer with Snowball generator -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions -- are met: -- -- 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 Snowball project nor the names of its contributors -- may be used to endorse or promote products derived from this software -- without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -- ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -- WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -- DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR -- ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -- ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ----------------------------------------------------------------------- package Stemmer with SPARK_Mode is pragma Preelaborate; WORD_MAX_LENGTH : constant := 1024; type Context_Type is abstract tagged private; -- Apply the stemming algorithm on the word initialized in the context. procedure Stem (Context : in out Context_Type; Result : out Boolean) is abstract; -- Stem the word and return True if it was reduced. procedure Stem_Word (Context : in out Context_Type'Class; Word : in String; Result : out Boolean) with Global => null, Pre => Word'Length < WORD_MAX_LENGTH; -- Get the stem or the input word unmodified. function Get_Result (Context : in Context_Type'Class) return String with Global => null, Post => Get_Result'Result'Length < WORD_MAX_LENGTH; private type Mask_Type is mod 2**32; -- A 32-bit character value that was read from UTF-8 sequence. -- A modular value is used because shift and logical arithmetic is necessary. type Utf8_Type is mod 2**32; -- Index of the Grouping_Array. The index comes from the 32-bit character value -- minus a starting offset. We don't expect large tables and we check against -- a maximum value. subtype Grouping_Index is Utf8_Type range 0 .. 16384; type Grouping_Array is array (Grouping_Index range <>) of Boolean with Pack; subtype Among_Index is Natural range 0 .. 65535; subtype Among_Start_Index is Among_Index range 1 .. Among_Index'Last; subtype Operation_Index is Natural range 0 .. 65535; subtype Result_Index is Integer range -1 .. WORD_MAX_LENGTH - 1; subtype Char_Index is Result_Index range 0 .. Result_Index'Last; type Among_Type is record First : Among_Start_Index; Last : Among_Index; Substring_I : Integer; Result : Integer; Operation : Operation_Index; end record; type Among_Array_Type is array (Natural range <>) of Among_Type; function Eq_S (Context : in Context_Type'Class; S : in String) return Char_Index with Global => null, Pre => S'Length > 0, Post => Eq_S'Result = 0 or Eq_S'Result = S'Length; function Eq_S_Backward (Context : in Context_Type'Class; S : in String) return Char_Index with Global => null, Pre => S'Length > 0, Post => Eq_S_Backward'Result = 0 or Eq_S_Backward'Result = S'Length; procedure Find_Among (Context : in out Context_Type'Class; Amongs : in Among_Array_Type; Pattern : in String; Execute : access procedure (Ctx : in out Context_Type'Class; Operation : in Operation_Index; Status : out Boolean); Result : out Integer) with Global => null, Pre => Pattern'Length > 0 and Amongs'Length > 0; procedure Find_Among_Backward (Context : in out Context_Type'Class; Amongs : in Among_Array_Type; Pattern : in String; Execute : access procedure (Ctx : in out Context_Type'Class; Operation : in Operation_Index; Status : out Boolean); Result : out Integer) with Global => null, Pre => Pattern'Length > 0 and Amongs'Length > 0; function Skip_Utf8 (Context : in Context_Type'Class) return Result_Index with Global => null; function Skip_Utf8 (Context : in Context_Type'Class; N : in Integer) return Result_Index with Global => null; function Skip_Utf8_Backward (Context : in Context_Type'Class) return Result_Index with Global => null; function Skip_Utf8_Backward (Context : in Context_Type'Class; N : in Integer) return Result_Index with Global => null; procedure Get_Utf8 (Context : in Context_Type'Class; Value : out Utf8_Type; Count : out Natural); procedure Get_Utf8_Backward (Context : in Context_Type'Class; Value : out Utf8_Type; Count : out Natural); function Length (Context : in Context_Type'Class) return Natural; function Length_Utf8 (Context : in Context_Type'Class) return Natural; function Check_Among (Context : in Context_Type'Class; Pos : in Char_Index; Shift : in Natural; Mask : in Mask_Type) return Boolean; procedure Out_Grouping (Context : in out Context_Type'Class; S : in Grouping_Array; Min : in Utf8_Type; Max : in Utf8_Type; Repeat : in Boolean; Result : out Result_Index); procedure Out_Grouping_Backward (Context : in out Context_Type'Class; S : in Grouping_Array; Min : in Utf8_Type; Max : in Utf8_Type; Repeat : in Boolean; Result : out Result_Index); procedure In_Grouping (Context : in out Context_Type'Class; S : in Grouping_Array; Min : in Utf8_Type; Max : in Utf8_Type; Repeat : in Boolean; Result : out Result_Index); procedure In_Grouping_Backward (Context : in out Context_Type'Class; S : in Grouping_Array; Min : in Utf8_Type; Max : in Utf8_Type; Repeat : in Boolean; Result : out Result_Index); procedure Replace (Context : in out Context_Type'Class; C_Bra : in Char_Index; C_Ket : in Char_Index; S : in String; Adjustment : out Integer) with Global => null, Pre => C_Bra >= Context.Lb and C_Ket >= C_Bra and C_Ket <= Context.L; procedure Slice_Del (Context : in out Context_Type'Class) with Global => null, Pre => Context.Bra >= Context.Lb and Context.Ket >= Context.Bra and Context.Ket <= Context.L; procedure Slice_From (Context : in out Context_Type'Class; Text : in String) with Global => null, Pre => Context.Bra >= Context.Lb and Context.Ket >= Context.Bra and Context.Ket <= Context.L and Context.L - Context.Lb + Text'Length + Context.Ket - Context.Bra < Context.P'Length; function Slice_To (Context : in Context_Type'Class) return String; procedure Insert (Context : in out Context_Type'Class; C_Bra : in Char_Index; C_Ket : in Char_Index; S : in String) with Global => null, Pre => C_Bra >= Context.Lb and C_Ket >= C_Bra and C_Ket <= Context.L; -- The context indexes follow the C paradigm: they start at 0 for the first character. -- This is necessary because several algorithms rely on this when they compare the -- cursor position ('C') or setup some markers from the cursor. type Context_Type is abstract tagged record C : Char_Index := 0; L : Char_Index := 0; Lb : Char_Index := 0; Bra : Char_Index := 0; Ket : Char_Index := 0; P : String (1 .. WORD_MAX_LENGTH); end record; end Stemmer;
-- Copyright 2017 Steven Stewart-Gallus -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -- implied. See the License for the specific language governing -- permissions and limitations under the License. with Ada.Unchecked_Conversion; with Interfaces; package body Linted.Tagged_Accessors is use type Interfaces.Unsigned_64; -- Warnings are off because of a spurious warning about strict -- aliasing pragma Warnings (Off); function Convert is new Ada.Unchecked_Conversion (Source => Access_T, Target => Interfaces.Unsigned_64); function Convert is new Ada.Unchecked_Conversion (Source => Interfaces.Unsigned_64, Target => Access_T); pragma Warnings (On); function To (Ptr : Access_T) return Tagged_Access is begin return To (Ptr, 0); end To; function To (Ptr : Access_T; Tag : Tag_Bits) return Tagged_Access is Converted : Interfaces.Unsigned_64; begin Converted := Convert (Ptr); pragma Assert (Interfaces.Shift_Right (Interfaces.Unsigned_64 (Converted), 48) = 0); return Tagged_Access (Interfaces.Shift_Right (Converted, 6) or Interfaces.Shift_Left (Interfaces.Unsigned_64 (Tag), 42)); end To; function From (Ptr : Tagged_Access) return Access_T is begin return Convert (Interfaces.Shift_Left (Interfaces.Unsigned_64 (Ptr) and 2#11_11111111_11111111_11111111_11111111_11111111#, 6)); end From; function Tag (Ptr : Tagged_Access) return Tag_Bits is begin return Tag_Bits (Interfaces.Shift_Right (Interfaces.Unsigned_64 (Ptr), 42)); end Tag; end Linted.Tagged_Accessors;
package Access_To_Subprogram is type Access_To_Procedure_1 is access procedure; type Access_To_Procedure_2 is access procedure (Parm_1 : in Integer); type Access_To_Procedure_3 is access protected procedure; type Access_To_Function_1 is access function return Boolean; type Access_To_Function_2 is access function (Parm_2 : in Integer) return Boolean; type Access_To_Function_3 is access protected function return Boolean; end Access_To_Subprogram;
package Tagged_Type_Pkg is type TT is tagged limited record Self : access TT'Class := TT'Unchecked_Access; end record; function Pass_TT_Access (Obj : access TT'Class) return access TT'Class; end Tagged_Type_Pkg;
package body Forward_Declaration is procedure P is null; procedure Q; procedure Q is null; end Forward_Declaration;
pragma License (Unrestricted); -- implementation unit with Ada.UCD.Normalization; private package Ada.Strings.Canonical_Composites is pragma Preelaborate; -- decomposition Expanding : constant := 4; -- same as Ada.Strings.Normalization.Expanding subtype Decomposed_Wide_Wide_String is Wide_Wide_String (1 .. Expanding); function Decomposed_Length (Item : Decomposed_Wide_Wide_String) return Natural; type D_Map_Element is record From : Wide_Wide_Character; To : Decomposed_Wide_Wide_String; end record; pragma Suppress_Initialization (D_Map_Element); type D_Map_Array is array (1 .. UCD.Normalization.NFD_Total) of D_Map_Element; pragma Suppress_Initialization (D_Map_Array); type D_Map_Array_Access is access D_Map_Array; D_Map : D_Map_Array_Access; function D_Find (Item : Wide_Wide_Character) return Natural; procedure Initialize_D; Unexpanded_D_Map : D_Map_Array_Access; procedure Initialize_Unexpanded_D; -- composition subtype Composing_Wide_Wide_String is Wide_Wide_String (1 .. 2); type C_Map_Element is record From : Composing_Wide_Wide_String; To : Wide_Wide_Character; end record; pragma Suppress_Initialization (C_Map_Element); type C_Map_Array is array (1 .. UCD.Normalization.NFC_Total) of C_Map_Element; pragma Suppress_Initialization (C_Map_Array); type C_Map_Array_Access is access C_Map_Array; C_Map : C_Map_Array_Access; function C_Find (Item : Composing_Wide_Wide_String) return Natural; procedure Initialize_C; end Ada.Strings.Canonical_Composites;
package TLSF.Proof.Test with SPARK_Mode, Ghost, Pure, Preelaborate is end TLSF.Proof.Test;
with Ada.Text_IO; use Ada.Text_IO; with Native.Filesystem; use Native.Filesystem; with Virtual_File_System; use Virtual_File_System; with Helpers; use Helpers; procedure TC_Nested_Mount is Strict_Mode : constant Boolean := False; -- Debug switch to enable strict mode. Currently, non-strict mode avoids -- calls that are more or less expected to fail. Root_VFS : Virtual_File_System.VFS; Child_VFS : Virtual_File_System.Any_VFS := new Virtual_File_System.VFS; Empty_FS : Native_FS_Driver_Ref := Create ("empty", Create_If_Missing => True); Subdirs_FS : Native_FS_Driver_Ref := Create ("subdirs"); begin Test (Root_VFS.Mount ("empty", Empty_FS.all'Access)); Test (Root_VFS.Mount ("child_vfs", Child_VFS.all'Access)); Test (Child_VFS.Mount ("subdirs", Subdirs_FS.all'Access)); Dump (Root_VFS, "/"); -- Unmounting is not implemented yet if Strict_Mode then Test (Root_VFS.Umount ("empty")); Test (Root_VFS.Umount ("child_vfs")); Test (Child_VFS.Umount ("subdirs")); end if; Destroy (Child_VFS); Destroy (Empty_FS); Destroy (Subdirs_FS); Put_Line ("Done."); end TC_Nested_Mount;
with Ada.Text_IO; procedure Prologue is begin Ada.Text_IO.Put("Hello World!"); end Prologue;
package body Exported is function Query (Data : chars_ptr; Size : access size_t) return int is Result : char_array := "Here am I"; begin if Size.all < Result'Length then return 0; else Update (Data, 0, Result); Size.all := Result'Length; return 1; end if; end Query; end Exported;
------------------------------------------------------------------------------ -- Copyright (c) 2011, 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. -- ------------------------------------------------------------------------------ with Ada.Strings; with Ada.Strings.Fixed; with Ada.Unchecked_Deallocation; package body Natools.Chunked_Strings is package Fixed renames Ada.Strings.Fixed; type Relation is (Equal, Greater, Lesser); ----------------------- -- Local subprograms -- ----------------------- function Allocated_Size (Source : in Chunked_String) return Natural; pragma Inline (Allocated_Size); -- Return the number of Characters that can currently fit in Source function Chunks_For (Size : in Natural; Chunk_Size : in Positive; Allocation_Unit : in Positive) return Natural; pragma Inline (Chunks_For); -- Return the number of chunks to accommodate Size characters generic type Map_Type is private; with function Count (Source : in String; Pattern : in String; Mapping : in Map_Type) return Natural; function Count_Gen (Source : in Chunked_String; Pattern : in String; Mapping : in Map_Type) return Natural; -- Count the number of non-overlapping occurrences of the pattern function Compare (Left : in Chunk_Array; Left_Size : in Natural; Right : in Chunk_Array; Right_Size : in Natural) return Relation; function Compare (Left : in Chunk_Array_Access; Left_Size : in Natural; Right : in Chunk_Array_Access; Right_Size : in Natural) return Relation; function Compare (Left : in Chunk_Array; Left_Size : in Natural; Right : in String) return Relation; function Compare (Left : in Chunk_Array_Access; Left_Size : in Natural; Right : in String) return Relation; -- String comparisons procedure Fill (Data : in out Chunk_Array; From : in Positive; Count : in Natural; C : in Character; Chunk_Size : in Positive); -- Fill an area of the chunks with the given Character procedure Free (Data : in out Chunk_Array_Access); -- Free data associated to all chunks and to the chunk array generic type Map_Type is private; with function Index (Source : String; Pattern : String; From : Positive; Going : Ada.Strings.Direction; Map : Map_Type) return Natural; function Index_Gen (Source : Chunked_String; Pattern : String; From : Positive; Going : Ada.Strings.Direction; Map : Map_Type) return Natural; -- Search for a pattern in a source as described in the ARM procedure Move (Target : in out Chunk_Array; Target_Position : in Positive; Source : in out Chunk_Array; Source_Position : in Positive; Length : in Natural); -- Moves characters from one Chunk_Array to another, even when they -- do not have the same chunk size procedure Move (Target : in out Chunk_Array; Source : in String; Position : in Positive; Chunk_Size : in Positive); -- Writes the string in the chunk array, which must be large enough procedure Move (Target : out String; Source : in Chunk_Array; From : in Positive); -- Fills a string using characters from the Chunk_Array procedure Move (Data : in out Chunk_Array; Target_Position : in Positive; Source_Position : in Positive; Length : in Positive; Chunk_Size : in Positive); -- Move a slice of data inside a given chunk array procedure Resize_Chunk (Chunk : in out String_Access; Size : in Positive); -- Resize a chunk to the target set procedure Resize_Chunks (Data : in out Chunk_Array_Access; Size : in Natural; Chunk_Size : in Positive; Allocation_Unit : in Positive; Can_Shrink : in Boolean := True); -- Resize Data to fit Size characters procedure Trim_Bounds (Source : in Chunked_String; Left : in Maps.Character_Set; Right : in Maps.Character_Set; Low : out Positive; High : out Natural); -- Compute slice bounds of the trimmed result function Units_For (Size : in Natural; Chunk_Size : in Positive; Allocation_Unit : in Positive) return Natural; pragma Inline (Units_For); -- Return the number of allocation units in the last chunk --------------------------------------- -- Chunked_String memory subprograms -- --------------------------------------- function Allocated_Size (Source : in Chunked_String) return Natural is begin if Source.Data = null or else Source.Data'Last < 1 then return 0; end if; return (Source.Data'Last - 1) * Source.Chunk_Size + Source.Data (Source.Data'Last)'Last; end Allocated_Size; function Chunks_For (Size : in Natural; Chunk_Size : in Positive; Allocation_Unit : in Positive) return Natural is begin pragma Unreferenced (Allocation_Unit); return (Size + Chunk_Size - 1) / Chunk_Size; end Chunks_For; procedure Free (Data : in out Chunk_Array_Access) is procedure Deallocate is new Ada.Unchecked_Deallocation (Chunk_Array, Chunk_Array_Access); begin if Data = null then return; end if; for J in Data'Range loop Free (Data (J)); end loop; Deallocate (Data); end Free; procedure Resize_Chunk (Chunk : in out String_Access; Size : in Positive) is New_Chunk : String_Access; begin if Size /= Chunk'Length then New_Chunk := new String (1 .. Size); if Size < Chunk'Length then New_Chunk.all := Chunk (Chunk'First .. Chunk'First + Size - 1); else New_Chunk.all (1 .. Chunk'Length) := Chunk.all; end if; Free (Chunk); Chunk := New_Chunk; end if; end Resize_Chunk; procedure Resize_Chunks (Data : in out Chunk_Array_Access; Size : in Natural; Chunk_Size : in Positive; Allocation_Unit : in Positive; Can_Shrink : in Boolean := True) is procedure Deallocate is new Ada.Unchecked_Deallocation (Chunk_Array, Chunk_Array_Access); Chunk_Nb : constant Natural := Chunks_For (Size, Chunk_Size, Allocation_Unit); Last_Chunk_Size : constant Natural := Units_For (Size, Chunk_Size, Allocation_Unit) * Allocation_Unit; begin if Size = 0 then if Can_Shrink then Free (Data); end if; return; end if; pragma Assert (Chunk_Nb > 0); if Data = null or else Data'Length < Chunk_Nb then declare First_New : Positive := 1; New_Data : constant Chunk_Array_Access := new Chunk_Array (1 .. Chunk_Nb); begin if Data /= null then Resize_Chunk (Data (Data'Last), Chunk_Size); New_Data (1 .. Data'Last) := Data.all; First_New := Data'Last + 1; Deallocate (Data); end if; Data := New_Data; for J in First_New .. Data'Last - 1 loop Data (J) := new String (1 .. Chunk_Size); end loop; Data (Data'Last) := new String (1 .. Last_Chunk_Size); end; elsif Data'Length > Chunk_Nb then if Can_Shrink then declare New_Data : constant Chunk_Array_Access := new Chunk_Array (1 .. Chunk_Nb); begin Resize_Chunk (Data (Chunk_Nb), Last_Chunk_Size); for J in Chunk_Nb + 1 .. Data'Last loop Free (Data (J)); end loop; New_Data.all := Data (1 .. Chunk_Nb); Data := New_Data; end; end if; else -- Data'Length = Chunk_Nb if Last_Chunk_Size > Data (Data'Last).all'Last or Can_Shrink then Resize_Chunk (Data (Data'Last), Last_Chunk_Size); end if; end if; end Resize_Chunks; function Units_For (Size : in Natural; Chunk_Size : in Positive; Allocation_Unit : in Positive) return Natural is begin return (((Size + Chunk_Size - 1) mod Chunk_Size + 1) + Allocation_Unit - 1) / Allocation_Unit; end Units_For; --------------------------- -- Low-level subprograms -- --------------------------- function Compare (Left : in Chunk_Array; Left_Size : in Natural; Right : in Chunk_Array; Right_Size : in Natural) return Relation is L_Chunk : Positive := Left'First; L_Pos : Positive := Left (L_Chunk).all'First; L_Remain : Natural := Left_Size; R_Chunk : Positive := Right'First; R_Pos : Positive := Right (R_Chunk).all'First; R_Remain : Natural := Right_Size; Step : Positive; begin loop Step := Positive'Min (Natural'Min (Left (L_Chunk).all'Last - L_Pos + 1, L_Remain), Natural'Min (Right (R_Chunk).all'Last - R_Pos + 1, R_Remain)); declare L_Part : String renames Left (L_Chunk).all (L_Pos .. L_Pos + Step - 1); R_Part : String renames Right (R_Chunk).all (R_Pos .. R_Pos + Step - 1); begin if L_Part < R_Part then return Lesser; elsif L_Part > R_Part then return Greater; end if; end; L_Remain := L_Remain - Step; R_Remain := R_Remain - Step; if L_Remain = 0 and R_Remain = 0 then return Equal; elsif L_Remain = 0 then return Lesser; elsif R_Remain = 0 then return Greater; end if; L_Pos := L_Pos + Step; R_Pos := R_Pos + Step; if L_Pos > Left (L_Chunk).all'Last then -- L_Chunk cannot be Left'Last because L_Remain > 0 L_Chunk := L_Chunk + 1; L_Pos := Left (L_Chunk).all'First; end if; if R_Pos > Right (R_Chunk).all'Last then -- R_Chunk cannot be Right'Last because R_Remain > 0 R_Chunk := R_Chunk + 1; R_Pos := Right (R_Chunk).all'First; end if; end loop; end Compare; function Compare (Left : in Chunk_Array_Access; Left_Size : in Natural; Right : in Chunk_Array_Access; Right_Size : in Natural) return Relation is begin if Left = null or Left_Size = 0 then if Right = null or Right_Size = 0 then return Equal; else return Lesser; end if; else if Right = null or Right_Size = 0 then return Greater; else return Compare (Left.all, Left_Size, Right.all, Right_Size); end if; end if; end Compare; function Compare (Left : in Chunk_Array; Left_Size : in Natural; Right : in String) return Relation is Chunk : Positive := Left'First; L_Pos : Positive := Left (Chunk).all'First; L_Remain : Natural := Left_Size; R_Pos : Positive := Right'First; Step : Positive; begin loop Step := Positive'Min (Positive'Min (Left (Chunk).all'Last - L_Pos + 1, L_Remain), Right'Last - R_Pos + 1); declare L_Part : String renames Left (Chunk).all (L_Pos .. L_Pos + Step - 1); R_Part : String renames Right (R_Pos .. R_Pos + Step - 1); begin if L_Part < R_Part then return Lesser; elsif L_Part > R_Part then return Greater; end if; end; L_Remain := L_Remain - Step; if L_Remain = 0 then if R_Pos + Step > Right'Last then return Equal; else return Lesser; end if; end if; L_Pos := L_Pos + Step; R_Pos := R_Pos + Step; if L_Pos > Left (Chunk).all'Last then -- _Chunk cannot be Left'Last because L_Remain > 0 Chunk := Chunk + 1; L_Pos := Left (Chunk).all'First; end if; if R_Pos > Right'Last then return Greater; end if; end loop; end Compare; function Compare (Left : in Chunk_Array_Access; Left_Size : in Natural; Right : in String) return Relation is begin if Left = null or Left_Size = 0 then if Right'Length = 0 then return Equal; else return Lesser; end if; else if Right'Length = 0 then return Greater; else return Compare (Left.all, Left_Size, Right); end if; end if; end Compare; procedure Fill (Data : in out Chunk_Array; From : in Positive; Count : in Natural; C : in Character; Chunk_Size : in Positive) is Chunk : Positive := (From - 1) / Chunk_Size + 1; Offset : Positive := (From - 1) mod Chunk_Size + 1; Done : Natural := 0; Step : Positive; begin while Done < Count loop Step := Positive'Min (Count - Done, Data (Chunk).all'Last - Offset + 1); Data (Chunk).all (Offset .. Offset + Step - 1) := Ada.Strings.Fixed."*" (Step, C); Chunk := Chunk + 1; Offset := 1; Done := Done + Step; end loop; end Fill; function Is_Valid (Source : in Chunked_String) return Boolean is begin -- Null data is only acceptable when the string is empty. if Source.Data = null then return Source.Size = 0; end if; -- Data array must contain non-null chunks of even size declare D : Chunk_Array renames Source.Data.all; begin if D'First /= 1 then return False; end if; for J in D'Range loop if D (J) = null then return False; end if; if D (J).all'First /= 1 or (J < D'Last and D (J).all'Last /= Source.Chunk_Size) then return False; end if; end loop; end; -- Real size must be smaller than allocated size if Source.Size > Allocated_Size (Source) then return False; end if; return True; end Is_Valid; procedure Move (Target : in out Chunk_Array; Target_Position : in Positive; Source : in out Chunk_Array; Source_Position : in Positive; Length : in Natural) is Count : Natural := 0; S_Chunk : Positive; S_Pos : Positive; T_Chunk : Positive; T_Pos : Positive; begin S_Chunk := Target'First; S_Pos := 1; while S_Pos + Source (S_Chunk).all'Length <= Source_Position loop S_Pos := S_Pos + Source (S_Chunk).all'Length; S_Chunk := S_Chunk + 1; end loop; S_Pos := Source_Position + 1 - S_Pos; T_Chunk := Target'First; T_Pos := 1; while T_Pos + Target (T_Chunk).all'Length <= Target_Position loop T_Pos := T_Pos + Target (T_Chunk).all'Length; T_Chunk := T_Chunk + 1; end loop; T_Pos := Target_Position + 1 - T_Pos; while Count < Length loop declare S_String : String renames Source (S_Chunk).all; T_String : String renames Target (T_Chunk).all; Step_C : constant Positive := Length - Count; Step_S : constant Positive := S_String'Last - S_Pos + 1; Step_T : constant Positive := T_String'Last - T_Pos + 1; Step : constant Positive := Positive'Min (Step_C, Positive'Min (Step_S, Step_T)); begin T_String (T_Pos .. T_Pos + Step - 1) := S_String (S_Pos .. S_Pos + Step - 1); Count := Count + Step; exit when Count >= Length; S_Pos := S_Pos + Step; T_Pos := T_Pos + Step; if S_Pos > S_String'Last then S_Chunk := S_Chunk + 1; S_Pos := Source (S_Chunk).all'First; end if; if T_Pos > T_String'Last then T_Chunk := T_Chunk + 1; T_Pos := Target (T_Chunk).all'First; end if; end; end loop; end Move; procedure Move (Target : in out Chunk_Array; Source : in String; Position : in Positive; Chunk_Size : in Positive) is Last_Position : constant Positive := Position + Source'Length - 1; First_Chunk : constant Positive := (Position - 1) / Chunk_Size + 1; First_Offset : constant Positive := (Position - 1) mod Chunk_Size + 1; Last_Chunk : constant Positive := (Last_Position - 1) / Chunk_Size + 1; Last_Offset : constant Positive := (Last_Position - 1) mod Chunk_Size + 1; Current : Positive; begin if First_Chunk = Last_Chunk then Target (First_Chunk).all (First_Offset .. Last_Offset) := Source; else Current := Source'First + Chunk_Size - First_Offset + 1; Target (First_Chunk).all (First_Offset .. Chunk_Size) := Source (Source'First .. Current - 1); for J in First_Chunk + 1 .. Last_Chunk - 1 loop Target (J).all := Source (Current .. Current + Chunk_Size - 1); Current := Current + Chunk_Size; end loop; Target (Last_Chunk).all (1 .. Last_Offset) := Source (Current .. Source'Last); end if; end Move; procedure Move (Target : out String; Source : in Chunk_Array; From : in Positive) is T_Pos : Positive := Target'First; S_Pos : Positive := 1; Chunk : Positive := 1; Step : Positive; begin while S_Pos + Source (Chunk).all'Length <= From loop S_Pos := S_Pos + Source (Chunk).all'Length; Chunk := Chunk + 1; end loop; S_Pos := From - S_Pos + 1; Step := Source (Chunk).all'Last - S_Pos + 1; if Target'Length <= Step then Target := Source (Chunk).all (S_Pos .. S_Pos + Target'Length - 1); return; end if; Target (T_Pos .. T_Pos + Step - 1) := Source (Chunk).all (S_Pos .. Source (Chunk).all'Last); T_Pos := T_Pos + Step; Chunk := Chunk + 1; while T_Pos <= Target'Last loop Step := Positive'Min (Source (Chunk).all'Length, Target'Last - T_Pos + 1); Target (T_Pos .. T_Pos + Step - 1) := Source (Chunk).all (1 .. Step); T_Pos := T_Pos + Step; Chunk := Chunk + 1; end loop; end Move; procedure Move (Data : in out Chunk_Array; Target_Position : in Positive; Source_Position : in Positive; Length : in Positive; Chunk_Size : in Positive) is begin if Target_Position < Source_Position then declare S_Chunk : Positive := (Source_Position - 1) / Chunk_Size + 1; S_Pos : Positive := (Source_Position - 1) mod Chunk_Size + 1; T_Chunk : Positive := (Target_Position - 1) / Chunk_Size + 1; T_Pos : Positive := (Target_Position - 1) mod Chunk_Size + 1; Count : Natural := 0; Step : Positive; begin while Count < Length loop Step := Positive'Min (Positive'Min (Data (S_Chunk).all'Last - S_Pos + 1, Data (T_Chunk).all'Last - T_Pos + 1), Length - Count); Data (T_Chunk).all (T_Pos .. T_Pos + Step - 1) := Data (S_Chunk).all (S_Pos .. S_Pos + Step - 1); Count := Count + Step; S_Pos := S_Pos + Step; if S_Pos > Chunk_Size then S_Chunk := S_Chunk + 1; S_Pos := 1; end if; T_Pos := T_Pos + Step; if T_Pos > Chunk_Size then T_Chunk := T_Chunk + 1; T_Pos := 1; end if; end loop; end; elsif Target_Position > Source_Position then declare S_End : constant Positive := Source_Position + Length - 1; T_End : constant Positive := Target_Position + Length - 1; S_Chunk : Positive := (S_End - 1) / Chunk_Size + 1; S_Pos : Positive := (S_End - 1) mod Chunk_Size + 1; T_Chunk : Positive := (T_End - 1) / Chunk_Size + 1; T_Pos : Positive := (T_End - 1) mod Chunk_Size + 1; Count : Natural := 0; Step : Positive; begin loop Step := Positive'Min (Positive'Min (S_Pos, T_Pos), Length - Count); Data (T_Chunk).all (T_Pos - Step + 1 .. T_Pos) := Data (S_Chunk).all (S_Pos - Step + 1 .. S_Pos); Count := Count + Step; exit when Count = Length; pragma Assert (Count < Length); if S_Pos <= Step then S_Chunk := S_Chunk - 1; S_Pos := Chunk_Size; else S_Pos := S_Pos - Step; end if; if T_Pos <= Step then T_Chunk := T_Chunk - 1; T_Pos := Chunk_Size; else T_Pos := T_Pos - Step; end if; end loop; end; end if; end Move; -------------------------------------------------- -- Public interface specific to Chunked_Strings -- -------------------------------------------------- function Build (Depth : Positive) return Natools.Accumulators.String_Accumulator'Class is pragma Unreferenced (Depth); begin return Null_Chunked_String; end Build; function Duplicate (Source : in Chunked_String) return Chunked_String is Data : Chunk_Array_Access := null; begin if Source.Data /= null then Data := new Chunk_Array (Source.Data'Range); for J in Source.Data'Range loop Data (J) := new String'(Source.Data (J).all); end loop; end if; return Chunked_String'(Ada.Finalization.Controlled with Chunk_Size => Source.Chunk_Size, Allocation_Unit => Source.Allocation_Unit, Size => Source.Size, Data => Data); end Duplicate; procedure Hard_Reset (Str : in out Chunked_String) is begin Str.Size := 0; Free (Str.Data); end Hard_Reset; procedure Soft_Reset (Str : in out Chunked_String) is begin Str.Size := 0; end Soft_Reset; procedure To_String (Source : Chunked_String; Output : out String) is Position : Positive := Output'First; Step : Positive; begin if Source.Size > 0 then for J in Source.Data'Range loop Step := Positive'Min (Source.Data (J).all'Length, Source.Size - Position + 1); Output (Position .. Position + Step - 1) := Source.Data (J).all (1 .. Step); Position := Position + Step; exit when Position > Source.Size; end loop; pragma Assert (Position = Source.Size + 1); end if; end To_String; ------------------------------------------- -- String_Accumulator specific interface -- ------------------------------------------- function Tail (Source : in Chunked_String; Size : in Natural) return String is Actual_Size : constant Natural := Natural'Min (Size, Source.Size); begin return Slice (Source, Source.Size - Actual_Size + 1, Source.Size); end Tail; procedure Unappend (From : in out Chunked_String; Text : in String) is begin if Text'Length <= From.Size and then String'(Tail (From, Text'Length)) = Text then From.Size := From.Size - Text'Length; end if; end Unappend; ------------------------ -- Standard interface -- ------------------------ function Length (Source : in Chunked_String) return Natural is begin return Source.Size; end Length; procedure Deallocate is new Ada.Unchecked_Deallocation (String, String_Access); procedure Free (X : in out String_Access) is begin Deallocate (X); end Free; procedure Free_Extra_Memory (From : in out Chunked_String) is begin Resize_Chunks (From.Data, From.Size, From.Chunk_Size, From.Allocation_Unit, Can_Shrink => True); end Free_Extra_Memory; procedure Preallocate (Str : in out Chunked_String; Size : Natural) is begin Resize_Chunks (Str.Data, Size, Str.Chunk_Size, Str.Allocation_Unit, Can_Shrink => False); end Preallocate; function To_Chunked_String (Source : in String; Chunk_Size : in Positive := Default_Chunk_Size; Allocation_Unit : in Positive := Default_Allocation_Unit) return Chunked_String is Data : Chunk_Array_Access := null; begin if Source'Length > 0 then Resize_Chunks (Data, Source'Length, Chunk_Size, Allocation_Unit); Move (Data.all, Source, 1, Chunk_Size); end if; return Chunked_String'(Ada.Finalization.Controlled with Chunk_Size => Chunk_Size, Allocation_Unit => Allocation_Unit, Size => Source'Length, Data => Data); end To_Chunked_String; function To_Chunked_String (Length : in Natural; Chunk_Size : in Positive := Default_Chunk_Size; Allocation_Unit : in Positive := Default_Allocation_Unit) return Chunked_String is Data : Chunk_Array_Access := null; begin Resize_Chunks (Data, Length, Chunk_Size, Allocation_Unit); return Chunked_String'(Ada.Finalization.Controlled with Chunk_Size => Chunk_Size, Allocation_Unit => Allocation_Unit, Size => Length, Data => Data); end To_Chunked_String; function To_String (Source : in Chunked_String) return String is Value : String (1 .. Source.Size); begin To_String (Source, Value); return Value; end To_String; procedure Set_Chunked_String (Target : out Chunked_String; Source : in String; Chunk_Size : in Positive := Default_Chunk_Size; Allocation_Unit : in Positive := Default_Allocation_Unit) is begin Resize_Chunks (Target.Data, Source'Length, Chunk_Size, Allocation_Unit, Can_Shrink => True); Target.Chunk_Size := Chunk_Size; Target.Allocation_Unit := Allocation_Unit; Target.Size := Source'Length; if Target.Size > 0 then Move (Target.Data.all, Source, 1, Chunk_Size); end if; end Set_Chunked_String; procedure Append (Source : in out Chunked_String; New_Item : in Chunked_String) is New_Size : constant Natural := Source.Size + New_Item.Size; begin Resize_Chunks (Source.Data, New_Size, Source.Chunk_Size, Source.Allocation_Unit, Can_Shrink => False); Move (Source.Data.all, Source.Size + 1, New_Item.Data.all, 1, New_Item.Size); Source.Size := New_Size; end Append; procedure Append (Source : in out Chunked_String; New_Item : in String) is New_Size : constant Natural := Source.Size + New_Item'Length; begin Resize_Chunks (Source.Data, New_Size, Source.Chunk_Size, Source.Allocation_Unit, Can_Shrink => False); Move (Source.Data.all, New_Item, Source.Size + 1, Source.Chunk_Size); Source.Size := New_Size; end Append; procedure Append (Source : in out Chunked_String; New_Item : in Character) is S : constant String (1 .. 1) := (1 => New_Item); begin Append (Source, S); end Append; function "&" (Left, Right : in Chunked_String) return Chunked_String is Size : constant Natural := Left.Size + Right.Size; Data : Chunk_Array_Access := null; begin Resize_Chunks (Data, Size, Default_Chunk_Size, Default_Allocation_Unit); if Left.Size > 0 then Move (Data.all, 1, Left.Data.all, 1, Left.Size); end if; if Right.Size > 0 then Move (Data.all, 1 + Left.Size, Right.Data.all, 1, Right.Size); end if; return Chunked_String'(Ada.Finalization.Controlled with Chunk_Size => Default_Chunk_Size, Allocation_Unit => Default_Allocation_Unit, Size => Size, Data => Data); end "&"; function "&" (Left : in Chunked_String; Right : in String) return Chunked_String is Size : constant Natural := Left.Size + Right'Length; Data : Chunk_Array_Access := null; begin Resize_Chunks (Data, Size, Default_Chunk_Size, Default_Allocation_Unit); if Left.Size > 0 then Move (Data.all, 1, Left.Data.all, 1, Left.Size); end if; if Right'Length > 0 then Move (Data.all, Right, 1 + Left.Size, Default_Chunk_Size); end if; return Chunked_String'(Ada.Finalization.Controlled with Chunk_Size => Default_Chunk_Size, Allocation_Unit => Default_Allocation_Unit, Size => Size, Data => Data); end "&"; function "&" (Left : in String; Right : in Chunked_String) return Chunked_String is Size : constant Natural := Left'Length + Right.Size; Data : Chunk_Array_Access := null; begin Resize_Chunks (Data, Size, Default_Chunk_Size, Default_Allocation_Unit); if Left'Length > 0 then Move (Data.all, Left, 1, Default_Chunk_Size); end if; if Right.Size > 0 then Move (Data.all, 1 + Left'Length, Right.Data.all, 1, Right.Size); end if; return Chunked_String'(Ada.Finalization.Controlled with Chunk_Size => Default_Chunk_Size, Allocation_Unit => Default_Allocation_Unit, Size => Size, Data => Data); end "&"; function "&" (Left : in Chunked_String; Right : in Character) return Chunked_String is Size : constant Natural := Left.Size + 1; Allocation_Unit : constant Positive := Default_Allocation_Unit; Chunk_Size : constant Positive := Default_Chunk_Size; Data : Chunk_Array_Access := null; begin Resize_Chunks (Data, Size, Chunk_Size, Allocation_Unit); if Left.Size > 0 then Move (Data.all, 1, Left.Data.all, 1, Left.Size); end if; declare Position : constant Positive := Left.Size + 1; Chunk : constant Positive := (Position - 1) / Chunk_Size + 1; Offset : constant Positive := (Position - 1) mod Chunk_Size + 1; begin Data (Chunk).all (Offset) := Right; end; return Chunked_String'(Ada.Finalization.Controlled with Chunk_Size => Chunk_Size, Allocation_Unit => Allocation_Unit, Size => Size, Data => Data); end "&"; function "&" (Left : in Character; Right : in Chunked_String) return Chunked_String is Size : constant Natural := 1 + Right.Size; Data : Chunk_Array_Access := null; begin Resize_Chunks (Data, Size, Default_Chunk_Size, Default_Allocation_Unit); Data (1).all (1) := Left; if Right.Size > 0 then Move (Data.all, 2, Right.Data.all, 1, Right.Size); end if; return Chunked_String'(Ada.Finalization.Controlled with Chunk_Size => Default_Chunk_Size, Allocation_Unit => Default_Allocation_Unit, Size => Size, Data => Data); end "&"; function Element (Source : in Chunked_String; Index : in Positive) return Character is Chunk : constant Positive := (Index - 1) / Source.Chunk_Size + 1; Offset : constant Positive := (Index - 1) mod Source.Chunk_Size + 1; begin if Index > Source.Size then raise Ada.Strings.Index_Error; end if; return Source.Data (Chunk).all (Offset); end Element; procedure Replace_Element (Source : in out Chunked_String; Index : in Positive; By : in Character) is Chunk : constant Positive := (Index - 1) / Source.Chunk_Size + 1; Offset : constant Positive := (Index - 1) mod Source.Chunk_Size + 1; begin if Index > Source.Size then raise Ada.Strings.Index_Error; end if; Source.Data (Chunk).all (Offset) := By; end Replace_Element; function Slice (Source : in Chunked_String; Low : in Positive; High : in Natural) return String is Returned : String (Low .. High); begin if Low > Source.Size + 1 or High > Source.Size then raise Ada.Strings.Index_Error; end if; if High >= Low then Move (Returned, Source.Data.all, Low); end if; return Returned; end Slice; function Chunked_Slice (Source : in Chunked_String; Low : in Positive; High : in Natural; Chunk_Size : in Positive := Default_Chunk_Size; Allocation_Unit : in Positive := Default_Allocation_Unit) return Chunked_String is Data : Chunk_Array_Access := null; Size : Natural := 0; begin if Low > Source.Size + 1 or High > Source.Size then raise Ada.Strings.Index_Error; end if; if Low <= High then Size := High - Low + 1; Resize_Chunks (Data, Size, Chunk_Size, Allocation_Unit); Move (Data.all, 1, Source.Data.all, Low, Size); end if; return Chunked_String'(Ada.Finalization.Controlled with Chunk_Size => Chunk_Size, Allocation_Unit => Allocation_Unit, Size => Size, Data => Data); end Chunked_Slice; procedure Chunked_Slice (Source : in Chunked_String; Target : out Chunked_String; Low : in Positive; High : in Natural; Chunk_Size : in Positive := Default_Chunk_Size; Allocation_Unit : in Positive := Default_Allocation_Unit) is begin if Low > Source.Size + 1 or High > Source.Size then raise Ada.Strings.Index_Error; end if; Target.Chunk_Size := Chunk_Size; Target.Allocation_Unit := Allocation_Unit; if Low <= High then Target.Size := High - Low + 1; Resize_Chunks (Target.Data, Target.Size, Chunk_Size, Allocation_Unit, Can_Shrink => True); Move (Target.Data.all, 1, Source.Data.all, Low, Target.Size); else Target.Size := 0; Target.Data := null; end if; end Chunked_Slice; function "=" (Left, Right : in Chunked_String) return Boolean is begin return Compare (Left.Data, Left.Size, Right.Data, Right.Size) = Equal; end "="; function "=" (Left : in Chunked_String; Right : in String) return Boolean is begin return Compare (Left.Data, Left.Size, Right) = Equal; end "="; function "=" (Left : in String; Right : in Chunked_String) return Boolean is begin return Compare (Right.Data, Right.Size, Left) = Equal; end "="; function "<" (Left, Right : in Chunked_String) return Boolean is begin return Compare (Left.Data, Left.Size, Right.Data, Right.Size) = Lesser; end "<"; function "<" (Left : in Chunked_String; Right : in String) return Boolean is begin return Compare (Left.Data, Left.Size, Right) = Lesser; end "<"; function "<" (Left : in String; Right : in Chunked_String) return Boolean is begin return Compare (Right.Data, Right.Size, Left) = Greater; end "<"; function "<=" (Left, Right : in Chunked_String) return Boolean is begin return Compare (Left.Data, Left.Size, Right.Data, Right.Size) /= Greater; end "<="; function "<=" (Left : in Chunked_String; Right : in String) return Boolean is begin return Compare (Left.Data, Left.Size, Right) /= Greater; end "<="; function "<=" (Left : in String; Right : in Chunked_String) return Boolean is begin return Compare (Right.Data, Right.Size, Left) /= Lesser; end "<="; function ">" (Left, Right : in Chunked_String) return Boolean is begin return Compare (Left.Data, Left.Size, Right.Data, Right.Size) = Greater; end ">"; function ">" (Left : in Chunked_String; Right : in String) return Boolean is begin return Compare (Left.Data, Left.Size, Right) = Greater; end ">"; function ">" (Left : in String; Right : in Chunked_String) return Boolean is begin return Compare (Right.Data, Right.Size, Left) = Lesser; end ">"; function ">=" (Left, Right : in Chunked_String) return Boolean is begin return Compare (Left.Data, Left.Size, Right.Data, Right.Size) /= Lesser; end ">="; function ">=" (Left : in Chunked_String; Right : in String) return Boolean is begin return Compare (Left.Data, Left.Size, Right) /= Lesser; end ">="; function ">=" (Left : in String; Right : in Chunked_String) return Boolean is begin return Compare (Right.Data, Right.Size, Left) /= Greater; end ">="; function Index_Gen (Source : Chunked_String; Pattern : String; From : Positive; Going : Ada.Strings.Direction; Map : Map_Type) return Natural is begin if Pattern = "" then raise Ada.Strings.Pattern_Error; end if; if Source.Size = 0 and From = 1 then return 0; end if; if From > Source.Size then raise Ada.Strings.Index_Error; end if; declare Chunk : Positive := (From - 1) / Source.Chunk_Size + 1; Offset : Positive := (From - 1) mod Source.Chunk_Size + 1; Buffer : String (1 .. Source.Chunk_Size + Pattern'Length - 1); Result : Natural; Span : Positive; begin case (Going) is when Ada.Strings.Forward => while (Chunk - 1) * Source.Chunk_Size + Pattern'Length <= Source.Size loop Span := Positive'Min (Source.Chunk_Size + Pattern'Length - 1, Source.Size - (Chunk - 1) * Source.Chunk_Size); Move (Buffer (1 .. Span), Source.Data.all, (Chunk - 1) * Source.Chunk_Size + 1); Result := Index (Buffer (1 .. Span), Pattern, Offset, Going, Map); if Result /= 0 then return (Chunk - 1) * Source.Chunk_Size + Result; end if; Chunk := Chunk + 1; Offset := 1; end loop; return 0; when Ada.Strings.Backward => loop Span := Positive'Min (Source.Chunk_Size + Pattern'Length - 1, Source.Size - (Chunk - 1) * Source.Chunk_Size); Move (Buffer (1 .. Span), Source.Data.all, (Chunk - 1) * Source.Chunk_Size + 1); Result := Index (Buffer (1 .. Span), Pattern, Offset, Going, Map); if Result /= 0 then return (Chunk - 1) * Source.Chunk_Size + Result; end if; exit when Chunk = 1; Chunk := Chunk - 1; Offset := Positive'Min (Source.Chunk_Size + Pattern'Length - 1, Source.Chunk_Size + Offset); end loop; return 0; end case; end; end Index_Gen; function Index_Mapping is new Index_Gen (Maps.Character_Mapping, Ada.Strings.Fixed.Index); function Index (Source : in Chunked_String; Pattern : in String; From : in Positive; Going : in Ada.Strings.Direction := Ada.Strings.Forward; Mapping : in Maps.Character_Mapping := Maps.Identity) return Natural renames Index_Mapping; function Index_Mapping_Function is new Index_Gen (Maps.Character_Mapping_Function, Ada.Strings.Fixed.Index); function Index (Source : in Chunked_String; Pattern : in String; From : in Positive; Going : in Ada.Strings.Direction := Ada.Strings.Forward; Mapping : in Maps.Character_Mapping_Function) return Natural renames Index_Mapping_Function; function Index (Source : in Chunked_String; Pattern : in String; Going : in Ada.Strings.Direction := Ada.Strings.Forward; Mapping : in Maps.Character_Mapping := Maps.Identity) return Natural is begin case (Going) is when Ada.Strings.Forward => return Index (Source, Pattern, 1, Going, Mapping); when Ada.Strings.Backward => return Index (Source, Pattern, Source.Size, Going, Mapping); end case; end Index; function Index (Source : in Chunked_String; Pattern : in String; Going : in Ada.Strings.Direction := Ada.Strings.Forward; Mapping : in Maps.Character_Mapping_Function) return Natural is begin case (Going) is when Ada.Strings.Forward => return Index (Source, Pattern, 1, Going, Mapping); when Ada.Strings.Backward => return Index (Source, Pattern, Source.Size, Going, Mapping); end case; end Index; function Index (Source : in Chunked_String; Set : in Maps.Character_Set; From : in Positive; Test : in Ada.Strings.Membership := Ada.Strings.Inside; Going : in Ada.Strings.Direction := Ada.Strings.Forward) return Natural is Chunk : Positive := (From - 1) / Source.Chunk_Size + 1; Offset : Positive := (From - 1) mod Source.Chunk_Size + 1; Result : Natural; begin if From > Source.Size then raise Ada.Strings.Index_Error; end if; case (Going) is when Ada.Strings.Forward => loop Result := Ada.Strings.Fixed.Index (Source.Data (Chunk).all (1 .. Positive'Min (Source.Size - (Chunk - 1) * Source.Chunk_Size, Source.Chunk_Size)), Set, Offset, Test, Going); if Result /= 0 then return (Chunk - 1) * Source.Chunk_Size + Result; end if; if Chunk = Source.Data'Last then return 0; end if; Chunk := Chunk + 1; Offset := 1; end loop; when Ada.Strings.Backward => loop Result := Ada.Strings.Fixed.Index (Source.Data (Chunk).all (1 .. Positive'Min (Source.Size - (Chunk - 1) * Source.Chunk_Size, Source.Chunk_Size)), Set, Offset, Test, Going); if Result /= 0 then return (Chunk - 1) * Source.Chunk_Size + Result; end if; if Chunk = Source.Data'First then return 0; end if; Chunk := Chunk - 1; Offset := Source.Chunk_Size; end loop; end case; end Index; function Index (Source : in Chunked_String; Set : in Maps.Character_Set; Test : in Ada.Strings.Membership := Ada.Strings.Inside; Going : in Ada.Strings.Direction := Ada.Strings.Forward) return Natural is begin case Going is when Ada.Strings.Forward => return Index (Source, Set, 1, Test, Going); when Ada.Strings.Backward => return Index (Source, Set, Source.Size, Test, Going); end case; end Index; function Index_Non_Blank (Source : in Chunked_String; From : in Positive; Going : in Ada.Strings.Direction := Ada.Strings.Forward) return Natural is begin return Index (Source, Maps.To_Set (Ada.Strings.Space), From, Ada.Strings.Outside, Going); end Index_Non_Blank; function Index_Non_Blank (Source : in Chunked_String; Going : in Ada.Strings.Direction := Ada.Strings.Forward) return Natural is begin return Index (Source, Maps.To_Set (Ada.Strings.Space), Ada.Strings.Outside, Going); end Index_Non_Blank; function Count_Gen (Source : in Chunked_String; Pattern : in String; Mapping : in Map_Type) return Natural is Buffer : String (1 .. Source.Chunk_Size + Pattern'Length - 1); Result : Natural := 0; Step : Positive; begin if Pattern = "" then raise Ada.Strings.Pattern_Error; end if; if Source.Size < Pattern'Length then return 0; end if; for J in Source.Data'Range loop Step := Positive'Min (Source.Size - (J - 1) * Source.Chunk_Size, Source.Chunk_Size + Pattern'Length - 1); Move (Buffer (1 .. Step), Source.Data.all, (J - 1) * Source.Chunk_Size + 1); Result := Result + Count (Buffer (1 .. Step), Pattern, Mapping); end loop; return Result; end Count_Gen; function Count_Mapping is new Count_Gen (Maps.Character_Mapping, Ada.Strings.Fixed.Count); function Count (Source : in Chunked_String; Pattern : in String; Mapping : in Maps.Character_Mapping := Maps.Identity) return Natural renames Count_Mapping; function Count_Mapping_Function is new Count_Gen (Maps.Character_Mapping_Function, Ada.Strings.Fixed.Count); function Count (Source : in Chunked_String; Pattern : in String; Mapping : in Maps.Character_Mapping_Function) return Natural renames Count_Mapping_Function; function Count (Source : in Chunked_String; Set : in Maps.Character_Set) return Natural is Result : Natural := 0; Done : Natural := 0; begin if Source.Size > 0 then for C in Source.Data'Range loop declare Chunk : String renames Source.Data (C).all; Step : constant Natural := Natural'Min (Source.Size - Done, Chunk'Length); begin Result := Result + Ada.Strings.Fixed.Count (Chunk (Chunk'First .. Chunk'First + Step - 1), Set); Done := Done + Step; end; end loop; end if; return Result; end Count; procedure Find_Token (Source : in Chunked_String; Set : in Maps.Character_Set; Test : in Ada.Strings.Membership; First : out Positive; Last : out Natural) is Invert : constant array (Ada.Strings.Membership) of Ada.Strings.Membership := (Ada.Strings.Inside => Ada.Strings.Outside, Ada.Strings.Outside => Ada.Strings.Inside); N : Natural; begin N := Index (Source, Set, Test); if N = 0 then First := 1; Last := 0; else First := N; N := Index (Source, Set, First, Invert (Test)); if N = 0 then Last := Source.Size; else Last := N - 1; end if; end if; end Find_Token; -- String translation subprograms function Translate (Source : in Chunked_String; Mapping : in Maps.Character_Mapping) return Chunked_String is Data : Chunk_Array_Access := null; begin if Source.Data /= null then Data := new Chunk_Array (Source.Data'Range); for J in Source.Data'Range loop Data (J) := new String (Source.Data (J).all'Range); Data (J).all := Fixed.Translate (Source.Data (J).all, Mapping); end loop; end if; return Chunked_String'(Ada.Finalization.Controlled with Chunk_Size => Source.Chunk_Size, Allocation_Unit => Source.Allocation_Unit, Size => Source.Size, Data => Data); end Translate; procedure Translate (Source : in out Chunked_String; Mapping : in Maps.Character_Mapping) is begin if Source.Data /= null then for J in Source.Data'Range loop Fixed.Translate (Source.Data (J).all, Mapping); end loop; end if; end Translate; function Translate (Source : in Chunked_String; Mapping : in Maps.Character_Mapping_Function) return Chunked_String is Data : Chunk_Array_Access := null; begin if Source.Data /= null then Data := new Chunk_Array (Source.Data'Range); for J in Source.Data'Range loop Data (J) := new String (Source.Data (J).all'Range); Data (J).all := Fixed.Translate (Source.Data (J).all, Mapping); end loop; end if; return Chunked_String'(Ada.Finalization.Controlled with Chunk_Size => Source.Chunk_Size, Allocation_Unit => Source.Allocation_Unit, Size => Source.Size, Data => Data); end Translate; procedure Translate (Source : in out Chunked_String; Mapping : in Maps.Character_Mapping_Function) is begin if Source.Data /= null then for J in Source.Data'Range loop Fixed.Translate (Source.Data (J).all, Mapping); end loop; end if; end Translate; -- String transformation subprograms function Replace_Slice (Source : in Chunked_String; Low : in Positive; High : in Natural; By : in String) return Chunked_String is Size : Natural := 0; Data : Chunk_Array_Access := null; Hi : Natural := High; begin if Low > Source.Size + 1 then raise Ada.Strings.Index_Error; end if; if High < Low then Hi := Low - 1; end if; Size := (Low - 1) + By'Length + (Source.Size - Hi); Resize_Chunks (Data, Size, Source.Chunk_Size, Source.Allocation_Unit, Can_Shrink => False); if Low > 1 then Move (Data.all, 1, Source.Data.all, 1, Low - 1); end if; if By'Length > 0 then Move (Data.all, By, Low, Source.Chunk_Size); end if; if Hi < Source.Size then Move (Data.all, Low + By'Length, Source.Data.all, Hi + 1, Source.Size - Hi); end if; return Chunked_String'(Ada.Finalization.Controlled with Chunk_Size => Source.Chunk_Size, Allocation_Unit => Source.Allocation_Unit, Size => Size, Data => Data); end Replace_Slice; procedure Replace_Slice (Source : in out Chunked_String; Low : in Positive; High : in Natural; By : in String) is Size : Natural := 0; Hi : Natural := High; begin if Low > Source.Size + 1 then raise Ada.Strings.Index_Error; end if; if High < Low then Hi := Low - 1; end if; Size := (Low - 1) + By'Length + (Source.Size - Hi); Resize_Chunks (Source.Data, Size, Source.Chunk_Size, Source.Allocation_Unit, Can_Shrink => False); if Hi < Source.Size and Low + By'Length /= Hi + 1 then Move (Data => Source.Data.all, Target_Position => Low + By'Length, Source_Position => Hi + 1, Length => Source.Size - Hi, Chunk_Size => Source.Chunk_Size); end if; if By'Length > 0 then Move (Source.Data.all, By, Low, Source.Chunk_Size); end if; Source.Size := Size; end Replace_Slice; function Insert (Source : in Chunked_String; Before : in Positive; New_Item : in String) return Chunked_String is begin return Replace_Slice (Source, Before, Before - 1, New_Item); end Insert; procedure Insert (Source : in out Chunked_String; Before : in Positive; New_Item : in String) is begin Replace_Slice (Source, Before, Before - 1, New_Item); end Insert; function Overwrite (Source : in Chunked_String; Position : in Positive; New_Item : in String) return Chunked_String is begin return Replace_Slice (Source, Position, Source.Size, New_Item); end Overwrite; procedure Overwrite (Source : in out Chunked_String; Position : in Positive; New_Item : in String) is begin Replace_Slice (Source, Low => Position, High => Natural'Min (Source.Size, Position + New_Item'Length - 1), By => New_Item); end Overwrite; function Delete (Source : in Chunked_String; From : in Positive; Through : in Natural) return Chunked_String is begin if From <= Through then return Replace_Slice (Source, From, Through, ""); else return Duplicate (Source); end if; end Delete; procedure Delete (Source : in out Chunked_String; From : in Positive; Through : in Natural) is begin if From <= Through then Replace_Slice (Source, From, Through, ""); end if; end Delete; function Trim (Source : in Chunked_String; Side : in Ada.Strings.Trim_End) return Chunked_String is begin case Side is when Ada.Strings.Left => return Trim (Source, Maps.To_Set (Ada.Strings.Space), Maps.Null_Set); when Ada.Strings.Right => return Trim (Source, Maps.Null_Set, Maps.To_Set (Ada.Strings.Space)); when Ada.Strings.Both => return Trim (Source, Maps.To_Set (Ada.Strings.Space), Maps.To_Set (Ada.Strings.Space)); end case; end Trim; procedure Trim (Source : in out Chunked_String; Side : in Ada.Strings.Trim_End) is begin case Side is when Ada.Strings.Left => Trim (Source, Maps.To_Set (Ada.Strings.Space), Maps.Null_Set); when Ada.Strings.Right => Trim (Source, Maps.Null_Set, Maps.To_Set (Ada.Strings.Space)); when Ada.Strings.Both => Trim (Source, Maps.To_Set (Ada.Strings.Space), Maps.To_Set (Ada.Strings.Space)); end case; end Trim; procedure Trim_Bounds (Source : in Chunked_String; Left : in Maps.Character_Set; Right : in Maps.Character_Set; Low : out Positive; High : out Natural) is Chunk : Positive; begin Low := 1; High := Source.Size; Chunk := 1; while Low <= High and then Maps.Is_In (Source.Data (Chunk).all (Low - (Chunk - 1) * Source.Chunk_Size), Left) loop Low := Low + 1; if Low mod Source.Chunk_Size = 1 then Chunk := Chunk + 1; end if; end loop; if High > 0 then Chunk := (High - 1) / Source.Chunk_Size + 1; while Low <= High and then Maps.Is_In (Source.Data (Chunk).all (High - (Chunk - 1) * Source.Chunk_Size), Right) loop High := High - 1; if High mod Source.Chunk_Size = 0 then Chunk := Chunk - 1; end if; end loop; end if; end Trim_Bounds; function Trim (Source : in Chunked_String; Left : in Maps.Character_Set; Right : in Maps.Character_Set) return Chunked_String is Low : Positive; High : Natural; begin Trim_Bounds (Source, Left, Right, Low, High); return Chunked_Slice (Source, Low, High, Source.Chunk_Size, Source.Allocation_Unit); end Trim; procedure Trim (Source : in out Chunked_String; Left : in Maps.Character_Set; Right : in Maps.Character_Set) is Low : Positive; High : Natural; begin Trim_Bounds (Source, Left, Right, Low, High); if Low > 1 then Move (Data => Source.Data.all, Target_Position => 1, Source_Position => Low, Length => High - Low + 1, Chunk_Size => Source.Chunk_Size); end if; Source.Size := High - Low + 1; end Trim; function Head (Source : in Chunked_String; Count : in Natural; Pad : in Character := Ada.Strings.Space; Chunk_Size : in Natural := 0; -- use value from Source Allocation_Unit : in Natural := 0) -- use value from Source return Chunked_String is Real_Chunk_Size : Positive := Default_Chunk_Size; Real_Unit : Positive := Default_Allocation_Unit; Data : Chunk_Array_Access := null; begin if Chunk_Size > 0 then Real_Chunk_Size := Chunk_Size; end if; if Allocation_Unit > 0 then Real_Unit := Allocation_Unit; end if; if Count > 0 then Resize_Chunks (Data, Count, Real_Chunk_Size, Real_Unit); if Count > Source.Size then Move (Data.all, 1, Source.Data.all, 1, Source.Size); Fill (Data.all, Source.Size + 1, Count - Source.Size, Pad, Real_Chunk_Size); else Move (Data.all, 1, Source.Data.all, 1, Count); end if; end if; return Chunked_String'(Ada.Finalization.Controlled with Chunk_Size => Real_Chunk_Size, Allocation_Unit => Real_Unit, Size => Count, Data => Data); end Head; procedure Head (Source : in out Chunked_String; Count : in Natural; Pad : in Character := Ada.Strings.Space) is begin if Count > Source.Size then Resize_Chunks (Source.Data, Count, Source.Chunk_Size, Source.Allocation_Unit, Can_Shrink => False); Fill (Source.Data.all, Source.Size + 1, Count - Source.Size, Pad, Source.Chunk_Size); end if; Source.Size := Count; end Head; function Tail (Source : in Chunked_String; Count : in Natural; Pad : in Character := Ada.Strings.Space; Chunk_Size : in Natural := 0; -- use value from Source Allocation_Unit : in Natural := 0) -- use value from Source return Chunked_String is Real_Chunk_Size : Positive := Default_Chunk_Size; Real_Unit : Positive := Default_Allocation_Unit; Data : Chunk_Array_Access := null; begin if Chunk_Size > 0 then Real_Chunk_Size := Chunk_Size; end if; if Allocation_Unit > 0 then Real_Unit := Allocation_Unit; end if; if Count > 0 then Resize_Chunks (Data, Count, Real_Chunk_Size, Real_Unit); if Count > Source.Size then Fill (Data.all, 1, Count - Source.Size, Pad, Real_Chunk_Size); Move (Data.all, Count - Source.Size + 1, Source.Data.all, 1, Source.Size); else Move (Data.all, 1, Source.Data.all, Source.Size - Count + 1, Count); end if; end if; return Chunked_String'(Ada.Finalization.Controlled with Chunk_Size => Real_Chunk_Size, Allocation_Unit => Real_Unit, Size => Count, Data => Data); end Tail; procedure Tail (Source : in out Chunked_String; Count : in Natural; Pad : in Character := Ada.Strings.Space) is begin Resize_Chunks (Source.Data, Count, Source.Chunk_Size, Source.Allocation_Unit, Can_Shrink => False); if Count > Source.Size then if Source.Size > 0 then Move (Data => Source.Data.all, Target_Position => Count - Source.Size + 1, Source_Position => 1, Length => Source.Size, Chunk_Size => Source.Chunk_Size); end if; Fill (Source.Data.all, 1, Count - Source.Size, Pad, Source.Chunk_Size); elsif Count > 0 then Move (Data => Source.Data.all, Target_Position => 1, Source_Position => Source.Size - Count + 1, Length => Count, Chunk_Size => Source.Chunk_Size); end if; Source.Size := Count; end Tail; function "*" (Left : in Natural; Right : in Character) return Chunked_String is Chunk_Size : constant Positive := Default_Chunk_Size; Allocation_Unit : constant Positive := Default_Allocation_Unit; Size : constant Natural := Left; Chunk_Nb : constant Natural := Chunks_For (Size, Chunk_Size, Allocation_Unit); Last_Chunk_Size : constant Natural := Units_For (Size, Chunk_Size, Allocation_Unit) * Allocation_Unit; Data : Chunk_Array_Access := null; begin if Size > 0 then Data := new Chunk_Array (1 .. Chunk_Nb); for J in 1 .. Chunk_Nb - 1 loop Data (J) := new String'(Ada.Strings.Fixed."*" (Chunk_Size, Right)); end loop; Data (Chunk_Nb) := new String'(Ada.Strings.Fixed."*" (Last_Chunk_Size, Right)); end if; return Chunked_String'(Ada.Finalization.Controlled with Chunk_Size => Chunk_Size, Allocation_Unit => Allocation_Unit, Size => Size, Data => Data); end "*"; function "*" (Left : in Natural; Right : in String) return Chunked_String is Chunk_Size : constant Positive := Default_Chunk_Size; Allocation_Unit : constant Positive := Default_Allocation_Unit; Size : constant Natural := Left * Right'Length; Chunk_Nb : constant Natural := Chunks_For (Size, Chunk_Size, Allocation_Unit); Last_Chunk_Size : constant Natural := Units_For (Size, Chunk_Size, Allocation_Unit) * Allocation_Unit; Data : Chunk_Array_Access := null; begin if Size > 0 then if Chunk_Size mod Right'Length = 0 then Data := new Chunk_Array (1 .. Chunk_Nb); for J in 1 .. Chunk_Nb - 1 loop Data (J) := new String'(Ada.Strings.Fixed."*" (Chunk_Size / Right'Length, Right)); end loop; Data (Chunk_Nb) := new String'(Ada.Strings.Fixed."*" (Last_Chunk_Size / Right'Length, Right)); else Resize_Chunks (Data, Size, Chunk_Size, Allocation_Unit); for J in 1 .. Left loop Move (Data.all, Right, (J - 1) * Right'Length + 1, Chunk_Size); end loop; end if; end if; return Chunked_String'(Ada.Finalization.Controlled with Chunk_Size => Chunk_Size, Allocation_Unit => Allocation_Unit, Size => Size, Data => Data); end "*"; function "*" (Left : in Natural; Right : in Chunked_String) return Chunked_String is Chunk_Size : constant Positive := Default_Chunk_Size; Allocation_Unit : constant Positive := Default_Allocation_Unit; Size : constant Natural := Left * Right.Size; Data : Chunk_Array_Access := null; begin if Size > 0 then Resize_Chunks (Data, Size, Chunk_Size, Allocation_Unit); for J in 1 .. Left loop Move (Data.all, (J - 1) * Right.Size + 1, Right.Data.all, 1, Right.Size); end loop; end if; return Chunked_String'(Ada.Finalization.Controlled with Chunk_Size => Chunk_Size, Allocation_Unit => Allocation_Unit, Size => Size, Data => Data); end "*"; -- Controlled object methods overriding procedure Initialize (Object : in out Chunked_String) is begin Object.Size := 0; Object.Data := null; end Initialize; overriding procedure Adjust (Object : in out Chunked_String) is New_Data : Chunk_Array_Access; begin if Object.Data /= null then New_Data := new Chunk_Array (Object.Data'Range); for J in Object.Data'Range loop New_Data (J) := new String'(Object.Data (J).all); end loop; Object.Data := New_Data; end if; end Adjust; overriding procedure Finalize (Object : in out Chunked_String) is begin Free (Object.Data); end Finalize; end Natools.Chunked_Strings;
-- -- Copyright 2018 The wookey project team <wookey@ssi.gouv.fr> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- with soc.layout; package ewok.layout with spark_mode => on is VTORS_SIZE : constant := 392; -- +----------------+0x0800 0000 -- | LDR (32k) | -- +----------------+0x0800 8000 -- | SHR (32k) | -- +----------------+0x0801 0000 -- | DFU1_k (64k) | -- + - - - - - - - -+0x0802 0000 -- | DFU1_u (64k) | -- +----------------+0x0803 0000 -- | FW1_k (64k) | -- + - - - - - - - -+0x0804 0000 -- | | -- | FW1_u (256k) | -- | | -- +----------------+0x0808 0000 -- | | -- | FW2_u (256k) | -- | | -- + - - - - - - - -+0x080c 0000 -- | FW2_k (64k) | -- +----------------+0x080d 0000 -- | DFU2_k (64k) | -- + - - - - - - - -+0x080e 0000 -- | DFU2_u (64k) | -- +----------------+0x080f 0000 FLASH_SIZE : constant := 1024 * KBYTE; LDR_BASE : constant system_address := 16#0800_0000#; LDR_SIZE : constant := 32 * KBYTE; SHR_BASE : constant system_address := 16#0800_8000#; SHR_SIZE : constant := 32 * KBYTE; -- -- DFU 1 -- DFU1_BASE : constant system_address := 16#0801_0000#; DFU1_SIZE : constant := 128 * KBYTE; DFU1_KERN_BASE : constant system_address := DFU1_BASE; DFU1_KERN_SIZE : constant := 64 * KBYTE; DFU1_START : constant system_address := DFU1_KERN_BASE + VTORS_SIZE + 1; DFU1_USER_BASE : constant system_address := DFU1_KERN_BASE + DFU1_KERN_SIZE; DFU1_USER_SIZE : constant := 64 * KBYTE; -- -- Firmware 1 -- FW1_BASE : constant system_address := 16#0803_0000#; FW1_SIZE : constant := 320 * KBYTE; FW1_KERN_BASE : constant system_address := FW1_BASE; FW1_KERN_SIZE : constant := 64 * KBYTE; FW1_START : constant system_address := FW1_KERN_BASE + VTORS_SIZE + 1; FW1_USER_BASE : constant system_address := FW1_KERN_BASE + FW1_KERN_SIZE; FW1_USER_SIZE : constant := 256 * KBYTE; -- -- Firmware 2 -- FW2_BASE : constant system_address := 16#0808_0000#; FW2_SIZE : constant := 320 * KBYTE; FW2_USER_BASE : constant system_address := FW2_BASE; FW2_USER_SIZE : constant := 256 * KBYTE; FW2_KERN_BASE : constant system_address := FW2_USER_BASE + FW2_USER_SIZE; FW2_START : constant system_address := FW2_KERN_BASE + VTORS_SIZE + 1; FW2_KERN_SIZE : constant := 64 * KBYTE; DFU2_BASE : constant system_address := 16#080d_0000#; DFU2_START : constant system_address := DFU2_BASE + VTORS_SIZE + 1; DFU2_KERN_BASE : constant system_address := DFU2_BASE; DFU2_USER_BASE : constant system_address := DFU2_BASE + (64*KBYTE); DFU2_SIZE : constant := 128 * KBYTE; DFU2_KERN_SIZE : constant := 64 * KBYTE; DFU2_USER_SIZE : constant := 64 * KBYTE; --------------------------------------------------------------- -- +----------------+ <- 16#1001_0000# -- | IDLE_STACK | -- +----------------+ <- 16#1000_F000# -- | SOFTIRQ_STACK | -- | | -- +----------------+ <- 16#1000_D000# -- | ISR_STACK | -- +----------------+ <- 16#1000_C000# -- | INITIAL_STACK | -- +----------------+ -- KERN_DATA_BASE : constant system_address := 16#1000_0000#; KERN_DATA_SIZE : constant := 64 * KBYTE; USER_DATA_BASE : constant system_address := soc.layout.RAM_BASE; LDR_DATA_BASE : constant system_address := 16#2001_c000#; LDR_DATA_SIZE : constant := 16 * KBYTE; STACK_TOP_IDLE : constant system_address := KERN_DATA_BASE + KERN_DATA_SIZE; STACK_SIZE_IDLE : constant := 4 * KBYTE; STACK_TOP_SOFTIRQ : constant system_address := STACK_TOP_IDLE - STACK_SIZE_IDLE; STACK_SIZE_SOFTIRQ : constant := 4 * KBYTE; STACK_TOP_TASK_ISR : constant system_address := STACK_TOP_SOFTIRQ - STACK_SIZE_SOFTIRQ; STACK_SIZE_TASK_ISR : constant := 4 * KBYTE; STACK_BOTTOM_TASK_ISR : constant system_address := STACK_TOP_TASK_ISR - STACK_SIZE_TASK_ISR; -- Transient stack. Used only during kernel initialization STACK_TOP_TASK_INITIAL : constant system_address := STACK_BOTTOM_TASK_ISR; --------------------------------------------------------------- --------------------------------------------------------------- FW_MAX_USER_SIZE : constant := 64 * KBYTE; DFU_MAX_USER_SIZE : constant := 32 * KBYTE; FW_MAX_USER_DATA : constant := 8 * KBYTE; USER_RAM_SIZE : constant := 128 * KBYTE; USER_DATA_SIZE : constant := 16 * KBYTE; FW1_APP1_BASE : constant system_address := FW1_USER_BASE; FW1_APP2_BASE : constant system_address := FW1_USER_BASE + (1 * FW_MAX_USER_SIZE); FW1_APP3_BASE : constant system_address := FW1_USER_BASE + (2 * FW_MAX_USER_SIZE); FW1_APP4_BASE : constant system_address := FW1_USER_BASE + (3 * FW_MAX_USER_SIZE); FW1_APP5_BASE : constant system_address := FW1_USER_BASE + (4 * FW_MAX_USER_SIZE); FW1_APP6_BASE : constant system_address := FW1_USER_BASE + (5 * FW_MAX_USER_SIZE); FW1_APP7_BASE : constant system_address := FW1_USER_BASE + (6 * FW_MAX_USER_SIZE); FW1_APP8_BASE : constant system_address := FW1_USER_BASE + (7 * FW_MAX_USER_SIZE); FW2_APP1_BASE : constant system_address := FW2_USER_BASE; FW2_APP2_BASE : constant system_address := FW2_USER_BASE + (1 * FW_MAX_USER_SIZE); FW2_APP3_BASE : constant system_address := FW2_USER_BASE + (2 * FW_MAX_USER_SIZE); FW2_APP4_BASE : constant system_address := FW2_USER_BASE + (3 * FW_MAX_USER_SIZE); FW2_APP5_BASE : constant system_address := FW2_USER_BASE + (4 * FW_MAX_USER_SIZE); FW2_APP6_BASE : constant system_address := FW2_USER_BASE + (5 * FW_MAX_USER_SIZE); FW2_APP7_BASE : constant system_address := FW2_USER_BASE + (6 * FW_MAX_USER_SIZE); FW2_APP8_BASE : constant system_address := FW2_USER_BASE + (7 * FW_MAX_USER_SIZE); USER_APP1_DATA_BASE : constant system_address := soc.layout.RAM_BASE; USER_APP2_DATA_BASE : constant system_address := soc.layout.RAM_BASE + (1 * USER_DATA_SIZE); USER_APP3_DATA_BASE : constant system_address := soc.layout.RAM_BASE + (2 * USER_DATA_SIZE); USER_APP4_DATA_BASE : constant system_address := soc.layout.RAM_BASE + (3 * USER_DATA_SIZE); USER_APP5_DATA_BASE : constant system_address := soc.layout.RAM_BASE + (4 * USER_DATA_SIZE); USER_APP6_DATA_BASE : constant system_address := soc.layout.RAM_BASE + (5 * USER_DATA_SIZE); USER_APP7_DATA_BASE : constant system_address := soc.layout.RAM_BASE + (6 * USER_DATA_SIZE); USER_APP8_DATA_BASE : constant system_address := soc.layout.RAM_BASE + (7 * USER_DATA_SIZE); -- SHM end ewok.layout;
with System.Zero_Terminated_Strings; with C.mach_o.dyld; with C.stdint; package body System.Program is use type C.signed_int; use type C.stdint.uint32_t; function Full_Name return String is -- use proc_pidpath instead of NSGetExecutablePath? Buffer_Length : aliased C.stdint.uint32_t := 0; Small_Buffer : aliased C.char_array (0 .. 0); R : C.signed_int; begin -- getting the length at first R := C.mach_o.dyld.NSGetExecutablePath ( Small_Buffer (0)'Access, Buffer_Length'Access); pragma Assert (R < 0 and then Buffer_Length > 0); -- Buffer_Length is updated declare Buffer : aliased C.char_array (0 .. C.size_t (Buffer_Length - 1)); begin R := C.mach_o.dyld.NSGetExecutablePath ( Buffer (0)'Access, Buffer_Length'Access); pragma Assert (not (R < 0)); return Zero_Terminated_Strings.Value ( Buffer (0)'Access, C.size_t (Buffer_Length - 1)); end; end Full_Name; end System.Program;
with Ada.Text_IO; use Ada.Text_IO; with hetro_stack; package body hetro_stack_elems is package IIO is new Ada.Text_IO.Integer_IO(Integer); use IIO; ---------- Procedure(s) for Vehicle Record ------------------------------------------- procedure AssignVehicleType(aVehicle: in out Vehicle; CarOrPlane: in Vehicles) is begin aVehicle.VehicleType := CarOrPlane; end AssignVehicleType; procedure AssignNumDoors(aVehicle: in out Vehicle; Num: in Integer) is begin aVehicle.NumOfDoors := Num; end AssignNumDoors; procedure PrintNumOfDoors(aVehicle: in out Vehicle) is begin put("Number Doors: "); put(aVehicle.NumOfDoors); new_line; end PrintNumOfDoors; procedure Print(aVehicle: in Vehicle) is begin null; end Print; function Compare(aVehicle: in Vehicle; Other: in Vehicle'Class) return Boolean is begin return False; end Compare; ---------Procedure for Car Record ------------------------------------------------------ procedure AssignManf(aCar: in out CarRec; Manf: in CarString) is begin aCar.Manf := Manf; end AssignManf; procedure PrintCarString(PrtStr: CarString) is begin for Index in 1..5 loop put(PrtStr(Index)); end loop; end PrintCarString; procedure Print(aCar: in CarRec) is begin put_line("-------------------------------------------------------------------------------------"); put("Vehicle Type: "); VehiclesIO.put(aCar.VehicleType);new_line; put("Manufacturer: "); PrintCarString(aCar.Manf) ;new_line; put("Number of Doors: "); put(aCar.NumOfDoors, 0);new_line; put_line("-------------------------------------------------------------------------------------"); end Print; function Compare(aCar: in CarRec; Other: in Vehicle'Class) return Boolean is begin return Other in CarRec and then aCar.Manf = CarRec(Other).Manf; end Compare; ---------Procedures for Plane Record ----------------------------------------------------- procedure AssignNumEngines(aPlane: in out PlaneRec; Num: in Integer) is begin aPlane.NumOfEngines := Num; end AssignNumEngines; procedure AssignManf(aPlane: in out PlaneRec; Manf: in PlaneString) is begin aPlane.Manf := Manf; end AssignManf; procedure PrintPlaneString(PrtStr: PlaneString) is begin for Index in 1..8 loop put(PrtStr(Index)); end loop; end PrintPlaneString; procedure Print(aPlane: in PlaneRec) is begin put_line("-------------------------------------------------------------------------------------"); put("Vehicle Type: "); VehiclesIO.put(aPlane.VehicleType);new_line; put("Manufacturer: "); PrintPlaneString(aPlane.Manf);new_line; put("Number of Doors: "); put(aPlane.NumOfDoors, 0);new_line; put("Number of Engines: "); put(aPlane.NumOfEngines, 0);new_line; put_line("-------------------------------------------------------------------------------------"); end Print; function Compare(aPlane: in PlaneRec; Other: in Vehicle'Class) return Boolean is begin return Other in PlaneRec and then aPlane.Manf = PlaneRec(Other).Manf; end Compare; end hetro_stack_elems;
------------------------------------------------------------------------------- -- LSE -- L-System Editor -- Author: Heziode -- -- License: -- MIT License -- -- Copyright (c) 2018 Quentin Dauprat (Heziode) <Heziode@protonmail.com> -- -- Permission is hereby granted, free of charge, to any person obtaining a -- copy of this software and associated documentation files (the "Software"), -- to deal in the Software without restriction, including without limitation -- the rights to use, copy, modify, merge, publish, distribute, sublicense, -- and/or sell copies of the Software, and to permit persons to whom the -- Software is furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in -- all copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER -- DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------- with Ada.Strings.Unbounded; with LSE.Utils.Angle; with LSE.Utils.Coordinate_2D_List; with LSE.Model.IO.Drawing_Area.Drawing_Area_Ptr; use Ada.Strings.Unbounded; use LSE.Utils.Angle; use LSE.Utils.Coordinate_2D_List; use LSE.Model.IO.Drawing_Area.Drawing_Area_Ptr; -- @summary -- Represent an abstract LOGO Turtle. -- -- @description -- This package represent an abstract LOGO Turtle. It encapsulates a set of -- structures and methods which is designed to draw what is dictated to him -- on a specific medium. -- package LSE.Model.IO.Turtle is -- Representing a LOGO Turtle type Instance is tagged private; -- Raise when Max_X - Min_X or Max_Y - Min_Y give 0 Divide_By_Zero : exception; -- Default width of the medium Default_Width : constant Positive := 600; -- Default height of the medium Default_Height : constant Positive := 600; -- Default background color Default_Background_Color : constant Unbounded_String := To_Unbounded_String (""); -- Default foreground color Default_Foreground_Color : constant Unbounded_String := To_Unbounded_String ("#000000"); -- Default size of line that will be drawn Default_Line_Size : constant Float := 100.0; -- Default angle Default_Angle : constant LSE.Utils.Angle.Angle := 0.0; Default_Margin_Top, Default_Margin_Right, Default_Margin_Bottom, Default_Margin_Left : constant Float := 0.0; -- Constructor function Initialize return Instance; -- Mutator of Width procedure Set_Width (This : out Instance; Value : Positive); -- Mutator of Height procedure Set_Height (This : out Instance; Value : Positive); -- Mutator of background color procedure Set_Background_Color (This : out Instance; Value : String); -- Mutator of foreground color procedure Set_Foreground_Color (This : out Instance; Value : String); -- Mutator of angle procedure Set_Angle (This : out Instance; Value : LSE.Utils.Angle.Angle); -- Accessor of width function Get_Width (This : Instance) return Positive; -- Accessor of height function Get_Height (This : Instance) return Positive; -- Accessor of background color function Get_Background_Color (This : Instance) return String; -- Accessor of foreground color function Get_Foreground_Color (This : Instance) return String; -- Accessor of offset x function Get_Offset_X (This : Instance) return Float; -- Accessor of offset y function Get_Offset_Y (This : Instance) return Float; -- Accessor of max X function Get_Max_X (This : Instance) return Float; -- Accessor of max Y function Get_Max_Y (This : Instance) return Float; -- Accessor of min X function Get_Min_X (This : Instance) return Float; -- Accessor of min Y function Get_Min_Y (This : Instance) return Float; -- Mutator of max X procedure Set_Max_X (This : out Instance; Value : Float); -- Mutator of max Y procedure Set_Max_Y (This : out Instance; Value : Float); -- Mutator of min X procedure Set_Min_X (This : out Instance; Value : Float); -- Mutator of min Y procedure Set_Min_Y (This : out Instance; Value : Float); -- Accessor of margin top function Get_Margin_Top (This : Instance) return Float; -- Accessor of margin right function Get_Margin_Right (This : Instance) return Float; -- Accessor of margin Bottom function Get_Margin_Bottom (This : Instance) return Float; -- Accessor of margin left function Get_Margin_Left (This : Instance) return Float; -- Accessor of medium function Get_Medium (This : Instance) return LSE.Model.IO.Drawing_Area.Drawing_Area_Ptr.Holder; -- Mutator of margin top procedure Set_Margin_Top (This : out Instance; Value : Natural); -- Mutator of margin right procedure Set_Margin_Right (This : out Instance; Value : Natural); -- Mutator of margin Bottom procedure Set_Margin_Bottom (This : out Instance; Value : Natural); -- Mutator of margin left procedure Set_Margin_Left (This : out Instance; Value : Natural); -- Mutator of all margin of medium procedure Set_Margin (This : out Instance; Value : Natural); -- Mutator of medium procedure Set_Medium (This : out Instance; Value : LSE.Model.IO.Drawing_Area. Drawing_Area_Ptr.Holder); -- Mutator of dry run procedure Set_Dry_Run (This : out Instance; Value : Boolean); -- Put this Turtle configuration in STDIO procedure Put (This : Instance); -- Configure the medium and turtle procedure Configure (This : in out Instance); -- Draw the final representation (save file, display in screen, etc.) procedure Draw (This : in out Instance); -- Go forward -- @param Trace True for stroke, False otherwise procedure Forward (This : in out Instance; Trace : Boolean := False); -- Positive rotation by angle procedure Rotate_Clockwise (This : in out Instance); -- Negative rotation by angle procedure Rotate_Anticlockwise (This : in out Instance); -- Go backward procedure UTurn (This : in out Instance); -- Save the current position in medium procedure Position_Save (This : in out Instance); -- Restore the previous saved location in medium procedure Position_Restore (This : in out Instance); private type Instance is tagged record -- Width of the medium Width : Positive := Default_Width; -- Height of the medium Height : Positive := Default_Height; -- Background color Background_Color : Unbounded_String := Default_Background_Color; -- foreground color Foreground_Color : Unbounded_String := Default_Foreground_Color; -- Size of line that will be drawn Line_Size : Float := Default_Line_Size; -- Angle step Angle : LSE.Utils.Angle.Angle := Default_Angle; -- Current angle use in medium Stack_Angle : List.Vector; -- "Stack_Coordinate" to save / restore coordinate Stack_Coordinate : LSE.Utils.Coordinate_2D_List.Vector; -- Maximum X coordinate of the L-System Max_X, -- Maximum Y coordinate of the L-System Max_Y, -- Minimum X coordinate of the L-System Min_X, -- Minimum Y coordinate of the L-System Min_Y : Float := 0.0; -- Ratio of the L-System (to fit closely the medium) Ratio : Float := 1.0; -- X shift on medium. -- Note: offset does not take margin in consideration because it is -- depending to the medium orientation. Offset_X, -- Y shift on medium -- Note: offset does not take margin in consideration because it is -- depending to the medium orientation. Offset_Y : Float := 0.0; -- Margin top Margin_Top : Float := Default_Margin_Top; -- Margin right Margin_Right : Float := Default_Margin_Right; -- Margin bottom Margin_Bottom : Float := Default_Margin_Bottom; -- Margin left Margin_Left : Float := Default_Margin_Left; -- Medium where draw L-System Medium : LSE.Model.IO.Drawing_Area.Drawing_Area_Ptr.Holder; -- Dry run it just used to compute l-system dimensions Dry_Run : Boolean := False; end record; -- Make ratio and offsets for current medium procedure Make_Offset (This : in out Instance); end LSE.Model.IO.Turtle;
pragma License (Unrestricted); -- Ada 2012 generic type Element_Type is private; package Ada.Containers.Synchronized_Queue_Interfaces is pragma Pure; type Queue is synchronized interface; procedure Enqueue ( Container : in out Queue; New_Item : Element_Type) is abstract with Synchronization => By_Entry; procedure Dequeue ( Container : in out Queue; Element : out Element_Type) is abstract with Synchronization => By_Entry; function Current_Use (Container : Queue) return Count_Type is abstract; function Peak_Use (Container : Queue) return Count_Type is abstract; end Ada.Containers.Synchronized_Queue_Interfaces;
-- -- Copyright 2018 The wookey project team <wookey@ssi.gouv.fr> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- with ewok.tasks_shared; use ewok.tasks_shared; with ewok.tasks; with soc.interrupts; with rings; package ewok.softirq with spark_mode => on is type t_isr_parameters is record handler : system_address := 0; interrupt : soc.interrupts.t_interrupt := soc.interrupts.INT_NONE; posthook_status : unsigned_32 := 0; posthook_data : unsigned_32 := 0; end record; type t_isr_request is record caller_id : ewok.tasks_shared.t_task_id := ID_UNUSED; params : t_isr_parameters := (others => <>); end record; type t_soft_parameters is record handler : system_address := 0; param1 : unsigned_32 := 0; param2 : unsigned_32 := 0; param3 : unsigned_32 := 0; end record; type t_soft_request is record caller_id : ewok.tasks_shared.t_task_id := ID_UNUSED; params : t_soft_parameters := (others => <>); end record; -- softirq input queue depth. Can be configured depending -- on the devices behavior (IRQ bursts) -- defaulting to 20 (see Kconfig) MAX_QUEUE_SIZE : constant := $CONFIG_KERNEL_SOFTIRQ_QUEUE_DEPTH; package p_isr_requests is new rings (t_isr_request, MAX_QUEUE_SIZE, t_isr_request'(others => <>)); use p_isr_requests; package p_soft_requests is new rings (t_soft_request, MAX_QUEUE_SIZE, t_soft_request'(others => <>)); use p_soft_requests; isr_queue : p_isr_requests.ring; soft_queue : p_soft_requests.ring; procedure init; procedure push_isr (task_id : in ewok.tasks_shared.t_task_id; params : in t_isr_parameters); procedure push_soft (task_id : in ewok.tasks_shared.t_task_id; params : in t_soft_parameters); procedure isr_handler (req : in t_isr_request) with global => (in_out => ewok.tasks.tasks_list); procedure soft_handler (req : in t_soft_request) with global => (in_out => ewok.tasks.tasks_list); procedure main_task with global => (in_out => ewok.tasks.tasks_list); private previous_isr_owner : t_task_id := ID_UNUSED; end ewok.softirq;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Posix; with HAL; with HAL.SPI; use HAL.SPI; with HAL.I2C; use HAL.I2C; with Native.SPI; -- use Native.SPI; with Native.I2C; procedure Spi_Test is SPI_Device : String := "/dev/spidev0.0"; SPI_Conf : Native.SPI.SPI_Configuration := (Data_Size => HAL.SPI.Data_Size_16b, Clock_Polarity => Native.SPI.High, Clock_Phase => Native.SPI.P1Edge, Slave_Manager => Native.SPI.Hardware_Managed, First_Bit => Native.SPI.MSB, Baud_Rate => 100_000); SPI_Port : Native.SPI.SPI_Port; SPI_Status : HAL.SPI.SPI_Status; SPI_Out_Data : HAL.SPI.SPI_Data_16b(1..1) := (1 => 16#D0#); SPI_In_Data : HAL.SPI.SPI_Data_16b(1..1); I2C_Device : String := "/dev/i2c-1"; I2C_Conf : Native.I2C.I2C_Configuration := (Addressing_Mode => Native.I2C.Addressing_Mode_7bit, Ack => Native.I2C.Ack_Enable, Device_Mode => Native.I2C.I2C_Mode); I2C_Port : Native.I2C.I2C_Port; I2C_Status : HAL.I2C.I2C_Status; I2C_Addr : HAL.I2C.I2C_Address := 16#0A#; I2C_Data : HAL.I2C.I2C_Data := (5,6,7,8); begin Put_Line ("Hello SPI"); -- Initialize the SPI_Port with given Configuration SPI_Port := Native.SPI.Configure (SPI_Device, SPI_Conf, SPI_Status); if SPI_Status /= HAL.SPI.Ok then Put_Line ("Error while initializing SPI Device"); return; end if; -- Send Data over the Wire Put_Line ("SPI Initialized, attempt to send"); SPI_Port.Transmit(SPI_Out_Data, SPI_Status); if SPI_Status /= HAL.SPI.Ok then Put_Line ("Error while transmitting SPI data"); return; end if; Put_Line ("Transmission was successfull"); SPI_Port.Receive(SPI_In_Data, SPI_Status); if SPI_Status /= HAL.SPI.Ok then Put_Line ("Error while receiving SPI data"); return; end if; Put ("Reveiced value:"); Put (Integer(SPI_In_Data(1)), 2); New_Line; Put_Line ("Hello I2C"); I2C_Port := Native.I2C.Configure (I2C_Device, I2C_Conf, I2C_Status); if I2C_Status /= HAL.I2C.Ok then Put_Line ("Error while initializing I2C Device"); end if; I2C_Port.Master_Transmit (I2C_Addr, I2C_Data, I2C_Status); if I2C_Status /= HAL.I2C.Ok then Put_Line ("Error while transmitting I2C data"); end if; end;
-------------------------------------------------------------------------------- -- -- -- Copyright (C) 2004, RISC OS Ada Library (RASCAL) developers. -- -- -- -- This library is free software; you can redistribute it and/or -- -- modify it under the terms of the GNU Lesser General Public -- -- License as published by the Free Software Foundation; either -- -- version 2.1 of the License, or (at your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- Lesser General Public License for more details. -- -- -- -- You should have received a copy of the GNU Lesser General Public -- -- License along with this library; if not, write to the Free Software -- -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA -- -- -- -------------------------------------------------------------------------------- -- $Author$ -- $Date$ -- $Revision$ with Kernel; use Kernel; with Interfaces.C; use Interfaces.C; with System.Storage_Elements; use System.Storage_Elements; with Reporter; with RASCAL.Memory; use RASCAL.Memory; with RASCAL.Utility; use RASCAL.Utility; with RASCAL.OS; package body RASCAL.Variable is OS_ReadVarVal : constant := 16#23#; OS_SetVarVal : constant := 16#24#; OS_GSTrans : constant := 16#27#; -- function Exists (Name : in String) return Boolean is Name_0 : String := Name & ASCII.NUL; Register : aliased Kernel.SWI_regs; Error : OSError_Access; begin Register.R(0) := Adr_To_Int(Name_0'address); Register.R(1) := 0; Register.R(2) := -1; Register.R(3) := 0; Register.R(4) := 0; Error := Kernel.SWI (OS_ReadVarVal,register'Access,register'Access); return Integer(Register.R(2)) /=0; end Exists; -- procedure Set_Value (Name : string; New_Value : string; Var_Type : Variable_Type := Literal) is Register : aliased Kernel.swi_regs; Name_0 : string := Name & ASCII.NUL; Error : OSError_Access; begin Register.R(0) := Adr_To_Int(Name_0'Address); Register.R(1) := Adr_To_Int(New_Value'Address); Register.R(2) := New_Value'Length; Register.R(3) := 0; Register.R(4) := Variable_Type'Pos(Var_Type); Error := Kernel.SWI (OS_SetVarVal,Register'Access,Register'Access); if Error /= null then pragma Debug(Reporter.Report("Variable.Set_Variable: " & To_Ada(Error.ErrMess))); OS.Raise_Error(Error); end if; end Set_Value; -- procedure UnSet (Name : string) is Register : aliased Kernel.SWI_regs; Name_0 : string := Name & ASCII.NUL; Error : OSError_Access; begin Register.R(0) := Adr_To_Int(Name_0'Address); Register.R(1) := 0; Register.R(2) := -1; Register.R(3) := 0; Register.R(4) := 0; Error := Kernel.SWI (OS_SetVarVal,Register'Access,Register'Access); if Error /= null then pragma Debug(Reporter.Report("Variable.UnSet_Variable: " & To_Ada(Error.ErrMess))); OS.Raise_Error(Error); end if; end UnSet; -- function Get_Value (Variable : in String) return String is variable_0 : String := Variable & ASCII.NUL; Register : aliased Kernel.SWI_regs; Error : OSError_Access; Bytes : Integer; begin Register.R(0) := int(To_Integer(Variable_0'address)); Register.R(1) := 0; Register.R(2) := -1; Register.R(3) := 0; Register.R(4) := 0; Error := Kernel.SWI (OS_ReadVarVal,Register'Access,Register'Access); Bytes := -1*Integer(Register.R(2)); if Bytes = 0 then return ""; end if; declare Buffer : String (1..Bytes); begin Register.R(0) := int(To_Integer(Variable_0'address)); Register.R(1) := Adr_To_Int(Buffer'Address); Register.R(2) := int(Bytes); Register.R(3) := 0; Register.R(4) := 0; Error := Kernel.SWI (OS_ReadVarVal,Register'Access,Register'Access); if Error /= null then pragma Debug(Reporter.Report("Variable.Get_Variable: " & To_Ada(Error.ErrMess))); OS.Raise_Error(Error); end if; return Buffer(1..Bytes-1); end; end Get_Value; -- function Translate (Str : in String) return String is Str_0 : String := Str & ASCII.NUL; Register : aliased Kernel.SWI_regs; Error : OSError_Access; Result : String(1..1024); begin Register.R(0) := int(To_Integer(Str_0'address)); Register.R(1) := int(To_Integer(Result'Address)); Register.R(2) := 1024; Error := Kernel.SWI (OS_GSTrans,Register'Access,Register'Access); if Error /= null then return ""; else return Result (1..Integer(Register.R(2))); end if; end Translate; -- end RASCAL.Variable;
with Ada.Text_IO; use Ada.Text_IO; procedure Test is procedure F(X: in out Integer) is begin X := 0; end; procedure G(X: in Integer) is begin F(X); end; X: Integer; begin G(X); end Test;
-- -- Copyright 2018 The wookey project team <wookey@ssi.gouv.fr> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- with system; package m4.fpu with spark_mode => off is ------------------------------------------------- -- Coprocessor access control register (CPACR) -- ------------------------------------------------- type t_cp_access is (ACCESS_DENIED, ACCESS_PRIV, ACCESS_UNDEF, ACCESS_FULL) with size => 2; for t_cp_access use (ACCESS_DENIED => 2#00#, ACCESS_PRIV => 2#01#, ACCESS_UNDEF => 2#10#, ACCESS_FULL => 2#11#); type t_CPACR is record CP10 : t_cp_access; CP11 : t_cp_access; end record with volatile_full_access, size => 32; for t_CPACR use record CP10 at 0 range 20 .. 21; CP11 at 0 range 22 .. 23; end record; ----------------------------------------------------- -- Floating-point context control register (FPCCR) -- ----------------------------------------------------- type t_FPU_FPCCR is record LSPACT : boolean; USER : boolean; THREAD : boolean; HFRDY : boolean; MMRDY : boolean; BFRDY : boolean; MONRDY : boolean; LSPEN : boolean; ASPEN : boolean; end record with volatile_full_access, size => 32; for t_FPU_FPCCR use record LSPACT at 0 range 0 .. 0; USER at 0 range 1 .. 1; THREAD at 0 range 3 .. 3; HFRDY at 0 range 4 .. 4; MMRDY at 0 range 5 .. 5; BFRDY at 0 range 6 .. 6; MONRDY at 0 range 8 .. 8; LSPEN at 0 range 30 .. 30; ASPEN at 0 range 31 .. 31; end record; ----------------------------------------------------- -- Floating-point context address register (FPCAR) -- ----------------------------------------------------- type t_FPU_FPCAR is record ADDRESS : unsigned_32; end record with volatile_full_access, size => 32; ---------------------------------------------------- -- Floating-point status control register (FPSCR) -- ---------------------------------------------------- type t_FPU_FPSCR is record IOC : bit; DZC : bit; OFC : bit; UFC : bit; IXC : bit; reserved_5_6 : bits_2; IDC : bit; reserved_8_15 : unsigned_8; reserved_16_21 : bits_6; RMode : bits_2; FZ : bit; DN : bit; AHP : bit; reserved_27_27 : bit; V : bit; C : bit; Z : bit; N : bit; end record with volatile_full_access, size => 32; for t_FPU_FPSCR use record IOC at 0 range 0 .. 0; DZC at 0 range 1 .. 1; OFC at 0 range 2 .. 2; UFC at 0 range 3 .. 3; IXC at 0 range 4 .. 4; reserved_5_6 at 0 range 5 .. 6; IDC at 0 range 7 .. 7; reserved_8_15 at 0 range 8 .. 15; reserved_16_21 at 0 range 16 .. 21; RMode at 0 range 22 .. 23; FZ at 0 range 24 .. 24; DN at 0 range 25 .. 25; AHP at 0 range 26 .. 26; reserved_27_27 at 0 range 27 .. 27; V at 0 range 28 .. 28; C at 0 range 29 .. 29; Z at 0 range 30 .. 30; N at 0 range 31 .. 31; end record; ------------------------------------------------------------- -- Floating-point default status control register (FPDSCR) -- ------------------------------------------------------------- type t_FPU_FPDSCR is record RMode : bits_2; FZ : bit; DN : bit; AHP : bit; end record with size => 32, volatile_full_access; for t_FPU_FPDSCR use record RMode at 0 range 22 .. 23; FZ at 0 range 24 .. 24; DN at 0 range 25 .. 25; AHP at 0 range 26 .. 26; end record; -------------------- -- FPU peripheral -- -------------------- type t_FPU_peripheral is record FPCCR : t_FPU_FPCCR; FPCAR : t_FPU_FPCAR; FPDSCR : t_FPU_FPDSCR; end record with volatile; for t_FPU_peripheral use record FPCCR at 16#04# range 0 .. 31; FPCAR at 16#08# range 0 .. 31; FPDSCR at 16#0C# range 0 .. 31; end record; FPU : t_FPU_peripheral with import, volatile, address => system'to_address(16#E000_EF30#); CPACR : t_CPACR with import, volatile, address => system'to_address(16#E000_ED88#); end m4.fpu;
with Ada.Text_IO; with Ada.Command_Line; use Ada.Command_Line; procedure SleepSort is task type PrintTask (num : Integer); task body PrintTask is begin delay Duration (num) / 100.0; Ada.Text_IO.Put(num'Img); end PrintTask; type TaskAcc is access PrintTask; TaskList : array (1 .. Argument_Count) of TaskAcc; begin for i in TaskList'Range loop TaskList(i) := new PrintTask(Integer'Value(Argument(i))); end loop; end SleepSort;
-- This package implements the main object used by the library, as -- well as several functions to manipulate it. with GNAT.Sockets; with GNAT.Regpat; with Ada.Strings.Unbounded; with Ada.Containers.Vectors; with Irc.Message; private with Ada.Streams; private with Ada.Characters.Latin_1; private with Ada.Characters.Handling; package Irc.Bot is package SU renames Ada.Strings.Unbounded; use type SU.Unbounded_String; use Ada.Containers; package Unbounded_Vector is new Vectors (Natural, SU.Unbounded_String); -- Irc.Bot.Connection is the main record that is used for the -- creation of bots. type Connection is tagged private; -- Contains various attributes of the Connection's current nick. type Nick_Attributes is record Nick : SU.Unbounded_String := SU.To_Unbounded_String ("adairc"); Realname : SU.Unbounded_String := SU.To_Unbounded_String ("adairc"); Password : SU.Unbounded_String; end record; -- Used for bot command callbacks type Command_Proc is access procedure (Conn : in out Connection; Msg : Message.Message); ----------------------------------- -- Irc.Bot.Connection Creation -- ----------------------------------- function Create (Server : String; Port : GNAT.Sockets.Port_Type; Nick : String := "adairc") return Connection; procedure Connect (Conn : in out Connection); procedure Disconnect (Conn : in out Connection); ---------------------------- -- Sending IRC commands -- ---------------------------- -- Any function or procedure that sends or receives from the IRC -- server will raise an Irc.Bot.Not_Connected error if the -- Connection is not currently active. -- Sends a standard start-up identify sequence (specifically, NICK -- followed by USER). This may be expanded in the future to -- auto-identify with Nickserv, but for now, when this is desired, -- run Command with the proper arguments. procedure Identify (This : Connection); -- Sends a PRIVMSG command to the specified nick or channel with -- the given message. procedure Privmsg (This : Connection; Chan_Or_Nick, Message : String); -- Joins the specified channel. No error checking is done to make -- sure the channel name is valid, so if you want to guarantee -- that the bot successfully joins, add a handler for the IRC -- protocol's "no such channel" error. procedure Join (This : Connection; Channel : String); -- Generic method of sending a command to the IRC server. Sends to -- the server the command and args joined by a single space procedure Command (This : Connection; Cmd, Args : String); -- Given a string, this function will append a CRLF and send the -- line to the server as-is. In most cases, the Command procedure -- would be better for this, but could potentially be used in -- special cases. procedure Send_Line (This : Connection; Line : String); -- Like the Send_Line procedure, but does not append a CRLF to the -- message. procedure Send_Raw (This : Connection; Raw : String); ----------------------------------- -- Reading from the IRC server -- ----------------------------------- procedure Read_Line (This : Connection; Buffer : out SU.Unbounded_String); ------------------------------- -- Adding command handlers -- ------------------------------- -- Irc.Bot.Connection's main functionality and extensibility comes -- from the callbacks given to it, which can either be strings or -- regular expressions. Commands are evaluated in sequence, -- meaning that if multiple commands match a specified string or -- regular expression, they will each be run in the order they are -- given. -- Adds a command that will be called whenever the provided -- message is received. For PRIVMSG commands, see On_Privmsg. procedure On_Message (This : in out Connection; OnMsg : String; Func : Command_Proc); -- Allows the creation of a command triggered by a regular -- expression, the given string is interpreted as a regular -- expression and added. procedure On_Regexp (This : in out Connection; OnRegexp : String; Func : Command_Proc); -- Allows a more customized regular expression to be used for a -- command (using case insensitivity, for example) procedure On_Regexp (This : in out Connection; OnRegexp : GNAT.Regpat.Pattern_Matcher; Func : Command_Proc); -- Add a callback to be Called whenever a PRIVMSG content matches -- the regular expression "^OnMsg". procedure On_Privmsg (This : in out Connection; OnMsg : String; Func : Command_Proc); ---------------------- -- Other commands -- ---------------------- -- Loops through commands, calling ones that apply to the given -- message. procedure Do_Message (This : in out Connection; Msg : Message.Message); -- Checks if a given nick or hostname is considered an admin by -- the admins set through the Add_Administrator procedure. function Is_Admin (Conn : in Connection; Sender : SU.Unbounded_String) return Boolean; ----------------------------------------------- -- Attribute accessors procedures/functions -- ----------------------------------------------- function Get_Attributes (Conn : in Connection) return Nick_Attributes; pragma Inline (Get_Attributes); procedure Set_Attributes (Conn : in out Connection; Nick : Nick_Attributes); function Get_Administrators (Conn : in Connection) return Unbounded_Vector.Vector; function Get_Default_Channels (Conn : in Connection) return Unbounded_Vector.Vector; -- Adds a new administrator to check against (for use with the -- Is_Admin function) procedure Add_Administrator (Conn : in out Connection; Admin : String); procedure Add_Administrator (Conn : in out Connection; Admin : SU.Unbounded_String); -- Adds a channel to be joined when a 001 is received from the -- server (when the default command set from Irc.Commands has been -- installed on the bot) procedure Add_Default_Channel (Conn : in out Connection; Channel : String); procedure Add_Default_Channel (Conn : in out Connection; Channel : SU.Unbounded_String); ------------------ -- Exceptions -- ------------------ Socket_Read_Error : exception; Not_Connected : exception; --------------------------- -- Private declarations -- --------------------------- private package Regexp renames GNAT.Regpat; CRLF : constant String := Ada.Characters.Latin_1.CR & Ada.Characters.Latin_1.LF; -- Provides a simple runtime check to guarantee that the -- given Connection is active before trying to send / receive. -- raises Not_Connected unless the connection is active. procedure Should_Be_Connected (This : Connection); procedure Privmsg_Command_Hook (This : in out Connection; Msg : Message.Message); type Command_Pair is record Func : Command_Proc; Regex : Regexp.Pattern_Matcher (1024); end record; package Command_Vector is new Vectors (Natural, Command_Pair); type Connection is tagged record Sock : GNAT.Sockets.Socket_Type; Address : GNAT.Sockets.Sock_Addr_Type; Connected : Boolean := False; Nick : Nick_Attributes; Commands : Command_Vector.Vector; Privmsg_Commands : Command_Vector.Vector; Administrators : Unbounded_Vector.Vector; Default_Channels : Unbounded_Vector.Vector; end record; end Irc.Bot;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . S T A C K _ C H E C K I N G . O P E R A T I O N S -- -- -- -- B o d y -- -- -- -- Copyright (C) 1999-2009, Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- As a special exception under Section 7 of GPL version 3, you are granted -- -- additional permissions described in the GCC Runtime Library Exception, -- -- version 3.1, as published by the Free Software Foundation. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ -- This is the RTEMS version of this package. -- This file should be kept synchronized with the general implementation -- provided by s-stchop.adb. pragma Restrictions (No_Elaboration_Code); -- We want to guarantee the absence of elaboration code because the -- binder does not handle references to this package. with Ada.Exceptions; with Interfaces.C; use Interfaces.C; package body System.Stack_Checking.Operations is ---------------------------- -- Invalidate_Stack_Cache -- ---------------------------- procedure Invalidate_Stack_Cache (Any_Stack : Stack_Access) is pragma Warnings (Off, Any_Stack); begin Cache := Null_Stack; end Invalidate_Stack_Cache; ----------------------------- -- Notify_Stack_Attributes -- ----------------------------- procedure Notify_Stack_Attributes (Initial_SP : System.Address; Size : System.Storage_Elements.Storage_Offset) is -- RTEMS keeps all the information we need. pragma Unreferenced (Size); pragma Unreferenced (Initial_SP); begin null; end Notify_Stack_Attributes; ----------------- -- Stack_Check -- ----------------- function Stack_Check (Stack_Address : System.Address) return Stack_Access is pragma Unreferenced (Stack_Address); -- RTEMS has a routine to check if the stack is blown. -- It returns a C99 bool. function rtems_stack_checker_is_blown return Interfaces.C.unsigned_char; pragma Import (C, rtems_stack_checker_is_blown, "rtems_stack_checker_is_blown"); begin -- RTEMS has a routine to check this. So use it. if rtems_stack_checker_is_blown /= 0 then Ada.Exceptions.Raise_Exception (E => Storage_Error'Identity, Message => "stack overflow detected"); end if; return null; end Stack_Check; ------------------------ -- Update_Stack_Cache -- ------------------------ procedure Update_Stack_Cache (Stack : Stack_Access) is begin if not Multi_Processor then Cache := Stack; end if; end Update_Stack_Cache; end System.Stack_Checking.Operations;