content
stringlengths 23
1.05M
|
|---|
-- Copyright 2016-2019 NXP
-- All rights reserved.SPDX-License-Identifier: BSD-3-Clause
-- This spec has been automatically generated from LPC55S6x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package NXP_SVD.MRT is
pragma Preelaborate;
---------------
-- Registers --
---------------
---------------------------------
-- CHANNEL cluster's Registers --
---------------------------------
subtype INTVAL_CHANNEL_IVALUE_Field is HAL.UInt24;
-- Determines how the timer interval value IVALUE -1 is loaded into the
-- TIMERn register. This bit is write-only. Reading this bit always returns
-- 0.
type INTVAL_LOAD_Field is
(
-- No force load. The load from the INTVALn register to the TIMERn
-- register is processed at the end of the time interval if the repeat
-- mode is selected.
No_Force_Load,
-- Force load. The INTVALn interval value IVALUE -1 is immediately
-- loaded into the TIMERn register while TIMERn is running.
Force_Load)
with Size => 1;
for INTVAL_LOAD_Field use
(No_Force_Load => 0,
Force_Load => 1);
-- MRT Time interval value register. This value is loaded into the TIMER
-- register.
type INTVAL_CHANNEL_Register is record
-- Time interval load value. This value is loaded into the TIMERn
-- register and the MRT channel n starts counting down from IVALUE -1.
-- If the timer is idle, writing a non-zero value to this bit field
-- starts the timer immediately. If the timer is running, writing a zero
-- to this bit field does the following: If LOAD = 1, the timer stops
-- immediately. If LOAD = 0, the timer stops at the end of the time
-- interval.
IVALUE : INTVAL_CHANNEL_IVALUE_Field := 16#0#;
-- unspecified
Reserved_24_30 : HAL.UInt7 := 16#0#;
-- Determines how the timer interval value IVALUE -1 is loaded into the
-- TIMERn register. This bit is write-only. Reading this bit always
-- returns 0.
LOAD : INTVAL_LOAD_Field := NXP_SVD.MRT.No_Force_Load;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for INTVAL_CHANNEL_Register use record
IVALUE at 0 range 0 .. 23;
Reserved_24_30 at 0 range 24 .. 30;
LOAD at 0 range 31 .. 31;
end record;
subtype TIMER_CHANNEL_VALUE_Field is HAL.UInt24;
-- MRT Timer register. This register reads the value of the down-counter.
type TIMER_CHANNEL_Register is record
-- Read-only. Holds the current timer value of the down-counter. The
-- initial value of the TIMERn register is loaded as IVALUE - 1 from the
-- INTVALn register either at the end of the time interval or
-- immediately in the following cases: INTVALn register is updated in
-- the idle state. INTVALn register is updated with LOAD = 1. When the
-- timer is in idle state, reading this bit fields returns -1 (0x00FF
-- FFFF).
VALUE : TIMER_CHANNEL_VALUE_Field;
-- unspecified
Reserved_24_31 : HAL.UInt8;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for TIMER_CHANNEL_Register use record
VALUE at 0 range 0 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-- Enable the TIMERn interrupt.
type CTRL_INTEN_Field is
(
-- Disabled. TIMERn interrupt is disabled.
Disabled,
-- Enabled. TIMERn interrupt is enabled.
Enabled)
with Size => 1;
for CTRL_INTEN_Field use
(Disabled => 0,
Enabled => 1);
-- Selects timer mode.
type CTRL_MODE_Field is
(
-- Repeat interrupt mode.
Repeat_Interrupt_Mode,
-- One-shot interrupt mode.
One_Shot_Interrupt_Mode,
-- One-shot stall mode.
One_Shot_Stall_Mode)
with Size => 2;
for CTRL_MODE_Field use
(Repeat_Interrupt_Mode => 0,
One_Shot_Interrupt_Mode => 1,
One_Shot_Stall_Mode => 2);
-- MRT Control register. This register controls the MRT modes.
type CTRL_CHANNEL_Register is record
-- Enable the TIMERn interrupt.
INTEN : CTRL_INTEN_Field := NXP_SVD.MRT.Disabled;
-- Selects timer mode.
MODE : CTRL_MODE_Field := NXP_SVD.MRT.Repeat_Interrupt_Mode;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CTRL_CHANNEL_Register use record
INTEN at 0 range 0 .. 0;
MODE at 0 range 1 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
-- Monitors the interrupt flag.
type STAT_INTFLAG_Field is
(
-- No pending interrupt. Writing a zero is equivalent to no operation.
No_Pending_Interrupt,
-- Pending interrupt. The interrupt is pending because TIMERn has
-- reached the end of the time interval. If the INTEN bit in the
-- CONTROLn is also set to 1, the interrupt for timer channel n and the
-- global interrupt are raised. Writing a 1 to this bit clears the
-- interrupt request.
Pending_Interrupt)
with Size => 1;
for STAT_INTFLAG_Field use
(No_Pending_Interrupt => 0,
Pending_Interrupt => 1);
-- Indicates the state of TIMERn. This bit is read-only.
type STAT_RUN_Field is
(
-- Idle state. TIMERn is stopped.
Idle_State,
-- Running. TIMERn is running.
Running)
with Size => 1;
for STAT_RUN_Field use
(Idle_State => 0,
Running => 1);
-- Channel In Use flag. Operating details depend on the MULTITASK bit in
-- the MODCFG register, and affects the use of IDLE_CH. See Idle channel
-- register for details of the two operating modes.
type STAT_INUSE_Field is
(
-- This channel is not in use.
No,
-- This channel is in use.
Yes)
with Size => 1;
for STAT_INUSE_Field use
(No => 0,
Yes => 1);
-- MRT Status register.
type STAT_CHANNEL_Register is record
-- Monitors the interrupt flag.
INTFLAG : STAT_INTFLAG_Field := NXP_SVD.MRT.No_Pending_Interrupt;
-- Indicates the state of TIMERn. This bit is read-only.
RUN : STAT_RUN_Field := NXP_SVD.MRT.Idle_State;
-- Channel In Use flag. Operating details depend on the MULTITASK bit in
-- the MODCFG register, and affects the use of IDLE_CH. See Idle channel
-- register for details of the two operating modes.
INUSE : STAT_INUSE_Field := NXP_SVD.MRT.No;
-- unspecified
Reserved_3_31 : HAL.UInt29 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for STAT_CHANNEL_Register use record
INTFLAG at 0 range 0 .. 0;
RUN at 0 range 1 .. 1;
INUSE at 0 range 2 .. 2;
Reserved_3_31 at 0 range 3 .. 31;
end record;
-- no description available
type CHANNEL_Cluster is record
-- MRT Time interval value register. This value is loaded into the TIMER
-- register.
INTVAL : aliased INTVAL_CHANNEL_Register;
-- MRT Timer register. This register reads the value of the
-- down-counter.
TIMER : aliased TIMER_CHANNEL_Register;
-- MRT Control register. This register controls the MRT modes.
CTRL : aliased CTRL_CHANNEL_Register;
-- MRT Status register.
STAT : aliased STAT_CHANNEL_Register;
end record
with Volatile, Size => 128;
for CHANNEL_Cluster use record
INTVAL at 16#0# range 0 .. 31;
TIMER at 16#4# range 0 .. 31;
CTRL at 16#8# range 0 .. 31;
STAT at 16#C# range 0 .. 31;
end record;
-- no description available
type CHANNEL_Clusters is array (0 .. 3) of CHANNEL_Cluster;
subtype MODCFG_NOC_Field is HAL.UInt4;
subtype MODCFG_NOB_Field is HAL.UInt5;
-- Selects the operating mode for the INUSE flags and the IDLE_CH register.
type MODCFG_MULTITASK_Field is
(
-- Hardware status mode. In this mode, the INUSE(n) flags for all
-- channels are reset.
Hardware_Status_Mode,
-- Multi-task mode.
Multi_Task_Mode)
with Size => 1;
for MODCFG_MULTITASK_Field use
(Hardware_Status_Mode => 0,
Multi_Task_Mode => 1);
-- Module Configuration register. This register provides information about
-- this particular MRT instance, and allows choosing an overall mode for
-- the idle channel feature.
type MODCFG_Register is record
-- Identifies the number of channels in this MRT.(4 channels on this
-- device.)
NOC : MODCFG_NOC_Field := 16#3#;
-- Identifies the number of timer bits in this MRT. (24 bits wide on
-- this device.)
NOB : MODCFG_NOB_Field := 16#17#;
-- unspecified
Reserved_9_30 : HAL.UInt22 := 16#0#;
-- Selects the operating mode for the INUSE flags and the IDLE_CH
-- register.
MULTITASK : MODCFG_MULTITASK_Field :=
NXP_SVD.MRT.Hardware_Status_Mode;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MODCFG_Register use record
NOC at 0 range 0 .. 3;
NOB at 0 range 4 .. 8;
Reserved_9_30 at 0 range 9 .. 30;
MULTITASK at 0 range 31 .. 31;
end record;
subtype IDLE_CH_CHAN_Field is HAL.UInt4;
-- Idle channel register. This register returns the number of the first
-- idle channel.
type IDLE_CH_Register is record
-- unspecified
Reserved_0_3 : HAL.UInt4;
-- Read-only. Idle channel. Reading the CHAN bits, returns the lowest
-- idle timer channel. The number is positioned such that it can be used
-- as an offset from the MRT base address in order to access the
-- registers for the allocated channel. If all timer channels are
-- running, CHAN = 0xF. See text above for more details.
CHAN : IDLE_CH_CHAN_Field;
-- unspecified
Reserved_8_31 : HAL.UInt24;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IDLE_CH_Register use record
Reserved_0_3 at 0 range 0 .. 3;
CHAN at 0 range 4 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- Monitors the interrupt flag of TIMER0.
type IRQ_FLAG_GFLAG0_Field is
(
-- No pending interrupt. Writing a zero is equivalent to no operation.
No_Pending_Interrupt,
-- Pending interrupt. The interrupt is pending because TIMER0 has
-- reached the end of the time interval. If the INTEN bit in the
-- CONTROL0 register is also set to 1, the interrupt for timer channel 0
-- and the global interrupt are raised. Writing a 1 to this bit clears
-- the interrupt request.
Pending_Interrupt)
with Size => 1;
for IRQ_FLAG_GFLAG0_Field use
(No_Pending_Interrupt => 0,
Pending_Interrupt => 1);
-- IRQ_FLAG_GFLAG array
type IRQ_FLAG_GFLAG_Field_Array is array (1 .. 3) of Boolean
with Component_Size => 1, Size => 3;
-- Type definition for IRQ_FLAG_GFLAG
type IRQ_FLAG_GFLAG_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- GFLAG as a value
Val : HAL.UInt3;
when True =>
-- GFLAG as an array
Arr : IRQ_FLAG_GFLAG_Field_Array;
end case;
end record
with Unchecked_Union, Size => 3;
for IRQ_FLAG_GFLAG_Field use record
Val at 0 range 0 .. 2;
Arr at 0 range 0 .. 2;
end record;
-- Global interrupt flag register
type IRQ_FLAG_Register is record
-- Monitors the interrupt flag of TIMER0.
GFLAG0 : IRQ_FLAG_GFLAG0_Field :=
NXP_SVD.MRT.No_Pending_Interrupt;
-- Monitors the interrupt flag of TIMER1. See description of channel 0.
GFLAG : IRQ_FLAG_GFLAG_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_4_31 : HAL.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for IRQ_FLAG_Register use record
GFLAG0 at 0 range 0 .. 0;
GFLAG at 0 range 1 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Multi-Rate Timer (MRT)
type MRT0_Peripheral is record
-- no description available
CHANNEL : aliased CHANNEL_Clusters;
-- Module Configuration register. This register provides information
-- about this particular MRT instance, and allows choosing an overall
-- mode for the idle channel feature.
MODCFG : aliased MODCFG_Register;
-- Idle channel register. This register returns the number of the first
-- idle channel.
IDLE_CH : aliased IDLE_CH_Register;
-- Global interrupt flag register
IRQ_FLAG : aliased IRQ_FLAG_Register;
end record
with Volatile;
for MRT0_Peripheral use record
CHANNEL at 16#0# range 0 .. 511;
MODCFG at 16#F0# range 0 .. 31;
IDLE_CH at 16#F4# range 0 .. 31;
IRQ_FLAG at 16#F8# range 0 .. 31;
end record;
-- Multi-Rate Timer (MRT)
MRT0_Periph : aliased MRT0_Peripheral
with Import, Address => System'To_Address (16#4000D000#);
end NXP_SVD.MRT;
|
-- SPDX-FileCopyrightText: 2020 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
----------------------------------------------------------------
with League.JSON.Documents;
with League.JSON.Objects;
with League.JSON.Values;
with Jupyter.Kernels;
procedure Magics.Output
(IO_Pub : not null Jupyter.Kernels.IO_Pub_Access;
MIME : League.Strings.Universal_String;
Text : League.Strings.Universal_String;
Silent : Boolean)
is
use type League.Strings.Universal_String;
Data : League.JSON.Objects.JSON_Object;
Meta : League.JSON.Objects.JSON_Object;
begin
if not Silent then
if MIME = +"application/json" then
declare
Doc : constant League.JSON.Documents.JSON_Document :=
League.JSON.Documents.From_JSON (Text);
Expanded : League.JSON.Objects.JSON_Object;
begin
Expanded.Insert
(+"expanded", League.JSON.Values.To_JSON_Value (True));
Meta.Insert (MIME, Expanded.To_JSON_Value);
if Doc.Is_Array then
Data.Insert (MIME, Doc.To_JSON_Array.To_JSON_Value);
else
Data.Insert (MIME, Doc.To_JSON_Object.To_JSON_Value);
end if;
end;
else
Data.Insert (MIME, League.JSON.Values.To_JSON_Value (Text));
end if;
IO_Pub.Execute_Result
(Data => Data,
Metadata => Meta,
Transient => League.JSON.Objects.Empty_JSON_Object);
end if;
end Magics.Output;
|
-- { dg-do run }
with Wide_Boolean_Pkg; use Wide_Boolean_Pkg;
procedure Wide_Boolean is
R : TREC;
LB_TEST_BOOL : TBOOL;
begin
R.B := FALSE;
LB_TEST_BOOL := FALSE;
Modify (R.H, R.B);
if (R.B /= TRUE) then
raise Program_Error;
end if;
Modify (R.H, LB_TEST_BOOL);
R.B := LB_TEST_BOOL;
if (R.B /= TRUE) then
raise Program_Error;
end if;
end;
|
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
-- Trivial implementation of library declarations
with Program.Library_Unit_Bodies;
with Program.Library_Unit_Declarations;
with Program.Compilation_Unit_Vectors;
with Program.Units.Vectors;
package Program.Units.Declarations is
pragma Preelaborate;
type Unit_Declaration is new Unit
and Program.Library_Unit_Declarations.Library_Unit_Declaration
with private;
procedure Initialize
(Self : in out Unit_Declaration;
Compilation : Program.Compilations.Compilation_Access;
Full_Name : Text;
Context_Clause : Program.Element_Vectors.Element_Vector_Access;
Declaration : not null Program.Elements.Element_Access;
Parent : Program.Library_Unit_Declarations
.Library_Unit_Declaration_Access);
procedure Append_Child
(Self : in out Unit_Declaration;
Value : Program.Compilation_Units.Compilation_Unit_Access);
procedure Set_Body
(Self : in out Unit_Declaration;
Value : Program.Library_Unit_Bodies.Library_Unit_Body_Access);
private
type Unit_Declaration is new Unit
and Program.Library_Unit_Declarations.Library_Unit_Declaration
with
record
Parent : Program.Library_Unit_Declarations
.Library_Unit_Declaration_Access;
Impl : Program.Library_Unit_Bodies.Library_Unit_Body_Access;
Childern : aliased Program.Units.Vectors.Unit_Vector;
end record;
overriding function Parent (Self : access Unit_Declaration)
return Program.Library_Unit_Declarations.Library_Unit_Declaration_Access;
overriding function Corresponding_Body (Self : access Unit_Declaration)
return Program.Library_Unit_Bodies.Library_Unit_Body_Access;
overriding function Corresponding_Childern
(Self : access Unit_Declaration)
return Program.Compilation_Unit_Vectors.Compilation_Unit_Vector_Access;
end Program.Units.Declarations;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . A L T I V E C . L O W _ L E V E L _ V E C T O R S --
-- --
-- S p e c --
-- (Soft Binding Version) --
-- --
-- Copyright (C) 2004-2009, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This unit exposes the low level vector support for the Soft binding,
-- intended for non AltiVec capable targets. See Altivec.Design for a
-- description of what is expected to be exposed.
with GNAT.Altivec.Vector_Views; use GNAT.Altivec.Vector_Views;
package GNAT.Altivec.Low_Level_Vectors is
----------------------------------------
-- Low level vector type declarations --
----------------------------------------
type LL_VUC is private;
type LL_VSC is private;
type LL_VBC is private;
type LL_VUS is private;
type LL_VSS is private;
type LL_VBS is private;
type LL_VUI is private;
type LL_VSI is private;
type LL_VBI is private;
type LL_VF is private;
type LL_VP is private;
------------------------------------
-- Low level functional interface --
------------------------------------
function abs_v16qi (A : LL_VSC) return LL_VSC;
function abs_v8hi (A : LL_VSS) return LL_VSS;
function abs_v4si (A : LL_VSI) return LL_VSI;
function abs_v4sf (A : LL_VF) return LL_VF;
function abss_v16qi (A : LL_VSC) return LL_VSC;
function abss_v8hi (A : LL_VSS) return LL_VSS;
function abss_v4si (A : LL_VSI) return LL_VSI;
function vaddubm (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vadduhm (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vadduwm (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vaddfp (A : LL_VF; B : LL_VF) return LL_VF;
function vaddcuw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vaddubs (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vaddsbs (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vadduhs (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vaddshs (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vadduws (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vaddsws (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vand (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vandc (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vavgub (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vavgsb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vavguh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vavgsh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vavguw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vavgsw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vcmpbfp (A : LL_VF; B : LL_VF) return LL_VSI;
function vcmpequb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vcmpequh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vcmpequw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vcmpeqfp (A : LL_VF; B : LL_VF) return LL_VSI;
function vcmpgefp (A : LL_VF; B : LL_VF) return LL_VSI;
function vcmpgtub (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vcmpgtsb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vcmpgtuh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vcmpgtsh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vcmpgtuw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vcmpgtsw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vcmpgtfp (A : LL_VF; B : LL_VF) return LL_VSI;
function vcfux (A : LL_VSI; B : c_int) return LL_VF;
function vcfsx (A : LL_VSI; B : c_int) return LL_VF;
function vctsxs (A : LL_VF; B : c_int) return LL_VSI;
function vctuxs (A : LL_VF; B : c_int) return LL_VSI;
procedure dss (A : c_int);
procedure dssall;
procedure dst (A : c_ptr; B : c_int; C : c_int);
procedure dstst (A : c_ptr; B : c_int; C : c_int);
procedure dststt (A : c_ptr; B : c_int; C : c_int);
procedure dstt (A : c_ptr; B : c_int; C : c_int);
function vexptefp (A : LL_VF) return LL_VF;
function vrfim (A : LL_VF) return LL_VF;
function lvx (A : c_long; B : c_ptr) return LL_VSI;
function lvebx (A : c_long; B : c_ptr) return LL_VSC;
function lvehx (A : c_long; B : c_ptr) return LL_VSS;
function lvewx (A : c_long; B : c_ptr) return LL_VSI;
function lvxl (A : c_long; B : c_ptr) return LL_VSI;
function vlogefp (A : LL_VF) return LL_VF;
function lvsl (A : c_long; B : c_ptr) return LL_VSC;
function lvsr (A : c_long; B : c_ptr) return LL_VSC;
function vmaddfp (A : LL_VF; B : LL_VF; C : LL_VF) return LL_VF;
function vmhaddshs (A : LL_VSS; B : LL_VSS; C : LL_VSS) return LL_VSS;
function vmaxub (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vmaxsb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vmaxuh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vmaxsh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vmaxuw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vmaxsw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vmaxfp (A : LL_VF; B : LL_VF) return LL_VF;
function vmrghb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vmrghh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vmrghw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vmrglb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vmrglh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vmrglw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function mfvscr return LL_VSS;
function vminfp (A : LL_VF; B : LL_VF) return LL_VF;
function vminsb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vminsh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vminsw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vminub (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vminuh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vminuw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vmladduhm (A : LL_VSS; B : LL_VSS; C : LL_VSS) return LL_VSS;
function vmhraddshs (A : LL_VSS; B : LL_VSS; C : LL_VSS) return LL_VSS;
function vmsumubm (A : LL_VSC; B : LL_VSC; C : LL_VSI) return LL_VSI;
function vmsummbm (A : LL_VSC; B : LL_VSC; C : LL_VSI) return LL_VSI;
function vmsumuhm (A : LL_VSS; B : LL_VSS; C : LL_VSI) return LL_VSI;
function vmsumshm (A : LL_VSS; B : LL_VSS; C : LL_VSI) return LL_VSI;
function vmsumuhs (A : LL_VSS; B : LL_VSS; C : LL_VSI) return LL_VSI;
function vmsumshs (A : LL_VSS; B : LL_VSS; C : LL_VSI) return LL_VSI;
procedure mtvscr (A : LL_VSI);
function vmuleub (A : LL_VSC; B : LL_VSC) return LL_VSS;
function vmuleuh (A : LL_VSS; B : LL_VSS) return LL_VSI;
function vmulesb (A : LL_VSC; B : LL_VSC) return LL_VSS;
function vmulesh (A : LL_VSS; B : LL_VSS) return LL_VSI;
function vmulosb (A : LL_VSC; B : LL_VSC) return LL_VSS;
function vmulosh (A : LL_VSS; B : LL_VSS) return LL_VSI;
function vmuloub (A : LL_VSC; B : LL_VSC) return LL_VSS;
function vmulouh (A : LL_VSS; B : LL_VSS) return LL_VSI;
function vnmsubfp (A : LL_VF; B : LL_VF; C : LL_VF) return LL_VF;
function vxor (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vnor (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vor (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vpkuhum (A : LL_VSS; B : LL_VSS) return LL_VSC;
function vpkuwum (A : LL_VSI; B : LL_VSI) return LL_VSS;
function vpkpx (A : LL_VSI; B : LL_VSI) return LL_VSS;
function vpkuhus (A : LL_VSS; B : LL_VSS) return LL_VSC;
function vpkuwus (A : LL_VSI; B : LL_VSI) return LL_VSS;
function vpkshss (A : LL_VSS; B : LL_VSS) return LL_VSC;
function vpkswss (A : LL_VSI; B : LL_VSI) return LL_VSS;
function vpkshus (A : LL_VSS; B : LL_VSS) return LL_VSC;
function vpkswus (A : LL_VSI; B : LL_VSI) return LL_VSS;
function vperm_4si (A : LL_VSI; B : LL_VSI; C : LL_VSC) return LL_VSI;
function vrefp (A : LL_VF) return LL_VF;
function vrlb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vrlh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vrlw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vrfin (A : LL_VF) return LL_VF;
function vrfip (A : LL_VF) return LL_VF;
function vrfiz (A : LL_VF) return LL_VF;
function vrsqrtefp (A : LL_VF) return LL_VF;
function vsel_4si (A : LL_VSI; B : LL_VSI; C : LL_VSI) return LL_VSI;
function vslb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vslh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vslw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsldoi_4si (A : LL_VSI; B : LL_VSI; C : c_int) return LL_VSI;
function vsldoi_8hi (A : LL_VSS; B : LL_VSS; C : c_int) return LL_VSS;
function vsldoi_16qi (A : LL_VSC; B : LL_VSC; C : c_int) return LL_VSC;
function vsldoi_4sf (A : LL_VF; B : LL_VF; C : c_int) return LL_VF;
function vsl (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vslo (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vspltb (A : LL_VSC; B : c_int) return LL_VSC;
function vsplth (A : LL_VSS; B : c_int) return LL_VSS;
function vspltw (A : LL_VSI; B : c_int) return LL_VSI;
function vspltisb (A : c_int) return LL_VSC;
function vspltish (A : c_int) return LL_VSS;
function vspltisw (A : c_int) return LL_VSI;
function vsrb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vsrh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vsrw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsrab (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vsrah (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vsraw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsr (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsro (A : LL_VSI; B : LL_VSI) return LL_VSI;
procedure stvx (A : LL_VSI; B : c_int; C : c_ptr);
procedure stvebx (A : LL_VSC; B : c_int; C : c_ptr);
procedure stvehx (A : LL_VSS; B : c_int; C : c_ptr);
procedure stvewx (A : LL_VSI; B : c_int; C : c_ptr);
procedure stvxl (A : LL_VSI; B : c_int; C : c_ptr);
function vsububm (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vsubuhm (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vsubuwm (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsubfp (A : LL_VF; B : LL_VF) return LL_VF;
function vsubcuw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsububs (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vsubsbs (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vsubuhs (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vsubshs (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vsubuws (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsubsws (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsum4ubs (A : LL_VSC; B : LL_VSI) return LL_VSI;
function vsum4sbs (A : LL_VSC; B : LL_VSI) return LL_VSI;
function vsum4shs (A : LL_VSS; B : LL_VSI) return LL_VSI;
function vsum2sws (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsumsws (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vupkhsb (A : LL_VSC) return LL_VSS;
function vupkhsh (A : LL_VSS) return LL_VSI;
function vupkhpx (A : LL_VSS) return LL_VSI;
function vupklsb (A : LL_VSC) return LL_VSS;
function vupklsh (A : LL_VSS) return LL_VSI;
function vupklpx (A : LL_VSS) return LL_VSI;
function vcmpequb_p (A : c_int; B : LL_VSC; C : LL_VSC) return c_int;
function vcmpequh_p (A : c_int; B : LL_VSS; C : LL_VSS) return c_int;
function vcmpequw_p (A : c_int; B : LL_VSI; C : LL_VSI) return c_int;
function vcmpeqfp_p (A : c_int; B : LL_VF; C : LL_VF) return c_int;
function vcmpgtub_p (A : c_int; B : LL_VSC; C : LL_VSC) return c_int;
function vcmpgtuh_p (A : c_int; B : LL_VSS; C : LL_VSS) return c_int;
function vcmpgtuw_p (A : c_int; B : LL_VSI; C : LL_VSI) return c_int;
function vcmpgtsb_p (A : c_int; B : LL_VSC; C : LL_VSC) return c_int;
function vcmpgtsh_p (A : c_int; B : LL_VSS; C : LL_VSS) return c_int;
function vcmpgtsw_p (A : c_int; B : LL_VSI; C : LL_VSI) return c_int;
function vcmpgtfp_p (A : c_int; B : LL_VF; C : LL_VF) return c_int;
function vcmpgefp_p (A : c_int; B : LL_VF; C : LL_VF) return c_int;
function vcmpbfp_p (A : c_int; B : LL_VF; C : LL_VF) return c_int;
private
---------------------------------------
-- Low level vector type definitions --
---------------------------------------
-- We simply use the natural array definitions corresponding to each
-- user-level vector type.
type LL_VUI is new VUI_View;
type LL_VSI is new VSI_View;
type LL_VBI is new VBI_View;
type LL_VUS is new VUS_View;
type LL_VSS is new VSS_View;
type LL_VBS is new VBS_View;
type LL_VUC is new VUC_View;
type LL_VSC is new VSC_View;
type LL_VBC is new VBC_View;
type LL_VF is new VF_View;
type LL_VP is new VP_View;
------------------------------------
-- Low level functional interface --
------------------------------------
pragma Convention_Identifier (LL_Altivec, C);
pragma Export (LL_Altivec, dss, "__builtin_altivec_dss");
pragma Export (LL_Altivec, dssall, "__builtin_altivec_dssall");
pragma Export (LL_Altivec, dst, "__builtin_altivec_dst");
pragma Export (LL_Altivec, dstst, "__builtin_altivec_dstst");
pragma Export (LL_Altivec, dststt, "__builtin_altivec_dststt");
pragma Export (LL_Altivec, dstt, "__builtin_altivec_dstt");
pragma Export (LL_Altivec, mtvscr, "__builtin_altivec_mtvscr");
pragma Export (LL_Altivec, mfvscr, "__builtin_altivec_mfvscr");
pragma Export (LL_Altivec, stvebx, "__builtin_altivec_stvebx");
pragma Export (LL_Altivec, stvehx, "__builtin_altivec_stvehx");
pragma Export (LL_Altivec, stvewx, "__builtin_altivec_stvewx");
pragma Export (LL_Altivec, stvx, "__builtin_altivec_stvx");
pragma Export (LL_Altivec, stvxl, "__builtin_altivec_stvxl");
pragma Export (LL_Altivec, lvebx, "__builtin_altivec_lvebx");
pragma Export (LL_Altivec, lvehx, "__builtin_altivec_lvehx");
pragma Export (LL_Altivec, lvewx, "__builtin_altivec_lvewx");
pragma Export (LL_Altivec, lvx, "__builtin_altivec_lvx");
pragma Export (LL_Altivec, lvxl, "__builtin_altivec_lvxl");
pragma Export (LL_Altivec, lvsl, "__builtin_altivec_lvsl");
pragma Export (LL_Altivec, lvsr, "__builtin_altivec_lvsr");
pragma Export (LL_Altivec, abs_v16qi, "__builtin_altivec_abs_v16qi");
pragma Export (LL_Altivec, abs_v8hi, "__builtin_altivec_abs_v8hi");
pragma Export (LL_Altivec, abs_v4si, "__builtin_altivec_abs_v4si");
pragma Export (LL_Altivec, abs_v4sf, "__builtin_altivec_abs_v4sf");
pragma Export (LL_Altivec, abss_v16qi, "__builtin_altivec_abss_v16qi");
pragma Export (LL_Altivec, abss_v8hi, "__builtin_altivec_abss_v8hi");
pragma Export (LL_Altivec, abss_v4si, "__builtin_altivec_abss_v4si");
pragma Export (LL_Altivec, vaddcuw, "__builtin_altivec_vaddcuw");
pragma Export (LL_Altivec, vaddfp, "__builtin_altivec_vaddfp");
pragma Export (LL_Altivec, vaddsbs, "__builtin_altivec_vaddsbs");
pragma Export (LL_Altivec, vaddshs, "__builtin_altivec_vaddshs");
pragma Export (LL_Altivec, vaddsws, "__builtin_altivec_vaddsws");
pragma Export (LL_Altivec, vaddubm, "__builtin_altivec_vaddubm");
pragma Export (LL_Altivec, vaddubs, "__builtin_altivec_vaddubs");
pragma Export (LL_Altivec, vadduhm, "__builtin_altivec_vadduhm");
pragma Export (LL_Altivec, vadduhs, "__builtin_altivec_vadduhs");
pragma Export (LL_Altivec, vadduwm, "__builtin_altivec_vadduwm");
pragma Export (LL_Altivec, vadduws, "__builtin_altivec_vadduws");
pragma Export (LL_Altivec, vand, "__builtin_altivec_vand");
pragma Export (LL_Altivec, vandc, "__builtin_altivec_vandc");
pragma Export (LL_Altivec, vavgsb, "__builtin_altivec_vavgsb");
pragma Export (LL_Altivec, vavgsh, "__builtin_altivec_vavgsh");
pragma Export (LL_Altivec, vavgsw, "__builtin_altivec_vavgsw");
pragma Export (LL_Altivec, vavgub, "__builtin_altivec_vavgub");
pragma Export (LL_Altivec, vavguh, "__builtin_altivec_vavguh");
pragma Export (LL_Altivec, vavguw, "__builtin_altivec_vavguw");
pragma Export (LL_Altivec, vcfsx, "__builtin_altivec_vcfsx");
pragma Export (LL_Altivec, vcfux, "__builtin_altivec_vcfux");
pragma Export (LL_Altivec, vcmpbfp, "__builtin_altivec_vcmpbfp");
pragma Export (LL_Altivec, vcmpeqfp, "__builtin_altivec_vcmpeqfp");
pragma Export (LL_Altivec, vcmpequb, "__builtin_altivec_vcmpequb");
pragma Export (LL_Altivec, vcmpequh, "__builtin_altivec_vcmpequh");
pragma Export (LL_Altivec, vcmpequw, "__builtin_altivec_vcmpequw");
pragma Export (LL_Altivec, vcmpgefp, "__builtin_altivec_vcmpgefp");
pragma Export (LL_Altivec, vcmpgtfp, "__builtin_altivec_vcmpgtfp");
pragma Export (LL_Altivec, vcmpgtsb, "__builtin_altivec_vcmpgtsb");
pragma Export (LL_Altivec, vcmpgtsh, "__builtin_altivec_vcmpgtsh");
pragma Export (LL_Altivec, vcmpgtsw, "__builtin_altivec_vcmpgtsw");
pragma Export (LL_Altivec, vcmpgtub, "__builtin_altivec_vcmpgtub");
pragma Export (LL_Altivec, vcmpgtuh, "__builtin_altivec_vcmpgtuh");
pragma Export (LL_Altivec, vcmpgtuw, "__builtin_altivec_vcmpgtuw");
pragma Export (LL_Altivec, vctsxs, "__builtin_altivec_vctsxs");
pragma Export (LL_Altivec, vctuxs, "__builtin_altivec_vctuxs");
pragma Export (LL_Altivec, vexptefp, "__builtin_altivec_vexptefp");
pragma Export (LL_Altivec, vlogefp, "__builtin_altivec_vlogefp");
pragma Export (LL_Altivec, vmaddfp, "__builtin_altivec_vmaddfp");
pragma Export (LL_Altivec, vmaxfp, "__builtin_altivec_vmaxfp");
pragma Export (LL_Altivec, vmaxsb, "__builtin_altivec_vmaxsb");
pragma Export (LL_Altivec, vmaxsh, "__builtin_altivec_vmaxsh");
pragma Export (LL_Altivec, vmaxsw, "__builtin_altivec_vmaxsw");
pragma Export (LL_Altivec, vmaxub, "__builtin_altivec_vmaxub");
pragma Export (LL_Altivec, vmaxuh, "__builtin_altivec_vmaxuh");
pragma Export (LL_Altivec, vmaxuw, "__builtin_altivec_vmaxuw");
pragma Export (LL_Altivec, vmhaddshs, "__builtin_altivec_vmhaddshs");
pragma Export (LL_Altivec, vmhraddshs, "__builtin_altivec_vmhraddshs");
pragma Export (LL_Altivec, vminfp, "__builtin_altivec_vminfp");
pragma Export (LL_Altivec, vminsb, "__builtin_altivec_vminsb");
pragma Export (LL_Altivec, vminsh, "__builtin_altivec_vminsh");
pragma Export (LL_Altivec, vminsw, "__builtin_altivec_vminsw");
pragma Export (LL_Altivec, vminub, "__builtin_altivec_vminub");
pragma Export (LL_Altivec, vminuh, "__builtin_altivec_vminuh");
pragma Export (LL_Altivec, vminuw, "__builtin_altivec_vminuw");
pragma Export (LL_Altivec, vmladduhm, "__builtin_altivec_vmladduhm");
pragma Export (LL_Altivec, vmrghb, "__builtin_altivec_vmrghb");
pragma Export (LL_Altivec, vmrghh, "__builtin_altivec_vmrghh");
pragma Export (LL_Altivec, vmrghw, "__builtin_altivec_vmrghw");
pragma Export (LL_Altivec, vmrglb, "__builtin_altivec_vmrglb");
pragma Export (LL_Altivec, vmrglh, "__builtin_altivec_vmrglh");
pragma Export (LL_Altivec, vmrglw, "__builtin_altivec_vmrglw");
pragma Export (LL_Altivec, vmsummbm, "__builtin_altivec_vmsummbm");
pragma Export (LL_Altivec, vmsumshm, "__builtin_altivec_vmsumshm");
pragma Export (LL_Altivec, vmsumshs, "__builtin_altivec_vmsumshs");
pragma Export (LL_Altivec, vmsumubm, "__builtin_altivec_vmsumubm");
pragma Export (LL_Altivec, vmsumuhm, "__builtin_altivec_vmsumuhm");
pragma Export (LL_Altivec, vmsumuhs, "__builtin_altivec_vmsumuhs");
pragma Export (LL_Altivec, vmulesb, "__builtin_altivec_vmulesb");
pragma Export (LL_Altivec, vmulesh, "__builtin_altivec_vmulesh");
pragma Export (LL_Altivec, vmuleub, "__builtin_altivec_vmuleub");
pragma Export (LL_Altivec, vmuleuh, "__builtin_altivec_vmuleuh");
pragma Export (LL_Altivec, vmulosb, "__builtin_altivec_vmulosb");
pragma Export (LL_Altivec, vmulosh, "__builtin_altivec_vmulosh");
pragma Export (LL_Altivec, vmuloub, "__builtin_altivec_vmuloub");
pragma Export (LL_Altivec, vmulouh, "__builtin_altivec_vmulouh");
pragma Export (LL_Altivec, vnmsubfp, "__builtin_altivec_vnmsubfp");
pragma Export (LL_Altivec, vnor, "__builtin_altivec_vnor");
pragma Export (LL_Altivec, vxor, "__builtin_altivec_vxor");
pragma Export (LL_Altivec, vor, "__builtin_altivec_vor");
pragma Export (LL_Altivec, vperm_4si, "__builtin_altivec_vperm_4si");
pragma Export (LL_Altivec, vpkpx, "__builtin_altivec_vpkpx");
pragma Export (LL_Altivec, vpkshss, "__builtin_altivec_vpkshss");
pragma Export (LL_Altivec, vpkshus, "__builtin_altivec_vpkshus");
pragma Export (LL_Altivec, vpkswss, "__builtin_altivec_vpkswss");
pragma Export (LL_Altivec, vpkswus, "__builtin_altivec_vpkswus");
pragma Export (LL_Altivec, vpkuhum, "__builtin_altivec_vpkuhum");
pragma Export (LL_Altivec, vpkuhus, "__builtin_altivec_vpkuhus");
pragma Export (LL_Altivec, vpkuwum, "__builtin_altivec_vpkuwum");
pragma Export (LL_Altivec, vpkuwus, "__builtin_altivec_vpkuwus");
pragma Export (LL_Altivec, vrefp, "__builtin_altivec_vrefp");
pragma Export (LL_Altivec, vrfim, "__builtin_altivec_vrfim");
pragma Export (LL_Altivec, vrfin, "__builtin_altivec_vrfin");
pragma Export (LL_Altivec, vrfip, "__builtin_altivec_vrfip");
pragma Export (LL_Altivec, vrfiz, "__builtin_altivec_vrfiz");
pragma Export (LL_Altivec, vrlb, "__builtin_altivec_vrlb");
pragma Export (LL_Altivec, vrlh, "__builtin_altivec_vrlh");
pragma Export (LL_Altivec, vrlw, "__builtin_altivec_vrlw");
pragma Export (LL_Altivec, vrsqrtefp, "__builtin_altivec_vrsqrtefp");
pragma Export (LL_Altivec, vsel_4si, "__builtin_altivec_vsel_4si");
pragma Export (LL_Altivec, vsldoi_4si, "__builtin_altivec_vsldoi_4si");
pragma Export (LL_Altivec, vsldoi_8hi, "__builtin_altivec_vsldoi_8hi");
pragma Export (LL_Altivec, vsldoi_16qi, "__builtin_altivec_vsldoi_16qi");
pragma Export (LL_Altivec, vsldoi_4sf, "__builtin_altivec_vsldoi_4sf");
pragma Export (LL_Altivec, vsl, "__builtin_altivec_vsl");
pragma Export (LL_Altivec, vslb, "__builtin_altivec_vslb");
pragma Export (LL_Altivec, vslh, "__builtin_altivec_vslh");
pragma Export (LL_Altivec, vslo, "__builtin_altivec_vslo");
pragma Export (LL_Altivec, vslw, "__builtin_altivec_vslw");
pragma Export (LL_Altivec, vspltb, "__builtin_altivec_vspltb");
pragma Export (LL_Altivec, vsplth, "__builtin_altivec_vsplth");
pragma Export (LL_Altivec, vspltisb, "__builtin_altivec_vspltisb");
pragma Export (LL_Altivec, vspltish, "__builtin_altivec_vspltish");
pragma Export (LL_Altivec, vspltisw, "__builtin_altivec_vspltisw");
pragma Export (LL_Altivec, vspltw, "__builtin_altivec_vspltw");
pragma Export (LL_Altivec, vsr, "__builtin_altivec_vsr");
pragma Export (LL_Altivec, vsrab, "__builtin_altivec_vsrab");
pragma Export (LL_Altivec, vsrah, "__builtin_altivec_vsrah");
pragma Export (LL_Altivec, vsraw, "__builtin_altivec_vsraw");
pragma Export (LL_Altivec, vsrb, "__builtin_altivec_vsrb");
pragma Export (LL_Altivec, vsrh, "__builtin_altivec_vsrh");
pragma Export (LL_Altivec, vsro, "__builtin_altivec_vsro");
pragma Export (LL_Altivec, vsrw, "__builtin_altivec_vsrw");
pragma Export (LL_Altivec, vsubcuw, "__builtin_altivec_vsubcuw");
pragma Export (LL_Altivec, vsubfp, "__builtin_altivec_vsubfp");
pragma Export (LL_Altivec, vsubsbs, "__builtin_altivec_vsubsbs");
pragma Export (LL_Altivec, vsubshs, "__builtin_altivec_vsubshs");
pragma Export (LL_Altivec, vsubsws, "__builtin_altivec_vsubsws");
pragma Export (LL_Altivec, vsububm, "__builtin_altivec_vsububm");
pragma Export (LL_Altivec, vsububs, "__builtin_altivec_vsububs");
pragma Export (LL_Altivec, vsubuhm, "__builtin_altivec_vsubuhm");
pragma Export (LL_Altivec, vsubuhs, "__builtin_altivec_vsubuhs");
pragma Export (LL_Altivec, vsubuwm, "__builtin_altivec_vsubuwm");
pragma Export (LL_Altivec, vsubuws, "__builtin_altivec_vsubuws");
pragma Export (LL_Altivec, vsum2sws, "__builtin_altivec_vsum2sws");
pragma Export (LL_Altivec, vsum4sbs, "__builtin_altivec_vsum4sbs");
pragma Export (LL_Altivec, vsum4shs, "__builtin_altivec_vsum4shs");
pragma Export (LL_Altivec, vsum4ubs, "__builtin_altivec_vsum4ubs");
pragma Export (LL_Altivec, vsumsws, "__builtin_altivec_vsumsws");
pragma Export (LL_Altivec, vupkhpx, "__builtin_altivec_vupkhpx");
pragma Export (LL_Altivec, vupkhsb, "__builtin_altivec_vupkhsb");
pragma Export (LL_Altivec, vupkhsh, "__builtin_altivec_vupkhsh");
pragma Export (LL_Altivec, vupklpx, "__builtin_altivec_vupklpx");
pragma Export (LL_Altivec, vupklsb, "__builtin_altivec_vupklsb");
pragma Export (LL_Altivec, vupklsh, "__builtin_altivec_vupklsh");
pragma Export (LL_Altivec, vcmpbfp_p, "__builtin_altivec_vcmpbfp_p");
pragma Export (LL_Altivec, vcmpeqfp_p, "__builtin_altivec_vcmpeqfp_p");
pragma Export (LL_Altivec, vcmpgefp_p, "__builtin_altivec_vcmpgefp_p");
pragma Export (LL_Altivec, vcmpgtfp_p, "__builtin_altivec_vcmpgtfp_p");
pragma Export (LL_Altivec, vcmpequw_p, "__builtin_altivec_vcmpequw_p");
pragma Export (LL_Altivec, vcmpgtsw_p, "__builtin_altivec_vcmpgtsw_p");
pragma Export (LL_Altivec, vcmpgtuw_p, "__builtin_altivec_vcmpgtuw_p");
pragma Export (LL_Altivec, vcmpgtuh_p, "__builtin_altivec_vcmpgtuh_p");
pragma Export (LL_Altivec, vcmpgtsh_p, "__builtin_altivec_vcmpgtsh_p");
pragma Export (LL_Altivec, vcmpequh_p, "__builtin_altivec_vcmpequh_p");
pragma Export (LL_Altivec, vcmpequb_p, "__builtin_altivec_vcmpequb_p");
pragma Export (LL_Altivec, vcmpgtsb_p, "__builtin_altivec_vcmpgtsb_p");
pragma Export (LL_Altivec, vcmpgtub_p, "__builtin_altivec_vcmpgtub_p");
end GNAT.Altivec.Low_Level_Vectors;
|
with Ada.Text_IO;
procedure Comb_Sort is
generic
type Element_Type is private;
type Index_Type is range <>;
type Array_Type is array (Index_Type range <>) of Element_Type;
with function ">" (Left, Right : Element_Type) return Boolean is <>;
with function "+" (Left : Index_Type; Right : Natural) return Index_Type is <>;
with function "-" (Left : Index_Type; Right : Natural) return Index_Type is <>;
procedure Comb_Sort (Data: in out Array_Type);
procedure Comb_Sort (Data: in out Array_Type) is
procedure Swap (Left, Right : in Index_Type) is
Temp : Element_Type := Data(Left);
begin
Data(Left) := Data(Right);
Data(Right) := Temp;
end Swap;
Gap : Natural := Data'Length;
Swap_Occured : Boolean;
begin
loop
Gap := Natural (Float(Gap) / 1.25 - 0.5);
if Gap < 1 then
Gap := 1;
end if;
Swap_Occured := False;
for I in Data'First .. Data'Last - Gap loop
if Data (I) > Data (I+Gap) then
Swap (I, I+Gap);
Swap_Occured := True;
end if;
end loop;
exit when Gap = 1 and not Swap_Occured;
end loop;
end Comb_Sort;
type Integer_Array is array (Positive range <>) of Integer;
procedure Int_Comb_Sort is new Comb_Sort (Integer, Positive, Integer_Array);
Test_Array : Integer_Array := (1, 3, 256, 0, 3, 4, -1);
begin
Int_Comb_Sort (Test_Array);
for I in Test_Array'Range loop
Ada.Text_IO.Put (Integer'Image (Test_Array (I)));
end loop;
Ada.Text_IO.New_Line;
end Comb_Sort;
|
------------------------------------------------------------------------------
-- Copyright (c) 2014-2015, 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 Natools.S_Expressions.Test_Tools;
package body Natools.S_Expressions.Printers.Tests is
procedure All_Tests (Report : in out NT.Reporter'Class) is
begin
Canonical_Test (Report);
end All_Tests;
procedure Canonical_Test (Report : in out NT.Reporter'Class) is
Name : constant String := "Canonical encoding";
begin
declare
Stream : aliased Test_Tools.Memory_Stream;
Printer : Canonical (Stream'Access);
begin
Stream.Set_Expected (To_Atom
("3:The(5:quick((5:brown3:fox)()))"
& "(5:jumps)9:over3:the()4:lazy0:3:dog"));
Printer.Append_String ("The");
Printer.Open_List;
Printer.Append_String ("quick");
Printer.Open_List;
Printer.Open_List;
Printer.Append_String ("brown");
Printer.Append_String ("fox");
Printer.Close_List;
Printer.Open_List;
Printer.Close_List;
Printer.Close_List;
Printer.Close_List;
Printer.Open_List;
Printer.Append_String ("jumps");
Printer.Close_List;
Printer.Append_String ("over3:the");
Printer.Open_List;
Printer.Close_List;
Printer.Append_String ("lazy");
Printer.Append_Atom (Null_Atom);
Printer.Append_String ("dog");
if Stream.Has_Mismatch
or else Stream.Unread_Expected /= Null_Atom
then
Report.Item (Name, NT.Fail);
Report.Info ("Mismatch at position"
& Count'Image (Stream.Mismatch_Index));
Report.Info ("Left to expect: """
& To_String (Stream.Unread_Expected) & '"');
Report.Info ("Written data: """
& To_String (Stream.Get_Data) & '"');
else
Report.Item (Name, NT.Success);
end if;
end;
exception
when Error : others => Report.Report_Exception (Name, Error);
end Canonical_Test;
end Natools.S_Expressions.Printers.Tests;
|
pragma Ada_2012;
package body TLSF.Proof.Relation is
function Relate(Container : R;
From, To : Element_Type)
return R
is
Len : constant Count_Type := Length(Container);
A : constant Arrow := (From, To);
begin
if Contains(Container, A) then
return Container;
else
pragma Assert (not Contains(Container, A));
declare
New_Container : constant R := Add(Container, A);
New_Len : constant Count_Type := Length(New_Container);
begin
pragma Assert (Contains(Container => Container,
Item => A));
pragma Assert (New_Len > Len);
return New_Container;
end;
end if;
end Relate;
end TLSF.Proof.Relation;
|
pragma License (Unrestricted);
-- extended unit
package Ada.Float is
-- Ada.Decimal-like (and more) utilities for float types.
pragma Pure;
generic
type Float_Type is digits <>;
function Infinity return Float_Type;
pragma Inline (Infinity);
generic
type Float_Type is digits <>;
function NaN return Float_Type;
pragma Inline (NaN);
generic
type Float_Type is digits <>;
function Is_Infinity (X : Float_Type) return Boolean;
pragma Inline (Is_Infinity);
generic
type Float_Type is digits <>;
function Is_NaN (X : Float_Type) return Boolean;
pragma Inline (Is_NaN);
generic
type Float_Type is digits <>;
function Is_Negative (X : Float_Type) return Boolean
with Import, Convention => Intrinsic;
generic
type Dividend_Type is digits <>;
type Divisor_Type is digits <>;
type Quotient_Type is digits <>;
type Remainder_Type is digits <>;
procedure Divide (
Dividend : Dividend_Type;
Divisor : Divisor_Type;
Quotient : out Quotient_Type;
Remainder : out Remainder_Type);
pragma Inline (Divide);
generic
type Dividend_Type is digits <>;
type Quotient_Type is digits <>;
type Remainder_Type is digits <>;
procedure Divide_By_1 (
Dividend : Dividend_Type;
Quotient : out Quotient_Type;
Remainder : out Remainder_Type); -- sign of Remainder = sign of Dividend
pragma Inline (Divide_By_1);
generic
type Dividend_Type is digits <>;
type Quotient_Type is digits <>;
type Remainder_Type is digits <>;
procedure Modulo_Divide_By_1 (
Dividend : Dividend_Type;
Quotient : out Quotient_Type;
Remainder : out Remainder_Type); -- Remainder >= 0
pragma Inline (Modulo_Divide_By_1);
end Ada.Float;
|
-- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
with AUnit; use AUnit;
with AUnit.Test_Cases; use AUnit.Test_Cases;
package Yaml.Lexer.Tokenization_Test is
type TC is new Test_Cases.Test_Case with record
Pool : Text.Pool.Reference;
end record;
overriding procedure Register_Tests (T : in out TC);
overriding procedure Set_Up (T : in out TC);
function Name (T : TC) return Message_String;
procedure Empty_Document (T : in out Test_Cases.Test_Case'Class);
procedure Single_Line_Scalar (T : in out Test_Cases.Test_Case'Class);
procedure Multiline_Scalar (T : in out Test_Cases.Test_Case'Class);
procedure Single_Line_Mapping (T : in out Test_Cases.Test_Case'Class);
procedure Multiline_Mapping (T : in out Test_Cases.Test_Case'Class);
procedure Explicit_Mapping (T : in out Test_Cases.Test_Case'Class);
procedure Sequence (T : in out Test_Cases.Test_Case'Class);
procedure Sequence_With_Block_Mappings (T : in out Test_Cases.Test_Case'Class);
procedure Single_Quoted_Scalar (T : in out Test_Cases.Test_Case'Class);
procedure Multiline_Single_Quoted_Scalar (T : in out Test_Cases.Test_Case'Class);
procedure Double_Quoted_Scalar (T : in out Test_Cases.Test_Case'Class);
procedure Multiline_Double_Quoted_Scalar (T : in out Test_Cases.Test_Case'Class);
procedure Escape_Sequences (T : in out Test_Cases.Test_Case'Class);
procedure Block_Scalar (T : in out Test_Cases.Test_Case'Class);
procedure Block_Scalars (T : in out Test_Cases.Test_Case'Class);
procedure Directives (T : in out Test_Cases.Test_Case'Class);
procedure Markers (T : in out Test_Cases.Test_Case'Class);
procedure Flow_Indicators (T : in out Test_Cases.Test_Case'Class);
procedure Adjacent_Map_Values (T : in out Test_Cases.Test_Case'Class);
procedure Tag_Handles (T : in out Test_Cases.Test_Case'Class);
procedure Verbatim_Tag_Handle (T : in out Test_Cases.Test_Case'Class);
procedure Anchors_And_Aliases (T : in out Test_Cases.Test_Case'Class);
procedure Empty_Lines (T : in out Test_Cases.Test_Case'Class);
end Yaml.Lexer.Tokenization_Test;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- A L I . U T I L --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2003 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This child unit provides utility data structures and procedures used
-- for manipulation of ALI data by the gnatbind and gnatmake.
package ALI.Util is
-----------------------
-- Source File Table --
-----------------------
-- A source file table entry is built for every source file that is
-- in the source dependency table of any of the ALI files that make
-- up the current program.
No_Source_Id : constant Source_Id := Source_Id'First;
-- Special value indicating no Source table entry
First_Source_Entry : constant Source_Id := No_Source_Id + 1;
-- Id of first actual entry in table
type Source_Record is record
Sfile : File_Name_Type;
-- Name of source file
Stamp : Time_Stamp_Type;
-- Time stamp value. If Check_Source_Files is set and the source
-- file is located, then Stamp is set from the source file. Otherwise
-- Stamp is set from the latest stamp value found in any of the
-- ALI files for the current program.
Source_Found : Boolean;
-- This flag is set to True if the corresponding source file was
-- located and the Stamp value was set from the actual source file.
-- It is always false if Check_Source_Files is not set.
All_Timestamps_Match : Boolean;
-- This flag is set only if all files referencing this source file
-- have a matching time stamp, and also, if Source_Found is True,
-- then the stamp of the source file also matches. If this flag is
-- True, then checksums for this file are never referenced. We only
-- use checksums if there are time stamp mismatches.
All_Checksums_Match : Boolean;
-- This flag is set only if all files referencing this source file
-- have checksums, and if all these checksums match. If this flag
-- is set to True, then the binder will ignore a timestamp mismatch.
-- An absent checksum causes this flag to be set False, and a mismatch
-- of checksums also causes it to be set False. The checksum of the
-- actual source file (if Source_Found is True) is included only if
-- All_Timestamps_Match is False (since checksums are only interesting
-- if we have time stamp mismatches, and we want to avoid computing the
-- checksum of the source file if it is not needed.)
Checksum : Word;
-- If no dependency line has a checksum for this source file (i.e. the
-- corresponding entries in the source dependency records all have the
-- Checksum_Present flag set False), then this field is undefined. If
-- at least one dependency entry has a checksum present, then this
-- field contains one of the possible checksum values that has been
-- seen. This is used to set All_Checksums_Match properly.
end record;
package Source is new Table.Table (
Table_Component_Type => Source_Record,
Table_Index_Type => Source_Id,
Table_Low_Bound => First_Source_Entry,
Table_Initial => 1000,
Table_Increment => 200,
Table_Name => "Source");
procedure Initialize_ALI_Source;
-- Initialize Source table
--------------------------------------------------
-- Subprograms for Manipulating ALI Information --
--------------------------------------------------
procedure Read_ALI (Id : ALI_Id);
-- Process an ALI file which has been read and scanned by looping
-- through all withed units in the ALI file, checking if they have
-- been processed. Each unit that has not yet been processed will
-- be read, scanned, and processed recursively.
procedure Set_Source_Table (A : ALI_Id);
-- Build source table entry corresponding to the ALI file whose id is A.
procedure Set_Source_Table;
-- Build the entire source table.
function Time_Stamp_Mismatch
(A : ALI_Id;
Read_Only : Boolean := False)
return File_Name_Type;
-- Looks in the Source_Table and checks time stamp mismatches between
-- the sources there and the sources in the Sdep section of ali file whose
-- id is A. If no time stamp mismatches are found No_File is returned.
-- Otherwise return the first file for which there is a mismatch.
-- Note that in check source files mode (Check_Source_Files = True), the
-- time stamp in the Source_Table should be the actual time stamp of the
-- source files. In minimal recompilation mode (Minimal_Recompilation set
-- to True, no mismatch is found if the file's timestamp has not changed.
-- If Read_Only is True, missing sources are not considered.
--------------------------------------------
-- Subprograms for manipulating checksums --
--------------------------------------------
Checksum_Error : constant Word := 16#FFFF_FFFF#;
-- This value is used to indicate an error in computing the checksum.
-- When comparing checksums for smart recompilation, the CRC_Error
-- value is never considered to match. This could possibly result
-- in a false negative, but that is never harmful, it just means
-- that in unusual cases an unnecessary recompilation occurs.
function Get_File_Checksum (Fname : Name_Id) return Word;
-- Compute checksum for the given file. As far as possible, this circuit
-- computes exactly the same value computed by the compiler, but it does
-- not matter if it gets it wrong in marginal cases, since the only result
-- is to miss some smart recompilation cases, correct functioning is not
-- affected by a miscomputation. Returns Checksum_Error if the file is
-- missing or has an error.
function Checksums_Match (Checksum1, Checksum2 : Word) return Boolean;
pragma Inline (Checksums_Match);
-- Returns True if Checksum1 and Checksum2 have the same value and are
-- not equal to Checksum_Error, returns False in all other cases. This
-- routine must always be used to compare for checksum equality, to
-- ensure that the case of Checksum_Error is handled properly.
end ALI.Util;
|
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Finalization;
package Adabots_Lua_Dispatcher is
type Lua_Dispatcher is new Ada.Finalization.Limited_Controlled with private;
function Create_Lua_Dispatcher return Lua_Dispatcher;
function Create_Lua_Dispatcher (Port : Integer) return Lua_Dispatcher;
function Raw_Function (T : Lua_Dispatcher; Lua_Code : String) return String;
function Boolean_Function
(T : Lua_Dispatcher; Lua_Code : String) return Boolean;
procedure Raw_Procedure (T : Lua_Dispatcher; Lua_Code : String);
private
task type Command_Server (Port : Integer) is
entry Schedule_Command (Command : String);
entry Fetch_Command (Command : out Unbounded_String);
entry Push_Return_Value (Return_Value : String);
entry Get_Result (Result : out Unbounded_String);
entry Shutdown;
end Command_Server;
type Access_Command_Server is access Command_Server;
type Lua_Dispatcher is new Ada.Finalization.Limited_Controlled with record
Server : Access_Command_Server;
end record;
overriding procedure Finalize (T : in out Lua_Dispatcher);
end Adabots_Lua_Dispatcher;
|
-- Copyright 2019 Michael Casadevall <michael@casadevall.pro>
--
-- 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; use Ada.Strings.Unbounded;
with DNSCatcher.DNS.Processor.Packet; use DNSCatcher.DNS.Processor.Packet;
with DNSCatcher.Config; use DNSCatcher.Config;
with DNSCatcher.DNS; use DNSCatcher.DNS;
with DNSCatcher.Types; use DNSCatcher.Types;
-- Creates and handles making DNS client requests
package DNSCatcher.DNS.Client is
-- DNS Client object
type Client is tagged private;
type Client_Access is access all Client'Class;
-- Populates the header field for a given DNS request
--
-- @value This the DNS Client object
procedure Create_Header (This : in out Client);
--!pp off
-- Adds a question to the DNS request
--
-- @value This the DNS Client object
-- @value QName DNS name to query
-- @value QType The RRType to query
-- @value QClass DNS Class to query
--!pp on
procedure Add_Query
(This : in out Client;
QName : Unbounded_String;
QType : RR_Types;
QClass : Classes);
--!pp off
-- Creates a DNS packet out of a client request (should be private)
--
-- @value This the DNS Client object
-- @value Config to the DNSCatcher configuration
--!pp on
function Create_Packet
(This : in out Client;
Config : Configuration)
return Raw_Packet_Record_Ptr;
private
type Client is tagged record
Header : DNS_Packet_Header;
Questions : Question_Vector.Vector;
end record;
end DNSCatcher.DNS.Client;
|
package Types.Strings is
Exponent_Digits : Natural := 2;
Digits_After_Decimal : Natural := 3;
function To_String
(Value : Miles_T)
return String;
function To_String
(Value : Hours_T)
return String;
-- Create functions to convert your types to strings
end Types.Strings;
|
with Ada.Exceptions;
with GNAT.OS_Lib;
with Ada.Text_IO; use Ada.Text_IO;
with Sf.Window.VideoMode; use Sf.Window.VideoMode;
with Sf.Graphics; use Sf.Graphics;
with Sf.Graphics.Sprite; use Sf.Graphics.Sprite;
with Sf.Graphics.Texture; use Sf.Graphics.Texture;
with Sf.Graphics.RenderTexture; use Sf.Graphics.RenderTexture;
with Sf.Graphics.View; use Sf.Graphics.View;
with Sf.Graphics.RenderWindow; use Sf.Graphics.RenderWindow;
with Sf.Window.Window; use Sf.Window.Window;
with Sf.Window.Event; use Sf.Window.Event;
with Sf.Window.Keyboard; use Sf.Window.Keyboard;
with Sf; use Sf;
with Ada.Real_Time; use Ada.Real_Time;
with Sf.System.Vector2; use Sf.System.Vector2;
with Ada.Unchecked_Conversion;
with simulator_assets;
package body PyGamer is
function Hack_SF_Binding is new Ada.Unchecked_Conversion (sfSprite_Ptr,
sfView_Ptr);
--------------
-- Set_View --
--------------
procedure Set_View (View : Sf.Graphics.sfView_Ptr;
Width, Height : sfUint32)
is
Win_Ratio : constant Float := Float (Width) / Float (Height);
View_Ratio : constant Float := Float (getSize (View).x) / Float (getSize (View).y);
Size_X : Float := 1.0;
Size_Y : Float := 1.0;
Pos_X : Float := 0.0;
Pos_Y : Float := 0.0;
Horizontal_Spacing : Boolean := True;
begin
if Win_Ratio < View_Ratio then
Size_Y := Win_Ratio / View_Ratio;
Pos_Y := (1.0 - Size_Y) / 2.0;
else
Size_X := View_Ratio / Win_Ratio;
Pos_X := (1.0 - Size_X) / 2.0;
end if;
setViewport (View, (Pos_X, Pos_Y, Size_X, Size_Y));
end Set_View;
task Periodic_Update is
end Periodic_Update;
---------------------
-- Periodic_Update --
---------------------
task body Periodic_Update is
BG_Width : constant := 730;
BG_Height : constant := 411;
Mode : constant Sf.Window.VideoMode.sfVideoMode :=
(BG_Width, BG_Height, 32);
Params : sfContextSettings := sfDefaultContextSettings;
Window : Sf.Graphics.sfRenderWindow_Ptr;
Framebuffer_Texture : Sf.Graphics.sfTexture_Ptr;
Render_Texture : Sf.Graphics.sfRenderTexture_Ptr;
PG_Texture : Sf.Graphics.sfTexture_Ptr;
PG_Sprite : Sf.Graphics.sfSprite_Ptr;
Screen_Sprite : Sf.Graphics.sfSprite_Ptr;
Sprite_Left : Sf.Graphics.sfSprite_Ptr;
Sprite_Right : Sf.Graphics.sfSprite_Ptr;
Letter_Box_View : Sf.Graphics.sfView_Ptr;
Event : sfEvent;
Period : constant Time_Span := Milliseconds (1000 / 60);
Next_Release : Time := Clock + Period;
Pressed : Boolean;
Screen_Scale : constant := 287.0 / Float (Screen_Width);
Screen_Offset : constant sfVector2f := (231.0, 66.0);
begin
Framebuffer_Texture := Create (Screen_Width, Screen_Height);
if Framebuffer_Texture = null then
Put_Line ("Failed to create screen texture");
GNAT.OS_Lib.OS_Exit (1);
end if;
declare
Ptr : constant simulator_assets.Content_Access :=
simulator_assets.Get_Content ("pygamer.png").Content;
begin
PG_Texture := createFromMemory (Ptr.all'Address, Ptr.all'Length);
end;
if PG_Texture = null then
Put_Line ("Failed to create PyGamer texture");
GNAT.OS_Lib.OS_Exit (1);
end if;
Render_Texture := create (Screen_Width, Screen_Height, False);
if Render_Texture = null then
Put_Line ("Could not create render texture");
GNAT.OS_Lib.OS_Exit (1);
end if;
Screen_Sprite := Create;
if Screen_Sprite = null then
Put_Line ("Could not create screen sprite");
GNAT.OS_Lib.OS_Exit (1);
end if;
SetTexture (Screen_Sprite, getTexture (Render_Texture));
scale (Screen_Sprite, (Screen_Scale, Screen_Scale));
setPosition (Screen_Sprite, Screen_Offset);
Sprite_Left := Create;
if Sprite_Left = null then
Put_Line ("Could not create sprite");
GNAT.OS_Lib.OS_Exit (1);
end if;
SetTexture (Sprite_Left, Framebuffer_Texture);
Sprite_Right := Create;
if Sprite_Right = null then
Put_Line ("Could not create sprite");
GNAT.OS_Lib.OS_Exit (1);
end if;
SetTexture (Sprite_Right, Framebuffer_Texture);
PG_Sprite := Create;
if PG_Sprite = null then
Put_Line ("Could not create sprite");
GNAT.OS_Lib.OS_Exit (1);
end if;
SetTexture (PG_Sprite, PG_Texture);
Window := Create (Mode, "PyGamer simulator", sfResize or sfClose, Params);
if Window = null then
Put_Line ("Failed to create window");
GNAT.OS_Lib.OS_Exit (1);
end if;
SetVerticalSyncEnabled (Window, sfFalse);
SetVisible (Window, sfTrue);
Letter_Box_View := create;
if Letter_Box_View = null then
Put_Line ("Failed to create view");
GNAT.OS_Lib.OS_Exit (1);
end if;
setSize (Letter_Box_View, (Float (BG_Width), Float (BG_Height)));
setCenter (Letter_Box_View,
(Float (BG_Width) / 2.0, Float (BG_Height) / 2.0));
Set_View (Letter_Box_View, getSize (Window).x, getSize (Window).y);
loop
delay until Next_Release;
Next_Release := Next_Release + Period;
while pollEvent (Window, Event) loop
if Event.eventType = sfEvtClosed then
Close (Window);
Put_Line ("Attempting to close");
GNAT.OS_Lib.OS_Exit (0);
end if;
if Event.eventType = sfEvtResized then
Set_View (Letter_Box_View, Event.size.width, Event.size.height);
end if;
if Event.eventType in sfEvtKeyPressed | sfEvtKeyReleased then
Pressed := Event.eventType = sfEvtKeyPressed;
case Event.key.code is
when sfKeyLeft =>
SFML_Pressed (Left) := Pressed;
when sfKeyRight =>
SFML_Pressed (Right) := Pressed;
when sfKeyDown =>
SFML_Pressed (Down) := Pressed;
when sfKeyUp =>
SFML_Pressed (Up) := Pressed;
when sfKeyZ =>
SFML_Pressed (B) := Pressed;
when sfKeyX =>
SFML_Pressed (A) := Pressed;
when sfKeyReturn =>
SFML_Pressed (Start) := Pressed;
when sfKeyC =>
SFML_Pressed (Sel) := Pressed;
when sfKeyEscape =>
Close (Window);
Put_Line ("Attempting to close");
GNAT.OS_Lib.OS_Exit (0);
when others =>
null;
end case;
end if;
end loop;
updateFromPixels (texture => Framebuffer_Texture,
pixels => Frame_Buffer (Frame_Buffer'First)'access,
width => Screen_Width,
height => Screen_Height,
x => 0,
y => 0);
setPosition (Sprite_Right,
(Float (Scroll_Val) - Float (Screen_Width), 0.0));
setPosition (Sprite_Left,
(Float (Scroll_Val), 0.0));
drawSprite (Render_Texture, Hack_SF_Binding (Sprite_Right));
drawSprite (Render_Texture, Hack_SF_Binding (Sprite_Left));
display (Render_Texture);
clear (Window);
drawSprite (Window, PG_Sprite);
drawSprite (Window, Screen_Sprite);
setView (Window, Letter_Box_View);
display (Window);
end loop;
exception
when E : others =>
Put_Line (Ada.Exceptions.Exception_Message (E));
GNAT.OS_Lib.OS_Exit (1);
end Periodic_Update;
end PyGamer;
|
with Ada.Text_IO; use Ada.Text_IO;
with Registre;
procedure Test_Registre is
package Registre_Test is new Registre (100, Integer);
use Registre_Test;
procedure Test_Initialiser is
Registre : T_Registre;
begin
Initialiser (Registre);
pragma Assert (Est_Vide (Registre));
Detruire (Registre);
end Test_Initialiser;
procedure Test_Attribuer is
Registre : T_Registre;
begin
Initialiser (Registre);
Attribuer (Registre, 1, 1);
pragma Assert (Existe (Registre, 1));
Detruire (Registre);
end Test_Attribuer;
procedure Test_Acceder is
Registre : T_Registre;
begin
Initialiser (Registre);
Attribuer (Registre, 1, 1);
pragma Assert (Acceder (Registre, 1) = 1);
Detruire (Registre);
end Test_Acceder;
procedure Test_Supprimer is
Registre : T_Registre;
begin
Initialiser (Registre);
Attribuer (Registre, 1, 2);
Supprimer (Registre, 1);
pragma Assert (not Existe (Registre, 1));
Detruire (Registre);
end Test_Supprimer;
procedure Test_Detruire is
Registre : T_Registre;
begin
Initialiser (Registre);
Attribuer (Registre, 1, 2);
Attribuer (Registre, 3, 4);
Attribuer (Registre, 2, 5);
Detruire (Registre);
pragma Assert (Est_Vide (Registre));
end Test_Detruire;
begin
Test_Initialiser;
Test_Acceder;
Test_Attribuer;
Test_Supprimer;
Test_Detruire;
Put_Line ("Le module est fonctionnel");
end Test_Registre;
|
-----------------------------------------------------------------------
-- upnp-ssdp -- UPnP SSDP operations
-- Copyright (C) 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.Strings;
with Ada.Strings.Unbounded;
with Ada.Calendar;
with System;
with Interfaces.C.Strings;
with Util.Log.Loggers;
package body UPnP.SSDP is
use type Ada.Streams.Stream_Element_Offset;
use type Ada.Streams.Stream_Element;
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("UPnP.SSDP");
Group : constant String := "239.255.255.250";
type Sockaddr is record
Sa_Family : Interfaces.C.unsigned_short;
Sa_Port : Interfaces.C.unsigned_short;
Sa_Addr : aliased Interfaces.C.char_array (1 .. 8);
end record;
pragma Convention (C, Sockaddr);
type If_Address;
type If_Address_Access is access all If_Address;
type If_Address is record
Ifa_Next : If_Address_Access;
Ifa_Name : Interfaces.C.Strings.chars_ptr;
Ifa_Flags : Interfaces.C.unsigned;
Ifa_Addr : access Sockaddr;
end record;
pragma Convention (C, If_Address);
function Sys_getifaddrs (ifap : access If_Address_Access) return Interfaces.C.int;
pragma Import (C, Sys_getifaddrs, "getifaddrs");
procedure Sys_freeifaddrs (ifap : If_Address_Access);
pragma Import (C, Sys_freeifaddrs, "freeifaddrs");
function Sys_Inet_Ntop (Af : in Interfaces.C.unsigned_short;
Addr : System.Address;
Dst : in Interfaces.C.Strings.chars_ptr;
Size : in Interfaces.C.int) return Interfaces.C.Strings.chars_ptr;
pragma Import (C, Sys_Inet_Ntop, "inet_ntop");
procedure Send (Socket : in GNAT.Sockets.Socket_Type;
Content : in String;
To : access GNAT.Sockets.Sock_Addr_Type);
procedure Receive (Socket : in GNAT.Sockets.Socket_Type;
Target : in String;
Desc : out Ada.Strings.Unbounded.Unbounded_String);
-- ------------------------------
-- Initialize the SSDP scanner by opening the UDP socket.
-- ------------------------------
procedure Initialize (Scanner : in out Scanner_Type) is
Address : aliased GNAT.Sockets.Sock_Addr_Type;
begin
Log.Info ("Discovering gateways on the network");
Address.Addr := GNAT.Sockets.Any_Inet_Addr;
Address.Port := 0;
GNAT.Sockets.Create_Socket (Scanner.Socket, GNAT.Sockets.Family_Inet,
GNAT.Sockets.Socket_Datagram);
GNAT.Sockets.Bind_Socket (Scanner.Socket, Address);
GNAT.Sockets.Set_Socket_Option (Scanner.Socket, GNAT.Sockets.IP_Protocol_For_IP_Level,
(GNAT.Sockets.Add_Membership, GNAT.Sockets.Inet_Addr (Group),
GNAT.Sockets.Any_Inet_Addr));
end Initialize;
-- ------------------------------
-- Find the IPv4 addresses of the network interfaces.
-- ------------------------------
procedure Find_IPv4_Addresses (Scanner : in out Scanner_Type;
IPs : out Util.Strings.Sets.Set) is
pragma Unreferenced (Scanner);
use type Interfaces.C.int;
use type Interfaces.C.Strings.chars_ptr;
Iflist : aliased If_Address_Access;
Ifp : If_Address_Access;
R : Interfaces.C.Strings.chars_ptr;
begin
if Sys_getifaddrs (Iflist'Access) = 0 then
R := Interfaces.C.Strings.New_String ("xxx.xxx.xxx.xxx.xxx");
Ifp := Iflist;
while Ifp /= null loop
if Sys_Inet_Ntop (Ifp.Ifa_Addr.Sa_Family, Ifp.Ifa_Addr.Sa_Addr'Address, R, 17)
/= Interfaces.C.Strings.Null_Ptr
then
Log.Debug ("Found interface: {0} - IP {1}",
Interfaces.C.Strings.Value (Ifp.Ifa_Name),
Interfaces.C.Strings.Value (R));
if Interfaces.C.Strings.Value (R) /= "::" then
IPs.Include (Interfaces.C.Strings.Value (R));
end if;
end if;
Ifp := Ifp.Ifa_Next;
end loop;
Interfaces.C.Strings.Free (R);
Sys_freeifaddrs (Iflist);
end if;
end Find_IPv4_Addresses;
procedure Send (Socket : in GNAT.Sockets.Socket_Type;
Content : in String;
To : access GNAT.Sockets.Sock_Addr_Type) is
Last : Ada.Streams.Stream_Element_Offset;
Buf : Ada.Streams.Stream_Element_Array (1 .. Content'Length);
for Buf'Address use Content'Address;
pragma Import (Ada, Buf);
pragma Unreferenced (Last);
begin
GNAT.Sockets.Send_Socket (Socket, Buf, Last, To);
end Send;
-- ------------------------------
-- Send the SSDP discovery UDP packet on the UPnP multicast group 239.255.255.250.
-- Set the "ST" header to the given target. The UDP packet is sent on each interface
-- whose IP address is defined in the set <tt>IPs</tt>.
-- ------------------------------
procedure Send_Discovery (Scanner : in out Scanner_Type;
Target : in String;
IPs : in Util.Strings.Sets.Set) is
Address : aliased GNAT.Sockets.Sock_Addr_Type;
begin
Address.Addr := GNAT.Sockets.Inet_Addr (Group);
Address.Port := 1900;
for IP of IPs loop
GNAT.Sockets.Set_Socket_Option (Scanner.Socket, GNAT.Sockets.IP_Protocol_For_IP_Level,
(GNAT.Sockets.Multicast_If,
GNAT.Sockets.Inet_Addr (IP)));
Log.Debug ("Sending SSDP search for IGD device from {0}", IP);
Send (Scanner.Socket, "M-SEARCH * HTTP/1.1" & ASCII.CR & ASCII.LF &
"HOST: 239.255.255.250:1900" & ASCII.CR & ASCII.LF &
"ST: " & Target & ASCII.CR & ASCII.LF &
"MAN: ""ssdp:discover""" & ASCII.CR & ASCII.LF &
"MX: 2" & ASCII.CR & ASCII.LF, Address'Access);
end loop;
end Send_Discovery;
procedure Receive (Socket : in GNAT.Sockets.Socket_Type;
Target : in String;
Desc : out Ada.Strings.Unbounded.Unbounded_String) is
function Get_Line return String;
Data : Ada.Streams.Stream_Element_Array (0 .. 1500);
Last : Ada.Streams.Stream_Element_Offset;
Pos : Ada.Streams.Stream_Element_Offset := Data'First;
function Get_Line return String is
First : constant Ada.Streams.Stream_Element_Offset := Pos;
begin
while Pos <= Last loop
if Data (Pos) = 16#0D# and then Pos + 1 <= Last and then Data (Pos + 1) = 16#0A# then
declare
Result : String (1 .. Natural (Pos - First));
P : Natural := 1;
begin
for I in First .. Pos - 1 loop
Result (P) := Character'Val (Data (I));
P := P + 1;
end loop;
Log.Debug ("L: {0}", Result);
Pos := Pos + 2;
return Result;
end;
end if;
Pos := Pos + 1;
end loop;
return "";
end Get_Line;
begin
Desc := Ada.Strings.Unbounded.To_Unbounded_String ("");
GNAT.Sockets.Receive_Socket (Socket, Data, Last);
if Get_Line /= "HTTP/1.1 200 OK" then
Log.Debug ("Receive a non HTTP/1.1 response");
return;
end if;
loop
declare
Line : constant String := Get_Line;
Pos : constant Natural := Util.Strings.Index (Line, ':');
Pos2 : Natural := Pos + 1;
begin
exit when Pos = 0;
while Pos2 < Line'Last and then Line (Pos2) = ' ' loop
Pos2 := Pos2 + 1;
end loop;
if Line (1 .. Pos) = "ST:" then
if Line (Pos2 .. Line'Last) /= Target then
return;
end if;
elsif Line (1 .. Pos) = "LOCATION:" then
Desc := Ada.Strings.Unbounded.To_Unbounded_String (Line (Pos2 .. Line'Last));
Log.Debug ("Found a IGD device: {0}", Ada.Strings.Unbounded.To_String (Desc));
return;
end if;
end;
end loop;
exception
when E : others =>
Log.Error ("Exception received", E);
end Receive;
-- ------------------------------
-- Receive the UPnP SSDP discovery messages for the given target.
-- Call the <tt>Process</tt> procedure for each of them. The <tt>Desc</tt> parameter
-- represents the UPnP location header which gives the UPnP XML root descriptor.
-- Wait at most the given time.
-- ------------------------------
procedure Discover (Scanner : in out Scanner_Type;
Target : in String;
Process : not null access procedure (Desc : in String);
Wait : in Duration) is
use type Ada.Calendar.Time;
use type GNAT.Sockets.Selector_Status;
Sel : GNAT.Sockets.Selector_Type;
Rset : GNAT.Sockets.Socket_Set_Type;
Wset : GNAT.Sockets.Socket_Set_Type;
Status : GNAT.Sockets.Selector_Status;
Desc : Ada.Strings.Unbounded.Unbounded_String;
Deadline : constant Ada.Calendar.Time := Ada.Calendar.Clock + Wait;
Remain : Duration;
begin
GNAT.Sockets.Create_Selector (Sel);
loop
GNAT.Sockets.Empty (Rset);
GNAT.Sockets.Empty (Wset);
GNAT.Sockets.Set (Rset, Scanner.Socket);
Remain := Deadline - Ada.Calendar.Clock;
exit when Remain < 0.0;
GNAT.Sockets.Check_Selector (Selector => Sel,
R_Socket_Set => Rset,
W_Socket_Set => Wset,
Status => Status,
Timeout => Remain);
exit when Status = GNAT.Sockets.Expired;
Receive (Scanner.Socket, Target, Desc);
declare
URI : constant String := Ada.Strings.Unbounded.To_String (Desc);
Pos : constant Natural := Util.Strings.Index (URI, ':');
begin
if Pos > 0 and URI (URI'First .. Pos + 2) = "http://" then
Process (URI);
end if;
end;
end loop;
end Discover;
-- ------------------------------
-- Release the socket.
-- ------------------------------
overriding
procedure Finalize (Scanner : in out Scanner_Type) is
use type GNAT.Sockets.Socket_Type;
begin
if Scanner.Socket /= GNAT.Sockets.No_Socket then
GNAT.Sockets.Close_Socket (Scanner.Socket);
end if;
end Finalize;
end UPnP.SSDP;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- ADA.STRINGS.UTF_ENCODING.CONVERSIONS --
-- --
-- S p e c --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. In accordance with the copyright of that document, you can freely --
-- copy and modify this specification, provided that if you redistribute a --
-- modified version, any changes that you have made are clearly indicated. --
-- --
------------------------------------------------------------------------------
-- This is an Ada 2012 package defined in AI05-0137-1. It provides conversions
-- from one UTF encoding method to another. Note: this package is consistent
-- with Ada 95, and may be used in Ada 95 or Ada 2005 mode.
package Ada.Strings.UTF_Encoding.Conversions is
pragma Pure (Conversions);
-- In the following conversion routines, a BOM in the input that matches
-- the encoding scheme is ignored, an incorrect BOM causes Encoding_Error
-- to be raised. A BOM is present in the output if the Output_BOM parameter
-- is set to True.
function Convert
(Item : UTF_String;
Input_Scheme : Encoding_Scheme;
Output_Scheme : Encoding_Scheme;
Output_BOM : Boolean := False) return UTF_String;
-- Convert from input encoded in UTF-8, UTF-16LE, or UTF-16BE as specified
-- by the Input_Scheme argument, and generate an output encoded in one of
-- these three schemes as specified by the Output_Scheme argument.
function Convert
(Item : UTF_String;
Input_Scheme : Encoding_Scheme;
Output_BOM : Boolean := False) return UTF_16_Wide_String;
-- Convert from input encoded in UTF-8, UTF-16LE, or UTF-16BE as specified
-- by the Input_Scheme argument, and generate an output encoded in UTF-16.
function Convert
(Item : UTF_8_String;
Output_BOM : Boolean := False) return UTF_16_Wide_String;
-- Convert from UTF-8 to UTF-16
function Convert
(Item : UTF_16_Wide_String;
Output_Scheme : Encoding_Scheme;
Output_BOM : Boolean := False) return UTF_String;
-- Convert from UTF-16 to UTF-8, UTF-16LE, or UTF-16BE as specified by
-- the Output_Scheme argument.
function Convert
(Item : UTF_16_Wide_String;
Output_BOM : Boolean := False) return UTF_8_String;
-- Convert from UTF-16 to UTF-8
end Ada.Strings.UTF_Encoding.Conversions;
|
generic
with function Decode (File_Name : Posix.C_String) return String is <>;
procedure Hide.Decode_generic;
|
pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
private package CUPS.wchar_h is
-- Copyright (C) 1995-2016 Free Software Foundation, Inc.
-- This file is part of the GNU C Library.
-- The GNU C 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.
-- The GNU C 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 the GNU C Library; if not, see
-- <http://www.gnu.org/licenses/>.
-- * ISO C99 Standard: 7.24
-- * Extended multibyte and wide character utilities <wchar.h>
--
-- Get FILE definition.
-- Get va_list definition.
-- Get size_t, wchar_t, wint_t and NULL from <stddef.h>.
-- We try to get wint_t from <stddef.h>, but not all GCC versions define it
-- there. So define it ourselves if it remains undefined.
-- Integral type unchanged by default argument promotions that can
-- hold any value corresponding to members of the extended character
-- set, as well as at least one value that does not correspond to any
-- member of the extended character set.
-- Work around problems with the <stddef.h> file which doesn't put
-- wint_t in the std namespace.
-- Tell the caller that we provide correct C++ prototypes.
-- Conversion state information.
type uu_mbstate_t;
subtype uu_mbstate_t_uu_wchb_array is Interfaces.C.char_array (0 .. 3);
type anon_2 (discr : unsigned := 0) is record
case discr is
when 0 =>
uu_wch : aliased unsigned; -- wchar.h:88
when others =>
uu_wchb : aliased uu_mbstate_t_uu_wchb_array; -- wchar.h:92
end case;
end record;
pragma Convention (C_Pass_By_Copy, anon_2);
pragma Unchecked_Union (anon_2);type uu_mbstate_t is record
uu_count : aliased int; -- wchar.h:84
uu_value : aliased anon_2; -- wchar.h:93
end record;
pragma Convention (C_Pass_By_Copy, uu_mbstate_t); -- wchar.h:94
-- skipped anonymous struct anon_1
-- Value so far.
-- The rest of the file is only used if used if __need_mbstate_t is not
-- defined.
-- Public type.
-- These constants might also be defined in <inttypes.h>.
-- For XPG4 compliance we have to define the stuff from <wctype.h> here
-- as well.
-- This incomplete type is defined in <time.h> but needed here because
-- of `wcsftime'.
-- XXX We have to clean this up at some point. Since tm is in the std
-- namespace but wcsftime is in __c99 the type wouldn't be found
-- without inserting it in the global namespace.
-- Copy SRC to DEST.
-- Copy no more than N wide-characters of SRC to DEST.
-- Append SRC onto DEST.
-- Append no more than N wide-characters of SRC onto DEST.
-- Compare S1 and S2.
-- Compare N wide-characters of S1 and S2.
-- Compare S1 and S2, ignoring case.
-- Compare no more than N chars of S1 and S2, ignoring case.
-- Similar to the two functions above but take the information from
-- the provided locale and not the global locale.
-- Compare S1 and S2, both interpreted as appropriate to the
-- LC_COLLATE category of the current locale.
-- Transform S2 into array pointed to by S1 such that if wcscmp is
-- applied to two transformed strings the result is the as applying
-- `wcscoll' to the original strings.
-- Similar to the two functions above but take the information from
-- the provided locale and not the global locale.
-- Compare S1 and S2, both interpreted as appropriate to the
-- LC_COLLATE category of the given locale.
-- Transform S2 into array pointed to by S1 such that if wcscmp is
-- applied to two transformed strings the result is the as applying
-- `wcscoll' to the original strings.
-- Duplicate S, returning an identical malloc'd string.
-- Find the first occurrence of WC in WCS.
-- Find the last occurrence of WC in WCS.
-- This function is similar to `wcschr'. But it returns a pointer to
-- the closing NUL wide character in case C is not found in S.
-- Return the length of the initial segmet of WCS which
-- consists entirely of wide characters not in REJECT.
-- Return the length of the initial segmet of WCS which
-- consists entirely of wide characters in ACCEPT.
-- Find the first occurrence in WCS of any character in ACCEPT.
-- Find the first occurrence of NEEDLE in HAYSTACK.
-- Divide WCS into tokens separated by characters in DELIM.
-- Return the number of wide characters in S.
-- Another name for `wcsstr' from XPG4.
-- Return the number of wide characters in S, but at most MAXLEN.
-- Search N wide characters of S for C.
-- Compare N wide characters of S1 and S2.
-- Copy N wide characters of SRC to DEST.
-- Copy N wide characters of SRC to DEST, guaranteeing
-- correct behavior for overlapping strings.
-- Set N wide characters of S to C.
-- Copy N wide characters of SRC to DEST and return pointer to following
-- wide character.
-- Determine whether C constitutes a valid (one-byte) multibyte
-- character.
-- Determine whether C corresponds to a member of the extended
-- character set whose multibyte representation is a single byte.
-- Determine whether PS points to an object representing the initial
-- state.
-- Write wide character representation of multibyte character pointed
-- to by S to PWC.
-- Write multibyte representation of wide character WC to S.
-- Return number of bytes in multibyte character pointed to by S.
-- Define inline function as optimization.
-- We can use the BTOWC and WCTOB optimizations since we know that all
-- locales must use ASCII encoding for the values in the ASCII range
-- and because the wchar_t encoding is always ISO 10646.
-- Write wide character representation of multibyte character string
-- SRC to DST.
-- Write multibyte character representation of wide character string
-- SRC to DST.
-- Write wide character representation of at most NMC bytes of the
-- multibyte character string SRC to DST.
-- Write multibyte character representation of at most NWC characters
-- from the wide character string SRC to DST.
-- The following functions are extensions found in X/Open CAE.
-- Determine number of column positions required for C.
-- Determine number of column positions required for first N wide
-- characters (or fewer if S ends before this) in S.
-- Convert initial portion of the wide string NPTR to `double'
-- representation.
-- Likewise for `float' and `long double' sizes of floating-point numbers.
-- Convert initial portion of wide string NPTR to `long int'
-- representation.
-- Convert initial portion of wide string NPTR to `unsigned long int'
-- representation.
-- Convert initial portion of wide string NPTR to `long long int'
-- representation.
-- Convert initial portion of wide string NPTR to `unsigned long long int'
-- representation.
-- Convert initial portion of wide string NPTR to `long long int'
-- representation.
-- Convert initial portion of wide string NPTR to `unsigned long long int'
-- representation.
-- The concept of one static locale per category is not very well
-- thought out. Many applications will need to process its data using
-- information from several different locales. Another application is
-- the implementation of the internationalization handling in the
-- upcoming ISO C++ standard library. To support this another set of
-- the functions using locale data exist which have an additional
-- argument.
-- Attention: all these functions are *not* standardized in any form.
-- This is a proof-of-concept implementation.
-- Structure for reentrant locale using functions. This is an
-- (almost) opaque type for the user level programs.
-- Special versions of the functions above which take the locale to
-- use as an additional parameter.
-- Copy SRC to DEST, returning the address of the terminating L'\0' in
-- DEST.
-- Copy no more than N characters of SRC to DEST, returning the address of
-- the last character written into DEST.
-- Wide character I/O functions.
-- Like OPEN_MEMSTREAM, but the stream is wide oriented and produces
-- a wide character string.
-- Select orientation for stream.
-- Write formatted output to STREAM.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
-- __attribute__ ((__format__ (__wprintf__, 2, 3)))
-- Write formatted output to stdout.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
-- __attribute__ ((__format__ (__wprintf__, 1, 2)))
-- Write formatted output of at most N characters to S.
-- __attribute__ ((__format__ (__wprintf__, 3, 4)))
-- Write formatted output to S from argument list ARG.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
-- __attribute__ ((__format__ (__wprintf__, 2, 0)))
-- Write formatted output to stdout from argument list ARG.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
-- __attribute__ ((__format__ (__wprintf__, 1, 0)))
-- Write formatted output of at most N character to S from argument
-- list ARG.
-- __attribute__ ((__format__ (__wprintf__, 3, 0)))
-- Read formatted input from STREAM.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
-- __attribute__ ((__format__ (__wscanf__, 2, 3)))
-- Read formatted input from stdin.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
-- __attribute__ ((__format__ (__wscanf__, 1, 2)))
-- Read formatted input from S.
-- __attribute__ ((__format__ (__wscanf__, 2, 3)))
-- For strict ISO C99 or POSIX compliance disallow %as, %aS and %a[
-- GNU extension which conflicts with valid %a followed by letter
-- s, S or [.
-- __attribute__ ((__format__ (__wscanf__, 2, 3)))
-- __attribute__ ((__format__ (__wscanf__, 1, 2)))
-- __attribute__ ((__format__ (__wscanf__, 2, 3)))
-- Read formatted input from S into argument list ARG.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
-- __attribute__ ((__format__ (__wscanf__, 2, 0)))
-- Read formatted input from stdin into argument list ARG.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
-- __attribute__ ((__format__ (__wscanf__, 1, 0)))
-- Read formatted input from S into argument list ARG.
-- __attribute__ ((__format__ (__wscanf__, 2, 0)))
-- __attribute__ ((__format__ (__wscanf__, 2, 0)))
-- __attribute__ ((__format__ (__wscanf__, 1, 0)))
-- __attribute__ ((__format__ (__wscanf__, 2, 0)))
-- Read a character from STREAM.
-- These functions are possible cancellation points and therefore not
-- marked with __THROW.
-- Read a character from stdin.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
-- Write a character to STREAM.
-- These functions are possible cancellation points and therefore not
-- marked with __THROW.
-- Write a character to stdout.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
-- Get a newline-terminated wide character string of finite length
-- from STREAM.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
-- Write a string to STREAM.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
-- Push a character back onto the input buffer of STREAM.
-- This function is a possible cancellation point and therefore not
-- marked with __THROW.
-- These are defined to be equivalent to the `char' functions defined
-- in POSIX.1:1996.
-- These functions are not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation they are cancellation points and
-- therefore not marked with __THROW.
-- This is the wide character version of a GNU extension.
-- This function is not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation it is a cancellation point and
-- therefore not marked with __THROW.
-- Faster version when locking is not necessary.
-- This function is not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation it is a cancellation point and
-- therefore not marked with __THROW.
-- These are defined to be equivalent to the `char' functions defined
-- in POSIX.1:1996.
-- These functions are not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation they are cancellation points and
-- therefore not marked with __THROW.
-- This function does the same as `fgetws' but does not lock the stream.
-- This function is not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation it is a cancellation point and
-- therefore not marked with __THROW.
-- This function does the same as `fputws' but does not lock the stream.
-- This function is not part of POSIX and therefore no official
-- cancellation point. But due to similarity with an POSIX interface
-- or due to the implementation it is a cancellation point and
-- therefore not marked with __THROW.
-- Format TP into S according to FORMAT.
-- Write no more than MAXSIZE wide characters and return the number
-- of wide characters written, or 0 if it would exceed MAXSIZE.
-- Similar to `wcsftime' but takes the information from
-- the provided locale and not the global locale.
-- The X/Open standard demands that most of the functions defined in
-- the <wctype.h> header must also appear here. This is probably
-- because some X/Open members wrote their implementation before the
-- ISO C standard was published and introduced the better solution.
-- We have to provide these definitions for compliance reasons but we
-- do this nonsense only if really necessary.
-- Define some macros helping to catch buffer overflows.
-- Undefine all __need_* constants in case we are included to get those
-- constants but the whole file was already read.
end CUPS.wchar_h;
|
pragma Ada_2012;
package Base64 with
Pure,
Preelaborate
is
end Base64;
|
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
separate (Program.Scanners)
procedure On_Accept
(Self : not null access Program.Scanned_Rule_Handlers.Handler'Class;
Scanner : not null access Program.Scanners.Scanner'Class;
Rule : Program.Scanner_States.Rule_Index;
Token : out Program.Scanner_Destinations.Token_Kind;
Skip : in out Boolean) is
begin
case Rule is
when 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10
| 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20
| 21 | 22 | 23 | 24 | 25 | 26 | 27 =>
Self.Delimiter (Scanner, Rule, Token, Skip);
when 28 =>
Self.Identifier (Scanner, Rule, Token, Skip);
when 29 =>
Self.Numeric_Literal (Scanner, Rule, Token, Skip);
when 30 =>
Self.Obsolescent_Numeric_Literal (Scanner, Rule, Token, Skip);
when 31 =>
Self.Character_Literal (Scanner, Rule, Token, Skip);
when 32 =>
Self.String_Literal (Scanner, Rule, Token, Skip);
when 33 =>
Self.Obsolescent_String_Literal (Scanner, Rule, Token, Skip);
when 34 =>
Self.Comment (Scanner, Rule, Token, Skip);
when 35 =>
Self.Space (Scanner, Rule, Token, Skip);
when 36 =>
Self.New_Line (Scanner, Rule, Token, Skip);
when 37 | 38 =>
Self.Error (Scanner, Rule, Token, Skip);
when others =>
raise Constraint_Error;
end case;
end On_Accept;
|
with STM32GD.GPIO.Pin;
generic
with package Input is new STM32GD.GPIO.Pin (<>);
with package Output is new STM32GD.GPIO.Pin (<>);
package Peripherals is
procedure Init;
procedure Run;
end Peripherals;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T A S K I N G --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2013, 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. GNARL is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- 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 Ravenscar/HI-E version of this package
-- Note: the compiler generates direct calls to this interface, via Rtsfind.
-- Any changes to this interface may require corresponding compiler changes.
pragma Restrictions (No_Elaboration_Code);
with Ada.Unchecked_Conversion;
with System.Storage_Elements;
with System.Parameters;
with System.Task_Info;
with System.Task_Primitives;
with System.Multiprocessors;
package System.Tasking is
pragma Preelaborate;
---------------------------------
-- Task_Id related definitions --
---------------------------------
type Ada_Task_Control_Block;
type Task_Id is access all Ada_Task_Control_Block;
function To_Task_Id is
new Ada.Unchecked_Conversion
(System.Task_Primitives.Task_Address, Task_Id);
function To_Address is
new Ada.Unchecked_Conversion
(Task_Id, System.Task_Primitives.Task_Address);
Null_Task : constant Task_Id := null;
type Task_List is array (Positive range <>) of Task_Id;
pragma Suppress_Initialization (Task_List);
function Self return Task_Id;
-- This is the compiler interface version of this function. Do not call
-- from the run-time system.
-----------------------
-- Enumeration types --
-----------------------
type Task_States is
(Unactivated,
-- Task was created but has not been activated. It cannot be executing
-- For all states from here down, the task has been activated. In
-- addition, for all states from here down, except for Terminated,
-- the task may be executing.
Runnable,
-- Task is not blocked for any reason known to Ada. (It may be waiting
-- for a mutex, though.) It is conceptually "executing" in normal mode.
Terminated,
-- The task is terminated, in the sense of ARM 9.3 (5)
Activator_Sleep,
-- Task is waiting for created tasks to complete activation
Acceptor_Sleep,
-- Task is waiting on an accept or selective wait statement
Entry_Caller_Sleep,
-- Task is waiting on an entry call
Async_Select_Sleep,
-- Task is waiting to start the abortable part of an asynchronous select
-- statement.
Delay_Sleep,
-- Task is waiting on a delay statement
Master_Completion_Sleep,
-- Master completion has two phases. In Phase 1 the task is sleeping
-- in Complete_Master having completed a master within itself, and is
-- waiting for the tasks dependent on that master to become terminated
-- or waiting on a terminate Phase.
Master_Phase_2_Sleep,
-- In Phase 2 the task is sleeping in Complete_Master waiting for tasks
-- on terminate alternatives to finish terminating.
Interrupt_Server_Idle_Sleep,
Interrupt_Server_Blocked_Interrupt_Sleep,
Timer_Server_Sleep,
AST_Server_Sleep,
-- Special uses of sleep, for server tasks within the run-time system
Asynchronous_Hold,
-- The task has been held by Asynchronous_Task_Control.Hold_Task
Interrupt_Server_Blocked_On_Event_Flag
-- The task has been blocked on a system call waiting for the
-- completion event.
);
-- The following status indicators are never used in a Ravenscar run time.
-- They Are defined for debugging purposes: The same code in GDB to get
-- the Current status of a task in a full run-time environment and in a
-- Ravenscar environment.
pragma Unreferenced (Activator_Sleep);
pragma Unreferenced (Acceptor_Sleep);
pragma Unreferenced (Async_Select_Sleep);
pragma Unreferenced (Master_Completion_Sleep);
pragma Unreferenced (Master_Phase_2_Sleep);
pragma Unreferenced (Interrupt_Server_Idle_Sleep);
pragma Unreferenced (Interrupt_Server_Blocked_Interrupt_Sleep);
pragma Unreferenced (Timer_Server_Sleep);
pragma Unreferenced (AST_Server_Sleep);
pragma Unreferenced (Asynchronous_Hold);
pragma Unreferenced (Interrupt_Server_Blocked_On_Event_Flag);
-------------------------------
-- Entry related definitions --
-------------------------------
-- These need comments ???
Null_Entry : constant := 0;
Max_Entry : constant := Integer'Last;
Interrupt_Entry : constant := -2;
Cancelled_Entry : constant := -1;
type Entry_Index is range Interrupt_Entry .. Max_Entry;
Null_Task_Entry : constant := Null_Entry;
Max_Task_Entry : constant := Max_Entry;
type Task_Entry_Index is new Entry_Index
range Null_Task_Entry .. Max_Task_Entry;
type Entry_Call_Record;
type Entry_Call_Link is access all Entry_Call_Record;
----------------------------------
-- Entry_Call_Record definition --
----------------------------------
type Entry_Call_Record is record
Self : Task_Id;
-- ID of the caller
Uninterpreted_Data : System.Address;
-- Data passed by the compiler
Next : Entry_Call_Link;
-- Entry_Call List
end record;
pragma Suppress_Initialization (Entry_Call_Record);
-------------------------------------------
-- Task termination procedure definition --
-------------------------------------------
-- We need to redefine this type (already defined in Ada.Task_Termination)
-- here to avoid circular dependencies.
type Termination_Handler is access protected procedure (T : Task_Id);
-- Represent a protected procedure to be executed when a task terminates
Fall_Back_Handler : Termination_Handler;
-- This is the fall-back handler that applies to all the tasks in the
-- partition (this is only for Ravenscar-compliant systems).
------------------------------------
-- Other Task-Related Definitions --
------------------------------------
type Activation_Chain is limited private;
type Activation_Chain_Access is access all Activation_Chain;
type Task_Procedure_Access is access procedure (Arg : System.Address);
type Access_Boolean is access all Boolean;
----------------------------------------------
-- Ada_Task_Control_Block (ATCB) definition --
----------------------------------------------
-- Notes on protection (synchronization) of TRTS data structures
-- Any field of the TCB can be written by the activator of a task when the
-- task is created, since no other task can access the new task's state
-- until creation is complete.
-- The protection for each field is described in a comment starting with
-- "Protection:".
-- When a lock is used to protect an ATCB field, this lock is simply named
-- Some protection is described in terms of tasks related to the ATCB being
-- protected. These are:
-- Self: The task which is controlled by this ATCB.
-- Activator: The task that created Self and initiated its activation.
-- Created: A task created and activated by Self.
type Stack_Info is record
Start_Address : System.Address := System.Null_Address;
Size : System.Storage_Elements.Storage_Offset;
end record;
pragma Suppress_Initialization (Stack_Info);
type TSD is record
Pri_Stack_Info : aliased Stack_Info;
-- Stack address and size of the task
Sec_Stack_Addr : Address;
-- Address of currently allocated secondary stack
end record;
pragma Suppress_Initialization (TSD);
type Common_ATCB is record
State : Task_States;
pragma Atomic (State);
-- Encodes some basic information about the state of a task, including
-- whether it has been activated, whether it is sleeping, and whether
-- it is terminated.
--
-- Protection: Only accessed by Self
Base_CPU : System.Multiprocessors.CPU_Range;
-- Protection: Only written during initialization, accessed by anyone
Base_Priority : System.Any_Priority;
-- Base priority
--
-- Protection: Only written by Self, accessed by anyone
Protected_Action_Nesting : Natural;
pragma Atomic (Protected_Action_Nesting);
-- The dynamic level of protected action nesting for this task. This
-- field is needed for checking whether potentially blocking operations
-- are invoked from protected actions. pragma Atomic is used because it
-- can be read/written from protected interrupt handlers.
LL : aliased Task_Primitives.Private_Data;
-- Control block used by underlying low-level tasking service (GNULLI)
--
-- Protection: This is used only by the GNULLI implementation, which
-- takes care of all of its synchronization.
Task_Arg : System.Address;
-- The argument to task procedure. Currently unused, this will provide
-- a handle for discriminant information.
--
-- Protection: Part of the synchronization between Self and Activator.
-- Activator writes it, once, before Self starts executing. Thereafter,
-- Self only reads it.
Task_Entry_Point : Task_Procedure_Access;
-- Information needed to call the procedure containing the code for
-- the body of this task.
--
-- Protection: Part of the synchronization between Self and Activator.
-- Activator writes it, once, before Self starts executing. Self reads
-- it, once, as part of its execution.
Compiler_Data : TSD;
-- Task-specific data needed by compiler to store per-task stuctures
--
-- Protection: Only accessed by Self
Activation_Link : Task_Id;
-- Used to link this task to a list of tasks to be activated
--
-- Protection: Only used by Activator. Once the task is activated, this
-- can also be reused by System.Tasking.Debug for the list of known
-- tasks.
Task_Info : System.Task_Info.Task_Info_Type;
-- System-specific attributes of the task as specified by the
-- Task_Info pragma.
end record;
pragma Suppress_Initialization (Common_ATCB);
type Ada_Task_Control_Block (Entry_Num : Task_Entry_Index) is record
-- The discriminant Entry_Num is not needed, but we keep it here for
-- compatibility reasons with the rest of the run times, so that the
-- expander does not need to know which run time is being used.
Common : Common_ATCB;
Entry_Call : aliased Entry_Call_Record;
-- Protection: This field is used on entry call queues associated with
-- protected objects, and is protected by the protected object lock.
end record;
pragma Suppress_Initialization (Ada_Task_Control_Block);
-- Why this pragma? comment needed???
--------------------------------
-- Master Related Definitions --
--------------------------------
subtype Master_Level is Integer;
subtype Master_ID is Master_Level;
Library_Task_Level : constant Master_Level := 3;
----------------------------------
-- Secondary Stack Manipulation --
----------------------------------
function Get_Sec_Stack return Address;
pragma Export (C, Get_Sec_Stack, "__gnat_get_secondary_stack");
-- Return the address of the task specific secondary stack, as expected by
-- System.Secondary_Stack.
procedure Set_Sec_Stack (Stk : Address);
-- Set the task specific secondary stack, as expected by
-- System.Secondary_Stack.
----------------------------------------
-- Task size, priority, affinity info --
----------------------------------------
function Storage_Size (T : Task_Id) return System.Parameters.Size_Type;
-- Retrieve from the TCB of the task the allocated size of its stack,
-- either the system default or the size specified by a pragma. This
-- is in general a non-static value that can depend on discriminants
-- of the task.
Unspecified_Priority : constant Integer := System.Priority'First - 1;
Unspecified_CPU : constant := -1;
-- No affinity specified
--------------------
-- Initialization --
--------------------
procedure Initialize;
-- This procedure constitutes the first part of the initialization of the
-- GNARL. This includes creating data structures to make the initial thread
-- into the environment task. The last part of the initialization is done
-- in System.Tasking.Initialization or System.Tasking.Restricted.Stages.
-- All the initializations used to be in Tasking.Initialization, but this
-- is no longer possible with the run time simplification (including
-- optimized PO and the restricted run time) since one cannot rely on
-- System.Tasking.Initialization being present, as was done before.
procedure Initialize_ATCB
(Task_Entry_Point : Task_Procedure_Access;
Task_Arg : System.Address;
Base_Priority : System.Any_Priority;
Base_CPU : System.Multiprocessors.CPU_Range;
Task_Info : System.Task_Info.Task_Info_Type;
Stack_Address : System.Address;
Stack_Size : System.Parameters.Size_Type;
T : Task_Id;
Success : out Boolean);
-- Initialize fields of a TCB and link into global TCB structures
-- Call this only with abort deferred and holding All_Tasks_L.
----------------------
-- Initialize_Slave --
----------------------
procedure Initialize_Slave (CPU_Id : System.Multiprocessors.CPU);
pragma Export (Asm, Initialize_Slave, "__gnat_initialize_slave");
-- Initialize a fake environment task for the current CPU. This fake task
-- is used to give a context during interrupt handling if the CPU doesn't
-- have regular task.
private
type Activation_Chain is limited record
T_ID : Task_Id;
end record;
end System.Tasking;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2017, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of STMicroelectronics nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
-- --
-- This file is based on: --
-- --
-- @file stm32f4xx_hal_adc.h --
-- @author MCD Application Team --
-- @version V1.3.1 --
-- @date 25-March-2015 --
-- @brief Header file of ADC HAL module. --
-- --
-- COPYRIGHT(c) 2014 STMicroelectronics --
------------------------------------------------------------------------------
-- This file provides interfaces for the analog-to-digital converters on the
-- STM32G4 (ARM Cortex M4F) microcontrollers from ST Microelectronics.
-- Channels are mapped to GPIO_Point values as follows. See the STM32G474xx
-- datasheet DS1228 rev 5 pg 57 chapter 4.10 Table 12. "STM32G474xB(C,E) pin
-- definitions" in the column "Aditional functions".
--
-- Channel ADC ADC ADC ADC ADC
-- # 1 2 3 4 5
--
-- 0
-- 1 PA0 PA0 PB1 PE14 PA8
-- 2 PA1 PA1 PE9 PE15 PA9
-- 3 PA2 PA6 PE13 PB12
-- 4 PA3 PA7 PE7 PB14
-- 5 PB14 PC4 PB13 PB15
-- 6 PC0 PC0 PE8 PE8 PE8
-- 7 PC1 PC1 PD10 PD10 PD10
-- 8 PC2 PC2 PD11 PD11 PD11
-- 9 PC3 PC3 PD12 PD12 PD12
-- 10 PF0 PF1 PD13 PD13 PD13
-- 11 PB12 PC5 PD14 PD14 PD14
-- 12 PB2 PB0 PD8 PD8
-- 13 PA5 PD9 PD9
-- 14 PB11 PB11 PE10 PE10 PE10
-- 15 PB15 PE11 PE11 PE11
-- 16 PE12 PE12 PE12
-- 17 PA4
with System; use System;
with Ada.Real_Time; use Ada.Real_Time;
private with STM32_SVD.ADC;
package STM32.ADC is
pragma Elaborate_Body;
type Analog_To_Digital_Converter is limited private;
subtype Analog_Input_Channel is UInt5 range 0 .. 18;
type ADC_Point is record
ADC : access Analog_To_Digital_Converter;
Channel : Analog_Input_Channel;
end record;
VRef_Channel : constant Analog_Input_Channel := 18;
-- See RM0440 rev 6 pg 621 chapter 21.4.11.
-- Note available with ADC_1 and ADC_2.
VBat_Channel : constant Analog_Input_Channel := 17;
-- See RM0440 rev 6 pg 621 chapter 21.4.11.
-- Note only available with ADC_1.
subtype TemperatureSensor_Channel is Analog_Input_Channel;
-- TODO: ??? The below predicate does not compile with GNAT GPL 2015.
-- with Static_Predicate => TemperatureSensor_Channel in 16 | VBat_Channel;
-- See RM pg 389 section 13.3.3. On some MCUs the temperature channel is
-- the same as the VBat channel, on others it is channel 16. Note only
-- available with ADC_1.
ADC_Supply_Voltage : constant := 3000; -- millivolts
-- This is the ideal value, likely not the actual.
procedure Enable (This : in out Analog_To_Digital_Converter) with
Pre => not Enabled (This) and
not Conversion_Started (This) and
not Injected_Conversion_Started (This),
Post => Enabled (This);
procedure Disable (This : in out Analog_To_Digital_Converter) with
Pre => Enabled (This) and
not Conversion_Started (This) and
not Injected_Conversion_Started (This),
Post => not Enabled (This);
function Enabled (This : Analog_To_Digital_Converter) return Boolean;
function Disabled (This : Analog_To_Digital_Converter) return Boolean;
type ADC_Resolution is
(ADC_Resolution_12_Bits, -- 15 ADC Clock cycles
ADC_Resolution_10_Bits, -- 12 ADC Clock cycles
ADC_Resolution_8_Bits, -- 10 ADC Clock cycles
ADC_Resolution_6_Bits); -- 8 ADC Clock cycles
type Data_Alignment is (Right_Aligned, Left_Aligned);
procedure Configure_Unit
(This : in out Analog_To_Digital_Converter;
Resolution : ADC_Resolution;
Alignment : Data_Alignment)
with
Post => Current_Resolution (This) = Resolution and
Current_Alignment (This) = Alignment;
function Current_Resolution (This : Analog_To_Digital_Converter)
return ADC_Resolution;
function Current_Alignment (This : Analog_To_Digital_Converter)
return Data_Alignment;
type Channel_Sampling_Times is
(Sample_2P5_Cycles,
Sample_6P5_Cycles,
Sample_12P5_Cycles,
Sample_24P5_Cycles,
Sample_47P5_Cycles,
Sample_92P5_Cycles,
Sample_247P5_Cycles,
Sample_640P5_Cycles)
with Size => 3;
-- The elapsed time between the start of a conversion and the end of
-- conversion is the sum of the configured sampling time plus the
-- successive approximation time (SAR = 12.5 for 12 bit) depending on data
-- resolution. See RM0440 rev 6 chapter 21.4.16 Timing.
type External_Trigger is
(Trigger_Disabled,
Trigger_Rising_Edge,
Trigger_Falling_Edge,
Trigger_Both_Edges);
type Regular_Channel_Rank is new Natural range 1 .. 16;
type Injected_Channel_Rank is new Natural range 1 .. 4;
type External_Events_Regular_Group is
(Option_1,
Option_2,
Timer1_CC3_Event,
Option_4,
Timer3_TRGO_Event,
Option_6,
Option_7,
Timer8_TRGO_Event,
Timer8_TRGO2_Event,
Timer1_TRGO_Event,
Timer1_TRGO2_Event,
Timer2_TRGO_Event,
Timer4_TRGO_Event,
Timer6_TRGO_Event,
Timer15_TRGO_Event,
Option_16,
Timer20_TRGO_Event,
Timer20_TRGO2_Event,
Timer20_CC1_Event,
Option_20,
Option_21,
HRTimer_ADC_TRG1_Event,
HRTimer_ADC_TRG3_Event,
HRTimer_ADC_TRG5_Event,
HRTimer_ADC_TRG6_Event,
HRTimer_ADC_TRG7_Event,
HRTimer_ADC_TRG8_Event,
HRTimer_ADC_TRG9_Event,
HRTimer_ADC_TRG10_Event,
LPTimer_OUT_Event,
Timer7_TRGO_Event)
with Size => 5;
-- External triggers for regular channels.
-- RM0440 Table 163 pg. 629 for ADC12 and Table 165 pg. 631 for ADC345.
-- Differences between ADC12 and ADC345:
-- Option ADC12 ADC345
-- 1 Timer1_CC1_Event Timer3_CC1_Event
-- 2 Timer1_CC2_Event Timer2_CC3_Event
-- 4 Timer2_CC2_Event Timer8_CC1
-- 6 Timer4_CC4_Event EXTI_Line2
-- 7 EXTI_Line11 Timer4_CC1
-- 16 Timer3_CC4_Event Timer2_CC1
-- 20 Timer20_CC2_Event HRTimer_ADC_TRG2_Event
-- 21 Timer20_CC3_Event HRTimer_ADC_TRG4_Event
for External_Events_Regular_Group use
(Option_1 => 2#00000#,
Option_2 => 2#00001#,
Timer1_CC3_Event => 2#00010#,
Option_4 => 2#00011#,
Timer3_TRGO_Event => 2#00100#,
Option_6 => 2#00101#,
Option_7 => 2#00110#,
Timer8_TRGO_Event => 2#00111#,
Timer8_TRGO2_Event => 2#01000#,
Timer1_TRGO_Event => 2#01001#,
Timer1_TRGO2_Event => 2#01010#,
Timer2_TRGO_Event => 2#01011#,
Timer4_TRGO_Event => 2#01100#,
Timer6_TRGO_Event => 2#01101#,
Timer15_TRGO_Event => 2#01110#,
Option_16 => 2#01111#,
Timer20_TRGO_Event => 2#10000#,
Timer20_TRGO2_Event => 2#10001#,
Timer20_CC1_Event => 2#10010#,
Option_20 => 2#10011#,
Option_21 => 2#10100#,
HRTimer_ADC_TRG1_Event => 2#10101#,
HRTimer_ADC_TRG3_Event => 2#10110#,
HRTimer_ADC_TRG5_Event => 2#10111#,
HRTimer_ADC_TRG6_Event => 2#11000#,
HRTimer_ADC_TRG7_Event => 2#11001#,
HRTimer_ADC_TRG8_Event => 2#11010#,
HRTimer_ADC_TRG9_Event => 2#11011#,
HRTimer_ADC_TRG10_Event => 2#11100#,
LPTimer_OUT_Event => 2#11101#,
Timer7_TRGO_Event => 2#11110#);
type Regular_Channel_Conversion_Trigger (Enabler : External_Trigger) is
record
case Enabler is
when Trigger_Disabled =>
null;
when others =>
Event : External_Events_Regular_Group;
end case;
end record;
Software_Triggered : constant Regular_Channel_Conversion_Trigger
:= (Enabler => Trigger_Disabled);
type Regular_Channel_Conversion is record
Channel : Analog_Input_Channel;
Sample_Time : Channel_Sampling_Times;
end record;
type Regular_Channel_Conversions is
array (Regular_Channel_Rank range <>) of Regular_Channel_Conversion;
procedure Configure_Regular_Conversions
(This : in out Analog_To_Digital_Converter;
Continuous : Boolean;
Trigger : Regular_Channel_Conversion_Trigger;
Conversions : Regular_Channel_Conversions)
with
Pre => Conversions'Length > 0,
Post =>
Length_Matches_Expected (This, Conversions) and
-- if there are multiple channels to be converted, we must want to
-- scan them so we set Scan_Mode accordingly
(if Conversions'Length > 1 then Scan_Mode_Enabled (This)) and
-- The VBat and VRef internal connections are enabled if This is
-- ADC_1 and the corresponding channels are included in the lists.
(VBat_May_Be_Enabled (This, Conversions) or else
VRef_TemperatureSensor_May_Be_Enabled (This, Conversions));
-- Configures all the regular channel conversions described in the array
-- Conversions. Note that the order of conversions in the array is the
-- order in which they are scanned, ie, their index is their "rank" in
-- the data structure. Note that if the VBat and Temperature channels are
-- the same channel, then only the VBat conversion takes place and only
-- that one will be enabled, so we must check the two in that order.
function Regular_Conversions_Expected (This : Analog_To_Digital_Converter)
return Natural;
-- Returns the total number of regular channel conversions specified in the
-- hardware.
function Scan_Mode_Enabled (This : Analog_To_Digital_Converter)
return Boolean;
-- Returns whether only one channel is converted, or if multiple channels
-- are converted (i.e., scanned). Note that this is independent of whether
-- the conversions are continuous.
type External_Events_Injected_Group is
(Timer1_TRGO_Event,
Timer1_CC4_Event,
Timer2_TRGO_Event,
Option_4,
Option_5,
Timer4_TRGO_Event,
Option_7,
Timer8_CC4_Event,
Timer1_TRGO2_Event,
Timer8_TRGO_Event,
Timer8_TRGO2_Event,
Option_12,
Timer3_TRGO_Event,
Option_14,
Timer6_TRGO_Event,
Timer15_TRGO_Event,
Timer20_TRGO_Event,
Timer20_TRGO2_Event,
Option_19,
HRTimer_ADC_TRG2_Event,
HRTimer_ADC_TRG4_Event,
HRTimer_ADC_TRG5_Event,
HRTimer_ADC_TRG6_Event,
HRTimer_ADC_TRG7_Event,
HRTimer_ADC_TRG8_Event,
HRTimer_ADC_TRG9_Event,
HRTimer_ADC_TRG10_Event,
Option_28,
Option_29,
LPTimer_OUT_Event,
Timer7_TRGO_Event)
with Size => 5;
-- External triggers for injected channels. RM0440 Table 164 pg. 630
-- and Table 166 pg. 632.
-- Differences between ADC12 and ADC345:
-- Option ADC12 ADC345
-- 4 Timer2_CC1_Event Timer8_CC2
-- 5 Timer3_CC4_Event Timer4_CC3
-- 7 EXTI_Line15 Timer4_CC4
-- 12 Timer3_CC3_Event Timer1_CC3
-- 14 Timer3_CC1_Event EXTI_Line3
-- 19 Timer20_CC4_Event Timer20_CC2
-- 28 Timer16_CC1_Event HRTimer_ADC_TRG1
-- 29 HRTimer_ADC_TRG3
for External_Events_Injected_Group use
(Timer1_TRGO_Event => 2#00000#,
Timer1_CC4_Event => 2#00001#,
Timer2_TRGO_Event => 2#00010#,
Option_4 => 2#00011#,
Option_5 => 2#00100#,
Timer4_TRGO_Event => 2#00101#,
Option_7 => 2#00110#,
Timer8_CC4_Event => 2#00111#,
Timer1_TRGO2_Event => 2#01000#,
Timer8_TRGO_Event => 2#01001#,
Timer8_TRGO2_Event => 2#01010#,
Option_12 => 2#01011#,
Timer3_TRGO_Event => 2#01100#,
Option_14 => 2#01101#,
Timer6_TRGO_Event => 2#01110#,
Timer15_TRGO_Event => 2#01111#,
Timer20_TRGO_Event => 2#10000#,
Timer20_TRGO2_Event => 2#10001#,
Option_19 => 2#10010#,
HRTimer_ADC_TRG2_Event => 2#10011#,
HRTimer_ADC_TRG4_Event => 2#10100#,
HRTimer_ADC_TRG5_Event => 2#10101#,
HRTimer_ADC_TRG6_Event => 2#10110#,
HRTimer_ADC_TRG7_Event => 2#10111#,
HRTimer_ADC_TRG8_Event => 2#11000#,
HRTimer_ADC_TRG9_Event => 2#11001#,
HRTimer_ADC_TRG10_Event => 2#11010#,
Option_28 => 2#11011#,
Option_29 => 2#11100#,
LPTimer_OUT_Event => 2#11101#,
Timer7_TRGO_Event => 2#11110#);
type Injected_Channel_Conversion_Trigger (Enabler : External_Trigger) is
record
case Enabler is
when Trigger_Disabled =>
null;
when others =>
Event : External_Events_Injected_Group;
end case;
end record;
Software_Triggered_Injected : constant Injected_Channel_Conversion_Trigger
:= (Enabler => Trigger_Disabled);
subtype Injected_Data_Offset is UInt12;
type Injected_Channel_Conversion is record
Channel : Analog_Input_Channel;
Sample_Time : Channel_Sampling_Times;
Offset : Injected_Data_Offset := 0;
end record;
type Injected_Channel_Conversions is
array (Injected_Channel_Rank range <>) of Injected_Channel_Conversion;
procedure Configure_Injected_Conversions
(This : in out Analog_To_Digital_Converter;
AutoInjection : Boolean;
Trigger : Injected_Channel_Conversion_Trigger;
Conversions : Injected_Channel_Conversions)
with
Pre =>
Conversions'Length > 0 and
(if AutoInjection then Trigger = Software_Triggered_Injected) and
(if AutoInjection then
not Discontinuous_Mode_Injected_Enabled (This)),
Post =>
Length_Is_Expected (This, Conversions) and
-- The VBat and VRef internal connections are enabled if This is
-- ADC_1 and the corresponding channels are included in the lists.
(VBat_May_Be_Enabled (This, Conversions) or else
VRef_TemperatureSensor_May_Be_Enabled (This, Conversions));
-- Configures all the injected channel conversions described in the array
-- Conversions. Note that the order of conversions in the array is the
-- order in which they are scanned, ie, their index is their "rank" in
-- the data structure. Note that if the VBat and Temperature channels are
-- the same channel, then only the VBat conversion takes place and only
-- that one will be enabled, so we must check the two in that order.
function Injected_Conversions_Expected (This : Analog_To_Digital_Converter)
return Natural;
-- Returns the total number of injected channel conversions to be done.
function VBat_Enabled (This : Analog_To_Digital_Converter) return Boolean;
-- Returns whether the hardware has the VBat internal connection enabled.
function VRef_TemperatureSensor_Enabled
(This : Analog_To_Digital_Converter) return Boolean;
-- Returns whether the hardware has the VRef or temperature sensor internal
-- connection enabled.
procedure Start_Conversion (This : in out Analog_To_Digital_Converter) with
Pre => Enabled (This) and Regular_Conversions_Expected (This) > 0;
-- Starts the conversion(s) for the regular channels.
procedure Stop_Conversion (This : in out Analog_To_Digital_Converter) with
Pre => Conversion_Started (This) and not Disabled (This);
-- Stops the conversion(s) for the regular channels.
function Conversion_Started (This : Analog_To_Digital_Converter)
return Boolean;
-- Returns whether the regular channels' conversions have started. Note
-- that the ADC hardware clears the corresponding bit immediately, as
-- part of starting.
function Conversion_Value (This : Analog_To_Digital_Converter)
return UInt16 with Inline;
-- Returns the latest regular conversion result for the specified ADC unit.
function Data_Register_Address (This : Analog_To_Digital_Converter)
return System.Address
with Inline;
-- Returns the address of the ADC Data Register. This is exported
-- STRICTLY for the sake of clients using DMA. All other
-- clients of this package should use the Conversion_Value functions!
-- Seriously, don't use this function otherwise.
procedure Start_Injected_Conversion
(This : in out Analog_To_Digital_Converter)
with Pre => Enabled (This) and Injected_Conversions_Expected (This) > 0;
-- Note that the ADC hardware clears the corresponding bit immediately, as
-- part of starting.
function Injected_Conversion_Started (This : Analog_To_Digital_Converter)
return Boolean;
-- Returns whether the injected channels' conversions have started.
function Injected_Conversion_Value
(This : Analog_To_Digital_Converter;
Rank : Injected_Channel_Rank)
return UInt16
with Inline;
-- Returns the latest conversion result for the analog input channel at
-- the injected sequence position given by Rank on the specified ADC unit.
--
-- Note that the offset corresponding to the specified Rank is subtracted
-- automatically, so check the sign bit for a negative result.
type CDR_Data is (Master, Slave);
function Multimode_Conversion_Value
(This : Analog_To_Digital_Converter;
Value : CDR_Data) return UInt16;
function Multimode_Conversion_Value
(This : Analog_To_Digital_Converter) return UInt32
with inline;
-- Returns the latest ADC_1, ADC_2 or ADC_3, ADC_4, ADC_5 regular channel
-- conversions' results based on the selected multi ADC mode.
-- Discontinuous Management --------------------------------------------------------
type Discontinuous_Mode_Channel_Count is range 1 .. 8;
-- Note this uses a biased representation implicitly because the underlying
-- representational bit values are 0 ... 7.
procedure Enable_Discontinuous_Mode
(This : in out Analog_To_Digital_Converter;
Regular : Boolean; -- if False, applies to Injected channels
Count : Discontinuous_Mode_Channel_Count)
with
Pre => not AutoInjection_Enabled (This),
Post =>
(if Regular then
(Discontinuous_Mode_Regular_Enabled (This)) and
(not Discontinuous_Mode_Injected_Enabled (This))
else
(not Discontinuous_Mode_Regular_Enabled (This)) and
(Discontinuous_Mode_Injected_Enabled (This)));
-- Enables discontinuous mode and sets the count. If Regular is True,
-- enables the mode only for regular channels. If Regular is False, enables
-- the mode only for Injected channels. The note in RM 13.3.10, pg 393,
-- says we cannot enable the mode for both regular and injected channels
-- at the same time, so this flag ensures we follow that rule.
procedure Disable_Discontinuous_Mode_Regular
(This : in out Analog_To_Digital_Converter)
with Post => not Discontinuous_Mode_Regular_Enabled (This);
procedure Disable_Discontinuous_Mode_Injected
(This : in out Analog_To_Digital_Converter)
with Post => not Discontinuous_Mode_Injected_Enabled (This);
function Discontinuous_Mode_Regular_Enabled
(This : Analog_To_Digital_Converter)
return Boolean;
function Discontinuous_Mode_Injected_Enabled
(This : Analog_To_Digital_Converter)
return Boolean;
function AutoInjection_Enabled
(This : Analog_To_Digital_Converter)
return Boolean;
-- DMA Management --------------------------------------------------------
procedure Enable_DMA (This : in out Analog_To_Digital_Converter) with
Pre => not Conversion_Started (This) and
not Injected_Conversion_Started (This),
Post => DMA_Enabled (This);
procedure Disable_DMA (This : in out Analog_To_Digital_Converter) with
Pre => not Conversion_Started (This) and
not Injected_Conversion_Started (This),
Post => not DMA_Enabled (This);
function DMA_Enabled (This : Analog_To_Digital_Converter) return Boolean;
procedure Enable_DMA_After_Last_Transfer
(This : in out Analog_To_Digital_Converter) with
Pre => not Conversion_Started (This) and
not Injected_Conversion_Started (This),
Post => DMA_Enabled_After_Last_Transfer (This);
procedure Disable_DMA_After_Last_Transfer
(This : in out Analog_To_Digital_Converter) with
Pre => not Conversion_Started (This) and
not Injected_Conversion_Started (This),
Post => not DMA_Enabled_After_Last_Transfer (This);
function DMA_Enabled_After_Last_Transfer
(This : Analog_To_Digital_Converter)
return Boolean;
-- Analog Watchdog -------------------------------------------------------
subtype Watchdog_Threshold is UInt12;
type Analog_Watchdog_Modes is
(Watchdog_All_Regular_Channels,
Watchdog_All_Injected_Channels,
Watchdog_All_Both_Kinds,
Watchdog_Single_Regular_Channel,
Watchdog_Single_Injected_Channel,
Watchdog_Single_Both_Kinds);
subtype Multiple_Channels_Watchdog is Analog_Watchdog_Modes
range Watchdog_All_Regular_Channels .. Watchdog_All_Both_Kinds;
procedure Watchdog_Enable_Channels
(This : in out Analog_To_Digital_Converter;
Mode : Multiple_Channels_Watchdog;
Low : Watchdog_Threshold;
High : Watchdog_Threshold)
with
Pre => not Watchdog_Enabled (This),
Post => Watchdog_Enabled (This);
-- Enables the watchdog on all channels; channel kind depends on Mode.
-- A call to this routine is considered a complete configuration of the
-- watchdog so do not call the other enabler routine (for a single channel)
-- while this configuration is active. You must first disable the watchdog
-- if you want to enable the watchdog for a single channel.
-- see RM0440 rev 6 Chapter 21.4.28, pg 659, Table 169.
subtype Single_Channel_Watchdog is Analog_Watchdog_Modes
range Watchdog_Single_Regular_Channel .. Watchdog_Single_Both_Kinds;
procedure Watchdog_Enable_Channel
(This : in out Analog_To_Digital_Converter;
Mode : Single_Channel_Watchdog;
Channel : Analog_Input_Channel;
Low : Watchdog_Threshold;
High : Watchdog_Threshold)
with
Pre => not Watchdog_Enabled (This),
Post => Watchdog_Enabled (This);
-- Enables the watchdog on this single channel, and no others. The kind of
-- channel depends on Mode. A call to this routine is considered a complete
-- configuration of the watchdog so do not call the other enabler routine
-- (for all channels) while this configuration is active. You must
-- first disable the watchdog if you want to enable the watchdog for
-- all channels.
-- see RM0440 rev 6 Chapter 21.4.28, pg 659, Table 169.
procedure Watchdog_Disable (This : in out Analog_To_Digital_Converter)
with Post => not Watchdog_Enabled (This);
-- Whether watching a single channel or all of them, the watchdog is now
-- disabled.
function Watchdog_Enabled (This : Analog_To_Digital_Converter)
return Boolean;
type Analog_Watchdog_Filtering is
(No_Filtering,
Two_Detections,
Three_Detections,
Four_Detections,
Five_Detections,
Six_Detections,
Seven_Detections,
Eight_Detections);
-- Consecutive detection generates an AWDx flag or an interrupt.
procedure Watchdog_Enable_Filtering
(This : in out Analog_To_Digital_Converter;
Filter : Analog_Watchdog_Filtering);
type Analog_Window_Watchdog is (Watchdog_2, Watchdog_3);
type Analog_Input_Channels is
array (Analog_Input_Channel range <>) of Analog_Input_Channel;
procedure Watchdog_Enable_Channels
(This : in out Analog_To_Digital_Converter;
Watchdog : Analog_Window_Watchdog;
Channels : Analog_Input_Channels;
Low : Watchdog_Threshold;
High : Watchdog_Threshold)
with
Pre => not Conversion_Started (This),
Post => Watchdog_Enabled (This, Watchdog);
-- Enable the watchdog 2 or 3 for any selected channel. The channels
-- selected by AWDxCH must be also selected into the ADC regular or injected
-- sequence registers SQRi or JSQRi registers. The watchdog is disabled when
-- none channel is selected.
procedure Watchdog_Disable_Channels
(This : in out Analog_To_Digital_Converter;
Watchdog : Analog_Window_Watchdog;
Channels : Analog_Input_Channels)
with
Pre => not Conversion_Started (This);
procedure Watchdog_Disable
(This : in out Analog_To_Digital_Converter;
Watchdog : Analog_Window_Watchdog)
with Post => not Watchdog_Enabled (This, Watchdog);
-- The watchdog is disabled when none channel is selected.
function Watchdog_Enabled
(This : Analog_To_Digital_Converter;
Watchdog : Analog_Window_Watchdog) return Boolean;
-- The watchdog is enabled when any channel is selected.
-- Status Management -----------------------------------------------------
type ADC_Status_Flag is
(ADC_Ready,
Regular_Channel_Conversion_Completed,
Regular_Sequence_Conversion_Completed,
Injected_Channel_Conversion_Completed,
Injected_Sequence_Conversion_Completed,
Analog_Watchdog_1_Event_Occurred,
Analog_Watchdog_2_Event_Occurred,
Analog_Watchdog_3_Event_Occurred,
Sampling_Completed,
Overrun,
Injected_Context_Queue_Overflow);
function Status
(This : Analog_To_Digital_Converter;
Flag : ADC_Status_Flag)
return Boolean
with Inline;
-- Returns whether Flag is indicated, ie set in the Status Register.
procedure Clear_Status
(This : in out Analog_To_Digital_Converter;
Flag : ADC_Status_Flag)
with
Inline,
Post => not Status (This, Flag);
procedure Poll_For_Status
(This : in out Analog_To_Digital_Converter;
Flag : ADC_Status_Flag;
Success : out Boolean;
Timeout : Time_Span := Time_Span_Last);
-- Continuously polls for the specified status flag to be set, up to the
-- deadline computed by the value of Clock + Timeout. Sets the Success
-- argument accordingly. The default Time_Span_Last value is the largest
-- possible value, thereby setting a very long, but not infinite, timeout.
-- Interrupt Management --------------------------------------------------
type ADC_Interrupts is
(ADC_Ready,
Regular_Channel_Conversion_Complete,
Regular_Sequence_Conversion_Complete,
Injected_Channel_Conversion_Complete,
Injected_Sequence_Conversion_Complete,
Analog_Watchdog_1_Event_Occurr,
Analog_Watchdog_2_Event_Occurr,
Analog_Watchdog_3_Event_Occurr,
Sampling_Complete,
Overrun,
Injected_Context_Queue_Overflow);
procedure Enable_Interrupts
(This : in out Analog_To_Digital_Converter;
Source : ADC_Interrupts)
with
Inline,
Post => Interrupt_Enabled (This, Source);
procedure Disable_Interrupts
(This : in out Analog_To_Digital_Converter;
Source : ADC_Interrupts)
with
Inline,
Post => not Interrupt_Enabled (This, Source);
function Interrupt_Enabled
(This : Analog_To_Digital_Converter;
Source : ADC_Interrupts)
return Boolean
with Inline;
procedure Clear_Interrupt_Pending
(This : in out Analog_To_Digital_Converter;
Source : ADC_Interrupts)
with Inline;
-- Common Properties ------------------------------------------------------
type ADC_Prescaler is
(Div_1,
Div_2,
Div_4,
Div_6,
Div_8,
Div_10,
Div_12,
Div_16,
Div_32,
Div_64,
Div_128,
Div_256)
with Size => 4;
type ADC_Clock_Mode is
(CLK_ADC,
PCLK2_Div_1,
PCLK2_Div_2,
PCLK2_Div_4);
type Dual_ADC_DMA_Modes is
(Disabled,
DMA_Mode_1,
DMA_Mode_2);
for Dual_ADC_DMA_Modes use
(Disabled => 2#00#,
DMA_Mode_1 => 2#10#,
DMA_Mode_2 => 2#11#);
type Sampling_Delay_Selections is
(Sampling_Delay_5_Cycles,
Sampling_Delay_6_Cycles,
Sampling_Delay_7_Cycles,
Sampling_Delay_8_Cycles,
Sampling_Delay_9_Cycles,
Sampling_Delay_10_Cycles,
Sampling_Delay_11_Cycles,
Sampling_Delay_12_Cycles,
Sampling_Delay_13_Cycles,
Sampling_Delay_14_Cycles,
Sampling_Delay_15_Cycles,
Sampling_Delay_16_Cycles,
Sampling_Delay_17_Cycles,
Sampling_Delay_18_Cycles,
Sampling_Delay_19_Cycles,
Sampling_Delay_20_Cycles);
type Multi_ADC_Mode_Selections is
(Independent,
Dual_Combined_Regular_Injected_Simultaneous,
Dual_Combined_Regular_Simultaneous_Alternate_Trigger,
Dual_Combined_Interleaved_Injected_Simultaneous,
Dual_Injected_Simultaneous,
Dual_Regular_Simultaneous,
Dual_Interleaved,
Dual_Alternate_Trigger);
-- In dual mode, master (ADC1/ADC3) and slave (ADC2/ADC4) ADCs work
-- together and need only a start conversion on the master channel.
-- ADC5 is single converter.
for Multi_ADC_Mode_Selections use
(Independent => 2#00000#,
Dual_Combined_Regular_Injected_Simultaneous => 2#00001#,
Dual_Combined_Regular_Simultaneous_Alternate_Trigger => 2#00010#,
Dual_Combined_Interleaved_Injected_Simultaneous => 2#00011#,
Dual_Injected_Simultaneous => 2#00101#,
Dual_Regular_Simultaneous => 2#00110#,
Dual_Interleaved => 2#00111#,
Dual_Alternate_Trigger => 2#01001#);
procedure Configure_Common_Properties
(This : Analog_To_Digital_Converter;
Mode : Multi_ADC_Mode_Selections;
Prescaler : ADC_Prescaler;
Clock_Mode : ADC_Clock_Mode;
DMA_Mode : Dual_ADC_DMA_Modes;
Sampling_Delay : Sampling_Delay_Selections);
-- These properties are common to all the ADC units on the board.
-- These Multi_DMA_Mode commands needs to be separate from the
-- Configure_Common_Properties procedure for the sake of dealing
-- with overruns etc.
procedure Multi_Enable_DMA_After_Last_Transfer
(This : Analog_To_Digital_Converter)
with Pre => not Conversion_Started (This),
Post => Multi_DMA_Enabled_After_Last_Transfer (This);
-- Make shure to execute this procedure only when conversion is
-- not started.
procedure Multi_Disable_DMA_After_Last_Transfer
(This : Analog_To_Digital_Converter)
with Pre => not Conversion_Started (This),
Post => not Multi_DMA_Enabled_After_Last_Transfer (This);
-- Make shure to execute this procedure only when conversion is
-- not started.
function Multi_DMA_Enabled_After_Last_Transfer
(This : Analog_To_Digital_Converter) return Boolean;
-- Queries ----------------------------------------------------------------
function VBat_Conversion
(This : Analog_To_Digital_Converter;
Channel : Analog_Input_Channel)
return Boolean with Inline;
function VRef_TemperatureSensor_Conversion
(This : Analog_To_Digital_Converter;
Channel : Analog_Input_Channel)
return Boolean with Inline;
-- Returns whether the ADC unit and channel specified are that of a VRef
-- OR a temperature sensor conversion. Note that one control bit is used
-- to enable either one, ie it is shared.
function VBat_May_Be_Enabled
(This : Analog_To_Digital_Converter;
These : Regular_Channel_Conversions)
return Boolean
is
((for all Conversion of These =>
(if VBat_Conversion (This, Conversion.Channel)
then VBat_Enabled (This))));
function VBat_May_Be_Enabled
(This : Analog_To_Digital_Converter;
These : Injected_Channel_Conversions)
return Boolean
is
((for all Conversion of These =>
(if VBat_Conversion (This, Conversion.Channel)
then VBat_Enabled (This))));
function VRef_TemperatureSensor_May_Be_Enabled
(This : Analog_To_Digital_Converter;
These : Regular_Channel_Conversions)
return Boolean
is
(for all Conversion of These =>
(if VRef_TemperatureSensor_Conversion (This, Conversion.Channel)
then VRef_TemperatureSensor_Enabled (This)));
function VRef_TemperatureSensor_May_Be_Enabled
(This : Analog_To_Digital_Converter;
These : Injected_Channel_Conversions)
return Boolean
is
(for all Conversion of These =>
(if VRef_TemperatureSensor_Conversion (This, Conversion.Channel)
then VRef_TemperatureSensor_Enabled (This)));
-- The *_Conversions_Expected functions will always return at least the
-- value 1 because the hardware uses a biased representation (in which
-- zero indicates the value one, one indicates the value two, and so on).
-- Therefore, we don't invoke the functions unless we know they will be
-- greater than zero.
function Length_Matches_Expected
(This : Analog_To_Digital_Converter;
These : Regular_Channel_Conversions)
return Boolean
is
(if These'Length > 0 then
Regular_Conversions_Expected (This) = These'Length);
function Length_Is_Expected
(This : Analog_To_Digital_Converter;
These : Injected_Channel_Conversions)
return Boolean
is
(if These'Length > 0 then
Injected_Conversions_Expected (This) = These'Length);
private
ADC_Stabilization : constant Time_Span := Microseconds (3);
Temperature_Sensor_Stabilization : constant Time_Span := Microseconds (10);
-- The RM, section 13.3.6, says stabilization times are required. These
-- values are specified in the datasheets, eg section 5.3.20, pg 129,
-- and section 5.3.21, pg 134, of the STM32F405/7xx, DocID022152 Rev 4.
procedure Configure_Regular_Channel
(This : in out Analog_To_Digital_Converter;
Channel : Analog_Input_Channel;
Rank : Regular_Channel_Rank;
Sample_Time : Channel_Sampling_Times);
procedure Configure_Injected_Channel
(This : in out Analog_To_Digital_Converter;
Channel : Analog_Input_Channel;
Rank : Injected_Channel_Rank;
Sample_Time : Channel_Sampling_Times;
Offset : Injected_Data_Offset);
procedure Enable_VBat_Connection (This : Analog_To_Digital_Converter)
with Post => VBat_Enabled (This);
procedure Enable_VRef_TemperatureSensor_Connection
(This : Analog_To_Digital_Converter)
with Post => VRef_TemperatureSensor_Enabled (This);
-- One bit controls both the VRef and the temperature internal connections.
type Analog_To_Digital_Converter is new STM32_SVD.ADC.ADC1_Peripheral;
function VBat_Conversion
(This : Analog_To_Digital_Converter;
Channel : Analog_Input_Channel)
return Boolean
is (This'Address = STM32_SVD.ADC.ADC1_Periph'Address and
Channel = VBat_Channel);
function VRef_TemperatureSensor_Conversion
(This : Analog_To_Digital_Converter;
Channel : Analog_Input_Channel)
return Boolean
is (This'Address = STM32_SVD.ADC.ADC1_Periph'Address and
(Channel in VRef_Channel | TemperatureSensor_Channel));
end STM32.ADC;
|
pragma Warnings (Off);
pragma Ada_95;
pragma Restrictions (No_Exception_Propagation);
with System;
with System.Parameters;
with System.Secondary_Stack;
package ada_main is
GNAT_Version : constant String :=
"GNAT Version: Community 2018 (20180524-73)" & ASCII.NUL;
pragma Export (C, GNAT_Version, "__gnat_version");
Ada_Main_Program_Name : constant String := "_ada_main" & ASCII.NUL;
pragma Export (C, Ada_Main_Program_Name, "__gnat_ada_main_program_name");
procedure adainit;
pragma Export (C, adainit, "adainit");
procedure main;
pragma Export (C, main, "main");
-- BEGIN ELABORATION ORDER
-- ada%s
-- interfaces%s
-- system%s
-- ada.exceptions%s
-- ada.exceptions%b
-- interfaces.nrf51%s
-- system.img_int%s
-- system.img_int%b
-- system.img_lli%s
-- system.img_lli%b
-- system.parameters%s
-- system.storage_elements%s
-- system.storage_elements%b
-- system.secondary_stack%s
-- system.secondary_stack%b
-- ada.tags%s
-- ada.tags%b
-- system.unsigned_types%s
-- interfaces.nrf51.uart%s
-- system.text_io%s
-- system.text_io%b
-- ada.text_io%s
-- ada.text_io%b
-- system.assertions%s
-- system.assertions%b
-- hal%s
-- adl_config%s
-- command_line%s
-- command_line%b
-- filesystem%s
-- hal.block_drivers%s
-- hal.filesystem%s
-- filesystem.fat%s
-- filesystem.fat.files%s
-- filesystem.fat.directories%s
-- filesystem.fat.directories%b
-- filesystem.fat.files%b
-- filesystem.fat%b
-- file_io%s
-- filesystem.mbr%s
-- file_io%b
-- filesystem.mbr%b
-- command_line.filesystem%s
-- command_line.filesystem.touch%s
-- command_line.filesystem.touch%b
-- command_line.filesystem.remove_directory%s
-- command_line.filesystem.remove_directory%b
-- command_line.filesystem.list_directory%s
-- command_line.filesystem.list_directory%b
-- command_line.filesystem.cat%s
-- command_line.filesystem.cat%b
-- command_line.filesystem%b
-- main%b
-- END ELABORATION ORDER
end ada_main;
|
-- -*- Mode: Ada -*-
-- Filename : memory.adb
-- Description : Memory routines.
-- Author : Luke A. Guest
-- Created On : Thur Nov 17 15:07:32 2016
-- Licence : See LICENCE in the root directory.
with Interfaces;
-- with System.Address_To_Access_Conversions;
package body Memory is
type Byte_Array is array (Integer range <>) of aliased Interfaces.Integer_8;
-- package Convert is new System.Address_To_Access_Conversions
-- (Object => Byte_Array);
function Copy (Dest : System.Address;
Source : System.Address;
Size : Integer) return System.Address is
-- S : Convert.Object_Pointer := Convert.To_Pointer (Source);
-- D : Convert.Object_Pointer := Convert.To_Pointer (Dest);
S : Byte_Array (0 .. Size) with
Address => Source;
pragma Import (Convention => C, Entity => S);
D : Byte_Array (0 .. Size) with
Address => Dest;
pragma Import (Convention => C, Entity => D);
begin
for I in S'Range loop
D (I) := S (I);
end loop;
return Dest;
end Copy;
end Memory;
|
-- { dg-do compile }
-- { dg-options "-O -gnatws" }
package body Array15 is
type Arr is array (Natural range <>) of Integer;
Table : Arr (1 .. 4);
N : Natural := 1;
procedure Zero is
begin
N := 0;
end;
function F (I : Integer) return Integer is
A1 : Arr := (1 => I);
A2 : Arr := Table (1 .. N) & A1;
begin
return A2 (I);
end;
end Array15;
|
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Text_IO; use Ada.Text_IO;
procedure String_Multiplication is
begin
Put_Line (5 * "ha");
end String_Multiplication;
|
------------------------------------------------------------------------------
-- --
-- SPARK LIBRARY COMPONENTS --
-- --
-- S P A R K . T E S T _ A R R A Y _ L E M M A S --
-- --
-- C o d e --
-- --
-- Copyright (C) 2016, AdaCore --
-- --
-- SPARK 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. SPARK 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/>. --
-- --
------------------------------------------------------------------------------
with SPARK.Unconstrained_Array_Lemmas;
with SPARK.Constrained_Array_Lemmas;
package body SPARK.Test_Array_Lemmas
with SPARK_Mode => Off -- TEST_ON
is
pragma Warnings
(Off, "postcondition does not check the outcome of calling");
package Test_Uint is new SPARK.Unconstrained_Array_Lemmas
(Index_Type => Integer,
Element_T => Integer,
A => Arr_Int_Unconstrained,
Less => "<");
package Test_Ufloat is new SPARK.Unconstrained_Array_Lemmas
(Index_Type => Integer,
Element_T => Float,
A => Arr_Float_Unconstrained,
Less => "<");
-- For now, constrained array need a type conversion. In the future,
-- there will be a constrained array library.
procedure Test_Transitive_Order_Int (Arr : Arr_Int_Constrained) is
begin
Test_UInt.Lemma_Transitive_Order
(Arr_Int_Unconstrained (Arr));
end Test_Transitive_Order_Int;
procedure Test_Transitive_Order_Float (Arr : Arr_Float_Constrained) is
begin
Test_UFloat.Lemma_Transitive_Order
(Arr_Float_Unconstrained (Arr));
end Test_Transitive_Order_Float;
procedure Test_Transitive_Order_Int (Arr : Arr_Int_Unconstrained) is
begin
Test_Uint.Lemma_Transitive_Order (Arr);
end Test_Transitive_Order_Int;
procedure Test_Transitive_Order_Float
(Arr : Arr_Float_Unconstrained) is
begin
Test_Ufloat.Lemma_Transitive_Order (Arr);
end Test_Transitive_Order_Float;
end SPARK.Test_Array_Lemmas;
|
with Ada.Characters.Handling;
with GNATCOLL.VFS_Utils;
with Langkit_Support.Slocs;
with Langkit_Support.Text;
package body Extraction.Node_Edge_Types is
use type LALCO.Ada_Node_Kind_Type;
use type VFS.Filesystem_String;
use type VFS.Virtual_File;
Decl_Name_Prefix : constant String := "decl:";
Dir_Name_Prefix : constant String := "dir:";
File_Name_Prefix : constant String := "file:";
Proj_Name_Prefix : constant String := "proj:";
Filenames_Are_Case_Insensitive : constant Boolean :=
not GNATCOLL.VFS_Utils.Local_Host_Is_Case_Sensitive;
function Encode (Text : Langkit_Support.Text.Text_Type) return String is
(Langkit_Support.Text.To_UTF8 (Text));
function Encode
(Sloc_Range : Langkit_Support.Slocs.Source_Location_Range)
return String is
(Langkit_Support.Slocs.Image (Sloc_Range));
function Encode (Value : Boolean) return String is
(if Value then "true" else "false");
function Get_Node_Name
(File : VFS.Virtual_File; Directory_Prefix : VFS.Virtual_File)
return String
is
Filename : constant String :=
Utilities.Get_Unique_Filename
(File, Directory_Prefix,
Make_Lower_Case => Filenames_Are_Case_Insensitive);
begin
if File.Is_Directory then
return Dir_Name_Prefix & Filename;
else
return File_Name_Prefix & Filename;
end if;
end Get_Node_Name;
function Get_Node_Name
(Project : GPR.Project_Type; Directory_Prefix : VFS.Virtual_File)
return String
is
Filename : constant String :=
Utilities.Get_Unique_Filename
(Project.Project_Path, Directory_Prefix,
Make_Lower_Case => Filenames_Are_Case_Insensitive);
Name : constant String := Project.Name;
begin
return Proj_Name_Prefix & Filename & ":" & Name;
end Get_Node_Name;
function Get_Node_Name
(Analysis_Unit : LAL.Analysis_Unit; Directory_Prefix : VFS.Virtual_File)
return String
is
Filename : constant String :=
Utilities.Get_Unique_Filename
(Analysis_Unit.Get_Filename, Directory_Prefix,
Make_Lower_Case => Filenames_Are_Case_Insensitive);
begin
return File_Name_Prefix & Filename;
end Get_Node_Name;
function Get_Node_Name
(Defining_Name : LAL.Defining_Name; Basic_Decl : LAL.Basic_Decl'Class;
Directory_Prefix : VFS.Virtual_File) return String
is
Filename : constant String :=
Utilities.Get_Unique_Filename
(Defining_Name.Unit.Get_Filename, Directory_Prefix,
Make_Lower_Case => Filenames_Are_Case_Insensitive);
Name : constant String := Encode (Defining_Name.P_Relative_Name.Text);
Sloc_Range : constant String := Encode (Basic_Decl.Sloc_Range);
begin
return Decl_Name_Prefix & Filename & ":" & Name & "[" & Sloc_Range & "]";
end Get_Node_Name;
function Node_Attributes return GW.Attribute_Definition_Sets.Map is
begin
return Attributes : GW.Attribute_Definition_Sets.Map do
Attributes.Insert
(Node_Attribute_Fully_Qualified_Name, GW.GraphML_String);
Attributes.Insert
(Node_Attribute_Is_Formal_Parameter, GW.GraphML_Boolean);
Attributes.Insert
(Node_Attribute_Is_Main_Program, GW.GraphML_Boolean);
Attributes.Insert (Node_Attribute_Relative_Name, GW.GraphML_String);
Attributes.Insert (Node_Attribute_Source_Location, GW.GraphML_String);
end return;
end Node_Attributes;
function Get_Node_Attributes
(File : VFS.Virtual_File; Directory_Prefix : VFS.Virtual_File)
return GW.Attribute_Value_Sets.Map
is
-- Note that in the case of the fully quantified and relative names, we
-- keep the original casing to keep the names as readable as possible.
-- This differs from the behavior in the case of node names, where we
-- normalize the casing depending on the case-sensitivity of file system
-- to ensure that we do not get dupicate nodes on case-insensitive file
-- systems due to file names having different casings in different parts
-- of a codebase. As Extraction.Extract_Dependency_Graph first iterates
-- over the file system to create nodes for all files and directories,
-- it is ensured, via the implementation of Extraction.File_System,
-- that the fully quantified and relative names that end up in our
-- graph have casings that match the on-disk ones.
Fully_Qualified_Name : constant SU.Unbounded_String :=
+Utilities.Get_Unique_Filename
(File, Directory_Prefix, Make_Lower_Case => False);
Relative_Name : constant SU.Unbounded_String := +(+File.Base_Dir_Name);
begin
return Attributes : GW.Attribute_Value_Sets.Map do
Attributes.Insert
(Node_Attribute_Fully_Qualified_Name, Fully_Qualified_Name);
Attributes.Insert (Node_Attribute_Relative_Name, Relative_Name);
end return;
end Get_Node_Attributes;
function Get_Node_Attributes
(Project : GPR.Project_Type) return GW.Attribute_Value_Sets.Map
is
Fully_Qualified_Name : constant SU.Unbounded_String := +Project.Name;
Relative_Name : constant SU.Unbounded_String := +Project.Name;
begin
return Attributes : GW.Attribute_Value_Sets.Map do
Attributes.Insert
(Node_Attribute_Fully_Qualified_Name, Fully_Qualified_Name);
Attributes.Insert (Node_Attribute_Relative_Name, Relative_Name);
end return;
end Get_Node_Attributes;
function Get_Node_Attributes
(Defining_Name : LAL.Defining_Name; Basic_Decl : LAL.Basic_Decl;
Context : Utilities.Project_Context) return GW.Attribute_Value_Sets.Map
is
Uninstantiated_Defining_Name : constant LAL.Defining_Name :=
Defining_Name.P_Get_Uninstantiated_Node.As_Defining_Name;
Uninstantiated_Basic_Decl : constant LAL.Basic_Decl :=
Basic_Decl.P_Get_Uninstantiated_Node.As_Basic_Decl;
Fully_Qualified_Name : constant String :=
Encode (Uninstantiated_Defining_Name.P_Fully_Qualified_Name);
Is_Formal_Parameter : constant String :=
Encode (Uninstantiated_Basic_Decl.P_Is_Formal);
Is_Main_Subprogram : constant String :=
Encode
(Utilities.Is_Project_Main_Program
(Uninstantiated_Basic_Decl, Context));
Relative_Name : constant String :=
Encode (Uninstantiated_Defining_Name.P_Relative_Name.Text);
Sloc_Range : constant String :=
Encode (Uninstantiated_Basic_Decl.Sloc_Range);
begin
return Attributes : GW.Attribute_Value_Sets.Map do
Attributes.Insert
(Node_Attribute_Fully_Qualified_Name, +Fully_Qualified_Name);
Attributes.Insert
(Node_Attribute_Is_Formal_Parameter, +Is_Formal_Parameter);
Attributes.Insert (Node_Attribute_Relative_Name, +Relative_Name);
Attributes.Insert (Node_Attribute_Source_Location, +Sloc_Range);
if Basic_Decl.P_Is_Subprogram then
Attributes.Insert
(Node_Attribute_Is_Main_Program, +Is_Main_Subprogram);
end if;
end return;
end Get_Node_Attributes;
function Get_File_Subtype (File : VFS.Virtual_File) return GW.Node_Subtype
is
Extension : constant String :=
Ada.Characters.Handling.To_Lower (+File.File_Extension);
begin
if File = Utilities.Standard_Unit_File then
return Node_Type_Ada_Specification_File;
elsif Extension = ".adb" then
return Node_Type_Ada_Body_File;
elsif Extension = ".ads" then
return Node_Type_Ada_Specification_File;
elsif Extension = ".c" then
return Node_Type_C_Source_File;
elsif Extension = ".gpr" then
return Node_Type_Gnat_Project_File;
elsif Extension = ".h" then
return Node_Type_C_Header_File;
else
return Node_Type_Unknown_File_Type;
end if;
end Get_File_Subtype;
function Get_Decl_Subtype (Decl : LAL.Basic_Decl) return GW.Node_Subtype is
begin
case LALCO.Ada_Basic_Decl (Decl.Kind) is
-- Components.
when LALCO.Ada_Component_Decl =>
return Node_Type_Ada_Component_Declaration;
-- Discriminants.
when LALCO.Ada_Discriminant_Spec =>
return Node_Type_Ada_Discriminant_Declaration;
-- Exceptions.
when LALCO.Ada_Exception_Decl =>
return Node_Type_Ada_Exception_Declaration;
-- Numbers.
when LALCO.Ada_Number_Decl =>
return Node_Type_Ada_Number_Declaration;
-- Objects.
when LALCO.Ada_Object_Decl =>
return Node_Type_Ada_Object_Declaration;
-- Packages.
when LALCO.Ada_Package_Decl | LALCO.Ada_Package_Body_Stub |
LALCO.Ada_Package_Body | LALCO.Ada_Package_Renaming_Decl |
LALCO.Ada_Generic_Package_Decl |
LALCO.Ada_Generic_Package_Instantiation |
LALCO.Ada_Generic_Package_Renaming_Decl =>
return Node_Type_Ada_Package_Declaration;
-- Protected.
when LALCO.Ada_Protected_Type_Decl | LALCO.Ada_Protected_Body_Stub |
LALCO.Ada_Protected_Body | LALCO.Ada_Single_Protected_Decl =>
return Node_Type_Ada_Protected_Declaration;
-- Subprograms.
when LALCO.Ada_Abstract_Subp_Decl | LALCO.Ada_Subp_Decl |
LALCO.Ada_Expr_Function | LALCO.Ada_Null_Subp_Decl |
LALCO.Ada_Subp_Body | LALCO.Ada_Subp_Renaming_Decl |
LALCO.Ada_Subp_Body_Stub | LALCO.Ada_Generic_Subp_Decl |
LALCO.Ada_Generic_Subp_Instantiation |
LALCO.Ada_Generic_Subp_Renaming_Decl |
LALCO.Ada_Abstract_Formal_Subp_Decl |
LALCO.Ada_Concrete_Formal_Subp_Decl =>
return Node_Type_Ada_Subprogram_Declaration;
when LALCO.Ada_Entry_Decl | LALCO.Ada_Entry_Body =>
return Node_Type_Ada_Entry_Declaration;
when LALCO.Ada_Enum_Literal_Decl =>
return Node_Type_Ada_Enum_Literal_Declaration;
-- Tasks.
when LALCO.Ada_Task_Type_Decl | LALCO.Ada_Task_Body_Stub |
LALCO.Ada_Task_Body | LALCO.Ada_Single_Task_Decl =>
return Node_Type_Ada_Task_Declaration;
-- Types.
when LALCO.Ada_Type_Decl | LALCO.Ada_Subtype_Decl |
LALCO.Ada_Incomplete_Type_Decl |
LALCO.Ada_Incomplete_Tagged_Type_Decl =>
return Node_Type_Ada_Type_Declaration;
when others =>
raise Internal_Extraction_Error
with "Unhandled basic declaration: " & Decl.Kind'Image;
end case;
end Get_Decl_Subtype;
function Edge_Attributes return GW.Attribute_Definition_Sets.Map is
begin
return Attributes : GW.Attribute_Definition_Sets.Map do
Attributes.Insert
(Edge_Attribute_Has_Access_Type, GW.GraphML_Boolean);
Attributes.Insert (Edge_Attribute_Has_Array_Type, GW.GraphML_Boolean);
Attributes.Insert (Edge_Attribute_Is_Dispatching, GW.GraphML_Boolean);
end return;
end Edge_Attributes;
function Get_Edge_Attributes
(Expr : LAL.Expr'Class) return GW.Attribute_Value_Sets.Map
is
Is_Dispatching : constant String := Encode (Expr.P_Is_Dispatching_Call);
begin
return Attributes : GW.Attribute_Value_Sets.Map do
Attributes.Insert (Edge_Attribute_Is_Dispatching, +Is_Dispatching);
end return;
end Get_Edge_Attributes;
function Get_Edge_Attributes
(Type_Expr : LAL.Type_Expr'Class; Can_Have_Array_Type : Boolean)
return GW.Attribute_Value_Sets.Map
is
Has_Access_Type : Boolean := False;
Has_Array_Type : Boolean := False;
procedure Get_Attribute_Values (Type_Def : LAL.Type_Def);
procedure Get_Attribute_Values (Type_Expr : LAL.Type_Expr'Class);
procedure Get_Attribute_Values (Type_Expr : LAL.Type_Expr'Class) is
begin
if Type_Expr.Kind = LALCO.Ada_Anonymous_Type then
Get_Attribute_Values
(Type_Expr.As_Anonymous_Type.F_Type_Decl.F_Type_Def);
end if;
end Get_Attribute_Values;
procedure Get_Attribute_Values (Type_Def : LAL.Type_Def) is
begin
if Type_Def.Kind = LALCO.Ada_Array_Type_Def then
Has_Array_Type := True;
Get_Attribute_Values
(Type_Def.As_Array_Type_Def.F_Component_Type.F_Type_Expr);
elsif Type_Def.Kind = LALCO.Ada_Type_Access_Def then
Has_Access_Type := True;
Get_Attribute_Values
(Type_Def.As_Type_Access_Def.F_Subtype_Indication);
end if;
end Get_Attribute_Values;
begin
Get_Attribute_Values (Type_Expr);
return Attributes : GW.Attribute_Value_Sets.Map do
Attributes.Insert
(Edge_Attribute_Has_Access_Type, +Encode (Has_Access_Type));
if Can_Have_Array_Type then
Attributes.Insert
(Edge_Attribute_Has_Array_Type, +Encode (Has_Array_Type));
elsif Has_Array_Type then
raise Internal_Extraction_Error
with "Unexpected Has_Array_Type in Get_Edge_Attributes";
end if;
end return;
end Get_Edge_Attributes;
end Extraction.Node_Edge_Types;
|
with Ada.Text_IO; use Ada.Text_IO;
with My_Class;
procedure Test is
T : My_Class.Object;
begin
T.Write;
end Test;
|
pragma Style_Checks (Off);
-- This spec has been automatically generated from ATSAMD51G19A.svd
pragma Restrictions (No_Elaboration_Code);
with HAL;
with System;
package SAM_SVD.AC is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Control A
type AC_CTRLA_Register is record
-- Software Reset
SWRST : Boolean := False;
-- Enable
ENABLE : Boolean := False;
-- unspecified
Reserved_2_7 : HAL.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for AC_CTRLA_Register use record
SWRST at 0 range 0 .. 0;
ENABLE at 0 range 1 .. 1;
Reserved_2_7 at 0 range 2 .. 7;
end record;
-- AC_CTRLB_START array
type AC_CTRLB_START_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for AC_CTRLB_START
type AC_CTRLB_START_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- START as a value
Val : HAL.UInt2;
when True =>
-- START as an array
Arr : AC_CTRLB_START_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for AC_CTRLB_START_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Control B
type AC_CTRLB_Register is record
-- Write-only. Comparator 0 Start Comparison
START : AC_CTRLB_START_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_2_7 : HAL.UInt6 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for AC_CTRLB_Register use record
START at 0 range 0 .. 1;
Reserved_2_7 at 0 range 2 .. 7;
end record;
-- AC_EVCTRL_COMPEO array
type AC_EVCTRL_COMPEO_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for AC_EVCTRL_COMPEO
type AC_EVCTRL_COMPEO_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- COMPEO as a value
Val : HAL.UInt2;
when True =>
-- COMPEO as an array
Arr : AC_EVCTRL_COMPEO_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for AC_EVCTRL_COMPEO_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- AC_EVCTRL_COMPEI array
type AC_EVCTRL_COMPEI_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for AC_EVCTRL_COMPEI
type AC_EVCTRL_COMPEI_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- COMPEI as a value
Val : HAL.UInt2;
when True =>
-- COMPEI as an array
Arr : AC_EVCTRL_COMPEI_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for AC_EVCTRL_COMPEI_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- AC_EVCTRL_INVEI array
type AC_EVCTRL_INVEI_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for AC_EVCTRL_INVEI
type AC_EVCTRL_INVEI_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- INVEI as a value
Val : HAL.UInt2;
when True =>
-- INVEI as an array
Arr : AC_EVCTRL_INVEI_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for AC_EVCTRL_INVEI_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Event Control
type AC_EVCTRL_Register is record
-- Comparator 0 Event Output Enable
COMPEO : AC_EVCTRL_COMPEO_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_2_3 : HAL.UInt2 := 16#0#;
-- Window 0 Event Output Enable
WINEO0 : Boolean := False;
-- unspecified
Reserved_5_7 : HAL.UInt3 := 16#0#;
-- Comparator 0 Event Input Enable
COMPEI : AC_EVCTRL_COMPEI_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_10_11 : HAL.UInt2 := 16#0#;
-- Comparator 0 Input Event Invert Enable
INVEI : AC_EVCTRL_INVEI_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_14_15 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for AC_EVCTRL_Register use record
COMPEO at 0 range 0 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
WINEO0 at 0 range 4 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
COMPEI at 0 range 8 .. 9;
Reserved_10_11 at 0 range 10 .. 11;
INVEI at 0 range 12 .. 13;
Reserved_14_15 at 0 range 14 .. 15;
end record;
-- AC_INTENCLR_COMP array
type AC_INTENCLR_COMP_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for AC_INTENCLR_COMP
type AC_INTENCLR_COMP_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- COMP as a value
Val : HAL.UInt2;
when True =>
-- COMP as an array
Arr : AC_INTENCLR_COMP_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for AC_INTENCLR_COMP_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Interrupt Enable Clear
type AC_INTENCLR_Register is record
-- Comparator 0 Interrupt Enable
COMP : AC_INTENCLR_COMP_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_2_3 : HAL.UInt2 := 16#0#;
-- Window 0 Interrupt Enable
WIN0 : Boolean := False;
-- unspecified
Reserved_5_7 : HAL.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for AC_INTENCLR_Register use record
COMP at 0 range 0 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
WIN0 at 0 range 4 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
end record;
-- AC_INTENSET_COMP array
type AC_INTENSET_COMP_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for AC_INTENSET_COMP
type AC_INTENSET_COMP_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- COMP as a value
Val : HAL.UInt2;
when True =>
-- COMP as an array
Arr : AC_INTENSET_COMP_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for AC_INTENSET_COMP_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Interrupt Enable Set
type AC_INTENSET_Register is record
-- Comparator 0 Interrupt Enable
COMP : AC_INTENSET_COMP_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_2_3 : HAL.UInt2 := 16#0#;
-- Window 0 Interrupt Enable
WIN0 : Boolean := False;
-- unspecified
Reserved_5_7 : HAL.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for AC_INTENSET_Register use record
COMP at 0 range 0 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
WIN0 at 0 range 4 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
end record;
-- AC_INTFLAG_COMP array
type AC_INTFLAG_COMP_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for AC_INTFLAG_COMP
type AC_INTFLAG_COMP_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- COMP as a value
Val : HAL.UInt2;
when True =>
-- COMP as an array
Arr : AC_INTFLAG_COMP_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for AC_INTFLAG_COMP_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Interrupt Flag Status and Clear
type AC_INTFLAG_Register is record
-- Comparator 0
COMP : AC_INTFLAG_COMP_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_2_3 : HAL.UInt2 := 16#0#;
-- Window 0
WIN0 : Boolean := False;
-- unspecified
Reserved_5_7 : HAL.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for AC_INTFLAG_Register use record
COMP at 0 range 0 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
WIN0 at 0 range 4 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
end record;
-- AC_STATUSA_STATE array
type AC_STATUSA_STATE_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for AC_STATUSA_STATE
type AC_STATUSA_STATE_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- STATE as a value
Val : HAL.UInt2;
when True =>
-- STATE as an array
Arr : AC_STATUSA_STATE_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for AC_STATUSA_STATE_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Window 0 Current State
type STATUSA_WSTATE0Select is
(-- Signal is above window
ABOVE,
-- Signal is inside window
INSIDE,
-- Signal is below window
BELOW)
with Size => 2;
for STATUSA_WSTATE0Select use
(ABOVE => 0,
INSIDE => 1,
BELOW => 2);
-- Status A
type AC_STATUSA_Register is record
-- Read-only. Comparator 0 Current State
STATE : AC_STATUSA_STATE_Field;
-- unspecified
Reserved_2_3 : HAL.UInt2;
-- Read-only. Window 0 Current State
WSTATE0 : STATUSA_WSTATE0Select;
-- unspecified
Reserved_6_7 : HAL.UInt2;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for AC_STATUSA_Register use record
STATE at 0 range 0 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
WSTATE0 at 0 range 4 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
end record;
-- AC_STATUSB_READY array
type AC_STATUSB_READY_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for AC_STATUSB_READY
type AC_STATUSB_READY_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- READY as a value
Val : HAL.UInt2;
when True =>
-- READY as an array
Arr : AC_STATUSB_READY_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for AC_STATUSB_READY_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Status B
type AC_STATUSB_Register is record
-- Read-only. Comparator 0 Ready
READY : AC_STATUSB_READY_Field;
-- unspecified
Reserved_2_7 : HAL.UInt6;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for AC_STATUSB_Register use record
READY at 0 range 0 .. 1;
Reserved_2_7 at 0 range 2 .. 7;
end record;
-- Debug Control
type AC_DBGCTRL_Register is record
-- Debug Run
DBGRUN : Boolean := False;
-- unspecified
Reserved_1_7 : HAL.UInt7 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for AC_DBGCTRL_Register use record
DBGRUN at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
end record;
-- Window 0 Interrupt Selection
type WINCTRL_WINTSEL0Select is
(-- Interrupt on signal above window
ABOVE,
-- Interrupt on signal inside window
INSIDE,
-- Interrupt on signal below window
BELOW,
-- Interrupt on signal outside window
OUTSIDE)
with Size => 2;
for WINCTRL_WINTSEL0Select use
(ABOVE => 0,
INSIDE => 1,
BELOW => 2,
OUTSIDE => 3);
-- Window Control
type AC_WINCTRL_Register is record
-- Window 0 Mode Enable
WEN0 : Boolean := False;
-- Window 0 Interrupt Selection
WINTSEL0 : WINCTRL_WINTSEL0Select := SAM_SVD.AC.ABOVE;
-- unspecified
Reserved_3_7 : HAL.UInt5 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for AC_WINCTRL_Register use record
WEN0 at 0 range 0 .. 0;
WINTSEL0 at 0 range 1 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
end record;
subtype AC_SCALER_VALUE_Field is HAL.UInt6;
-- Scaler n
type AC_SCALER_Register is record
-- Scaler Value
VALUE : AC_SCALER_VALUE_Field := 16#0#;
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for AC_SCALER_Register use record
VALUE at 0 range 0 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
end record;
-- Scaler n
type AC_SCALER_Registers is array (0 .. 1) of AC_SCALER_Register;
-- Interrupt Selection
type COMPCTRL_INTSELSelect is
(-- Interrupt on comparator output toggle
TOGGLE,
-- Interrupt on comparator output rising
RISING,
-- Interrupt on comparator output falling
FALLING,
-- Interrupt on end of comparison (single-shot mode only)
EOC)
with Size => 2;
for COMPCTRL_INTSELSelect use
(TOGGLE => 0,
RISING => 1,
FALLING => 2,
EOC => 3);
-- Negative Input Mux Selection
type COMPCTRL_MUXNEGSelect is
(-- I/O pin 0
PIN0,
-- I/O pin 1
PIN1,
-- I/O pin 2
PIN2,
-- I/O pin 3
PIN3,
-- Ground
GND,
-- VDD scaler
VSCALE,
-- Internal bandgap voltage
BANDGAP,
-- DAC output
DAC)
with Size => 3;
for COMPCTRL_MUXNEGSelect use
(PIN0 => 0,
PIN1 => 1,
PIN2 => 2,
PIN3 => 3,
GND => 4,
VSCALE => 5,
BANDGAP => 6,
DAC => 7);
-- Positive Input Mux Selection
type COMPCTRL_MUXPOSSelect is
(-- I/O pin 0
PIN0,
-- I/O pin 1
PIN1,
-- I/O pin 2
PIN2,
-- I/O pin 3
PIN3,
-- VDD Scaler
VSCALE)
with Size => 3;
for COMPCTRL_MUXPOSSelect use
(PIN0 => 0,
PIN1 => 1,
PIN2 => 2,
PIN3 => 3,
VSCALE => 4);
-- Speed Selection
type COMPCTRL_SPEEDSelect is
(-- Reset value for the field
COMPCTRL_SPEEDSelect_Reset,
-- High speed
HIGH)
with Size => 2;
for COMPCTRL_SPEEDSelect use
(COMPCTRL_SPEEDSelect_Reset => 0,
HIGH => 3);
-- Hysteresis Level
type COMPCTRL_HYSTSelect is
(-- 50mV
HYST50,
-- 100mV
HYST100,
-- 150mV
HYST150)
with Size => 2;
for COMPCTRL_HYSTSelect use
(HYST50 => 0,
HYST100 => 1,
HYST150 => 2);
-- Filter Length
type COMPCTRL_FLENSelect is
(-- No filtering
OFF,
-- 3-bit majority function (2 of 3)
MAJ3,
-- 5-bit majority function (3 of 5)
MAJ5)
with Size => 3;
for COMPCTRL_FLENSelect use
(OFF => 0,
MAJ3 => 1,
MAJ5 => 2);
-- Output
type COMPCTRL_OUTSelect is
(-- The output of COMPn is not routed to the COMPn I/O port
OFF,
-- The asynchronous output of COMPn is routed to the COMPn I/O port
ASYNC,
-- The synchronous output (including filtering) of COMPn is routed to the
-- COMPn I/O port
SYNC)
with Size => 2;
for COMPCTRL_OUTSelect use
(OFF => 0,
ASYNC => 1,
SYNC => 2);
-- Comparator Control n
type AC_COMPCTRL_Register is record
-- unspecified
Reserved_0_0 : HAL.Bit := 16#0#;
-- Enable
ENABLE : Boolean := False;
-- Single-Shot Mode
SINGLE : Boolean := False;
-- Interrupt Selection
INTSEL : COMPCTRL_INTSELSelect := SAM_SVD.AC.TOGGLE;
-- unspecified
Reserved_5_5 : HAL.Bit := 16#0#;
-- Run in Standby
RUNSTDBY : Boolean := False;
-- unspecified
Reserved_7_7 : HAL.Bit := 16#0#;
-- Negative Input Mux Selection
MUXNEG : COMPCTRL_MUXNEGSelect := SAM_SVD.AC.PIN0;
-- unspecified
Reserved_11_11 : HAL.Bit := 16#0#;
-- Positive Input Mux Selection
MUXPOS : COMPCTRL_MUXPOSSelect := SAM_SVD.AC.PIN0;
-- Swap Inputs and Invert
SWAP : Boolean := False;
-- Speed Selection
SPEED : COMPCTRL_SPEEDSelect := COMPCTRL_SPEEDSelect_Reset;
-- unspecified
Reserved_18_18 : HAL.Bit := 16#0#;
-- Hysteresis Enable
HYSTEN : Boolean := False;
-- Hysteresis Level
HYST : COMPCTRL_HYSTSelect := SAM_SVD.AC.HYST50;
-- unspecified
Reserved_22_23 : HAL.UInt2 := 16#0#;
-- Filter Length
FLEN : COMPCTRL_FLENSelect := SAM_SVD.AC.OFF;
-- unspecified
Reserved_27_27 : HAL.Bit := 16#0#;
-- Output
OUT_k : COMPCTRL_OUTSelect := SAM_SVD.AC.OFF;
-- unspecified
Reserved_30_31 : HAL.UInt2 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for AC_COMPCTRL_Register use record
Reserved_0_0 at 0 range 0 .. 0;
ENABLE at 0 range 1 .. 1;
SINGLE at 0 range 2 .. 2;
INTSEL at 0 range 3 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
RUNSTDBY at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
MUXNEG at 0 range 8 .. 10;
Reserved_11_11 at 0 range 11 .. 11;
MUXPOS at 0 range 12 .. 14;
SWAP at 0 range 15 .. 15;
SPEED at 0 range 16 .. 17;
Reserved_18_18 at 0 range 18 .. 18;
HYSTEN at 0 range 19 .. 19;
HYST at 0 range 20 .. 21;
Reserved_22_23 at 0 range 22 .. 23;
FLEN at 0 range 24 .. 26;
Reserved_27_27 at 0 range 27 .. 27;
OUT_k at 0 range 28 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
-- Comparator Control n
type AC_COMPCTRL_Registers is array (0 .. 1) of AC_COMPCTRL_Register;
-- AC_SYNCBUSY_COMPCTRL array
type AC_SYNCBUSY_COMPCTRL_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for AC_SYNCBUSY_COMPCTRL
type AC_SYNCBUSY_COMPCTRL_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- COMPCTRL as a value
Val : HAL.UInt2;
when True =>
-- COMPCTRL as an array
Arr : AC_SYNCBUSY_COMPCTRL_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for AC_SYNCBUSY_COMPCTRL_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Synchronization Busy
type AC_SYNCBUSY_Register is record
-- Read-only. Software Reset Synchronization Busy
SWRST : Boolean;
-- Read-only. Enable Synchronization Busy
ENABLE : Boolean;
-- Read-only. WINCTRL Synchronization Busy
WINCTRL : Boolean;
-- Read-only. COMPCTRL 0 Synchronization Busy
COMPCTRL : AC_SYNCBUSY_COMPCTRL_Field;
-- unspecified
Reserved_5_31 : HAL.UInt27;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for AC_SYNCBUSY_Register use record
SWRST at 0 range 0 .. 0;
ENABLE at 0 range 1 .. 1;
WINCTRL at 0 range 2 .. 2;
COMPCTRL at 0 range 3 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
subtype AC_CALIB_BIAS0_Field is HAL.UInt2;
-- Calibration
type AC_CALIB_Register is record
-- COMP0/1 Bias Scaling
BIAS0 : AC_CALIB_BIAS0_Field := 16#1#;
-- unspecified
Reserved_2_15 : HAL.UInt14 := 16#40#;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for AC_CALIB_Register use record
BIAS0 at 0 range 0 .. 1;
Reserved_2_15 at 0 range 2 .. 15;
end record;
-----------------
-- Peripherals --
-----------------
-- Analog Comparators
type AC_Peripheral is record
-- Control A
CTRLA : aliased AC_CTRLA_Register;
-- Control B
CTRLB : aliased AC_CTRLB_Register;
-- Event Control
EVCTRL : aliased AC_EVCTRL_Register;
-- Interrupt Enable Clear
INTENCLR : aliased AC_INTENCLR_Register;
-- Interrupt Enable Set
INTENSET : aliased AC_INTENSET_Register;
-- Interrupt Flag Status and Clear
INTFLAG : aliased AC_INTFLAG_Register;
-- Status A
STATUSA : aliased AC_STATUSA_Register;
-- Status B
STATUSB : aliased AC_STATUSB_Register;
-- Debug Control
DBGCTRL : aliased AC_DBGCTRL_Register;
-- Window Control
WINCTRL : aliased AC_WINCTRL_Register;
-- Scaler n
SCALER : aliased AC_SCALER_Registers;
-- Comparator Control n
COMPCTRL : aliased AC_COMPCTRL_Registers;
-- Synchronization Busy
SYNCBUSY : aliased AC_SYNCBUSY_Register;
-- Calibration
CALIB : aliased AC_CALIB_Register;
end record
with Volatile;
for AC_Peripheral use record
CTRLA at 16#0# range 0 .. 7;
CTRLB at 16#1# range 0 .. 7;
EVCTRL at 16#2# range 0 .. 15;
INTENCLR at 16#4# range 0 .. 7;
INTENSET at 16#5# range 0 .. 7;
INTFLAG at 16#6# range 0 .. 7;
STATUSA at 16#7# range 0 .. 7;
STATUSB at 16#8# range 0 .. 7;
DBGCTRL at 16#9# range 0 .. 7;
WINCTRL at 16#A# range 0 .. 7;
SCALER at 16#C# range 0 .. 15;
COMPCTRL at 16#10# range 0 .. 63;
SYNCBUSY at 16#20# range 0 .. 31;
CALIB at 16#24# range 0 .. 15;
end record;
-- Analog Comparators
AC_Periph : aliased AC_Peripheral
with Import, Address => AC_Base;
end SAM_SVD.AC;
|
-- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
with GL.Errors;
separate (GL)
procedure Raise_Exception_On_OpenGL_Error is
begin
case Errors.Error_Flag is
when Errors.Invalid_Operation => raise Errors.Invalid_Operation_Error;
when Errors.Invalid_Value => raise Errors.Invalid_Value_Error;
when Errors.Invalid_Framebuffer_Operation =>
raise Errors.Invalid_Framebuffer_Operation_Error;
when Errors.Out_Of_Memory => raise Errors.Out_Of_Memory_Error;
when Errors.Stack_Overflow => raise Errors.Stack_Overflow_Error;
when Errors.Stack_Underflow => raise Errors.Stack_Underflow_Error;
when Errors.Invalid_Enum => raise Errors.Internal_Error;
when Errors.No_Error => null;
end case;
exception
when Constraint_Error => raise Errors.Internal_Error;
end Raise_Exception_On_OpenGL_Error;
|
with mylog; use mylog;
package LogQueue with SPARK_Mode is
protected type queue is
procedure Put (msg : mylog.logmsg) with
Pre => msg.typ in mylog.msgtype'Range;
-- SPARK does not know that
entry Get (msg : out mylog.logmsg);
private
buf : mylog.logmsg; -- unconstrained variant record => mutable. GNATprove doesn't see that
Not_Empty : Boolean := False;
end queue;
myqueue : queue;
procedure mytest;
end LogQueue;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Web API Definition --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-2018, 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 WebAPI.DOM.Child_Nodes;
with WebAPI.DOM.HTML_Collections;
with WebAPI.DOM.Nodes;
with WebAPI.DOM.Non_Document_Type_Child_Nodes;
with WebAPI.DOM.Parent_Nodes;
with WebAPI.DOM.Rects;
with WebAPI.DOM.Token_Lists;
package WebAPI.DOM.Elements is
pragma Preelaborate;
type Element is limited interface
and WebAPI.DOM.Child_Nodes.Child_Node
and WebAPI.DOM.Nodes.Node
and WebAPI.DOM.Non_Document_Type_Child_Nodes.Non_Document_Type_Child_Node
and WebAPI.DOM.Parent_Nodes.Parent_Node;
type Element_Access is access all Element'Class
with Storage_Size => 0;
-- XXX Not implemented
--
-- interface Element : Node {
-- [SameObject] readonly attribute Attr[] attributes;
-- };
not overriding function Get_Namespace_URI
(Self : not null access constant Element)
return WebAPI.DOM_String is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "namespaceURI";
not overriding function Get_Prefix
(Self : not null access constant Element)
return WebAPI.DOM_String is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "prefix";
not overriding function Get_Local_Name
(Self : not null access constant Element)
return WebAPI.DOM_String is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "localName";
not overriding function Get_Tag_Name
(Self : not null access constant Element)
return WebAPI.DOM_String is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "tagName";
not overriding function Get_Id
(Self : not null access constant Element)
return WebAPI.DOM_String is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "id";
not overriding procedure Set_Id
(Self : not null access Element;
To : WebAPI.DOM_String) is abstract
with Import => True,
Convention => JavaScript_Property_Setter,
Link_Name => "id";
not overriding function Get_Class_Name
(Self : not null access constant Element)
return WebAPI.DOM_String is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "className";
not overriding procedure Set_Class_Name
(Self : not null access Element;
To : WebAPI.DOM_String) is abstract
with Import => True,
Convention => JavaScript_Property_Setter,
Link_Name => "className";
not overriding function Get_Class_List
(Self : not null access constant Element)
return WebAPI.DOM.Token_Lists.DOM_Token_List_Access is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "classList";
not overriding function Get_Attribute
(Self : not null access constant Element;
Name : WebAPI.DOM_String) return WebAPI.DOM_String is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "getAttribute";
not overriding function Get_Attribute_NS
(Self : not null access constant Element;
Namespace : WebAPI.DOM_String;
Local_Name : WebAPI.DOM_String) return WebAPI.DOM_String is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "getAttributeNS";
not overriding procedure Set_Attribute
(Self : not null access Element;
Name : WebAPI.DOM_String;
Value : WebAPI.DOM_String) is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "setAttribute";
not overriding procedure Set_Attribute_NS
(Self : not null access Element;
Namespace : WebAPI.DOM_String;
Local_Name : WebAPI.DOM_String;
Value : WebAPI.DOM_String) is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "setAttributeNS";
not overriding procedure Remove_Attribute
(Self : not null access Element;
Name : WebAPI.DOM_String) is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "removeAttribute";
not overriding procedure Remove_Attribute_NS
(Self : not null access Element;
Namespace : WebAPI.DOM_String;
Local_Name : WebAPI.DOM_String) is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "removeAttributeNS";
not overriding function Has_Attribute
(Self : not null access constant Element;
Name : WebAPI.DOM_String) return Boolean is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "hasAttribute";
not overriding function Has_Attribute_NS
(Self : not null access constant Element;
Namespace : WebAPI.DOM_String;
Local_Name : WebAPI.DOM_String) return Boolean is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "hasAttributeNS";
not overriding function Get_Elements_By_Tag_Name
(Self : not null access constant Element;
Local_Name : WebAPI.DOM_String)
return WebAPI.DOM.HTML_Collections.HTML_Collection is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "getElementsByTagName";
not overriding function Get_Elements_By_Tag_Name_NS
(Self : not null access constant Element;
Namespace : WebAPI.DOM_String;
Local_Name : WebAPI.DOM_String)
return WebAPI.DOM.HTML_Collections.HTML_Collection is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "getElementsByTagNameNS";
not overriding function Get_Elements_By_Class_Name
(Self : not null access constant Element;
Class_Name : WebAPI.DOM_String)
return WebAPI.DOM.HTML_Collections.HTML_Collection is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "getElementsByClassName";
----------------------------------
-- CSSOM View Module Extensions --
----------------------------------
-- partial interface Element {
-- sequence<DOMRect> getClientRects();
-- void scrollIntoView();
-- void scrollIntoView((boolean or object) arg
-- );
-- void scroll(optional ScrollToOptions options
-- );
-- void scroll(unrestricted double x
-- , unrestricted double y
-- );
-- void scrollTo(optional ScrollToOptions options
-- );
-- void scrollTo(unrestricted double x
-- , unrestricted double y
-- );
-- void scrollBy(optional ScrollToOptions options
-- );
-- void scrollBy(unrestricted double x
-- , unrestricted double y
-- );
not overriding function Get_Bounding_Client_Rect
(Self : not null access constant Element)
return WebAPI.DOM.Rects.DOM_Rect_Access is abstract
with Import => True,
Convention => JavaScript_Method,
Link_Name => "getBoundingClientRect";
not overriding function Get_Scroll_Width
(Self : not null access constant Element)
return DOM_Long is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "scrollWidth";
not overriding function Get_Scroll_Height
(Self : not null access constant Element)
return DOM_Long is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "scrollHeight";
not overriding function Get_Scroll_Top
(Self : not null access constant Element)
return DOM_Double is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "scrollTop";
not overriding function Get_Scroll_Left
(Self : not null access constant Element)
return DOM_Double is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "scrollLeft";
not overriding function Get_Client_Top
(Self : not null access constant Element)
return DOM_Long is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "clientTop";
not overriding function Get_Client_Left
(Self : not null access constant Element)
return DOM_Long is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "clientLeft";
not overriding function Get_Client_Width
(Self : not null access constant Element)
return DOM_Long is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "clientWidth";
not overriding function Get_Client_Height
(Self : not null access constant Element)
return DOM_Long is abstract
with Import => True,
Convention => JavaScript_Property_Getter,
Link_Name => "clientHeight";
end WebAPI.DOM.Elements;
|
-- { dg-do run }
-- { dg-options "-gnato -O" }
procedure Overflow_Fixed is
type Unsigned_8_Bit is mod 2**8;
procedure Fixed_To_Eight (Value : Duration) is
Item : Unsigned_8_Bit;
begin
Item := Unsigned_8_Bit(Value);
raise Program_Error;
exception
when Constraint_Error => null; -- expected case
end;
begin
Fixed_To_Eight (-0.5);
end;
|
with
freetype_c.Pointers;
package freetype_c.FT_GlyphSlot
is
subtype Item is freetype_c.Pointers.FT_GlyphSlotRec_Pointer;
type Item_array is array (C.Size_t range <>) of aliased freetype_c.FT_GlyphSlot.Item;
type Pointer is access all freetype_c.FT_GlyphSlot.Item;
type Pointer_array is array (C.Size_t range <>) of aliased freetype_c.FT_GlyphSlot.Pointer;
type pointer_Pointer is access all freetype_c.FT_GlyphSlot.Pointer;
end freetype_c.FT_GlyphSlot;
|
with STM32_SVD.PWR; use STM32_SVD.PWR;
with Ada.Real_Time; use Ada.Real_Time;
package body STM32.SubGhzRF is
-- procedure SubGhzRF_RegRead (Addr : UInt16; Value : out UInt8)
-- is
-- begin
-- null;
-- end SubGhzRF_RegRead;
Pa_Power_Choice : PaSel_Choice := LP_PA;
GX : UInt8;
procedure NSS_Assert
is
begin
Flush_Fifo (SubGhzPhyPort.all);
PWR_Periph.SUBGHZSPICR.NSS := False;
end NSS_Assert;
procedure NSS_Deassert
is
begin
PWR_Periph.SUBGHZSPICR.NSS := True;
end NSS_Deassert;
procedure WaitOnBusy
is
Mask : Boolean;
begin
loop
Mask := PWR_Periph.SR2.RFBUSYMS;
-- Need a timeout here
exit when not (Mask and PWR_Periph.SR2.RFBUSYS);
end loop;
end WaitOnBusy;
procedure CheckDeviceReady
is
begin
-- if in deep sleep... wait (add later)
NSS_Assert;
null;
NSS_Deassert;
WaitOnBusy;
end CheckDeviceReady;
procedure Set_Standby (Choice : Set_Standby_Selection)
is
Msg : SPI_Data_8b (1 .. 2);
Status : SPI_Status;
begin
Msg (1) := Opcode_Set_Standby;
Msg (2) := Choice'Enum_Rep;
CheckDeviceReady;
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
NSS_Deassert;
end Set_Standby;
procedure Set_RegulatorMode (Choice : Set_RegulatorMode_Selection)
is
Msg : SPI_Data_8b (1 .. 2);
Status : SPI_Status;
begin
Msg (1) := Opcode_Set_RegulatorMode;
Msg (2) := Choice'Enum_Rep;
CheckDeviceReady;
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
NSS_Deassert;
end Set_RegulatorMode;
procedure Set_TcxoMode (Trim : Set_TcxoMode_Message)
is
Msg : SPI_Data_8b (1 .. Trim'Size / 8);
LTrim : Set_TcxoMode_Message := Trim;
for Msg'Address use LTrim'Address;
Status : SPI_Status;
begin
LTrim.Opcode := Opcode_Set_TcxoMode;
CheckDeviceReady;
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
NSS_Deassert;
end Set_TcxoMode;
procedure Write_Register (Reg : Write_Register_Message)
is
Msg : SPI_Data_8b (1 .. Reg'Size / 8);
LReg : Write_Register_Message := Reg;
for Msg'Address use LReg'Address;
Status : SPI_Status;
begin
LReg.Opcode := Opcode_Write_Register;
CheckDeviceReady;
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
NSS_Deassert;
WaitOnBusy;
end Write_Register;
procedure Read_Register (Reg : Read_Register_Message;
RFStatus : out Subghz_Status;
Value : out UInt8)
is
Msg : SPI_Data_8b (1 .. Reg'Size / 8);
Reply : SPI_Data_8b (1 .. 2);
LReg : Read_Register_Message := Reg;
for Msg'Address use LReg'Address;
Status : SPI_Status;
begin
LReg.Opcode := Opcode_Read_Register;
CheckDeviceReady;
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
Flush_Fifo (SubGhzPhyPort.all);
Receive (SubGhzPhyPort.all, Reply, Status);
NSS_Deassert;
WaitOnBusy;
RFStatus := Reply (1);
Value := Reply (2);
end Read_Register;
procedure Calibrate (CalRec : Calibrate_Message)
is
Msg : SPI_Data_8b (1 .. CalRec'Size / 8);
LCalRec : Calibrate_Message := CalRec;
for Msg'Address use LCalRec'Address;
Status : SPI_Status;
begin
LCalRec.Opcode := Opcode_Calibrate;
CheckDeviceReady;
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
NSS_Deassert;
end Calibrate;
procedure Set_PacketType (PacketType : Set_PacketType_Message)
is
Msg : SPI_Data_8b (1 .. PacketType'Size / 8);
LPacketType : Set_PacketType_Message := PacketType;
for Msg'Address use LPacketType'Address;
Status : SPI_Status;
begin
LPacketType.Opcode := Opcode_Set_PacketType;
CheckDeviceReady;
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
NSS_Deassert;
end Set_PacketType;
procedure Set_BufferBaseAddress (Bases : Set_BufferBaseAddress_Message)
is
Msg : SPI_Data_8b (1 .. Bases'Size / 8);
LBases : Set_BufferBaseAddress_Message := Bases;
for Msg'Address use LBases'Address;
Status : SPI_Status;
begin
LBases.Opcode := Opcode_Set_BufferBaseAddress;
CheckDeviceReady;
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
NSS_Deassert;
end Set_BufferBaseAddress;
procedure Set_PaConfig (PaCfg : Set_PaConfig_Message)
is
Msg : SPI_Data_8b (1 .. PaCfg'Size / 8);
LPaCfg : Set_PaConfig_Message := PaCfg;
for Msg'Address use LPaCfg'Address;
Status : SPI_Status;
begin
LPaCfg.Opcode := Opcode_Set_PaConfig;
LPaCfg.Extra := 1;
Pa_Power_Choice := PaCfg.PaSel; -- Make a note of this. Its used in later setup
CheckDeviceReady;
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
NSS_Deassert;
end Set_PaConfig;
procedure Set_TxParams (TxParams : Set_TxParams_Message)
is
Msg : SPI_Data_8b (1 .. TxParams'Size / 8);
LTxParams : Set_TxParams_Message := TxParams;
for Msg'Address use LTxParams'Address;
Status : SPI_Status;
begin
LTxParams.Opcode := Opcode_Set_TxParams;
if (Pa_Power_Choice = LP_PA) and (TxParams.Power in -17 .. 14) then
raise Program_Error with "LP power out of range";
elsif Pa_Power_Choice = HP_PA and TxParams.Power in -9 .. 14 then
raise Program_Error with "HP power out of range";
end if;
CheckDeviceReady;
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
NSS_Deassert;
end Set_TxParams;
procedure Cfg_DioIrq (Cfg : Cfg_DioIrq_Message)
is
Msg : SPI_Data_8b (1 .. Cfg'Size / 8);
LCfg : Cfg_DioIrq_Message := Cfg;
for Msg'Address use LCfg'Address;
Status : SPI_Status;
begin
LCfg.Opcode := Opcode_Cfg_DioIrq;
CheckDeviceReady;
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
NSS_Deassert;
end Cfg_DioIrq;
procedure Set_Sleep (Cfg : Set_Sleep_Message)
is
Msg : SPI_Data_8b (1 .. Cfg'Size / 8);
LCfg : Set_Sleep_Message := Cfg;
for Msg'Address use LCfg'Address;
Status : SPI_Status;
begin
LCfg.Opcode := Opcode_Set_Sleep;
CheckDeviceReady;
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
NSS_Deassert;
end Set_Sleep;
procedure LoRa_Set_ModulationParams (Params : LoRa_Mod_Params_Message)
is
Msg : SPI_Data_8b (1 .. Params'Size / 8);
LParams : LoRa_Mod_Params_Message := Params;
for Msg'Address use LParams'Address;
Status : SPI_Status;
begin
LParams.Opcode := Opcode_Set_ModulationParams;
CheckDeviceReady;
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
NSS_Deassert;
end LoRa_Set_ModulationParams;
procedure Swap16 (X : in out UInt16)
is
begin
X := Shift_Right (X, 8) or Shift_Left (X, 8);
end Swap16;
procedure Swap24 (X : in out UInt24)
is
LX : UInt24 := X;
B : UInt8_Array (1 .. 4);
for LX'Address use B'Address;
for LX'Alignment use 1;
begin
B := (B (4), B (3), B (2), B (1));
X := LX;
end Swap24;
procedure Swap32 (X : in out UInt32)
is
LX : UInt32 := X;
B : UInt8_Array (1 .. 4);
for LX'Address use B'Address;
for LX'Alignment use 1;
begin
B := (B (4), B (3), B (2), B (1));
X := LX;
end Swap32;
procedure LoRa_Set_PacketParams (Params : LoRa_Set_PacketParams_Message)
is
Msg : SPI_Data_8b (1 .. Params'Size / 8);
LParams : LoRa_Set_PacketParams_Message := Params;
for Msg'Address use LParams'Address;
Status : SPI_Status;
begin
Swap16 (LParams.PreambleLength);
LParams.Opcode := Opcode_Set_PacketParams;
CheckDeviceReady;
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
NSS_Deassert;
end LoRa_Set_PacketParams;
procedure Set_StopRxTimerOnPreamble (Choice : Set_StopRxTimerOnPreamble_Selection)
is
Msg : SPI_Data_8b (1 .. 2);
Status : SPI_Status;
begin
Msg (1) := Opcode_Set_StopRxTimerOnPreamble;
Msg (2) := Choice'Enum_Rep;
CheckDeviceReady;
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
NSS_Deassert;
end Set_StopRxTimerOnPreamble;
procedure Set_LoRaSymbTimeout (NumberOfSymbols : UInt8)
is
Msg : SPI_Data_8b (1 .. 2);
Status : SPI_Status;
begin
Msg (1) := Opcode_Set_LoRaSymbTimeout;
Msg (2) := NumberOfSymbols;
CheckDeviceReady;
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
NSS_Deassert;
end Set_LoRaSymbTimeout;
procedure Set_RfFrequency (Freq : Set_RfFrequency_Message)
is
Msg : SPI_Data_8b (1 .. Freq'Size / 8);
Tmp : SPI_Data_8b (1 .. 4);
Status : SPI_Status;
LF : aliased Frequency := Freq.F;
for LF'Address use Tmp (1)'Address;
for LF'Alignment use 1;
begin
Msg (1) := Opcode_Set_RfFrequency;
-- Trouble swapping this one... (tried in the record type)
Msg := (Opcode_Set_RfFrequency, Tmp (4), Tmp (3), Tmp (2), Tmp (1));
CheckDeviceReady;
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
NSS_Deassert;
end Set_RfFrequency;
procedure Set_Rx (Timeout : UInt24)
is
Msg : SPI_Data_8b (1 .. 4);
Tmp : SPI_Data_8b (1 .. 4);
Status : SPI_Status;
LTimeout : aliased UInt32 := UInt32 (Timeout);
for LTimeout'Address use Tmp (1)'Address;
for LTimeout'Alignment use 1;
begin
Msg (1) := Opcode_Set_Rx;
-- Trouble swapping this one... (tried in the record type)
Msg := (Opcode_Set_Rx, Tmp (3), Tmp (2), Tmp (1));
CheckDeviceReady;
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
NSS_Deassert;
end Set_Rx;
procedure Set_Tx (Timeout : UInt24)
is
Msg : SPI_Data_8b (1 .. 4);
Tmp : SPI_Data_8b (1 .. 4);
Status : SPI_Status;
LTimeout : aliased UInt32 := UInt32 (Timeout);
for LTimeout'Address use Tmp (1)'Address;
for LTimeout'Alignment use 1;
begin
Msg (1) := Opcode_Set_Tx;
-- Trouble swapping this one... (tried in the record type)
Msg := (Opcode_Set_Tx, Tmp (3), Tmp (2), Tmp (1));
CheckDeviceReady;
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
NSS_Deassert;
end Set_Tx;
function Get_IrqStatus (RFStatus : out Subghz_Status) return UInt16
is
Msg : SPI_Data_8b (1 .. 1);
Reply : SPI_Data_8b (1 .. 3);
Status : SPI_Status;
begin
Msg (1) := Opcode_Get_IrqStatus;
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
Receive (SubGhzPhyPort.all, Reply, Status);
NSS_Deassert;
RFStatus := Reply (1);
return Shift_Left (UInt16 (Reply (2)), 8) or UInt16 (Reply (3));
end Get_IrqStatus;
procedure Clr_IrqStatus (IrqStatus : UInt16)
is
Status : SPI_Status;
Msg : SPI_Data_8b (1 .. 3);
LStat : UInt16 := IrqStatus;
for LStat'Address use Msg (2)'Address;
for LStat'Alignment use 1;
Tmp : UInt8;
begin
Msg (1) := Opcode_Clr_IrqStatus;
Tmp := Msg (2);
Msg (2) := Msg (3);
Msg (3) := Tmp;
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
NSS_Deassert;
end Clr_IrqStatus;
procedure Get_RxBufferStatus (RFStatus : out Subghz_Status;
RxPayloadLength : out UInt8;
RxStartBufferPointer : out UInt8)
is
Msg : SPI_Data_8b (1 .. 1);
Reply : SPI_Data_8b (1 .. 3);
Status : SPI_Status;
begin
Msg (1) := Opcode_Get_RxBufferStatus;
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
Receive (SubGhzPhyPort.all, Reply, Status);
NSS_Deassert;
RFStatus := Reply (1);
RxPayloadLength := Reply (2);
RxStartBufferPointer := Reply (3);
end Get_RxBufferStatus;
procedure Read_Buffer (Offset : UInt8;
RFStatus : out Subghz_Status;
Buffer : out SPI_Data_8b)
is
Msg : SPI_Data_8b (1 .. 2);
Reply : SPI_Data_8b (1 .. 1);
Status : SPI_Status;
begin
Msg (1) := Opcode_Read_Buffer;
Msg (2) := Offset;
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
Receive (SubGhzPhyPort.all, Reply, Status);
Receive (SubGhzPhyPort.all, Buffer, Status);
NSS_Deassert;
RFStatus := Reply (1);
end Read_Buffer;
procedure LoRa_Get_Stats (RFStatus : out Subghz_Status;
NbPktReceived : out UInt16;
NbPktCrcError : out UInt16;
NbPktLengthError : out UInt16)
is
Msg : SPI_Data_8b (1 .. 1);
Reply : SPI_Data_8b (1 .. 1 + (3 * 2));
Status : SPI_Status;
begin
Msg (1) := Opcode_Get_Stats;
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
Receive (SubGhzPhyPort.all, Reply, Status);
NSS_Deassert;
RFStatus := Reply (1);
NbPktReceived := Shift_Left (UInt16 (Reply (2)), 8) or UInt16 (Reply (3));
NbPktCrcError := Shift_Left (UInt16 (Reply (4)), 8) or UInt16 (Reply (5));
NbPktLengthError := Shift_Left (UInt16 (Reply (6)), 8) or UInt16 (Reply (7));
end LoRa_Get_Stats;
procedure Reset_Stats
is
Msg : SPI_Data_8b (1 .. 7);
Status : SPI_Status;
begin
Msg := (Opcode_Reset_Stats, others => 0);
NSS_Assert;
Transmit (SubGhzPhyPort.all, Msg, Status);
NSS_Deassert;
end Reset_Stats;
procedure Toggle_TxRx
is
begin
-- Set_RfFrequency ((F => 915.0E6, others => <>));
Set_Tx (0);
-- Set_RfFrequency ((F => 915.0E6, others => <>));
Set_Rx (0);
end Toggle_TxRx;
procedure SubGhzRF_Init
is
RFStat : Subghz_Status;
X : UInt8;
Irq : UInt16;
begin
Set_Standby (RC_13_MHz);
Set_TcxoMode ((Trim => V_1_7,
Timeout => 640, -- 10ms (X * 15.625us)
others => <>));
Write_Register ((Address => 16#0911#,
Value => 0,
others => <>));
Calibrate ((ImageCalibration => Enabled,
RF_ADC_BulkP_Cal => Enabled,
RF_ADC_BulkN_Cal => Enabled,
RF_ADC_Pulse_Cal => Enabled,
RF_PLL_Cal => Enabled,
Sub_GHz_RC13Mhz => Enabled,
Sub_GHz_RC64Khz => Enabled,
others => <>));
Set_PacketType ((PacketType => LoRa_Packet, others => <>));
Write_Register ((Address => 16#0740#, Value => 20, others => <>));
Write_Register ((Address => 16#0741#, Value => 36, others => <>));
Set_RegulatorMode (LDO);
Set_BufferBaseAddress ((Tx_BaseAddress => 0, Rx_BaseAddress => 0, others => <>));
Set_PaConfig ((
PaDutyCycle => Pa_DC_4,
HpMax => HpMax_0,
PaSel => LP_PA,
others => <>));
Write_Register ((Address => 16#08e7#, Value => 24, others => <>));
Set_TxParams ((Power => 0,
RampTime => Microsecs_200,
others => <>));
Cfg_DioIrq ((Irq_Mask => 16#ffff#,
Irq_Mask1 => 16#ffff#,
Irq_Mask2 => 0,
Irq_Mask3 => 0,
others => <>));
Set_Sleep ((StartSel => Warm_Startup,
SleepCfg => Disabled,
others => <>));
delay until Clock + Milliseconds (100);
LoRa_Set_ModulationParams ((SpreadFactor => Factor_7,
BandWidth => BandWidth_125Khz,
CodingRate => CR_FEC_4_5,
Low_Data_Rate_Opt => Disabled,
others => <>
));
LoRa_Set_PacketParams ((
PreambleLength => 8,
HeaderType => Explicit,
PayloadLength => 16#ff#,
Crc => Enabled,
InvertIQ => Standard,
others => <>
));
Read_Register ((Address => 16#0889#, others => <>), RFStatus => RFStat, Value => X); -- [37]
Write_Register ((Address => 16#0889#, Value => X, others => <>)); -- Which bit?
Set_TxParams ((Power => 14,
RampTime => Microsecs_40,
others => <>));
Set_StopRxTimerOnPreamble (Stop_On_Sync);
Set_PacketType ((PacketType => LoRa_Packet, others => <>));
LoRa_Set_ModulationParams ((SpreadFactor => Factor_7,
BandWidth => BandWidth_125Khz,
CodingRate => CR_FEC_4_5,
Low_Data_Rate_Opt => Disabled,
others => <>
));
Set_LoRaSymbTimeout (NumberOfSymbols => 0);
Read_Register ((Address => 16#0736#, others => <>), RFStatus => RFStat, Value => X); -- [13]
Write_Register ((Address => 16#0736#, Value => X, others => <>)); -- what bit
LoRa_Set_PacketParams ((
PreambleLength => 8,
HeaderType => Explicit,
PayloadLength => 16#40#,
Crc => Enabled,
InvertIQ => Standard,
others => <>
));
Set_RfFrequency ((F => 915.0E6, others => <>));
Reset_Stats;
Set_Rx (Timeout => 2_000_000); -- > 30secs
-- Set_Rx (Timeout => 0);
end SubGhzRF_Init;
end STM32.SubGhzRF;
|
--Constants
package Constants is
-- constants for use by other packages
end Constants;
|
-- Copyright (c) 2016 onox <denkpadje@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 Ahven.Framework;
package Test_Tokenizers is
type Test is new Ahven.Framework.Test_Case with null record;
overriding
procedure Initialize (T : in out Test);
private
-- Keyword
procedure Test_Null_Token;
procedure Test_True_Token;
procedure Test_False_Token;
-- String
procedure Test_Empty_String_Token;
procedure Test_Non_Empty_String_Token;
procedure Test_Number_String_Token;
procedure Test_Escaped_Character_String_Token;
procedure Test_Escaped_Quotation_Solidus_String_Token;
-- Integer/float number
procedure Test_Zero_Number_Token;
procedure Test_Integer_Number_Token;
procedure Test_Float_Number_Token;
procedure Test_Negative_Float_Number_Token;
procedure Test_Integer_Exponent_Number_Token;
procedure Test_Float_Exponent_Number_Token;
procedure Test_Float_Negative_Exponent_Number_Token;
-- Array
procedure Test_Empty_Array_Tokens;
procedure Test_One_Element_Array_Tokens;
procedure Test_Two_Elements_Array_Tokens;
-- Object
procedure Test_Empty_Object_Tokens;
procedure Test_One_Pair_Object_Tokens;
procedure Test_Two_Pairs_Object_Tokens;
-- Exceptions
procedure Test_Control_Character_String_Exception;
procedure Test_Unexpected_Escaped_Character_String_Exception;
procedure Test_Minus_Number_EOF_Exception;
procedure Test_Minus_Number_Exception;
procedure Test_End_Dot_Number_Exception;
procedure Test_End_Exponent_Number_Exception;
procedure Test_End_Dot_Exponent_Number_Exception;
procedure Test_End_Exponent_Minus_Number_Exception;
procedure Test_Prefixed_Plus_Number_Exception;
procedure Test_Leading_Zeroes_Integer_Number_Exception;
procedure Test_Leading_Zeroes_Float_Number_Exception;
procedure Test_Incomplete_True_Text_Exception;
procedure Test_Incomplete_False_Text_Exception;
procedure Test_Incomplete_Null_Text_Exception;
procedure Test_Unknown_Keyword_Text_Exception;
end Test_Tokenizers;
|
with Ada.Text_IO; use Ada.Text_IO;
with Test_Directories; use Test_Directories;
with File_Block_Drivers; use File_Block_Drivers;
with File_IO; use File_IO;
with Filesystem.FAT; use Filesystem.FAT;
with HAL.Filesystem;
with GNAT.MD5; use GNAT.MD5;
with Ada.Streams;
with Compare_Files;
procedure TC_FAT_Write is
use type HAL.Filesystem.Status_Code;
package Hash renames GNAT.MD5;
Test_File_Size : constant := 2000;
function Write_File (Filename : String) return String;
function Check_File (Filename : String; Md5 : String) return Boolean;
function Delete_Tree (Filename : String) return Boolean;
function Check_Read_Test_Dir return Boolean;
----------------
-- Write_File --
----------------
function Write_File (Filename : String) return String is
FD : File_Descriptor;
Status : Status_Code;
Context : aliased GNAT.MD5.Context := GNAT.MD5.Initial_Context;
Buffer : Ada.Streams.Stream_Element_Array (1 .. Test_File_Size);
Last : Ada.Streams.Stream_Element_Offset;
Size : File_Size;
begin
Status := Open (FD, Filename, Write_Only);
if Status /= OK then
Put_Line ("Cannot open file: '" & Filename & "'");
Put_Line ("Status: " & Status'Img);
return "";
end if;
Size := Buffer'Length;
Buffer := (others => 42);
Last := Ada.Streams.Stream_Element_Offset (Size);
Hash.Update (Context, Buffer (1 .. Last));
if Write (FD, Buffer'Address, Size) /= Size then
Put_Line ("Cannot write file: '" & Filename & "'");
Put_Line ("Status: " & Status'Img);
return "";
end if;
Close (FD);
return Hash.Digest (Context);
end Write_File;
----------------
-- Check_File --
----------------
function Check_File (Filename : String;
Md5 : String)
return Boolean
is
FD : File_Descriptor;
Status : Status_Code;
begin
Status := Open (FD, Filename, Read_Only);
if Status /= OK then
Put_Line ("Cannot open file: '" & Filename & "'");
Put_Line ("Status: " & Status'Img);
return False;
end if;
if Size (FD) /= Test_File_Size then
Put_Line ("Error: wrong file size: " & Size (FD)'Img &
" (expected " & Test_File_Size'Img & ")");
return False;
end if;
declare
Hash_Str : constant String := Compare_Files.Compute_Hash (FD);
begin
if Hash_Str /= Md5 then
Put_Line ("Error: Hash is different than filename");
return False;
else
return True;
end if;
end;
end Check_File;
-----------------
-- Delete_Tree --
-----------------
function Delete_Tree (Filename : String) return Boolean is
Dir : Directory_Descriptor;
Status : Status_Code;
begin
Status := Open (Dir, Filename);
if Status /= OK then
Put_Line ("Cannot open directory: '" & Filename & "'");
Put_Line ("Status: " & Status'Img);
return False;
end if;
loop
declare
Ent : constant Directory_Entry := Read (Dir);
begin
if Ent /= Invalid_Dir_Entry then
declare
Sub : constant String := Filename & "/" & Ent.Name;
begin
if Ent.Name = "." or else Ent.Name = ".." then
null; -- do nothing
elsif Ent.Subdirectory then
if not Delete_Tree (Sub) then
return False;
end if;
elsif not Ent.Symlink then
Status := Unlink (Sub);
if Status /= OK then
Put_Line ("Cannot delete file: '" & Sub & "' :" &
Status'Img);
return False;
end if;
end if;
end;
else
exit;
end if;
end;
end loop;
Status := Remove_Directory (Filename);
if Status /= OK then
Put_Line ("Cannot delete dir: '" & Filename & "' :" & Status'Img);
return False;
else
return True;
end if;
end Delete_Tree;
-------------------------
-- Check_Read_Test_Dir --
-------------------------
function Check_Read_Test_Dir return Boolean is
Dir : Directory_Descriptor;
Status : Status_Code;
Filename : constant String := "/disk_img/read_test/";
begin
Status := Open (Dir, Filename);
if Status /= OK then
Put_Line ("Cannot open directory: '" & Filename & "'");
Put_Line ("Status: " & Status'Img);
return False;
else
Close (Dir);
return True;
end if;
end Check_Read_Test_Dir;
Disk_Img_Path : constant String := "/" & Test_Dir_Mount_Name & "/fat.fs";
Copy_Disk_Img_Path : constant String := "/" & Test_Dir_Mount_Name & "/obj/fat.fs.copy";
Disk : aliased File_Block_Driver;
FAT_FS : access FAT_Filesystem;
Status : Status_Code;
HALFS_Status : HAL.Filesystem.Status_Code;
begin
Test_Directories.Mount_Test_Directory;
-- Make a copy of the disk image
if Copy_File (Disk_Img_Path, Copy_Disk_Img_Path) /= OK then
raise Program_Error with "Cannot copy disk image";
end if;
Status := Disk.Open (Copy_Disk_Img_Path, Read_Write);
if Status /= OK then
Put_Line ("Cannot open disk image '" & Copy_Disk_Img_Path & "': " &
Status'Img);
return;
end if;
declare
begin
FAT_FS := new FAT_Filesystem;
HALFS_Status := Open (Controller => Disk'Unchecked_Access,
LBA => 0,
FS => FAT_FS.all);
if HALFS_Status /= HAL.Filesystem.OK then
Put_Line ("Cannot open FAT FS - Status:" & HALFS_Status'Img);
return;
end if;
Status := Mount_Volume (Mount_Point => "disk_img",
FS => FAT_FS);
if Status /= OK then
Put_Line ("Cannot mount volume - Status: " & Status'Img);
return;
end if;
-- Check if the "read_test" directory is here
if Check_Read_Test_Dir then
Put_Line ("PASS");
else
Put_Line ("FAIL");
end if;
-- Make some room for the file that we will create
if not Delete_Tree ("/disk_img/read_test/lvl1_b") then
Put_Line ("Cannot delete directory lvl1_b");
end if;
if not Delete_Tree ("/disk_img/read_test/lvl1_c") then
Put_Line ("Cannot delete directory lvl1_c");
end if;
if Check_File (Filename => "/disk_img/write_test",
Md5 => Write_File ("/disk_img/write_test"))
then
Put_Line ("PASS");
else
Put_Line ("FAIL");
end if;
-- Check if the "read_test" directory is still here
if Check_Read_Test_Dir then
Put_Line ("PASS");
else
Put_Line ("FAIL");
end if;
end;
end TC_FAT_Write;
|
with Interfaces.C;
package ZMQ_Constants is
-- Errors
ENOTSUP : constant Interfaces.C.int := 45;
EPROTONOSUPPORT : constant Interfaces.C.int := 43;
ENOBUFS : constant Interfaces.C.int := 55;
ENETDOWN : constant Interfaces.C.int := 50;
EADDRINUSE : constant Interfaces.C.int := 48;
EADDRNOTAVAIL : constant Interfaces.C.int := 49;
ECONNREFUSED : constant Interfaces.C.int := 61;
EINPROGRESS : constant Interfaces.C.int := 36;
ENOTSOCK : constant Interfaces.C.int := 38;
EMSGSIZE : constant Interfaces.C.int := 40;
EAFNOSUPPORT : constant Interfaces.C.int := 47;
ENETUNREACH : constant Interfaces.C.int := 51;
ECONNABORTED : constant Interfaces.C.int := 53;
ECONNRESET : constant Interfaces.C.int := 54;
ENOTCONN : constant Interfaces.C.int := 57;
ETIMEDOUT : constant Interfaces.C.int := 60;
EHOSTUNREACH : constant Interfaces.C.int := 65;
ENETRESET : constant Interfaces.C.int := 52;
EFSM : constant Interfaces.C.int := 156384763;
ENOCOMPATPROTO : constant Interfaces.C.int := 156384764;
ETERM : constant Interfaces.C.int := 156384765;
EMTHREAD : constant Interfaces.C.int := 156384766;
-- Context
ZMQ_IO_THREADS : constant Interfaces.C.int := 1;
ZMQ_MAX_SOCKETS : constant Interfaces.C.int := 2;
ZMQ_IO_THREADS_DFLT : constant Interfaces.C.int := 1;
ZMQ_MAX_SOCKETS_DFLT : constant Interfaces.C.int := 1023;
-- Socket Types
ZMQ_PAIR : constant Interfaces.C.int := 0;
ZMQ_PUB : constant Interfaces.C.int := 1;
ZMQ_SUB : constant Interfaces.C.int := 2;
ZMQ_REQ : constant Interfaces.C.int := 3;
ZMQ_REP : constant Interfaces.C.int := 4;
ZMQ_DEALER : constant Interfaces.C.int := 5;
ZMQ_ROUTER : constant Interfaces.C.int := 6;
ZMQ_PULL : constant Interfaces.C.int := 7;
ZMQ_PUSH : constant Interfaces.C.int := 8;
ZMQ_XPUB : constant Interfaces.C.int := 9;
ZMQ_XSUB : constant Interfaces.C.int := 10;
ZMQ_STREAM : constant Interfaces.C.int := 11;
-- Socket Options
ZMQ_AFFINITY : constant Interfaces.C.int := 4;
ZMQ_IDENTITY : constant Interfaces.C.int := 5;
ZMQ_SUBSCRIBE : constant Interfaces.C.int := 6;
ZMQ_UNSUBSCRIBE : constant Interfaces.C.int := 7;
ZMQ_RATE : constant Interfaces.C.int := 8;
ZMQ_RECOVERY_IVL : constant Interfaces.C.int := 9;
ZMQ_SNDBUF : constant Interfaces.C.int := 11;
ZMQ_RCVBUF : constant Interfaces.C.int := 12;
ZMQ_RCVMORE : constant Interfaces.C.int := 13;
ZMQ_FD : constant Interfaces.C.int := 14;
ZMQ_EVENTS : constant Interfaces.C.int := 15;
ZMQ_TYPE : constant Interfaces.C.int := 16;
ZMQ_LINGER : constant Interfaces.C.int := 17;
ZMQ_RECONNECT_IVL : constant Interfaces.C.int := 18;
ZMQ_BACKLOG : constant Interfaces.C.int := 19;
ZMQ_RECONNECT_IVL_MAX : constant Interfaces.C.int := 21;
ZMQ_MAXMSGSIZE : constant Interfaces.C.int := 22;
ZMQ_SNDHWM : constant Interfaces.C.int := 23;
ZMQ_RCVHWM : constant Interfaces.C.int := 24;
ZMQ_MULTICAST_HOPS : constant Interfaces.C.int := 25;
ZMQ_RCVTIMEO : constant Interfaces.C.int := 27;
ZMQ_SNDTIMEO : constant Interfaces.C.int := 28;
ZMQ_LAST_ENDPOINT : constant Interfaces.C.int := 32;
ZMQ_ROUTER_MANDATORY : constant Interfaces.C.int := 33;
ZMQ_TCP_KEEPALIVE : constant Interfaces.C.int := 34;
ZMQ_TCP_KEEPALIVE_CNT : constant Interfaces.C.int := 35;
ZMQ_TCP_KEEPALIVE_IDLE : constant Interfaces.C.int := 36;
ZMQ_TCP_KEEPALIVE_INTVL : constant Interfaces.C.int := 37;
ZMQ_TCP_ACCEPT_FILTER : constant Interfaces.C.int := 38;
ZMQ_IMMEDIATE : constant Interfaces.C.int := 39;
ZMQ_XPUB_VERBOSE : constant Interfaces.C.int := 40;
ZMQ_ROUTER_RAW : constant Interfaces.C.int := 41;
ZMQ_IPV6 : constant Interfaces.C.int := 42;
ZMQ_MECHANISM : constant Interfaces.C.int := 43;
ZMQ_PLAIN_SERVER : constant Interfaces.C.int := 44;
ZMQ_PLAIN_USERNAME : constant Interfaces.C.int := 45;
ZMQ_PLAIN_PASSWORD : constant Interfaces.C.int := 46;
ZMQ_CURVE_SERVER : constant Interfaces.C.int := 47;
ZMQ_CURVE_PUBLICKEY : constant Interfaces.C.int := 48;
ZMQ_CURVE_SECRETKEY : constant Interfaces.C.int := 49;
ZMQ_CURVE_SERVERKEY : constant Interfaces.C.int := 50;
ZMQ_PROBE_ROUTER : constant Interfaces.C.int := 51;
ZMQ_REQ_CORRELATE : constant Interfaces.C.int := 52;
ZMQ_REQ_RELAXED : constant Interfaces.C.int := 53;
ZMQ_CONFLATE : constant Interfaces.C.int := 54;
ZMQ_ZAP_DOMAIN : constant Interfaces.C.int := 55;
-- Message Options
ZMQ_MORE : constant Interfaces.C.int := 1;
ZMQ_SRCFD : constant Interfaces.C.int := 2;
ZMQ_SHARED : constant Interfaces.C.int := 3;
-- Send/Recv Flags
ZMQ_DONTWAIT : constant Interfaces.C.unsigned := 1;
ZMQ_SNDMORE : constant Interfaces.C.unsigned := 2;
-- Security Options
ZMQ_NULL : constant Interfaces.C.int := 0;
ZMQ_PLAIN : constant Interfaces.C.int := 1;
ZMQ_CURVE : constant Interfaces.C.int := 2;
-- Socket Event Flags
ZMQ_EVENT_CONNECTED : constant Interfaces.C.unsigned := 1;
ZMQ_EVENT_CONNECT_DELAYED : constant Interfaces.C.unsigned := 2;
ZMQ_EVENT_CONNECT_RETRIED : constant Interfaces.C.unsigned := 4;
ZMQ_EVENT_LISTENING : constant Interfaces.C.unsigned := 8;
ZMQ_EVENT_BIND_FAILED : constant Interfaces.C.unsigned := 16;
ZMQ_EVENT_ACCEPTED : constant Interfaces.C.unsigned := 32;
ZMQ_EVENT_ACCEPT_FAILED : constant Interfaces.C.unsigned := 64;
ZMQ_EVENT_CLOSED : constant Interfaces.C.unsigned := 128;
ZMQ_EVENT_CLOSE_FAILED : constant Interfaces.C.unsigned := 256;
ZMQ_EVENT_DISCONNECTED : constant Interfaces.C.unsigned := 512;
ZMQ_EVENT_MONITOR_STOPPED : constant Interfaces.C.unsigned := 1024;
ZMQ_EVENT_ALL : constant Interfaces.C.unsigned := 2047;
-- I/O Multiplexing
ZMQ_POLLIN : constant Interfaces.C.unsigned := 1;
ZMQ_POLLOUT : constant Interfaces.C.unsigned := 2;
ZMQ_POLLERR : constant Interfaces.C.unsigned := 4;
end ZMQ_Constants;
|
package body Opt48_Pkg1 is
function G return Rec is
begin
return (32, "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA");
end G;
X : Rec := F;
Y : Rec := G;
Z : Rec := F;
function Get_Z return Rec is
begin
return Z;
end;
end Opt48_Pkg1;
|
with Ada.Text_IO; use Ada.Text_IO;
package body xample1 is
procedure SayWelcome (x : in Integer) is
begin
for i in 1 .. x loop
Put ("We say welcome to you!!!");
-- put(i);
Put_Line (" Number " & Integer'Image (i));
-- new_line;
end loop;
end SayWelcome;
end xample1;
|
With Ada.Text_IO; Use Ada.Text_IO;
Procedure BubbleSort is
numeros: array(1..15) of Integer;
I : Integer;
buffer: Integer;
-- Leitura String
function Get_String return String is
Line : String (1 .. 1_000);
Last : Natural;
begin
Get_Line (Line, Last);
return Line (1 .. Last);
end Get_String;
-- Leitura Integer
function Get_Integer return Integer is
S : constant String := Get_String;
begin
return Integer'Value (S);
end Get_Integer;
-- Lê 15 elementos do array
procedure Faz_Leitura is
begin
for I in Integer range 1 .. 15 loop
numeros(I) := Get_Integer;
end loop;
end Faz_Leitura;
begin
Faz_Leitura;
for downStep in Integer range 1 .. 15 loop
I := 15 - downStep;
for J in Integer range 1 .. I loop
if numeros(J) > numeros(J + 1) then
buffer := numeros(J);
numeros(J) := numeros(J + 1);
numeros(J + 1) := buffer;
end if;
end loop;
end loop;
for Index in Integer range 1 .. 15 loop
Put_Line(Integer'Image(numeros(Index)));
end loop;
end BubbleSort;
|
with Actors, Game_Maps, GUIs;
with Libtcod, Libtcod.Console, Libtcod.Maps, Libtcod.Input;
use Actors, Game_Maps, Libtcod;
package Engines is
type Game_Status is
(Status_Idle, Status_New_Turn, Status_Victory, Status_Defeat);
subtype Endgame_Status is Game_Status range Status_Victory .. Status_Defeat;
subtype Valid_Key_Type is Input.Key_Type
with Static_Predicate => Valid_Key_Type in Input.Arrow_Key_Type;
type Engine(width : Maps.X_Pos; height : Maps.Y_Pos) is tagged limited record
map : Game_Map(width, height);
gui : GUIs.GUI;
actor_list : Actor_Vector;
player_id : Actor_Id;
fov_radius : Maps.Radius;
status : Game_Status;
last_key_type : Valid_Key_Type;
end record;
function make_engine(w : Width; h : Height) return Engine;
procedure update(self : in out Engine);
procedure render(self : in out Engine; screen : in out Console.Screen);
function can_walk(self : Engine; x : Maps.X_Pos; y : Maps.Y_Pos) return Boolean;
function player(self : in out Engine) return Actor_Ref;
end Engines;
|
with
collada.Document;
procedure launch_parse_Box
--
-- Loads an xml file, parses it into a collada document.
--
is
the_Asset : collada.Document.item := collada.document.to_Document ("./box.dae")
with unreferenced;
begin
null;
end launch_parse_Box;
|
with Ada.Numerics.Elementary_Functions;
use Ada.Numerics.Elementary_Functions;
with Ada.Numerics.Big_Numbers.Big_Integers;
use Ada.Numerics.Big_Numbers.Big_Integers;
package body Primes is
function Is_Prime (N : Natural) return Boolean is
Limit : constant Natural := Natural (Sqrt (Float (N)));
begin
if N < 2 then return False; end if;
for I in 2 .. Limit loop
if N mod I = 0 then return False; end if;
end loop;
return True;
end Is_Prime;
function Is_Prime (N : Big_Natural) return Boolean is
Limit : constant Big_Natural := N / To_Big_Integer (2);
I : Big_Natural := To_Big_Integer (2);
begin
if N < To_Big_Integer (2) then return False; end if;
while I < Limit loop
if N mod I = To_Big_Integer (0) then return False; end if;
I := I + To_Big_Integer (1);
end loop;
return True;
end Is_Prime;
function Get_Primes (Limit : Natural) return Prime_Vectors.Vector is
Result : Prime_Vectors.Vector;
begin
for I in 2 .. Limit loop
if Is_Prime (I) then Result.Append (I); end if;
end loop;
return Result;
end Get_Primes;
function Get_Primes (Limit : Big_Natural) return Big_Prime_Vectors.Vector is
I : Big_Natural := To_Big_Integer (2);
Result : Big_Prime_Vectors.Vector;
begin
while I < Limit loop
null;
I := I + To_Big_Integer (1);
if Is_Prime (I) then Result.Append (I); end if;
end loop;
return Result;
end Get_Primes;
end Primes;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- A component represents a modular part of a system that encapsulates its
-- contents and whose manifestation is replaceable within its environment.
--
-- In the namespace of a component, all model elements that are involved in
-- or related to its definition are either owned or imported explicitly. This
-- may include, for example, use cases and dependencies (e.g. mappings),
-- packages, components, and artifacts.
------------------------------------------------------------------------------
with AMF.UML.Classes;
limited with AMF.UML.Classifiers;
limited with AMF.UML.Component_Realizations.Collections;
limited with AMF.UML.Interfaces.Collections;
limited with AMF.UML.Packageable_Elements.Collections;
package AMF.UML.Components is
pragma Preelaborate;
type UML_Component is limited interface
and AMF.UML.Classes.UML_Class;
type UML_Component_Access is
access all UML_Component'Class;
for UML_Component_Access'Storage_Size use 0;
not overriding function Get_Is_Indirectly_Instantiated
(Self : not null access constant UML_Component)
return Boolean is abstract;
-- Getter of Component::isIndirectlyInstantiated.
--
-- isIndirectlyInstantiated : Boolean {default = true} The kind of
-- instantiation that applies to a Component. If false, the component is
-- instantiated as an addressable object. If true, the Component is
-- defined at design-time, but at run-time (or execution-time) an object
-- specified by the Component does not exist, that is, the component is
-- instantiated indirectly, through the instantiation of its realizing
-- classifiers or parts. Several standard stereotypes use this meta
-- attribute (e.g., «specification», «focus», «subsystem»).
not overriding procedure Set_Is_Indirectly_Instantiated
(Self : not null access UML_Component;
To : Boolean) is abstract;
-- Setter of Component::isIndirectlyInstantiated.
--
-- isIndirectlyInstantiated : Boolean {default = true} The kind of
-- instantiation that applies to a Component. If false, the component is
-- instantiated as an addressable object. If true, the Component is
-- defined at design-time, but at run-time (or execution-time) an object
-- specified by the Component does not exist, that is, the component is
-- instantiated indirectly, through the instantiation of its realizing
-- classifiers or parts. Several standard stereotypes use this meta
-- attribute (e.g., «specification», «focus», «subsystem»).
not overriding function Get_Packaged_Element
(Self : not null access constant UML_Component)
return AMF.UML.Packageable_Elements.Collections.Set_Of_UML_Packageable_Element is abstract;
-- Getter of Component::packagedElement.
--
-- The set of PackageableElements that a Component owns. In the namespace
-- of a component, all model elements that are involved in or related to
-- its definition may be owned or imported explicitly. These may include
-- e.g. Classes, Interfaces, Components, Packages, Use cases, Dependencies
-- (e.g. mappings), and Artifacts.
not overriding function Get_Provided
(Self : not null access constant UML_Component)
return AMF.UML.Interfaces.Collections.Set_Of_UML_Interface is abstract;
-- Getter of Component::provided.
--
-- The interfaces that the component exposes to its environment. These
-- interfaces may be Realized by the Component or any of its
-- realizingClassifiers, or they may be the Interfaces that are provided
-- by its public Ports.
not overriding function Get_Realization
(Self : not null access constant UML_Component)
return AMF.UML.Component_Realizations.Collections.Set_Of_UML_Component_Realization is abstract;
-- Getter of Component::realization.
--
-- The set of Realizations owned by the Component. Realizations reference
-- the Classifiers of which the Component is an abstraction; i.e., that
-- realize its behavior.
not overriding function Get_Required
(Self : not null access constant UML_Component)
return AMF.UML.Interfaces.Collections.Set_Of_UML_Interface is abstract;
-- Getter of Component::required.
--
-- The interfaces that the component requires from other components in its
-- environment in order to be able to offer its full set of provided
-- functionality. These interfaces may be used by the Component or any of
-- its realizingClassifiers, or they may be the Interfaces that are
-- required by its public Ports.
not overriding function Provided
(Self : not null access constant UML_Component)
return AMF.UML.Interfaces.Collections.Set_Of_UML_Interface is abstract;
-- Operation Component::provided.
--
-- Missing derivation for Component::/provided : Interface
not overriding function Realized_Interfaces
(Self : not null access constant UML_Component;
Classifier : AMF.UML.Classifiers.UML_Classifier_Access)
return AMF.UML.Interfaces.Collections.Set_Of_UML_Interface is abstract;
-- Operation Component::realizedInterfaces.
--
-- Utility returning the set of realized interfaces of a component.
not overriding function Required
(Self : not null access constant UML_Component)
return AMF.UML.Interfaces.Collections.Set_Of_UML_Interface is abstract;
-- Operation Component::required.
--
-- Missing derivation for Component::/required : Interface
not overriding function Used_Interfaces
(Self : not null access constant UML_Component;
Classifier : AMF.UML.Classifiers.UML_Classifier_Access)
return AMF.UML.Interfaces.Collections.Set_Of_UML_Interface is abstract;
-- Operation Component::usedInterfaces.
--
-- Utility returning the set of used interfaces of a component.
end AMF.UML.Components;
|
package BSSNBase.ADM_BSSN is
function adm_gab (gBar : MetricPointArray;
phi : Real)
return MetricPointArray;
function adm_Kab (ABar : ExtcurvPointArray;
gBar : MetricPointArray;
phi : Real;
trK : Real)
return ExtcurvPointArray;
function bssn_phi (gab : MetricPointArray)
return Real;
function bssn_trK (Kab : ExtcurvPointArray;
gab : MetricpointArray)
return Real;
function bssn_gBar (gab : MetricPointArray)
return MetricPointArray;
function bssn_ABar (Kab : ExtcurvPointArray;
gab : MetricPointArray)
return ExtcurvPointArray;
end BSSNBase.ADM_BSSN;
|
-- Copyright (c) 1990 Regents of the University of California.
-- All rights reserved.
--
-- This software was developed by John Self of the Arcadia project
-- at the University of California, Irvine.
--
-- Redistribution and use in source and binary forms are permitted
-- provided that the above copyright notice and this paragraph are
-- duplicated in all such forms and that any documentation,
-- advertising materials, and other materials related to such
-- distribution and use acknowledge that the software was developed
-- by the University of California, Irvine. The name of the
-- University may not be used to endorse or promote products derived
-- from this software without specific prior written permission.
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
-- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-- TITLE character classes routines
-- AUTHOR: John Self (UCI)
-- DESCRIPTION routines for character classes like [abc]
-- $Header: /dc/uc/self/arcadia/aflex/ada/src/RCS/cclB.a,v 1.7 1993/04/27 23:17:15 self Exp $
with Ada.Characters.Conversions;
with Ada.Strings.Unbounded;
with Ada.Strings.Wide_Wide_Maps;
with Misc;
package body CCL is
use Ada.Characters.Conversions;
use Ada.Strings.Unbounded;
use Ada.Strings.Wide_Wide_Maps;
use Ada.Wide_Wide_Text_IO;
-- ccladd - add a single character to a ccl
------------
-- CCLADD --
------------
procedure CCL_Add
(CCLP : Integer;
Ch : Unicode.Unicode_Character)
is
IND, LEN, NEWPOS : INTEGER;
begin
-- Check to see if the character is already in the ccl.
if Is_In (Ch, CCL_Sets (CCLP)) then
return;
end if;
CCL_Sets (CCLP) := CCL_Sets (CCLP) or To_Set (Ch);
LEN := CCLLEN(CCLP);
IND := CCLMAP(CCLP);
NEWPOS := IND + LEN;
if (NEWPOS >= Current_Max_CCL_Table_Size) then
Current_Max_CCL_Table_Size := Current_Max_CCL_Table_Size +
MAX_CCL_TBL_SIZE_INCREMENT;
NUM_REALLOCS := NUM_REALLOCS + 1;
Reallocate_Unicode_Character_Array
(CCLTBL, Current_Max_CCL_Table_Size);
end if;
CCLLEN(CCLP) := LEN + 1;
CCLTBL(NEWPOS) := CH;
end CCL_Add;
-- cclinit - make an empty ccl
function CCLINIT return INTEGER is
begin
LASTCCL := LASTCCL + 1;
if (LASTCCL >= CURRENT_MAXCCLS) then
CURRENT_MAXCCLS := CURRENT_MAXCCLS + MAX_CCLS_INCREMENT;
NUM_REALLOCS := NUM_REALLOCS + 1;
REALLOCATE_INTEGER_ARRAY(CCLMAP, CURRENT_MAXCCLS);
REALLOCATE_INTEGER_ARRAY(CCLLEN, CURRENT_MAXCCLS);
REALLOCATE_INTEGER_ARRAY(CCLNG, CURRENT_MAXCCLS);
Reallocate_Wide_Wide_Character_Set_Array (CCL_Sets, CURRENT_MAXCCLS);
end if;
if (LASTCCL = 1) then
-- we're making the first ccl
CCLMAP(LASTCCL) := 0;
else
-- the new pointer is just past the end of the last ccl. Since
-- the cclmap points to the \first/ character of a ccl, adding the
-- length of the ccl to the cclmap pointer will produce a cursor
-- to the first free space
CCLMAP(LASTCCL) := CCLMAP(LASTCCL - 1) + CCLLEN(LASTCCL - 1);
end if;
CCLLEN(LASTCCL) := 0;
CCLNG(LASTCCL) := 0;
-- ccl's start out life un-negated
return LASTCCL;
end CCLINIT;
-- cclnegate - negate a ccl
procedure CCLNEGATE(CCLP : in INTEGER) is
begin
CCLNG(CCLP) := 1;
end CCLNEGATE;
------------------------
-- List_Character_Set --
------------------------
-- list_character_set - list the members of a set of characters in CCL form
--
-- writes to the given file a character-class representation of those
-- characters present in the given set. A character is present if it
-- has a non-zero value in the set array.
procedure List_Character_Set
(File : Ada.Wide_Wide_Text_IO.File_Type;
CSET : C_SIZE_BOOL_ARRAY)
is
I, START_CHAR : INTEGER;
begin
PUT (File, '[');
I := 1;
while I <= CSIZE loop
if CSET (I) then
START_CHAR := I;
PUT (File, ' ');
PUT
(File,
To_Wide_Wide_String
(To_String
(MISC.Readable_Form (Wide_Wide_Character'Val (I)))));
I := I + 1;
while I <= CSIZE and then CSET(I) loop
I := I + 1;
end loop;
if (I - 1 > START_CHAR) then
-- this was a run
PUT (File, "-");
PUT
(File,
To_Wide_Wide_String
(To_String
(MISC.Readable_Form (Wide_Wide_Character'Val (I - 1)))));
end if;
PUT (File, ' ');
end if;
I := I + 1;
end loop;
PUT (File, ']');
end List_Character_Set;
end CCL;
|
------------------------------------------------------------------------------
-- --
-- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T A S K I N G . I N I T I A L I Z A T I O N --
-- --
-- S p e c --
-- --
-- $Revision$
-- --
-- Copyright (C) 1992-1999, Free Software Foundation, Inc. --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNARL; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package provides overall initialization of the tasking portion of the
-- RTS. This package must be elaborated before any tasking features are used.
-- It also contains initialization for Ada Task Control Block (ATCB) records.
package System.Tasking.Initialization is
procedure Remove_From_All_Tasks_List (T : Task_ID);
-- Remove T from All_Tasks_List.
------------------------------------------------
-- Static (Compile-Time) Configuration Flags --
------------------------------------------------
-- ?????
-- Maybe this does not belong here? Where else?
-- For now, it is here because so is Change_Base_Priority,
-- and the two are used together.
Dynamic_Priority_Support : constant Boolean := True;
-- Should we poll for pending base priority changes at every
-- abort completion point?
---------------------------------
-- Tasking-Specific Soft Links --
---------------------------------
-- These permit us to leave out certain portions of the tasking
-- run-time system if they are not used. They are only used internally
-- by the tasking run-time system.
-- So far, the only example is support for Ada.Task_Attributes.
type Proc_T is access procedure (T : Task_ID);
procedure Finalize_Attributes (T : Task_ID);
procedure Initialize_Attributes (T : Task_ID);
Finalize_Attributes_Link : Proc_T := Finalize_Attributes'Access;
-- should be called with abortion deferred and T.L write-locked
Initialize_Attributes_Link : Proc_T := Initialize_Attributes'Access;
-- should be called with abortion deferred, but holding no locks
-------------------------
-- Abort Defer/Undefer --
-------------------------
-- Defer_Abort defers the affects of low-level abort and priority change
-- in the calling task until a matching Undefer_Abort call is executed.
-- Undefer_Abort DOES MORE than just undo the effects of one call to
-- Defer_Abort. It is the universal "polling point" for deferred
-- processing, including the following:
-- 1) base priority changes
-- 2) exceptions that need to be raised
-- 3) abort/ATC
-- Abort deferral MAY be nested (Self_ID.Deferral_Level is a count),
-- but to avoid waste and undetected errors, it generally SHOULD NOT
-- be nested. The symptom of over-deferring abort is that an exception
-- may fail to be raised, or an abort may fail to take place.
-- Therefore, there are two sets of the inlinable defer/undefer
-- routines, which are the ones to be used inside GNARL.
-- One set allows nesting. The other does not. People who
-- maintain the GNARL should try to avoid using the nested versions,
-- or at least look very critically at the places where they are
-- used.
-- In general, any GNARL call that is potentially blocking, or
-- whose semantics require that it sometimes raise an exception,
-- or that is required to be an abort completion point, must be
-- made with abort Deferral_Level = 1.
-- In general, non-blocking GNARL calls, which may be made from inside
-- a protected action, are likely to need to allow nested abort
-- deferral.
-- With some critical exceptions (which are supposed to be documented),
-- internal calls to the tasking runtime system assume abort is already
-- deferred, and do not modify the deferral level.
-- There is also a set of non-linable defer/undefer routines,
-- for direct call from the compiler. These are not in-lineable
-- because they may need to be called via pointers ("soft links").
-- For the sake of efficiency, the version with Self_ID as parameter
-- should used wherever possible. These are all nestable.
-- Non-nestable inline versions --
procedure Defer_Abort (Self_ID : Task_ID);
pragma Inline (Defer_Abort);
procedure Undefer_Abort (Self_ID : Task_ID);
pragma Inline (Undefer_Abort);
-- Nestable inline versions --
procedure Defer_Abort_Nestable (Self_ID : Task_ID);
pragma Inline (Defer_Abort_Nestable);
procedure Undefer_Abort_Nestable (Self_ID : Task_ID);
pragma Inline (Undefer_Abort_Nestable);
-- NON-INLINE versions without Self_ID for code generated by the
-- expander and for hard links
procedure Defer_Abortion;
procedure Undefer_Abortion;
-- ?????
-- Try to phase out all uses of the above versions.
function Check_Abort_Status return Integer;
-- Returns Boolean'Pos (True) iff abort signal should raise
-- Standard.Abort_Signal. Only used by IRIX currently.
---------------------------
-- Change Base Priority --
---------------------------
procedure Change_Base_Priority (T : Task_ID);
-- Change the base priority of T.
-- Has to be called with the affected task's ATCB write-locked.
-- May temporariliy release the lock.
procedure Poll_Base_Priority_Change (Self_ID : Task_ID);
-- Has to be called with Self_ID's ATCB write-locked.
-- May temporariliy release the lock.
pragma Inline (Poll_Base_Priority_Change);
----------------------
-- Task Lock/Unlock --
----------------------
procedure Task_Lock (Self_ID : Task_ID);
procedure Task_Unlock (Self_ID : Task_ID);
-- These are versions of Lock_Task and Unlock_Task created for use
-- within the GNARL.
procedure Final_Task_Unlock (Self_ID : Task_ID);
-- This version is only for use in Terminate_Task, when the task
-- is relinquishing further rights to its own ATCB.
-- There is a very interesting potential race condition there, where
-- the old task may run concurrently with a new task that is allocated
-- the old tasks (now reused) ATCB. The critical thing here is to
-- not make any reference to the ATCB after the lock is released.
-- See also comments on Terminate_Task and Unlock.
procedure Wakeup_Entry_Caller
(Self_ID : Task_ID;
Entry_Call : Entry_Call_Link;
New_State : Entry_Call_State);
pragma Inline (Wakeup_Entry_Caller);
-- This is called at the end of service of an entry call,
-- to abort the caller if he is in an abortable part, and
-- to wake up the caller if he is on Entry_Caller_Sleep.
-- Call it holding the lock of Entry_Call.Self.
--
-- Timed_Call or Simple_Call:
-- The caller is waiting on Entry_Caller_Sleep, in
-- Wait_For_Completion, or Wait_For_Completion_With_Timeout.
--
-- Conditional_Call:
-- The caller might be in Wait_For_Completion,
-- waiting for a rendezvous (possibly requeued without abort)
-- to complete.
--
-- Asynchronous_Call:
-- The caller may be executing in the abortable part o
-- an async. select, or on a time delay,
-- if Entry_Call.State >= Was_Abortable.
procedure Locked_Abort_To_Level
(Self_ID : Task_ID;
T : Task_ID;
L : ATC_Level);
pragma Inline (Locked_Abort_To_Level);
-- Abort a task to a specified ATC level.
-- Call this only with T locked.
end System.Tasking.Initialization;
|
with System;
with GDNative.Objects; use GDNative.Objects;
package Adventure is
type Player is new Node with record
Health : Integer;
end record;
for Player'External_Tag use "Player";
overriding function Initialize return Player is (Player'(Health => 100));
overriding procedure Process (Self : in out Player; Delta_Time : in Long_Float);
package Player_Registration is new Node_Registration (Player);
procedure Register_Classes;
end;
|
-- SPDX-FileCopyrightText: 2020 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Ada.Containers.Hashed_Maps;
with Ada.Containers.Vectors;
with Program.Symbols.Tables;
package Program.Symbol_Lists is
pragma Preelaborate;
type Symbol_List is private;
-- A symbol or several symbols separated by a dot ('.');
function Empty_Symbol_List return Symbol_List
with Inline;
-- An empty symbol list
function Hash (Value : Symbol_List) return Ada.Containers.Hash_Type
with Inline;
type Symbol_List_Table
(Table : not null access Program.Symbols.Tables.Symbol_Table'Class) is
tagged limited private;
type Symbol_List_Table_Access is access all Symbol_List_Table'Class
with Storage_Size => 0;
function Find
(Self : Symbol_List_Table'Class;
Value : Program.Text) return Symbol_List;
-- Return a Symbol_List for given Text or Empty_Symbol_List if no such
-- value in the table.
procedure Find_Or_Create
(Self : in out Symbol_List_Table'Class;
Value : Program.Text;
Result : out Symbol_List);
-- Return existing symbol list or create new one otherise. The parent
-- table should have all symbols from the list.
procedure Find_Or_Create
(Self : in out Symbol_List_Table'Class;
Prefix : Symbol_List := Empty_Symbol_List;
Suffix : Program.Symbols.Symbol;
Result : out Symbol_List);
-- Find or build a new list by appending Suffix to Prefix (if any).
function Symbol_List_Text
(Self : Symbol_List_Table'Class;
List : Symbol_List) return Program.Text;
-- Return text of the list
function Prefix
(Self : Symbol_List_Table'Class;
List : Program.Symbol_Lists.Symbol_List)
return Program.Symbol_Lists.Symbol_List
with Pre => List /= Empty_Symbol_List;
function Suffix
(Self : Symbol_List_Table'Class;
List : Program.Symbol_Lists.Symbol_List)
return Program.Symbols.Symbol
with Pre => List /= Empty_Symbol_List;
private
type Symbol_List is range 0 .. Integer'Last;
subtype Symbol_List_Positive is Symbol_List range 1 .. Symbol_List'Last;
type Symbol_List_Item is record
Prefix : Symbol_List;
Symbol : Program.Symbols.Symbol;
end record;
function Hash (Value : Symbol_List_Item) return Ada.Containers.Hash_Type;
package Symbol_List_Maps is new Ada.Containers.Hashed_Maps
(Key_Type => Symbol_List_Item,
Element_Type => Symbol_List_Positive,
Hash => Hash,
Equivalent_Keys => "=");
package Symbol_List_Vectors is new Ada.Containers.Vectors
(Symbol_List_Positive, Symbol_List_Item);
type Symbol_List_Table
(Table : not null access Program.Symbols.Tables.Symbol_Table'Class) is
tagged limited
record
Map : Symbol_List_Maps.Map;
Back : Symbol_List_Vectors.Vector;
end record;
end Program.Symbol_Lists;
|
-- { dg-do run }
procedure interface2 is
package Types is
type Iface is synchronized interface;
type Any_Iface is access all Iface'Class;
--
protected type T_PO (S : Integer) is new Iface with end;
task type T_Task (R : Any_Iface);
--
Obj_1 : aliased T_PO (0);
Obj_2 : T_Task (Obj_1'Access); -- Test
end Types;
--
package body Types is
protected body T_PO is end;
task body T_Task is begin null; end;
end Types;
--
begin
null;
end;
|
pragma License (Unrestricted);
-- extended unit
package Ada.References.Wide_Wide_Strings is
-- Returning access values to sliced Wide_Wide_String from functions.
pragma Pure;
type Constant_Reference_Type (
Element : not null access constant Wide_Wide_String) is null record
with Implicit_Dereference => Element;
pragma Suppress_Initialization (Constant_Reference_Type);
type Reference_Type (
Element : not null access Wide_Wide_String) is null record
with Implicit_Dereference => Element;
pragma Suppress_Initialization (Reference_Type);
package Slicing is
new Generic_Slicing (Positive, Wide_Wide_Character, Wide_Wide_String);
end Ada.References.Wide_Wide_Strings;
|
-- { dg-do compile }
-- { dg-options "-fdump-tree-gimple" }
with Atomic6_Pkg; use Atomic6_Pkg;
procedure Atomic6_6 is
Temp : Integer;
begin
Counter(1) := Counter(2);
Timer(1) := Timer(2);
Counter(1) := Int(Timer(1));
Timer(1) := Integer(Counter(1));
Temp := Integer(Counter(1));
Counter(1) := Int(Temp);
Temp := Timer(1);
Timer(1) := Temp;
end;
-- { dg-final { scan-tree-dump-times "atomic_load\[^\n\r\]*&atomic6_pkg__counter\\\[1" 2 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_load\[^\n\r\]*&atomic6_pkg__counter\\\[2" 1 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_load\[^\n\r\]*&atomic6_pkg__timer\\\[1" 2 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_load\[^\n\r\]*&atomic6_pkg__timer\\\[2" 1 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_load\[^\n\r\]*&temp" 0 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_load\[^\n\r\]*ptr" 0 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_store\[^\n\r\]*&atomic6_pkg__counter\\\[1" 3 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_store\[^\n\r\]*&atomic6_pkg__counter\\\[2" 0 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_store\[^\n\r\]*&atomic6_pkg__timer\\\[1" 3 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_store\[^\n\r\]*&atomic6_pkg__timer\\\[2" 0 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_store\[^\n\r\]*&temp" 0 "gimple"} }
-- { dg-final { scan-tree-dump-times "atomic_store\[^\n\r\]*ptr" 0 "gimple"} }
|
-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>
-- MIT license. Please refer to the LICENSE file.
with Apsepp.Debug_Trace_Class.Stub.Create;
function Apsepp.Debug_Trace_Class.Output.Create return Debug_Trace_Output is
begin
return (Stub.Create with null record);
end Apsepp.Debug_Trace_Class.Output.Create;
|
package body I2C_Interface with SPARK_Mode
--,Refined_State => (State => (G_Data))
is
G_Data : Data_Type(1 .. 2);
procedure configure(Port : I2C_Type; Config : Configuration_Type) is
begin
-- Port.pin = 0;
null;
end configure;
procedure write (Port : I2C_Type; Address : Address_Type; Data : Data_Type) is
begin
G_Data(1) := Data(1);
end write;
function read (Port : I2C_Type; Address : Address_Type) return Data_Type is
begin
return G_Data;
end read;
end I2C_Interface;
|
package Complex is
type Complex is private;
i, zero : constant Complex;
-- arithmetic plus operator on complex values
function "+" ( lhs, -- left hand side
rhs : in Complex -- right hand side
) return Complex; -- returns a Compelx
-- extracts imaginary component
function Imag(val : in Complex) return Float;
-- extracts real component
function Real(val : in Complex) return Float;
function Origin return Complex;
private
type Complex is record
Re : Float := 0.0;
Im : Float := 0.0;
end record;
i : constant Complex := (0.0, 1.0);
zero: constant Complex := (0.0, 0.0);
end Complex;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- A U N I T . R E P O R T E R . X M L --
-- --
-- S p e c --
-- --
-- --
-- Copyright (C) 2000-2013, 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 is maintained by AdaCore (http://www.adacore.com) --
-- --
------------------------------------------------------------------------------
-- This is a xUnit reporter with output compatible with jUnit capable to
-- catch stdout and stderr and report to Streams.
with Ada.Streams;
private with Ada_Containers;
private with AUnit.Time_Measure;
private with Ada.Text_IO.Text_Streams;
private with GNAT.OS_Lib;
package AUnit.Reporter.Stream_XML is
type XML_Reporter is new Reporter with private;
type Stream_Access is not null access all Ada.Streams.Root_Stream_Type'Class;
procedure Set_Output (Engine : in out XML_Reporter; Stream : Stream_Access);
-- Set the stream for the report.
procedure Catch_Output_And_Error (Engine : in out XML_Reporter);
-- A call to this routine will redirct Standard_Output and Standard_Error
-- to temporary files and include the contents of these files
-- in the final testreport.
procedure Report (Engine : XML_Reporter;
R : in out Result'Class;
Options : AUnit_Options := Default_Options);
private
type XML_Reporter is new Reporter with record
Output : Stream_Access := Stream_Access (Ada.Text_IO.Text_Streams.Stream (Ada.Text_IO.Standard_Output));
Stdout : GNAT.OS_Lib.File_Descriptor := GNAT.OS_Lib.Invalid_FD;
Stderr : GNAT.OS_Lib.File_Descriptor := GNAT.OS_Lib.Invalid_FD;
Stdout_Name : GNAT.OS_Lib.String_Access;
Stderr_Name : GNAT.OS_Lib.String_Access;
end record;
function Image (S : Ada_Containers.Count_Type) return String;
function Image (S : Integer) return String;
function Image (S : AUnit.Time_Measure.AUnit_Duration) return String;
end AUnit.Reporter.Stream_XML;
|
with Ada.Streams; use Ada.Streams;
with PBKDF2_Generic;
with HMAC; use HMAC;
with SHA1;
with SHA2;
package PBKDF2 with
Pure,
Preelaborate
is
package PBKDF2_HMAC_SHA_1_Package is new PBKDF2_Generic
(Element => Stream_Element, Index => Stream_Element_Offset,
Element_Array => Stream_Element_Array, Hash_Length => SHA1.Digest_Length,
Hash_Context => HMAC_SHA_1.Context,
Hash_Initialize => HMAC_SHA_1.Initialize,
Hash_Update => HMAC_SHA_1.Update, Hash_Finalize => HMAC_SHA_1.Finalize);
function PBKDF2_HMAC_SHA_1
(Password : String; Salt : String; Iterations : Positive;
Derived_Key_Length : Stream_Element_Offset := SHA1.Digest_Length)
return Stream_Element_Array renames
PBKDF2_HMAC_SHA_1_Package.PBKDF2;
function PBKDF2_HMAC_SHA_1
(Password : Stream_Element_Array; Salt : Stream_Element_Array;
Iterations : Positive;
Derived_Key_Length : Stream_Element_Offset := SHA1.Digest_Length)
return Stream_Element_Array renames
PBKDF2_HMAC_SHA_1_Package.PBKDF2;
package PBKDF2_HMAC_SHA_256_Package is new PBKDF2_Generic
(Element => Stream_Element, Index => Stream_Element_Offset,
Element_Array => Stream_Element_Array,
Hash_Length => SHA2.SHA_256.Digest_Length,
Hash_Context => HMAC_SHA_256.Context,
Hash_Initialize => HMAC_SHA_256.Initialize,
Hash_Update => HMAC_SHA_256.Update,
Hash_Finalize => HMAC_SHA_256.Finalize);
function PBKDF2_HMAC_SHA_256
(Password : String; Salt : String; Iterations : Positive;
Derived_Key_Length : Stream_Element_Offset := SHA2.SHA_256.Digest_Length)
return Stream_Element_Array renames
PBKDF2_HMAC_SHA_256_Package.PBKDF2;
function PBKDF2_HMAC_SHA_256
(Password : Stream_Element_Array; Salt : Stream_Element_Array;
Iterations : Positive;
Derived_Key_Length : Stream_Element_Offset := SHA2.SHA_256.Digest_Length)
return Stream_Element_Array renames
PBKDF2_HMAC_SHA_256_Package.PBKDF2;
package PBKDF2_HMAC_SHA_512_Package is new PBKDF2_Generic
(Element => Stream_Element, Index => Stream_Element_Offset,
Element_Array => Stream_Element_Array,
Hash_Length => SHA2.SHA_512.Digest_Length,
Hash_Context => HMAC_SHA_512.Context,
Hash_Initialize => HMAC_SHA_512.Initialize,
Hash_Update => HMAC_SHA_512.Update,
Hash_Finalize => HMAC_SHA_512.Finalize);
function PBKDF2_HMAC_SHA_512
(Password : String; Salt : String; Iterations : Positive;
Derived_Key_Length : Stream_Element_Offset := SHA2.SHA_512.Digest_Length)
return Stream_Element_Array renames
PBKDF2_HMAC_SHA_512_Package.PBKDF2;
function PBKDF2_HMAC_SHA_512
(Password : Stream_Element_Array; Salt : Stream_Element_Array;
Iterations : Positive;
Derived_Key_Length : Stream_Element_Offset := SHA2.SHA_512.Digest_Length)
return Stream_Element_Array renames
PBKDF2_HMAC_SHA_512_Package.PBKDF2;
end PBKDF2;
|
-----------------------------------------------------------------------
-- GtkAda - Ada95 binding for the Gimp Toolkit --
-- --
-- Copyright (C) 1998-1999 --
-- Emmanuel Briot, Joel Brobecker and Arnaud Charlet --
-- Copyright (C) 2003-2006 AdaCore --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU General Public --
-- License as published by the Free Software Foundation; either --
-- version 2 of the License, or (at your option) any later version. --
-- --
-- This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. --
-- --
-- You should have received a copy of the GNU General Public --
-- License along with this library; if not, write to the --
-- Free Software Foundation, Inc., 59 Temple Place - Suite 330, --
-- Boston, MA 02111-1307, USA. --
-- --
-----------------------------------------------------------------------
with Gtk.Arguments;
with Gtk.Enums; use Gtk.Enums;
with Ada.Strings.Fixed;
package body Common_Gtk
is
procedure Page_Switch (Notebook : access Gtk_Notebook_Record'Class;
old_page_Id,
new_page_Id : in Gint)
is
begin
if old_page_Id >= 0 then
declare
old_Page : constant Gtk_Widget := Get_Nth_Page (Notebook, old_page_Id);
old_page_Label : constant gtk_Label := gtk_Label (Notebook.Get_Tab_Label (old_Page));
old_label_Text : constant String := old_page_Label.Get_Text;
begin
if old_label_Text'Length >= 3
and then old_label_Text (1 .. 3) = "<b>"
then
old_page_Label.set_Markup (old_label_Text (4 .. old_label_Text'Last - 4));
else
old_page_Label.set_Markup (old_label_Text);
end if;
end;
end if;
if new_page_Id >= 0 then
declare
new_Page : constant Gtk_Widget := Get_Nth_Page (Notebook, new_page_Id);
new_page_Label : constant gtk_Label := gtk_Label (Notebook.Get_Tab_Label (new_Page));
begin
if new_page_Label /= null then
new_page_Label.set_Markup ("<b>" & new_page_Label.Get_Text & "</b>");
end if;
end;
end if;
end Page_Switch;
procedure Page_Switch (Notebook : access Gtk_Notebook_Record'Class;
Params : in Gtk.Arguments.Gtk_Args)
is
old_page_Id : constant Gint := Get_Current_Page (Notebook);
new_page_Id : constant Gint := Gint (Gtk.Arguments.To_Guint (Params, 2));
begin
Page_Switch (Notebook,
old_page_Id, new_page_Id);
end Page_Switch;
procedure enable_bold_Tabs_for (the_Notebook : in gtk_Notebook)
is
begin
Notebook_Cb.Connect (the_Notebook, "switch_page", Page_Switch'Access);
Page_Switch (Notebook => the_Notebook,
old_page_Id => Get_Current_Page (the_Notebook),
new_page_Id => Get_Current_Page (the_Notebook));
end enable_bold_Tabs_for;
-------------------------
-- Build_Option_Menu --
-------------------------
-- procedure Build_Option_Menu
-- (Omenu : out Gtk.Option_Menu.Gtk_Option_Menu;
-- Gr : in out Widget_SList.GSlist;
-- Items : Chars_Ptr_Array;
-- History : Gint;
-- Cb : Widget_Handler.Marshallers.Void_Marshaller.Handler)
--
-- is
-- Menu : Gtk_Menu;
-- Menu_Item : Gtk_Radio_Menu_Item;
--
-- begin
-- Gtk.Option_Menu.Gtk_New (Omenu);
-- Gtk_New (Menu);
--
-- for I in Items'Range loop
-- Gtk_New (Menu_Item, Gr, ICS.Value (Items (I)));
-- Widget_Handler.Object_Connect (Menu_Item, "activate",
-- Widget_Handler.To_Marshaller (Cb),
-- Slot_Object => Menu_Item);
-- Gr := Get_Group (Menu_Item);
-- Append (Menu, Menu_Item);
-- if Gint (I) = History then
-- Set_Active (Menu_Item, True);
-- end if;
-- Show (Menu_Item);
-- end loop;
-- Gtk.Option_Menu.Set_Menu (Omenu, Menu);
-- Gtk.Option_Menu.Set_History (Omenu, History);
-- end Build_Option_Menu;
--------------------
-- Destroy_Window --
--------------------
procedure Destroy_Window (Win : access Gtk.Window.Gtk_Window_Record'Class;
Ptr : in Gtk_Window_Access) is
pragma Warnings (Off, Win);
begin
Ptr.all := null;
end Destroy_Window;
--------------------
-- Destroy_Dialog --
--------------------
procedure Destroy_Dialog (Win : access Gtk.Dialog.Gtk_Dialog_Record'Class;
Ptr : in Gtk_Dialog_Access) is
pragma Warnings (Off, Win);
begin
Ptr.all := null;
end Destroy_Dialog;
--------------
-- Image_Of --
--------------
function Image_Of (I : in Gint) return String is
begin
return Ada.Strings.Fixed.Trim (Gint'Image (I), Ada.Strings.Left);
end Image_Of;
end Common_Gtk;
|
-- ___ _ ___ _ _ --
-- / __| |/ (_) | | Common SKilL implementation --
-- \__ \ ' <| | | |__ Iterators for SKilL API --
-- |___/_|\_\_|_|____| by: Timm Felden --
-- --
pragma Ada_2012;
generic
type T is private;
type Index_Type is range <>;
package Skill.Types.Iterators is
subtype Index_Base is Index_Type'Base;
type Abstract_Iterator is abstract tagged private;
type Iterator is not null access Abstract_Iterator'Class;
function Next (This : access Abstract_Iterator) return T is abstract;
function Has_Next
(This : access Abstract_Iterator) return Boolean is abstract;
type Array_Iterator_T is new Abstract_Iterator with private;
type Array_Iterator_T_Array_T is array (Index_Type range <>) of T;
type Array_Iterator_T_Array is not null access all Array_Iterator_T_Array_T;
function New_Array (Data : Array_Iterator_T_Array) return Iterator;
function New_Array
(Data : Array_Iterator_T_Array;
First : Index_Type;
Last : Index_Type) return Iterator;
function Next (This : access Array_Iterator_T) return T;
function Has_Next (This : access Array_Iterator_T) return Boolean;
type Empty_Iterator_T is new Abstract_Iterator with private;
function New_Empty return Iterator;
function Next
(This : access Empty_Iterator_T) return T is
(raise Constraint_Error with "empty iterator has no next element");
function Has_Next
(This : access Empty_Iterator_T) return Boolean is
(False);
private
type Abstract_Iterator is abstract tagged null record;
type Array_Iterator_T is new Abstract_Iterator with record
Data : Array_Iterator_T_Array;
Position : Index_Type;
-- exclusive last position
Last : Index_Base;
end record;
type Empty_Iterator_T is new Abstract_Iterator with null record;
end Skill.Types.Iterators;
|
pragma License (Unrestricted);
-- implementation unit specialized for Windows
package System.Native_Credentials is
pragma Preelaborate;
function User_Name return String;
end System.Native_Credentials;
|
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Text_Io; use Ada.Text_Io;
procedure Parse_Commas is
Source_String : String := "Hello,How,Are,You,Today";
Index_List : array(Source_String'Range) of Natural;
Next_Index : Natural := Index_List'First;
begin
Index_List(Next_Index) := Source_String'First;
while Index_List(Next_Index) < Source_String'Last loop
Next_Index := Next_Index + 1;
Index_List(Next_Index) := 1 + Index(Source_String(Index_List(Next_Index - 1)..Source_String'Last), ",");
if Index_List(Next_Index) = 1 then
Index_List(Next_Index) := Source_String'Last + 2;
end if;
Put(Source_String(Index_List(Next_Index - 1)..Index_List(Next_Index)-2) & ".");
end loop;
end Parse_Commas;
|
------------------------------------------------------------------------------
-- --
-- Simple HTTP --
-- --
-- Basic HTTP 1.1 support for API endpoints --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2021, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This package contains items defined or under the perview of IETF RFCs
-- 7230 & 7231
with Ada.Characters.Handling;
with Ada.Characters.Latin_1;
package Simple_HTTP.RFC_7230_7231 is
package Latin_1 renames Ada.Characters.Latin_1;
-- RFC 7230 --
CR : Character renames Latin_1.CR;
LF : Character renames Latin_1.LF;
HT : Character renames Latin_1.HT;
SP : Character renames Latin_1.Space;
CRLF: constant String := Latin_1.CR & Latin_1.LF;
function Is_Whitespace (C: Character) return Boolean is (C in HT | SP);
function Is_VCHAR (C: Character) return Boolean is
(Character'Pos (C) in 16#21# .. 16#7E#);
-- RFC 7230 defines VCHAR via RFC 5234, Appendix B, which defines it:
-- VCHAR = %x21-7E
function Is_ALPHA (C: Character) return Boolean
renames Ada.Characters.Handling.Is_Letter;
function Is_DIGIT (C: Character) return Boolean
renames Ada.Characters.Handling.Is_Digit;
function Is_Token (C: Character) return Boolean is
(Is_ALPHA (C) or else Is_DIGIT (C)
or else (C in '!' | '#' | '$' | '%' | '&' | ''' | '*' |
'+' | '-' | '.' | '^' | '_' | '`' | '|' | '~'));
function Is_obs_text (C: Character) return Boolean is
(Character'Pos (C) in 16#80# .. 16#FF#);
type Request_Method is
(GET, HEAD, POST, PUT, DELETE, CONNECT, OPTIONS, TRACE);
Request_Method_Max_Length: constant := 7;
-- "CONNECT"
-- We do not support extension-methods
type Response_Status is range 100 .. 599;
subtype Standard_Response_Status is Response_Status with
Static_Predicate => Standard_Response_Status in
100 .. 101 | 200 .. 206 | 300 .. 307 |
400 .. 417 | 426 |
500 .. 505;
-- RFC 7231 --
-- Status phrases
Phrase_100: constant String := "Continue";
Phrase_101: constant String := "Switching Protocols";
Phrase_200: constant String := "OK";
Phrase_201: constant String := "Created";
Phrase_202: constant String := "Accepted";
Phrase_203: constant String := "Non-Authoritative Information";
Phrase_204: constant String := "No Content";
Phrase_205: constant String := "Reset Content";
Phrase_206: constant String := "Partial Content";
Phrase_300: constant String := "Multiple Choices";
Phrase_301: constant String := "Moved Permanently";
Phrase_302: constant String := "Found";
Phrase_303: constant String := "See Other";
Phrase_304: constant String := "Not Modified";
Phrase_305: constant String := "Use Proxy";
Phrase_307: constant String := "Temporary Redirect";
Phrase_400: constant String := "Bad Request";
Phrase_401: constant String := "Unauthorized";
Phrase_402: constant String := "Payment Required";
Phrase_403: constant String := "Forbidden";
Phrase_404: constant String := "Not Found";
Phrase_405: constant String := "Method Not Allowed";
Phrase_406: constant String := "Not Acceptable";
Phrase_407: constant String := "Proxy Authentication Required";
Phrase_408: constant String := "Request Time-out";
Phrase_409: constant String := "Conflict";
Phrase_410: constant String := "Gone";
Phrase_411: constant String := "Length Required";
Phrase_412: constant String := "Precondition Failed";
Phrase_413: constant String := "Request Entity Too Large";
Phrase_414: constant String := "Request-URI Too Large";
Phrase_415: constant String := "Unsupported Media Type";
Phrase_416: constant String := "Requested range not satisfiable";
Phrase_417: constant String := "Expectation Failed";
Phrase_426: constant String := "Upgrade Required";
Phrase_500: constant String := "Internal Server Error";
Phrase_501: constant String := "Not Implemented";
Phrase_502: constant String := "Bad Gateway";
Phrase_503: constant String := "Service Unavailable";
Phrase_504: constant String := "Gateway Time-out";
Phrase_505: constant String := "HTTP Version not supported";
end Simple_HTTP.RFC_7230_7231;
|
package body Regression_Library is
function LibraryFun (Input : Boolean) return Boolean is
begin
return False;
end;
end Regression_Library;
|
-- { dg-excess-errors "no code generated" }
generic
type Element_Type is private;
type Index_Type is (<>);
type Constrained_Array_Type is array (Index_Type) of Element_Type;
package Loop_Optimization1_Pkg is
procedure Proc (CA : in out Constrained_Array_Type);
end Loop_Optimization1_Pkg;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S E M _ C H 6 --
-- --
-- S p e c --
-- --
-- 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 Types; use Types;
package Sem_Ch6 is
procedure Analyze_Abstract_Subprogram_Declaration (N : Node_Id);
procedure Analyze_Function_Call (N : Node_Id);
procedure Analyze_Operator_Symbol (N : Node_Id);
procedure Analyze_Parameter_Association (N : Node_Id);
procedure Analyze_Procedure_Call (N : Node_Id);
procedure Analyze_Return_Statement (N : Node_Id);
procedure Analyze_Subprogram_Declaration (N : Node_Id);
procedure Analyze_Subprogram_Body (N : Node_Id);
function Analyze_Subprogram_Specification (N : Node_Id) return Entity_Id;
-- Analyze subprogram specification in both subprogram declarations
-- and body declarations. Returns the defining entity for the spec.
procedure Cannot_Inline (Msg : String; N : Node_Id; Subp : Entity_Id);
-- This procedure is called if the node N, an instance of a call to
-- subprogram Subp, cannot be inlined. Msg is the message to be issued,
-- and has a ? as the last character. If Subp has a pragma Always_Inlined,
-- then an error message is issued (by removing the last character of Msg).
-- If Subp is not Always_Inlined, then a warning is issued if the flag
-- Ineffective_Inline_Warnings is set, and if not, the call has no effect.
procedure Check_Delayed_Subprogram (Designator : Entity_Id);
-- Designator can be a E_Subrpgram_Type, E_Procedure or E_Function. If a
-- type in its profile depends on a private type without a full
-- declaration, indicate that the subprogram is delayed.
procedure Check_Discriminant_Conformance
(N : Node_Id;
Prev : Entity_Id;
Prev_Loc : Node_Id);
-- Check that the discriminants of a full type N fully conform to
-- the discriminants of the corresponding partial view Prev.
-- Prev_Loc indicates the source location of the partial view,
-- which may be different than Prev in the case of private types.
procedure Check_Fully_Conformant
(New_Id : Entity_Id;
Old_Id : Entity_Id;
Err_Loc : Node_Id := Empty);
-- Check that two callable entitites (subprograms, entries, literals)
-- are fully conformant, post error message if not (RM 6.3.1(17)) with
-- the flag being placed on the Err_Loc node if it is specified, and
-- on the appropriate component of the New_Id construct if not. Note:
-- when checking spec/body conformance, New_Id must be the body entity
-- and Old_Id is the spec entity (the code in the implementation relies
-- on this ordering, and in any case, this makes sense, since if flags
-- are to be placed on the construct, they clearly belong on the body.
procedure Check_Mode_Conformant
(New_Id : Entity_Id;
Old_Id : Entity_Id;
Err_Loc : Node_Id := Empty;
Get_Inst : Boolean := False);
-- Check that two callable entitites (subprograms, entries, literals)
-- are mode conformant, post error message if not (RM 6.3.1(15)) with
-- the flag being placed on the Err_Loc node if it is specified, and
-- on the appropriate component of the New_Id construct if not. The
-- argument Get_Inst is set to True when this is a check against a
-- formal access-to-subprogram type, indicating that mapping of types
-- is needed.
procedure Check_Subtype_Conformant
(New_Id : Entity_Id;
Old_Id : Entity_Id;
Err_Loc : Node_Id := Empty);
-- Check that two callable entitites (subprograms, entries, literals)
-- are subtype conformant, post error message if not (RM 6.3.1(16))
-- the flag being placed on the Err_Loc node if it is specified, and
-- on the appropriate component of the New_Id construct if not.
procedure Check_Type_Conformant
(New_Id : Entity_Id;
Old_Id : Entity_Id;
Err_Loc : Node_Id := Empty);
-- Check that two callable entitites (subprograms, entries, literals)
-- are type conformant, post error message if not (RM 6.3.1(14)) with
-- the flag being placed on the Err_Loc node if it is specified, and
-- on the appropriate component of the New_Id construct if not.
procedure Create_Extra_Formals (E : Entity_Id);
-- For each parameter of a subprogram or entry that requires an additional
-- formal (such as for access parameters and indefinite discriminated
-- parameters), creates the appropriate formal and attach it to its
-- associated parameter. Each extra formal will also be appended to
-- the end of Subp's parameter list (with each subsequent extra formal
-- being attached to the preceding extra formal).
function Find_Corresponding_Spec (N : Node_Id) return Entity_Id;
-- Use the subprogram specification in the body to retrieve the previous
-- subprogram declaration, if any.
function Fully_Conformant (New_Id, Old_Id : Entity_Id) return Boolean;
-- Determine whether two callable entities (subprograms, entries,
-- literals) are fully conformant (RM 6.3.1(17))
function Fully_Conformant_Expressions
(Given_E1 : Node_Id;
Given_E2 : Node_Id)
return Boolean;
-- Determines if two (non-empty) expressions are fully conformant
-- as defined by (RM 6.3.1(18-21))
function Fully_Conformant_Discrete_Subtypes
(Given_S1 : Node_Id;
Given_S2 : Node_Id)
return Boolean;
-- Determines if two subtype definitions are fully conformant. Used
-- for entry family conformance checks (RM 6.3.1 (24)).
function Mode_Conformant (New_Id, Old_Id : Entity_Id) return Boolean;
-- Determine whether two callable entities (subprograms, entries,
-- literals) are mode conformant (RM 6.3.1(15))
procedure New_Overloaded_Entity
(S : Entity_Id;
Derived_Type : Entity_Id := Empty);
-- Process new overloaded entity. Overloaded entities are created by
-- enumeration type declarations, subprogram specifications, entry
-- declarations, and (implicitly) by type derivations. Derived_Type non-
-- Empty indicates that this is subprogram derived for that type.
procedure Process_Formals (T : List_Id; Related_Nod : Node_Id);
-- Enter the formals in the scope of the subprogram or entry, and
-- analyze default expressions if any. The implicit types created for
-- access parameter are attached to the Related_Nod which comes from the
-- context.
procedure Set_Actual_Subtypes (N : Node_Id; Subp : Entity_Id);
-- If the formals of a subprogram are unconstrained, build a subtype
-- declaration that uses the bounds or discriminants of the actual to
-- construct an actual subtype for them. This is an optimization that
-- is done only in some cases where the actual subtype cannot change
-- during execution of the subprogram. By setting the actual subtype
-- once, we avoid recomputing it unnecessarily.
procedure Set_Formal_Mode (Formal_Id : Entity_Id);
-- Set proper Ekind to reflect formal mode (in, out, in out)
function Subtype_Conformant (New_Id, Old_Id : Entity_Id) return Boolean;
-- Determine whether two callable entities (subprograms, entries,
-- literals) are subtype conformant (RM6.3.1(16)).
function Type_Conformant
(New_Id : Entity_Id;
Old_Id : Entity_Id;
Skip_Controlling_Formals : Boolean := False) return Boolean;
-- Determine whether two callable entities (subprograms, entries,
-- literals) are type conformant (RM6.3.1(14)).
procedure Valid_Operator_Definition (Designator : Entity_Id);
-- Verify that an operator definition has the proper number of formals
end Sem_Ch6;
|
with CSV;
with Config.software;
with Simulation;
with Ada.Text_IO; use Ada.Text_IO;
with Units; use Units;
package body ms5611.driver with
SPARK_Mode => Off,
Refined_State => (State => ( cur_temp, cur_press), Coefficients => null) is
G_CELSIUS_0 : constant := 273.15;
cur_temp : Temperature_Type := 300.0 * Kelvin;
cur_press : Pressure_Type := 1.0 * Bar;
procedure reset is null;
procedure init is null;
subtype TEMP_Type is Float range -4000.9 .. 8500.9;
function convertToKelvin (thisTemp : in TEMP_Type) return Temperature_Type is
begin
return Temperature_Type (G_CELSIUS_0 + thisTemp / 100.0); -- SPARK Range Check might fail
end convertToKelvin;
procedure Update_Val (have_update : out Boolean) is
begin
-- cur_press := Pressure_Type (Simulation.CSV_here.Get_Column ("Press"));
-- declare
-- f : float := Simulation.CSV_here.Get_Column ("Temp");
-- begin
-- cur_temp := convertToKelvin (f);
-- end;
null;
end update_val;
function get_temperature return Temperature_Type is (cur_temp);
function get_pressure return Pressure_Type is (cur_press);
procedure self_check (Status : out Error_Type) is null;
end ms5611.driver;
|
-- same as simple_select_accept, with two select cases decorated with
-- when conditions in the task body.
procedure Simple_Select_Accept_Guarded(Ch : Character) is
task Callee is
entry Do_This;
entry Do_That;
entry Do_Nothing;
end Callee;
task body Callee is
begin
delay 5.0;
select -- Selective Accept
accept Do_This do
null;
end Do_This;
or
when True =>
accept Do_That do
null;
end Do_That;
or
when 1 /= 2 =>
delay 5.0;
null;
end select;
accept Do_Nothing;
end Callee;
begin -- Caller executable part
if Ch = 'c' then -- Conditional Entry Call
select
Callee.Do_This;
else
null;
end select;
elsif Ch = 't' then -- Timed Entry Call
select
Callee.Do_That;
or
delay 3.0;
null;
end select;
else
null;
end if;
Callee.Do_Nothing; -- Both tasks can quit
end Simple_Select_Accept_Guarded;
|
with Ada.Unchecked_Deallocation;
with Ada.Streams;
with kv.avm.Control;
package kv.avm.Transactions is
type Obligatory_Parameter_Type is null record;
-- Responsibility: represent an abstract inter-VM transaction
--
type Transactions_Interface is interface;
type Transactions_Access is access all Transactions_Interface'CLASS;
procedure Initialize
(Self : in out Transactions_Interface) is abstract;
function Equals
(Left : Transactions_Interface;
Right : Transactions_Interface'CLASS) return Boolean is abstract;
function Constructor
(Info : not null access Obligatory_Parameter_Type) return Transactions_Interface is abstract;
function New_Copy(Self : Transactions_Interface) return Transactions_Access is abstract;
procedure Execute
(Self : in out Transactions_Interface;
Machine : in kv.avm.Control.Control_Access) is null;
function Input_Transaction
(Stream : not null access Ada.Streams.Root_Stream_Type'CLASS) return Transactions_Interface'CLASS;
procedure Output_Transaction
(Stream : not null access Ada.Streams.Root_Stream_Type'CLASS;
Item : in Transactions_Interface'CLASS);
for Transactions_Interface'CLASS'INPUT use Input_Transaction;
for Transactions_Interface'CLASS'OUTPUT use Output_Transaction;
function New_Transaction_From_Stream
(Stream : not null access Ada.Streams.Root_Stream_Type'CLASS) return Transactions_Access;
procedure Free is new Ada.Unchecked_Deallocation(Transactions_Interface'CLASS, Transactions_Access);
end kv.avm.Transactions;
|
--Ada Standard Libraries
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Float_Text_IO; use Ada.Float_Text_IO;
--TJa Libraries
with TJa.Window.Text; use TJa.Window.Text;
with TJa.Keyboard; use TJa.Keyboard;
with TJa.Window.Elementary; use TJa.Window.Elementary;
package graphics is
--------------------------------------------------------------------------------
Scaling_Factor : constant Integer := 2;
--------------------------------------------------------------------------------
type Picture_Type is
array (Positive Range <>, Positive Range <>) of Integer;
--------------------------------------------------------------------------------
procedure Transform_To_Graphical(X_Pos, Y_pos : in Integer; G_X, G_Y : out Integer);
procedure Get_Picture_Dimensions(File_Name : in String; X_Dim, Y_dim : out Integer);
procedure Load_Picture(File_Name : in String; Picture : out Picture_Type);
procedure Put_Picture(Picture : in Picture_Type; X_Pos, Y_Pos, X_Range, Y_Range : in Integer);
procedure Fix_Picture(Picture : in Picture_Type; X_Pos, Y_Pos, X_Range, Y_Range : in Integer);
procedure Put_Bushes(Picture : in Picture_Type; Background_Start_X, Background_Start_Y, Width, Height : in Integer);
procedure Check_Out_Of_Bounds(X_Gra, Y_Gra, Width, Height, Size_Of_Water : in Integer; Running : in out Boolean);
procedure Setup_Terminal;
procedure Start_Up_Screen(Name : out String);
procedure Put_End_Screen(X_Start, Y_Start, X_Range, Y_Range : in Integer);
procedure Exit_Game;
--------------------------------------------------------------------------------
private
end graphics;
|
with ada.text_io, ada.Integer_text_IO, Ada.Text_IO.Text_Streams, Ada.Strings.Fixed, Interfaces.C;
use ada.text_io, ada.Integer_text_IO, Ada.Strings, Ada.Strings.Fixed, Interfaces.C;
procedure abstest is
type stringptr is access all char_array;
procedure PInt(i : in Integer) is
begin
String'Write (Text_Streams.Stream (Current_Output), Trim(Integer'Image(i), Left));
end;
begin
PInt(abs(5 + 2) * 3);
PInt(3 * abs(5 + 2));
end;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . B B . B O A R D _ S U P P O R T --
-- --
-- B o d y --
-- --
-- Copyright (C) 1999-2002 Universidad Politecnica de Madrid --
-- Copyright (C) 2003-2005 The European Space Agency --
-- Copyright (C) 2003-2017, 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. --
-- --
-- The port of GNARL to bare board targets was initially developed by the --
-- Real-Time Systems Group at the Technical University of Madrid. --
-- --
------------------------------------------------------------------------------
-- Board support for mpc5566
with Interfaces; use Interfaces;
with System.BB.CPU_Specific;
with System.Machine_Code;
package body System.BB.Board_Support is
procedure Clear_Alarm_Interrupt;
pragma Inline (Clear_Alarm_Interrupt);
-- Implement Time.Clear_Alarm_Interrupt
procedure Interrupt_Handler;
-- Procedure called in case of interrupt
----------------------
-- Initialize_Board --
----------------------
procedure Initialize_Board is
INTC_MCR : Unsigned_32;
for INTC_MCR'Address use 16#FFF4_8000#;
pragma Volatile (INTC_MCR);
pragma Import (Ada, INTC_MCR);
begin
-- Initialize the INTC
INTC_MCR := 0; -- VTES=0, HVEN=0
-- Mask interrupts
Interrupts.Set_Current_Priority (Interrupt_Priority'Last - 1);
-- Install handler for external interrupts
CPU_Specific.Install_Exception_Handler
(Interrupt_Handler'Address, CPU_Specific.External_Interrupt_Excp);
end Initialize_Board;
---------------------------
-- Clear_Alarm_Interrupt --
---------------------------
procedure Clear_Alarm_Interrupt is
use System.Machine_Code;
begin
-- Clear TSR[DIS]
Asm ("mtspr 336,%0",
Inputs => Unsigned_32'Asm_Input ("r", 2 ** (63 - 36)),
Volatile => True);
end Clear_Alarm_Interrupt;
package body Interrupts is
-------------------------------
-- Install_Interrupt_Handler --
-------------------------------
procedure Install_Interrupt_Handler
(Interrupt : System.BB.Interrupts.Interrupt_ID;
Prio : Interrupt_Priority)
is null;
---------------------------
-- Priority_Of_Interrupt --
---------------------------
function Priority_Of_Interrupt
(Interrupt : System.BB.Interrupts.Interrupt_ID)
return System.Any_Priority
is
type Intc_Psr_Type is
array (System.BB.Interrupts.Interrupt_ID) of Unsigned_8;
INTC_PSR : Intc_Psr_Type;
for INTC_PSR'Address use 16#FFF4_8040#;
pragma Volatile (INTC_PSR);
pragma Import (Ada, INTC_PSR);
begin
return Interrupt_Priority'First +
Natural (INTC_PSR (Interrupt) and 16#0F#);
end Priority_Of_Interrupt;
----------------
-- Power_Down --
----------------
procedure Power_Down is
begin
null;
end Power_Down;
--------------------------
-- Set_Current_Priority --
--------------------------
procedure Set_Current_Priority (Priority : Integer) is
INTC_CPR : Unsigned_32;
for INTC_CPR'Address use 16#FFF4_8008#;
pragma Volatile (INTC_CPR);
pragma Import (Ada, INTC_CPR);
-- INTC current priority register
begin
-- Note that Priority cannot be the last one, as this procedure is
-- unable to disable the decrementer interrupt.
pragma Assert (Priority /= Interrupt_Priority'Last);
if Priority in Interrupt_Priority then
INTC_CPR := Unsigned_32 (Priority - Interrupt_Priority'First);
else
INTC_CPR := 0;
end if;
end Set_Current_Priority;
end Interrupts;
-----------------------
-- Interrupt_Handler --
-----------------------
procedure Interrupt_Handler is
INTC_IACKR : Unsigned_32
with Import, Volatile, Address => 16#FFF4_8010#;
-- Interrupt acknowledge register
INTC_EOIR : Unsigned_32
with Import, Volatile, Address => 16#FFF4_8018#;
-- INTC end of interrupt register
Id : BB.Interrupts.Interrupt_ID;
begin
Id := BB.Interrupts.Interrupt_ID ((INTC_IACKR and 16#7FC#) / 4);
-- No spurious interrupts on p5566, so always call the wrapper
System.BB.Interrupts.Interrupt_Wrapper (Id);
INTC_EOIR := 0;
end Interrupt_Handler;
package body Time is separate;
package body Multiprocessors is separate;
end System.BB.Board_Support;
|
with Ada.Strings;
with Interfaces.C;
with System;
package dl_loader is
pragma Assertion_Policy (Pre => Check,
Post => Check,
Type_Invariant => Check);
type Handle is limited private;
function Open(path: in String; h: in out Handle) return Boolean;
function Is_Valid(h: in Handle) return Boolean;
function Get_Symbol(h: in Handle; name: in String) return System.Address;
procedure Close(h: in out Handle)
with Post => Is_Valid(h) = False;
private
type Handle is limited record
h: System.Address := System.Null_Address;
end record;
end dl_loader;
|
with GMP.Z;
with GMP.Q;
with GMP.F;
with GMP.FR;
with GMP.C;
with Ada.Text_IO;
procedure test_image is
package Default_F is new GMP.F;
package Default_FR is new GMP.FR;
package Default_C is new GMP.C (Default_FR, Default_FR);
use GMP.Z;
use GMP.Q;
use Default_F;
use Default_FR;
use Default_C;
Z : MP_Integer;
Q : MP_Rational;
F : Default_F.MP_Float;
FR : Default_FR.MP_Float;
C : MP_Complex;
begin
pragma Assert (Image (Z) = "0");
pragma Assert (Image (Q) = "0");
pragma Assert (Image (F) = "0");
pragma Assert (Image (FR) = "NAN");
pragma Assert (Image (C) = "(@NaN@ @NaN@)");
Z := To_MP_Integer (99);
Q := 5 / 7;
F := To_MP_Float (5.0 / 7.0);
FR := To_MP_Float (5.0 / 7.0);
C := 1.0 - 2.0 * i;
pragma Assert (Image (Z) = "99");
pragma Assert (Image (Q) = "5/7");
pragma Assert (Image (F) = "0.714285714285714301575");
pragma Assert (Image (FR) = "0.71428571428571430");
pragma Assert (Image (C) = "(1.0000000000000000 -2.0000000000000000)");
Z := Value ("-2");
Q := Value ("-3/4");
F := Value ("-1e3");
FR := Value ("-1e3");
C := Value ("-1e3");
pragma Assert (Image (Z) = "-2");
pragma Assert (Image (Q) = "-3/4");
pragma Assert (Image (F) = "-1000");
pragma Assert (Image (FR) = "-1000.0000000000000");
pragma Assert (Image (C) = "(-1.0000000000000000e+3 +0)");
F := Value ("+1e3");
FR := Value ("+1e3");
C := Value ("(1.2 1.4)");
pragma Assert (Image (F) = "1000");
pragma Assert (Image (FR) = "1000.0000000000000");
pragma Assert (Image (NaN) = "NAN");
pragma Assert (Image (Infinity) = "INF");
pragma Assert (Image (-Infinity) = "-INF");
pragma Assert (Image (C) = "(1.2000000000000000 1.3999999999999999)");
-- finish
Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error.all, "ok");
end test_image;
|
with Interfaces.C, Interfaces.C.Extensions, Ada.Unchecked_Conversion;
package body Libtcod.Maps.Lines is
use bresenham_h, Interfaces.C, Interfaces.C.Extensions;
type Int_Ptr is access all int;
type X_Pos_Ptr is access all X_Pos;
type Y_Pos_Ptr is access all Y_Pos;
function X_Ptr_To_Int_Ptr is new Ada.Unchecked_Conversion
(Source => X_Pos_Ptr, Target => Int_Ptr);
function Y_Ptr_To_Int_Ptr is new Ada.Unchecked_Conversion
(Source => Y_Pos_Ptr, Target => Int_Ptr);
function Line_Cb_To_TCOD_Cb is new Ada.Unchecked_Conversion
(Source => Line_Callback, Target => TCOD_line_listener_t);
---------------
-- make_line --
---------------
function make_line(start_x : X_Pos; start_y : Y_Pos;
end_x : X_Pos; end_y : Y_Pos) return Line is
begin
return l : Line do
TCOD_line_init_mt(int(start_x), int(start_y),
int(end_x), int(end_y), l.data'Access);
end return;
end make_line;
---------------
-- copy_line --
---------------
procedure copy_line(a : Line; b : out Line) is
begin
b.data := a.data;
end copy_line;
----------
-- step --
----------
function step(l : aliased in out Line;
x : aliased in out X_Pos; y : aliased in out Y_Pos) return Boolean is
(Boolean(TCOD_line_step_mt(X_Ptr_To_Int_Ptr(x'Unchecked_Access),
Y_Ptr_To_Int_Ptr(y'Unchecked_Access),
l.data'Access)));
----------------
-- visit_line --
----------------
function visit_line(start_x : X_Pos; start_y : Y_Pos;
end_x : X_Pos; end_y : Y_Pos; cb : Line_Callback) return Boolean is
(Boolean(TCOD_line(int(start_x), int(start_y), int(end_x), int(end_y),
Line_Cb_To_TCOD_Cb(cb))));
end Libtcod.Maps.Lines;
|
separate (Formatter)
function Get (Format : in String;
Value : in Values ) return String is
-- ++
--
-- FUNCTIONAL DESCRIPTION:
--
-- Returns a formatted string given a FORMAT string and a
-- variable number of data values.
--
-- FORMAL PARAMETERS:
--
-- Format : The input format string.
--
-- Value : an array of data values.
--
-- RETURN VALUE:
--
-- The formatted string.
--
-- DESIGN:
--
-- for all input characters loop
-- if input character is an escape character ("\") then
-- translate to appropriate ASCII representation
-- insert in output string at current position
-- update current position
-- if input character is a data format character ("%") then
-- test for left justification ("-")
-- test for zero fill ("0")
-- get field width
-- if decimal point present, skip over it
-- get optional precision width
-- get format specifier
-- if character format specifier ("c") then Format_Character
-- if scientific format specifier ("e") then Format_Real
-- if floating point format specifier ("f") then Format_Real
-- if integer number format specifier ("i") then Format_Number
-- if octal number format specifier ("o") then Format_Number
-- if string format specifier ("s") then Format_String
-- if hexadecimal number format specifier ("x") then Format_Number
-- else Format_Error string
-- else copy character
-- end loop
--
--
-- EXCEPTIONS:
--
-- End_of_Format_String is raised by internal Get_Character procedure
-- when there are no more characters in the input
-- format string. Remaining data values, if any,
-- are ignored and the function returns the
-- Formatted_String.
--
-- KEYWORDS:
--
-- Format
--
-- --
-- Input dependent variables
C : Character; -- Format character being examined
Item : Natural range 0..Value'last := 0; -- Value index
-- Format specifier flags
Fill_With_Zeros : Boolean := False;
Left_Justify : Boolean := False;
Specified_Width : Integer;
Precision : Integer;
-- Formatted output string
Formatted_String : String(1..255) := (others => ' ');
Source_Position : Natural := 0; -- Input Format string character position
Target_Position : Natural := 1; -- Formatted string character position
-- Temporary data values
Octal_Value : Integer := 0;
Hexadecimal_Value : Integer := 0;
-- Exception declarations
End_Of_Format_String : Exception;
-- Constant declarations
Escape_Character : constant character := Ascii.Back_Slash; -- '\'
Data_Format : constant character := Ascii.Percent; -- '%'
Default_Width : constant := 8;
Base_Eight : constant := 8;
Base_Ten : constant := 10;
Base_Sixteen : constant := 16;
-- Local program units
procedure Get_Character ( C : out Character ) is
begin
C := Character(Format(Source_Position + 1)); -- Convert Working_String_Type to Character
Source_Position := Source_Position + 1; -- Global symbol reference
exception
when Constraint_Error =>
raise End_Of_Format_String;
end Get_Character;
function Is_Digit (C : in Character ) return Boolean is
begin
return C in '0'..'9';
end Is_Digit;
function Zero_Fill (The_String : in String ) return String is
-- Local constants
Blank : constant character := ' ';
Zero : constant character := '0';
-- Working String
Temp_String : String(1..The_String'Length) := The_String;
begin
for Next_Character in Temp_String'range loop
exit when Temp_String(Next_Character) /= Blank;
Temp_String(Next_Character) := Zero;
end loop;
return Temp_String;
end Zero_Fill;
function Left_Justified(Data : in String) return String is
Blank : constant Character := ' ';
First : Natural := Data'First;
begin -- Left_Justified
-- Starting at the left, find first non-blank character
while Data(First) = Blank loop
First := First + 1;
end loop;
return Data(First..Data'Last) & Data(Data'First..First-1);
end Left_Justified;
procedure Format_Error(In_The_String : in out String;
Location : in out Positive;
Width : in Positive) is
Stars : String(1..Width) := (others => '*');
begin
In_The_String(Location..Location + Width - 1) := Stars;
Location := Location + Width;
end Format_Error;
-- Data format conversion procedures
procedure Format_character (Data : in Contents;
In_The_String : in out String;
Location : in out Natural;
Width : in Natural := 0;
Left_Justify : in Boolean := False) is separate;
procedure Format_string (Data : in Contents;
In_The_String : in out String;
Location : in out Natural;
Width : in Natural := 0;
Precision : in Natural := 0;
Left_Justify : in Boolean := False) is separate;
procedure Format_Number (Data : in Contents;
In_The_String : in out String;
Location : in out Natural;
Number_Base : in Natural := 10;
Width : in Natural := 0;
Left_Justify : in Boolean := False;
Fill_With_Zeros : in Boolean := False) is separate;
procedure Format_Real (Data : in Contents;
In_The_String : in out String;
Location : in out Natural;
Width : in Natural := 0;
Precision : in Natural := 0;
Exponent : in Natural := 0;
Fill_With_Zeros : in Boolean := False) is separate;
begin
For_All_Characters : loop
Get_Character(C);
case C is
when Escape_Character =>
-- a) a 3 digit octal number follows
-- b) a control character follows
-- \n is newline
-- \t is tab
-- \b is backspace
-- \r is carriage return
-- \f is form feed
-- c) a literal character follows
-- \\ is backslash character
-- \% is percent character
-- \ followed by any other character is output as is
Get_Character(C); -- Skip over Escape character
case C is
when '0'.. '7' => -- Convert octal string
Octal_value := (Character'pos(C) - Character'pos('0'));
for Next in 1..2 loop
Get_Character(C);
Octal_value := 8 * Octal_value + (Character'pos(C) - Character'pos('0'));
end loop;
Formatted_String(Target_Position) := Character'Val(Octal_value);
Target_Position := Target_Position + 1;
when 'n' => -- "\n" is a new line
Formatted_String(Target_Position..Target_Position + 1) := Ascii.Cr & Ascii.Lf;
Target_Position := Target_Position + 2;
when 't' => -- "\t" is a tab
Formatted_String(Target_Position) := Ascii.Ht;
Target_Position := Target_Position + 1;
when 'b' => -- "\b" is a backspace
Formatted_String(Target_Position) := Ascii.Bs;
Target_Position := Target_Position + 1;
when 'r' => -- "\r" is a carriage return
Formatted_String(Target_Position) := Ascii.Cr;
Target_Position := Target_Position + 1;
when 'f' => -- "\f" is a form feed
Formatted_String(Target_Position) := Ascii.Ff;
Target_Position := Target_Position + 1;
when '\' => -- "\\" is the '\' character
Formatted_String(Target_Position) := C;
Target_Position := Target_Position + 1;
when '%' => -- "\%" is the '%' character
Formatted_String(Target_Position) := C;
Target_Position := Target_Position + 1;
when others => -- Literal character
Formatted_String(Target_Position) := C;
Target_Position := Target_Position + 1;
end case;
when Data_Format =>
-- Format in form %-0w.pS where:
-- - specifies left justification
-- 0 specifies zero fill
-- w specifies the total field width (decimal value)
-- p specifies the precision width (decimal value)
-- s is the format specifier:
-- c - character
-- e - scientific (exponent) format
-- f - floating point
-- i - integer format
-- o - octal format
-- s - string
-- x - hexadecimal format
Get_Character(C); -- Skip over current data format character
-- Initialize data format flags and values
Left_Justify := False;
Fill_With_Zeros := False;
Specified_Width := 0;
Precision := 0;
-- Set data format flags and values
if C = '-' then -- Set Left-justify string
Left_justify := true;
Get_Character(C); -- Skip over current '-' character in FORMAT
end if;
if C = '0' then -- Set Zero fill string
Fill_with_zeros := true;
Get_Character(C); -- Skip over current '0' character in FORMAT
end if;
while Is_digit(C) loop -- Get field width
Specified_Width := 10 * Specified_Width + (Character'pos(C) - Character'pos('0'));
Get_Character(C);
end loop;
if C = '.' then -- Skip precision separator character
Get_Character(C);
end if;
while Is_digit(C) loop -- Get field precision
Precision := 10 * Precision + (Character'pos(C) - Character'pos('0'));
Get_Character(C);
end loop;
-- Exits with data format specifier in C
-- Process data item according to format specifier
Item := Item + 1; -- Get next data item to format
case C is -- Convert specification character
when 'c' | 'C' => Format_character(Data => Value(Item),
In_The_String => Formatted_String,
Location => Target_Position,
Width => Specified_Width,
Left_Justify => Left_Justify);
when 'e' | 'E' => Format_Real(Data => Value(Item), -- Scientific Notation
In_The_String => Formatted_String,
Location => Target_Position,
Width => Specified_Width,
Precision => Precision,
Exponent => 3,
Fill_With_Zeros => Fill_With_Zeros);
when 'f' | 'F' => Format_Real(Data => Value(Item), -- Floating Decimal
In_The_String => Formatted_String,
Location => Target_Position,
Width => Specified_Width,
Precision => Precision,
Fill_With_Zeros => Fill_With_Zeros);
when 'i' | 'I' => Format_Number(Data => Value(Item), -- Decimal Number
In_The_String => Formatted_String,
Location => Target_Position,
Number_Base => Base_Ten,
Width => Specified_Width,
Left_Justify => Left_Justify,
Fill_With_Zeros => Fill_With_Zeros);
when 'o' | 'O' => Format_Number(Data => Value(Item), -- Octal Number
In_The_String => Formatted_String,
Location => Target_Position,
Number_Base => Base_Eight,
Width => Specified_Width,
Left_Justify => Left_Justify,
Fill_With_Zeros => Fill_With_Zeros);
when 's' | 'S' => Format_string(Data => Value(Item),
In_The_String => Formatted_String,
Location => Target_Position,
Width => Specified_Width,
Precision => Precision,
Left_Justify => Left_Justify);
when 'x' | 'X' => Format_Number(Data => Value(Item), -- Hexadecimal Number
In_The_String => Formatted_String,
Location => Target_Position,
Number_Base => Base_Sixteen,
Width => Specified_Width,
Left_Justify => Left_Justify,
Fill_With_Zeros => Fill_With_Zeros);
when others => Format_Error(In_The_String => Formatted_String,
Location => Target_Position,
Width => Default_Width);
end case;
when others => -- Copy character
Formatted_String(Target_Position) := C;
Target_Position := Target_Position + 1;
end case;
end loop For_All_Characters;
return Formatted_String(1..Target_Position - 1);
exception
when End_of_format_string =>
return Formatted_String(1..Target_Position - 1);
end Get;
|
package Stack_Usage1_Pkg is
function Ident_Int (X : Integer) return Integer;
type R is
record
C0, C1, C2, C3, C4, C5, C6, C7, C8, C9 : Integer;
end record;
procedure My_Proc (X : R);
end Stack_Usage1_Pkg;
|
with Ada.Numerics.Generic_Elementary_Functions;
package body Pendulums is
package Math is new Ada.Numerics.Generic_Elementary_Functions (Float_Type);
function New_Pendulum (Length : Float_Type;
Theta0 : Float_Type) return Pendulum is
Result : Pendulum;
begin
Result.Length := Length;
Result.Theta := Theta0 / 180.0 * Ada.Numerics.Pi;
Result.X := Math.Sin (Theta0) * Length;
Result.Y := Math.Cos (Theta0) * Length;
Result.Velocity := 0.0;
return Result;
end New_Pendulum;
function Get_X (From : Pendulum) return Float_Type is
begin
return From.X;
end Get_X;
function Get_Y (From : Pendulum) return Float_Type is
begin
return From.Y;
end Get_Y;
procedure Update_Pendulum (Item : in out Pendulum; Time : in Duration) is
Acceleration : constant Float_Type := Gravitation / Item.Length *
Math.Sin (Item.Theta);
begin
Item.X := Math.Sin (Item.Theta) * Item.Length;
Item.Y := Math.Cos (Item.Theta) * Item.Length;
Item.Velocity := Item.Velocity +
Acceleration * Float_Type (Time);
Item.Theta := Item.Theta +
Item.Velocity * Float_Type (Time);
end Update_Pendulum;
end Pendulums;
|
pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
package SDL_blendmode_h is
-- Simple DirectMedia Layer
-- Copyright (C) 1997-2018 Sam Lantinga <slouken@libsdl.org>
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
-- 3. This notice may not be removed or altered from any source distribution.
--
--*
-- * \file SDL_blendmode.h
-- *
-- * Header file declaring the SDL_BlendMode enumeration
--
-- Set up for C function definitions, even when using C++
--*
-- * \brief The blend mode used in SDL_RenderCopy() and drawing operations.
--
--*< no blending
-- dstRGBA = srcRGBA
--*< alpha blending
-- dstRGB = (srcRGB * srcA) + (dstRGB * (1-srcA))
-- dstA = srcA + (dstA * (1-srcA))
--*< additive blending
-- dstRGB = (srcRGB * srcA) + dstRGB
-- dstA = dstA
--*< color modulate
-- dstRGB = srcRGB * dstRGB
-- dstA = dstA
-- Additional custom blend modes can be returned by SDL_ComposeCustomBlendMode()
subtype SDL_BlendMode is unsigned;
SDL_BLENDMODE_NONE : constant unsigned := 0;
SDL_BLENDMODE_BLEND : constant unsigned := 1;
SDL_BLENDMODE_ADD : constant unsigned := 2;
SDL_BLENDMODE_MOD : constant unsigned := 4;
SDL_BLENDMODE_INVALID : constant unsigned := 2147483647; -- ..\SDL2_tmp\SDL_blendmode.h:57
--*
-- * \brief The blend operation used when combining source and destination pixel components
--
--*< dst + src: supported by all renderers
--*< dst - src : supported by D3D9, D3D11, OpenGL, OpenGLES
--*< src - dst : supported by D3D9, D3D11, OpenGL, OpenGLES
--*< min(dst, src) : supported by D3D11
--*< max(dst, src) : supported by D3D11
subtype SDL_BlendOperation is unsigned;
SDL_BLENDOPERATION_ADD : constant unsigned := 1;
SDL_BLENDOPERATION_SUBTRACT : constant unsigned := 2;
SDL_BLENDOPERATION_REV_SUBTRACT : constant unsigned := 3;
SDL_BLENDOPERATION_MINIMUM : constant unsigned := 4;
SDL_BLENDOPERATION_MAXIMUM : constant unsigned := 5; -- ..\SDL2_tmp\SDL_blendmode.h:70
--*
-- * \brief The normalized factor used to multiply pixel components
--
--*< 0, 0, 0, 0
--*< 1, 1, 1, 1
--*< srcR, srcG, srcB, srcA
--*< 1-srcR, 1-srcG, 1-srcB, 1-srcA
--*< srcA, srcA, srcA, srcA
--*< 1-srcA, 1-srcA, 1-srcA, 1-srcA
--*< dstR, dstG, dstB, dstA
--*< 1-dstR, 1-dstG, 1-dstB, 1-dstA
--*< dstA, dstA, dstA, dstA
--*< 1-dstA, 1-dstA, 1-dstA, 1-dstA
subtype SDL_BlendFactor is unsigned;
SDL_BLENDFACTOR_ZERO : constant unsigned := 1;
SDL_BLENDFACTOR_ONE : constant unsigned := 2;
SDL_BLENDFACTOR_SRC_COLOR : constant unsigned := 3;
SDL_BLENDFACTOR_ONE_MINUS_SRC_COLOR : constant unsigned := 4;
SDL_BLENDFACTOR_SRC_ALPHA : constant unsigned := 5;
SDL_BLENDFACTOR_ONE_MINUS_SRC_ALPHA : constant unsigned := 6;
SDL_BLENDFACTOR_DST_COLOR : constant unsigned := 7;
SDL_BLENDFACTOR_ONE_MINUS_DST_COLOR : constant unsigned := 8;
SDL_BLENDFACTOR_DST_ALPHA : constant unsigned := 9;
SDL_BLENDFACTOR_ONE_MINUS_DST_ALPHA : constant unsigned := 10; -- ..\SDL2_tmp\SDL_blendmode.h:88
--*
-- * \brief Create a custom blend mode, which may or may not be supported by a given renderer
-- *
-- * \param srcColorFactor
-- * \param dstColorFactor
-- * \param colorOperation
-- * \param srcAlphaFactor
-- * \param dstAlphaFactor
-- * \param alphaOperation
-- *
-- * The result of the blend mode operation will be:
-- * dstRGB = dstRGB * dstColorFactor colorOperation srcRGB * srcColorFactor
-- * and
-- * dstA = dstA * dstAlphaFactor alphaOperation srcA * srcAlphaFactor
--
function SDL_ComposeCustomBlendMode
(srcColorFactor : SDL_BlendFactor;
dstColorFactor : SDL_BlendFactor;
colorOperation : SDL_BlendOperation;
srcAlphaFactor : SDL_BlendFactor;
dstAlphaFactor : SDL_BlendFactor;
alphaOperation : SDL_BlendOperation) return SDL_BlendMode; -- ..\SDL2_tmp\SDL_blendmode.h:105
pragma Import (C, SDL_ComposeCustomBlendMode, "SDL_ComposeCustomBlendMode");
-- Ends C function definitions when using C++
-- vi: set ts=4 sw=4 expandtab:
end SDL_blendmode_h;
|
pragma License (Unrestricted);
with System.File_Control_Block;
package System.File_IO is
pragma Preelaborate;
procedure Check_File_Open (File : File_Control_Block.AFCB_Ptr);
end System.File_IO;
|
package Opt59_Pkg is
type Boolean_Vector is array (1 .. 8) of Boolean;
function Get_BV1 return Boolean_Vector;
function Get_BV2 return Boolean_Vector;
procedure Test (B : Boolean);
end Opt59_Pkg;
|
package body COBS.Stream.Decoder is
subtype Dispatch is Instance'Class;
--------------
-- Do_Flush --
--------------
procedure Do_Flush (This : in out Instance) is
begin
if This.Out_Index > This.Buffer'First then
Dispatch (This).Flush
(This.Buffer (This.Buffer'First .. This.Out_Index - 1));
end if;
This.Out_Index := This.Buffer'First;
end Do_Flush;
----------
-- Push --
----------
procedure Push (This : in out Instance; Data : Storage_Element) is
begin
if This.Start_Of_Frame then
This.Code := Data;
This.Last_Code := This.Code;
This.Start_Of_Frame := False;
if This.Code = 0 then
raise Program_Error;
end if;
elsif This.Code > 1 then
This.Buffer (This.Out_Index) := Data;
This.Out_Index := This.Out_Index + 1;
This.Code := This.Code - 1;
else
if Data /= 0 and then This.Last_Code /= 16#FF# then
This.Buffer (This.Out_Index) := 0;
This.Out_Index := This.Out_Index + 1;
end if;
This.Code := Data;
This.Last_Code := This.Code;
This.Do_Flush;
if Data = 0 then
Dispatch (This).End_Of_Frame;
This.Start_Of_Frame := True;
end if;
end if;
end Push;
end COBS.Stream.Decoder;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2013, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.OCL.Any_Types;
with AMF.OCL.Association_Class_Call_Exps;
with AMF.OCL.Bag_Types;
with AMF.OCL.Boolean_Literal_Exps;
with AMF.OCL.Collection_Items;
with AMF.OCL.Collection_Literal_Exps;
with AMF.OCL.Collection_Ranges;
with AMF.OCL.Collection_Types;
with AMF.OCL.Enum_Literal_Exps;
with AMF.OCL.Expression_In_Ocls;
with AMF.OCL.If_Exps;
with AMF.OCL.Integer_Literal_Exps;
with AMF.OCL.Invalid_Literal_Exps;
with AMF.OCL.Invalid_Types;
with AMF.OCL.Iterate_Exps;
with AMF.OCL.Iterator_Exps;
with AMF.OCL.Let_Exps;
with AMF.OCL.Message_Exps;
with AMF.OCL.Message_Types;
with AMF.OCL.Null_Literal_Exps;
with AMF.OCL.Operation_Call_Exps;
with AMF.OCL.Ordered_Set_Types;
with AMF.OCL.Property_Call_Exps;
with AMF.OCL.Real_Literal_Exps;
with AMF.OCL.Sequence_Types;
with AMF.OCL.Set_Types;
with AMF.OCL.State_Exps;
with AMF.OCL.String_Literal_Exps;
with AMF.OCL.Template_Parameter_Types;
with AMF.OCL.Tuple_Literal_Exps;
with AMF.OCL.Tuple_Literal_Parts;
with AMF.OCL.Tuple_Types;
with AMF.OCL.Type_Exps;
with AMF.OCL.Unlimited_Natural_Literal_Exps;
with AMF.OCL.Unspecified_Value_Exps;
with AMF.OCL.Variable_Exps;
with AMF.OCL.Variables;
with AMF.OCL.Void_Types;
package AMF.Factories.OCL_Factories is
pragma Preelaborate;
type OCL_Factory is limited interface
and AMF.Factories.Factory;
type OCL_Factory_Access is access all OCL_Factory'Class;
for OCL_Factory_Access'Storage_Size use 0;
not overriding function Create_Any_Type
(Self : not null access OCL_Factory)
return AMF.OCL.Any_Types.OCL_Any_Type_Access is abstract;
not overriding function Create_Association_Class_Call_Exp
(Self : not null access OCL_Factory)
return AMF.OCL.Association_Class_Call_Exps.OCL_Association_Class_Call_Exp_Access is abstract;
not overriding function Create_Bag_Type
(Self : not null access OCL_Factory)
return AMF.OCL.Bag_Types.OCL_Bag_Type_Access is abstract;
not overriding function Create_Boolean_Literal_Exp
(Self : not null access OCL_Factory)
return AMF.OCL.Boolean_Literal_Exps.OCL_Boolean_Literal_Exp_Access is abstract;
not overriding function Create_Collection_Item
(Self : not null access OCL_Factory)
return AMF.OCL.Collection_Items.OCL_Collection_Item_Access is abstract;
not overriding function Create_Collection_Literal_Exp
(Self : not null access OCL_Factory)
return AMF.OCL.Collection_Literal_Exps.OCL_Collection_Literal_Exp_Access is abstract;
not overriding function Create_Collection_Range
(Self : not null access OCL_Factory)
return AMF.OCL.Collection_Ranges.OCL_Collection_Range_Access is abstract;
not overriding function Create_Collection_Type
(Self : not null access OCL_Factory)
return AMF.OCL.Collection_Types.OCL_Collection_Type_Access is abstract;
not overriding function Create_Enum_Literal_Exp
(Self : not null access OCL_Factory)
return AMF.OCL.Enum_Literal_Exps.OCL_Enum_Literal_Exp_Access is abstract;
not overriding function Create_Expression_In_Ocl
(Self : not null access OCL_Factory)
return AMF.OCL.Expression_In_Ocls.OCL_Expression_In_Ocl_Access is abstract;
not overriding function Create_If_Exp
(Self : not null access OCL_Factory)
return AMF.OCL.If_Exps.OCL_If_Exp_Access is abstract;
not overriding function Create_Integer_Literal_Exp
(Self : not null access OCL_Factory)
return AMF.OCL.Integer_Literal_Exps.OCL_Integer_Literal_Exp_Access is abstract;
not overriding function Create_Invalid_Literal_Exp
(Self : not null access OCL_Factory)
return AMF.OCL.Invalid_Literal_Exps.OCL_Invalid_Literal_Exp_Access is abstract;
not overriding function Create_Invalid_Type
(Self : not null access OCL_Factory)
return AMF.OCL.Invalid_Types.OCL_Invalid_Type_Access is abstract;
not overriding function Create_Iterate_Exp
(Self : not null access OCL_Factory)
return AMF.OCL.Iterate_Exps.OCL_Iterate_Exp_Access is abstract;
not overriding function Create_Iterator_Exp
(Self : not null access OCL_Factory)
return AMF.OCL.Iterator_Exps.OCL_Iterator_Exp_Access is abstract;
not overriding function Create_Let_Exp
(Self : not null access OCL_Factory)
return AMF.OCL.Let_Exps.OCL_Let_Exp_Access is abstract;
not overriding function Create_Message_Exp
(Self : not null access OCL_Factory)
return AMF.OCL.Message_Exps.OCL_Message_Exp_Access is abstract;
not overriding function Create_Message_Type
(Self : not null access OCL_Factory)
return AMF.OCL.Message_Types.OCL_Message_Type_Access is abstract;
not overriding function Create_Null_Literal_Exp
(Self : not null access OCL_Factory)
return AMF.OCL.Null_Literal_Exps.OCL_Null_Literal_Exp_Access is abstract;
not overriding function Create_Operation_Call_Exp
(Self : not null access OCL_Factory)
return AMF.OCL.Operation_Call_Exps.OCL_Operation_Call_Exp_Access is abstract;
not overriding function Create_Ordered_Set_Type
(Self : not null access OCL_Factory)
return AMF.OCL.Ordered_Set_Types.OCL_Ordered_Set_Type_Access is abstract;
not overriding function Create_Property_Call_Exp
(Self : not null access OCL_Factory)
return AMF.OCL.Property_Call_Exps.OCL_Property_Call_Exp_Access is abstract;
not overriding function Create_Real_Literal_Exp
(Self : not null access OCL_Factory)
return AMF.OCL.Real_Literal_Exps.OCL_Real_Literal_Exp_Access is abstract;
not overriding function Create_Sequence_Type
(Self : not null access OCL_Factory)
return AMF.OCL.Sequence_Types.OCL_Sequence_Type_Access is abstract;
not overriding function Create_Set_Type
(Self : not null access OCL_Factory)
return AMF.OCL.Set_Types.OCL_Set_Type_Access is abstract;
not overriding function Create_State_Exp
(Self : not null access OCL_Factory)
return AMF.OCL.State_Exps.OCL_State_Exp_Access is abstract;
not overriding function Create_String_Literal_Exp
(Self : not null access OCL_Factory)
return AMF.OCL.String_Literal_Exps.OCL_String_Literal_Exp_Access is abstract;
not overriding function Create_Template_Parameter_Type
(Self : not null access OCL_Factory)
return AMF.OCL.Template_Parameter_Types.OCL_Template_Parameter_Type_Access is abstract;
not overriding function Create_Tuple_Literal_Exp
(Self : not null access OCL_Factory)
return AMF.OCL.Tuple_Literal_Exps.OCL_Tuple_Literal_Exp_Access is abstract;
not overriding function Create_Tuple_Literal_Part
(Self : not null access OCL_Factory)
return AMF.OCL.Tuple_Literal_Parts.OCL_Tuple_Literal_Part_Access is abstract;
not overriding function Create_Tuple_Type
(Self : not null access OCL_Factory)
return AMF.OCL.Tuple_Types.OCL_Tuple_Type_Access is abstract;
not overriding function Create_Type_Exp
(Self : not null access OCL_Factory)
return AMF.OCL.Type_Exps.OCL_Type_Exp_Access is abstract;
not overriding function Create_Unlimited_Natural_Literal_Exp
(Self : not null access OCL_Factory)
return AMF.OCL.Unlimited_Natural_Literal_Exps.OCL_Unlimited_Natural_Literal_Exp_Access is abstract;
not overriding function Create_Unspecified_Value_Exp
(Self : not null access OCL_Factory)
return AMF.OCL.Unspecified_Value_Exps.OCL_Unspecified_Value_Exp_Access is abstract;
not overriding function Create_Variable
(Self : not null access OCL_Factory)
return AMF.OCL.Variables.OCL_Variable_Access is abstract;
not overriding function Create_Variable_Exp
(Self : not null access OCL_Factory)
return AMF.OCL.Variable_Exps.OCL_Variable_Exp_Access is abstract;
not overriding function Create_Void_Type
(Self : not null access OCL_Factory)
return AMF.OCL.Void_Types.OCL_Void_Type_Access is abstract;
end AMF.Factories.OCL_Factories;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2018-2021, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with System.Storage_Elements;
with HAL; use HAL;
private with System;
package USB is
subtype EP_Id is UInt4;
type EP_Dir is (EP_In, EP_Out);
type EP_Addr is record
Num : EP_Id;
Dir : EP_Dir;
end record;
type EP_Type is (Control, Isochronous, Bulk, Interrupt);
for EP_Type use (Control => 0,
Isochronous => 1,
Bulk => 2,
Interrupt => 3);
type Data_Phase_Transfer_Direction is (Host_To_Device,
Device_To_Host)
with Size => 1;
for Data_Phase_Transfer_Direction use (Host_To_Device => 0,
Device_To_Host => 1);
type Request_Type_Type is (Stand, Class, Vendor, Reserved)
with Size => 2;
for Request_Type_Type use (Stand => 0,
Class => 1,
Vendor => 2,
Reserved => 3);
type Request_Type_Recipient is (Dev, Iface, Endpoint, Other);
for Request_Type_Recipient use (Dev => 0,
Iface => 1,
Endpoint => 2,
Other => 3);
type Request_Type is record
Recipient : Request_Type_Recipient;
Reserved : UInt3;
Typ : Request_Type_Type;
Dir : Data_Phase_Transfer_Direction;
end record with Pack, Size => 8;
type Setup_Data is record
RType : Request_Type;
Request : UInt8;
Value : UInt16;
Index : UInt16;
Length : UInt16;
end record with Pack, Size => 8 * 8;
function Img (D : Setup_Data) return String
is ("Type: (" & D.RType.Dir'Img & "," & D.RType.Typ'Img & "," &
D.RType.Recipient'Img & ")" &
" Req:" & D.Request'Img &
" Val:" & D.Value'Img &
" Index:" & D.Index'Img &
" Len:" & D.Length'Img);
function Img (EP : EP_Addr) return String
is ("[" & EP.Dir'Img & EP.Num'Img & "]");
type String_Id is new UInt8;
Invalid_String_Id : constant String_Id := 0;
type Lang_ID is new UInt16;
type Interface_Id is new UInt8;
type Device_Descriptor is record
bLength : UInt8;
bDescriptorType : UInt8;
bcdUSB : UInt16;
bDeviceClass : UInt8;
bDeviceSubClass : UInt8;
bDeviceProtocol : UInt8;
bMaxPacketSize0 : UInt8;
idVendor : UInt16;
idProduct : UInt16;
bcdDevice : UInt16;
iManufacturer : String_Id;
iProduct : String_Id;
iSerialNumber : String_Id;
bNumConfigurations : UInt8;
end record with Pack;
type Device_Qualifier is record
bLength : UInt8;
bDescriptorType : UInt8;
bcdUSB : UInt16;
bDeviceClass : UInt8;
bDeviceSubClass : UInt8;
bDeviceProtocol : UInt8;
bMaxPacketSize0 : UInt8;
bNumConfigurations : UInt8;
bReserved : UInt8;
end record with Pack;
type String_Descriptor_Zero is record
bLength : UInt8;
bDescriptorType : UInt8 := 3;
Str : String (1 .. 2);
end record;
subtype String_Range is UInt8 range 0 .. 253;
-- The maximum length of a string is limited by the the bLength field of the
-- String Descriptor. This field is one byte: 0 .. 255, but bLength encodes
-- to total size of the descriptor including the bLenght and bDescriptorType
-- fields (one byte each). So the remaining length for string is 255 - 2.
type USB_String is array (String_Range range <>) of Character;
function To_USB_String (Str : String) return USB_String
with Pre => Str'Length * 2 <= String_Range'Last - String_Range'First + 1;
-- Convert Ada ASCII string to USB UTF16 string
type String_Descriptor (bLength : UInt8) is record
bDescriptorType : UInt8 := 3;
Str : USB_String (3 .. bLength);
end record with Pack;
type Setup_Request_Answer is (Handled, Not_Supported, Next_Callback);
subtype Buffer_Len is System.Storage_Elements.Storage_Offset;
Verbose : constant Boolean := False;
Logs_Enabled : constant Boolean := True;
Control_Buffer_Size : constant := 256;
Max_Strings : constant := 5;
Max_Total_String_Chars : constant := 256;
end USB;
|
with Ada.Text_IO;
procedure Vignere_Cryptanalysis is
subtype Letter is Character range 'A' .. 'Z';
function "+"(X, Y: Letter) return Letter is
begin
return Character'Val( ( (Character'Pos(X)-Character'Pos('A'))
+ (Character'Pos(Y)-Character'Pos('A')) ) mod 26
+ Character'Pos('A'));
end;
function "-"(X, Y: Letter) return Letter is
begin
return Character'Val( ( (Character'Pos(X)-Character'Pos('A'))
- (Character'Pos(Y)-Character'Pos('A')) ) mod 26
+ Character'Pos('A'));
end;
type Frequency_Array is array (Letter) of Float;
English: Frequency_Array :=
( 0.08167, 0.01492, 0.02782, 0.04253, 0.12702, 0.02228, 0.02015,
0.06094, 0.06966, 0.00153, 0.00772, 0.04025, 0.02406, 0.06749,
0.07507, 0.01929, 0.00095, 0.05987, 0.06327, 0.09056, 0.02758,
0.00978, 0.02360, 0.00150, 0.01974, 0.00074 );
function Get_Frequency(S: String) return Frequency_Array is
Result: Frequency_Array := (others => 0.0);
Offset: Float := 1.0/Float(S'Length);
begin
for I in S'Range loop
if S(I) in Letter then
Result(S(I)) := Result(S(I)) + Offset;
end if;
end loop;
return Result;
end Get_Frequency;
function Remove_Whitespace(S: String) return String is
begin
if S="" then
return "";
elsif S(S'First) in Letter then
return S(S'First) & Remove_Whitespace(S(S'First+1 .. S'Last));
else
return Remove_Whitespace(S(S'First+1 .. S'Last));
end if;
end Remove_Whitespace;
function Distance(A, B: Frequency_Array;
Offset: Character := 'A') return Float is
Result: Float := 0.0;
Diff: Float;
begin
for C in A'Range loop
Diff := A(C+Offset) - B(C);
Result := Result + (Diff * Diff);
end loop;
return Result;
end Distance;
function Find_Key(Cryptogram: String; Key_Length: Positive) return String is
function Find_Caesar_Key(S: String) return Letter is
Frequency: Frequency_Array := Get_Frequency(S);
Candidate: Letter := 'A'; -- a fake candidate
Candidate_Dist : Float := Distance(Frequency, English, 'A');
New_Dist: Float;
begin
for L in Letter range 'B' .. 'Z' loop
New_Dist := Distance(Frequency, English, L);
if New_Dist <= Candidate_Dist then
Candidate_Dist := New_Dist;
Candidate := L;
end if;
end loop;
return Candidate;
end Find_Caesar_Key;
function Get_Slide(S: String; Step: Positive) return String is
begin
if S'Length= 0 then
return "";
else
return S(S'First) & Get_Slide(S(S'First+Step .. S'Last), Step);
end if;
end Get_Slide;
Key: String(1 .. Key_Length);
S: String renames Cryptogram;
begin
for I in Key'Range loop
Key(I) := Find_Caesar_Key(Get_Slide(S(S'First+I-1 .. S'Last),
Key_Length));
end loop;
return Key;
end Find_Key;
function Key_Char(Key: String; Index: Positive) return Letter is
begin
if Index > Key'Last then
return Key_Char(Key, Index-Key'Last);
else
return Key(Index);
end if;
end Key_Char;
Ciphertext: String := Remove_Whitespace(
"MOMUD EKAPV TQEFM OEVHP AJMII CDCTI FGYAG JSPXY ALUYM NSMYH" &
"VUXJE LEPXJ FXGCM JHKDZ RYICU HYPUS PGIGM OIYHF WHTCQ KMLRD" &
"ITLXZ LJFVQ GHOLW CUHLO MDSOE KTALU VYLNZ RFGBX PHVGA LWQIS" &
"FGRPH JOOFW GUBYI LAPLA LCAFA AMKLG CETDW VOELJ IKGJB XPHVG" &
"ALWQC SNWBU BYHCU HKOCE XJEYK BQKVY KIIEH GRLGH XEOLW AWFOJ" &
"ILOVV RHPKD WIHKN ATUHN VRYAQ DIVHX FHRZV QWMWV LGSHN NLVZS" &
"JLAKI FHXUF XJLXM TBLQV RXXHR FZXGV LRAJI EXPRV OSMNP KEPDT" &
"LPRWM JAZPK LQUZA ALGZX GVLKL GJTUI ITDSU REZXJ ERXZS HMPST" &
"MTEOE PAPJH SMFNB YVQUZ AALGA YDNMP AQOWT UHDBV TSMUE UIMVH" &
"QGVRW AEFSP EMPVE PKXZY WLKJA GWALT VYYOB YIXOK IHPDS EVLEV" &
"RVSGB JOGYW FHKBL GLXYA MVKIS KIEHY IMAPX UOISK PVAGN MZHPW" &
"TTZPV XFCCD TUHJH WLAPF YULTB UXJLN SIJVV YOVDJ SOLXG TGRVO" &
"SFRII CTMKO JFCQF KTINQ BWVHG TENLH HOGCS PSFPV GJOKM SIFPR" &
"ZPAAS ATPTZ FTPPD PORRF TAXZP KALQA WMIUD BWNCT LEFKO ZQDLX" &
"BUXJL ASIMR PNMBF ZCYLV WAPVF QRHZV ZGZEF KBYIO OFXYE VOWGB" &
"BXVCB XBAWG LQKCM ICRRX MACUO IKHQU AJEGL OIJHH XPVZW JEWBA" &
"FWAML ZZRXJ EKAHV FASMU LVVUT TGK");
Best_Plain: String := Ciphertext;
Best_Dist: Float := Distance(English, Get_Frequency(Best_Plain));
Best_Key: String := Ciphertext;
Best_Key_L: Natural := 0;
begin -- Vignere_Cryptanalysis
for I in 1 .. Ciphertext'Length/10 loop
declare
Key: String(1 .. I) := Find_Key(Ciphertext, I);
Plaintext: String(Ciphertext'Range);
begin
for I in Ciphertext'Range loop
Plaintext(I) := Ciphertext(I) - Key_Char(Key, I);
end loop;
if Distance(English, Get_Frequency(Plaintext)) < Best_Dist then
Best_Plain := Plaintext;
Best_Dist := Distance(English, Get_Frequency(Plaintext));
Best_Key(1 .. I) := Key;
Best_Key_L := I;
if Best_dist < 0.01 then
declare
use Ada.Text_IO;
begin
Put_Line("Key =" & Best_Key(1 .. Best_Key_L));
Put_Line("Distance = " & Float'Image(Best_Dist));
New_Line;
Put_Line("Plaintext =");
Put_Line(Best_Plain);
New_Line; New_Line;
end;
end if;
end if;
end;
end loop;
end Vignere_Cryptanalysis;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- I M P U N I T --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 2000-2001 Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Lib; use Lib;
with Namet; use Namet;
with Opt; use Opt;
package body Impunit is
subtype File_Name_8 is String (1 .. 8);
type File_List is array (Nat range <>) of File_Name_8;
-- The following is a giant string containing the concenated names
-- of all non-implementation internal files, i.e. the complete list
-- of files for internal units which a program may legitimately WITH.
-- Note that this list should match the list of units documented in
-- the "GNAT Library" section of the GNAT Reference Manual.
Non_Imp_File_Names : File_List := (
-----------------------------------------------
-- Ada Hierarchy Units from Reference Manual --
-----------------------------------------------
"a-astaco", -- Ada.Asynchronous_Task_Control
"a-calend", -- Ada.Calendar
"a-chahan", -- Ada.Characters.Handling
"a-charac", -- Ada.Characters
"a-chlat1", -- Ada.Characters.Latin_1
"a-comlin", -- Ada.Command_Line
"a-decima", -- Ada.Decimal
"a-direio", -- Ada.Direct_IO
"a-dynpri", -- Ada.Dynamic_Priorities
"a-except", -- Ada.Exceptions
"a-finali", -- Ada.Finalization
"a-flteio", -- Ada.Float_Text_IO
"a-fwteio", -- Ada.Float_Wide_Text_IO
"a-inteio", -- Ada.Integer_Text_IO
"a-interr", -- Ada.Interrupts
"a-intnam", -- Ada.Interrupts.Names
"a-ioexce", -- Ada.IO_Exceptions
"a-iwteio", -- Ada.Integer_Wide_Text_IO
"a-ncelfu", -- Ada.Numerics.Complex_Elementary_Functions
"a-ngcefu", -- Ada.Numerics.Generic_Complex_Elementary_Functions
"a-ngcoty", -- Ada.Numerics.Generic_Complex_Types
"a-ngelfu", -- Ada.Numerics.Generic_Elementary_Functions
"a-nucoty", -- Ada.Numerics.Complex_Types
"a-nudira", -- Ada.Numerics.Discrete_Random
"a-nuelfu", -- Ada.Numerics.Elementary_Functions
"a-nuflra", -- Ada.Numerics.Float_Random
"a-numeri", -- Ada.Numerics
"a-reatim", -- Ada.Real_Time
"a-sequio", -- Ada.Sequential_IO
"a-stmaco", -- Ada.Strings.Maps.Constants
"a-storio", -- Ada.Storage_IO
"a-strbou", -- Ada.Strings.Bounded
"a-stream", -- Ada.Streams
"a-strfix", -- Ada.Strings.Fixed
"a-string", -- Ada.Strings
"a-strmap", -- Ada.Strings.Maps
"a-strunb", -- Ada.Strings.Unbounded
"a-ststio", -- Ada.Streams.Stream_IO
"a-stwibo", -- Ada.Strings.Wide_Bounded
"a-stwifi", -- Ada.Strings.Wide_Fixed
"a-stwima", -- Ada.Strings.Wide_Maps
"a-stwiun", -- Ada.Strings.Wide_Unbounded
"a-swmwco", -- Ada.Strings.Wide_Maps.Wide_Constants
"a-sytaco", -- Ada.Synchronous_Task_Control
"a-tags ", -- Ada.Tags
"a-tasatt", -- Ada.Task_Attributes
"a-taside", -- Ada.Task_Identification
"a-teioed", -- Ada.Text_IO.Editing
"a-textio", -- Ada.Text_IO
"a-ticoio", -- Ada.Text_IO.Complex_IO
"a-titest", -- Ada.Text_IO.Text_Streams
"a-unccon", -- Ada.Unchecked_Conversion
"a-uncdea", -- Ada.Unchecked_Deallocation
"a-witeio", -- Ada.Wide_Text_IO
"a-wtcoio", -- Ada.Wide_Text_IO.Complex_IO
"a-wtedit", -- Ada.Wide_Text_IO.Editing
"a-wttest", -- Ada.Wide_Text_IO.Text_Streams
-------------------------------------------------
-- RM Required Additions to Ada for GNAT Types --
-------------------------------------------------
"a-lfteio", -- Ada.Long_Float_Text_IO
"a-lfwtio", -- Ada.Long_Float_Wide_Text_IO
"a-liteio", -- Ada.Long_Integer_Text_IO
"a-liwtio", -- Ada.Long_Integer_Wide_Text_IO
"a-llftio", -- Ada.Long_Long_Float_Text_IO
"a-llfwti", -- Ada.Long_Long_Float_Wide_Text_IO
"a-llitio", -- Ada.Long_Long_Integer_Text_IO
"a-lliwti", -- Ada.Long_Long_Integer_Wide_Text_IO
"a-nlcefu", -- Ada.Long_Complex_Elementary_Functions
"a-nlcoty", -- Ada.Numerics.Long_Complex_Types
"a-nlelfu", -- Ada.Numerics.Long_Elementary_Functions
"a-nllcef", -- Ada.Long_Long_Complex_Elementary_Functions
"a-nllefu", -- Ada.Numerics.Long_Long_Elementary_Functions
"a-nltcty", -- Ada.Numerics.Long_Long_Complex_Types
"a-nscefu", -- Ada.Short_Complex_Elementary_Functions
"a-nscoty", -- Ada.Numerics.Short_Complex_Types
"a-nselfu", -- Ada.Numerics.Short_Elementary_Functions
"a-sfteio", -- Ada.Short_Float_Text_IO
"a-sfwtio", -- Ada.Short_Float_Wide_Text_IO
"a-siteio", -- Ada.Short_Integer_Text_IO
"a-siwtio", -- Ada.Short_Integer_Wide_Text_IO
"a-ssitio", -- Ada.Short_Short_Integer_Text_IO
"a-ssiwti", -- Ada.Short_Short_Integer_Wide_Text_IO
-----------------------------------
-- GNAT Defined Additions to Ada --
-----------------------------------
"a-colire", -- Ada.Command_Line.Remove
"a-cwila1", -- Ada.Characters.Wide_Latin_1
"a-diocst", -- Ada.Direct_IO.C_Streams
"a-einuoc", -- Ada.Exceptions.Is_Null_Occurrence
"a-siocst", -- Ada.Sequential_IO.C_Streams
"a-ssicst", -- Ada.Streams.Stream_IO.C_Streams
"a-suteio", -- Ada.Strings.Unbounded.Text_IO
"a-swuwti", -- Ada.Strings.Wide_Unbounded.Wide_Text_IO
"a-taidim", -- Ada.Task_Identification.Image
"a-tiocst", -- Ada.Text_IO.C_Streams
"a-wtcstr", -- Ada.Wide_Text_IO.C_Streams
---------------------------
-- GNAT Special IO Units --
---------------------------
-- As further explained elsewhere (see Sem_Ch10), the internal
-- packages of Text_IO and Wide_Text_IO are actually implemented
-- as separate children, but this fact is intended to be hidden
-- from the user completely. Any attempt to WITH one of these
-- units will be diagnosed as an error later on, but for now we
-- do not consider these internal implementation units (if we did,
-- then we would get a junk warning which would be confusing and
-- unecessary, given that we generate a clear error message).
"a-tideio", -- Ada.Text_IO.Decimal_IO
"a-tienio", -- Ada.Text_IO.Enumeration_IO
"a-tifiio", -- Ada.Text_IO.Fixed_IO
"a-tiflio", -- Ada.Text_IO.Float_IO
"a-tiinio", -- Ada.Text_IO.Integer_IO
"a-tiinio", -- Ada.Text_IO.Integer_IO
"a-timoio", -- Ada.Text_IO.Modular_IO
"a-wtdeio", -- Ada.Wide_Text_IO.Decimal_IO
"a-wtenio", -- Ada.Wide_Text_IO.Enumeration_IO
"a-wtfiio", -- Ada.Wide_Text_IO.Fixed_IO
"a-wtflio", -- Ada.Wide_Text_IO.Float_IO
"a-wtinio", -- Ada.Wide_Text_IO.Integer_IO
"a-wtmoio", -- Ada.Wide_Text_IO.Modular_IO
------------------------
-- GNAT Library Units --
------------------------
"g-awk ", -- GNAT.AWK
"g-busora", -- GNAT.Bubble_Sort_A
"g-busorg", -- GNAT.Bubble_Sort_G
"g-calend", -- GNAT.Calendar
"g-catiio", -- GNAT.Calendar.Time_IO
"g-casuti", -- GNAT.Case_Util
"g-cgi ", -- GNAT.CGI
"g-cgicoo", -- GNAT.CGI.Cookie
"g-cgideb", -- GNAT.CGI.Debug
"g-comlin", -- GNAT.Command_Line
"g-crc32 ", -- GNAT.CRC32
"g-curexc", -- GNAT.Current_Exception
"g-debpoo", -- GNAT.Debug_Pools
"g-debuti", -- GNAT.Debug_Utilities
"g-diopit", -- GNAT.Directory_Operations.Iteration
"g-dirope", -- GNAT.Directory_Operations
"g-dyntab", -- GNAT.Dynamic_Tables
"g-exctra", -- GNAT.Exception_Traces
"g-expect", -- GNAT.Expect
"g-flocon", -- GNAT.Float_Control
"g-htable", -- GNAT.Htable
"g-hesora", -- GNAT.Heap_Sort_A
"g-hesorg", -- GNAT.Heap_Sort_G
"g-io ", -- GNAT.IO
"g-io_aux", -- GNAT.IO_Aux
"g-locfil", -- GNAT.Lock_Files
"g-moreex", -- GNAT.Most_Recent_Exception
"g-os_lib", -- GNAT.Os_Lib
"g-regexp", -- GNAT.Regexp
"g-regist", -- GNAT.Registry
"g-regpat", -- GNAT.Regpat
"g-socket", -- GNAT.Sockets
"g-sptabo", -- GNAT.Spitbol.Table_Boolean
"g-sptain", -- GNAT.Spitbol.Table_Integer
"g-sptavs", -- GNAT.Spitbol.Table_Vstring
"g-souinf", -- GNAT.Source_Info
"g-speche", -- GNAT.Spell_Checker
"g-spitbo", -- GNAT.Spitbol
"g-spipat", -- GNAT.Spitbol.Patterns
"g-table ", -- GNAT.Table
"g-tasloc", -- GNAT.Task_Lock
"g-thread", -- GNAT.Threads
"g-traceb", -- GNAT.Traceback
"g-trasym", -- GNAT.Traceback.Symbolic
-----------------------------------------------------
-- Interface Hierarchy Units from Reference Manual --
-----------------------------------------------------
"i-c ", -- Interfaces.C
"i-cobol ", -- Interfaces.Cobol
"i-cpoint", -- Interfaces.C.Pointers
"i-cstrin", -- Interfaces.C.Strings
"i-fortra", -- Interfaces.Fortran
------------------------------------------
-- GNAT Defined Additions to Interfaces --
------------------------------------------
"i-cexten", -- Interfaces.C.Extensions
"i-csthre", -- Interfaces.C.Sthreads
"i-cstrea", -- Interfaces.C.Streams
"i-cpp ", -- Interfaces.CPP
"i-java ", -- Interfaces.Java
"i-javlan", -- Interfaces.Java.Lang
"i-jalaob", -- Interfaces.Java.Lang.Object
"i-jalasy", -- Interfaces.Java.Lang.System
"i-jalath", -- Interfaces.Java.Lang.Thread
"i-os2err", -- Interfaces.Os2lib.Errors
"i-os2lib", -- Interfaces.Os2lib
"i-os2syn", -- Interfaces.Os2lib.Synchronization
"i-os2thr", -- Interfaces.Os2lib.Threads
"i-pacdec", -- Interfaces.Packed_Decimal
"i-vxwork", -- Interfaces.Vxworks
--------------------------------------------------
-- System Hierarchy Units from Reference Manual --
--------------------------------------------------
"s-atacco", -- System.Address_To_Access_Conversions
"s-maccod", -- System.Machine_Code
"s-rpc ", -- System.Rpc
"s-stoele", -- System.Storage_Elements
"s-stopoo", -- System.Storage_Pools
--------------------------------------
-- GNAT Defined Additions to System --
--------------------------------------
"s-addima", -- System.Address_Image
"s-assert", -- System.Assertions
"s-parint", -- System.Partition_Interface
"s-tasinf", -- System.Task_Info
"s-wchcnv", -- System.Wch_Cnv
"s-wchcon"); -- System.Wch_Con
-------------------------
-- Implementation_Unit --
-------------------------
function Implementation_Unit (U : Unit_Number_Type) return Boolean is
Fname : constant File_Name_Type := Unit_File_Name (U);
begin
-- All units are OK in GNAT mode
if GNAT_Mode then
return False;
end if;
-- If length of file name is greater than 12, definitely OK!
-- The value 12 here is an 8 char name with extension .ads.
if Length_Of_Name (Fname) > 12 then
return False;
end if;
-- Otherwise test file name
Get_Name_String (Fname);
-- Definitely OK if file name does not start with a- g- s- i-
if Name_Len < 3
or else Name_Buffer (2) /= '-'
or else (Name_Buffer (1) /= 'a'
and then
Name_Buffer (1) /= 'g'
and then
Name_Buffer (1) /= 'i'
and then
Name_Buffer (1) /= 's')
then
return False;
end if;
-- Definitely OK if file name does not end in .ads. This can
-- happen when non-standard file names are being used.
if Name_Buffer (Name_Len - 3 .. Name_Len) /= ".ads" then
return False;
end if;
-- Otherwise normalize file name to 8 characters
Name_Len := Name_Len - 4;
while Name_Len < 8 loop
Name_Len := Name_Len + 1;
Name_Buffer (Name_Len) := ' ';
end loop;
-- Definitely OK if name is in list
for J in Non_Imp_File_Names'Range loop
if Name_Buffer (1 .. 8) = Non_Imp_File_Names (J) then
return False;
end if;
end loop;
-- Only remaining special possibilities are children of
-- System.RPC and System.Garlic and special files of the
-- form System.Aux...
Get_Name_String (Unit_Name (U));
if Name_Len > 12
and then Name_Buffer (1 .. 11) = "system.rpc."
then
return False;
end if;
if Name_Len > 15
and then Name_Buffer (1 .. 14) = "system.garlic."
then
return False;
end if;
if Name_Len > 11
and then Name_Buffer (1 .. 10) = "system.aux"
then
return False;
end if;
-- All tests failed, this is definitely an implementation unit
return True;
end Implementation_Unit;
end Impunit;
|
with System;
package Ada.Exceptions is
pragma Preelaborate (Exceptions);
type Exception_Id is private;
pragma Preelaborable_Initialization (Exception_Id);
Null_Id : constant Exception_Id;
procedure Raise_Exception
(E : Exception_Id;
Message : String := "");
pragma No_Return (Raise_Exception);
private
type Exception_Id is new Natural;
Null_Id : constant Exception_Id := Exception_Id'First;
end Ada.Exceptions;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, 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 Ada.Containers.Hashed_Maps;
with Ada.Tags.Generic_Dispatching_Constructor;
with League.Strings.Hash;
with Matreshka.DOM_Attributes;
with Matreshka.DOM_Elements;
with Matreshka.DOM_Texts;
package body Matreshka.DOM_Documents is
procedure Split_Qualified_Name
(Qualified_Name : League.Strings.Universal_String;
Prefix : out League.Strings.Universal_String;
Local_Name : out League.Strings.Universal_String);
-- Splits qualified name into prefix and local name parts.
type Qualified_Name is record
Namespace_URI : League.Strings.Universal_String;
Local_Name : League.Strings.Universal_String;
end record;
function Hash (Item : Qualified_Name) return Ada.Containers.Hash_Type;
-- Hash function to be used with standard containers.
package Qualified_Name_Maps is
new Ada.Containers.Hashed_Maps
(Qualified_Name, Ada.Tags.Tag, Hash, "=", Ada.Tags."=");
Attribute_Registry : Qualified_Name_Maps.Map;
Element_Registry : Qualified_Name_Maps.Map;
------------------
-- Constructors --
------------------
package body Constructors is
----------------
-- Initialize --
----------------
procedure Initialize (Self : not null access Document_Node'Class) is
begin
Matreshka.DOM_Nodes.Constructors.Initialize (Self, Self);
end Initialize;
end Constructors;
----------------------
-- Create_Attribute --
----------------------
function Create_Attribute
(Self : not null access Document_Node'Class;
Namespace_URI : League.Strings.Universal_String;
Prefix : League.Strings.Universal_String;
Local_Name : League.Strings.Universal_String)
return not null XML.DOM.Attributes.DOM_Attribute_Access
is
function Constructor is
new Ada.Tags.Generic_Dispatching_Constructor
(Matreshka.DOM_Attributes.Abstract_Attribute_L2_Node,
Matreshka.DOM_Attributes.Attribute_L2_Parameters,
Matreshka.DOM_Attributes.Create);
Parameters : aliased Matreshka.DOM_Attributes.Attribute_L2_Parameters
:= (Document => Self,
Namespace_URI => Namespace_URI,
Prefix => Prefix,
Local_Name => Local_Name);
Position : Qualified_Name_Maps.Cursor;
Tag : Ada.Tags.Tag;
Node : Matreshka.DOM_Nodes.Node_Access;
begin
Position :=
Attribute_Registry.Find
((Parameters.Namespace_URI, Parameters.Local_Name));
if Qualified_Name_Maps.Has_Element (Position) then
Tag := Qualified_Name_Maps.Element (Position);
else
Tag := Matreshka.DOM_Attributes.Attribute_L2_Node'Tag;
end if;
Node :=
new Matreshka.DOM_Attributes.Abstract_Attribute_L2_Node'Class'
(Constructor (Tag, Parameters'Access));
return XML.DOM.Attributes.DOM_Attribute_Access (Node);
end Create_Attribute;
-------------------------
-- Create_Attribute_NS --
-------------------------
overriding function Create_Attribute_NS
(Self : not null access Document_Node;
Namespace_URI : League.Strings.Universal_String;
Qualified_Name : League.Strings.Universal_String)
return not null XML.DOM.Attributes.DOM_Attribute_Access
is
Prefix : League.Strings.Universal_String;
Local_Name : League.Strings.Universal_String;
Node : constant not null Matreshka.DOM_Nodes.Node_Access
:= new Matreshka.DOM_Attributes.Attribute_L2_Node;
begin
Split_Qualified_Name (Qualified_Name, Prefix, Local_Name);
return Self.Create_Attribute (Namespace_URI, Prefix, Local_Name);
end Create_Attribute_NS;
--------------------
-- Create_Element --
--------------------
function Create_Element
(Self : not null access Document_Node'Class;
Namespace_URI : League.Strings.Universal_String;
Prefix : League.Strings.Universal_String;
Local_Name : League.Strings.Universal_String)
return not null XML.DOM.Elements.DOM_Element_Access
is
function Constructor is
new Ada.Tags.Generic_Dispatching_Constructor
(Matreshka.DOM_Elements.Abstract_Element_Node,
Matreshka.DOM_Elements.Element_L2_Parameters,
Matreshka.DOM_Elements.Create);
Parameters : aliased Matreshka.DOM_Elements.Element_L2_Parameters
:= (Document => Self,
Namespace_URI => Namespace_URI,
Prefix => Prefix,
Local_Name => Local_Name);
Position : Qualified_Name_Maps.Cursor;
Tag : Ada.Tags.Tag;
Node : Matreshka.DOM_Nodes.Node_Access;
begin
Position :=
Element_Registry.Find
((Parameters.Namespace_URI, Parameters.Local_Name));
if Qualified_Name_Maps.Has_Element (Position) then
Tag := Qualified_Name_Maps.Element (Position);
else
Tag := Matreshka.DOM_Elements.Element_Node'Tag;
end if;
Node :=
new Matreshka.DOM_Elements.Abstract_Element_Node'Class'
(Constructor (Tag, Parameters'Access));
return XML.DOM.Elements.DOM_Element_Access (Node);
end Create_Element;
-----------------------
-- Create_Element_NS --
-----------------------
overriding function Create_Element_NS
(Self : not null access Document_Node;
Namespace_URI : League.Strings.Universal_String;
Qualified_Name : League.Strings.Universal_String)
return not null XML.DOM.Elements.DOM_Element_Access
is
Prefix : League.Strings.Universal_String;
Local_Name : League.Strings.Universal_String;
begin
Split_Qualified_Name (Qualified_Name, Prefix, Local_Name);
return Self.Create_Element (Namespace_URI, Prefix, Local_Name);
end Create_Element_NS;
----------------------
-- Create_Text_Node --
----------------------
overriding function Create_Text_Node
(Self : not null access Document_Node;
Data : League.Strings.Universal_String)
return not null XML.DOM.Texts.DOM_Text_Access
is
Node : constant not null Matreshka.DOM_Nodes.Node_Access
:= new Matreshka.DOM_Texts.Text_Node;
begin
Matreshka.DOM_Texts.Constructors.Initialize
(Matreshka.DOM_Texts.Text_Node'Class (Node.all)'Access, Self, Data);
return XML.DOM.Texts.DOM_Text_Access (Node);
end Create_Text_Node;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Document_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
Visitor.Enter_Document
(XML.DOM.Documents.DOM_Document_Access (Self), Control);
end Enter_Node;
----------------
-- Error_Code --
----------------
overriding function Error_Code
(Self : not null access constant Document_Node)
return XML.DOM.Error_Code is
begin
return Self.Diagnosis;
end Error_Code;
------------------
-- Error_String --
------------------
overriding function Error_String
(Self : not null access constant Document_Node)
return League.Strings.Universal_String is
begin
return League.Strings.Empty_Universal_String;
end Error_String;
-------------------
-- Get_Node_Name --
-------------------
overriding function Get_Node_Name
(Self : not null access constant Document_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return League.Strings.To_Universal_String ("#document");
end Get_Node_Name;
-------------------
-- Get_Node_Type --
-------------------
overriding function Get_Node_Type
(Self : not null access constant Document_Node)
return XML.DOM.Node_Type
is
pragma Unreferenced (Self);
begin
return XML.DOM.Document_Node;
end Get_Node_Type;
------------------------
-- Get_Owner_Document --
------------------------
overriding function Get_Owner_Document
(Self : not null access constant Document_Node)
return XML.DOM.Documents.DOM_Document_Access
is
pragma Unreferenced (Self);
begin
return null;
end Get_Owner_Document;
----------
-- Hash --
----------
function Hash (Item : Qualified_Name) return Ada.Containers.Hash_Type is
use type Ada.Containers.Hash_Type;
begin
return
League.Strings.Hash (Item.Namespace_URI)
+ League.Strings.Hash (Item.Local_Name);
end Hash;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Document_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
Visitor.Leave_Document
(XML.DOM.Documents.DOM_Document_Access (Self), Control);
end Leave_Node;
------------------------
-- Register_Attribute --
------------------------
procedure Register_Attribute
(Namespace_URI : League.Strings.Universal_String;
Local_Name : League.Strings.Universal_String;
Tag : Ada.Tags.Tag) is
begin
Attribute_Registry.Insert ((Namespace_URI, Local_Name), Tag);
end Register_Attribute;
----------------------
-- Register_Element --
----------------------
procedure Register_Element
(Namespace_URI : League.Strings.Universal_String;
Local_Name : League.Strings.Universal_String;
Tag : Ada.Tags.Tag) is
begin
Element_Registry.Insert ((Namespace_URI, Local_Name), Tag);
end Register_Element;
--------------------------
-- Split_Qualified_Name --
--------------------------
procedure Split_Qualified_Name
(Qualified_Name : League.Strings.Universal_String;
Prefix : out League.Strings.Universal_String;
Local_Name : out League.Strings.Universal_String)
is
Delimiter : constant Natural := Qualified_Name.Index (':');
begin
if Delimiter = 0 then
Prefix := League.Strings.Empty_Universal_String;
Local_Name := Qualified_Name;
else
Prefix := Qualified_Name.Head (Delimiter - 1);
Local_Name := Qualified_Name.Tail_From (Delimiter + 1);
end if;
end Split_Qualified_Name;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Document_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
Iterator.Visit_Document
(Visitor, XML.DOM.Documents.DOM_Document_Access (Self), Control);
end Visit_Node;
end Matreshka.DOM_Documents;
|
------------------------------------------------------------------------------
-- --
-- Internet Protocol Suite Package --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- --
-- * Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
package INET.IP is
Invalid_Address: exception;
type IP_Version is (IPv4, IPv6);
type IPv6_Address is private;
type IPv4_Address is private;
-- Discriminated 4/6 address
type IP_Address (Version: IP_Version := IPv6) is
record
case Version is
when IPv4 =>
v4_Address: IPv4_Address;
when IPv6 =>
v6_Address: IPv6_Address;
end case;
end record;
function From_String_Address (Address: String) return IP_Address;
function To_String_Address (Address: IP_Address) return String;
IPv6_Wildcard: constant IP_Address;
IPv4_Wildcard: constant IP_Address; -- INADDR_ANY
private
type Octet is mod 2**8
with Size => 8;
-- These values are _always_ in "network order" (big endian).
-- The most significant octet is always at 'First.
type IPv4_Address is array (1 .. 4) of aliased Octet with Pack;
-- 4 x 8bits = 32 bits
type IPv6_Address is array (1 .. 16) of aliased Octet with Pack;
-- 1 x 16 = 128 bits
IPv6_Wildcard: constant IP_Address := (Version => IPv6,
v6_Address => (others => 0));
IPv4_Wildcard: constant IP_Address := (Version => IPv4,
v4_Address => (others => 0));
end INET.IP;
|
package body Tkmrpc.Servers.Ees
is
--------------------------------
-- charon callback signatures --
--------------------------------
procedure Charon_Esa_Acquire
(Result : out Results.Result_Type;
Sp_Id : Types.Sp_Id_Type);
pragma Import (C, Charon_Esa_Acquire, "charon_esa_acquire");
procedure Charon_Esa_Expire
(Result : out Results.Result_Type;
Sp_Id : Types.Sp_Id_Type;
Spi_Rem : Types.Esp_Spi_Type;
Protocol : Types.Protocol_Type;
Hard : Types.Expiry_Flag_Type);
pragma Import (C, Charon_Esa_Expire, "charon_esa_expire");
-------------------------------------------------------------------------
procedure Esa_Acquire
(Result : out Results.Result_Type;
Sp_Id : Types.Sp_Id_Type)
is
begin
Charon_Esa_Acquire (Result => Result,
Sp_Id => Sp_Id);
end Esa_Acquire;
-------------------------------------------------------------------------
procedure Esa_Expire
(Result : out Results.Result_Type;
Sp_Id : Types.Sp_Id_Type;
Spi_Rem : Types.Esp_Spi_Type;
Protocol : Types.Protocol_Type;
Hard : Types.Expiry_Flag_Type)
is
begin
Charon_Esa_Expire (Result => Result,
Sp_Id => Sp_Id,
Spi_Rem => Spi_Rem,
Protocol => Protocol,
Hard => Hard);
end Esa_Expire;
-------------------------------------------------------------------------
procedure Finalize
is
begin
null;
end Finalize;
-------------------------------------------------------------------------
procedure Init
is
begin
null;
end Init;
end Tkmrpc.Servers.Ees;
|
with
Ada.Iterator_Interfaces;
private with
System.Address_To_Access_Conversions;
package FLTK.Widgets.Groups is
type Group is new Widget with private
with Default_Iterator => Iterate,
Iterator_Element => Widget_Reference,
Variable_Indexing => Child;
type Group_Reference (Data : not null access Group'Class) is limited null record
with Implicit_Dereference => Data;
subtype Index is Positive;
subtype Extended_Index is Natural;
No_Index : constant Extended_Index := Extended_Index'First;
-- type Clip_Mode is (No_Clip, Clip);
type Cursor is private;
package Forge is
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Group;
end Forge;
procedure Add
(This : in out Group;
Item : in out Widget'Class);
procedure Insert
(This : in out Group;
Item : in out Widget'Class;
Place : in Index);
procedure Insert
(This : in out Group;
Item : in out Widget'Class;
Before : in Widget'Class);
procedure Remove
(This : in out Group;
Item : in out Widget'Class);
procedure Remove
(This : in out Group;
Place : in Index);
procedure Clear
(This : in out Group);
function Has_Child
(This : in Group;
Place : in Index)
return Boolean;
function Has_Child
(Place : in Cursor)
return Boolean;
function Child
(This : in Group;
Place : in Index)
return Widget_Reference;
function Child
(This : in Group;
Place : in Cursor)
return Widget_Reference;
function Find
(This : in Group;
Item : in out Widget'Class)
return Extended_Index;
function Number_Of_Children
(This : in Group)
return Natural;
package Group_Iterators is
new Ada.Iterator_Interfaces (Cursor, Has_Child);
function Iterate
(This : in Group)
return Group_Iterators.Reversible_Iterator'Class;
-- function Get_Clip_Mode
-- (This : in Group)
-- return Clip_Mode;
-- procedure Set_Clip_Mode
-- (This : in out Group;
-- Mode : in Clip_Mode);
function Get_Resizable
(This : in Group)
return access Widget'Class;
procedure Set_Resizable
(This : in out Group;
Item : in Widget'Class);
procedure Reset_Initial_Sizes
(This : in out Group);
function Get_Current
return access Group'Class;
procedure Set_Current
(To : in Group'Class);
procedure Draw
(This : in out Group);
function Handle
(This : in out Group;
Event : in Event_Kind)
return Event_Outcome;
private
type Group is new Widget with null record;
overriding procedure Finalize
(This : in out Group);
package Group_Convert is new System.Address_To_Access_Conversions (Group);
procedure fl_group_end
(G : in System.Address);
pragma Import (C, fl_group_end, "fl_group_end");
type Cursor is record
My_Container : access Group;
My_Index : Index'Base := Index'First;
end record;
type Iterator is new Group_Iterators.Reversible_Iterator with record
My_Container : access Group;
end record;
overriding function First
(Object : in Iterator)
return Cursor;
overriding function Next
(Object : in Iterator;
Place : in Cursor)
return Cursor;
overriding function Last
(Object : in Iterator)
return Cursor;
overriding function Previous
(Object : in Iterator;
Place : in Cursor)
return Cursor;
pragma Inline (Add);
pragma Inline (Insert);
pragma Inline (Remove);
pragma Inline (Clear);
pragma Inline (Has_Child);
pragma Inline (Child);
pragma Inline (Find);
pragma Inline (Number_Of_Children);
pragma Inline (Iterate);
-- pragma Inline (Get_Clip_Mode);
-- pragma Inline (Set_Clip_Mode);
pragma Inline (Get_Resizable);
pragma Inline (Set_Resizable);
pragma Inline (Reset_Initial_Sizes);
pragma Inline (Get_Current);
pragma Inline (Set_Current);
pragma Inline (Draw);
pragma Inline (Handle);
end FLTK.Widgets.Groups;
|
package GESTE_Fonts.FreeSerifItalic8pt7b is
Font : constant Bitmap_Font_Ref;
private
FreeSerifItalic8pt7bBitmaps : aliased constant Font_Bitmap := (
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#20#, 16#01#, 16#80#, 16#04#, 16#00#, 16#10#, 16#00#, 16#40#, 16#02#,
16#00#, 16#08#, 16#00#, 16#40#, 16#00#, 16#00#, 16#00#, 16#00#, 16#10#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#48#, 16#03#,
16#40#, 16#09#, 16#00#, 16#24#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#24#, 16#00#, 16#90#, 16#04#,
16#80#, 16#7F#, 16#80#, 16#48#, 16#02#, 16#40#, 16#09#, 16#00#, 16#FE#,
16#01#, 16#20#, 16#04#, 16#80#, 16#22#, 16#00#, 16#00#, 16#00#, 16#00#,
16#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#03#, 16#70#, 16#09#, 16#40#, 16#38#,
16#00#, 16#60#, 16#00#, 16#C0#, 16#03#, 16#80#, 16#12#, 16#01#, 16#48#,
16#05#, 16#60#, 16#0F#, 16#00#, 16#20#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#71#, 16#03#, 16#3C#, 16#09#, 16#20#, 16#65#, 16#01#, 16#14#,
16#06#, 16#A7#, 16#0E#, 16#B2#, 16#04#, 16#88#, 16#16#, 16#40#, 16#89#,
16#02#, 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#0E#,
16#00#, 16#28#, 16#01#, 16#20#, 16#07#, 16#00#, 16#18#, 16#01#, 16#EE#,
16#08#, 16#90#, 16#63#, 16#41#, 16#86#, 16#06#, 16#18#, 16#0F#, 16#B8#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#40#, 16#03#, 16#00#,
16#08#, 16#00#, 16#20#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#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#04#, 16#00#,
16#20#, 16#01#, 16#80#, 16#04#, 16#00#, 16#10#, 16#00#, 16#40#, 16#01#,
16#00#, 16#04#, 16#00#, 16#10#, 16#00#, 16#40#, 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#01#, 16#00#, 16#04#, 16#00#, 16#10#, 16#00#,
16#20#, 16#01#, 16#80#, 16#06#, 16#00#, 16#18#, 16#00#, 16#40#, 16#01#,
16#00#, 16#08#, 16#00#, 16#20#, 16#01#, 16#00#, 16#08#, 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#80#, 16#0A#, 16#C0#, 16#1C#, 16#00#, 16#68#, 16#02#,
16#90#, 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#04#, 16#00#, 16#10#, 16#00#, 16#40#, 16#1F#,
16#E0#, 16#04#, 16#00#, 16#10#, 16#00#, 16#40#, 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#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#0C#, 16#00#, 16#10#, 16#00#, 16#40#, 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#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#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
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#08#,
16#00#, 16#40#, 16#01#, 16#00#, 16#08#, 16#00#, 16#60#, 16#01#, 16#00#,
16#0C#, 16#00#, 16#20#, 16#01#, 16#00#, 16#04#, 16#00#, 16#20#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#38#, 16#01#, 16#20#,
16#08#, 16#40#, 16#61#, 16#01#, 16#84#, 16#04#, 16#30#, 16#10#, 16#C0#,
16#42#, 16#01#, 16#18#, 16#04#, 16#C0#, 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#02#, 16#00#, 16#70#, 16#00#, 16#40#, 16#01#, 16#00#,
16#0C#, 16#00#, 16#20#, 16#00#, 16#80#, 16#02#, 16#00#, 16#18#, 16#00#,
16#40#, 16#01#, 16#00#, 16#1E#, 16#00#, 16#00#, 16#00#, 16#00#, 16#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#06#, 16#60#, 16#10#, 16#80#, 16#02#, 16#00#,
16#18#, 16#00#, 16#40#, 16#02#, 16#00#, 16#10#, 16#00#, 16#80#, 16#04#,
16#00#, 16#3F#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#38#, 16#01#, 16#20#, 16#00#, 16#80#, 16#04#, 16#00#, 16#F0#, 16#00#,
16#C0#, 16#01#, 16#00#, 16#04#, 16#00#, 16#10#, 16#00#, 16#80#, 16#3C#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#04#, 16#00#,
16#20#, 16#03#, 16#80#, 16#12#, 16#00#, 16#90#, 16#04#, 16#40#, 16#21#,
16#00#, 16#FE#, 16#00#, 16#20#, 16#00#, 16#80#, 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#3C#, 16#01#, 16#00#, 16#08#,
16#00#, 16#3C#, 16#00#, 16#10#, 16#00#, 16#60#, 16#00#, 16#80#, 16#02#,
16#00#, 16#10#, 16#00#, 16#80#, 16#3C#, 16#00#, 16#00#, 16#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#01#, 16#80#, 16#0C#, 16#00#, 16#7C#,
16#01#, 16#98#, 16#04#, 16#20#, 16#10#, 16#80#, 16#C2#, 16#01#, 16#18#,
16#04#, 16#40#, 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#FC#, 16#04#, 16#10#, 16#00#, 16#80#, 16#02#, 16#00#, 16#10#,
16#00#, 16#40#, 16#02#, 16#00#, 16#10#, 16#00#, 16#40#, 16#02#, 16#00#,
16#08#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#1E#, 16#00#, 16#4C#,
16#02#, 16#10#, 16#0C#, 16#40#, 16#12#, 16#00#, 16#30#, 16#03#, 16#40#,
16#11#, 16#80#, 16#C2#, 16#01#, 16#08#, 16#04#, 16#60#, 16#0F#, 16#00#,
16#00#, 16#00#, 16#00#, 16#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#03#, 16#20#,
16#18#, 16#40#, 16#61#, 16#01#, 16#8C#, 16#06#, 16#30#, 16#0F#, 16#80#,
16#06#, 16#00#, 16#30#, 16#03#, 16#80#, 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#C0#, 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#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#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#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#04#,
16#00#, 16#18#, 16#00#, 16#40#, 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#01#, 16#80#, 16#18#, 16#01#,
16#80#, 16#18#, 16#00#, 16#70#, 16#00#, 16#70#, 16#00#, 16#30#, 16#00#,
16#20#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#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#F8#, 16#00#,
16#00#, 16#00#, 16#01#, 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#60#, 16#00#, 16#60#, 16#00#, 16#60#, 16#00#, 16#60#, 16#03#,
16#80#, 16#38#, 16#03#, 16#00#, 16#10#, 16#00#, 16#00#, 16#00#, 16#00#,
16#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#01#, 16#20#, 16#00#, 16#C0#, 16#02#,
16#00#, 16#18#, 16#00#, 16#40#, 16#02#, 16#00#, 16#10#, 16#00#, 16#00#,
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#3E#, 16#01#, 16#86#, 16#08#, 16#D4#, 16#66#, 16#D1#, 16#92#,
16#44#, 16#C9#, 16#1A#, 16#24#, 16#6D#, 16#A0#, 16#9B#, 16#01#, 16#80#,
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#08#,
16#00#, 16#20#, 16#01#, 16#C0#, 16#0B#, 16#00#, 16#2C#, 16#01#, 16#10#,
16#07#, 16#C0#, 16#21#, 16#01#, 16#04#, 16#04#, 16#18#, 16#38#, 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#FC#, 16#01#, 16#88#,
16#06#, 16#30#, 16#18#, 16#80#, 16#46#, 16#03#, 16#E0#, 16#0C#, 16#40#,
16#21#, 16#80#, 16#86#, 16#06#, 16#30#, 16#3F#, 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#1E#, 16#81#, 16#84#, 16#0C#, 16#10#,
16#20#, 16#01#, 16#80#, 16#06#, 16#00#, 16#10#, 16#00#, 16#60#, 16#01#,
16#80#, 16#03#, 16#18#, 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#FE#, 16#01#, 16#8C#, 16#06#, 16#18#, 16#18#, 16#60#,
16#40#, 16#83#, 16#06#, 16#0C#, 16#18#, 16#20#, 16#60#, 16#83#, 16#06#,
16#38#, 16#3F#, 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#FF#, 16#01#, 16#84#, 16#06#, 16#10#, 16#18#, 16#00#, 16#44#, 16#03#,
16#E0#, 16#0C#, 16#00#, 16#20#, 16#00#, 16#80#, 16#06#, 16#18#, 16#3F#,
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#FF#, 16#01#,
16#84#, 16#06#, 16#10#, 16#18#, 16#00#, 16#44#, 16#03#, 16#E0#, 16#0C#,
16#80#, 16#20#, 16#00#, 16#80#, 16#06#, 16#00#, 16#3C#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#1E#, 16#01#, 16#86#, 16#04#,
16#08#, 16#30#, 16#01#, 16#80#, 16#06#, 16#00#, 16#18#, 16#78#, 16#40#,
16#C1#, 16#83#, 16#06#, 16#08#, 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#FB#, 16#C1#, 16#82#, 16#06#, 16#18#, 16#18#,
16#60#, 16#41#, 16#03#, 16#FC#, 16#0C#, 16#30#, 16#20#, 16#C0#, 16#82#,
16#06#, 16#18#, 16#3C#, 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#F0#, 16#01#, 16#80#, 16#06#, 16#00#, 16#18#, 16#00#, 16#40#,
16#03#, 16#00#, 16#0C#, 16#00#, 16#20#, 16#00#, 16#80#, 16#06#, 16#00#,
16#3C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#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#60#, 16#01#, 16#00#, 16#04#, 16#00#, 16#30#, 16#00#, 16#C0#,
16#02#, 16#00#, 16#08#, 16#00#, 16#60#, 16#09#, 16#00#, 16#3C#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FB#, 16#81#, 16#84#,
16#06#, 16#20#, 16#1B#, 16#00#, 16#50#, 16#03#, 16#C0#, 16#0D#, 16#80#,
16#26#, 16#00#, 16#8C#, 16#06#, 16#10#, 16#3D#, 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#F8#, 16#01#, 16#80#, 16#06#, 16#00#,
16#18#, 16#00#, 16#40#, 16#03#, 16#00#, 16#0C#, 16#00#, 16#20#, 16#00#,
16#82#, 16#06#, 16#18#, 16#3F#, 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#E0#, 16#70#, 16#81#, 16#87#, 16#0E#, 16#1C#, 16#58#,
16#B1#, 16#42#, 16#CB#, 16#09#, 16#4C#, 16#25#, 16#21#, 16#18#, 16#84#,
16#46#, 16#39#, 16#3C#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#E1#, 16#C1#, 16#82#, 16#07#, 16#08#, 16#1C#, 16#40#, 16#99#, 16#02#,
16#64#, 16#08#, 16#A0#, 16#23#, 16#81#, 16#06#, 16#04#, 16#10#, 16#38#,
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#1E#, 16#01#,
16#8C#, 16#0C#, 16#18#, 16#30#, 16#61#, 16#81#, 16#86#, 16#06#, 16#10#,
16#30#, 16#40#, 16#C1#, 16#06#, 16#06#, 16#30#, 16#0F#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#FE#, 16#01#, 16#88#, 16#06#,
16#30#, 16#18#, 16#C0#, 16#46#, 16#03#, 16#F0#, 16#0C#, 16#00#, 16#20#,
16#00#, 16#80#, 16#06#, 16#00#, 16#3C#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#1E#, 16#00#, 16#8C#, 16#04#, 16#18#, 16#30#,
16#61#, 16#81#, 16#86#, 16#06#, 16#10#, 16#10#, 16#40#, 16#C1#, 16#02#,
16#04#, 16#10#, 16#08#, 16#80#, 16#1C#, 16#00#, 16#E1#, 16#04#, 16#F8#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#FC#, 16#01#, 16#88#, 16#06#, 16#30#, 16#18#, 16#C0#, 16#46#,
16#03#, 16#F0#, 16#0D#, 16#80#, 16#22#, 16#00#, 16#8C#, 16#06#, 16#30#,
16#3C#, 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#74#,
16#03#, 16#30#, 16#08#, 16#00#, 16#30#, 16#00#, 16#E0#, 16#01#, 16#C0#,
16#03#, 16#00#, 16#06#, 16#02#, 16#18#, 16#0C#, 16#40#, 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#FF#, 16#82#, 16#64#,
16#01#, 16#80#, 16#06#, 16#00#, 16#10#, 16#00#, 16#C0#, 16#03#, 16#00#,
16#08#, 16#00#, 16#20#, 16#01#, 16#80#, 16#0F#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#F9#, 16#C1#, 16#82#, 16#06#, 16#08#,
16#18#, 16#20#, 16#41#, 16#03#, 16#04#, 16#0C#, 16#10#, 16#20#, 16#40#,
16#82#, 16#03#, 16#18#, 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#F1#, 16#C1#, 16#82#, 16#06#, 16#10#, 16#18#, 16#40#,
16#22#, 16#00#, 16#90#, 16#02#, 16#40#, 16#0E#, 16#00#, 16#38#, 16#00#,
16#C0#, 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#F7#, 16#B1#, 16#8C#, 16#46#, 16#31#, 16#18#, 16#C8#, 16#67#, 16#20#,
16#AD#, 16#02#, 16#94#, 16#0C#, 16#60#, 16#31#, 16#80#, 16#84#, 16#02#,
16#10#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#F3#, 16#81#,
16#84#, 16#06#, 16#20#, 16#09#, 16#00#, 16#38#, 16#00#, 16#40#, 16#03#,
16#80#, 16#12#, 16#00#, 16#8C#, 16#04#, 16#30#, 16#39#, 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#F3#, 16#81#, 16#84#, 16#06#,
16#20#, 16#09#, 16#00#, 16#28#, 16#00#, 16#E0#, 16#03#, 16#00#, 16#0C#,
16#00#, 16#20#, 16#00#, 16#80#, 16#0F#, 16#00#, 16#00#, 16#00#, 16#00#,
16#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#02#, 16#18#, 16#10#, 16#C0#, 16#02#,
16#00#, 16#10#, 16#00#, 16#C0#, 16#06#, 16#00#, 16#30#, 16#00#, 16#82#,
16#04#, 16#18#, 16#3F#, 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#70#, 16#01#, 16#00#, 16#04#, 16#00#, 16#10#, 16#00#, 16#C0#,
16#02#, 16#00#, 16#08#, 16#00#, 16#20#, 16#01#, 16#80#, 16#04#, 16#00#,
16#10#, 16#00#, 16#40#, 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#80#,
16#03#, 16#00#, 16#04#, 16#00#, 16#10#, 16#00#, 16#20#, 16#00#, 16#80#,
16#03#, 16#00#, 16#04#, 16#00#, 16#10#, 16#00#, 16#20#, 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#70#, 16#00#, 16#40#,
16#03#, 16#00#, 16#08#, 16#00#, 16#20#, 16#00#, 16#80#, 16#06#, 16#00#,
16#10#, 16#00#, 16#40#, 16#01#, 16#00#, 16#0C#, 16#00#, 16#20#, 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#40#, 16#02#, 16#80#, 16#0A#, 16#00#,
16#44#, 16#01#, 16#10#, 16#08#, 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#03#, 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#80#, 16#01#, 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#78#, 16#03#, 16#20#, 16#18#,
16#80#, 16#46#, 16#03#, 16#10#, 16#0D#, 16#C0#, 16#19#, 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#C0#, 16#01#, 16#00#, 16#04#,
16#00#, 16#20#, 16#00#, 16#B8#, 16#03#, 16#30#, 16#18#, 16#C0#, 16#42#,
16#01#, 16#18#, 16#04#, 16#C0#, 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#70#, 16#02#, 16#60#, 16#10#, 16#00#, 16#40#, 16#03#, 16#00#,
16#04#, 16#80#, 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#0C#, 16#00#, 16#10#, 16#00#, 16#40#, 16#03#, 16#00#, 16#78#,
16#03#, 16#20#, 16#18#, 16#80#, 16#44#, 16#03#, 16#10#, 16#0D#, 16#C0#,
16#19#, 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#70#, 16#03#, 16#40#,
16#19#, 16#00#, 16#58#, 16#03#, 16#80#, 16#0C#, 16#40#, 16#1E#, 16#00#,
16#00#, 16#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#30#, 16#00#, 16#80#,
16#02#, 16#00#, 16#18#, 16#00#, 16#F0#, 16#01#, 16#00#, 16#04#, 16#00#,
16#10#, 16#00#, 16#C0#, 16#02#, 16#00#, 16#08#, 16#00#, 16#20#, 16#01#,
16#00#, 16#08#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#F0#, 16#06#, 16#60#, 16#11#, 16#00#, 16#4C#, 16#00#,
16#E0#, 16#04#, 16#00#, 16#1E#, 16#00#, 16#84#, 16#02#, 16#20#, 16#0F#,
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#01#, 16#00#, 16#04#, 16#00#, 16#20#, 16#00#,
16#98#, 16#03#, 16#A0#, 16#18#, 16#80#, 16#66#, 16#01#, 16#10#, 16#04#,
16#40#, 16#31#, 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#40#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#01#, 16#80#, 16#02#,
16#00#, 16#08#, 16#00#, 16#60#, 16#01#, 16#00#, 16#04#, 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#20#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#E0#, 16#01#, 16#00#, 16#04#,
16#00#, 16#10#, 16#00#, 16#C0#, 16#02#, 16#00#, 16#08#, 16#00#, 16#20#,
16#01#, 16#00#, 16#08#, 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#01#, 16#00#, 16#04#,
16#00#, 16#20#, 16#00#, 16#98#, 16#02#, 16#40#, 16#1A#, 16#00#, 16#70#,
16#01#, 16#60#, 16#04#, 16#A0#, 16#33#, 16#00#, 16#00#, 16#00#, 16#00#,
16#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#01#, 16#00#, 16#04#, 16#00#, 16#20#,
16#00#, 16#80#, 16#02#, 16#00#, 16#18#, 16#00#, 16#40#, 16#01#, 16#00#,
16#06#, 16#00#, 16#10#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#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#99#,
16#83#, 16#BE#, 16#19#, 16#90#, 16#66#, 16#41#, 16#11#, 16#04#, 16#4E#,
16#32#, 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#01#, 16#98#, 16#03#, 16#A0#,
16#19#, 16#80#, 16#64#, 16#01#, 16#10#, 16#04#, 16#60#, 16#31#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#,
16#00#, 16#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#03#, 16#20#, 16#18#, 16#80#,
16#42#, 16#03#, 16#18#, 16#04#, 16#C0#, 16#1E#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#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#B8#, 16#03#, 16#20#, 16#08#, 16#80#, 16#62#, 16#01#,
16#18#, 16#04#, 16#C0#, 16#1E#, 16#00#, 16#80#, 16#02#, 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#7C#, 16#03#, 16#20#, 16#18#, 16#80#, 16#46#, 16#03#, 16#10#, 16#0D#,
16#C0#, 16#19#, 16#00#, 16#0C#, 16#00#, 16#20#, 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#01#, 16#B0#, 16#03#,
16#00#, 16#08#, 16#00#, 16#60#, 16#01#, 16#00#, 16#04#, 16#00#, 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#D0#, 16#02#, 16#80#, 16#08#,
16#00#, 16#30#, 16#02#, 16#60#, 16#09#, 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#10#, 16#01#, 16#E0#, 16#02#, 16#00#, 16#08#, 16#00#, 16#40#,
16#01#, 16#00#, 16#04#, 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#01#, 16#88#, 16#02#, 16#60#, 16#19#, 16#80#, 16#4C#, 16#01#, 16#50#,
16#05#, 16#40#, 16#19#, 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#01#, 16#88#,
16#02#, 16#20#, 16#0C#, 16#80#, 16#34#, 16#00#, 16#60#, 16#01#, 16#80#,
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#01#, 16#89#, 16#82#, 16#22#,
16#09#, 16#90#, 16#2A#, 16#40#, 16#CA#, 16#03#, 16#30#, 16#08#, 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#D8#, 16#05#, 16#A0#, 16#04#, 16#00#,
16#10#, 16#00#, 16#C0#, 16#04#, 16#80#, 16#23#, 16#00#, 16#00#, 16#00#,
16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#00#, 16#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#88#, 16#03#, 16#20#, 16#04#, 16#80#, 16#12#, 16#00#,
16#70#, 16#00#, 16#80#, 16#02#, 16#00#, 16#10#, 16#00#, 16#80#, 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#01#,
16#F0#, 16#04#, 16#80#, 16#04#, 16#00#, 16#20#, 16#01#, 16#00#, 16#04#,
16#00#, 16#38#, 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#30#, 16#00#, 16#80#, 16#06#, 16#00#, 16#10#, 16#00#, 16#40#, 16#01#,
16#00#, 16#08#, 16#00#, 16#20#, 16#00#, 16#80#, 16#02#, 16#00#, 16#10#,
16#00#, 16#40#, 16#01#, 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#80#, 16#02#,
16#00#, 16#08#, 16#00#, 16#20#, 16#00#, 16#80#, 16#02#, 16#00#, 16#08#,
16#00#, 16#20#, 16#00#, 16#80#, 16#02#, 16#00#, 16#08#, 16#00#, 16#00#,
16#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#30#, 16#00#, 16#C0#, 16#02#,
16#00#, 16#08#, 16#00#, 16#20#, 16#01#, 16#80#, 16#02#, 16#00#, 16#10#,
16#00#, 16#40#, 16#02#, 16#00#, 16#08#, 16#00#, 16#20#, 16#01#, 16#80#,
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#1C#, 16#40#, 16#4E#, 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 => 33,
Glyph_Width => 14,
Glyph_Height => 19,
Data => FreeSerifItalic8pt7bBitmaps'Access);
Font : constant Bitmap_Font_Ref := Font_D'Access;
end GESTE_Fonts.FreeSerifItalic8pt7b;
|
with Ada.Text_IO;
use Ada.Text_IO;
procedure UglyForm is
begin
Put("Good form ");
Put("can aid in ");
Put ("understanding a program,");
New_Line;
Put("and bad form ");
Put("can make a program ");
Put("unreadable.");
New_Line;
end UglyForm;
-- Result of execution
-- Good form can aid in understanding a program,
-- and bad form can make a program unreadable.
|
------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- A D A . C O N T A I N E R S . V E C T O R S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2004-2006 Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- This unit was originally developed by Matthew J Heaney. --
------------------------------------------------------------------------------
with Ada.Containers.Generic_Array_Sort;
with Ada.Unchecked_Deallocation;
with System; use type System.Address;
package body Ada.Containers.Vectors is
type Int is range System.Min_Int .. System.Max_Int;
type UInt is mod System.Max_Binary_Modulus;
procedure Free is
new Ada.Unchecked_Deallocation (Elements_Type, Elements_Access);
---------
-- "&" --
---------
function "&" (Left, Right : Vector) return Vector is
LN : constant Count_Type := Length (Left);
RN : constant Count_Type := Length (Right);
begin
if LN = 0 then
if RN = 0 then
return Empty_Vector;
end if;
declare
RE : Elements_Type renames
Right.Elements (Index_Type'First .. Right.Last);
Elements : constant Elements_Access :=
new Elements_Type'(RE);
begin
return (Controlled with Elements, Right.Last, 0, 0);
end;
end if;
if RN = 0 then
declare
LE : Elements_Type renames
Left.Elements (Index_Type'First .. Left.Last);
Elements : constant Elements_Access :=
new Elements_Type'(LE);
begin
return (Controlled with Elements, Left.Last, 0, 0);
end;
end if;
declare
N : constant Int'Base := Int (LN) + Int (RN);
Last_As_Int : Int'Base;
begin
if Int (No_Index) > Int'Last - N then
raise Constraint_Error with "new length is out of range";
end if;
Last_As_Int := Int (No_Index) + N;
if Last_As_Int > Int (Index_Type'Last) then
raise Constraint_Error with "new length is out of range";
end if;
declare
Last : constant Index_Type := Index_Type (Last_As_Int);
LE : Elements_Type renames
Left.Elements (Index_Type'First .. Left.Last);
RE : Elements_Type renames
Right.Elements (Index_Type'First .. Right.Last);
Elements : constant Elements_Access :=
new Elements_Type'(LE & RE);
begin
return (Controlled with Elements, Last, 0, 0);
end;
end;
end "&";
function "&" (Left : Vector; Right : Element_Type) return Vector is
LN : constant Count_Type := Length (Left);
begin
if LN = 0 then
declare
subtype Elements_Subtype is
Elements_Type (Index_Type'First .. Index_Type'First);
Elements : constant Elements_Access :=
new Elements_Subtype'(others => Right);
begin
return (Controlled with Elements, Index_Type'First, 0, 0);
end;
end if;
declare
Last_As_Int : Int'Base;
begin
if Int (Index_Type'First) > Int'Last - Int (LN) then
raise Constraint_Error with "new length is out of range";
end if;
Last_As_Int := Int (Index_Type'First) + Int (LN);
if Last_As_Int > Int (Index_Type'Last) then
raise Constraint_Error with "new length is out of range";
end if;
declare
Last : constant Index_Type := Index_Type (Last_As_Int);
LE : Elements_Type renames
Left.Elements (Index_Type'First .. Left.Last);
subtype ET is Elements_Type (Index_Type'First .. Last);
Elements : constant Elements_Access := new ET'(LE & Right);
begin
return (Controlled with Elements, Last, 0, 0);
end;
end;
end "&";
function "&" (Left : Element_Type; Right : Vector) return Vector is
RN : constant Count_Type := Length (Right);
begin
if RN = 0 then
declare
subtype Elements_Subtype is
Elements_Type (Index_Type'First .. Index_Type'First);
Elements : constant Elements_Access :=
new Elements_Subtype'(others => Left);
begin
return (Controlled with Elements, Index_Type'First, 0, 0);
end;
end if;
declare
Last_As_Int : Int'Base;
begin
if Int (Index_Type'First) > Int'Last - Int (RN) then
raise Constraint_Error with "new length is out of range";
end if;
Last_As_Int := Int (Index_Type'First) + Int (RN);
if Last_As_Int > Int (Index_Type'Last) then
raise Constraint_Error with "new length is out of range";
end if;
declare
Last : constant Index_Type := Index_Type (Last_As_Int);
RE : Elements_Type renames
Right.Elements (Index_Type'First .. Right.Last);
subtype ET is Elements_Type (Index_Type'First .. Last);
Elements : constant Elements_Access := new ET'(Left & RE);
begin
return (Controlled with Elements, Last, 0, 0);
end;
end;
end "&";
function "&" (Left, Right : Element_Type) return Vector is
begin
if Index_Type'First >= Index_Type'Last then
raise Constraint_Error with "new length is out of range";
end if;
declare
Last : constant Index_Type := Index_Type'First + 1;
subtype ET is Elements_Type (Index_Type'First .. Last);
Elements : constant Elements_Access := new ET'(Left, Right);
begin
return (Controlled with Elements, Last, 0, 0);
end;
end "&";
---------
-- "=" --
---------
function "=" (Left, Right : Vector) return Boolean is
begin
if Left'Address = Right'Address then
return True;
end if;
if Left.Last /= Right.Last then
return False;
end if;
for J in Index_Type range Index_Type'First .. Left.Last loop
if Left.Elements (J) /= Right.Elements (J) then
return False;
end if;
end loop;
return True;
end "=";
------------
-- Adjust --
------------
procedure Adjust (Container : in out Vector) is
begin
if Container.Last = No_Index then
Container.Elements := null;
return;
end if;
declare
E : constant Elements_Access := Container.Elements;
L : constant Index_Type := Container.Last;
begin
Container.Elements := null;
Container.Last := No_Index;
Container.Busy := 0;
Container.Lock := 0;
Container.Elements := new Elements_Type'(E (Index_Type'First .. L));
Container.Last := L;
end;
end Adjust;
------------
-- Append --
------------
procedure Append (Container : in out Vector; New_Item : Vector) is
begin
if Is_Empty (New_Item) then
return;
end if;
if Container.Last = Index_Type'Last then
raise Constraint_Error with "vector is already at its maximum length";
end if;
Insert
(Container,
Container.Last + 1,
New_Item);
end Append;
procedure Append
(Container : in out Vector;
New_Item : Element_Type;
Count : Count_Type := 1)
is
begin
if Count = 0 then
return;
end if;
if Container.Last = Index_Type'Last then
raise Constraint_Error with "vector is already at its maximum length";
end if;
Insert
(Container,
Container.Last + 1,
New_Item,
Count);
end Append;
--------------
-- Capacity --
--------------
function Capacity (Container : Vector) return Count_Type is
begin
if Container.Elements = null then
return 0;
end if;
return Container.Elements'Length;
end Capacity;
-----------
-- Clear --
-----------
procedure Clear (Container : in out Vector) is
begin
if Container.Busy > 0 then
raise Program_Error with
"attempt to tamper with elements (vector is busy)";
end if;
Container.Last := No_Index;
end Clear;
--------------
-- Contains --
--------------
function Contains
(Container : Vector;
Item : Element_Type) return Boolean
is
begin
return Find_Index (Container, Item) /= No_Index;
end Contains;
------------
-- Delete --
------------
procedure Delete
(Container : in out Vector;
Index : Extended_Index;
Count : Count_Type := 1)
is
begin
if Index < Index_Type'First then
raise Constraint_Error with "Index is out of range (too small)";
end if;
if Index > Container.Last then
if Index > Container.Last + 1 then
raise Constraint_Error with "Index is out of range (too large)";
end if;
return;
end if;
if Count = 0 then
return;
end if;
if Container.Busy > 0 then
raise Program_Error with
"attempt to tamper with elements (vector is busy)";
end if;
declare
I_As_Int : constant Int := Int (Index);
Old_Last_As_Int : constant Int := Index_Type'Pos (Container.Last);
Count1 : constant Int'Base := Count_Type'Pos (Count);
Count2 : constant Int'Base := Old_Last_As_Int - I_As_Int + 1;
N : constant Int'Base := Int'Min (Count1, Count2);
J_As_Int : constant Int'Base := I_As_Int + N;
begin
if J_As_Int > Old_Last_As_Int then
Container.Last := Index - 1;
else
declare
J : constant Index_Type := Index_Type (J_As_Int);
E : Elements_Type renames Container.Elements.all;
New_Last_As_Int : constant Int'Base := Old_Last_As_Int - N;
New_Last : constant Index_Type :=
Index_Type (New_Last_As_Int);
begin
E (Index .. New_Last) := E (J .. Container.Last);
Container.Last := New_Last;
end;
end if;
end;
end Delete;
procedure Delete
(Container : in out Vector;
Position : in out Cursor;
Count : Count_Type := 1)
is
begin
if Position.Container = null then
raise Constraint_Error with "Position cursor has no element";
end if;
if Position.Container /= Container'Unrestricted_Access then
raise Program_Error with "Position cursor denotes wrong container";
end if;
if Position.Index > Container.Last then
raise Program_Error with "Position index is out of range";
end if;
Delete (Container, Position.Index, Count);
-- This is the old behavior, prior to the York API (2005/06):
-- if Position.Index <= Container.Last then
-- Position := (Container'Unchecked_Access, Position.Index);
-- else
-- Position := No_Element;
-- end if;
-- This is the behavior specified by the York API:
Position := No_Element;
end Delete;
------------------
-- Delete_First --
------------------
procedure Delete_First
(Container : in out Vector;
Count : Count_Type := 1)
is
begin
if Count = 0 then
return;
end if;
if Count >= Length (Container) then
Clear (Container);
return;
end if;
Delete (Container, Index_Type'First, Count);
end Delete_First;
-----------------
-- Delete_Last --
-----------------
procedure Delete_Last
(Container : in out Vector;
Count : Count_Type := 1)
is
Index : Int'Base;
begin
if Count = 0 then
return;
end if;
if Container.Busy > 0 then
raise Program_Error with
"attempt to tamper with elements (vector is busy)";
end if;
Index := Int'Base (Container.Last) - Int'Base (Count);
if Index < Index_Type'Pos (Index_Type'First) then
Container.Last := No_Index;
else
Container.Last := Index_Type (Index);
end if;
end Delete_Last;
-------------
-- Element --
-------------
function Element
(Container : Vector;
Index : Index_Type) return Element_Type
is
begin
if Index > Container.Last then
raise Constraint_Error with "Index is out of range";
end if;
return Container.Elements (Index);
end Element;
function Element (Position : Cursor) return Element_Type is
begin
if Position.Container = null then
raise Constraint_Error with "Position cursor has no element";
end if;
return Element (Position.Container.all, Position.Index);
end Element;
--------------
-- Finalize --
--------------
procedure Finalize (Container : in out Vector) is
X : Elements_Access := Container.Elements;
begin
if Container.Busy > 0 then
raise Program_Error with
"attempt to tamper with elements (vector is busy)";
end if;
Container.Elements := null;
Container.Last := No_Index;
Free (X);
end Finalize;
----------
-- Find --
----------
function Find
(Container : Vector;
Item : Element_Type;
Position : Cursor := No_Element) return Cursor
is
begin
if Position.Container /= null then
if Position.Container /= Container'Unrestricted_Access then
raise Program_Error with "Position cursor denotes wrong container";
end if;
if Position.Index > Container.Last then
raise Program_Error with "Position index is out of range";
end if;
end if;
for J in Position.Index .. Container.Last loop
if Container.Elements (J) = Item then
return (Container'Unchecked_Access, J);
end if;
end loop;
return No_Element;
end Find;
----------------
-- Find_Index --
----------------
function Find_Index
(Container : Vector;
Item : Element_Type;
Index : Index_Type := Index_Type'First) return Extended_Index
is
begin
for Indx in Index .. Container.Last loop
if Container.Elements (Indx) = Item then
return Indx;
end if;
end loop;
return No_Index;
end Find_Index;
-----------
-- First --
-----------
function First (Container : Vector) return Cursor is
begin
if Is_Empty (Container) then
return No_Element;
end if;
return (Container'Unchecked_Access, Index_Type'First);
end First;
-------------------
-- First_Element --
-------------------
function First_Element (Container : Vector) return Element_Type is
begin
return Element (Container, Index_Type'First);
end First_Element;
-----------------
-- First_Index --
-----------------
function First_Index (Container : Vector) return Index_Type is
pragma Unreferenced (Container);
begin
return Index_Type'First;
end First_Index;
---------------------
-- Generic_Sorting --
---------------------
package body Generic_Sorting is
---------------
-- Is_Sorted --
---------------
function Is_Sorted (Container : Vector) return Boolean is
begin
if Container.Last <= Index_Type'First then
return True;
end if;
declare
E : Elements_Type renames Container.Elements.all;
begin
for I in Index_Type'First .. Container.Last - 1 loop
if E (I + 1) < E (I) then
return False;
end if;
end loop;
end;
return True;
end Is_Sorted;
-----------
-- Merge --
-----------
procedure Merge (Target, Source : in out Vector) is
I : Index_Type'Base := Target.Last;
J : Index_Type'Base;
begin
if Target.Last < Index_Type'First then
Move (Target => Target, Source => Source);
return;
end if;
if Target'Address = Source'Address then
return;
end if;
if Source.Last < Index_Type'First then
return;
end if;
if Source.Busy > 0 then
raise Program_Error with
"attempt to tamper with elements (vector is busy)";
end if;
Target.Set_Length (Length (Target) + Length (Source));
J := Target.Last;
while Source.Last >= Index_Type'First loop
pragma Assert (Source.Last <= Index_Type'First
or else not (Source.Elements (Source.Last) <
Source.Elements (Source.Last - 1)));
if I < Index_Type'First then
Target.Elements (Index_Type'First .. J) :=
Source.Elements (Index_Type'First .. Source.Last);
Source.Last := No_Index;
return;
end if;
pragma Assert (I <= Index_Type'First
or else not (Target.Elements (I) <
Target.Elements (I - 1)));
if Source.Elements (Source.Last) < Target.Elements (I) then
Target.Elements (J) := Target.Elements (I);
I := I - 1;
else
Target.Elements (J) := Source.Elements (Source.Last);
Source.Last := Source.Last - 1;
end if;
J := J - 1;
end loop;
end Merge;
----------
-- Sort --
----------
procedure Sort (Container : in out Vector)
is
procedure Sort is
new Generic_Array_Sort
(Index_Type => Index_Type,
Element_Type => Element_Type,
Array_Type => Elements_Type,
"<" => "<");
begin
if Container.Last <= Index_Type'First then
return;
end if;
if Container.Lock > 0 then
raise Program_Error with
"attempt to tamper with cursors (vector is locked)";
end if;
Sort (Container.Elements (Index_Type'First .. Container.Last));
end Sort;
end Generic_Sorting;
-----------------
-- Has_Element --
-----------------
function Has_Element (Position : Cursor) return Boolean is
begin
if Position.Container = null then
return False;
end if;
return Position.Index <= Position.Container.Last;
end Has_Element;
------------
-- Insert --
------------
procedure Insert
(Container : in out Vector;
Before : Extended_Index;
New_Item : Element_Type;
Count : Count_Type := 1)
is
N : constant Int := Count_Type'Pos (Count);
First : constant Int := Int (Index_Type'First);
New_Last_As_Int : Int'Base;
New_Last : Index_Type;
New_Length : UInt;
Max_Length : constant UInt := UInt (Count_Type'Last);
Dst : Elements_Access;
begin
if Before < Index_Type'First then
raise Constraint_Error with
"Before index is out of range (too small)";
end if;
if Before > Container.Last
and then Before > Container.Last + 1
then
raise Constraint_Error with
"Before index is out of range (too large)";
end if;
if Count = 0 then
return;
end if;
declare
Old_Last_As_Int : constant Int := Int (Container.Last);
begin
if Old_Last_As_Int > Int'Last - N then
-- ???
-- The purpose of this test is to ensure that the calculation of
-- New_Last_As_Int (see below) doesn't overflow.
-- This isn't quite right, since the only requirements are:
-- V.Last <= Index_Type'Last
-- V.Length <= Count_Type'Last
-- To be strictly correct there's no (explicit) requirement that
-- Old_Last + N <= Int'Last
-- However, there might indeed be an implied requirement, since
-- machine constraints dictate that
-- Index_Type'Last <= Int'Last
-- and so this check is perhaps proper after all.
-- This shouldn't be an issue in practice, since it can only
-- happen when N is very large, or V.Last is near Int'Last.
-- N isn't likely to be large, since there's probably not enough
-- storage.
-- V.Last would only be large if IT'First is very large (and
-- V.Length has some "normal" size). But typically IT'First is
-- either 0 or 1.
raise Constraint_Error with "new length is out of range";
end if;
New_Last_As_Int := Old_Last_As_Int + N;
if New_Last_As_Int > Int (Index_Type'Last) then
raise Constraint_Error with "new length is out of range";
end if;
New_Length := UInt (New_Last_As_Int - First + Int'(1));
if New_Length > Max_Length then
raise Constraint_Error with "new length is out of range";
end if;
New_Last := Index_Type (New_Last_As_Int);
end;
if Container.Busy > 0 then
raise Program_Error with
"attempt to tamper with elements (vector is busy)";
end if;
if Container.Elements = null then
declare
subtype Elements_Subtype is
Elements_Type (Index_Type'First .. New_Last);
begin
Container.Elements := new Elements_Subtype'(others => New_Item);
end;
Container.Last := New_Last;
return;
end if;
if New_Last <= Container.Elements'Last then
declare
E : Elements_Type renames Container.Elements.all;
begin
if Before <= Container.Last then
declare
Index_As_Int : constant Int'Base :=
Index_Type'Pos (Before) + N;
Index : constant Index_Type := Index_Type (Index_As_Int);
begin
E (Index .. New_Last) := E (Before .. Container.Last);
E (Before .. Index_Type'Pred (Index)) :=
(others => New_Item);
end;
else
E (Before .. New_Last) := (others => New_Item);
end if;
end;
Container.Last := New_Last;
return;
end if;
declare
C, CC : UInt;
begin
C := UInt'Max (1, Container.Elements'Length);
while C < New_Length loop
if C > UInt'Last / 2 then
C := UInt'Last;
exit;
end if;
C := 2 * C;
end loop;
if C > Max_Length then
C := Max_Length;
end if;
if Index_Type'First <= 0
and then Index_Type'Last >= 0
then
CC := UInt (Index_Type'Last) + UInt (-Index_Type'First) + 1;
else
CC := UInt (Int (Index_Type'Last) - First + 1);
end if;
if C > CC then
C := CC;
end if;
declare
Dst_Last : constant Index_Type :=
Index_Type (First + UInt'Pos (C) - 1);
begin
Dst := new Elements_Type (Index_Type'First .. Dst_Last);
end;
end;
declare
Src : Elements_Type renames Container.Elements.all;
begin
Dst (Index_Type'First .. Index_Type'Pred (Before)) :=
Src (Index_Type'First .. Index_Type'Pred (Before));
if Before <= Container.Last then
declare
Index_As_Int : constant Int'Base :=
Index_Type'Pos (Before) + N;
Index : constant Index_Type := Index_Type (Index_As_Int);
begin
Dst (Before .. Index_Type'Pred (Index)) := (others => New_Item);
Dst (Index .. New_Last) := Src (Before .. Container.Last);
end;
else
Dst (Before .. New_Last) := (others => New_Item);
end if;
exception
when others =>
Free (Dst);
raise;
end;
declare
X : Elements_Access := Container.Elements;
begin
Container.Elements := Dst;
Container.Last := New_Last;
Free (X);
end;
end Insert;
procedure Insert
(Container : in out Vector;
Before : Extended_Index;
New_Item : Vector)
is
N : constant Count_Type := Length (New_Item);
begin
if Before < Index_Type'First then
raise Constraint_Error with
"Before index is out of range (too small)";
end if;
if Before > Container.Last
and then Before > Container.Last + 1
then
raise Constraint_Error with
"Before index is out of range (too large)";
end if;
if N = 0 then
return;
end if;
Insert_Space (Container, Before, Count => N);
declare
Dst_Last_As_Int : constant Int'Base :=
Int'Base (Before) + Int'Base (N) - 1;
Dst_Last : constant Index_Type := Index_Type (Dst_Last_As_Int);
begin
if Container'Address /= New_Item'Address then
Container.Elements (Before .. Dst_Last) :=
New_Item.Elements (Index_Type'First .. New_Item.Last);
return;
end if;
declare
subtype Src_Index_Subtype is Index_Type'Base range
Index_Type'First .. Before - 1;
Src : Elements_Type renames
Container.Elements (Src_Index_Subtype);
Index_As_Int : constant Int'Base :=
Int (Before) + Src'Length - 1;
Index : constant Index_Type'Base :=
Index_Type'Base (Index_As_Int);
Dst : Elements_Type renames
Container.Elements (Before .. Index);
begin
Dst := Src;
end;
if Dst_Last = Container.Last then
return;
end if;
declare
subtype Src_Index_Subtype is Index_Type'Base range
Dst_Last + 1 .. Container.Last;
Src : Elements_Type renames
Container.Elements (Src_Index_Subtype);
Index_As_Int : constant Int'Base :=
Dst_Last_As_Int - Src'Length + 1;
Index : constant Index_Type :=
Index_Type (Index_As_Int);
Dst : Elements_Type renames
Container.Elements (Index .. Dst_Last);
begin
Dst := Src;
end;
end;
end Insert;
procedure Insert
(Container : in out Vector;
Before : Cursor;
New_Item : Vector)
is
Index : Index_Type'Base;
begin
if Before.Container /= null
and then Before.Container /= Container'Unchecked_Access
then
raise Program_Error with "Before cursor denotes wrong container";
end if;
if Is_Empty (New_Item) then
return;
end if;
if Before.Container = null
or else Before.Index > Container.Last
then
if Container.Last = Index_Type'Last then
raise Constraint_Error with
"vector is already at its maximum length";
end if;
Index := Container.Last + 1;
else
Index := Before.Index;
end if;
Insert (Container, Index, New_Item);
end Insert;
procedure Insert
(Container : in out Vector;
Before : Cursor;
New_Item : Vector;
Position : out Cursor)
is
Index : Index_Type'Base;
begin
if Before.Container /= null
and then Before.Container /= Container'Unchecked_Access
then
raise Program_Error with "Before cursor denotes wrong container";
end if;
if Is_Empty (New_Item) then
if Before.Container = null
or else Before.Index > Container.Last
then
Position := No_Element;
else
Position := (Container'Unchecked_Access, Before.Index);
end if;
return;
end if;
if Before.Container = null
or else Before.Index > Container.Last
then
if Container.Last = Index_Type'Last then
raise Constraint_Error with
"vector is already at its maximum length";
end if;
Index := Container.Last + 1;
else
Index := Before.Index;
end if;
Insert (Container, Index, New_Item);
Position := Cursor'(Container'Unchecked_Access, Index);
end Insert;
procedure Insert
(Container : in out Vector;
Before : Cursor;
New_Item : Element_Type;
Count : Count_Type := 1)
is
Index : Index_Type'Base;
begin
if Before.Container /= null
and then Before.Container /= Container'Unchecked_Access
then
raise Program_Error with "Before cursor denotes wrong container";
end if;
if Count = 0 then
return;
end if;
if Before.Container = null
or else Before.Index > Container.Last
then
if Container.Last = Index_Type'Last then
raise Constraint_Error with
"vector is already at its maximum length";
end if;
Index := Container.Last + 1;
else
Index := Before.Index;
end if;
Insert (Container, Index, New_Item, Count);
end Insert;
procedure Insert
(Container : in out Vector;
Before : Cursor;
New_Item : Element_Type;
Position : out Cursor;
Count : Count_Type := 1)
is
Index : Index_Type'Base;
begin
if Before.Container /= null
and then Before.Container /= Container'Unchecked_Access
then
raise Program_Error with "Before cursor denotes wrong container";
end if;
if Count = 0 then
if Before.Container = null
or else Before.Index > Container.Last
then
Position := No_Element;
else
Position := (Container'Unchecked_Access, Before.Index);
end if;
return;
end if;
if Before.Container = null
or else Before.Index > Container.Last
then
if Container.Last = Index_Type'Last then
raise Constraint_Error with
"vector is already at its maximum length";
end if;
Index := Container.Last + 1;
else
Index := Before.Index;
end if;
Insert (Container, Index, New_Item, Count);
Position := Cursor'(Container'Unchecked_Access, Index);
end Insert;
procedure Insert
(Container : in out Vector;
Before : Extended_Index;
Count : Count_Type := 1)
is
New_Item : Element_Type; -- Default-initialized value
pragma Warnings (Off, New_Item);
begin
Insert (Container, Before, New_Item, Count);
end Insert;
procedure Insert
(Container : in out Vector;
Before : Cursor;
Position : out Cursor;
Count : Count_Type := 1)
is
New_Item : Element_Type; -- Default-initialized value
pragma Warnings (Off, New_Item);
begin
Insert (Container, Before, New_Item, Position, Count);
end Insert;
------------------
-- Insert_Space --
------------------
procedure Insert_Space
(Container : in out Vector;
Before : Extended_Index;
Count : Count_Type := 1)
is
N : constant Int := Count_Type'Pos (Count);
First : constant Int := Int (Index_Type'First);
New_Last_As_Int : Int'Base;
New_Last : Index_Type;
New_Length : UInt;
Max_Length : constant UInt := UInt (Count_Type'Last);
Dst : Elements_Access;
begin
if Before < Index_Type'First then
raise Constraint_Error with
"Before index is out of range (too small)";
end if;
if Before > Container.Last
and then Before > Container.Last + 1
then
raise Constraint_Error with
"Before index is out of range (too large)";
end if;
if Count = 0 then
return;
end if;
declare
Old_Last_As_Int : constant Int := Int (Container.Last);
begin
if Old_Last_As_Int > Int'Last - N then -- see Insert ???
raise Constraint_Error with "new length is out of range";
end if;
New_Last_As_Int := Old_Last_As_Int + N;
if New_Last_As_Int > Int (Index_Type'Last) then
raise Constraint_Error with "new length is out of range";
end if;
New_Length := UInt (New_Last_As_Int - First + Int'(1));
if New_Length > Max_Length then
raise Constraint_Error with "new length is out of range";
end if;
New_Last := Index_Type (New_Last_As_Int);
end;
if Container.Busy > 0 then
raise Program_Error with
"attempt to tamper with elements (vector is busy)";
end if;
if Container.Elements = null then
Container.Elements :=
new Elements_Type (Index_Type'First .. New_Last);
Container.Last := New_Last;
return;
end if;
if New_Last <= Container.Elements'Last then
declare
E : Elements_Type renames Container.Elements.all;
begin
if Before <= Container.Last then
declare
Index_As_Int : constant Int'Base :=
Index_Type'Pos (Before) + N;
Index : constant Index_Type := Index_Type (Index_As_Int);
begin
E (Index .. New_Last) := E (Before .. Container.Last);
end;
end if;
end;
Container.Last := New_Last;
return;
end if;
declare
C, CC : UInt;
begin
C := UInt'Max (1, Container.Elements'Length);
while C < New_Length loop
if C > UInt'Last / 2 then
C := UInt'Last;
exit;
end if;
C := 2 * C;
end loop;
if C > Max_Length then
C := Max_Length;
end if;
if Index_Type'First <= 0
and then Index_Type'Last >= 0
then
CC := UInt (Index_Type'Last) + UInt (-Index_Type'First) + 1;
else
CC := UInt (Int (Index_Type'Last) - First + 1);
end if;
if C > CC then
C := CC;
end if;
declare
Dst_Last : constant Index_Type :=
Index_Type (First + UInt'Pos (C) - 1);
begin
Dst := new Elements_Type (Index_Type'First .. Dst_Last);
end;
end;
declare
Src : Elements_Type renames Container.Elements.all;
begin
Dst (Index_Type'First .. Index_Type'Pred (Before)) :=
Src (Index_Type'First .. Index_Type'Pred (Before));
if Before <= Container.Last then
declare
Index_As_Int : constant Int'Base :=
Index_Type'Pos (Before) + N;
Index : constant Index_Type := Index_Type (Index_As_Int);
begin
Dst (Index .. New_Last) := Src (Before .. Container.Last);
end;
end if;
exception
when others =>
Free (Dst);
raise;
end;
declare
X : Elements_Access := Container.Elements;
begin
Container.Elements := Dst;
Container.Last := New_Last;
Free (X);
end;
end Insert_Space;
procedure Insert_Space
(Container : in out Vector;
Before : Cursor;
Position : out Cursor;
Count : Count_Type := 1)
is
Index : Index_Type'Base;
begin
if Before.Container /= null
and then Before.Container /= Container'Unchecked_Access
then
raise Program_Error with "Before cursor denotes wrong container";
end if;
if Count = 0 then
if Before.Container = null
or else Before.Index > Container.Last
then
Position := No_Element;
else
Position := (Container'Unchecked_Access, Before.Index);
end if;
return;
end if;
if Before.Container = null
or else Before.Index > Container.Last
then
if Container.Last = Index_Type'Last then
raise Constraint_Error with
"vector is already at its maximum length";
end if;
Index := Container.Last + 1;
else
Index := Before.Index;
end if;
Insert_Space (Container, Index, Count => Count);
Position := Cursor'(Container'Unchecked_Access, Index);
end Insert_Space;
--------------
-- Is_Empty --
--------------
function Is_Empty (Container : Vector) return Boolean is
begin
return Container.Last < Index_Type'First;
end Is_Empty;
-------------
-- Iterate --
-------------
procedure Iterate
(Container : Vector;
Process : not null access procedure (Position : Cursor))
is
V : Vector renames Container'Unrestricted_Access.all;
B : Natural renames V.Busy;
begin
B := B + 1;
begin
for Indx in Index_Type'First .. Container.Last loop
Process (Cursor'(Container'Unchecked_Access, Indx));
end loop;
exception
when others =>
B := B - 1;
raise;
end;
B := B - 1;
end Iterate;
----------
-- Last --
----------
function Last (Container : Vector) return Cursor is
begin
if Is_Empty (Container) then
return No_Element;
end if;
return (Container'Unchecked_Access, Container.Last);
end Last;
------------------
-- Last_Element --
------------------
function Last_Element (Container : Vector) return Element_Type is
begin
return Element (Container, Container.Last);
end Last_Element;
----------------
-- Last_Index --
----------------
function Last_Index (Container : Vector) return Extended_Index is
begin
return Container.Last;
end Last_Index;
------------
-- Length --
------------
function Length (Container : Vector) return Count_Type is
L : constant Int := Int (Container.Last);
F : constant Int := Int (Index_Type'First);
N : constant Int'Base := L - F + 1;
begin
return Count_Type (N);
end Length;
----------
-- Move --
----------
procedure Move
(Target : in out Vector;
Source : in out Vector)
is
begin
if Target'Address = Source'Address then
return;
end if;
if Target.Busy > 0 then
raise Program_Error with
"attempt to tamper with elements (Target is busy)";
end if;
if Source.Busy > 0 then
raise Program_Error with
"attempt to tamper with elements (Source is busy)";
end if;
declare
Target_Elements : constant Elements_Access := Target.Elements;
begin
Target.Elements := Source.Elements;
Source.Elements := Target_Elements;
end;
Target.Last := Source.Last;
Source.Last := No_Index;
end Move;
----------
-- Next --
----------
function Next (Position : Cursor) return Cursor is
begin
if Position.Container = null then
return No_Element;
end if;
if Position.Index < Position.Container.Last then
return (Position.Container, Position.Index + 1);
end if;
return No_Element;
end Next;
----------
-- Next --
----------
procedure Next (Position : in out Cursor) is
begin
if Position.Container = null then
return;
end if;
if Position.Index < Position.Container.Last then
Position.Index := Position.Index + 1;
else
Position := No_Element;
end if;
end Next;
-------------
-- Prepend --
-------------
procedure Prepend (Container : in out Vector; New_Item : Vector) is
begin
Insert (Container, Index_Type'First, New_Item);
end Prepend;
procedure Prepend
(Container : in out Vector;
New_Item : Element_Type;
Count : Count_Type := 1)
is
begin
Insert (Container,
Index_Type'First,
New_Item,
Count);
end Prepend;
--------------
-- Previous --
--------------
procedure Previous (Position : in out Cursor) is
begin
if Position.Container = null then
return;
end if;
if Position.Index > Index_Type'First then
Position.Index := Position.Index - 1;
else
Position := No_Element;
end if;
end Previous;
function Previous (Position : Cursor) return Cursor is
begin
if Position.Container = null then
return No_Element;
end if;
if Position.Index > Index_Type'First then
return (Position.Container, Position.Index - 1);
end if;
return No_Element;
end Previous;
-------------------
-- Query_Element --
-------------------
procedure Query_Element
(Container : Vector;
Index : Index_Type;
Process : not null access procedure (Element : Element_Type))
is
V : Vector renames Container'Unrestricted_Access.all;
B : Natural renames V.Busy;
L : Natural renames V.Lock;
begin
if Index > Container.Last then
raise Constraint_Error with "Index is out of range";
end if;
B := B + 1;
L := L + 1;
begin
Process (V.Elements (Index));
exception
when others =>
L := L - 1;
B := B - 1;
raise;
end;
L := L - 1;
B := B - 1;
end Query_Element;
procedure Query_Element
(Position : Cursor;
Process : not null access procedure (Element : Element_Type))
is
begin
if Position.Container = null then
raise Constraint_Error with "Position cursor has no element";
end if;
Query_Element (Position.Container.all, Position.Index, Process);
end Query_Element;
----------
-- Read --
----------
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Container : out Vector)
is
Length : Count_Type'Base;
Last : Index_Type'Base := No_Index;
begin
Clear (Container);
Count_Type'Base'Read (Stream, Length);
if Length > Capacity (Container) then
Reserve_Capacity (Container, Capacity => Length);
end if;
for J in Count_Type range 1 .. Length loop
Last := Last + 1;
Element_Type'Read (Stream, Container.Elements (Last));
Container.Last := Last;
end loop;
end Read;
procedure Read
(Stream : not null access Root_Stream_Type'Class;
Position : out Cursor)
is
begin
raise Program_Error with "attempt to stream vector cursor";
end Read;
---------------------
-- Replace_Element --
---------------------
procedure Replace_Element
(Container : in out Vector;
Index : Index_Type;
New_Item : Element_Type)
is
begin
if Index > Container.Last then
raise Constraint_Error with "Index is out of range";
end if;
if Container.Lock > 0 then
raise Program_Error with
"attempt to tamper with cursors (vector is locked)";
end if;
Container.Elements (Index) := New_Item;
end Replace_Element;
procedure Replace_Element
(Container : in out Vector;
Position : Cursor;
New_Item : Element_Type)
is
begin
if Position.Container = null then
raise Constraint_Error with "Position cursor has no element";
end if;
if Position.Container /= Container'Unrestricted_Access then
raise Program_Error with "Position cursor denotes wrong container";
end if;
Replace_Element (Container, Position.Index, New_Item);
end Replace_Element;
----------------------
-- Reserve_Capacity --
----------------------
procedure Reserve_Capacity
(Container : in out Vector;
Capacity : Count_Type)
is
N : constant Count_Type := Length (Container);
begin
if Capacity = 0 then
if N = 0 then
declare
X : Elements_Access := Container.Elements;
begin
Container.Elements := null;
Free (X);
end;
elsif N < Container.Elements'Length then
if Container.Busy > 0 then
raise Program_Error with
"attempt to tamper with elements (vector is busy)";
end if;
declare
subtype Array_Index_Subtype is Index_Type'Base range
Index_Type'First .. Container.Last;
Src : Elements_Type renames
Container.Elements (Array_Index_Subtype);
subtype Array_Subtype is
Elements_Type (Array_Index_Subtype);
X : Elements_Access := Container.Elements;
begin
Container.Elements := new Array_Subtype'(Src);
Free (X);
end;
end if;
return;
end if;
if Container.Elements = null then
declare
Last_As_Int : constant Int'Base :=
Int (Index_Type'First) + Int (Capacity) - 1;
begin
if Last_As_Int > Index_Type'Pos (Index_Type'Last) then
raise Constraint_Error with "new length is out of range";
end if;
declare
Last : constant Index_Type := Index_Type (Last_As_Int);
subtype Array_Subtype is
Elements_Type (Index_Type'First .. Last);
begin
Container.Elements := new Array_Subtype;
end;
end;
return;
end if;
if Capacity <= N then
if N < Container.Elements'Length then
if Container.Busy > 0 then
raise Program_Error with
"attempt to tamper with elements (vector is busy)";
end if;
declare
subtype Array_Index_Subtype is Index_Type'Base range
Index_Type'First .. Container.Last;
Src : Elements_Type renames
Container.Elements (Array_Index_Subtype);
subtype Array_Subtype is
Elements_Type (Array_Index_Subtype);
X : Elements_Access := Container.Elements;
begin
Container.Elements := new Array_Subtype'(Src);
Free (X);
end;
end if;
return;
end if;
if Capacity = Container.Elements'Length then
return;
end if;
if Container.Busy > 0 then
raise Program_Error with
"attempt to tamper with elements (vector is busy)";
end if;
declare
Last_As_Int : constant Int'Base :=
Int (Index_Type'First) + Int (Capacity) - 1;
begin
if Last_As_Int > Index_Type'Pos (Index_Type'Last) then
raise Constraint_Error with "new length is out of range";
end if;
declare
Last : constant Index_Type := Index_Type (Last_As_Int);
subtype Array_Subtype is
Elements_Type (Index_Type'First .. Last);
E : Elements_Access := new Array_Subtype;
begin
declare
Src : Elements_Type renames
Container.Elements (Index_Type'First .. Container.Last);
Tgt : Elements_Type renames
E (Index_Type'First .. Container.Last);
begin
Tgt := Src;
exception
when others =>
Free (E);
raise;
end;
declare
X : Elements_Access := Container.Elements;
begin
Container.Elements := E;
Free (X);
end;
end;
end;
end Reserve_Capacity;
----------------------
-- Reverse_Elements --
----------------------
procedure Reverse_Elements (Container : in out Vector) is
begin
if Container.Length <= 1 then
return;
end if;
if Container.Lock > 0 then
raise Program_Error with
"attempt to tamper with cursors (vector is locked)";
end if;
declare
I, J : Index_Type;
E : Elements_Type renames Container.Elements.all;
begin
I := Index_Type'First;
J := Container.Last;
while I < J loop
declare
EI : constant Element_Type := E (I);
begin
E (I) := E (J);
E (J) := EI;
end;
I := I + 1;
J := J - 1;
end loop;
end;
end Reverse_Elements;
------------------
-- Reverse_Find --
------------------
function Reverse_Find
(Container : Vector;
Item : Element_Type;
Position : Cursor := No_Element) return Cursor
is
Last : Index_Type'Base;
begin
if Position.Container /= null
and then Position.Container /= Container'Unchecked_Access
then
raise Program_Error with "Position cursor denotes wrong container";
end if;
if Position.Container = null
or else Position.Index > Container.Last
then
Last := Container.Last;
else
Last := Position.Index;
end if;
for Indx in reverse Index_Type'First .. Last loop
if Container.Elements (Indx) = Item then
return (Container'Unchecked_Access, Indx);
end if;
end loop;
return No_Element;
end Reverse_Find;
------------------------
-- Reverse_Find_Index --
------------------------
function Reverse_Find_Index
(Container : Vector;
Item : Element_Type;
Index : Index_Type := Index_Type'Last) return Extended_Index
is
Last : Index_Type'Base;
begin
if Index > Container.Last then
Last := Container.Last;
else
Last := Index;
end if;
for Indx in reverse Index_Type'First .. Last loop
if Container.Elements (Indx) = Item then
return Indx;
end if;
end loop;
return No_Index;
end Reverse_Find_Index;
---------------------
-- Reverse_Iterate --
---------------------
procedure Reverse_Iterate
(Container : Vector;
Process : not null access procedure (Position : Cursor))
is
V : Vector renames Container'Unrestricted_Access.all;
B : Natural renames V.Busy;
begin
B := B + 1;
begin
for Indx in reverse Index_Type'First .. Container.Last loop
Process (Cursor'(Container'Unchecked_Access, Indx));
end loop;
exception
when others =>
B := B - 1;
raise;
end;
B := B - 1;
end Reverse_Iterate;
----------------
-- Set_Length --
----------------
procedure Set_Length (Container : in out Vector; Length : Count_Type) is
begin
if Length = Vectors.Length (Container) then
return;
end if;
if Container.Busy > 0 then
raise Program_Error with
"attempt to tamper with elements (vector is busy)";
end if;
if Length > Capacity (Container) then
Reserve_Capacity (Container, Capacity => Length);
end if;
declare
Last_As_Int : constant Int'Base :=
Int (Index_Type'First) + Int (Length) - 1;
begin
Container.Last := Index_Type'Base (Last_As_Int);
end;
end Set_Length;
----------
-- Swap --
----------
procedure Swap (Container : in out Vector; I, J : Index_Type) is
begin
if I > Container.Last then
raise Constraint_Error with "I index is out of range";
end if;
if J > Container.Last then
raise Constraint_Error with "J index is out of range";
end if;
if I = J then
return;
end if;
if Container.Lock > 0 then
raise Program_Error with
"attempt to tamper with cursors (vector is locked)";
end if;
declare
EI : Element_Type renames Container.Elements (I);
EJ : Element_Type renames Container.Elements (J);
EI_Copy : constant Element_Type := EI;
begin
EI := EJ;
EJ := EI_Copy;
end;
end Swap;
procedure Swap (Container : in out Vector; I, J : Cursor) is
begin
if I.Container = null then
raise Constraint_Error with "I cursor has no element";
end if;
if J.Container = null then
raise Constraint_Error with "J cursor has no element";
end if;
if I.Container /= Container'Unrestricted_Access then
raise Program_Error with "I cursor denotes wrong container";
end if;
if J.Container /= Container'Unrestricted_Access then
raise Program_Error with "J cursor denotes wrong container";
end if;
Swap (Container, I.Index, J.Index);
end Swap;
---------------
-- To_Cursor --
---------------
function To_Cursor
(Container : Vector;
Index : Extended_Index) return Cursor
is
begin
if Index not in Index_Type'First .. Container.Last then
return No_Element;
end if;
return Cursor'(Container'Unchecked_Access, Index);
end To_Cursor;
--------------
-- To_Index --
--------------
function To_Index (Position : Cursor) return Extended_Index is
begin
if Position.Container = null then
return No_Index;
end if;
if Position.Index <= Position.Container.Last then
return Position.Index;
end if;
return No_Index;
end To_Index;
---------------
-- To_Vector --
---------------
function To_Vector (Length : Count_Type) return Vector is
begin
if Length = 0 then
return Empty_Vector;
end if;
declare
First : constant Int := Int (Index_Type'First);
Last_As_Int : constant Int'Base := First + Int (Length) - 1;
Last : Index_Type;
Elements : Elements_Access;
begin
if Last_As_Int > Index_Type'Pos (Index_Type'Last) then
raise Constraint_Error with "Length is out of range";
end if;
Last := Index_Type (Last_As_Int);
Elements := new Elements_Type (Index_Type'First .. Last);
return Vector'(Controlled with Elements, Last, 0, 0);
end;
end To_Vector;
function To_Vector
(New_Item : Element_Type;
Length : Count_Type) return Vector
is
begin
if Length = 0 then
return Empty_Vector;
end if;
declare
First : constant Int := Int (Index_Type'First);
Last_As_Int : constant Int'Base := First + Int (Length) - 1;
Last : Index_Type;
Elements : Elements_Access;
begin
if Last_As_Int > Index_Type'Pos (Index_Type'Last) then
raise Constraint_Error with "Length is out of range";
end if;
Last := Index_Type (Last_As_Int);
Elements := new Elements_Type'(Index_Type'First .. Last => New_Item);
return Vector'(Controlled with Elements, Last, 0, 0);
end;
end To_Vector;
--------------------
-- Update_Element --
--------------------
procedure Update_Element
(Container : in out Vector;
Index : Index_Type;
Process : not null access procedure (Element : in out Element_Type))
is
B : Natural renames Container.Busy;
L : Natural renames Container.Lock;
begin
if Index > Container.Last then
raise Constraint_Error with "Index is out of range";
end if;
B := B + 1;
L := L + 1;
begin
Process (Container.Elements (Index));
exception
when others =>
L := L - 1;
B := B - 1;
raise;
end;
L := L - 1;
B := B - 1;
end Update_Element;
procedure Update_Element
(Container : in out Vector;
Position : Cursor;
Process : not null access procedure (Element : in out Element_Type))
is
begin
if Position.Container = null then
raise Constraint_Error with "Position cursor has no element";
end if;
if Position.Container /= Container'Unrestricted_Access then
raise Program_Error with "Position cursor denotes wrong container";
end if;
Update_Element (Container, Position.Index, Process);
end Update_Element;
-----------
-- Write --
-----------
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Container : Vector)
is
begin
Count_Type'Base'Write (Stream, Length (Container));
for J in Index_Type'First .. Container.Last loop
Element_Type'Write (Stream, Container.Elements (J));
end loop;
end Write;
procedure Write
(Stream : not null access Root_Stream_Type'Class;
Position : Cursor)
is
begin
raise Program_Error with "attempt to stream vector cursor";
end Write;
end Ada.Containers.Vectors;
|
-- The Village of Vampire by YT, このソースコードはNYSLです
procedure Vampire.Villages.Save (
Name : in String;
Village : in out Villages.Village_Type);
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.