content
stringlengths 23
1.05M
|
|---|
with Ada.Unchecked_Deallocation;
-- Define the link type
procedure Singly_Linked is
type Link;
type Link_Access is access Link;
type Link is record
Data : Integer;
Next : Link_Access := null;
end record;
-- Instantiate the generic deallocator for the link type
procedure Free is new Ada.Unchecked_Deallocation(Link, Link_Access);
-- Define the procedure
procedure Insert_Append(Anchor : Link_Access; Newbie : Link_Access) is
begin
if Anchor /= null and Newbie /= null then
Newbie.Next := Anchor.Next;
Anchor.Next := Newbie;
end if;
end Insert_Append;
-- Create the link elements
A : Link_Access := new Link'(1, null);
B : Link_Access := new Link'(2, null);
C : Link_Access := new Link'(3, null);
-- Execute the program
begin
Insert_Append(A, B);
Insert_Append(A, C);
Free(A);
Free(B);
Free(C);
end Singly_Linked;
|
package Problem_59 is
-- Each character on a computer is assigned a unique code and the preferred
-- standard is ASCII (American Standard Code for Information
-- Interchange). For example, uppercase A = 65, asterisk (*) = 42, and
-- lowercase k = 107.
--
-- A modern encryption method is to take a text file, convert the bytes to
-- ASCII, then XOR each byte with a given value, taken from a secret
-- key. The advantage with the XOR function is that using the same
-- encryption key on the cipher text, restores the plain text; for example,
-- 65 XOR 42 = 107, then 107 XOR 42 = 65.
--
-- For unbreakable encryption, the key is the same length as the plain text
-- message, and the key is made up of random bytes. The user would keep the
-- encrypted message and the encryption key in different locations, and
-- without both "halves", it is impossible to decrypt the message.
--
-- Unfortunately, this method is impractical for most users, so the modified
-- method is to use a password as a key. If the password is shorter than the
-- message, which is likely, the key is repeated cyclically throughout the
-- message. The balance for this method is using a sufficiently long
-- password key for security, but short enough to be memorable.
--
-- Your task has been made easy, as the encryption key consists of three
-- lower case characters. Using cipher1.txt, a file containing the encrypted
-- ASCII codes, and the knowledge that the plain text must contain common
-- English words, decrypt the message and find the sum of the ASCII values
-- in the original text.
procedure Solve;
end Problem_59;
|
-----------------------------------------------------------------------
-- awa-commands -- AWA commands for server or admin tool
-- Copyright (C) 2019, 2020 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Finalization;
with Util.Commands;
with AWA.Applications;
with Ada.Exceptions;
private with Keystore.Passwords;
private with Keystore.Passwords.GPG;
private with Util.Commands.Consoles.Text;
private with ASF.Applications;
private with AWA.Applications.Factory;
private with Keystore.Properties;
private with Keystore.Files;
private with Keystore.Passwords.Keys;
private with GNAT.Command_Line;
private with GNAT.Strings;
package AWA.Commands is
Error : exception;
FILL_CONFIG : constant String := "fill-mode";
GPG_CRYPT_CONFIG : constant String := "gpg-encrypt";
GPG_DECRYPT_CONFIG : constant String := "gpg-decrypt";
GPG_LIST_CONFIG : constant String := "gpg-list-keys";
subtype Argument_List is Util.Commands.Argument_List;
type Context_Type is limited new Ada.Finalization.Limited_Controlled with private;
overriding
procedure Initialize (Context : in out Context_Type);
overriding
procedure Finalize (Context : in out Context_Type);
-- Returns True if a keystore is used by the configuration and must be unlocked.
function Use_Keystore (Context : in Context_Type) return Boolean;
-- Open the keystore file using the password password.
procedure Open_Keystore (Context : in out Context_Type);
-- Get the keystore file path.
function Get_Keystore_Path (Context : in out Context_Type) return String;
-- Configure the application by loading its configuration file and merging it with
-- the keystore file if there is one.
procedure Configure (Application : in out AWA.Applications.Application'Class;
Name : in String;
Context : in out Context_Type);
procedure Print (Context : in out Context_Type;
Ex : in Ada.Exceptions.Exception_Occurrence);
-- Configure the logs.
procedure Configure_Logs (Root : in String;
Debug : in Boolean;
Dump : in Boolean;
Verbose : in Boolean);
private
function "-" (Message : in String) return String is (Message);
procedure Load_Configuration (Context : in out Context_Type;
Path : in String);
package GC renames GNAT.Command_Line;
type Field_Number is range 1 .. 256;
type Notice_Type is (N_USAGE, N_INFO, N_ERROR);
package Consoles is
new Util.Commands.Consoles (Field_Type => Field_Number,
Notice_Type => Notice_Type);
package Text_Consoles is
new Consoles.Text;
subtype Justify_Type is Consoles.Justify_Type;
type Context_Type is limited new Ada.Finalization.Limited_Controlled with record
Console : Text_Consoles.Console_Type;
Wallet : aliased Keystore.Files.Wallet_File;
Info : Keystore.Wallet_Info;
Config : Keystore.Wallet_Config := Keystore.Secure_Config;
Secure_Config : Keystore.Properties.Manager;
App_Config : ASF.Applications.Config;
File_Config : ASF.Applications.Config;
Factory : AWA.Applications.Factory.Application_Factory;
Provider : Keystore.Passwords.Provider_Access;
Key_Provider : Keystore.Passwords.Keys.Key_Provider_Access;
Slot : Keystore.Key_Slot;
Version : aliased Boolean := False;
Verbose : aliased Boolean := False;
Debug : aliased Boolean := False;
Dump : aliased Boolean := False;
Zero : aliased Boolean := False;
Config_File : aliased GNAT.Strings.String_Access;
Wallet_File : aliased GNAT.Strings.String_Access;
Data_Path : aliased GNAT.Strings.String_Access;
Wallet_Key_File : aliased GNAT.Strings.String_Access;
Password_File : aliased GNAT.Strings.String_Access;
Password_Env : aliased GNAT.Strings.String_Access;
Unsafe_Password : aliased GNAT.Strings.String_Access;
Password_Socket : aliased GNAT.Strings.String_Access;
Password_Command : aliased GNAT.Strings.String_Access;
Password_Askpass : aliased Boolean := False;
No_Password_Opt : Boolean := False;
Command_Config : GC.Command_Line_Configuration;
First_Arg : Positive := 1;
GPG : Keystore.Passwords.GPG.Context_Type;
end record;
procedure Setup_Password_Provider (Context : in out Context_Type);
procedure Setup_Key_Provider (Context : in out Context_Type);
-- Setup the command before parsing the arguments and executing it.
procedure Setup_Command (Config : in out GC.Command_Line_Configuration;
Context : in out Context_Type);
function Sys_Daemon (No_Chdir : in Integer; No_Close : in Integer) return Integer
with Import => True, Convention => C, Link_Name => "daemon";
pragma Weak_External (Sys_Daemon);
end AWA.Commands;
|
-- DECLS-DTNODE.ads
-- Declaracions del node
with Decls.Dgenerals,
Decls.D_Taula_De_Noms,
Decls.Dtdesc;
use Decls.Dgenerals,
Decls.D_Taula_De_Noms,
Decls.Dtdesc;
package Decls.Dtnode is
--pragma pure;
type Mmode is
(Entra,
Surt,
Entrasurt);
type Operacio is
(Suma,
Resta,
Mult,
Div,
Menor,
Menorig,
Major,
Majorig,
Igual,
Distint,
Modul,
Unio,
Interseccio,
Negacio);
type Node;
type Pnode is access Node;
type Tipusnode is
(Programa,
Repeticio,
CondicionalS,
CondicionalC,
Expressio,
ExpressioUnaria,
Pencap,
Procediment,
Dvariable,
Dconstant,
Dcoleccio,
Dregistre,
Dencapregistre,
Dsubrang,
Identificador,
Const,
Declaracions,
Bloc,
Assignacio,
Referencia,
Pri,
Param,
Pcoleccio,
Pdimcoleccio,
Declmultvar,
Tnul,
Mode,
Encappri,
Firecord,
Fireferencia);
type node (Tipus : Tipusnode := tnul) is record
case Tipus is
when tnul => null;
when Programa =>
Proc : Pnode;
when repeticio | condicionalS
| declaracions | bloc | assignacio | pri
| dcoleccio | Pdimcoleccio | Referencia
| pcoleccio | dvariable
| Declmultvar | encappri | Pencap =>
Fe1, Fd1 : Pnode;
when CondicionalC | dconstant | dregistre
| Dencapregistre | Param => fe2, fc2, fd2: pnode;
when expressio => fe3, fd3: pnode;
op3: operacio;
when ExpressioUnaria => f4: pnode;
op4: operacio;
when Procediment | dsubrang =>
fe5, fc5, fd5, fid5: pnode;
when identificador => id12 : Id_Nom;
l1, c1 : natural;
when Firecord | Fireferencia => f6 : pnode;
when const => val : valor;
l2, c2 : natural;
Tconst : Tipus_Atribut;
when Mode => M12 : Mmode;
end case;
end record;
end Decls.Dtnode;
|
------------------------------------------------------------------------------
-- A d a r u n - t i m e s p e c i f i c a t i o n --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of ada.ads file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
package System is
pragma Pure (System);
type Name is (implementation_defined);
-- implementation-defined-enumeration-type;
System_Name : constant Name := implementation-defined;
-- System-Dependent Named Numbers:
Min_Int : constant := root_integer'First;
Max_Int : constant := root_integer'Last;
Max_Binary_Modulus : constant := implementation-defined;
Max_Nonbinary_Modulus : constant := implementation-defined;
Max_Base_Digits : constant := root_real'Digits;
Max_Digits : constant := implementation-defined;
Max_Mantissa : constant := implementation-defined;
Fine_Delta : constant := implementation-defined;
Tick : constant := implementation-defined;
-- Storage-related Declarations:
type Address is private; -- implementation-defined;
Null_Address : constant Address;
Storage_Unit : constant := implementation-defined;
Word_Size : constant := implementation-defined * Storage_Unit;
Memory_Size : constant := implementation-defined;
-- Address Comparison:
function "<" (Left, Right : Address) return Boolean;
function "<=" (Left, Right : Address) return Boolean;
function ">" (Left, Right : Address) return Boolean;
function ">=" (Left, Right : Address) return Boolean;
function "=" (Left, Right : Address) return Boolean;
-- function "/=" (Left, Right : Address) return Boolean;
-- "/=" is implicitly defined
pragma Convention (Intrinsic, "<");
pragma Convention (Intrinsic, "<=");
pragma Convention (Intrinsic, ">");
pragma Convention (Intrinsic, ">=");
pragma Convention (Intrinsic, "=");
-- and so on for all language-defined subprograms in this package
-- Other System-Dependent Declarations:
type Bit_Order is (High_Order_First, Low_Order_First);
Default_Bit_Order : constant Bit_Order := implementation-defined;
-- Priority-related declarations (see D.1):
subtype Any_Priority is
Integer range implementation-defined .. implementation-defined;
subtype Priority is
Any_Priority range Any_Priority'First .. implementation-defined;
subtype Interrupt_Priority is Any_Priority
range Priority'Last + 1 .. Any_Priority'Last;
Default_Priority : constant Priority :=
(Priority'First + Priority'Last) / 2;
private
pragma Import (Ada, Address);
pragma Import (Ada, Null_Address);
pragma Import (Intrinsic, "<");
pragma Import (Intrinsic, "<=");
pragma Import (Intrinsic, ">");
pragma Import (Intrinsic, ">=");
pragma Import (Intrinsic, "=");
end System;
|
--
-- Copyright 2021 (C) Holger Rodriguez
--
-- SPDX-License-Identifier: BSD-3-Clause
--
with Interfaces;
private with Edc_Client.Matrix.Common;
with Edc_Client.Matrix.Types; use Edc_Client.Matrix.Types;
package body Edc_Client.Matrix.Double_Word is
--------------------------------------------------------------------------
-- see .ads
procedure Show_LSW_LSB (Value : HAL.UInt8) is
begin
Edc_Client.Matrix.Common.Show_Byte (Value => Value,
Side => '1',
Block => '0');
end Show_LSW_LSB;
--------------------------------------------------------------------------
-- see .ads
procedure Show_LSW_MSB (Value : HAL.UInt8) is
begin
Edc_Client.Matrix.Common.Show_Byte (Value => Value,
Side => '1',
Block => '1');
end Show_LSW_MSB;
--------------------------------------------------------------------------
-- see .ads
procedure Show_MSW_LSB (Value : HAL.UInt8) is
begin
Edc_Client.Matrix.Common.Show_Byte (Value => Value,
Side => '1',
Block => '2');
end Show_MSW_LSB;
--------------------------------------------------------------------------
-- see .ads
procedure Show_MSW_MSB (Value : HAL.UInt8) is
begin
Edc_Client.Matrix.Common.Show_Byte (Value => Value,
Side => '1',
Block => '3');
end Show_MSW_MSB;
--------------------------------------------------------------------------
-- see .ads
procedure Show_LSW (Value : HAL.UInt16) is
begin
Edc_Client.Matrix.Common.Show_Word (Value => Value,
Side => '1',
Block => '0');
end Show_LSW;
--------------------------------------------------------------------------
-- see .ads
procedure Show_MSW (Value : HAL.UInt16) is
begin
Edc_Client.Matrix.Common.Show_Word (Value => Value,
Side => '1',
Block => '1');
end Show_MSW;
--------------------------------------------------------------------------
-- see .ads
procedure Show_Double_Word (Value : HAL.UInt32) is
use HAL;
use Interfaces;
Command : Double_Word_String := "M1D000000000";
MSW : constant Interfaces.Unsigned_16 :=
Interfaces.Unsigned_16 (Interfaces.Shift_Right (
Interfaces.Unsigned_32 (Value), 16));
LSW : constant Interfaces.Unsigned_16
:= Interfaces.Unsigned_16 (Value and 16#FFFF#);
MSB : Interfaces.Unsigned_8;
LSB : Interfaces.Unsigned_8;
MSN : Interfaces.Unsigned_8;
LSN : Interfaces.Unsigned_8;
begin
--
MSB :=
Interfaces.Unsigned_8 (Interfaces.Shift_Right (MSW, 8));
MSN := Interfaces.Shift_Right (MSB, 4);
Command (5) := Edc_Client.Matrix.Common.Nibble_To_Char (UInt8 (MSN));
LSN := MSB and 16#F#;
Command (6) := Edc_Client.Matrix.Common.Nibble_To_Char (UInt8 (LSN));
LSB :=
Interfaces.Unsigned_8 (MSW and 16#FF#);
MSN := Interfaces.Shift_Right (LSB, 4);
Command (7) := Edc_Client.Matrix.Common.Nibble_To_Char (UInt8 (MSN));
LSN := LSB and 16#F#;
Command (8) := Edc_Client.Matrix.Common.Nibble_To_Char (UInt8 (LSN));
--
MSB :=
Interfaces.Unsigned_8 (Interfaces.Shift_Right (LSW, 8));
MSN := Interfaces.Shift_Right (MSB, 4);
Command (9) := Edc_Client.Matrix.Common.Nibble_To_Char (UInt8 (MSN));
LSN := MSB and 16#F#;
Command (10) := Edc_Client.Matrix.Common.Nibble_To_Char (UInt8 (LSN));
LSB :=
Interfaces.Unsigned_8 (LSW and 16#FF#);
MSN := Interfaces.Shift_Right (LSB, 4);
Command (11) := Edc_Client.Matrix.Common.Nibble_To_Char (UInt8 (MSN));
LSN := LSB and 16#F#;
Command (12) := Edc_Client.Matrix.Common.Nibble_To_Char (UInt8 (LSN));
--
Transmitter (Command);
end Show_Double_Word;
end Edc_Client.Matrix.Double_Word;
|
-------------------------------------------------------------------------------
-- Copyright (c) 2016 Daniel King
--
-- 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 DW1000.System_Time;
with DW1000.Types; use DW1000.Types;
with System;
-- This package defines types for each of the DW1000 registers.
--
-- Each register type has a representation clause to match the layout of the
-- register according to the DW1000 User Manual.
package DW1000.Register_Types
with SPARK_Mode => On
is
----------------------------------------------------------------------------
-- DEV_ID register file
type DEV_ID_Type is record
REV : Types.Bits_4 := 2#0000#;
VER : Types.Bits_4 := 2#0011#;
MODEL : Types.Bits_8 := 16#01#;
RIDTAG : Types.Bits_16 := 16#DECA#;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for DEV_ID_Type use record
REV at 0 range 0 .. 3;
VER at 0 range 4 .. 7;
MODEL at 0 range 8 .. 15;
RIDTAG at 0 range 16 .. 31;
end record;
----------------------------------------------------------------------------
-- EUI register file
type EUI_Type is record
EUI : Types.Bits_64;
end record
with Size => 64,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for EUI_Type use record
EUI at 0 range 0 .. 63;
end record;
----------------------------------------------------------------------------
-- PANDADR register file
type PANADR_Type is record
SHORT_ADDR : Types.Bits_16 := 16#FFFF#;
PAN_ID : Types.Bits_16 := 16#FFFF#;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for PANADR_Type use record
SHORT_ADDR at 0 range 0 .. 15;
PAN_ID at 0 range 16 .. 31;
end record;
----------------------------------------------------------------------------
-- SYS_CFG register file
type SYS_CFG_FFEN_Field is
(Disabled,
Enabled)
with Size => 1;
-- Frame Filtering Enable.
type SYS_CFG_FFBC_Field is
(Disabled,
Enabled)
with Size => 1;
-- Frame Filtering Behave as a Coordinator.
type SYS_CFG_FFAB_Field is
(Not_Allowed,
Allowed)
with Size => 1;
-- Frame Filtering Allow Beacon frame reception.
type SYS_CFG_FFAD_Field is
(Not_Allowed,
Allowed)
with Size => 1;
-- Frame Filtering Allow Data frame reception.
type SYS_CFG_FFAA_Field is
(Not_Allowed,
Allowed)
with Size => 1;
-- Frame Filtering Allow Acknowledgment frame reception.
type SYS_CFG_FFAM_Field is
(Not_Allowed,
Allowed)
with Size => 1;
-- Frame Filtering Allow MAC command frame reception.
type SYS_CFG_FFAR_Field is
(Not_Allowed,
Allowed)
with Size => 1;
-- Frame Filtering Allow Reserved frame types.
type SYS_CFG_FFA4_Field is
(Not_Allowed,
Allowed)
with Size => 1;
-- Frame Filtering Allow frames with frame type field of 4, (binary 100).
type SYS_CFG_FFA5_Field is
(Not_Allowed,
Allowed)
with Size => 1;
-- Frame Filtering Allow frames with frame type field of 5, (binary 101).
type SYS_CFG_HIRQ_Pol_Field is
(Active_Low,
Active_High)
with Size => 1;
-- Host interrupt polarity.
type SYS_CFG_SPI_EDGE_Field is
(Sampling_Edge,
Opposite_Edge)
with Size => 1;
-- SPI data launch edge.
type SYS_CFG_DIS_FCE_Field is
(Not_Disabled,
Disabled)
with Size => 1;
-- Disable frame check error handling.
type SYS_CFG_DIS_DRXB_Field is
(Not_Disabled,
Disabled)
with Size => 1;
-- Disable Double RX Buffer.
type SYS_CFG_DIS_PHE_Field is
(Not_Disabled,
Disabled)
with Size => 1;
-- Disable receiver abort on PHR error.
type SYS_CFG_DIS_RSDE_Field is
(Not_Disabled,
Disabled)
with Size => 1;
-- Disable Receiver Abort on RSD (Reed-Solomon Decoder) error.
type SYS_CFG_FCS_INIT2F_Field is
(All_Zeroes,
All_Ones)
with Size => 1;
-- This bit allows selection of the initial seed value for the FCS
-- generation and checking function that is set at the start of each frame
-- transmission and reception.
type SYS_CFG_PHR_MODE_Field is
(Standard_Frames_Mode,
Reserved_01,
Reserved_10,
Long_Frames_Mode)
with Size => 2;
-- Standard (max. 127 octets) or long (max. 1023 octets) frames.
type SYS_CFG_DIS_STXP_Field is
(Not_Disabled,
Disabled)
with Size => 1;
-- Disable Smart TX Power control.
type SYS_CFG_RXM110K_Field is
(SFD_850K_6M8,
SFD_110K)
with Size => 1;
-- Receiver Mode 110 kbps data rate.
type SYS_CFG_RXWTOE_Field is
(Disabled,
Enabled)
with Size => 1;
-- Receive Wait Timeout Enable.
type SYS_CFG_RXAUTR_Field is
(Disabled,
Enabled)
with Size => 1;
-- Receiver Auto-Re-enable.
type SYS_CFG_AUTOACK_Field is
(Disabled,
Enabled)
with Size => 1;
-- Automatic Acknowledgement Enable.
type SYS_CFG_AACKPEND_Field is
(Disabled,
Enabled)
with Size => 1;
-- Automatic Acknowledgement Pending bit control.
type SYS_CFG_Type is record
FFEN : SYS_CFG_FFEN_Field := Disabled;
FFBC : SYS_CFG_FFBC_Field := Disabled;
FFAB : SYS_CFG_FFAB_Field := Not_Allowed;
FFAD : SYS_CFG_FFAD_Field := Not_Allowed;
FFAA : SYS_CFG_FFAA_Field := Not_Allowed;
FFAM : SYS_CFG_FFAM_Field := Not_Allowed;
FFAR : SYS_CFG_FFAR_Field := Not_Allowed;
FFA4 : SYS_CFG_FFA4_Field := Not_Allowed;
FFA5 : SYS_CFG_FFA5_Field := Not_Allowed;
HIRQ_POL : SYS_CFG_HIRQ_Pol_Field := Active_High;
SPI_EDGE : SYS_CFG_SPI_EDGE_Field := Sampling_Edge;
DIS_FCE : SYS_CFG_DIS_FCE_Field := Not_Disabled;
DIS_DRXB : SYS_CFG_DIS_DRXB_Field := Disabled;
DIS_PHE : SYS_CFG_DIS_PHE_Field := Not_Disabled;
DIS_RSDE : SYS_CFG_DIS_RSDE_Field := Not_Disabled;
FCS_INT2F : SYS_CFG_FCS_INIT2F_Field := All_Zeroes;
PHR_MODE : SYS_CFG_PHR_MODE_Field := Standard_Frames_Mode;
DIS_STXP : SYS_CFG_DIS_STXP_Field := Not_Disabled;
RXM110K : SYS_CFG_RXM110K_Field := SFD_850K_6M8;
RXWTOE : SYS_CFG_RXWTOE_Field := Disabled;
RXAUTR : SYS_CFG_RXAUTR_Field := Disabled;
AUTOACK : SYS_CFG_AUTOACK_Field := Disabled;
AACKPEND : SYS_CFG_AACKPEND_Field := Disabled;
Reserved_1 : Types.Bits_3 := 0;
Reserved_2 : Types.Bits_5 := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for SYS_CFG_Type use record
FFEN at 0 range 0 .. 0;
FFBC at 0 range 1 .. 1;
FFAB at 0 range 2 .. 2;
FFAD at 0 range 3 .. 3;
FFAA at 0 range 4 .. 4;
FFAM at 0 range 5 .. 5;
FFAR at 0 range 6 .. 6;
FFA4 at 0 range 7 .. 7;
FFA5 at 0 range 8 .. 8;
HIRQ_POL at 0 range 9 .. 9;
SPI_EDGE at 0 range 10 .. 10;
DIS_FCE at 0 range 11 .. 11;
DIS_DRXB at 0 range 12 .. 12;
DIS_PHE at 0 range 13 .. 13;
DIS_RSDE at 0 range 14 .. 14;
FCS_INT2F at 0 range 15 .. 15;
PHR_MODE at 0 range 16 .. 17;
DIS_STXP at 0 range 18 .. 18;
Reserved_1 at 0 range 19 .. 21;
RXM110K at 0 range 22 .. 22;
Reserved_2 at 0 range 23 .. 27;
RXWTOE at 0 range 28 .. 28;
RXAUTR at 0 range 29 .. 29;
AUTOACK at 0 range 30 .. 30;
AACKPEND at 0 range 31 .. 31;
end record;
----------------------------------------------------------------------------
-- SYS_TIME register file
type SYS_TIME_Type is record
SYS_TIME : System_Time.Coarse_System_Time;
end record
with Pack, Size => 40,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
----------------------------------------------------------------------------
-- TX_FCTRL register file
type TX_FCTRL_TFLEN_Field is range 0 .. 127
with Size => 7;
-- Transmit Frame Length.
type TX_FCTRL_TFLE_Field is range 0 .. 7
with Size => 3;
-- Transmit Frame Length Extension.
type TX_FCTRL_TXBR_Field is
(Data_Rate_110K,
Data_Rate_850K,
Data_Rate_6M8,
Reserved)
with Size => 2;
-- Transmit Bit Rate.
type TX_FCTRL_TR_Field is
(Disabled,
Enabled)
with Size => 1;
-- Transmit Ranging enable.
type TX_FCTRL_TXPRF_Field is
(PRF_4MHz,
PRF_16MHz,
PRF_64MHz,
Reserved)
with Size => 2;
-- Transmit Pulse Repetition Frequency.
type TX_FCTRL_TXPSR_Field is
(PLEN_16,
PLEN_64,
PLEN_1024,
PLEN_4096)
with Size => 2;
-- Transmit Preamble Symbol Repetitions (PSR).
type TX_FCTRL_PE_Field is range 0 .. 3
with Size => 2;
-- Preamble Extension.
type TX_FCTRL_TXBOFFS_Field is range 0 .. 2**10 - 1
with Size => 10;
-- Transmit buffer index offset.
type TX_FCTRL_IFSDELAY_Field is range 0 .. 255
with Size => 8;
-- Inter-Frame Spacing.
type TX_FCTRL_Type is record
TFLEN : TX_FCTRL_TFLEN_Field := 12;
TFLE : TX_FCTRL_TFLE_Field := 0;
R : Types.Bits_3 := 0;
TXBR : TX_FCTRL_TXBR_Field := Data_Rate_6M8;
TR : TX_FCTRL_TR_Field := Disabled;
TXPRF : TX_FCTRL_TXPRF_Field := PRF_16MHz;
TXPSR : TX_FCTRL_TXPSR_Field := PLEN_64;
PE : TX_FCTRL_PE_Field := 0;
TXBOFFS : TX_FCTRL_TXBOFFS_Field := 0;
IFSDELAY : TX_FCTRL_IFSDELAY_Field := 0;
end record
with Size => 40,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for TX_FCTRL_Type use record
TFLEN at 0 range 0 .. 6;
TFLE at 0 range 7 .. 9;
R at 0 range 10 .. 12;
TXBR at 0 range 13 .. 14;
TR at 0 range 15 .. 15;
TXPRF at 0 range 16 .. 17;
TXPSR at 0 range 18 .. 19;
PE at 0 range 20 .. 21;
TXBOFFS at 0 range 22 .. 31;
IFSDELAY at 0 range 32 .. 39;
end record;
----------------------------------------------------------------------------
-- TX_BUFFER register file
type TX_BUFFER_Type is record
TX_BUFFER : Types.Byte_Array (1 .. 1024) := (others => 0);
end record
with Size => 8192,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for TX_BUFFER_Type use record
TX_BUFFER at 0 range 0 .. 8191;
end record;
----------------------------------------------------------------------------
-- DX_TIME register file
type DX_TIME_Type is record
DX_TIME : System_Time.Coarse_System_Time := 0.0;
end record
with Pack, Size => 40,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
----------------------------------------------------------------------------
-- RX_FWTO register file
type RX_FWTO_Type is record
RXFWTO : System_Time.Frame_Wait_Timeout_Time := 0.0;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for RX_FWTO_Type use record
RXFWTO at 0 range 0 .. 15;
end record;
----------------------------------------------------------------------------
-- SYS_CTRL register file
type SYS_CTRL_SFCST_Field is
(Not_Suppressed,
Suppressed)
with Size => 1;
-- Suppress auto-FCS Transmission (on this next frame).
type SYS_CTRL_TXSTRT_Field is
(No_Action,
Start_Tx)
with Size => 1;
-- Transmit Start.
type SYS_CTRL_TXDLYS_Field is
(Not_Delayed,
Delayed)
with Size => 1;
-- Transmitter Delayed Sending.
type SYS_CTRL_CANSFCS_Field is
(Not_Cancelled,
Cancelled)
with Size => 1;
-- Cancel Suppression of auto-FCS transmission (on the current frame).
type SYS_CTRL_TRXOFF_Field is
(No_Action,
Transceiver_Off)
with Size => 1;
-- Transceiver Off.
type SYS_CTRL_WAIT4RESP_Field is
(No_Wait,
Wait)
with Size => 1;
-- Wait for Response.
type SYS_CTRL_RXENAB_Field is
(No_Action,
Start_Rx)
with Size => 1;
-- Enable Receiver.
type SYS_CTRL_RXDLYE_Field is
(Not_Delayed,
Delayed)
with Size => 1;
-- Receiver Delayed Enable.
type SYS_CTRL_HRBPT_Field is
(No_Action,
Toggle)
with Size => 1;
-- Host Side Receive Buffer Pointer Toggle.
type SYS_CTRL_Type is record
SFCST : SYS_CTRL_SFCST_Field := Not_Suppressed;
TXSTRT : SYS_CTRL_TXSTRT_Field := No_Action;
TXDLYS : SYS_CTRL_TXDLYS_Field := Not_Delayed;
CANSFCS : SYS_CTRL_CANSFCS_Field := Not_Cancelled;
TRXOFF : SYS_CTRL_TRXOFF_Field := No_Action;
WAIT4RESP : SYS_CTRL_WAIT4RESP_Field := No_Wait;
RXENAB : SYS_CTRL_RXENAB_Field := No_Action;
RXDLYE : SYS_CTRL_RXDLYE_Field := Not_Delayed;
HRBPT : SYS_CTRL_HRBPT_Field := No_Action;
Reserved_1 : Types.Bits_2 := 0;
Reserved_2 : Types.Bits_14 := 0;
Reserved_3 : Types.Bits_7 := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for SYS_CTRL_Type use record
SFCST at 0 range 0 .. 0;
TXSTRT at 0 range 1 .. 1;
TXDLYS at 0 range 2 .. 2;
CANSFCS at 0 range 3 .. 3;
Reserved_1 at 0 range 4 .. 5;
TRXOFF at 0 range 6 .. 6;
WAIT4RESP at 0 range 7 .. 7;
RXENAB at 0 range 8 .. 8;
RXDLYE at 0 range 9 .. 9;
Reserved_2 at 0 range 10 .. 23;
HRBPT at 0 range 24 .. 24;
Reserved_3 at 0 range 25 .. 31;
end record;
----------------------------------------------------------------------------
-- SYS_MASK register file
type SYS_MASK_Mask_Field is
(Masked,
Not_Masked)
with Size => 1;
-- Mask event.
type SYS_MASK_Type is record
MCPLOCK : SYS_MASK_Mask_Field := Masked;
MESYNCR : SYS_MASK_Mask_Field := Masked;
MAAT : SYS_MASK_Mask_Field := Masked;
MTXFRB : SYS_MASK_Mask_Field := Masked;
MTXPRS : SYS_MASK_Mask_Field := Masked;
MTXPHS : SYS_MASK_Mask_Field := Masked;
MTXFRS : SYS_MASK_Mask_Field := Masked;
MRXPRD : SYS_MASK_Mask_Field := Masked;
MRXSFDD : SYS_MASK_Mask_Field := Masked;
MLDEDONE : SYS_MASK_Mask_Field := Masked;
MRXPHD : SYS_MASK_Mask_Field := Masked;
MRXPHE : SYS_MASK_Mask_Field := Masked;
MRXDFR : SYS_MASK_Mask_Field := Masked;
MRXFCG : SYS_MASK_Mask_Field := Masked;
MRXFCE : SYS_MASK_Mask_Field := Masked;
MRXRFSL : SYS_MASK_Mask_Field := Masked;
MRXRFTO : SYS_MASK_Mask_Field := Masked;
MLDEERR : SYS_MASK_Mask_Field := Masked;
MRXOVRR : SYS_MASK_Mask_Field := Masked;
MRXPTO : SYS_MASK_Mask_Field := Masked;
MGPIOIRQ : SYS_MASK_Mask_Field := Masked;
MSLP2INIT : SYS_MASK_Mask_Field := Masked;
MRFPLLLL : SYS_MASK_Mask_Field := Masked;
MCPLLLL : SYS_MASK_Mask_Field := Masked;
MRXSFDTO : SYS_MASK_Mask_Field := Masked;
MHPDWARN : SYS_MASK_Mask_Field := Masked;
MTXBERR : SYS_MASK_Mask_Field := Masked;
MAFFREJ : SYS_MASK_Mask_Field := Masked;
Reserved_1 : Types.Bits_1 := 0;
Reserved_2 : Types.Bits_1 := 0;
Reserved_3 : Types.Bits_2 := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for SYS_MASK_Type use record
Reserved_1 at 0 range 0 .. 0;
MCPLOCK at 0 range 1 .. 1;
MESYNCR at 0 range 2 .. 2;
MAAT at 0 range 3 .. 3;
MTXFRB at 0 range 4 .. 4;
MTXPRS at 0 range 5 .. 5;
MTXPHS at 0 range 6 .. 6;
MTXFRS at 0 range 7 .. 7;
MRXPRD at 0 range 8 .. 8;
MRXSFDD at 0 range 9 .. 9;
MLDEDONE at 0 range 10 .. 10;
MRXPHD at 0 range 11 .. 11;
MRXPHE at 0 range 12 .. 12;
MRXDFR at 0 range 13 .. 13;
MRXFCG at 0 range 14 .. 14;
MRXFCE at 0 range 15 .. 15;
MRXRFSL at 0 range 16 .. 16;
MRXRFTO at 0 range 17 .. 17;
MLDEERR at 0 range 18 .. 18;
Reserved_2 at 0 range 19 .. 19;
MRXOVRR at 0 range 20 .. 20;
MRXPTO at 0 range 21 .. 21;
MGPIOIRQ at 0 range 22 .. 22;
MSLP2INIT at 0 range 23 .. 23;
MRFPLLLL at 0 range 24 .. 24;
MCPLLLL at 0 range 25 .. 25;
MRXSFDTO at 0 range 26 .. 26;
MHPDWARN at 0 range 27 .. 27;
MTXBERR at 0 range 28 .. 28;
MAFFREJ at 0 range 29 .. 29;
Reserved_3 at 0 range 30 .. 31;
end record;
----------------------------------------------------------------------------
-- SYS_STATUS register file
type SYS_STATUS_Type is record
IRQS : Types.Bits_1 := 0;
CPLOCK : Types.Bits_1 := 0;
ESYNCR : Types.Bits_1 := 0;
AAT : Types.Bits_1 := 0;
TXFRB : Types.Bits_1 := 0;
TXPRS : Types.Bits_1 := 0;
TXPHS : Types.Bits_1 := 0;
TXFRS : Types.Bits_1 := 0;
RXPRD : Types.Bits_1 := 0;
RXSFDD : Types.Bits_1 := 0;
LDEDONE : Types.Bits_1 := 0;
RXPHD : Types.Bits_1 := 0;
RXPHE : Types.Bits_1 := 0;
RXDFR : Types.Bits_1 := 0;
RXFCG : Types.Bits_1 := 0;
RXFCE : Types.Bits_1 := 0;
RXRFSL : Types.Bits_1 := 0;
RXRFTO : Types.Bits_1 := 0;
LDEERR : Types.Bits_1 := 0;
RXOVRR : Types.Bits_1 := 0;
RXPTO : Types.Bits_1 := 0;
GPIOIRQ : Types.Bits_1 := 0;
SLP2INIT : Types.Bits_1 := 0;
RFPLL_LL : Types.Bits_1 := 0;
CLKPLL_LL : Types.Bits_1 := 0;
RXSFDTO : Types.Bits_1 := 0;
HPDWARN : Types.Bits_1 := 0;
TXBERR : Types.Bits_1 := 0;
AFFREJ : Types.Bits_1 := 0;
HSRBP : Types.Bits_1 := 0;
ICRBP : Types.Bits_1 := 0;
RXRSCS : Types.Bits_1 := 0;
RXPREJ : Types.Bits_1 := 0;
TXPUTE : Types.Bits_1 := 0;
Reserved_1 : Types.Bits_1 := 0;
Reserved_2 : Types.Bits_5 := 0;
end record
with Size => 40,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for SYS_STATUS_Type use record
IRQS at 0 range 0 .. 0;
CPLOCK at 0 range 1 .. 1;
ESYNCR at 0 range 2 .. 2;
AAT at 0 range 3 .. 3;
TXFRB at 0 range 4 .. 4;
TXPRS at 0 range 5 .. 5;
TXPHS at 0 range 6 .. 6;
TXFRS at 0 range 7 .. 7;
RXPRD at 0 range 8 .. 8;
RXSFDD at 0 range 9 .. 9;
LDEDONE at 0 range 10 .. 10;
RXPHD at 0 range 11 .. 11;
RXPHE at 0 range 12 .. 12;
RXDFR at 0 range 13 .. 13;
RXFCG at 0 range 14 .. 14;
RXFCE at 0 range 15 .. 15;
RXRFSL at 0 range 16 .. 16;
RXRFTO at 0 range 17 .. 17;
LDEERR at 0 range 18 .. 18;
Reserved_1 at 0 range 19 .. 19;
RXOVRR at 0 range 20 .. 20;
RXPTO at 0 range 21 .. 21;
GPIOIRQ at 0 range 22 .. 22;
SLP2INIT at 0 range 23 .. 23;
RFPLL_LL at 0 range 24 .. 24;
CLKPLL_LL at 0 range 25 .. 25;
RXSFDTO at 0 range 26 .. 26;
HPDWARN at 0 range 27 .. 27;
TXBERR at 0 range 28 .. 28;
AFFREJ at 0 range 29 .. 29;
HSRBP at 0 range 30 .. 30;
ICRBP at 0 range 31 .. 31;
RXRSCS at 4 range 0 .. 0;
RXPREJ at 4 range 1 .. 1;
TXPUTE at 4 range 2 .. 2;
Reserved_2 at 4 range 3 .. 7;
end record;
----------------------------------------------------------------------------
-- RX_FINFO register file
type RX_FINFO_RXFLEN_Field is range 0 .. 127
with Size => 7;
-- Receive Frame Length.
type RX_FINFO_RXFLE_Field is range 0 .. 7
with Size => 3;
-- Receive Frame Length Extension.
type RX_FINFO_RXNSPL_Field is range 0 .. 3
with Size => 2;
-- Receive non-standard preamble length.
type RX_FINFO_RXBR_Field is
(Data_Rate_110K,
Data_Rate_850K,
Data_Rate_6M8,
Reserved)
with Size => 2;
-- Receive Bit Rate report.
type RX_FINFO_RNG_Field is
(Disabled,
Enabled)
with Size => 1;
-- Receiver Ranging.
type RX_FINFO_RXPRFR_Field is
(Reserved_00,
PRF_16MHz,
PRF_64MHz,
Reserved_11)
with Size => 2;
-- RX Pulse Repetition Rate report.
type RX_FINFO_RXPSR_Field is
(PLEN_16,
PLEN_64,
PLEN_1024,
PLEN_4096)
with Size => 2;
-- RX Preamble Repetition.
type RX_FINFO_RXPACC_Field is range 0 .. 2**12 - 1
with Size => 12;
type RX_FINFO_Type is record
RXFLEN : RX_FINFO_RXFLEN_Field := 0;
RXFLE : RX_FINFO_RXFLE_Field := 0;
RXNSPL : RX_FINFO_RXNSPL_Field := 0;
RXBR : RX_FINFO_RXBR_Field := Data_Rate_110K;
RNG : RX_FINFO_RNG_Field := Disabled;
RXPRF : RX_FINFO_RXPRFR_Field := Reserved_00;
RXPSR : RX_FINFO_RXPSR_Field := PLEN_16;
RXPACC : RX_FINFO_RXPACC_Field := 0;
Reserved : Types.Bits_1 := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for RX_FINFO_Type use record
RXFLEN at 0 range 0 .. 6;
RXFLE at 0 range 7 .. 9;
Reserved at 0 range 10 .. 10;
RXNSPL at 0 range 11 .. 12;
RXBR at 0 range 13 .. 14;
RNG at 0 range 15 .. 15;
RXPRF at 0 range 16 .. 17;
RXPSR at 0 range 18 .. 19;
RXPACC at 0 range 20 .. 31;
end record;
----------------------------------------------------------------------------
-- RX_BUFFER register file
type RX_BUFFER_Type is record
RX_BUFFER : Types.Byte_Array (1 .. 1024) := (others => 0);
end record
with Size => 8192,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for RX_BUFFER_Type use record
RX_BUFFER at 0 range 0 .. 8191;
end record;
----------------------------------------------------------------------------
-- RX_FQUAL register file
type RX_FQUAL_STD_NOISE_Field is range 0 .. 2**16 - 1
with Size => 16;
-- Standard Deviation of Noise.
type RX_FQUAL_FP_AMPL2_Field is range 0 .. 2**16 - 1
with Size => 16;
-- First Path Amplitude point 2.
type RX_FQUAL_FP_AMPL3_Field is range 0 .. 2**16 - 1
with Size => 16;
-- First Path Amplitude point 3.
type RX_FQUAL_CIR_PWR_Field is range 0 .. 2**16 - 1
with Size => 16;
-- Channel Impulse Response Power.
type RX_FQUAL_Type is record
STD_NOISE : RX_FQUAL_STD_NOISE_Field := 0;
FP_AMPL2 : RX_FQUAL_FP_AMPL2_Field := 0;
FP_AMPL3 : RX_FQUAL_FP_AMPL3_Field := 0;
CIR_PWR : RX_FQUAL_CIR_PWR_Field := 0;
end record
with Size => 64,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for RX_FQUAL_Type use record
STD_NOISE at 0 range 0 .. 15;
FP_AMPL2 at 0 range 16 .. 31;
FP_AMPL3 at 4 range 0 .. 15;
CIR_PWR at 4 range 16 .. 31;
end record;
----------------------------------------------------------------------------
-- RX_TTCKI register file
type RX_TTCKI_RXTTCKI_Field is range 0 .. 2**32 - 1
with Size => 32;
-- RX time tracking interval.
type RX_TTCKI_Type is record
RXTTCKI : RX_TTCKI_RXTTCKI_Field := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for RX_TTCKI_Type use record
RXTTCKI at 0 range 0 .. 31;
end record;
----------------------------------------------------------------------------
-- RX_TTCKO register file
type RX_TTCKO_RXTOFS_Field is range -2**18 .. 2**18 - 1
with Size => 19;
-- RX time tracking offset.
type RX_TTCKO_RSMPDEL_Field is range 0 .. 255
with Size => 8;
-- This 8-bit field reports an internal re-sampler delay value.
type RX_TTCKO_RCPHASE_Field is
delta 360.0 / 127.0
range 0.0 .. 360.0
with Small => 360.0 / 127.0,
Size => 7;
-- This 7-bit field reports the receive carrier phase adjustment at time
-- the ranging timestamp is made. This gives the phase (7 bits = 360 degrees)
-- of the internal carrier tracking loop at the time that the RX timestamp
-- is received.
type RX_TTCKO_Type is record
RXTOFS : RX_TTCKO_RXTOFS_Field := 0;
RSMPDEL : RX_TTCKO_RSMPDEL_Field := 0;
RCPHASE : RX_TTCKO_RCPHASE_Field := RX_TTCKO_RCPHASE_Field'First;
Reserved_1 : Types.Bits_5 := 0;
Reserved_2 : Types.Bits_1 := 0;
end record
with Size => 40,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for RX_TTCKO_Type use record
RXTOFS at 0 range 0 .. 18;
Reserved_1 at 0 range 19 .. 23;
RSMPDEL at 0 range 24 .. 31;
RCPHASE at 0 range 32 .. 38;
Reserved_2 at 0 range 39 .. 39;
end record;
----------------------------------------------------------------------------
-- RX_TIME register file
type RX_TIME_FP_INDEX_Field is range 0 .. 2**16 - 1
with Size => 16;
-- First path index.
type RX_TIME_FP_AMPL1_Field is range 0 .. 2**16 - 1
with Size => 16;
-- First Path Amplitude point 1.
type RX_TIME_Type is record
RX_STAMP : System_Time.Fine_System_Time := 0.0;
FP_INDEX : RX_TIME_FP_INDEX_Field := 0;
FP_AMPL1 : RX_TIME_FP_AMPL1_Field := 0;
RX_RAWST : System_Time.Coarse_System_Time := 0.0;
end record
with Size => 8 * 14,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for RX_TIME_Type use record
RX_STAMP at 0 range 0 .. 39;
FP_INDEX at 4 range 8 .. 23;
FP_AMPL1 at 4 range 24 .. 39;
RX_RAWST at 8 range 8 .. 47;
end record;
----------------------------------------------------------------------------
-- TX_TIME register file
type TX_TIME_Type is record
TX_STAMP : System_Time.Fine_System_Time := 0.0;
TX_RAWST : System_Time.Coarse_System_Time := 0.0;
end record
with Size => 80,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for TX_TIME_Type use record
TX_STAMP at 0 range 0 .. 39;
TX_RAWST at 4 range 8 .. 47;
end record;
----------------------------------------------------------------------------
-- TX_ANTD register file
type TX_ANTD_Type is record
TX_ANTD : System_Time.Antenna_Delay_Time := 0.0;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for TX_ANTD_Type use record
TX_ANTD at 0 range 0 .. 15;
end record;
----------------------------------------------------------------------------
-- SYS_STATE register file
type SYS_STATE_TX_STATE_Field is
(Idle,
Transmitting_Preamble,
Transmitting_SFD,
Transmitting_PHR,
Transmitting_SDE,
Transmitting_DATA,
Reserved_0110,
Reserved_0111,
Reserved_1000,
Reserved_1001,
Reserved_1010,
Reserved_1011,
Reserved_1100,
Reserved_1101,
Reserved_1110,
Reserved_1111)
with Size => 4;
-- Current Transmit State Machine value
type SYS_STATE_RX_STATE_Field is
(Idle,
Start_Analog,
Reserved_00010,
Reserved_00011,
Rx_Ready,
Preamble_Search,
Preamble_Timeout,
SFD_Search,
Configure_PHR_Rx,
PHY_Rx_Start,
Data_Rate_Ready,
Reserved_01011,
Data_Rx_Seq,
Configure_Data_Rx,
PHR_Not_OK,
Last_Symbol,
Wait_RSD_Done,
RSD_OK,
RSD_Not_OK,
Reconfigure_110K,
Wait_110K_PHR,
Reserved_10101,
Reserved_10110,
Reserved_10111,
Reserved_11000,
Reserved_11001,
Reserved_11010,
Reserved_11011,
Reserved_11100,
Reserved_11101,
Reserved_11110,
Reserved_11111)
with Size => 5;
-- Current Receive State Machine value
type SYS_STATE_PMSC_STATE_Field is
(Init,
Idle,
TX_Wait,
RX_Wait,
Tx,
Rx,
Reserved_0110,
Reserved_0111,
Reserved_1000,
Reserved_1001,
Reserved_1010,
Reserved_1011,
Reserved_1100,
Reserved_1101,
Reserved_1110,
Reserved_1111)
with Size => 4;
type SYS_STATE_Type is record
TX_STATE : SYS_STATE_TX_STATE_Field := Idle;
RX_STATE : SYS_STATE_RX_STATE_Field := Idle;
PMSC_STATE : SYS_STATE_PMSC_STATE_Field := Idle;
Reserved_1 : Bits_4 := 0;
Reserved_2 : Bits_3 := 0;
Reserved_3 : Bits_12 := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for SYS_STATE_Type use record
TX_STATE at 0 range 0 .. 3;
Reserved_1 at 0 range 4 .. 7;
RX_STATE at 0 range 8 .. 12;
Reserved_2 at 0 range 13 .. 15;
PMSC_STATE at 0 range 16 .. 19;
Reserved_3 at 0 range 20 .. 31;
end record;
----------------------------------------------------------------------------
-- ACK_RESP_T register file
type ACK_RESP_T_ACK_TIM_Field is range 0 .. 255
with Size => 8;
-- Auto-Acknowledgement turn-around Time (in number of preamble symbols).
type ACK_RESP_T_Type is record
W4D_TIM : System_Time.Response_Wait_Timeout_Time := 0.0;
ACK_TIM : ACK_RESP_T_ACK_TIM_Field := 0;
Reserved : Types.Bits_4 := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for ACK_RESP_T_Type use record
W4D_TIM at 0 range 0 .. 19;
Reserved at 0 range 20 .. 23;
ACK_TIM at 0 range 24 .. 31;
end record;
----------------------------------------------------------------------------
-- RX_SNIFF register file
type RX_SNIFF_SNIFF_ONT_Field is range 0 .. 15
with Size => 4;
-- SNIFF Mode ON time. This parameter is specified in units of PAC.
type RX_SNIFF_Type is record
SNIFF_ONT : RX_SNIFF_SNIFF_ONT_Field := 0;
SNIFF_OFFT : System_Time.Sniff_Off_Time := 0.0;
Reserved_1 : Types.Bits_4 := 0;
Reserved_2 : Types.Bits_16 := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for RX_SNIFF_Type use record
SNIFF_ONT at 0 range 0 .. 3;
Reserved_1 at 0 range 4 .. 7;
SNIFF_OFFT at 0 range 8 .. 15;
Reserved_2 at 0 range 16 .. 31;
end record;
----------------------------------------------------------------------------
-- TX_POWER register file
type TX_POWER_COARSE_Field is
(Gain_15_dB,
Gain_12_5_dB,
Gain_10_dB,
Gain_7_5_dB,
Gain_5_dB,
Gain_2_5_dB,
Gain_0_dB,
Off) -- No output when used
with Size => 3;
-- Coarse (DA setting) gain in 2.5 dB steps.
--
-- Unfortunately we can't use a fixed-point type here (like the fine gain)
-- due to the reversed HW representation of the coarse gain and the
-- need for the special "Off" setting.
type TX_POWER_FINE_Field is delta 0.5 range 0.0 .. 15.5
with Size => 5;
-- Fine (Mixer) gain in dB (Decibels) in 0.5 dB steps.
type TX_POWER_Field is record
Fine_Gain : TX_POWER_FINE_Field := 0.0;
Coarse_Gain : TX_POWER_COARSE_Field := Gain_15_dB;
end record
with Size => 8;
for TX_POWER_Field use record
Fine_Gain at 0 range 0 .. 4;
Coarse_Gain at 0 range 5 .. 7;
end record;
type TX_POWER_Type is record
BOOSTNORM : TX_POWER_Field := (Fine_Gain => 1.0,
Coarse_Gain => Gain_12_5_dB);
BOOSTP500 : TX_POWER_Field := (Fine_Gain => 1.0,
Coarse_Gain => Gain_15_dB);
BOOSTP250 : TX_POWER_Field := (Fine_Gain => 4.0,
Coarse_Gain => Gain_15_dB);
BOOSTP125 : TX_POWER_Field := (Fine_Gain => 7.0,
Coarse_Gain => Gain_15_dB);
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for TX_POWER_Type use record
BOOSTNORM at 0 range 0 .. 7;
BOOSTP500 at 0 range 8 .. 15;
BOOSTP250 at 0 range 16 .. 23;
BOOSTP125 at 0 range 24 .. 31;
end record;
----------------------------------------------------------------------------
-- CHAN_CTRL register file
type CHAN_CTRL_Channel_Field is range 0 .. 15
with Size => 4;
-- This selects the transmit/receive channel.
type CHAN_CTRL_DWSFD_Field is
(Disabled,
Enabled)
with Size => 1;
-- This bit enables a non-standard Decawave proprietary SFD sequence.
type CHAN_CTRL_RXPRF_Field is
(Reserved_00,
PRF_16MHz,
PRF_64MHz,
Reserved_11)
with Size => 2;
-- This two bit field selects the PRF used in the receiver.
type CHAN_CTRL_TNSSFD_Field is
(Disabled,
Enabled)
with Size => 1;
-- This bit enables the use of a user specified (non-standard) SFD in the
-- transmitter.
type CHAN_CTRL_RNSSFD_Field is
(Disabled,
Enabled)
with Size => 1;
-- This bit enables the use of a user specified (non-standard) SFD in the
-- receiver.
type CHAN_CTRL_PCODE_Field is range 0 .. 31
with Size => 5;
-- This field selects the preamble code used in the transmitter/receiver.
type CHAN_CTRL_Type is record
TX_CHAN : CHAN_CTRL_Channel_Field := 5;
RX_CHAN : CHAN_CTRL_Channel_Field := 5;
DWSFD : CHAN_CTRL_DWSFD_Field := Disabled;
RXPRF : CHAN_CTRL_RXPRF_Field := Reserved_00;
TNSSFD : CHAN_CTRL_TNSSFD_Field := Disabled;
RNSSFD : CHAN_CTRL_RNSSFD_Field := Disabled;
TX_PCODE : CHAN_CTRL_PCODE_Field := 0;
RX_PCODE : CHAN_CTRL_PCODE_Field := 0;
Reserved : Types.Bits_9 := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for CHAN_CTRL_Type use record
TX_CHAN at 0 range 0 .. 3;
RX_CHAN at 0 range 4 .. 7;
Reserved at 0 range 8 .. 16;
DWSFD at 0 range 17 .. 17;
RXPRF at 0 range 18 .. 19;
TNSSFD at 0 range 20 .. 20;
RNSSFD at 0 range 21 .. 21;
TX_PCODE at 0 range 22 .. 26;
RX_PCODE at 0 range 27 .. 31;
end record;
----------------------------------------------------------------------------
-- USR_SFD register file
type USR_SFD_Type is record
Sub_Registers : Types.Byte_Array (0 .. 40);
end record
with Size => 41 * 8,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for USR_SFD_Type use record
Sub_Registers at 0 range 0 .. (41 * 8) - 1;
end record;
----------------------------------------------------------------------------
-- AGC_CTRL register file
------------------------------
-- AGC_CTRL1 sub-register --
------------------------------
type AGC_CTRL1_DIS_AM_Field is
(Not_Disabled,
Disabled)
with Size => 1;
type AGC_CTRL1_Type is record
DIS_AM : AGC_CTRL1_DIS_AM_Field := Disabled;
Reserved : Types.Bits_15 := 0;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for AGC_CTRL1_Type use record
DIS_AM at 0 range 0 .. 0;
Reserved at 0 range 1 .. 15;
end record;
------------------------------
-- AGC_TUNE1 sub-register --
------------------------------
type AGC_TUNE1_Field is new Bits_16;
AGC_TUNE1_PRF_16MHz : constant AGC_TUNE1_Field := 16#8870#;
AGC_TUNE1_PRF_64MHz : constant AGC_TUNE1_Field := 16#889B#;
type AGC_TUNE1_Type is record
AGC_TUNE1 : AGC_TUNE1_Field;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for AGC_TUNE1_Type use record
AGC_TUNE1 at 0 range 0 .. 15;
end record;
------------------------------
-- AGC_TUNE2 sub-register --
------------------------------
type AGC_TUNE2_Field is new Bits_32;
AGC_TUNE2_Value : constant AGC_TUNE2_Field := 16#2502A907#;
type AGC_TUNE2_Type is record
AGC_TUNE2 : AGC_TUNE2_Field;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for AGC_TUNE2_Type use record
AGC_TUNE2 at 0 range 0 .. 31;
end record;
------------------------------
-- AGC_TUNE3 sub-register --
------------------------------
type AGC_TUNE3_Field is new Bits_16;
AGC_TUNE3_Value : constant AGC_TUNE3_Field := 16#0035#;
type AGC_TUNE3_Type is record
AGC_TUNE3 : AGC_TUNE3_Field;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for AGC_TUNE3_Type use record
AGC_TUNE3 at 0 range 0 .. 15;
end record;
------------------------------
-- AGC_STAT1 sub-register --
------------------------------
type AGC_STAT1_EDG1_Field is range 0 .. 2**5 - 1
with Size => 5;
-- This 5-bit gain value relates to input noise power measurement.
type AGC_STAT1_EDV2_Field is range 0 .. 2**9 - 1
with Size => 9;
-- This 9-bit value relates to the input noise power measurement.
type AGC_STAT1_Type is record
EDG1 : AGC_STAT1_EDG1_Field;
EDV2 : AGC_STAT1_EDV2_Field;
Reserved_1 : Types.Bits_6;
Reserved_2 : Types.Bits_4;
end record
with Size => 24,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for AGC_STAT1_Type use record
Reserved_1 at 0 range 0 .. 5;
EDG1 at 0 range 6 .. 10;
EDV2 at 0 range 11 .. 19;
Reserved_2 at 0 range 20 .. 23;
end record;
----------------------------------------------------------------------------
-- EXT_SYNC register file
---------------------------
-- EC_CTRL sub-register --
---------------------------
type EC_CTRL_OSTSM_Field is
(Disabled,
Enabled)
with Size => 1;
-- External transmit synchronisation mode enable.
type EC_CTRL_OSRSM_Field is
(Disabled,
Enabled)
with Size => 1;
-- External receive synchronisation mode enable.
type EC_CTRL_PLLLDT_Field is
(Disabled,
Enabled)
with Size => 1;
-- Clock PLL lock detect tune.
type EC_CTRL_WAIT_Field is range 0 .. 255
with Size => 8;
-- Wait counter used for external transmit synchronisation and external
-- timebase reset.
--
-- The wait time is the number of external clock cycles (@ 38.4 MHz).
type EC_CTRL_OSTRM_Field is
(Disabled,
Enabled)
with Size => 1;
type EC_CTRL_Type is record
OSTSM : EC_CTRL_OSTSM_Field := Disabled;
OSRSM : EC_CTRL_OSRSM_Field := Disabled;
PLLLDT : EC_CTRL_PLLLDT_Field := Enabled;
WAIT : EC_CTRL_WAIT_Field := 0;
OSTRM : EC_CTRL_OSTRM_Field := Disabled;
Reserved : Types.Bits_20 := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for EC_CTRL_Type use record
OSTSM at 0 range 0 .. 0;
OSRSM at 0 range 1 .. 1;
PLLLDT at 0 range 2 .. 2;
WAIT at 0 range 3 .. 10;
OSTRM at 0 range 11 .. 11;
Reserved at 0 range 12 .. 31;
end record;
---------------------------
-- EC_RXTC sub-register --
---------------------------
type EC_RCTC_RX_TS_EST_Field is range 0 .. 2**32 - 1
with Size => 32;
-- External clock synchronisation counter captured on RMARKER.
type EC_RXTC_Type is record
RX_TS_EST : EC_RCTC_RX_TS_EST_Field;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for EC_RXTC_Type use record
RX_TS_EST at 0 range 0 .. 31;
end record;
---------------------------
-- EC_GOLP sub-register --
---------------------------
type EC_GOLP_OFFSET_EXT_Field is range 0 .. 2**6 - 1
with Size => 6;
type EC_GOLP_Type is record
OFFSET_EXT : EC_GOLP_OFFSET_EXT_Field := 0;
Reserved : Types.Bits_26 := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for EC_GOLP_Type use record
OFFSET_EXT at 0 range 0 .. 5;
Reserved at 0 range 6 .. 31;
end record;
----------------------------------------------------------------------------
-- ACC_MEM register file
type ACC_MEM_Number_Type is range -32_768 .. 32_767
with Size => 16;
type ACC_MEM_Sample_Type is record
Real : ACC_MEM_Number_Type;
Imag : ACC_MEM_Number_Type;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for ACC_MEM_Sample_Type use record
Real at 0 range 0 .. 15;
Imag at 2 range 0 .. 15;
end record;
type ACC_MEM_CIR_Array is array (Types.Index range <>) of ACC_MEM_Sample_Type;
type ACC_MEM_Type is record
CIR : ACC_MEM_CIR_Array (0 .. 1015);
end record
with Size => 4064 * 8,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for ACC_MEM_Type use record
CIR at 0 range 0 .. (4064 * 8) - 1;
end record;
----------------------------------------------------------------------------
-- GPIO_CTRL register file
-----------------------------
-- GPIO_MODE sub-register --
-----------------------------
type GPIO_MODE_MSGP0_Field is
(GPIO0,
RXOKLED,
Reserved_10,
Reserved_11)
with Size => 2;
-- Mode Selection for GPIO0/RXOKLED.
type GPIO_MODE_MSGP1_Field is
(GPIO1,
SFDLED,
Reserved_10,
Reserved_11)
with Size => 2;
-- Mode Selection for GPIO1/SFDLED.
type GPIO_MODE_MSGP2_Field is
(GPIO2,
RXLED,
Reserved_10,
Reserved_11)
with Size => 2;
-- Mode Selection for GPIO2/RXLED
type GPIO_MODE_MSGP3_Field is
(GPIO3,
TXLED,
Reserved_10,
Reserved_11)
with Size => 2;
-- Mode Selection for GPIO3/TXLED
type GPIO_MODE_MSGP4_Field is
(GPIO4,
EXTPA,
Reserved_10,
Reserved_11)
with Size => 2;
-- Mode Selection for GPIO4/EXTPA
type GPIO_MODE_MSGP5_Field is
(GPIO5,
EXTTXE,
Reserved_10,
Reserved_11)
with Size => 2;
-- Mode Selection for GPIO5/EXTTXE
type GPIO_MODE_MSGP6_Field is
(GPIO6,
EXTRXE,
Reserved_10,
Reserved_11)
with Size => 2;
-- Mode Selection for GPIO6/EXTRXE
type GPIO_MODE_MSGP7_Field is
(SYNC,
GPIO7,
Reserved_10,
Reserved_11)
with Size => 2;
-- Mode Selection for SYNC/GPIO7
type GPIO_MODE_MSGP8_Field is
(IRQ,
GPIO8,
Reserved_10,
Reserved_11)
with Size => 2;
-- Mode Selection for IRQ/GPIO8
type GPIO_MODE_Type is record
MSGP0 : GPIO_MODE_MSGP0_Field := GPIO0;
MSGP1 : GPIO_MODE_MSGP1_Field := GPIO1;
MSGP2 : GPIO_MODE_MSGP2_Field := GPIO2;
MSGP3 : GPIO_MODE_MSGP3_Field := GPIO3;
MSGP4 : GPIO_MODE_MSGP4_Field := GPIO4;
MSGP5 : GPIO_MODE_MSGP5_Field := GPIO5;
MSGP6 : GPIO_MODE_MSGP6_Field := GPIO6;
MSGP7 : GPIO_MODE_MSGP7_Field := SYNC;
MSGP8 : GPIO_MODE_MSGP8_Field := IRQ;
Reserved_1 : Types.Bits_6 := 0;
Reserved_2 : Types.Bits_8 := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for GPIO_MODE_Type use record
Reserved_1 at 0 range 0 .. 5;
MSGP0 at 0 range 6 .. 7;
MSGP1 at 0 range 8 .. 9;
MSGP2 at 0 range 10 .. 11;
MSGP3 at 0 range 12 .. 13;
MSGP4 at 0 range 14 .. 15;
MSGP5 at 0 range 16 .. 17;
MSGP6 at 0 range 18 .. 19;
MSGP7 at 0 range 20 .. 21;
MSGP8 at 0 range 22 .. 23;
Reserved_2 at 0 range 24 .. 31;
end record;
----------------------------
-- GPIO_DIR sub-register --
----------------------------
type GPIO_DIR_GDP_Field is
(Output,
Input)
with Size => 1;
-- Direction Selection for GPIOx
type GPIO_DIR_GDM_Field is
(Clear,
Set)
with Size => 1;
-- Mask for setting the direction of GPIOx.
--
-- When writing to GDP0 so select the I/O direction of GPIOx, the value of
-- GDPx is only changed if this GDMx mask bit is Set for the write
-- operation. GDMx will always read as 0.
type GPIO_DIR_Type is record
GDP0 : GPIO_DIR_GDP_Field := Input;
GDP1 : GPIO_DIR_GDP_Field := Input;
GDP2 : GPIO_DIR_GDP_Field := Input;
GDP3 : GPIO_DIR_GDP_Field := Input;
GDM0 : GPIO_DIR_GDM_Field := Clear;
GDM1 : GPIO_DIR_GDM_Field := Clear;
GDM2 : GPIO_DIR_GDM_Field := Clear;
GDM3 : GPIO_DIR_GDM_Field := Clear;
GDP4 : GPIO_DIR_GDP_Field := Input;
GDP5 : GPIO_DIR_GDP_Field := Input;
GDP6 : GPIO_DIR_GDP_Field := Input;
GDP7 : GPIO_DIR_GDP_Field := Input;
GDM4 : GPIO_DIR_GDM_Field := Clear;
GDM5 : GPIO_DIR_GDM_Field := Clear;
GDM6 : GPIO_DIR_GDM_Field := Clear;
GDM7 : GPIO_DIR_GDM_Field := Clear;
GDP8 : GPIO_DIR_GDP_Field := Input;
GDM8 : GPIO_DIR_GDM_Field := Clear;
Reserved_1 : Types.Bits_3 := 0;
Reserved_2 : Types.Bits_11 := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for GPIO_DIR_Type use record
GDP0 at 0 range 0 .. 0;
GDP1 at 0 range 1 .. 1;
GDP2 at 0 range 2 .. 2;
GDP3 at 0 range 3 .. 3;
GDM0 at 0 range 4 .. 4;
GDM1 at 0 range 5 .. 5;
GDM2 at 0 range 6 .. 6;
GDM3 at 0 range 7 .. 7;
GDP4 at 0 range 8 .. 8;
GDP5 at 0 range 9 .. 9;
GDP6 at 0 range 10 .. 10;
GDP7 at 0 range 11 .. 11;
GDM4 at 0 range 12 .. 12;
GDM5 at 0 range 13 .. 13;
GDM6 at 0 range 14 .. 14;
GDM7 at 0 range 15 .. 15;
GDP8 at 0 range 16 .. 16;
Reserved_1 at 0 range 17 .. 19;
GDM8 at 0 range 20 .. 20;
Reserved_2 at 0 range 21 .. 31;
end record;
-----------------------------
-- GPIO_DOUT sub-register --
-----------------------------
type GPIO_DOUT_GOM_Field is
(Clear,
Set)
with Size => 1;
type GPIO_DOUT_Type is record
GOP0 : Types.Bits_1 := 0;
GOP1 : Types.Bits_1 := 0;
GOP2 : Types.Bits_1 := 0;
GOP3 : Types.Bits_1 := 0;
GOM0 : GPIO_DOUT_GOM_Field := Clear;
GOM1 : GPIO_DOUT_GOM_Field := Clear;
GOM2 : GPIO_DOUT_GOM_Field := Clear;
GOM3 : GPIO_DOUT_GOM_Field := Clear;
GOP4 : Types.Bits_1 := 0;
GOP5 : Types.Bits_1 := 0;
GOP6 : Types.Bits_1 := 0;
GOP7 : Types.Bits_1 := 0;
GOM4 : GPIO_DOUT_GOM_Field := Clear;
GOM5 : GPIO_DOUT_GOM_Field := Clear;
GOM6 : GPIO_DOUT_GOM_Field := Clear;
GOM7 : GPIO_DOUT_GOM_Field := Clear;
GOP8 : Types.Bits_1 := 0;
GOM8 : GPIO_DOUT_GOM_Field := Clear;
Reserved_1 : Types.Bits_3 := 0;
Reserved_2 : Types.Bits_11 := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for GPIO_DOUT_Type use record
GOP0 at 0 range 0 .. 0;
GOP1 at 0 range 1 .. 1;
GOP2 at 0 range 2 .. 2;
GOP3 at 0 range 3 .. 3;
GOM0 at 0 range 4 .. 4;
GOM1 at 0 range 5 .. 5;
GOM2 at 0 range 6 .. 6;
GOM3 at 0 range 7 .. 7;
GOP4 at 0 range 8 .. 8;
GOP5 at 0 range 9 .. 9;
GOP6 at 0 range 10 .. 10;
GOP7 at 0 range 11 .. 11;
GOM4 at 0 range 12 .. 12;
GOM5 at 0 range 13 .. 13;
GOM6 at 0 range 14 .. 14;
GOM7 at 0 range 15 .. 15;
GOP8 at 0 range 16 .. 16;
Reserved_1 at 0 range 17 .. 19;
GOM8 at 0 range 20 .. 20;
Reserved_2 at 0 range 21 .. 31;
end record;
-----------------------------
-- GPIO_IRQE sub-register --
-----------------------------
type GPIO_IREQ_GIRQE_Field is
(Disabled,
Enabled)
with Size => 1;
-- GPIO IRQ Enable for GPIOx input.
type GPIO_IRQE_Type is record
GIRQE0 : GPIO_IREQ_GIRQE_Field := Disabled;
GIRQE1 : GPIO_IREQ_GIRQE_Field := Disabled;
GIRQE2 : GPIO_IREQ_GIRQE_Field := Disabled;
GIRQE3 : GPIO_IREQ_GIRQE_Field := Disabled;
GIRQE4 : GPIO_IREQ_GIRQE_Field := Disabled;
GIRQE5 : GPIO_IREQ_GIRQE_Field := Disabled;
GIRQE6 : GPIO_IREQ_GIRQE_Field := Disabled;
GIRQE7 : GPIO_IREQ_GIRQE_Field := Disabled;
GIRQE8 : GPIO_IREQ_GIRQE_Field := Disabled;
Reserved : Types.Bits_23 := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for GPIO_IRQE_Type use record
GIRQE0 at 0 range 0 .. 0;
GIRQE1 at 0 range 1 .. 1;
GIRQE2 at 0 range 2 .. 2;
GIRQE3 at 0 range 3 .. 3;
GIRQE4 at 0 range 4 .. 4;
GIRQE5 at 0 range 5 .. 5;
GIRQE6 at 0 range 6 .. 6;
GIRQE7 at 0 range 7 .. 7;
GIRQE8 at 0 range 8 .. 8;
Reserved at 0 range 9 .. 31;
end record;
-----------------------------
-- GPIO_ISEN sub-register --
-----------------------------
type GPIO_ISEN_GISEN_Field is
(Active_High,
Active_Low)
with Size => 1;
-- GPIO IRQ Sense selection GPIO0 input.
type GPIO_ISEN_Type is record
GISEN0 : GPIO_ISEN_GISEN_Field := Active_High;
GISEN1 : GPIO_ISEN_GISEN_Field := Active_High;
GISEN2 : GPIO_ISEN_GISEN_Field := Active_High;
GISEN3 : GPIO_ISEN_GISEN_Field := Active_High;
GISEN4 : GPIO_ISEN_GISEN_Field := Active_High;
GISEN5 : GPIO_ISEN_GISEN_Field := Active_High;
GISEN6 : GPIO_ISEN_GISEN_Field := Active_High;
GISEN7 : GPIO_ISEN_GISEN_Field := Active_High;
GISEN8 : GPIO_ISEN_GISEN_Field := Active_High;
Reserved : Types.Bits_23 := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for GPIO_ISEN_Type use record
GISEN0 at 0 range 0 .. 0;
GISEN1 at 0 range 1 .. 1;
GISEN2 at 0 range 2 .. 2;
GISEN3 at 0 range 3 .. 3;
GISEN4 at 0 range 4 .. 4;
GISEN5 at 0 range 5 .. 5;
GISEN6 at 0 range 6 .. 6;
GISEN7 at 0 range 7 .. 7;
GISEN8 at 0 range 8 .. 8;
Reserved at 0 range 9 .. 31;
end record;
------------------------------
-- GPIO_IMODE sub-register --
------------------------------
type GPIO_IMODE_GIMOD_Field is
(Level,
Edge)
with Size => 1;
-- GPIO IRQ Mode selection for GPIOx input.
type GPIO_IMODE_Type is record
GIMOD0 : GPIO_IMODE_GIMOD_Field := Level;
GIMOD1 : GPIO_IMODE_GIMOD_Field := Level;
GIMOD2 : GPIO_IMODE_GIMOD_Field := Level;
GIMOD3 : GPIO_IMODE_GIMOD_Field := Level;
GIMOD4 : GPIO_IMODE_GIMOD_Field := Level;
GIMOD5 : GPIO_IMODE_GIMOD_Field := Level;
GIMOD6 : GPIO_IMODE_GIMOD_Field := Level;
GIMOD7 : GPIO_IMODE_GIMOD_Field := Level;
GIMOD8 : GPIO_IMODE_GIMOD_Field := Level;
Reserved : Types.Bits_23 := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for GPIO_IMODE_Type use record
GIMOD0 at 0 range 0 .. 0;
GIMOD1 at 0 range 1 .. 1;
GIMOD2 at 0 range 2 .. 2;
GIMOD3 at 0 range 3 .. 3;
GIMOD4 at 0 range 4 .. 4;
GIMOD5 at 0 range 5 .. 5;
GIMOD6 at 0 range 6 .. 6;
GIMOD7 at 0 range 7 .. 7;
GIMOD8 at 0 range 8 .. 8;
Reserved at 0 range 9 .. 31;
end record;
-----------------------------
-- GPIO_IBES sub-register --
-----------------------------
type GPIO_IBES_GIBES_Field is
(Use_GPIO_IMODE,
Both_Edges)
with Size => 1;
-- GPIO IRQ "Both Edge" selection for GPIOx input.
type GPIO_IBES_Type is record
GIBES0 : GPIO_IBES_GIBES_Field := Use_GPIO_IMODE;
GIBES1 : GPIO_IBES_GIBES_Field := Use_GPIO_IMODE;
GIBES2 : GPIO_IBES_GIBES_Field := Use_GPIO_IMODE;
GIBES3 : GPIO_IBES_GIBES_Field := Use_GPIO_IMODE;
GIBES4 : GPIO_IBES_GIBES_Field := Use_GPIO_IMODE;
GIBES5 : GPIO_IBES_GIBES_Field := Use_GPIO_IMODE;
GIBES6 : GPIO_IBES_GIBES_Field := Use_GPIO_IMODE;
GIBES7 : GPIO_IBES_GIBES_Field := Use_GPIO_IMODE;
GIBES8 : GPIO_IBES_GIBES_Field := Use_GPIO_IMODE;
Reserved : Types.Bits_23 := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for GPIO_IBES_Type use record
GIBES0 at 0 range 0 .. 0;
GIBES1 at 0 range 1 .. 1;
GIBES2 at 0 range 2 .. 2;
GIBES3 at 0 range 3 .. 3;
GIBES4 at 0 range 4 .. 4;
GIBES5 at 0 range 5 .. 5;
GIBES6 at 0 range 6 .. 6;
GIBES7 at 0 range 7 .. 7;
GIBES8 at 0 range 8 .. 8;
Reserved at 0 range 9 .. 31;
end record;
-----------------------------
-- GPIO_ICLR sub-register --
-----------------------------
type GPIO_ICLR_GICLR_Field is
(No_Action,
Clear_IRQ_Latch)
with Size => 1;
-- GPIO IRQ latch clear for GPIOx input.
type GPIO_ICLR_Type is record
GICLR0 : GPIO_ICLR_GICLR_Field := No_Action;
GICLR1 : GPIO_ICLR_GICLR_Field := No_Action;
GICLR2 : GPIO_ICLR_GICLR_Field := No_Action;
GICLR3 : GPIO_ICLR_GICLR_Field := No_Action;
GICLR4 : GPIO_ICLR_GICLR_Field := No_Action;
GICLR5 : GPIO_ICLR_GICLR_Field := No_Action;
GICLR6 : GPIO_ICLR_GICLR_Field := No_Action;
GICLR7 : GPIO_ICLR_GICLR_Field := No_Action;
GICLR8 : GPIO_ICLR_GICLR_Field := No_Action;
Reserved : Types.Bits_23 := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for GPIO_ICLR_Type use record
GICLR0 at 0 range 0 .. 0;
GICLR1 at 0 range 1 .. 1;
GICLR2 at 0 range 2 .. 2;
GICLR3 at 0 range 3 .. 3;
GICLR4 at 0 range 4 .. 4;
GICLR5 at 0 range 5 .. 5;
GICLR6 at 0 range 6 .. 6;
GICLR7 at 0 range 7 .. 7;
GICLR8 at 0 range 8 .. 8;
Reserved at 0 range 9 .. 31;
end record;
-----------------------------
-- GPIO_IDBE sub-register --
-----------------------------
type GPIO_IDBE_GIDBE_Field is
(Disabled,
Enabled)
with Size => 1;
-- GPIO IRQ de-bounce enable for GPIOx.
type GPIO_IDBE_Type is record
GIDBE0 : GPIO_IDBE_GIDBE_Field := Disabled;
GIDBE1 : GPIO_IDBE_GIDBE_Field := Disabled;
GIDBE2 : GPIO_IDBE_GIDBE_Field := Disabled;
GIDBE3 : GPIO_IDBE_GIDBE_Field := Disabled;
GIDBE4 : GPIO_IDBE_GIDBE_Field := Disabled;
GIDBE5 : GPIO_IDBE_GIDBE_Field := Disabled;
GIDBE6 : GPIO_IDBE_GIDBE_Field := Disabled;
GIDBE7 : GPIO_IDBE_GIDBE_Field := Disabled;
GIDBE8 : GPIO_IDBE_GIDBE_Field := Disabled;
Reserved : Types.Bits_23 := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for GPIO_IDBE_Type use record
GIDBE0 at 0 range 0 .. 0;
GIDBE1 at 0 range 1 .. 1;
GIDBE2 at 0 range 2 .. 2;
GIDBE3 at 0 range 3 .. 3;
GIDBE4 at 0 range 4 .. 4;
GIDBE5 at 0 range 5 .. 5;
GIDBE6 at 0 range 6 .. 6;
GIDBE7 at 0 range 7 .. 7;
GIDBE8 at 0 range 8 .. 8;
Reserved at 0 range 9 .. 31;
end record;
----------------------------
-- GPIO_RAW sub-register --
----------------------------
type GPIO_RAW_Type is record
GRAWP0 : Types.Bits_1 := 0;
GRAWP1 : Types.Bits_1 := 0;
GRAWP2 : Types.Bits_1 := 0;
GRAWP3 : Types.Bits_1 := 0;
GRAWP4 : Types.Bits_1 := 0;
GRAWP5 : Types.Bits_1 := 0;
GRAWP6 : Types.Bits_1 := 0;
GRAWP7 : Types.Bits_1 := 0;
GRAWP8 : Types.Bits_1 := 0;
Reserved : Types.Bits_23 := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for GPIO_RAW_Type use record
GRAWP0 at 0 range 0 .. 0;
GRAWP1 at 0 range 1 .. 1;
GRAWP2 at 0 range 2 .. 2;
GRAWP3 at 0 range 3 .. 3;
GRAWP4 at 0 range 4 .. 4;
GRAWP5 at 0 range 5 .. 5;
GRAWP6 at 0 range 6 .. 6;
GRAWP7 at 0 range 7 .. 7;
GRAWP8 at 0 range 8 .. 8;
Reserved at 0 range 9 .. 31;
end record;
----------------------------------------------------------------------------
-- DRX_CONF register file
------------------------------
-- DRX_TUNE0b sub-register --
------------------------------
type DRX_TUNE0b_Field is new Bits_16;
DRX_TUNE0b_110K_STD : constant DRX_TUNE0b_Field := 16#000A#;
DRX_TUNE0b_110K_Non_STD : constant DRX_TUNE0b_Field := 16#0016#;
DRX_TUNE0b_850K_STD : constant DRX_TUNE0b_Field := 16#0001#;
DRX_TUNE0b_850K_Non_STD : constant DRX_TUNE0b_Field := 16#0006#;
DRX_TUNE0b_6M8_STD : constant DRX_TUNE0b_Field := 16#0001#;
DRX_TUNE0b_6M8_Non_STD : constant DRX_TUNE0b_Field := 16#0002#;
type DRX_TUNE0b_Type is record
DRX_TUNE0b : DRX_TUNE0b_Field;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for DRX_TUNE0b_Type use record
DRX_TUNE0b at 0 range 0 .. 15;
end record;
------------------------------
-- DRX_TUNE1a sub-register --
------------------------------
type DRX_TUNE1a_Field is new Bits_16;
DRX_TUNE1a_16MHz : constant DRX_TUNE1a_Field := 16#0087#;
DRX_TUNE1a_64MHz : constant DRX_TUNE1a_Field := 16#008D#;
type DRX_TUNE1a_Type is record
DRX_TUNE1a : DRX_TUNE1a_Field;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for DRX_TUNE1a_Type use record
DRX_TUNE1a at 0 range 0 .. 15;
end record;
------------------------------
-- DRX_TUNE1b sub-register --
------------------------------
type DRX_TUNE1b_Field is new Bits_16;
DRX_TUNE1b_110K : constant DRX_TUNE1b_Field := 16#0064#;
-- Preamble lengths > 1024 symbols, for 110 kbps operation
DRX_TUNE1b_850K_6M8 : constant DRX_TUNE1b_Field := 16#0020#;
-- Preamble lengths 128 to 1024 symbols, for 850 kbps and 6.8 Mbps operation
DRX_TUNE1b_6M8 : constant DRX_TUNE1b_Field := 16#0010#;
-- Preamble length = 64 symbols, for 6.8 Mbps operation
type DRX_TUNE1b_Type is record
DRX_TUNE1b : DRX_TUNE1b_Field;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for DRX_TUNE1b_Type use record
DRX_TUNE1b at 0 range 0 .. 15;
end record;
------------------------------
-- DRX_TUNE2 sub-register --
------------------------------
type DRX_TUNE2_Field is new Bits_32;
DRX_TUNE2_PAC8_16MHz : constant DRX_TUNE2_Field := 16#311A002D#;
DRX_TUNE2_PAC8_64MHz : constant DRX_TUNE2_Field := 16#313B006B#;
DRX_TUNE2_PAC16_16MHz : constant DRX_TUNE2_Field := 16#331A0052#;
DRX_TUNE2_PAC16_64MHz : constant DRX_TUNE2_Field := 16#333B00BE#;
DRX_TUNE2_PAC32_16MHz : constant DRX_TUNE2_Field := 16#351A009A#;
DRX_TUNE2_PAC32_64MHz : constant DRX_TUNE2_Field := 16#353B015E#;
DRX_TUNE2_PAC64_16MHz : constant DRX_TUNE2_Field := 16#371A011D#;
DRX_TUNE2_PAC64_64MHz : constant DRX_TUNE2_Field := 16#373B0296#;
type DRX_TUNE2_Type is record
DRX_TUNE2 : DRX_TUNE2_Field;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for DRX_TUNE2_Type use record
DRX_TUNE2 at 0 range 0 .. 31;
end record;
------------------------------
-- DRX_SFDTOC sub-register --
------------------------------
type DRX_SFDTOC_Field is range 0 .. 2**16 - 1
with Size => 16;
-- SFD detection timeout count (in units of preamble symbols)
type DRX_SFDTOC_Type is record
DRX_SFDTOC : DRX_SFDTOC_Field;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for DRX_SFDTOC_Type use record
DRX_SFDTOC at 0 range 0 .. 15;
end record;
------------------------------
-- DRX_PRETOC sub-register --
------------------------------
type DRX_PRETOC_Field is range 0 .. 2**16 - 1
with Size => 16;
-- Preamble detection timeout count (in units of PAC size symbols)
type DRX_PRETOC_Type is record
DRX_PRETOC : DRX_PRETOC_Field;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for DRX_PRETOC_Type use record
DRX_PRETOC at 0 range 0 .. 15;
end record;
------------------------------
-- DRX_TUNE4H sub-register --
------------------------------
type DRX_TUNE4H_Field is new Bits_16;
DRX_TUNE4H_Preamble_64 : constant DRX_TUNE4H_Field := 16#0010#; -- 64
DRX_TUNE4H_Others : constant DRX_TUNE4H_Field := 16#0028#; -- 128 or greater
type DRX_TUNE4H_Type is record
DRX_TUNE4H : DRX_TUNE4H_Field;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for DRX_TUNE4H_Type use record
DRX_TUNE4H at 0 range 0 .. 15;
end record;
--------------------------------
-- RXPACC_NOSAT sub-register --
--------------------------------
type RXPACC_NOSAT_Field is range 0 .. 2**16 - 1
with Size => 16;
type RXPACC_NOSAT_Type is record
RXPACC_NOSAT : RXPACC_NOSAT_Field;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for RXPACC_NOSAT_Type use record
RXPACC_NOSAT at 0 range 0 .. 15;
end record;
----------------------------------------------------------------------------
-- RF_CONF register file
---------------------------
-- RF_CONF sub-register --
---------------------------
type RF_CONF_TXFEN_Field is new Bits_5;
-- Transmit block force enable.
RF_CONF_TXFEN_Force_Enable : constant RF_CONF_TXFEN_Field := 16#1F#;
type RF_CONF_PLLFEN_Field is new Bits_3;
-- PLL block force enables.
RF_CONF_PLLFEN_Force_Enable : constant RF_CONF_PLLFEN_Field := 16#5#;
type RF_CONF_LDOFEN_Field is new Bits_5;
-- Write 0x1F to force the enable to all LDOs.
RF_CONF_LDOFEN_Force_Enable : constant RF_CONF_LDOFEN_Field := 16#1F#;
type RF_CONF_TXRXSW_Field is new Bits_2;
RF_CONF_TXRXSW_Force_Tx : constant RF_CONF_TXRXSW_Field := 16#2#;
RF_CONF_TXRXSW_Force_Rx : constant RF_CONF_TXRXSW_Field := 16#1#;
type RF_CONF_Type is record
TXFEN : RF_CONF_TXFEN_Field := 0;
PLLFEN : RF_CONF_PLLFEN_Field := 0;
LDOFEN : RF_CONF_LDOFEN_Field := 0;
TXRXSW : RF_CONF_TXRXSW_Field := 0;
Reserved_1 : Types.Bits_8 := 0;
Reserved_2 : Types.Bits_9 := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for RF_CONF_Type use record
Reserved_1 at 0 range 0 .. 7;
TXFEN at 0 range 8 .. 12;
PLLFEN at 0 range 13 .. 15;
LDOFEN at 0 range 16 .. 20;
TXRXSW at 0 range 21 .. 22;
Reserved_2 at 0 range 23 .. 31;
end record;
------------------------------
-- RF_RXCTRLH sub-register --
------------------------------
type RF_RXCTRLH_Field is new Bits_8;
RF_RXCTRLH_500MHz : constant RF_RXCTRLH_Field := 16#D8#; -- Channels 1,2,3,5
RF_RXCTRLH_900MHz : constant RF_RXCTRLH_Field := 16#BC#; -- Channels 4,7
type RF_RXCTRLH_Type is record
RF_RXCTRLH : RF_RXCTRLH_Field;
end record
with Size => 8,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for RF_RXCTRLH_Type use record
RF_RXCTRLH at 0 range 0 .. 7;
end record;
-----------------------------
-- RF_TXCTRL sub-register --
-----------------------------
type RF_TXCTRL_Field is new Bits_32;
RF_TXCTRL_Channel_1 : constant RF_TXCTRL_Field := 16#00005C40#;
RF_TXCTRL_Channel_2 : constant RF_TXCTRL_Field := 16#00045CA0#;
RF_TXCTRL_Channel_3 : constant RF_TXCTRL_Field := 16#00086CC0#;
RF_TXCTRL_Channel_4 : constant RF_TXCTRL_Field := 16#00045C80#;
RF_TXCTRL_Channel_5 : constant RF_TXCTRL_Field := 16#001E3FE3#;
RF_TXCTRL_Channel_7 : constant RF_TXCTRL_Field := 16#001E7DE0#;
type RF_TXCTRL_Type is record
RF_TXCTRL : RF_TXCTRL_Field;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for RF_TXCTRL_Type use record
RF_TXCTRL at 0 range 0 .. 31;
end record;
-----------------------------
-- RF_STATUS sub-register --
-----------------------------
type RF_STATUS_CPLLLOCK_Field is
(Not_Locked,
Locked)
with Size => 1;
-- Clock PLL Lock status.
type RF_STATUS_CPLLLOW_Field is
(Not_Low,
Low)
with Size => 1;
-- Clock PLL Low flag status.
type RF_STATUS_CPLLHIGH_Field is
(Not_High,
High)
with Size => 1;
-- Clock PLL High flag status.
type RF_STATUS_RFPLLLOCK_Field is
(Not_Locked,
Locked)
with Size => 1;
-- RF PLL Lock status.
type RF_STATUS_Type is record
CPLLLOCK : RF_STATUS_CPLLLOCK_Field := Not_Locked;
CPLLLOW : RF_STATUS_CPLLLOW_Field := Not_Low;
CPLLHIGH : RF_STATUS_CPLLHIGH_Field := Not_High;
RFPLLLOCK : RF_STATUS_RFPLLLOCK_Field := Not_Locked;
Reserved : Types.Bits_4 := 0;
end record
with Size => 8,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for RF_STATUS_Type use record
CPLLLOCK at 0 range 0 .. 0;
CPLLLOW at 0 range 1 .. 1;
CPLLHIGH at 0 range 2 .. 2;
RFPLLLOCK at 0 range 3 .. 3;
Reserved at 0 range 4 .. 7;
end record;
---------------------------
-- LDOTUNE sub-register --
---------------------------
type LDOTUNE_Field is new Bits_40;
type LDOTUNE_Type is record
LDOTUNE : LDOTUNE_Field := 16#88_8888_8888#;
end record
with Size => 40,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for LDOTUNE_Type use record
LDOTUNE at 0 range 0 .. 39;
end record;
----------------------------------------------------------------------------
-- TX_CAL register file
---------------------------
-- TC_SARC sub-register --
---------------------------
type TC_SARC_SAR_CTRL_Field is
(Disabled,
Enabled)
with Size => 1;
-- Enable or disable the SAR
type TC_SARC_Type is record
SAR_CTRL : TC_SARC_SAR_CTRL_Field := Disabled;
Reserved : Types.Bits_15 := 0;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for TC_SARC_Type use record
SAR_CTRL at 0 range 0 .. 0;
Reserved at 0 range 1 .. 15;
end record;
---------------------------
-- TC_SARL sub-register --
---------------------------
type TC_SARL_SAR_LVBAT_Field is range 0 .. 255
with Size => 8;
-- Latest SAR reading for Voltage level.
type TC_SARL_SAR_LTEMP_Field is range 0 .. 255
with Size => 8;
-- Latest SAR reading for Temperature level.
type TC_SARL_Type is record
SAR_LVBAT : TC_SARL_SAR_LVBAT_Field := 0;
SAR_LTEMP : TC_SARL_SAR_LTEMP_Field := 0;
Reserved : Types.Bits_8 := 0;
end record
with Size => 24,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for TC_SARL_Type use record
SAR_LVBAT at 0 range 0 .. 7;
SAR_LTEMP at 0 range 8 .. 15;
Reserved at 0 range 16 .. 23;
end record;
---------------------------
-- TC_SARW sub-register --
---------------------------
type TC_SARW_WVBAT_Field is range 0 .. 255
with Size => 8;
-- SAR reading of Voltage level taken at last wakeup event.
type TC_SARW_WTEMP_Field is range 0 .. 255
with Size => 8;
-- SAR reading of temperature level taken at last wakeup event.
type TC_SARW_Type is record
SAR_WVBAT : TC_SARW_WVBAT_Field := 0;
SAR_WTEMP : TC_SARW_WTEMP_Field := 0;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for TC_SARW_Type use record
SAR_WVBAT at 0 range 0 .. 7;
SAR_WTEMP at 0 range 8 .. 15;
end record;
-------------------------------
-- TC_PG_CTRL sub-register --
-------------------------------
type TC_PG_CTRL_PG_START_Field is
(No_Action,
Start)
with Size => 1;
-- Start the pulse generator calibration.
type TC_PG_CTRL_PG_TMEAS_Field is range 0 .. 15
with Size => 4;
-- Number of clock cycles over which to run the pulse generator cal counter.
type TC_PG_CTRL_Type is record
PG_START : TC_PG_CTRL_PG_START_Field := No_Action;
PG_TMEAS : TC_PG_CTRL_PG_TMEAS_Field := 0;
Reserved_1 : Bits_1;
Reserved_2 : Bits_2;
end record
with Size => 8,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for TC_PG_CTRL_Type use record
PG_START at 0 range 0 .. 0;
Reserved_1 at 0 range 1 .. 1;
PG_TMEAS at 0 range 2 .. 5;
Reserved_2 at 0 range 6 .. 7;
end record;
---------------------------------
-- TC_PG_STATUS sub-register --
---------------------------------
type TC_PG_STATUS_DELAY_CNT_Field is range 0 .. 2**12 - 1
with Size => 12;
-- Reference value required for temperature bandwidth compensation
type TC_PG_STATUS_Type is record
DELAY_CNT : TC_PG_STATUS_DELAY_CNT_Field := 0;
Reserved : Bits_4;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for TC_PG_STATUS_Type use record
DELAY_CNT at 0 range 0 .. 11;
Reserved at 0 range 12 .. 15;
end record;
------------------------------
-- TC_PGDELAY sub-register --
------------------------------
type TC_PGDELAY_Field is new Bits_8;
-- 8-bit configuration register for setting the Pulse Generator Delay value.
TC_PGDELAY_Channel_1 : constant TC_PGDELAY_Field := 16#C9#;
TC_PGDELAY_Channel_2 : constant TC_PGDELAY_Field := 16#C2#;
TC_PGDELAY_Channel_3 : constant TC_PGDELAY_Field := 16#C5#;
TC_PGDELAY_Channel_4 : constant TC_PGDELAY_Field := 16#95#;
TC_PGDELAY_Channel_5 : constant TC_PGDELAY_Field := 16#B5#;
TC_PGDELAY_Channel_7 : constant TC_PGDELAY_Field := 16#93#;
type TC_PGDELAY_Type is record
TC_PGDELAY : TC_PGDELAY_Field;
end record
with Size => 8,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for TC_PGDELAY_Type use record
TC_PGDELAY at 0 range 0 .. 7;
end record;
-----------------------------
-- TC_PGTEST sub-register --
-----------------------------
type TC_PGTEST_Field is new Bits_8;
-- 8-bit configuration register for use in setting the transmitter into
-- continuous wave (CW) mode.
TC_PGTEST_Normal_Operation : constant TC_PGTEST_Field := 16#00#;
TC_PGTEST_Continuous_Wave : constant TC_PGTEST_Field := 16#13#;
type TC_PGTEST_Type is record
TC_PGTEST : TC_PGTEST_Field := TC_PGTEST_Normal_Operation;
end record
with Size => 8,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for TC_PGTEST_Type use record
TC_PGTEST at 0 range 0 .. 7;
end record;
----------------------------------------------------------------------------
-- FS_CTRL register file
-----------------------------
-- FS_PLLCFG sub-register --
-----------------------------
type FS_PLLCFG_Field is new Bits_32;
FS_PLLCFG_Channel_1 : constant FS_PLLCFG_Field := 16#09000407#;
FS_PLLCFG_Channel_2 : constant FS_PLLCFG_Field := 16#08400508#;
FS_PLLCFG_Channel_3 : constant FS_PLLCFG_Field := 16#08401009#;
FS_PLLCFG_Channel_4 : constant FS_PLLCFG_Field := 16#08400508#;
FS_PLLCFG_Channel_5 : constant FS_PLLCFG_Field := 16#0800041D#;
FS_PLLCFG_Channel_7 : constant FS_PLLCFG_Field := 16#0800041D#;
type FS_PLLCFG_Type is record
FS_PLLCFG : FS_PLLCFG_Field;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for FS_PLLCFG_Type use record
FS_PLLCFG at 0 range 0 .. 31;
end record;
------------------------------
-- FS_PLLTUNE sub-register --
------------------------------
type FS_PLLTUNE_Field is new Bits_8;
FS_PLLTUNE_Channel_1 : constant FS_PLLTUNE_Field := 16#1E#;
FS_PLLTUNE_Channel_2 : constant FS_PLLTUNE_Field := 16#26#;
FS_PLLTUNE_Channel_3 : constant FS_PLLTUNE_Field := 16#56#;
FS_PLLTUNE_Channel_4 : constant FS_PLLTUNE_Field := 16#26#;
FS_PLLTUNE_Channel_5 : constant FS_PLLTUNE_Field := 16#BE#;
FS_PLLTUNE_Channel_7 : constant FS_PLLTUNE_Field := 16#BE#;
type FS_PLLTUNE_Type is record
FS_PLLTUNE : FS_PLLTUNE_Field;
end record
with Size => 8,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for FS_PLLTUNE_Type use record
FS_PLLTUNE at 0 range 0 .. 7;
end record;
----------------------------
-- FS_XTALT sub-register --
----------------------------
type FS_XTALT_Field is range 0 .. 2**5 - 1
with Size => 5;
-- Crystal Trim.
type FS_XTALT_Type is record
XTALT : FS_XTALT_Field := 0;
Reserved : Types.Bits_3 := 2#011#;
end record
with Size => 8,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for FS_XTALT_Type use record
XTALT at 0 range 0 .. 4;
Reserved at 0 range 5 .. 7;
end record;
----------------------------------------------------------------------------
-- AON register file
----------------------------
-- AON_WCFG sub-register --
----------------------------
type AON_WCFG_ONW_RADC_Field is
(Disabled,
Enabled)
with Size => 1;
-- On Wake-up Run the (temperature and voltage) Analog-to-Digital Convertors.
type AON_WCFG_ONW_RX_Field is
(Disabled,
Enabled)
with Size => 1;
-- On Wake-up turn on the Receiver.
type AON_WCFG_ONW_LEUI_Field is
(Disabled,
Enabled)
with Size => 1;
-- On Wake-up load the EUI from OTP memory into the EUI register.
type AON_WCFG_ONW_LDC_Field is
(Disabled,
Enabled)
with Size => 1;
-- On Wake-upload configurations from the AON memory into the host
-- interface register set.
type AON_WCFG_ONW_L64_Field is
(Disabled,
Enabled)
with Size => 1;
-- On Wake-up load the Length64 receiver operating parameter set.
type AON_WCFG_PRES_SLEEP_Field is
(Disabled,
Enabled)
with Size => 1;
-- Preserve Sleep.
type AON_WCFG_ONW_LLDE_Field is
(Disabled,
Enabled)
with Size => 1;
-- On Wake-up load the LDE microcode.
type AON_WCFG_ONW_LLD0_Field is
(Disabled,
Enabled)
with Size => 1;
-- On Wake-up load the LDOTUNE value from OTP.
type AON_WCFG_Type is record
ONW_RADC : AON_WCFG_ONW_RADC_Field := Disabled;
ONW_RX : AON_WCFG_ONW_RX_Field := Disabled;
ONW_LEUI : AON_WCFG_ONW_LEUI_Field := Disabled;
ONW_LDC : AON_WCFG_ONW_LDC_Field := Disabled;
ONW_L64 : AON_WCFG_ONW_L64_Field := Disabled;
PRES_SLEEP : AON_WCFG_PRES_SLEEP_Field := Disabled;
ONW_LLDE : AON_WCFG_ONW_LLDE_Field := Disabled;
ONW_LLD0 : AON_WCFG_ONW_LLD0_Field := Disabled;
Reserved_1 : Types.Bits_1 := 0;
Reserved_2 : Types.Bits_2 := 0;
Reserved_3 : Types.Bits_2 := 0;
Reserved_4 : Types.Bits_3 := 0;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for AON_WCFG_Type use record
ONW_RADC at 0 range 0 .. 0;
ONW_RX at 0 range 1 .. 1;
Reserved_1 at 0 range 2 .. 2;
ONW_LEUI at 0 range 3 .. 3;
Reserved_2 at 0 range 4 .. 5;
ONW_LDC at 0 range 6 .. 6;
ONW_L64 at 0 range 7 .. 7;
PRES_SLEEP at 0 range 8 .. 8;
Reserved_3 at 0 range 9 .. 10;
ONW_LLDE at 0 range 11 .. 11;
ONW_LLD0 at 0 range 12 .. 12;
Reserved_4 at 0 range 13 .. 15;
end record;
----------------------------
-- AON_CTRL sub-register --
----------------------------
type AON_CTRL_RESTORE_Field is
(No_Action,
Restore)
with Size => 1;
-- When this bit is set the DW1000 will copy the user configurations from
-- the AON memory to the host interface register set.
type AON_CTRL_SAVE_Field is
(No_Action,
Save)
with Size => 1;
-- When this bit is set the DW1000 will copy the user configurations from
-- the host interface register set into the AON memory.
type AON_CTRL_UPL_CFG_Field is
(No_Action,
Upload)
with Size => 1;
-- Upload the AON block configurations to the AON.
type AON_CTRL_DCA_READ_Field is
(No_Action,
Trigger_Read)
with Size => 1;
-- Direct AON memory access read.
type AON_CTRL_DCA_ENAB_Field is
(Disabled,
Enabled)
with Size => 1;
-- Direct AON memory access enable bit.
type AON_CTRL_Type is record
RESTORE : AON_CTRL_RESTORE_Field := No_Action;
SAVE : AON_CTRL_SAVE_Field := No_Action;
UPL_CFG : AON_CTRL_UPL_CFG_Field := No_Action;
DCA_READ : AON_CTRL_DCA_READ_Field := No_Action;
DCA_ENAB : AON_CTRL_DCA_ENAB_Field := Disabled;
Reserved : Types.Bits_3 := 0;
end record
with Size => 8,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for AON_CTRL_Type use record
RESTORE at 0 range 0 .. 0;
SAVE at 0 range 1 .. 1;
UPL_CFG at 0 range 2 .. 2;
DCA_READ at 0 range 3 .. 3;
Reserved at 0 range 4 .. 6;
DCA_ENAB at 0 range 7 .. 7;
end record;
----------------------------
-- AON_RDAT sub-register --
----------------------------
type AON_RDAT_Type is record
AON_RDAT : Types.Bits_8;
end record
with Size => 8,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for AON_RDAT_Type use record
AON_RDAT at 0 range 0 .. 7;
end record;
----------------------------
-- AON_ADDR sub-register --
----------------------------
type AON_ADDR_Field is new Bits_8;
type AON_ADDR_Type is record
AON_ADDR : AON_ADDR_Field;
end record
with Size => 8,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for AON_ADDR_Type use record
AON_ADDR at 0 range 0 .. 7;
end record;
----------------------------
-- AON_CFG0 sub-register --
----------------------------
type AON_CFG0_SLEEP_EN_Field is
(Disabled,
Enabled)
with Size => 1;
-- This is the sleep enable configuration bit.
type AON_CFG0_WAKE_PIN_Field is
(Disabled,
Enabled)
with Size => 1;
-- Wake using WAKEUP pin.
type AON_CFG0_WAKE_SPI_Pin_Field is
(Disabled,
Enabled)
with Size => 1;
-- Wake using SPI access.
type AON_CFG0_WAKE_CNT_Pin_Field is
(Disabled,
Enabled)
with Size => 1;
-- Wake when sleep counter elapses.
type AON_CFG0_LPDIV_EN_Field is
(Disabled,
Enabled)
with Size => 1;
-- Low power divider enable configuration.
type AON_CFG0_LPCLKDIVA_Field is range 0 .. 2**11 - 1
with Size => 11;
-- This field specifies a divider count for dividing the raw DW1000 XTAL
-- oscillator frequency to set an LP clock frequency.
type AON_CFG0_SLEEP_TIM_Field is range 0 .. 2**16 - 1
with Size => 16;
-- Sleep time.
type AON_CFG0_Type is record
SLEEP_EN : AON_CFG0_SLEEP_EN_Field := Disabled;
WAKE_PIN : AON_CFG0_WAKE_PIN_Field := Enabled;
WAKE_SPI : AON_CFG0_WAKE_SPI_Pin_Field := Enabled;
WAKE_CNT : AON_CFG0_WAKE_CNT_Pin_Field := Enabled;
LPDIV_EN : AON_CFG0_LPDIV_EN_Field := Disabled;
LPCLKDIVA : AON_CFG0_LPCLKDIVA_Field := 255;
SLEEP_TIM : AON_CFG0_SLEEP_TIM_Field := 20735;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for AON_CFG0_Type use record
SLEEP_EN at 0 range 0 .. 0;
WAKE_PIN at 0 range 1 .. 1;
WAKE_SPI at 0 range 2 .. 2;
WAKE_CNT at 0 range 3 .. 3;
LPDIV_EN at 0 range 4 .. 4;
LPCLKDIVA at 0 range 5 .. 15;
SLEEP_TIM at 0 range 16 .. 31;
end record;
----------------------------
-- AON_CFG1 sub-register --
----------------------------
type AON_CFG1_SLEEP_CE_Field is
(Disabled,
Enabled)
with Size => 1;
-- This bit enables the sleep counter.
type AON_CFG1_SMXX_Field is
(Clear,
Set)
with Size => 1;
-- This bit needs to be Cleared for correct operation in the SLEEP state
-- within the DW1000. By default this bit is Set.
type AON_CFG1_LPOSC_C_Field is
(Disabled,
Enabled)
with Size => 1;
-- This bit enables the calibration function that measures the period of the
-- IC's internal low powered oscillator
type AON_CFG1_Type is record
SLEEP_CE : AON_CFG1_SLEEP_CE_Field := Enabled;
SMXX : AON_CFG1_SMXX_Field := Set;
LPOSC_C : AON_CFG1_LPOSC_C_Field := Enabled;
Reserved : Types.Bits_13 := 0;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for AON_CFG1_Type use record
SLEEP_CE at 0 range 0 .. 0;
SMXX at 0 range 1 .. 1;
LPOSC_C at 0 range 2 .. 2;
Reserved at 0 range 3 .. 15;
end record;
----------------------------------------------------------------------------
-- OTP_IF register file
----------------------------
-- OTP_WDAT sub-register --
----------------------------
type OTP_WDAT_Type is record
OTP_WDAT : Types.Bits_32;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for OTP_WDAT_Type use record
OTP_WDAT at 0 range 0 .. 31;
end record;
----------------------------
-- OTP_ADDR sub-register --
----------------------------
type OTP_ADDR_Field is new Bits_11;
type OTP_ADDR_Type is record
OTP_ADDR : OTP_ADDR_Field;
Reserved : Types.Bits_5 := 0;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for OTP_ADDR_Type use record
OTP_ADDR at 0 range 0 .. 10;
Reserved at 0 range 11 .. 15;
end record;
----------------------------
-- OTP_CTRL sub-register --
----------------------------
type OTP_CTRL_OPTRDEN_Field is
(Disabled,
Enabled)
with Size => 1;
-- This bit forces the OTP into manual read mode.
type OTP_CTRL_OTPREAD_Field is
(No_Action,
Trigger_Read)
with Size => 1;
-- This bit commands a read operation from the address specified in the
-- OTP_ADDR register, the value read will then be available in the OTP_RDAT
-- register.
type OTP_CTRL_OTPMRWR_Field is
(Clear,
Set)
with Size => 1;
-- OTP mode register write.
type OTP_CTRL_PPROG_Field is
(Clear,
Set)
with Size => 1;
-- Setting this bit will cause the contents of OTP_WDAT to be written to
-- OTP_ADDR.
type OTP_CTRL_OTPMR_Field is
(Clear,
Set)
with Size => 1;
type OTP_CTRL_LDELOAD_Field is
(No_Action,
Load_LDE_Microcode)
with Size => 1;
-- This bit forces a load of LDE microcode.
type OTP_CTRL_Type is record
OTPRDEN : OTP_CTRL_OPTRDEN_Field := Disabled;
OTPREAD : OTP_CTRL_OTPREAD_Field := No_Action;
OTPMRWR : OTP_CTRL_OTPMRWR_Field := Clear;
OTPPROG : OTP_CTRL_PPROG_Field := Clear;
OTPMR : OTP_CTRL_OTPMR_Field := Clear;
LDELOAD : OTP_CTRL_LDELOAD_Field := No_Action;
Reserved_1 : Types.Bits_1 := 0;
Reserved_2 : Types.Bits_2 := 0;
Reserved_3 : Types.Bits_4 := 0;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for OTP_CTRL_Type use record
OTPRDEN at 0 range 0 .. 0;
OTPREAD at 0 range 1 .. 1;
Reserved_1 at 0 range 2 .. 2;
OTPMRWR at 0 range 3 .. 3;
Reserved_2 at 0 range 4 .. 5;
OTPPROG at 0 range 6 .. 6;
OTPMR at 0 range 7 .. 10;
Reserved_3 at 0 range 11 .. 14;
LDELOAD at 0 range 15 .. 15;
end record;
----------------------------
-- OTP_STAT sub-register --
----------------------------
type OTP_STAT_Type is record
OTPPRGD : Types.Bits_1 := 0;
OTPVPOK : Types.Bits_1 := 0;
Reserved : Types.Bits_14 := 0;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for OTP_STAT_Type use record
OTPPRGD at 0 range 0 .. 0;
OTPVPOK at 0 range 1 .. 1;
Reserved at 0 range 2 .. 15;
end record;
----------------------------
-- OTP_RDAT sub-register --
----------------------------
type OTP_RDAT_Type is record
OTP_RDAT : Types.Bits_32;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for OTP_RDAT_Type use record
OTP_RDAT at 0 range 0 .. 31;
end record;
-----------------------------
-- OTP_SRDAT sub-register --
-----------------------------
type OTP_SRDAT_Type is record
OTP_SRDAT : Types.Bits_32;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for OTP_SRDAT_Type use record
OTP_SRDAT at 0 range 0 .. 31;
end record;
--------------------------
-- OTP_SF sub-register --
--------------------------
type OTP_SF_OPS_KICK_Field is
(Clear,
Set)
with Size => 1;
-- This bit when set initiates a load of the operating parameter set
-- selected by the OPS_SEL configuration below.
type OTP_SF_LDO_KICK_Field is
(Clear,
Set)
with Size => 1;
-- This bit when set initiates the loading of the LDOTUNE_CAL parameter
-- from OTP address 0x4 into the LDOTUNE register
type OTP_SF_OPS_SEL_Field is
(Length64,
Tight,
Default,
Reserved)
with Size => 2;
-- Operating parameter set selection.
type OTP_SF_Type is record
OPS_KICK : OTP_SF_OPS_KICK_Field := Clear;
LDO_KICK : OTP_SF_LDO_KICK_Field := Clear;
OPS_SEL : OTP_SF_OPS_SEL_Field := Length64;
Reserved_1 : Types.Bits_3 := 0;
Reserved_2 : Types.Bits_1 := 0;
end record
with Size => 8,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for OTP_SF_Type use record
OPS_KICK at 0 range 0 .. 0;
LDO_KICK at 0 range 1 .. 1;
Reserved_1 at 0 range 2 .. 4;
OPS_SEL at 0 range 5 .. 6;
Reserved_2 at 0 range 7 .. 7;
end record;
----------------------------------------------------------------------------
-- LDE_IF register file
------------------------------
-- LDE_THRESH sub-register --
------------------------------
type LDE_THRESH_Field is range 0 .. 2**16 - 1
with Size => 16;
type LDE_THRESH_Type is record
LDE_THRESH : LDE_THRESH_Field;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for LDE_THRESH_Type use record
LDE_THRESH at 0 range 0 .. 15;
end record;
----------------------------
-- LDE_CFG1 sub-register --
----------------------------
type LDE_CFG1_NTM_Field is range 0 .. 31
with Size => 5;
-- Noise Threshold Multiplier.
type LDE_CFG1_PMULT_Field is range 0 .. 7
with Size => 3;
-- Peak Multiplier.
type LDE_CFG1_Type is record
NTM : LDE_CFG1_NTM_Field := 12;
PMULT : LDE_CFG1_PMULT_Field := 3;
end record
with Size => 8,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for LDE_CFG1_Type use record
NTM at 0 range 0 .. 4;
PMULT at 0 range 5 .. 7;
end record;
------------------------------
-- LDE_PPINDX sub-register --
------------------------------
type LDE_PPINDX_Field is range 0 .. 2**16 - 1
with Size => 16;
type LDE_PPINDX_Type is record
LDE_PPINDX : LDE_PPINDX_Field;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for LDE_PPINDX_Type use record
LDE_PPINDX at 0 range 0 .. 15;
end record;
------------------------------
-- LDE_PPAMPL sub-register --
------------------------------
type LDE_PPAMLP_Field is range 0 .. 2**16 - 1
with Size => 16;
type LDE_PPAMPL_Type is record
LDE_PPAMPL : LDE_PPAMLP_Field;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for LDE_PPAMPL_Type use record
LDE_PPAMPL at 0 range 0 .. 15;
end record;
------------------------------
-- LDE_RXANTD sub-register --
------------------------------
type LDE_RXANTD_Type is record
LDE_RXANTD : System_Time.Antenna_Delay_Time;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for LDE_RXANTD_Type use record
LDE_RXANTD at 0 range 0 .. 15;
end record;
----------------------------
-- LDE_CFG2 sub-register --
----------------------------
type LDE_CFG2_Field is new Bits_16;
LDE_CFG2_16MHz : constant LDE_CFG2_Field := 16#1607#;
LDE_CFG2_64MHz : constant LDE_CFG2_Field := 16#0607#;
type LDE_CFG2_Type is record
LDE_CFG2 : LDE_CFG2_Field;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for LDE_CFG2_Type use record
LDE_CFG2 at 0 range 0 .. 15;
end record;
----------------------------
-- LDE_REPC sub-register --
----------------------------
type LDE_REPC_Field is new Bits_16;
LDE_REPC_PCODE_1 : constant LDE_REPC_Field := 16#5998#;
LDE_REPC_PCODE_2 : constant LDE_REPC_Field := 16#5998#;
LDE_REPC_PCODE_3 : constant LDE_REPC_Field := 16#51EA#;
LDE_REPC_PCODE_4 : constant LDE_REPC_Field := 16#428E#;
LDE_REPC_PCODE_5 : constant LDE_REPC_Field := 16#451E#;
LDE_REPC_PCODE_6 : constant LDE_REPC_Field := 16#2E14#;
LDE_REPC_PCODE_7 : constant LDE_REPC_Field := 16#8000#;
LDE_REPC_PCODE_8 : constant LDE_REPC_Field := 16#51EA#;
LDE_REPC_PCODE_9 : constant LDE_REPC_Field := 16#28F4#;
LDE_REPC_PCODE_10 : constant LDE_REPC_Field := 16#3332#;
LDE_REPC_PCODE_11 : constant LDE_REPC_Field := 16#3AE0#;
LDE_REPC_PCODE_12 : constant LDE_REPC_Field := 16#3D70#;
LDE_REPC_PCODE_13 : constant LDE_REPC_Field := 16#3AE0#;
LDE_REPC_PCODE_14 : constant LDE_REPC_Field := 16#35C2#;
LDE_REPC_PCODE_15 : constant LDE_REPC_Field := 16#2B84#;
LDE_REPC_PCODE_16 : constant LDE_REPC_Field := 16#35C2#;
LDE_REPC_PCODE_17 : constant LDE_REPC_Field := 16#3332#;
LDE_REPC_PCODE_18 : constant LDE_REPC_Field := 16#35C2#;
LDE_REPC_PCODE_19 : constant LDE_REPC_Field := 16#35C2#;
LDE_REPC_PCODE_20 : constant LDE_REPC_Field := 16#47AE#;
LDE_REPC_PCODE_21 : constant LDE_REPC_Field := 16#3AE0#;
LDE_REPC_PCODE_22 : constant LDE_REPC_Field := 16#3850#;
LDE_REPC_PCODE_23 : constant LDE_REPC_Field := 16#30A2#;
LDE_REPC_PCODE_24 : constant LDE_REPC_Field := 16#3850#;
type LDE_REPC_Type is record
LDE_REPC : LDE_REPC_Field;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for LDE_REPC_Type use record
LDE_REPC at 0 range 0 .. 15;
end record;
----------------------------------------------------------------------------
-- DIG_DIAG register file
----------------------------
-- EVC_CTRL sub-register --
----------------------------
type EVC_CTRL_EVC_EN_Field is
(Disabled,
Enabled)
with Size => 1;
-- Event Counters Enable.
type EVC_CTRL_EVC_CLR_Field is
(No_Action,
Clear_Counters)
with Size => 1;
-- Event Counters Clear.
type EVC_CTRL_Type is record
EVC_EN : EVC_CTRL_EVC_EN_Field := Disabled;
EVC_CLR : EVC_CTRL_EVC_CLR_Field := No_Action;
Reserved : Types.Bits_30 := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for EVC_CTRL_Type use record
EVC_EN at 0 range 0 .. 0;
EVC_CLR at 0 range 1 .. 1;
Reserved at 0 range 2 .. 31;
end record;
---------------------------
-- EVC_PHE sub-register --
---------------------------
type EVC_Counter_Field is range 0 .. 2**12 - 1
with Size => 12;
-- Event counter field
type EVC_PHE_Type is record
EVC_PHE : EVC_Counter_Field := 0;
Reserved : Types.Bits_4 := 0;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for EVC_PHE_Type use record
EVC_PHE at 0 range 0 .. 11;
Reserved at 0 range 12 .. 15;
end record;
---------------------------
-- EVC_RSE sub-register --
---------------------------
type EVC_RSE_Type is record
EVC_RSE : EVC_Counter_Field := 0;
Reserved : Types.Bits_4 := 0;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for EVC_RSE_Type use record
EVC_RSE at 0 range 0 .. 11;
Reserved at 0 range 12 .. 15;
end record;
---------------------------
-- EVC_FCG sub-register --
---------------------------
type EVC_FCG_Type is record
EVC_FCG : EVC_Counter_Field := 0;
Reserved : Types.Bits_4 := 0;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for EVC_FCG_Type use record
EVC_FCG at 0 range 0 .. 11;
Reserved at 0 range 12 .. 15;
end record;
---------------------------
-- EVC_FCE sub-register --
---------------------------
type EVC_FCE_Type is record
EVC_FCE : EVC_Counter_Field := 0;
Reserved : Types.Bits_4 := 0;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for EVC_FCE_Type use record
EVC_FCE at 0 range 0 .. 11;
Reserved at 0 range 12 .. 15;
end record;
---------------------------
-- EVC_FFR sub-register --
---------------------------
type EVC_FFR_Type is record
EVC_FFR : EVC_Counter_Field := 0;
Reserved : Types.Bits_4 := 0;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for EVC_FFR_Type use record
EVC_FFR at 0 range 0 .. 11;
Reserved at 0 range 12 .. 15;
end record;
---------------------------
-- EVC_OVR sub-register --
---------------------------
type EVC_OVR_Type is record
EVC_OVR : EVC_Counter_Field := 0;
Reserved : Types.Bits_4 := 0;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for EVC_OVR_Type use record
EVC_OVR at 0 range 0 .. 11;
Reserved at 0 range 12 .. 15;
end record;
---------------------------
-- EVC_STO sub-register --
---------------------------
type EVC_STO_Type is record
EVC_STO : EVC_Counter_Field := 0;
Reserved : Types.Bits_4 := 0;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for EVC_STO_Type use record
EVC_STO at 0 range 0 .. 11;
Reserved at 0 range 12 .. 15;
end record;
---------------------------
-- EVC_PTO sub-register --
---------------------------
type EVC_PTO_Type is record
EVC_PTO : EVC_Counter_Field := 0;
Reserved : Types.Bits_4 := 0;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for EVC_PTO_Type use record
EVC_PTO at 0 range 0 .. 11;
Reserved at 0 range 12 .. 15;
end record;
----------------------------
-- EVC_FWTO sub-register --
----------------------------
type EVC_FWTO_Type is record
EVC_FWTO : EVC_Counter_Field := 0;
Reserved : Types.Bits_4 := 0;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for EVC_FWTO_Type use record
EVC_FWTO at 0 range 0 .. 11;
Reserved at 0 range 12 .. 15;
end record;
----------------------------
-- EVC_TXFS sub-register --
----------------------------
type EVC_TXFS_Type is record
EVC_TXFS : EVC_Counter_Field := 0;
Reserved : Types.Bits_4 := 0;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for EVC_TXFS_Type use record
EVC_TXFS at 0 range 0 .. 11;
Reserved at 0 range 12 .. 15;
end record;
---------------------------
-- EVC_HPW sub-register --
---------------------------
type EVC_HPW_Type is record
EVC_HPW : EVC_Counter_Field := 0;
Reserved : Types.Bits_4 := 0;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for EVC_HPW_Type use record
EVC_HPW at 0 range 0 .. 11;
Reserved at 0 range 12 .. 15;
end record;
---------------------------
-- EVC_TPW sub-register --
---------------------------
type EVC_TPW_Type is record
EVC_TPW : EVC_Counter_Field := 0;
Reserved : Types.Bits_4;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for EVC_TPW_Type use record
EVC_TPW at 0 range 0 .. 11;
Reserved at 0 range 12 .. 15;
end record;
----------------------------
-- DIAG_TMC sub-register --
----------------------------
type DIAG_TMC_TX_PSTM_Field is
(Disabled,
Enabled)
with Size => 1;
-- Transmit Power Spectrum Test Mode.
type DIAG_TMC_Type is record
TX_PSTM : DIAG_TMC_TX_PSTM_Field := Disabled;
Reserved_1 : Types.Bits_4 := 0;
Reserved_2 : Types.Bits_11 := 0;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for DIAG_TMC_Type use record
Reserved_1 at 0 range 0 .. 3;
TX_PSTM at 0 range 4 .. 4;
Reserved_2 at 0 range 5 .. 15;
end record;
----------------------------------------------------------------------------
-- PMSC register file
type PMSC_CTRL0_SYSCLKS_Field is
(Auto,
Force_XTI,
Force_PLL,
Reserved)
with Size => 2;
-- System Clock Selection.
type PMSC_CTRL0_RXCLKS_Field is
(Auto,
Force_XTI,
Force_PLL,
Force_Off)
with Size => 2;
-- Receiver Clock Selection.
type PMSC_CTRL0_TXCLKS_Field is new PMSC_CTRL0_RXCLKS_Field;
-- Transmitter Clock Selection.
type PMSC_CTRL0_FACE_Field is
(Disabled,
Enabled)
with Size => 1;
-- Force Accumulator Clock Enable.
type PMSC_CTRL0_ADCCE_Field is
(Disabled,
Enabled)
with Size => 1;
-- (temperature and voltage) Analog-to-Digital Convertor Clock Enable.
type PMSC_CTRL0_AMCE_Field is
(Disabled,
Enabled)
with Size => 1;
-- Accumulator Memory Clock Enable.
type PMSC_CTRL0_GPCE_Field is
(Disabled,
Enabled)
with Size => 1;
-- GPIO clock Enable.
type PMSC_CTRL0_GPRN_Field is
(Disabled,
Enabled)
with Size => 1;
-- GPIO reset (NOT), active low.
type PMSC_CTRL0_GPDCE_Field is
(Disabled,
Enabled)
with Size => 1;
-- GPIO De-bounce Clock Enable.
type PMSC_CTRL0_GPDRN_Field is
(Disabled,
Enabled)
with Size => 1;
-- GPIO de-bounce reset (NOT), active low.
type PMSC_CTRL0_KHZCLKEN_Field is
(Disabled,
Enabled)
with Size => 1;
-- Kilohertz clock Enable.
type PMSC_CTRL0_PLL2_SEQ_EN_Field is
(Normal,
Sniff)
with Size => 1;
type PMSC_CTRL0_SOFTRESET_Field is new Bits_4;
-- These four bits reset the IC TX, RX, Host Interface and the PMSC itself,
-- essentially allowing a reset of the IC under software control.
PMSC_CTRL0_SOFTRESET_Reset : constant PMSC_CTRL0_SOFTRESET_Field := 2#0000#;
PMSC_CTRL0_SOFTRESET_Reset_Rx : constant PMSC_CTRL0_SOFTRESET_Field := 2#0111#;
PMSC_CTRL0_SOFTRESET_Set_All : constant PMSC_CTRL0_SOFTRESET_Field := 2#1111#;
type PMSC_CTRL0_Type is record
SYSCLKS : PMSC_CTRL0_SYSCLKS_Field := Auto;
RXCLKS : PMSC_CTRL0_RXCLKS_Field := Auto;
TXCLKS : PMSC_CTRL0_TXCLKS_Field := Auto;
FACE : PMSC_CTRL0_FACE_Field := Disabled;
ADCCE : PMSC_CTRL0_ADCCE_Field := Disabled;
AMCE : PMSC_CTRL0_AMCE_Field := Disabled;
GPCE : PMSC_CTRL0_GPCE_Field := Disabled;
GPRN : PMSC_CTRL0_GPRN_Field := Disabled;
GPDCE : PMSC_CTRL0_GPDCE_Field := Disabled;
GPDRN : PMSC_CTRL0_GPDRN_Field := Disabled;
KHZCLKEN : PMSC_CTRL0_KHZCLKEN_Field := Disabled;
PLL2_SEQ_EN : PMSC_CTRL0_PLL2_SEQ_EN_Field := Normal;
SOFTRESET : PMSC_CTRL0_SOFTRESET_Field := PMSC_CTRL0_SOFTRESET_Set_All;
Reserved_1 : Types.Bits_3 := 2#100#;
Reserved_2 : Types.Bits_4 := 0;
Reserved_3 : Types.Bits_3 := 2#011#;
Reserved_4 : Types.Bits_3 := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for PMSC_CTRL0_Type use record
SYSCLKS at 0 range 0 .. 1;
RXCLKS at 0 range 2 .. 3;
TXCLKS at 0 range 4 .. 5;
FACE at 0 range 6 .. 6;
Reserved_1 at 0 range 7 .. 9;
ADCCE at 0 range 10 .. 10;
Reserved_2 at 0 range 11 .. 14;
AMCE at 0 range 15 .. 15;
GPCE at 0 range 16 .. 16;
GPRN at 0 range 17 .. 17;
GPDCE at 0 range 18 .. 18;
GPDRN at 0 range 19 .. 19;
Reserved_3 at 0 range 20 .. 22;
KHZCLKEN at 0 range 23 .. 23;
PLL2_SEQ_EN at 0 range 24 .. 24;
Reserved_4 at 0 range 25 .. 27;
SOFTRESET at 0 range 28 .. 31;
end record;
------------------------------
-- PMSC_CTRL1 sub-register --
------------------------------
type PMSC_CTRL1_ARX2INIT_Field is
(Disabled,
Enabled)
with Size => 1;
-- Automatic transition from receive mode into the INIT state.
type PMSC_CTRL1_PKTSEQ_Field is new Bits_8;
PMSC_CTRL1_Disabled : constant PMSC_CTRL1_PKTSEQ_Field := 16#00#;
PMSC_CTRL1_Enabled : constant PMSC_CTRL1_PKTSEQ_Field := 16#E7#;
type PMSC_CTRL1_ATXSLP_Field is
(Disabled,
Enabled)
with Size => 1;
-- After TX automatically Sleep.
type PMSC_CTRL1_ARXSLP_Field is
(Disabled,
Enabled)
with Size => 1;
-- After RX automatically Sleep.
type PMSC_CTRL1_SNOZE_Field is
(Disabled,
Enabled)
with Size => 1;
-- Snooze Enable.
type PMSC_CTRL1_SNOZR_Field is
(Disabled,
Enabled)
with Size => 1;
-- Snooze Repeat.
type PMSC_CTRL1_PLLSYN_Field is
(Disabled,
Enabled)
with Size => 1;
-- This enables a special 1 GHz clock used for some external SYNC modes.
type PMSC_CTRL1_LDERUNE_Field is
(Disabled,
Enabled)
with Size => 1;
-- LDE run enable.
type PMSC_CTRL1_KHZCLKDIV_Field is range 0 .. 2**6 - 1
with Size => 6;
type PMSC_CTRL1_Type is record
ARX2INIT : PMSC_CTRL1_ARX2INIT_Field := Disabled;
PKTSEQ : PMSC_CTRL1_PKTSEQ_Field := PMSC_CTRL1_Enabled;
ATXSLP : PMSC_CTRL1_ATXSLP_Field := Disabled;
ARXSLP : PMSC_CTRL1_ARXSLP_Field := Disabled;
SNOZE : PMSC_CTRL1_SNOZE_Field := Disabled;
SNOZR : PMSC_CTRL1_SNOZR_Field := Disabled;
PLLSYN : PMSC_CTRL1_PLLSYN_Field := Disabled;
LDERUNE : PMSC_CTRL1_LDERUNE_Field := Enabled;
KHZCLKDIV : PMSC_CTRL1_KHZCLKDIV_Field := 32;
Reserved_1 : Types.Bits_1 := 0;
Reserved_2 : Types.Bits_1 := 0;
Reserved_3 : Types.Bits_1 := 0;
Reserved_4 : Types.Bits_8 := 2#0100_0000#;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for PMSC_CTRL1_Type use record
Reserved_1 at 0 range 0 .. 0;
ARX2INIT at 0 range 1 .. 1;
Reserved_2 at 0 range 2 .. 2;
PKTSEQ at 0 range 3 .. 10;
ATXSLP at 0 range 11 .. 11;
ARXSLP at 0 range 12 .. 12;
SNOZE at 0 range 13 .. 13;
SNOZR at 0 range 14 .. 14;
PLLSYN at 0 range 15 .. 15;
Reserved_3 at 0 range 16 .. 16;
LDERUNE at 0 range 17 .. 17;
Reserved_4 at 0 range 18 .. 25;
KHZCLKDIV at 0 range 26 .. 31;
end record;
------------------------------
-- PMSC_SNOZT sub-register --
------------------------------
type PMSC_SNOZT_Type is record
SNOZ_TIM : System_Time.Snooze_Time := 0.001_706_667;
end record
with Size => 8,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for PMSC_SNOZT_Type use record
SNOZ_TIM at 0 range 0 .. 7;
end record;
-------------------------------
-- PMSC_TXFSEQ sub-register --
-------------------------------
type PMSC_TXFSEQ_Field is new Bits_16;
type PMSC_TXFSEQ_Type is record
TXFINESEQ : PMSC_TXFSEQ_Field := 2#0000_1011_0011_1100#;
end record
with Size => 16,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for PMSC_TXFSEQ_Type use record
TXFINESEQ at 0 range 0 .. 15;
end record;
-----------------------------
-- PMSC_LEDC sub-register --
-----------------------------
type PMSC_LEDC_BLINKEN_Field is
(Disabled,
Enabled)
with Size => 1;
-- Blink Enable.
type PMSC_LEDC_BLNKNOW_Field is
(No_Action,
Blink_Now)
with Size => 1;
type PMSC_LEDC_Type is record
BLINK_TIM : System_Time.Blink_Time := 0.448;
BLNKEN : PMSC_LEDC_BLINKEN_Field := Disabled;
BLNKNOW_RXOKLED : PMSC_LEDC_BLNKNOW_Field := No_Action;
BLNKNOW_SFDLED : PMSC_LEDC_BLNKNOW_Field := No_Action;
BLNKNOW_RXLED : PMSC_LEDC_BLNKNOW_Field := No_Action;
BLNKNOW_TXLED : PMSC_LEDC_BLNKNOW_Field := No_Action;
Reserved_1 : Types.Bits_7 := 0;
Reserved_2 : Types.Bits_12 := 0;
end record
with Size => 32,
Bit_Order => System.Low_Order_First,
Scalar_Storage_Order => System.Low_Order_First;
for PMSC_LEDC_Type use record
BLINK_TIM at 0 range 0 .. 7;
BLNKEN at 0 range 8 .. 8;
Reserved_1 at 0 range 9 .. 15;
BLNKNOW_RXOKLED at 0 range 16 .. 16;
BLNKNOW_SFDLED at 0 range 17 .. 17;
BLNKNOW_RXLED at 0 range 18 .. 18;
BLNKNOW_TXLED at 0 range 19 .. 19;
Reserved_2 at 0 range 20 .. 31;
end record;
end DW1000.Register_Types;
|
generic
type Float_Type is digits <>;
package Fmt.Generic_Float_Argument is
-- float to string
-- https://www.cs.tufts.edu/~nr/cs257/archive/florian-loitsch/printf.pdf
-- https://github.com/jk-jeon/dragonbox/blob/master/other_files/Dragonbox.pdf
-- Edit format
-- "w=" width
-- "a=" width after decimal point
-- "e=" width of exponent
-- "f=" width before decimal point
function To_Argument (X : Float_Type) return Argument_Type'Class
with Inline;
function "&" (Args : Arguments; X : Float_Type) return Arguments
with Inline;
private
type Float_Argument_Type is new Argument_Type with record
Value : Float_Type;
Width : Natural;
Fore : Natural := 2;
Aft : Natural := Float_Type'Digits - 1;
Exp : Natural := 3;
end record;
overriding
procedure Parse (Self : in out Float_Argument_Type; Edit : String);
overriding
function Get_Length (Self : in out Float_Argument_Type) return Natural;
overriding
procedure Put (
Self : in out Float_Argument_Type;
Edit : String;
To : in out String);
end Fmt.Generic_Float_Argument;
|
with Ada.Containers.Generic_Array_Access_Types;
with Ada.Unchecked_Deallocation;
package body GNAT.Dynamic_Tables is
procedure Free is new Ada.Unchecked_Deallocation (Table_Type, Table_Ptr);
package Arrays is
new Ada.Containers.Generic_Array_Access_Types (
Implementation.Index_Type,
Table_Component_Type,
Table_Type,
Table_Ptr,
Free => Free);
procedure Init (T : in out Instance) is
begin
Arrays.Set_Length (T.Table, Table_Initial);
end Init;
function Last (T : Instance) return Table_Index_Type is
begin
return T.Last_Index;
end Last;
procedure Free (T : in out Instance) is
begin
Free (T.Table);
end Free;
procedure Set_Last (T : in out Instance; New_Val : Table_Index_Type) is
begin
if New_Val > T.Table'Last then
Arrays.Set_Length (
T.Table,
Ada.Containers.Count_Type (New_Val - Table_Low_Bound + 1));
end if;
T.Last_Index := New_Val;
end Set_Last;
procedure Append (T : in out Instance; New_Val : Table_Component_Type) is
begin
Set_Last (T, T.Last_Index + 1);
T.Table (T.Last_Index) := New_Val;
end Append;
end GNAT.Dynamic_Tables;
|
with Ada.Numerics.Generic_Complex_Types;
with Ada.Numerics.Generic_Complex_Elementary_Functions;
with Ada.Numerics.Generic_Elementary_Functions;
with Ada.Text_IO.Complex_Io;
with Ada.Text_Io; use Ada.Text_Io;
procedure Factorial_Numeric_Approximation is
type Real is digits 15;
package Complex_Pck is new Ada.Numerics.Generic_Complex_Types(Real);
use Complex_Pck;
package Complex_Io is new Ada.Text_Io.Complex_Io(Complex_Pck);
use Complex_IO;
package Cmplx_Elem_Funcs is new Ada.Numerics.Generic_Complex_Elementary_Functions(Complex_Pck);
use Cmplx_Elem_Funcs;
function Gamma(X : Complex) return Complex is
package Elem_Funcs is new Ada.Numerics.Generic_Elementary_Functions(Real);
use Elem_Funcs;
use Ada.Numerics;
-- Coefficients used by the GNU Scientific Library
G : Natural := 7;
P : constant array (Natural range 0..G + 1) of Real := (
0.99999999999980993, 676.5203681218851, -1259.1392167224028,
771.32342877765313, -176.61502916214059, 12.507343278686905,
-0.13857109526572012, 9.9843695780195716e-6, 1.5056327351493116e-7);
Z : Complex := X;
Cx : Complex;
Ct : Complex;
begin
if Re(Z) < 0.5 then
return Pi / (Sin(Pi * Z) * Gamma(1.0 - Z));
else
Z := Z - 1.0;
Set_Re(Cx, P(0));
Set_Im(Cx, 0.0);
for I in 1..P'Last loop
Cx := Cx + (P(I) / (Z + Real(I)));
end loop;
Ct := Z + Real(G) + 0.5;
return Sqrt(2.0 * Pi) * Ct**(Z + 0.5) * Exp(-Ct) * Cx;
end if;
end Gamma;
function Factorial(N : Complex) return Complex is
begin
return Gamma(N + 1.0);
end Factorial;
Arg : Complex;
begin
Put("factorial(-0.5)**2.0 = ");
Set_Re(Arg, -0.5);
Set_Im(Arg, 0.0);
Put(Item => Factorial(Arg) **2.0, Fore => 1, Aft => 8, Exp => 0);
New_Line;
for I in 0..9 loop
Set_Re(Arg, Real(I));
Set_Im(Arg, 0.0);
Put("factorial(" & Integer'Image(I) & ") = ");
Put(Item => Factorial(Arg), Fore => 6, Aft => 8, Exp => 0);
New_Line;
end loop;
end Factorial_Numeric_Approximation;
|
with
NSO.JSON.Gnoga_Object,
NSO.JSON.Parameters_to_JSON,
NSO.Types.Report_Objects.Observation_Report,
NSO.Types.Report_Objects.Weather_Report,
Ada.Strings.Unbounded,
Gnoga.Types,
Gnoga.Gui.View,
Gnoga.Gui.Window,
Gnoga.Gui.Element.Table;
Function Report_Table
(
Parent : in out Gnoga.Gui.View.View_Type;
Main_Window : in Gnoga.Gui.Window.Window_Type'Class;
Parameters : in out Gnoga.Types.Data_Map_Type
)
return Gnoga.Gui.Element.Table.Table_Access is
Function Reformat(Input : String) return String is
Use Ada.Strings.Unbounded;
Function "*"(Left: Natural; Right : String) return String is
(case Left is
when 0 => "",
when 1 => Right,
when 2 => Right & Right,
when others => ((Left rem 2) * Right) &
(2 * ((Left/2)*Right))
);
HTML_TAB : Constant String:= 8 * " ";
HTML_CRLF : Constant String:= "<br />";
Working : Unbounded_String;
Begin
For Index in Input'Range loop
Append(New_Item =>
(case Input(Index) is
when ASCII.HT => HTML_TAB,
when ASCII.CR => HTML_CRLF,
when others => (1 => Input(Index))
),
Source => Working
);
End loop;
return Result : Constant String:= To_String(Working);
End Reformat;
Procedure Create_Row(
Left, Right : in String;
Table : in out Gnoga.Gui.Element.Table.Table_Type'Class ) is
use Gnoga.Gui.Element.Table;
row : constant Table_Row_Access := new Table_Row_Type;
col1 : constant Table_Column_Access := new Table_Column_Type;
col2 : constant Table_Column_Access := new Table_Column_Type;
Begin
row.Dynamic;
col1.Dynamic;
col2.Dynamic;
row.Create (Table);
col1.Create (row.all, Left );
col2.Create (row.all, Right);
End Create_Row;
procedure Create_Title(
Title : in String;
Table : in out Gnoga.Gui.Element.Table.Table_Type'Class ) is
use Gnoga.Gui.Element.Table;
Head : constant Table_Header_Access := new Table_Header_Type;
Row : constant Table_Row_Access := new Table_Row_Type;
Col : constant Table_Heading_Access:= new Table_Heading_Type;
begin
head.Dynamic;
row.Dynamic;
col.Dynamic;
head.Create(Table);
row.Create (Head.all);
col.Create (row.all, Title, Column_Span => 2 );
end Create_Title;
---------------------------------------------
-- GET PARAMETER-DATA AND GENERATE REPORTS --
---------------------------------------------
Package GO renames NSO.JSON.Gnoga_Object;
Package RO renames NSO.Types.Report_Objects;
Generic
Parameter_Object : NSO.JSON.Instance'Class;
Function Bind_Parameters(O : GO.Form_Object) return NSO.JSON.Instance'Class;
Function Bind_Parameters(O : GO.Form_Object) return NSO.JSON.Instance'Class is
( Parameter_Object );
Function Bound_Parameters is new Bind_Parameters(
NSO.JSON.Parameters_to_JSON(Parameters)
);
Package Reports is new GO.Generic_Reporter(
Form => NSO.JSON.Gnoga_Object.Form_Object,
Params => NSO.JSON.Gnoga_Object.JSON_Class,
Parameters => Bound_Parameters, --NSO.JSON.Gnoga_Object.Parameters,
This => NSO.JSON.Gnoga_Object.As_Form(Main_Window)
);
Function Observation_Table is new Reports.Generate_Report(
Report => RO.Observation_Report.Report_Map.Map,
View => String,
Get_Report => RO.Observation_Report.Report,
Processing => RO.Observation_Report.Report
);
Function Weather_Table is new Reports.Generate_Report(
Report => RO.Weather_Report.Report_Map.Map,
View => String,
Get_Report => RO.Weather_Report.Report,
Processing => RO.Weather_Report.Report
);
-- Here we are renaming the parameters recieved from the form as an instance
-- of the JSON class, under the name "Parameter" so that we might select a
-- parameter via the "**" operator.
Form_Parameter: NSO.JSON.Instance'Class renames Reports.Original_Parameters;
-- Here we import the "**" operator, the right-hand side is a string and it
-- acts as a safe-indexing returning the empty string when the left-hand is
-- either not an Object or else it does not contain the given string.
Use all type NSO.JSON.Instance'Class;
Message : Constant String:= Form_Parameter ** "Message";
Observer : Constant String:= Form_Parameter ** "Observer";
Name : Constant String:= Form_Parameter ** "Name";
Conditions : Constant String:= Form_Parameter ** "Conditions";
Report_Title : Constant String:= "Daily Log Report";
-- Create the result, and a renaming for the dereference thereof.
Result : Constant Gnoga.Gui.Element.Table.Table_Access:=
new Gnoga.Gui.Element.Table.Table_Type;
Table : Gnoga.Gui.Element.Table.Table_Type renames Result.All;
Begin
Table.Dynamic;
Table.Create( Parent );
--Ada.Text_IO.Put_Line( Form_Parameter.To_String );
---------------------
-- STYLE THE TABLE --
---------------------
Table.Style(Name => "width", Value => "50%");
Table.Style(Name => "margin", Value => "auto");
Table.Style(Name => "clear", Value => "both");
Table.Style(Name => "position", Value => "absolute");
Table.Style(Name => "top", Value => "53%");
Table.Style(Name => "left", Value => "50%");
Table.Style(Name => "margin-right", Value => "-50%");
Table.Style(Name => "transform", Value => "translate(-50%, -50%)");
Table.Border(Width => "thick");
-----------------
-- ADD CELLS --
-----------------
Create_Title( Report_Title, Table );
-- Create_Row( "Name", Name, Table );
Create_Row( "Observer", Observer, Table );
Create_Row( "Message", Reformat(Message), Table );
-- Create_Row( "Conditions", Conditions, Table );
Create_Row( "Weather Report", Weather_Table, Table );
Create_Row( "Observation Report", Observation_Table, Table );
Return Result;
End Report_Table;
|
with Ada.Text_IO;
with OpenAL.Context.Error;
with OpenAL.Error;
with OpenAL.Context;
with OpenAL.Global;
with Test;
procedure global_001 is
package ALC renames OpenAL.Context;
package ALC_Error renames OpenAL.Context.Error;
package AL_Error renames OpenAL.Error;
Device : ALC.Device_t;
Context : ALC.Context_t;
OK : Boolean;
TC : Test.Context_t;
use type ALC.Device_t;
use type ALC.Context_t;
use type ALC_Error.Error_t;
use type AL_Error.Error_t;
procedure Finish is
begin
ALC.Destroy_Context (Context);
ALC.Close_Device (Device);
end Finish;
procedure Init is
begin
Device := ALC.Open_Default_Device;
pragma Assert (Device /= ALC.Invalid_Device);
Context := ALC.Create_Context (Device);
pragma Assert (Context /= ALC.Invalid_Context);
OK := ALC.Make_Context_Current (Context);
pragma Assert (OK);
end Init;
begin
Test.Initialize
(Test_Context => TC,
Program => "global_001",
Test_DB => "TEST_DB",
Test_Results => "TEST_RESULTS");
Init;
Ada.Text_IO.Put_Line ("VERSION : " & OpenAL.Global.Version);
Test.Check (TC, 51, AL_Error.Get_Error = AL_Error.No_Error,
"AL_Error.Get_Error = AL_Error.No_Error");
Ada.Text_IO.Put_Line ("RENDERER : " & OpenAL.Global.Renderer);
Test.Check (TC, 52, AL_Error.Get_Error = AL_Error.No_Error,
"AL_Error.Get_Error = AL_Error.No_Error");
Ada.Text_IO.Put_Line ("VENDOR : " & OpenAL.Global.Vendor);
Test.Check (TC, 53, AL_Error.Get_Error = AL_Error.No_Error,
"AL_Error.Get_Error = AL_Error.No_Error");
Ada.Text_IO.Put_Line ("EXTENSIONS : " & OpenAL.Global.Extensions);
Test.Check (TC, 54, AL_Error.Get_Error = AL_Error.No_Error,
"AL_Error.Get_Error = AL_Error.No_Error");
Finish;
end global_001;
|
with Ada.Numerics.Elementary_Functions;
with Ada.Calendar.Formatting;
with Ada.Calendar.Time_Zones;
with SDL.Video.Windows.Makers;
with SDL.Video.Renderers.Makers;
with SDL.Events.Events;
procedure Draw_A_Clock is
use Ada.Calendar;
use Ada.Calendar.Formatting;
Window : SDL.Video.Windows.Window;
Renderer : SDL.Video.Renderers.Renderer;
Event : SDL.Events.Events.Events;
Offset : Time_Zones.Time_Offset;
procedure Draw_Clock (Stamp : Time)
is
use SDL.C;
use Ada.Numerics.Elementary_Functions;
Radi : constant array (0 .. 59) of int := (0 | 15 | 30 | 45 => 2,
5 | 10 | 20 | 25 | 35 | 40 | 50 | 55 => 1,
others => 0);
Diam : constant array (0 .. 59) of int := (0 | 15 | 30 | 45 => 5,
5 | 10 | 20 | 25 | 35 | 40 | 50 | 55 => 3,
others => 1);
Width : constant int := Window.Get_Surface.Size.Width;
Height : constant int := Window.Get_Surface.Size.Height;
Radius : constant Float := Float (int'Min (Width, Height));
R_1 : constant Float := 0.48 * Radius;
R_2 : constant Float := 0.35 * Radius;
R_3 : constant Float := 0.45 * Radius;
R_4 : constant Float := 0.47 * Radius;
Hour : constant Hour_Number := Formatting.Hour (Stamp, Offset);
Minute : constant Minute_Number := Formatting.Minute (Stamp, Offset);
Second : constant Second_Number := Formatting.Second (Stamp);
function To_X (A : Float; R : Float) return int is
(Width / 2 + int (R * Sin (A, 60.0)));
function To_Y (A : Float; R : Float) return int is
(Height / 2 - int (R * Cos (A, 60.0)));
begin
SDL.Video.Renderers.Makers.Create (Renderer, Window.Get_Surface);
Renderer.Set_Draw_Colour ((0, 0, 150, 255));
Renderer.Fill (Rectangle => (0, 0, Width, Height));
Renderer.Set_Draw_Colour ((200, 200, 200, 255));
for A in 0 .. 59 loop
Renderer.Fill (Rectangle => (To_X (Float (A), R_1) - Radi (A),
To_Y (Float (A), R_1) - Radi (A), Diam (A), Diam (A)));
end loop;
Renderer.Set_Draw_Colour ((200, 200, 0, 255));
Renderer.Draw (Line => ((Width / 2, Height / 2),
(To_X (5.0 * (Float (Hour) + Float (Minute) / 60.0), R_2),
To_Y (5.0 * (Float (Hour) + Float (Minute) / 60.0), R_2))));
Renderer.Draw (Line => ((Width / 2, Height / 2),
(To_X (Float (Minute) + Float (Second) / 60.0, R_3),
To_Y (Float (Minute) + Float (Second) / 60.0, R_3))));
Renderer.Set_Draw_Colour ((220, 0, 0, 255));
Renderer.Draw (Line => ((Width / 2, Height / 2),
(To_X (Float (Second), R_4),
To_Y (Float (Second), R_4))));
Renderer.Fill (Rectangle => (Width / 2 - 3, Height / 2 - 3, 7, 7));
end Draw_Clock;
function Poll_Quit return Boolean is
use type SDL.Events.Event_Types;
begin
while SDL.Events.Events.Poll (Event) loop
if Event.Common.Event_Type = SDL.Events.Quit then
return True;
end if;
end loop;
return False;
end Poll_Quit;
begin
Offset := Time_Zones.UTC_Time_Offset;
if not SDL.Initialise (Flags => SDL.Enable_Screen) then
return;
end if;
SDL.Video.Windows.Makers.Create (Win => Window,
Title => "Draw a clock",
Position => SDL.Natural_Coordinates'(X => 10, Y => 10),
Size => SDL.Positive_Sizes'(300, 300),
Flags => SDL.Video.Windows.Resizable);
loop
Draw_Clock (Clock);
Window.Update_Surface;
delay 0.200;
exit when Poll_Quit;
end loop;
Window.Finalize;
SDL.Finalise;
end Draw_A_Clock;
|
------------------------------------------------------------------------------
-- A d a r u n - t i m e s p e c i f i c a t i o n --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of ada.ads file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
package Ada.Finalization is
pragma Preelaborate (Finalization);
pragma Remote_Types (Finalization);
type Controlled is abstract tagged private;
pragma Preelaborable_Initialization (Controlled);
procedure Initialize (Object : in out Controlled) is null;
procedure Adjust (Object : in out Controlled) is null;
procedure Finalize (Object : in out Controlled) is null;
type Limited_Controlled is abstract tagged limited private;
pragma Preelaborable_Initialization (Limited_Controlled);
procedure Initialize (Object : in out Limited_Controlled) is null;
procedure Finalize (Object : in out Limited_Controlled) is null;
private
pragma Import (Ada, Controlled);
pragma Import (Ada, Limited_Controlled);
end Ada.Finalization;
|
-- This package has been generated automatically by GNATtest.
-- You are allowed to add your code to the bodies of test routines.
-- Such changes will be kept during further regeneration of this file.
-- All code placed outside of test routine bodies will be lost. The
-- code intended to set up and tear down the test environment should be
-- placed into Factions.Test_Data.
with AUnit.Assertions; use AUnit.Assertions;
with System.Assertions;
-- begin read only
-- id:2.2/00/
--
-- This section can be used to add with clauses if necessary.
--
-- end read only
-- begin read only
-- end read only
package body Factions.Test_Data.Tests is
-- begin read only
-- id:2.2/01/
--
-- This section can be used to add global variables and other elements.
--
-- end read only
-- begin read only
-- end read only
-- begin read only
function Wrap_Test_GetReputation_f138bb_ad6480
(SourceFaction, TargetFaction: Unbounded_String) return Integer is
begin
begin
pragma Assert
((Factions_List.Contains(SourceFaction) and
Factions_List.Contains(TargetFaction)));
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"req_sloc(factions.ads:0):Test_GetReputation test requirement violated");
end;
declare
Test_GetReputation_f138bb_ad6480_Result: constant Integer :=
GNATtest_Generated.GNATtest_Standard.Factions.GetReputation
(SourceFaction, TargetFaction);
begin
begin
pragma Assert(True);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"ens_sloc(factions.ads:0:):Test_GetReputation test commitment violated");
end;
return Test_GetReputation_f138bb_ad6480_Result;
end;
end Wrap_Test_GetReputation_f138bb_ad6480;
-- end read only
-- begin read only
procedure Test_GetReputation_test_getreputation(Gnattest_T: in out Test);
procedure Test_GetReputation_f138bb_ad6480(Gnattest_T: in out Test) renames
Test_GetReputation_test_getreputation;
-- id:2.2/f138bbb5c8b2b971/GetReputation/1/0/test_getreputation/
procedure Test_GetReputation_test_getreputation(Gnattest_T: in out Test) is
function GetReputation
(SourceFaction, TargetFaction: Unbounded_String) return Integer renames
Wrap_Test_GetReputation_f138bb_ad6480;
-- end read only
pragma Unreferenced(Gnattest_T);
begin
Assert
(GetReputation
(To_Unbounded_String("POLEIS"), To_Unbounded_String("POLEIS")) =
0,
"Failed to get reputation for Poleis to Poleis.");
Assert
(GetReputation
(To_Unbounded_String("POLEIS"), To_Unbounded_String("PIRATES")) =
-10,
"Failed to get reputation for Poleis to Pirates.");
-- begin read only
end Test_GetReputation_test_getreputation;
-- end read only
-- begin read only
function Wrap_Test_IsFriendly_868bec_4ae8b6
(SourceFaction, TargetFaction: Unbounded_String) return Boolean is
begin
begin
pragma Assert
((Factions_List.Contains(SourceFaction) and
Factions_List.Contains(TargetFaction)));
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"req_sloc(factions.ads:0):Test_IsFriendly test requirement violated");
end;
declare
Test_IsFriendly_868bec_4ae8b6_Result: constant Boolean :=
GNATtest_Generated.GNATtest_Standard.Factions.IsFriendly
(SourceFaction, TargetFaction);
begin
begin
pragma Assert(True);
null;
exception
when System.Assertions.Assert_Failure =>
AUnit.Assertions.Assert
(False,
"ens_sloc(factions.ads:0:):Test_IsFriendly test commitment violated");
end;
return Test_IsFriendly_868bec_4ae8b6_Result;
end;
end Wrap_Test_IsFriendly_868bec_4ae8b6;
-- end read only
-- begin read only
procedure Test_IsFriendly_test_isfriendly(Gnattest_T: in out Test);
procedure Test_IsFriendly_868bec_4ae8b6(Gnattest_T: in out Test) renames
Test_IsFriendly_test_isfriendly;
-- id:2.2/868bec8bf6fd9c98/IsFriendly/1/0/test_isfriendly/
procedure Test_IsFriendly_test_isfriendly(Gnattest_T: in out Test) is
function IsFriendly
(SourceFaction, TargetFaction: Unbounded_String) return Boolean renames
Wrap_Test_IsFriendly_868bec_4ae8b6;
-- end read only
pragma Unreferenced(Gnattest_T);
begin
Assert
(IsFriendly
(To_Unbounded_String("POLEIS"),
To_Unbounded_String("INDEPENDENT")) =
True,
"Failed to check two friendly factions.");
Assert
(IsFriendly
(To_Unbounded_String("POLEIS"), To_Unbounded_String("PIRATES")) =
False,
"Failed to check two unfriendly factions.");
-- begin read only
end Test_IsFriendly_test_isfriendly;
-- end read only
-- begin read only
function Wrap_Test_GetRandomFaction_47dd81_103989 return Unbounded_String is
begin
declare
Test_GetRandomFaction_47dd81_103989_Result: constant Unbounded_String :=
GNATtest_Generated.GNATtest_Standard.Factions.GetRandomFaction;
begin
return Test_GetRandomFaction_47dd81_103989_Result;
end;
end Wrap_Test_GetRandomFaction_47dd81_103989;
-- end read only
-- begin read only
procedure Test_GetRandomFaction_test_getrandomfaction
(Gnattest_T: in out Test);
procedure Test_GetRandomFaction_47dd81_103989
(Gnattest_T: in out Test) renames
Test_GetRandomFaction_test_getrandomfaction;
-- id:2.2/47dd8179e978586a/GetRandomFaction/1/0/test_getrandomfaction/
procedure Test_GetRandomFaction_test_getrandomfaction
(Gnattest_T: in out Test) is
function GetRandomFaction return Unbounded_String renames
Wrap_Test_GetRandomFaction_47dd81_103989;
-- end read only
pragma Unreferenced(Gnattest_T);
FactionName: Unbounded_String := Null_Unbounded_String;
begin
FactionName := GetRandomFaction;
Assert
(FactionName /= Null_Unbounded_String,
"Failed to get random faction name. Empty name.");
Assert
(Factions_List.Contains(FactionName),
"Failed to get random faction name. Got not existing name.");
-- begin read only
end Test_GetRandomFaction_test_getrandomfaction;
-- end read only
-- begin read only
-- id:2.2/02/
--
-- This section can be used to add elaboration code for the global state.
--
begin
-- end read only
null;
-- begin read only
-- end read only
end Factions.Test_Data.Tests;
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 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 Ada.Containers.Indefinite_Hashed_Maps;
with Ada.Streams;
with Ada.Strings.Hash;
with GL.Low_Level.Enums;
with GL.Objects.Textures;
with GL.Pixels;
with GL.Types;
with Orka.Resources;
private package Orka.KTX is
pragma Preelaborate;
package String_Maps is new Ada.Containers.Indefinite_Hashed_Maps
(Key_Type => String,
Element_Type => String,
Hash => Ada.Strings.Hash,
Equivalent_Keys => "=");
use GL.Low_Level.Enums;
use type GL.Types.Size;
type Header (Compressed : Boolean) is record
Kind : GL.Low_Level.Enums.Texture_Kind;
Width : GL.Types.Size;
Height : GL.Types.Size;
Depth : GL.Types.Size;
Array_Elements : GL.Types.Size;
Mipmap_Levels : GL.Objects.Textures.Mipmap_Level;
Bytes_Key_Value : GL.Types.Size;
case Compressed is
when True =>
Compressed_Format : GL.Pixels.Compressed_Format;
when False =>
Data_Type : GL.Pixels.Data_Type;
Format : GL.Pixels.Format;
Internal_Format : GL.Pixels.Internal_Format;
end case;
end record
with Dynamic_Predicate => Header.Width > 0
and not (Header.Height = 0 and Header.Depth > 0)
and (if Header.Compressed then Header.Mipmap_Levels > 0)
and (case Header.Kind is
when Texture_1D | Texture_2D | Texture_3D => Header.Array_Elements = 0,
when Texture_Cube_Map => Header.Array_Elements = 0,
when others => Header.Array_Elements > 0)
and (case Header.Kind is
when Texture_1D | Texture_1D_Array => Header.Height = 0,
when Texture_2D | Texture_2D_Array => Header.Height > 0 and Header.Depth = 0,
when Texture_3D => Header.Depth > 0,
when Texture_Cube_Map => Header.Width = Header.Height and Header.Depth = 0,
when Texture_Cube_Map_Array => Header.Width = Header.Height and Header.Depth = 0,
when others => raise Constraint_Error);
subtype Bytes_Reference is Resources.Byte_Array_Pointers.Constant_Reference;
function Valid_Identifier (Bytes : Bytes_Reference) return Boolean;
function Get_Header (Bytes : Bytes_Reference) return Header;
function Get_Key_Value_Map
(Bytes : Bytes_Reference;
Length : GL.Types.Size) return String_Maps.Map;
function Get_Length
(Bytes : Bytes_Reference;
Offset : Ada.Streams.Stream_Element_Offset) return Natural;
function Get_Data_Offset
(Bytes : Bytes_Reference;
Bytes_Key_Value : GL.Types.Size) return Ada.Streams.Stream_Element_Offset;
Invalid_Enum_Error : exception;
function Create_KTX_Bytes
(KTX_Header : Header;
Get_Data : not null access function (Level : GL.Objects.Textures.Mipmap_Level)
return Resources.Byte_Array_Pointers.Pointer)
return Resources.Byte_Array_Pointers.Pointer;
end Orka.KTX;
|
with Ada.Integer_Text_IO, Ada.Text_IO;
procedure Introspection is
use Ada.Integer_Text_IO, Ada.Text_IO;
begin
Put ("Integer range: ");
Put (Integer'First);
Put (" .. ");
Put (Integer'Last);
New_Line;
Put ("Float digits: ");
Put (Float'Digits);
New_Line;
end Introspection;
|
generic
N : in Natural;
package DataOperations is
subtype Index is Positive range 1 .. N;
type Vector is array (Index) of Integer;
type Matrix is array (Index) of Vector;
procedure Input (a : out Integer);
procedure Generate (a : out Integer);
procedure FillWithOne (a : out Integer);
procedure Input (A : out Vector);
procedure Generate (A : out Vector);
procedure FillWithOne (A : out Vector);
procedure Input (MA : out Matrix);
procedure Generate (MA : out Matrix);
procedure FillWithOne (MA : out Matrix);
procedure Output (V : in Vector);
procedure Output (MA : in Matrix);
function Multiple
(A : in Integer;
MB : in Matrix;
From : Integer;
To : Integer) return Matrix;
function Multiple
(Left : in Matrix;
Right : in Matrix;
From : Integer;
To : Integer) return Matrix;
function Amount
(MA : in Matrix;
MB : in Matrix;
From : Integer;
To : Integer) return Matrix;
end DataOperations;
|
package Test1 is
Question: constant string := "How Many Characters?";
Ask_Twice: constant string := Question & Question;
end Test1;
with Test1; use Test1;
package Test2 is
Str: string(Ask_Twice'range) := Ask_Twice;
end Test2;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Test is A'B : integer; begin Put('a'); end;
|
limited with Actors, Engines;
package Components.Destructibles is
-- Base components
type Destructible is abstract tagged record
max_hp, hp : Health;
defense_stat : Defense;
end record;
function is_dead(self : Destructible) return Boolean with Inline;
function take_damage(self : in out Destructible'Class; owner : in out Actors.Actor;
damage : Health; engine : in out Engines.Engine) return Health;
procedure die(self : in out Destructible; owner : in out Actors.Actor;
engine : in out Engines.Engine);
type Monster_Destructible is new Destructible with null record;
overriding procedure die(self : in out Monster_Destructible; owner : in out Actors.Actor;
engine : in out Engines.Engine);
type Player_Destructible is new Destructible with null record;
overriding procedure die(self : in out Player_Destructible; owner : in out Actors.Actor;
engine : in out Engines.Engine);
end Components.Destructibles;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T A S K I N G . A S Y N C _ D E L A Y S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1998-2020, Free Software Foundation, Inc. --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
with Ada.Task_Identification;
with System.Task_Primitives.Operations;
with System.Tasking.Utilities;
with System.Tasking.Initialization;
with System.Tasking.Debug;
with System.OS_Primitives;
with System.Interrupt_Management.Operations;
package body System.Tasking.Async_Delays is
package STPO renames System.Task_Primitives.Operations;
package ST renames System.Tasking;
package STU renames System.Tasking.Utilities;
package STI renames System.Tasking.Initialization;
package OSP renames System.OS_Primitives;
function To_System is new Ada.Unchecked_Conversion
(Ada.Task_Identification.Task_Id, Task_Id);
Timer_Attention : Boolean := False;
pragma Atomic (Timer_Attention);
task Timer_Server is
pragma Interrupt_Priority (System.Any_Priority'Last);
end Timer_Server;
Timer_Server_ID : constant ST.Task_Id := To_System (Timer_Server'Identity);
-- The timer queue is a circular doubly linked list, ordered by absolute
-- wakeup time. The first item in the queue is Timer_Queue.Succ.
-- It is given a Resume_Time that is larger than any legitimate wakeup
-- time, so that the ordered insertion will always stop searching when it
-- gets back to the queue header block.
Timer_Queue : aliased Delay_Block;
package Init_Timer_Queue is end Init_Timer_Queue;
pragma Unreferenced (Init_Timer_Queue);
-- Initialize the Timer_Queue. This is a package to work around the
-- fact that statements are syntactically illegal here. We want this
-- initialization to happen before the Timer_Server is activated. A
-- build-in-place function would also work, but that's not supported
-- on all platforms (e.g. cil).
package body Init_Timer_Queue is
begin
Timer_Queue.Succ := Timer_Queue'Unchecked_Access;
Timer_Queue.Pred := Timer_Queue'Unchecked_Access;
Timer_Queue.Resume_Time := Duration'Last;
end Init_Timer_Queue;
------------------------
-- Cancel_Async_Delay --
------------------------
-- This should (only) be called from the compiler-generated cleanup routine
-- for an async. select statement with delay statement as trigger. The
-- effect should be to remove the delay from the timer queue, and exit one
-- ATC nesting level.
-- The usage and logic are similar to Cancel_Protected_Entry_Call, but
-- simplified because this is not a true entry call.
procedure Cancel_Async_Delay (D : Delay_Block_Access) is
Dpred : Delay_Block_Access;
Dsucc : Delay_Block_Access;
begin
-- A delay block level of Level_No_Pending_Abort indicates the delay
-- has been canceled. If the delay has already been canceled, there is
-- nothing more to be done.
if D.Level = Level_No_Pending_Abort then
return;
end if;
D.Level := Level_No_Pending_Abort;
-- Remove self from timer queue
STI.Defer_Abort_Nestable (D.Self_Id);
STPO.Write_Lock (Timer_Server_ID);
Dpred := D.Pred;
Dsucc := D.Succ;
Dpred.Succ := Dsucc;
Dsucc.Pred := Dpred;
D.Succ := D;
D.Pred := D;
STPO.Unlock (Timer_Server_ID);
-- Note that the above deletion code is required to be
-- idempotent, since the block may have been dequeued
-- previously by the Timer_Server.
-- leave the asynchronous select
STPO.Write_Lock (D.Self_Id);
STU.Exit_One_ATC_Level (D.Self_Id);
STPO.Unlock (D.Self_Id);
STI.Undefer_Abort_Nestable (D.Self_Id);
end Cancel_Async_Delay;
----------------------
-- Enqueue_Duration --
----------------------
function Enqueue_Duration
(T : Duration;
D : Delay_Block_Access) return Boolean
is
begin
if T <= 0.0 then
D.Timed_Out := True;
STPO.Yield;
return False;
else
-- The corresponding call to Undefer_Abort is performed by the
-- expanded code (see exp_ch9).
STI.Defer_Abort (STPO.Self);
Time_Enqueue
(STPO.Monotonic_Clock
+ Duration'Min (T, OSP.Max_Sensible_Delay), D);
return True;
end if;
end Enqueue_Duration;
------------------
-- Time_Enqueue --
------------------
-- Allocate a queue element for the wakeup time T and put it in the
-- queue in wakeup time order. Assume we are on an asynchronous
-- select statement with delay trigger. Put the calling task to
-- sleep until either the delay expires or is canceled.
-- We use one entry call record for this delay, since we have
-- to increment the ATC nesting level, but since it is not a
-- real entry call we do not need to use any of the fields of
-- the call record. The following code implements a subset of
-- the actions for the asynchronous case of Protected_Entry_Call,
-- much simplified since we know this never blocks, and does not
-- have the full semantics of a protected entry call.
procedure Time_Enqueue
(T : Duration;
D : Delay_Block_Access)
is
Self_Id : constant Task_Id := STPO.Self;
Q : Delay_Block_Access;
begin
pragma Debug (Debug.Trace (Self_Id, "Async_Delay", 'P'));
pragma Assert (Self_Id.Deferral_Level = 1,
"async delay from within abort-deferred region");
if Self_Id.ATC_Nesting_Level = ATC_Level'Last then
raise Storage_Error with "not enough ATC nesting levels";
end if;
Self_Id.ATC_Nesting_Level := Self_Id.ATC_Nesting_Level + 1;
pragma Debug
(Debug.Trace (Self_Id, "ASD: entered ATC level: " &
ATC_Level'Image (Self_Id.ATC_Nesting_Level), 'A'));
D.Level := Self_Id.ATC_Nesting_Level;
D.Self_Id := Self_Id;
D.Resume_Time := T;
STPO.Write_Lock (Timer_Server_ID);
-- Previously, there was code here to dynamically create
-- the Timer_Server task, if one did not already exist.
-- That code had a timing window that could allow multiple
-- timer servers to be created. Luckily, the need for
-- postponing creation of the timer server should now be
-- gone, since this package will only be linked in if
-- there are calls to enqueue calls on the timer server.
-- Insert D in the timer queue, at the position determined
-- by the wakeup time T.
Q := Timer_Queue.Succ;
while Q.Resume_Time < T loop
Q := Q.Succ;
end loop;
-- Q is the block that has Resume_Time equal to or greater than
-- T. After the insertion we want Q to be the successor of D.
D.Succ := Q;
D.Pred := Q.Pred;
D.Pred.Succ := D;
Q.Pred := D;
-- If the new element became the head of the queue,
-- signal the Timer_Server to wake up.
if Timer_Queue.Succ = D then
Timer_Attention := True;
STPO.Wakeup (Timer_Server_ID, ST.Timer_Server_Sleep);
end if;
STPO.Unlock (Timer_Server_ID);
end Time_Enqueue;
---------------
-- Timed_Out --
---------------
function Timed_Out (D : Delay_Block_Access) return Boolean is
begin
return D.Timed_Out;
end Timed_Out;
------------------
-- Timer_Server --
------------------
task body Timer_Server is
Ignore : constant Boolean := STU.Make_Independent;
-- Local Declarations
Next_Wakeup_Time : Duration := Duration'Last;
Timedout : Boolean;
Yielded : Boolean;
Now : Duration;
Dequeued : Delay_Block_Access;
Dequeued_Task : Task_Id;
pragma Unreferenced (Timedout, Yielded);
begin
pragma Assert (Timer_Server_ID = STPO.Self);
-- Since this package may be elaborated before System.Interrupt,
-- we need to call Setup_Interrupt_Mask explicitly to ensure that
-- this task has the proper signal mask.
Interrupt_Management.Operations.Setup_Interrupt_Mask;
-- Initialize the timer queue to empty, and make the wakeup time of the
-- header node be larger than any real wakeup time we will ever use.
loop
STI.Defer_Abort (Timer_Server_ID);
STPO.Write_Lock (Timer_Server_ID);
-- The timer server needs to catch pending aborts after finalization
-- of library packages. If it doesn't poll for it, the server will
-- sometimes hang.
if not Timer_Attention then
Timer_Server_ID.Common.State := ST.Timer_Server_Sleep;
if Next_Wakeup_Time = Duration'Last then
Timer_Server_ID.User_State := 1;
Next_Wakeup_Time :=
STPO.Monotonic_Clock + OSP.Max_Sensible_Delay;
else
Timer_Server_ID.User_State := 2;
end if;
STPO.Timed_Sleep
(Timer_Server_ID, Next_Wakeup_Time,
OSP.Absolute_RT, ST.Timer_Server_Sleep,
Timedout, Yielded);
Timer_Server_ID.Common.State := ST.Runnable;
end if;
-- Service all of the wakeup requests on the queue whose times have
-- been reached, and update Next_Wakeup_Time to next wakeup time
-- after that (the wakeup time of the head of the queue if any, else
-- a time far in the future).
Timer_Server_ID.User_State := 3;
Timer_Attention := False;
Now := STPO.Monotonic_Clock;
while Timer_Queue.Succ.Resume_Time <= Now loop
-- Dequeue the waiting task from the front of the queue
pragma Debug (System.Tasking.Debug.Trace
(Timer_Server_ID, "Timer service: waking up waiting task", 'E'));
Dequeued := Timer_Queue.Succ;
Timer_Queue.Succ := Dequeued.Succ;
Dequeued.Succ.Pred := Dequeued.Pred;
Dequeued.Succ := Dequeued;
Dequeued.Pred := Dequeued;
-- We want to abort the queued task to the level of the async.
-- select statement with the delay. To do that, we need to lock
-- the ATCB of that task, but to avoid deadlock we need to release
-- the lock of the Timer_Server. This leaves a window in which
-- another task might perform an enqueue or dequeue operation on
-- the timer queue, but that is OK because we always restart the
-- next iteration at the head of the queue.
STPO.Unlock (Timer_Server_ID);
STPO.Write_Lock (Dequeued.Self_Id);
Dequeued_Task := Dequeued.Self_Id;
Dequeued.Timed_Out := True;
STI.Locked_Abort_To_Level
(Timer_Server_ID, Dequeued_Task, Dequeued.Level - 1);
STPO.Unlock (Dequeued_Task);
STPO.Write_Lock (Timer_Server_ID);
end loop;
Next_Wakeup_Time := Timer_Queue.Succ.Resume_Time;
-- Service returns the Next_Wakeup_Time.
-- The Next_Wakeup_Time is either an infinity (no delay request)
-- or the wakeup time of the queue head. This value is used for
-- an actual delay in this server.
STPO.Unlock (Timer_Server_ID);
STI.Undefer_Abort (Timer_Server_ID);
end loop;
end Timer_Server;
end System.Tasking.Async_Delays;
|
pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with bits_types_h;
package sys_types_h is
-- Copyright (C) 1991-2021 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
-- <https://www.gnu.org/licenses/>.
-- * POSIX Standard: 2.6 Primitive System Data Types <sys/types.h>
--
subtype u_char is bits_types_h.uu_u_char; -- /usr/include/sys/types.h:33
subtype u_short is bits_types_h.uu_u_short; -- /usr/include/sys/types.h:34
subtype u_int is bits_types_h.uu_u_int; -- /usr/include/sys/types.h:35
subtype u_long is bits_types_h.uu_u_long; -- /usr/include/sys/types.h:36
subtype quad_t is bits_types_h.uu_quad_t; -- /usr/include/sys/types.h:37
subtype u_quad_t is bits_types_h.uu_u_quad_t; -- /usr/include/sys/types.h:38
subtype fsid_t is bits_types_h.uu_fsid_t; -- /usr/include/sys/types.h:39
subtype loff_t is bits_types_h.uu_loff_t; -- /usr/include/sys/types.h:42
subtype ino_t is bits_types_h.uu_ino_t; -- /usr/include/sys/types.h:47
subtype ino64_t is bits_types_h.uu_ino64_t; -- /usr/include/sys/types.h:54
subtype dev_t is bits_types_h.uu_dev_t; -- /usr/include/sys/types.h:59
subtype gid_t is bits_types_h.uu_gid_t; -- /usr/include/sys/types.h:64
subtype mode_t is bits_types_h.uu_mode_t; -- /usr/include/sys/types.h:69
subtype nlink_t is bits_types_h.uu_nlink_t; -- /usr/include/sys/types.h:74
subtype uid_t is bits_types_h.uu_uid_t; -- /usr/include/sys/types.h:79
subtype off_t is bits_types_h.uu_off_t; -- /usr/include/sys/types.h:85
subtype off64_t is bits_types_h.uu_off64_t; -- /usr/include/sys/types.h:92
subtype pid_t is bits_types_h.uu_pid_t; -- /usr/include/sys/types.h:97
subtype id_t is bits_types_h.uu_id_t; -- /usr/include/sys/types.h:103
subtype ssize_t is bits_types_h.uu_ssize_t; -- /usr/include/sys/types.h:108
subtype daddr_t is bits_types_h.uu_daddr_t; -- /usr/include/sys/types.h:114
subtype caddr_t is bits_types_h.uu_caddr_t; -- /usr/include/sys/types.h:115
subtype key_t is bits_types_h.uu_key_t; -- /usr/include/sys/types.h:121
subtype useconds_t is bits_types_h.uu_useconds_t; -- /usr/include/sys/types.h:134
subtype suseconds_t is bits_types_h.uu_suseconds_t; -- /usr/include/sys/types.h:138
-- Old compatibility names for C types.
subtype ulong is unsigned_long; -- /usr/include/sys/types.h:148
subtype ushort is unsigned_short; -- /usr/include/sys/types.h:149
subtype uint is unsigned; -- /usr/include/sys/types.h:150
-- These size-specific names are used by some of the inet code.
-- These were defined by ISO C without the first `_'.
subtype u_int8_t is bits_types_h.uu_uint8_t; -- /usr/include/sys/types.h:158
subtype u_int16_t is bits_types_h.uu_uint16_t; -- /usr/include/sys/types.h:159
subtype u_int32_t is bits_types_h.uu_uint32_t; -- /usr/include/sys/types.h:160
subtype u_int64_t is bits_types_h.uu_uint64_t; -- /usr/include/sys/types.h:161
subtype register_t is long; -- /usr/include/sys/types.h:164
-- Some code from BIND tests this macro to see if the types above are
-- defined.
-- In BSD <sys/types.h> is expected to define BYTE_ORDER.
-- It also defines `fd_set' and the FD_* macros for `select'.
subtype blksize_t is bits_types_h.uu_blksize_t; -- /usr/include/sys/types.h:185
-- Types from the Large File Support interface.
-- Type to count number of disk blocks.
subtype blkcnt_t is bits_types_h.uu_blkcnt_t; -- /usr/include/sys/types.h:192
-- Type to count file system blocks.
subtype fsblkcnt_t is bits_types_h.uu_fsblkcnt_t; -- /usr/include/sys/types.h:196
-- Type to count file system inodes.
subtype fsfilcnt_t is bits_types_h.uu_fsfilcnt_t; -- /usr/include/sys/types.h:200
-- Type to count number of disk blocks.
-- Type to count file system blocks.
-- Type to count file system inodes.
-- Type to count number of disk blocks.
subtype blkcnt64_t is bits_types_h.uu_blkcnt64_t; -- /usr/include/sys/types.h:219
-- Type to count file system blocks.
subtype fsblkcnt64_t is bits_types_h.uu_fsblkcnt64_t; -- /usr/include/sys/types.h:220
-- Type to count file system inodes.
subtype fsfilcnt64_t is bits_types_h.uu_fsfilcnt64_t; -- /usr/include/sys/types.h:221
-- Now add the thread types.
end sys_types_h;
|
with VisitFailurePackage, VisitablePackage, EnvironmentPackage;
use VisitFailurePackage, VisitablePackage, EnvironmentPackage;
package body SequenceStrategy is
----------------------------------------------------------------------------
-- Object implementation
----------------------------------------------------------------------------
overriding
function toString(o: Sequence) return String is
begin
return "Sequence()";
end;
----------------------------------------------------------------------------
-- Strategy implementation
----------------------------------------------------------------------------
overriding
function visitLight(str:access Sequence; any: ObjectPtr; i: access Introspector'Class) return ObjectPtr is
op : ObjectPtr := visitLight( StrategyPtr(str.arguments(FIRST)), any, i);
begin
return visitLight(StrategyPtr(str.arguments(SECOND)), op, i);
end;
overriding
function visit(str: access Sequence; i: access Introspector'Class) return Integer is
status : Integer := visit(StrategyPtr(str.arguments(FIRST)), i);
begin
if status = EnvironmentPackage.SUCCESS then
return visit(StrategyPtr(str.arguments(SECOND)), i);
else
return status;
end if;
end;
----------------------------------------------------------------------------
procedure makeSequence(s : in out Sequence; str1, str2 : StrategyPtr) is
begin
initSubterm(s, str1, str2);
end;
function make(str1, str2: StrategyPtr) return StrategyPtr is
ns : StrategyPtr := null;
begin
if str2 = null then
return str1;
else
ns := new Sequence;
makeSequence(Sequence(ns.all), str1, str2);
return ns;
end if;
end;
function newSequence(str1, str2: StrategyPtr) return StrategyPtr is
begin
return SequenceStrategy.make(str1,str2);
end;
----------------------------------------------------------------------------
end SequenceStrategy;
|
-----------------------------------------------------------------------
-- ado-queries -- Database Queries
-- Copyright (C) 2011, 2012, 2013, 2014, 2015, 2017, 2018 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with ADO.Queries.Loaders;
package body ADO.Queries is
-- ------------------------------
-- Set the query definition which identifies the SQL query to execute.
-- The query is represented by the <tt>sql</tt> XML entry.
-- ------------------------------
procedure Set_Query (Into : in out Context;
Query : in Query_Definition_Access) is
begin
Into.Query_Def := Query;
Into.Is_Count := False;
end Set_Query;
-- ------------------------------
-- Set the query definition which identifies the SQL query to execute.
-- The query count is represented by the <tt>sql-count</tt> XML entry.
-- ------------------------------
procedure Set_Count_Query (Into : in out Context;
Query : in Query_Definition_Access) is
begin
Into.Query_Def := Query;
Into.Is_Count := True;
end Set_Count_Query;
procedure Set_Query (Into : in out Context;
Name : in String) is
begin
Into.Query_Def := ADO.Queries.Loaders.Find_Query (Name);
end Set_Query;
-- ------------------------------
-- Set the query to execute as SQL statement.
-- ------------------------------
procedure Set_SQL (Into : in out Context;
SQL : in String) is
begin
ADO.SQL.Clear (Into.SQL);
ADO.SQL.Append (Into.SQL, SQL);
end Set_SQL;
-- ------------------------------
-- Set the limit for the SQL query.
-- ------------------------------
procedure Set_Limit (Into : in out Context;
First : in Natural;
Last : in Natural) is
begin
Into.First := First;
Into.Last := Last;
end Set_Limit;
-- ------------------------------
-- Get the first row index.
-- ------------------------------
function Get_First_Row_Index (From : in Context) return Natural is
begin
return From.First;
end Get_First_Row_Index;
-- ------------------------------
-- Get the last row index.
-- ------------------------------
function Get_Last_Row_Index (From : in Context) return Natural is
begin
return From.Last;
end Get_Last_Row_Index;
-- ------------------------------
-- Get the maximum number of rows that the SQL query can return.
-- This operation uses the <b>sql-count</b> query.
-- ------------------------------
function Get_Max_Row_Count (From : in Context) return Natural is
begin
return From.Max_Row_Count;
end Get_Max_Row_Count;
-- ------------------------------
-- Get the SQL query that correspond to the query context.
-- ------------------------------
function Get_SQL (From : in Context;
Manager : in Query_Manager'Class) return String is
begin
if From.Query_Def = null then
return ADO.SQL.To_String (From.SQL);
else
return Get_SQL (From.Query_Def, Manager, From.Is_Count);
end if;
end Get_SQL;
-- ------------------------------
-- Find the query with the given name.
-- Returns the query definition that matches the name or null if there is none
-- ------------------------------
function Find_Query (File : in Query_File_Info;
Name : in String) return Query_Definition_Access is
Query : Query_Definition_Access := File.File.Queries;
begin
while Query /= null loop
if Query.Name.all = Name then
return Query;
end if;
Query := Query.Next;
end loop;
return null;
end Find_Query;
function Get_SQL (From : in Query_Definition_Access;
Manager : in Query_Manager;
Use_Count : in Boolean) return String is
Query : Query_Info_Ref.Ref;
begin
ADO.Queries.Loaders.Read_Query (Manager, From);
Query := Manager.Queries (From.Query);
if Query.Is_Null then
raise Query_Error with "Query '" & From.Name.all & "'does not exist";
end if;
if Use_Count then
if Length (Query.Value.Count_Query (Manager.Driver).SQL) > 0 then
return To_String (Query.Value.Count_Query (Manager.Driver).SQL);
elsif Length (Query.Value.Count_Query (Driver_Index'First).SQL) > 0 then
return To_String (Query.Value.Count_Query (Driver_Index'First).SQL);
else
raise Query_Error with "Default count-query '" & From.Name.all & "'is empty";
end if;
elsif Length (Query.Value.Main_Query (Manager.Driver).SQL) > 0 then
return To_String (Query.Value.Main_Query (Manager.Driver).SQL);
elsif Length (Query.Value.Main_Query (Driver_Index'First).SQL) > 0 then
return To_String (Query.Value.Main_Query (Driver_Index'First).SQL);
else
raise Query_Error with "Default query '" & From.Name.all & "' is empty";
end if;
end Get_SQL;
overriding
procedure Finalize (Manager : in out Query_Manager) is
procedure Free is
new Ada.Unchecked_Deallocation (Object => File_Table,
Name => File_Table_Access);
procedure Free is
new Ada.Unchecked_Deallocation (Object => Query_Table,
Name => Query_Table_Access);
begin
Free (Manager.Queries);
Free (Manager.Files);
end Finalize;
end ADO.Queries;
|
-- Hardware contains the code to control the hardware platform. This
-- top level package contains initialisation for the hardware before any
-- of the specific modules are set up.
package Hardware is
-- Init is required for any of other hardware modules.
procedure Init;
end Hardware;
|
package body Separated is
procedure Watch_Me is separate;
function Look_Out return Float is (5.0);
end Separated;
|
-- package Clenshaw
--
-- Clenshaw's formula is used to evaluate functions Q_k (X), and
-- summations over functions Q_k (X), where the functions Q_k (X)
-- are defined by recurrance relations of the sort:
--
-- Q_0 = some given function of X
-- Q_1 = Alpha(1, X) * Q_0(X)
-- Q_k = Alpha(k, X) * Q_k-1(X) + Beta(k, X) * Q_k-2(X) (k > 1)
--
-- The procedure "Sum" evaluates the sum
-- n
-- F_n(X) = SUM ( C_k * Q_k(X) )
-- k=0
--
-- where the coefficients C_k are given quantities, like Alpha, Beta, Q_0, Q_1.
-- Procedure "Evaluate_Qs" calculates the function Q_k, a special case
-- of the sum above. Clenshaw's method is usually more accurate and less
-- unstable than direct summations of F_n.
--
-- The most common application of this algorithm is in the construction
-- of orthogonal polynomials and their sums. But notice that the functions
-- functions Q_k need not be orthogonal, and they need not be polynomials.
-- In most cases, though, the Q_k are orthogonal polynomials.
-- Common cases are Hermite, Laguerre, Chebychev, Legendre,
-- and Gegenbauer polynomials.
--
-- WARNING:
--
-- These functions are not the same as the Gram-Schmidt polynomials.
-- Gram-Schmidt polys are orthogonal on a discrete set of points, and
-- form a complete for function defined on that discrete set of points.
-- The orthogonality of the following functions is respect integration on
-- an interval, not summation over a discrete set of points. So these
-- functions don't form a complete set on a discrete set of points
-- (unlike the discrete polys generated by a gram-schmidt method, or
-- the sinusoids in a discrete Fourier transform.)
--
-- EXAMPLES.
--
-- Chebychev Polynomials of the first kind:
-- Q_0(X) = 1
-- Q_1(X) = X
-- Q_k(X) = 2X*Q_k-1(X) - Q_k-2(X) (k > 1)
-- Alpha(k,X) = 2*X (k > 1)
-- Alpha(k,X) = X (k = 1)
-- Beta(k,X) = -1
-- They are orthogonal on the interval (-1,1) with
-- weight function W(X) = 1.0 / SQRT(1 - X*X).
-- Normalizing integral: Integral(Q_n(X) * Q_n(X) * W(X)) = Pi/2 for n>0
-- Normalizing integral: Integral(Q_n(X) * Q_n(X) * W(X)) = Pi for n=0
--
-- Chebychev Polynomials of the 2nd kind:
-- Q_0(X) = 1
-- Q_1(X) = 2*X
-- Q_k(X) = 2X*Q_k-1(X) - Q_k-2(X)
-- Alpha(k,X) = 2*X
-- Beta(k,X) = -1
-- They are orthogonal on the interval (-1,1) with
-- weight function W(X) = SQRT(1 - X*X).
-- Normalizing integral: Integral(Q_n(X) * Q_n(X) * W(X)) = Pi/2
--
-- Legendre: Q_0(X) = 1
-- Q_1(X) = X
-- Q_k(X) = ((2*k-1)/k)*X*Q_k-1(X) - ((k-1)/k)*Q_k-2(X)
-- Alpha(k,X) = X*(2*k-1)/k
-- Beta(k,X) = -(k-1)/k
-- They are orthogonal on the interval [-1,1] with
-- weight function W(X) = 1.
-- Normalizing integral: Integral(Q_n(X) * Q_n(X) * W(X)) = 2/(2n+1)
--
-- Associated Legendre(m, k): ( k must be greater than m-1 )
-- Q_m(X) = (-1)**m * (2m-1)!! * Sqrt(1-X*X)**m
-- Q_m+1(X) = X * (2*m + 1) * Q_m(X)
-- Q_k(X) = ((2*k-1)/(k-m))*X*Q_k-1(X) - ((k-1+m)/(k-m))*Q_k-2(X)
-- Alpha(k,X) = X*(2*k-1)/(k-m)
-- Beta(k,X) = -(k-1+m)/k
-- They are orthogonal on the interval [-1,1] with
-- weight function W(X) = 1.
-- Normalizing integral:
-- Integral(Q_n(X) * Q_n(X) * W(X)) = 2*(n+m)! / (2*n+1)*(n-m)!)
--
-- Hermite: Q_0(X) = 1
-- Q_1(X) = 2*X
-- Q_k(X) = 2*X*Q_k-1(X) - 2*(k-1)*Q_k-2(X)
-- Alpha(k,X) = 2*X
-- Beta(k,X) = -2*(k-1)
-- They are orthogonal on the interval (-infinity, infinity) with
-- weight function W(X) = Exp (-X*X).
-- Normalizing integral: Integral (Q_n(X)*Q_n(X)*W(X)) = n!(2**n)*Sqrt(Pi)
--
-- Laguerre: Q_0(X) = 1
-- Q_1(X) = 1 - X
-- Q_k(X) = (2*k - 1 - X)*Q_k-1(X) - (k-1)*(k-1)*Q_k-2(X)
-- Alpha(k,X) = 2*k - 1 - X
-- Beta(k,X) = -(k-1)*(k-1)
-- They are orthogonal on the interval (0,infinity) with
-- weight function Exp(-X).
-- Normalizing integral: Integral (Q_n(X)*Q_n(X)*W(X)) = Gamma(n+1)/n!
--
-- Generalized Laguerre:
-- Q_0(X) = 1
-- Q_1(X) = 1 - X
-- Q_k(X) = ((2*k-1+a-X)/k)*Q_k-1(X) - ((k-1+a)/k)*Q_k-2(X)
-- Alpha(k,X) = (2*k - 1 + a - X) / k
-- Beta(k,X) = -(k - 1 + a) / k
-- They are orthogonal on the interval (0,infinity) with
-- weight function W(X) = (X**a)*Exp(-X).
-- Normalizing integral: Integral (Q_n(X)*Q_n(X)*W(X)) = Gamma(n+a+1)/n!
--
--
-- procedure Evaluate_Qs
--
-- The procedure calculates the value of functions Q_k at points
-- X for each k in 0..Poly_ID. These are returned in the array
-- Q in the range 0..PolyID.
--
-- In most cases only the value of Q_k (X) at k = Poly_ID is desired. This
-- is returned as Q(k), where k = Poly_ID, the ID of the desired function.
-- The values of the other Q's are returned (in the same array
-- Q, at the appropriate index) because they are calculated along the
-- way, and may be useful also.
--
-- WARNING:
--
-- The functions Q_k generated by this routine are usually
-- *un-normalized*. Frequently, values of the normalized Q_k
-- are desired. The normalization factors are not given
-- by this package. They are given in most cases by the
-- procedures that use this package, and by standard reference
-- sources. These factors are usually k dependent, so you
-- must multiply each element of Q(1..Poly_ID) by a different
-- number to get an array of values of the normalized functions.
--
-- function Sum
--
-- This function sums the functions Q_k (at X) with coefficients given
-- by the array C. The result is returned as the function value.
-- This function is also a fast and efficient way of getting the
-- value of Q_k at X. Just let C = 0 everywhere, except at k. Let
-- the of C at k be C(k) = 1.0. then the function returns Q_k(X).
--
-- Notes on the algorithm.
--
-- We want to evaluate
-- n
-- F_n(X) = SUM ( C_k * Q_k(X) )
-- k=0
--
-- where Q is defined by
--
-- Q_k = Alpha(k, X) * Q_k-1 + Beta(k, X) * Q_k-2 (k > 1)
--
-- This package calculates F_n by the following formula
--
-- (*) F_n(X) = D_0*Q_0(X) + D_1*(Q_1(X) - Alpha(1,X)*Q_0(X)).
--
-- where the D_k are functions of X that satisfy:
--
-- D_n+2 = 0
-- D_n+1 = 0
-- D_k = C_k + Alpha(k+1,X) * D_k+1(X) + Beta(k+2,X) * D_k+2(X)
--
-- The proof of (*) is straightforward. Solve for C_k in the equation for
-- D_k above and plug it into the sum that defines F_n to get
--
-- n
-- F_n = SUM (D_k - Alpha(k+1)*D_k+1 - Beta(k+1)*D_k+2 ) * Q_k
-- k=0
-- n
-- F_n = D_0*Q_0 + D_1*Q_1 + SUM ( D_k * Q_k )
-- k=2
-- n
-- -Alpha(1)*D_1*Q_0 + SUM (-Alpha(k) * D_k * Q_k-1 )
-- k=2
-- n
-- + SUM (-Beta(k) * D_k * Q_k-2 ).
-- k=2
--
-- Now factor out D_k from the three SUM terms above, and notice
-- that what remains is just the recurrance relation that defines
-- Q_k for k > 0. It evaluates to zero, leaving
--
-- F_n(X) = D_0*Q_0(X)
--
-- (It should be clear that this process can be easily generalized
-- to recurrance relations in which Q_k depends on the previous 3 Q's.
--
-- Q_0 = some given function of X
-- Q_1 = some given function of X
-- Q_2 = some given function of X
-- Q_k = Alpha(k,X)*Q_k-1(X) + Beta(k,X)*Q_k-2(k,X) + Gamma*Q_k-3(X)
--
-- The SUM's above should start at k=3, but the derivation is identical.)
--
-- Finally notice that in special cases this simplifies further.
-- In many cases, particularly the orthogonal polynomials,
-- Q_0 is 1, so that F_n = D_0.
--
generic
type Real is digits <>;
-- Package only sums functions of real variables.
type Base_Poly_Index_Type is range <>;
Poly_Limit : Base_Poly_Index_Type;
with function Alpha
(k : Base_Poly_Index_Type;
Parameter : Real;
X : Real)
return Real;
with function Beta
(k : Base_Poly_Index_Type;
Parameter : Real;
X : Real)
return Real;
with function Q_0
(Parameter : Real;
X : Real)
return Real;
package Clenshaw is
subtype Poly_ID_Type is Base_Poly_Index_Type range 0 .. Poly_Limit;
-- The index k. k always starts a 0.
type Poly_Values is array(Poly_ID_Type) of Real;
procedure Evaluate_Qs
(X : in Real;
Q : in out Poly_Values;
Max_Poly_ID : in Poly_ID_Type;
P : in Real := 0.0;
No_Of_Iterations : in Positive := 1);
-- Get Q_0(X), Q_1(X) ... Q_m(X) where m = Max_Poly_ID.
-- P is the parameter in Alpha and Beta.
type Coefficients is array(Poly_ID_Type) of Real;
function Sum
(X : in Real;
C : in Coefficients;
Sum_Limit : in Poly_ID_Type;
P : in Real := 0.0;
No_Of_Iterations : in Positive := 1)
return Real;
-- Sum the polys Q times the Coefficients: SUM (Q_k * C_k)
-- P is the parameter in Alpha and Beta.
end Clenshaw;
|
-----------------------------------------------------------------------
-- components-widgets-progress -- Simple progress bar
-- Copyright (C) 2021 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Beans.Objects;
with ASF.Components.Base;
with ASF.Contexts.Writer;
with Ada.Text_IO.Editing;
package body ASF.Components.Widgets.Progress is
use Util.Beans.Objects;
package Formatter is
new Ada.Text_IO.Editing.Decimal_Output (Num => Progress_Type);
Format : constant Ada.Text_IO.Editing.Picture := Ada.Text_IO.Editing.To_Picture ("ZZ9.9");
function Get_Progress (UI : in UIProgressBar;
Context : in ASF.Contexts.Faces.Faces_Context'Class)
return Progress_Type is
Value_Obj : constant Object := UI.Get_Attribute (Context, VALUE_ATTR_NAME);
Min_Obj : constant Object := UI.Get_Attribute (Context, MIN_VALUE_ATTR_NAME);
Max_Obj : constant Object := UI.Get_Attribute (Context, MAX_VALUE_ATTR_NAME);
Value : Long_Long_Float := To_Long_Long_Float (Value_Obj);
Min_Val : Long_Long_Float := 0.0;
Max_Val : Long_Long_Float := 0.0;
Div : Long_Long_Float;
begin
if not Is_Null (Min_Obj) then
Min_Val := To_Long_Long_Float (Min_Obj);
end if;
if not Is_Null (Max_Obj) then
Max_Val := To_Long_Long_Float (Max_Obj);
end if;
if Max_Val < Min_Val then
Base.Log_Error (UI, "progress min value ({0}) is < max value ({1})",
To_String (Min_Obj),
To_String (Max_Obj));
end if;
Div := Max_Val - Min_Val;
if Div <= 0.0 then
return 0.0;
end if;
Value := Value - Min_Val;
if Value >= Div then
return 100.0;
else
return Progress_Type (100.0 * Value / Div);
end if;
end Get_Progress;
-- ------------------------------
-- Render the tab start.
-- ------------------------------
overriding
procedure Encode_Begin (UI : in UIProgressBar;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
Writer : constant Contexts.Writer.Response_Writer_Access := Context.Get_Response_Writer;
begin
if UI.Is_Rendered (Context) then
Writer.Start_Element ("div");
declare
Style : constant Object := UI.Get_Attribute (Context, "style");
Class : constant Object := UI.Get_Attribute (Context, "styleClass");
Title : constant Object := UI.Get_Attribute (Context, "title");
Direction : constant Object := UI.Get_Attribute (Context, DIRECTION_ATTR_NAME);
Progress : constant Progress_Type := UI.Get_Progress (Context);
Image : constant String := Formatter.Image (Progress, Format);
Pos : Positive := Image'First;
Vertical : constant Boolean := To_String (Direction) = "vertical";
begin
while Pos < Image'Last and then Image (Pos) = ' ' loop
Pos := Pos + 1;
end loop;
if not UI.Is_Generated_Id then
Writer.Write_Attribute ("id", UI.Get_Client_Id);
end if;
if not Is_Null (Class) then
Writer.Write_Attribute ("class", Class);
else
Writer.Write_Attribute ("class", "asf-progress-bar");
end if;
if not Is_Null (Style) then
Writer.Write_Attribute ("style", Style);
end if;
if not Is_Null (Title) then
Writer.Write_Attribute ("title", Title);
end if;
Writer.Start_Element ("span");
if Vertical then
Writer.Write_Attribute ("class", "asf-progress-status-vertical");
Writer.Write_Attribute ("style",
"height:" & Image (Pos .. Image'Last) & "%");
else
Writer.Write_Attribute ("class", "asf-progress-status-horizontal");
Writer.Write_Attribute ("style",
"width:" & Image (Pos .. Image'Last) & "%");
end if;
end;
end if;
end Encode_Begin;
-- ------------------------------
-- Render the tab close.
-- ------------------------------
overriding
procedure Encode_End (UI : in UIProgressBar;
Context : in out ASF.Contexts.Faces.Faces_Context'Class) is
Writer : constant Contexts.Writer.Response_Writer_Access := Context.Get_Response_Writer;
begin
if UI.Is_Rendered (Context) then
Writer.End_Element ("span");
Writer.End_Element ("div");
end if;
end Encode_End;
end ASF.Components.Widgets.Progress;
|
with Interfaces;
use type Interfaces.Unsigned_32;
package body Symbex.Parse is
package body Internal is
function Get_Data (Node : in Node_t)
return UBW_Strings.Unbounded_Wide_String is
begin
case Node.Kind is
when Node_Symbol => return Node.Name;
when Node_String => return Node.Data;
when others => raise Constraint_Error with "invalid node type";
end case;
end Get_Data;
function Get_List_ID (Node : in Node_t) return List_ID_t is
begin
case Node.Kind is
when Node_List => return Node.List;
when others => raise Constraint_Error with "invalid node type";
end case;
end Get_List_ID;
procedure List_Iterate
(List : in List_t;
Process : access procedure (Node : in Node_t))
is
procedure Inner_Process (Cursor : in Lists.Cursor) is
begin
Lists.Query_Element (Cursor, Process);
end Inner_Process;
begin
Lists.Iterate
(Container => List.Nodes,
Process => Inner_Process'Access);
end List_Iterate;
function Get_List
(Tree : in Tree_t;
List_ID : in List_ID_t) return List_t is
begin
return List_Arrays.Element
(Container => Tree.Lists,
Index => List_ID);
end Get_List;
end Internal;
--
-- Append Node to list List_ID
--
procedure Append_Node
(Tree : in out Tree_t;
Node : in Node_t;
List_ID : in List_ID_t)
is
procedure Process (List : in out List_t) is
begin
Lists.Append
(Container => List.Nodes,
New_Item => Node);
end Process;
begin
List_Arrays.Update_Element
(Container => Tree.Lists,
Index => List_ID,
Process => Process'Access);
end Append_Node;
--
-- Append list to list array and push list ID onto stack.
--
procedure Append_List
(Tree : in out Tree_t;
List : in List_t;
List_ID : in List_ID_t) is
begin
-- Add list to tree.
List_Arrays.Append
(Container => Tree.Lists,
New_Item => List);
pragma Assert (List_Arrays.Last_Index (Tree.Lists) = List_ID);
-- Push list onto stack.
List_ID_Stack.Push
(Stack => Tree.List_Stack,
Element => List_ID);
end Append_List;
--
-- Token processors.
--
--
-- Add quoted string to current list.
--
procedure Process_Quoted_String
(Tree : in out Tree_t;
Token : in Lex.Token_t)
is
Current_List : List_ID_t;
Node : Node_t (Kind => Node_String);
begin
Node.Data := Token.Text;
-- Fetch current list.
List_ID_Stack.Peek
(Stack => Tree.List_Stack,
Element => Current_List);
-- Add node to list.
Append_Node
(Tree => Tree,
List_ID => Current_List,
Node => Node);
end Process_Quoted_String;
--
-- Add symbol to current list.
--
procedure Process_Symbol
(Tree : in out Tree_t;
Token : in Lex.Token_t)
is
Current_List : List_ID_t;
Node : Node_t (Kind => Node_Symbol);
begin
Node.Name := Token.Text;
-- Fetch current list.
List_ID_Stack.Peek
(Stack => Tree.List_Stack,
Element => Current_List);
-- Add node to list.
Append_Node
(Tree => Tree,
List_ID => Current_List,
Node => Node);
end Process_Symbol;
--
-- Open new list. Create new node pointing to new list in current.
-- Push list onto stack.
--
procedure Process_List_Open (Tree : in out Tree_t) is
List : List_t;
New_ID : List_ID_t;
Node : Node_t (Kind => Node_List);
begin
New_ID := List_Arrays.Last_Index (Tree.Lists) + 1;
-- Fetch list parent, if available.
List_ID_Stack.Peek
(Stack => Tree.List_Stack,
Element => List.Parent);
-- Append node to parent pointing to this list.
Node.List := New_ID;
Append_Node
(Tree => Tree,
List_ID => List.Parent,
Node => Node);
-- Add list to tree.
Append_List
(Tree => Tree,
List => List,
List_ID => New_ID);
pragma Assert (List_Arrays.Last_Index (Tree.Lists) = New_ID);
end Process_List_Open;
--
-- Close list and remove from stack.
--
procedure Process_List_Close
(Tree : in out Tree_t;
Status : in out Tree_Status_t) is
begin
if List_ID_Stack.Size (Tree.List_Stack) > 1 then
List_ID_Stack.Pop_Discard (Tree.List_Stack);
else
Status := Tree_Error_Excess_Closing_Parentheses;
end if;
end Process_List_Close;
--
-- Check for premature EOF.
--
procedure Process_EOF
(Tree : in out Tree_t;
Status : in out Tree_Status_t) is
begin
if List_ID_Stack.Size (Tree.List_Stack) > 1 then
Status := Tree_Error_Unterminated_List;
end if;
Tree.Completed := True;
end Process_EOF;
--
-- Add initial empty root list.
--
procedure Add_Root_List (Tree : in out Tree_t) is
List : List_t;
New_ID : List_ID_t;
begin
New_ID := List_ID_t'First;
-- Root list is parent of itself.
List.Parent := New_ID;
-- Add list to tree.
Append_List
(Tree => Tree,
List => List,
List_ID => New_ID);
end Add_Root_List;
--
-- Public API.
--
function Initialized
(Tree : in Tree_t) return Boolean is
begin
return Tree.Inited;
end Initialized;
function Completed
(Tree : in Tree_t) return Boolean is
begin
return Tree.Completed;
end Completed;
--
-- Initialize tree state.
--
procedure Initialize_Tree
(Tree : in out Tree_t;
Status : out Tree_Status_t) is
begin
Tree := Tree_t'
(Inited => True,
Completed => False,
List_Stack => <>,
Lists => <>,
Current_List => List_ID_t'First);
Add_Root_List (Tree);
Status := Tree_OK;
end Initialize_Tree;
--
-- Process token.
--
procedure Process_Token
(Tree : in out Tree_t;
Token : in Lex.Token_t;
Status : out Tree_Status_t) is
begin
-- Status is OK by default.
Status := Tree_OK;
case Token.Kind is
when Lex.Token_Quoted_String =>
Process_Quoted_String
(Tree => Tree,
Token => Token);
when Lex.Token_Symbol =>
Process_Symbol
(Tree => Tree,
Token => Token);
when Lex.Token_List_Open =>
Process_List_Open (Tree);
when Lex.Token_List_Close =>
Process_List_Close
(Tree => Tree,
Status => Status);
when Lex.Token_EOF =>
Process_EOF
(Tree => Tree,
Status => Status);
end case;
end Process_Token;
--
-- Node accessors.
--
function Node_Kind (Node : in Node_t) return Node_Kind_t is
begin
return Node.Kind;
end Node_Kind;
--
-- List accessors.
--
function List_Length (List : in List_t) return List_Length_t is
begin
return List_Length_t (Lists.Length (List.Nodes));
end List_Length;
end Symbex.Parse;
|
------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- ADA.CONTAINERS.HASH_TABLES.GENERIC_BOUNDED_OPERATIONS --
-- --
-- S p e c --
-- --
-- Copyright (C) 2004-2015, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- This unit was originally developed by Matthew J Heaney. --
------------------------------------------------------------------------------
-- Hash_Table_Type is used to implement hashed containers. This package
-- declares hash-table operations that do not depend on keys.
with Ada.Streams;
generic
with package HT_Types is
new Generic_Bounded_Hash_Table_Types (<>);
use HT_Types, HT_Types.Implementation;
with function Hash_Node (Node : Node_Type) return Hash_Type;
with function Next (Node : Node_Type) return Count_Type;
with procedure Set_Next
(Node : in out Node_Type;
Next : Count_Type);
package Ada.Containers.Hash_Tables.Generic_Bounded_Operations is
pragma Pure;
function Index
(Buckets : Buckets_Type;
Node : Node_Type) return Hash_Type;
pragma Inline (Index);
-- Uses the hash value of Node to compute its Buckets array index
function Index
(HT : Hash_Table_Type'Class;
Node : Node_Type) return Hash_Type;
pragma Inline (Index);
-- Uses the hash value of Node to compute its Hash_Table buckets array
-- index.
function Checked_Index
(Hash_Table : aliased in out Hash_Table_Type'Class;
Node : Count_Type) return Hash_Type;
-- Calls Index, but also locks and unlocks the container, per AI05-0022, in
-- order to detect element tampering by the generic actual Hash function.
generic
with function Find
(HT : Hash_Table_Type'Class;
Key : Node_Type) return Boolean;
function Generic_Equal (L, R : Hash_Table_Type'Class) return Boolean;
-- Used to implement hashed container equality. For each node in hash table
-- L, it calls Find to search for an equivalent item in hash table R. If
-- Find returns False for any node then Generic_Equal terminates
-- immediately and returns False. Otherwise if Find returns True for every
-- node then Generic_Equal returns True.
procedure Clear (HT : in out Hash_Table_Type'Class);
-- Deallocates each node in hash table HT. (Note that it only deallocates
-- the nodes, not the buckets array.) Program_Error is raised if the hash
-- table is busy.
procedure Delete_Node_At_Index
(HT : in out Hash_Table_Type'Class;
Indx : Hash_Type;
X : Count_Type);
-- Delete a node whose bucket position is known. extracted from following
-- subprogram, but also used directly to remove a node whose element has
-- been modified through a key_preserving reference: in that case we cannot
-- use the value of the element precisely because the current value does
-- not correspond to the hash code that determines its bucket.
procedure Delete_Node_Sans_Free
(HT : in out Hash_Table_Type'Class;
X : Count_Type);
-- Removes node X from the hash table without deallocating the node
generic
with procedure Set_Element (Node : in out Node_Type);
procedure Generic_Allocate
(HT : in out Hash_Table_Type'Class;
Node : out Count_Type);
-- Claim a node from the free store. Generic_Allocate first
-- calls Set_Element on the potential node, and then returns
-- the node's index as the value of the Node parameter.
procedure Free
(HT : in out Hash_Table_Type'Class;
X : Count_Type);
-- Return a node back to the free store, from where it had
-- been previously claimed via Generic_Allocate.
function First (HT : Hash_Table_Type'Class) return Count_Type;
-- Returns the head of the list in the first (lowest-index) non-empty
-- bucket.
function Next
(HT : Hash_Table_Type'Class;
Node : Count_Type) return Count_Type;
-- Returns the node that immediately follows Node. This corresponds to
-- either the next node in the same bucket, or (if Node is the last node in
-- its bucket) the head of the list in the first non-empty bucket that
-- follows.
generic
with procedure Process (Node : Count_Type);
procedure Generic_Iteration (HT : Hash_Table_Type'Class);
-- Calls Process for each node in hash table HT
generic
use Ada.Streams;
with procedure Write
(Stream : not null access Root_Stream_Type'Class;
Node : Node_Type);
procedure Generic_Write
(Stream : not null access Root_Stream_Type'Class;
HT : Hash_Table_Type'Class);
-- Used to implement the streaming attribute for hashed containers. It
-- calls Write for each node to write its value into Stream.
generic
use Ada.Streams;
with function New_Node (Stream : not null access Root_Stream_Type'Class)
return Count_Type;
procedure Generic_Read
(Stream : not null access Root_Stream_Type'Class;
HT : out Hash_Table_Type'Class);
-- Used to implement the streaming attribute for hashed containers. It
-- first clears hash table HT, then populates the hash table by calling
-- New_Node for each item in Stream.
end Ada.Containers.Hash_Tables.Generic_Bounded_Operations;
|
with Ada.Text_IO;
with Interfaces; use Interfaces;
with HAL;
with Lv; use Lv;
with Lv.Color;
with Lv.Hal.Disp; use Lv.Hal.Disp;
with Lv.Hal.Indev; use Lv.Hal.Indev;
with Lv.Indev;
with Lv.Objx;
with Lv.Objx.Img;
with Lv.Vdb;
with BB_Pico_Bsp.LCD;
with BB_Pico_Bsp.Keyboard;
with BB_Pico_Bsp.Touch;
with BBQ10KBD;
package body BB_Pico_Bsp.LVGL_Backend is
LV_Disp_Drv : aliased Disp_Drv_T;
LV_Disp : Disp_T;
LV_Indev_Pointer_Drv : aliased Indev_Drv_T;
LV_Indev_Keypad_Drv : aliased Indev_Drv_T;
LV_Indev_Keypad : Indev_T;
LV_Indev_Pointer : Indev_T;
Cursor_Obj : Lv.Objx.Img.Instance;
Pointer : Indev_Data_T;
function Read_Pointer (Data : access Indev_Data_T) return U_Bool
with Convention => C;
function Read_Keypad (Data : access Indev_Data_T) return U_Bool
with Convention => C;
procedure Disp_Flush
(X1 : Int32_T;
Y1 : Int32_T;
X2 : Int32_T;
Y2 : Int32_T;
Color : access constant Color_Array)
with Convention => C;
procedure Disp_Fill
(X1 : Int32_T;
Y1 : Int32_T;
X2 : Int32_T;
Y2 : Int32_T;
Color : Lv.Color.Color_T)
with Convention => C;
procedure Disp_Map
(X1 : Int32_T;
Y1 : Int32_T;
X2 : Int32_T;
Y2 : Int32_T;
Color : access constant Color_Array)
with Convention => C;
----------------
-- Initialize --
----------------
procedure Initialize (Enable_Pointer : Boolean := True) is
Mouse_Cursor_Icon : Integer;
pragma Import (C, Mouse_Cursor_Icon, "mouse_cursor_icon");
begin
Lv.Hal.Disp.Init_Drv (LV_Disp_Drv'Access);
LV_Disp_Drv.Disp_Flush := Disp_Flush'Access;
LV_Disp_Drv.Disp_Fill := Disp_Fill'Access;
LV_Disp_Drv.Disp_Map := Disp_Map'Access;
LV_Disp := Lv.Hal.Disp.Register (LV_Disp_Drv'Access);
Lv.Hal.Disp.Set_Active (LV_Disp);
Pointer.Union.Point := (0, 0);
Pointer.State := Lv.Hal.Indev.State_Rel;
Lv.Hal.Indev.Init_Drv (LV_Indev_Keypad_Drv'Access);
LV_Indev_Keypad_Drv.Read := Read_Keypad'Access;
LV_Indev_Keypad_Drv.C_Type := Lv.Hal.Indev.Type_Keypad;
LV_Indev_Keypad := Lv.Hal.Indev.Register (LV_Indev_Keypad_Drv'Access);
Lv.Hal.Indev.Init_Drv (LV_Indev_Pointer_Drv'Access);
LV_Indev_Pointer_Drv.Read := Read_Pointer'Access;
LV_Indev_Pointer_Drv.C_Type := Lv.Hal.Indev.Type_Pointer;
LV_Indev_Pointer := Lv.Hal.Indev.Register (LV_Indev_Pointer_Drv'Access);
if Enable_Pointer then
Cursor_Obj := Lv.Objx.Img.Create (Lv.Objx.Scr_Act, Lv.Objx.No_Obj);
Lv.Objx.Img.Set_Src (Cursor_Obj, Mouse_Cursor_Icon'Address);
Lv.Indev.Set_Cursor (LV_Indev_Pointer, Cursor_Obj);
end if;
end Initialize;
------------------
-- Keypad_Indev --
------------------
function Keypad_Indev return Lv.Hal.Indev.Indev_T
is (LV_Indev_Keypad);
------------------
-- Read_Pointer --
------------------
function Read_Pointer (Data : access Indev_Data_T) return U_Bool is
begin
Pointer.State := Lv.Hal.Indev.State_Rel;
for Elt of BB_Pico_Bsp.Touch.Get_All_Touch_Points loop
if Elt.Weight /= 0 then
Pointer.Union.Point.X := Integer_16 (Elt.X);
Pointer.Union.Point.Y := Integer_16 (Elt.Y);
Pointer.State := Lv.Hal.Indev.State_Pr;
end if;
end loop;
Data.all := Pointer;
return 0;
end Read_Pointer;
-----------------
-- Read_Keypad --
-----------------
function Read_Keypad (Data : access Indev_Data_T) return U_Bool is
use BBQ10KBD;
State : Key_State;
begin
loop
State := BB_Pico_Bsp.Keyboard.Key_FIFO_Pop;
case State.Kind is
when Error =>
return 0; -- No more events
when Held_Pressed =>
null; -- LVGL doesn't have a held pressed event
when others =>
declare
Pressed : constant Boolean := State.Kind = BBQ10KBD.Pressed;
begin
case State.Code is
when Keyboard.KEY_JOY_UP =>
Data.Union.Key := Lv.LV_KEY_UP;
when Keyboard.KEY_JOY_DOWN =>
Data.Union.Key := Lv.LV_KEY_DOWN;
when Keyboard.KEY_JOY_LEFT =>
Data.Union.Key := Lv.LV_KEY_LEFT;
when Keyboard.KEY_JOY_RIGHT =>
Data.Union.Key := Lv.LV_KEY_RIGHT;
when Keyboard.KEY_JOY_CENTER =>
Data.Union.Key := Lv.LV_KEY_ENTER;
when Keyboard.KEY_BTN_LEFT1 =>
Data.Union.Key := Lv.LV_KEY_PREV;
when Keyboard.KEY_BTN_LEFT2 =>
Data.Union.Key := Lv.LV_KEY_HOME;
when Keyboard.KEY_BTN_RIGHT1 =>
Data.Union.Key := Lv.LV_KEY_BACKSPACE;
when Keyboard.KEY_BTN_RIGHT2 =>
Data.Union.Key := Lv.LV_KEY_NEXT;
when others =>
Data.Union.Key := Unsigned_32 (State.Code);
end case;
Data.State := (if Pressed
then Lv.Hal.Indev.State_Pr
else Lv.Hal.Indev.State_Rel);
return 1;
end;
end case;
end loop;
end Read_Keypad;
----------------
-- Disp_Flush --
----------------
procedure Disp_Flush
(X1 : Int32_T;
Y1 : Int32_T;
X2 : Int32_T;
Y2 : Int32_T;
Color : access constant Color_Array)
is
Width : constant Natural := LCD.Width;
Height : constant Natural := LCD.Height;
Len : constant Int32_T := (X2 - X1 + 1) * (Y2 - Y1 + 1);
begin
LCD.Wait_For_DMA;
if X2 < 0
or else
Y2 < 0
or else
X1 > Int32_T (Width - 1)
or else
Y1 > Int32_T (Height - 1)
then
Lv.Vdb.Flush_Ready;
return;
end if;
LCD.Send_Pixels (Natural (X1),
Natural (Y1),
Natural (X2),
Natural (Y2),
Color.all'Address,
HAL.UInt32 (Len),
Blocking => False);
Lv.Vdb.Flush_Ready;
end Disp_Flush;
---------------
-- Disp_Fill --
---------------
procedure Disp_Fill
(X1 : Int32_T;
Y1 : Int32_T;
X2 : Int32_T;
Y2 : Int32_T;
Color : Lv.Color.Color_T)
is
C : constant Uint16_T := Lv.Color.Color_To16 (Color);
pragma Unreferenced (C);
Width : constant Natural := LCD.Width;
Height : constant Natural := LCD.Height;
Len : constant Int32_T := (X2 - X1) * (Y2 - Y1);
pragma Unreferenced (Len);
begin
if X2 < 0
or else
Y2 < 0
or else
X1 > Int32_T (Width - 1)
or else
Y1 > Int32_T (Height - 1)
then
Lv.Vdb.Flush_Ready;
return;
end if;
Lv.Vdb.Flush_Ready;
end Disp_Fill;
--------------
-- Disp_Map --
--------------
procedure Disp_Map
(X1 : Int32_T;
Y1 : Int32_T;
X2 : Int32_T;
Y2 : Int32_T;
Color : access constant Color_Array)
is
begin
Ada.Text_IO.Put_Line ("X1:" & X1'Img);
Ada.Text_IO.Put_Line ("Y1:" & Y1'Img);
Ada.Text_IO.Put_Line ("X2:" & X2'Img);
Ada.Text_IO.Put_Line ("Y2:" & Y2'Img);
Ada.Text_IO.Put_Line ("Length:" & Color'Length'Img);
Ada.Text_IO.Put_Line ("First:" & Color'First'Img);
end Disp_Map;
end BB_Pico_Bsp.LVGL_Backend;
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Containers.Doubly_Linked_Lists;
procedure Pythagore_Set is
type Triangles is array (1 .. 3) of Positive;
package Triangle_Lists is new Ada.Containers.Doubly_Linked_Lists (
Triangles);
use Triangle_Lists;
function Find_List (Upper_Bound : Positive) return List is
L : List := Empty_List;
begin
for A in 1 .. Upper_Bound loop
for B in A + 1 .. Upper_Bound loop
for C in B + 1 .. Upper_Bound loop
if ((A * A + B * B) = C * C) then
Append (L, (A, B, C));
end if;
end loop;
end loop;
end loop;
return L;
end Find_List;
Triangle_List : List;
C : Cursor;
T : Triangles;
begin
Triangle_List := Find_List (Upper_Bound => 20);
C := First (Triangle_List);
while Has_Element (C) loop
T := Element (C);
Put
("(" &
Integer'Image (T (1)) &
Integer'Image (T (2)) &
Integer'Image (T (3)) &
") ");
Next (C);
end loop;
end Pythagore_Set;
|
generic
Size : Positive;
type Item is private;
package Ringbuffers is
type Ringbuffer is tagged private;
procedure Write (Self : in out Ringbuffer; e : Item);
function Read (Self : in out Ringbuffer) return Item;
function Is_Empty (Self : Ringbuffer) return Boolean;
private
type Item_Array is array (1 .. Size) of Item;
pragma Volatile (Item_Array);
type Ringbuffer is tagged record
Read_Index : Positive := 1;
Write_Index : Positive := 1;
Items : Item_Array;
end record;
pragma Volatile (Ringbuffer);
end Ringbuffers;
|
with HAL; use HAL;
with HiFive1.LEDs; use HiFive1.LEDs;
with FE310;
with FE310.CLINT;
with FE310.Time; use FE310.Time;
with Interfaces; use Interfaces;
with IO;
-- Create dependencies to force recompilation of the whole libraryw
pragma Warnings (Off);
with SPARKNaCl; use SPARKNaCl;
with SPARKNaCl.Core;
with SPARKNaCl.Cryptobox;
with SPARKNaCl.Hashing;
with SPARKNaCl.MAC;
with SPARKNaCl.Scalar;
with SPARKNaCl.Secretbox;
with SPARKNaCl.Sign; use SPARKNaCl.Sign;
with SPARKNaCl.Sign.Utils; use SPARKNaCl.Sign.Utils;
with SPARKNaCl.Stream;
with SPARKNaCl.Count;
with TweetNaCl_API;
with RISCV.CSR; use RISCV.CSR;
with FE310.Performance_Monitor; use FE310.Performance_Monitor;
procedure TSize is
subtype U64 is Unsigned_64;
M : constant Byte_Seq (0 .. 255) := (0 => 16#55#, others => 16#aa#);
SK : Signing_SK;
SM1 : Byte_Seq (0 .. 319) := (others => 0);
SM2 : Byte_Seq (0 .. 319) := (others => 0);
My_SK : constant Bytes_64 :=
(16#56#, 16#89#, 16#60#, 16#72#, 16#D7#, 16#E1#, 16#B5#, 16#35#,
16#2B#, 16#12#, 16#B6#, 16#FC#, 16#69#, 16#94#, 16#F3#, 16#76#,
16#A7#, 16#5C#, 16#42#, 16#DF#, 16#70#, 16#1E#, 16#AC#, 16#F0#,
16#A0#, 16#EF#, 16#30#, 16#C6#, 16#A1#, 16#D8#, 16#27#, 16#F6#,
16#D6#, 16#40#, 16#DA#, 16#F4#, 16#0B#, 16#0B#, 16#35#, 16#EF#,
16#03#, 16#25#, 16#5B#, 16#EF#, 16#A3#, 16#4E#, 16#31#, 16#D4#,
16#35#, 16#A1#, 16#A2#, 16#E2#, 16#FF#, 16#AA#, 16#EA#, 16#72#,
16#82#, 16#82#, 16#D2#, 16#D0#, 16#93#, 16#6C#, 16#19#, 16#10#);
T1, T2 : UInt64;
Total_Time : Unsigned_64;
CPU_Hz1, CPU_Hz2 : UInt32;
procedure Report;
procedure Tweet_Sign (SM : out Byte_Seq;
M : in Byte_Seq;
SK : in Signing_SK);
procedure Tweet_Sign (SM : out Byte_Seq;
M : in Byte_Seq;
SK : in Signing_SK)
is
SMLen : Unsigned_64;
begin
TweetNaCl_API.Crypto_Sign (SM,
SMLen,
M,
M'Length,
SK);
end Tweet_Sign;
procedure Report
is
begin
IO.Put ("Total: ");
IO.Put (UInt64 (Total_Time));
IO.Put_Line (" cycles");
end Report;
begin
CPU_Hz1 := FE310.CPU_Frequency;
-- The SPI flash clock divider should be as small as possible to increase
-- the execution speed of instructions that are not yet in the instruction
-- cache.
FE310.Set_SPI_Flash_Clock_Divider (2);
-- Load the internal oscillator factory calibration to be sure it
-- oscillates at a known frequency.
FE310.Load_Internal_Oscilator_Calibration;
-- Use the HiFive1 16 MHz crystal oscillator which is more acurate than the
-- internal oscillator.
FE310.Use_Crystal_Oscillator;
HiFive1.LEDs.Initialize;
CPU_Hz2 := FE310.CPU_Frequency;
IO.Put_Line ("CPU Frequency reset was: ", U64 (CPU_Hz1));
IO.Put_Line ("CPU Frequency now is: ", U64 (CPU_Hz2));
Construct (My_SK, SK);
FE310.Performance_Monitor.Set_Commit_Events (3, No_Commit_Events);
FE310.Performance_Monitor.Set_Commit_Events (4, No_Commit_Events);
Turn_On (Red_LED);
T1 := FE310.CLINT.Machine_Time;
T2 := FE310.CLINT.Machine_Time;
IO.Put_Line ("Null timing test:", U64 (T2 - T1));
T1 := Mcycle.Read;
Delay_S (1);
T2 := Mcycle.Read;
IO.Put_Line ("One second test (CYCLE): ", U64 (T2 - T1));
T1 := Minstret.Read;
Delay_S (1);
T2 := Minstret.Read;
IO.Put_Line ("One second test (INSTRET):", U64 (T2 - T1));
T1 := FE310.CLINT.Machine_Time;
Delay_S (1);
T2 := FE310.CLINT.Machine_Time;
IO.Put_Line ("One second test (CLINT): ", U64 (T2 - T1));
IO.Put_Line ("SPARKNaCl.Sign test");
SPARKNaCl.Count.Reset;
T1 := Mcycle.Read;
SPARKNaCl.Sign.Sign (SM1, M, SK);
T2 := Mcycle.Read;
Total_Time := Unsigned_64 (T2 - T1);
Report;
Turn_Off (Red_LED);
Turn_On (Green_LED);
IO.New_Line;
IO.Put_Line ("TweetNaCl.Sign test");
TweetNaCl_API.Reset;
T1 := Mcycle.Read;
Tweet_Sign (SM2, M, SK);
T2 := Mcycle.Read;
Total_Time := Unsigned_64 (T2 - T1);
Report;
Turn_Off (Green_LED);
-- Blinky!
loop
Turn_On (Red_LED);
Delay_S (1);
Turn_Off (Red_LED);
Turn_On (Green_LED);
Delay_S (1);
Turn_Off (Green_LED);
Turn_On (Blue_LED);
Delay_S (1);
Turn_Off (Blue_LED);
end loop;
end TSize;
|
with
ada.unchecked_Conversion;
package openGL.Culler.frustum
--
-- Provides a frustrum culler.
--
is
type Item is new Culler.Item with private;
type View is access all Item'Class;
---------
--- Forge
--
procedure define (Self : in out Item);
--------------
--- Attributes
--
overriding
procedure add (Self : in out Item; the_Visual : in Visual.view);
overriding
procedure rid (Self : in out Item; the_Visual : in Visual.view);
overriding
function object_Count (Self : in Item) return Natural;
overriding
function cull (Self : in Item; the_Visuals : in Visual.views;
camera_Frustum : in openGL.frustum.Plane_array;
camera_Site : in Vector_3) return Visual.views;
function vanish_point_size_Min (Self : in Item'Class) return Real;
procedure vanish_point_size_Min_is (Self : in out Item'Class; Now : in Real);
--
-- Visuals whose projected size falls below this minimum will not be displayed.
private
type Item is new Culler.item with
record
countDown : Natural := 0;
frame_Count : Natural := 0;
vanish_point_size_Min : safe_Real;
end record;
end openGL.Culler.frustum;
|
-- C74206A.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT IF A COMPOSITE TYPE IS DECLARED IN THE PACKAGE AS A
-- PRIVATE TYPE AND CONTAINS A COMPONENT OF THE PRIVATE TYPE, OPERATIONS
-- OF THE COMPOSITE TYPE WHICH DO NOT DEPEND ON CHARACTERISTICS OF THE
-- PRIVATE TYPE ARE AVAILABLE AFTER THE FULL DECLARATION OF THE PRIVATE
-- TYPE, BUT BEFORE THE EARLIEST PLACE WITHIN THE IMMEDIATE SCOPE OF THE
-- DECLARATION OF THE COMPOSITE TYPE THAT IS AFTER THE FULL DECLARATION
-- OF THE PRIVATE TYPE. IN PARTICULAR, CHECK FOR THE FOLLOWING :
-- 'FIRST, 'LAST, 'RANGE, AND 'LENGTH FOR ARRAY TYPES
-- SELECTED COMPONENTS FOR DISCRIMINANTS AND COMPONENTS OF RECORDS
-- INDEXED COMPONENTS AND SLICES FOR ARRAYS
-- DSJ 5/5/83
-- JBG 3/8/84
WITH REPORT;
PROCEDURE C74206A IS
USE REPORT;
BEGIN
TEST("C74206A", "CHECK THAT ADDITIONAL OPERATIONS FOR "
& "COMPOSITE TYPES OF PRIVATE TYPES ARE "
& "AVAILABLE AT THE EARLIEST PLACE AFTER THE "
& "FULL DECLARATION OF THE PRIVATE TYPE EVEN "
& "IF BEFORE THE EARLIEST PLACE WITHIN THE "
& "IMMEDIATE SCOPE OF THE COMPOSITE TYPE");
DECLARE
PACKAGE PACK1 IS
TYPE P1 IS PRIVATE;
TYPE LP1 IS LIMITED PRIVATE;
PACKAGE PACK_LP IS
TYPE LP_ARR IS ARRAY (1 .. 2) OF LP1;
TYPE LP_REC (D : INTEGER) IS
RECORD
C1, C2 : LP1;
END RECORD;
END PACK_LP;
PACKAGE PACK2 IS
TYPE ARR IS ARRAY ( 1 .. 2 ) OF P1;
TYPE REC (D : INTEGER) IS
RECORD
C1, C2 : P1;
END RECORD;
END PACK2;
PRIVATE
TYPE P1 IS NEW BOOLEAN;
TYPE LP1 IS NEW BOOLEAN;
END PACK1;
PACKAGE BODY PACK1 IS
USE PACK_LP;
USE PACK2;
A1 : ARR;
L1 : LP_ARR;
N1 : INTEGER := ARR'FIRST; -- LEGAL
N2 : INTEGER := ARR'LAST; -- LEGAL
N3 : INTEGER := A1'LENGTH; -- LEGAL
N4 : INTEGER := LP_ARR'FIRST; -- LEGAL
N5 : INTEGER := LP_ARR'LAST; -- LEGAL
N6 : INTEGER := L1'LENGTH; -- LEGAL
B1 : BOOLEAN := 1 IN ARR'RANGE; -- LEGAL
B2 : BOOLEAN := 5 IN LP_ARR'RANGE; -- LEGAL
N7 : INTEGER := A1(1)'SIZE; -- LEGAL: A1(1)
N8 : INTEGER := L1(2)'SIZE; -- LEGAL: L1(2)
R1 : REC(1);
Q1 : LP_REC(1);
K1 : INTEGER := R1.D'SIZE; -- LEGAL: R1.D
K2 : INTEGER := R1.C1'SIZE; -- LEGAL: R1.C1
K3 : INTEGER := Q1.D'SIZE; -- LEGAL: Q1.D
K4 : INTEGER := Q1.C2'SIZE; -- LEGAL: Q1.C2
BEGIN
IF N1 /= 1 OR N4 /= 1 THEN
FAILED ("WRONG VALUE FOR 'FIRST");
END IF;
IF N2 /= 2 OR N5 /= 2 THEN
FAILED ("WRONG VALUE FOR 'LAST");
END IF;
IF N3 /= 2 OR N6 /= 2 THEN
FAILED ("WRONG VALUE FOR 'LENGTH");
END IF;
IF B1 /= TRUE OR B2 /= FALSE THEN
FAILED ("INCORRECT RANGE TEST");
END IF;
IF N7 /= N8 THEN
FAILED ("INCORRECT INDEXED COMPONENTS");
END IF;
IF K1 /= K3 OR K2 /= K4 THEN
FAILED ("INCORRECT COMPONENT SELECTION");
END IF;
END PACK1;
BEGIN
NULL;
END;
RESULT;
END C74206A;
|
-- Copyright (c) 2021 Devin Hill
-- zlib License -- see LICENSE for details.
with GBA.Interrupts;
use GBA.Interrupts;
with GBA.Numerics;
use GBA.Numerics;
with GBA.Memory;
use GBA.Memory;
with Interfaces;
use Interfaces;
with GBA.Display.Backgrounds;
use GBA.Display.Backgrounds;
with GBA.Display.Objects;
use GBA.Display.Objects;
with GBA.BIOS.Generic_Interface;
generic
with package Raw is new GBA.BIOS.Generic_Interface (<>);
package GBA.BIOS.Extended_Interface is
-- Reexport functionality from Raw interface --
-- Marked Inline_Always so that link-time optimization
-- takes place and reduces these to a pure `svc` instruction.
-- This eliminates the overhead of a function call to BIOS routines.
-- Unfortunately, due to the numeric code of the interrupts
-- being different in ARM and THUMB mode, we still need to have
-- two versions of this package. We share as much as possible by
-- making them instances of this same generic package.
procedure Soft_Reset renames Raw.Soft_Reset with Inline_Always;
procedure Hard_Reset renames Raw.Hard_Reset with Inline_Always;
procedure Halt renames Raw.Halt with Inline_Always;
procedure Stop renames Raw.Stop with Inline_Always;
procedure Register_RAM_Reset (Flags : Register_RAM_Reset_Flags)
renames Raw.Register_RAM_Reset with Inline_Always;
procedure Wait_For_Interrupt (New_Only : Boolean; Wait_For : Interrupt_Flags)
renames Raw.Wait_For_Interrupt with Inline_Always;
procedure Wait_For_VBlank
renames Raw.Wait_For_VBlank with Inline_Always;
function Div_Mod (N, D : Integer) return Long_Long_Integer
renames Raw.Div_Mod with Inline_Always;
function Div_Mod_Arm (D, N : Integer) return Long_Long_Integer
renames Raw.Div_Mod_Arm with Inline_Always;
function Sqrt (N : Unsigned_32) return Unsigned_16
renames Raw.Sqrt with Inline_Always;
function Arc_Tan (X, Y : Fixed_2_14) return Radians_16
renames Raw.Arc_Tan with Inline_Always;
procedure Cpu_Set (S, D : Address; Config : Cpu_Set_Config)
renames Raw.Cpu_Set with Inline_Always;
procedure Cpu_Fast_Set (S, D : Address; Config : Cpu_Set_Config)
renames Raw.Cpu_Fast_Set with Inline_Always;
function Bios_Checksum return Unsigned_32
renames Raw.Bios_Checksum with Inline_Always;
procedure Affine_Set_Ext (Parameters : Address; Transform : Address; Count : Integer)
renames Raw.Affine_Set_Ext with Inline_Always;
procedure Affine_Set (Parameters : Address; Transform : Address; Count, Stride : Integer)
renames Raw.Affine_Set with Inline_Always;
-- More convenient interfaces to Raw functions --
-- Most routines should be Inline_Always, and delegate to the underlying Raw routine.
-- Any functionality which needs to compose results from multiple BIOS calls
-- should be external to this package, and depend on it either by being generic,
-- or importing the Arm or Thumb instantiations as required.
procedure Register_RAM_Reset
( Clear_External_WRAM
, Clear_Internal_WRAM
, Clear_Palette
, Clear_VRAM
, Clear_OAM
, Reset_SIO_Registers
, Reset_Sound_Registers
, Reset_Other_Registers
: Boolean := False)
with Inline_Always;
procedure Wait_For_Interrupt (Wait_For : Interrupt_Flags)
with Inline_Always;
function Divide (Num, Denom : Integer) return Integer
with Pure_Function, Inline_Always;
function Remainder (Num, Denom : Integer) return Integer
with Pure_Function, Inline_Always;
procedure Div_Mod (Num, Denom : Integer; Quotient, Remainder : out Integer)
with Inline_Always;
procedure Cpu_Set
( Source, Dest : Address;
Unit_Count : Cpu_Set_Unit_Count;
Mode : Cpu_Set_Mode;
Unit_Size : Cpu_Set_Unit_Size )
with Inline_Always;
procedure Cpu_Fast_Set
( Source, Dest : Address;
Word_Count : Cpu_Set_Unit_Count;
Mode : Cpu_Set_Mode )
with Inline_Always;
--
-- Single-matrix affine transform computation
--
procedure Affine_Set
( Parameters : Affine_Parameters;
Transform : out Affine_Transform_Matrix )
with Inline_Always;
procedure Affine_Set
( Parameters : Affine_Parameters;
Transform : OBJ_Affine_Transform_Index )
with Inline_Always;
procedure Affine_Set_Ext
( Parameters : Affine_Parameters_Ext;
Transform : out BG_Transform_Info )
with Inline_Always;
--
-- Multiple-matrix affine transform computation
--
type OBJ_Affine_Parameter_Array is
array (OBJ_Affine_Transform_Index range <>) of Affine_Parameters;
procedure Affine_Set (Parameters : OBJ_Affine_Parameter_Array)
with Inline_Always;
type BG_Affine_Parameter_Ext_Array is
array (Affine_BG_ID range <>) of Affine_Parameters_Ext;
procedure Affine_Set_Ext (Parameters : BG_Affine_Parameter_Ext_Array)
with Inline_Always;
type Affine_Parameter_Array is
array (Natural range <>) of Affine_Parameters;
type Affine_Transform_Array is
array (Natural range <>) of Affine_Transform_Matrix;
procedure Affine_Set
( Parameters : Affine_Parameter_Array;
Transforms : out Affine_Transform_Array )
with Inline_Always;
type Affine_Parameter_Ext_Array is
array (Natural range <>) of Affine_Parameters_Ext;
procedure Affine_Set_Ext
( Parameters : Affine_Parameter_Ext_Array;
Transforms : out BG_Transform_Info_Array )
with Inline_Always;
end GBA.BIOS.Extended_Interface;
|
--------------------------
with Text_IO;
with Formatter;
procedure Formatter_Test is
-- ++
--
-- FUNCTIONAL DESCRIPTION:
--
-- This is a test driver program for the generic Formatter package.
--
-- FORMAL PARAMETERS:
--
-- None.
--
-- DESIGN:
--
-- This test driver contains a number of calls to the Formatter Put
-- procedure with a format string and data values. Each test is identified
-- by a test number and a description of the test.
--
-- EXCEPTIONS:
--
-- No exceptions are declared in this test driver, although any exception
-- raised by Formatter.Put are handled.
--
-- KEYWORDS:
--
-- Test Driver.
--
-- --
type Days_of_Week is (Sunday,
Monday,
Tuesday,
Wednesday,
Thursday,
Friday,
Saturday);
package Ada_Format is
new Formatter (Enumerated => Days_of_Week);
use Ada_Format; -- Direct visibility of F conversion functions
Name : String(1..6);
Integer_Value : Positive := 66;
Real_Value : Float := 3.1415927;
Character_Value : Character := 'x';
Enumeration_Value : Days_of_Week := Thursday;
begin -- Formatter_Test
Test_1:
begin
Name := "Test_1";
Ada_Format.Put("%s:\tDefault Formats\n", F(Name));
Ada_Format.Put("Integer_Value = '%i'\n", F(Integer_Value));
Ada_Format.Put("Real_Value = '%f'\n", F(Real_Value));
Ada_Format.Put("Scientific_Value = '%e'\n", F(Real_Value));
Ada_Format.Put("Character_Value = '%c'\n", F(Character_Value));
Ada_Format.Put("Enumeration_Value = '%s'\n\n", F(Enumeration_Value));
exception
when others =>
Text_IO.Put_Line("Test_1: Unknown exception raised.");
Text_IO.New_Line;
end Test_1;
Test_2:
begin
Name := "Test_2";
Ada_Format.Put("%s:\t" &
"Wide-Field Formats\n" &
"Integer_Value = '%15i'\n" &
"Real_Value = '%15f'\n" &
"Scientific_Value = '%15e'\n" &
"Character_Value = '%15c'\n" &
"Enumeration_Value = '%15s'\n\n",
(F(Name),
F(Integer_Value),
F(Real_Value),
F(Real_Value),
F(Character_Value),
F(Enumeration_Value)));
exception
when others =>
Text_IO.Put_Line("Test_2: Unknown exception raised.");
Text_IO.New_Line;
end Test_2;
Test_3:
begin
Name := "Test_3";
Ada_Format.Put("%s:\t" &
"Wide-Field Left-Justified Formats\n" &
"Integer_Value = '%-15i'\n" &
"Real_Value = '%-15f'\n" &
"Scientific_Value = '%-15e'\n" &
"Character_Value = '%-15c'\n" &
"Enumeration_Value = '%-15s'\n\n",
(F(Name),
F(Integer_Value),
F(Real_Value),
F(Real_Value),
F(Character_Value),
F(Enumeration_Value)));
exception
when others =>
Text_IO.Put_Line("Test_3: Unknown exception raised.");
Text_IO.New_Line;
end Test_3;
Test_4:
begin
Name := "Test_4";
Ada_Format.Put("%s:\tDefault Formats, Zero-Fill\n", F(Name));
Ada_Format.Put("Integer_Value = '%0i'\n", F(Integer_Value));
Ada_Format.Put("Real_Value = '%0f'\n", F(Real_Value));
Ada_Format.Put("Scientific_Value = '%0e'\n\n", F(Real_Value));
exception
when others =>
Text_IO.Put_Line("Test_4: Unknown exception raised.");
Text_IO.New_Line;
end Test_4;
Test_5:
begin
Name := "Test_5";
Ada_Format.Put("%s:\t" &
"Specified Field Width, Non-Decimal Bases\n" &
"Integer Value = '%4i'\n" &
"Hexadecimal Value = '%4x'\n" &
"Octal Value = '%4o'\n\n",
(F(Name),
F(Integer_Value),
F(Integer_Value),
F(Integer_Value)));
exception
when others =>
Text_IO.Put_Line("Test_5: Unknown exception raised.");
Text_IO.New_Line;
end Test_5;
Test_6:
begin
Name := "Test_6";
Ada_Format.Put("%s:\t" &
"Precision Formats\n" &
"Integer_Value = '%15.4i'\n" &
"Real_Value = '%15.4f'\n" &
"Scientific_Value = '%15.4e'\n" &
"String_Value = '%15.6s'\n\n",
(F(Name),
F(Integer_Value),
F(Real_Value),
F(Real_Value),
F(Name)));
exception
when others =>
Text_IO.Put_Line("Test_6: Unknown exception raised.");
Text_IO.New_Line;
end Test_6;
Test_7:
begin
Name := "Test_7";
Ada_Format.Put("%s:\t" &
"Incorrect Field Widths\n" &
"Integer_Value = '%1i'\n" &
"Real_Value = '%2.1f'\n" &
"Scientific_Value = '%3.2e'\n" &
"String_Value = '%4s'\n" &
"Unknown Format = '%+02,7z'\n\n",
(F(Name),
F(Integer_Value),
F(Real_Value),
F(Real_Value),
F(Name),
F(25)));
exception
when others =>
Text_IO.Put_Line("Test_7: Unknown exception raised.");
Text_IO.New_Line;
end Test_7;
end Formatter_Test;
-----------------------------
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . F I L E _ I O --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2006, 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 package provides support for the routines described in (RM A.8.2)
-- which are common to Text_IO, Direct_IO, Sequential_IO and Stream_IO.
with Interfaces.C_Streams;
with System.File_Control_Block;
package System.File_IO is
package FCB renames System.File_Control_Block;
package ICS renames Interfaces.C_Streams;
---------------------
-- File Management --
---------------------
procedure Open
(File_Ptr : in out FCB.AFCB_Ptr;
Dummy_FCB : FCB.AFCB'Class;
Mode : FCB.File_Mode;
Name : String;
Form : String;
Amethod : Character;
Creat : Boolean;
Text : Boolean;
C_Stream : ICS.FILEs := ICS.NULL_Stream);
-- This routine is used for both Open and Create calls:
--
-- File_Ptr is the file type, which must be null on entry
-- (i.e. the file must be closed before the call).
--
-- Dummy_FCB is a default initialized file control block of appropriate
-- type. Note that the tag of this record indicates the type and length
-- of the control block. This control block is used only for the purpose
-- of providing the controlling argument for calling the write version
-- of Allocate_AFCB. It has no other purpose, and its fields are never
-- read or written.
--
-- Mode is the required mode
--
-- Name is the file name, with a null string indicating that a temporary
-- file is to be created (only permitted in create mode, not open mode)
--
-- Creat is True for a create call, and false for an open call
--
-- Text is set True to open the file in text mode (w+t or r+t) instead
-- of the usual binary mode open (w+b or r+b).
--
-- Form is the form string given in the open or create call, this is
-- stored in the AFCB, but otherwise is not used by this or any other
-- routine in this unit (except Form which retrieves the original value)
--
-- Amethod indicates the access method
--
-- D = Direct_IO
-- Q = Sequential_IO
-- S = Stream_IO
-- T = Text_IO
-- W = Wide_Text_IO
--
-- C_Stream is left at its default value for the normal case of an
-- Open or Create call as defined in the RM. The only time this is
-- non-null is for the Open call from Ada.xxx_IO.C_Streams.Open.
--
-- On return, if the open/create succeeds, then the fields of File are
-- filled in, and this value is copied to the heap. File_Ptr points to
-- this allocated file control block. If the open/create fails, then the
-- fields of File are undefined, and File_Ptr is unchanged.
procedure Close (File : in out FCB.AFCB_Ptr);
-- The file is closed, all storage associated with it is released, and
-- File is set to null. Note that this routine calls AFCB_Close to perform
-- any specialized close actions, then closes the file at the system level,
-- then frees the mode and form strings, and finally calls AFCB_Free to
-- free the file control block itself, setting File to null.
procedure Delete (File : in out FCB.AFCB_Ptr);
-- The indicated file is unlinked
procedure Reset (File : in out FCB.AFCB_Ptr; Mode : FCB.File_Mode);
-- The file is reset, and the mode changed as indicated
procedure Reset (File : in out FCB.AFCB_Ptr);
-- The files is reset, and the mode is unchanged
function Mode (File : FCB.AFCB_Ptr) return FCB.File_Mode;
-- Returns the mode as supplied by create, open or reset
function Name (File : FCB.AFCB_Ptr) return String;
-- Returns the file name as supplied by Open or Create. Raises Use_Error
-- if used with temporary files or standard files.
function Form (File : FCB.AFCB_Ptr) return String;
-- Returns the form as supplied by create, open or reset
-- The string is normalized to all lower case letters.
function Is_Open (File : FCB.AFCB_Ptr) return Boolean;
-- Determines if file is open or not
----------------------
-- Utility Routines --
----------------------
-- Some internal routines not defined in A.8.2. These are routines which
-- provide required common functionality shared by separate packages.
procedure Chain_File (File : FCB.AFCB_Ptr);
-- Used to chain the given file into the list of open files. Normally this
-- is done implicitly by Open. Chain_File is used for the special cases of
-- the system files defined by Text_IO (stdin, stdout, stderr) which are
-- not opened in the normal manner. Note that the caller is responsible
-- for task lock out to protect the global data structures if this is
-- necessary (it is needed for the calls from within this unit itself,
-- but not required for the calls from Text_IO and Wide_Text_IO that
-- are made during elaboration of the environment task).
procedure Check_File_Open (File : FCB.AFCB_Ptr);
-- If the current file is not open, then Status_Error is raised.
-- Otherwise control returns normally (with File pointing to the
-- control block for the open file.
procedure Check_Read_Status (File : FCB.AFCB_Ptr);
-- If the current file is not open, then Status_Error is raised. If
-- the file is open, then the mode is checked to ensure that reading
-- is permitted, and if not Mode_Error is raised, otherwise control
-- returns normally.
procedure Check_Write_Status (File : FCB.AFCB_Ptr);
-- If the current file is not open, then Status_Error is raised. If
-- the file is open, then the mode is checked to ensure that writing
-- is permitted, and if not Mode_Error is raised, otherwise control
-- returns normally.
function End_Of_File (File : FCB.AFCB_Ptr) return Boolean;
-- File must be opened in read mode. True is returned if the stream is
-- currently positioned at the end of file, otherwise False is returned.
-- The position of the stream is not affected.
procedure Flush (File : FCB.AFCB_Ptr);
-- Flushes the stream associated with the given file. The file must be
-- open and in write mode (if not, an appropriate exception is raised)
function Form_Boolean
(Form : String;
Keyword : String;
Default : Boolean)
return Boolean;
-- Searches form string for an entry of the form Keyword=xx where xx is
-- either Yes/No or y/n. Returns True if Yes or Y is found, False if No
-- or N is found. If the keyword parameter is not found, returns the
-- value given as Default. May raise Use_Error if a form string syntax
-- error is detected. Keyword and Form must be in lower case.
function Form_Integer
(Form : String;
Keyword : String;
Default : Integer)
return Integer;
-- Searches form string for an entry of the form Keyword=xx where xx is
-- an unsigned decimal integer in the range 0 to 999_999. Returns this
-- integer value if it is found. If the keyword parameter is not found,
-- returns the value given as Default. Raise Use_Error if a form string
-- syntax error is detected. Keyword and Form must be in lower case.
procedure Form_Parameter
(Form : String;
Keyword : String;
Start : out Natural;
Stop : out Natural);
-- Searches form string for an entry of the form Keyword=xx and if found
-- Sets Start and Stop to the first and last characters of xx. Keyword
-- and Form must be in lower case. If no entry matches, then Start and
-- Stop are set to zero on return. Use_Error is raised if a malformed
-- string is detected, but there is no guarantee of full syntax checking.
procedure Read_Buf
(File : FCB.AFCB_Ptr;
Buf : Address;
Siz : Interfaces.C_Streams.size_t);
-- Reads Siz bytes from File.Stream into Buf. The caller has checked
-- that the file is open in read mode. Raises an exception if Siz bytes
-- cannot be read (End_Error if no data was read, Data_Error if a partial
-- buffer was read, Device_Error if an error occurs).
procedure Read_Buf
(File : FCB.AFCB_Ptr;
Buf : Address;
Siz : Interfaces.C_Streams.size_t;
Count : out Interfaces.C_Streams.size_t);
-- Reads Siz bytes from File.Stream into Buf. The caller has checked
-- that the file is open in read mode. Device Error is raised if an error
-- occurs. Count is the actual number of bytes read, which may be less
-- than Siz if the end of file is encountered.
procedure Append_Set (File : FCB.AFCB_Ptr);
-- If the mode of the file is Append_File, then the file is positioned
-- at the end of file using fseek, otherwise this call has no effect.
procedure Write_Buf
(File : FCB.AFCB_Ptr;
Buf : Address;
Siz : Interfaces.C_Streams.size_t);
-- Writes size_t bytes to File.Stream from Buf. The caller has checked
-- that the file is open in write mode. Raises Device_Error if the
-- complete buffer cannot be written.
procedure Make_Unbuffered (File : FCB.AFCB_Ptr);
procedure Make_Line_Buffered
(File : FCB.AFCB_Ptr;
Line_Siz : Interfaces.C_Streams.size_t);
procedure Make_Buffered
(File : FCB.AFCB_Ptr;
Buf_Siz : Interfaces.C_Streams.size_t);
private
pragma Inline (Check_Read_Status);
pragma Inline (Check_Write_Status);
pragma Inline (Mode);
end System.File_IO;
|
-- This file is generated by SWIG. Please do *not* modify by hand.
--
with gmp_c.a_a_mpf_struct;
with Interfaces.C;
package gmp_c.mpf_srcptr is
-- Item
--
subtype Item is gmp_c.a_a_mpf_struct.Pointer;
-- Items
--
type Items is
array (Interfaces.C.size_t range <>) of aliased gmp_c.mpf_srcptr.Item;
-- Pointer
--
type Pointer is access all gmp_c.mpf_srcptr.Item;
-- Pointers
--
type Pointers is
array (Interfaces.C.size_t range <>) of aliased gmp_c.mpf_srcptr.Pointer;
-- Pointer_Pointer
--
type Pointer_Pointer is access all gmp_c.mpf_srcptr.Pointer;
end gmp_c.mpf_srcptr;
|
with
Ada.Strings.unbounded,
Ada.Containers.vectors;
package AdaM
is
-- Text
--
subtype Text is ada.Strings.Unbounded.Unbounded_String;
function "+" (the_Text : in Text) return String
renames ada.Strings.Unbounded.To_String;
function "+" (the_String : in String) return Text
renames ada.Strings.Unbounded.To_Unbounded_String;
use type Text;
package text_Vectors is new ada.Containers.Vectors (Positive, Text);
subtype text_Lines is text_Vectors.Vector;
procedure put (the_Lines : in text_Lines);
-- Ids
--
type Id is range 0 .. 1_000_000;
null_Id : constant Id;
-- Exceptions
--
Error : exception;
-- Identifiers
--
type Identifier is new String;
function "+" (Id : in Identifier) return String
is (String (Id));
function "+" (the_String : in String) return Identifier
is (Identifier (the_String));
function "+" (the_Text : in Text) return Identifier
is (Identifier (String' (+the_Text)));
-- renames ada.Strings.Unbounded.To_String;
--
-- function "+" (Id : in Identifier) return Text
-- is (
-- renames ada.Strings.Unbounded.To_Unbounded_String;
private
for Id'Size use 32;
null_Id : constant Id := Id'First;
end AdaM;
|
-- Abstract :
--
-- See spec.
--
-- Copyright (C) 2018 - 2019 Free Software Foundation, Inc.
--
-- This library is free software; you can redistribute it and/or modify it
-- under terms of the GNU General Public License as published by the Free
-- Software Foundation; either version 3, or (at your option) any later
-- version. This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-- As a special exception under Section 7 of GPL version 3, you are granted
-- additional permissions described in the GCC Runtime Library Exception,
-- version 3.1, as published by the Free Software Foundation.
pragma License (Modified_GPL);
package body WisiToken.Parse.Packrat.Generated is
overriding procedure Parse (Parser : aliased in out Generated.Parser)
is
-- 'aliased' required for Base_Tree'Access. WORKAROUND: that was
-- enough when Parser type was declared in generated Main; now that
-- it's a derived type, it doesn't work. So we use Unchecked_Access.
Descriptor : WisiToken.Descriptor renames Parser.Trace.Descriptor.all;
Junk : WisiToken.Syntax_Trees.Valid_Node_Index;
pragma Unreferenced (Junk);
Result : Memo_Entry;
begin
Parser.Base_Tree.Clear;
Parser.Tree.Initialize (Parser.Base_Tree'Unchecked_Access, Flush => True);
Parser.Lex_All;
Parser.Derivs.Set_First_Last (Descriptor.First_Nonterminal, Descriptor.Last_Nonterminal);
for Nonterm in Descriptor.First_Nonterminal .. Parser.Trace.Descriptor.Last_Nonterminal loop
Parser.Derivs (Nonterm).Clear;
Parser.Derivs (Nonterm).Set_First_Last (Parser.Terminals.First_Index, Parser.Terminals.Last_Index);
end loop;
for Token_Index in Parser.Terminals.First_Index .. Parser.Terminals.Last_Index loop
Junk := Parser.Tree.Add_Terminal (Token_Index, Parser.Terminals);
-- FIXME: move this into Lex_All, delete Terminals, just use Syntax_Tree
end loop;
Result := Parser.Parse_WisiToken_Accept (Parser, Parser.Terminals.First_Index - 1);
if Result.State /= Success then
if Trace_Parse > Outline then
Parser.Trace.Put_Line ("parse failed");
end if;
raise Syntax_Error with "parse failed"; -- FIXME: need better error message!
else
Parser.Tree.Set_Root (Result.Result);
end if;
end Parse;
overriding function Tree (Parser : in Generated.Parser) return Syntax_Trees.Tree
is begin
return Parser.Tree;
end Tree;
overriding function Any_Errors (Parser : in Generated.Parser) return Boolean
is
use all type Ada.Containers.Count_Type;
begin
return Parser.Lexer.Errors.Length > 0;
end Any_Errors;
overriding procedure Put_Errors (Parser : in Generated.Parser)
is
use Ada.Text_IO;
begin
for Item of Parser.Lexer.Errors loop
Put_Line
(Current_Error,
Parser.Lexer.File_Name & ":0:0: lexer unrecognized character at" & Buffer_Pos'Image (Item.Char_Pos));
end loop;
-- FIXME: Packrat parser does not report errors yet.
end Put_Errors;
end WisiToken.Parse.Packrat.Generated;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 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$
------------------------------------------------------------------------------
with League.Holders.Booleans;
with League.JSON.Arrays.Internals;
with League.Holders.JSON_Arrays;
with League.Holders.JSON_Objects;
with League.JSON.Objects.Internals;
with League.Strings.Internals;
with Matreshka.Internals.Strings;
package body League.JSON.Values is
use type Matreshka.JSON_Types.Value_Kinds;
------------
-- Adjust --
------------
overriding procedure Adjust (Self : in out JSON_Value) is
begin
Matreshka.JSON_Types.Reference (Self.Data);
end Adjust;
--------------
-- Finalize --
--------------
overriding procedure Finalize (Self : in out JSON_Value) is
use type Matreshka.JSON_Types.Shared_JSON_Value_Access;
begin
if Self.Data /= null then
Matreshka.JSON_Types.Dereference (Self.Data);
end if;
end Finalize;
--------------
-- Is_Array --
--------------
function Is_Array (Self : JSON_Value'Class) return Boolean is
begin
return Self.Data.Value.Kind = Matreshka.JSON_Types.Array_Value;
end Is_Array;
----------------
-- Is_Boolean --
----------------
function Is_Boolean (Self : JSON_Value'Class) return Boolean is
begin
return Self.Data.Value.Kind = Matreshka.JSON_Types.Boolean_Value;
end Is_Boolean;
--------------
-- Is_Empty --
--------------
function Is_Empty (Self : JSON_Value'Class) return Boolean is
begin
return Self.Data.Value.Kind = Matreshka.JSON_Types.Empty_Value;
end Is_Empty;
---------------------
-- Is_Float_Number --
---------------------
function Is_Float_Number (Self : JSON_Value'Class) return Boolean is
begin
return Self.Data.Value.Kind = Matreshka.JSON_Types.Float_Value;
end Is_Float_Number;
-----------------------
-- Is_Integer_Number --
-----------------------
function Is_Integer_Number (Self : JSON_Value'Class) return Boolean is
begin
return Self.Data.Value.Kind = Matreshka.JSON_Types.Integer_Value;
end Is_Integer_Number;
-------------
-- Is_Null --
-------------
function Is_Null (Self : JSON_Value'Class) return Boolean is
begin
return Self.Data.Value.Kind = Matreshka.JSON_Types.Null_Value;
end Is_Null;
---------------
-- Is_Number --
---------------
function Is_Number (Self : JSON_Value'Class) return Boolean is
begin
return
Self.Data.Value.Kind in Matreshka.JSON_Types.Float_Value
| Matreshka.JSON_Types.Integer_Value;
end Is_Number;
---------------
-- Is_Object --
---------------
function Is_Object (Self : JSON_Value'Class) return Boolean is
begin
return Self.Data.Value.Kind = Matreshka.JSON_Types.Object_Value;
end Is_Object;
---------------
-- Is_String --
---------------
function Is_String (Self : JSON_Value'Class) return Boolean is
begin
return Self.Data.Value.Kind = Matreshka.JSON_Types.String_Value;
end Is_String;
----------
-- Kind --
----------
function Kind (Self : JSON_Value'Class) return JSON_Value_Kinds is
begin
case Self.Data.Value.Kind is
when Matreshka.JSON_Types.Empty_Value =>
return Empty_Value;
when Matreshka.JSON_Types.Boolean_Value =>
return Boolean_Value;
when Matreshka.JSON_Types.Integer_Value =>
return Number_Value;
when Matreshka.JSON_Types.Float_Value =>
return Number_Value;
when Matreshka.JSON_Types.String_Value =>
return String_Value;
when Matreshka.JSON_Types.Array_Value =>
return Array_Value;
when Matreshka.JSON_Types.Object_Value =>
return Object_Value;
when Matreshka.JSON_Types.Null_Value =>
return Null_Value;
end case;
end Kind;
--------------
-- To_Array --
--------------
function To_Array
(Self : JSON_Value'Class;
Default : League.JSON.Arrays.JSON_Array
:= League.JSON.Arrays.Empty_JSON_Array)
return League.JSON.Arrays.JSON_Array is
begin
if Self.Data.Value.Kind = Matreshka.JSON_Types.Array_Value then
return
League.JSON.Arrays.Internals.Create (Self.Data.Value.Array_Value);
else
return Default;
end if;
end To_Array;
----------------
-- To_Boolean --
----------------
function To_Boolean
(Self : JSON_Value'Class; Default : Boolean := False) return Boolean is
begin
if Self.Data.Value.Kind = Matreshka.JSON_Types.Boolean_Value then
return Self.Data.Value.Boolean_Value;
else
return Default;
end if;
end To_Boolean;
--------------
-- To_Float --
--------------
function To_Float
(Self : JSON_Value'Class;
Default : League.Holders.Universal_Float := 0.0)
return League.Holders.Universal_Float is
begin
if Self.Data.Value.Kind = Matreshka.JSON_Types.Float_Value then
return Self.Data.Value.Float_Value;
elsif Self.Data.Value.Kind = Matreshka.JSON_Types.Integer_Value then
return League.Holders.Universal_Float (Self.Data.Value.Integer_Value);
else
return Default;
end if;
end To_Float;
---------------
-- To_Holder --
---------------
function To_Holder (Self : JSON_Value'Class) return League.Holders.Holder is
begin
case Self.Data.Value.Kind is
when Matreshka.JSON_Types.Empty_Value =>
return League.Holders.Empty_Holder;
when Matreshka.JSON_Types.Boolean_Value =>
return
League.Holders.Booleans.To_Holder
(Self.Data.Value.Boolean_Value);
when Matreshka.JSON_Types.Integer_Value =>
return Result : League.Holders.Holder do
League.Holders.Set_Tag
(Result, League.Holders.Universal_Integer_Tag);
League.Holders.Replace_Element
(Result, Self.Data.Value.Integer_Value);
end return;
when Matreshka.JSON_Types.Float_Value =>
return Result : League.Holders.Holder do
League.Holders.Set_Tag
(Result, League.Holders.Universal_Float_Tag);
League.Holders.Replace_Element
(Result, Self.Data.Value.Float_Value);
end return;
when Matreshka.JSON_Types.String_Value =>
return
League.Holders.To_Holder
(League.Strings.Internals.Create
(Self.Data.Value.String_Value));
when Matreshka.JSON_Types.Array_Value =>
return League.Holders.JSON_Arrays.To_Holder
(League.JSON.Arrays.Internals.Create
(Self.Data.Value.Array_Value));
when Matreshka.JSON_Types.Object_Value =>
return League.Holders.JSON_Objects.To_Holder
(League.JSON.Objects.Internals.Create
(Self.Data.Value.Object_Value));
when Matreshka.JSON_Types.Null_Value =>
return League.Holders.Empty_Holder;
end case;
end To_Holder;
----------------
-- To_Integer --
----------------
function To_Integer
(Self : JSON_Value'Class;
Default : League.Holders.Universal_Integer := 0)
return League.Holders.Universal_Integer is
begin
if Self.Data.Value.Kind = Matreshka.JSON_Types.Float_Value then
return League.Holders.Universal_Integer (Self.Data.Value.Float_Value);
elsif Self.Data.Value.Kind = Matreshka.JSON_Types.Integer_Value then
return Self.Data.Value.Integer_Value;
else
return Default;
end if;
end To_Integer;
-------------------
-- To_JSON_Value --
-------------------
function To_JSON_Value (Value : Boolean) return JSON_Value is
begin
return
(Ada.Finalization.Controlled with
Data =>
new Matreshka.JSON_Types.Shared_JSON_Value'
(Counter => <>,
Value =>
(Kind => Matreshka.JSON_Types.Boolean_Value,
Boolean_Value => Value)));
end To_JSON_Value;
-------------------
-- To_JSON_Value --
-------------------
function To_JSON_Value
(Value : League.Holders.Universal_Float) return JSON_Value is
begin
return
(Ada.Finalization.Controlled with
Data =>
new Matreshka.JSON_Types.Shared_JSON_Value'
(Counter => <>,
Value =>
(Kind => Matreshka.JSON_Types.Float_Value,
Float_Value => Value)));
end To_JSON_Value;
-------------------
-- To_JSON_Value --
-------------------
function To_JSON_Value
(Value : League.Holders.Universal_Integer) return JSON_Value is
begin
return
(Ada.Finalization.Controlled with
Data =>
new Matreshka.JSON_Types.Shared_JSON_Value'
(Counter => <>,
Value =>
(Kind => Matreshka.JSON_Types.Integer_Value,
Integer_Value => Value)));
end To_JSON_Value;
-------------------
-- To_JSON_Value --
-------------------
function To_JSON_Value
(Value : League.Strings.Universal_String) return JSON_Value
is
Aux : constant Matreshka.Internals.Strings.Shared_String_Access
:= League.Strings.Internals.Internal (Value);
begin
Matreshka.Internals.Strings.Reference (Aux);
return
(Ada.Finalization.Controlled with
Data =>
new Matreshka.JSON_Types.Shared_JSON_Value'
(Counter => <>,
Value =>
(Kind => Matreshka.JSON_Types.String_Value,
String_Value => Aux)));
end To_JSON_Value;
-------------------
-- To_JSON_Value --
-------------------
function To_JSON_Value (Value : League.Holders.Holder) return JSON_Value is
use type League.Holders.Tag;
begin
if League.Holders.Get_Tag (Value)
= League.Holders.Booleans.Value_Tag
then
return To_JSON_Value (League.Holders.Booleans.Element (Value));
elsif League.Holders.Is_Abstract_Integer (Value) then
return
To_JSON_Value
(League.Holders.Universal_Integer'
(League.Holders.Element (Value)));
elsif League.Holders.Is_Abstract_Float (Value) then
return
To_JSON_Value
(League.Holders.Universal_Float'(League.Holders.Element (Value)));
else
return Empty_JSON_Value;
end if;
end To_JSON_Value;
---------------
-- To_Object --
---------------
function To_Object
(Self : JSON_Value'Class;
Default : League.JSON.Objects.JSON_Object
:= League.JSON.Objects.Empty_JSON_Object)
return League.JSON.Objects.JSON_Object is
begin
if Self.Data.Value.Kind = Matreshka.JSON_Types.Object_Value then
return
League.JSON.Objects.Internals.Create (Self.Data.Value.Object_Value);
else
return Default;
end if;
end To_Object;
---------------
-- To_String --
---------------
function To_String
(Self : JSON_Value'Class;
Default : League.Strings.Universal_String
:= League.Strings.Empty_Universal_String)
return League.Strings.Universal_String is
begin
if Self.Data.Value.Kind = Matreshka.JSON_Types.String_Value then
return League.Strings.Internals.Create (Self.Data.Value.String_Value);
else
return Default;
end if;
end To_String;
end League.JSON.Values;
|
--------------------------------------------------------------------------------
-- MIT License
--
-- Copyright (c) 2021 Zane Myers
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to deal
-- in the Software without restriction, including without limitation the rights
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-- copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in all
-- copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-- SOFTWARE.
--------------------------------------------------------------------------------
with Vulkan.Math;
with Vulkan.Math.Vec2;
with Vulkan.Math.Vec3;
with Vulkan.Math.Vec4;
with Vulkan.Math.Mat2x2;
with Vulkan.Math.Mat2x3;
with Vulkan.Math.Mat2x4;
with Vulkan.Math.Mat3x2;
with Vulkan.Math.Mat3x3;
with Vulkan.Math.Mat3x4;
with Vulkan.Math.Mat4x2;
with Vulkan.Math.Mat4x3;
with Vulkan.Math.Mat4x4;
with Vulkan.Math.Dvec2;
with Vulkan.Math.Dvec3;
with Vulkan.Math.Dvec4;
with Vulkan.Math.Dmat2x2;
with Vulkan.Math.Dmat2x3;
with Vulkan.Math.Dmat2x4;
with Vulkan.Math.Dmat3x2;
with Vulkan.Math.Dmat3x3;
with Vulkan.Math.Dmat3x4;
with Vulkan.Math.Dmat4x2;
with Vulkan.Math.Dmat4x3;
with Vulkan.Math.Dmat4x4;
use Vulkan.Math;
use Vulkan.Math.Vec2;
use Vulkan.Math.Vec3;
use Vulkan.Math.Vec4;
use Vulkan.Math.Mat2x2;
use Vulkan.Math.Mat2x3;
use Vulkan.Math.Mat2x4;
use Vulkan.Math.Mat3x2;
use Vulkan.Math.Mat3x3;
use Vulkan.Math.Mat3x4;
use Vulkan.Math.Mat4x2;
use Vulkan.Math.Mat4x3;
use Vulkan.Math.Mat4x4;
use Vulkan.Math.Dvec2;
use Vulkan.Math.Dvec3;
use Vulkan.Math.Dvec4;
use Vulkan.Math.Dmat2x2;
use Vulkan.Math.Dmat2x3;
use Vulkan.Math.Dmat2x4;
use Vulkan.Math.Dmat3x2;
use Vulkan.Math.Dmat3x3;
use Vulkan.Math.Dmat3x4;
use Vulkan.Math.Dmat4x2;
use Vulkan.Math.Dmat4x3;
use Vulkan.Math.Dmat4x4;
--------------------------------------------------------------------------------
--< @group Vulkan Test Framwork
--------------------------------------------------------------------------------
--< @summary
--< This package provides a simple framework for validating the VulkanAda library.
--------------------------------------------------------------------------------
package Vulkan.Test.Framework is
-- An exception that is raised when a failure is observed.
VULKAN_TEST_ASSERTION_FAIL : exception;
procedure Assert_Vkm_Bool_Equals(
actual : in Vkm_Bool;
expected : in Vkm_Bool);
procedure Assert_Vec2_Equals(
vec : in Vkm_Vec2;
value1, value2 : in Vkm_Float);
procedure Assert_Vec3_Equals(
vec : in Vkm_Vec3;
value1, value2, value3 : in Vkm_Float);
procedure Assert_Vec4_Equals(
vec : in Vkm_Vec4;
value1, value2, value3, value4 : in Vkm_Float);
procedure Assert_Mat2x2_Equals(
mat : in Vkm_Mat2;
value1, value2,
value3, value4 : in Vkm_Float);
procedure Assert_Mat2x3_Equals(
mat : in Vkm_Mat2x3;
value1, value2, value3,
value4, value5, value6 : in Vkm_Float);
procedure Assert_Mat2x4_Equals(
mat : in Vkm_Mat2x4;
value1, value2, value3, value4,
value5, value6, value7, value8 : in Vkm_Float);
procedure Assert_Mat3x2_Equals(
mat : in Vkm_Mat3x2;
value1, value2,
value3, value4,
value5, value6 : in Vkm_Float);
procedure Assert_Mat3x3_Equals(
mat : in Vkm_Mat3;
value1, value2, value3,
value4, value5, value6,
value7, value8, value9 : in Vkm_Float);
procedure Assert_Mat3x4_Equals(
mat : in Vkm_Mat3x4;
value1, value2 , value3 , value4 ,
value5, value6 , value7 , value8 ,
value9, value10, value11, value12 : in Vkm_Float);
procedure Assert_Mat4x2_Equals(
mat : in Vkm_Mat4x2;
value1, value2,
value3, value4,
value5, value6,
value7, value8 : in Vkm_Float);
procedure Assert_Mat4x3_Equals(
mat : in Vkm_Mat4x3;
value1 , value2 , value3 ,
value4 , value5 , value6 ,
value7 , value8 , value9 ,
value10, value11, value12 : in Vkm_Float);
procedure Assert_Mat4x4_Equals(
mat : in Vkm_Mat4x4;
value1 , value2 , value3 , value4 ,
value5 , value6 , value7 , value8 ,
value9 , value10, value11, value12,
value13, value14, value15, value16 : in Vkm_Float);
-- Double precision
procedure Assert_Dvec2_Equals(
vec : in Vkm_Dvec2;
value1, value2 : in Vkm_Double);
procedure Assert_Dvec3_Equals(
vec : in Vkm_Dvec3;
value1, value2, value3 : in Vkm_Double);
procedure Assert_Dvec4_Equals(
vec : in Vkm_Dvec4;
value1, value2, value3, value4 : in Vkm_Double);
procedure Assert_Dmat2x2_Equals(
mat : in Vkm_Dmat2;
value1, value2,
value3, value4 : in Vkm_Double);
procedure Assert_Dmat2x3_Equals(
mat : in Vkm_Dmat2x3;
value1, value2, value3,
value4, value5, value6 : in Vkm_Double);
procedure Assert_Dmat2x4_Equals(
mat : in Vkm_Dmat2x4;
value1, value2, value3, value4,
value5, value6, value7, value8 : in Vkm_Double);
procedure Assert_Dmat3x2_Equals(
mat : in Vkm_Dmat3x2;
value1, value2,
value3, value4,
value5, value6 : in Vkm_Double);
procedure Assert_Dmat3x3_Equals(
mat : in Vkm_Dmat3;
value1, value2, value3,
value4, value5, value6,
value7, value8, value9 : in Vkm_Double);
procedure Assert_Dmat3x4_Equals(
mat : in Vkm_Dmat3x4;
value1, value2 , value3 , value4 ,
value5, value6 , value7 , value8 ,
value9, value10, value11, value12 : in Vkm_Double);
procedure Assert_Dmat4x2_Equals(
mat : in Vkm_Dmat4x2;
value1, value2,
value3, value4,
value5, value6,
value7, value8 : in Vkm_Double);
procedure Assert_Dmat4x3_Equals(
mat : in Vkm_Dmat4x3;
value1 , value2 , value3 ,
value4 , value5 , value6 ,
value7 , value8 , value9 ,
value10, value11, value12 : in Vkm_Double);
procedure Assert_Dmat4x4_Equals(
mat : in Vkm_Dmat4x4;
value1 , value2 , value3 , value4 ,
value5 , value6 , value7 , value8 ,
value9 , value10, value11, value12,
value13, value14, value15, value16 : in Vkm_Double);
end Vulkan.Test.Framework;
|
with Ada.Text_IO;
with Spatial_Data; use Spatial_Data;
procedure Spatial1 is
package TIO renames Ada.Text_IO;
procedure print (shape : Geometry; label : String);
procedure print (shape : Geometry; label : String) is
begin
TIO.Put_Line ("===== " & label & " =====");
TIO.Put_Line ("MySQL: " & mysql_text (shape));
TIO.Put_Line (" WKT: " & Well_Known_Text (shape)); -- (shape));
TIO.Put_Line ("");
end print;
magic_point : constant Geometric_Point := (18.2, -3.4);
magic_linestr : constant Geometric_Line_String := ((0.5, 2.0), (11.0, 4.4), (12.0, 8.1));
magic_polygon : constant Geometric_Polygon := start_polygon (((0.5, 2.0), (11.0, 4.4), (12.0, 8.1), (0.005, 2.0)));
my_point : Geometry := initialize_as_point (magic_point);
my_linestr : Geometry := initialize_as_line (magic_linestr);
my_polygon : Geometry := initialize_as_polygon (magic_polygon);
pt1 : Geometric_Point := (9.2, 4.773);
pt2 : Geometric_Point := (-7.01, -4.9234);
pt3 : Geometric_Point := (4.5, 6.0);
altpoly : Geometric_Ring := ((1.0, 2.0), (3.2, 4.5), (8.8, 7.7), (1.0, 2.0));
polyhole : Geometric_Polygon;
begin
-- critical checklist
-- =========================================================
-- single point 59
-- single line_string 60
-- single polygon 61
-- single polygon with 1 hole 71-74
-- single polygon with 2 holes 66-70
-- point + point = multipoint 72-77
-- point + line_string = collection 94-100
-- point + point(s) = collection 102-108
-- point + polygon = collection 110-115
-- point + polygon with 2 holex = 2 item collection 117-122
-- line_string + line_string = multiline 87-92
-- line_string + point + point = collection 124-130
-- line_string + polygon = collection 132-137
-- line_string + polygon w/holes = 2 item collection 139-144
-- polygon + point = 2 item collection 146-151
-- polygon + line_string = 2 item collection 153-158
-- polygon + hole + point + point = 3 item collection 160-167
-- polygon + hole + polygon + point = 3 item collection 169-176
-- polygon + polygon + hole = 2 item multipolygon 178-182
-- polygon + polygon + hole + line_string = 3 item col. 178-185
-- polygon + hole + polygon + hole = 2 item multipolygon 187-196
-- polygon + hole + point = 2 item collection 198-204
-- polygon + hole + line_string = 2 item collection 206-212
print (my_point, "SINGLE POINT");
print (my_linestr, "SINGLE LINE STRING (THREE POINT)");
print (my_polygon, "SINGLE POLYGON (3 SIDES)");
polyhole := magic_polygon;
append_inner_ring (polyhole, altpoly);
declare
shape : Geometry := initialize_as_polygon (polyhole);
begin
print (shape, "STILL SINGLE POLYGON #1");
end;
append_inner_ring (polyhole, ((13.5, 15.35), (98.1, 11.7), (-13.75, 0.0004), (13.5, 15.35)));
declare
shape : Geometry := initialize_as_polygon (polyhole);
begin
print (shape, "STILL SINGLE POLYGON #2");
end;
declare
MP : Geometry := initialize_as_multi_point (magic_point);
begin
augment_multi_point (MP, pt1);
augment_multi_point (MP, pt2);
print (MP, "MULTIPOINT COLLECTION");
end;
declare
MLS : Geometry := initialize_as_multi_line (magic_linestr);
begin
augment_multi_line (MLS, ((pt3, pt1, pt2)));
print (MLS, "MULTILINESTRING COLLECTION");
end;
declare
shape : Geometry :=
initialize_as_collection (initialize_as_point (pt1));
begin
augment_collection (shape, my_linestr);
print (shape, "MIXED COLLECTION #1 (PT + LINE)");
end;
declare
shape : Geometry := initialize_as_collection (my_point);
begin
augment_collection (shape, initialize_as_point (pt1));
augment_collection (shape, initialize_as_point (pt2));
print (shape, "MIXED COLLECTION #2 (ALL POINTS)");
end;
declare
shape : Geometry := initialize_as_collection (my_point);
begin
augment_collection (shape, my_polygon);
print (shape, "MIXED COLLECTION #3 (PT + POLY)");
end;
declare
shape : Geometry := initialize_as_collection (my_point);
begin
augment_collection (shape, initialize_as_polygon (polyhole));
print (shape, "MIXED COLLECTION #4 (PT + CMPLX POLY)");
end;
declare
shape : Geometry := initialize_as_collection (my_linestr);
begin
augment_collection (shape, initialize_as_point (pt1));
augment_collection (shape, initialize_as_point (pt2));
print (shape, "MIXED COLLECTION #5 (LINE + 2 PT)");
end;
declare
shape : Geometry := initialize_as_collection (my_linestr);
begin
augment_collection (shape, my_polygon);
print (shape, "MIXED COLLECTION #6 (LINE + POLY)");
end;
declare
shape : Geometry := initialize_as_collection (my_linestr);
begin
augment_collection (shape, initialize_as_polygon (polyhole));
print (shape, "MIXED COLLECTION #6 ENHANCED (LINE + CMPLX POLY)");
end;
declare
shape : Geometry := initialize_as_collection (my_polygon);
begin
augment_collection (shape, initialize_as_point (pt2));
print (shape, "MIXED COLLECTION #7 (POLY + PT)");
end;
declare
shape : Geometry := initialize_as_collection (my_polygon);
begin
augment_collection (shape, my_linestr);
print (shape, "MIXED COLLECTION #7 (POLY + LINE)");
end;
declare
shape : Geometry :=
initialize_as_collection (initialize_as_polygon (polyhole));
begin
augment_collection (shape, initialize_as_point (pt1));
augment_collection (shape, initialize_as_point (pt2));
print (shape, "MIXED COLLECTION #8 (CMPLX POLY + 2 PT)");
end;
declare
shape : Geometry :=
initialize_as_collection (initialize_as_polygon (polyhole));
begin
augment_collection (shape, my_polygon);
augment_collection (shape, initialize_as_point (pt2));
print (shape, "MIXED COLLECTION #9 (CMPLX POLY + POLY + PT)");
end;
declare
shape : Geometry := initialize_as_collection (my_polygon);
begin
augment_collection (shape, initialize_as_polygon (polyhole));
print (shape, "MIXED COLLECTION #10 (POLY + CMPLX POLY)");
augment_collection (shape, my_linestr);
print (shape, "MIXED COLLECTION #11 (POLY + CMPLX POLY + LINE)");
end;
declare
shape : Geometry :=
initialize_as_collection (initialize_as_polygon (polyhole));
new_poly : Geometric_Polygon;
begin
new_poly := start_polygon (((5.0, 6.0), (1.4, 2.2), (18.1, 24.0), (5.0, 6.0)));
append_inner_ring (new_poly, ((5.0, 6.0), (1.4, 2.2), (18.1, 24.0), (5.0, 6.0)));
augment_collection (shape, initialize_as_polygon (new_poly));
print (shape, "MIXED COLLECTION #12 (2 CMPLX POLY)");
end;
declare
shape : Geometry :=
initialize_as_collection (initialize_as_polygon (polyhole));
begin
augment_collection (shape, initialize_as_point (pt3));
print (shape, "MIXED COLLECTION #13 (CMPLX POLY + PT)");
end;
declare
shape : Geometry :=
initialize_as_collection (initialize_as_polygon (polyhole));
begin
augment_collection (shape, my_linestr);
print (shape, "MIXED COLLECTION #13 (CMPLX POLY + Line)");
end;
-----------------------------------
-- Additional collection tests --
-----------------------------------
-- repeat double polygon test, but multipolygon instead of collection
declare
shape : Geometry := initialize_as_multi_polygon (magic_polygon);
begin
augment_multi_polygon (shape, polyhole);
print (shape, "MULTI-POLYGON (POLY + CMPLX POLY)");
end;
-- Have a collection inside a collection
declare
shape : Geometry := initialize_as_collection (my_point);
shape2 : Geometry := initialize_as_collection (initialize_as_point
(pt3));
begin
augment_collection (shape2, my_linestr);
augment_collection (shape2, my_polygon);
augment_collection (shape, shape2);
print (shape, "COLLECTION THAT CONTAINS ANOTHER COLLECTION");
end;
-- Have a collection two levels deep
declare
shape : Geometry := initialize_as_collection (my_point);
shape2 : Geometry := initialize_as_collection (initialize_as_point
(pt3));
shape3 : Geometry := initialize_as_collection (initialize_as_polygon
(polyhole));
begin
augment_collection (shape, initialize_as_point ((3.25, 5.0)));
augment_collection (shape2, my_linestr);
augment_collection (shape3, initialize_as_point (pt2));
augment_collection (shape3, initialize_as_multi_point (pt1));
augment_collection (shape2, shape3);
augment_collection (shape, shape2);
print (shape, "COLLECTION THAT CONTAINS 2 LEVELS OF COLLECTIONS");
Ada.Text_IO.Put_Line (dump (shape));
Ada.Text_IO.Put_Line ("Dump shape 3");
Ada.Text_IO.Put_Line (dump (retrieve_subcollection (shape, 3)));
end;
end Spatial1;
|
-- CD2A23A.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT WHEN A SIZE SPECIFICATION AND AN ENUMERATION
-- REPRESENTATION CLAUSE ARE GIVEN FOR AN ENUMERATION TYPE,
-- THEN OPERATIONS ON VALUES OF SUCH A TYPE ARE NOT AFFECTED
-- BY THE REPRESENTATION CLAUSE.
-- HISTORY:
-- RJW 07/28/87 CREATED ORIGINAL TEST.
-- DHH 04/18/89 CHANGED EXTENSION FROM '.DEP' TO '.ADA', CHANGED
-- OPERATORS ON 'SIZE TESTS, AND ADDED CHECK ON
-- REPRESENTATION CLAUSE.
-- WMC 03/27/92 ELIMINATED TEST REDUNDANCIES.
WITH REPORT; USE REPORT;
WITH LENGTH_CHECK; -- CONTAINS A CALL TO 'FAILED'.
PROCEDURE CD2A23A IS
BASIC_SIZE : CONSTANT := INTEGER'SIZE/2;
TYPE CHECK_TYPE IS (ZERO, ONE, TWO);
FOR CHECK_TYPE USE (ZERO => 3, ONE => 4, TWO => 5);
FOR CHECK_TYPE'SIZE USE BASIC_SIZE;
C0 : CHECK_TYPE := ZERO;
C1 : CHECK_TYPE := ONE;
C2 : CHECK_TYPE := TWO;
TYPE ARRAY_TYPE IS ARRAY (0 .. 2) OF CHECK_TYPE;
CHARRAY : ARRAY_TYPE := (ZERO, ONE, TWO);
TYPE REC_TYPE IS RECORD
COMP0 : CHECK_TYPE := ZERO;
COMP1 : CHECK_TYPE := ONE;
COMP2 : CHECK_TYPE := TWO;
END RECORD;
CHREC : REC_TYPE;
FUNCTION IDENT (CH : CHECK_TYPE) RETURN CHECK_TYPE IS
BEGIN
IF EQUAL (3, 3) THEN
RETURN CH;
ELSE
RETURN ONE;
END IF;
END IDENT;
PROCEDURE CHECK_1 IS NEW LENGTH_CHECK (CHECK_TYPE);
PROCEDURE PROC (CI0, CI2 : CHECK_TYPE;
CIO1, CIO2 : IN OUT CHECK_TYPE;
CO2 : OUT CHECK_TYPE) IS
BEGIN
IF NOT ((IDENT (CIO1) IN CIO1 .. CIO2) AND
(CI0 NOT IN IDENT (ONE) .. CIO2)) THEN
FAILED ("INCORRECT RESULTS FOR MEMBERSHIP OPERATORS " &
"- 1");
END IF;
IF CHECK_TYPE'VAL (0) /= IDENT (CI0) OR
CHECK_TYPE'VAL (1) /= IDENT (CIO1) OR
CHECK_TYPE'VAL (2) /= IDENT (CIO2) THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'VAL - 1");
END IF;
IF CHECK_TYPE'PRED (CIO1) /= IDENT (CI0) OR
CHECK_TYPE'PRED (CIO2) /= IDENT (CIO1) THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'PRED - 1");
END IF;
IF CHECK_TYPE'VALUE ("ZERO") /= IDENT (CI0) OR
CHECK_TYPE'VALUE ("ONE") /= IDENT (CIO1) OR
CHECK_TYPE'VALUE ("TWO") /= IDENT (CIO2) THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'VALUE - 1");
END IF;
CO2 := TWO;
END PROC;
BEGIN
TEST ("CD2A23A", "CHECK THAT WHEN A SIZE SPECIFICATION AND " &
"AN ENUMERATION REPRESENTATION CLAUSE ARE " &
"GIVEN FOR AN ENUMERATION TYPE, THEN " &
"OPERATIONS ON VALUES OF SUCH A TYPE ARE " &
"NOT AFFECTED BY THE REPRESENTATION CLAUSE");
CHECK_1 (C0, BASIC_SIZE, "CHECK_TYPE");
PROC (ZERO, TWO, C1, C2, C2);
IF CHECK_TYPE'SIZE /= IDENT_INT (BASIC_SIZE) THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'SIZE");
END IF;
IF C0'SIZE < IDENT_INT (BASIC_SIZE) THEN
FAILED ("INCORRECT VALUE FOR C0'SIZE");
END IF;
IF NOT ((C0 < IDENT (ONE)) AND(IDENT (C2) > IDENT (C1)) AND
(C1 <= IDENT (ONE)) AND(IDENT (TWO) = C2)) THEN
FAILED ("INCORRECT RESULTS FOR RELATIONAL OPERATORS - 2");
END IF;
IF CHECK_TYPE'LAST /= IDENT (TWO) THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'LAST - 2");
END IF;
IF CHECK_TYPE'POS (C0) /= IDENT_INT (0) OR
CHECK_TYPE'POS (C1) /= IDENT_INT (1) OR
CHECK_TYPE'POS (C2) /= IDENT_INT (2) THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'POS - 2");
END IF;
IF CHECK_TYPE'SUCC (C0) /= IDENT (C1) OR
CHECK_TYPE'SUCC (C1) /= IDENT (C2) THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'SUCC - 2");
END IF;
IF CHECK_TYPE'IMAGE (C0) /= IDENT_STR ("ZERO") OR
CHECK_TYPE'IMAGE (C1) /= IDENT_STR ("ONE") OR
CHECK_TYPE'IMAGE (C2) /= IDENT_STR ("TWO") THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'IMAGE - 2");
END IF;
IF CHARRAY (1)'SIZE < IDENT_INT (BASIC_SIZE) THEN
FAILED ("INCORRECT VALUE FOR CHARRAY (1)'SIZE");
END IF;
IF NOT ((CHARRAY (0) < IDENT (ONE)) AND
(IDENT (CHARRAY (2)) > IDENT (CHARRAY (1))) AND
(CHARRAY (1) <= IDENT (ONE)) AND
(IDENT (TWO) = CHARRAY (2))) THEN
FAILED ("INCORRECT RESULTS FOR RELATIONAL OPERATORS - 3");
END IF;
IF NOT ((IDENT (CHARRAY (1)) IN CHARRAY (1) .. CHARRAY (2)) AND
(CHARRAY (0) NOT IN IDENT (ONE) .. CHARRAY (2))) THEN
FAILED ("INCORRECT RESULTS FOR MEMBERSHIP OPERATORS - 3");
END IF;
IF CHECK_TYPE'VAL (0) /= IDENT (CHARRAY (0)) OR
CHECK_TYPE'VAL (1) /= IDENT (CHARRAY (1)) OR
CHECK_TYPE'VAL (2) /= IDENT (CHARRAY (2)) THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'VAL - 3");
END IF;
IF CHECK_TYPE'PRED (CHARRAY (1)) /= IDENT (CHARRAY (0)) OR
CHECK_TYPE'PRED (CHARRAY (2)) /= IDENT (CHARRAY (1)) THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'PRED - 3");
END IF;
IF CHECK_TYPE'VALUE ("ZERO") /= IDENT (CHARRAY (0)) OR
CHECK_TYPE'VALUE ("ONE") /= IDENT (CHARRAY (1)) OR
CHECK_TYPE'VALUE ("TWO") /= IDENT (CHARRAY (2)) THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'VALUE - 3");
END IF;
IF CHREC.COMP2'SIZE < IDENT_INT (BASIC_SIZE) THEN
FAILED ("INCORRECT VALUE FOR CHREC.COMP2'SIZE");
END IF;
IF NOT ((CHREC.COMP0 < IDENT (ONE)) AND
(IDENT (CHREC.COMP2) > IDENT (CHREC.COMP1)) AND
(CHREC.COMP1 <= IDENT (ONE)) AND
(IDENT (TWO) = CHREC.COMP2)) THEN
FAILED ("INCORRECT RESULTS FOR RELATIONAL OPERATORS - 4");
END IF;
IF NOT ((IDENT (CHREC.COMP1) IN CHREC.COMP1 .. CHREC.COMP2) AND
(CHREC.COMP0 NOT IN IDENT (ONE) .. CHREC.COMP2)) THEN
FAILED ("INCORRECT RESULTS FOR MEMBERSHIP OPERATORS - 4");
END IF;
IF CHECK_TYPE'POS (CHREC.COMP0) /= IDENT_INT (0) OR
CHECK_TYPE'POS (CHREC.COMP1) /= IDENT_INT (1) OR
CHECK_TYPE'POS (CHREC.COMP2) /= IDENT_INT (2) THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'POS - 4");
END IF;
IF CHECK_TYPE'SUCC (CHREC.COMP0) /= IDENT (CHREC.COMP1) OR
CHECK_TYPE'SUCC (CHREC.COMP1) /= IDENT (CHREC.COMP2) THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'SUCC - 4");
END IF;
IF CHECK_TYPE'IMAGE (CHREC.COMP0) /= IDENT_STR ("ZERO") OR
CHECK_TYPE'IMAGE (CHREC.COMP1) /= IDENT_STR ("ONE") OR
CHECK_TYPE'IMAGE (CHREC.COMP2) /= IDENT_STR ("TWO") THEN
FAILED ("INCORRECT VALUE FOR CHECK_TYPE'IMAGE - 4");
END IF;
RESULT;
END CD2A23A;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Hello_world is
begin
Put_Line ("Hello World!");
end Hello_world;
|
with TH;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
procedure TH_Sujet is
package TH_str_int is
new TH (Capacite => 11, T_Cle => Unbounded_String, T_Donnee => Integer, Hachage => Length);
use TH_str_int;
Donnees : T_TH;
procedure Afficher_Element(Cle: Unbounded_String; Donnee: Integer) is
begin
Put(To_String(Cle) & " -> ");
Put(Donnee, 1);
New_Line;
end Afficher_Element;
procedure Afficher_Elements is
new Pour_Chaque(Afficher_Element);
begin
Initialiser(Donnees);
Enregistrer(Donnees, To_Unbounded_String("un"), 1);
Enregistrer(Donnees, To_Unbounded_String("deux"), 2);
Enregistrer(Donnees, To_Unbounded_String("trois"), 3);
Enregistrer(Donnees, To_Unbounded_String("quatre"), 4);
Enregistrer(Donnees, To_Unbounded_String("cinq"), 5);
Enregistrer(Donnees, To_Unbounded_String("quatre-vingt-dix-neuf"), 99);
Enregistrer(Donnees, To_Unbounded_String("vingt-et-un"), 21);
Put("Elements de la table de hachage.");
Afficher_Elements(Donnees);
Vider(Donnees);
end TH_Sujet;
|
package body Ada.Numerics.dSFMT.Generating is
-- no SIMD version
use type Interfaces.Unsigned_64;
procedure do_recursion (
r : aliased out w128_t;
a, b : aliased w128_t;
lung : aliased in out w128_t)
is
t0, t1, L0, L1 : Unsigned_64;
begin
t0 := a (0);
t1 := a (1);
L0 := lung (0);
L1 := lung (1);
lung (0) :=
Interfaces.Shift_Left (t0, SL1)
xor Interfaces.Shift_Right (L1, 32)
xor Interfaces.Shift_Left (L1, 32)
xor b (0);
lung (1) :=
Interfaces.Shift_Left (t1, SL1)
xor Interfaces.Shift_Right (L0, 32)
xor Interfaces.Shift_Left (L0, 32)
xor b (1);
r (0) :=
Interfaces.Shift_Right (lung (0), SR) xor (lung (0) and MSK1) xor t0;
r (1) :=
Interfaces.Shift_Right (lung (1), SR) xor (lung (1) and MSK2) xor t1;
end do_recursion;
procedure convert_c0o1 (w : aliased in out w128_t) is
d : Long_Float_Array (0 .. 1);
for d'Address use w'Address;
begin
d (0) := d (0) - 1.0;
d (1) := d (1) - 1.0;
end convert_c0o1;
procedure convert_o0c1 (w : aliased in out w128_t) is
d : Long_Float_Array (0 .. 1);
for d'Address use w'Address;
begin
d (0) := 2.0 - d (0);
d (1) := 2.0 - d (1);
end convert_o0c1;
procedure convert_o0o1 (w : aliased in out w128_t) is
d : Long_Float_Array (0 .. 1);
for d'Address use w'Address;
begin
w (0) := w (0) or 1;
w (1) := w (1) or 1;
d (0) := d (0) - 1.0;
d (1) := d (1) - 1.0;
end convert_o0o1;
end Ada.Numerics.dSFMT.Generating;
|
with Ada.Exceptions;
private with Ada.Finalization;
-- Provides routines that prefix the output with the name of the current
-- module.
--
-- Note:
-- If this is instantiated multiple times inside nested declarative regions
-- (e.g. nested subprograms) and the resulting package is "use"d, then calls on
-- Log, etc. in the inner statements will be ambiguious and will not compile.
-- Solution: Prefix the call with the instantiated package name.
generic
Module_Name : in string;
package Generic_Logging is
procedure Log (Message : in String);
procedure Log_Wide (Message : in Wide_String);
procedure Log_Exception (X : in Ada.Exceptions.Exception_Occurrence);
type Auto_Logger is limited private;
private
type Auto_Logger is new Ada.Finalization.Limited_Controlled with null record;
procedure Initialize (Self : in out Auto_Logger);
procedure Finalize (Self : in out Auto_Logger);
end Generic_Logging;
|
-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>
-- MIT license. Please refer to the LICENSE file.
with Ada.Tags; use Ada.Tags;
with Apsepp.Generic_Prot_Integer;
private with Ada.Containers.Hashed_Maps,
Apsepp.Containers,
Apsepp.Tags;
package Apsepp.Test_Node_Class is
-- Evaluate the pre-conditions and class-wide pre-conditions in this
-- package.
pragma Assertion_Policy (Pre'Class => Check);
type Test_Outcome is (Failed, Passed);
type Run_Kind is (Check_Cond, Assert_Cond_And_Run_Test);
function Check_Cond_Run (Kind : Run_Kind) return Boolean
is (case Kind is
when Check_Cond => True,
when Assert_Cond_And_Run_Test => False);
type Test_Node_Count is new Natural;
subtype Test_Node_Index is Test_Node_Count range 1 .. Test_Node_Count'Last;
type Test_Routine_Count is new Natural;
subtype Test_Routine_Index
is Test_Routine_Count range 1 .. Test_Routine_Count'Last;
type Test_Routine is not null access procedure;
procedure Null_Test_Routine is null;
type Test_Assert_Count is new Natural;
package Prot_Test_Assert_Count
is new Generic_Prot_Integer (Test_Assert_Count);
subtype O_P_I_Test_Assert_Count is Prot_Test_Assert_Count.O_P_I_Type;
type Routine_State is record
Routine_Index : Test_Routine_Index;
Assert_Count : O_P_I_Test_Assert_Count;
Assert_Outcome : Test_Outcome;
end record;
type Tag_Routine_State is record
T : Tag;
S : Routine_State;
end record;
-- TODOC: A test node must not have two children with the same tag.
-- <2019-03-02>
-- TODOC: A runner must make sure that only one test node with a given tag
-- is running at a given time. <2019-03-02>
type Test_Node_Interfa is limited interface;
-- PORT: Type_Invariant'Class aspect causes compiler error.
-- 8.3.0 (x86_64-linux-gnu) GCC error:
-- in gnat_to_gnu_entity, at ada/gcc-interface/decl.c:425
-- <2019-06-10>
-- with Type_Invariant'Class
-- => (for all K_1 in 1 .. Test_Node_Interfa.Child_Count
-- => (for all K_2 in 1 .. Test_Node_Interfa.Child_Count
-- => K_2 = K_1 or else Test_Node_Interfa.Child (K_1)'Tag
-- /=
-- Test_Node_Interfa.Child (K_2)'Tag))
-- and then
-- (
-- Test_Node_Interfa.Has_Early_Test
-- or else
-- Test_Node_Interfa.Early_Run_Done
-- );
type Test_Node_Access is not null access all Test_Node_Interfa'Class;
type Test_Node_Array
is array (Test_Node_Index range <>) of Test_Node_Access;
type Test_Node_Array_Access is access Test_Node_Array;
not overriding
function Child_Count (Obj : Test_Node_Interfa)
return Test_Node_Count is abstract;
not overriding
function Child (Obj : Test_Node_Interfa;
K : Test_Node_Index) return Test_Node_Access is abstract
with Pre'Class => K <= Obj.Child_Count;
not overriding
function Routine_Count (Obj : Test_Node_Interfa) return Test_Routine_Count
is abstract;
not overriding
function Routine (Obj : Test_Node_Interfa;
K : Test_Routine_Index) return Test_Routine is abstract
with Pre'Class => K <= Obj.Routine_Count;
-- TODOC: Never called in implementations where Routine_Count returns 0.
-- <2019-03-19>
not overriding
procedure Setup_Routine (Obj : Test_Node_Interfa) is null;
not overriding
function No_Subtasking (Obj : Test_Node_Interfa)
return Boolean is abstract;
not overriding
function Has_Early_Test
(Obj : Test_Node_Interfa) return Boolean is abstract;
not overriding
function Early_Run_Done (Obj : Test_Node_Interfa) return Boolean
is abstract;
not overriding
procedure Early_Run (Obj : in out Test_Node_Interfa) is abstract
with Pre'Class => not Obj.Early_Run_Done,
Post'Class => Obj.Early_Run_Done;
not overriding
procedure Run
(Obj : in out Test_Node_Interfa;
Outcome : out Test_Outcome;
Kind : Run_Kind := Assert_Cond_And_Run_Test)
is abstract
with Post'Class => (case Kind is
when Check_Cond =>
True,
when Assert_Cond_And_Run_Test =>
Obj.Has_Early_Test xor Obj.Early_Run_Done);
procedure Run_Test_Routines (Obj : Test_Node_Interfa'Class;
Outcome : out Test_Outcome;
Kind : Run_Kind)
with Pre => Kind = Assert_Cond_And_Run_Test;
procedure Assert (Node_Tag : Tag; Cond : Boolean; Message : String := "");
private
use Ada.Containers,
Apsepp.Containers,
Apsepp.Tags;
package Routine_State_Hashed_Maps
is new Ada.Containers.Hashed_Maps (Key_Type => Tag,
Element_Type => Routine_State,
Hash => Tag_Hash,
Equivalent_Keys => "=");
type Tag_Routine_State_Array
is array (Index_Type range <>) of Tag_Routine_State;
----------------------------------------------------------------------------
protected Routine_State_Map_Handler is
procedure Reset_Routine_State (Node_Tag : Tag;
Routine_Index : Test_Routine_Index)
with Pre => Node_Tag /= No_Tag,
Post => Invariant;
procedure Increment_Assert_Count (Node_Tag : Tag)
with Pre => Node_Tag /= No_Tag,
Post => Invariant;
procedure Set_Failed_Outcome (Node_Tag : Tag)
with Pre => Node_Tag /= No_Tag,
Post => Invariant;
procedure Get_Assert_Count (Node_Tag : Tag;
Routine_Index : out Test_Routine_Index;
Count : out O_P_I_Test_Assert_Count)
with Pre => Node_Tag /= No_Tag,
Post => Invariant;
procedure Get_Assert_Outcome (Node_Tag : Tag;
Outcome : out Test_Outcome)
with Pre => Node_Tag /= No_Tag,
Post => Invariant;
procedure Delete (Node_Tag : Tag)
with Pre => Node_Tag /= No_Tag,
Post => Invariant;
function Invariant return Boolean;
function Count return Count_Type;
function To_Array return Tag_Routine_State_Array
with Post => To_Array'Result'First = 1
and then
To_Array'Result'Length = Count
and then
(for all R of To_Array'Result => R.T /= No_Tag);
private
T : Tag;
S : Routine_State;
M : Routine_State_Hashed_Maps.Map;
end Routine_State_Map_Handler;
----------------------------------------------------------------------------
end Apsepp.Test_Node_Class;
|
with Ada.Text_IO, Bonacci;
procedure Test_Bonacci is
procedure Print(Name: String; S: Bonacci.Sequence) is
begin
Ada.Text_IO.Put(Name & "(");
for I in S'First .. S'Last-1 loop
Ada.Text_IO.Put(Integer'Image(S(I)) & ",");
end loop;
Ada.Text_IO.Put_Line(Integer'Image(S(S'Last)) & " )");
end Print;
begin
Print("Fibonacci: ", Bonacci.Generate(Bonacci.Start_Fibonacci));
Print("Tribonacci: ", Bonacci.Generate(Bonacci.Start_Tribonacci));
Print("Tetranacci: ", Bonacci.Generate(Bonacci.Start_Tetranacci));
Print("Lucas: ", Bonacci.Generate(Bonacci.Start_Lucas));
Print("Decanacci: ",
Bonacci.Generate((1, 1, 2, 4, 8, 16, 32, 64, 128, 256), 15));
end Test_Bonacci;
|
with
Ada.Streams;
package AdaM.a_Type.signed_integer_type
is
type Item is new a_Type.integer_Type with private;
type View is access all Item'Class;
-- Forge
--
function new_Type (Name : in String := "") return signed_integer_type.view;
overriding
procedure destruct (Self : in out Item);
procedure free (Self : in out signed_integer_type.view);
-- Attributes
--
overriding
function Id (Self : access Item) return AdaM.Id;
overriding
function to_Source (Self : in Item) return text_Vectors.Vector;
function First (Self : in Item) return Long_Long_Integer;
procedure First_is (Self : in out Item; Now : in Long_Long_Integer);
function Last (Self : in Item) return Long_Long_Integer;
procedure Last_is (Self : in out Item; Now : in Long_Long_Integer);
private
type Item is new a_Type.integer_Type with
record
First : Long_Long_Integer := 0;
Last : Long_Long_Integer := Long_Long_Integer'Last;
end record;
-- Streams
--
procedure View_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Self : in View);
procedure View_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Self : out View);
for View'write use View_write;
for View'read use View_read;
end AdaM.a_Type.signed_integer_type;
|
with Ada.Text_IO;
with Ada.Integer_Text_IO;
with PrimeInstances;
with Ada.Containers.Ordered_Sets;
package body Problem_37 is
package IO renames Ada.Text_IO;
package I_IO renames Ada.Integer_Text_IO;
package Integer_Primes renames PrimeInstances.Integer_Primes;
package Integer_Set is new Ada.Containers.Ordered_Sets(Integer);
procedure Solve is
gen : Integer_Primes.Prime_Generator := Integer_Primes.Make_Generator;
primes : Integer_Set.Set;
count : Natural := 0;
sum : Integer := 0;
prime : Integer;
begin
Integer_Primes.Next_Prime(gen, prime); primes.Insert(prime); -- 2
Integer_Primes.Next_Prime(gen, prime); primes.Insert(prime); -- 3
Integer_Primes.Next_Prime(gen, prime); primes.Insert(prime); -- 5
Integer_Primes.Next_Prime(gen, prime); primes.Insert(prime); -- 7
loop
Integer_Primes.Next_Prime(gen, prime);
exit when prime = 1;
primes.Insert(prime);
declare
divisor : Integer := 10;
All_Prime : Boolean := True;
begin
while divisor < prime loop
if not primes.Contains(prime / divisor) or else not primes.Contains(prime mod divisor) then
All_Prime := False;
exit;
end if;
divisor := divisor * 10;
end loop;
if All_Prime then
sum := sum + prime;
count := count + 1;
exit when count = 11;
end if;
end;
end loop;
I_IO.Put(sum);
IO.New_Line;
end Solve;
end Problem_37;
|
pragma License (Unrestricted);
package Ada.Characters.Latin_1 is
pragma Pure;
-- Control characters:
NUL : constant Character := Character'Val (0);
SOH : constant Character := Character'Val (1);
STX : constant Character := Character'Val (2);
ETX : constant Character := Character'Val (3);
EOT : constant Character := Character'Val (4);
ENQ : constant Character := Character'Val (5);
ACK : constant Character := Character'Val (6);
BEL : constant Character := Character'Val (7);
BS : constant Character := Character'Val (8);
HT : constant Character := Character'Val (9);
LF : constant Character := Character'Val (10);
VT : constant Character := Character'Val (11);
FF : constant Character := Character'Val (12);
CR : constant Character := Character'Val (13);
SO : constant Character := Character'Val (14);
SI : constant Character := Character'Val (15);
DLE : constant Character := Character'Val (16);
DC1 : constant Character := Character'Val (17);
DC2 : constant Character := Character'Val (18);
DC3 : constant Character := Character'Val (19);
DC4 : constant Character := Character'Val (20);
NAK : constant Character := Character'Val (21);
SYN : constant Character := Character'Val (22);
ETB : constant Character := Character'Val (23);
CAN : constant Character := Character'Val (24);
EM : constant Character := Character'Val (25);
SUB : constant Character := Character'Val (26);
ESC : constant Character := Character'Val (27);
FS : constant Character := Character'Val (28);
GS : constant Character := Character'Val (29);
RS : constant Character := Character'Val (30);
US : constant Character := Character'Val (31);
-- ISO 646 graphic characters:
Space : constant Character := Character'Val (32); -- ' '
Exclamation : constant Character := Character'Val (33); -- '!'
Quotation : constant Character := Character'Val (34); -- '"'
Number_Sign : constant Character := Character'Val (35); -- '#'
Dollar_Sign : constant Character := Character'Val (36); -- '$'
Percent_Sign : constant Character := Character'Val (37); -- '%'
Ampersand : constant Character := Character'Val (38); -- '&'
Apostrophe : constant Character := Character'Val (39); -- '''
Left_Parenthesis : constant Character := Character'Val (40); -- '('
Right_Parenthesis : constant Character := Character'Val (41); -- ')'
Asterisk : constant Character := Character'Val (42); -- '*'
Plus_Sign : constant Character := Character'Val (43); -- '+'
Comma : constant Character := Character'Val (44); -- ','
Hyphen : constant Character := Character'Val (45); -- '-'
Minus_Sign : Character
renames Hyphen;
Full_Stop : constant Character := Character'Val (46); -- '.'
Solidus : constant Character := Character'Val (47); -- '/'
-- Decimal digits '0' though '9' are at positions 48 through 57
Colon : constant Character := Character'Val (58); -- ':'
Semicolon : constant Character := Character'Val (59); -- ';'
Less_Than_Sign : constant Character := Character'Val (60); -- '<'
Equals_Sign : constant Character := Character'Val (61); -- '='
Greater_Than_Sign : constant Character := Character'Val (62); -- '>'
Question : constant Character := Character'Val (63); -- '?'
Commercial_At : constant Character := Character'Val (64); -- '@'
-- Letters 'A' through 'Z' are at positions 65 through 90
Left_Square_Bracket : constant Character := Character'Val (91); -- '['
Reverse_Solidus : constant Character := Character'Val (92); -- '\'
Right_Square_Bracket : constant Character := Character'Val (93); -- ']'
Circumflex : constant Character := Character'Val (94); -- '^'
Low_Line : constant Character := Character'Val (95); -- '_'
Grave : constant Character := Character'Val (96); -- '`'
LC_A : constant Character := Character'Val (97); -- 'a'
LC_B : constant Character := Character'Val (98); -- 'b'
LC_C : constant Character := Character'Val (99); -- 'c'
LC_D : constant Character := Character'Val (100); -- 'd'
LC_E : constant Character := Character'Val (101); -- 'e'
LC_F : constant Character := Character'Val (102); -- 'f'
LC_G : constant Character := Character'Val (103); -- 'g'
LC_H : constant Character := Character'Val (104); -- 'h'
LC_I : constant Character := Character'Val (105); -- 'i'
LC_J : constant Character := Character'Val (106); -- 'j'
LC_K : constant Character := Character'Val (107); -- 'k'
LC_L : constant Character := Character'Val (108); -- 'l'
LC_M : constant Character := Character'Val (109); -- 'm'
LC_N : constant Character := Character'Val (110); -- 'n'
LC_O : constant Character := Character'Val (111); -- 'o'
LC_P : constant Character := Character'Val (112); -- 'p'
LC_Q : constant Character := Character'Val (113); -- 'q'
LC_R : constant Character := Character'Val (114); -- 'r'
LC_S : constant Character := Character'Val (115); -- 's'
LC_T : constant Character := Character'Val (116); -- 't'
LC_U : constant Character := Character'Val (117); -- 'u'
LC_V : constant Character := Character'Val (118); -- 'v'
LC_W : constant Character := Character'Val (119); -- 'w'
LC_X : constant Character := Character'Val (120); -- 'x'
LC_Y : constant Character := Character'Val (121); -- 'y'
LC_Z : constant Character := Character'Val (122); -- 'z'
Left_Curly_Bracket : constant Character := Character'Val (123); -- '{'
Vertical_Line : constant Character := Character'Val (124); -- '|'
Right_Curly_Bracket : constant Character := Character'Val (125); -- '}'
Tilde : constant Character := Character'Val (126); -- '~'
DEL : constant Character := Character'Val (127);
-- ISO 6429 control characters:
IS4 : Character renames FS;
IS3 : Character renames GS;
IS2 : Character renames RS;
IS1 : Character renames US;
-- modified from here
-- These constants are stored as UTF-8 as a String.
Reserved_128 : constant String :=
Character'Val (16#c2#) & Character'Val (16#80#);
Reserved_129 : constant String :=
Character'Val (16#c2#) & Character'Val (16#81#);
BPH : constant String :=
Character'Val (16#c2#) & Character'Val (16#82#);
NBH : constant String :=
Character'Val (16#c2#) & Character'Val (16#83#);
Reserved_132 : constant String :=
Character'Val (16#c2#) & Character'Val (16#84#);
NEL : constant String :=
Character'Val (16#c2#) & Character'Val (16#85#);
SSA : constant String :=
Character'Val (16#c2#) & Character'Val (16#86#);
ESA : constant String :=
Character'Val (16#c2#) & Character'Val (16#87#);
HTS : constant String :=
Character'Val (16#c2#) & Character'Val (16#88#);
HTJ : constant String :=
Character'Val (16#c2#) & Character'Val (16#89#);
VTS : constant String :=
Character'Val (16#c2#) & Character'Val (16#8a#);
PLD : constant String :=
Character'Val (16#c2#) & Character'Val (16#8b#);
PLU : constant String :=
Character'Val (16#c2#) & Character'Val (16#8c#);
RI : constant String :=
Character'Val (16#c2#) & Character'Val (16#8d#);
SS2 : constant String :=
Character'Val (16#c2#) & Character'Val (16#8e#);
SS3 : constant String :=
Character'Val (16#c2#) & Character'Val (16#8f#);
DCS : constant String :=
Character'Val (16#c2#) & Character'Val (16#90#);
PU1 : constant String :=
Character'Val (16#c2#) & Character'Val (16#91#);
PU2 : constant String :=
Character'Val (16#c2#) & Character'Val (16#92#);
STS : constant String :=
Character'Val (16#c2#) & Character'Val (16#93#);
CCH : constant String :=
Character'Val (16#c2#) & Character'Val (16#94#);
MW : constant String :=
Character'Val (16#c2#) & Character'Val (16#95#);
SPA : constant String :=
Character'Val (16#c2#) & Character'Val (16#96#);
EPA : constant String :=
Character'Val (16#c2#) & Character'Val (16#97#);
SOS : constant String :=
Character'Val (16#c2#) & Character'Val (16#98#);
Reserved_153 : constant String :=
Character'Val (16#c2#) & Character'Val (16#99#);
SCI : constant String :=
Character'Val (16#c2#) & Character'Val (16#9a#);
CSI : constant String :=
Character'Val (16#c2#) & Character'Val (16#9b#);
ST : constant String :=
Character'Val (16#c2#) & Character'Val (16#9c#);
OSC : constant String :=
Character'Val (16#c2#) & Character'Val (16#9d#);
PM : constant String :=
Character'Val (16#c2#) & Character'Val (16#9e#);
APC : constant String :=
Character'Val (16#c2#) & Character'Val (16#9f#);
-- Other graphic characters:
-- Character positions 160 (16#A0#) .. 175 (16#AF#):
No_Break_Space : constant String :=
Character'Val (16#c2#) & Character'Val (16#a0#); -- ' '
NBSP : String
renames No_Break_Space;
Inverted_Exclamation : constant String :=
Character'Val (16#c2#) & Character'Val (16#a1#); -- '¡'
Cent_Sign : constant String :=
Character'Val (16#c2#) & Character'Val (16#a2#); -- '¢'
Pound_Sign : constant String :=
Character'Val (16#c2#) & Character'Val (16#a3#); -- '£'
Currency_Sign : constant String :=
Character'Val (16#c2#) & Character'Val (16#a4#); -- '¤'
Yen_Sign : constant String :=
Character'Val (16#c2#) & Character'Val (16#a5#); -- '¥'
Broken_Bar : constant String :=
Character'Val (16#c2#) & Character'Val (16#a6#); -- '¦'
Section_Sign : constant String :=
Character'Val (16#c2#) & Character'Val (16#a7#); -- '§'
Diaeresis : constant String :=
Character'Val (16#c2#) & Character'Val (16#a8#); -- '¨'
Copyright_Sign : constant String :=
Character'Val (16#c2#) & Character'Val (16#a9#); -- '©'
Feminine_Ordinal_Indicator : constant String :=
Character'Val (16#c2#) & Character'Val (16#aa#); -- 'ª'
Left_Angle_Quotation : constant String :=
Character'Val (16#c2#) & Character'Val (16#ab#); -- '«'
Not_Sign : constant String :=
Character'Val (16#c2#) & Character'Val (16#ac#); -- '¬'
Soft_Hyphen : constant String :=
Character'Val (16#c2#) & Character'Val (16#ad#); -- ' '
Registered_Trade_Mark_Sign : constant String :=
Character'Val (16#c2#) & Character'Val (16#ae#); -- '®'
Macron : constant String :=
Character'Val (16#c2#) & Character'Val (16#af#); -- '¯'
-- Character positions 176 (16#B0#) .. 191 (16#BF#):
Degree_Sign : constant String :=
Character'Val (16#c2#) & Character'Val (16#b0#); -- '°'
Ring_Above : String
renames Degree_Sign;
Plus_Minus_Sign : constant String :=
Character'Val (16#c2#) & Character'Val (16#b1#); -- '±'
Superscript_Two : constant String :=
Character'Val (16#c2#) & Character'Val (16#b2#); -- '²'
Superscript_Three : constant String :=
Character'Val (16#c2#) & Character'Val (16#b3#); -- '³'
Acute : constant String :=
Character'Val (16#c2#) & Character'Val (16#b4#); -- '´'
Micro_Sign : constant String :=
Character'Val (16#c2#) & Character'Val (16#b5#); -- 'µ'
Pilcrow_Sign : constant String :=
Character'Val (16#c2#) & Character'Val (16#b6#); -- '¶'
Paragraph_Sign : String
renames Pilcrow_Sign;
Middle_Dot : constant String :=
Character'Val (16#c2#) & Character'Val (16#b7#); -- '·'
Cedilla : constant String :=
Character'Val (16#c2#) & Character'Val (16#b8#); -- '¸'
Superscript_One : constant String :=
Character'Val (16#c2#) & Character'Val (16#b9#); -- '¹'
Masculine_Ordinal_Indicator : constant String :=
Character'Val (16#c2#) & Character'Val (16#ba#); -- 'º'
Right_Angle_Quotation : constant String :=
Character'Val (16#c2#) & Character'Val (16#bb#); -- '»'
Fraction_One_Quarter : constant String :=
Character'Val (16#c2#) & Character'Val (16#bc#); -- '¼'
Fraction_One_Half : constant String :=
Character'Val (16#c2#) & Character'Val (16#bd#); -- '½'
Fraction_Three_Quarters : constant String :=
Character'Val (16#c2#) & Character'Val (16#be#); -- '¾'
Inverted_Question : constant String :=
Character'Val (16#c2#) & Character'Val (16#bf#); -- '¿'
-- Character positions 192 (16#C0#) .. 207 (16#CF#):
UC_A_Grave : constant String :=
Character'Val (16#c3#) & Character'Val (16#80#); -- 'À'
UC_A_Acute : constant String :=
Character'Val (16#c3#) & Character'Val (16#81#); -- 'Á'
UC_A_Circumflex : constant String :=
Character'Val (16#c3#) & Character'Val (16#82#); -- 'Â'
UC_A_Tilde : constant String :=
Character'Val (16#c3#) & Character'Val (16#83#); -- 'Ã'
UC_A_Diaeresis : constant String :=
Character'Val (16#c3#) & Character'Val (16#84#); -- 'Ä'
UC_A_Ring : constant String :=
Character'Val (16#c3#) & Character'Val (16#85#); -- 'Å'
UC_AE_Diphthong : constant String :=
Character'Val (16#c3#) & Character'Val (16#86#); -- 'Æ'
UC_C_Cedilla : constant String :=
Character'Val (16#c3#) & Character'Val (16#87#); -- 'Ç'
UC_E_Grave : constant String :=
Character'Val (16#c3#) & Character'Val (16#88#); -- 'È'
UC_E_Acute : constant String :=
Character'Val (16#c3#) & Character'Val (16#89#); -- 'É'
UC_E_Circumflex : constant String :=
Character'Val (16#c3#) & Character'Val (16#8a#); -- 'Ê'
UC_E_Diaeresis : constant String :=
Character'Val (16#c3#) & Character'Val (16#8b#); -- 'Ë'
UC_I_Grave : constant String :=
Character'Val (16#c3#) & Character'Val (16#8c#); -- 'Ì'
UC_I_Acute : constant String :=
Character'Val (16#c3#) & Character'Val (16#8d#); -- 'Í'
UC_I_Circumflex : constant String :=
Character'Val (16#c3#) & Character'Val (16#8e#); -- 'Î'
UC_I_Diaeresis : constant String :=
Character'Val (16#c3#) & Character'Val (16#8f#); -- 'Ï'
-- Character positions 208 (16#D0#) .. 223 (16#DF#):
UC_Icelandic_Eth : constant String :=
Character'Val (16#c3#) & Character'Val (16#90#); -- 'Ð'
UC_N_Tilde : constant String :=
Character'Val (16#c3#) & Character'Val (16#91#); -- 'Ñ'
UC_O_Grave : constant String :=
Character'Val (16#c3#) & Character'Val (16#92#); -- 'Ò'
UC_O_Acute : constant String :=
Character'Val (16#c3#) & Character'Val (16#93#); -- 'Ó'
UC_O_Circumflex : constant String :=
Character'Val (16#c3#) & Character'Val (16#94#); -- 'Ô'
UC_O_Tilde : constant String :=
Character'Val (16#c3#) & Character'Val (16#95#); -- 'Õ'
UC_O_Diaeresis : constant String :=
Character'Val (16#c3#) & Character'Val (16#96#); -- 'Ö'
Multiplication_Sign : constant String :=
Character'Val (16#c3#) & Character'Val (16#97#); -- '×'
UC_O_Oblique_Stroke : constant String :=
Character'Val (16#c3#) & Character'Val (16#98#); -- 'Ø'
UC_U_Grave : constant String :=
Character'Val (16#c3#) & Character'Val (16#99#); -- 'Ù'
UC_U_Acute : constant String :=
Character'Val (16#c3#) & Character'Val (16#9a#); -- 'Ú'
UC_U_Circumflex : constant String :=
Character'Val (16#c3#) & Character'Val (16#9b#); -- 'Û'
UC_U_Diaeresis : constant String :=
Character'Val (16#c3#) & Character'Val (16#9c#); -- 'Ü'
UC_Y_Acute : constant String :=
Character'Val (16#c3#) & Character'Val (16#9d#); -- 'Ý'
UC_Icelandic_Thorn : constant String :=
Character'Val (16#c3#) & Character'Val (16#9e#); -- 'Þ'
LC_German_Sharp_S : constant String :=
Character'Val (16#c3#) & Character'Val (16#9f#); -- 'ß'
-- Character positions 224 (16#E0#) .. 239 (16#EF#):
LC_A_Grave : constant String :=
Character'Val (16#c3#) & Character'Val (16#a0#); -- 'à'
LC_A_Acute : constant String :=
Character'Val (16#c3#) & Character'Val (16#a1#); -- 'á'
LC_A_Circumflex : constant String :=
Character'Val (16#c3#) & Character'Val (16#a2#); -- 'â'
LC_A_Tilde : constant String :=
Character'Val (16#c3#) & Character'Val (16#a3#); -- 'ã'
LC_A_Diaeresis : constant String :=
Character'Val (16#c3#) & Character'Val (16#a4#); -- 'ä'
LC_A_Ring : constant String :=
Character'Val (16#c3#) & Character'Val (16#a5#); -- 'å'
LC_AE_Diphthong : constant String :=
Character'Val (16#c3#) & Character'Val (16#a6#); -- 'æ'
LC_C_Cedilla : constant String :=
Character'Val (16#c3#) & Character'Val (16#a7#); -- 'ç'
LC_E_Grave : constant String :=
Character'Val (16#c3#) & Character'Val (16#a8#); -- 'è'
LC_E_Acute : constant String :=
Character'Val (16#c3#) & Character'Val (16#a9#); -- 'é'
LC_E_Circumflex : constant String :=
Character'Val (16#c3#) & Character'Val (16#aa#); -- 'ê'
LC_E_Diaeresis : constant String :=
Character'Val (16#c3#) & Character'Val (16#ab#); -- 'ë'
LC_I_Grave : constant String :=
Character'Val (16#c3#) & Character'Val (16#ac#); -- 'ì'
LC_I_Acute : constant String :=
Character'Val (16#c3#) & Character'Val (16#ad#); -- 'í'
LC_I_Circumflex : constant String :=
Character'Val (16#c3#) & Character'Val (16#ae#); -- 'î'
LC_I_Diaeresis : constant String :=
Character'Val (16#c3#) & Character'Val (16#af#); -- 'ï'
-- Character positions 240 (16#F0#) .. 255 (16#FF#):
LC_Icelandic_Eth : constant String :=
Character'Val (16#c3#) & Character'Val (16#b0#); -- 'ð'
LC_N_Tilde : constant String :=
Character'Val (16#c3#) & Character'Val (16#b1#); -- 'ñ'
LC_O_Grave : constant String :=
Character'Val (16#c3#) & Character'Val (16#b2#); -- 'ò'
LC_O_Acute : constant String :=
Character'Val (16#c3#) & Character'Val (16#b3#); -- 'ó'
LC_O_Circumflex : constant String :=
Character'Val (16#c3#) & Character'Val (16#b4#); -- 'ô'
LC_O_Tilde : constant String :=
Character'Val (16#c3#) & Character'Val (16#b5#); -- 'õ'
LC_O_Diaeresis : constant String :=
Character'Val (16#c3#) & Character'Val (16#b6#); -- 'ö'
Division_Sign : constant String :=
Character'Val (16#c3#) & Character'Val (16#b7#); -- '÷';
LC_O_Oblique_Stroke : constant String :=
Character'Val (16#c3#) & Character'Val (16#b8#); -- 'ø'
LC_U_Grave : constant String :=
Character'Val (16#c3#) & Character'Val (16#b9#); -- 'ù'
LC_U_Acute : constant String :=
Character'Val (16#c3#) & Character'Val (16#ba#); -- 'ú'
LC_U_Circumflex : constant String :=
Character'Val (16#c3#) & Character'Val (16#bb#); -- 'û';
LC_U_Diaeresis : constant String :=
Character'Val (16#c3#) & Character'Val (16#bc#); -- 'ü'
LC_Y_Acute : constant String :=
Character'Val (16#c3#) & Character'Val (16#bd#); -- 'ý'
LC_Icelandic_Thorn : constant String :=
Character'Val (16#c3#) & Character'Val (16#be#); -- 'þ'
LC_Y_Diaeresis : constant String :=
Character'Val (16#c3#) & Character'Val (16#bf#); -- 'ÿ'
end Ada.Characters.Latin_1;
|
--
-- Copyright 2018 The wookey project team <wookey@ssi.gouv.fr>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with ewok.exported.dma; use ewok.exported.dma;
with ewok.sanitize;
with ewok.tasks;
with ewok.interrupts;
with ewok.devices_shared;
with ewok.debug;
#if CONFIG_KERNEL_DOMAIN
with ewok.perm;
#end if;
with soc.dma; use soc.dma;
with soc.dma.interfaces; use soc.dma.interfaces;
with soc.nvic;
package body ewok.dma
with spark_mode => off
is
procedure get_registered_dma_entry
(index : out ewok.dma_shared.t_registered_dma_index;
success : out boolean)
is
begin
for id in registered_dma'range loop
if registered_dma(id).status = DMA_UNUSED then
registered_dma(id).status := DMA_USED;
index := id;
success := true;
return;
end if;
end loop;
success := false;
end get_registered_dma_entry;
function has_same_dma_channel
(index : ewok.dma_shared.t_registered_dma_index;
user_config : ewok.exported.dma.t_dma_user_config)
return boolean
is
begin
if registered_dma(index).config.dma_id =
soc.dma.t_dma_periph_index (user_config.controller)
and
registered_dma(index).config.stream =
soc.dma.t_stream_index (user_config.stream)
and
registered_dma(index).config.channel =
soc.dma.t_channel_index (user_config.channel)
then
return true;
else
return false;
end if;
end has_same_dma_channel;
function stream_is_already_used
(user_config : ewok.exported.dma.t_dma_user_config)
return boolean
is
begin
for index in registered_dma'range loop
if registered_dma(index).status /= DMA_UNUSED then
if registered_dma(index).config.dma_id =
soc.dma.t_dma_periph_index (user_config.controller)
and
registered_dma(index).config.stream =
soc.dma.t_stream_index (user_config.stream)
then
return true;
end if;
end if;
end loop;
return false;
end stream_is_already_used;
function task_owns_dma_stream
(caller_id : ewok.tasks_shared.t_task_id;
dma_id : ewok.exported.dma.t_controller;
stream_id : ewok.exported.dma.t_stream)
return boolean
is
begin
for index in registered_dma'range loop
if registered_dma(index).task_id = caller_id
and then
registered_dma(index).config.dma_id =
soc.dma.t_dma_periph_index (dma_id)
and then
registered_dma(index).config.stream =
soc.dma.t_stream_index (stream_id)
then
return true;
end if;
end loop;
return false;
end task_owns_dma_stream;
procedure enable_dma_stream
(index : in ewok.dma_shared.t_registered_dma_index)
is
begin
if registered_dma(index).status = DMA_CONFIGURED then
soc.dma.interfaces.enable_stream
(registered_dma(index).config.dma_id,
registered_dma(index).config.stream);
end if;
end enable_dma_stream;
procedure disable_dma_stream
(index : in ewok.dma_shared.t_registered_dma_index)
is
begin
if registered_dma(index).status = DMA_CONFIGURED then
soc.dma.interfaces.disable_stream
(registered_dma(index).config.dma_id,
registered_dma(index).config.stream);
end if;
end disable_dma_stream;
procedure enable_dma_irq
(index : in ewok.dma_shared.t_registered_dma_index)
is
-- Peripheral associated with the DMA stream
periph_id : constant soc.devmap.t_periph_id := registered_dma(index).periph_id;
-- DMAs have only one IRQ line per stream
intr : constant soc.interrupts.t_interrupt :=
soc.devmap.periphs(periph_id).interrupt_list
(soc.devmap.t_interrupt_range'first);
begin
soc.nvic.enable_irq (soc.nvic.to_irq_number (intr));
end enable_dma_irq;
function is_config_complete
(config : soc.dma.interfaces.t_dma_config)
return boolean
is
begin
if config.in_addr = 0 or
config.out_addr = 0 or
config.bytes = 0 or
config.transfer_dir = MEMORY_TO_MEMORY or
(config.transfer_dir = MEMORY_TO_PERIPHERAL and config.in_handler = 0)
or
(config.transfer_dir = PERIPHERAL_TO_MEMORY and config.out_handler = 0)
then
return false;
else
return true;
end if;
end is_config_complete;
function sanitize_dma
(user_config : ewok.exported.dma.t_dma_user_config;
caller_id : ewok.tasks_shared.t_task_id;
to_configure : ewok.exported.dma.t_config_mask;
mode : ewok.tasks_shared.t_task_mode)
return boolean
is
begin
case user_config.transfer_dir is
when PERIPHERAL_TO_MEMORY =>
if to_configure.buffer_in then
if not ewok.sanitize.is_word_in_allocated_device
(user_config.in_addr, caller_id)
then
return false;
end if;
end if;
if to_configure.buffer_out then
if not ewok.sanitize.is_range_in_any_slot
(user_config.out_addr, unsigned_32 (user_config.size),
caller_id, mode)
and
not ewok.sanitize.is_range_in_dma_shm
(user_config.out_addr, unsigned_32 (user_config.size),
SHM_ACCESS_WRITE, caller_id)
then
return false;
end if;
end if;
if to_configure.handlers then
if not ewok.sanitize.is_word_in_txt_slot
(user_config.out_handler, caller_id)
then
return false;
end if;
end if;
when MEMORY_TO_PERIPHERAL =>
if to_configure.buffer_in then
if not ewok.sanitize.is_range_in_any_slot
(user_config.in_addr, unsigned_32 (user_config.size),
caller_id, mode)
and
not ewok.sanitize.is_range_in_dma_shm
(user_config.in_addr, unsigned_32 (user_config.size),
SHM_ACCESS_READ, caller_id)
then
return false;
end if;
end if;
if to_configure.buffer_out then
if not ewok.sanitize.is_word_in_allocated_device
(user_config.out_addr, caller_id)
then
return false;
end if;
end if;
if to_configure.handlers then
if not ewok.sanitize.is_word_in_txt_slot
(user_config.in_handler, caller_id)
then
return false;
end if;
end if;
when MEMORY_TO_MEMORY =>
return false;
end case;
return true;
end sanitize_dma;
function sanitize_dma_shm
(shm : ewok.exported.dma.t_dma_shm_info;
caller_id : ewok.tasks_shared.t_task_id;
mode : ewok.tasks_shared.t_task_mode)
return boolean
is
begin
if not ewok.tasks.is_real_user (shm.granted_id) then
pragma DEBUG (debug.log (debug.ERROR, "sanitize_dma_shm(): wrong target"));
return false;
end if;
if shm.accessed_id /= caller_id then
pragma DEBUG (debug.log (debug.ERROR, "sanitize_dma_shm(): wrong caller"));
return false;
end if;
#if CONFIG_KERNEL_DOMAIN
if not ewok.perm.is_same_domain (shm.granted_id, shm.accessed_id) then
pragma DEBUG (debug.log (debug.ERROR, "sanitize_dma_shm(): not same domain"));
return false;
end if;
#end if;
if not ewok.sanitize.is_range_in_data_slot
(shm.base, shm.size, caller_id, mode) and
not ewok.sanitize.is_range_in_devices_slot
(shm.base, shm.size, caller_id)
then
pragma DEBUG (debug.log (debug.ERROR, "sanitize_dma_shm(): shm not in range"));
return false;
end if;
return true;
end sanitize_dma_shm;
procedure reconfigure_stream
(user_config : in out ewok.exported.dma.t_dma_user_config;
index : in ewok.dma_shared.t_registered_dma_index;
to_configure : in ewok.exported.dma.t_config_mask;
caller_id : in ewok.tasks_shared.t_task_id;
success : out boolean)
is
periph_id : constant soc.devmap.t_periph_id := registered_dma(index).periph_id;
ok : boolean;
begin
if not to_configure.buffer_size then
user_config.size := registered_dma(index).config.bytes;
else
registered_dma(index).config.bytes := user_config.size;
end if;
if to_configure.buffer_in then
registered_dma(index).config.in_addr := user_config.in_addr;
end if;
if to_configure.buffer_out then
registered_dma(index).config.out_addr := user_config.out_addr;
end if;
if to_configure.mode then
registered_dma(index).config.mode := user_config.mode;
end if;
if to_configure.priority then
case user_config.transfer_dir is
when PERIPHERAL_TO_MEMORY =>
registered_dma(index).config.out_priority :=
user_config.out_priority;
when MEMORY_TO_PERIPHERAL =>
registered_dma(index).config.in_priority :=
user_config.in_priority;
when MEMORY_TO_MEMORY =>
pragma DEBUG (debug.log
(debug.ERROR,
"reconfigure_stream(): MEMORY_TO_MEMORY not implemented"));
success := false;
return;
end case;
end if;
if to_configure.direction then
registered_dma(index).config.transfer_dir := user_config.transfer_dir;
end if;
if to_configure.handlers then
case user_config.transfer_dir is
when PERIPHERAL_TO_MEMORY =>
registered_dma(index).config.out_handler :=
user_config.out_handler;
ewok.interrupts.set_interrupt_handler
(soc.devmap.periphs(periph_id).interrupt_list(soc.devmap.t_interrupt_range'first),
ewok.interrupts.to_handler_access (user_config.out_handler),
caller_id,
ewok.devices_shared.ID_DEV_UNUSED,
ok);
if not ok then
raise program_error;
end if;
when MEMORY_TO_PERIPHERAL =>
registered_dma(index).config.in_handler :=
user_config.in_handler;
ewok.interrupts.set_interrupt_handler
(soc.devmap.periphs(periph_id).interrupt_list (soc.devmap.t_interrupt_range'first),
ewok.interrupts.to_handler_access (user_config.in_handler),
caller_id,
ewok.devices_shared.ID_DEV_UNUSED,
ok);
if not ok then
raise program_error;
end if;
when MEMORY_TO_MEMORY =>
pragma DEBUG (debug.log (debug.ERROR, "reconfigure_stream(): MEMORY_TO_MEMORY not implemented"));
success := false;
return;
end case;
end if;
--
-- Configuring the DMA
--
soc.dma.interfaces.reconfigure_stream
(registered_dma(index).config.dma_id,
registered_dma(index).config.stream,
registered_dma(index).config,
soc.dma.interfaces.t_config_mask (to_configure));
if is_config_complete (registered_dma(index).config) then
registered_dma(index).status := DMA_CONFIGURED;
soc.dma.interfaces.enable_stream
(registered_dma(index).config.dma_id,
registered_dma(index).config.stream);
else
registered_dma(index).status := DMA_USED;
end if;
success := true;
end reconfigure_stream;
procedure init_stream
(user_config : in ewok.exported.dma.t_dma_user_config;
caller_id : in ewok.tasks_shared.t_task_id;
index : out ewok.dma_shared.t_registered_dma_index;
success : out boolean)
is
periph_id : soc.devmap.t_periph_id;
ok : boolean;
begin
-- Find a free entry in the registered_dma array
get_registered_dma_entry (index, ok);
if not ok then
pragma DEBUG (debug.log ("dma.init(): no DMA entry available"));
success := false;
return;
end if;
-- Copy the user configuration
registered_dma(index).config :=
(dma_id => soc.dma.t_dma_periph_index (user_config.controller),
stream => soc.dma.t_stream_index (user_config.stream),
channel => soc.dma.t_channel_index (user_config.channel),
bytes => user_config.size,
in_addr => user_config.in_addr,
in_priority => user_config.in_priority,
in_handler => user_config.in_handler,
out_addr => user_config.out_addr,
out_priority => user_config.out_priority,
out_handler => user_config.out_handler,
flow_controller => user_config.flow_controller,
transfer_dir => user_config.transfer_dir,
mode => user_config.mode,
data_size => user_config.data_size,
memory_inc => boolean (user_config.memory_inc),
periph_inc => boolean (user_config.periph_inc),
mem_burst_size => user_config.mem_burst_size,
periph_burst_size => user_config.periph_burst_size);
registered_dma(index).task_id := caller_id;
registered_dma(index).periph_id :=
soc.devmap.find_dma_periph
(soc.dma.t_dma_periph_index (user_config.controller),
soc.dma.t_stream_index (user_config.stream));
periph_id := registered_dma(index).periph_id;
-- Set up the interrupt handler
case user_config.transfer_dir is
when PERIPHERAL_TO_MEMORY =>
if user_config.out_handler /= 0 then
ewok.interrupts.set_interrupt_handler
(soc.devmap.periphs(periph_id).interrupt_list(soc.devmap.t_interrupt_range'first),
ewok.interrupts.to_handler_access (user_config.out_handler),
caller_id,
ewok.devices_shared.ID_DEV_UNUSED,
ok);
if not ok then
raise program_error;
end if;
end if;
when MEMORY_TO_PERIPHERAL =>
if user_config.in_handler /= 0 then
ewok.interrupts.set_interrupt_handler
(soc.devmap.periphs(periph_id).interrupt_list(soc.devmap.t_interrupt_range'first),
ewok.interrupts.to_handler_access (user_config.in_handler),
caller_id,
ewok.devices_shared.ID_DEV_UNUSED,
ok);
if not ok then
raise program_error;
end if;
end if;
when MEMORY_TO_MEMORY =>
pragma DEBUG (debug.log ("dma.init(): MEMORY_TO_MEMORY not implemented"));
success := false;
return;
end case;
if is_config_complete (registered_dma(index).config) then
registered_dma(index).status := DMA_CONFIGURED;
else
registered_dma(index).status := DMA_USED;
end if;
-- Reset the DMA stream
soc.dma.interfaces.reset_stream
(registered_dma(index).config.dma_id,
registered_dma(index).config.stream);
-- Configure the DMA stream
soc.dma.interfaces.configure_stream
(registered_dma(index).config.dma_id,
registered_dma(index).config.stream,
registered_dma(index).config);
success := true;
end init_stream;
procedure init
is
begin
soc.dma.enable_clocks;
end init;
procedure clear_dma_interrupts
(caller_id : in ewok.tasks_shared.t_task_id;
interrupt : in soc.interrupts.t_interrupt)
is
soc_dma_id : soc.dma.t_dma_periph_index;
soc_stream_id : soc.dma.t_stream_index;
ok : boolean;
begin
soc.dma.get_dma_stream_from_interrupt
(interrupt, soc_dma_id, soc_stream_id, ok);
if not ok then
raise program_error;
end if;
if not task_owns_dma_stream (caller_id, t_controller (soc_dma_id),
t_stream (soc_stream_id))
then
raise program_error;
end if;
soc.dma.interfaces.clear_all_interrupts
(soc_dma_id, soc_stream_id);
end clear_dma_interrupts;
procedure get_status_register
(caller_id : in ewok.tasks_shared.t_task_id;
interrupt : in soc.interrupts.t_interrupt;
status : out soc.dma.t_dma_stream_int_status;
success : out boolean)
is
soc_dma_id : soc.dma.t_dma_periph_index;
soc_stream_id : soc.dma.t_stream_index;
ok : boolean;
begin
soc.dma.get_dma_stream_from_interrupt
(interrupt, soc_dma_id, soc_stream_id, ok);
if not ok then
success := false;
return;
end if;
if not task_owns_dma_stream (caller_id,
t_controller (soc_dma_id),
t_stream (soc_stream_id))
then
success := false;
return;
end if;
status := soc.dma.interfaces.get_interrupt_status
(soc_dma_id, soc_stream_id);
soc.dma.interfaces.clear_all_interrupts (soc_dma_id, soc_stream_id);
success := true;
end get_status_register;
procedure release_stream
(caller_id : in ewok.tasks_shared.t_task_id;
index : in ewok.dma_shared.t_registered_dma_index;
success : out boolean)
is
periph_id : soc.devmap.t_periph_id;
begin
if registered_dma(index).status = DMA_UNUSED or
registered_dma(index).task_id /= caller_id
then
success := false;
return;
end if;
soc.dma.interfaces.reset_stream
(registered_dma(index).config.dma_id,
registered_dma(index).config.stream);
periph_id := registered_dma(index).periph_id;
if registered_dma(index).config.in_handler /= 0 or
registered_dma(index).config.out_handler /= 0
then
ewok.interrupts.reset_interrupt_handler
(soc.devmap.periphs(periph_id).interrupt_list(soc.devmap.t_interrupt_range'first),
caller_id,
ewok.devices_shared.ID_DEV_UNUSED);
registered_dma(index).config.in_handler := 0;
registered_dma(index).config.out_handler := 0;
end if;
registered_dma(index).status := DMA_UNUSED;
registered_dma(index).periph_id := soc.devmap.NO_PERIPH;
registered_dma(index).task_id := ID_UNUSED;
success := true;
end release_stream;
end ewok.dma;
|
-- CD4031A.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- OBJECTIVE:
-- CHECK THAT WHEN A RECORD REPRESENTATION CLAUSE IS GIVEN FOR A
-- VARIANT RECORD TYPE, THEN COMPONENTS BELONGING TO DIFFERENT
-- VARIANTS CAN BE GIVEN OVERLAPPING STORAGE.
-- HISTORY:
-- PWB 07/22/87 CREATED ORIGINAL TEST.
-- DHH 03/27/89 CHANGED EXTENSION FROM '.DEP' TO '.ADA' AND
-- ADDED CHECK FOR REPRESENTATION CLAUSE.
-- RJW 06/12/90 REMOVED REFERENCES TO LENGTH_CHECK. REVISED
-- COMMENTS.
-- JRL 10/13/96 Adjusted ranges in type definitions to allow 1's
-- complement machines to represent all values in
-- the specified number of bits.
WITH REPORT; USE REPORT;
PROCEDURE CD4031A IS
TYPE DISCRIMINAN IS RANGE -1 .. 1;
TYPE INT IS RANGE -3 .. 3;
TYPE LARGE_INT IS RANGE -7 .. 7;
TYPE TEST_CLAUSE (DISC : DISCRIMINAN := 0) IS
RECORD
CASE DISC IS
WHEN 0 =>
INTEGER_COMP : LARGE_INT;
WHEN OTHERS =>
CH_COMP_1 : INT;
CH_COMP_2 : INT;
END CASE;
END RECORD;
FOR TEST_CLAUSE USE
RECORD
DISC AT 0
RANGE 0 .. 1;
INTEGER_COMP AT 0
RANGE 2 .. 5;
CH_COMP_1 AT 0
RANGE 2 .. 4;
CH_COMP_2 AT 0
RANGE 5 .. 7;
END RECORD;
TYPE TEST_CL1 IS NEW TEST_CLAUSE(DISC => 0);
TYPE TEST_CL2 IS NEW TEST_CLAUSE(DISC => 1);
TEST_RECORD : TEST_CL1;
TEST_RECORD1 : TEST_CL2;
INTEGER_COMP_FIRST,
CH_COMP_1_FIRST : INTEGER;
BEGIN
TEST ("CD4031A", "IN RECORD REPRESENTATION CLAUSES " &
"FOR VARIANT RECORD TYPES, " &
"COMPONENTS OF DIFFERENT VARIANTS " &
"CAN BE GIVEN OVERLAPPING STORAGE");
TEST_RECORD := (0, -7);
INTEGER_COMP_FIRST := TEST_RECORD.INTEGER_COMP'FIRST_BIT;
TEST_RECORD1 := (1, -3, -3);
CH_COMP_1_FIRST := TEST_RECORD1.CH_COMP_1'FIRST_BIT;
IF INTEGER_COMP_FIRST /= CH_COMP_1_FIRST THEN
FAILED ("COMPONENTS DO NOT BEGIN AT SAME POINT");
END IF;
RESULT;
END CD4031A;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Delegation is
package Things is
-- We need a common root for our stuff
type Object is tagged null record;
type Object_Ptr is access all Object'Class;
-- Objects that have operation thing
type Substantial is new Object with null record;
function Thing (X : Substantial) return String;
-- Delegator objects
type Delegator is new Object with record
Delegate : Object_Ptr;
end record;
function Operation (X : Delegator) return String;
No_Thing : aliased Object; -- Does not have thing
Has_Thing : aliased Substantial; -- Has one
end Things;
package body Things is
function Thing (X : Substantial) return String is
begin
return "delegate implementation";
end Thing;
function Operation (X : Delegator) return String is
begin
if X.Delegate /= null and then X.Delegate.all in Substantial'Class then
return Thing (Substantial'Class (X.Delegate.all));
else
return "default implementation";
end if;
end Operation;
end Things;
use Things;
A : Delegator; -- Without a delegate
begin
Put_Line (A.Operation);
A.Delegate := No_Thing'Access; -- Set no thing
Put_Line (A.Operation);
A.Delegate := Has_Thing'Access; -- Set a thing
Put_Line (A.Operation);
end Delegation;
|
procedure Ada.Unchecked_Deallocate_Subpool (
Subpool : in out System.Storage_Pools.Subpools.Subpool_Handle)
is
pragma Suppress (All_Checks);
begin
System.Storage_Pools.Subpools.Unchecked_Deallocate_Subpool (Subpool);
end Ada.Unchecked_Deallocate_Subpool;
|
with AUnit.Assertions; use AUnit.Assertions;
package body Day.Test is
procedure Test_Part1 (T : in out AUnit.Test_Cases.Test_Case'Class) is
pragma Unreferenced (T);
f : constant Ferry := load_file("test1.txt");
d : constant Natural := distance(f);
begin
Assert(d = 25, "Wrong number, expected 25, got" & Natural'IMAGE(d));
end Test_Part1;
procedure Test_Part2 (T : in out AUnit.Test_Cases.Test_Case'Class) is
pragma Unreferenced (T);
f : constant Ferry := load_file("test1.txt");
d : constant Natural := waypoint_distance(f);
begin
Assert(d = 286, "Wrong number, expected 286, got" & Natural'IMAGE(d));
end Test_Part2;
function Name (T : Test) return AUnit.Message_String is
pragma Unreferenced (T);
begin
return AUnit.Format ("Test Day package");
end Name;
procedure Register_Tests (T : in out Test) is
use AUnit.Test_Cases.Registration;
begin
Register_Routine (T, Test_Part1'Access, "Test Part 1");
Register_Routine (T, Test_Part2'Access, "Test Part 2");
end Register_Tests;
end Day.Test;
|
------------------------------------------------------------------------------
-- A d a r u n - t i m e s p e c i f i c a t i o n --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of ada.ads file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
with Ada.Numerics.Generic_Complex_Types;
generic
with package Complex_Types is
new Ada.Numerics.Generic_Complex_Types (<>);
package Ada.Wide_Wide_Text_IO.Complex_IO is
use Complex_Types;
Default_Fore : Field := 2;
Default_Aft : Field := Real'Digits - 1;
Default_Exp : Field := 3;
procedure Get (File : in File_Type;
Item : out Complex;
Width : in Field := 0);
procedure Get (Item : out Complex;
Width : in Field := 0);
procedure Put (File : in File_Type;
Item : in Complex;
Fore : in Field := Default_Fore;
Aft : in Field := Default_Aft;
Exp : in Field := Default_Exp);
procedure Put (Item : in Complex;
Fore : in Field := Default_Fore;
Aft : in Field := Default_Aft;
Exp : in Field := Default_Exp);
procedure Get (From : in Wide_Wide_String;
Item : out Complex;
Last : out Positive);
procedure Put (To : out Wide_Wide_String;
Item : in Complex;
Aft : in Field := Default_Aft;
Exp : in Field := Default_Exp);
end Ada.Wide_Wide_Text_IO.Complex_IO;
|
-- 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.FLEXCOMM is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Peripheral Select. This field is writable by software.
type PSELID_PERSEL_Field is
(
-- No peripheral selected.
No_Periph_Selected,
-- USART function selected.
Usart,
-- SPI function selected.
Spi,
-- I2C function selected.
I2C,
-- I2S transmit function selected.
I2S_Transmit,
-- I2S receive function selected.
I2S_Receive)
with Size => 3;
for PSELID_PERSEL_Field use
(No_Periph_Selected => 0,
Usart => 1,
Spi => 2,
I2C => 3,
I2S_Transmit => 4,
I2S_Receive => 5);
-- Lock the peripheral select. This field is writable by software.
type PSELID_LOCK_Field is
(
-- Peripheral select can be changed by software.
Unlocked,
-- Peripheral select is locked and cannot be changed until this Flexcomm
-- or the entire device is reset.
Locked)
with Size => 1;
for PSELID_LOCK_Field use
(Unlocked => 0,
Locked => 1);
-- USART present indicator. This field is Read-only.
type PSELID_USARTPRESENT_Field is
(
-- This Flexcomm does not include the USART function.
Not_Present,
-- This Flexcomm includes the USART function.
Present)
with Size => 1;
for PSELID_USARTPRESENT_Field use
(Not_Present => 0,
Present => 1);
-- SPI present indicator. This field is Read-only.
type PSELID_SPIPRESENT_Field is
(
-- This Flexcomm does not include the SPI function.
Not_Present,
-- This Flexcomm includes the SPI function.
Present)
with Size => 1;
for PSELID_SPIPRESENT_Field use
(Not_Present => 0,
Present => 1);
-- I2C present indicator. This field is Read-only.
type PSELID_I2CPRESENT_Field is
(
-- This Flexcomm does not include the I2C function.
Not_Present,
-- This Flexcomm includes the I2C function.
Present)
with Size => 1;
for PSELID_I2CPRESENT_Field use
(Not_Present => 0,
Present => 1);
-- I 2S present indicator. This field is Read-only.
type PSELID_I2SPRESENT_Field is
(
-- This Flexcomm does not include the I2S function.
Not_Present,
-- This Flexcomm includes the I2S function.
Present)
with Size => 1;
for PSELID_I2SPRESENT_Field use
(Not_Present => 0,
Present => 1);
subtype PSELID_ID_Field is HAL.UInt20;
-- Peripheral Select and Flexcomm ID register.
type PSELID_Register is record
-- Peripheral Select. This field is writable by software.
PERSEL : PSELID_PERSEL_Field :=
NXP_SVD.FLEXCOMM.No_Periph_Selected;
-- Lock the peripheral select. This field is writable by software.
LOCK : PSELID_LOCK_Field := NXP_SVD.FLEXCOMM.Unlocked;
-- Read-only. USART present indicator. This field is Read-only.
USARTPRESENT : PSELID_USARTPRESENT_Field :=
NXP_SVD.FLEXCOMM.Not_Present;
-- Read-only. SPI present indicator. This field is Read-only.
SPIPRESENT : PSELID_SPIPRESENT_Field := NXP_SVD.FLEXCOMM.Not_Present;
-- Read-only. I2C present indicator. This field is Read-only.
I2CPRESENT : PSELID_I2CPRESENT_Field := NXP_SVD.FLEXCOMM.Not_Present;
-- Read-only. I 2S present indicator. This field is Read-only.
I2SPRESENT : PSELID_I2SPRESENT_Field := NXP_SVD.FLEXCOMM.Not_Present;
-- unspecified
Reserved_8_11 : HAL.UInt4 := 16#0#;
-- Read-only. Flexcomm ID.
ID : PSELID_ID_Field := 16#101#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PSELID_Register use record
PERSEL at 0 range 0 .. 2;
LOCK at 0 range 3 .. 3;
USARTPRESENT at 0 range 4 .. 4;
SPIPRESENT at 0 range 5 .. 5;
I2CPRESENT at 0 range 6 .. 6;
I2SPRESENT at 0 range 7 .. 7;
Reserved_8_11 at 0 range 8 .. 11;
ID at 0 range 12 .. 31;
end record;
subtype PID_APERTURE_Field is HAL.UInt8;
subtype PID_MINOR_REV_Field is HAL.UInt4;
subtype PID_MAJOR_REV_Field is HAL.UInt4;
subtype PID_ID_Field is HAL.UInt16;
-- Peripheral identification register.
type PID_Register is record
-- Read-only. size aperture for the register port on the bus (APB or
-- AHB).
APERTURE : PID_APERTURE_Field;
-- Read-only. Minor revision of module implementation.
MINOR_REV : PID_MINOR_REV_Field;
-- Read-only. Major revision of module implementation.
MAJOR_REV : PID_MAJOR_REV_Field;
-- Read-only. Module identifier for the selected function.
ID : PID_ID_Field;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PID_Register use record
APERTURE at 0 range 0 .. 7;
MINOR_REV at 0 range 8 .. 11;
MAJOR_REV at 0 range 12 .. 15;
ID at 0 range 16 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Flexcomm serial communication
type FLEXCOMM_Peripheral is record
-- Peripheral Select and Flexcomm ID register.
PSELID : aliased PSELID_Register;
-- Peripheral identification register.
PID : aliased PID_Register;
end record
with Volatile;
for FLEXCOMM_Peripheral use record
PSELID at 16#FF8# range 0 .. 31;
PID at 16#FFC# range 0 .. 31;
end record;
-- Flexcomm serial communication
FLEXCOMM0_Periph : aliased FLEXCOMM_Peripheral
with Import, Address => System'To_Address (16#40086000#);
-- Flexcomm serial communication
FLEXCOMM1_Periph : aliased FLEXCOMM_Peripheral
with Import, Address => System'To_Address (16#40087000#);
-- Flexcomm serial communication
FLEXCOMM2_Periph : aliased FLEXCOMM_Peripheral
with Import, Address => System'To_Address (16#40088000#);
-- Flexcomm serial communication
FLEXCOMM3_Periph : aliased FLEXCOMM_Peripheral
with Import, Address => System'To_Address (16#40089000#);
-- Flexcomm serial communication
FLEXCOMM4_Periph : aliased FLEXCOMM_Peripheral
with Import, Address => System'To_Address (16#4008A000#);
-- Flexcomm serial communication
FLEXCOMM5_Periph : aliased FLEXCOMM_Peripheral
with Import, Address => System'To_Address (16#40096000#);
-- Flexcomm serial communication
FLEXCOMM6_Periph : aliased FLEXCOMM_Peripheral
with Import, Address => System'To_Address (16#40097000#);
-- Flexcomm serial communication
FLEXCOMM7_Periph : aliased FLEXCOMM_Peripheral
with Import, Address => System'To_Address (16#40098000#);
-- Flexcomm serial communication
FLEXCOMM8_Periph : aliased FLEXCOMM_Peripheral
with Import, Address => System'To_Address (16#4009F000#);
end NXP_SVD.FLEXCOMM;
|
-------------------------------------------------------------------------------
-- Copyright (c) 2016 Daniel King
--
-- 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.Real_Time; use Ada.Real_Time;
with DecaDriver;
with DW1000.BSP;
with DW1000.Driver; use DW1000.Driver;
with DW1000.Types;
-- This simple example demonstrates using the DW1000 to receive packets.
procedure Receive_Example
with SPARK_Mode,
Global => (Input => Ada.Real_Time.Clock_Time,
In_Out => (DW1000.BSP.Device_State,
DecaDriver.Driver)),
Depends => (DecaDriver.Driver =>+ DW1000.BSP.Device_State,
DW1000.BSP.Device_State =>+ DecaDriver.Driver,
null => Ada.Real_Time.Clock_Time)
is
Rx_Packet : DW1000.Types.Byte_Array (1 .. 127) := (others => 0);
Rx_Packet_Length : DecaDriver.Frame_Length_Number;
Rx_Frame_Info : DecaDriver.Frame_Info_Type;
Rx_Status : DecaDriver.Rx_Status_Type;
Rx_Overrun : Boolean;
begin
-- Driver must be initialized once before it is used.
DecaDriver.Driver.Initialize
(Load_Antenna_Delay => True,
Load_XTAL_Trim => True,
Load_UCode_From_ROM => True);
-- Configure the DW1000
DecaDriver.Driver.Configure
(DecaDriver.Configuration_Type'
(Channel => 1,
PRF => PRF_64MHz,
Tx_Preamble_Length => PLEN_1024,
Rx_PAC => PAC_8,
Tx_Preamble_Code => 9,
Rx_Preamble_Code => 9,
Use_Nonstandard_SFD => False,
Data_Rate => Data_Rate_110k,
PHR_Mode => Standard_Frames,
SFD_Timeout => 1024 + 64 + 1));
-- We don't need to configure the transmit power in this example, because
-- we don't transmit any frames!
-- Enable the LEDs controlled by the DW1000.
DW1000.Driver.Configure_LEDs
(Tx_LED_Enable => True, -- Enable transmit LED
Rx_LED_Enable => True, -- Enable receive LED
Rx_OK_LED_Enable => False,
SFD_LED_Enable => False,
Test_Flash => True); -- Flash both LEDs once
-- In this example we only want to receive valid packets without errors,
-- so configure the DW1000 to automatically re-enable the receiver when
-- errors occur. The driver will not be notified of receiver errors whilst
-- this is enabled.
DW1000.Driver.Set_Auto_Rx_Reenable (Enable => True);
-- Continuously receive packets
loop
-- Enable the receiver to listen for a packet
DecaDriver.Driver.Start_Rx_Immediate;
-- Wait for a packet
DecaDriver.Driver.Rx_Wait
(Frame => Rx_Packet,
Length => Rx_Packet_Length,
Frame_Info => Rx_Frame_Info,
Status => Rx_Status,
Overrun => Rx_Overrun);
-- When execution has reached here then a packet has been received
-- successfully.
end loop;
end Receive_Example;
|
with Protypo.Api.Engine_Values.Array_Wrappers;
package Integer_Arrays is
type Int_Array is array (Positive range <>) of Integer;
package Wrappers is
new Protypo.Api.Engine_Values.Array_Wrappers
(Element_Type => Integer,
Array_Type => Int_Array,
Create => Protypo.Api.Engine_Values.Create);
end Integer_Arrays;
|
-----------------------------------------------------------------------
-- openapi-credentials-oauth -- OAuth2 client credentials
-- Copyright (C) 2018, 2022 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body OpenAPI.Credentials.OAuth is
use Ada.Strings.Unbounded;
-- ------------------------------
-- Set the credentials on the HTTP client request before doing the call.
-- ------------------------------
overriding
procedure Set_Credentials (Credential : in OAuth2_Credential_Type;
Into : in out Util.Http.Clients.Client'Class) is
begin
Into.Set_Header (Name => "Authorization",
Value => "Bearer " & Credential.Token.Get_Name);
end Set_Credentials;
-- ------------------------------
-- Request a OAuth token with username and password credential.
-- Upon successful completion, the credential contains an access token that
-- can be used to authorize REST operations.
-- ------------------------------
procedure Request_Token (Credential : in out OAuth2_Credential_Type;
Username : in String;
Password : in String;
Scope : in String) is
begin
Credential.Scope := To_Unbounded_String (Scope);
Credential.Request_Token (Username, Password, Scope, Credential.Token);
end Request_Token;
-- ------------------------------
-- Refresh the OAuth access token with the refresh token.
-- ------------------------------
procedure Refresh_Token (Credential : in out OAuth2_Credential_Type) is
begin
Credential.Refresh_Token (To_String (Credential.Scope), Credential.Token);
end Refresh_Token;
end OpenAPI.Credentials.OAuth;
|
C:\Users\Noah Lie\OneDrive\Desktop\snek>"C:\Users\Noah Lie\OneDrive\Desktop\snek\bin\Debug\net5.0\snek"
O hmmm.. Reading C:\Users\Noah Lie\SnekTheGam\Storage.json
Window handle is invalid, cannot resume.
Full message:
System.IO.IOException: The handle is invalid.
at System.ConsolePal.Clear()
at System.Console.Clear()
at SnekTheGam.Program.Main(String[] args) in C:\Users\Noah Lie\OneDrive\Desktop\snek\Program.cs:line 309
|
------------------------------------------------------------------------------
-- Copyright (c) 2013, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
package body Natools.S_Expressions.Encodings is
--------------------------
-- Hexadecimal Decoding --
--------------------------
function Is_Hex_Digit (Value : in Octet) return Boolean is
begin
case Value is
when Digit_0 .. Digit_9 => return True;
when Lower_A .. Lower_F => return True;
when Upper_A .. Upper_F => return True;
when others => return False;
end case;
end Is_Hex_Digit;
function Decode_Hex (Value : in Octet) return Octet is
begin
case Value is
when Digit_0 .. Digit_9 => return Value - Digit_0;
when Lower_A .. Lower_F => return Value - Lower_A + 10;
when Upper_A .. Upper_F => return Value - Upper_A + 10;
when others => raise Constraint_Error;
end case;
end Decode_Hex;
function Decode_Hex (High, Low : in Octet) return Octet is
begin
return Decode_Hex (High) * 16 + Decode_Hex (Low);
end Decode_Hex;
function Decode_Hex (Data : in Atom) return Atom is
Length : Count := 0;
begin
for I in Data'Range loop
if Is_Hex_Digit (Data (I)) then
Length := Length + 1;
end if;
end loop;
Length := (Length + 1) / 2;
return Result : Atom (0 .. Length - 1) do
declare
O : Offset := Result'First;
High : Octet := 0;
Has_High : Boolean := False;
begin
for I in Data'Range loop
if Is_Hex_Digit (Data (I)) then
if Has_High then
Result (O) := Decode_Hex (High, Data (I));
O := O + 1;
High := 0;
Has_High := False;
else
High := Data (I);
Has_High := True;
end if;
end if;
end loop;
if Has_High then
Result (O) := Decode_Hex (High, Digit_0);
O := O + 1;
end if;
pragma Assert (O - 1 = Result'Last);
end;
end return;
end Decode_Hex;
--------------------------
-- Hexadecimal Encoding --
--------------------------
function Encode_Hex (Value : in Octet; Casing : in Hex_Casing)
return Octet is
begin
case Value is
when 0 .. 9 =>
return Digit_0 + Value;
when 10 .. 15 =>
case Casing is
when Upper => return Upper_A + Value - 10;
when Lower => return Lower_A + Value - 10;
end case;
when others =>
raise Constraint_Error;
end case;
end Encode_Hex;
procedure Encode_Hex
(Value : in Octet;
Casing : in Hex_Casing;
High, Low : out Octet) is
begin
High := Encode_Hex (Value / 2**4 mod 2**4, Casing);
Low := Encode_Hex (Value mod 2**4, Casing);
end Encode_Hex;
function Encode_Hex (Data : in Atom; Casing : in Hex_Casing) return Atom is
Result : Atom (0 .. Data'Length * 2 - 1);
Cursor : Offset := Result'First;
begin
for I in Data'Range loop
Encode_Hex (Data (I), Casing, Result (Cursor), Result (Cursor + 1));
Cursor := Cursor + 2;
end loop;
pragma Assert (Cursor = Result'Last + 1);
return Result;
end Encode_Hex;
----------------------
-- Base-64 Decoding --
----------------------
function Is_Base64_Digit (Value : in Octet) return Boolean is
begin
return Value in Digit_0 .. Digit_9
or Value in Lower_A .. Lower_Z
or Value in Upper_A .. Upper_Z
or Value = Plus
or Value = Slash;
end Is_Base64_Digit;
function Decode_Base64 (Value : in Octet) return Octet is
begin
case Value is
when Upper_A .. Upper_Z => return Value - Upper_A + 0;
when Lower_A .. Lower_Z => return Value - Lower_A + 26;
when Digit_0 .. Digit_9 => return Value - Digit_0 + 52;
when Plus => return 62;
when Slash => return 63;
when others => raise Constraint_Error;
end case;
end Decode_Base64;
function Decode_Base64 (A, B : in Octet) return Atom is
VA : constant Octet := Decode_Base64 (A);
VB : constant Octet := Decode_Base64 (B);
begin
return (0 => VA * 2**2 + VB / 2**4);
end Decode_Base64;
function Decode_Base64 (A, B, C : in Octet) return Atom is
VA : constant Octet := Decode_Base64 (A);
VB : constant Octet := Decode_Base64 (B);
VC : constant Octet := Decode_Base64 (C);
begin
return (0 => VA * 2**2 + VB / 2**4,
1 => VB * 2**4 + VC / 2**2);
end Decode_Base64;
function Decode_Base64 (A, B, C, D : in Octet) return Atom is
VA : constant Octet := Decode_Base64 (A);
VB : constant Octet := Decode_Base64 (B);
VC : constant Octet := Decode_Base64 (C);
VD : constant Octet := Decode_Base64 (D);
begin
return (0 => VA * 2**2 + VB / 2**4,
1 => VB * 2**4 + VC / 2**2,
2 => VC * 2**6 + VD);
end Decode_Base64;
function Decode_Base64 (Data : in Atom) return Atom is
Length : Count := 0;
begin
for I in Data'Range loop
if Is_Base64_Digit (Data (I)) then
Length := Length + 1;
end if;
end loop;
declare
Chunks : constant Count := Length / 4;
Remains : constant Count := Length mod 4;
begin
if Remains >= 2 then
Length := Chunks * 3 + Remains - 1;
else
Length := Chunks * 3;
end if;
end;
return Result : Atom (0 .. Length - 1) do
declare
O : Count := Result'First;
Buffer : Atom (0 .. 3);
Accumulated : Count := 0;
begin
for I in Data'Range loop
if Is_Base64_Digit (Data (I)) then
Buffer (Accumulated) := Data (I);
Accumulated := Accumulated + 1;
if Accumulated = 4 then
Result (O .. O + 2) := Decode_Base64 (Buffer (0),
Buffer (1),
Buffer (2),
Buffer (3));
O := O + 3;
Accumulated := 0;
end if;
end if;
end loop;
if Accumulated = 2 then
Result (O .. O) := Decode_Base64 (Buffer (0), Buffer (1));
O := O + 1;
elsif Accumulated = 3 then
Result (O .. O + 1) := Decode_Base64 (Buffer (0),
Buffer (1),
Buffer (2));
O := O + 2;
end if;
pragma Assert (O = Length);
end;
end return;
end Decode_Base64;
----------------------
-- Base-64 Encoding --
----------------------
function Encode_Base64 (Value : in Octet) return Octet is
begin
case Value is
when 0 .. 25 =>
return Upper_A + Value;
when 26 .. 51 =>
return Lower_A + Value - 26;
when 52 .. 61 =>
return Digit_0 + Value - 52;
when 62 =>
return Plus;
when 63 =>
return Slash;
when others =>
raise Constraint_Error;
end case;
end Encode_Base64;
procedure Encode_Base64 (Output : out Atom; A : in Octet) is
begin
Output (Output'First + 0) := Encode_Base64 (A / 2**2 mod 2**6);
Output (Output'First + 1) := Encode_Base64 (A * 2**4 mod 2**6);
Output (Output'First + 2) := Base64_Filler;
Output (Output'First + 3) := Base64_Filler;
end Encode_Base64;
procedure Encode_Base64 (Output : out Atom; A, B : in Octet) is
begin
Output (Output'First + 0) := Encode_Base64 (A / 2**2 mod 2**6);
Output (Output'First + 1) := Encode_Base64 ((A * 2**4 + B / 2**4)
mod 2**6);
Output (Output'First + 2) := Encode_Base64 (B * 2**2 mod 2**6);
Output (Output'First + 3) := Base64_Filler;
end Encode_Base64;
procedure Encode_Base64 (Output : out Atom; A, B, C : in Octet) is
begin
Output (Output'First + 0) := Encode_Base64 (A / 2**2 mod 2**6);
Output (Output'First + 1) := Encode_Base64 ((A * 2**4 + B / 2**4)
mod 2**6);
Output (Output'First + 2) := Encode_Base64 ((B * 2**2 + C / 2**6)
mod 2**6);
Output (Output'First + 3) := Encode_Base64 (C mod 2**6);
end Encode_Base64;
function Encode_Base64 (Data : in Atom) return Atom is
Chunks : constant Count := (Data'Length + 2) / 3;
Result : Atom (0 .. Chunks * 4 - 1);
Cursor : Offset := Result'First;
I : Offset := Data'First;
begin
while I in Data'Range loop
if I + 2 in Data'Range then
Encode_Base64
(Result (Cursor .. Cursor + 3),
Data (I),
Data (I + 1),
Data (I + 2));
I := I + 3;
elsif I + 1 in Data'Range then
Encode_Base64
(Result (Cursor .. Cursor + 3),
Data (I),
Data (I + 1));
I := I + 2;
else
Encode_Base64
(Result (Cursor .. Cursor + 3),
Data (I));
I := I + 1;
end if;
Cursor := Cursor + 4;
end loop;
return Result;
end Encode_Base64;
---------------------------------
-- Base-64 with other charsets --
---------------------------------
function Decode_Base64 (Data : in Atom; Digit_62, Digit_63 : in Octet)
return Atom
is
Recoded : Atom := Data;
begin
for I in Recoded'Range loop
if Recoded (I) = Digit_62 then
Recoded (I) := Plus;
elsif Recoded (I) = Digit_63 then
Recoded (I) := Slash;
end if;
end loop;
return Decode_Base64 (Recoded);
end Decode_Base64;
function Encode_Base64 (Data : in Atom; Digit_62, Digit_63 : in Octet)
return Atom
is
Result : Atom := Encode_Base64 (Data);
Last : Count := Result'Last;
begin
for I in Result'Range loop
if Result (I) = Plus then
Result (I) := Digit_62;
elsif Result (I) = Slash then
Result (I) := Digit_63;
elsif Result (I) = Base64_Filler then
pragma Assert (Result (I + 1 .. Result'Last)
= (I + 1 .. Result'Last => Base64_Filler));
Last := I - 1;
exit;
end if;
end loop;
return Result (Result'First .. Last);
end Encode_Base64;
function Encode_Base64
(Data : in Atom;
Digit_62, Digit_63, Padding : in Octet)
return Atom
is
Result : Atom := Encode_Base64 (Data);
begin
for I in Result'Range loop
if Result (I) = Plus then
Result (I) := Digit_62;
elsif Result (I) = Slash then
Result (I) := Digit_63;
elsif Result (I) = Base64_Filler then
Result (I) := Padding;
end if;
end loop;
return Result;
end Encode_Base64;
end Natools.S_Expressions.Encodings;
|
-- remote_server.adb - Main package for use by NymphRPC clients.
--
-- 2017/07/01, Maya Posch
-- (c) Nyanko.ws
package body NymphRemoteServer is
function init(logger : in <?>, level : in integer, timeout: in integer) return Boolean is
begin
--
end init;
end NymphRemoteServer;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . M E M O R Y --
-- --
-- B o d y --
-- --
-- Copyright (C) 2001-2019, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This version contains allocation tracking capability
-- The object file corresponding to this instrumented version is to be found
-- in libgmem.
-- When enabled, the subsystem logs all the calls to __gnat_malloc and
-- __gnat_free. This log can then be processed by gnatmem to detect
-- dynamic memory leaks.
-- To use this functionality, you must compile your application with -g
-- and then link with this object file:
-- gnatmake -g program -largs -lgmem
-- After compilation, you may use your program as usual except that upon
-- completion, it will generate in the current directory the file gmem.out.
-- You can then investigate for possible memory leaks and mismatch by calling
-- gnatmem with this file as an input:
-- gnatmem -i gmem.out program
-- See gnatmem section in the GNAT User's Guide for more details
-- NOTE: This capability is currently supported on the following targets:
-- Windows
-- AIX
-- GNU/Linux
-- HP-UX
-- Solaris
-- NOTE FOR FUTURE PLATFORMS SUPPORT: It is assumed that type Duration is
-- 64 bit. If the need arises to support architectures where this assumption
-- is incorrect, it will require changing the way timestamps of allocation
-- events are recorded.
pragma Source_File_Name (System.Memory, Body_File_Name => "memtrack.adb");
with Ada.Exceptions;
with System.Soft_Links;
with System.Traceback;
with System.Traceback_Entries;
with GNAT.IO;
with System.OS_Primitives;
package body System.Memory is
use Ada.Exceptions;
use System.Soft_Links;
use System.Traceback;
use System.Traceback_Entries;
use GNAT.IO;
function c_malloc (Size : size_t) return System.Address;
pragma Import (C, c_malloc, "malloc");
procedure c_free (Ptr : System.Address);
pragma Import (C, c_free, "free");
function c_realloc
(Ptr : System.Address; Size : size_t) return System.Address;
pragma Import (C, c_realloc, "realloc");
subtype File_Ptr is System.Address;
function fopen (Path : String; Mode : String) return File_Ptr;
pragma Import (C, fopen);
procedure OS_Exit (Status : Integer);
pragma Import (C, OS_Exit, "__gnat_os_exit");
pragma No_Return (OS_Exit);
procedure fwrite
(Ptr : System.Address;
Size : size_t;
Nmemb : size_t;
Stream : File_Ptr);
pragma Import (C, fwrite);
procedure fputc (C : Integer; Stream : File_Ptr);
pragma Import (C, fputc);
procedure fclose (Stream : File_Ptr);
pragma Import (C, fclose);
procedure Finalize;
pragma Export (C, Finalize, "__gnat_finalize");
-- Replace the default __gnat_finalize to properly close the log file
Address_Size : constant := System.Address'Max_Size_In_Storage_Elements;
-- Size in bytes of a pointer
Max_Call_Stack : constant := 200;
-- Maximum number of frames supported
Tracebk : Tracebacks_Array (1 .. Max_Call_Stack);
Num_Calls : aliased Integer := 0;
Gmemfname : constant String := "gmem.out" & ASCII.NUL;
-- Allocation log of a program is saved in a file gmem.out
-- ??? What about Ada.Command_Line.Command_Name & ".out" instead of static
-- gmem.out
Gmemfile : File_Ptr;
-- Global C file pointer to the allocation log
Needs_Init : Boolean := True;
-- Reset after first call to Gmem_Initialize
procedure Gmem_Initialize;
-- Initialization routine; opens the file and writes a header string. This
-- header string is used as a magic-tag to know if the .out file is to be
-- handled by GDB or by the GMEM (instrumented malloc/free) implementation.
First_Call : Boolean := True;
-- Depending on implementation, some of the traceback routines may
-- themselves do dynamic allocation. We use First_Call flag to avoid
-- infinite recursion
-----------
-- Alloc --
-----------
function Alloc (Size : size_t) return System.Address is
Result : aliased System.Address;
Actual_Size : aliased size_t := Size;
Timestamp : aliased Duration;
begin
if Size = size_t'Last then
Raise_Exception (Storage_Error'Identity, "object too large");
end if;
-- Change size from zero to non-zero. We still want a proper pointer
-- for the zero case because pointers to zero length objects have to
-- be distinct, but we can't just go ahead and allocate zero bytes,
-- since some malloc's return zero for a zero argument.
if Size = 0 then
Actual_Size := 1;
end if;
Lock_Task.all;
Result := c_malloc (Actual_Size);
if First_Call then
-- Logs allocation call
-- format is:
-- 'A' <mem addr> <size chunk> <len backtrace> <addr1> ... <addrn>
First_Call := False;
if Needs_Init then
Gmem_Initialize;
end if;
Timestamp := System.OS_Primitives.Clock;
Call_Chain
(Tracebk, Max_Call_Stack, Num_Calls, Skip_Frames => 2);
fputc (Character'Pos ('A'), Gmemfile);
fwrite (Result'Address, Address_Size, 1, Gmemfile);
fwrite (Actual_Size'Address, size_t'Max_Size_In_Storage_Elements, 1,
Gmemfile);
fwrite (Timestamp'Address, Duration'Max_Size_In_Storage_Elements, 1,
Gmemfile);
fwrite (Num_Calls'Address, Integer'Max_Size_In_Storage_Elements, 1,
Gmemfile);
for J in Tracebk'First .. Tracebk'First + Num_Calls - 1 loop
declare
Ptr : System.Address := PC_For (Tracebk (J));
begin
fwrite (Ptr'Address, Address_Size, 1, Gmemfile);
end;
end loop;
First_Call := True;
end if;
Unlock_Task.all;
if Result = System.Null_Address then
Raise_Exception (Storage_Error'Identity, "heap exhausted");
end if;
return Result;
end Alloc;
--------------
-- Finalize --
--------------
procedure Finalize is
begin
if not Needs_Init then
fclose (Gmemfile);
end if;
end Finalize;
----------
-- Free --
----------
procedure Free (Ptr : System.Address) is
Addr : aliased constant System.Address := Ptr;
Timestamp : aliased Duration;
begin
Lock_Task.all;
if First_Call then
-- Logs deallocation call
-- format is:
-- 'D' <mem addr> <len backtrace> <addr1> ... <addrn>
First_Call := False;
if Needs_Init then
Gmem_Initialize;
end if;
Call_Chain
(Tracebk, Max_Call_Stack, Num_Calls, Skip_Frames => 2);
Timestamp := System.OS_Primitives.Clock;
fputc (Character'Pos ('D'), Gmemfile);
fwrite (Addr'Address, Address_Size, 1, Gmemfile);
fwrite (Timestamp'Address, Duration'Max_Size_In_Storage_Elements, 1,
Gmemfile);
fwrite (Num_Calls'Address, Integer'Max_Size_In_Storage_Elements, 1,
Gmemfile);
for J in Tracebk'First .. Tracebk'First + Num_Calls - 1 loop
declare
Ptr : System.Address := PC_For (Tracebk (J));
begin
fwrite (Ptr'Address, Address_Size, 1, Gmemfile);
end;
end loop;
c_free (Ptr);
First_Call := True;
end if;
Unlock_Task.all;
end Free;
---------------------
-- Gmem_Initialize --
---------------------
procedure Gmem_Initialize is
Timestamp : aliased Duration;
begin
if Needs_Init then
Needs_Init := False;
System.OS_Primitives.Initialize;
Timestamp := System.OS_Primitives.Clock;
Gmemfile := fopen (Gmemfname, "wb" & ASCII.NUL);
if Gmemfile = System.Null_Address then
Put_Line ("Couldn't open gnatmem log file for writing");
OS_Exit (255);
end if;
declare
S : constant String := "GMEM DUMP" & ASCII.LF;
begin
fwrite (S'Address, S'Length, 1, Gmemfile);
fwrite (Timestamp'Address, Duration'Max_Size_In_Storage_Elements,
1, Gmemfile);
end;
end if;
end Gmem_Initialize;
-------------
-- Realloc --
-------------
function Realloc
(Ptr : System.Address;
Size : size_t) return System.Address
is
Addr : aliased constant System.Address := Ptr;
Result : aliased System.Address;
Timestamp : aliased Duration;
begin
-- For the purposes of allocations logging, we treat realloc as a free
-- followed by malloc. This is not exactly accurate, but is a good way
-- to fit it into malloc/free-centered reports.
if Size = size_t'Last then
Raise_Exception (Storage_Error'Identity, "object too large");
end if;
Abort_Defer.all;
Lock_Task.all;
if First_Call then
First_Call := False;
-- We first log deallocation call
if Needs_Init then
Gmem_Initialize;
end if;
Call_Chain
(Tracebk, Max_Call_Stack, Num_Calls, Skip_Frames => 2);
Timestamp := System.OS_Primitives.Clock;
fputc (Character'Pos ('D'), Gmemfile);
fwrite (Addr'Address, Address_Size, 1, Gmemfile);
fwrite (Timestamp'Address, Duration'Max_Size_In_Storage_Elements, 1,
Gmemfile);
fwrite (Num_Calls'Address, Integer'Max_Size_In_Storage_Elements, 1,
Gmemfile);
for J in Tracebk'First .. Tracebk'First + Num_Calls - 1 loop
declare
Ptr : System.Address := PC_For (Tracebk (J));
begin
fwrite (Ptr'Address, Address_Size, 1, Gmemfile);
end;
end loop;
-- Now perform actual realloc
Result := c_realloc (Ptr, Size);
-- Log allocation call using the same backtrace
fputc (Character'Pos ('A'), Gmemfile);
fwrite (Result'Address, Address_Size, 1, Gmemfile);
fwrite (Size'Address, size_t'Max_Size_In_Storage_Elements, 1,
Gmemfile);
fwrite (Timestamp'Address, Duration'Max_Size_In_Storage_Elements, 1,
Gmemfile);
fwrite (Num_Calls'Address, Integer'Max_Size_In_Storage_Elements, 1,
Gmemfile);
for J in Tracebk'First .. Tracebk'First + Num_Calls - 1 loop
declare
Ptr : System.Address := PC_For (Tracebk (J));
begin
fwrite (Ptr'Address, Address_Size, 1, Gmemfile);
end;
end loop;
First_Call := True;
end if;
Unlock_Task.all;
Abort_Undefer.all;
if Result = System.Null_Address then
Raise_Exception (Storage_Error'Identity, "heap exhausted");
end if;
return Result;
end Realloc;
end System.Memory;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Adventofcode.Day_10.Main is
begin
Put_Line ("Day-10");
end Adventofcode.Day_10.Main;
|
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Scanned_Rule_Handlers;
with Program.Scanner_States;
with Program.Scanners;
with Program.Scanner_Destinations;
package Program.Lexical_Handlers is
pragma Pure;
type Handler
(Output : not null access
Program.Scanner_Destinations.Scanner_Destination'Class)
is new Program.Scanned_Rule_Handlers.Handler with private;
overriding procedure Identifier
(Self : not null access Handler;
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);
overriding procedure Numeric_Literal
(Self : not null access Handler;
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);
overriding procedure Obsolescent_Numeric_Literal
(Self : not null access Handler;
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);
overriding procedure Character_Literal
(Self : not null access Handler;
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);
overriding procedure String_Literal
(Self : not null access Handler;
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);
overriding procedure Obsolescent_String_Literal
(Self : not null access Handler;
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);
overriding procedure Comment
(Self : not null access Handler;
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);
overriding procedure Space
(Self : not null access Handler;
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);
overriding procedure New_Line
(Self : not null access Handler;
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);
overriding procedure Error
(Self : not null access Handler;
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);
overriding procedure Delimiter
(Self : not null access Handler;
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);
private
type Handler
(Output : not null access
Program.Scanner_Destinations.Scanner_Destination'Class)
is new Program.Scanned_Rule_Handlers.Handler with
record
Last_Token : Program.Scanner_Destinations.Token_Kind :=
Program.Scanner_Destinations.Token_Kind'First;
Line : Positive := 1;
end record;
end Program.Lexical_Handlers;
|
procedure Enum_Derived_Type is
type Rainbow is (Red, Orange, Yellow, Green, Blue, Indigo, Violet);
type ColdColors is new Rainbow range Blue .. Violet;
BlueColor : ColdColors := Blue;
begin
null;
end Enum_Derived_Type;
|
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Lexical_Elements; use Program.Lexical_Elements;
package Program.Symbols is
pragma Pure;
type Symbol is mod 2 ** 32;
-- Symbol is case-insensitive representation of identifiers, operators
-- and character literals
function No_Symbol return Symbol is (0);
subtype Operator_Symbol is Symbol range 1 .. 19;
function Less_Symbol return Operator_Symbol is
(Lexical_Element_Kind'Pos (Less) + 1);
function Equal_Symbol return Operator_Symbol is
(Lexical_Element_Kind'Pos (Equal) + 1);
function Greater_Symbol return Operator_Symbol is
(Lexical_Element_Kind'Pos (Greater) + 1);
function Hyphen_Symbol return Operator_Symbol is
(Lexical_Element_Kind'Pos (Hyphen) + 1);
function Slash_Symbol return Operator_Symbol is
(Lexical_Element_Kind'Pos (Slash) + 1);
function Star_Symbol return Operator_Symbol is
(Lexical_Element_Kind'Pos (Star) + 1);
function Ampersand_Symbol return Operator_Symbol is
(Lexical_Element_Kind'Pos (Ampersand) + 1);
function Plus_Symbol return Operator_Symbol is
(Lexical_Element_Kind'Pos (Plus) + 1);
function Less_Or_Equal_Symbol return Operator_Symbol is
(Lexical_Element_Kind'Pos (Less_Or_Equal) + 1);
function Greater_Or_Equal_Symbol return Operator_Symbol is
(Lexical_Element_Kind'Pos (Greater_Or_Equal) + 1);
function Inequality_Symbol return Operator_Symbol is
(Lexical_Element_Kind'Pos (Inequality) + 1);
function Double_Star_Symbol return Operator_Symbol is
(Lexical_Element_Kind'Pos (Double_Star) + 1);
function Or_Symbol return Operator_Symbol is
(Lexical_Element_Kind'Pos (Or_Keyword) + 1);
function And_Symbol return Operator_Symbol is
(Lexical_Element_Kind'Pos (And_Keyword) + 1);
function Xor_Symbol return Operator_Symbol is
(Lexical_Element_Kind'Pos (Xor_Keyword) + 1);
function Mod_Symbol return Operator_Symbol is
(Lexical_Element_Kind'Pos (Mod_Keyword) + 1);
function Rem_Symbol return Operator_Symbol is
(Lexical_Element_Kind'Pos (Rem_Keyword) + 1);
function Abs_Symbol return Operator_Symbol is
(Lexical_Element_Kind'Pos (Abs_Keyword) + 1);
function Not_Symbol return Operator_Symbol is
(Lexical_Element_Kind'Pos (Not_Keyword) + 1);
subtype Character_Literal_Symbol is Symbol range 16#00_0020# .. 16#10_FFFF#;
subtype X_Symbol is Symbol range 16#11_0000# .. 16#11_0097#;
function All_Calls_Remote return X_Symbol is (16#11_0000#);
function Assert return X_Symbol is (16#11_0001#);
function Assertion_Policy return X_Symbol is (16#11_0002#);
function Asynchronous return X_Symbol is (16#11_0003#);
function Atomic return X_Symbol is (16#11_0004#);
function Atomic_Components return X_Symbol is (16#11_0005#);
function Attach_Handler return X_Symbol is (16#11_0006#);
function Controlled return X_Symbol is (16#11_0007#);
function Convention return X_Symbol is (16#11_0008#);
function Detect_Blocking return X_Symbol is (16#11_0009#);
function Discard_Names return X_Symbol is (16#11_000A#);
function Elaborate return X_Symbol is (16#11_000B#);
function Elaborate_All return X_Symbol is (16#11_000C#);
function Elaborate_Body return X_Symbol is (16#11_000D#);
function Export return X_Symbol is (16#11_000E#);
function Import return X_Symbol is (16#11_000F#);
function Inline return X_Symbol is (16#11_0010#);
function Inspection_Point return X_Symbol is (16#11_0011#);
function Interrupt_Handler return X_Symbol is (16#11_0012#);
function Interrupt_Priority return X_Symbol is (16#11_0013#);
function Linker_Options return X_Symbol is (16#11_0014#);
function List return X_Symbol is (16#11_0015#);
function Locking_Policy return X_Symbol is (16#11_0016#);
function No_Return return X_Symbol is (16#11_0017#);
function Normalize_Scalars return X_Symbol is (16#11_0018#);
function Optimize return X_Symbol is (16#11_0019#);
function Pack return X_Symbol is (16#11_001A#);
function Page return X_Symbol is (16#11_001B#);
function Partition_Elaboration_Policy return X_Symbol is (16#11_001C#);
function Preelaborable_Initialization return X_Symbol is (16#11_001D#);
function Preelaborate return X_Symbol is (16#11_001E#);
function Priority_Specific_Dispatching return X_Symbol is (16#11_001F#);
function Profile return X_Symbol is (16#11_0020#);
function Pure return X_Symbol is (16#11_0021#);
function Queuing_Policy return X_Symbol is (16#11_0022#);
function Relative_Deadline return X_Symbol is (16#11_0023#);
function Remote_Call_Interface return X_Symbol is (16#11_0024#);
function Remote_Types return X_Symbol is (16#11_0025#);
function Restrictions return X_Symbol is (16#11_0026#);
function Reviewable return X_Symbol is (16#11_0027#);
function Shared_Passive return X_Symbol is (16#11_0028#);
function Suppress return X_Symbol is (16#11_0029#);
function Task_Dispatching_Policy return X_Symbol is (16#11_002A#);
function Unchecked_Union return X_Symbol is (16#11_002B#);
function Unsuppress return X_Symbol is (16#11_002C#);
function Volatile return X_Symbol is (16#11_002D#);
function Volatile_Components return X_Symbol is (16#11_002E#);
-- Attributes:
function Access_Symbol return X_Symbol is (16#11_002F#);
function Address return X_Symbol is (16#11_0030#);
function Adjacent return X_Symbol is (16#11_0031#);
function Aft return X_Symbol is (16#11_0032#);
function Alignment return X_Symbol is (16#11_0033#);
function Base return X_Symbol is (16#11_0034#);
function Bit_Order return X_Symbol is (16#11_0035#);
function Body_Version return X_Symbol is (16#11_0036#);
function Callable return X_Symbol is (16#11_0037#);
function Caller return X_Symbol is (16#11_0038#);
function Ceiling return X_Symbol is (16#11_0039#);
function Class return X_Symbol is (16#11_003A#);
function Component_Size return X_Symbol is (16#11_003B#);
function Compose return X_Symbol is (16#11_003C#);
function Constrained return X_Symbol is (16#11_003D#);
function Copy_Sign return X_Symbol is (16#11_003E#);
function Count return X_Symbol is (16#11_003F#);
function Definite return X_Symbol is (16#11_0040#);
function Delta_Symbol return X_Symbol is (16#11_0041#);
function Denorm return X_Symbol is (16#11_0042#);
function Digits_Symbol return X_Symbol is (16#11_0043#);
function Exponent return X_Symbol is (16#11_0044#);
function External_Tag return X_Symbol is (16#11_0045#);
function First return X_Symbol is (16#11_0046#);
function First_Bit return X_Symbol is (16#11_0047#);
function Floor return X_Symbol is (16#11_0048#);
function Fore return X_Symbol is (16#11_0049#);
function Fraction return X_Symbol is (16#11_004A#);
function Identity return X_Symbol is (16#11_004B#);
function Image return X_Symbol is (16#11_004C#);
function Input return X_Symbol is (16#11_004D#);
function Last return X_Symbol is (16#11_004E#);
function Last_Bit return X_Symbol is (16#11_004F#);
function Leading_Part return X_Symbol is (16#11_0050#);
function Length return X_Symbol is (16#11_0051#);
function Machine return X_Symbol is (16#11_0052#);
function Machine_Emax return X_Symbol is (16#11_0053#);
function Machine_Emin return X_Symbol is (16#11_0054#);
function Machine_Mantissa return X_Symbol is (16#11_0055#);
function Machine_Overflows return X_Symbol is (16#11_0056#);
function Machine_Radix return X_Symbol is (16#11_0057#);
function Machine_Rounding return X_Symbol is (16#11_0058#);
function Machine_Rounds return X_Symbol is (16#11_0059#);
function Max return X_Symbol is (16#11_005A#);
function Max_Size_In_Storage_Elements return X_Symbol is (16#11_005B#);
function Min return X_Symbol is (16#11_005C#);
function Mod_Keyword return X_Symbol is (16#11_005D#);
function Model return X_Symbol is (16#11_005E#);
function Model_Emin return X_Symbol is (16#11_005F#);
function Model_Epsilon return X_Symbol is (16#11_0060#);
function Model_Mantissa return X_Symbol is (16#11_0061#);
function Model_Small return X_Symbol is (16#11_0062#);
function Modulus return X_Symbol is (16#11_0063#);
function Output return X_Symbol is (16#11_0064#);
function Partition_ID return X_Symbol is (16#11_0065#);
function Pos return X_Symbol is (16#11_0066#);
function Position return X_Symbol is (16#11_0067#);
function Pred return X_Symbol is (16#11_0068#);
function Priority return X_Symbol is (16#11_0069#);
function Range_Keyword return X_Symbol is (16#11_006A#);
function Read return X_Symbol is (16#11_006B#);
function Remainder return X_Symbol is (16#11_006C#);
function Round return X_Symbol is (16#11_006D#);
function Rounding return X_Symbol is (16#11_006E#);
function Safe_First return X_Symbol is (16#11_006F#);
function Safe_Last return X_Symbol is (16#11_0070#);
function Scale return X_Symbol is (16#11_0071#);
function Scaling return X_Symbol is (16#11_0072#);
function Signed_Zeros return X_Symbol is (16#11_0073#);
function Size return X_Symbol is (16#11_0074#);
function Small return X_Symbol is (16#11_0075#);
function Storage_Pool return X_Symbol is (16#11_0076#);
function Storage_Size return X_Symbol is (16#11_0077#);
function Stream_Size return X_Symbol is (16#11_0078#);
function Succ return X_Symbol is (16#11_0079#);
function Tag return X_Symbol is (16#11_007A#);
function Terminated return X_Symbol is (16#11_007B#);
function Truncation return X_Symbol is (16#11_007C#);
function Unbiased_Rounding return X_Symbol is (16#11_007D#);
function Unchecked_Access return X_Symbol is (16#11_007E#);
function Val return X_Symbol is (16#11_007F#);
function Valid return X_Symbol is (16#11_0080#);
function Value return X_Symbol is (16#11_0081#);
function Version return X_Symbol is (16#11_0082#);
function Wide_Image return X_Symbol is (16#11_0083#);
function Wide_Value return X_Symbol is (16#11_0084#);
function Wide_Wide_Image return X_Symbol is (16#11_0085#);
function Wide_Wide_Value return X_Symbol is (16#11_0086#);
function Wide_Wide_Width return X_Symbol is (16#11_0087#);
function Wide_Width return X_Symbol is (16#11_0088#);
function Width return X_Symbol is (16#11_0089#);
function Write return X_Symbol is (16#11_008A#);
-- Other names:
package S renames Standard;
function Standard return X_Symbol is (16#11_008B#);
function Boolean return X_Symbol is (16#11_008C#);
function Integer return X_Symbol is (16#11_008D#);
function Float return X_Symbol is (16#11_008E#);
function Character return X_Symbol is (16#11_008F#);
function Wide_Character return X_Symbol is (16#11_0090#);
function Wide_Wide_Character return X_Symbol is (16#11_0091#);
function String return X_Symbol is (16#11_0092#);
function Wide_String return X_Symbol is (16#11_0093#);
function Wide_Wide_String return X_Symbol is (16#11_0094#);
function Duration return X_Symbol is (16#11_0095#);
function Root_Integer return X_Symbol is (16#11_0096#);
function Root_Real return X_Symbol is (16#11_0097#);
end Program.Symbols;
|
-- ----------------------------------------------------------------- --
-- AdaSDL --
-- Thin binding to Simple Direct Media Layer --
-- Copyright (C) 2000-2012 A.M.F.Vargas --
-- Antonio M. M. Ferreira Vargas --
-- Manhente - Barcelos - Portugal --
-- http://adasdl.sourceforge.net --
-- E-mail: amfvargas@gmail.com --
-- ----------------------------------------------------------------- --
-- --
-- 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. --
-- --
-- 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. --
-- ----------------------------------------------------------------- --
with Interfaces.C.Pointers;
generic
type The_Element is mod <>;
type The_Element_Array is
array (Interfaces.C.size_t range <>) of aliased The_Element;
package UintN_PtrOps is
package C renames Interfaces.C;
package Operations is
new Interfaces.C.Pointers (
Index => Interfaces.C.size_t,
Element => The_Element,
Element_Array => The_Element_Array,
Default_Terminator => 0);
subtype Pointer is Operations.Pointer;
function Value
(Ref : in Pointer;
Terminator : in The_Element)
return The_Element_Array renames Operations.Value;
function Value
(Ref : in Pointer;
Length : in C.ptrdiff_t)
return The_Element_Array renames Operations.Value;
--------------------------------
-- C-style Pointer Arithmetic --
--------------------------------
function "+" (Left : in Pointer; Right : in C.ptrdiff_t) return Pointer
renames Operations."+";
function "+" (Left : in C.ptrdiff_t; Right : in Pointer) return Pointer
renames Operations."+";
function "-" (Left : in Pointer; Right : in C.ptrdiff_t) return Pointer
renames Operations."-";
function "-" (Left : in Pointer; Right : in Pointer) return C.ptrdiff_t
renames Operations."-";
procedure Increment (Ref : in out Pointer)
renames Operations.Increment;
procedure Decrement (Ref : in out Pointer)
renames Operations.Increment;
function Virtual_Length
(Ref : in Pointer;
Terminator : in The_Element := 0)
return C.ptrdiff_t renames Operations.Virtual_Length;
procedure Copy_Terminated_Array
(Source : in Pointer;
Target : in Pointer;
Limit : in C.ptrdiff_t := C.ptrdiff_t'Last;
Terminator : in The_Element := 0)
renames Operations.Copy_Terminated_Array;
procedure Copy_Array
(Source : in Pointer;
Target : in Pointer;
Length : in C.ptrdiff_t)
renames Operations.Copy_Array;
end UintN_PtrOps;
|
-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>
-- MIT license. Please refer to the LICENSE file.
with Ada.Exceptions; use Ada.Exceptions;
with Ada.Tags; use Ada.Tags;
limited with Apsepp.Test_Node_Class;
package Apsepp.Test_Reporter_Class is
type Test_Reporter_Interfa is limited interface;
type Test_Reporter_Access is access all Test_Reporter_Interfa'Class;
not overriding
function Is_Conflicting_Node_Tag
(Obj : Test_Reporter_Interfa;
Node_Tag : Tag) return Boolean is abstract;
not overriding
procedure Provide_Node_Lineage (Obj : in out Test_Reporter_Interfa;
Node_Lineage : Tag_Array) is null
with Pre'Class
=> (for all T of Node_Lineage => T /= No_Tag)
and then
not Test_Reporter_Interfa'Class (Obj).Is_Conflicting_Node_Tag
(Node_Lineage (Node_Lineage'Last));
-- TODOC: Called by Test_Node_Class.Suite_Stub.Run_Children.
-- <2019-03-03>
not overriding
procedure Report_Failed_Child_Test_Node_Access
(Obj : in out Test_Reporter_Interfa;
Node_Tag : Tag;
Previous_Child_Tag : Tag;
E : Exception_Occurrence) is null;
-- TODOC: Called by Test_Node_Class.Generic_Case_And_Suite_Run_Body.
-- <2019-03-02>
not overriding
procedure Report_Unexpected_Node_Cond_Check_Error
(Obj : in out Test_Reporter_Interfa;
Node_Tag : Tag;
E : Exception_Occurrence) is null;
-- TODOC: Called by Test_Node_Class.Generic_Case_And_Suite_Run_Body.
-- <2019-03-02>
not overriding
procedure Report_Unexpected_Node_Run_Error
(Obj : in out Test_Reporter_Interfa;
Node_Tag : Tag;
E : Exception_Occurrence) is null;
-- TODOC: Called by Test_Node_Class.Generic_Case_And_Suite_Run_Body.
-- <2019-03-02>
not overriding
procedure Report_Node_Cond_Check_Start
(Obj : in out Test_Reporter_Interfa;
Node_Tag : Tag) is null;
-- TODOC: Called by Test_Node_Class.Generic_Case_And_Suite_Run_Body.
-- <2019-03-02>
not overriding
procedure Report_Passed_Node_Cond_Check
(Obj : in out Test_Reporter_Interfa;
Node_Tag : Tag) is null;
-- TODOC: Called by Test_Node_Class.Generic_Case_And_Suite_Run_Body.
-- <2019-03-02>
not overriding
procedure Report_Failed_Node_Cond_Check
(Obj : in out Test_Reporter_Interfa;
Node_Tag : Tag) is null;
-- TODOC: Called by Test_Node_Class.Generic_Case_And_Suite_Run_Body.
-- <2019-03-02>
not overriding
procedure Report_Passed_Node_Cond_Assert
(Obj : in out Test_Reporter_Interfa;
Node_Tag : Tag) is null;
-- TODOC: Called by Test_Node_Class.Generic_Case_And_Suite_Run_Body.
-- <2019-03-02>
not overriding
procedure Report_Failed_Node_Cond_Assert
(Obj : in out Test_Reporter_Interfa;
Node_Tag : Tag) is null;
-- TODOC: Called by Test_Node_Class.Generic_Case_And_Suite_Run_Body.
-- <2019-03-02>
not overriding
procedure Report_Node_Run_Start
(Obj : in out Test_Reporter_Interfa;
Node_Tag : Tag) is null;
-- TODOC: Called by Test_Node_Class.Run_Test_Routines. <2019-03-02>
not overriding
procedure Report_Test_Routine_Start
(Obj : in out Test_Reporter_Interfa;
Node_Tag : Tag;
K : Test_Node_Class.Test_Routine_Count) is null;
-- TODOC: Called by Test_Node_Class.Run_Test_Routines. <2019-03-02>
not overriding
procedure Report_Test_Routines_Cancellation
(Obj : in out Test_Reporter_Interfa;
Node_Tag : Tag;
First_K, Last_K : Test_Node_Class.Test_Routine_Count) is null;
-- TODOC: Called by Test_Node_Class.Run_Test_Routines. <2019-03-02>
not overriding
procedure Report_Failed_Test_Routine_Access
(Obj : in out Test_Reporter_Interfa;
Node_Tag : Tag;
K : Test_Node_Class.Test_Routine_Count;
E : Exception_Occurrence) is null;
-- TODOC: Called by Test_Node_Class.Run_Test_Routines. <2019-03-02>
not overriding
procedure Report_Failed_Test_Routine_Setup
(Obj : in out Test_Reporter_Interfa;
Node_Tag : Tag;
K : Test_Node_Class.Test_Routine_Count;
E : Exception_Occurrence) is null;
-- TODOC: Called by Test_Node_Class.Assert. <2019-03-02>
not overriding
procedure Report_Passed_Test_Assert
(Obj : in out Test_Reporter_Interfa;
Node_Tag : Tag;
K : Test_Node_Class.Test_Routine_Count;
Assert_Num_Avail : Boolean;
Assert_Num : Test_Node_Class.Test_Assert_Count) is null;
-- TODOC: Called by Test_Node_Class.Assert. <2019-03-02>
not overriding
procedure Report_Failed_Test_Assert
(Obj : in out Test_Reporter_Interfa;
Node_Tag : Tag;
K : Test_Node_Class.Test_Routine_Count;
Assert_Num_Avail : Boolean;
Assert_Num : Test_Node_Class.Test_Assert_Count;
E : Exception_Occurrence) is null;
-- TODOC: Called by Test_Node_Class.Run_Test_Routines. <2019-03-02>
not overriding
procedure Report_Unexpected_Routine_Exception
(Obj : in out Test_Reporter_Interfa;
Node_Tag : Tag;
K : Test_Node_Class.Test_Routine_Count;
E : Exception_Occurrence) is null;
-- TODOC: Called by Test_Node_Class.Run_Test_Routines. <2019-03-02>
not overriding
procedure Report_Passed_Test_Routine
(Obj : in out Test_Reporter_Interfa;
Node_Tag : Tag;
K : Test_Node_Class.Test_Routine_Count) is null;
-- TODOC: Called by Test_Node_Class.Run_Test_Routines. <2019-03-02>
not overriding
procedure Report_Failed_Test_Routine
(Obj : in out Test_Reporter_Interfa;
Node_Tag : Tag;
K : Test_Node_Class.Test_Routine_Count) is null;
-- TODOC: Called by Test_Node_Class.Generic_Case_And_Suite_Run_Body.
-- <2019-03-02>
not overriding
procedure Report_Passed_Node_Run
(Obj : in out Test_Reporter_Interfa;
Node_Tag : Tag) is null;
-- TODOC: Called by Test_Node_Class.Generic_Case_And_Suite_Run_Body.
-- <2019-03-02>
not overriding
procedure Report_Failed_Node_Run
(Obj : in out Test_Reporter_Interfa;
Node_Tag : Tag) is null;
-- TODOC: Called by Test_Node_Class.Runner_Sequential.Run. <2019-03-03>
not overriding
procedure Process (Obj : in out Test_Reporter_Interfa) is null;
end Apsepp.Test_Reporter_Class;
|
package body Forward_AD.AD2D is
function "+" (A, B : in AD2D) return AD2D is
begin
return (X => A.X + B.X,
Y => A.Y + B.Y);
end "+";
function "-" (A, B : in AD2D) return AD2D is
begin
return (X => A.X - B.X,
Y => A.Y - B.Y);
end "-";
function "*" (A : in AD2D;
B : in AD2D) return AD_Type is
Result : AD_Type := A.X * B.X + A.Y * B.Y;
begin
return Result;
end "*";
function "-" (A : in AD2D) return AD2D is
begin
return (X => -A.X, Y => -A.Y);
end "-";
function To_AD2D_Vector (Pos_Vector : in Pos2D_Vector) return AD2D_Vector is
Rvec : AD_Vector := Var (To_Array (Pos_Vector));
Result : AD2D_Vector (Pos_Vector'First .. Pos_Vector'Last);
Idx : Int := Pos_Vector'First;
begin
for K in Rvec'Range loop
if K mod 2 = 1 then -- K is odd
Result (Idx).X := Rvec (K);
else -- K is even
Result (Idx).Y := Rvec (K);
Idx := Idx + 1;
end if;
end loop;
return Result;
end To_AD2D_Vector;
end Forward_AD.AD2D;
|
-----------------------------------------------------------------------
-- util-beans-objects-maps -- Object maps
-- Copyright (C) 2010, 2011, 2012, 2017, 2018, 2019 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body Util.Beans.Objects.Maps is
-- ------------------------------
-- Get the value identified by the name.
-- If the name cannot be found, the method should return the Null object.
-- ------------------------------
function Get_Value (From : in Map_Bean;
Name : in String) return Object is
Pos : constant Cursor := From.Find (Name);
begin
if Has_Element (Pos) then
return Element (Pos);
else
return Null_Object;
end if;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name.
-- If the map contains the given name, the value changed.
-- Otherwise name is added to the map and the value associated with it.
-- ------------------------------
procedure Set_Value (From : in out Map_Bean;
Name : in String;
Value : in Object) is
begin
From.Include (Name, Value);
end Set_Value;
-- ------------------------------
-- Iterate over the members of the map.
-- ------------------------------
procedure Iterate (From : in Object;
Process : not null access procedure (Name : in String;
Item : in Object)) is
procedure Process_One (Pos : in Maps.Cursor);
procedure Process_One (Pos : in Maps.Cursor) is
begin
Process (Maps.Key (Pos), Maps.Element (Pos));
end Process_One;
Bean : constant access Util.Beans.Basic.Readonly_Bean'Class := To_Bean (From);
begin
if Bean /= null and then Bean.all in Util.Beans.Objects.Maps.Map_Bean'Class then
Map_Bean'Class (Bean.all).Iterate (Process_One'Access);
end if;
end Iterate;
-- ------------------------------
-- Create an object that contains a <tt>Map_Bean</tt> instance.
-- ------------------------------
function Create return Object is
M : constant Map_Bean_Access := new Map_Bean;
begin
return To_Object (Value => M, Storage => DYNAMIC);
end Create;
end Util.Beans.Objects.Maps;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- C O N T R A C T S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2015-2020, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package contains routines that perform analysis and expansion of
-- various contracts.
with Types; use Types;
package Contracts is
procedure Add_Contract_Item (Prag : Node_Id; Id : Entity_Id);
-- Add pragma Prag to the contract of a constant, entry, entry family,
-- [generic] package, package body, protected unit, [generic] subprogram,
-- subprogram body, variable, task unit, or type denoted by Id.
-- The following are valid pragmas:
--
-- Abstract_State
-- Async_Readers
-- Async_Writers
-- Attach_Handler
-- Constant_After_Elaboration
-- Contract_Cases
-- Depends
-- Effective_Reads
-- Effective_Writes
-- Extensions_Visible
-- Global
-- Initial_Condition
-- Initializes
-- Interrupt_Handler
-- No_Caching
-- Part_Of
-- Postcondition
-- Precondition
-- Refined_Depends
-- Refined_Global
-- Refined_Post
-- Refined_States
-- Test_Case
-- Volatile_Function
procedure Analyze_Contracts (L : List_Id);
-- Analyze the contracts of all eligible constructs found in list L
procedure Analyze_Entry_Or_Subprogram_Body_Contract (Body_Id : Entity_Id);
-- Analyze all delayed pragmas chained on the contract of entry or
-- subprogram body Body_Id as if they appeared at the end of a declarative
-- region. Pragmas in question are:
--
-- Contract_Cases (stand alone subprogram body)
-- Depends (stand alone subprogram body)
-- Global (stand alone subprogram body)
-- Postcondition (stand alone subprogram body)
-- Precondition (stand alone subprogram body)
-- Refined_Depends
-- Refined_Global
-- Refined_Post
-- Subprogram_Variant (stand alone subprogram body)
-- Test_Case (stand alone subprogram body)
procedure Analyze_Entry_Or_Subprogram_Contract
(Subp_Id : Entity_Id;
Freeze_Id : Entity_Id := Empty);
-- Analyze all delayed pragmas chained on the contract of entry or
-- subprogram Subp_Id as if they appeared at the end of a declarative
-- region. The pragmas in question are:
--
-- Contract_Cases
-- Depends
-- Global
-- Postcondition
-- Precondition
-- Subprogram_Variant
-- Test_Case
--
-- Freeze_Id is the entity of a [generic] package body or a [generic]
-- subprogram body which "freezes" the contract of Subp_Id.
procedure Analyze_Object_Contract
(Obj_Id : Entity_Id;
Freeze_Id : Entity_Id := Empty);
-- Analyze all delayed pragmas chained on the contract of object Obj_Id as
-- if they appeared at the end of the declarative region. The pragmas to be
-- considered are:
--
-- Async_Readers
-- Async_Writers
-- Depends (single concurrent object)
-- Effective_Reads
-- Effective_Writes
-- Global (single concurrent object)
-- Part_Of
--
-- Freeze_Id is the entity of a [generic] package body or a [generic]
-- subprogram body which "freezes" the contract of Obj_Id.
procedure Analyze_Type_Contract (Type_Id : Entity_Id);
-- Analyze all delayed pragmas chained on the contract of object Obj_Id as
-- if they appeared at the end of the declarative region. The pragmas to be
-- considered are:
--
-- Async_Readers
-- Async_Writers
-- Effective_Reads
-- Effective_Writes
--
-- In the case of a protected or task type, there will also be
-- a call to Analyze_Protected_Contract or Analyze_Task_Contract.
procedure Analyze_Package_Body_Contract
(Body_Id : Entity_Id;
Freeze_Id : Entity_Id := Empty);
-- Analyze all delayed pragmas chained on the contract of package body
-- Body_Id as if they appeared at the end of a declarative region. The
-- pragmas that are considered are:
--
-- Refined_State
--
-- Freeze_Id is the entity of a [generic] package body or a [generic]
-- subprogram body which "freezes" the contract of Body_Id.
procedure Analyze_Package_Contract (Pack_Id : Entity_Id);
-- Analyze all delayed pragmas chained on the contract of package Pack_Id
-- as if they appeared at the end of a declarative region. The pragmas
-- that are considered are:
--
-- Initial_Condition
-- Initializes
procedure Analyze_Protected_Contract (Prot_Id : Entity_Id);
-- Analyze all delayed pragmas chained on the contract of protected unit
-- Prot_Id if they appeared at the end of a declarative region. Currently
-- there are no such pragmas.
procedure Analyze_Subprogram_Body_Stub_Contract (Stub_Id : Entity_Id);
-- Analyze all delayed pragmas chained on the contract of subprogram body
-- stub Stub_Id as if they appeared at the end of a declarative region. The
-- pragmas in question are:
--
-- Contract_Cases
-- Depends
-- Global
-- Postcondition
-- Precondition
-- Refined_Depends
-- Refined_Global
-- Refined_Post
-- Test_Case
procedure Analyze_Task_Contract (Task_Id : Entity_Id);
-- Analyze all delayed pragmas chained on the contract of task unit Task_Id
-- as if they appeared at the end of a declarative region. The pragmas in
-- question are:
--
-- Depends
-- Global
procedure Create_Generic_Contract (Unit : Node_Id);
-- Create a contract node for a generic package, generic subprogram, or a
-- generic body denoted by Unit by collecting all source contract-related
-- pragmas in the contract of the unit.
procedure Freeze_Previous_Contracts (Body_Decl : Node_Id);
-- Freeze the contracts of all source constructs found in the declarative
-- list which contains entry, package, protected, subprogram, or task body
-- denoted by Body_Decl. In addition, freeze the contract of the nearest
-- enclosing package body.
procedure Inherit_Subprogram_Contract
(Subp : Entity_Id;
From_Subp : Entity_Id);
-- Inherit relevant contract items from source subprogram From_Subp. Subp
-- denotes the destination subprogram. The inherited items are:
-- Extensions_Visible
-- ??? it would be nice if this routine handles Pre'Class and Post'Class
procedure Instantiate_Subprogram_Contract (Templ : Node_Id; L : List_Id);
-- Instantiate all source pragmas found in the contract of the generic
-- subprogram declaration template denoted by Templ. The instantiated
-- pragmas are added to list L.
procedure Save_Global_References_In_Contract
(Templ : Node_Id;
Gen_Id : Entity_Id);
-- Save all global references found within the aspect specifications and
-- the contract-related source pragmas assocated with generic template
-- Templ. Gen_Id denotes the entity of the analyzed generic copy.
end Contracts;
|
-- { dg-do compile }
-- { dg-options "-gnatws" }
package body array1 is
subtype Small is Integer range 1 .. MAX;
type LFT is record
RIC_ID : RIC_TYPE;
end record;
LF : array (RIC_TYPE, Small) of LFT;
procedure Foo (R : RIC_TYPE) is
L : Small;
T : LFT renames LF (R, L);
begin
Start_Timer (T'ADDRESS);
end;
procedure Bar (A : Integer; R : RIC_TYPE) is
S : LFT renames LF (R, A);
begin
null;
end;
procedure Start_Timer (Q : SYSTEM.ADDRESS) is
begin
null;
end;
end array1;
|
-- This spec has been automatically generated from msp430g2553.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
-- ADC10
package MSP430_SVD.ADC10 is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- ADC10 Data Transfer Control 0
type ADC10DTC0_Register is record
-- This bit should normally be reset
ADC10FETCH : MSP430_SVD.Bit := 16#0#;
-- ADC10 block one
ADC10B1 : MSP430_SVD.Bit := 16#0#;
-- ADC10 continuous transfer
ADC10CT : MSP430_SVD.Bit := 16#0#;
-- ADC10 two-block mode
ADC10TB : MSP430_SVD.Bit := 16#0#;
-- unspecified
Reserved_4_7 : MSP430_SVD.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 8,
Bit_Order => System.Low_Order_First;
for ADC10DTC0_Register use record
ADC10FETCH at 0 range 0 .. 0;
ADC10B1 at 0 range 1 .. 1;
ADC10CT at 0 range 2 .. 2;
ADC10TB at 0 range 3 .. 3;
Reserved_4_7 at 0 range 4 .. 7;
end record;
-- ADC10 Sample Hold Select Bit: 0
type ADC10CTL0_ADC10SHT_Field is
(-- 4 x ADC10CLKs
Adc10Sht_0,
-- 8 x ADC10CLKs
Adc10Sht_1,
-- 16 x ADC10CLKs
Adc10Sht_2,
-- 64 x ADC10CLKs
Adc10Sht_3)
with Size => 2;
for ADC10CTL0_ADC10SHT_Field use
(Adc10Sht_0 => 0,
Adc10Sht_1 => 1,
Adc10Sht_2 => 2,
Adc10Sht_3 => 3);
-- ADC10 Reference Select Bit: 0
type ADC10CTL0_SREF_Field is
(-- VR+ = AVCC and VR- = AVSS
Sref_0,
-- VR+ = VREF+ and VR- = AVSS
Sref_1,
-- VR+ = VEREF+ and VR- = AVSS
Sref_2,
-- VR+ = VEREF+ and VR- = AVSS
Sref_3,
-- VR+ = AVCC and VR- = VREF-/VEREF-
Sref_4,
-- VR+ = VREF+ and VR- = VREF-/VEREF-
Sref_5,
-- VR+ = VEREF+ and VR- = VREF-/VEREF-
Sref_6,
-- VR+ = VEREF+ and VR- = VREF-/VEREF-
Sref_7)
with Size => 3;
for ADC10CTL0_SREF_Field use
(Sref_0 => 0,
Sref_1 => 1,
Sref_2 => 2,
Sref_3 => 3,
Sref_4 => 4,
Sref_5 => 5,
Sref_6 => 6,
Sref_7 => 7);
-- ADC10 Control 0
type ADC10CTL0_Register is record
-- ADC10 Start Conversion
ADC10SC : MSP430_SVD.Bit := 16#0#;
-- ADC10 Enable Conversion
ENC : MSP430_SVD.Bit := 16#0#;
-- ADC10 Interrupt Flag
ADC10IFG : MSP430_SVD.Bit := 16#0#;
-- ADC10 Interrupt Enalbe
ADC10IE : MSP430_SVD.Bit := 16#0#;
-- ADC10 On/Enable
ADC10ON : MSP430_SVD.Bit := 16#0#;
-- ADC10 Reference on
REFON : MSP430_SVD.Bit := 16#0#;
-- ADC10 Ref 0:1.5V / 1:2.5V
REF2_5V : MSP430_SVD.Bit := 16#0#;
-- ADC10 Multiple SampleConversion
MSC : MSP430_SVD.Bit := 16#0#;
-- ADC10 Reference Burst Mode
REFBURST : MSP430_SVD.Bit := 16#0#;
-- ADC10 Enalbe output of Ref.
REFOUT : MSP430_SVD.Bit := 16#0#;
-- ADC10 Sampling Rate 0:200ksps / 1:50ksps
ADC10SR : MSP430_SVD.Bit := 16#0#;
-- ADC10 Sample Hold Select Bit: 0
ADC10SHT : ADC10CTL0_ADC10SHT_Field := MSP430_SVD.ADC10.Adc10Sht_0;
-- ADC10 Reference Select Bit: 0
SREF : ADC10CTL0_SREF_Field := MSP430_SVD.ADC10.Sref_0;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for ADC10CTL0_Register use record
ADC10SC at 0 range 0 .. 0;
ENC at 0 range 1 .. 1;
ADC10IFG at 0 range 2 .. 2;
ADC10IE at 0 range 3 .. 3;
ADC10ON at 0 range 4 .. 4;
REFON at 0 range 5 .. 5;
REF2_5V at 0 range 6 .. 6;
MSC at 0 range 7 .. 7;
REFBURST at 0 range 8 .. 8;
REFOUT at 0 range 9 .. 9;
ADC10SR at 0 range 10 .. 10;
ADC10SHT at 0 range 11 .. 12;
SREF at 0 range 13 .. 15;
end record;
-- ADC10 Conversion Sequence Select 0
type ADC10CTL1_CONSEQ_Field is
(-- Single channel single conversion
Conseq_0,
-- Sequence of channels
Conseq_1,
-- Repeat single channel
Conseq_2,
-- Repeat sequence of channels
Conseq_3)
with Size => 2;
for ADC10CTL1_CONSEQ_Field use
(Conseq_0 => 0,
Conseq_1 => 1,
Conseq_2 => 2,
Conseq_3 => 3);
-- ADC10 Clock Source Select Bit: 0
type ADC10CTL1_ADC10SSEL_Field is
(-- ADC10OSC
Adc10Ssel_0,
-- ACLK
Adc10Ssel_1,
-- MCLK
Adc10Ssel_2,
-- SMCLK
Adc10Ssel_3)
with Size => 2;
for ADC10CTL1_ADC10SSEL_Field use
(Adc10Ssel_0 => 0,
Adc10Ssel_1 => 1,
Adc10Ssel_2 => 2,
Adc10Ssel_3 => 3);
-- ADC10 Clock Divider Select Bit: 0
type ADC10CTL1_ADC10DIV_Field is
(-- ADC10 Clock Divider Select 0
Adc10Div_0,
-- ADC10 Clock Divider Select 1
Adc10Div_1,
-- ADC10 Clock Divider Select 2
Adc10Div_2,
-- ADC10 Clock Divider Select 3
Adc10Div_3,
-- ADC10 Clock Divider Select 4
Adc10Div_4,
-- ADC10 Clock Divider Select 5
Adc10Div_5,
-- ADC10 Clock Divider Select 6
Adc10Div_6,
-- ADC10 Clock Divider Select 7
Adc10Div_7)
with Size => 3;
for ADC10CTL1_ADC10DIV_Field use
(Adc10Div_0 => 0,
Adc10Div_1 => 1,
Adc10Div_2 => 2,
Adc10Div_3 => 3,
Adc10Div_4 => 4,
Adc10Div_5 => 5,
Adc10Div_6 => 6,
Adc10Div_7 => 7);
-- ADC10 Sample/Hold Source Bit: 0
type ADC10CTL1_SHS_Field is
(-- ADC10SC
Shs_0,
-- TA3 OUT1
Shs_1,
-- TA3 OUT0
Shs_2,
-- TA3 OUT2
Shs_3)
with Size => 2;
for ADC10CTL1_SHS_Field use
(Shs_0 => 0,
Shs_1 => 1,
Shs_2 => 2,
Shs_3 => 3);
-- ADC10 Input Channel Select Bit: 0
type ADC10CTL1_INCH_Field is
(-- Selects Channel 0
Inch_0,
-- Selects Channel 1
Inch_1,
-- Selects Channel 2
Inch_2,
-- Selects Channel 3
Inch_3,
-- Selects Channel 4
Inch_4,
-- Selects Channel 5
Inch_5,
-- Selects Channel 6
Inch_6,
-- Selects Channel 7
Inch_7,
-- Selects Channel 8
Inch_8,
-- Selects Channel 9
Inch_9,
-- Selects Channel 10
Inch_10,
-- Selects Channel 11
Inch_11,
-- Selects Channel 12
Inch_12,
-- Selects Channel 13
Inch_13,
-- Selects Channel 14
Inch_14,
-- Selects Channel 15
Inch_15)
with Size => 4;
for ADC10CTL1_INCH_Field use
(Inch_0 => 0,
Inch_1 => 1,
Inch_2 => 2,
Inch_3 => 3,
Inch_4 => 4,
Inch_5 => 5,
Inch_6 => 6,
Inch_7 => 7,
Inch_8 => 8,
Inch_9 => 9,
Inch_10 => 10,
Inch_11 => 11,
Inch_12 => 12,
Inch_13 => 13,
Inch_14 => 14,
Inch_15 => 15);
-- ADC10 Control 1
type ADC10CTL1_Register is record
-- ADC10 BUSY
ADC10BUSY : MSP430_SVD.Bit := 16#0#;
-- ADC10 Conversion Sequence Select 0
CONSEQ : ADC10CTL1_CONSEQ_Field := MSP430_SVD.ADC10.Conseq_0;
-- ADC10 Clock Source Select Bit: 0
ADC10SSEL : ADC10CTL1_ADC10SSEL_Field := MSP430_SVD.ADC10.Adc10Ssel_0;
-- ADC10 Clock Divider Select Bit: 0
ADC10DIV : ADC10CTL1_ADC10DIV_Field := MSP430_SVD.ADC10.Adc10Div_0;
-- ADC10 Invert Sample Hold Signal
ISSH : MSP430_SVD.Bit := 16#0#;
-- ADC10 Data Format 0:binary 1:2's complement
ADC10DF : MSP430_SVD.Bit := 16#0#;
-- ADC10 Sample/Hold Source Bit: 0
SHS : ADC10CTL1_SHS_Field := MSP430_SVD.ADC10.Shs_0;
-- ADC10 Input Channel Select Bit: 0
INCH : ADC10CTL1_INCH_Field := MSP430_SVD.ADC10.Inch_0;
end record
with Volatile_Full_Access, Object_Size => 16,
Bit_Order => System.Low_Order_First;
for ADC10CTL1_Register use record
ADC10BUSY at 0 range 0 .. 0;
CONSEQ at 0 range 1 .. 2;
ADC10SSEL at 0 range 3 .. 4;
ADC10DIV at 0 range 5 .. 7;
ISSH at 0 range 8 .. 8;
ADC10DF at 0 range 9 .. 9;
SHS at 0 range 10 .. 11;
INCH at 0 range 12 .. 15;
end record;
-----------------
-- Peripherals --
-----------------
-- ADC10
type ADC10_Peripheral is record
-- ADC10 Data Transfer Control 0
ADC10DTC0 : aliased ADC10DTC0_Register;
-- ADC10 Data Transfer Control 1
ADC10DTC1 : aliased MSP430_SVD.Byte;
-- ADC10 Analog Enable 0
ADC10AE0 : aliased MSP430_SVD.Byte;
-- ADC10 Control 0
ADC10CTL0 : aliased ADC10CTL0_Register;
-- ADC10 Control 1
ADC10CTL1 : aliased ADC10CTL1_Register;
-- ADC10 Memory
ADC10MEM : aliased MSP430_SVD.UInt16;
-- ADC10 Data Transfer Start Address
ADC10SA : aliased MSP430_SVD.UInt16;
end record
with Volatile;
for ADC10_Peripheral use record
ADC10DTC0 at 16#0# range 0 .. 7;
ADC10DTC1 at 16#1# range 0 .. 7;
ADC10AE0 at 16#2# range 0 .. 7;
ADC10CTL0 at 16#168# range 0 .. 15;
ADC10CTL1 at 16#16A# range 0 .. 15;
ADC10MEM at 16#16C# range 0 .. 15;
ADC10SA at 16#174# range 0 .. 15;
end record;
-- ADC10
ADC10_Periph : aliased ADC10_Peripheral
with Import, Address => ADC10_Base;
end MSP430_SVD.ADC10;
|
with vectores; use vectores;
function esta_en_vector_ordenado (n: in Integer; V: in Vector_De_Enteros) return Boolean is
-- pre: V contiene al menos un elemento (V'Last >= 1)
-- V esta ordenado ascendentemente:
-- V(i) <= V(i+1), 1 <= i < V'last
-- post: el resultado es True si N esta en V y False si no
-- El algoritmo es eficiente aprovechando que V esta ordenado
rdo: Boolean;
I: Integer;
begin
rdo:= False;
I:= V'First;
while (rdo=False and I<=V'Last) and then n>=V(I) loop
if V(I)=n then
rdo:= True;
end if;
I:=I+1;
end loop;
return rdo;
end esta_en_vector_ordenado;
|
pragma License (Unrestricted);
-- implementation unit specialized for FreeBSD (or Linux)
with Ada.IO_Exceptions;
with Ada.Streams;
with C.iconv;
package System.Native_Environment_Encoding is
-- Platform-depended text encoding.
pragma Preelaborate;
use type C.char_array;
-- max length of one multi-byte character
Max_Substitute_Length : constant := 6; -- UTF-8
-- encoding identifier
type Encoding_Id is access constant C.char;
for Encoding_Id'Storage_Size use 0;
function Get_Image (Encoding : Encoding_Id) return String;
function Get_Default_Substitute (Encoding : Encoding_Id)
return Ada.Streams.Stream_Element_Array;
function Get_Min_Size_In_Stream_Elements (Encoding : Encoding_Id)
return Ada.Streams.Stream_Element_Offset;
UTF_8_Name : aliased constant C.char_array (0 .. 5) :=
"UTF-8" & C.char'Val (0);
UTF_8 : constant Encoding_Id := UTF_8_Name (0)'Access;
UTF_16_Names : aliased constant
array (Bit_Order) of aliased C.char_array (0 .. 8) := (
High_Order_First => "UTF-16BE" & C.char'Val (0),
Low_Order_First => "UTF-16LE" & C.char'Val (0));
UTF_16 : constant Encoding_Id := UTF_16_Names (Default_Bit_Order)(0)'Access;
UTF_16BE : constant Encoding_Id :=
UTF_16_Names (High_Order_First)(0)'Access;
UTF_16LE : constant Encoding_Id :=
UTF_16_Names (Low_Order_First)(0)'Access;
UTF_32_Names : aliased constant
array (Bit_Order) of aliased C.char_array (0 .. 8) := (
High_Order_First => "UTF-32BE" & C.char'Val (0),
Low_Order_First => "UTF-32LE" & C.char'Val (0));
UTF_32 : constant Encoding_Id := UTF_32_Names (Default_Bit_Order)(0)'Access;
UTF_32BE : constant Encoding_Id :=
UTF_32_Names (High_Order_First)(0)'Access;
UTF_32LE : constant Encoding_Id :=
UTF_32_Names (Low_Order_First)(0)'Access;
function Get_Current_Encoding return Encoding_Id;
-- Returns UTF-8. In POSIX, The system encoding is assumed as UTF-8.
pragma Inline (Get_Current_Encoding);
-- subsidiary types to converter
type Subsequence_Status_Type is (
Finished,
Success,
Overflow, -- the output buffer is not large enough
Illegal_Sequence, -- a input character could not be mapped to the output
Truncated); -- the input buffer is broken off at a multi-byte character
pragma Discard_Names (Subsequence_Status_Type);
type Continuing_Status_Type is
new Subsequence_Status_Type range
Success ..
Subsequence_Status_Type'Last;
type Finishing_Status_Type is
new Subsequence_Status_Type range
Finished ..
Overflow;
type Status_Type is
new Subsequence_Status_Type range
Finished ..
Illegal_Sequence;
type Substituting_Status_Type is
new Status_Type range
Finished ..
Overflow;
subtype True_Only is Boolean range True .. True;
-- converter
type Converter is record
iconv : C.iconv.iconv_t := C.void_ptr (Null_Address);
-- about "From"
Min_Size_In_From_Stream_Elements : Ada.Streams.Stream_Element_Offset;
-- about "To"
Substitute_Length : Ada.Streams.Stream_Element_Offset;
Substitute : Ada.Streams.Stream_Element_Array (
1 ..
Max_Substitute_Length);
end record;
pragma Suppress_Initialization (Converter);
Disable_Controlled : constant Boolean := False;
procedure Open (Object : in out Converter; From, To : Encoding_Id);
procedure Close (Object : in out Converter);
function Is_Open (Object : Converter) return Boolean;
pragma Inline (Is_Open);
function Min_Size_In_From_Stream_Elements_No_Check (Object : Converter)
return Ada.Streams.Stream_Element_Offset;
function Substitute_No_Check (Object : Converter)
return Ada.Streams.Stream_Element_Array;
procedure Set_Substitute_No_Check (
Object : in out Converter;
Substitute : Ada.Streams.Stream_Element_Array);
-- convert subsequence
procedure Convert_No_Check (
Object : Converter;
Item : Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Out_Item : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Finish : Boolean;
Status : out Subsequence_Status_Type);
procedure Convert_No_Check (
Object : Converter;
Item : Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Out_Item : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Status : out Continuing_Status_Type);
procedure Convert_No_Check (
Object : Converter;
Out_Item : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Finish : True_Only;
Status : out Finishing_Status_Type);
-- convert all character sequence
-- procedure Convert_No_Check (
-- Object : Converter;
-- Item : Ada.Streams.Stream_Element_Array;
-- Last : out Ada.Streams.Stream_Element_Offset;
-- Out_Item : out Ada.Streams.Stream_Element_Array;
-- Out_Last : out Ada.Streams.Stream_Element_Offset;
-- Finish : True_Only;
-- Status : out Status_Type);
-- convert all character sequence with substitute
procedure Convert_No_Check (
Object : Converter;
Item : Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Out_Item : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Finish : True_Only;
Status : out Substituting_Status_Type);
procedure Put_Substitute (
Object : Converter;
Out_Item : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Is_Overflow : out Boolean);
-- exceptions
Name_Error : exception
renames Ada.IO_Exceptions.Name_Error;
Use_Error : exception
renames Ada.IO_Exceptions.Use_Error;
end System.Native_Environment_Encoding;
|
with System.Address_To_Named_Access_Conversions;
with System.Storage_Barriers;
package body System.Atomic_Primitives is
use type Interfaces.Unsigned_8;
use type Interfaces.Unsigned_16;
use type Interfaces.Unsigned_32;
use type Interfaces.Unsigned_64;
pragma Compile_Time_Warning (
not uint8'Atomic_Always_Lock_Free,
"uint8 is not atomic");
pragma Compile_Time_Warning (
not uint16'Atomic_Always_Lock_Free,
"uint16 is not atomic");
pragma Compile_Time_Warning (
not uint32'Atomic_Always_Lock_Free,
"uint32 is not atomic");
-- pragma Compile_Time_Warning (
-- not uint64'Atomic_Always_Lock_Free,
-- "uint64 is not atomic");
type uint8_Access is access all uint8;
for uint8_Access'Storage_Size use 0;
type uint16_Access is access all uint16;
for uint16_Access'Storage_Size use 0;
type uint32_Access is access all uint32;
for uint32_Access'Storage_Size use 0;
type uint64_Access is access all uint64;
for uint64_Access'Storage_Size use 0;
package uint8_Access_Conv is
new Address_To_Named_Access_Conversions (uint8, uint8_Access);
package uint16_Access_Conv is
new Address_To_Named_Access_Conversions (uint16, uint16_Access);
package uint32_Access_Conv is
new Address_To_Named_Access_Conversions (uint32, uint32_Access);
package uint64_Access_Conv is
new Address_To_Named_Access_Conversions (uint64, uint64_Access);
-- Use sequentially consistent model for general purpose.
Order : constant := Storage_Barriers.ATOMIC_SEQ_CST;
function atomic_load (
ptr : not null access constant uint8;
memorder : Integer := Order)
return uint8
with Import, Convention => Intrinsic, External_Name => "__atomic_load_1";
function atomic_load (
ptr : not null access constant uint16;
memorder : Integer := Order)
return uint16
with Import, Convention => Intrinsic, External_Name => "__atomic_load_2";
function atomic_load (
ptr : not null access constant uint32;
memorder : Integer := Order)
return uint32
with Import, Convention => Intrinsic, External_Name => "__atomic_load_4";
function atomic_load (
ptr : not null access constant uint64;
memorder : Integer := Order)
return uint64
with Import, Convention => Intrinsic, External_Name => "__atomic_load_8";
function atomic_compare_exchange (
ptr : not null access uint8;
expected : not null access uint8;
desired : uint8;
weak : Boolean := False;
success_memorder : Integer := Order;
failure_memorder : Integer := Order)
return Boolean
with Import,
Convention => Intrinsic,
External_Name => "__atomic_compare_exchange_1";
function atomic_compare_exchange (
ptr : not null access uint16;
expected : not null access uint16;
desired : uint16;
weak : Boolean := False;
success_memorder : Integer := Order;
failure_memorder : Integer := Order)
return Boolean
with Import,
Convention => Intrinsic,
External_Name => "__atomic_compare_exchange_2";
function atomic_compare_exchange (
ptr : not null access uint32;
expected : not null access uint32;
desired : uint32;
weak : Boolean := False;
success_memorder : Integer := Order;
failure_memorder : Integer := Order)
return Boolean
with Import,
Convention => Intrinsic,
External_Name => "__atomic_compare_exchange_4";
function atomic_compare_exchange (
ptr : not null access uint64;
expected : not null access uint64;
desired : uint64;
weak : Boolean := False;
success_memorder : Integer := Order;
failure_memorder : Integer := Order)
return Boolean
with Import,
Convention => Intrinsic,
External_Name => "__atomic_compare_exchange_8";
-- implementation
function Lock_Free_Read_8 (Ptr : Address) return Interfaces.Unsigned_8 is
begin
return atomic_load (uint8_Access_Conv.To_Pointer (Ptr));
end Lock_Free_Read_8;
function Lock_Free_Read_16 (Ptr : Address) return Interfaces.Unsigned_16 is
begin
return atomic_load (uint16_Access_Conv.To_Pointer (Ptr));
end Lock_Free_Read_16;
function Lock_Free_Read_32 (Ptr : Address) return Interfaces.Unsigned_32 is
begin
return atomic_load (uint32_Access_Conv.To_Pointer (Ptr));
end Lock_Free_Read_32;
function Lock_Free_Read_64 (Ptr : Address) return Interfaces.Unsigned_64 is
begin
return atomic_load (uint64_Access_Conv.To_Pointer (Ptr));
end Lock_Free_Read_64;
function Lock_Free_Try_Write_8 (
Ptr : Address;
Expected : in out Interfaces.Unsigned_8;
Desired : Interfaces.Unsigned_8)
return Boolean is
begin
return atomic_compare_exchange (
uint8_Access_Conv.To_Pointer (Ptr),
Expected'Unrestricted_Access,
Desired);
end Lock_Free_Try_Write_8;
function Lock_Free_Try_Write_16 (
Ptr : Address;
Expected : in out Interfaces.Unsigned_16;
Desired : Interfaces.Unsigned_16)
return Boolean is
begin
return atomic_compare_exchange (
uint16_Access_Conv.To_Pointer (Ptr),
Expected'Unrestricted_Access,
Desired);
end Lock_Free_Try_Write_16;
function Lock_Free_Try_Write_32 (
Ptr : Address;
Expected : in out Interfaces.Unsigned_32;
Desired : Interfaces.Unsigned_32)
return Boolean is
begin
return atomic_compare_exchange (
uint32_Access_Conv.To_Pointer (Ptr),
Expected'Unrestricted_Access,
Desired);
end Lock_Free_Try_Write_32;
function Lock_Free_Try_Write_64 (
Ptr : Address;
Expected : in out Interfaces.Unsigned_64;
Desired : Interfaces.Unsigned_64)
return Boolean is
begin
return atomic_compare_exchange (
uint64_Access_Conv.To_Pointer (Ptr),
Expected'Unrestricted_Access,
Desired);
end Lock_Free_Try_Write_64;
end System.Atomic_Primitives;
|
with Giza.Widget.Tiles;
use Giza.Widget;
with Basic_Test_Window; use Basic_Test_Window;
package Test_Tiles_Window is
type Tiles_Window is new Test_Window with private;
type Tiles_Window_Ref is access all Tiles_Window;
overriding
procedure On_Init (This : in out Tiles_Window);
overriding
procedure On_Displayed (This : in out Tiles_Window);
overriding
procedure On_Hidden (This : in out Tiles_Window);
private
type Tiles_Window is new Test_Window with record
Tile_Top_Down : Tiles.Ref;
Tile_Bottom_Up : Tiles.Ref;
Tile_Right_Left : Tiles.Ref;
Tile_Left_Right : Tiles.Ref;
end record;
end Test_Tiles_Window;
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2013 Felix Krause <contact@flyx.org>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Strings.Unbounded;
with Ada.Text_IO;
with GL.Context;
with GL.Types;
with Orka.Contexts;
with Orka.Loggers.Terminal;
with Orka.Logging;
with Orka.Windows.GLFW;
procedure Orka_Info is
Context : constant Orka.Contexts.Context'Class
:= Orka.Windows.GLFW.Initialize (Major => 4, Minor => 2);
pragma Unreferenced (Context);
procedure Display_Context_Information is
use Ada.Strings.Unbounded;
use Ada.Text_IO;
begin
Put_Line ("Major version: " & GL.Types.Int'Image (GL.Context.Major_Version));
Put_Line ("Minor version: " & GL.Types.Int'Image (GL.Context.Minor_Version));
Put_Line (" Vendor: " & GL.Context.Vendor);
Put_Line ("Renderer: " & GL.Context.Renderer);
Put_Line ("OpenGL version: " & GL.Context.Version_String);
Put_Line (" GLSL version: " & GL.Context.Primary_Shading_Language_Version);
Put_Line ("Extensions: ");
for US_Name of GL.Context.Extensions loop
declare
Name : constant String := To_String (US_Name);
begin
Put_Line (" " & Name);
pragma Assert (GL.Context.Has_Extension (Name));
end;
end loop;
Put_Line ("Supported shading language versions:");
begin
for US_Version of GL.Context.Supported_Shading_Language_Versions loop
declare
Version : constant String := To_String (US_Version);
begin
Put_Line (" " & Version);
pragma Assert (GL.Context.Supports_Shading_Language_Version (Version));
end;
end loop;
exception
when others =>
Put_Line ("OpenGL version too old for querying supported versions");
end;
end Display_Context_Information;
begin
Orka.Logging.Set_Logger (Orka.Loggers.Terminal.Create_Logger (Level => Orka.Loggers.Info));
declare
W : aliased Orka.Windows.Window'Class := Orka.Windows.GLFW.Create_Window
(1, 1, Visible => False);
pragma Unreferenced (W);
begin
Display_Context_Information;
end;
end Orka_Info;
|
with Unchecked_Deallocation;
package body Stack_Pack is
SCCS_ID : constant String := "@(#) stack.ada, Version 1.2";
type Node is
record
Datum : Element;
Next : Link;
end record;
function Top_Value (S: in Stack) return Element is
begin
if S.Top = null then
raise Stack_Underflow;
else
return S.Top.Datum;
end if;
end Top_Value;
function Depth_of_Stack (S: in Stack) return Natural is
begin
return S.Tos;
end Depth_of_Stack;
procedure Make_Stack(S: out Stack) is
begin
S := (Tos => 0, Top | Extras => null);
end Make_Stack;
procedure Push(S: in out Stack; Value: in Element) is
New_Node : Link;
begin
S.Tos := S.Tos + 1;
if S.Extras = null then
New_Node := new Node;
else
New_Node := S.Extras;
S.Extras := S.Extras.Next;
end if;
New_Node.all := (Datum => Value, Next => S.Top);
S.Top := New_Node;
end Push;
procedure Pop (S: in out Stack; Value: out Element) is
Temp : Link;
begin
if S.Tos = 0 then
raise Stack_Underflow;
end if;
Value := S.Top.Datum;
Temp := S.Top.Next;
S.Top.Next := S.Extras;
S.Extras := S.Top;
S.Top := Temp;
S.Tos := S.Tos - 1;
end Pop;
procedure Free is new Unchecked_Deallocation(Node, Link);
-- procedure free(x : link);
-- pragma interface(c , free);
procedure Free_List(List: in out Link) is
Temp : Link;
begin
Temp := List;
while Temp /= null loop
List := List.Next;
Free(Temp);
Temp := List;
end loop;
end Free_List;
procedure Free_Stack(S: in out Stack) is
begin
Free_List(S.Top);
Free_List(S.Extras);
end Free_Stack;
end Stack_Pack;
|
with Ada.Text_Io, Ada.Integer_Text_IO;
use Ada.Text_Io, Ada.Integer_Text_IO;
procedure Diff_Ints is
A, B, C : Integer;
begin
Put("A=");
Get(A);
Put("B=");
Get(B);
Put("C=");
Get(C);
if A = B and B = C and C = A then
Put_Line("All the same");
elsif A = B or A = C or B = C then
Put_Line("Two the same");
else
Put_Line("All different");
end if;
end Diff_Ints;
|
-- $Id: parser.adb,v 1.15 2008/10/08 11:18:33 grosch Exp $
$@ with $, General, DynArray, Strings,
# ifndef NO_RECOVER
Sets,
# endif
# if ! defined NO_RECOVER | defined YYReParse
Errors,
# endif
# ifndef YYDEBUG
Position,
# endif
Text_Io;
$@ package body @ is
$G[ -- GLOBAL section is inserted here
$@ type tParsAttribute is record Scan: $.tScanAttribute; end record;
$]
# ifndef yyInitStackSize
# define yyInitStackSize 100
# endif
# ifndef ERROR
# define ERROR
# endif
yyNoState : constant Integer := 0;
yystandard : constant Integer := 0;
yytrial : constant Integer := 1;
yybuffering : constant Integer := 2;
yyreparsing : constant Integer := 3;
# define yyS yySynAttribute
# define yyA yyAttributeStack
$T -- table constants are inserted here
yyFirstFinalState : constant Integer := yyFirstReadReduceState;
# define YYACCEPT goto yyAccept
# define YYABORT goto yyAbort
# define ErrorMessages(Messages) yyControl.yyMessages := Messages
# define SemActions(Actions) yyControl.yyActions := Actions
# ifdef YYNDefault
# define yytNComb yyCombType
# else
# define yytNComb yyStateRange
# endif
subtype yyShortCard is Integer range 0 .. 2 ** 16 - 1;
subtype yyShortInt is Integer range - (2 ** 15 - 1) .. 2 ** 15 - 1;
subtype yyStateRange is Integer range 0 .. yyLastState;
subtype yyReadReduceRange is Integer range yyFirstReadReduceState .. yyLastReadReduceState + 1;
subtype yyReduceRange is Integer range yyFirstReduceState .. yyLastReduceState;
subtype yySymbolRange is Integer range yyFirstSymbol .. yyLastSymbol;
type yyCombType is record Check, Next: yyStateRange; end record;
type yytControl is record yyMode: Integer; yyActions, yyMessages: Boolean; end record;
yyTBase : constant array (0 .. yyLastReadState) of Integer := (0,
$P
);
yyNBase : constant array (0 .. yyLastReadState) of Integer := (0,
$Q
);
# ifdef YYTDefault
yyTDefault : constant array (0 .. yyLastReadState) of yyStateRange := (0,
$D
);
# endif
# ifdef YYNDefault
yyNDefault : constant array (0 .. yyLastReadState) of yyStateRange := (0,
$V
);
# endif
yyTComb : constant array (0 .. yyTTableMax) of yyCombType := (
$M
);
yyNComb : constant array (yyLastTerminal + 1 .. yyNTableMax) of yytNComb := (
$N
$Y
);
yyLength : constant array (yyReduceRange) of yyShortCard := (
$K
);
yyLeftHandSide : constant array (yyReduceRange) of yySymbolRange := (
$H
);
yyContinuation : constant array (0 .. yyLastReadState + 1) of yySymbolRange := (0,
$O
others => 0);
yyFinalToProd : constant array (yyReadReduceRange) of yyReduceRange := (
$F
others => yyFirstReduceState);
yyCondition : constant array (yyLastReduceState + 1 .. yyLastState + 1) of yyStateRange := (
$A
others => 0);
yyStartLine : constant array (1 .. yyLastStopState - yyLastReadReduceState + 1) of yyShortCard := (
$J
others => 0);
yyControl : yytControl;
package SStack_DA is new DynArray (yyStateRange );
package AStack_DA is new DynArray (tParsAttribute );
function TokenName (Token: Integer) return String is
begin
case Token is
$W -- token names are inserted here
when others => return "_unknown_";
end case;
end TokenName;
# ifdef YYDEBUG
function yyRule (Rule: Integer) return String is
begin
case Rule is
$S -- rules are inserted here
when others => return "";
end case;
end yyRule;
yyCount : Integer := 0;
yyTraceFile : Text_Io.File_Type;
yyIsStdOut : Boolean := True;
function yyTrace return Text_Io.File_Type is
begin
if yyIsStdOut then return Text_Io.Standard_Output; else return yyTraceFile; end if;
end yyTrace;
procedure yyOpenTrace (FileName: String) is
begin
Text_Io.Open (yyTraceFile, Text_Io.Out_File, FileName);
yyIsStdOut := False;
end yyOpenTrace;
package Int_Io is new Text_Io.Integer_IO (Integer);
package Bool_Io is new Text_Io.Enumeration_IO (Boolean);
procedure yyNl;
procedure yyPrintState (yyState: yyStateRange);
# endif
# if defined YYTrialParse | defined YYReParse | defined YYGetLook
# ifndef yyInitBufferSize
# define yyInitBufferSize 100
# endif
# ifndef TOKENOP
# define TOKENOP
# endif
# ifndef BEFORE_TRIAL
# define BEFORE_TRIAL
# endif
# ifndef AFTER_TRIAL
# define AFTER_TRIAL
# endif
type yytBuffer is record Token : yySymbolRange;
$@ Attribute : $.tScanAttribute;
# ifdef YYMemoParse
yyStart : yyShortInt;
# endif
end record;
package Buffer_DA is new DynArray (yytBuffer);
yyBuffer : Buffer_DA.FlexArray;
yyBufferSize : Integer;
yyBufferNext : Integer;
yyBufferLast : Integer;
yyBufferClear : Boolean := True;
yyParseLevel : yyShortCard;
procedure yyBufferSet (yyToken: yySymbolRange) is
begin
if yyBufferNext = yyBufferLast then
if yyBufferClear then yyBufferLast := 0; end if;
yyBufferLast := yyBufferLast + 1;
if yyBufferLast >= yyBufferSize then
Buffer_DA.ExtendArray (yyBuffer, yyBufferSize);
# ifdef YYDEBUG
if yyDebug then
yyPrintState (0);
Text_Io.Put (yyTrace, "extend token buffer from ");
Int_Io .Put (yyTrace, yyBufferSize / 2, 0);
Text_Io.Put (yyTrace, " to ");
Int_Io .Put (yyTrace, yyBufferSize, 0);
yyNl;
end if;
# endif
end if;
yyBuffer (yyBufferLast).Token := yyToken;
$@ yyBuffer (yyBufferLast).Attribute := $.Attribute;
# ifdef YYMemoParse
yyBuffer (yyBufferLast).yyStart := 0;
# endif
yyBufferNext := yyBufferLast;
end if;
end yyBufferSet;
function yyGetToken return Integer is
yyToken : yySymbolRange;
begin
if yyBufferNext < yyBufferLast then
yyBufferNext := yyBufferNext + 1;
yyToken := yyBuffer (yyBufferNext).Token;
$@ $.Attribute := yyBuffer (yyBufferNext).Attribute;
else
$@ yyToken := $.GetToken;
if (yyControl.yyMode = yytrial) or (yyControl.yyMode = yybuffering) then
yyBufferLast := yyBufferLast + 1;
if yyBufferLast >= yyBufferSize then
Buffer_DA.ExtendArray (yyBuffer, yyBufferSize);
# ifdef YYDEBUG
if yyDebug then
yyPrintState (0);
Text_Io.Put (yyTrace, "extend token buffer from ");
Int_Io .Put (yyTrace, yyBufferSize / 2, 0);
Text_Io.Put (yyTrace, " to ");
Int_Io .Put (yyTrace, yyBufferSize, 0);
yyNl;
end if;
# endif
end if;
yyBuffer (yyBufferLast).Token := yyToken;
$@ yyBuffer (yyBufferLast).Attribute := $.Attribute;
# ifdef YYMemoParse
yyBuffer (yyBufferLast).yyStart := 0;
# endif
yyBufferNext := yyBufferLast;
end if;
end if;
TOKENOP
return yyToken;
end yyGetToken;
# else
$@ # define yyGetToken $.GetToken
# endif
# ifdef YYGetLook
# define GetLookahead(k) yyGetLookahead ((k) - 1, yyTerminal)
# define GetAttribute(k, a) yyGetAttribute ((k) - 1, yyTerminal, a)
function yyGetLookahead (k, Terminal: Integer) return Integer is
begin
if k = 0 then return Terminal; end if;
if yyControl.yyMode = yystandard then yyBufferSet (Terminal); end if;
while yyBufferNext + k > yyBufferLast loop
if (yyBufferNext < yyBufferLast) and
$@ (yyBuffer (yyBufferLast).Token = $.EofToken) then
$@ return $.EofToken;
end if;
yyBufferLast := yyBufferLast + 1;
if yyBufferLast >= yyBufferSize then
Buffer_DA.ExtendArray (yyBuffer, yyBufferSize);
# ifdef YYDEBUG
if yyDebug then
yyPrintState (0);
Text_Io.Put (yyTrace, "extend token buffer from ");
Int_Io .Put (yyTrace, yyBufferSize / 2, 0);
Text_Io.Put (yyTrace, " to ");
Int_Io .Put (yyTrace, yyBufferSize, 0);
yyNl;
end if;
# endif
end if;
$@ yyBuffer (yyBufferLast).Token := $.GetToken;
$@ yyBuffer (yyBufferLast).Attribute := $.Attribute;
# ifdef YYMemoParse
yyBuffer (yyBufferLast).yyStart := 0;
# endif
end loop;
return yyBuffer (yyBufferNext + k).Token;
end yyGetLookahead;
$@ procedure yyGetAttribute (k, Terminal: Integer; Attribute: out $.tScanAttribute) is
x : Integer;
begin
$@ if k = 0 then Attribute := $.Attribute;
else
x := yyGetLookahead (k, Terminal);
Attribute := yyBuffer (General.Min (yyBufferNext + k, yyBufferLast)).Attribute;
end if;
end yyGetAttribute;
# endif
# ifdef YYReParse
# define BufferOn(Actions, Messages) yyBufferOn (Actions, Messages, yyTerminal)
# define BufferPosition yyBufferNext
yyPrevControl : yytControl;
function yyBufferOn (yyActions, yyMessages: Boolean; yyToken: yySymbolRange) return Integer is
begin
if yyControl.yyMode = yystandard then
yyPrevControl := yyControl;
yyControl.yyMode := yybuffering;
yyControl.yyActions := yyActions;
yyControl.yyMessages := yyMessages;
yyBufferSet (yyToken);
yyBufferClear := False;
end if;
return yyBufferNext;
end yyBufferOn;
function BufferOff return Integer is
begin
if yyControl.yyMode = yybuffering then yyControl := yyPrevControl; end if;
return yyBufferNext;
end BufferOff;
procedure BufferClear is
begin
yyBufferClear := True;
end BufferClear;
# endif
# ifdef YYDEBUG
yyModeLetter: constant array (0 .. 3) of Character := ('S', 'T', 'B', 'R');
procedure yyNl is begin Text_Io.New_Line (yyTrace); end yyNl;
procedure yyPrintState (yyState: yyStateRange) is
begin
yyCount := yyCount + 1;
Int_Io .Put (yyTrace, yyCount, 4);
Text_Io.Put (yyTrace, ":");
$@ Position.WritePosition (yyTrace, $.Attribute.Position);
Text_Io.Put (yyTrace, ":");
Int_Io .Put (yyTrace, yyState, 5);
Text_Io.Put (yyTrace, " ");
Text_Io.Put (yyTrace, yyModeLetter (yyControl.yyMode));
Text_Io.Put (yyTrace, " ");
# if defined YYTrialParse | defined YYReParse
if yyParseLevel > 0 then
Int_Io .Put (yyTrace, yyParseLevel, 2);
for i in 0 .. yyParseLevel loop Text_Io.Put (yyTrace, " "); end loop;
else
Text_Io.Put (yyTrace, " ");
end if;
# else
Text_Io.Put (yyTrace, " ");
# endif
end yyPrintState;
# endif
yyStackPtr : yyShortCard;
yyStateStackSize : Integer;
yyAttrStackSize : Integer;
yyShortStackSize : yyShortCard;
yyStateStack : SStack_DA.FlexArray;
yyAttributeStack : AStack_DA.FlexArray;
function yyParse (yyStartSymbol: Integer; yyToken: Integer;
yyLine: Integer) return Integer;
function Next (pState: Integer; Symbol: Integer) return Integer;
# ifndef NO_RECOVER
procedure ErrorRecovery (Terminal: in out Integer;
StackSize: Integer; StackPtr: Integer);
procedure ComputeContinuation (StackSize: Integer; StackPtr: Integer;
ContinueSet: out Sets.tSet; reduce: Boolean);
procedure ComputeRestartPoints (pStackSize: Integer;
pStackPtr: Integer; RestartSet: out Sets.tSet);
function IsContinuation (Terminal: Integer; pStackSize: Integer;
pStackPtr: Integer; reduce: Boolean) return Boolean;
# endif
$@ function @ return Integer is
begin
$@ return @2 (yyStartState);
$@ end @;
$@ function @2 (yyStartSymbol: Integer) return Integer is
yyErrorCount : Integer;
begin
$@ Begin@;
yyStateStackSize := yyInitStackSize;
yyAttrStackSize := yyInitStackSize;
SStack_DA.MakeArray (yyStateStack, yyStateStackSize);
AStack_DA.MakeArray (yyAttributeStack, yyAttrStackSize);
yyShortStackSize := yyStateStackSize - 1;
yyStackPtr := 0;
# if defined YYTrialParse | defined YYReParse
yyBufferSize := yyInitBufferSize;
Buffer_DA.MakeArray (yyBuffer, yyBufferSize);
yyBufferNext := 1;
yyBufferLast := 1;
yyParseLevel := 0;
# endif
# ifdef YYDEBUG
if yyDebug then
Text_Io.Put (yyTrace, " # |Position|State|Mod|Lev|Action |Terminal and Lookahead or Rule");
yyNl; yyNl;
end if;
# endif
yyControl.yyMode := yystandard;
yyControl.yyActions := True;
yyControl.yyMessages := True;
yyErrorCount := yyParse (yyStartSymbol, yyGetToken, yyStartLine (yyStartSymbol));
SStack_DA.ReleaseArray (yyStateStack, yyStateStackSize);
AStack_DA.ReleaseArray (yyAttributeStack, yyAttrStackSize);
# if defined YYTrialParse | defined YYReParse
Buffer_DA.ReleaseArray (yyBuffer, yyBufferSize);
# endif
return yyErrorCount;
$@ end @2;
# ifdef YYTrialParse
# ifdef YYMemoParse
# define MemoryClear(Position) yyBuffer (Position).yyStart := 0
# endif
function yyTrialParse (yyStartSymbol: Integer; yyToken: Integer; yyLine: Integer) return Integer is
yyErrorCount : Integer;
yyPrevStackPtr : Integer;
yyPrevBufferNext : Integer;
yyPrevControl : yytControl;
begin
BEFORE_TRIAL
# ifdef YYMemoParse
if yyBuffer (yyBufferNext).yyStart = yyStartSymbol then return 0; end if;
if yyBuffer (yyBufferNext).yyStart = - yyStartSymbol then return 1; end if;
# endif
yyPrevControl := yyControl;
yyPrevStackPtr := yyStackPtr;
yyStackPtr := yyStackPtr + 1;
yyParseLevel := yyParseLevel + 1;
if yyControl.yyMode = yystandard then yyBufferSet (yyToken); end if;
yyPrevBufferNext := yyBufferNext;
yyControl.yyMode := yytrial;
yyControl.yyActions := False;
yyControl.yyMessages := False;
yyErrorCount := yyParse (yyStartSymbol, yyToken, yyLine);
# ifdef YYMemoParse
if yyErrorCount = 0 then
yyBuffer (yyPrevBufferNext).yyStart := yyStartSymbol;
else
yyBuffer (yyPrevBufferNext).yyStart := - yyStartSymbol;
end if;
# endif
yyStackPtr := yyPrevStackPtr;
yyBufferNext := yyPrevBufferNext;
yyControl := yyPrevControl;
yyParseLevel := yyParseLevel - 1;
$@ $.Attribute := yyBuffer (yyBufferNext).Attribute;
AFTER_TRIAL
return yyErrorCount;
end yyTrialParse;
# endif
# ifdef YYReParse
function ReParse (yyStartSymbol: Integer; yyFrom, yyTo: Integer; yyActions, yyMessages: Boolean) return Integer is
yyErrorCount : Integer;
yyPrevStackPtr : Integer;
yyPrevBufferNext : Integer;
yyPrevControl : yytControl;
yyToToken : Integer;
begin
if (1 <= yyFrom) and (yyFrom <= yyTo) and (yyTo <= yyBufferLast) then
yyPrevStackPtr := yyStackPtr;
yyPrevBufferNext := yyBufferNext;
yyToToken := yyBuffer (yyTo).Token;
yyPrevControl := yyControl;
yyStackPtr := yyStackPtr + 1;
yyParseLevel := yyParseLevel + 1;
yyBufferNext := yyFrom - 1;
$@ yyBuffer (yyTo).Token := $.EofToken;
yyControl.yyMode := yyreparsing;
yyControl.yyActions := yyActions;
yyControl.yyMessages := yyMessages;
yyErrorCount := yyParse (yyStartSymbol, yyGetToken, yyStartLine (yyStartSymbol));
yyStackPtr := yyPrevStackPtr;
yyBufferNext := yyPrevBufferNext;
yyControl := yyPrevControl;
yyParseLevel := yyParseLevel - 1;
yyBuffer (yyTo).Token := yyToToken;
$@ $.Attribute := yyBuffer (yyBufferNext).Attribute;
return yyErrorCount;
else
$@ Errors.Message ("invalid call of ReParse", Errors.Error, $.Attribute.Position);
return 1;
end if;
end ReParse;
# endif
function yyParse (yyStartSymbol: Integer; yyToken: Integer; yyLine: Integer) return Integer is
$L -- LOCAL section is inserted here
yyState : Integer;
yyTerminal : Integer;
yyNonterminal : Integer; -- left-hand side symbol
yySynAttribute : tParsAttribute; -- synthesized attribute
$@ yyRepairAttribute : $.tScanAttribute;
yyRepairToken : Integer;
yyNextState : Integer;
yyCombIndex : Integer;
yyIsRepairing : Boolean;
yyErrorCount : Integer;
yyTokenString : Strings.tString;
# ifdef YYDEBUG
yyStartCount : Integer;
yyPrevTerminal : Integer;
# endif
# ifdef YYGetLook
yy2 : Integer;
# endif
procedure yyRead is
begin
yyState := yyCondition (yyState);
yyStackPtr := yyStackPtr + 1;
$@ yyAttributeStack (yyStackPtr).Scan := $.Attribute;
yyTerminal := yyGetToken;
# ifdef YYDEBUG
if yyDebug then
yyPrintState (yyStateStack (yyStackPtr - 1));
Text_Io.Put (yyTrace, "shift ");
Text_Io.Put (yyTrace, TokenName (yyPrevTerminal));
Text_Io.Put (yyTrace, ", lookahead: ");
Text_Io.Put (yyTrace, TokenName (yyTerminal));
yyNl;
yyPrevTerminal := yyTerminal;
end if;
# endif
yyIsRepairing := False;
end yyRead;
# ifdef YYDEBUG
function yyPrintResult (Line: Integer; Condition: Boolean) return Boolean is
begin
if yyDebug then
yyPrintState (yyStateStack (yyStackPtr));
Text_Io.Put (yyTrace, "check predicate in line ");
Int_Io .Put (yyTrace, Line, 0);
Text_Io.Put (yyTrace, ", result = ");
Bool_Io.Put (yyTrace, Condition);
yyNl;
end if;
return Condition;
end yyPrintResult;
# define yyGotoReduce(State, Rule) yyState := State; goto yyReduce;
# else
# define yyGotoReduce(State, Rule) goto Rule;
# define yyPrintResult(State, Line, Condition) Condition
# endif
begin
# ifdef YYDEBUG
if yyDebug then
yyPrintState (yyStartSymbol);
Text_Io.Put (yyTrace, "parse for predicate in line ");
Int_Io .Put (yyTrace, yyLine, 0);
Text_Io.Put (yyTrace, ", lookahead: ");
Text_Io.Put (yyTrace, TokenName (yyToken));
yyNl;
yyStartCount := yyCount;
yyPrevTerminal := yyToken;
end if;
# endif
yyState := yyStartSymbol;
yyTerminal := yyToken;
yyErrorCount := 0;
yyIsRepairing := False;
loop
if yyStackPtr >= yyShortStackSize then
SStack_DA.ExtendArray (yyStateStack, yyStateStackSize);
AStack_DA.ExtendArray (yyAttributeStack, yyAttrStackSize);
yyShortStackSize := yyStateStackSize - 1;
# ifdef YYDEBUG
if yyDebug then
yyPrintState (yyState);
Text_Io.Put (yyTrace, "extend stack from ");
Int_Io .Put (yyTrace, yyStateStackSize / 2, 0);
Text_Io.Put (yyTrace, " to ");
Int_Io .Put (yyTrace, yyStateStackSize, 0);
yyNl;
end if;
# endif
end if;
yyStateStack (yyStackPtr) := yyState;
yyTerm: loop -- SPEC State := Next (State, Terminal); terminal transition
yyCombIndex := yyTBase (yyState) + yyTerminal;
if yyTComb (yyCombIndex).Check = yyState then
yyState := yyTComb (yyCombIndex).Next; exit;
end if;
# ifdef YYTDefault
yyState := yyTDefault (yyState);
# else
yyState := yyNoState;
# endif
if yyState = yyNoState then -- syntax error
if not yyIsRepairing then -- report and recover
# ifdef YYTrialParse
if yyControl.yyMode = yytrial then goto yyAbort; end if;
# endif
ERROR
# ifndef NO_RECOVER
yyErrorCount := yyErrorCount + 1;
ErrorRecovery (yyTerminal, yyStateStackSize, yyStackPtr);
yyIsRepairing := True;
# else
YYABORT;
# endif
end if;
# ifndef NO_RECOVER
yyState := yyStateStack (yyStackPtr);
loop
yyNextState := Next (yyState, yyTerminal);
if (yyNextState /= yyNoState) and (yyNextState <= yyLastReadReduceState) then
yyState := yyNextState; -- restart point reached
yyIsRepairing := FALSE; -- stop error recovery
exit yyTerm;
end if;
yyRepairToken := yyContinuation (yyState); -- repair
yyState := Next (yyState, yyRepairToken);
if yyState > yyLastReduceState then -- dynamic ?
yyState := yyCondition (yyState);
end if;
if yyState <= yyLastReadReduceState then -- read or read reduce ?
$@ $.ErrorAttribute (yyRepairToken, yyRepairAttribute);
if yyControl.yyMessages then
Strings.To_tString (TokenName (yyRepairToken), yyTokenString);
Errors.ErrorMessageI (Errors.TokenInserted, Errors.Repair,
$@ $.Attribute.Position, Errors.cString, yyTokenString'Address);
end if;
# ifdef YYDEBUG
if yyDebug then
yyPrintState (yyStateStack (yyStackPtr));
Text_Io.Put (yyTrace, "insert ");
Text_Io.Put (yyTrace, TokenName (yyRepairToken));
yyNl;
yyPrintState (yyStateStack (yyStackPtr));
Text_Io.Put (yyTrace, "shift ");
Text_Io.Put (yyTrace, TokenName (yyRepairToken));
Text_Io.Put (yyTrace, ", lookahead: ");
Text_Io.Put (yyTrace, TokenName (yyTerminal));
yyNl;
end if;
# endif
if yyState >= yyFirstFinalState then -- avoid second push
yyState := yyFinalToProd (yyState);
end if;
if yyStackPtr >= yyShortStackSize then
SStack_DA.ExtendArray (yyStateStack, yyStateStackSize);
AStack_DA.ExtendArray (yyAttributeStack, yyAttrStackSize);
yyShortStackSize := yyStateStackSize - 1;
# ifdef YYDEBUG
if yyDebug then
yyPrintState (yyState);
Text_Io.Put (yyTrace, "extend stack from ");
Int_Io .Put (yyTrace, yyStateStackSize / 2, 0);
Text_Io.Put (yyTrace, " to ");
Int_Io .Put (yyTrace, yyStateStackSize, 0);
yyNl;
end if;
# endif
end if;
yyStackPtr := yyStackPtr + 1;
yyAttributeStack (yyStackPtr).Scan := yyRepairAttribute;
yyStateStack (yyStackPtr) := yyState;
end if;
if yyState >= yyFirstFinalState then -- final state ?
exit yyTerm;
end if;
end loop;
# endif
end if;
end loop yyTerm;
if yyState >= yyFirstFinalState then -- final state ?
if yyState <= yyLastReadReduceState then -- read reduce ?
yyStackPtr := yyStackPtr + 1;
$@ yyAttributeStack (yyStackPtr).Scan := $.Attribute;
yyTerminal := yyGetToken;
# ifdef YYDEBUG
if yyDebug then
yyStateStack (yyStackPtr) := yyStateStack (yyStackPtr - 1);
yyPrintState (yyStateStack (yyStackPtr));
Text_Io.Put (yyTrace, "shift ");
Text_Io.Put (yyTrace, TokenName (yyPrevTerminal));
Text_Io.Put (yyTrace, ", lookahead: ");
Text_Io.Put (yyTrace, TokenName (yyTerminal));
yyNl;
yyPrevTerminal := yyTerminal;
end if;
# endif
yyIsRepairing := False;
$X yyState := yyFinalToProd (yyState);
end if;
loop -- reduce
<<yyReduce>>
# ifdef YYDEBUG
if yyDebug then
if yyState <= yyLastReadReduceState then -- read reduce ?
yyState := yyFinalToProd (yyState);
end if;
yyPrintState (yyStateStack (yyStackPtr));
if yyState <= yyLastReduceState then
Text_Io.Put (yyTrace, "reduce ");
Text_Io.Put (yyTrace, yyRule (yyState - yyLastReadReduceState));
else
Text_Io.Put (yyTrace, "dynamic decision ");
Int_Io .Put (yyTrace, yyState - yyLastReduceState, 0);
end if;
yyNl;
end if;
# endif
$R -- Code for Reductions is inserted here
-- SPEC State := Next (Top (), Nonterminal); nonterminal transition
# ifdef YYNDefault
yyState := yyStateStack (yyStackPtr);
loop
yyCombIndex := yyNBase (yyState) + yyNonterminal;
if yyNComb (yyCombIndex).Check = yyState then
yyState := yyNComb (yyCombIndex).Next; exit;
end if;
yyState := yyNDefault (yyState);
end loop;
# else
yyState := yyNComb (yyNBase (yyStateStack (yyStackPtr)) + yyNonterminal);
# endif
yyStackPtr := yyStackPtr + 1;
yyAttributeStack (yyStackPtr) := yySynAttribute;
if yyState < yyFirstFinalState then exit; end if; -- read nonterminal ?
# ifdef YYDEBUG
if yyDebug then
yyStateStack (yyStackPtr) := yyStateStack (yyStackPtr - 1);
end if;
# endif
end loop;
else -- read
yyStackPtr := yyStackPtr + 1;
$@ yyAttributeStack (yyStackPtr).Scan := $.Attribute;
yyTerminal := yyGetToken;
# ifdef YYDEBUG
if yyDebug then
yyPrintState (yyStateStack (yyStackPtr - 1));
Text_Io.Put (yyTrace, "shift ");
Text_Io.Put (yyTrace, TokenName (yyPrevTerminal));
Text_Io.Put (yyTrace, ", lookahead: ");
Text_Io.Put (yyTrace, TokenName (yyTerminal));
yyNl;
yyPrevTerminal := yyTerminal;
end if;
# endif
yyIsRepairing := False;
end if;
end loop;
<<yyAbort>>
# ifdef YYDEBUG
if yyDebug then -- abort
yyPrintState (yyStateStack (yyStackPtr));
Text_Io.Put (yyTrace, "fail parse started at ");
Int_Io .Put (yyTrace, yyStartCount, 0);
yyNl;
end if;
# endif
yyErrorCount := yyErrorCount + 1;
return yyErrorCount;
<<yyAccept>>
# ifdef YYDEBUG
if yyDebug then -- accept
yyPrintState (yyStateStack (yyStackPtr));
Text_Io.Put (yyTrace, "accept parse started at ");
Int_Io .Put (yyTrace, yyStartCount, 0);
yyNl;
end if;
# endif
return yyErrorCount;
end yyParse;
# ifndef NO_RECOVER
procedure ErrorRecovery (
Terminal : in out Integer;
StackSize : Integer ;
StackPtr : Integer ) is
use Strings;
TokensSkipped : Boolean;
ContinueSet : Sets.tSet;
RestartSet : Sets.tSet;
# ifdef YYDEBUG
PrevTerminal : Integer;
# endif
TokenString : Strings.tString;
ContinueArray : String (1 .. 5000);
ContinueString : Strings.tString;
Length : Integer := 0;
Min, Max, NewLength : Integer;
begin
if yyControl.yyMessages then
-- 1. report the error
$@ Errors.ErrorMessage (Errors.SyntaxError, Errors.Error, $.Attribute.Position);
-- 2. report the offending token
Strings.To_tString (TokenName (Terminal), TokenString);
# ifdef SPELLING
$@ $.GetWord (ContinueString);
if not (TokenString = ContinueString) then
TokenString := TokenString & " " & ContinueString;
end if;
# endif
Errors.ErrorMessageI (Errors.TokenFound, Errors.Information,
$@ $.Attribute.Position, Errors.cString, TokenString'Address);
-- 3. report the set of expected terminal symbols
Sets.MakeSet (ContinueSet, yyLastTerminal);
ComputeContinuation (StackSize, StackPtr, ContinueSet, True);
Length := 0;
Sets.Minimum (ContinueSet, Min);
Sets.Maximum (ContinueSet, Max);
for Token in Min .. Max loop
if Sets.IsElement (Token, ContinueSet) then
NewLength := Length + TokenName (Token)'Last + 1;
if NewLength <= 5000 then
ContinueArray (Length + 1 .. NewLength) := TokenName (Token) & " ";
Length := NewLength;
end if;
end if;
end loop;
Strings.To_tString (ContinueArray (1 .. Length), ContinueString);
Errors.ErrorMessageI (Errors.ExpectedTokens, Errors.Information,
$@ $.Attribute.Position, Errors.cString, ContinueString'Address);
Sets.ReleaseSet (ContinueSet);
end if;
-- 4. compute the set of terminal symbols for restart of the parse
Sets.MakeSet (RestartSet, yyLastTerminal);
ComputeRestartPoints (StackSize, StackPtr, RestartSet);
-- 5. skip terminal symbols until a restart point is reached
TokensSkipped := False;
while not Sets.IsElement (Terminal, RestartSet) loop
# ifdef YYDEBUG
PrevTerminal := Terminal;
# endif
Terminal := yyGetToken;
TokensSkipped := True;
# ifdef YYDEBUG
if yyDebug then
yyPrintState (yyStateStack (StackPtr));
Text_Io.Put (yyTrace, "skip ");
Text_Io.Put (yyTrace, TokenName (PrevTerminal));
Text_Io.Put (yyTrace, ", lookahead: ");
Text_Io.Put (yyTrace, TokenName (Terminal));
yyNl;
end if;
# endif
end loop;
Sets.ReleaseSet (RestartSet);
-- 6. report the restart point
if TokensSkipped and yyControl.yyMessages then
$@ Errors.ErrorMessage (Errors.RestartPoint, Errors.Information, $.Attribute.Position);
end if;
end ErrorRecovery;
-- compute the set of terminal symbols that can be accepted (read)
-- in a given stack configuration (eventually after reduce actions)
procedure ComputeContinuation (
StackSize : Integer ;
StackPtr : Integer ;
ContinueSet : out Sets.tSet ;
reduce : Boolean ) is
begin
Sets.AssignEmpty (ContinueSet);
for Terminal in yyFirstTerminal .. yyLastTerminal loop
if IsContinuation (Terminal, StackSize, StackPtr, reduce) then
Sets.Include (ContinueSet, Terminal);
end if;
end loop;
end ComputeContinuation;
-- check whether a given terminal symbol can be accepted (read)
-- in a certain stack configuration (eventually after reduce actions)
function IsContinuation (
Terminal : Integer ;
pStackSize : Integer ;
pStackPtr : Integer ;
reduce : Boolean ) return Boolean is
State : Integer;
Nonterminal : Integer;
Stack : SStack_DA.FlexArray;
StackSize : Integer := pStackSize;
StackPtr : Integer := pStackPtr;
begin
SStack_DA.MakeArray (Stack, StackSize);
Stack (0 .. StackPtr) := yyStateStack (0 .. StackPtr);
State := Stack (StackPtr);
loop
Stack (StackPtr) := State;
State := Next (State, Terminal);
if State = yyNoState then
SStack_DA.ReleaseArray (Stack, StackSize);
return False;
end if;
loop -- reduce
if State > yyLastReduceState then -- dynamic ?
State := yyCondition (State);
end if;
if State <= yyLastStopState then -- read, read reduce, or accept ?
SStack_DA.ReleaseArray (Stack, StackSize);
return True;
elsif reduce then -- reduce
StackPtr := StackPtr - yyLength (State);
Nonterminal := yyLeftHandSide (State);
else
return False;
end if;
State := Next (Stack (StackPtr), Nonterminal);
StackPtr := StackPtr + 1;
if StackPtr >= StackSize then
SStack_DA.ExtendArray (Stack, StackSize);
end if;
if State < yyFirstFinalState then exit; end if;
end loop;
end loop;
end IsContinuation;
-- compute a set of terminal symbols that can be used to restart
-- parsing in a given stack configuration. we simulate parsing until
-- end of file using a suffix program synthesized by the function
-- Continuation. All symbols acceptable in the states reached during
-- the simulation can be used to restart parsing.
procedure ComputeRestartPoints (
pStackSize : Integer ;
pStackPtr : Integer ;
RestartSet : out Sets.tSet ) is
Stack : SStack_DA.FlexArray;
StackSize : Integer := pStackSize;
StackPtr : Integer := pStackPtr;
State : Integer;
Nonterminal : Integer;
ContinueSet : Sets.tSet;
begin
SStack_DA.MakeArray (Stack, StackSize);
Stack (0 .. StackPtr) := yyStateStack (0 .. StackPtr);
Sets.MakeSet (ContinueSet, yyLastTerminal);
Sets.AssignEmpty (RestartSet);
State := Stack (StackPtr);
loop
if StackPtr >= StackSize then
SStack_DA.ExtendArray (Stack, StackSize);
end if;
Stack (StackPtr) := State;
ComputeContinuation (StackSize, StackPtr, ContinueSet, False);
Sets.Union (RestartSet, ContinueSet);
State := Next (State, yyContinuation (State));
if State >= yyFirstFinalState then -- final state ?
if State <= yyLastReadReduceState then -- read reduce ?
StackPtr := StackPtr + 1;
State := yyFinalToProd (State);
end if;
loop -- reduce
if State > yyLastReduceState then -- dynamic ?
State := yyCondition (State);
end if;
if (yyFirstReduceState <= State) and
(State <= yyLastStopState) then -- accept
SStack_DA.ReleaseArray (Stack, StackSize);
Sets.ReleaseSet (ContinueSet);
return;
end if;
if State < yyFirstFinalState then -- read
StackPtr := StackPtr + 1;
exit;
else -- reduce
StackPtr := StackPtr - yyLength (State);
Nonterminal := yyLeftHandSide (State);
end if;
State := Next (Stack (StackPtr), Nonterminal);
StackPtr := StackPtr + 1;
if State < yyFirstFinalState then exit; end if;
end loop;
else -- read
StackPtr := StackPtr + 1;
end if;
end loop;
end ComputeRestartPoints;
# endif
-- access the parse table: Next : State x Symbol -> State
function Next (pState: Integer; Symbol: Integer) return Integer is
CombIndex : Integer;
State : Integer := pState;
begin
if Symbol <= yyLastTerminal then
loop
CombIndex := yyTBase (State) + Symbol;
if yyTComb (CombIndex).Check = State then return yyTComb (CombIndex).Next; end if;
# ifdef YYTDefault
State := yyTDefault (State);
if State = yyNoState then return yyNoState; end if;
# else
return yyNoState;
# endif
end loop;
else
# ifdef YYNDefault
loop
CombIndex := yyNBase (State) + Symbol;
if yyNComb (CombIndex).Check = State then return yyNComb (CombIndex).Next; end if;
State := yyNDefault (State);
end loop;
# else
return yyNComb (yyNBase (State) + Symbol);
# endif
end if;
end Next;
$@ procedure Begin@ is
begin
null;
$B -- BEGIN section is inserted here
$@ end Begin@;
$@ procedure Close@ is
begin
null;
$C -- CLOSE section is inserted here
$@ end Close@;
$@ end @;
|
with Cards, Ada.Numerics.Discrete_Random;
use Cards;
package Deck is
function Draw return Card;
private
type Index_Type is range 1 .. 52;
package Random_Index is new Ada.Numerics.Discrete_Random(Index_Type);
use Random_Index;
Index_Generator : Random_Index.Generator;
type Deck_Card is new Card with record
In_Deck : Boolean := True;
end record;
type Card_Array is array(Index_Type) of Deck_Card;
Backing : Card_Array := (
Deck_Card'(2, Heart, others => <>),
Deck_Card'(3, Heart, others => <>),
Deck_Card'(4, Heart, others => <>),
Deck_Card'(5, Heart, others => <>),
Deck_Card'(6, Heart, others => <>),
Deck_Card'(7, Heart, others => <>),
Deck_Card'(8, Heart, others => <>),
Deck_Card'(9, Heart, others => <>),
Deck_Card'(10, Heart, others => <>),
Deck_Card'(11, Heart, others => <>),
Deck_Card'(12, Heart, others => <>),
Deck_Card'(13, Heart, others => <>),
Deck_Card'(14, Heart, others => <>),
Deck_Card'(2, Spade, others => <>),
Deck_Card'(3, Spade, others => <>),
Deck_Card'(4, Spade, others => <>),
Deck_Card'(5, Spade, others => <>),
Deck_Card'(6, Spade, others => <>),
Deck_Card'(7, Spade, others => <>),
Deck_Card'(8, Spade, others => <>),
Deck_Card'(9, Spade, others => <>),
Deck_Card'(10, Spade, others => <>),
Deck_Card'(11, Spade, others => <>),
Deck_Card'(12, Spade, others => <>),
Deck_Card'(13, Spade, others => <>),
Deck_Card'(14, Spade, others => <>),
Deck_Card'(2, Diamond, others => <>),
Deck_Card'(3, Diamond, others => <>),
Deck_Card'(4, Diamond, others => <>),
Deck_Card'(5, Diamond, others => <>),
Deck_Card'(6, Diamond, others => <>),
Deck_Card'(7, Diamond, others => <>),
Deck_Card'(8, Diamond, others => <>),
Deck_Card'(9, Diamond, others => <>),
Deck_Card'(10, Diamond, others => <>),
Deck_Card'(11, Diamond, others => <>),
Deck_Card'(12, Diamond, others => <>),
Deck_Card'(13, Diamond, others => <>),
Deck_Card'(14, Diamond, others => <>),
Deck_Card'(2, Club, others => <>),
Deck_Card'(3, Club, others => <>),
Deck_Card'(4, Club, others => <>),
Deck_Card'(5, Club, others => <>),
Deck_Card'(6, Club, others => <>),
Deck_Card'(7, Club, others => <>),
Deck_Card'(8, Club, others => <>),
Deck_Card'(9, Club, others => <>),
Deck_Card'(10, Club, others => <>),
Deck_Card'(11, Club, others => <>),
Deck_Card'(12, Club, others => <>),
Deck_Card'(13, Club, others => <>),
Deck_Card'(14, Club, others => <>)
);
end Deck;
|
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure Test_Literals is
begin
Put (16#2D7#);
Put (10#727#);
Put (8#1_327#);
Put (2#10_1101_0111#);
end Test_Literals;
|
-- { dg-do compile }
package Volatile1 is
C : Character;
for C'Size use 32;
pragma Volatile (C);
type R1 is record
C: Character;
pragma Volatile (C);
end record;
for R1 use record
C at 0 range 0 .. 31;
end record;
type R2 is record
C: Character;
pragma Volatile (C);
end record;
for R2 use record
C at 0 range 0 .. 10; -- { dg-error "size of volatile field" }
end record;
end Volatile1;
|
pragma License (Unrestricted);
-- overridable runtime unit specialized for POSIX (Darwin, FreeBSD, or Linux)
private with C.signal;
package System.Unwind.Mapping is
pragma Preelaborate;
-- signal alt stack
type Signal_Stack_Type is private;
-- register signal handler (init.c/seh_init.c)
procedure Install_Exception_Handler (SEH : Address)
with Export, -- for weak linking
Convention => Ada,
External_Name => "__drake_install_exception_handler";
pragma No_Inline (Install_Exception_Handler);
procedure Install_Task_Exception_Handler (
SEH : Address;
Signal_Stack : not null access Signal_Stack_Type)
with Export,
Convention => Ada,
External_Name => "__drake_install_task_exception_handler";
pragma No_Inline (Install_Task_Exception_Handler);
procedure Reinstall_Exception_Handler is null
with Export,
Convention => Ada,
External_Name => "__drake_reinstall_exception_handler";
private
use type C.size_t;
Signal_Stack_Storage_Count : constant :=
C.size_t'Max (
C.signal.MINSIGSTKSZ,
(Standard'Address_Size / Standard'Storage_Unit) * 1024);
-- this value is baseless and from experience
type Signal_Stack_Type is
array (1 .. Signal_Stack_Storage_Count) of aliased C.char;
pragma Suppress_Initialization (Signal_Stack_Type);
for Signal_Stack_Type'Size use
Signal_Stack_Storage_Count * Standard'Storage_Unit;
end System.Unwind.Mapping;
|
------------------------------------------------------------------------------
-- A d a r u n - t i m e s p e c i f i c a t i o n --
-- ASIS implementation for Gela project, a portable Ada compiler --
-- http://gela.ada-ru.org --
-- - - - - - - - - - - - - - - - --
-- Read copyright and license at the end of ada.ads file --
------------------------------------------------------------------------------
-- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $
generic
type Key_Type is private;
type Element_Type is private;
with function "<" (Left : in Key_Type;
Right : in Key_Type)
return Boolean is <>;
with function "=" (Left : in Element_Type;
Right : in Element_Type)
return Boolean is <>;
package Ada.Containers.Ordered_Maps is
pragma Preelaborate (Ordered_Maps);
function Equivalent_Keys (Left : in Key_Type;
Right : in Key_Type)
return Boolean;
type Map is tagged private;
pragma Preelaborable_Initialization (Map);
type Cursor is private;
pragma Preelaborable_Initialization (Cursor);
Empty_Map : constant Map;
No_Element : constant Cursor;
function "=" (Left : in Map;
Right : in Map)
return Boolean;
function Length (Container : in Map) return Count_Type;
function Is_Empty (Container : in Map) return Boolean;
procedure Clear (Container : in out Map);
function Key (Position : in Cursor) return Key_Type;
function Element (Position : in Cursor) return Element_Type;
procedure Replace_Element (Container : in out Map;
Position : in Cursor;
New_Item : in Element_Type);
procedure Query_Element
(Position : in Cursor;
Process : not null access procedure (Key : in Key_Type;
Element : in Element_Type));
procedure Update_Element
(Container : in out Map;
Position : in Cursor;
Process : not null access procedure (Key : in Key_Type;
Element : in out Element_Type));
procedure Move (Target : in out Map;
Source : in out Map);
procedure Insert (Container : in out Map;
Key : in Key_Type;
New_Item : in Element_Type;
Position : out Cursor;
Inserted : out Boolean);
procedure Insert (Container : in out Map;
Key : in Key_Type;
Position : out Cursor;
Inserted : out Boolean);
procedure Insert (Container : in out Map;
Key : in Key_Type;
New_Item : in Element_Type);
procedure Include (Container : in out Map;
Key : in Key_Type;
New_Item : in Element_Type);
procedure Replace (Container : in out Map;
Key : in Key_Type;
New_Item : in Element_Type);
procedure Exclude (Container : in out Map;
Key : in Key_Type);
procedure Delete (Container : in out Map;
Key : in Key_Type);
procedure Delete (Container : in out Map;
Position : in out Cursor);
procedure Delete_First (Container : in out Map);
procedure Delete_Last (Container : in out Map);
function First (Container : in Map) return Cursor;
function First_Element (Container : in Map) return Element_Type;
function First_Key (Container : in Map) return Key_Type;
function Last (Container : in Map) return Cursor;
function Last_Element (Container : in Map) return Element_Type;
function Last_Key (Container : in Map) return Key_Type;
function Next (Position : in Cursor) return Cursor;
procedure Next (Position : in out Cursor);
function Previous (Position : in Cursor) return Cursor;
procedure Previous (Position : in out Cursor);
function Find (Container : in Map;
Key : in Key_Type)
return Cursor;
function Element (Container : in Map;
Key : in Key_Type)
return Element_Type;
function Floor (Container : in Map;
Key : in Key_Type)
return Cursor;
function Ceiling (Container : in Map;
Key : in Key_Type)
return Cursor;
function Contains (Container : in Map;
Key : in Key_Type)
return Boolean;
function Has_Element (Position : in Cursor) return Boolean;
function "<" (Left : in Cursor;
Right : in Cursor)
return Boolean;
function ">" (Left : in Cursor;
Right : in Cursor)
return Boolean;
function "<" (Left : in Cursor;
Right : in Key_Type)
return Boolean;
function ">" (Left : in Cursor;
Right : in Key_Type)
return Boolean;
function "<" (Left : in Key_Type;
Right : in Cursor)
return Boolean;
function ">" (Left : in Key_Type;
Right : in Cursor)
return Boolean;
procedure Iterate
(Container : in Map;
Process : not null access procedure (Position : in Cursor));
procedure Reverse_Iterate
(Container : in Map;
Process : not null access procedure (Position : in Cursor));
private
type Map is tagged null record;
Empty_Map : constant Map := (null record);
type Cursor is null record;
No_Element : constant Cursor := (null record);
end Ada.Containers.Ordered_Maps;
|
-- { dg-do compile }
pragma Implicit_Packing;
package Rep_Clause5 is
type Modes_Type is (Mode_0, Mode_1);
for Modes_Type'size use 8;
type Mode_Record_Type is
record
Mode_1 : aliased Modes_Type;
Mode_2 : aliased Modes_Type;
Mode_3 : aliased Modes_Type;
Mode_4 : aliased Modes_Type;
Time : aliased Float;
end record;
for Mode_Record_Type use
record
Mode_1 at 00 range 00 .. 07;
Mode_2 at 01 range 00 .. 07;
Mode_3 at 02 range 00 .. 07;
Mode_4 at 03 range 00 .. 07;
Time at 04 range 00 .. 31;
end record;
for Mode_Record_Type'Size use 64;
for Mode_Record_Type'Alignment use 4;
type Array_1_Type is array (0 .. 31) of Boolean;
for Array_1_Type'size use 32;
type Array_2_Type is array (0 .. 127) of Boolean;
for Array_2_Type'size use 128;
type Array_3_Type is array (0 .. 31) of Boolean;
for Array_3_Type'size use 32;
type Unsigned_Long is mod 2 ** 32;
type Array_4_Type is array (1 .. 6) of unsigned_Long;
type Primary_Data_Type is
record
Array_1 : aliased Array_1_Type;
Mode_Record : aliased Mode_Record_Type;
Array_2 : aliased Array_2_Type;
Array_3 : Array_3_Type;
Array_4 : Array_4_Type;
end record;
for Primary_Data_Type use
record
Array_1 at 0 range 0 .. 31; -- WORD 1
Mode_Record at 4 range 0 .. 63; -- WORD 2 .. 3
Array_2 at 12 range 0 .. 127; -- WORD 4 .. 7
Array_3 at 28 range 0 .. 31; -- WORD 8
Array_4 at 32 range 0 .. 191; -- WORD 9 .. 14
end record;
for Primary_Data_Type'Size use 448;
type Results_Record_Type is
record
Thirty_Two_Bit_Pad : Float;
Result : Primary_Data_Type;
end record;
for Results_Record_Type use
record
Thirty_Two_Bit_Pad at 0 range 0 .. 31;
Result at 4 range 0 .. 447;
end record;
end Rep_Clause5;
|
-- C64105D.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT CONSTRAINT_ERROR IS NOT RAISED FOR ACCESS PARAMETERS
-- IN THE FOLLOWING CIRCUMSTANCES:
-- (1)
-- (2)
-- (3) BEFORE OR AFTER THE CALL, WHEN AN UNCONSTRAINED ACTUAL
-- OUT ACCESS PARAMETER DESIGNATES AN OBJECT (PRIOR TO THE
-- CALL) WITH CONSTRAINTS DIFFERENT FROM THE FORMAL
-- PARAMETER.
-- SUBTESTS ARE:
-- (G) CASE 3, STATIC LIMITED PRIVATE DISCRIMINANT.
-- (H) CASE 3, DYNAMIC ONE DIMENSIONAL BOUNDS.
-- JRK 3/20/81
-- SPS 10/26/82
WITH REPORT;
PROCEDURE C64105D IS
USE REPORT;
BEGIN
TEST ("C64105D", "CHECK THAT CONSTRAINT_ERROR IS NOT RAISED " &
"BEFORE AND AFTER THE CALL, WHEN AN UNCONSTRAINED ACTUAL " &
"OUT ACCESS PARAMETER DESIGNATES AN OBJECT (PRIOR TO THE " &
"CALL) WITH CONSTRAINTS DIFFERENT FROM THE FORMAL " &
"PARAMETER" );
--------------------------------------------------
DECLARE -- (G)
PACKAGE PKG IS
SUBTYPE INT IS INTEGER RANGE 0..5;
TYPE T (I : INT := 0) IS LIMITED PRIVATE;
PRIVATE
TYPE ARR IS ARRAY (INTEGER RANGE <>) OF INTEGER;
TYPE T (I : INT := 0) IS
RECORD
J : INTEGER;
A : ARR (1..I);
END RECORD;
END PKG;
USE PKG;
TYPE A IS ACCESS T;
SUBTYPE SA IS A(3);
V : A := NEW T (2);
CALLED : BOOLEAN := FALSE;
PROCEDURE P (X : OUT SA) IS
BEGIN
CALLED := TRUE;
X := NEW T (3);
EXCEPTION
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED IN PROCEDURE - (G)");
END P;
BEGIN -- (G)
P (V);
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF NOT CALLED THEN
FAILED ("EXCEPTION RAISED BEFORE CALL - (G)");
ELSE
FAILED ("EXCEPTION RAISED ON RETURN - (G)");
END IF;
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED - (G)");
END; -- (G)
--------------------------------------------------
DECLARE -- (H)
TYPE A IS ACCESS STRING;
SUBTYPE SA IS A (1..2);
V : A := NEW STRING (IDENT_INT(5) .. IDENT_INT(7));
CALLED : BOOLEAN := FALSE;
PROCEDURE P (X : OUT SA) IS
BEGIN
CALLED := TRUE;
X := NEW STRING (IDENT_INT(1) .. IDENT_INT(2));
EXCEPTION
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED IN PROCEDURE - (H)");
END P;
BEGIN -- (H)
P (V);
EXCEPTION
WHEN CONSTRAINT_ERROR =>
IF NOT CALLED THEN
FAILED ("EXCEPTION RAISED BEFORE CALL - (H)");
ELSE
FAILED ("EXCEPTION RAISED ON RETURN - (H)");
END IF;
WHEN OTHERS =>
FAILED ("EXCEPTION RAISED - (H)");
END; -- (H)
--------------------------------------------------
RESULT;
END C64105D;
|
separate (Exprs)
procedure Store (The_Expr : Expr'Class;
Result : out Expr_Handle;
Success : out Boolean) is
use Ada.Containers;
use Storage;
begin
if Length (Container) >= Container.Capacity then
Success := False;
Result := 1;
return;
end if;
Append (Container, The_Expr);
Result := Last_Index (Container);
Success := Is_Valid (Result);
end Store;
|
--
-- Copyright (C) 2013 Reto Buerki <reet@codelabs.ch>
-- Copyright (C) 2013 Adrian-Ken Rueegsegger <ken@codelabs.ch>
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions
-- are met:
-- 1. Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- 3. Neither the name of the University 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 REGENTS 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 REGENTS 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 Tkmrpc.Types;
package Tkmrpc.Mock
is
Ref_Nonce : constant Types.Nonce_Type
:= (Size => 156,
Data => (others => Character'Pos ('f')));
-- Reference nonce returned by Nc_Create function.
Last_Nonce_Id : Types.Nc_Id_Type := Types.Nc_Id_Type'Last;
Last_Nonce_Length : Types.Nonce_Length_Type := 16;
-- Calls to Nc_Create will set these vars to the last requested nonce Id
-- and length.
Ref_Dh_Pubvalue : constant Types.Dh_Pubvalue_Type
:= (Size => 8,
Data => (others => 16#3b#));
-- Reference Diffie-Hellman public value checked in Dh_Generate_Key
-- procedure.
end Tkmrpc.Mock;
|
with Ada.Exception_Identification.From_Here;
with System.Native_Calendar;
with System.Native_Time;
package body Ada.Calendar is
use Exception_Identification.From_Here;
use type System.Native_Time.Nanosecond_Number;
function add_overflow (
a, b : System.Native_Time.Nanosecond_Number;
res : not null access System.Native_Time.Nanosecond_Number)
return Boolean
with Import,
Convention => Intrinsic, External_Name => "__builtin_saddll_overflow";
function sub_overflow (
a, b : System.Native_Time.Nanosecond_Number;
res : not null access System.Native_Time.Nanosecond_Number)
return Boolean
with Import,
Convention => Intrinsic, External_Name => "__builtin_ssubll_overflow";
-- for Year, Month, Day
type Packed_Split_Time is mod 2 ** 32;
-- for Packed_Split_Time use record
-- Day at 0 range 0 .. 7; -- 2 ** 5 = 32 > 31
-- Month at 0 range 8 .. 15; -- 2 ** 4 = 16 > 12
-- Year at 0 range 16 .. 31; -- 2 ** 9 = 512 > 2399 - 1901 + 1 = 499
-- end record;
pragma Provide_Shift_Operators (Packed_Split_Time);
function Packed_Split (Date : Time) return Packed_Split_Time;
-- The callings of this function will be unified since pure attribute
-- when Year, Month, and Day are inlined.
pragma Pure_Function (Packed_Split);
pragma Machine_Attribute (Packed_Split, "const");
function Packed_Split (Date : Time) return Packed_Split_Time is
Year : Year_Number;
Month : Month_Number;
Day : Day_Number;
Hour : System.Native_Calendar.Hour_Number;
Minute : System.Native_Calendar.Minute_Number;
Second : System.Native_Calendar.Second_Number;
Sub_Second : System.Native_Calendar.Second_Duration;
Day_of_Week : System.Native_Calendar.Day_Name;
Leap_Second : Boolean;
Error : Boolean;
begin
System.Native_Calendar.Split (
Duration (Date),
Year => Year,
Month => Month,
Day => Day,
Hour => Hour,
Minute => Minute,
Second => Second,
Sub_Second => Sub_Second,
Leap_Second => Leap_Second,
Day_of_Week => Day_of_Week,
Time_Zone => 0, -- GMT
Error => Error);
if Error then
Raise_Exception (Time_Error'Identity);
end if;
return Packed_Split_Time (Day)
or Shift_Left (Packed_Split_Time (Month), 8)
or Shift_Left (Packed_Split_Time (Year), 16);
end Packed_Split;
-- implementation
function Clock return Time is
begin
return Time (
System.Native_Calendar.To_Time (System.Native_Calendar.Clock));
end Clock;
function Year (Date : Time) return Year_Number is
pragma Suppress (Range_Check);
begin
return Year_Number (Shift_Right (Packed_Split (Date), 16));
end Year;
function Month (Date : Time) return Month_Number is
pragma Suppress (Range_Check);
begin
return Month_Number (Shift_Right (Packed_Split (Date), 8) and 16#ff#);
end Month;
function Day (Date : Time) return Day_Number is
pragma Suppress (Range_Check);
begin
return Day_Number (Packed_Split (Date) and 16#ff#);
end Day;
function Seconds (Date : Time) return Day_Duration is
Year : Year_Number;
Month : Month_Number;
Day : Day_Number;
Seconds : Day_Duration;
begin
Split (Date,
Year => Year, Month => Month, Day => Day, Seconds => Seconds);
return Seconds;
end Seconds;
procedure Split (
Date : Time;
Year : out Year_Number;
Month : out Month_Number;
Day : out Day_Number;
Seconds : out Day_Duration)
is
Leap_Second : Boolean;
Error : Boolean;
begin
System.Native_Calendar.Split (
Duration (Date),
Year => Year,
Month => Month,
Day => Day,
Seconds => Seconds,
Leap_Second => Leap_Second,
Time_Zone => 0, -- GMT
Error => Error);
if Error then
Raise_Exception (Time_Error'Identity);
end if;
end Split;
function Time_Of (
Year : Year_Number;
Month : Month_Number;
Day : Day_Number;
Seconds : Day_Duration := 0.0)
return Time
is
Result : Duration;
Error : Boolean;
begin
System.Native_Calendar.Time_Of (
Year => Year,
Month => Month,
Day => Day,
Seconds => Seconds,
Leap_Second => False,
Time_Zone => 0,
Result => Result,
Error => Error);
if Error then
Raise_Exception (Time_Error'Identity);
end if;
return Time (Result);
end Time_Of;
function "+" (Left : Time; Right : Duration) return Time is
begin
if not Standard'Fast_Math and then Overflow_Check'Enabled then
declare
Result : aliased System.Native_Time.Nanosecond_Number;
begin
if add_overflow (
System.Native_Time.Nanosecond_Number'Integer_Value (Left),
System.Native_Time.Nanosecond_Number'Integer_Value (Right),
Result'Access)
then
raise Time_Error;
end if;
return Time'Fixed_Value (Result);
end;
else
return Time (Duration (Left) + Right);
end if;
end "+";
function "+" (Left : Duration; Right : Time) return Time is
begin
if not Standard'Fast_Math and then Overflow_Check'Enabled then
declare
Result : aliased System.Native_Time.Nanosecond_Number;
begin
if add_overflow (
System.Native_Time.Nanosecond_Number'Integer_Value (Left),
System.Native_Time.Nanosecond_Number'Integer_Value (Right),
Result'Access)
then
raise Time_Error;
end if;
return Time'Fixed_Value (Result);
end;
else
return Time (Left + Duration (Right));
end if;
end "+";
function "-" (Left : Time; Right : Duration) return Time is
begin
if not Standard'Fast_Math and then Overflow_Check'Enabled then
declare
Result : aliased System.Native_Time.Nanosecond_Number;
begin
if sub_overflow (
System.Native_Time.Nanosecond_Number'Integer_Value (Left),
System.Native_Time.Nanosecond_Number'Integer_Value (Right),
Result'Access)
then
raise Time_Error;
end if;
return Time'Fixed_Value (Result);
end;
else
return Time (Duration (Left) - Right);
end if;
end "-";
function "-" (Left : Time; Right : Time) return Duration is
begin
if not Standard'Fast_Math and then Overflow_Check'Enabled then
declare
Result : aliased System.Native_Time.Nanosecond_Number;
begin
if sub_overflow (
System.Native_Time.Nanosecond_Number'Integer_Value (Left),
System.Native_Time.Nanosecond_Number'Integer_Value (Right),
Result'Access)
then
raise Time_Error;
end if;
return Duration'Fixed_Value (Result);
end;
else
return Duration (Left) - Duration (Right);
end if;
end "-";
end Ada.Calendar;
|
with Ada.Integer_Text_IO;
with Ada.Text_IO;
with PrimeUtilities;
package body Problem_21 is
package IO renames Ada.Text_IO;
package I_IO renames Ada.Integer_Text_IO;
procedure Solve is
subtype subset is Integer range 1 .. 10_000;
package Subset_Primes is new PrimeUtilities(Num => subset);
sieve : constant Subset_Primes.sieve := Subset_Primes.Generate_Sieve(subset'Last);
d : Array (2 .. subset'Last) of Integer;
sum : Integer := 0;
procedure sum_divisors(num : in subset; sum : out Natural) is
divisors : constant Subset_Primes.Proper_Divisors := Subset_Primes.Generate_Proper_Divisors(num, sieve);
begin
sum := 0;
for index in divisors'Range loop
sum := sum + divisors(index);
end loop;
end sum_divisors;
begin
for n in d'Range loop
sum_divisors(n, d(n));
end loop;
for n in d'Range loop
if (d(n) <= d'Last and d(n) >= d'First) and then d(d(n)) = n then
sum := sum + n;
end if;
end loop;
I_IO.Put(sum);
IO.New_Line;
end Solve;
end Problem_21;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.