CombinedText stringlengths 4 3.42M |
|---|
-- Copyright 2013-2015 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package body Pck is
procedure Set_Float (F : Float) is
begin
Global_Float := F;
end Set_Float;
procedure Set_Double (Dummy : Integer; D : Long_Float) is
begin
Global_Double := D;
end Set_Double;
procedure Set_Long_Double (Dummy : Integer;
DS : Small_Struct;
LD : Long_Long_Float) is
begin
Global_Long_Double := LD;
end Set_Long_Double;
end Pck;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . E X C E P T I O N S . I S _ N U L L _ O C C U R R E N C E --
-- --
-- B o d y --
-- --
-- Copyright (C) 2000-2009, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
---------------------------------------
-- Ada.Exceptions.Is_Null_Occurrence --
---------------------------------------
function Ada.Exceptions.Is_Null_Occurrence
(X : Exception_Occurrence) return Boolean
is
begin
-- The null exception is uniquely identified by the fact that the Id value
-- is null. No other exception occurrence can have a null Id.
if X.Id = Null_Id then
return True;
else
return False;
end if;
end Ada.Exceptions.Is_Null_Occurrence;
|
-- This spec has been automatically generated from STM32F40x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
with HAL;
with System;
package STM32_SVD.I2C is
pragma Preelaborate;
---------------
-- Registers --
---------------
------------------
-- CR1_Register --
------------------
-- Control register 1
type CR1_Register is record
-- Peripheral enable
PE : Boolean := False;
-- SMBus mode
SMBUS : Boolean := False;
-- unspecified
Reserved_2_2 : HAL.Bit := 16#0#;
-- SMBus type
SMBTYPE : Boolean := False;
-- ARP enable
ENARP : Boolean := False;
-- PEC enable
ENPEC : Boolean := False;
-- General call enable
ENGC : Boolean := False;
-- Clock stretching disable (Slave mode)
NOSTRETCH : Boolean := False;
-- Start generation
START : Boolean := False;
-- Stop generation
STOP : Boolean := False;
-- Acknowledge enable
ACK : Boolean := False;
-- Acknowledge/PEC Position (for data reception)
POS : Boolean := False;
-- Packet error checking
PEC : Boolean := False;
-- SMBus alert
ALERT : Boolean := False;
-- unspecified
Reserved_14_14 : HAL.Bit := 16#0#;
-- Software reset
SWRST : Boolean := False;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR1_Register use record
PE at 0 range 0 .. 0;
SMBUS at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
SMBTYPE at 0 range 3 .. 3;
ENARP at 0 range 4 .. 4;
ENPEC at 0 range 5 .. 5;
ENGC at 0 range 6 .. 6;
NOSTRETCH at 0 range 7 .. 7;
START at 0 range 8 .. 8;
STOP at 0 range 9 .. 9;
ACK at 0 range 10 .. 10;
POS at 0 range 11 .. 11;
PEC at 0 range 12 .. 12;
ALERT at 0 range 13 .. 13;
Reserved_14_14 at 0 range 14 .. 14;
SWRST at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
------------------
-- CR2_Register --
------------------
subtype CR2_FREQ_Field is HAL.UInt6;
-- Control register 2
type CR2_Register is record
-- Peripheral clock frequency
FREQ : CR2_FREQ_Field := 16#0#;
-- unspecified
Reserved_6_7 : HAL.UInt2 := 16#0#;
-- Error interrupt enable
ITERREN : Boolean := False;
-- Event interrupt enable
ITEVTEN : Boolean := False;
-- Buffer interrupt enable
ITBUFEN : Boolean := False;
-- DMA requests enable
DMAEN : Boolean := False;
-- DMA last transfer
LAST : Boolean := False;
-- unspecified
Reserved_13_31 : HAL.UInt19 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR2_Register use record
FREQ at 0 range 0 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
ITERREN at 0 range 8 .. 8;
ITEVTEN at 0 range 9 .. 9;
ITBUFEN at 0 range 10 .. 10;
DMAEN at 0 range 11 .. 11;
LAST at 0 range 12 .. 12;
Reserved_13_31 at 0 range 13 .. 31;
end record;
-------------------
-- OAR1_Register --
-------------------
subtype OAR1_ADD7_Field is HAL.UInt7;
subtype OAR1_ADD10_Field is HAL.UInt2;
-- Own address register 1
type OAR1_Register is record
-- Interface address
ADD0 : Boolean := False;
-- Interface address
ADD7 : OAR1_ADD7_Field := 16#0#;
-- Interface address
ADD10 : OAR1_ADD10_Field := 16#0#;
-- unspecified
Reserved_10_14 : HAL.UInt5 := 16#0#;
-- Addressing mode (slave mode)
ADDMODE : Boolean := False;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for OAR1_Register use record
ADD0 at 0 range 0 .. 0;
ADD7 at 0 range 1 .. 7;
ADD10 at 0 range 8 .. 9;
Reserved_10_14 at 0 range 10 .. 14;
ADDMODE at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-------------------
-- OAR2_Register --
-------------------
subtype OAR2_ADD2_Field is HAL.UInt7;
-- Own address register 2
type OAR2_Register is record
-- Dual addressing mode enable
ENDUAL : Boolean := False;
-- Interface address
ADD2 : OAR2_ADD2_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for OAR2_Register use record
ENDUAL at 0 range 0 .. 0;
ADD2 at 0 range 1 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-----------------
-- DR_Register --
-----------------
subtype DR_DR_Field is HAL.Byte;
-- Data register
type DR_Register is record
-- 8-bit data register
DR : DR_DR_Field := 16#0#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR_Register use record
DR at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
------------------
-- SR1_Register --
------------------
-- Status register 1
type SR1_Register is record
-- Read-only. Start bit (Master mode)
SB : Boolean := False;
-- Read-only. Address sent (master mode)/matched (slave mode)
ADDR : Boolean := False;
-- Read-only. Byte transfer finished
BTF : Boolean := False;
-- Read-only. 10-bit header sent (Master mode)
ADD10 : Boolean := False;
-- Read-only. Stop detection (slave mode)
STOPF : Boolean := False;
-- unspecified
Reserved_5_5 : HAL.Bit := 16#0#;
-- Read-only. Data register not empty (receivers)
RxNE : Boolean := False;
-- Read-only. Data register empty (transmitters)
TxE : Boolean := False;
-- Bus error
BERR : Boolean := False;
-- Arbitration lost (master mode)
ARLO : Boolean := False;
-- Acknowledge failure
AF : Boolean := False;
-- Overrun/Underrun
OVR : Boolean := False;
-- PEC Error in reception
PECERR : Boolean := False;
-- unspecified
Reserved_13_13 : HAL.Bit := 16#0#;
-- Timeout or Tlow error
TIMEOUT : Boolean := False;
-- SMBus alert
SMBALERT : Boolean := False;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SR1_Register use record
SB at 0 range 0 .. 0;
ADDR at 0 range 1 .. 1;
BTF at 0 range 2 .. 2;
ADD10 at 0 range 3 .. 3;
STOPF at 0 range 4 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
RxNE at 0 range 6 .. 6;
TxE at 0 range 7 .. 7;
BERR at 0 range 8 .. 8;
ARLO at 0 range 9 .. 9;
AF at 0 range 10 .. 10;
OVR at 0 range 11 .. 11;
PECERR at 0 range 12 .. 12;
Reserved_13_13 at 0 range 13 .. 13;
TIMEOUT at 0 range 14 .. 14;
SMBALERT at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
------------------
-- SR2_Register --
------------------
subtype SR2_PEC_Field is HAL.Byte;
-- Status register 2
type SR2_Register is record
-- Read-only. Master/slave
MSL : Boolean;
-- Read-only. Bus busy
BUSY : Boolean;
-- Read-only. Transmitter/receiver
TRA : Boolean;
-- unspecified
Reserved_3_3 : HAL.Bit;
-- Read-only. General call address (Slave mode)
GENCALL : Boolean;
-- Read-only. SMBus device default address (Slave mode)
SMBDEFAULT : Boolean;
-- Read-only. SMBus host header (Slave mode)
SMBHOST : Boolean;
-- Read-only. Dual flag (Slave mode)
DUALF : Boolean;
-- Read-only. acket error checking register
PEC : SR2_PEC_Field;
-- unspecified
Reserved_16_31 : HAL.Short;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SR2_Register use record
MSL at 0 range 0 .. 0;
BUSY at 0 range 1 .. 1;
TRA at 0 range 2 .. 2;
Reserved_3_3 at 0 range 3 .. 3;
GENCALL at 0 range 4 .. 4;
SMBDEFAULT at 0 range 5 .. 5;
SMBHOST at 0 range 6 .. 6;
DUALF at 0 range 7 .. 7;
PEC at 0 range 8 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
------------------
-- CCR_Register --
------------------
subtype CCR_CCR_Field is HAL.UInt12;
-- Clock control register
type CCR_Register is record
-- Clock control register in Fast/Standard mode (Master mode)
CCR : CCR_CCR_Field := 16#0#;
-- unspecified
Reserved_12_13 : HAL.UInt2 := 16#0#;
-- Fast mode duty cycle
DUTY : Boolean := False;
-- I2C master mode selection
F_S : Boolean := False;
-- unspecified
Reserved_16_31 : HAL.Short := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CCR_Register use record
CCR at 0 range 0 .. 11;
Reserved_12_13 at 0 range 12 .. 13;
DUTY at 0 range 14 .. 14;
F_S at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
--------------------
-- TRISE_Register --
--------------------
subtype TRISE_TRISE_Field is HAL.UInt6;
-- TRISE register
type TRISE_Register is record
-- Maximum rise time in Fast/Standard mode (Master mode)
TRISE : TRISE_TRISE_Field := 16#2#;
-- unspecified
Reserved_6_31 : HAL.UInt26 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for TRISE_Register use record
TRISE at 0 range 0 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Inter-integrated circuit
type I2C_Peripheral is record
-- Control register 1
CR1 : CR1_Register;
-- Control register 2
CR2 : CR2_Register;
-- Own address register 1
OAR1 : OAR1_Register;
-- Own address register 2
OAR2 : OAR2_Register;
-- Data register
DR : DR_Register;
-- Status register 1
SR1 : SR1_Register;
-- Status register 2
SR2 : SR2_Register;
-- Clock control register
CCR : CCR_Register;
-- TRISE register
TRISE : TRISE_Register;
end record
with Volatile;
for I2C_Peripheral use record
CR1 at 0 range 0 .. 31;
CR2 at 4 range 0 .. 31;
OAR1 at 8 range 0 .. 31;
OAR2 at 12 range 0 .. 31;
DR at 16 range 0 .. 31;
SR1 at 20 range 0 .. 31;
SR2 at 24 range 0 .. 31;
CCR at 28 range 0 .. 31;
TRISE at 32 range 0 .. 31;
end record;
-- Inter-integrated circuit
I2C1_Periph : aliased I2C_Peripheral
with Import, Address => I2C1_Base;
-- Inter-integrated circuit
I2C2_Periph : aliased I2C_Peripheral
with Import, Address => I2C2_Base;
-- Inter-integrated circuit
I2C3_Periph : aliased I2C_Peripheral
with Import, Address => I2C3_Base;
end STM32_SVD.I2C;
|
-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
limited with Program.Scanners;
with Program.Scanner_Destinations;
with Program.Scanner_States;
package Program.Scanned_Rule_Handlers is
pragma Pure;
type Handler is abstract tagged limited null record;
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) is abstract;
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) is abstract;
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) is abstract;
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) is abstract;
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) is abstract;
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) is abstract;
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) is abstract;
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) is abstract;
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) is abstract;
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) is abstract;
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) is abstract;
type Handler_Access is access all Handler'Class with Storage_Size => 0;
end Program.Scanned_Rule_Handlers;
|
-------------------------------------------------------------------------------
-- Copyright (c) 2019, Daniel King
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
-- * Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * The name of the copyright holder may not be used to endorse or promote
-- Products derived from this software without specific prior written
-- permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO;
with Ada.Unchecked_Deallocation;
with Interfaces; use Interfaces;
with Keccak.Types;
with Test_Vectors; use Test_Vectors;
package body CSHAKE_Runner
is
procedure Free is new Ada.Unchecked_Deallocation
(Object => Keccak.Types.Byte_Array,
Name => Byte_Array_Access);
procedure Run_Tests (File_Name : in String;
Num_Passed : out Natural;
Num_Failed : out Natural)
is
use type Keccak.Types.Byte_Array;
package Integer_IO is new Ada.Text_IO.Integer_IO(Integer);
N_Key : constant Unbounded_String := To_Unbounded_String("N");
S_Key : constant Unbounded_String := To_Unbounded_String("S");
InLen_Key : constant Unbounded_String := To_Unbounded_String("InLen");
In_Key : constant Unbounded_String := To_Unbounded_String("In");
OutLen_Key : constant Unbounded_String := To_Unbounded_String("OutLen");
Out_Key : constant Unbounded_String := To_Unbounded_String("Out");
Schema : Test_Vectors.Schema_Maps.Map;
Tests : Test_Vectors.Lists.List;
Ctx : CSHAKE.Context;
Output : Byte_Array_Access;
OutLen : Natural;
begin
Num_Passed := 0;
Num_Failed := 0;
-- Setup schema
Schema.Insert (Key => N_Key,
New_Item => Schema_Entry'(VType => String_Type,
Required => True,
Is_List => False));
Schema.Insert (Key => S_Key,
New_Item => Schema_Entry'(VType => String_Type,
Required => True,
Is_List => False));
Schema.Insert (Key => InLen_Key,
New_Item => Schema_Entry'(VType => Integer_Type,
Required => True,
Is_List => False));
Schema.Insert (Key => In_Key,
New_Item => Schema_Entry'(VType => Hex_Array_Type,
Required => True,
Is_List => False));
Schema.Insert (Key => OutLen_Key,
New_Item => Schema_Entry'(VType => Integer_Type,
Required => True,
Is_List => False));
Schema.Insert (Key => Out_Key,
New_Item => Schema_Entry'(VType => Hex_Array_Type,
Required => True,
Is_List => False));
-- Load the test file using the file name given on the command line
Ada.Text_IO.Put_Line("Loading file: " & File_Name);
Test_Vectors.Load (File_Name => File_Name,
Schema => Schema,
Vectors_List => Tests);
Ada.Text_IO.Put ("Running ");
Integer_IO.Put (Integer (Tests.Length), Width => 0);
Ada.Text_IO.Put_Line (" tests ...");
-- Run each test.
for C of Tests loop
CSHAKE.Init (Ctx => Ctx,
Customization => To_String (C.Element (S_Key).First_Element.Str),
Function_Name => To_String (C.Element (N_Key).First_Element.Str));
CSHAKE.Update(Ctx => Ctx,
Message => C.Element (In_Key).First_Element.Hex.all,
Bit_Length => C.Element (InLen_Key).First_Element.Int);
Output := new Keccak.Types.Byte_Array (C.Element (Out_Key).First_Element.Hex.all'Range);
CSHAKE.Extract (Ctx, Output.all);
-- Mask any unused bits from the output.
OutLen := C.Element (OutLen_Key).First_Element.Int;
if OutLen mod 8 /= 0 then
Output.all(Output.all'Last) := Output.all(Output.all'Last) and Keccak.Types.Byte((2**(OutLen mod 8)) - 1);
end if;
-- Check output
if Output.all = C.Element(Out_Key).First_Element.Hex.all then
Num_Passed := Num_Passed + 1;
else
Num_Failed := Num_Failed + 1;
-- Display a message on failure to help with debugging.
Ada.Text_IO.Put("FAILURE (Input bit-len: ");
Integer_IO.Put(C.Element (InLen_Key).First_Element.Int, Width => 0);
Ada.Text_IO.Put_Line(")");
Ada.Text_IO.Put(" Expected MD: ");
Ada.Text_IO.Put(Byte_Array_To_String (C.Element(Out_Key).First_Element.Hex.all));
Ada.Text_IO.New_Line;
Ada.Text_IO.Put(" Actual MD: ");
Ada.Text_IO.Put(Byte_Array_To_String(Output.all));
Ada.Text_IO.New_Line;
end if;
Free (Output);
end loop;
end Run_Tests;
end CSHAKE_Runner;
|
-- Auto generated file. Don't edit
-- Read copyright and license at the end of this file
package Encodings.Maps.CP_1255 is
function Decode (Char : Character) return Wide_Character;
pragma Inline (Decode);
procedure Encode
(Text : in Wide_String;
Text_Last : out Natural;
Result : out Raw_String;
Result_Last : out Natural;
Map : in Encoding := Encodings.CP_1255);
procedure Decode
(Text : in Raw_String;
Text_Last : out Natural;
Result : out Wide_String;
Result_Last : out Natural;
Map : in Encoding := Encodings.CP_1255);
end Encodings.Maps.CP_1255;
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, Maxim Reznik
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * Neither the name of the Maxim Reznik, IE nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
|
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE boost_serialization>
<boost_serialization signature="serialization::archive" version="14">
<syndb class_id="0" tracking_level="0" version="0">
<userIPLatency>-1</userIPLatency>
<userIPName></userIPName>
<cdfg class_id="1" tracking_level="1" version="0" object_id="_0">
<name>hls_target</name>
<ret_bitwidth>0</ret_bitwidth>
<ports class_id="2" tracking_level="0" version="0">
<count>4</count>
<item_version>0</item_version>
<item class_id="3" tracking_level="1" version="0" object_id="_1">
<Value class_id="4" tracking_level="0" version="0">
<Obj class_id="5" tracking_level="0" version="0">
<type>1</type>
<id>1</id>
<name>hw_input_V_value_V</name>
<fileName></fileName>
<fileDirectory></fileDirectory>
<lineNumber>0</lineNumber>
<contextFuncName></contextFuncName>
<inlineStackInfo class_id="6" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</inlineStackInfo>
<originalName>hw_input.V.value.V</originalName>
<rtlName></rtlName>
<coreName></coreName>
</Obj>
<bitwidth>32</bitwidth>
</Value>
<direction>0</direction>
<if_type>0</if_type>
<array_size>0</array_size>
<bit_vecs class_id="7" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
<item class_id_reference="3" object_id="_2">
<Value>
<Obj>
<type>1</type>
<id>2</id>
<name>hw_input_V_last_V</name>
<fileName></fileName>
<fileDirectory></fileDirectory>
<lineNumber>0</lineNumber>
<contextFuncName></contextFuncName>
<inlineStackInfo>
<count>0</count>
<item_version>0</item_version>
</inlineStackInfo>
<originalName>hw_input.V.last.V</originalName>
<rtlName></rtlName>
<coreName></coreName>
</Obj>
<bitwidth>1</bitwidth>
</Value>
<direction>0</direction>
<if_type>0</if_type>
<array_size>0</array_size>
<bit_vecs>
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
<item class_id_reference="3" object_id="_3">
<Value>
<Obj>
<type>1</type>
<id>3</id>
<name>hw_output_V_value_V</name>
<fileName></fileName>
<fileDirectory></fileDirectory>
<lineNumber>0</lineNumber>
<contextFuncName></contextFuncName>
<inlineStackInfo>
<count>0</count>
<item_version>0</item_version>
</inlineStackInfo>
<originalName>hw_output.V.value.V</originalName>
<rtlName></rtlName>
<coreName></coreName>
</Obj>
<bitwidth>32</bitwidth>
</Value>
<direction>1</direction>
<if_type>0</if_type>
<array_size>0</array_size>
<bit_vecs>
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
<item class_id_reference="3" object_id="_4">
<Value>
<Obj>
<type>1</type>
<id>4</id>
<name>hw_output_V_last_V</name>
<fileName></fileName>
<fileDirectory></fileDirectory>
<lineNumber>0</lineNumber>
<contextFuncName></contextFuncName>
<inlineStackInfo>
<count>0</count>
<item_version>0</item_version>
</inlineStackInfo>
<originalName>hw_output.V.last.V</originalName>
<rtlName></rtlName>
<coreName></coreName>
</Obj>
<bitwidth>1</bitwidth>
</Value>
<direction>1</direction>
<if_type>0</if_type>
<array_size>0</array_size>
<bit_vecs>
<count>0</count>
<item_version>0</item_version>
</bit_vecs>
</item>
</ports>
<nodes class_id="8" tracking_level="0" version="0">
<count>4</count>
<item_version>0</item_version>
<item class_id="9" tracking_level="1" version="0" object_id="_5">
<Value>
<Obj>
<type>0</type>
<id>11</id>
<name>p_hw_input_stencil_st</name>
<fileName>hls_target.cpp</fileName>
<fileDirectory>/home/dhuff/Halide-HLS/apps/hls_examples/camera_ready_synthesis/app_files/big_apps_32_shifts/conv2d</fileDirectory>
<lineNumber>57</lineNumber>
<contextFuncName>hls_target</contextFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item class_id="10" tracking_level="0" version="0">
<first>/home/dhuff/Halide-HLS/apps/hls_examples/camera_ready_synthesis/app_files/big_apps_32_shifts/conv2d</first>
<second class_id="11" tracking_level="0" version="0">
<count>1</count>
<item_version>0</item_version>
<item class_id="12" tracking_level="0" version="0">
<first class_id="13" tracking_level="0" version="0">
<first>hls_target.cpp</first>
<second>hls_target</second>
</first>
<second>57</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName>_hw_input_stencil_stream.V.value.V</originalName>
<rtlName></rtlName>
<coreName></coreName>
</Obj>
<bitwidth>288</bitwidth>
</Value>
<oprand_edges>
<count>1</count>
<item_version>0</item_version>
<item>22</item>
</oprand_edges>
<opcode>alloca</opcode>
<m_Display>0</m_Display>
</item>
<item class_id_reference="9" object_id="_6">
<Value>
<Obj>
<type>0</type>
<id>17</id>
<name></name>
<fileName>hls_target.cpp</fileName>
<fileDirectory>/home/dhuff/Halide-HLS/apps/hls_examples/camera_ready_synthesis/app_files/big_apps_32_shifts/conv2d</fileDirectory>
<lineNumber>61</lineNumber>
<contextFuncName>hls_target</contextFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/dhuff/Halide-HLS/apps/hls_examples/camera_ready_synthesis/app_files/big_apps_32_shifts/conv2d</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>hls_target.cpp</first>
<second>hls_target</second>
</first>
<second>61</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<coreName></coreName>
</Obj>
<bitwidth>0</bitwidth>
</Value>
<oprand_edges>
<count>4</count>
<item_version>0</item_version>
<item>24</item>
<item>25</item>
<item>26</item>
<item>27</item>
</oprand_edges>
<opcode>call</opcode>
<m_Display>0</m_Display>
</item>
<item class_id_reference="9" object_id="_7">
<Value>
<Obj>
<type>0</type>
<id>18</id>
<name></name>
<fileName></fileName>
<fileDirectory></fileDirectory>
<lineNumber>0</lineNumber>
<contextFuncName></contextFuncName>
<inlineStackInfo>
<count>0</count>
<item_version>0</item_version>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<coreName></coreName>
</Obj>
<bitwidth>0</bitwidth>
</Value>
<oprand_edges>
<count>6</count>
<item_version>0</item_version>
<item>29</item>
<item>30</item>
<item>31</item>
<item>32</item>
<item>136</item>
<item>137</item>
</oprand_edges>
<opcode>call</opcode>
<m_Display>0</m_Display>
</item>
<item class_id_reference="9" object_id="_8">
<Value>
<Obj>
<type>0</type>
<id>19</id>
<name></name>
<fileName>hls_target.cpp</fileName>
<fileDirectory>/home/dhuff/Halide-HLS/apps/hls_examples/camera_ready_synthesis/app_files/big_apps_32_shifts/conv2d</fileDirectory>
<lineNumber>159</lineNumber>
<contextFuncName>hls_target</contextFuncName>
<inlineStackInfo>
<count>1</count>
<item_version>0</item_version>
<item>
<first>/home/dhuff/Halide-HLS/apps/hls_examples/camera_ready_synthesis/app_files/big_apps_32_shifts/conv2d</first>
<second>
<count>1</count>
<item_version>0</item_version>
<item>
<first>
<first>hls_target.cpp</first>
<second>hls_target</second>
</first>
<second>159</second>
</item>
</second>
</item>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<coreName></coreName>
</Obj>
<bitwidth>0</bitwidth>
</Value>
<oprand_edges>
<count>0</count>
<item_version>0</item_version>
</oprand_edges>
<opcode>ret</opcode>
<m_Display>0</m_Display>
</item>
</nodes>
<consts class_id="15" tracking_level="0" version="0">
<count>3</count>
<item_version>0</item_version>
<item class_id="16" tracking_level="1" version="0" object_id="_9">
<Value>
<Obj>
<type>2</type>
<id>21</id>
<name>empty</name>
<fileName></fileName>
<fileDirectory></fileDirectory>
<lineNumber>0</lineNumber>
<contextFuncName></contextFuncName>
<inlineStackInfo>
<count>0</count>
<item_version>0</item_version>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<coreName></coreName>
</Obj>
<bitwidth>64</bitwidth>
</Value>
<const_type>0</const_type>
<content>1</content>
</item>
<item class_id_reference="16" object_id="_10">
<Value>
<Obj>
<type>2</type>
<id>23</id>
<name>linebuffer_1</name>
<fileName></fileName>
<fileDirectory></fileDirectory>
<lineNumber>0</lineNumber>
<contextFuncName></contextFuncName>
<inlineStackInfo>
<count>0</count>
<item_version>0</item_version>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<coreName></coreName>
</Obj>
<bitwidth>0</bitwidth>
</Value>
<const_type>6</const_type>
<content><constant:linebuffer.1></content>
</item>
<item class_id_reference="16" object_id="_11">
<Value>
<Obj>
<type>2</type>
<id>28</id>
<name>Loop_1_proc</name>
<fileName></fileName>
<fileDirectory></fileDirectory>
<lineNumber>0</lineNumber>
<contextFuncName></contextFuncName>
<inlineStackInfo>
<count>0</count>
<item_version>0</item_version>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<coreName></coreName>
</Obj>
<bitwidth>0</bitwidth>
</Value>
<const_type>6</const_type>
<content><constant:Loop_1_proc></content>
</item>
</consts>
<blocks class_id="17" tracking_level="0" version="0">
<count>1</count>
<item_version>0</item_version>
<item class_id="18" tracking_level="1" version="0" object_id="_12">
<Obj>
<type>3</type>
<id>20</id>
<name>hls_target</name>
<fileName></fileName>
<fileDirectory></fileDirectory>
<lineNumber>0</lineNumber>
<contextFuncName></contextFuncName>
<inlineStackInfo>
<count>0</count>
<item_version>0</item_version>
</inlineStackInfo>
<originalName></originalName>
<rtlName></rtlName>
<coreName></coreName>
</Obj>
<node_objs>
<count>4</count>
<item_version>0</item_version>
<item>11</item>
<item>17</item>
<item>18</item>
<item>19</item>
</node_objs>
</item>
</blocks>
<edges class_id="19" tracking_level="0" version="0">
<count>11</count>
<item_version>0</item_version>
<item class_id="20" tracking_level="1" version="0" object_id="_13">
<id>22</id>
<edge_type>1</edge_type>
<source_obj>21</source_obj>
<sink_obj>11</sink_obj>
</item>
<item class_id_reference="20" object_id="_14">
<id>24</id>
<edge_type>1</edge_type>
<source_obj>23</source_obj>
<sink_obj>17</sink_obj>
</item>
<item class_id_reference="20" object_id="_15">
<id>25</id>
<edge_type>1</edge_type>
<source_obj>1</source_obj>
<sink_obj>17</sink_obj>
</item>
<item class_id_reference="20" object_id="_16">
<id>26</id>
<edge_type>1</edge_type>
<source_obj>2</source_obj>
<sink_obj>17</sink_obj>
</item>
<item class_id_reference="20" object_id="_17">
<id>27</id>
<edge_type>1</edge_type>
<source_obj>11</source_obj>
<sink_obj>17</sink_obj>
</item>
<item class_id_reference="20" object_id="_18">
<id>29</id>
<edge_type>1</edge_type>
<source_obj>28</source_obj>
<sink_obj>18</sink_obj>
</item>
<item class_id_reference="20" object_id="_19">
<id>30</id>
<edge_type>1</edge_type>
<source_obj>11</source_obj>
<sink_obj>18</sink_obj>
</item>
<item class_id_reference="20" object_id="_20">
<id>31</id>
<edge_type>1</edge_type>
<source_obj>3</source_obj>
<sink_obj>18</sink_obj>
</item>
<item class_id_reference="20" object_id="_21">
<id>32</id>
<edge_type>1</edge_type>
<source_obj>4</source_obj>
<sink_obj>18</sink_obj>
</item>
<item class_id_reference="20" object_id="_22">
<id>136</id>
<edge_type>4</edge_type>
<source_obj>17</source_obj>
<sink_obj>18</sink_obj>
</item>
<item class_id_reference="20" object_id="_23">
<id>137</id>
<edge_type>4</edge_type>
<source_obj>17</source_obj>
<sink_obj>18</sink_obj>
</item>
</edges>
</cdfg>
<cdfg_regions class_id="21" tracking_level="0" version="0">
<count>1</count>
<item_version>0</item_version>
<item class_id="22" tracking_level="1" version="0" object_id="_24">
<mId>1</mId>
<mTag>hls_target</mTag>
<mType>0</mType>
<sub_regions>
<count>0</count>
<item_version>0</item_version>
</sub_regions>
<basic_blocks>
<count>1</count>
<item_version>0</item_version>
<item>20</item>
</basic_blocks>
<mII>-1</mII>
<mDepth>-1</mDepth>
<mMinTripCount>-1</mMinTripCount>
<mMaxTripCount>-1</mMaxTripCount>
<mMinLatency>2077921</mMinLatency>
<mMaxLatency>-1</mMaxLatency>
<mIsDfPipe>1</mIsDfPipe>
<mDfPipe class_id="23" tracking_level="1" version="0" object_id="_25">
<port_list class_id="24" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</port_list>
<process_list class_id="25" tracking_level="0" version="0">
<count>2</count>
<item_version>0</item_version>
<item class_id="26" tracking_level="1" version="0" object_id="_26">
<type>0</type>
<name>linebuffer_1_U0</name>
<ssdmobj_id>17</ssdmobj_id>
<pins class_id="27" tracking_level="0" version="0">
<count>3</count>
<item_version>0</item_version>
<item class_id="28" tracking_level="1" version="0" object_id="_27">
<port class_id="29" tracking_level="1" version="0" object_id="_28">
<name>in_axi_stream_V_value_V</name>
<dir>3</dir>
<type>0</type>
</port>
<inst class_id="30" tracking_level="1" version="0" object_id="_29">
<type>0</type>
<name>linebuffer_1_U0</name>
<ssdmobj_id>17</ssdmobj_id>
</inst>
</item>
<item class_id_reference="28" object_id="_30">
<port class_id_reference="29" object_id="_31">
<name>in_axi_stream_V_last_V</name>
<dir>3</dir>
<type>0</type>
</port>
<inst class_id_reference="30" object_id_reference="_29"></inst>
</item>
<item class_id_reference="28" object_id="_32">
<port class_id_reference="29" object_id="_33">
<name>out_stream_V_value_V</name>
<dir>0</dir>
<type>1</type>
</port>
<inst class_id_reference="30" object_id_reference="_29"></inst>
</item>
</pins>
</item>
<item class_id_reference="26" object_id="_34">
<type>0</type>
<name>Loop_1_proc_U0</name>
<ssdmobj_id>18</ssdmobj_id>
<pins>
<count>3</count>
<item_version>0</item_version>
<item class_id_reference="28" object_id="_35">
<port class_id_reference="29" object_id="_36">
<name>p_hw_input_stencil_stream_V_value_V</name>
<dir>0</dir>
<type>0</type>
</port>
<inst class_id_reference="30" object_id="_37">
<type>0</type>
<name>Loop_1_proc_U0</name>
<ssdmobj_id>18</ssdmobj_id>
</inst>
</item>
<item class_id_reference="28" object_id="_38">
<port class_id_reference="29" object_id="_39">
<name>hw_output_V_value_V</name>
<dir>3</dir>
<type>1</type>
</port>
<inst class_id_reference="30" object_id_reference="_37"></inst>
</item>
<item class_id_reference="28" object_id="_40">
<port class_id_reference="29" object_id="_41">
<name>hw_output_V_last_V</name>
<dir>3</dir>
<type>1</type>
</port>
<inst class_id_reference="30" object_id_reference="_37"></inst>
</item>
</pins>
</item>
</process_list>
<channel_list class_id="31" tracking_level="0" version="0">
<count>1</count>
<item_version>0</item_version>
<item class_id="32" tracking_level="1" version="0" object_id="_42">
<type>1</type>
<name>p_hw_input_stencil_st</name>
<ssdmobj_id>11</ssdmobj_id>
<ctype>0</ctype>
<depth>1</depth>
<bitwidth>288</bitwidth>
<source class_id_reference="28" object_id="_43">
<port class_id_reference="29" object_id="_44">
<name>in</name>
<dir>3</dir>
<type>0</type>
</port>
<inst class_id_reference="30" object_id_reference="_29"></inst>
</source>
<sink class_id_reference="28" object_id="_45">
<port class_id_reference="29" object_id="_46">
<name>out</name>
<dir>3</dir>
<type>1</type>
</port>
<inst class_id_reference="30" object_id_reference="_37"></inst>
</sink>
</item>
</channel_list>
<net_list class_id="33" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</net_list>
</mDfPipe>
</item>
</cdfg_regions>
<fsm class_id="-1"></fsm>
<res class_id="-1"></res>
<node_label_latency class_id="36" tracking_level="0" version="0">
<count>4</count>
<item_version>0</item_version>
<item class_id="37" tracking_level="0" version="0">
<first>11</first>
<second class_id="38" tracking_level="0" version="0">
<first>0</first>
<second>0</second>
</second>
</item>
<item>
<first>17</first>
<second>
<first>0</first>
<second>1</second>
</second>
</item>
<item>
<first>18</first>
<second>
<first>2</first>
<second>1</second>
</second>
</item>
<item>
<first>19</first>
<second>
<first>3</first>
<second>0</second>
</second>
</item>
</node_label_latency>
<bblk_ent_exit class_id="39" tracking_level="0" version="0">
<count>1</count>
<item_version>0</item_version>
<item class_id="40" tracking_level="0" version="0">
<first>20</first>
<second class_id="41" tracking_level="0" version="0">
<first>0</first>
<second>3</second>
</second>
</item>
</bblk_ent_exit>
<regions class_id="42" tracking_level="0" version="0">
<count>1</count>
<item_version>0</item_version>
<item class_id="43" tracking_level="1" version="0" object_id="_47">
<region_name>hls_target</region_name>
<basic_blocks>
<count>1</count>
<item_version>0</item_version>
<item>20</item>
</basic_blocks>
<nodes>
<count>15</count>
<item_version>0</item_version>
<item>5</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>9</item>
<item>10</item>
<item>11</item>
<item>12</item>
<item>13</item>
<item>14</item>
<item>15</item>
<item>16</item>
<item>17</item>
<item>18</item>
<item>19</item>
</nodes>
<anchor_node>-1</anchor_node>
<region_type>16</region_type>
<interval>0</interval>
<pipe_depth>0</pipe_depth>
</item>
</regions>
<dp_fu_nodes class_id="44" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</dp_fu_nodes>
<dp_fu_nodes_expression class_id="45" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</dp_fu_nodes_expression>
<dp_fu_nodes_module>
<count>0</count>
<item_version>0</item_version>
</dp_fu_nodes_module>
<dp_fu_nodes_io>
<count>0</count>
<item_version>0</item_version>
</dp_fu_nodes_io>
<return_ports>
<count>0</count>
<item_version>0</item_version>
</return_ports>
<dp_mem_port_nodes class_id="46" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</dp_mem_port_nodes>
<dp_reg_nodes>
<count>0</count>
<item_version>0</item_version>
</dp_reg_nodes>
<dp_regname_nodes>
<count>0</count>
<item_version>0</item_version>
</dp_regname_nodes>
<dp_reg_phi>
<count>0</count>
<item_version>0</item_version>
</dp_reg_phi>
<dp_regname_phi>
<count>0</count>
<item_version>0</item_version>
</dp_regname_phi>
<dp_port_io_nodes class_id="47" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</dp_port_io_nodes>
<port2core class_id="48" tracking_level="0" version="0">
<count>0</count>
<item_version>0</item_version>
</port2core>
<node2core>
<count>0</count>
<item_version>0</item_version>
</node2core>
</syndb>
</boost_serialization>
|
package FLTK.Widgets.Groups.Wizards is
type Wizard is new Group with private;
type Wizard_Reference (Data : not null access Wizard'Class) is limited null record
with Implicit_Dereference => Data;
package Forge is
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Wizard;
end Forge;
procedure Next
(This : in out Wizard);
procedure Prev
(This : in out Wizard);
function Get_Visible
(This : in Wizard)
return access Widget'Class;
procedure Set_Visible
(This : in out Wizard;
Item : in out Widget'Class);
procedure Draw
(This : in out Wizard);
function Handle
(This : in out Wizard;
Event : in Event_Kind)
return Event_Outcome;
private
type Wizard is new Group with null record;
overriding procedure Finalize
(This : in out Wizard);
pragma Inline (Next);
pragma Inline (Prev);
pragma Inline (Get_Visible);
pragma Inline (Set_Visible);
pragma Inline (Draw);
pragma Inline (Handle);
end FLTK.Widgets.Groups.Wizards;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Internals.UML_Elements;
with AMF.Standard_Profile_L2.Implementation_Classes;
with AMF.UML.Classes;
with AMF.Visitors;
package AMF.Internals.Standard_Profile_L2_Implementation_Classes is
type Standard_Profile_L2_Implementation_Class_Proxy is
limited new AMF.Internals.UML_Elements.UML_Element_Base
and AMF.Standard_Profile_L2.Implementation_Classes.Standard_Profile_L2_Implementation_Class with null record;
overriding function Get_Base_Class
(Self : not null access constant Standard_Profile_L2_Implementation_Class_Proxy)
return AMF.UML.Classes.UML_Class_Access;
-- Getter of ImplementationClass::base_Class.
--
overriding procedure Set_Base_Class
(Self : not null access Standard_Profile_L2_Implementation_Class_Proxy;
To : AMF.UML.Classes.UML_Class_Access);
-- Setter of ImplementationClass::base_Class.
--
overriding procedure Enter_Element
(Self : not null access constant Standard_Profile_L2_Implementation_Class_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Leave_Element
(Self : not null access constant Standard_Profile_L2_Implementation_Class_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
overriding procedure Visit_Element
(Self : not null access constant Standard_Profile_L2_Implementation_Class_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control);
end AMF.Internals.Standard_Profile_L2_Implementation_Classes;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . E X C E P T I O N S . M A C H I N E --
-- --
-- S p e c --
-- --
-- Copyright (C) 2013-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. --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
-- Declaration of the machine exception and some associated facilities. The
-- machine exception is the object that is propagated by low level routines
-- and that contains the Ada exception occurrence.
-- This is the version using the GCC EH mechanism
with Ada.Unchecked_Conversion;
with Ada.Exceptions;
package System.Exceptions.Machine is
pragma Preelaborate;
------------------------------------------------
-- Entities to interface with the GCC runtime --
------------------------------------------------
-- These come from "C++ ABI for Itanium: Exception handling", which is
-- the reference for GCC.
-- Return codes from the GCC runtime functions used to propagate
-- an exception.
type Unwind_Reason_Code is
(URC_NO_REASON,
URC_FOREIGN_EXCEPTION_CAUGHT,
URC_PHASE2_ERROR,
URC_PHASE1_ERROR,
URC_NORMAL_STOP,
URC_END_OF_STACK,
URC_HANDLER_FOUND,
URC_INSTALL_CONTEXT,
URC_CONTINUE_UNWIND);
pragma Unreferenced
(URC_NO_REASON,
URC_FOREIGN_EXCEPTION_CAUGHT,
URC_PHASE2_ERROR,
URC_PHASE1_ERROR,
URC_NORMAL_STOP,
URC_END_OF_STACK,
URC_HANDLER_FOUND,
URC_INSTALL_CONTEXT,
URC_CONTINUE_UNWIND);
pragma Convention (C, Unwind_Reason_Code);
-- Mandatory common header for any exception object handled by the
-- GCC unwinding runtime.
type Exception_Class is mod 2 ** 64;
GNAT_Exception_Class : constant Exception_Class := 16#474e552d41646100#;
-- "GNU-Ada\0"
type Unwind_Word is mod 2 ** System.Word_Size;
for Unwind_Word'Size use System.Word_Size;
-- Map the corresponding C type used in Unwind_Exception below
type Unwind_Exception is record
Class : Exception_Class;
Cleanup : System.Address;
Private1 : Unwind_Word;
Private2 : Unwind_Word;
-- Usual exception structure has only two private fields, but the SEH
-- one has six. To avoid making this file more complex, we use six
-- fields on all platforms, wasting a few bytes on some.
Private3 : Unwind_Word;
Private4 : Unwind_Word;
Private5 : Unwind_Word;
Private6 : Unwind_Word;
end record;
pragma Convention (C, Unwind_Exception);
-- Map the GCC struct used for exception handling
for Unwind_Exception'Alignment use Standard'Maximum_Alignment;
-- The C++ ABI mandates the common exception header to be at least
-- doubleword aligned, and the libGCC implementation actually makes it
-- maximally aligned (see unwind.h). See additional comments on the
-- alignment below.
-- There is a subtle issue with the common header alignment, since the C
-- version is aligned on BIGGEST_ALIGNMENT, the Ada version is aligned on
-- Standard'Maximum_Alignment, and those two values don't quite represent
-- the same concepts and so may be decoupled someday. One typical reason
-- is that BIGGEST_ALIGNMENT may be larger than what the underlying system
-- allocator guarantees, and there are extra costs involved in allocating
-- objects aligned to such factors.
-- To deal with the potential alignment differences between the C and Ada
-- representations, the Ada part of the whole structure is only accessed
-- by the personality routine through accessors. Ada specific fields are
-- thus always accessed through consistent layout, and we expect the
-- actual alignment to always be large enough to avoid traps from the C
-- accesses to the common header. Besides, accessors alleviate the need
-- for a C struct whole counterpart, both painful and error-prone to
-- maintain anyway.
type GCC_Exception_Access is access all Unwind_Exception;
-- Pointer to a GCC exception
procedure Unwind_DeleteException (Excp : not null GCC_Exception_Access);
pragma Import (C, Unwind_DeleteException, "_Unwind_DeleteException");
-- Procedure to free any GCC exception
--------------------------------------------------------------
-- GNAT Specific Entities To Deal With The GCC EH Circuitry --
--------------------------------------------------------------
-- A GNAT exception object to be dealt with by the personality routine
-- called by the GCC unwinding runtime.
type GNAT_GCC_Exception is record
Header : Unwind_Exception;
-- ABI Exception header first
Occurrence : aliased Ada.Exceptions.Exception_Occurrence;
-- The Ada occurrence
end record;
pragma Convention (C, GNAT_GCC_Exception);
type GNAT_GCC_Exception_Access is access all GNAT_GCC_Exception;
function To_GCC_Exception is new
Ada.Unchecked_Conversion (System.Address, GCC_Exception_Access);
function To_GNAT_GCC_Exception is new
Ada.Unchecked_Conversion
(GCC_Exception_Access, GNAT_GCC_Exception_Access);
function New_Occurrence return GNAT_GCC_Exception_Access;
-- Allocate and initialize a machine occurrence
end System.Exceptions.Machine;
|
--------------------------------------------------------------------------------
-- Copyright (c) 2013, Felix Krause <contact@flyx.org>
--
-- Permission to use, copy, modify, and/or distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--------------------------------------------------------------------------------
with CL.Vector_Operations;
generic
type Base is private;
type Base_Vector is array (Natural range <>) of aliased Base;
with function "+" (Left, Right: Base) return Base is <>;
with function "-" (Left, Right: Base) return Base is <>;
with function "*" (Left, Right: Base) return Base is <>;
with function "/" (Left, Right: Base) return Base is <>;
--with function "=" (Left, Right: Base) return Boolean is <>;
with function To_String (Values : Base) return String is <>;
package CL.Vector_Set is
pragma Preelaborate (CL.Vector_Set);
-- TODO: GNAT has a bug that causes pragma Unchecked_Union
-- not to be inherited to derived types. Therefore, accessing
-- the records with named parameters is currently disabled.
-- See http://stackoverflow.com/questions/14663316/derive-from-unchecked-union
-- type Access_Kind is (Named, Indexed);
package V2 is new Vector_Operations (Base => Base,
Base_Vector => Base_Vector,
Vector_Range => Range2);
package V3 is new Vector_Operations (Base => Base,
Base_Vector => Base_Vector,
Vector_Range => Range3);
package V4 is new Vector_Operations (Base => Base,
Base_Vector => Base_Vector,
Vector_Range => Range4);
package V8 is new Vector_Operations (Base => Base,
Base_Vector => Base_Vector,
Vector_Range => Range8);
package V16 is new Vector_Operations (Base => Base,
Base_Vector => Base_Vector,
Vector_Range => Range16);
type R2 is record
-- type R2 (Kind : Access_Kind := Access_Kind'First) is record
-- case Kind is
-- when Named =>
-- X, Y : Base;
-- when Indexed =>
S : V2.Vector;
-- end case;
end record;
type R3 is record
-- type R3 (Kind : Access_Kind := Access_Kind'First) is record
-- case Kind is
-- when Named =>
-- X, Y, Z : Base;
-- when Indexed =>
S : V3.Vector;
-- end case;
end record;
type R4 is record
-- type R4 (Kind : Access_Kind := Access_Kind'First) is record
-- case Kind is
-- when Named =>
-- X, Y, Z, W : Base;
-- when Indexed =>
S : V4.Vector;
-- end case;
end record;
type R8 is record
-- type R8 (Kind : Access_Kind := Access_Kind'First) is record
-- case Kind is
-- when Named =>
-- S0, S1, S2, S3, S4, S5, S6, S7 : Base;
-- when Indexed =>
S : V8.Vector;
-- end case;
end record;
type R16 is record
-- type R16 (Kind : Access_Kind := Access_Kind'First) is record
-- case Kind is
-- when Named =>
-- S0, S1, S2, S3, S4, S5, S6, S7, S8, S9, SA, SB, SC, SD, SE, SF : Base;
-- when Indexed =>
S : V16.Vector;
-- end case;
end record;
-- pragma Unchecked_Union (R2);
-- pragma Unchecked_Union (R3);
-- pragma Unchecked_Union (R4);
-- pragma Unchecked_Union (R8);
-- pragma Unchecked_Union (R16);
pragma Convention (C_Pass_By_Copy, R2);
pragma Convention (C_Pass_By_Copy, R3);
pragma Convention (C_Pass_By_Copy, R4);
pragma Convention (C_Pass_By_Copy, R8);
pragma Convention (C_Pass_By_Copy, R16);
function CL_Vector (X, Y : Base) return R2;
function CL_Vector (V : V2.Vector) return R2;
function CL_Vector (X, Y, Z : Base) return R3;
function CL_Vector (V : V3.Vector) return R3;
function CL_Vector (X, Y, Z, W : Base) return R4;
function CL_Vector (V : V4.Vector) return R4;
function CL_Vector (S0, S1, S2, S3, S4, S5, S6, S7 : Base) return R8;
function CL_Vector (V : V8.Vector) return R8;
function CL_Vector (S0, S1, S2, S3, S4, S5, S6, S7,
S8, S9, SA, SB, SC, SD, SE, SF : Base) return R16;
function CL_Vector (V : V16.Vector) return R16;
pragma Inline (CL_Vector);
function To_String (Value : R2) return String;
function To_String (Value : R3) return String;
function To_String (Value : R4) return String;
function To_String (Value : R8) return String;
function To_String (Value : R16) return String;
pragma Inline (To_String);
generic
type Record_Type is new R2;
type Record_Array is array (Integer range <>) of Record_Type;
function Vector2_Array (List : V2.Vector_Array) return Record_Array;
generic
type Record_Type is new R3;
type Record_Array is array (Integer range <>) of Record_Type;
function Vector3_Array (List : V3.Vector_Array) return Record_Array;
generic
type Record_Type is new R4;
type Record_Array is array (Integer range <>) of Record_Type;
function Vector4_Array (List : V4.Vector_Array) return Record_Array;
generic
type Record_Type is new R8;
type Record_Array is array (Integer range <>) of Record_Type;
function Vector8_Array (List : V8.Vector_Array) return Record_Array;
generic
type Record_Type is new R16;
type Record_Array is array (Integer range <>) of Record_Type;
function Vector16_Array (List : V16.Vector_Array) return Record_Array;
end CL.Vector_Set;
|
-- Copyright 2013-2016 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Caller; use Caller;
procedure Foo is
Num : Float := 99.0;
begin
Verbose_Increment (Num, "Foo");
end Foo;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Test is begin P(); end;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Strings.Wide_Wide_Fixed;
with AMF.Holders.Reals;
separate (AMF.Internals.Factories.Primitive_Types_Factories)
function Convert_Real_To_String
(Value : League.Holders.Holder) return League.Strings.Universal_String is
begin
return
League.Strings.To_Universal_String
(Ada.Strings.Wide_Wide_Fixed.Trim
(AMF.Real'Wide_Wide_Image (AMF.Holders.Reals.Element (Value)),
Ada.Strings.Both));
end Convert_Real_To_String;
|
package body Bubble with SPARK_Mode is
procedure Sort (A : in out Arr) is
Tmp : Integer;
begin
Outer: for I in reverse A'First .. A'Last - 1 loop
Inner: for J in A'First .. I loop
if A(J) > A(J + 1) then
Tmp := A(J);
A(J) := A(J + 1);
A(J + 1) := Tmp;
end if;
pragma Loop_Invariant (for all K1 in A'Range => (for some K2 in A'Range => A(K2) = A'Loop_Entry(Inner)(K1)));
end loop Inner;
pragma Loop_Invariant (for all K1 in A'Range => (for some K2 in A'Range => A(K2) = A'Loop_Entry(Outer)(K1)));
end loop Outer;
end Sort;
end Bubble;
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
procedure Euler13 is
function To_Integer(C : Character) return Integer is (Character'Pos(C) - Character'Pos('0'));
function Digit(A : String; D : Positive) return Natural is
begin
if D in A'Range then
return To_Integer(A(A'Length - D + 1));
else
return 0;
end if;
end Digit;
function "+"(A, B : String) return String is
Length : Natural := Natural'Max(A'Length, B'Length);
R : Unbounded_String;
Carry : Natural := 0;
S : Natural;
begin
for D in 1 .. Length loop
S := Carry + Digit(A, D) + Digit(B, D);
R := Integer'Image(S mod 10)(2) & R;
Carry := S / 10;
end loop;
if Carry > 0 then
R := Integer'Image(Carry)(2) & R;
end if;
return To_String(R);
end "+";
Nums : constant array(Positive range <>) of String(1 .. 50) :=
(
"37107287533902102798797998220837590246510135740250",
"46376937677490009712648124896970078050417018260538",
"74324986199524741059474233309513058123726617309629",
"91942213363574161572522430563301811072406154908250",
"23067588207539346171171980310421047513778063246676",
"89261670696623633820136378418383684178734361726757",
"28112879812849979408065481931592621691275889832738",
"44274228917432520321923589422876796487670272189318",
"47451445736001306439091167216856844588711603153276",
"70386486105843025439939619828917593665686757934951",
"62176457141856560629502157223196586755079324193331",
"64906352462741904929101432445813822663347944758178",
"92575867718337217661963751590579239728245598838407",
"58203565325359399008402633568948830189458628227828",
"80181199384826282014278194139940567587151170094390",
"35398664372827112653829987240784473053190104293586",
"86515506006295864861532075273371959191420517255829",
"71693888707715466499115593487603532921714970056938",
"54370070576826684624621495650076471787294438377604",
"53282654108756828443191190634694037855217779295145",
"36123272525000296071075082563815656710885258350721",
"45876576172410976447339110607218265236877223636045",
"17423706905851860660448207621209813287860733969412",
"81142660418086830619328460811191061556940512689692",
"51934325451728388641918047049293215058642563049483",
"62467221648435076201727918039944693004732956340691",
"15732444386908125794514089057706229429197107928209",
"55037687525678773091862540744969844508330393682126",
"18336384825330154686196124348767681297534375946515",
"80386287592878490201521685554828717201219257766954",
"78182833757993103614740356856449095527097864797581",
"16726320100436897842553539920931837441497806860984",
"48403098129077791799088218795327364475675590848030",
"87086987551392711854517078544161852424320693150332",
"59959406895756536782107074926966537676326235447210",
"69793950679652694742597709739166693763042633987085",
"41052684708299085211399427365734116182760315001271",
"65378607361501080857009149939512557028198746004375",
"35829035317434717326932123578154982629742552737307",
"94953759765105305946966067683156574377167401875275",
"88902802571733229619176668713819931811048770190271",
"25267680276078003013678680992525463401061632866526",
"36270218540497705585629946580636237993140746255962",
"24074486908231174977792365466257246923322810917141",
"91430288197103288597806669760892938638285025333403",
"34413065578016127815921815005561868836468420090470",
"23053081172816430487623791969842487255036638784583",
"11487696932154902810424020138335124462181441773470",
"63783299490636259666498587618221225225512486764533",
"67720186971698544312419572409913959008952310058822",
"95548255300263520781532296796249481641953868218774",
"76085327132285723110424803456124867697064507995236",
"37774242535411291684276865538926205024910326572967",
"23701913275725675285653248258265463092207058596522",
"29798860272258331913126375147341994889534765745501",
"18495701454879288984856827726077713721403798879715",
"38298203783031473527721580348144513491373226651381",
"34829543829199918180278916522431027392251122869539",
"40957953066405232632538044100059654939159879593635",
"29746152185502371307642255121183693803580388584903",
"41698116222072977186158236678424689157993532961922",
"62467957194401269043877107275048102390895523597457",
"23189706772547915061505504953922979530901129967519",
"86188088225875314529584099251203829009407770775672",
"11306739708304724483816533873502340845647058077308",
"82959174767140363198008187129011875491310547126581",
"97623331044818386269515456334926366572897563400500",
"42846280183517070527831839425882145521227251250327",
"55121603546981200581762165212827652751691296897789",
"32238195734329339946437501907836945765883352399886",
"75506164965184775180738168837861091527357929701337",
"62177842752192623401942399639168044983993173312731",
"32924185707147349566916674687634660915035914677504",
"99518671430235219628894890102423325116913619626622",
"73267460800591547471830798392868535206946944540724",
"76841822524674417161514036427982273348055556214818",
"97142617910342598647204516893989422179826088076852",
"87783646182799346313767754307809363333018982642090",
"10848802521674670883215120185883543223812876952786",
"71329612474782464538636993009049310363619763878039",
"62184073572399794223406235393808339651327408011116",
"66627891981488087797941876876144230030984490851411",
"60661826293682836764744779239180335110989069790714",
"85786944089552990653640447425576083659976645795096",
"66024396409905389607120198219976047599490197230297",
"64913982680032973156037120041377903785566085089252",
"16730939319872750275468906903707539413042652315011",
"94809377245048795150954100921645863754710598436791",
"78639167021187492431995700641917969777599028300699",
"15368713711936614952811305876380278410754449733078",
"40789923115535562561142322423255033685442488917353",
"44889911501440648020369068063960672322193204149535",
"41503128880339536053299340368006977710650566631954",
"81234880673210146739058568557934581403627822703280",
"82616570773948327592232845941706525094512325230608",
"22918802058777319719839450180888072429661980811197",
"77158542502016545090413245809786882778948721859617",
"72107838435069186155435662884062257473692284509516",
"20849603980134001723930671666823555245252804609722",
"53503534226472524250874054075591789781264330331690");
Sum : Unbounded_String;
begin
for I in Nums'Range loop
Sum := To_Unbounded_String(To_String(Sum) + Nums(I));
end loop;
Put_Line(To_String(Sum));
Put_Line(To_String(Sum)(1 .. 10));
end Euler13;
|
-- Copyright 2005-2016 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
procedure Second is
procedure Break_Me is
begin
null;
end Break_Me;
begin
Break_Me;
end Second;
|
-- Copyright 2008-2020 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package Pck is
type Data is record
One : Integer;
Two : Integer;
Three : Integer;
Four : Integer;
Five : Integer;
Six : Integer;
end record;
procedure Call_Me (D : in out Data);
end Pck;
|
-- CE2110A.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 AN EXTERNAL FILE CEASES TO EXIST AFTER A SUCCESSFUL
-- DELETE.
-- APPLICABILITY CRITERIA:
-- THIS TEST IS APPLICABLE ONLY TO IMPLEMENTATIONS WHICH SUPPORT
-- CREATION AND DELETION OF SEQUENTIAL FILES.
-- HISTORY:
-- SPS 08/25/82
-- SPS 11/09/82
-- JBG 04/01/83
-- EG 05/31/85
-- JLH 07/21/87 ADDED A CALL TO NOT_APPLICABLE, IF EXCEPTION
-- USE_ERROR IS RAISED BY DELETE.
WITH REPORT; USE REPORT;
WITH SEQUENTIAL_IO;
PROCEDURE CE2110A IS
BEGIN
TEST ("CE2110A", "CHECK THAT THE EXTERNAL FILE CEASES TO EXIST " &
"AFTER A SUCCESSFUL DELETE");
DECLARE
PACKAGE SEQ IS NEW SEQUENTIAL_IO (INTEGER);
USE SEQ;
FL1, FL2 : FILE_TYPE;
VAR1 : INTEGER := 5;
INCOMPLETE : EXCEPTION;
BEGIN
BEGIN
CREATE (FL1, OUT_FILE, LEGAL_FILE_NAME);
EXCEPTION
WHEN USE_ERROR =>
NOT_APPLICABLE ("USE_ERROR RAISED ON CREATE " &
"WITH OUT_FILE MODE");
RAISE INCOMPLETE;
WHEN NAME_ERROR =>
NOT_APPLICABLE ("NAME_ERROR RAISED ON CREATE " &
"WITH OUT_FILE MODE");
RAISE INCOMPLETE;
WHEN OTHERS =>
FAILED ("UNEXPECTED EXCEPTION RAISED ON CREATE");
RAISE INCOMPLETE;
END;
BEGIN
WRITE (FL1, VAR1); -- THIS WRITES TO THE FILE IF IT
EXCEPTION -- CAN, NOT NECESSARY FOR THE
WHEN OTHERS => -- OBJECTIVE.
NULL;
END;
BEGIN
DELETE (FL1);
EXCEPTION
WHEN USE_ERROR =>
NOT_APPLICABLE ("DELETION OF EXTERNAL FILES NOT " &
"SUPPORTED");
RAISE INCOMPLETE;
END;
BEGIN
OPEN (FL2, IN_FILE, LEGAL_FILE_NAME);
FAILED ("EXTERNAL FILE STILL EXISTS AFTER " &
"A SUCCESSFUL DELETION - SEQ");
EXCEPTION
WHEN NAME_ERROR =>
NULL;
END;
EXCEPTION
WHEN INCOMPLETE =>
NULL;
END;
RESULT;
END CE2110A;
|
with System.Synchronous_Objects.Abortable;
with System.Tasks;
package body Ada.Synchronous_Task_Control.EDF is
procedure Suspend_Until_True_And_Set_Deadline (
S : in out Suspension_Object;
TS : Real_Time.Time_Span)
is
Dummy : Boolean;
begin
Suspend_Until_True_And_Set_Deadline (S, TS, Dummy);
end Suspend_Until_True_And_Set_Deadline;
procedure Suspend_Until_True_And_Set_Deadline (
S : in out Suspension_Object;
TS : Real_Time.Time_Span;
State : out Boolean)
is
Aborted : Boolean;
begin
System.Tasks.Enable_Abort;
System.Synchronous_Objects.Abortable.Wait (
S.Object,
Real_Time.To_Duration (TS),
State,
Aborted => Aborted);
System.Tasks.Disable_Abort (Aborted);
end Suspend_Until_True_And_Set_Deadline;
end Ada.Synchronous_Task_Control.EDF;
|
-----------------------------------------------------------------------
-- util-http -- HTTP Utility Library
-- Copyright (C) 2012 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Strings;
package body Util.Http is
-- Sets a header with the given name and date-value.
-- The date is specified in terms of milliseconds since the epoch.
-- If the header had already been set, the new value overwrites the previous one.
-- The containsHeader method can be used to test for the presence of a header
-- before setting its value.
procedure Set_Date_Header (Request : in out Abstract_Message'Class;
Name : in String;
Date : in Ada.Calendar.Time) is
begin
null;
end Set_Date_Header;
-- Adds a header with the given name and date-value. The date is specified
-- in terms of milliseconds since the epoch. This method allows response headers
-- to have multiple values.
procedure Add_Date_Header (Request : in out Abstract_Message'Class;
Name : in String;
Date : in Ada.Calendar.Time) is
begin
null;
end Add_Date_Header;
-- ------------------------------
-- Sets a header with the given name and integer value.
-- If the header had already been set, the new value overwrites the previous one.
-- The containsHeader method can be used to test for the presence of a header
-- before setting its value.
-- ------------------------------
procedure Set_Int_Header (Request : in out Abstract_Message'Class;
Name : in String;
Value : in Integer) is
begin
Request.Set_Header (Name, Util.Strings.Image (Value));
end Set_Int_Header;
-- ------------------------------
-- Adds a header with the given name and integer value. This method
-- allows headers to have multiple values.
-- ------------------------------
procedure Add_Int_Header (Request : in out Abstract_Message'Class;
Name : in String;
Value : in Integer) is
begin
Request.Add_Header (Name, Util.Strings.Image (Value));
end Add_Int_Header;
end Util.Http;
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <denkpadje@gmail.com>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with AUnit.Test_Suites;
with AUnit.Test_Fixtures;
package Test_Tokenizers is
function Suite return AUnit.Test_Suites.Access_Test_Suite;
private
type Test is new AUnit.Test_Fixtures.Test_Fixture with null record;
-- Keyword
procedure Test_Null_Token (Object : in out Test);
procedure Test_True_Token (Object : in out Test);
procedure Test_False_Token (Object : in out Test);
-- String
procedure Test_Empty_String_Token (Object : in out Test);
procedure Test_Non_Empty_String_Token (Object : in out Test);
procedure Test_Number_String_Token (Object : in out Test);
procedure Test_Escaped_Character_String_Token (Object : in out Test);
procedure Test_Escaped_Quotation_Solidus_String_Token (Object : in out Test);
-- Integer/float number
procedure Test_Zero_Number_Token (Object : in out Test);
procedure Test_Integer_Number_Token (Object : in out Test);
procedure Test_Float_Number_Token (Object : in out Test);
procedure Test_Negative_Float_Number_Token (Object : in out Test);
procedure Test_Integer_Exponent_Number_Token (Object : in out Test);
procedure Test_Float_Exponent_Number_Token (Object : in out Test);
procedure Test_Float_Negative_Exponent_Number_Token (Object : in out Test);
-- Array
procedure Test_Empty_Array_Tokens (Object : in out Test);
procedure Test_One_Element_Array_Tokens (Object : in out Test);
procedure Test_Two_Elements_Array_Tokens (Object : in out Test);
-- Object
procedure Test_Empty_Object_Tokens (Object : in out Test);
procedure Test_One_Pair_Object_Tokens (Object : in out Test);
procedure Test_Two_Pairs_Object_Tokens (Object : in out Test);
-- Exceptions
procedure Test_Control_Character_String_Exception (Object : in out Test);
procedure Test_Unexpected_Escaped_Character_String_Exception (Object : in out Test);
procedure Test_Minus_Number_EOF_Exception (Object : in out Test);
procedure Test_Minus_Number_Exception (Object : in out Test);
procedure Test_End_Dot_Number_Exception (Object : in out Test);
procedure Test_End_Exponent_Number_Exception (Object : in out Test);
procedure Test_End_Dot_Exponent_Number_Exception (Object : in out Test);
procedure Test_End_Exponent_Minus_Number_Exception (Object : in out Test);
procedure Test_End_Exponent_One_Digit_Exception (Object : in out Test);
procedure Test_End_Exponent_Minus_One_Digit_Exception (Object : in out Test);
procedure Test_Prefixed_Plus_Number_Exception (Object : in out Test);
procedure Test_Leading_Zeroes_Integer_Number_Exception (Object : in out Test);
procedure Test_Leading_Zeroes_Float_Number_Exception (Object : in out Test);
procedure Test_Incomplete_True_Text_Exception (Object : in out Test);
procedure Test_Incomplete_False_Text_Exception (Object : in out Test);
procedure Test_Incomplete_Null_Text_Exception (Object : in out Test);
procedure Test_Unknown_Keyword_Text_Exception (Object : in out Test);
end Test_Tokenizers;
|
with Interfaces.C_Streams;
with Simple_Logging; use Simple_Logging;
with Simple_Logging.Decorators;
package body CLIC.TTY is
use all type ANSI.Colors;
use all type ANSI.Styles;
Use_Color : Boolean := False; -- Err on the safe side
function Regular_Decorator (Level : Simple_Logging.Levels;
Message : String) return String;
function Verbose_Decorator (Level : Simple_Logging.Levels;
Message : String) return String;
Disabled_By_User : Boolean := False;
-----------------------
-- Force_Disable_TTY --
-----------------------
procedure Force_Disable_TTY is
begin
Disabled_By_User := True;
end Force_Disable_TTY;
---------------
-- Check_TTY --
---------------
function Check_TTY return Boolean is
use Interfaces.C_Streams;
begin
return isatty (fileno (stdout)) /= 0;
end Check_TTY;
------------
-- Is_TTY --
------------
function Is_TTY return Boolean
is (if Disabled_By_User then False else Check_TTY);
-------------------
-- Color_Enabled --
-------------------
function Color_Enabled return Boolean is (Use_Color);
-------------------
-- Disable_Color --
-------------------
procedure Disable_Color is
begin
Use_Color := False;
end Disable_Color;
------------------
-- Enable_Color --
------------------
procedure Enable_Color (Force : Boolean := False) is
begin
-- Enable when appropriate
if Force or else Is_TTY then
Use_Color := True;
Simple_Logging.Debug ("Color output enabled");
else
Simple_Logging.Debug ("Color output was requested but not enabled:"
& " force=" & Force'Img
& "; Is_TTY=" & Is_TTY'Img);
end if;
-- Set debug colors. When Detail/Debug are also enabled, we add the
-- "info:" prefix to otherwise normal output, so it's seen more easily.
if Use_Color then
case Simple_Logging.Level is
when Always .. Info =>
Decorators.Level_Decorator :=
Regular_Decorator'Access;
when others =>
Decorators.Level_Decorator :=
Verbose_Decorator'Access;
end case;
end if;
end Enable_Color;
------------
-- Format --
------------
function Format (Text : String;
Fore : ANSI.Colors := ANSI.Default;
Back : ANSI.Colors := ANSI.Default;
Style : ANSI.Styles := ANSI.Default)
return String
is
use ANSI;
begin
if not Use_Color then
return Text;
end if;
return
((if Fore /= Default then Foreground (Fore) else "")
& (if Back /= Default then Background (Fore) else "")
& (if Style /= Default then ANSI.Style (Style, On) else "")
& Text
& (if Fore /= Default then Foreground (Default) else "")
& (if Back /= Default then Background (Default) else "")
& (if Style /= Default then ANSI.Style (Style, Off) else ""));
end Format;
-----------------------
-- Regular_Decorator --
-----------------------
function Regular_Decorator (Level : Simple_Logging.Levels;
Message : String) return String is
(case Level is
when Info => Message,
when others => Verbose_Decorator (Level, Message));
-----------------------
-- Verbose_Decorator --
-----------------------
function Verbose_Decorator (Level : Simple_Logging.Levels;
Message : String) return String
is
use ANSI;
begin
return
(case Level is
when Always => Message,
when Error =>
ANSI.Wrap (Text => "error:",
Style => Bright,
Foreground => ANSI.Foreground (Red)) & " " & Message,
when Warning =>
ANSI.Wrap (Text => "warn:",
Style => Bright,
Foreground => ANSI.Foreground (Yellow)) & " " & Message,
when Info =>
ANSI.Wrap (Text => "info:",
Style => Bright,
Foreground => ANSI.Foreground (Green)) & " " & Message,
when Detail =>
ANSI.Wrap (Text => "detail:",
Style => Bright,
Foreground => ANSI.Foreground (Cyan)) & " " & Message,
when Debug =>
ANSI.Wrap (Text => "debug:",
Style => Default,
Foreground => ANSI.Foreground (Grey)) & " "
& ANSI.Wrap (Text => Message,
Style => Dim));
end Verbose_Decorator;
end CLIC.TTY;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T S Y M --
-- --
-- B o d y --
-- --
-- Copyright (C) 2003-2005, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This utility application creates symbol files in a format that is
-- platform-dependent.
-- A symbol file is a text file that lists the symbols to be exported from
-- a shared library. The format of a symbol file depends on the platform;
-- it may be a simple enumeration of the symbol (one per line) or a more
-- elaborate format (on VMS, for example). A symbol file may be used as an
-- input to the platform linker when building a shared library.
-- This utility is not available on all platforms. It is currently supported
-- only on OpenVMS.
-- gnatsym takes as parameters:
-- - the name of the symbol file to create
-- - (optional) the policy to create the symbol file
-- - (optional) the name of the reference symbol file
-- - the names of one or more object files where the symbols are found
with GNAT.Command_Line; use GNAT.Command_Line;
with GNAT.OS_Lib; use GNAT.OS_Lib;
with Gnatvsn; use Gnatvsn;
with Osint; use Osint;
with Output; use Output;
with Symbols; use Symbols;
with Table;
procedure Gnatsym is
Empty_String : aliased String := "";
Empty : constant String_Access := Empty_String'Unchecked_Access;
-- To initialize variables Reference and Version_String
Copyright_Displayed : Boolean := False;
-- A flag to prevent multiple display of the Copyright notice
Success : Boolean := True;
Symbol_Policy : Policy := Autonomous;
Verbose : Boolean := False;
-- True when -v switch is used
Quiet : Boolean := False;
-- True when -q switch is used
Symbol_File_Name : String_Access := null;
-- The name of the symbol file
Reference_Symbol_File_Name : String_Access := Empty;
-- The name of the reference symbol file
Version_String : String_Access := Empty;
-- The version of the library (used on VMS)
package Object_Files is new Table.Table
(Table_Component_Type => String_Access,
Table_Index_Type => Natural,
Table_Low_Bound => 0,
Table_Initial => 10,
Table_Increment => 10,
Table_Name => "Gnatsymb.Object_Files");
-- A table to store the object file names
Object_File : Natural := 0;
-- An index to traverse the Object_Files table
procedure Display_Copyright;
-- Display Copyright notice
procedure Parse_Cmd_Line;
-- Parse the command line switches and file names
procedure Usage;
-- Display the usage
-----------------------
-- Display_Copyright --
-----------------------
procedure Display_Copyright is
begin
if not Copyright_Displayed then
Write_Eol;
Write_Str ("GNATSYMB ");
Write_Str (Gnat_Version_String);
Write_Eol;
Write_Str ("Copyright 2003-2004 Free Software Foundation, Inc");
Write_Eol;
Copyright_Displayed := True;
end if;
end Display_Copyright;
--------------------
-- Parse_Cmd_Line --
--------------------
procedure Parse_Cmd_Line is
begin
loop
case GNAT.Command_Line.Getopt ("c C q r: R s: v V:") is
when ASCII.NUL =>
exit;
when 'c' =>
Symbol_Policy := Compliant;
when 'C' =>
Symbol_Policy := Controlled;
when 'q' =>
Quiet := True;
when 'r' =>
Reference_Symbol_File_Name :=
new String'(GNAT.Command_Line.Parameter);
when 'R' =>
Symbol_Policy := Restricted;
when 's' =>
Symbol_File_Name := new String'(GNAT.Command_Line.Parameter);
when 'v' =>
Verbose := True;
when 'V' =>
Version_String := new String'(GNAT.Command_Line.Parameter);
when others =>
Fail ("invalid switch: ", Full_Switch);
end case;
end loop;
-- Get the file names
loop
declare
S : constant String_Access :=
new String'(GNAT.Command_Line.Get_Argument);
begin
exit when S'Length = 0;
Object_Files.Increment_Last;
Object_Files.Table (Object_Files.Last) := S;
end;
end loop;
exception
when Invalid_Switch =>
Usage;
Fail ("invalid switch : ", Full_Switch);
end Parse_Cmd_Line;
-----------
-- Usage --
-----------
procedure Usage is
begin
Write_Line ("gnatsym [options] object_file {object_file}");
Write_Eol;
Write_Line (" -c Compliant symbol policy");
Write_Line (" -C Controlled symbol policy");
Write_Line (" -q Quiet mode");
Write_Line (" -r<ref> Reference symbol file name");
Write_Line (" -R Restricted symbol policy");
Write_Line (" -s<sym> Symbol file name");
Write_Line (" -v Verbose mode");
Write_Line (" -V<ver> Version");
Write_Eol;
Write_Line ("Specifying a symbol file with -s<sym> is compulsory");
Write_Eol;
end Usage;
-- Start of processing of Gnatsym
begin
-- Initialize Object_Files table
Object_Files.Set_Last (0);
-- Parse the command line
Parse_Cmd_Line;
if Verbose then
Display_Copyright;
end if;
-- If there is no symbol file or no object files on the command line,
-- display the usage and exit with an error status.
if Symbol_File_Name = null or else Object_Files.Last = 0 then
Usage;
OS_Exit (1);
else
if Verbose then
Write_Str ("Initializing symbol file """);
Write_Str (Symbol_File_Name.all);
Write_Line ("""");
end if;
-- Initialize symbol file and, if specified, read reference file
Symbols.Initialize
(Symbol_File => Symbol_File_Name.all,
Reference => Reference_Symbol_File_Name.all,
Symbol_Policy => Symbol_Policy,
Quiet => Quiet,
Version => Version_String.all,
Success => Success);
-- Process the object files in order. Stop as soon as there is
-- something wrong.
Object_File := 0;
while Success and then Object_File < Object_Files.Last loop
Object_File := Object_File + 1;
if Verbose then
Write_Str ("Processing object file """);
Write_Str (Object_Files.Table (Object_File).all);
Write_Line ("""");
end if;
Processing.Process (Object_Files.Table (Object_File).all, Success);
end loop;
-- Finalize the object file
if Success then
if Verbose then
Write_Str ("Finalizing """);
Write_Str (Symbol_File_Name.all);
Write_Line ("""");
end if;
Finalize (Quiet, Success);
end if;
-- Fail if there was anything wrong
if not Success then
Fail ("unable to build symbol file");
end if;
end if;
end Gnatsym;
|
with Ada.Text_IO;
with Ada.Exceptions;
with Text_IO; -- Old style
with Vole_Tokens;
with Vole_Goto;
with Vole_Shift_Reduce;
with vole_lex_dfa;
with kv.avm.Vole_Lex;
with kv.avm.Vole_Tree;
with kv.avm.Instructions;
with kv.avm.Registers;
use Ada.Text_IO;
use Ada.Exceptions;
use Text_IO; -- Old style
use Vole_Tokens;
use Vole_Goto;
use Vole_Shift_Reduce;
use vole_lex_dfa;
use kv.avm.Vole_Lex;
use kv.avm.Vole_Tree;
use kv.avm.Instructions;
use kv.avm.Registers;
package body kv.avm.vole_parser is
procedure YYError(Text : in String) is
begin
New_Line;
Put_Line("PARSE ERROR on line"&Positive'IMAGE(kv.avm.Vole_Lex.Line_Number)&" parsing '"&vole_lex_dfa.yytext&"'");
end YYError;
procedure YYParse is
-- Rename User Defined Packages to Internal Names.
package yy_goto_tables renames
Vole_Goto;
package yy_shift_reduce_tables renames
Vole_Shift_Reduce;
package yy_tokens renames
Vole_Tokens;
use yy_tokens, yy_goto_tables, yy_shift_reduce_tables;
procedure yyerrok;
procedure yyclearin;
package yy is
-- the size of the value and state stacks
stack_size : constant Natural := 300;
-- subtype rule is natural;
subtype parse_state is natural;
-- subtype nonterminal is integer;
-- encryption constants
default : constant := -1;
first_shift_entry : constant := 0;
accept_code : constant := -3001;
error_code : constant := -3000;
-- stack data used by the parser
tos : natural := 0;
value_stack : array(0..stack_size) of yy_tokens.yystype;
state_stack : array(0..stack_size) of parse_state;
-- current input symbol and action the parser is on
action : integer;
rule_id : rule;
input_symbol : yy_tokens.token;
-- error recovery flag
error_flag : natural := 0;
-- indicates 3 - (number of valid shifts after an error occurs)
look_ahead : boolean := true;
index : integer;
-- Is Debugging option on or off
DEBUG : boolean renames Verbose;
end yy;
function goto_state
(state : yy.parse_state;
sym : nonterminal) return yy.parse_state;
function parse_action
(state : yy.parse_state;
t : yy_tokens.token) return integer;
pragma inline(goto_state, parse_action);
function goto_state(state : yy.parse_state;
sym : nonterminal) return yy.parse_state is
index : integer;
begin
index := goto_offset(state);
while integer(goto_matrix(index).nonterm) /= sym loop
index := index + 1;
end loop;
return integer(goto_matrix(index).newstate);
end goto_state;
function parse_action(state : yy.parse_state;
t : yy_tokens.token) return integer is
index : integer;
tok_pos : integer;
default : constant integer := -1;
begin
tok_pos := yy_tokens.token'pos(t);
index := shift_reduce_offset(state);
while integer(shift_reduce_matrix(index).t) /= tok_pos and then
integer(shift_reduce_matrix(index).t) /= default
loop
index := index + 1;
end loop;
return integer(shift_reduce_matrix(index).act);
end parse_action;
-- error recovery stuff
procedure handle_error is
temp_action : integer;
begin
if yy.error_flag = 3 then -- no shift yet, clobber input.
if yy.debug then
text_io.put_line("Ayacc.YYParse: Error Recovery Clobbers " &
yy_tokens.token'image(yy.input_symbol));
end if;
if yy.input_symbol = yy_tokens.end_of_input then -- don't discard,
if yy.debug then
text_io.put_line("Ayacc.YYParse: Can't discard END_OF_INPUT, quiting...");
end if;
raise yy_tokens.syntax_error;
end if;
yy.look_ahead := true; -- get next token
return; -- and try again...
end if;
if yy.error_flag = 0 then -- brand new error
yyerror("Syntax Error");
end if;
yy.error_flag := 3;
-- find state on stack where error is a valid shift --
if yy.debug then
text_io.put_line("Ayacc.YYParse: Looking for state with error as valid shift");
end if;
loop
if yy.debug then
text_io.put_line("Ayacc.YYParse: Examining State " &
yy.parse_state'image(yy.state_stack(yy.tos)));
end if;
temp_action := parse_action(yy.state_stack(yy.tos), error);
if temp_action >= yy.first_shift_entry then
if yy.tos = yy.stack_size then
text_io.put_line(" Stack size exceeded on state_stack");
raise yy_Tokens.syntax_error;
end if;
yy.tos := yy.tos + 1;
yy.state_stack(yy.tos) := temp_action;
exit;
end if;
Decrement_Stack_Pointer :
begin
yy.tos := yy.tos - 1;
exception
when Constraint_Error =>
yy.tos := 0;
end Decrement_Stack_Pointer;
if yy.tos = 0 then
if yy.debug then
text_io.put_line("Ayacc.YYParse: Error recovery popped entire stack, aborting...");
end if;
raise yy_tokens.syntax_error;
end if;
end loop;
if yy.debug then
text_io.put_line("Ayacc.YYParse: Shifted error token in state " &
yy.parse_state'image(yy.state_stack(yy.tos)));
end if;
end handle_error;
-- print debugging information for a shift operation
procedure shift_debug(state_id: yy.parse_state; lexeme: yy_tokens.token) is
begin
text_io.put_line("Ayacc.YYParse: Shift "& yy.parse_state'image(state_id)&" on input symbol "&
yy_tokens.token'image(lexeme) );
end;
-- print debugging information for a reduce operation
procedure reduce_debug(rule_id: rule; state_id: yy.parse_state) is
begin
text_io.put_line("Ayacc.YYParse: Reduce by rule "&rule'image(rule_id)&" goto state "&
yy.parse_state'image(state_id));
end;
-- make the parser believe that 3 valid shifts have occured.
-- used for error recovery.
procedure yyerrok is
begin
yy.error_flag := 0;
end yyerrok;
-- called to clear input symbol that caused an error.
procedure yyclearin is
begin
-- yy.input_symbol := yylex;
yy.look_ahead := true;
end yyclearin;
begin
-- initialize by pushing state 0 and getting the first input symbol
yy.state_stack(yy.tos) := 0;
loop
yy.index := shift_reduce_offset(yy.state_stack(yy.tos));
if integer(shift_reduce_matrix(yy.index).t) = yy.default then
yy.action := integer(shift_reduce_matrix(yy.index).act);
else
if yy.look_ahead then
yy.look_ahead := false;
yy.input_symbol := yylex;
end if;
yy.action :=
parse_action(yy.state_stack(yy.tos), yy.input_symbol);
end if;
if yy.action >= yy.first_shift_entry then -- SHIFT
if yy.debug then
shift_debug(yy.action, yy.input_symbol);
end if;
-- Enter new state
if yy.tos = yy.stack_size then
text_io.put_line(" Stack size exceeded on state_stack");
raise yy_Tokens.syntax_error;
end if;
yy.tos := yy.tos + 1;
yy.state_stack(yy.tos) := yy.action;
yy.value_stack(yy.tos) := yylval;
if yy.error_flag > 0 then -- indicate a valid shift
yy.error_flag := yy.error_flag - 1;
end if;
-- Advance lookahead
yy.look_ahead := true;
elsif yy.action = yy.error_code then -- ERROR
handle_error;
elsif yy.action = yy.accept_code then
if yy.debug then
text_io.put_line("Ayacc.YYParse: Accepting Grammar...");
end if;
exit;
else -- Reduce Action
-- Convert action into a rule
yy.rule_id := -1 * yy.action;
-- Execute User Action
-- user_action(yy.rule_id);
case yy.rule_id is
when 1 =>
--#line 64
Build_Program(
yyval.Node, Line_Number,
yy.value_stack(yy.tos-1).Node,
yy.value_stack(yy.tos).Node);
Save_Program(
yyval.Node);
when 4 =>
--#line 76
Put_Line("unimp 01");
when 5 =>
--#line 80
Put_Line("unimp 02");
when 6 =>
--#line 84
Put_Line("unimp 03");
when 7 =>
--#line 89
yyval.Node :=
yy.value_stack(yy.tos-2).Node; -- Copy up
yy.value_stack(yy.tos-2).Node := null; -- Only keep one reference to this node.
Add_Next(
yyval.Node,
yy.value_stack(yy.tos).Node);
when 8 =>
--#line 97
yyval.Node := null;
when 9 =>
--#line 98
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 10 =>
--#line 103
Build_Actor_Node(
yyval.Node, Line_Number,
yy.value_stack(yy.tos-4).Node,
yy.value_stack(yy.tos-2).Node,
yy.value_stack(yy.tos-1).Node);
when 11 =>
--#line 105
Build_Actor_Node(
yyval.Node, Line_Number,
yy.value_stack(yy.tos-6).Node,
yy.value_stack(yy.tos-2).Node,
yy.value_stack(yy.tos-1).Node,
yy.value_stack(yy.tos-4).Node);
when 12 =>
--#line 109
yyval.Node := null;
when 13 =>
--#line 110
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 14 =>
--#line 115
yyval.Node :=
yy.value_stack(yy.tos-1).Node; -- Copy up
yy.value_stack(yy.tos-1).Node := null; -- Only keep one reference to this node.
Add_Next(
yyval.Node,
yy.value_stack(yy.tos).Node);
when 15 =>
--#line 123
Build_Attribute(
yyval.Node, Line_Number,
yy.value_stack(yy.tos-3).Node,
yy.value_stack(yy.tos-1).Node);
when 16 =>
--#line 124
Build_Attribute(
yyval.Node, Line_Number,
yy.value_stack(yy.tos-1).Node,
yy.value_stack(yy.tos).Node);
when 17 =>
--#line 128
Build_Kind(
yyval.Node, Line_Number, Bit_Or_Boolean);
when 18 =>
--#line 129
Build_Kind(
yyval.Node, Line_Number, Bit_Or_Boolean,
yy.value_stack(yy.tos-1).Node);
when 19 =>
--#line 133
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 20 =>
--#line 134
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 21 =>
--#line 135
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 22 =>
--#line 136
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 23 =>
--#line 137
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 24 =>
--#line 138
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 25 =>
--#line 139
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 26 =>
--#line 144
Build_Kind(
yyval.Node, Line_Number, Signed_Integer);
when 27 =>
--#line 146
Build_Kind(
yyval.Node, Line_Number, Signed_Integer,
yy.value_stack(yy.tos).Node);
when 28 =>
--#line 151
Build_Kind(
yyval.Node, Line_Number, Unsigned_Integer);
when 29 =>
--#line 153
Build_Kind(
yyval.Node, Line_Number, Unsigned_Integer,
yy.value_stack(yy.tos).Node);
when 30 =>
--#line 157
Put_Line("unimp 06");
when 31 =>
--#line 158
Put_Line("unimp 07");
when 32 =>
--#line 162
Put_Line("unimp 08");
when 33 =>
--#line 163
Build_Kind(
yyval.Node, Line_Number, Immutable_String,
yy.value_stack(yy.tos).Node);
when 34 =>
--#line 168
Build_Kind(
yyval.Node, Line_Number, Actor_Definition);
when 35 =>
--#line 170
Build_Kind(
yyval.Node, Line_Number, Actor_Definition,
yy.value_stack(yy.tos).Node);
when 36 =>
--#line 172
Build_Kind(
yyval.Node, Line_Number, Actor_Definition, New_Constructor_Send(
yy.value_stack(yy.tos-1).Node,
yy.value_stack(yy.tos).Node));
when 37 =>
--#line 176
Put_Line("unimp 10");
when 38 =>
--#line 177
Put_Line("unimp 11");
when 39 =>
--#line 182
Build_Kind(
yyval.Node, Line_Number, Bit_Or_Boolean);
when 40 =>
--#line 184
Build_Kind(
yyval.Node, Line_Number, Bit_Or_Boolean,
yy.value_stack(yy.tos).Node);
when 41 =>
--#line 190
Build_Kind(
yyval.Node, Line_Number, Signed_Integer);
when 42 =>
--#line 192
Build_Kind(
yyval.Node, Line_Number, Unsigned_Integer);
when 43 =>
--#line 194
Build_Kind(
yyval.Node, Line_Number, Floatingpoint);
when 44 =>
--#line 196
Build_Kind(
yyval.Node, Line_Number, Actor_Definition);
when 45 =>
--#line 198
Build_Kind(
yyval.Node, Line_Number, Tuple);
when 46 =>
--#line 200
Build_Kind(
yyval.Node, Line_Number, Immutable_String);
when 47 =>
--#line 205
yyval.Node :=
yy.value_stack(yy.tos-2).Node; -- Copy up
yy.value_stack(yy.tos-2).Node := null; -- Only keep one reference to this node.
Add_Next(
yyval.Node,
yy.value_stack(yy.tos).Node);
when 48 =>
--#line 213
yyval.Node := null;
when 49 =>
--#line 214
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 50 =>
--#line 219
Build_Message(
yyval.Node, Line_Number, True,
yy.value_stack(yy.tos-4).Node,
yy.value_stack(yy.tos-3).Node,
yy.value_stack(yy.tos-1).Node,
yy.value_stack(yy.tos).Node, null);
when 51 =>
--#line 221
Build_Message(
yyval.Node, Line_Number, True,
yy.value_stack(yy.tos-4).Node,
yy.value_stack(yy.tos-3).Node,
yy.value_stack(yy.tos-1).Node,
yy.value_stack(yy.tos).Node,
yy.value_stack(yy.tos-6).Node);
when 52 =>
--#line 223
Build_Message(
yyval.Node, Line_Number, False,
yy.value_stack(yy.tos-4).Node,
yy.value_stack(yy.tos-3).Node,
yy.value_stack(yy.tos-1).Node,
yy.value_stack(yy.tos).Node, null);
when 53 =>
--#line 225
Build_Constructor(
yyval.Node, Line_Number,
yy.value_stack(yy.tos-1).Node,
yy.value_stack(yy.tos).Node);
when 54 =>
--#line 230
yyval.Node :=
yy.value_stack(yy.tos-1).Node;
when 55 =>
--#line 234
yyval.Node := null;
when 56 =>
--#line 235
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 57 =>
--#line 240
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 58 =>
--#line 242
yyval.Node :=
yy.value_stack(yy.tos-2).Node; -- Copy up
yy.value_stack(yy.tos-2).Node := null; -- Only keep one reference to this node.
Add_Next(
yyval.Node,
yy.value_stack(yy.tos).Node);
when 59 =>
--#line 251
Build_Arg(
yyval.Node, Line_Number,
yy.value_stack(yy.tos-2).Node,
yy.value_stack(yy.tos).Node);
when 60 =>
--#line 256
Build_Id_Node(
yyval.Node, Line_Number, yytext);
when 61 =>
--#line 260
yyval.Node :=
yy.value_stack(yy.tos-1).Node;
when 62 =>
--#line 264
yyval.Node := null;
when 63 =>
--#line 265
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 64 =>
--#line 270
yyval.Node :=
yy.value_stack(yy.tos-2).Node; -- Copy up
yy.value_stack(yy.tos-2).Node := null; -- Only keep one reference to this node.
Add_Next(
yyval.Node,
yy.value_stack(yy.tos).Node);
when 65 =>
--#line 278
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 66 =>
--#line 279
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 67 =>
--#line 280
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 68 =>
--#line 281
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 69 =>
--#line 282
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 70 =>
--#line 283
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 71 =>
--#line 284
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 72 =>
--#line 285
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 73 =>
--#line 289
Build_While(
yyval.Node, Line_Number,
yy.value_stack(yy.tos-2).Node,
yy.value_stack(yy.tos).Node);
when 74 =>
--#line 290
Build_While(
yyval.Node, Line_Number, null,
yy.value_stack(yy.tos).Node);
when 75 =>
--#line 294
Build_Assert(
yyval.Node, Line_Number,
yy.value_stack(yy.tos).Node);
when 76 =>
--#line 298
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 77 =>
--#line 302
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 78 =>
--#line 303
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 79 =>
--#line 307
Build_If(
yyval.Node, Line_Number,
yy.value_stack(yy.tos-4).Node,
yy.value_stack(yy.tos-1).Node,
yy.value_stack(yy.tos).Node);
when 80 =>
--#line 311
yyval.Node := null;
when 81 =>
--#line 312
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 82 =>
--#line 313
Build_If(
yyval.Node, Line_Number,
yy.value_stack(yy.tos-5).Node,
yy.value_stack(yy.tos-2).Node,
yy.value_stack(yy.tos-1).Node);
when 83 =>
--#line 317
Build_Return(
yyval.Node, Line_Number,
yy.value_stack(yy.tos).Node);
when 84 =>
--#line 321
yyval.Node := null;
when 85 =>
--#line 322
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 86 =>
--#line 323
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 87 =>
--#line 324
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 88 =>
--#line 325
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 89 =>
--#line 326
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 90 =>
--#line 331
yyval.Node :=
yy.value_stack(yy.tos-1).Node;
when 91 =>
--#line 335
Put_Line("unimp 30");
when 92 =>
--#line 340
Put_Line("unimp 29");
when 93 =>
--#line 344
Build_Send_Statement(
yyval.Node, Line_Number, Self, null,
yy.value_stack(yy.tos-1).Node,
yy.value_stack(yy.tos).Node);
when 94 =>
--#line 348
Build_Send_Statement(
yyval.Node, Line_Number, Actor,
yy.value_stack(yy.tos-3).Node,
yy.value_stack(yy.tos-1).Node,
yy.value_stack(yy.tos).Node);
when 95 =>
--#line 352
Build_Call_Statement(
yyval.Node, Line_Number, Self, null,
yy.value_stack(yy.tos-1).Node,
yy.value_stack(yy.tos).Node);
when 96 =>
--#line 356
Build_Call_Statement(
yyval.Node, Line_Number, Super, null,
yy.value_stack(yy.tos-1).Node,
yy.value_stack(yy.tos).Node);
when 97 =>
--#line 360
Build_Call_Statement(
yyval.Node, Line_Number, Actor,
yy.value_stack(yy.tos-3).Node,
yy.value_stack(yy.tos-1).Node,
yy.value_stack(yy.tos).Node);
when 98 =>
--#line 364
Build_Assignment(
yyval.Node, Line_Number,
yy.value_stack(yy.tos-2).Node,
yy.value_stack(yy.tos).Node);
when 99 =>
--#line 365
Raise_Exception(Unimplemented_Error'IDENTITY, "Rule statement_assign (tuple)");
when 100 =>
--#line 369
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 101 =>
--#line 370
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 102 =>
--#line 371
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 103 =>
--#line 372
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 104 =>
--#line 376
Build_Op_Expression(
yyval.Node, Line_Number, Op_Pos, null,
yy.value_stack(yy.tos).Node);
when 105 =>
--#line 380
Build_Kind(
yyval.Node, Line_Number, Actor_Definition, New_Constructor_Send(
yy.value_stack(yy.tos-1).Node,
yy.value_stack(yy.tos).Node));
when 106 =>
--#line 385
Build_Var_Expression(
yyval.Node, Line_Number, True,
yy.value_stack(yy.tos).Node);
when 107 =>
--#line 387
Build_Var_Expression(
yyval.Node, Line_Number, False,
yy.value_stack(yy.tos).Node);
when 108 =>
--#line 391
Put_Line("unimp 35");
when 109 =>
--#line 392
Put_Line("unimp 36");
when 110 =>
--#line 393
Put_Line("unimp 37");
when 111 =>
--#line 394
Put_Line("unimp 38");
when 112 =>
--#line 398
yyval.Node := null;
when 113 =>
--#line 400
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 114 =>
--#line 405
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 115 =>
--#line 407
yyval.Node :=
yy.value_stack(yy.tos-2).Node; -- Copy up
yy.value_stack(yy.tos-2).Node := null; -- Only keep one reference to this node.
Add_Next(
yyval.Node,
yy.value_stack(yy.tos).Node);
when 116 =>
--#line 415
Build_Op_Expression(
yyval.Node, Line_Number, Add,
yy.value_stack(yy.tos-2).Node,
yy.value_stack(yy.tos).Node);
when 117 =>
--#line 416
Build_Op_Expression(
yyval.Node, Line_Number, Sub,
yy.value_stack(yy.tos-2).Node,
yy.value_stack(yy.tos).Node);
when 118 =>
--#line 417
Build_Op_Expression(
yyval.Node, Line_Number, Mul,
yy.value_stack(yy.tos-2).Node,
yy.value_stack(yy.tos).Node);
when 119 =>
--#line 418
Build_Op_Expression(
yyval.Node, Line_Number, Div,
yy.value_stack(yy.tos-2).Node,
yy.value_stack(yy.tos).Node);
when 120 =>
--#line 419
Build_Op_Expression(
yyval.Node, Line_Number, Modulo,
yy.value_stack(yy.tos-2).Node,
yy.value_stack(yy.tos).Node);
when 121 =>
--#line 420
Build_Op_Expression(
yyval.Node, Line_Number, Exp,
yy.value_stack(yy.tos-2).Node,
yy.value_stack(yy.tos).Node);
when 122 =>
--#line 421
Build_Op_Expression(
yyval.Node, Line_Number, Eq,
yy.value_stack(yy.tos-2).Node,
yy.value_stack(yy.tos).Node);
when 123 =>
--#line 422
Build_Op_Expression(
yyval.Node, Line_Number, Neq,
yy.value_stack(yy.tos-2).Node,
yy.value_stack(yy.tos).Node);
when 124 =>
--#line 423
Build_Op_Expression(
yyval.Node, Line_Number, L_t,
yy.value_stack(yy.tos-2).Node,
yy.value_stack(yy.tos).Node);
when 125 =>
--#line 424
Build_Op_Expression(
yyval.Node, Line_Number, Lte,
yy.value_stack(yy.tos-2).Node,
yy.value_stack(yy.tos).Node);
when 126 =>
--#line 425
Build_Op_Expression(
yyval.Node, Line_Number, G_t,
yy.value_stack(yy.tos-2).Node,
yy.value_stack(yy.tos).Node);
when 127 =>
--#line 426
Build_Op_Expression(
yyval.Node, Line_Number, Gte,
yy.value_stack(yy.tos-2).Node,
yy.value_stack(yy.tos).Node);
when 128 =>
--#line 427
Build_Op_Expression(
yyval.Node, Line_Number, Shift_Left,
yy.value_stack(yy.tos-2).Node,
yy.value_stack(yy.tos).Node);
when 129 =>
--#line 428
Build_Op_Expression(
yyval.Node, Line_Number, Shift_Right,
yy.value_stack(yy.tos-2).Node,
yy.value_stack(yy.tos).Node);
when 130 =>
--#line 429
Build_Op_Expression(
yyval.Node, Line_Number, B_And,
yy.value_stack(yy.tos-2).Node,
yy.value_stack(yy.tos).Node);
when 131 =>
--#line 430
Build_Op_Expression(
yyval.Node, Line_Number, B_Or ,
yy.value_stack(yy.tos-2).Node,
yy.value_stack(yy.tos).Node);
when 132 =>
--#line 431
Build_Op_Expression(
yyval.Node, Line_Number, B_Xor,
yy.value_stack(yy.tos-2).Node,
yy.value_stack(yy.tos).Node);
when 133 =>
--#line 432
yyval.Node :=
yy.value_stack(yy.tos-1).Node;
when 134 =>
--#line 433
Build_Op_Expression(
yyval.Node, Line_Number, Negate,
yy.value_stack(yy.tos).Node);
when 135 =>
--#line 434
Build_Op_Expression(
yyval.Node, Line_Number, Op_Neg,
yy.value_stack(yy.tos).Node);
when 136 =>
--#line 435
Build_Op_Expression(
yyval.Node, Line_Number, Op_Pos,
yy.value_stack(yy.tos).Node);
when 137 =>
--#line 436
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 138 =>
--#line 437
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 139 =>
--#line 441
Build_Literal_Expression(
yyval.Node, Line_Number, Signed_Integer, yytext);
when 140 =>
--#line 442
Build_Literal_Expression(
yyval.Node, Line_Number, Floatingpoint, yytext);
when 141 =>
--#line 443
Build_Literal_Expression(
yyval.Node, Line_Number, Immutable_String, yytext);
when 142 =>
--#line 444
yyval.Node :=
yy.value_stack(yy.tos).Node;
when 143 =>
--#line 448
Build_Literal_Expression(
yyval.Node, Line_Number, Bit_Or_Boolean, yytext);
when 144 =>
--#line 449
Build_Literal_Expression(
yyval.Node, Line_Number, Bit_Or_Boolean, yytext);
when 145 =>
--#line 454
Build_Var_Def(
yyval.Node, Line_Number,
yy.value_stack(yy.tos-2).Node,
yy.value_stack(yy.tos).Node);
when 146 =>
--#line 458
Build_Emit(
yyval.Node, Line_Number,
yy.value_stack(yy.tos).Node);
when others => null;
end case;
-- Pop RHS states and goto next state
yy.tos := yy.tos - rule_length(yy.rule_id) + 1;
if yy.tos > yy.stack_size then
text_io.put_line(" Stack size exceeded on state_stack");
raise yy_Tokens.syntax_error;
end if;
yy.state_stack(yy.tos) := goto_state(yy.state_stack(yy.tos-1) ,
get_lhs_rule(yy.rule_id));
yy.value_stack(yy.tos) := yyval;
if yy.debug then
reduce_debug(yy.rule_id,
goto_state(yy.state_stack(yy.tos - 1),
get_lhs_rule(yy.rule_id)));
end if;
end if;
end loop;
end yyparse;
end kv.avm.vole_parser;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2015, 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$
------------------------------------------------------------------------------
pragma Restrictions (No_Elaboration_Code);
-- GNAT: enforce generation of preinitialized data section instead of
-- generation of elaboration code.
package Matreshka.Internals.Unicode.Ucd.Core_00D8 is
pragma Preelaborate;
Group_00D8 : aliased constant Core_Second_Stage
:= (others =>
(Surrogate, Neutral,
Control, Other, Other, Surrogate,
(others => False)));
end Matreshka.Internals.Unicode.Ucd.Core_00D8;
|
-----------------------------------------------------------------------
-- awa-storages-services-tests -- Unit tests for storage service
-- Copyright (C) 2012 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.Streams;
with Ada.Strings.Unbounded;
with Util.Test_Caller;
with ADO;
with ADO.Objects;
with Security.Contexts;
with AWA.Services.Contexts;
with AWA.Storages.Modules;
with AWA.Storages.Beans.Factories;
with AWA.Tests.Helpers.Users;
package body AWA.Storages.Services.Tests is
use Util.Tests;
use ADO;
package Caller is new Util.Test_Caller (Test, "Storages.Services");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test AWA.Storages.Services.Save (DATABASE)",
Test_Create_Storage'Access);
Caller.Add_Test (Suite, "Test AWA.Storages.Services.Save (FILE)",
Test_File_Create_Storage'Access);
Caller.Add_Test (Suite, "Test AWA.Storages.Services.Delete",
Test_Delete_Storage'Access);
Caller.Add_Test (Suite, "Test AWA.Storages.Services.Save_Folder, Folder_Bean",
Test_Create_Folder'Access);
Caller.Add_Test (Suite, "Test AWA.Storages.Services.Get_Local_File",
Test_Get_Local_File'Access);
end Add_Tests;
-- ------------------------------
-- Save something in a storage element and keep track of the store id in the test <b>Id</b>.
-- ------------------------------
procedure Save (T : in out Test) is
Store : AWA.Storages.Models.Storage_Ref;
begin
T.Manager := AWA.Storages.Modules.Get_Storage_Manager;
T.Assert (T.Manager /= null, "Null storage manager");
Store.Set_Mime_Type ("text/plain");
Store.Set_Name ("Makefile");
Store.Set_File_Size (1000);
T.Manager.Save (Into => Store,
Path => "Makefile",
Storage => T.Kind);
T.Assert (not Store.Is_Null, "Storage object should not be null");
T.Id := Store.Get_Id;
T.Assert (T.Id > 0, "Invalid storage identifier");
end Save;
-- ------------------------------
-- Load the storage element refered to by the test <b>Id</b>.
-- ------------------------------
procedure Load (T : in out Test) is
use type Ada.Streams.Stream_Element_Offset;
Name : Ada.Strings.Unbounded.Unbounded_String;
Mime : Ada.Strings.Unbounded.Unbounded_String;
Date : Ada.Calendar.Time;
Data : ADO.Blob_Ref;
begin
T.Manager := AWA.Storages.Modules.Get_Storage_Manager;
T.Assert (T.Manager /= null, "Null storage manager");
T.Manager.Load (From => T.Id, Name => Name, Mime => Mime, Date => Date, Into => Data);
T.Assert (not Data.Is_Null, "Null blob returned by load");
T.Assert (Data.Value.Len > 100, "Invalid length for the blob data");
end Load;
-- ------------------------------
-- Test creation of a storage object
-- ------------------------------
procedure Test_Create_Storage (T : in out Test) is
Sec_Ctx : Security.Contexts.Security_Context;
Context : AWA.Services.Contexts.Service_Context;
begin
AWA.Tests.Helpers.Users.Login (Context, Sec_Ctx, "test-storage@test.com");
T.Save;
T.Load;
end Test_Create_Storage;
procedure Test_File_Create_Storage (T : in out Test) is
begin
T.Kind := AWA.Storages.Models.FILE;
T.Test_Create_Storage;
end Test_File_Create_Storage;
-- ------------------------------
-- Test creation of a storage object and local file access after its creation.
-- ------------------------------
procedure Test_Get_Local_File (T : in out Test) is
Sec_Ctx : Security.Contexts.Security_Context;
Context : AWA.Services.Contexts.Service_Context;
begin
AWA.Tests.Helpers.Users.Login (Context, Sec_Ctx, "test-storage@test.com");
T.Save;
declare
File : AWA.Storages.Storage_File;
begin
T.Manager.Get_Local_File (From => T.Id, Into => File);
T.Assert (AWA.Storages.Get_Path (File)'Length > 0, "Invalid local file path");
end;
end Test_Get_Local_File;
-- ------------------------------
-- Test deletion of a storage object
-- ------------------------------
procedure Test_Delete_Storage (T : in out Test) is
Sec_Ctx : Security.Contexts.Security_Context;
Context : AWA.Services.Contexts.Service_Context;
Data : ADO.Blob_Ref;
Name : Ada.Strings.Unbounded.Unbounded_String;
Mime : Ada.Strings.Unbounded.Unbounded_String;
Date : Ada.Calendar.Time;
begin
AWA.Tests.Helpers.Users.Login (Context, Sec_Ctx, "test-storage@test.com");
T.Save;
T.Manager.Delete (T.Id);
begin
T.Manager.Load (From => T.Id, Name => Name, Mime => Mime, Date => Date, Into => Data);
T.Assert (False, "No exception raised");
exception
when ADO.Objects.NOT_FOUND =>
null;
end;
end Test_Delete_Storage;
-- ------------------------------
-- Test creation of a storage folder
-- ------------------------------
procedure Test_Create_Folder (T : in out Test) is
Sec_Ctx : Security.Contexts.Security_Context;
Context : AWA.Services.Contexts.Service_Context;
Folder : AWA.Storages.Beans.Factories.Folder_Bean;
Outcome : Ada.Strings.Unbounded.Unbounded_String;
Upload : AWA.Storages.Beans.Factories.Upload_Bean;
begin
AWA.Tests.Helpers.Users.Login (Context, Sec_Ctx, "test-storage@test.com");
Folder.Module := AWA.Storages.Modules.Get_Storage_Module;
Upload.Module := AWA.Storages.Modules.Get_Storage_Module;
Folder.Set_Name ("Test folder name");
Folder.Save (Outcome);
Util.Tests.Assert_Equals (T, "success", Outcome, "Invalid outcome returned by Save action");
Upload.Set_Value ("folderId", ADO.Objects.To_Object (Folder.Get_Key));
Util.Tests.Assert_Equals (T, "Test folder name", String '(Upload.Get_Folder.Get_Name),
"Invalid folder name");
end Test_Create_Folder;
end AWA.Storages.Services.Tests;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements.Generic_Hash;
function AMF.UML.Data_Types.Hash is
new AMF.Elements.Generic_Hash (UML_Data_Type, UML_Data_Type_Access);
|
-- Abstract :
--
-- see spec.
--
-- Copyright (C) 2017 - 2020 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.
pragma License (GPL);
with Ada.Strings.Fixed;
with Ada.Strings.Unbounded;
with Ada.Text_IO;
with Ada_Process_Actions; -- token_enum_id
package body Wisi.Ada is
use WisiToken;
----------
-- body local subprograms
function Indent_Record
(Data : in out Parse_Data_Type;
Anchor_Token : in Augmented_Token;
Record_Token : in Augmented_Token;
Indenting_Token : in Augmented_Token;
Indenting_Comment : in Boolean;
Offset : in Integer)
return Wisi.Delta_Type
is
use Ada_Process_Actions;
begin
if Anchor_Token.Byte_Region = Null_Buffer_Region or
Record_Token.Byte_Region = Null_Buffer_Region or
Indenting_Token.Byte_Region = Null_Buffer_Region
then
return Null_Delta;
end if;
if not Indenting_Comment and Indenting_Token.ID = +RECORD_ID then
-- Indenting 'record'
return Indent_Anchored_2
(Data, Anchor_Token.Line, Record_Token.Last_Line (Indenting_Comment), Ada_Indent_Record_Rel_Type,
Accumulate => True);
elsif Indenting_Comment and Indenting_Token.ID = +WITH_ID then
-- comment before 'record'. test/ada_mode-nominal-child.ads Child_Type_1
return Indent_Anchored_2
(Data, Anchor_Token.Line, Indenting_Token.Last_Line (Indenting_Comment), Ada_Indent_Record_Rel_Type,
Accumulate => True);
elsif Indenting_Comment and Indenting_Token.ID = +IS_ID then
-- comment after 'is'
if Record_Token.ID = +RECORD_ID then
-- before 'record'. test/ada_mode-nominal.ads Record_Type_1
return Indent_Anchored_2
(Data, Anchor_Token.Line, Indenting_Token.Last_Line (Indenting_Comment), Ada_Indent_Record_Rel_Type,
Accumulate => True);
else
-- not before 'record'. test/ada_mode-nominal-child.ads Child_Type_1
return (Simple, (Int, Offset));
end if;
else
-- Indenting other comment, component or 'end'
--
-- Ensure 'record' line is anchored.
if not (Data.Indents (Record_Token.Line).Label = Anchored or
Data.Indents (Record_Token.Line).Label = Anchor_Anchored)
then
if Anchor_Token.Line /= Record_Token.Line then
-- We don't pass Indenting_Comment here, because 'record' is code.
Indent_Token_1
(Data,
Record_Token,
Indent_Anchored_2
(Data, Anchor_Token.Line,
Record_Token.Last_Line (Indenting_Comment => False),
Ada_Indent_Record_Rel_Type,
Accumulate => True),
Indenting_Comment => False);
end if;
end if;
return Indent_Anchored_2
(Data,
Anchor_Line => Anchor_Token.Line,
Last_Line => Indenting_Token.Last_Line (Indenting_Comment),
Offset => Current_Indent_Offset
(Data, Anchor_Token,
Offset =>
(if Anchor_Token.Line = Record_Token.Line
then Offset
else Offset + Ada_Indent_Record_Rel_Type)),
Accumulate => True);
end if;
end Indent_Record;
----------
-- Refactor body subprograms
function Find_ID_At
(Tree : in WisiToken.Syntax_Trees.Tree;
Terminals : in Augmented_Token_Arrays.Vector;
ID : in Token_ID;
Edit_Begin : in WisiToken.Buffer_Pos)
return WisiToken.Syntax_Trees.Node_Index
is
use WisiToken.Syntax_Trees;
function Match (Tree : in Syntax_Trees.Tree; Node : in Valid_Node_Index) return Boolean
is begin
return Tree.ID (Node) = ID and then
Terminals (Tree.Min_Terminal_Index (Node)).Byte_Region.First = Edit_Begin;
end Match;
begin
return Tree.Find_Descendant (Tree.Root, Predicate => Match'Access);
end Find_ID_At;
procedure Unrecognized
(Expecting : in String;
Found : in WisiToken.Syntax_Trees.Valid_Node_Index;
Edit_Begin : in WisiToken.Buffer_Pos)
with No_Return
is begin
raise SAL.Parameter_Error with "unrecognized subprogram call at byte_pos" & Edit_Begin'Image &
"; expecting " & Expecting & " found node" & Found'Image;
end Unrecognized;
procedure Method_Object_To_Object_Method
(Tree : in WisiToken.Syntax_Trees.Tree;
Data : in out Parse_Data_Type;
Edit_Begin : in WisiToken.Buffer_Pos)
is
-- Data.Tree contains one statement or declaration; Edit_Begin is at
-- start of a subprogram call. Convert the subprogram call from
-- Prefix.Method (Object, ...) to Object.Method (...).
use Ada_Process_Actions;
use Standard.Ada.Strings.Unbounded;
use Standard.Ada.Text_IO;
use WisiToken.Syntax_Trees;
Call : Node_Index := Find_ID_At (Tree, Data.Terminals, +name_ID, Edit_Begin);
Edit_End : WisiToken.Buffer_Pos;
Method : Valid_Node_Index;
Temp : Node_Index;
Association_List : Node_Index;
Object : Valid_Node_Index;
Result : Unbounded_String;
begin
if Call = Invalid_Node_Index then
-- Most likely the edit point is wrong.
raise SAL.Parameter_Error with "no 'name' found at byte_pos" & Edit_Begin'Image;
elsif not (Tree.RHS_Index (Call) in 1 | 3) then
raise SAL.Parameter_Error with "no subprogram call found at byte_pos" & Edit_Begin'Image &
" (found node" & Call'Image & ")";
end if;
if WisiToken.Trace_Action > Detail then
Put_Line (";; refactoring node" & Call'Image & " '" & Data.Get_Text (Tree, Call) & "'");
end if;
if Tree.RHS_Index (Call) = 3 then
-- Code looks like: Length (Container)'Old. We only want to edit
-- 'Length (Container)', keeping the trailing 'Old.
Call := Tree.Child (Tree.Child (Call, 1), 1);
end if;
Association_List := Tree.Child (Tree.Child (Call, 2), 2);
Edit_End := Tree.Byte_Region (Call).Last;
Method := Tree.Child (Tree.Child (Call, 1), 1);
loop
case To_Token_Enum (Tree.ID (Method)) is
when selected_component_ID | attribute_reference_ID =>
Method := Tree.Child (Method, 3);
when qualified_expression_ID =>
Method := Tree.Child (Method, 3); -- aggregate
if Tree.ID (Tree.Child (Method, 2)) = +association_list_ID then
Method := Tree.Child (Method, 2);
if Tree.RHS_Index (Method) = 1 then
Temp := Tree.Find_Descendant (Tree.Child (Method, 1), +expression_ID);
if Temp = Invalid_Node_Index then
Unrecognized ("expression", Tree.Child (Method, 1), Edit_Begin);
else
Method := Temp;
exit;
end if;
else
Unrecognized ("association", Method, Edit_Begin);
end if;
else
Unrecognized ("association_list", Method, Edit_Begin);
end if;
when IDENTIFIER_ID | STRING_LITERAL_ID =>
exit;
when others =>
Unrecognized ("supported token", Method, Edit_Begin);
end case;
end loop;
Temp := Tree.Find_Descendant (Association_List, +expression_ID);
if Temp = Invalid_Node_Index then
Unrecognized ("expression", Association_List, Edit_Begin);
else
Object := Temp;
end if;
-- Build remaining arg list in Result.
loop
if Tree.RHS_Index (Association_List) = 0 then
Result := Get_Text (Data, Tree, Tree.Child (Association_List, 3)) &
(if Length (Result) = 0 then "" else ", ") &
Result;
Association_List := Tree.Child (Association_List, 1);
else
-- The remaining element in Association_List is the first one, which is Object.
if Length (Result) > 0 then
Result := " (" & Result & ")";
end if;
exit;
end if;
end loop;
Result := (Get_Text (Data, Tree, Object) & "." & Get_Text (Data, Tree, Method)) & Result;
Put_Line ("[" & Edit_Action_Code & Edit_Begin'Image & Edit_End'Image & " """ &
Elisp_Escape_Quotes (To_String (Result)) & """]");
end Method_Object_To_Object_Method;
procedure Object_Method_To_Method_Object
(Tree : in WisiToken.Syntax_Trees.Tree;
Data : in out Parse_Data_Type;
Edit_Begin : in WisiToken.Buffer_Pos)
is
-- Data.Tree contains one statement or declaration; Edit_Begin is at
-- start of a subprogram call. Convert the subprogram call from
-- Object.Method (...) to Method (Object, ...).
use Ada_Process_Actions;
use Standard.Ada.Strings.Unbounded;
use Standard.Ada.Text_IO;
use WisiToken.Syntax_Trees;
Call : Node_Index := Find_ID_At (Tree, Data.Terminals, +name_ID, Edit_Begin);
Edit_End : WisiToken.Buffer_Pos;
Object_Method : Valid_Node_Index;
Method : Unbounded_String;
Object : Unbounded_String;
Result : Unbounded_String;
begin
if Call = Invalid_Node_Index then
-- Most likely the edit point is wrong.
raise SAL.Parameter_Error with "no 'name' at byte_pos" & Edit_Begin'Image;
elsif not (Tree.RHS_Index (Call) in 1 | 2 | 3) then
raise SAL.Parameter_Error with "no subprogram call found at byte_pos" & Edit_Begin'Image &
" (found node" & Call'Image & ")";
end if;
if WisiToken.Trace_Action > Detail then
Put_Line (";; refactoring node" & Call'Image & " '" & Data.Get_Text (Tree, Call) & "'");
end if;
if Tree.RHS_Index (Call) = 3 then
-- Code looks like: Container.Length'Old. We only want to edit
-- 'Container.Length', keeping the trailing 'Old.
Call := Tree.Child (Tree.Child (Call, 1), 1);
end if;
Edit_End := Tree.Byte_Region (Call).Last;
Object_Method := Tree.Child (Call, 1);
loop
case To_Token_Enum (Tree.ID (Object_Method)) is
when name_ID =>
Object_Method := Tree.Child (Object_Method, 1);
when selected_component_ID =>
Object := +Get_Text (Data, Tree, Tree.Child (Object_Method, 1));
Method := +Get_Text (Data, Tree, Tree.Child (Object_Method, 3));
exit;
when others =>
Unrecognized ("supported token", Object_Method, Edit_Begin);
end case;
end loop;
Result := Method & " (" & Object;
if Tree.RHS_Index (Call) = 1 then
Result := Result & ", " & Get_Text (Data, Tree, Tree.Child (Tree.Child (Call, 2), 2));
end if;
Result := Result & ")";
Put_Line ("[" & Edit_Action_Code & Edit_Begin'Image & Edit_End'Image & " """ &
Elisp_Escape_Quotes (To_String (Result)) & """]");
end Object_Method_To_Method_Object;
procedure Element_Object_To_Object_Index
(Tree : in WisiToken.Syntax_Trees.Tree;
Data : in out Parse_Data_Type;
Edit_Begin : in WisiToken.Buffer_Pos)
is
-- Data.Tree contains one statement or declaration; Edit_Begin is at
-- start of a subprogram call. Convert the subprogram call from
-- Prefix.Element (Object, Index) to Object (Index).
use Ada_Process_Actions;
use Standard.Ada.Text_IO;
use WisiToken.Syntax_Trees;
Call : Node_Index := Find_ID_At (Tree, Data.Terminals, +name_ID, Edit_Begin);
Edit_End : WisiToken.Buffer_Pos;
Temp : Node_Index;
Association_List : Node_Index;
Object : Valid_Node_Index;
Index : Valid_Node_Index;
begin
if Call = Invalid_Node_Index then
-- Most likely the edit point is wrong.
raise SAL.Parameter_Error with "no 'name' found at byte_pos" & Edit_Begin'Image;
elsif not (Tree.RHS_Index (Call) in 1 | 2 | 3) then
raise SAL.Parameter_Error with "no subprogram call found at byte_pos" & Edit_Begin'Image &
" (found node" & Call'Image & ")";
end if;
if WisiToken.Trace_Action > Detail then
Put_Line (";; refactoring node" & Call'Image & " '" & Data.Get_Text (Tree, Call) & "'");
end if;
if Tree.RHS_Index (Call) = 2 then
-- Code looks like: Element (Container, I).Op. We only want to edit
-- the subprogram call, keeping the trailing .Op.
Call := Tree.Child (Tree.Child (Call, 1), 1);
elsif Tree.RHS_Index (Call) = 3 then
-- Code looks like: Element (Container, I)'Old. We only want to edit
-- the subprogram call, keeping the trailing 'Old.
Call := Tree.Child (Tree.Child (Call, 1), 1);
end if;
Association_List := Tree.Child (Tree.Child (Call, 2), 2);
Edit_End := Tree.Byte_Region (Call).Last;
if Tree.RHS_Index (Association_List) /= 0 then
Unrecognized ("two args", Association_List, Edit_Begin);
end if;
Temp := Tree.Find_Descendant (Association_List, +expression_ID);
if Temp = Invalid_Node_Index then
Unrecognized ("expression", Association_List, Edit_Begin);
else
Object := Temp;
end if;
Temp := Tree.Find_Descendant (Tree.Child (Association_List, 3), +expression_ID);
if Temp = Invalid_Node_Index then
Unrecognized ("expression", Association_List, Edit_Begin);
else
Index := Temp;
end if;
Put_Line
("[" & Edit_Action_Code & Edit_Begin'Image & Edit_End'Image & " """ &
Elisp_Escape_Quotes (Get_Text (Data, Tree, Object) & " (" & Get_Text (Data, Tree, Index) & ")") &
"""]");
end Element_Object_To_Object_Index;
procedure Object_Index_To_Element_Object
(Tree : in WisiToken.Syntax_Trees.Tree;
Data : in out Parse_Data_Type;
Edit_Begin : in WisiToken.Buffer_Pos)
is
-- Data.Tree contains one statement or declaration; Edit_Begin is at
-- start of a subprogram call. Convert the subprogram call from
-- Object (Index) to Element (Object, Index).
use Ada_Process_Actions;
use Standard.Ada.Text_IO;
use WisiToken.Syntax_Trees;
Call : Node_Index := Find_ID_At (Tree, Data.Terminals, +name_ID, Edit_Begin);
Edit_End : WisiToken.Buffer_Pos;
Temp : Node_Index;
Association_List : Node_Index;
Object : Valid_Node_Index;
Index : Valid_Node_Index;
begin
if Call = Invalid_Node_Index then
-- Most likely the edit point is wrong.
raise SAL.Parameter_Error with "no 'name' found at byte_pos" & Edit_Begin'Image;
elsif not (Tree.RHS_Index (Call) in 1 | 2 | 3) then
raise SAL.Parameter_Error with "no subprogram call found at byte_pos" & Edit_Begin'Image &
" (found node" & Call'Image & ")";
end if;
if WisiToken.Trace_Action > Detail then
Put_Line (";; refactoring node" & Call'Image & " '" & Data.Get_Text (Tree, Call) & "'");
end if;
if Tree.RHS_Index (Call) = 2 then
-- Code looks like: Object (I).Component. We only want to edit
-- the subprogram call, keeping the trailing .Component.
Call := Tree.Child (Tree.Child (Call, 1), 1);
elsif Tree.RHS_Index (Call) = 3 then
-- Code looks like: Container (I)'Old. We only want to edit
-- the subprogram call, keeping the trailing 'Old.
Call := Tree.Child (Tree.Child (Call, 1), 1);
end if;
Object := Tree.Child (Tree.Child (Call, 1), 1);
Association_List := Tree.Child (Tree.Child (Call, 2), 2);
Edit_End := Tree.Byte_Region (Call).Last;
if Tree.RHS_Index (Association_List) /= 1 then
Unrecognized ("one args", Association_List, Edit_Begin);
end if;
Temp := Tree.Find_Descendant (Tree.Child (Association_List, 1), +expression_ID);
if Temp = Invalid_Node_Index then
Unrecognized ("expression", Association_List, Edit_Begin);
else
Index := Temp;
end if;
Put_Line
("[" & Edit_Action_Code & Edit_Begin'Image & Edit_End'Image & " """ &
Elisp_Escape_Quotes
("Element (" & Get_Text (Data, Tree, Object) & ", " & Get_Text (Data, Tree, Index) & ")") &
"""]");
end Object_Index_To_Element_Object;
procedure Format_Parameter_List
(Tree : in WisiToken.Syntax_Trees.Tree;
Data : in out Parse_Data_Type;
Edit_Begin : in WisiToken.Buffer_Pos)
is separate;
-- Data.Tree contains a subprogram declaration or body; Edit_Begin is
-- at the start of a parameter list. Format the parameter list.
--
-- Handle virtual tokens as much as possible; at least closing paren.
----------
-- Public subprograms, declaration order
overriding
procedure Initialize
(Data : in out Parse_Data_Type;
Lexer : in WisiToken.Lexer.Handle;
Descriptor : access constant WisiToken.Descriptor;
Base_Terminals : in WisiToken.Base_Token_Array_Access;
Post_Parse_Action : in Post_Parse_Action_Type;
Begin_Line : in WisiToken.Line_Number_Type;
End_Line : in WisiToken.Line_Number_Type;
Begin_Indent : in Integer;
Params : in String)
is
use Standard.Ada.Strings.Fixed;
use all type Ada_Process_Actions.Token_Enum_ID;
First : Integer := Params'First;
Last : Integer := Index (Params, " ");
begin
Wisi.Initialize
(Wisi.Parse_Data_Type (Data), Lexer, Descriptor, Base_Terminals, Post_Parse_Action, Begin_Line, End_Line,
Begin_Indent, "");
Data.First_Comment_ID := +COMMENT_ID;
Data.Last_Comment_ID := WisiToken.Invalid_Token_ID;
Data.Left_Paren_ID := +LEFT_PAREN_ID;
Data.Right_Paren_ID := +RIGHT_PAREN_ID;
Data.Embedded_Quote_Escape_Doubled := True;
if Params /= "" then
Ada_Indent := Integer'Value (Params (First .. Last - 1));
First := Last + 1;
Last := Index (Params, " ", First);
Ada_Indent_Broken := Integer'Value (Params (First .. Last - 1));
First := Last + 1;
Last := First + 1;
Ada_Indent_Comment_Col_0 := Params (First) = '1';
First := Last + 1;
Last := First + 1;
Ada_Indent_Comment_GNAT := Params (First) = '1';
First := Last + 1;
Last := Index (Params, " ", First);
Ada_Indent_Label := Integer'Value (Params (First .. Last - 1));
First := Last + 1;
Last := Index (Params, " ", First);
Ada_Indent_Record_Rel_Type := Integer'Value (Params (First .. Last - 1));
First := Last + 1;
Last := Index (Params, " ", First);
Ada_Indent_Renames := Integer'Value (Params (First .. Last - 1));
First := Last + 1;
Last := Index (Params, " ", First);
Ada_Indent_Return := Integer'Value (Params (First .. Last - 1));
First := Last + 1;
Last := Index (Params, " ", First);
Ada_Indent_Use := Integer'Value (Params (First .. Last - 1));
First := Last + 1;
Last := Index (Params, " ", First);
Ada_Indent_When := Integer'Value (Params (First .. Last - 1));
First := Last + 1;
Last := Index (Params, " ", First);
Ada_Indent_With := Integer'Value (Params (First .. Last - 1));
First := Last + 1;
Last := First + 1;
Ada_Indent_Hanging_Rel_Exp := Params (First) = '1';
First := Last + 1;
Last := First + 1;
End_Names_Optional := Params (First) = '1';
end if;
Data.Indent_Comment_Col_0 := Ada_Indent_Comment_Col_0;
end Initialize;
overriding
procedure Refactor
(Data : in out Parse_Data_Type;
Tree : in WisiToken.Syntax_Trees.Tree;
Action : in Positive;
Edit_Begin : in WisiToken.Buffer_Pos)
is
-- Must match "ada-refactor-*" in ada-wisi.el
Method_Object_To_Object_Method : constant Positive := 1;
Object_Method_To_Method_Object : constant Positive := 2;
Element_Object_To_Object_Index : constant Positive := 3;
Object_Index_To_Element_Object : constant Positive := 4;
Format_Parameter_List : constant Positive := 5;
begin
if WisiToken.Trace_Action > Detail then
Tree.Print_Tree (Data.Descriptor.all);
end if;
case Action is
when Method_Object_To_Object_Method =>
Wisi.Ada.Method_Object_To_Object_Method (Tree, Data, Edit_Begin);
when Object_Method_To_Method_Object =>
Wisi.Ada.Object_Method_To_Method_Object (Tree, Data, Edit_Begin);
when Element_Object_To_Object_Index =>
Wisi.Ada.Element_Object_To_Object_Index (Tree, Data, Edit_Begin);
when Object_Index_To_Element_Object =>
Wisi.Ada.Object_Index_To_Element_Object (Tree, Data, Edit_Begin);
when Format_Parameter_List =>
Wisi.Ada.Format_Parameter_List (Tree, Data, Edit_Begin);
when others =>
Standard.Ada.Text_IO.Put_Line ("(error ""unrecognized refactor action " & Action'Image & """)");
end case;
end Refactor;
overriding
function Indent_Hanging_1
(Data : in out Parse_Data_Type;
Tree : in Syntax_Trees.Tree;
Tokens : in Syntax_Trees.Valid_Node_Index_Array;
Tree_Indenting : in Syntax_Trees.Valid_Node_Index;
Indenting_Comment : in Boolean;
Delta_1 : in Simple_Indent_Param;
Delta_2 : in Simple_Indent_Param;
Option : in Boolean;
Accumulate : in Boolean)
return Delta_Type
is
use all type Syntax_Trees.Node_Index;
Indenting_Token : constant Aug_Token_Ref := Get_Aug_Token (Data, Tree, Tree_Indenting);
function Result (Delta_1 : in Simple_Indent_Param; Delta_2 : in Simple_Delta_Type) return Delta_Type
is begin
return
(Hanging,
Hanging_First_Line => Indenting_Token.Line,
Hanging_Paren_State => Indenting_Token.Paren_State,
Hanging_Delta_1 => Indent_Compute_Delta
(Data, Tree, Tokens, (Simple, Delta_1), Tree_Indenting, Indenting_Comment).Simple_Delta,
Hanging_Delta_2 => Delta_2,
Hanging_Accumulate => Accumulate);
end Result;
function Result (Delta_1 : in Simple_Delta_Type) return Delta_Type
is begin
return
(Hanging,
Hanging_First_Line => Indenting_Token.Line,
Hanging_Paren_State => Indenting_Token.Paren_State,
Hanging_Delta_1 => Delta_1,
Hanging_Delta_2 => Delta_1,
Hanging_Accumulate => Accumulate);
end Result;
function Comment_Result (D : in Simple_Indent_Param) return Delta_Type
is begin
return Indent_Compute_Delta
(Data, Tree, Tokens, (Simple, D), Tree_Indenting, Indenting_Comment => False);
end Comment_Result;
use Ada_Process_Actions;
begin
if Tree.ID (Tree.Parent (Tree_Indenting)) = +association_opt_ID and then
Syntax_Trees.Invalid_Node_Index /= Tree.Find_Ancestor (Tree_Indenting, +aspect_specification_opt_ID)
then
-- In aspect_specification_opt
-- See ada.wy association_opt for test cases
if not Indenting_Comment then
return Result
(Delta_1,
Indent_Anchored_2
(Data, Indenting_Token.Line, Indenting_Token.Last_Indent_Line,
Current_Indent_Offset (Data, Indenting_Token, 0),
Accumulate => False).Simple_Delta);
else
-- Test case in test/aspects.ads
return Result
(Indent_Compute_Delta
(Data, Tree, Tokens, (Simple, Delta_1), Tree_Indenting, Indenting_Comment).Simple_Delta);
end if;
elsif Ada_Indent_Hanging_Rel_Exp then
declare
New_Delta_2 : constant Simple_Delta_Type := Indent_Anchored_2
(Data, Indenting_Token.Line, Indenting_Token.Last_Indent_Line,
Current_Indent_Offset (Data, Indenting_Token, Ada_Indent_Broken),
Accumulate => False).Simple_Delta;
begin
if not Option or Indenting_Token.Line = Indenting_Token.First_Indent_Line then
return Result (Delta_1, New_Delta_2);
else
return Result (New_Delta_2);
end if;
end;
elsif Indenting_Comment then
-- Use delta for last line of Indenting_Token.
-- Test cases in test/ada_mode-parens.adb Hello
declare
First_Terminal : Augmented_Token renames
Data.Terminals (Indenting_Token.First_Terminals_Index);
begin
if Option then
-- Test cases with "Item => ..."
if First_Terminal.First then
if Indenting_Token.First_Indent_Line = Indenting_Token.Last_Indent_Line then
return Comment_Result (Delta_1);
else
return Comment_Result (Delta_2);
end if;
else
if Indenting_Token.First_Indent_Line = Invalid_Line_Number then
return Comment_Result ((Int, 0));
else
return Comment_Result (Delta_1);
end if;
end if;
else
if First_Terminal.First then
if Indenting_Token.First_Indent_Line = Indenting_Token.Last_Indent_Line then
return Comment_Result (Delta_1);
else
return Comment_Result (Delta_2);
end if;
else
if Indenting_Token.First_Indent_Line = Invalid_Line_Number then
-- Comment is after first line in token
return Comment_Result (Delta_1);
else
return Comment_Result (Delta_2);
end if;
end if;
end if;
end;
elsif not Option or Indenting_Token.Line = Indenting_Token.First_Indent_Line then
return Result
(Delta_1,
Indent_Compute_Delta
(Data, Tree, Tokens, (Simple, Delta_2), Tree_Indenting, Indenting_Comment).Simple_Delta);
else
return Result
(Indent_Compute_Delta
(Data, Tree, Tokens, (Simple, Delta_1), Tree_Indenting, Indenting_Comment).Simple_Delta);
end if;
end Indent_Hanging_1;
function Ada_Indent_Aggregate
(Data : in out Wisi.Parse_Data_Type'Class;
Tree : in Syntax_Trees.Tree;
Tokens : in Syntax_Trees.Valid_Node_Index_Array;
Tree_Indenting : in Syntax_Trees.Valid_Node_Index;
Indenting_Comment : in Boolean;
Args : in Wisi.Indent_Arg_Arrays.Vector)
return Wisi.Delta_Type
is
pragma Unreferenced (Data);
pragma Unreferenced (Indenting_Comment);
pragma Unreferenced (Args);
pragma Unreferenced (Tokens);
use all type Syntax_Trees.Node_Index;
use Ada_Process_Actions;
-- In our grammar, 'aggregate' can be an Ada aggregate, or a
-- parenthesized expression.
--
-- We always want an 'aggregate' to be indented by ada-indent-broken.
-- However, in some places in the grammar, 'aggregate' is indented by
-- ada-indent. The following checks for those places, and returns a
-- correction value. The aggregate may be nested inside a conidtional
-- expression, so we search for 'name' as well; see
-- test/ada_mode-conditional_expressions-more_1.adb.
Expression : constant Syntax_Trees.Node_Index := Tree.Find_Ancestor
(Tree_Indenting, (+expression_opt_ID, +name_ID));
begin
if Expression = Syntax_Trees.Invalid_Node_Index or else
Tree.Parent (Expression) = Syntax_Trees.Invalid_Node_Index
then
return Null_Delta;
elsif Tree.ID (Tree.Parent (Expression)) in +if_expression_ID | +elsif_expression_item_ID |
+case_expression_alternative_ID
then
-- The controlling boolean expression in 'if_expression' and
-- 'elsif_expression_item' cannot be an aggregate in legal Ada
-- syntax.
return (Simple, (Int, Ada_Indent_Broken - Ada_Indent));
else
return Null_Delta;
end if;
end Ada_Indent_Aggregate;
function Ada_Indent_Renames_0
(Data : in out Wisi.Parse_Data_Type'Class;
Tree : in Syntax_Trees.Tree;
Tokens : in Syntax_Trees.Valid_Node_Index_Array;
Tree_Indenting : in Syntax_Trees.Valid_Node_Index;
Indenting_Comment : in Boolean;
Args : in Indent_Arg_Arrays.Vector)
return Wisi.Delta_Type
is
Subp_Tok : constant Aug_Token_Ref := Get_Aug_Token
(Data, Tree, Tokens (Positive_Index_Type (Integer'(Args (1)))));
Renames_Tok : constant Aug_Token_Ref := Get_Aug_Token (Data, Tree, Tree_Indenting);
Paren_I : Base_Token_Index;
begin
if Subp_Tok.Char_Region = Null_Buffer_Region then
-- built from entirely virtual tokens
return Null_Delta;
end if;
Paren_I := Data.Find (Data.Left_Paren_ID, Subp_Tok);
if Paren_I /= Augmented_Token_Arrays.No_Index then
-- paren is present
declare
Paren_Tok : Augmented_Token renames Data.Terminals (Paren_I);
begin
if Ada_Indent_Renames > 0 then
return Indent_Anchored_2
(Data,
Anchor_Line => Subp_Tok.Line,
Last_Line => Renames_Tok.Last_Line (Indenting_Comment),
Offset => Ada_Indent_Renames,
Accumulate => True);
else
return Indent_Anchored_2
(Data,
Anchor_Line => Paren_Tok.Line,
Last_Line => Renames_Tok.Last_Line (Indenting_Comment),
Offset => Current_Indent_Offset (Data, Paren_Tok, abs Ada_Indent_Renames),
Accumulate => True);
end if;
end;
else
return Indent_Anchored_2
(Data,
Anchor_Line => Subp_Tok.Line,
Last_Line => Renames_Tok.Last_Line (Indenting_Comment),
Offset => Ada_Indent_Broken,
Accumulate => True);
end if;
end Ada_Indent_Renames_0;
function Ada_Indent_Return_0
(Data : in out Wisi.Parse_Data_Type'Class;
Tree : in Syntax_Trees.Tree;
Tokens : in Syntax_Trees.Valid_Node_Index_Array;
Tree_Indenting : in Syntax_Trees.Valid_Node_Index;
Indenting_Comment : in Boolean;
Args : in Wisi.Indent_Arg_Arrays.Vector)
return Wisi.Delta_Type
is
use all type Ada_Process_Actions.Token_Enum_ID;
-- Tokens (Args (1)) = 'formal_part'
-- Indenting = 'result_profile'
-- Args (2) = delta (= 0!)
--
-- We are indenting 'result_profile' in
-- 'parameter_and_result_profile'. The indent depends on whether the
-- 'formal_part' is present, and the location of 'FUNCTION'.
Parameter_And_Result_Profile : constant Syntax_Trees.Valid_Node_Index := Tree.Parent (Tree_Indenting);
Indenting : constant Aug_Token_Ref := Get_Aug_Token (Data, Tree, Tree_Indenting);
begin
if Indenting.Line = Indenting.First_Indent_Line then
if Ada_Indent_Return <= 0 then
declare
Anchor_Token : constant Aug_Token_Ref := Get_Aug_Token
(Data, Tree, Tokens (Positive_Index_Type (Integer'(Args (1)))));
begin
return Indent_Anchored_2
(Data,
Anchor_Line => Anchor_Token.Line,
Last_Line => Indenting.Last_Line (Indenting_Comment),
Offset => Current_Indent_Offset (Data, Anchor_Token, Args (2) + abs Ada_Indent_Return),
Accumulate => True);
end;
else
declare
Function_N : constant Syntax_Trees.Valid_Node_Index := Tree.Find_Sibling
(Parameter_And_Result_Profile, +FUNCTION_ID);
Anchor_Token : constant Aug_Token_Ref := Get_Aug_Token (Data, Tree, Function_N);
begin
return Indent_Anchored_2
(Data,
Anchor_Line => Anchor_Token.Line,
Last_Line => Indenting.Last_Line (Indenting_Comment),
Offset => Current_Indent_Offset (Data, Anchor_Token, Args (2) + abs Ada_Indent_Return),
Accumulate => True);
end;
end if;
else
return Null_Delta;
end if;
end Ada_Indent_Return_0;
function Ada_Indent_Record_0
(Data : in out Wisi.Parse_Data_Type'Class;
Tree : in Syntax_Trees.Tree;
Tokens : in Syntax_Trees.Valid_Node_Index_Array;
Tree_Indenting : in Syntax_Trees.Valid_Node_Index;
Indenting_Comment : in Boolean;
Args : in Wisi.Indent_Arg_Arrays.Vector)
return Wisi.Delta_Type
is begin
return Indent_Record
(Parse_Data_Type (Data),
Anchor_Token => Get_Aug_Token (Data, Tree, Tokens (Positive_Index_Type (Integer'(Args (1))))),
Record_Token => Get_Aug_Token (Data, Tree, Tokens (Positive_Index_Type (Integer'(Args (2))))),
Offset => Args (3),
Indenting_Token => Get_Aug_Token (Data, Tree, Tree_Indenting),
Indenting_Comment => Indenting_Comment);
end Ada_Indent_Record_0;
function Ada_Indent_Record_1
(Data : in out Wisi.Parse_Data_Type'Class;
Tree : in Syntax_Trees.Tree;
Tokens : in Syntax_Trees.Valid_Node_Index_Array;
Tree_Indenting : in Syntax_Trees.Valid_Node_Index;
Indenting_Comment : in Boolean;
Args : in Wisi.Indent_Arg_Arrays.Vector)
return Wisi.Delta_Type
is
-- We are indenting a token in record_definition or
-- record_representation_clause, or a comment before 'record'.
--
-- If record_definition, args (1) is the token ID of the anchor (=
-- TYPE); it appears as a direct child in an ancestor
-- full_type_declaration.
--
-- If record_representation_clause, args (1) is FOR, child of
-- record_representation_clause.
use all type WisiToken.Syntax_Trees.Node_Label;
use Ada_Process_Actions;
Anchor : constant Token_ID := Token_ID (Integer'(Args (1)));
Declaration : constant Syntax_Trees.Valid_Node_Index := Tree.Find_Ancestor
(Tree_Indenting,
(if To_Token_Enum (Anchor) = TYPE_ID
then +full_type_declaration_ID
else +record_representation_clause_ID));
Tree_Anchor : constant Syntax_Trees.Valid_Node_Index := Tree.Find_Child (Declaration, Anchor);
begin
if Tree.Label (Tree_Anchor) /= WisiToken.Syntax_Trees.Shared_Terminal then
-- Anchor is virtual; Indent_Record would return Null_Delta
return Null_Delta;
end if;
declare
Anchor_Token : constant Aug_Token_Ref := Get_Aug_Token (Data, Tree, Tree_Anchor);
-- Args (2) is the index of RECORD (or a nonterminal possibly
-- starting with RECORD) in Tokens
Record_Token_Tree_Index : constant Syntax_Trees.Node_Index :=
Tokens (Positive_Index_Type (Integer'(Args (2))));
Record_Token : constant Aug_Token_Ref :=
(case Tree.Label (Record_Token_Tree_Index) is
when Shared_Terminal | Virtual_Terminal | Virtual_Identifier => Get_Aug_Token
(Data, Tree, Record_Token_Tree_Index),
when Nonterm => To_Aug_Token_Ref (Data.Terminals (Tree.Min_Terminal_Index (Record_Token_Tree_Index))));
Indenting_Token : constant Aug_Token_Ref := Get_Aug_Token (Data, Tree, Tree_Indenting);
begin
-- Args (3) is the offset
return Indent_Record
(Parse_Data_Type (Data), Anchor_Token, Record_Token, Indenting_Token, Indenting_Comment, Args (3));
end;
end Ada_Indent_Record_1;
end Wisi.Ada;
|
-- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
with Ada.Text_IO;
with GL.Attributes;
with GL.Buffers;
with GL.Files;
with GL.Objects.Buffers;
with GL.Objects.Shaders;
with GL.Objects.Programs;
with GL.Objects.Vertex_Arrays;
with GL.Types.Colors;
with GL_Test.Display_Backend;
procedure GL_Test.OpenGL3 is
use GL.Buffers;
use GL.Types;
use GL.Objects.Vertex_Arrays;
procedure Load_Vectors is new GL.Objects.Buffers.Load_To_Buffer
(Singles.Vector3_Pointers);
procedure Load_Colors is new GL.Objects.Buffers.Load_To_Buffer
(Colors.Basic_Color_Pointers);
procedure Load_Data (Array1, Array2 : Vertex_Array_Object;
Buffer1, Buffer2, Buffer3 : GL.Objects.Buffers.Buffer) is
use GL.Objects.Buffers;
Triangle1 : constant Singles.Vector3_Array
:= ((-0.3, 0.5, -1.0),
(-0.8, -0.5, -1.0),
(0.2, -0.5, -1.0));
Triangle2 : constant Singles.Vector3_Array
:= ((-0.2, 0.5, -1.0),
(0.3, -0.5, -1.0),
(0.8, 0.5, -1.0));
Color_Array : constant Colors.Basic_Color_Array
:= ((1.0, 0.0, 0.0),
(0.0, 1.0, 0.0),
(0.0, 0.0, 1.0));
begin
-- First vertex array object: Colored vertices
Array1.Bind;
Array_Buffer.Bind (Buffer1);
Load_Vectors (Array_Buffer, Triangle1, Static_Draw);
GL.Attributes.Set_Vertex_Attrib_Pointer (0, 3, Single_Type, False, 0, 0);
GL.Attributes.Enable_Vertex_Attrib_Array (0);
Array_Buffer.Bind (Buffer2);
Load_Colors (Array_Buffer, Color_Array, Static_Draw);
GL.Attributes.Set_Vertex_Attrib_Pointer (1, 3, Single_Type, False, 0, 0);
GL.Attributes.Enable_Vertex_Attrib_Array (1);
-- Second vertex array object: Only vertices
Array2.Bind;
Array_Buffer.Bind (Buffer3);
Load_Vectors (Array_Buffer, Triangle2, Static_Draw);
GL.Attributes.Set_Vertex_Attrib_Pointer (0, 3, Single_Type, False, 0, 0);
GL.Attributes.Enable_Vertex_Attrib_Array (0);
end Load_Data;
procedure Load_Shaders (Program : out GL.Objects.Programs.Program) is
Vertex_Shader : GL.Objects.Shaders.Shader
(Kind => GL.Objects.Shaders.Vertex_Shader);
Fragment_Shader : GL.Objects.Shaders.Shader
(Kind => GL.Objects.Shaders.Fragment_Shader);
begin
Vertex_Shader.Initialize_Id;
Fragment_Shader.Initialize_Id;
Program.Initialize_Id;
-- load shader sources and compile shaders
GL.Files.Load_Shader_Source_From_File
(Vertex_Shader, "../tests/gl/gl_test-opengl3-vertex.glsl");
GL.Files.Load_Shader_Source_From_File
(Fragment_Shader, "../tests/gl/gl_test-opengl3-fragment.glsl");
Vertex_Shader.Compile;
Fragment_Shader.Compile;
if not Vertex_Shader.Compile_Status then
Ada.Text_IO.Put_Line ("Compilation of vertex shader failed. log:");
Ada.Text_IO.Put_Line (Vertex_Shader.Info_Log);
end if;
if not Fragment_Shader.Compile_Status then
Ada.Text_IO.Put_Line ("Compilation of fragment shader failed. log:");
Ada.Text_IO.Put_Line (Fragment_Shader.Info_Log);
end if;
-- set up program
Program.Attach (Vertex_Shader);
Program.Attach (Fragment_Shader);
Program.Bind_Attrib_Location (0, "in_Position");
Program.Bind_Attrib_Location (1, "in_Color");
Program.Link;
if not Program.Link_Status then
Ada.Text_IO.Put_Line ("Program linking failed. Log:");
Ada.Text_IO.Put_Line (Program.Info_Log);
return;
end if;
Program.Use_Program;
end Load_Shaders;
Program : GL.Objects.Programs.Program;
Vector_Buffer1, Vector_Buffer2, Color_Buffer : GL.Objects.Buffers.Buffer;
Array1, Array2 : GL.Objects.Vertex_Arrays.Vertex_Array_Object;
begin
Display_Backend.Init;
Display_Backend.Configure_Minimum_OpenGL_Version (Major => 3, Minor => 2);
Display_Backend.Open_Window (Width => 500, Height => 500);
Ada.Text_IO.Put_Line ("Initialized GLFW window");
Vector_Buffer1.Initialize_Id;
Vector_Buffer2.Initialize_Id;
Color_Buffer.Initialize_Id;
Array1.Initialize_Id;
Array2.Initialize_Id;
Ada.Text_IO.Put_Line ("Initialized objects");
Load_Shaders (Program);
Ada.Text_IO.Put_Line ("Loaded shaders");
Load_Data (Array1, Array2, Vector_Buffer1, Color_Buffer, Vector_Buffer2);
Ada.Text_IO.Put_Line ("Loaded data");
while Display_Backend.Window_Opened loop
Clear (Buffer_Bits'(Color => True, Depth => True, others => False));
Array1.Bind;
GL.Objects.Vertex_Arrays.Draw_Arrays (Triangles, 0, 3);
Array2.Bind;
GL.Attributes.Set_Single (1, 1.0, 0.0, 0.0);
GL.Objects.Vertex_Arrays.Draw_Arrays (Triangles, 0, 3);
GL.Objects.Vertex_Arrays.Null_Array_Object.Bind;
GL.Flush;
Display_Backend.Swap_Buffers;
Display_Backend.Poll_Events;
end loop;
Display_Backend.Shutdown;
end GL_Test.OpenGL3;
|
-- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
private with Ada.Containers.Hashed_Maps;
with Yaml.Events.Store;
package Yaml.Events.Context is
type Reference is tagged private;
type Cursor is private;
type Local_Scope_Cursor is private;
type Generated_Store_Cursor is private;
type Symbol_Cursor is private;
type Location_Type is (Generated, Local, Document, Stream, External, None);
function Create (External : Store.Reference := Store.New_Store)
return Reference;
function External_Store (Object : Reference) return Store.Accessor;
function Stream_Store (Object : Reference) return Store.Accessor;
function Document_Store (Object : Reference) return Store.Accessor;
function Transformed_Store (Object : Reference) return Store.Accessor;
function Local_Store (Object : Reference; Position : Local_Scope_Cursor)
return Store.Accessor;
function Local_Store_Ref (Object : Reference; Position : Local_Scope_Cursor)
return Store.Optional_Reference;
function Generated_Store (Object : Reference;
Position : Generated_Store_Cursor)
return Store.Accessor;
function Generated_Store_Ref (Object : Reference;
Position : Generated_Store_Cursor)
return Store.Optional_Reference;
function Position (Object : Reference; Alias : Text.Reference) return Cursor;
function Location (Position : Cursor) return Location_Type;
procedure Create_Local_Store (Object : Reference;
Position : out Local_Scope_Cursor);
procedure Create_Local_Symbol_Scope (Object : Reference;
Position : out Local_Scope_Cursor);
procedure Release_Local_Store (Object : Reference;
Position : Local_Scope_Cursor);
procedure Create_Generated_Store (Object : Reference;
Position : out Generated_Store_Cursor);
procedure Release_Generated_Store (Object : Reference;
Position : Generated_Store_Cursor);
procedure Create_Symbol (Object : Reference;
Scope : Local_Scope_Cursor;
Name : Text.Reference;
Position : out Symbol_Cursor);
procedure Update_Symbol (Object : Reference;
Scope : Local_Scope_Cursor;
Position : Symbol_Cursor;
New_Value : Cursor);
function Symbol_Name (Position : Symbol_Cursor) return Text.Reference;
No_Element : constant Cursor;
No_Local_Store : constant Local_Scope_Cursor;
function Is_Anchored (Pos : Cursor) return Boolean;
function Retrieve (Pos : Cursor) return Store.Stream_Reference
with Pre => Pos /= No_Element;
function First (Pos : Cursor) return Event with Pre => Pos /= No_Element;
function Exists_In_Ouput (Position : Cursor) return Boolean;
procedure Set_Exists_In_Output (Position : in out Cursor);
procedure Get_Store_And_Cursor
(Position : Cursor; Target : out Store.Optional_Reference;
Element_Position : out Events.Store.Element_Cursor);
function To_Cursor (Object : Reference;
Parent : Store.Optional_Reference;
Element_Position : Events.Store.Element_Cursor)
return Cursor;
private
type Cursor is record
Target : Store.Optional_Reference;
Anchored_Position : Events.Store.Anchor_Cursor;
Element_Position : Events.Store.Element_Cursor;
Target_Location : Location_Type;
end record;
package Symbol_Tables is new Ada.Containers.Hashed_Maps
(Text.Reference, Cursor, Text.Hash, Text."=");
type Symbol_Table_Pointer is access Symbol_Tables.Map;
type Local_Scope is record
Events : Store.Optional_Reference;
Symbols : Symbol_Table_Pointer;
end record;
type Scope_Array is array (Positive range <>) of Local_Scope;
type Scope_Array_Pointer is access Scope_Array;
type Data_Array is array (Positive range <>) of Store.Optional_Reference;
type Data_Array_Pointer is access Data_Array;
type Instance is limited new Refcount_Base with record
Generated_Data : Data_Array_Pointer;
Document_Data, Stream_Data, External_Data, Transformed_Data :
Store.Reference;
Local_Scopes : Scope_Array_Pointer := null;
Local_Scope_Count, Generated_Data_Count : Natural := 0;
end record;
type Instance_Access is access all Instance;
overriding procedure Finalize (Object : in out Instance);
type Local_Scope_Cursor is new Natural;
type Generated_Store_Cursor is new Natural;
type Symbol_Cursor is new Symbol_Tables.Cursor;
type Reference is new Ada.Finalization.Controlled with record
Data : not null Instance_Access := raise Constraint_Error with "uninitialized context instance!";
end record;
overriding procedure Adjust (Object : in out Reference);
overriding procedure Finalize (Object : in out Reference);
No_Element : constant Cursor :=
(Target => Store.Null_Reference,
Element_Position => Events.Store.No_Element,
Anchored_Position => Events.Store.No_Anchor,
Target_Location => None);
No_Local_Store : constant Local_Scope_Cursor := 0;
end Yaml.Events.Context;
|
-- Copyright 2008 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Ident;
procedure Assign is
Q: array (1..5) of Integer := (2, 3, 5, 7, 11);
begin
Q(1) := Ident (Q(3)); -- START
end Assign;
|
pragma License (Unrestricted);
-- extended unit, not in RM
package Ada.Wide_Characters.Latin_1 is
-- Wide_Character version of Ada.Characters.Latin_1.
pragma Pure;
-- Control characters:
NUL : constant Wide_Character :=
Wide_Character'Val (0);
SOH : constant Wide_Character :=
Wide_Character'Val (1);
STX : constant Wide_Character :=
Wide_Character'Val (2);
ETX : constant Wide_Character :=
Wide_Character'Val (3);
EOT : constant Wide_Character :=
Wide_Character'Val (4);
ENQ : constant Wide_Character :=
Wide_Character'Val (5);
ACK : constant Wide_Character :=
Wide_Character'Val (6);
BEL : constant Wide_Character :=
Wide_Character'Val (7);
BS : constant Wide_Character :=
Wide_Character'Val (8);
HT : constant Wide_Character :=
Wide_Character'Val (9);
LF : constant Wide_Character :=
Wide_Character'Val (10);
VT : constant Wide_Character :=
Wide_Character'Val (11);
FF : constant Wide_Character :=
Wide_Character'Val (12);
CR : constant Wide_Character :=
Wide_Character'Val (13);
SO : constant Wide_Character :=
Wide_Character'Val (14);
SI : constant Wide_Character :=
Wide_Character'Val (15);
DLE : constant Wide_Character :=
Wide_Character'Val (16);
DC1 : constant Wide_Character :=
Wide_Character'Val (17);
DC2 : constant Wide_Character :=
Wide_Character'Val (18);
DC3 : constant Wide_Character :=
Wide_Character'Val (19);
DC4 : constant Wide_Character :=
Wide_Character'Val (20);
NAK : constant Wide_Character :=
Wide_Character'Val (21);
SYN : constant Wide_Character :=
Wide_Character'Val (22);
ETB : constant Wide_Character :=
Wide_Character'Val (23);
CAN : constant Wide_Character :=
Wide_Character'Val (24);
EM : constant Wide_Character :=
Wide_Character'Val (25);
SUB : constant Wide_Character :=
Wide_Character'Val (26);
ESC : constant Wide_Character :=
Wide_Character'Val (27);
FS : constant Wide_Character :=
Wide_Character'Val (28);
GS : constant Wide_Character :=
Wide_Character'Val (29);
RS : constant Wide_Character :=
Wide_Character'Val (30);
US : constant Wide_Character :=
Wide_Character'Val (31);
-- ISO 646 graphic characters:
Space : constant Wide_Character :=
Wide_Character'Val (32); -- ' '
Exclamation : constant Wide_Character :=
Wide_Character'Val (33); -- '!'
Quotation : constant Wide_Character :=
Wide_Character'Val (34); -- '"'
Number_Sign : constant Wide_Character :=
Wide_Character'Val (35); -- '#'
Dollar_Sign : constant Wide_Character :=
Wide_Character'Val (36); -- '$'
Percent_Sign : constant Wide_Character :=
Wide_Character'Val (37); -- '%'
Ampersand : constant Wide_Character :=
Wide_Character'Val (38); -- '&'
Apostrophe : constant Wide_Character :=
Wide_Character'Val (39); -- '''
Left_Parenthesis : constant Wide_Character :=
Wide_Character'Val (40); -- '('
Right_Parenthesis : constant Wide_Character :=
Wide_Character'Val (41); -- ')'
Asterisk : constant Wide_Character :=
Wide_Character'Val (42); -- '*'
Plus_Sign : constant Wide_Character :=
Wide_Character'Val (43); -- '+'
Comma : constant Wide_Character :=
Wide_Character'Val (44); -- ','
Hyphen : constant Wide_Character :=
Wide_Character'Val (45); -- '-'
Minus_Sign : Wide_Character
renames Hyphen;
Full_Stop : constant Wide_Character :=
Wide_Character'Val (46); -- '.'
Solidus : constant Wide_Character :=
Wide_Character'Val (47); -- '/'
-- Decimal digits '0' though '9' are at positions 48 through 57
Colon : constant Wide_Character :=
Wide_Character'Val (58); -- ':'
Semicolon : constant Wide_Character :=
Wide_Character'Val (59); -- ';'
Less_Than_Sign : constant Wide_Character :=
Wide_Character'Val (60); -- '<'
Equals_Sign : constant Wide_Character :=
Wide_Character'Val (61); -- '='
Greater_Than_Sign : constant Wide_Character :=
Wide_Character'Val (62); -- '>'
Question : constant Wide_Character :=
Wide_Character'Val (63); -- '?'
Commercial_At : constant Wide_Character :=
Wide_Character'Val (64); -- '@'
-- Letters 'A' through 'Z' are at positions 65 through 90
Left_Square_Bracket : constant Wide_Character :=
Wide_Character'Val (91); -- '['
Reverse_Solidus : constant Wide_Character :=
Wide_Character'Val (92); -- '\'
Right_Square_Bracket : constant Wide_Character :=
Wide_Character'Val (93); -- ']'
Circumflex : constant Wide_Character :=
Wide_Character'Val (94); -- '^'
Low_Line : constant Wide_Character :=
Wide_Character'Val (95); -- '_'
Grave : constant Wide_Character :=
Wide_Character'Val (96); -- '`'
LC_A : constant Wide_Character :=
Wide_Character'Val (97); -- 'a'
LC_B : constant Wide_Character :=
Wide_Character'Val (98); -- 'b'
LC_C : constant Wide_Character :=
Wide_Character'Val (99); -- 'c'
LC_D : constant Wide_Character :=
Wide_Character'Val (100); -- 'd'
LC_E : constant Wide_Character :=
Wide_Character'Val (101); -- 'e'
LC_F : constant Wide_Character :=
Wide_Character'Val (102); -- 'f'
LC_G : constant Wide_Character :=
Wide_Character'Val (103); -- 'g'
LC_H : constant Wide_Character :=
Wide_Character'Val (104); -- 'h'
LC_I : constant Wide_Character :=
Wide_Character'Val (105); -- 'i'
LC_J : constant Wide_Character :=
Wide_Character'Val (106); -- 'j'
LC_K : constant Wide_Character :=
Wide_Character'Val (107); -- 'k'
LC_L : constant Wide_Character :=
Wide_Character'Val (108); -- 'l'
LC_M : constant Wide_Character :=
Wide_Character'Val (109); -- 'm'
LC_N : constant Wide_Character :=
Wide_Character'Val (110); -- 'n'
LC_O : constant Wide_Character :=
Wide_Character'Val (111); -- 'o'
LC_P : constant Wide_Character :=
Wide_Character'Val (112); -- 'p'
LC_Q : constant Wide_Character :=
Wide_Character'Val (113); -- 'q'
LC_R : constant Wide_Character :=
Wide_Character'Val (114); -- 'r'
LC_S : constant Wide_Character :=
Wide_Character'Val (115); -- 's'
LC_T : constant Wide_Character :=
Wide_Character'Val (116); -- 't'
LC_U : constant Wide_Character :=
Wide_Character'Val (117); -- 'u'
LC_V : constant Wide_Character :=
Wide_Character'Val (118); -- 'v'
LC_W : constant Wide_Character :=
Wide_Character'Val (119); -- 'w'
LC_X : constant Wide_Character :=
Wide_Character'Val (120); -- 'x'
LC_Y : constant Wide_Character :=
Wide_Character'Val (121); -- 'y'
LC_Z : constant Wide_Character :=
Wide_Character'Val (122); -- 'z'
Left_Curly_Bracket : constant Wide_Character :=
Wide_Character'Val (123); -- '{'
Vertical_Line : constant Wide_Character :=
Wide_Character'Val (124); -- '|'
Right_Curly_Bracket : constant Wide_Character :=
Wide_Character'Val (125); -- '}'
Tilde : constant Wide_Character :=
Wide_Character'Val (126); -- '~'
DEL : constant Wide_Character :=
Wide_Character'Val (127);
-- ISO 6429 control characters:
IS4 : Wide_Character renames FS;
IS3 : Wide_Character renames GS;
IS2 : Wide_Character renames RS;
IS1 : Wide_Character renames US;
Reserved_128 : constant Wide_Character :=
Wide_Character'Val (128);
Reserved_129 : constant Wide_Character :=
Wide_Character'Val (129);
BPH : constant Wide_Character :=
Wide_Character'Val (130);
NBH : constant Wide_Character :=
Wide_Character'Val (131);
Reserved_132 : constant Wide_Character :=
Wide_Character'Val (132);
NEL : constant Wide_Character :=
Wide_Character'Val (133);
SSA : constant Wide_Character :=
Wide_Character'Val (134);
ESA : constant Wide_Character :=
Wide_Character'Val (135);
HTS : constant Wide_Character :=
Wide_Character'Val (136);
HTJ : constant Wide_Character :=
Wide_Character'Val (137);
VTS : constant Wide_Character :=
Wide_Character'Val (138);
PLD : constant Wide_Character :=
Wide_Character'Val (139);
PLU : constant Wide_Character :=
Wide_Character'Val (140);
RI : constant Wide_Character :=
Wide_Character'Val (141);
SS2 : constant Wide_Character :=
Wide_Character'Val (142);
SS3 : constant Wide_Character :=
Wide_Character'Val (143);
DCS : constant Wide_Character :=
Wide_Character'Val (144);
PU1 : constant Wide_Character :=
Wide_Character'Val (145);
PU2 : constant Wide_Character :=
Wide_Character'Val (146);
STS : constant Wide_Character :=
Wide_Character'Val (147);
CCH : constant Wide_Character :=
Wide_Character'Val (148);
MW : constant Wide_Character :=
Wide_Character'Val (149);
SPA : constant Wide_Character :=
Wide_Character'Val (150);
EPA : constant Wide_Character :=
Wide_Character'Val (151);
SOS : constant Wide_Character :=
Wide_Character'Val (152);
Reserved_153 : constant Wide_Character :=
Wide_Character'Val (153);
SCI : constant Wide_Character :=
Wide_Character'Val (154);
CSI : constant Wide_Character :=
Wide_Character'Val (155);
ST : constant Wide_Character :=
Wide_Character'Val (156);
OSC : constant Wide_Character :=
Wide_Character'Val (157);
PM : constant Wide_Character :=
Wide_Character'Val (158);
APC : constant Wide_Character :=
Wide_Character'Val (159);
-- Other graphic characters:
-- Character positions 160 (16#A0#) .. 175 (16#AF#):
No_Break_Space : constant Wide_Character :=
Wide_Character'Val (160); -- ' '
NBSP : Wide_Character
renames No_Break_Space;
Inverted_Exclamation : constant Wide_Character :=
Wide_Character'Val (161); -- '¡'
Cent_Sign : constant Wide_Character :=
Wide_Character'Val (162); -- '¢'
Pound_Sign : constant Wide_Character :=
Wide_Character'Val (163); -- '£'
Currency_Sign : constant Wide_Character :=
Wide_Character'Val (164); -- '¤'
Yen_Sign : constant Wide_Character :=
Wide_Character'Val (165); -- '¥'
Broken_Bar : constant Wide_Character :=
Wide_Character'Val (166); -- '¦'
Section_Sign : constant Wide_Character :=
Wide_Character'Val (167); -- '§'
Diaeresis : constant Wide_Character :=
Wide_Character'Val (168); -- '¨'
Copyright_Sign : constant Wide_Character :=
Wide_Character'Val (169); -- '©'
Feminine_Ordinal_Indicator : constant Wide_Character :=
Wide_Character'Val (170); -- 'ª'
Left_Angle_Quotation : constant Wide_Character :=
Wide_Character'Val (171); -- '«'
Not_Sign : constant Wide_Character :=
Wide_Character'Val (172); -- '¬'
Soft_Hyphen : constant Wide_Character :=
Wide_Character'Val (173); -- ' '
Registered_Trade_Mark_Sign : constant Wide_Character :=
Wide_Character'Val (174); -- '®'
Macron : constant Wide_Character :=
Wide_Character'Val (175); -- '¯'
-- Character positions 176 (16#B0#) .. 191 (16#BF#):
Degree_Sign : constant Wide_Character :=
Wide_Character'Val (176); -- '°'
Ring_Above : Wide_Character
renames Degree_Sign;
Plus_Minus_Sign : constant Wide_Character :=
Wide_Character'Val (177); -- '±'
Superscript_Two : constant Wide_Character :=
Wide_Character'Val (178); -- '²'
Superscript_Three : constant Wide_Character :=
Wide_Character'Val (179); -- '³'
Acute : constant Wide_Character :=
Wide_Character'Val (180); -- '´'
Micro_Sign : constant Wide_Character :=
Wide_Character'Val (181); -- 'µ'
Pilcrow_Sign : constant Wide_Character :=
Wide_Character'Val (182); -- '¶'
Paragraph_Sign : Wide_Character
renames Pilcrow_Sign;
Middle_Dot : constant Wide_Character :=
Wide_Character'Val (183); -- '·'
Cedilla : constant Wide_Character :=
Wide_Character'Val (184); -- '¸'
Superscript_One : constant Wide_Character :=
Wide_Character'Val (185); -- '¹'
Masculine_Ordinal_Indicator : constant Wide_Character :=
Wide_Character'Val (186); -- 'º'
Right_Angle_Quotation : constant Wide_Character :=
Wide_Character'Val (187); -- '»'
Fraction_One_Quarter : constant Wide_Character :=
Wide_Character'Val (188); -- '¼'
Fraction_One_Half : constant Wide_Character :=
Wide_Character'Val (189); -- '½'
Fraction_Three_Quarters : constant Wide_Character :=
Wide_Character'Val (190); -- '¾'
Inverted_Question : constant Wide_Character :=
Wide_Character'Val (191); -- '¿'
-- Character positions 192 (16#C0#) .. 207 (16#CF#):
UC_A_Grave : constant Wide_Character :=
Wide_Character'Val (192); -- 'À'
UC_A_Acute : constant Wide_Character :=
Wide_Character'Val (193); -- 'Á'
UC_A_Circumflex : constant Wide_Character :=
Wide_Character'Val (194); -- 'Â'
UC_A_Tilde : constant Wide_Character :=
Wide_Character'Val (195); -- 'Ã'
UC_A_Diaeresis : constant Wide_Character :=
Wide_Character'Val (196); -- 'Ä'
UC_A_Ring : constant Wide_Character :=
Wide_Character'Val (197); -- 'Å'
UC_AE_Diphthong : constant Wide_Character :=
Wide_Character'Val (198); -- 'Æ'
UC_C_Cedilla : constant Wide_Character :=
Wide_Character'Val (199); -- 'Ç'
UC_E_Grave : constant Wide_Character :=
Wide_Character'Val (200); -- 'È'
UC_E_Acute : constant Wide_Character :=
Wide_Character'Val (201); -- 'É'
UC_E_Circumflex : constant Wide_Character :=
Wide_Character'Val (202); -- 'Ê'
UC_E_Diaeresis : constant Wide_Character :=
Wide_Character'Val (203); -- 'Ë'
UC_I_Grave : constant Wide_Character :=
Wide_Character'Val (204); -- 'Ì'
UC_I_Acute : constant Wide_Character :=
Wide_Character'Val (205); -- 'Í'
UC_I_Circumflex : constant Wide_Character :=
Wide_Character'Val (206); -- 'Î'
UC_I_Diaeresis : constant Wide_Character :=
Wide_Character'Val (207); -- 'Ï'
-- Character positions 208 (16#D0#) .. 223 (16#DF#):
UC_Icelandic_Eth : constant Wide_Character :=
Wide_Character'Val (208); -- 'Ð'
UC_N_Tilde : constant Wide_Character :=
Wide_Character'Val (209); -- 'Ñ'
UC_O_Grave : constant Wide_Character :=
Wide_Character'Val (210); -- 'Ò'
UC_O_Acute : constant Wide_Character :=
Wide_Character'Val (211); -- 'Ó'
UC_O_Circumflex : constant Wide_Character :=
Wide_Character'Val (212); -- 'Ô'
UC_O_Tilde : constant Wide_Character :=
Wide_Character'Val (213); -- 'Õ'
UC_O_Diaeresis : constant Wide_Character :=
Wide_Character'Val (214); -- 'Ö'
Multiplication_Sign : constant Wide_Character :=
Wide_Character'Val (215); -- '×'
UC_O_Oblique_Stroke : constant Wide_Character :=
Wide_Character'Val (216); -- 'Ø'
UC_U_Grave : constant Wide_Character :=
Wide_Character'Val (217); -- 'Ù'
UC_U_Acute : constant Wide_Character :=
Wide_Character'Val (218); -- 'Ú'
UC_U_Circumflex : constant Wide_Character :=
Wide_Character'Val (219); -- 'Û'
UC_U_Diaeresis : constant Wide_Character :=
Wide_Character'Val (220); -- 'Ü'
UC_Y_Acute : constant Wide_Character :=
Wide_Character'Val (221); -- 'Ý'
UC_Icelandic_Thorn : constant Wide_Character :=
Wide_Character'Val (222); -- 'Þ'
LC_German_Sharp_S : constant Wide_Character :=
Wide_Character'Val (223); -- 'ß'
-- Character positions 224 (16#E0#) .. 239 (16#EF#):
LC_A_Grave : constant Wide_Character :=
Wide_Character'Val (224); -- 'à'
LC_A_Acute : constant Wide_Character :=
Wide_Character'Val (225); -- 'á'
LC_A_Circumflex : constant Wide_Character :=
Wide_Character'Val (226); -- 'â'
LC_A_Tilde : constant Wide_Character :=
Wide_Character'Val (227); -- 'ã'
LC_A_Diaeresis : constant Wide_Character :=
Wide_Character'Val (228); -- 'ä'
LC_A_Ring : constant Wide_Character :=
Wide_Character'Val (229); -- 'å'
LC_AE_Diphthong : constant Wide_Character :=
Wide_Character'Val (230); -- 'æ'
LC_C_Cedilla : constant Wide_Character :=
Wide_Character'Val (231); -- 'ç'
LC_E_Grave : constant Wide_Character :=
Wide_Character'Val (232); -- 'è'
LC_E_Acute : constant Wide_Character :=
Wide_Character'Val (233); -- 'é'
LC_E_Circumflex : constant Wide_Character :=
Wide_Character'Val (234); -- 'ê'
LC_E_Diaeresis : constant Wide_Character :=
Wide_Character'Val (235); -- 'ë'
LC_I_Grave : constant Wide_Character :=
Wide_Character'Val (236); -- 'ì'
LC_I_Acute : constant Wide_Character :=
Wide_Character'Val (237); -- 'í'
LC_I_Circumflex : constant Wide_Character :=
Wide_Character'Val (238); -- 'î'
LC_I_Diaeresis : constant Wide_Character :=
Wide_Character'Val (239); -- 'ï'
-- Character positions 240 (16#F0#) .. 255 (16#FF#):
LC_Icelandic_Eth : constant Wide_Character :=
Wide_Character'Val (240); -- 'ð'
LC_N_Tilde : constant Wide_Character :=
Wide_Character'Val (241); -- 'ñ'
LC_O_Grave : constant Wide_Character :=
Wide_Character'Val (242); -- 'ò'
LC_O_Acute : constant Wide_Character :=
Wide_Character'Val (243); -- 'ó'
LC_O_Circumflex : constant Wide_Character :=
Wide_Character'Val (244); -- 'ô'
LC_O_Tilde : constant Wide_Character :=
Wide_Character'Val (245); -- 'õ'
LC_O_Diaeresis : constant Wide_Character :=
Wide_Character'Val (246); -- 'ö'
Division_Sign : constant Wide_Character :=
Wide_Character'Val (247); -- '÷';
LC_O_Oblique_Stroke : constant Wide_Character :=
Wide_Character'Val (248); -- 'ø'
LC_U_Grave : constant Wide_Character :=
Wide_Character'Val (249); -- 'ù'
LC_U_Acute : constant Wide_Character :=
Wide_Character'Val (250); -- 'ú'
LC_U_Circumflex : constant Wide_Character :=
Wide_Character'Val (251); -- 'û';
LC_U_Diaeresis : constant Wide_Character :=
Wide_Character'Val (252); -- 'ü'
LC_Y_Acute : constant Wide_Character :=
Wide_Character'Val (253); -- 'ý'
LC_Icelandic_Thorn : constant Wide_Character :=
Wide_Character'Val (254); -- 'þ'
LC_Y_Diaeresis : constant Wide_Character :=
Wide_Character'Val (255); -- 'ÿ'
end Ada.Wide_Characters.Latin_1;
|
package body App is
procedure Main is separate;
begin
Main;
end App;
|
package body OpenGL.Buffer is
procedure Clear (Mask : in Buffer_Mask_t) is
begin
Thin.Clear (Thin.Bitfield_t (Mask));
end Clear;
procedure Clear_Color
(Red : in OpenGL.Types.Clamped_Float_t;
Green : in OpenGL.Types.Clamped_Float_t;
Blue : in OpenGL.Types.Clamped_Float_t;
Alpha : in OpenGL.Types.Clamped_Float_t) is
begin
Thin.Clear_Color
(Red => Thin.Float_t (Red),
Green => Thin.Float_t (Green),
Blue => Thin.Float_t (Blue),
Alpha => Thin.Float_t (Alpha));
end Clear_Color;
end OpenGL.Buffer;
|
with Ada.Real_Time;
private with ACO.Utils.DS.Generic_Collection;
private with ACO.Utils.DS.Generic_Collection.Sorted;
generic
Maximum_Nof_Alarms : Positive;
package ACO.Utils.Generic_Alarms is
type Alarm_Type is abstract tagged limited null record;
type Alarm_Access is access all Alarm_Type'Class;
procedure Signal
(This : access Alarm_Type;
T_Now : in Ada.Real_Time.Time) is abstract;
type Alarm_Manager is tagged limited private;
procedure Set
(This : in out Alarm_Manager;
Alarm : in Alarm_Access;
Signal_Time : in Ada.Real_Time.Time);
function Is_Pending
(This : in out Alarm_Manager;
Alarm : in Alarm_Access)
return Boolean;
procedure Cancel
(This : in out Alarm_Manager;
Alarm : in Alarm_Access);
function Get_Next_Up
(This : Alarm_Manager;
T_Now : Ada.Real_Time.Time)
return Alarm_Access;
procedure Process
(This : in out Alarm_Manager;
T_Now : in Ada.Real_Time.Time);
No_Alarm : constant Alarm_Access := null;
private
type Alarm_Data is record
Alarm_Ref : Alarm_Access := No_Alarm;
Signal_Time : Ada.Real_Time.Time := Ada.Real_Time.Time_Last;
end record;
function "<" (Left, Right : Alarm_Data) return Boolean;
function "=" (Left, Right : Alarm_Data) return Boolean;
package Collection_Pack is new ACO.Utils.DS.Generic_Collection
(Item_Type => Alarm_Data,
"=" => "=");
package Sorted_Pack is new Collection_Pack.Sorted
("<" => "<");
subtype Sorted_Collection is Sorted_Pack.Sorted_Collection
(Max_Size => Maximum_Nof_Alarms);
type Alarm_Manager is tagged limited record
Alarm_List : Sorted_Collection;
end record;
end ACO.Utils.Generic_Alarms;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- P R J . A T T R --
-- --
-- B o d y --
-- --
-- Copyright (C) 2001-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. --
-- --
------------------------------------------------------------------------------
with Namet; use Namet;
with Osint;
with Prj.Com; use Prj.Com;
with System.Case_Util; use System.Case_Util;
package body Prj.Attr is
-- Data for predefined attributes and packages
-- Names end with '#'
-- Package names are preceded by 'P'
-- Attribute names are preceded by two letters:
-- The first letter is one of
-- 'S' for Single
-- 's' for Single with optional index
-- 'L' for List
-- 'l' for List of strings with optional indexes
-- The second letter is one of
-- 'V' for single variable
-- 'A' for associative array
-- 'a' for case insensitive associative array
-- 'b' for associative array, case insensitive if file names are case
-- insensitive
-- 'c' same as 'b', with optional index
-- End is indicated by two consecutive '#'
Initialization_Data : constant String :=
-- project attributes
"SVobject_dir#" &
"SVexec_dir#" &
"LVsource_dirs#" &
"LVsource_files#" &
"LVlocally_removed_files#" &
"SVsource_list_file#" &
"SVlibrary_dir#" &
"SVlibrary_name#" &
"SVlibrary_kind#" &
"SVlibrary_version#" &
"LVlibrary_interface#" &
"SVlibrary_auto_init#" &
"LVlibrary_options#" &
"SVlibrary_src_dir#" &
"SVlibrary_ali_dir#" &
"SVlibrary_gcc#" &
"SVlibrary_symbol_file#" &
"SVlibrary_symbol_policy#" &
"SVlibrary_reference_symbol_file#" &
"lVmain#" &
"LVlanguages#" &
"SVmain_language#" &
"LVada_roots#" &
"SVexternally_built#" &
-- package Naming
"Pnaming#" &
"Saspecification_suffix#" &
"Saspec_suffix#" &
"Saimplementation_suffix#" &
"Sabody_suffix#" &
"SVseparate_suffix#" &
"SVcasing#" &
"SVdot_replacement#" &
"sAspecification#" &
"sAspec#" &
"sAimplementation#" &
"sAbody#" &
"Laspecification_exceptions#" &
"Laimplementation_exceptions#" &
-- package Compiler
"Pcompiler#" &
"Ladefault_switches#" &
"Lcswitches#" &
"SVlocal_configuration_pragmas#" &
-- package Builder
"Pbuilder#" &
"Ladefault_switches#" &
"Lcswitches#" &
"Scexecutable#" &
"SVexecutable_suffix#" &
"SVglobal_configuration_pragmas#" &
-- package gnatls
"Pgnatls#" &
"LVswitches#" &
-- package Binder
"Pbinder#" &
"Ladefault_switches#" &
"Lcswitches#" &
-- package Linker
"Plinker#" &
"Ladefault_switches#" &
"Lcswitches#" &
"LVlinker_options#" &
-- package Cross_Reference
"Pcross_reference#" &
"Ladefault_switches#" &
"Lbswitches#" &
-- package Finder
"Pfinder#" &
"Ladefault_switches#" &
"Lbswitches#" &
-- package Pretty_Printer
"Ppretty_printer#" &
"Ladefault_switches#" &
"Lbswitches#" &
-- package gnatstub
"Pgnatstub#" &
"Ladefault_switches#" &
"Lbswitches#" &
-- package Check
"Pcheck#" &
"Ladefault_switches#" &
"Lbswitches#" &
-- package Eliminate
"Peliminate#" &
"Ladefault_switches#" &
"Lbswitches#" &
-- package Metrics
"Pmetrics#" &
"Ladefault_switches#" &
"Lbswitches#" &
-- package Ide
"Pide#" &
"Ladefault_switches#" &
"SVremote_host#" &
"SVprogram_host#" &
"SVcommunication_protocol#" &
"Sacompiler_command#" &
"SVdebugger_command#" &
"SVgnatlist#" &
"SVvcs_kind#" &
"SVvcs_file_check#" &
"SVvcs_log_check#" &
-- package Language_Processing
"Planguage_processing#" &
"Lacompiler_driver#" &
"Sacompiler_kind#" &
"Ladependency_option#" &
"Lacompute_dependency#" &
"Lainclude_option#" &
"Sabinder_driver#" &
"SVdefault_linker#" &
"#";
Initialized : Boolean := False;
-- A flag to avoid multiple initialization
function Name_Id_Of (Name : String) return Name_Id;
-- Returns the Name_Id for Name in lower case
-----------------------
-- Attribute_Kind_Of --
-----------------------
function Attribute_Kind_Of
(Attribute : Attribute_Node_Id) return Attribute_Kind
is
begin
if Attribute = Empty_Attribute then
return Unknown;
else
return Attrs.Table (Attribute.Value).Attr_Kind;
end if;
end Attribute_Kind_Of;
-----------------------
-- Attribute_Name_Of --
-----------------------
function Attribute_Name_Of (Attribute : Attribute_Node_Id) return Name_Id is
begin
if Attribute = Empty_Attribute then
return No_Name;
else
return Attrs.Table (Attribute.Value).Name;
end if;
end Attribute_Name_Of;
--------------------------
-- Attribute_Node_Id_Of --
--------------------------
function Attribute_Node_Id_Of
(Name : Name_Id;
Starting_At : Attribute_Node_Id) return Attribute_Node_Id
is
Id : Attr_Node_Id := Starting_At.Value;
begin
while Id /= Empty_Attr
and then Attrs.Table (Id).Name /= Name
loop
Id := Attrs.Table (Id).Next;
end loop;
return (Value => Id);
end Attribute_Node_Id_Of;
----------------
-- Initialize --
----------------
procedure Initialize is
Start : Positive := Initialization_Data'First;
Finish : Positive := Start;
Current_Package : Pkg_Node_Id := Empty_Pkg;
Current_Attribute : Attr_Node_Id := Empty_Attr;
Is_An_Attribute : Boolean := False;
Var_Kind : Variable_Kind := Undefined;
Optional_Index : Boolean := False;
Attr_Kind : Attribute_Kind := Single;
Package_Name : Name_Id := No_Name;
Attribute_Name : Name_Id := No_Name;
First_Attribute : Attr_Node_Id := Attr.First_Attribute;
function Attribute_Location return String;
-- Returns a string depending if we are in the project level attributes
-- or in the attributes of a package.
------------------------
-- Attribute_Location --
------------------------
function Attribute_Location return String is
begin
if Package_Name = No_Name then
return "project level attributes";
else
return "attribute of package """ &
Get_Name_String (Package_Name) & """";
end if;
end Attribute_Location;
-- Start of processing for Initialize
begin
-- Don't allow Initialize action to be repeated
if Initialized then
return;
end if;
-- Make sure the two tables are empty
Attrs.Init;
Package_Attributes.Init;
while Initialization_Data (Start) /= '#' loop
Is_An_Attribute := True;
case Initialization_Data (Start) is
when 'P' =>
-- New allowed package
Start := Start + 1;
Finish := Start;
while Initialization_Data (Finish) /= '#' loop
Finish := Finish + 1;
end loop;
Package_Name :=
Name_Id_Of (Initialization_Data (Start .. Finish - 1));
for Index in First_Package .. Package_Attributes.Last loop
if Package_Name = Package_Attributes.Table (Index).Name then
Osint.Fail ("duplicate name """,
Initialization_Data (Start .. Finish - 1),
""" in predefined packages.");
end if;
end loop;
Is_An_Attribute := False;
Current_Attribute := Empty_Attr;
Package_Attributes.Increment_Last;
Current_Package := Package_Attributes.Last;
Package_Attributes.Table (Current_Package) :=
(Name => Package_Name,
Known => True,
First_Attribute => Empty_Attr);
Start := Finish + 1;
when 'S' =>
Var_Kind := Single;
Optional_Index := False;
when 's' =>
Var_Kind := Single;
Optional_Index := True;
when 'L' =>
Var_Kind := List;
Optional_Index := False;
when 'l' =>
Var_Kind := List;
Optional_Index := True;
when others =>
raise Program_Error;
end case;
if Is_An_Attribute then
-- New attribute
Start := Start + 1;
case Initialization_Data (Start) is
when 'V' =>
Attr_Kind := Single;
when 'A' =>
Attr_Kind := Associative_Array;
when 'a' =>
Attr_Kind := Case_Insensitive_Associative_Array;
when 'b' =>
if Osint.File_Names_Case_Sensitive then
Attr_Kind := Associative_Array;
else
Attr_Kind := Case_Insensitive_Associative_Array;
end if;
when 'c' =>
if Osint.File_Names_Case_Sensitive then
Attr_Kind := Optional_Index_Associative_Array;
else
Attr_Kind :=
Optional_Index_Case_Insensitive_Associative_Array;
end if;
when others =>
raise Program_Error;
end case;
Start := Start + 1;
Finish := Start;
while Initialization_Data (Finish) /= '#' loop
Finish := Finish + 1;
end loop;
Attribute_Name :=
Name_Id_Of (Initialization_Data (Start .. Finish - 1));
Attrs.Increment_Last;
if Current_Attribute = Empty_Attr then
First_Attribute := Attrs.Last;
if Current_Package /= Empty_Pkg then
Package_Attributes.Table (Current_Package).First_Attribute
:= Attrs.Last;
end if;
else
-- Check that there are no duplicate attributes
for Index in First_Attribute .. Attrs.Last - 1 loop
if Attribute_Name = Attrs.Table (Index).Name then
Osint.Fail ("duplicate attribute """,
Initialization_Data (Start .. Finish - 1),
""" in " & Attribute_Location);
end if;
end loop;
Attrs.Table (Current_Attribute).Next :=
Attrs.Last;
end if;
Current_Attribute := Attrs.Last;
Attrs.Table (Current_Attribute) :=
(Name => Attribute_Name,
Var_Kind => Var_Kind,
Optional_Index => Optional_Index,
Attr_Kind => Attr_Kind,
Next => Empty_Attr);
Start := Finish + 1;
end if;
end loop;
Initialized := True;
end Initialize;
----------------
-- Name_Id_Of --
----------------
function Name_Id_Of (Name : String) return Name_Id is
begin
Name_Len := 0;
Add_Str_To_Name_Buffer (Name);
To_Lower (Name_Buffer (1 .. Name_Len));
return Name_Find;
end Name_Id_Of;
--------------------
-- Next_Attribute --
--------------------
function Next_Attribute
(After : Attribute_Node_Id) return Attribute_Node_Id
is
begin
if After = Empty_Attribute then
return Empty_Attribute;
else
return (Value => Attrs.Table (After.Value).Next);
end if;
end Next_Attribute;
-----------------------
-- Optional_Index_Of --
-----------------------
function Optional_Index_Of (Attribute : Attribute_Node_Id) return Boolean is
begin
if Attribute = Empty_Attribute then
return False;
else
return Attrs.Table (Attribute.Value).Optional_Index;
end if;
end Optional_Index_Of;
------------------------
-- Package_Node_Id_Of --
------------------------
function Package_Node_Id_Of (Name : Name_Id) return Package_Node_Id is
begin
for Index in Package_Attributes.First .. Package_Attributes.Last loop
if Package_Attributes.Table (Index).Name = Name then
return (Value => Index);
end if;
end loop;
-- If there is no package with this name, return Empty_Package
return Empty_Package;
end Package_Node_Id_Of;
----------------------------
-- Register_New_Attribute --
----------------------------
procedure Register_New_Attribute
(Name : String;
In_Package : Package_Node_Id;
Attr_Kind : Defined_Attribute_Kind;
Var_Kind : Defined_Variable_Kind;
Index_Is_File_Name : Boolean := False;
Opt_Index : Boolean := False)
is
Attr_Name : Name_Id;
First_Attr : Attr_Node_Id := Empty_Attr;
Curr_Attr : Attr_Node_Id;
Real_Attr_Kind : Attribute_Kind;
begin
if Name'Length = 0 then
Fail ("cannot register an attribute with no name");
raise Project_Error;
end if;
if In_Package = Empty_Package then
Fail ("attempt to add attribute """, Name,
""" to an undefined package");
raise Project_Error;
end if;
Attr_Name := Name_Id_Of (Name);
First_Attr :=
Package_Attributes.Table (In_Package.Value).First_Attribute;
-- Check if attribute name is a duplicate
Curr_Attr := First_Attr;
while Curr_Attr /= Empty_Attr loop
if Attrs.Table (Curr_Attr).Name = Attr_Name then
Fail ("duplicate attribute name """, Name,
""" in package """ &
Get_Name_String
(Package_Attributes.Table (In_Package.Value).Name) &
"""");
raise Project_Error;
end if;
Curr_Attr := Attrs.Table (Curr_Attr).Next;
end loop;
Real_Attr_Kind := Attr_Kind;
-- If Index_Is_File_Name, change the attribute kind if necessary
if Index_Is_File_Name and then not Osint.File_Names_Case_Sensitive then
case Attr_Kind is
when Associative_Array =>
Real_Attr_Kind := Case_Insensitive_Associative_Array;
when Optional_Index_Associative_Array =>
Real_Attr_Kind :=
Optional_Index_Case_Insensitive_Associative_Array;
when others =>
null;
end case;
end if;
-- Add the new attribute
Attrs.Increment_Last;
Attrs.Table (Attrs.Last) :=
(Name => Attr_Name,
Var_Kind => Var_Kind,
Optional_Index => Opt_Index,
Attr_Kind => Real_Attr_Kind,
Next => First_Attr);
Package_Attributes.Table (In_Package.Value).First_Attribute :=
Attrs.Last;
end Register_New_Attribute;
--------------------------
-- Register_New_Package --
--------------------------
procedure Register_New_Package (Name : String; Id : out Package_Node_Id) is
Pkg_Name : Name_Id;
begin
if Name'Length = 0 then
Fail ("cannot register a package with no name");
Id := Empty_Package;
return;
end if;
Pkg_Name := Name_Id_Of (Name);
for Index in Package_Attributes.First .. Package_Attributes.Last loop
if Package_Attributes.Table (Index).Name = Pkg_Name then
Fail ("cannot register a package with a non unique name""",
Name, """");
Id := Empty_Package;
return;
end if;
end loop;
Package_Attributes.Increment_Last;
Id := (Value => Package_Attributes.Last);
Package_Attributes.Table (Package_Attributes.Last) :=
(Name => Pkg_Name, Known => True, First_Attribute => Empty_Attr);
end Register_New_Package;
procedure Register_New_Package
(Name : String;
Attributes : Attribute_Data_Array)
is
Pkg_Name : Name_Id;
Attr_Name : Name_Id;
First_Attr : Attr_Node_Id := Empty_Attr;
Curr_Attr : Attr_Node_Id;
Attr_Kind : Attribute_Kind;
begin
if Name'Length = 0 then
Fail ("cannot register a package with no name");
raise Project_Error;
end if;
Pkg_Name := Name_Id_Of (Name);
for Index in Package_Attributes.First .. Package_Attributes.Last loop
if Package_Attributes.Table (Index).Name = Pkg_Name then
Fail ("cannot register a package with a non unique name""",
Name, """");
raise Project_Error;
end if;
end loop;
for Index in Attributes'Range loop
Attr_Name := Name_Id_Of (Attributes (Index).Name);
Curr_Attr := First_Attr;
while Curr_Attr /= Empty_Attr loop
if Attrs.Table (Curr_Attr).Name = Attr_Name then
Fail ("duplicate attribute name """, Attributes (Index).Name,
""" in new package """ & Name & """");
raise Project_Error;
end if;
Curr_Attr := Attrs.Table (Curr_Attr).Next;
end loop;
Attr_Kind := Attributes (Index).Attr_Kind;
if Attributes (Index).Index_Is_File_Name
and then not Osint.File_Names_Case_Sensitive
then
case Attr_Kind is
when Associative_Array =>
Attr_Kind := Case_Insensitive_Associative_Array;
when Optional_Index_Associative_Array =>
Attr_Kind :=
Optional_Index_Case_Insensitive_Associative_Array;
when others =>
null;
end case;
end if;
Attrs.Increment_Last;
Attrs.Table (Attrs.Last) :=
(Name => Attr_Name,
Var_Kind => Attributes (Index).Var_Kind,
Optional_Index => Attributes (Index).Opt_Index,
Attr_Kind => Attr_Kind,
Next => First_Attr);
First_Attr := Attrs.Last;
end loop;
Package_Attributes.Increment_Last;
Package_Attributes.Table (Package_Attributes.Last) :=
(Name => Pkg_Name, Known => True, First_Attribute => First_Attr);
end Register_New_Package;
---------------------------
-- Set_Attribute_Kind_Of --
---------------------------
procedure Set_Attribute_Kind_Of
(Attribute : Attribute_Node_Id;
To : Attribute_Kind)
is
begin
if Attribute /= Empty_Attribute then
Attrs.Table (Attribute.Value).Attr_Kind := To;
end if;
end Set_Attribute_Kind_Of;
--------------------------
-- Set_Variable_Kind_Of --
--------------------------
procedure Set_Variable_Kind_Of
(Attribute : Attribute_Node_Id;
To : Variable_Kind)
is
begin
if Attribute /= Empty_Attribute then
Attrs.Table (Attribute.Value).Var_Kind := To;
end if;
end Set_Variable_Kind_Of;
----------------------
-- Variable_Kind_Of --
----------------------
function Variable_Kind_Of
(Attribute : Attribute_Node_Id) return Variable_Kind
is
begin
if Attribute = Empty_Attribute then
return Undefined;
else
return Attrs.Table (Attribute.Value).Var_Kind;
end if;
end Variable_Kind_Of;
------------------------
-- First_Attribute_Of --
------------------------
function First_Attribute_Of
(Pkg : Package_Node_Id) return Attribute_Node_Id
is
begin
if Pkg = Empty_Package then
return Empty_Attribute;
else
return
(Value => Package_Attributes.Table (Pkg.Value).First_Attribute);
end if;
end First_Attribute_Of;
end Prj.Attr;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 1 7 --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- 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. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Handling of packed arrays with Component_Size = 17
package System.Pack_17 is
pragma Preelaborate;
Bits : constant := 17;
type Bits_17 is mod 2 ** Bits;
for Bits_17'Size use Bits;
function Get_17 (Arr : System.Address; N : Natural) return Bits_17;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is extracted and returned.
procedure Set_17 (Arr : System.Address; N : Natural; E : Bits_17);
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is set to the given value.
end System.Pack_17;
|
-----------------------------------------------------------------------
-- ado-schemas -- Database Schemas
-- Copyright (C) 2009, 2010, 2018 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Ada.Finalization;
with Ada.Containers;
with Util.Strings;
with ADO.Configs;
package ADO.Schemas is
type Column_Index is new Natural range 0 .. ADO.Configs.MAX_COLUMNS;
type Member_Names is array (Column_Index range <>) of Util.Strings.Name_Access;
type Class_Mapping (Count : Column_Index)
is tagged limited record
Table : Util.Strings.Name_Access;
Members : Member_Names (1 .. Count);
end record;
type Class_Mapping_Access is access constant Class_Mapping'Class;
-- Get the hash value associated with the class mapping.
function Hash (Mapping : Class_Mapping_Access) return Ada.Containers.Hash_Type;
-- Get the Ada type mapping for the column
type Column_Type is
(
T_UNKNOWN,
-- Boolean column
T_BOOLEAN,
T_TINYINT,
T_SMALLINT,
T_INTEGER,
T_LONG_INTEGER,
T_FLOAT,
T_DOUBLE,
T_DECIMAL,
T_ENUM,
T_SET,
T_TIME,
T_YEAR,
T_DATE,
T_DATE_TIME,
T_TIMESTAMP,
T_CHAR,
T_VARCHAR,
T_BLOB,
T_NULL
);
-- ------------------------------
-- Column Representation
-- ------------------------------
-- Describes a column in a table.
type Column_Definition is private;
-- Get the column name
function Get_Name (Column : Column_Definition) return String;
-- Get the column type
function Get_Type (Column : Column_Definition) return Column_Type;
-- Get the default column value
function Get_Default (Column : Column_Definition) return String;
-- Get the column collation (for string based columns)
function Get_Collation (Column : Column_Definition) return String;
-- Check whether the column can be null
function Is_Null (Column : Column_Definition) return Boolean;
-- Check whether the column is an unsigned number
function Is_Unsigned (Column : Column_Definition) return Boolean;
-- Returns true if the column can hold a binary string
function Is_Binary (Column : Column_Definition) return Boolean;
-- Returns true if the column is a primary key.
function Is_Primary (Column : Column_Definition) return Boolean;
-- Get the column length
function Get_Size (Column : Column_Definition) return Natural;
-- ------------------------------
-- Column iterator
-- ------------------------------
type Column_Cursor is private;
-- Returns true if the iterator contains more column
function Has_Element (Cursor : Column_Cursor) return Boolean;
-- Move to the next column
procedure Next (Cursor : in out Column_Cursor);
-- Get the current column definition
function Element (Cursor : Column_Cursor) return Column_Definition;
-- ------------------------------
-- Table Representation
-- ------------------------------
-- Describes a table in the database. The table contains a list
-- of columns described by Column_Definition.
type Table_Definition is private;
-- Get the table name
function Get_Name (Table : Table_Definition) return String;
-- Get the column iterator
function Get_Columns (Table : Table_Definition) return Column_Cursor;
-- Find the column having the given name
function Find_Column (Table : Table_Definition;
Name : String) return Column_Definition;
-- ------------------------------
-- Table iterator
-- ------------------------------
type Table_Cursor is private;
-- Returns true if the iterator contains more tables
function Has_Element (Cursor : Table_Cursor) return Boolean;
-- Move to the next column
procedure Next (Cursor : in out Table_Cursor);
-- Get the current table definition
function Element (Cursor : Table_Cursor) return Table_Definition;
-- ------------------------------
-- Database Schema
-- ------------------------------
type Schema_Definition is limited private;
-- Find a table knowing its name
function Find_Table (Schema : Schema_Definition;
Name : String) return Table_Definition;
function Get_Tables (Schema : Schema_Definition) return Table_Cursor;
private
use Ada.Strings.Unbounded;
type Column;
type Column_Definition is access all Column;
type Table;
type Table_Definition is access all Table;
type Schema;
type Schema_Access is access all Schema;
type Schema_Definition is new Ada.Finalization.Limited_Controlled with record
Schema : Schema_Access;
end record;
procedure Finalize (Schema : in out Schema_Definition);
type Column_Cursor is record
Current : Column_Definition;
end record;
type Table_Cursor is record
Current : Table_Definition;
end record;
type Column is record
Next_Column : Column_Definition;
Table : Table_Definition;
Name : Unbounded_String;
Default : Unbounded_String;
Collation : Unbounded_String;
Col_Type : Column_Type := T_VARCHAR;
Size : Natural := 0;
Is_Null : Boolean := False;
Is_Binary : Boolean := False;
Is_Unsigned : Boolean := False;
Is_Primary : Boolean := False;
end record;
type Table is record
Name : Unbounded_String;
First_Column : Column_Definition;
Next_Table : Table_Definition;
end record;
type Schema is record
-- Tables : Table_Definition;
First_Table : Table_Definition;
end record;
end ADO.Schemas;
|
-- Abstract :
--
-- See spec.
--
-- Copyright (C) 2017 - 2019 Free Software Foundation, Inc.
--
-- This library is free software; you can redistribute it and/or modify it
-- under terms of the GNU General Public License as published by the Free
-- Software Foundation; either version 3, or (at your option) any later
-- version. This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-- As a special exception under Section 7 of GPL version 3, you are granted
-- additional permissions described in the GCC Runtime Library Exception,
-- version 3.1, as published by the Free Software Foundation.
pragma License (Modified_GPL);
with GNAT.Strings;
package body WisiToken.Lexer is
procedure Finalize (Object : in out Source)
is begin
case Object.Label is
when String_Label =>
if not Object.User_Buffer then
Ada.Strings.Unbounded.Free (Object.Buffer);
end if;
when File_Label =>
GNATCOLL.Mmap.Free (Object.Region);
GNATCOLL.Mmap.Close (Object.File);
end case;
end Finalize;
function Buffer (Source : in Lexer.Source) return GNATCOLL.Mmap.Str_Access
is
use GNATCOLL.Mmap;
begin
case Source.Label is
when String_Label =>
return Short.To_Str_Access (GNAT.Strings.String_Access (Source.Buffer));
when File_Label =>
return Data (Source.Region);
end case;
end Buffer;
function File_Name (Source : in Lexer.Source) return String
is begin
return -Source.File_Name;
end File_Name;
function To_Char_Pos (Source : in Lexer.Source; Lexer_Char_Pos : in Integer) return Base_Buffer_Pos
is begin
return Base_Buffer_Pos (Lexer_Char_Pos) + Source.Buffer_Nominal_First_Char - Buffer_Pos'First;
end To_Char_Pos;
end WisiToken.Lexer;
|
-----------------------------------------------------------------------
-- awa-setup-applications -- Setup and installation
-- Copyright (C) 2016, 2017, 2018, 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.Strings.Unbounded;
with ASF.Applications.Main;
with ASF.Servlets.Faces;
with Servlet.Core.Files;
with ASF.Requests;
with ASF.Responses;
with ASF.Server;
with ADO.Connections;
with Util.Beans.Objects;
with Util.Beans.Basic;
with Util.Beans.Methods;
-- == Setup Procedure Instantiation==
-- The setup process is managed by the *Configure* generic procedure.
-- The procedure must be instantiated with the application class type and
-- the application initialize procedure.
--
-- procedure Setup is
-- new AWA.Setup.Applications.Configure (MyApp.Application'Class,
-- MyApp.Application_Access,
-- MyApp.Initialize);
--
-- == Setup Operation ==
-- The *Setup* instantiated operation must then be called with the web container.
-- The web container is started first and the *Setup* procedure gets as parameter
-- the web container, the application instance to configure, the application name
-- and the application context path.
--
-- Setup (WS, App, "atlas", MyApp.CONTEXT_PATH)
--
-- The operation will install the setup application to handle the setup actions.
-- Through the setup actions, the installer will be able to:
--
-- * Configure the database (MySQL or SQLite),
-- * Configure the Google+ and Facebook OAuth authentication keys,
-- * Configure the application name,
-- * Configure the mail parameters to be able to send email.
--
-- After the setup and configure is finished, the file <tt>.initialized</tt>
-- is created in the application directory to indicate the application is
-- configured. The next time the *Setup* operation is called, the installation
-- process will be skipped.
--
-- To run again the installation, remove manually the <tt>.initialized</tt> file.
package AWA.Setup.Applications is
Empty : constant Util.Beans.Objects.Object := Util.Beans.Objects.To_Object (String '(""));
-- The <b>Servlet</b> represents the component that will handle
-- an HTTP request received by the server.
type Redirect_Servlet is new Servlet.Core.Servlet with null record;
overriding
procedure Do_Get (Server : in Redirect_Servlet;
Request : in out ASF.Requests.Request'Class;
Response : in out ASF.Responses.Response'Class);
-- The configuration state starts in the `CONFIGURING` state and moves to the
-- `STARTING` state after the application is configured and it is started.
-- Once the application is initialized and registered in the server container,
-- the state is changed to `READY`.
type Configure_State is (CONFIGURING, STARTING, READY);
-- Maintains the state of the configuration between the main task and
-- the http configuration requests.
protected type State is
-- Wait until the configuration is finished.
entry Wait_Configuring;
-- Wait until the server application is initialized and ready.
entry Wait_Ready;
-- Set the configuration state.
procedure Set (V : in Configure_State);
private
Value : Configure_State := CONFIGURING;
end State;
type Application is new ASF.Applications.Main.Application and Util.Beans.Basic.Bean
and Util.Beans.Methods.Method_Bean with record
Faces : aliased ASF.Servlets.Faces.Faces_Servlet;
Files : aliased Servlet.Core.Files.File_Servlet;
Redirect : aliased Redirect_Servlet;
Config : ASF.Applications.Config;
Changed : ASF.Applications.Config;
Factory : ASF.Applications.Main.Application_Factory;
Path : Ada.Strings.Unbounded.Unbounded_String;
Database : ADO.Connections.Configuration;
Driver : Util.Beans.Objects.Object;
Result : Util.Beans.Objects.Object;
Root_User : Util.Beans.Objects.Object := Empty;
Root_Passwd : Util.Beans.Objects.Object := Empty;
Db_Host : Util.Beans.Objects.Object;
Db_Port : Util.Beans.Objects.Object;
Has_Error : Boolean := False;
Status : State;
end record;
-- Get the value identified by the name.
function Get_Value (From : in Application;
Name : in String) return Util.Beans.Objects.Object;
-- Set the value identified by the name.
procedure Set_Value (From : in out Application;
Name : in String;
Value : in Util.Beans.Objects.Object);
-- Get the database connection string to be used by the application.
function Get_Database_URL (From : in Application) return String;
-- Get the command to configure the database.
function Get_Configure_Command (From : in Application) return String;
-- Configure the database.
procedure Configure_Database (From : in out Application;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
-- Validate the database configuration parameters.
procedure Validate (From : in out Application);
-- Save the configuration.
procedure Save (From : in out Application;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
-- Finish the setup to start the application.
procedure Start (From : in out Application;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
-- Finish the setup and wait for the application to be started.
procedure Finish (From : in out Application;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
-- This bean provides some methods that can be used in a Method_Expression
overriding
function Get_Method_Bindings (From : in Application)
return Util.Beans.Methods.Method_Binding_Array_Access;
-- Enter in the application setup
procedure Setup (App : in out Application;
Config : in String;
Server : in out ASF.Server.Container'Class);
-- Configure the application by using the setup application, allowing
-- the administrator to setup the application database, define the application
-- admin parameters. After the configuration is done, register the
-- application in the server container and start it.
generic
type Application_Type (<>) is new ASF.Servlets.Servlet_Registry with private;
type Application_Access is access all Application_Type'Class;
with procedure Initialize (App : in Application_Access;
Config : in ASF.Applications.Config);
procedure Configure (Server : in out ASF.Server.Container'Class;
App : in Application_Access;
Config : in String;
URI : in String);
end AWA.Setup.Applications;
|
-----------------------------------------------------------------------
-- files.tests -- Unit tests for files
-- Copyright (C) 2009, 2010, 2011, 2012 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.Tests;
package Util.Files.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
procedure Test_Read_File (T : in out Test);
procedure Test_Read_File_Missing (T : in out Test);
procedure Test_Read_File_Truncate (T : in out Test);
procedure Test_Write_File (T : in out Test);
procedure Test_Find_File_Path (T : in out Test);
procedure Test_Iterate_Path (T : in out Test);
procedure Test_Compose_Path (T : in out Test);
-- Test the Get_Relative_Path operation.
procedure Test_Get_Relative_Path (T : in out Test);
end Util.Files.Tests;
|
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with League.Strings;
with Slim.Menu_Commands;
with Slim.Players.Displays;
package body Slim.Menu_Views is
----------
-- Back --
----------
procedure Back (Self : in out Menu_View'Class) is
use type Slim.Menu_Models.Menu_Path;
Ignore : Boolean;
begin
Self.Current_Menu := Self.Menu.Parent (Self.Current_Menu);
if Self.Current_Menu = Self.Menu.Root then
Self.Current_Menu := Self.Menu.Root;
Ignore := Self.Menu.Child (Self.Current_Menu);
end if;
end Back;
----------
-- Down --
----------
procedure Down (Self : in out Menu_View'Class) is
Ignore : Boolean;
begin
Ignore := Self.Menu.Next (Self.Current_Menu);
end Down;
----------
-- Draw --
----------
procedure Draw
(Self : in out Menu_View'Class;
Display : in out Slim.Players.Displays.Display)
is
Text : constant League.Strings.Universal_String :=
Self.Menu.Label (Self.Current_Menu);
begin
Slim.Players.Displays.Draw_Text
(Self => Display,
X => 1,
Y => 2 - Slim.Fonts.Size (Self.Font.all, Text).Bottom,
Font => Self.Font.all,
Text => Text);
end Draw;
-----------
-- Enter --
-----------
procedure Enter (Self : in out Menu_View'Class) is
procedure Free is new Ada.Unchecked_Deallocation
(Slim.Menu_Commands.Menu_Command'Class,
Slim.Menu_Commands.Menu_Command_Access);
Command : Slim.Menu_Commands.Menu_Command_Access;
begin
if not Self.Menu.Child (Self.Current_Menu) then
Command := Self.Menu.Enter_Command (Self.Current_Menu);
if Command not in null then
Command.Run;
Free (Command);
end if;
end if;
end Enter;
----------------
-- Initialize --
----------------
procedure Initialize
(Self : in out Menu_View'Class;
Menu : Slim.Menu_Models.Menu_Model_Access;
Font : Slim.Fonts.Font_Access)
is
Ignore : Boolean;
begin
Self.Font := Font;
Self.Menu := Menu;
Self.Current_Menu := Menu.Root;
Ignore := Menu.Child (Self.Current_Menu);
end Initialize;
----------
-- Play --
----------
procedure Play (Self : in out Menu_View'Class) is
procedure Free is new Ada.Unchecked_Deallocation
(Slim.Menu_Commands.Menu_Command'Class,
Slim.Menu_Commands.Menu_Command_Access);
Command : Slim.Menu_Commands.Menu_Command_Access;
begin
Command := Self.Menu.Play_Command (Self.Current_Menu);
if Command not in null then
Command.Run;
Free (Command);
end if;
end Play;
--------
-- Up --
--------
procedure Up (Self : in out Menu_View'Class) is
Ignore : Boolean;
begin
Ignore := Self.Menu.Previous (Self.Current_Menu);
end Up;
end Slim.Menu_Views;
|
-- Abstract :
--
-- See spec.
--
-- Copyright (C) 2014, 2017 - 2019 All Rights Reserved.
--
-- This program 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 program is distributed in the
-- hope that it will be useful, but WITHOUT ANY WARRANTY; without even
-- the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-- PURPOSE. See the GNU General Public License for more details. You
-- should have received a copy of the GNU General Public License
-- distributed with this program; see file COPYING. If not, write to
-- the Free Software Foundation, 51 Franklin Street, Suite 500, Boston,
-- MA 02110-1335, USA.
pragma License (GPL);
with Ada.Command_Line;
with Ada.Directories;
with Emacs_Wisi_Common_Parse; use Emacs_Wisi_Common_Parse;
with WisiToken.Text_IO_Trace;
procedure Gen_Emacs_Wisi_LR_Text_Rep_Parse
is
use WisiToken; -- "+", "-" Unbounded_string
Trace : aliased WisiToken.Text_IO_Trace.Trace (Descriptor'Unrestricted_Access);
Parser : WisiToken.Parse.LR.Parser.Parser;
Parse_Data : aliased Parse_Data_Type (Parser.Line_Begin_Token'Access);
Params : constant Process_Start_Params := Get_Process_Start_Params;
begin
Create_Parser
(Parser, Language_Fixes, Language_Matching_Begin_Tokens, Language_String_ID_Set,
Trace'Unrestricted_Access,
Parse_Data'Unchecked_Access,
Ada.Directories.Containing_Directory (Ada.Command_Line.Command_Name) & "/" & Text_Rep_File_Name);
Process_Stream (Name, Language_Protocol_Version, Partial_Parse_Active, Params, Parser, Parse_Data, Descriptor);
end Gen_Emacs_Wisi_LR_Text_Rep_Parse;
|
-- Abstract:
--
-- Bounded stack implementation, with full Spark verification,
-- optimized for speed.
--
-- Copyright (C) 1998-2000, 2002-2003, 2009, 2015, 2017 - 2019 Free Software Foundation, Inc.
--
-- SAL 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. SAL 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 distributed
-- with SAL; see file COPYING. If not, write to the Free Software
-- Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307,
-- USA.
--
-- As a special exception 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);
generic
type Element_Type is private;
package SAL.Gen_Bounded_Definite_Stacks
with Spark_Mode
is
pragma Pure;
-- pragma Suppress (All_Checks); -- Users must check Is_Full before Push, Is_Empty before Pop etc.
package Sgbds renames SAL.Gen_Bounded_Definite_Stacks;
subtype Size_Type is Base_Peek_Type range 0 .. Base_Peek_Type'Last / 2;
-- The upper limit is needed to avoid overflow in Peek.
-- Zero included for Depth result.
type Stack (Size : Size_Type) is tagged private;
-- Tagged to allow Object.Method notation.
-- No Empty_Stack constant, to avoid requiring a Default_Element.
procedure Clear (Stack : in out Sgbds.Stack)
with Post'Class => Depth (Stack) = 0;
-- Empty Stack of all items.
function Depth (Stack : in Sgbds.Stack) return Size_Type;
-- Returns current count of items in Stack
function Is_Empty (Stack : in Sgbds.Stack) return Boolean
with Post'Class => Is_Empty'Result = (Depth (Stack) = 0);
-- Returns true iff no items are in Stack.
function Is_Full (Stack : in Sgbds.Stack) return Boolean
with Post'Class => Is_Full'Result = (Depth (Stack) = Stack.Size);
-- Returns true iff Stack is full.
function Peek (Stack : in Sgbds.Stack; Index : in Peek_Type := 1) return Element_Type
with Pre'Class => Depth (Stack) in 1 .. Stack.Size and Index in 1 .. Depth (Stack);
-- Return the Index'th item from the top of Stack; the Item is _not_ removed.
-- Top item has index 1.
procedure Pop (Stack : in out Sgbds.Stack; Count : in Base_Peek_Type := 1) with
Pre'Class => Depth (Stack) in 1 .. Stack.Size and Count in 0 .. Depth (Stack),
Post'Class => Depth (Stack) = Depth (Stack)'Old - Count and then
(for all I in 1 .. Depth (Stack) => Peek (Stack'Old, I + Count) = Peek (Stack, I));
-- Remove Count Items from the top of Stack, discard them.
procedure Pop (Stack : in out Sgbds.Stack; Item : out Element_Type) with
Pre'Class => Depth (Stack) in 1 .. Stack.Size,
Post'Class =>
Depth (Stack) = Depth (Stack)'Old - 1 and then
(Item = Peek (Stack'Old) and
(for all I in 1 .. Depth (Stack) => Peek (Stack'Old, I + 1) = Peek (Stack, I)));
-- Remove one item from the top of Stack, return in Item.
function Pop (Stack : in out Sgbds.Stack) return Element_Type with
Spark_Mode => Off;
-- Remove one item from the top of Stack, and return it.
procedure Push (Stack : in out Sgbds.Stack; Item : in Element_Type) with
Pre'Class => Depth (Stack) in 0 .. Stack.Size - 1,
Post'Class =>
Depth (Stack) = Depth (Stack)'Old + 1 and then
(Item = Peek (Stack) and
(for all I in 1 .. Depth (Stack'Old) => Peek (Stack'Old, I) = Peek (Stack, I + 1)));
-- Add Item to the top of Stack.
private
type Element_Array is array (Size_Type range <>) of aliased Element_Type;
type Stack (Size : Size_Type) is tagged record
Top : Base_Peek_Type := Invalid_Peek_Index; -- empty
Data : Element_Array (1 .. Size);
-- Top of stack is at Data (Top).
-- Data (1 .. Top) has been set at some point.
end record with
Dynamic_Predicate => Top in 0 .. Size;
end SAL.Gen_Bounded_Definite_Stacks;
|
with TEXT_IO; use TEXT_IO;
procedure HW is
task HELLO;
task WORLD is
entry PRINT_NOW;
end WORLD;
-- --
-- End of type declairations. --
-- --
task body HELLO is
begin
PUT("Hello, ");
WORLD.PRINT_NOW;
end HELLO;
task body WORLD is
begin
accept PRINT_NOW;
PUT("World");
NEW_LINE;
end WORLD;
-- The tasks become active as soon as the procedure under which
-- their scope falls becomes active. (i.e. when procedure HW
-- becomes active then it's tasks are started.
begin -- HW (Hello World)
null;
end HW;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . A L T I V E C . L O W _ L E V E L _ V E C T O R S --
-- --
-- S p e c --
-- (Soft Binding Version) --
-- --
-- Copyright (C) 2004-2009, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This unit exposes the low level vector support for the Soft binding,
-- intended for non AltiVec capable targets. See Altivec.Design for a
-- description of what is expected to be exposed.
with GNAT.Altivec.Vector_Views; use GNAT.Altivec.Vector_Views;
package GNAT.Altivec.Low_Level_Vectors is
----------------------------------------
-- Low level vector type declarations --
----------------------------------------
type LL_VUC is private;
type LL_VSC is private;
type LL_VBC is private;
type LL_VUS is private;
type LL_VSS is private;
type LL_VBS is private;
type LL_VUI is private;
type LL_VSI is private;
type LL_VBI is private;
type LL_VF is private;
type LL_VP is private;
------------------------------------
-- Low level functional interface --
------------------------------------
function abs_v16qi (A : LL_VSC) return LL_VSC;
function abs_v8hi (A : LL_VSS) return LL_VSS;
function abs_v4si (A : LL_VSI) return LL_VSI;
function abs_v4sf (A : LL_VF) return LL_VF;
function abss_v16qi (A : LL_VSC) return LL_VSC;
function abss_v8hi (A : LL_VSS) return LL_VSS;
function abss_v4si (A : LL_VSI) return LL_VSI;
function vaddubm (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vadduhm (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vadduwm (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vaddfp (A : LL_VF; B : LL_VF) return LL_VF;
function vaddcuw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vaddubs (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vaddsbs (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vadduhs (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vaddshs (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vadduws (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vaddsws (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vand (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vandc (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vavgub (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vavgsb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vavguh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vavgsh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vavguw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vavgsw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vcmpbfp (A : LL_VF; B : LL_VF) return LL_VSI;
function vcmpequb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vcmpequh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vcmpequw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vcmpeqfp (A : LL_VF; B : LL_VF) return LL_VSI;
function vcmpgefp (A : LL_VF; B : LL_VF) return LL_VSI;
function vcmpgtub (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vcmpgtsb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vcmpgtuh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vcmpgtsh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vcmpgtuw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vcmpgtsw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vcmpgtfp (A : LL_VF; B : LL_VF) return LL_VSI;
function vcfux (A : LL_VSI; B : c_int) return LL_VF;
function vcfsx (A : LL_VSI; B : c_int) return LL_VF;
function vctsxs (A : LL_VF; B : c_int) return LL_VSI;
function vctuxs (A : LL_VF; B : c_int) return LL_VSI;
procedure dss (A : c_int);
procedure dssall;
procedure dst (A : c_ptr; B : c_int; C : c_int);
procedure dstst (A : c_ptr; B : c_int; C : c_int);
procedure dststt (A : c_ptr; B : c_int; C : c_int);
procedure dstt (A : c_ptr; B : c_int; C : c_int);
function vexptefp (A : LL_VF) return LL_VF;
function vrfim (A : LL_VF) return LL_VF;
function lvx (A : c_long; B : c_ptr) return LL_VSI;
function lvebx (A : c_long; B : c_ptr) return LL_VSC;
function lvehx (A : c_long; B : c_ptr) return LL_VSS;
function lvewx (A : c_long; B : c_ptr) return LL_VSI;
function lvxl (A : c_long; B : c_ptr) return LL_VSI;
function vlogefp (A : LL_VF) return LL_VF;
function lvsl (A : c_long; B : c_ptr) return LL_VSC;
function lvsr (A : c_long; B : c_ptr) return LL_VSC;
function vmaddfp (A : LL_VF; B : LL_VF; C : LL_VF) return LL_VF;
function vmhaddshs (A : LL_VSS; B : LL_VSS; C : LL_VSS) return LL_VSS;
function vmaxub (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vmaxsb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vmaxuh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vmaxsh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vmaxuw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vmaxsw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vmaxfp (A : LL_VF; B : LL_VF) return LL_VF;
function vmrghb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vmrghh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vmrghw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vmrglb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vmrglh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vmrglw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function mfvscr return LL_VSS;
function vminfp (A : LL_VF; B : LL_VF) return LL_VF;
function vminsb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vminsh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vminsw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vminub (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vminuh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vminuw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vmladduhm (A : LL_VSS; B : LL_VSS; C : LL_VSS) return LL_VSS;
function vmhraddshs (A : LL_VSS; B : LL_VSS; C : LL_VSS) return LL_VSS;
function vmsumubm (A : LL_VSC; B : LL_VSC; C : LL_VSI) return LL_VSI;
function vmsummbm (A : LL_VSC; B : LL_VSC; C : LL_VSI) return LL_VSI;
function vmsumuhm (A : LL_VSS; B : LL_VSS; C : LL_VSI) return LL_VSI;
function vmsumshm (A : LL_VSS; B : LL_VSS; C : LL_VSI) return LL_VSI;
function vmsumuhs (A : LL_VSS; B : LL_VSS; C : LL_VSI) return LL_VSI;
function vmsumshs (A : LL_VSS; B : LL_VSS; C : LL_VSI) return LL_VSI;
procedure mtvscr (A : LL_VSI);
function vmuleub (A : LL_VSC; B : LL_VSC) return LL_VSS;
function vmuleuh (A : LL_VSS; B : LL_VSS) return LL_VSI;
function vmulesb (A : LL_VSC; B : LL_VSC) return LL_VSS;
function vmulesh (A : LL_VSS; B : LL_VSS) return LL_VSI;
function vmulosb (A : LL_VSC; B : LL_VSC) return LL_VSS;
function vmulosh (A : LL_VSS; B : LL_VSS) return LL_VSI;
function vmuloub (A : LL_VSC; B : LL_VSC) return LL_VSS;
function vmulouh (A : LL_VSS; B : LL_VSS) return LL_VSI;
function vnmsubfp (A : LL_VF; B : LL_VF; C : LL_VF) return LL_VF;
function vxor (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vnor (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vor (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vpkuhum (A : LL_VSS; B : LL_VSS) return LL_VSC;
function vpkuwum (A : LL_VSI; B : LL_VSI) return LL_VSS;
function vpkpx (A : LL_VSI; B : LL_VSI) return LL_VSS;
function vpkuhus (A : LL_VSS; B : LL_VSS) return LL_VSC;
function vpkuwus (A : LL_VSI; B : LL_VSI) return LL_VSS;
function vpkshss (A : LL_VSS; B : LL_VSS) return LL_VSC;
function vpkswss (A : LL_VSI; B : LL_VSI) return LL_VSS;
function vpkshus (A : LL_VSS; B : LL_VSS) return LL_VSC;
function vpkswus (A : LL_VSI; B : LL_VSI) return LL_VSS;
function vperm_4si (A : LL_VSI; B : LL_VSI; C : LL_VSC) return LL_VSI;
function vrefp (A : LL_VF) return LL_VF;
function vrlb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vrlh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vrlw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vrfin (A : LL_VF) return LL_VF;
function vrfip (A : LL_VF) return LL_VF;
function vrfiz (A : LL_VF) return LL_VF;
function vrsqrtefp (A : LL_VF) return LL_VF;
function vsel_4si (A : LL_VSI; B : LL_VSI; C : LL_VSI) return LL_VSI;
function vslb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vslh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vslw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsldoi_4si (A : LL_VSI; B : LL_VSI; C : c_int) return LL_VSI;
function vsldoi_8hi (A : LL_VSS; B : LL_VSS; C : c_int) return LL_VSS;
function vsldoi_16qi (A : LL_VSC; B : LL_VSC; C : c_int) return LL_VSC;
function vsldoi_4sf (A : LL_VF; B : LL_VF; C : c_int) return LL_VF;
function vsl (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vslo (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vspltb (A : LL_VSC; B : c_int) return LL_VSC;
function vsplth (A : LL_VSS; B : c_int) return LL_VSS;
function vspltw (A : LL_VSI; B : c_int) return LL_VSI;
function vspltisb (A : c_int) return LL_VSC;
function vspltish (A : c_int) return LL_VSS;
function vspltisw (A : c_int) return LL_VSI;
function vsrb (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vsrh (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vsrw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsrab (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vsrah (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vsraw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsr (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsro (A : LL_VSI; B : LL_VSI) return LL_VSI;
procedure stvx (A : LL_VSI; B : c_int; C : c_ptr);
procedure stvebx (A : LL_VSC; B : c_int; C : c_ptr);
procedure stvehx (A : LL_VSS; B : c_int; C : c_ptr);
procedure stvewx (A : LL_VSI; B : c_int; C : c_ptr);
procedure stvxl (A : LL_VSI; B : c_int; C : c_ptr);
function vsububm (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vsubuhm (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vsubuwm (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsubfp (A : LL_VF; B : LL_VF) return LL_VF;
function vsubcuw (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsububs (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vsubsbs (A : LL_VSC; B : LL_VSC) return LL_VSC;
function vsubuhs (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vsubshs (A : LL_VSS; B : LL_VSS) return LL_VSS;
function vsubuws (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsubsws (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsum4ubs (A : LL_VSC; B : LL_VSI) return LL_VSI;
function vsum4sbs (A : LL_VSC; B : LL_VSI) return LL_VSI;
function vsum4shs (A : LL_VSS; B : LL_VSI) return LL_VSI;
function vsum2sws (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vsumsws (A : LL_VSI; B : LL_VSI) return LL_VSI;
function vupkhsb (A : LL_VSC) return LL_VSS;
function vupkhsh (A : LL_VSS) return LL_VSI;
function vupkhpx (A : LL_VSS) return LL_VSI;
function vupklsb (A : LL_VSC) return LL_VSS;
function vupklsh (A : LL_VSS) return LL_VSI;
function vupklpx (A : LL_VSS) return LL_VSI;
function vcmpequb_p (A : c_int; B : LL_VSC; C : LL_VSC) return c_int;
function vcmpequh_p (A : c_int; B : LL_VSS; C : LL_VSS) return c_int;
function vcmpequw_p (A : c_int; B : LL_VSI; C : LL_VSI) return c_int;
function vcmpeqfp_p (A : c_int; B : LL_VF; C : LL_VF) return c_int;
function vcmpgtub_p (A : c_int; B : LL_VSC; C : LL_VSC) return c_int;
function vcmpgtuh_p (A : c_int; B : LL_VSS; C : LL_VSS) return c_int;
function vcmpgtuw_p (A : c_int; B : LL_VSI; C : LL_VSI) return c_int;
function vcmpgtsb_p (A : c_int; B : LL_VSC; C : LL_VSC) return c_int;
function vcmpgtsh_p (A : c_int; B : LL_VSS; C : LL_VSS) return c_int;
function vcmpgtsw_p (A : c_int; B : LL_VSI; C : LL_VSI) return c_int;
function vcmpgtfp_p (A : c_int; B : LL_VF; C : LL_VF) return c_int;
function vcmpgefp_p (A : c_int; B : LL_VF; C : LL_VF) return c_int;
function vcmpbfp_p (A : c_int; B : LL_VF; C : LL_VF) return c_int;
private
---------------------------------------
-- Low level vector type definitions --
---------------------------------------
-- We simply use the natural array definitions corresponding to each
-- user-level vector type.
type LL_VUI is new VUI_View;
type LL_VSI is new VSI_View;
type LL_VBI is new VBI_View;
type LL_VUS is new VUS_View;
type LL_VSS is new VSS_View;
type LL_VBS is new VBS_View;
type LL_VUC is new VUC_View;
type LL_VSC is new VSC_View;
type LL_VBC is new VBC_View;
type LL_VF is new VF_View;
type LL_VP is new VP_View;
------------------------------------
-- Low level functional interface --
------------------------------------
pragma Convention_Identifier (LL_Altivec, C);
pragma Export (LL_Altivec, dss, "__builtin_altivec_dss");
pragma Export (LL_Altivec, dssall, "__builtin_altivec_dssall");
pragma Export (LL_Altivec, dst, "__builtin_altivec_dst");
pragma Export (LL_Altivec, dstst, "__builtin_altivec_dstst");
pragma Export (LL_Altivec, dststt, "__builtin_altivec_dststt");
pragma Export (LL_Altivec, dstt, "__builtin_altivec_dstt");
pragma Export (LL_Altivec, mtvscr, "__builtin_altivec_mtvscr");
pragma Export (LL_Altivec, mfvscr, "__builtin_altivec_mfvscr");
pragma Export (LL_Altivec, stvebx, "__builtin_altivec_stvebx");
pragma Export (LL_Altivec, stvehx, "__builtin_altivec_stvehx");
pragma Export (LL_Altivec, stvewx, "__builtin_altivec_stvewx");
pragma Export (LL_Altivec, stvx, "__builtin_altivec_stvx");
pragma Export (LL_Altivec, stvxl, "__builtin_altivec_stvxl");
pragma Export (LL_Altivec, lvebx, "__builtin_altivec_lvebx");
pragma Export (LL_Altivec, lvehx, "__builtin_altivec_lvehx");
pragma Export (LL_Altivec, lvewx, "__builtin_altivec_lvewx");
pragma Export (LL_Altivec, lvx, "__builtin_altivec_lvx");
pragma Export (LL_Altivec, lvxl, "__builtin_altivec_lvxl");
pragma Export (LL_Altivec, lvsl, "__builtin_altivec_lvsl");
pragma Export (LL_Altivec, lvsr, "__builtin_altivec_lvsr");
pragma Export (LL_Altivec, abs_v16qi, "__builtin_altivec_abs_v16qi");
pragma Export (LL_Altivec, abs_v8hi, "__builtin_altivec_abs_v8hi");
pragma Export (LL_Altivec, abs_v4si, "__builtin_altivec_abs_v4si");
pragma Export (LL_Altivec, abs_v4sf, "__builtin_altivec_abs_v4sf");
pragma Export (LL_Altivec, abss_v16qi, "__builtin_altivec_abss_v16qi");
pragma Export (LL_Altivec, abss_v8hi, "__builtin_altivec_abss_v8hi");
pragma Export (LL_Altivec, abss_v4si, "__builtin_altivec_abss_v4si");
pragma Export (LL_Altivec, vaddcuw, "__builtin_altivec_vaddcuw");
pragma Export (LL_Altivec, vaddfp, "__builtin_altivec_vaddfp");
pragma Export (LL_Altivec, vaddsbs, "__builtin_altivec_vaddsbs");
pragma Export (LL_Altivec, vaddshs, "__builtin_altivec_vaddshs");
pragma Export (LL_Altivec, vaddsws, "__builtin_altivec_vaddsws");
pragma Export (LL_Altivec, vaddubm, "__builtin_altivec_vaddubm");
pragma Export (LL_Altivec, vaddubs, "__builtin_altivec_vaddubs");
pragma Export (LL_Altivec, vadduhm, "__builtin_altivec_vadduhm");
pragma Export (LL_Altivec, vadduhs, "__builtin_altivec_vadduhs");
pragma Export (LL_Altivec, vadduwm, "__builtin_altivec_vadduwm");
pragma Export (LL_Altivec, vadduws, "__builtin_altivec_vadduws");
pragma Export (LL_Altivec, vand, "__builtin_altivec_vand");
pragma Export (LL_Altivec, vandc, "__builtin_altivec_vandc");
pragma Export (LL_Altivec, vavgsb, "__builtin_altivec_vavgsb");
pragma Export (LL_Altivec, vavgsh, "__builtin_altivec_vavgsh");
pragma Export (LL_Altivec, vavgsw, "__builtin_altivec_vavgsw");
pragma Export (LL_Altivec, vavgub, "__builtin_altivec_vavgub");
pragma Export (LL_Altivec, vavguh, "__builtin_altivec_vavguh");
pragma Export (LL_Altivec, vavguw, "__builtin_altivec_vavguw");
pragma Export (LL_Altivec, vcfsx, "__builtin_altivec_vcfsx");
pragma Export (LL_Altivec, vcfux, "__builtin_altivec_vcfux");
pragma Export (LL_Altivec, vcmpbfp, "__builtin_altivec_vcmpbfp");
pragma Export (LL_Altivec, vcmpeqfp, "__builtin_altivec_vcmpeqfp");
pragma Export (LL_Altivec, vcmpequb, "__builtin_altivec_vcmpequb");
pragma Export (LL_Altivec, vcmpequh, "__builtin_altivec_vcmpequh");
pragma Export (LL_Altivec, vcmpequw, "__builtin_altivec_vcmpequw");
pragma Export (LL_Altivec, vcmpgefp, "__builtin_altivec_vcmpgefp");
pragma Export (LL_Altivec, vcmpgtfp, "__builtin_altivec_vcmpgtfp");
pragma Export (LL_Altivec, vcmpgtsb, "__builtin_altivec_vcmpgtsb");
pragma Export (LL_Altivec, vcmpgtsh, "__builtin_altivec_vcmpgtsh");
pragma Export (LL_Altivec, vcmpgtsw, "__builtin_altivec_vcmpgtsw");
pragma Export (LL_Altivec, vcmpgtub, "__builtin_altivec_vcmpgtub");
pragma Export (LL_Altivec, vcmpgtuh, "__builtin_altivec_vcmpgtuh");
pragma Export (LL_Altivec, vcmpgtuw, "__builtin_altivec_vcmpgtuw");
pragma Export (LL_Altivec, vctsxs, "__builtin_altivec_vctsxs");
pragma Export (LL_Altivec, vctuxs, "__builtin_altivec_vctuxs");
pragma Export (LL_Altivec, vexptefp, "__builtin_altivec_vexptefp");
pragma Export (LL_Altivec, vlogefp, "__builtin_altivec_vlogefp");
pragma Export (LL_Altivec, vmaddfp, "__builtin_altivec_vmaddfp");
pragma Export (LL_Altivec, vmaxfp, "__builtin_altivec_vmaxfp");
pragma Export (LL_Altivec, vmaxsb, "__builtin_altivec_vmaxsb");
pragma Export (LL_Altivec, vmaxsh, "__builtin_altivec_vmaxsh");
pragma Export (LL_Altivec, vmaxsw, "__builtin_altivec_vmaxsw");
pragma Export (LL_Altivec, vmaxub, "__builtin_altivec_vmaxub");
pragma Export (LL_Altivec, vmaxuh, "__builtin_altivec_vmaxuh");
pragma Export (LL_Altivec, vmaxuw, "__builtin_altivec_vmaxuw");
pragma Export (LL_Altivec, vmhaddshs, "__builtin_altivec_vmhaddshs");
pragma Export (LL_Altivec, vmhraddshs, "__builtin_altivec_vmhraddshs");
pragma Export (LL_Altivec, vminfp, "__builtin_altivec_vminfp");
pragma Export (LL_Altivec, vminsb, "__builtin_altivec_vminsb");
pragma Export (LL_Altivec, vminsh, "__builtin_altivec_vminsh");
pragma Export (LL_Altivec, vminsw, "__builtin_altivec_vminsw");
pragma Export (LL_Altivec, vminub, "__builtin_altivec_vminub");
pragma Export (LL_Altivec, vminuh, "__builtin_altivec_vminuh");
pragma Export (LL_Altivec, vminuw, "__builtin_altivec_vminuw");
pragma Export (LL_Altivec, vmladduhm, "__builtin_altivec_vmladduhm");
pragma Export (LL_Altivec, vmrghb, "__builtin_altivec_vmrghb");
pragma Export (LL_Altivec, vmrghh, "__builtin_altivec_vmrghh");
pragma Export (LL_Altivec, vmrghw, "__builtin_altivec_vmrghw");
pragma Export (LL_Altivec, vmrglb, "__builtin_altivec_vmrglb");
pragma Export (LL_Altivec, vmrglh, "__builtin_altivec_vmrglh");
pragma Export (LL_Altivec, vmrglw, "__builtin_altivec_vmrglw");
pragma Export (LL_Altivec, vmsummbm, "__builtin_altivec_vmsummbm");
pragma Export (LL_Altivec, vmsumshm, "__builtin_altivec_vmsumshm");
pragma Export (LL_Altivec, vmsumshs, "__builtin_altivec_vmsumshs");
pragma Export (LL_Altivec, vmsumubm, "__builtin_altivec_vmsumubm");
pragma Export (LL_Altivec, vmsumuhm, "__builtin_altivec_vmsumuhm");
pragma Export (LL_Altivec, vmsumuhs, "__builtin_altivec_vmsumuhs");
pragma Export (LL_Altivec, vmulesb, "__builtin_altivec_vmulesb");
pragma Export (LL_Altivec, vmulesh, "__builtin_altivec_vmulesh");
pragma Export (LL_Altivec, vmuleub, "__builtin_altivec_vmuleub");
pragma Export (LL_Altivec, vmuleuh, "__builtin_altivec_vmuleuh");
pragma Export (LL_Altivec, vmulosb, "__builtin_altivec_vmulosb");
pragma Export (LL_Altivec, vmulosh, "__builtin_altivec_vmulosh");
pragma Export (LL_Altivec, vmuloub, "__builtin_altivec_vmuloub");
pragma Export (LL_Altivec, vmulouh, "__builtin_altivec_vmulouh");
pragma Export (LL_Altivec, vnmsubfp, "__builtin_altivec_vnmsubfp");
pragma Export (LL_Altivec, vnor, "__builtin_altivec_vnor");
pragma Export (LL_Altivec, vxor, "__builtin_altivec_vxor");
pragma Export (LL_Altivec, vor, "__builtin_altivec_vor");
pragma Export (LL_Altivec, vperm_4si, "__builtin_altivec_vperm_4si");
pragma Export (LL_Altivec, vpkpx, "__builtin_altivec_vpkpx");
pragma Export (LL_Altivec, vpkshss, "__builtin_altivec_vpkshss");
pragma Export (LL_Altivec, vpkshus, "__builtin_altivec_vpkshus");
pragma Export (LL_Altivec, vpkswss, "__builtin_altivec_vpkswss");
pragma Export (LL_Altivec, vpkswus, "__builtin_altivec_vpkswus");
pragma Export (LL_Altivec, vpkuhum, "__builtin_altivec_vpkuhum");
pragma Export (LL_Altivec, vpkuhus, "__builtin_altivec_vpkuhus");
pragma Export (LL_Altivec, vpkuwum, "__builtin_altivec_vpkuwum");
pragma Export (LL_Altivec, vpkuwus, "__builtin_altivec_vpkuwus");
pragma Export (LL_Altivec, vrefp, "__builtin_altivec_vrefp");
pragma Export (LL_Altivec, vrfim, "__builtin_altivec_vrfim");
pragma Export (LL_Altivec, vrfin, "__builtin_altivec_vrfin");
pragma Export (LL_Altivec, vrfip, "__builtin_altivec_vrfip");
pragma Export (LL_Altivec, vrfiz, "__builtin_altivec_vrfiz");
pragma Export (LL_Altivec, vrlb, "__builtin_altivec_vrlb");
pragma Export (LL_Altivec, vrlh, "__builtin_altivec_vrlh");
pragma Export (LL_Altivec, vrlw, "__builtin_altivec_vrlw");
pragma Export (LL_Altivec, vrsqrtefp, "__builtin_altivec_vrsqrtefp");
pragma Export (LL_Altivec, vsel_4si, "__builtin_altivec_vsel_4si");
pragma Export (LL_Altivec, vsldoi_4si, "__builtin_altivec_vsldoi_4si");
pragma Export (LL_Altivec, vsldoi_8hi, "__builtin_altivec_vsldoi_8hi");
pragma Export (LL_Altivec, vsldoi_16qi, "__builtin_altivec_vsldoi_16qi");
pragma Export (LL_Altivec, vsldoi_4sf, "__builtin_altivec_vsldoi_4sf");
pragma Export (LL_Altivec, vsl, "__builtin_altivec_vsl");
pragma Export (LL_Altivec, vslb, "__builtin_altivec_vslb");
pragma Export (LL_Altivec, vslh, "__builtin_altivec_vslh");
pragma Export (LL_Altivec, vslo, "__builtin_altivec_vslo");
pragma Export (LL_Altivec, vslw, "__builtin_altivec_vslw");
pragma Export (LL_Altivec, vspltb, "__builtin_altivec_vspltb");
pragma Export (LL_Altivec, vsplth, "__builtin_altivec_vsplth");
pragma Export (LL_Altivec, vspltisb, "__builtin_altivec_vspltisb");
pragma Export (LL_Altivec, vspltish, "__builtin_altivec_vspltish");
pragma Export (LL_Altivec, vspltisw, "__builtin_altivec_vspltisw");
pragma Export (LL_Altivec, vspltw, "__builtin_altivec_vspltw");
pragma Export (LL_Altivec, vsr, "__builtin_altivec_vsr");
pragma Export (LL_Altivec, vsrab, "__builtin_altivec_vsrab");
pragma Export (LL_Altivec, vsrah, "__builtin_altivec_vsrah");
pragma Export (LL_Altivec, vsraw, "__builtin_altivec_vsraw");
pragma Export (LL_Altivec, vsrb, "__builtin_altivec_vsrb");
pragma Export (LL_Altivec, vsrh, "__builtin_altivec_vsrh");
pragma Export (LL_Altivec, vsro, "__builtin_altivec_vsro");
pragma Export (LL_Altivec, vsrw, "__builtin_altivec_vsrw");
pragma Export (LL_Altivec, vsubcuw, "__builtin_altivec_vsubcuw");
pragma Export (LL_Altivec, vsubfp, "__builtin_altivec_vsubfp");
pragma Export (LL_Altivec, vsubsbs, "__builtin_altivec_vsubsbs");
pragma Export (LL_Altivec, vsubshs, "__builtin_altivec_vsubshs");
pragma Export (LL_Altivec, vsubsws, "__builtin_altivec_vsubsws");
pragma Export (LL_Altivec, vsububm, "__builtin_altivec_vsububm");
pragma Export (LL_Altivec, vsububs, "__builtin_altivec_vsububs");
pragma Export (LL_Altivec, vsubuhm, "__builtin_altivec_vsubuhm");
pragma Export (LL_Altivec, vsubuhs, "__builtin_altivec_vsubuhs");
pragma Export (LL_Altivec, vsubuwm, "__builtin_altivec_vsubuwm");
pragma Export (LL_Altivec, vsubuws, "__builtin_altivec_vsubuws");
pragma Export (LL_Altivec, vsum2sws, "__builtin_altivec_vsum2sws");
pragma Export (LL_Altivec, vsum4sbs, "__builtin_altivec_vsum4sbs");
pragma Export (LL_Altivec, vsum4shs, "__builtin_altivec_vsum4shs");
pragma Export (LL_Altivec, vsum4ubs, "__builtin_altivec_vsum4ubs");
pragma Export (LL_Altivec, vsumsws, "__builtin_altivec_vsumsws");
pragma Export (LL_Altivec, vupkhpx, "__builtin_altivec_vupkhpx");
pragma Export (LL_Altivec, vupkhsb, "__builtin_altivec_vupkhsb");
pragma Export (LL_Altivec, vupkhsh, "__builtin_altivec_vupkhsh");
pragma Export (LL_Altivec, vupklpx, "__builtin_altivec_vupklpx");
pragma Export (LL_Altivec, vupklsb, "__builtin_altivec_vupklsb");
pragma Export (LL_Altivec, vupklsh, "__builtin_altivec_vupklsh");
pragma Export (LL_Altivec, vcmpbfp_p, "__builtin_altivec_vcmpbfp_p");
pragma Export (LL_Altivec, vcmpeqfp_p, "__builtin_altivec_vcmpeqfp_p");
pragma Export (LL_Altivec, vcmpgefp_p, "__builtin_altivec_vcmpgefp_p");
pragma Export (LL_Altivec, vcmpgtfp_p, "__builtin_altivec_vcmpgtfp_p");
pragma Export (LL_Altivec, vcmpequw_p, "__builtin_altivec_vcmpequw_p");
pragma Export (LL_Altivec, vcmpgtsw_p, "__builtin_altivec_vcmpgtsw_p");
pragma Export (LL_Altivec, vcmpgtuw_p, "__builtin_altivec_vcmpgtuw_p");
pragma Export (LL_Altivec, vcmpgtuh_p, "__builtin_altivec_vcmpgtuh_p");
pragma Export (LL_Altivec, vcmpgtsh_p, "__builtin_altivec_vcmpgtsh_p");
pragma Export (LL_Altivec, vcmpequh_p, "__builtin_altivec_vcmpequh_p");
pragma Export (LL_Altivec, vcmpequb_p, "__builtin_altivec_vcmpequb_p");
pragma Export (LL_Altivec, vcmpgtsb_p, "__builtin_altivec_vcmpgtsb_p");
pragma Export (LL_Altivec, vcmpgtub_p, "__builtin_altivec_vcmpgtub_p");
end GNAT.Altivec.Low_Level_Vectors;
|
-- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with swig;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_setup_request_t is
-- Item
--
type Item is record
byte_order : aliased Interfaces.Unsigned_8;
pad0 : aliased Interfaces.Unsigned_8;
protocol_major_version : aliased Interfaces.Unsigned_16;
protocol_minor_version : aliased Interfaces.Unsigned_16;
authorization_protocol_name_len : aliased Interfaces.Unsigned_16;
authorization_protocol_data_len : aliased Interfaces.Unsigned_16;
pad1 : aliased swig.int8_t_Array (0 .. 1);
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_setup_request_t.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_setup_request_t.Item,
Element_Array => xcb.xcb_setup_request_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_setup_request_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_setup_request_t.Pointer,
Element_Array => xcb.xcb_setup_request_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_setup_request_t;
|
-- 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);
with Ada.Exceptions;
with SAL.Gen_Bounded_Definite_Queues;
with WisiToken.Parse.LR.McKenzie_Recover.Parse;
with WisiToken.Parse.LR.Parser;
package body WisiToken.Parse.LR.McKenzie_Recover.Explore is
procedure Do_Shift
(Label : in String;
Super : not null access Base.Supervisor;
Shared : not null access Base.Shared;
Parser_Index : in SAL.Peek_Type;
Local_Config_Heap : in out Config_Heaps.Heap_Type;
Config : in out Configuration;
State : in State_Index;
ID : in Token_ID;
Cost_Delta : in Integer;
Strategy : in Strategies)
is
use Config_Op_Arrays;
McKenzie_Param : McKenzie_Param_Type renames Shared.Table.McKenzie_Param;
Op : constant Config_Op := (Insert, ID, Config.Current_Shared_Token, State, Config.Stack.Depth);
begin
Config.Strategy_Counts (Strategy) := Config.Strategy_Counts (Strategy) + 1;
if Is_Full (Config.Ops) then
Super.Config_Full ("do_shift ops", Parser_Index);
raise Bad_Config;
else
Append (Config.Ops, Op);
end if;
if Cost_Delta = 0 then
Config.Cost := Config.Cost + McKenzie_Param.Insert (ID);
else
-- Cost_Delta /= 0 comes from Insert_Minimal_Complete_Actions. That
-- doesn't mean it is better than any other solution, so don't let
-- cost be 0.
--
-- We don't just eliminate all cost for Minimal_Complete_Actions;
-- that leads to using it far too much at the expense of better
-- solutions.
Config.Cost := Integer'Max (1, Config.Cost + McKenzie_Param.Insert (ID) + Cost_Delta);
end if;
Config.Error_Token.ID := Invalid_Token_ID;
Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok);
if Config.Stack.Is_Full then
Super.Config_Full ("do_shift stack", Parser_Index);
raise Bad_Config;
else
Config.Stack.Push ((State, Syntax_Trees.Invalid_Node_Index, (ID, Virtual => True, others => <>)));
end if;
if Trace_McKenzie > Detail then
Base.Put
((if Label'Length > 0 then Label & ": " else "") & "insert " & Image (ID, Super.Trace.Descriptor.all),
Super, Shared, Parser_Index, Config);
end if;
Local_Config_Heap.Add (Config);
end Do_Shift;
procedure Do_Reduce_1
(Label : in String;
Super : not null access Base.Supervisor;
Shared : not null access Base.Shared;
Parser_Index : in SAL.Peek_Type;
Local_Config_Heap : in out Config_Heaps.Heap_Type;
Config : in out Configuration;
Action : in Reduce_Action_Rec;
Do_Language_Fixes : in Boolean := True)
is
use all type Semantic_Checks.Check_Status_Label;
use all type WisiToken.Parse.LR.Parser.Language_Fixes_Access;
Prev_State : constant Unknown_State_Index := Config.Stack.Peek.State;
Descriptor : WisiToken.Descriptor renames Super.Trace.Descriptor.all;
Table : Parse_Table renames Shared.Table.all;
Nonterm : Recover_Token;
New_State : Unknown_State_Index;
begin
Config.Check_Status := Parse.Reduce_Stack (Shared, Config.Stack, Action, Nonterm, Default_Virtual => True);
case Config.Check_Status.Label is
when Ok =>
null;
when Semantic_Checks.Error =>
Config.Error_Token := Nonterm;
Config.Check_Token_Count := Action.Token_Count;
if Do_Language_Fixes then
if Shared.Language_Fixes /= null then
Shared.Language_Fixes
(Super.Trace.all, Shared.Lexer, Super.Label (Parser_Index), Shared.Table.all, Shared.Terminals.all,
Super.Parser_State (Parser_Index).Tree, Local_Config_Heap,
Config);
end if;
end if;
-- Finish the reduce; ignore the check fail.
if Config.Stack.Depth < SAL.Base_Peek_Type (Config.Check_Token_Count) then
raise SAL.Programmer_Error;
else
Config.Stack.Pop (SAL.Base_Peek_Type (Config.Check_Token_Count));
end if;
Config.Error_Token.ID := Invalid_Token_ID;
Config.Check_Status := (Label => Ok);
end case;
if Config.Stack.Depth = 0 or else Config.Stack.Peek.State = Unknown_State then
raise Bad_Config;
end if;
New_State := Goto_For (Table, Config.Stack.Peek.State, Action.Production.LHS);
if New_State = Unknown_State then
if Trace_McKenzie > Extra then
Put_Line
(Super.Trace.all, Super.Label (Parser_Index), Label &
": Do_Reduce_1: unknown_State " & Config.Stack.Peek.State'Image & " " &
Image (Action.Production.LHS, Descriptor));
end if;
raise Bad_Config;
end if;
Config.Stack.Push ((New_State, Syntax_Trees.Invalid_Node_Index, Nonterm));
if Trace_McKenzie > Extra and Label'Length > 0 then
Put_Line
(Super.Trace.all, Super.Label (Parser_Index), Label &
": state" & State_Index'Image (Prev_State) & " reduce" &
Ada.Containers.Count_Type'Image (Action.Token_Count) & " to " &
Image (Action.Production.LHS, Descriptor) & ", goto" &
State_Index'Image (New_State) & " via" & State_Index'Image (Config.Stack.Peek (2).State));
end if;
end Do_Reduce_1;
procedure Do_Reduce_2
(Label : in String;
Super : not null access Base.Supervisor;
Shared : not null access Base.Shared;
Parser_Index : in SAL.Peek_Type;
Local_Config_Heap : in out Config_Heaps.Heap_Type;
Config : in out Configuration;
Inserted_ID : in Token_ID;
Cost_Delta : in Integer;
Strategy : in Strategies)
is
-- Perform reduce actions until shift Inserted_ID; if all succeed,
-- add the final configuration to the heap, return True. If a conflict is
-- encountered, process the other action the same way. If a semantic
-- check fails, enqueue possible solutions. For parse table error
-- actions, or exception Bad_Config, return False.
Orig_Config : Configuration;
Table : Parse_Table renames Shared.Table.all;
Next_Action : Parse_Action_Node_Ptr := Action_For (Table, Config.Stack.Peek.State, Inserted_ID);
begin
if Next_Action.Next /= null then
Orig_Config := Config;
end if;
case Next_Action.Item.Verb is
when Shift =>
Do_Shift
(Label, Super, Shared, Parser_Index, Local_Config_Heap, Config, Next_Action.Item.State, Inserted_ID,
Cost_Delta, Strategy);
when Reduce =>
Do_Reduce_1 (Label, Super, Shared, Parser_Index, Local_Config_Heap, Config, Next_Action.Item);
Do_Reduce_2
(Label, Super, Shared, Parser_Index, Local_Config_Heap, Config, Inserted_ID, Cost_Delta, Strategy);
when Accept_It =>
raise SAL.Programmer_Error with "found test case for Do_Reduce Accept_It";
when Error =>
null;
end case;
loop
exit when Next_Action.Next = null;
-- There is a conflict; create a new config to shift or reduce.
declare
New_Config : Configuration := Orig_Config;
Action : Parse_Action_Rec renames Next_Action.Next.Item;
begin
case Action.Verb is
when Shift =>
Do_Shift
(Label, Super, Shared, Parser_Index, Local_Config_Heap, New_Config, Action.State, Inserted_ID,
Cost_Delta, Strategy);
when Reduce =>
Do_Reduce_1 (Label, Super, Shared, Parser_Index, Local_Config_Heap, New_Config, Action);
Do_Reduce_2
(Label, Super, Shared, Parser_Index, Local_Config_Heap, New_Config, Inserted_ID,
Cost_Delta, Strategy);
when Accept_It =>
raise SAL.Programmer_Error with "found test case for Do_Reduce Accept_It conflict";
when Error =>
null;
end case;
end;
Next_Action := Next_Action.Next;
end loop;
exception
when Bad_Config =>
if Debug_Mode then
raise;
end if;
end Do_Reduce_2;
function Fast_Forward
(Super : not null access Base.Supervisor;
Shared : not null access Base.Shared;
Parser_Index : in SAL.Base_Peek_Type;
Local_Config_Heap : in out Config_Heaps.Heap_Type;
Config : in out Configuration)
return Non_Success_Status
is
-- Apply the ops in Config; they were inserted by some fix.
-- Return Abandon if Config should be abandoned, otherwise Continue.
-- Leaves Config.Error_Token, Config.Check_Status set.
--
-- If there are conflicts, all are parsed; if more than one succeed,
-- all are enqueued in Local_Config_Heap, and this returns Abandon.
use Parse.Parse_Item_Arrays;
use Config_Op_Arrays;
use all type Ada.Containers.Count_Type;
Parse_Items : aliased Parse.Parse_Item_Arrays.Vector;
Dummy : Boolean := Parse.Parse
(Super, Shared, Parser_Index, Parse_Items, Config,
Shared_Token_Goal => Invalid_Token_Index,
All_Conflicts => True,
Trace_Prefix => "fast_forward");
begin
-- This solution is from Language_Fixes; any cost increase is done there.
if Length (Parse_Items) = 1 then
declare
Item : Parse.Parse_Item renames Parse.Parse_Item_Array_Refs.Constant_Ref (Parse_Items, 1);
begin
if Item.Parsed and Item.Config.Current_Insert_Delete = No_Insert_Delete then
-- Item.Config.Error_Token.ID, Check_Status are correct.
Config := Item.Config;
if Is_Full (Config.Ops) then
Super.Config_Full ("fast_forward 1", Parser_Index);
return Abandon;
else
Append (Config.Ops, (Fast_Forward, Config.Current_Shared_Token));
end if;
Config.Minimal_Complete_State := None;
Config.Matching_Begin_Done := False;
return Continue;
else
return Abandon;
end if;
end;
else
for I in First_Index (Parse_Items) .. Last_Index (Parse_Items) loop
declare
Item : Parse.Parse_Item renames Parse.Parse_Item_Array_Refs.Variable_Ref (Parse_Items, I);
begin
if Item.Parsed and Item.Config.Current_Insert_Delete = No_Insert_Delete then
if Is_Full (Config.Ops) then
Super.Config_Full ("fast_forward 2", Parser_Index);
return Abandon;
else
Append (Item.Config.Ops, (Fast_Forward, Item.Config.Current_Shared_Token));
end if;
Item.Config.Minimal_Complete_State := None;
Item.Config.Matching_Begin_Done := False;
Local_Config_Heap.Add (Item.Config);
if Trace_McKenzie > Detail then
Base.Put ("fast forward enqueue", Super, Shared, Parser_Index, Item.Config);
end if;
end if;
end;
end loop;
return Abandon;
end if;
exception
when Bad_Config =>
return Abandon;
end Fast_Forward;
function Check
(Super : not null access Base.Supervisor;
Shared : not null access Base.Shared;
Parser_Index : in SAL.Base_Peek_Type;
Config : in out Configuration;
Local_Config_Heap : in out Config_Heaps.Heap_Type)
return Check_Status
is
use Config_Op_Arrays, Config_Op_Array_Refs;
use Parse.Parse_Item_Arrays;
use all type Semantic_Checks.Check_Status_Label;
McKenzie_Param : McKenzie_Param_Type renames Shared.Table.McKenzie_Param;
Parse_Items : aliased Parse.Parse_Item_Arrays.Vector;
Result : Check_Status := Continue;
function Max_Push_Back_Token_Index (Ops : aliased in Config_Op_Arrays.Vector) return WisiToken.Base_Token_Index
is
Result : WisiToken.Base_Token_Index := WisiToken.Base_Token_Index'First;
begin
-- For Ops since last Fast_Forward, return maximum Token_Index in a
-- Push_Back. If there are no such ops, return a value that will be
-- less than the current token index.
for I in reverse First_Index (Ops) .. Last_Index (Ops) loop
declare
Op : Config_Op renames Constant_Ref (Ops, I);
begin
exit when Op.Op = Fast_Forward;
if Op.Op = Push_Back and then Op.PB_Token_Index > Result then
Result := Op.PB_Token_Index;
end if;
end;
end loop;
return Result;
end Max_Push_Back_Token_Index;
begin
if Parse.Parse
(Super, Shared, Parser_Index, Parse_Items, Config, Config.Resume_Token_Goal,
All_Conflicts => False,
Trace_Prefix => "check")
then
Config.Error_Token.ID := Invalid_Token_ID;
-- FIXME: if there were conflicts, enqueue them; they might yield a
-- cheaper or same cost solution?
return Success;
end if;
-- Set Config.error to reflect failure, if it is at current token, so
-- Use_Minimal_Complete_Actions can see it.
declare
Item : Parse.Parse_Item renames Parse.Parse_Item_Array_Refs.Constant_Ref
(Parse_Items, First_Index (Parse_Items));
begin
if Item.Config.Check_Status.Label /= Ok then
Config.Check_Status := Item.Config.Check_Status;
Config.Error_Token := Item.Config.Error_Token;
-- Explore cannot fix a check fail; only Language_Fixes can. The
-- "ignore error" case is handled immediately on return from
-- Language_Fixes in Process_One, below.
Result := Abandon;
elsif Item.Config.Error_Token.ID /= Invalid_Token_ID then
if Item.Shift_Count = 0 then
Config.Error_Token := Item.Config.Error_Token;
Config.Check_Status := (Label => Ok);
else
-- Error is not at current token, but Explore might find something
-- that will help (see test_mckenzie_recover.adb Extra_Begin). On the
-- other hand, this can lead to lots of bogus configs (see
-- If_In_Handler).
Config.Error_Token.ID := Invalid_Token_ID;
Config.Check_Status := (Label => Ok);
end if;
end if;
end;
-- All Parse_Items either failed or were not parsed; if they failed
-- and made progress, enqueue them so Language_Fixes can try to fix
-- them.
for I in First_Index (Parse_Items) .. Last_Index (Parse_Items) loop
declare
Item : Parse.Parse_Item renames Parse.Parse_Item_Array_Refs.Variable_Ref (Parse_Items, I);
begin
if Item.Config.Error_Token.ID /= Invalid_Token_ID and then
Item.Shift_Count > 0 and then
Max_Push_Back_Token_Index (Item.Config.Ops) < Item.Config.Current_Shared_Token - 1
then
-- Some progress was made; explore at the new error point. It is
-- likely that there is only one actual error point, and this moves
-- away from it, so we give it a cost.
begin
Item.Config.Minimal_Complete_State := None;
Item.Config.Matching_Begin_Done := False;
if Constant_Ref (Item.Config.Ops, Last_Index (Item.Config.Ops)).Op = Fast_Forward then
Item.Config.Cost := Item.Config.Cost + McKenzie_Param.Fast_Forward;
Variable_Ref (Item.Config.Ops, Last_Index (Item.Config.Ops)).FF_Token_Index :=
Item.Config.Current_Shared_Token;
else
Item.Config.Cost := Item.Config.Cost + McKenzie_Param.Fast_Forward;
if Is_Full (Item.Config.Ops) then
Super.Config_Full ("check 1", Parser_Index);
raise Bad_Config;
else
Append (Item.Config.Ops, (Fast_Forward, Item.Config.Current_Shared_Token));
end if;
end if;
end;
Local_Config_Heap.Add (Item.Config);
if Trace_McKenzie > Detail then
Base.Put ("new error point ", Super, Shared, Parser_Index, Item.Config);
end if;
end if;
end;
end loop;
if Trace_McKenzie > Extra then
Put_Line (Super.Trace.all, Super.Label (Parser_Index), "check result: " & Result'Image);
end if;
return Result;
exception
when Bad_Config =>
return Abandon;
end Check;
function Check_Reduce_To_Start
(Super : not null access Base.Supervisor;
Shared : not null access Base.Shared;
Parser_Index : in SAL.Base_Peek_Type;
Orig_Config : in Configuration)
return Boolean
-- Returns True if Config reduces to the start nonterm.
is
Table : Parse_Table renames Shared.Table.all;
function To_Reduce_Action (Item : in Minimal_Action) return Reduce_Action_Rec
is begin
return (Reduce, (Item.Nonterm, 0), null, null, Item.Token_Count);
end To_Reduce_Action;
Local_Config_Heap : Config_Heaps.Heap_Type; -- never used, because Do_Language_Fixes is False.
Config : Configuration := Orig_Config;
Actions : Minimal_Action_Arrays.Vector := Table.States (Config.Stack.Peek.State).Minimal_Complete_Actions;
begin
loop
case Actions.Length is
when 0 =>
if (for some Item of Table.States (Config.Stack.Peek.State).Kernel =>
Item.LHS = Super.Trace.Descriptor.Accept_ID)
then
return True;
else
return False;
end if;
when 1 =>
case Actions (Actions.First_Index).Verb is
when Shift =>
return False;
when Reduce =>
Do_Reduce_1
("", Super, Shared, Parser_Index, Local_Config_Heap, Config,
To_Reduce_Action (Actions (Actions.First_Index)),
Do_Language_Fixes => False);
Actions := Table.States (Config.Stack.Peek.State).Minimal_Complete_Actions;
end case;
when others =>
return False;
end case;
-- loop only exits via returns above
end loop;
exception
when Bad_Config =>
-- From Do_Reduce_1
return False;
end Check_Reduce_To_Start;
procedure Try_Push_Back
(Super : not null access Base.Supervisor;
Shared : not null access Base.Shared;
Parser_Index : in SAL.Base_Peek_Type;
Config : in Configuration;
Local_Config_Heap : in out Config_Heaps.Heap_Type)
is
Trace : WisiToken.Trace'Class renames Super.Trace.all;
McKenzie_Param : McKenzie_Param_Type renames Shared.Table.McKenzie_Param;
Token : constant Recover_Token := Config.Stack.Peek.Token;
begin
-- Try pushing back the stack top, to allow insert and other
-- operations at that point.
--
-- Since we are not actually changing the source text, it is tempting
-- to give this operation zero cost. But then we keep doing push_back
-- forever, making no progress. So we give it a cost.
if not Token.Virtual then
-- If Virtual, this is from earlier in this recover session; no point
-- in trying to redo it.
declare
use Config_Op_Arrays;
New_Config : Configuration := Config;
begin
New_Config.Error_Token.ID := Invalid_Token_ID;
New_Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok);
New_Config.Stack.Pop;
if Is_Full (New_Config.Ops) then
Super.Config_Full ("push_back 1", Parser_Index);
raise Bad_Config;
else
if Token.Min_Terminal_Index = Invalid_Token_Index then
-- Token is empty; Config.current_shared_token does not change, no
-- cost increase.
Append (New_Config.Ops, (Push_Back, Token.ID, New_Config.Current_Shared_Token));
else
New_Config.Cost := New_Config.Cost + McKenzie_Param.Push_Back (Token.ID);
Append (New_Config.Ops, (Push_Back, Token.ID, Token.Min_Terminal_Index));
New_Config.Current_Shared_Token := Token.Min_Terminal_Index;
end if;
end if;
New_Config.Strategy_Counts (Explore_Table) := New_Config.Strategy_Counts (Explore_Table) + 1;
Local_Config_Heap.Add (New_Config);
if Trace_McKenzie > Detail then
Base.Put ("push_back " & Image (Token.ID, Trace.Descriptor.all), Super, Shared,
Parser_Index, New_Config);
end if;
end;
end if;
end Try_Push_Back;
function Just_Pushed_Back_Or_Deleted (Config : in Configuration; ID : in Token_ID) return Boolean
is
use Config_Op_Arrays, Config_Op_Array_Refs;
use all type Ada.Containers.Count_Type;
begin
if Length (Config.Ops) = 0 then
return False;
else
declare
Last_Op : Config_Op renames Constant_Ref (Config.Ops, Last_Index (Config.Ops));
begin
return
(Last_Op.Op = Push_Back and then Last_Op.PB_ID = ID) or
(Last_Op.Op = Delete and then Last_Op.Del_ID = ID);
end;
end if;
end Just_Pushed_Back_Or_Deleted;
procedure Try_Undo_Reduce
(Super : not null access Base.Supervisor;
Shared : not null access Base.Shared;
Parser_Index : in SAL.Base_Peek_Type;
Config : in Configuration;
Local_Config_Heap : in out Config_Heaps.Heap_Type)
is
Trace : WisiToken.Trace'Class renames Super.Trace.all;
McKenzie_Param : McKenzie_Param_Type renames Shared.Table.McKenzie_Param;
Token : constant Recover_Token := Config.Stack.Peek.Token;
begin
-- Try expanding the nonterm on the stack top, to allow pushing_back
-- its components, or insert and other operations at that point.
if Undo_Reduce_Valid (Config.Stack, Super.Parser_State (Parser_Index).Tree) then
declare
use Config_Op_Arrays;
New_Config : Configuration := Config;
Token_Count : Ada.Containers.Count_Type;
begin
New_Config.Error_Token.ID := Invalid_Token_ID;
New_Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok);
Token_Count := Undo_Reduce (New_Config.Stack, Super.Parser_State (Parser_Index).Tree);
if Token.Min_Terminal_Index /= Invalid_Token_Index then
-- If Token is empty no cost increase.
New_Config.Cost := New_Config.Cost + McKenzie_Param.Undo_Reduce (Token.ID);
end if;
if Is_Full (New_Config.Ops) then
Super.Config_Full ("undo_reduce 1", Parser_Index);
raise Bad_Config;
else
Append (New_Config.Ops, (Undo_Reduce, Token.ID, Token_Count));
end if;
New_Config.Strategy_Counts (Explore_Table) := New_Config.Strategy_Counts (Explore_Table) + 1;
Local_Config_Heap.Add (New_Config);
if Trace_McKenzie > Detail then
Base.Put ("undo_reduce " & Image (Token.ID, Trace.Descriptor.all), Super, Shared,
Parser_Index, New_Config);
end if;
end;
end if;
end Try_Undo_Reduce;
procedure Insert_From_Action_List
(Super : not null access Base.Supervisor;
Shared : not null access Base.Shared;
Parser_Index : in SAL.Base_Peek_Type;
Config : in Configuration;
Minimal_Insert : in Token_ID_Arrays.Vector;
Local_Config_Heap : in out Config_Heaps.Heap_Type)
is
Table : Parse_Table renames Shared.Table.all;
EOF_ID : Token_ID renames Super.Trace.Descriptor.EOI_ID;
Descriptor : WisiToken.Descriptor renames Super.Trace.Descriptor.all;
-- Find terminal insertions from the current state's action_list to try.
--
-- We perform any needed reductions and one shift, so the config is
-- in a consistent state, and enqueue the result. If there are any
-- conflicts or semantic check fails encountered, they create other
-- configs to enqueue.
Current_Token : constant Token_ID := Current_Token_ID_Peek
(Shared.Terminals.all, Config.Current_Shared_Token, Config.Insert_Delete, Config.Current_Insert_Delete);
Cached_Config : Configuration;
Cached_Action : Reduce_Action_Rec;
-- Most of the time, all the reductions in a state are the same. So
-- we cache the first result. This includes one reduction; if an
-- associated semantic check failed, this does not include the fixes.
I : Parse_Action_Node_Ptr;
begin
for Node of Table.States (Config.Stack.Peek.State).Action_List loop
I := Node.Actions;
loop
exit when I = null;
declare
ID : constant Token_ID := Node.Symbol;
Action : Parse_Action_Rec renames I.Item;
begin
if ID /= EOF_ID and then -- can't insert eof
ID /= Invalid_Token_ID -- invalid when Verb = Error
then
if Just_Pushed_Back_Or_Deleted (Config, ID) then
if Trace_McKenzie > Extra then
Put_Line
(Super.Trace.all, Super.Label (Parser_Index), "Insert: abandon " & Image (ID, Descriptor) &
": undo push_back");
end if;
elsif ID = Current_Token then
-- This needed because we allow explore when the error is not at the
-- explore point; it prevents inserting useless tokens (ie
-- 'identifier ;' in ada_lite).
if Trace_McKenzie > Extra then
Put_Line
(Super.Trace.all, Super.Label (Parser_Index), "Insert: abandon " & Image (ID, Descriptor) &
": current token");
end if;
elsif (for some Minimal of Minimal_Insert => ID = Minimal) then
-- Was inserted by Insert_Minimal_Complete_Actions
null;
else
case Action.Verb is
when Shift =>
declare
New_Config : Configuration := Config;
begin
Do_Shift
("Insert", Super, Shared, Parser_Index, Local_Config_Heap, New_Config, Action.State, ID,
Cost_Delta => 0,
Strategy => Explore_Table);
end;
when Reduce =>
if not Equal (Action, Cached_Action) then
declare
New_Config : Configuration := Config;
begin
New_Config.Error_Token.ID := Invalid_Token_ID;
New_Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok);
Do_Reduce_1
("Insert", Super, Shared, Parser_Index, Local_Config_Heap, New_Config, Action);
Cached_Config := New_Config;
Cached_Action := Action;
Do_Reduce_2
("Insert", Super, Shared, Parser_Index, Local_Config_Heap, New_Config, ID,
Cost_Delta => 0,
Strategy => Explore_Table);
end;
else
declare
New_Config : Configuration := Cached_Config;
begin
Do_Reduce_2
("Insert", Super, Shared, Parser_Index, Local_Config_Heap, New_Config, ID,
Cost_Delta => 0,
Strategy => Explore_Table);
end;
end if;
when Accept_It =>
raise SAL.Programmer_Error with "found test case for Process_One Accept_It";
when Error =>
null;
end case;
end if;
end if;
end;
I := I.Next;
end loop;
end loop;
end Insert_From_Action_List;
function Insert_Minimal_Complete_Actions
(Super : not null access Base.Supervisor;
Shared : not null access Base.Shared;
Parser_Index : in SAL.Base_Peek_Type;
Orig_Config : in out Configuration;
Local_Config_Heap : in out Config_Heaps.Heap_Type)
return Token_ID_Arrays.Vector
-- Return tokens inserted (empty if none).
is
use Ada.Containers;
Table : Parse_Table renames Shared.Table.all;
Descriptor : WisiToken.Descriptor renames Super.Trace.Descriptor.all;
Inserted : Token_ID_Array (1 .. 10) := (others => Invalid_Token_ID);
Inserted_Last : Integer := Inserted'First - 1;
type Work_Item is record
Action : Minimal_Action;
Config : Configuration;
end record;
package Item_Queues is new SAL.Gen_Bounded_Definite_Queues (Work_Item);
use Item_Queues;
Work : Queue_Type (10);
-- The required queue size depends on the number of multiple-item
-- Minimal_Complete_Actions encountered. That is limited by compound
-- statement nesting, and by the frequency of such actions.
function To_Reduce_Action (Action : in Minimal_Action) return Reduce_Action_Rec
is (Reduce, (Action.Nonterm, 0), null, null, Action.Token_Count);
procedure Minimal_Do_Shift (Action : in Minimal_Action; Config : in out Configuration)
is
use Config_Op_Arrays, Config_Op_Array_Refs;
begin
-- Check for a cycle. We compare stack depth as well as state, so
-- nested compound statements don't look like a cycle; see
-- test_mckenzie_recover Push_Back_1. We don't check for cycles in
-- Insert_From_Action_List because we assume cost eliminates cycles
-- there; Minimal_Complete_Delta is usually negative, so cost does
-- not necessarily increase here.
for I in reverse First_Index (Config.Ops) .. Last_Index (Config.Ops) loop
declare
Op : Config_Op renames Constant_Ref (Config.Ops, I);
begin
if Op.Op = Insert and then
(Op.Ins_ID = Action.ID and Op.State = Action.State and Op.Stack_Depth = Config.Stack.Depth)
then
if Trace_McKenzie > Extra then
Put_Line
(Super.Trace.all, Super.Label (Parser_Index), "Minimal_Complete_Actions: abandon " &
Image (Action.ID, Descriptor) & Action.State'Image & ": cycle");
end if;
return;
end if;
end;
end loop;
-- We don't check Action.ID = Current_Token; the error is at the
-- explore point, so ID is valid.
if Just_Pushed_Back_Or_Deleted (Config, Action.ID) then
if Trace_McKenzie > Extra then
Put_Line
(Super.Trace.all, Super.Label (Parser_Index),
"Minimal_Complete_Actions: abandon " & Image (Action.ID, Descriptor) & ": undo push back");
end if;
else
Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok);
Config.Minimal_Complete_State := Active;
Inserted_Last := Inserted_Last + 1;
Inserted (Inserted_Last) := Action.ID;
Do_Shift
("Minimal_Complete_Actions", Super, Shared, Parser_Index, Local_Config_Heap, Config,
Action.State, Action.ID, Table.McKenzie_Param.Minimal_Complete_Cost_Delta,
Strategy => Minimal_Complete);
end if;
end Minimal_Do_Shift;
procedure Enqueue_Min_Actions
(Label : in String;
Actions : in Minimal_Action_Arrays.Vector;
Recursive : in Boolean;
Config : in Configuration;
Reduce_Only : in Boolean)
is
use SAL;
Length : array (Actions.First_Index .. Actions.Last_Index) of Count_Type := (others => Count_Type'Last);
Item_Not_Recursive : array (Actions.First_Index .. Actions.Last_Index) of Boolean := (others => False);
Not_Recursive_Count : Count_Type := 0;
Min_Length : Count_Type := Count_Type'Last;
Use_Recursive : Boolean;
begin
-- Enqueue non-minimal actions on Work,
if Trace_McKenzie > Extra then
Put_Line
(Super.Trace.all, Super.Label (Parser_Index), "Minimal_Complete_Actions: " & Label &
Image (Actions, Descriptor) & (if Recursive then " recursive" else ""));
end if;
if Actions.Length = 0 then
return;
elsif Actions.Length = 1 then
if (not Reduce_Only) or Actions (Actions.First_Index).Verb = Reduce then
if Is_Full (Work) then
Super.Config_Full ("Minimal_Complete_Actions 1", Parser_Index);
raise Bad_Config;
else
Add (Work, (Actions (Actions.First_Index), Config));
end if;
end if;
return;
end if;
for I in Actions.First_Index .. Actions.Last_Index loop
declare
Action : Minimal_Action renames Actions (I);
Next_State : constant State_Index :=
(case Action.Verb is
when Shift => Action.State,
when Reduce => Goto_For
(Shared.Table.all,
Config.Stack.Peek (Base_Peek_Type (Action.Token_Count) + 1).State,
Action.Nonterm));
Before_Dot : constant Token_ID :=
(case Action.Verb is
when Shift => Action.ID,
when Reduce => Action.Nonterm);
Kernel : Kernel_Info_Arrays.Vector renames Shared.Table.States (Next_State).Kernel;
begin
if (not Reduce_Only) or Action.Verb = Reduce then
for Item of Kernel loop
Item_Not_Recursive (I) := Item_Not_Recursive (I) or not Item.Recursive;
if Item.Before_Dot = Before_Dot and
Item.Length_After_Dot < Length (I)
then
Length (I) := Item.Length_After_Dot;
if Length (I) < Min_Length then
Min_Length := Length (I);
end if;
end if;
end loop;
end if;
end;
if Item_Not_Recursive (I) then
Not_Recursive_Count := Not_Recursive_Count + 1;
end if;
end loop;
Use_Recursive := Recursive and Not_Recursive_Count > 0 and Not_Recursive_Count < Actions.Length;
for I in Length'Range loop
if (Use_Recursive and Item_Not_Recursive (I)) or ((not Use_Recursive) and Length (I) = Min_Length) then
if Is_Full (Work) then
Super.Config_Full ("Minimal_Complete_Actions 2", Parser_Index);
raise Bad_Config;
else
Add (Work, (Actions (I), Config));
end if;
elsif Trace_McKenzie > Extra then
Put_Line
(Super.Trace.all, Super.Label (Parser_Index), "Minimal_Complete_Actions: drop " &
Image (Actions (I), Descriptor));
end if;
end loop;
end Enqueue_Min_Actions;
begin
if Orig_Config.Stack.Depth = 1 then
-- Get here with an empty source file, or a syntax error on the first
-- token.
return Token_ID_Arrays.Empty_Vector;
elsif Orig_Config.Minimal_Complete_State = Done then
if Trace_McKenzie > Extra then
Put_Line
(Super.Trace.all, Super.Label (Parser_Index), "Minimal_Complete_Actions: done");
end if;
return Token_ID_Arrays.Empty_Vector;
end if;
Enqueue_Min_Actions
("",
Table.States (Orig_Config.Stack.Peek.State).Minimal_Complete_Actions,
Table.States (Orig_Config.Stack.Peek.State).Minimal_Complete_Actions_Recursive,
Orig_Config, Reduce_Only => False);
loop
exit when Is_Empty (Work);
declare
Item : Work_Item := Get (Work);
begin
if Trace_McKenzie > Extra then
Put_Line
(Super.Trace.all, Super.Label (Parser_Index), "Minimal_Complete_Actions: dequeue work item " &
Image (Item.Action, Descriptor));
end if;
case Item.Action.Verb is
when Reduce =>
-- Do a reduce, look at resulting state. Keep reducing until we can't
-- anymore.
declare
Reduce_Action : Reduce_Action_Rec := To_Reduce_Action (Item.Action);
Actions : Minimal_Action_Arrays.Vector;
Recursive : Boolean;
begin
loop
Do_Reduce_1
("Minimal_Complete_Actions", Super, Shared, Parser_Index, Local_Config_Heap, Item.Config,
Reduce_Action,
Do_Language_Fixes => False);
Actions := Table.States (Item.Config.Stack.Peek.State).Minimal_Complete_Actions;
Recursive := Table.States (Item.Config.Stack.Peek.State).Minimal_Complete_Actions_Recursive;
case Actions.Length is
when 0 =>
if Trace_McKenzie > Extra then
Put_Line
(Super.Trace.all, Super.Label (Parser_Index),
"Minimal_Complete_Actions abandoned: no actions");
end if;
exit;
when 1 =>
case Actions (Actions.First_Index).Verb is
when Shift =>
Minimal_Do_Shift (Actions (Actions.First_Index), Item.Config);
exit;
when Reduce =>
Reduce_Action := To_Reduce_Action (Actions (Actions.First_Index));
end case;
when others =>
Enqueue_Min_Actions ("multiple actions ", Actions, Recursive, Item.Config, Reduce_Only => True);
exit;
end case;
end loop;
end;
when Shift =>
Minimal_Do_Shift (Item.Action, Item.Config);
end case;
end;
end loop;
if Inserted_Last = Inserted'First - 1 then
if Orig_Config.Minimal_Complete_State = Active then
Orig_Config.Minimal_Complete_State := Done;
end if;
end if;
return To_Vector (Inserted (1 .. Inserted_Last));
end Insert_Minimal_Complete_Actions;
procedure Insert_Matching_Begin
(Super : not null access Base.Supervisor;
Shared : not null access Base.Shared;
Parser_Index : in SAL.Base_Peek_Type;
Config : in Configuration;
Local_Config_Heap : in out Config_Heaps.Heap_Type;
Matching_Begin_Tokens : in Token_ID_Arrays.Vector)
is
Table : Parse_Table renames Shared.Table.all;
Descriptor : WisiToken.Descriptor renames Super.Trace.Descriptor.all;
begin
-- We don't check for insert = current token; that's either ok or a
-- severe bug in Language_Use_Minimal_Complete.
if Config.Matching_Begin_Done then
if Trace_McKenzie > Extra then
Put_Line (Super.Trace.all, Super.Label (Parser_Index), "Matching_Begin abandoned: done");
end if;
return;
end if;
if Just_Pushed_Back_Or_Deleted (Config, Matching_Begin_Tokens (Matching_Begin_Tokens.First_Index)) then
if Trace_McKenzie > Extra then
Put_Line
(Super.Trace.all, Super.Label (Parser_Index), "Matching_Begin abandoned " &
Image (Matching_Begin_Tokens (Matching_Begin_Tokens.First_Index), Descriptor) & ": undo push_back");
end if;
return;
end if;
declare
New_Config : Configuration := Config;
begin
for ID of Matching_Begin_Tokens loop
Insert (New_Config, ID);
end loop;
declare
use Parse.Parse_Item_Arrays;
Parse_Items : aliased Parse.Parse_Item_Arrays.Vector;
Dummy : constant Boolean := Parse.Parse
(Super, Shared, Parser_Index, Parse_Items, New_Config,
Shared_Token_Goal => Invalid_Token_Index,
All_Conflicts => True,
Trace_Prefix => "parse Matching_Begin");
begin
for I in First_Index (Parse_Items) .. Last_Index (Parse_Items) loop
declare
Item : Parse.Parse_Item renames Parse.Parse_Item_Array_Refs.Variable_Ref (Parse_Items, I);
begin
if Item.Parsed and Item.Config.Current_Insert_Delete = No_Insert_Delete then
Item.Config.Matching_Begin_Done := True;
Item.Config.Cost := Item.Config.Cost + Table.McKenzie_Param.Matching_Begin;
Item.Config.Strategy_Counts (Matching_Begin) := Item.Config.Strategy_Counts (Matching_Begin) + 1;
Item.Config.Error_Token.ID := Invalid_Token_ID;
Item.Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok);
if Trace_McKenzie > Detail then
Base.Put
("Matching_Begin: insert " & Image (Matching_Begin_Tokens, Descriptor),
Super, Shared, Parser_Index, Item.Config);
end if;
Local_Config_Heap.Add (Item.Config);
else
if Trace_McKenzie > Detail then
Base.Put
("Matching_Begin: abandon " & Image (Matching_Begin_Tokens, Descriptor) & ": parse fail",
Super, Shared, Parser_Index, Item.Config);
end if;
end if;
end;
end loop;
end;
end;
exception
when SAL.Container_Full =>
-- From config_ops_sorted
Super.Config_Full ("Minimal_Complete_Actions 3", Parser_Index);
end Insert_Matching_Begin;
procedure Try_Insert_Terminal
(Super : not null access Base.Supervisor;
Shared : not null access Base.Shared;
Parser_Index : in SAL.Base_Peek_Type;
Config : in out Configuration;
Local_Config_Heap : in out Config_Heaps.Heap_Type)
is
use all type WisiToken.Parse.LR.Parser.Language_Matching_Begin_Tokens_Access;
use all type Ada.Containers.Count_Type;
Tokens : Token_ID_Array_1_3;
Matching_Begin_Tokens : Token_ID_Arrays.Vector;
Forbid_Minimal_Insert : Boolean := False;
Minimal_Inserted : Token_ID_Arrays.Vector;
begin
if Shared.Language_Matching_Begin_Tokens /= null then
Current_Token_ID_Peek_3
(Shared.Terminals.all, Config.Current_Shared_Token, Config.Insert_Delete, Config.Current_Insert_Delete,
Super.Parser_State (Parser_Index).Prev_Deleted, Tokens);
Shared.Language_Matching_Begin_Tokens (Tokens, Config, Matching_Begin_Tokens, Forbid_Minimal_Insert);
end if;
if not Forbid_Minimal_Insert then
-- See test_mckenzie_recover.adb Forbid_Minimal_Insert for rationale.
Minimal_Inserted := Insert_Minimal_Complete_Actions
(Super, Shared, Parser_Index, Config, Local_Config_Heap);
end if;
if Matching_Begin_Tokens.Length > 0 then
Insert_Matching_Begin (Super, Shared, Parser_Index, Config, Local_Config_Heap, Matching_Begin_Tokens);
end if;
-- We always do all three Insert_Minimal_Complete (unless
-- Forbid_Minimal_Insert), Insert_Matching_Begin,
-- Insert_From_Action_List; in general it's not possible to tell when
-- one will be better (see test_mckenzie_recover.adb
-- Always_Minimal_Complete, Always_Matching_Begin).
-- Insert_From_Action does not insert the Minimal_Inserted tokens,
-- and it will never insert the Matching_Begin_Tokens, so there is no
-- duplication. Insert_From_Action_List will normally be more
-- expensive.
Insert_From_Action_List (Super, Shared, Parser_Index, Config, Minimal_Inserted, Local_Config_Heap);
-- It is tempting to use the Goto_List to find nonterms to insert.
-- But that can easily lead to error states, and it turns out to be
-- not useful, especially if the grammar has been relaxed so most
-- expressions and lists can be empty.
exception
when Bad_Config =>
null;
end Try_Insert_Terminal;
procedure Try_Insert_Quote
(Super : not null access Base.Supervisor;
Shared : not null access Base.Shared;
Parser_Index : in SAL.Base_Peek_Type;
Config : in out Configuration;
Local_Config_Heap : in out Config_Heaps.Heap_Type)
is
use Config_Op_Arrays;
use all type Parser.Language_String_ID_Set_Access;
Descriptor : WisiToken.Descriptor renames Shared.Trace.Descriptor.all;
Check_Limit : WisiToken.Token_Index renames Shared.Table.McKenzie_Param.Check_Limit;
Current_Line : constant Line_Number_Type := Shared.Terminals.all (Config.Current_Shared_Token).Line;
Lexer_Error_Token_Index : Base_Token_Index;
Lexer_Error_Token : Base_Token;
function Recovered_Lexer_Error (Line : in Line_Number_Type) return Base_Token_Index
is begin
-- We are assuming the list of lexer errors is short, so binary
-- search would not be significantly faster.
for Err of reverse Shared.Lexer.Errors loop
if Err.Recover_Token /= Invalid_Token_Index and then
Shared.Terminals.all (Err.Recover_Token).Line = Line
then
return Err.Recover_Token;
end if;
end loop;
return Invalid_Token_Index;
end Recovered_Lexer_Error;
function String_ID_Set (String_ID : in Token_ID) return Token_ID_Set
is begin
if Shared.Language_String_ID_Set = null then
return (String_ID .. String_ID => True);
else
return Shared.Language_String_ID_Set (Descriptor, String_ID);
end if;
end String_ID_Set;
procedure String_Literal_In_Stack
(Label : in String;
New_Config : in out Configuration;
Matching : in SAL.Peek_Type;
String_Literal_ID : in Token_ID)
is
use Parse.Parse_Item_Arrays;
Saved_Shared_Token : constant WisiToken.Token_Index := New_Config.Current_Shared_Token;
Tok : Recover_Token;
J : WisiToken.Token_Index;
Parse_Items : aliased Parse.Parse_Item_Arrays.Vector;
begin
-- Matching is the index of a token on New_Config.Stack containing a string
-- literal. Push back thru that token, then delete all tokens after
-- the string literal to Saved_Shared_Token.
if not Has_Space (New_Config.Ops, Ada.Containers.Count_Type (Matching)) then
Super.Config_Full ("insert quote 1 " & Label, Parser_Index);
raise Bad_Config;
end if;
for I in 1 .. Matching loop
Tok := New_Config.Stack.Pop.Token;
Append (New_Config.Ops, (Push_Back, Tok.ID, Tok.Min_Terminal_Index));
end loop;
New_Config.Current_Shared_Token := Tok.Min_Terminal_Index;
-- Find last string literal in pushed back terminals.
J := Saved_Shared_Token - 1;
loop
exit when Shared.Terminals.all (J).ID = String_Literal_ID;
J := J - 1;
end loop;
begin
if Parse.Parse
(Super, Shared, Parser_Index, Parse_Items, New_Config,
Shared_Token_Goal => J,
All_Conflicts => False,
Trace_Prefix => "insert quote parse pushback " & Label)
then
-- The non-deleted tokens parsed without error. We don't care if any
-- conflicts were encountered; we are not using the parse result.
New_Config := Parse.Parse_Item_Array_Refs.Constant_Ref (Parse_Items, 1).Config;
Append (New_Config.Ops, (Fast_Forward, New_Config.Current_Shared_Token));
else
raise SAL.Programmer_Error;
end if;
exception
when Bad_Config =>
raise SAL.Programmer_Error;
end;
if not Has_Space
(New_Config.Ops, Ada.Containers.Count_Type (Saved_Shared_Token - 1 - New_Config.Current_Shared_Token))
then
Super.Config_Full ("insert quote 2 " & Label, Parser_Index);
raise Bad_Config;
end if;
for J in New_Config.Current_Shared_Token .. Saved_Shared_Token - 1 loop
Append (New_Config.Ops, (Delete, Shared.Terminals.all (J).ID, J));
end loop;
New_Config.Current_Shared_Token := Saved_Shared_Token;
end String_Literal_In_Stack;
procedure Finish
(Label : in String;
New_Config : in out Configuration;
First, Last : in Base_Token_Index)
is begin
-- Delete tokens First .. Last; either First - 1 or Last + 1 should
-- be a String_Literal. Leave Current_Shared_Token at Last + 1.
New_Config.Error_Token.ID := Invalid_Token_ID;
New_Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok);
-- This is a guess, so we give it a nominal cost
New_Config.Cost := New_Config.Cost + 1;
if not Has_Space (New_Config.Ops, Ada.Containers.Count_Type (Last - First)) then
Super.Config_Full ("insert quote 3 " & Label, Parser_Index);
raise Bad_Config;
end if;
for I in First .. Last loop
Append (New_Config.Ops, (Delete, Shared.Terminals.all (I).ID, I));
end loop;
New_Config.Current_Shared_Token := Last + 1;
-- Let explore do insert after these deletes.
Append (New_Config.Ops, (Fast_Forward, New_Config.Current_Shared_Token));
if New_Config.Resume_Token_Goal - Check_Limit < New_Config.Current_Shared_Token then
New_Config.Resume_Token_Goal := New_Config.Current_Shared_Token + Check_Limit;
if Trace_McKenzie > Detail then
Put_Line
(Super.Trace.all, Super.Label (Parser_Index), "resume_token_goal:" & WisiToken.Token_Index'Image
(New_Config.Resume_Token_Goal));
end if;
end if;
New_Config.Strategy_Counts (String_Quote) := New_Config.Strategy_Counts (String_Quote) + 1;
if Trace_McKenzie > Detail then
Base.Put ("insert quote " & Label & " ", Super, Shared, Parser_Index, New_Config);
end if;
end Finish;
begin
-- When the lexer finds an unbalanced quote, it inserts a virtual
-- balancing quote at the same character position as the unbalanced
-- quote, returning an empty string literal token there. The parser
-- does not see that as an error; it encounters a syntax error
-- before, at, or after that string literal.
--
-- Here we assume the parse error in Config.Error_Token is due to
-- putting the balancing quote in the wrong place, and attempt to
-- find a better place to put the balancing quote. Then all tokens
-- from the balancing quote to the unbalanced quote are now part of a
-- string literal, so delete them, leaving just the string literal
-- created by Lexer error recovery.
-- First we check to see if there is an unbalanced quote in the
-- current line; if not, just return. Some lexer errors are for other
-- unrecognized characters; see ada_mode-recover_bad_char.adb.
--
-- An alternate strategy is to treat the lexer error as a parse error
-- immediately, but that complicates the parse logic.
Config.String_Quote_Checked := Current_Line;
Lexer_Error_Token_Index := Recovered_Lexer_Error (Current_Line);
if Lexer_Error_Token_Index = Invalid_Token_Index then
return;
end if;
Lexer_Error_Token := Shared.Terminals.all (Lexer_Error_Token_Index);
-- It is not possible to tell where the best place to put the
-- balancing quote is, so we always try all reasonable places.
if Lexer_Error_Token.Byte_Region.First = Config.Error_Token.Byte_Region.First then
-- The parse error token is the string literal at the lexer error.
--
-- case a: Insert the balancing quote somewhere before the error
-- point. There is no way to tell how far back to put the balancing
-- quote, so we just do one non-empty token. See
-- test_mckenzie_recover.adb String_Quote_0. So far we have not found
-- a test case for more than one token.
declare
New_Config : Configuration := Config;
Token : Recover_Token;
begin
loop
Token := New_Config.Stack.Pop.Token;
if Token.Byte_Region /= Null_Buffer_Region then
if Is_Full (New_Config.Ops) then
Super.Config_Full ("insert quote 4 a", Parser_Index);
raise Bad_Config;
else
Append (New_Config.Ops, (Push_Back, Token.ID, Token.Min_Terminal_Index));
end if;
exit;
end if;
end loop;
Finish ("a", New_Config, Token.Min_Terminal_Index, Config.Current_Shared_Token - 1);
Local_Config_Heap.Add (New_Config);
end;
-- Note that it is not reasonable to insert a quote after the error
-- in this case. If that were the right solution, the parser error
-- token would not be the lexer repaired string literal, since a
-- string literal would be legal here.
elsif Lexer_Error_Token.Byte_Region.First < Config.Error_Token.Byte_Region.First then
-- The unbalanced quote is before the parse error token; see
-- test_mckenzie_recover.adb String_Quote_2.
--
-- The missing quote belongs after the parse error token, before or
-- at the end of the current line; try inserting it at the end of
-- the current line.
--
-- The lexer repaired string literal may be in a reduced token on the
-- stack.
declare
Matching : SAL.Peek_Type := 1;
begin
Find_Descendant_ID
(Super.Parser_State (Parser_Index).Tree, Config, Lexer_Error_Token.ID,
String_ID_Set (Lexer_Error_Token.ID), Matching);
if Matching = Config.Stack.Depth then
-- String literal is in a virtual nonterm; give up. So far this only
-- happens in a high cost non critical config.
if Trace_McKenzie > Detail then
Put_Line
(Super.Trace.all, Super.Label (Parser_Index), "insert quote b abandon; string literal in virtual");
end if;
return;
end if;
declare
New_Config : Configuration := Config;
begin
String_Literal_In_Stack ("b", New_Config, Matching, Lexer_Error_Token.ID);
Finish
("b", New_Config, Config.Current_Shared_Token, Shared.Line_Begin_Token.all (Current_Line + 1) - 1);
Local_Config_Heap.Add (New_Config);
end;
end;
else
-- The unbalanced quote is after the parse error token.
-- case c: Assume a missing quote belongs immediately before the current token.
-- See test_mckenzie_recover.adb String_Quote_3.
declare
New_Config : Configuration := Config;
begin
Finish ("c", New_Config, Config.Current_Shared_Token, Lexer_Error_Token_Index - 1);
Local_Config_Heap.Add (New_Config);
exception
when Bad_Config =>
null;
end;
-- case d: Assume a missing quote belongs somewhere farther before
-- the current token; try one non-empty (as in case a above). See
-- test_mckenzie_recover.adb String_Quote_4.
declare
New_Config : Configuration := Config;
Token : Recover_Token;
begin
loop
Token := New_Config.Stack.Pop.Token;
if Token.Byte_Region /= Null_Buffer_Region then
if Is_Full (New_Config.Ops) then
Super.Config_Full ("insert quote 5 d", Parser_Index);
raise Bad_Config;
else
Append (New_Config.Ops, (Push_Back, Token.ID, Token.Min_Terminal_Index));
end if;
exit;
end if;
end loop;
Finish ("d", New_Config, Token.Min_Terminal_Index, Lexer_Error_Token_Index - 1);
Local_Config_Heap.Add (New_Config);
exception
when SAL.Container_Empty =>
-- From Stack.Pop
null;
when Bad_Config =>
null;
end;
-- case e: Assume the actual error is an extra quote that terminates
-- an intended string literal early, in which case there is a token
-- on the stack containing the string literal that should be extended
-- to the found quote. See test_mckenzie_recover.adb String_Quote_1.
declare
Matching : SAL.Peek_Type := 1;
begin
-- Lexer_Error_Token is a string literal; find a matching one.
Find_Descendant_ID
(Super.Parser_State (Parser_Index).Tree, Config, Lexer_Error_Token.ID, String_ID_Set
(Lexer_Error_Token.ID), Matching);
if Matching = Config.Stack.Depth then
-- No matching string literal, so this case does not apply.
null;
else
declare
New_Config : Configuration := Config;
begin
String_Literal_In_Stack ("e", New_Config, Matching, Lexer_Error_Token.ID);
Finish ("e", New_Config, Config.Current_Shared_Token, Lexer_Error_Token_Index);
Local_Config_Heap.Add (New_Config);
end;
end if;
end;
end if;
exception
when Bad_Config =>
null;
end Try_Insert_Quote;
procedure Try_Delete_Input
(Super : not null access Base.Supervisor;
Shared : not null access Base.Shared;
Parser_Index : in SAL.Base_Peek_Type;
Config : in Configuration;
Local_Config_Heap : in out Config_Heaps.Heap_Type)
is
-- Try deleting (= skipping) the current shared input token.
use Config_Op_Arrays, Config_Op_Array_Refs;
use all type Ada.Containers.Count_Type;
Trace : WisiToken.Trace'Class renames Super.Trace.all;
EOF_ID : Token_ID renames Trace.Descriptor.EOI_ID;
Check_Limit : WisiToken.Token_Index renames Shared.Table.McKenzie_Param.Check_Limit;
McKenzie_Param : McKenzie_Param_Type renames Shared.Table.McKenzie_Param;
ID : constant Token_ID := Shared.Terminals.all (Config.Current_Shared_Token).ID;
begin
if ID /= EOF_ID and then
-- can't delete EOF
(Length (Config.Ops) = 0 or else
-- Don't delete an ID we just inserted; waste of time
(not Equal (Constant_Ref (Config.Ops, Last_Index (Config.Ops)),
(Insert, ID, Config.Current_Shared_Token, 1, 0))))
then
declare
New_Config : Configuration := Config;
function Matching_Push_Back return Boolean
is begin
for I in reverse First_Index (New_Config.Ops) .. Last_Index (New_Config.Ops) loop
declare
Op : Config_Op renames Config_Op_Array_Refs.Variable_Ref (New_Config.Ops, I).Element.all;
begin
exit when not (Op.Op in Undo_Reduce | Push_Back | Delete);
if Op = (Push_Back, ID, New_Config.Current_Shared_Token) then
return True;
end if;
end;
end loop;
return False;
end Matching_Push_Back;
begin
New_Config.Error_Token.ID := Invalid_Token_ID;
New_Config.Check_Status := (Label => WisiToken.Semantic_Checks.Ok);
New_Config.Cost := New_Config.Cost + McKenzie_Param.Delete (ID);
New_Config.Strategy_Counts (Explore_Table) := Config.Strategy_Counts (Explore_Table) + 1;
if Matching_Push_Back then
-- We are deleting a push_back; cancel the push_back cost, to make
-- this the same as plain deleting.
New_Config.Cost := Natural'Max (Natural'First, New_Config.Cost - McKenzie_Param.Push_Back (ID));
end if;
if Is_Full (New_Config.Ops) then
Super.Config_Full ("delete", Parser_Index);
raise Bad_Config;
else
Append (New_Config.Ops, (Delete, ID, Config.Current_Shared_Token));
end if;
New_Config.Current_Shared_Token := New_Config.Current_Shared_Token + 1;
loop
exit when not Super.Parser_State (Parser_Index).Prev_Deleted.Contains (New_Config.Current_Shared_Token);
New_Config.Current_Shared_Token := New_Config.Current_Shared_Token + 1;
end loop;
if New_Config.Resume_Token_Goal - Check_Limit < New_Config.Current_Shared_Token then
New_Config.Resume_Token_Goal := New_Config.Current_Shared_Token + Check_Limit;
end if;
Local_Config_Heap.Add (New_Config);
if Trace_McKenzie > Detail then
Base.Put
("delete " & Image (ID, Trace.Descriptor.all), Super, Shared, Parser_Index, New_Config);
end if;
end;
end if;
end Try_Delete_Input;
procedure Process_One
(Super : not null access Base.Supervisor;
Shared : not null access Base.Shared;
Config_Status : out Base.Config_Status)
is
-- Get one config from Super, check to see if it is a viable
-- solution. If not, enqueue variations to check.
use all type Base.Config_Status;
use all type Parser.Language_Fixes_Access;
use all type Semantic_Checks.Check_Status_Label;
Trace : WisiToken.Trace'Class renames Super.Trace.all;
Descriptor : WisiToken.Descriptor renames Super.Trace.Descriptor.all;
Table : Parse_Table renames Shared.Table.all;
Parser_Index : SAL.Base_Peek_Type;
Config : Configuration;
Local_Config_Heap : Config_Heaps.Heap_Type;
-- We collect all the variants to enqueue, then deliver them all at
-- once to Super, to minimizes task interactions.
begin
Super.Get (Parser_Index, Config, Config_Status);
if Config_Status = All_Done then
return;
end if;
if Trace_McKenzie > Detail then
Base.Put ("dequeue", Super, Shared, Parser_Index, Config);
if Trace_McKenzie > Extra then
Put_Line (Trace, Super.Label (Parser_Index), "stack: " & Image (Config.Stack, Trace.Descriptor.all));
end if;
end if;
-- Fast_Forward; parse Insert, Delete in Config.Ops that have not
-- been parsed yet. 'parse' here means adjusting Config.Stack and
-- Current_Terminal_Index. Code in this file always parses when
-- adding ops to Config (except as noted); Language_Fixes should use
-- McKenzie_Recover.Insert, Delete instead.
if Config.Current_Insert_Delete = 1 then
-- Config.Current_Insert_Delete > 1 is a programming error.
case Fast_Forward (Super, Shared, Parser_Index, Local_Config_Heap, Config) is
when Abandon =>
-- We know Local_Config_Heap is empty; just tell
-- Super we are done working.
Super.Put (Parser_Index, Local_Config_Heap);
return;
when Continue =>
-- We don't increase cost for this Fast_Forward, since it is due to a
-- Language_Fixes.
null;
end case;
end if;
pragma Assert (Config.Current_Insert_Delete = 0);
-- Language_Fixes: let it enqueue configs.
if Config.Error_Token.ID /= Invalid_Token_ID then
if Shared.Language_Fixes = null then
null;
else
Shared.Language_Fixes
(Trace, Shared.Lexer, Super.Label (Parser_Index), Shared.Table.all,
Shared.Terminals.all, Super.Parser_State (Parser_Index).Tree, Local_Config_Heap,
Config);
-- The solutions enqueued by Language_Fixes should be lower cost than
-- others (typically 0), so they will be checked first.
if Config.Check_Status.Label = Ok then
-- Parse table Error action.
--
-- We don't clear Config.Error_Token here, because
-- Language_Use_Minimal_Complete_Actions needs it. We only clear it
-- when a parse results in no error (or a different error), or a
-- push_back moves the Current_Token.
null;
else
-- Assume "ignore check error" is a viable solution. But give it a
-- cost, so a solution provided by Language_Fixes is preferred.
declare
New_State : Unknown_State_Index;
begin
Config.Cost := Config.Cost + Table.McKenzie_Param.Ignore_Check_Fail;
-- finish reduce.
Config.Stack.Pop (SAL.Base_Peek_Type (Config.Check_Token_Count));
New_State := Goto_For (Table, Config.Stack.Peek.State, Config.Error_Token.ID);
if New_State = Unknown_State then
if Config.Stack.Depth = 1 then
-- Stack is empty, and we did not get Accept; really bad syntax got
-- us here; abandon this config. See ada_mode-recover_bad_char.adb.
Super.Put (Parser_Index, Local_Config_Heap);
return;
else
raise SAL.Programmer_Error with
"process_one found test case for new_state = Unknown; old state " &
Trimmed_Image (Config.Stack.Peek.State) & " nonterm " & Image
(Config.Error_Token.ID, Trace.Descriptor.all);
end if;
end if;
Config.Stack.Push ((New_State, Syntax_Trees.Invalid_Node_Index, Config.Error_Token));
-- We clear Check_Status and Error_Token so the check error is ignored.
Config.Check_Status := (Label => Ok);
Config.Error_Token.ID := Invalid_Token_ID;
end;
end if;
end if;
end if;
-- Call Check to see if this config succeeds. Note that Check does
-- more than Fast_Forward, so the fact that Fast_Forward succeeds
-- does not mean we don't need to call Check.
case Check (Super, Shared, Parser_Index, Config, Local_Config_Heap) is
when Success =>
Super.Success (Parser_Index, Config, Local_Config_Heap);
return;
when Abandon =>
Super.Put (Parser_Index, Local_Config_Heap);
return;
when Continue =>
null;
end case;
if Trace_McKenzie > Detail then
Base.Put ("continuing", Super, Shared, Parser_Index, Config);
if Trace_McKenzie > Extra then
Put_Line (Trace, Super.Label (Parser_Index), "stack: " & Image (Config.Stack, Trace.Descriptor.all));
end if;
end if;
-- Grouping these operations (push_back, delete, insert) ensures that
-- there are no duplicate solutions found. We reset the grouping
-- after each fast_forward.
--
-- We do delete before insert so Insert_Matching_Begin can operate on
-- the new next token, before Fast_Forwarding past it.
--
-- All possible permutations will be explored.
pragma Assert (Config.Stack.Depth > 0);
Try_Insert_Terminal (Super, Shared, Parser_Index, Config, Local_Config_Heap);
if None_Since_FF (Config.Ops, Delete) and then
None_Since_FF (Config.Ops, Insert) and then
Config.Stack.Depth > 1 and then -- can't delete the first state
(not Check_Reduce_To_Start (Super, Shared, Parser_Index, Config))
-- If Config reduces to the start nonterm, there's no point in push_back.
then
Try_Push_Back (Super, Shared, Parser_Index, Config, Local_Config_Heap);
Try_Undo_Reduce (Super, Shared, Parser_Index, Config, Local_Config_Heap);
end if;
if None_Since_FF (Config.Ops, Insert) then
Try_Delete_Input (Super, Shared, Parser_Index, Config, Local_Config_Heap);
end if;
-- This is run once per input line, independent of what other ops
-- have been done.
if Config.Check_Status.Label = Ok and
(Descriptor.String_1_ID /= Invalid_Token_ID or Descriptor.String_2_ID /= Invalid_Token_ID) and
(Config.String_Quote_Checked = Invalid_Line_Number or else
Config.String_Quote_Checked < Shared.Terminals.all (Config.Current_Shared_Token).Line)
then
-- See if there is a mismatched quote. The solution is to delete
-- tokens, replacing them with a string literal. So we try this when
-- it is ok to try delete.
Try_Insert_Quote (Super, Shared, Parser_Index, Config, Local_Config_Heap);
end if;
Super.Put (Parser_Index, Local_Config_Heap);
exception
when Bad_Config =>
-- Just abandon this config; tell Super we are done.
Super.Put (Parser_Index, Local_Config_Heap);
when E : others =>
Super.Put (Parser_Index, Local_Config_Heap);
if Debug_Mode then
raise;
elsif Trace_McKenzie > Outline then
Put_Line
(Super.Trace.all, Super.Label (Parser_Index),
"Process_One: unhandled exception " & Ada.Exceptions.Exception_Name (E) & ": " &
Ada.Exceptions.Exception_Message (E));
end if;
end Process_One;
end WisiToken.Parse.LR.McKenzie_Recover.Explore;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY COMPONENTS --
-- --
-- S Y S T E M . C O M P A R E _ A R R A Y _ U N S I G N E D _ 8 --
-- --
-- S p e c --
-- --
-- Copyright (C) 2002-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. --
-- --
-- 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 package contains functions for runtime comparisons on arrays whose
-- elements are 8-bit discrete type values to be treated as unsigned.
pragma Compiler_Unit_Warning;
package System.Compare_Array_Unsigned_8 is
-- Note: although the functions in this package are in a sense Pure, the
-- package cannot be declared as Pure, since the arguments are addresses,
-- not the data, and the result is not pure wrt the address values.
function Compare_Array_U8
(Left : System.Address;
Right : System.Address;
Left_Len : Natural;
Right_Len : Natural) return Integer;
-- Compare the array starting at address Left of length Left_Len with the
-- array starting at address Right of length Right_Len. The comparison is
-- in the normal Ada semantic sense of array comparison. The result is -1,
-- 0, +1 for Left < Right, Left = Right, Left > Right respectively. This
-- function works with 4 byte words if the operands are aligned on 4-byte
-- boundaries and long enough.
function Compare_Array_U8_Unaligned
(Left : System.Address;
Right : System.Address;
Left_Len : Natural;
Right_Len : Natural) return Integer;
-- Same functionality as Compare_Array_U8 but always proceeds by bytes.
-- Used when the caller knows that the operands are unaligned, or short
-- enough that it makes no sense to go by words.
end System.Compare_Array_Unsigned_8;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.UML.Activity_Edges.Collections is
pragma Preelaborate;
package UML_Activity_Edge_Collections is
new AMF.Generic_Collections
(UML_Activity_Edge,
UML_Activity_Edge_Access);
type Set_Of_UML_Activity_Edge is
new UML_Activity_Edge_Collections.Set with null record;
Empty_Set_Of_UML_Activity_Edge : constant Set_Of_UML_Activity_Edge;
type Ordered_Set_Of_UML_Activity_Edge is
new UML_Activity_Edge_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UML_Activity_Edge : constant Ordered_Set_Of_UML_Activity_Edge;
type Bag_Of_UML_Activity_Edge is
new UML_Activity_Edge_Collections.Bag with null record;
Empty_Bag_Of_UML_Activity_Edge : constant Bag_Of_UML_Activity_Edge;
type Sequence_Of_UML_Activity_Edge is
new UML_Activity_Edge_Collections.Sequence with null record;
Empty_Sequence_Of_UML_Activity_Edge : constant Sequence_Of_UML_Activity_Edge;
private
Empty_Set_Of_UML_Activity_Edge : constant Set_Of_UML_Activity_Edge
:= (UML_Activity_Edge_Collections.Set with null record);
Empty_Ordered_Set_Of_UML_Activity_Edge : constant Ordered_Set_Of_UML_Activity_Edge
:= (UML_Activity_Edge_Collections.Ordered_Set with null record);
Empty_Bag_Of_UML_Activity_Edge : constant Bag_Of_UML_Activity_Edge
:= (UML_Activity_Edge_Collections.Bag with null record);
Empty_Sequence_Of_UML_Activity_Edge : constant Sequence_Of_UML_Activity_Edge
:= (UML_Activity_Edge_Collections.Sequence with null record);
end AMF.UML.Activity_Edges.Collections;
|
-- Abstract :
--
-- See spec.
--
-- Copyright (C) 2018 - 2019 Free Software Foundation, Inc.
--
-- This program 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 program is distributed in the
-- hope that it will be useful, but WITHOUT ANY WARRANTY; without even
-- the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-- PURPOSE. See the GNU General Public License for more details. You
-- should have received a copy of the GNU General Public License
-- distributed with this program; see file COPYING. If not, write to
-- the Free Software Foundation, 51 Franklin Street, Suite 500, Boston,
-- MA 02110-1335, USA.
pragma License (GPL);
with Ada.Command_Line;
with Ada.Directories;
with Ada.Exceptions;
with Ada.Strings.Fixed;
with Ada.Text_IO;
with GNAT.OS_Lib;
with GNAT.Traceback.Symbolic;
with SAL;
with System.Multiprocessors;
with System.Storage_Elements;
with WisiToken.Lexer;
package body Emacs_Wisi_Common_Parse is
procedure Usage (Name : in String)
is
use Ada.Text_IO;
begin
Put_Line ("usage: " & Name & "[--recover-log <file-name>]");
Put_Line ("enters a loop waiting for commands:");
Put_Line ("Prompt is '" & Prompt & "'");
Put_Line ("commands are case sensitive");
Put_Line ("See wisi-process-parse.el *--send-parse, *--send-noop for arguments.");
end Usage;
procedure Read_Input (A : System.Address; N : Integer)
is
use System.Storage_Elements;
B : System.Address := A;
Remaining : Integer := N;
Read : Integer;
begin
-- We use GNAT.OS_Lib because it does not buffer input, so it runs
-- under Emacs nicely; GNAT Text_IO does not return text until
-- some fairly large buffer is filled.
--
-- With GNAT GPL 2016, GNAT.OS_Lib.Read does _not_ wait for all N
-- bytes or EOF; it returns as soon as it gets some bytes.
loop
Read := GNAT.OS_Lib.Read (GNAT.OS_Lib.Standin, B, Remaining);
if Read = 0 then
-- Pipe closed; probably parent Emacs crashed. Force exit.
raise SAL.Programmer_Error with "input pipe closed";
end if;
Remaining := Remaining - Read;
exit when Remaining <= 0;
B := B + Storage_Offset (Read);
end loop;
end Read_Input;
function Get_Command_Length return Integer
is
Temp : aliased String (1 .. 3) := (others => ' '); -- initialize for error message
begin
Read_Input (Temp'Address, Temp'Length);
return Integer'Value (Temp);
exception
when Constraint_Error =>
-- From Integer'Value
raise Protocol_Error with "invalid command byte count; '" & Temp & "'";
end Get_Command_Length;
function Get_String
(Source : in String;
Last : in out Integer)
return String
is
use Ada.Strings.Fixed;
First : constant Integer := Index
(Source => Source,
Pattern => """",
From => Last + 1);
begin
Last := Index
(Source => Source,
Pattern => """",
From => First + 1);
if First = 0 or Last = 0 then
raise Protocol_Error with "no '""' found for string";
end if;
return Source (First + 1 .. Last - 1);
end Get_String;
function Get_Integer
(Source : in String;
Last : in out Integer)
return Integer
is
use Ada.Strings.Fixed;
First : constant Integer := Last + 2; -- final char of previous item, space
begin
Last := Index
(Source => Source,
Pattern => " ",
From => First);
if Last = 0 then
Last := Source'Last;
else
Last := Last - 1;
end if;
return Integer'Value (Source (First .. Last));
exception
when others =>
Ada.Text_IO.Put_Line ("bad integer '" & Source (First .. Source'Last) & "'");
raise;
end Get_Integer;
function Get_Process_Start_Params return Process_Start_Params
is
use Ada.Command_Line;
procedure Put_Usage
is
use Ada.Text_IO;
begin
Put_Line (Standard_Error, "process start args:");
Put_Line (Standard_Error, "--help : put this help");
Put_Line (Standard_Error, "--recover-log <file_name> : log recover actions to file");
end Put_Usage;
Next_Arg : Integer := 1;
begin
return Result : Process_Start_Params do
loop
exit when Next_Arg > Argument_Count;
if Next_Arg <= Argument_Count and then Argument (Next_Arg) = "--help" then
Put_Usage;
raise Finish;
elsif Next_Arg + 1 <= Argument_Count and then Argument (Next_Arg) = "--recover-log" then
Result.Recover_Log_File_Name := Ada.Strings.Unbounded.To_Unbounded_String (Argument (Next_Arg + 1));
Next_Arg := Next_Arg + 2;
end if;
end loop;
end return;
end Get_Process_Start_Params;
function Get_Parse_Params (Command_Line : in String; Last : in out Integer) return Parse_Params
is
use WisiToken;
begin
return Result : Parse_Params do
-- We don't use an aggregate, to enforce execution order.
-- Match wisi-process-parse.el wisi-process--send-parse
Result.Post_Parse_Action := Wisi.Post_Parse_Action_Type'Val (Get_Integer (Command_Line, Last));
Result.Source_File_Name := +Get_String (Command_Line, Last);
Result.Begin_Byte_Pos := Get_Integer (Command_Line, Last);
-- Emacs end is after last char.
Result.End_Byte_Pos := Get_Integer (Command_Line, Last) - 1;
Result.Goal_Byte_Pos := Get_Integer (Command_Line, Last);
Result.Begin_Char_Pos := WisiToken.Buffer_Pos (Get_Integer (Command_Line, Last));
Result.Begin_Line := WisiToken.Line_Number_Type (Get_Integer (Command_Line, Last));
Result.End_Line := WisiToken.Line_Number_Type (Get_Integer (Command_Line, Last));
Result.Begin_Indent := Get_Integer (Command_Line, Last);
Result.Partial_Parse_Active := 1 = Get_Integer (Command_Line, Last);
Result.Debug_Mode := 1 = Get_Integer (Command_Line, Last);
Result.Parse_Verbosity := Get_Integer (Command_Line, Last);
Result.McKenzie_Verbosity := Get_Integer (Command_Line, Last);
Result.Action_Verbosity := Get_Integer (Command_Line, Last);
Result.McKenzie_Disable := Get_Integer (Command_Line, Last);
Result.Task_Count := Get_Integer (Command_Line, Last);
Result.Check_Limit := Get_Integer (Command_Line, Last);
Result.Enqueue_Limit := Get_Integer (Command_Line, Last);
Result.Max_Parallel := Get_Integer (Command_Line, Last);
Result.Byte_Count := Get_Integer (Command_Line, Last);
end return;
end Get_Parse_Params;
function Get_Refactor_Params (Command_Line : in String; Last : in out Integer) return Refactor_Params
is
use WisiToken;
begin
return Result : Refactor_Params do
-- We don't use an aggregate, to enforce execution order.
-- Match wisi-process-parse.el wisi-process--send-refactor
Result.Refactor_Action := Get_Integer (Command_Line, Last);
Result.Source_File_Name := +Get_String (Command_Line, Last);
Result.Parse_Region.First := WisiToken.Buffer_Pos (Get_Integer (Command_Line, Last));
Result.Parse_Region.Last := WisiToken.Buffer_Pos (Get_Integer (Command_Line, Last) - 1);
Result.Edit_Begin := WisiToken.Buffer_Pos (Get_Integer (Command_Line, Last));
Result.Parse_Begin_Char_Pos := WisiToken.Buffer_Pos (Get_Integer (Command_Line, Last));
Result.Parse_Begin_Line := WisiToken.Line_Number_Type (Get_Integer (Command_Line, Last));
Result.Parse_End_Line := WisiToken.Line_Number_Type (Get_Integer (Command_Line, Last));
Result.Debug_Mode := 1 = Get_Integer (Command_Line, Last);
Result.Parse_Verbosity := Get_Integer (Command_Line, Last);
Result.Action_Verbosity := Get_Integer (Command_Line, Last);
Result.Max_Parallel := Get_Integer (Command_Line, Last);
Result.Byte_Count := Get_Integer (Command_Line, Last);
end return;
end Get_Refactor_Params;
procedure Process_Stream
(Name : in String;
Language_Protocol_Version : in String;
Partial_Parse_Active : in out Boolean;
Params : in Process_Start_Params;
Parser : in out WisiToken.Parse.LR.Parser.Parser;
Parse_Data : in out Wisi.Parse_Data_Type'Class;
Descriptor : in WisiToken.Descriptor)
is
use Ada.Text_IO;
use WisiToken; -- "+", "-" Unbounded_string
procedure Cleanup
is begin
if Is_Open (Parser.Recover_Log_File) then
Close (Parser.Recover_Log_File);
end if;
end Cleanup;
begin
declare
use Ada.Directories;
use Ada.Strings.Unbounded;
begin
if Length (Params.Recover_Log_File_Name) > 0 then
Put_Line (";; logging to '" & (-Params.Recover_Log_File_Name) & "'");
-- to Current_Output, visible from Emacs
if Exists (-Params.Recover_Log_File_Name) then
Open (Parser.Recover_Log_File, Append_File, -Params.Recover_Log_File_Name);
else
Create (Parser.Recover_Log_File, Out_File, -Params.Recover_Log_File_Name);
end if;
end if;
end;
Parser.Trace.Set_Prefix (";; "); -- so debug messages don't confuse Emacs.
Put_Line
(Name & " protocol: process version " & Protocol_Version & " language version " & Language_Protocol_Version);
-- Read commands and tokens from standard_input via GNAT.OS_Lib,
-- send results to standard_output.
loop
Put (Prompt); Flush;
declare
Command_Length : constant Integer := Get_Command_Length;
Command_Line : aliased String (1 .. Command_Length);
Last : Integer;
function Match (Target : in String) return Boolean
is begin
Last := Command_Line'First + Target'Length - 1;
return Last <= Command_Line'Last and then Command_Line (Command_Line'First .. Last) = Target;
end Match;
begin
Read_Input (Command_Line'Address, Command_Length);
Put_Line (";; " & Command_Line);
if Match ("parse") then
-- Args: see wisi-process-parse.el wisi-process-parse--send-parse
-- Input: <source text>
-- Response:
-- [response elisp vector]...
-- [elisp error form]...
-- prompt
declare
Params : constant Parse_Params := Get_Parse_Params (Command_Line, Last);
Buffer : Ada.Strings.Unbounded.String_Access;
procedure Clean_Up
is
use all type SAL.Base_Peek_Type;
begin
Parser.Lexer.Discard_Rest_Of_Input;
if Parser.Parsers.Count > 0 then
Parse_Data.Put
(Parser.Lexer.Errors,
Parser.Parsers.First.State_Ref.Errors,
Parser.Parsers.First.State_Ref.Tree);
end if;
Ada.Strings.Unbounded.Free (Buffer);
end Clean_Up;
begin
Trace_Parse := Params.Parse_Verbosity;
Trace_McKenzie := Params.McKenzie_Verbosity;
Trace_Action := Params.Action_Verbosity;
Debug_Mode := Params.Debug_Mode;
Partial_Parse_Active := Params.Partial_Parse_Active;
if WisiToken.Parse.LR.McKenzie_Defaulted (Parser.Table.all) then
-- There is no McKenzie information; don't override that.
null;
elsif Params.McKenzie_Disable = -1 then
-- Use default
Parser.Enable_McKenzie_Recover := True;
else
Parser.Enable_McKenzie_Recover := Params.McKenzie_Disable = 0;
end if;
Parse_Data.Initialize
(Post_Parse_Action => Params.Post_Parse_Action,
Lexer => Parser.Lexer,
Descriptor => Descriptor'Unrestricted_Access,
Base_Terminals => Parser.Terminals'Unrestricted_Access,
Begin_Line => Params.Begin_Line,
End_Line => Params.End_Line,
Begin_Indent => Params.Begin_Indent,
Params => Command_Line (Last + 2 .. Command_Line'Last));
if Params.Task_Count > 0 then
Parser.Table.McKenzie_Param.Task_Count := System.Multiprocessors.CPU_Range (Params.Task_Count);
end if;
if Params.Check_Limit > 0 then
Parser.Table.McKenzie_Param.Check_Limit := Base_Token_Index (Params.Check_Limit);
end if;
if Params.Enqueue_Limit > 0 then
Parser.Table.McKenzie_Param.Enqueue_Limit := Params.Enqueue_Limit;
end if;
if Params.Max_Parallel > 0 then
Parser.Max_Parallel := SAL.Base_Peek_Type (Params.Max_Parallel);
end if;
Buffer := new String (Params.Begin_Byte_Pos .. Params.End_Byte_Pos);
Read_Input (Buffer (Params.Begin_Byte_Pos)'Address, Params.Byte_Count);
Parser.Lexer.Reset_With_String_Access
(Buffer, Params.Source_File_Name, Params.Begin_Char_Pos, Params.Begin_Line);
begin
Parser.Parse;
exception
when WisiToken.Partial_Parse =>
null;
end;
Parser.Execute_Actions;
Parse_Data.Put (Parser);
Clean_Up;
exception
when Syntax_Error =>
Clean_Up;
Put_Line ("(parse_error)");
when E : Parse_Error =>
Clean_Up;
Put_Line ("(parse_error """ & Ada.Exceptions.Exception_Message (E) & """)");
when E : Fatal_Error =>
Clean_Up;
Put_Line ("(error """ & Ada.Exceptions.Exception_Message (E) & """)");
end;
elsif Match ("refactor") then
-- Args: see wisi-process-parse.el wisi-process-parse--send-refactor
-- Input: <source text>
-- Response:
-- [edit elisp vector]...
-- prompt
declare
Params : constant Refactor_Params := Get_Refactor_Params (Command_Line, Last);
Buffer : Ada.Strings.Unbounded.String_Access;
procedure Clean_Up
is
use all type SAL.Base_Peek_Type;
begin
Parser.Lexer.Discard_Rest_Of_Input;
if Parser.Parsers.Count > 0 then
Parse_Data.Put
(Parser.Lexer.Errors,
Parser.Parsers.First.State_Ref.Errors,
Parser.Parsers.First.State_Ref.Tree);
end if;
Ada.Strings.Unbounded.Free (Buffer);
end Clean_Up;
begin
Trace_Parse := Params.Parse_Verbosity;
Trace_Action := Params.Action_Verbosity;
Debug_Mode := Params.Debug_Mode;
Partial_Parse_Active := True;
Parse_Data.Initialize
(Post_Parse_Action => Wisi.Navigate, -- mostly ignored
Lexer => Parser.Lexer,
Descriptor => Descriptor'Unrestricted_Access,
Base_Terminals => Parser.Terminals'Unrestricted_Access,
Begin_Line => Params.Parse_Begin_Line,
End_Line => Params.Parse_End_Line,
Begin_Indent => 0,
Params => "");
if Params.Max_Parallel > 0 then
Parser.Max_Parallel := SAL.Base_Peek_Type (Params.Max_Parallel);
end if;
Buffer := new String (Integer (Params.Parse_Region.First) .. Integer (Params.Parse_Region.Last));
Read_Input (Buffer (Buffer'First)'Address, Params.Byte_Count);
Parser.Lexer.Reset_With_String_Access
(Buffer, Params.Source_File_Name, Params.Parse_Begin_Char_Pos, Params.Parse_Begin_Line);
begin
Parser.Parse;
exception
when WisiToken.Partial_Parse =>
null;
end;
Parser.Execute_Actions;
Parse_Data.Refactor (Parser.Parsers.First_State_Ref.Tree, Params.Refactor_Action, Params.Edit_Begin);
Clean_Up;
exception
when Syntax_Error =>
Clean_Up;
Put_Line ("(parse_error ""refactor " & Params.Parse_Region.First'Image &
Params.Parse_Region.Last'Image & ": syntax error"")");
when E : Parse_Error =>
Clean_Up;
Put_Line ("(parse_error ""refactor " & Params.Parse_Region.First'Image &
Params.Parse_Region.Last'Image & ": " & Ada.Exceptions.Exception_Message (E) & """)");
when E : others => -- includes Fatal_Error
Clean_Up;
Put_Line ("(error """ & Ada.Exceptions.Exception_Message (E) & """)");
end;
elsif Match ("noop") then
-- Args: <source byte count>
-- Input: <source text>
-- Response: prompt
declare
Byte_Count : constant Integer := Get_Integer (Command_Line, Last);
Buffer : constant Ada.Strings.Unbounded.String_Access := new String (1 .. Byte_Count);
Token : Base_Token;
Lexer_Error : Boolean;
pragma Unreferenced (Lexer_Error);
begin
Token.ID := Invalid_Token_ID;
Read_Input (Buffer (1)'Address, Byte_Count);
Parser.Lexer.Reset_With_String_Access (Buffer, +"");
loop
exit when Token.ID = Parser.Trace.Descriptor.EOI_ID;
Lexer_Error := Parser.Lexer.Find_Next (Token);
end loop;
exception
when Syntax_Error =>
Parser.Lexer.Discard_Rest_Of_Input;
end;
elsif Match ("quit") then
exit;
else
Put_Line ("(error ""bad command: '" & Command_Line & "'"")");
end if;
exception
when E : Protocol_Error =>
-- don't exit the loop; allow debugging bad elisp
Put_Line ("(error ""protocol error "": " & Ada.Exceptions.Exception_Message (E) & """)");
end;
end loop;
Cleanup;
exception
when Finish =>
null;
when E : others =>
Cleanup;
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
New_Line (2);
Put_Line
("(error ""unhandled exception: " & Ada.Exceptions.Exception_Name (E) & ": " &
Ada.Exceptions.Exception_Message (E) & """)");
Put_Line (GNAT.Traceback.Symbolic.Symbolic_Traceback (E));
end Process_Stream;
end Emacs_Wisi_Common_Parse;
|
------ USANDO IN OUT
procedure Hello is
a: Integer;
b: Float := 2.0 ;
c: Boolean := false;
function uno(a,b:out Boolean; x,y :in Integer) return Boolean is
begin
Put(one);
return a;
end uno;
function dos(a: in out Float; x,y :in Integer) return Boolean is
begin
Put(one);
return a;
end dos;
begin
c := dos(c);
Put(b);
end Hello; |
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- I N T E R F A C E S . F O R T R A N --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-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. --
-- --
------------------------------------------------------------------------------
package body Interfaces.Fortran is
------------
-- To_Ada --
------------
-- Single character case
function To_Ada (Item : Character_Set) return Character is
begin
return Character (Item);
end To_Ada;
-- String case (function returning converted result)
function To_Ada (Item : Fortran_Character) return String is
T : String (1 .. Item'Length);
begin
for J in T'Range loop
T (J) := Character (Item (J - 1 + Item'First));
end loop;
return T;
end To_Ada;
-- String case (procedure copying converted string to given buffer)
procedure To_Ada
(Item : Fortran_Character;
Target : out String;
Last : out Natural)
is
begin
if Item'Length = 0 then
Last := 0;
return;
elsif Target'Length = 0 then
raise Constraint_Error;
else
Last := Target'First - 1;
for J in Item'Range loop
Last := Last + 1;
if Last > Target'Last then
raise Constraint_Error;
else
Target (Last) := Character (Item (J));
end if;
end loop;
end if;
end To_Ada;
----------------
-- To_Fortran --
----------------
-- Character case
function To_Fortran (Item : Character) return Character_Set is
begin
return Character_Set (Item);
end To_Fortran;
-- String case (function returning converted result)
function To_Fortran (Item : String) return Fortran_Character is
T : Fortran_Character (1 .. Item'Length);
begin
for J in T'Range loop
T (J) := Character_Set (Item (J - 1 + Item'First));
end loop;
return T;
end To_Fortran;
-- String case (procedure copying converted string to given buffer)
procedure To_Fortran
(Item : String;
Target : out Fortran_Character;
Last : out Natural)
is
begin
if Item'Length = 0 then
Last := 0;
return;
elsif Target'Length = 0 then
raise Constraint_Error;
else
Last := Target'First - 1;
for J in Item'Range loop
Last := Last + 1;
if Last > Target'Last then
raise Constraint_Error;
else
Target (Last) := Character_Set (Item (J));
end if;
end loop;
end if;
end To_Fortran;
end Interfaces.Fortran;
|
-- The Village of Vampire by YT, このソースコードはNYSLです
with Ada.Strings.Unbounded;
with Tabula.Calendar.Time_IO;
with Tabula.Casts.Cast_IO;
with Tabula.Villages.Village_IO;
package body Vampire.Villages.Village_IO is
use People;
use Person_Records;
procedure IO (
Serializer : not null access Serialization.Serializer;
Name : in String;
People : in out Villages.People.Vector)
is
package People_IO is
new Serialization.IO_List (
Cursor => Villages.People.Cursor,
Element_Type => Person_Type,
Container_Type => Villages.People.Vector,
Reference_Type => Villages.People.Reference_Type,
Default => Empty_Person,
Has_Element => Villages.People.Has_Element,
Next => Villages.People.Cursor'Succ);
use Serialization;
use Person_Role_IO;
use Person_State_IO;
use Requested_Role_IO;
use People_IO;
use Calendar.Time_IO;
use Casts.Cast_IO;
procedure People_Callback (
Serializer : not null access Serialization.Serializer;
Item : in out Person_Type)
is
procedure Person_Records_Callback (
Serializer : not null access Serialization.Serializer;
Item : in out Person_Record) is
begin
for P in IO (Serializer) loop
IO (Serializer, "state", Item.State);
IO (Serializer, "vote", Item.Vote, Default => Default_Person_Record.Vote);
IO (Serializer, "provisional-vote", Item.Provisional_Vote,
Default => Default_Person_Record.Provisional_Vote);
IO (Serializer, "candidate", Item.Candidate,
Default => Default_Person_Record.Candidate);
IO (Serializer, "target", Item.Target,
Default => Default_Person_Record.Target);
IO (Serializer, "special", Item.Special,
Default => Default_Person_Record.Special);
IO (Serializer, "note", Item.Note, Default => Default_Person_Record.Note);
end loop;
end Person_Records_Callback;
package Person_Records_IO is
new Serialization.IO_List (
Cursor => Villages.Person_Records.Cursor,
Element_Type => Person_Record,
Container_Type => Villages.Person_Records.Vector,
Reference_Type => Villages.Person_Records.Reference_Type,
Default => Default_Person_Record,
Has_Element => Villages.Person_Records.Has_Element,
Next => Villages.Person_Records.Cursor'Succ);
use Person_Records_IO;
begin
for P in IO (Serializer) loop
IO (Serializer, "id", Item.Id);
IO_Partial (Serializer, Item);
IO (Serializer, "request", Item.Request);
IO (Serializer, "role", Item.Role);
IO (Serializer, "ignore-request", Item.Ignore_Request,
Default => Empty_Person.Ignore_Request);
IO (Serializer, "records", Item.Records, Person_Records_Callback'Access);
IO (Serializer, "commited", Item.Commited);
end loop;
end People_Callback;
begin
IO (Serializer, Name, People, People_Callback'Access);
end IO;
procedure IO (
Serializer : not null access Serialization.Serializer;
Name : in String;
Messages : in out Villages.Messages.Vector)
is
use Serialization;
use Message_Kind_IO;
use Calendar.Time_IO;
procedure Messages_Callback (
Serializer : not null access Serialization.Serializer;
Item : in out Message) is
begin
for P in IO (Serializer) loop
IO (Serializer, "day", Item.Day);
IO (Serializer, "time", Item.Time);
IO (Serializer, "kind", Item.Kind);
IO (Serializer, "subject", Item.Subject, Default => Default_Message.Subject);
IO (Serializer, "target", Item.Target, Default => Default_Message.Target);
IO (Serializer, "text", Item.Text, Default => Default_Message.Text);
end loop;
end Messages_Callback;
use Villages.Messages;
package Messages_IO is
new Serialization.IO_List (
Cursor => Villages.Messages.Cursor,
Element_Type => Message,
Container_Type => Villages.Messages.Vector,
Reference_Type => Villages.Messages.Reference_Type,
Default => Default_Message,
Has_Element => Villages.Messages.Has_Element,
Next => Villages.Messages.Cursor'Succ);
use Messages_IO;
begin
IO (Serializer, Name, Messages, Messages_Callback'Access);
end IO;
procedure IO (
Serializer : not null access Serialization.Serializer;
Village : in out Village_Type;
Info_Only : in Boolean := False)
is
use Serialization;
use Calendar.Time_IO;
use Tabula.Villages.Village_IO.Village_State_IO;
use Village_Time_IO;
use Vote_IO;
use Execution_IO;
use Attack_IO;
use Vampire_Action_Set_IO;
use Servant_Knowing_IO;
use Person_Role_IO;
use Monster_Side_IO;
use Role_Appearance_IO;
use Hunter_Silver_Bullet_IO;
use Unfortunate_IO;
use Daytime_Preview_IO;
use Doctor_Infected_IO;
use Formation_IO;
use Obsolete_Teaming_IO;
procedure IO (
Serializer : not null access Serialization.Serializer;
Name : in String;
Item : in out Role_Appearances) is
begin
for P in IO (Serializer, Name) loop
for I in Village.Appearance'Range loop
IO (Serializer, Person_Role'Image (I), Item (I));
end loop;
end loop;
end IO;
begin
for P in IO (Serializer) loop
-- inherited
IO (Serializer, "name", Village.Name);
IO (Serializer, "by", Village.By,
Default => Ada.Strings.Unbounded.Null_Unbounded_String);
IO (Serializer, "face-group", Village.Face_Group);
IO (Serializer, "face-width", Village.Face_Width);
IO (Serializer, "face-height", Village.Face_Height);
-- additional
IO (Serializer, "state", Village.State);
IO (Serializer, "today", Village.Today);
IO (Serializer, "time", Village.Time);
IO (Serializer, "dawn", Village.Dawn);
IO (Serializer, "day-duration", Village.Day_Duration);
IO (Serializer, "night-duration", Village.Night_Duration);
IO (Serializer, "vote", Village.Vote, Default => Unsigned);
IO (Serializer, "execution", Village.Execution, Default => From_First);
IO (Serializer, "formation", Village.Formation, Default => Public);
IO (Serializer, "monster-side", Village.Monster_Side, Default => Fixed);
IO (Serializer, "attack", Village.Attack, Default => Two);
IO (Serializer, "vampire-action-set", Village.Vampire_Action_Set,
Default => Gaze);
IO (Serializer, "servant-knowing", Village.Servant_Knowing, Default => None);
IO (Serializer, "daytime-preview", Village.Daytime_Preview,
Default => Role_And_Message);
IO (Serializer, "doctor-infected", Village.Doctor_Infected, Default => Cure);
IO (Serializer, "hunter-silver-bullet", Village.Hunter_Silver_Bullet,
Default => Target_And_Self);
IO (Serializer, "unfortunate", Village.Unfortunate, Default => None);
IO (Serializer, "teaming", Village.Obsolete_Teaming); -- 記録用
if Serializer.Direction = Reading
or else Village.Appearance /= Role_Appearances'(others => Random)
then
IO (Serializer, "appearance", Village.Appearance);
end if;
if Serializer.Direction = Reading
or else Village.Execution = Dummy_Killed_And_From_First
then
IO (Serializer, "dummy-role", Village.Dummy_Role);
end if;
IO (Serializer, "people", Village.People);
if Serializer.Direction = Reading
or else not Village.Escaped_People.Is_Empty
then
IO (Serializer, "escaped-people", Village.Escaped_People);
end if;
if not Info_Only then
IO (Serializer, "messages", Village.Messages);
end if;
end loop;
end IO;
end Vampire.Villages.Village_IO;
|
with Ada.Text_IO;
procedure double_1_20 is
package T_IO renames Ada.Text_IO;
package I_IO is new Ada.Text_IO.Integer_IO(Integer);
procedure Power(Item : in out Integer)is
begin
Item:=Item*2;
end Power;
X:Integer := 1;
begin
for i in Integer range 1..30 loop
I_IO.Put(X);
T_IO.New_Line;
Power(X);
end loop;
end double_1_20;
|
-- Copyright 2017 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
local json = require("json")
name = "ReconDev"
type = "api"
function start()
setratelimit(5)
end
function check()
local c
local cfg = datasrc_config()
if cfg ~= nil then
c = cfg.credentials
end
if (c ~= nil and c.key ~= nil and c.key ~= "") then
return true
end
return false
end
function vertical(ctx, domain)
local c
local cfg = datasrc_config()
if cfg ~= nil then
c = cfg.credentials
end
if (c == nil or c.key == nil or c.key == "") then
return
end
local resp
local u = buildurl(domain, c.key)
-- Check if the response data is in the graph database
if (cfg.ttl ~= nil and cfg.ttl > 0) then
resp = obtain_response(domain, cfg.ttl)
end
if (resp == nil or resp == "") then
local err
resp, err = request(ctx, {
url=u,
headers={['Content-Type']="application/json"},
})
if (err ~= nil and err ~= "") then
log(ctx, err .. ": " .. resp)
return
end
if (cfg.ttl ~= nil and cfg.ttl > 0) then
cache_response(domain, resp)
end
end
local data = json.decode(resp)
if (data == nil or #data == 0) then
return
end
for i, set in pairs(data) do
local domains = set["rawDomains"]
if domains ~= nil and #domains > 0 then
for j, name in pairs(domains) do
sendnames(ctx, name)
end
end
local addrs = set["rawIp"]
if addr ~= nil then
newaddr(ctx, domain, addr)
end
end
end
function buildurl(domain, key)
return "https://recon.dev/api/search?key=" .. key .. "&domain=" .. domain
end
function sendnames(ctx, content)
local names = find(content, subdomainre)
if names == nil then
return
end
local found = {}
for i, v in pairs(names) do
if found[v] == nil then
newname(ctx, v)
found[v] = true
end
end
end
|
-- { dg-do run }
-- { dg-options "-O2" }
with Enum1_Pkg; use Enum1_Pkg;
procedure Enum1 is
function Cond return Boolean is
begin
return My_N = Two or My_N = Three;
end;
begin
if Cond then
raise Constraint_Error;
end if;
end;
|
--
-- Jan & Uwe R. Zimmer, Australia, July 2011
--
with Real_Type; use Real_Type;
generic
type Element is private;
Buffer_Size : Positive;
package Generic_Sliding_Statistics is
procedure Add_Reading (New_Reading : Element);
generic
with function "+" (Left, Right : Element) return Element is <>;
with function "/" (Left : Element; Right : Real) return Element is <>;
package Averages is
function Average (New_Reading : Element) return Element;
function Average return Element;
end Averages;
--
generic
pragma Warnings (Off, "declaration of ""<"" hides predefined operator");
with function "<" (Left, Right : Element) return Boolean is <>;
pragma Warnings (On, "declaration of ""<"" hides predefined operator");
package MinMax is
function Min (New_Reading : Element) return Element;
function Max (New_Reading : Element) return Element;
function Min return Element;
function Max return Element;
end MinMax;
No_Elements_in_Stats_Buffer : exception;
end Generic_Sliding_Statistics;
|
with
FLTK.Menu_Items,
Ada.Iterator_Interfaces;
private with
Ada.Containers.Vectors,
Interfaces,
System;
package FLTK.Widgets.Menus is
type Menu is new Widget with private
with Default_Iterator => Iterate,
Iterator_Element => FLTK.Menu_Items.Menu_Item_Reference,
Variable_Indexing => Item;
type Menu_Reference (Data : not null access Menu'Class) is limited null record
with Implicit_Dereference => Data;
subtype Index is Positive;
subtype Extended_Index is Natural;
No_Index : constant Extended_Index := Extended_Index'First;
type Cursor is private;
package Forge is
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Menu;
end Forge;
procedure Add
(This : in out Menu;
Text : in String;
Action : in Widget_Callback := null;
Shortcut : in Key_Combo := No_Key;
Flags : in Menu_Flag := Flag_Normal);
procedure Insert
(This : in out Menu;
Place : in Index;
Text : in String;
Action : in Widget_Callback := null;
Shortcut : in Key_Combo := No_Key;
Flags : in Menu_Flag := Flag_Normal);
procedure Remove
(This : in out Menu;
Place : in Index);
procedure Clear
(This : in out Menu);
function Has_Item
(This : in Menu;
Place : in Index)
return Boolean;
function Has_Item
(Place : in Cursor)
return Boolean;
function Item
(This : in Menu;
Place : in Index)
return FLTK.Menu_Items.Menu_Item_Reference;
function Item
(This : in Menu;
Place : in Cursor)
return FLTK.Menu_Items.Menu_Item_Reference;
function Find_Item
(This : in Menu;
Name : in String)
return FLTK.Menu_Items.Menu_Item_Reference;
function Find_Item
(This : in Menu;
Action : in Widget_Callback)
return FLTK.Menu_Items.Menu_Item_Reference;
function Find_Index
(This : in Menu;
Name : in String)
return Extended_Index;
function Find_Index
(This : in Menu;
Item : in FLTK.Menu_Items.Menu_Item)
return Extended_Index;
function Find_Index
(This : in Menu;
Action : in Widget_Callback)
return Extended_Index;
function Number_Of_Items
(This : in Menu)
return Natural;
package Menu_Iterators is
new Ada.Iterator_Interfaces (Cursor, Has_Item);
function Iterate
(This : in Menu)
return Menu_Iterators.Reversible_Iterator'Class;
function Chosen
(This : in Menu)
return FLTK.Menu_Items.Menu_Item_Reference;
function Chosen_Label
(This : in Menu)
return String;
function Chosen_Index
(This : in Menu)
return Extended_Index;
procedure Set_Chosen
(This : in out Menu;
Place : in Index);
procedure Set_Chosen
(This : in out Menu;
Item : in FLTK.Menu_Items.Menu_Item);
function Get_Text_Color
(This : in Menu)
return Color;
procedure Set_Text_Color
(This : in out Menu;
To : in Color);
function Get_Text_Font
(This : in Menu)
return Font_Kind;
procedure Set_Text_Font
(This : in out Menu;
To : in Font_Kind);
function Get_Text_Size
(This : in Menu)
return Font_Size;
procedure Set_Text_Size
(This : in out Menu;
To : in Font_Size);
function Get_Down_Box
(This : in Menu)
return Box_Kind;
procedure Set_Down_Box
(This : in out Menu;
To : in Box_Kind);
procedure Make_Global
(This : in out Menu);
procedure Measure_Item
(This : in Menu;
Item : in Index;
W, H : out Integer);
function Popup
(This : in Menu;
X, Y : in Integer;
Title : in String := "";
Initial : in Extended_Index := No_Index)
return FLTK.Menu_Items.Menu_Item_Reference;
function Pulldown
(This : in Menu;
X, Y, W, H : in Integer;
Initial : in Extended_Index := No_Index)
return FLTK.Menu_Items.Menu_Item_Reference;
procedure Draw
(This : in out Menu) is null;
procedure Draw_Item
(This : in out Menu;
Item : in Index;
X, Y, W, H : in Integer;
Selected : in Boolean := False);
function Handle
(This : in out Menu;
Event : in Event_Kind)
return Event_Outcome;
private
-- I'm not very happy with using a Vector of dynamically allocated
-- Menu_Item wrappers like this, but I kinda painted myself into a
-- corner with use of Limited_Controlled and the way the Add method
-- works for Menus.
type Item_Access is access FLTK.Menu_Items.Menu_Item;
package Item_Vectors is new Ada.Containers.Vectors
(Index_Type => Positive, Element_Type => Item_Access);
type Menu is new Widget with record
My_Items : Item_Vectors.Vector;
end record;
overriding procedure Finalize
(This : in out Menu);
procedure Item_Hook (M, U : in System.Address);
pragma Convention (C, Item_Hook);
type Cursor is record
My_Container : access Menu;
My_Index : Index'Base := Index'First;
end record;
type Iterator is new Menu_Iterators.Reversible_Iterator with record
My_Container : access Menu;
end record;
overriding function First
(Object : in Iterator)
return Cursor;
overriding function Next
(Object : in Iterator;
Place : in Cursor)
return Cursor;
overriding function Last
(Object : in Iterator)
return Cursor;
overriding function Previous
(Object : in Iterator;
Place : in Cursor)
return Cursor;
pragma Inline (Has_Item);
pragma Inline (Item);
pragma Inline (Find_Item);
pragma Inline (Find_Index);
pragma Inline (Number_Of_Items);
pragma Inline (Iterate);
pragma Inline (Chosen);
pragma Inline (Chosen_Label);
pragma Inline (Chosen_Index);
pragma Inline (Set_Chosen);
pragma Inline (Get_Text_Color);
pragma Inline (Set_Text_Color);
pragma Inline (Get_Text_Font);
pragma Inline (Set_Text_Font);
pragma Inline (Get_Text_Size);
pragma Inline (Set_Text_Size);
pragma Inline (Get_Down_Box);
pragma Inline (Set_Down_Box);
pragma Inline (Make_Global);
pragma Inline (Measure_Item);
pragma Inline (Popup);
pragma Inline (Pulldown);
pragma Inline (Draw);
pragma Inline (Draw_Item);
pragma Inline (Handle);
end FLTK.Widgets.Menus;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . C O M M A N D _ L I N E --
-- --
-- S p e c --
-- --
-- Copyright (C) 1999-2016, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- High level package for command line parsing and manipulation
----------------------------------------
-- Simple Parsing of the Command Line --
----------------------------------------
-- This package provides an interface for parsing command line arguments,
-- when they are either read from Ada.Command_Line or read from a string list.
-- As shown in the example below, one should first retrieve the switches
-- (special command line arguments starting with '-' by default) and their
-- parameters, and then the rest of the command line arguments.
--
-- While it may appear easy to parse the command line arguments with
-- Ada.Command_Line, there are in fact lots of special cases to handle in some
-- applications. Those are fully managed by GNAT.Command_Line. Among these are
-- switches with optional parameters, grouping switches (for instance "-ab"
-- might mean the same as "-a -b"), various characters to separate a switch
-- and its parameter (or none: "-a 1" and "-a1" are generally the same, which
-- can introduce confusion with grouped switches),...
--
-- begin
-- loop
-- case Getopt ("a b: ad") is -- Accepts '-a', '-ad', or '-b argument'
-- when ASCII.NUL => exit;
-- when 'a' =>
-- if Full_Switch = "a" then
-- Put_Line ("Got a");
-- else
-- Put_Line ("Got ad");
-- end if;
-- when 'b' => Put_Line ("Got b + " & Parameter);
-- when others =>
-- raise Program_Error; -- cannot occur
-- end case;
-- end loop;
-- loop
-- declare
-- S : constant String := Get_Argument (Do_Expansion => True);
-- begin
-- exit when S'Length = 0;
-- Put_Line ("Got " & S);
-- end;
-- end loop;
-- exception
-- when Invalid_Switch => Put_Line ("Invalid Switch " & Full_Switch);
-- when Invalid_Parameter => Put_Line ("No parameter for " & Full_Switch);
-- end;
--------------
-- Sections --
--------------
-- A more complicated example would involve the use of sections for the
-- switches, as for instance in gnatmake. The same command line is used to
-- provide switches for several tools. Each tool recognizes its switches by
-- separating them with special switches that act as section separators.
-- Each section acts as a command line of its own.
-- begin
-- Initialize_Option_Scan ('-', False, "largs bargs cargs");
-- loop
-- -- Same loop as above to get switches and arguments
-- end loop;
-- Goto_Section ("bargs");
-- loop
-- -- Same loop as above to get switches and arguments
-- -- The supported switches in Getopt might be different
-- end loop;
-- Goto_Section ("cargs");
-- loop
-- -- Same loop as above to get switches and arguments
-- -- The supported switches in Getopt might be different
-- end loop;
-- end;
-------------------------------
-- Parsing a List of Strings --
-------------------------------
-- The examples above show how to parse the command line when the arguments
-- are read directly from Ada.Command_Line. However, these arguments can also
-- be read from a list of strings. This can be useful in several contexts,
-- either because your system does not support Ada.Command_Line, or because
-- you are manipulating other tools and creating their command lines by hand,
-- or for any other reason.
-- To create the list of strings, it is recommended to use
-- GNAT.OS_Lib.Argument_String_To_List.
-- The example below shows how to get the parameters from such a list. Note
-- also the use of '*' to get all the switches, and not report errors when an
-- unexpected switch was used by the user
-- declare
-- Parser : Opt_Parser;
-- Args : constant Argument_List_Access :=
-- GNAT.OS_Lib.Argument_String_To_List ("-g -O1 -Ipath");
-- begin
-- Initialize_Option_Scan (Parser, Args);
-- while Getopt ("* g O! I=", Parser) /= ASCII.NUL loop
-- Put_Line ("Switch " & Full_Switch (Parser)
-- & " param=" & Parameter (Parser));
-- end loop;
-- Free (Parser);
-- end;
-------------------------------------------
-- High-Level Command Line Configuration --
-------------------------------------------
-- As shown above, the code is still relatively low-level. For instance, there
-- is no way to indicate which switches are related (thus if "-l" and "--long"
-- should have the same effect, your code will need to test for both cases).
-- Likewise, it is difficult to handle more advanced constructs, like:
-- * Specifying -gnatwa is the same as specifying -gnatwu -gnatwv, but
-- shorter and more readable
-- * All switches starting with -gnatw can be grouped, for instance one
-- can write -gnatwcd instead of -gnatwc -gnatwd.
-- Of course, this can be combined with the above and -gnatwacd is the
-- same as -gnatwc -gnatwd -gnatwu -gnatwv
-- * The switch -T is the same as -gnatwAB (same as -gnatwA -gnatwB)
-- With the above form of Getopt, you would receive "-gnatwa", "-T" or
-- "-gnatwcd" in the examples above, and thus you require additional manual
-- parsing of the switch.
-- Instead, this package provides the type Command_Line_Configuration, which
-- stores all the knowledge above. For instance:
-- Config : Command_Line_Configuration;
-- Define_Alias (Config, "-gnatwa", "-gnatwu -gnatwv");
-- Define_Prefix (Config, "-gnatw");
-- Define_Alias (Config, "-T", "-gnatwAB");
-- You then need to specify all possible switches in your application by
-- calling Define_Switch, for instance:
-- Define_Switch (Config, "-gnatwu", Help => "warn on unused entities");
-- Define_Switch (Config, "-gnatwv", Help => "warn on unassigned var");
-- ...
-- Specifying the help message is optional, but makes it easy to then call
-- the function:
-- Display_Help (Config);
-- that will display a properly formatted help message for your application,
-- listing all possible switches. That way you have a single place in which
-- to maintain the list of switches and their meaning, rather than maintaining
-- both the string to pass to Getopt and a subprogram to display the help.
-- Both will properly stay synchronized.
-- Once you have this Config, you just have to call:
-- Getopt (Config, Callback'Access);
-- to parse the command line. The Callback will be called for each switch
-- found on the command line (in the case of our example, that is "-gnatwu"
-- and then "-gnatwv", not "-gnatwa" itself). This simplifies command line
-- parsing a lot.
-- In fact, this can be further automated for the most command case where the
-- parameter passed to a switch is stored in a variable in the application.
-- When a switch is defined, you only have to indicate where to store the
-- value, and let Getopt do the rest. For instance:
-- Optimization : aliased Integer;
-- Verbose : aliased Boolean;
-- Define_Switch (Config, Verbose'Access,
-- "-v", Long_Switch => "--verbose",
-- Help => "Output extra verbose information");
-- Define_Switch (Config, Optimization'Access,
-- "-O?", Help => "Optimization level");
-- Getopt (Config); -- No callback
-- Since all switches are handled automatically, we don't even need to pass
-- a callback to Getopt. Once getopt has been called, the two variables
-- Optimization and Verbose have been properly initialized, either to the
-- default value or to the value found on the command line.
------------------------------------------------
-- Creating and Manipulating the Command Line --
------------------------------------------------
-- This package provides mechanisms to create and modify command lines by
-- adding or removing arguments from them. The resulting command line is kept
-- as short as possible by coalescing arguments whenever possible.
-- Complex command lines can thus be constructed, for example from a GUI
-- (although this package does not by itself depend upon any specific GUI
-- toolkit).
-- Using the configuration defined earlier, one can then construct a command
-- line for the tool with:
-- Cmd : Command_Line;
-- Set_Configuration (Cmd, Config); -- Config created earlier
-- Add_Switch (Cmd, "-bar");
-- Add_Switch (Cmd, "-gnatwu");
-- Add_Switch (Cmd, "-gnatwv"); -- will be grouped with the above
-- Add_Switch (Cmd, "-T");
-- The resulting command line can be iterated over to get all its switches,
-- There are two modes for this iteration: either you want to get the
-- shortest possible command line, which would be:
-- -bar -gnatwaAB
-- or on the other hand you want each individual switch (so that your own
-- tool does not have to do further complex processing), which would be:
-- -bar -gnatwu -gnatwv -gnatwA -gnatwB
-- Of course, we can assume that the tool you want to spawn would understand
-- both of these, since they are both compatible with the description we gave
-- above. However, the first result is useful if you want to show the user
-- what you are spawning (since that keeps the output shorter), and the second
-- output is more useful for a tool that would check whether -gnatwu was
-- passed (which isn't obvious in the first output). Likewise, the second
-- output is more useful if you have a graphical interface since each switch
-- can be associated with a widget, and you immediately know whether -gnatwu
-- was selected.
--
-- Some command line arguments can have parameters, which on a command line
-- appear as a separate argument that must immediately follow the switch.
-- Since the subprograms in this package will reorganize the switches to group
-- them, you need to indicate what is a command line parameter, and what is a
-- switch argument.
-- This is done by passing an extra argument to Add_Switch, as in:
-- Add_Switch (Cmd, "-foo", Parameter => "arg1");
-- This ensures that "arg1" will always be treated as the argument to -foo,
-- and will not be grouped with other parts of the command line.
with Ada.Command_Line;
with GNAT.Directory_Operations;
with GNAT.OS_Lib;
with GNAT.Regexp;
with GNAT.Strings;
package GNAT.Command_Line is
-------------
-- Parsing --
-------------
type Opt_Parser is private;
Command_Line_Parser : constant Opt_Parser;
-- This object is responsible for parsing a list of arguments, which by
-- default are the standard command line arguments from Ada.Command_Line.
-- This is really a pointer to actual data, which must therefore be
-- initialized through a call to Initialize_Option_Scan, and must be freed
-- with a call to Free.
--
-- As a special case, Command_Line_Parser does not need to be either
-- initialized or free-ed.
procedure Initialize_Option_Scan
(Switch_Char : Character := '-';
Stop_At_First_Non_Switch : Boolean := False;
Section_Delimiters : String := "");
procedure Initialize_Option_Scan
(Parser : out Opt_Parser;
Command_Line : GNAT.OS_Lib.Argument_List_Access;
Switch_Char : Character := '-';
Stop_At_First_Non_Switch : Boolean := False;
Section_Delimiters : String := "");
-- The first procedure resets the internal state of the package to prepare
-- to rescan the parameters. It does not need to be called before the
-- first use of Getopt (but it could be), but it must be called if you
-- want to start rescanning the command line parameters from the start.
-- The optional parameter Switch_Char can be used to reset the switch
-- character, e.g. to '/' for use in DOS-like systems.
--
-- The second subprogram initializes a parser that takes its arguments
-- from an array of strings rather than directly from the command line. In
-- this case, the parser is responsible for freeing the strings stored in
-- Command_Line. If you pass null to Command_Line, this will in fact create
-- a second parser for Ada.Command_Line, which doesn't share any data with
-- the default parser. This parser must be free'ed.
--
-- The optional parameter Stop_At_First_Non_Switch indicates if Getopt is
-- to look for switches on the whole command line, or if it has to stop as
-- soon as a non-switch argument is found.
--
-- Example:
--
-- Arguments: my_application file1 -c
--
-- If Stop_At_First_Non_Switch is False, then -c will be considered
-- as a switch (returned by getopt), otherwise it will be considered
-- as a normal argument (returned by Get_Argument).
--
-- If Section_Delimiters is set, then every following subprogram
-- (Getopt and Get_Argument) will only operate within a section, which
-- is delimited by any of these delimiters or the end of the command line.
--
-- Example:
-- Initialize_Option_Scan (Section_Delimiters => "largs bargs cargs");
--
-- Arguments on command line : my_application -c -bargs -d -e -largs -f
-- This line contains three sections, the first one is the default one
-- and includes only the '-c' switch, the second one is between -bargs
-- and -largs and includes '-d -e' and the last one includes '-f'.
procedure Free (Parser : in out Opt_Parser);
-- Free the memory used by the parser. Calling this is not mandatory for
-- the Command_Line_Parser
procedure Goto_Section
(Name : String := "";
Parser : Opt_Parser := Command_Line_Parser);
-- Change the current section. The next Getopt or Get_Argument will start
-- looking at the beginning of the section. An empty name ("") refers to
-- the first section between the program name and the first section
-- delimiter. If the section does not exist in Section_Delimiters, then
-- Invalid_Section is raised. If the section does not appear on the command
-- line, then it is treated as an empty section.
function Full_Switch
(Parser : Opt_Parser := Command_Line_Parser) return String;
-- Returns the full name of the last switch found (Getopt only returns the
-- first character). Does not include the Switch_Char ('-' by default),
-- unless the "*" option of Getopt is used (see below).
function Current_Section
(Parser : Opt_Parser := Command_Line_Parser) return String;
-- Return the name of the current section.
-- The list of valid sections is defined through Initialize_Option_Scan
function Getopt
(Switches : String;
Concatenate : Boolean := True;
Parser : Opt_Parser := Command_Line_Parser) return Character;
-- This function moves to the next switch on the command line (defined as
-- switch character followed by a character within Switches, casing being
-- significant). The result returned is the first character of the switch
-- that is located. If there are no more switches in the current section,
-- returns ASCII.NUL. If Concatenate is True (the default), the switches do
-- not need to be separated by spaces (they can be concatenated if they do
-- not require an argument, e.g. -ab is the same as two separate arguments
-- -a -b).
--
-- Switches is a string of all the possible switches, separated by
-- spaces. A switch can be followed by one of the following characters:
--
-- ':' The switch requires a parameter. There can optionally be a space
-- on the command line between the switch and its parameter.
--
-- '=' The switch requires a parameter. There can either be a '=' or a
-- space on the command line between the switch and its parameter.
--
-- '!' The switch requires a parameter, but there can be no space on the
-- command line between the switch and its parameter.
--
-- '?' The switch may have an optional parameter. There can be no space
-- between the switch and its argument.
--
-- e.g. if Switches has the following value : "a? b",
-- The command line can be:
--
-- -afoo : -a switch with 'foo' parameter
-- -a foo : -a switch and another element on the
-- command line 'foo', returned by Get_Argument
--
-- Example: if Switches is "-a: -aO:", you can have the following
-- command lines:
--
-- -aarg : 'a' switch with 'arg' parameter
-- -a arg : 'a' switch with 'arg' parameter
-- -aOarg : 'aO' switch with 'arg' parameter
-- -aO arg : 'aO' switch with 'arg' parameter
--
-- Example:
--
-- Getopt ("a b: ac ad?")
--
-- accept either 'a' or 'ac' with no argument,
-- accept 'b' with a required argument
-- accept 'ad' with an optional argument
--
-- If the first item in switches is '*', then Getopt will catch
-- every element on the command line that was not caught by any other
-- switch. The character returned by GetOpt is '*', but Full_Switch
-- contains the full command line argument, including leading '-' if there
-- is one. If this character was not returned, there would be no way of
-- knowing whether it is there or not.
--
-- Example
-- Getopt ("* a b")
-- If the command line is '-a -c toto.o -b', Getopt will return
-- successively 'a', '*', '*' and 'b', with Full_Switch returning
-- "a", "-c", "toto.o", and "b".
--
-- When Getopt encounters an invalid switch, it raises the exception
-- Invalid_Switch and sets Full_Switch to return the invalid switch.
-- When Getopt cannot find the parameter associated with a switch, it
-- raises Invalid_Parameter, and sets Full_Switch to return the invalid
-- switch.
--
-- Note: in case of ambiguity, e.g. switches a ab abc, then the longest
-- matching switch is returned.
--
-- Arbitrary characters are allowed for switches, although it is
-- strongly recommended to use only letters and digits for portability
-- reasons.
--
-- When Concatenate is False, individual switches need to be separated by
-- spaces.
--
-- Example
-- Getopt ("a b", Concatenate => False)
-- If the command line is '-ab', exception Invalid_Switch will be
-- raised and Full_Switch will return "ab".
function Get_Argument
(Do_Expansion : Boolean := False;
Parser : Opt_Parser := Command_Line_Parser) return String;
-- Returns the next element on the command line that is not a switch. This
-- function should not be called before Getopt has returned ASCII.NUL.
--
-- If Do_Expansion is True, then the parameter on the command line will
-- be considered as a filename with wild cards, and will be expanded. The
-- matching file names will be returned one at a time. This is useful in
-- non-Unix systems for obtaining normal expansion of wild card references.
-- When there are no more arguments on the command line, this function
-- returns an empty string.
function Parameter
(Parser : Opt_Parser := Command_Line_Parser) return String;
-- Returns parameter associated with the last switch returned by Getopt.
-- If no parameter was associated with the last switch, or no previous call
-- has been made to Get_Argument, raises Invalid_Parameter. If the last
-- switch was associated with an optional argument and this argument was
-- not found on the command line, Parameter returns an empty string.
function Separator
(Parser : Opt_Parser := Command_Line_Parser) return Character;
-- The separator that was between the switch and its parameter. This is
-- useful if you want to know exactly what was on the command line. This
-- is in general a single character, set to ASCII.NUL if the switch and
-- the parameter were concatenated. A space is returned if the switch and
-- its argument were in two separate arguments.
Invalid_Section : exception;
-- Raised when an invalid section is selected by Goto_Section
Invalid_Switch : exception;
-- Raised when an invalid switch is detected in the command line
Invalid_Parameter : exception;
-- Raised when a parameter is missing, or an attempt is made to obtain a
-- parameter for a switch that does not allow a parameter.
-----------------------------------------
-- Expansion of command line arguments --
-----------------------------------------
-- These subprograms take care of expanding globbing patterns on the
-- command line. On Unix, such expansion is done by the shell before your
-- application is called. But on Windows you must do this expansion
-- yourself.
type Expansion_Iterator is limited private;
-- Type used during expansion of file names
procedure Start_Expansion
(Iterator : out Expansion_Iterator;
Pattern : String;
Directory : String := "";
Basic_Regexp : Boolean := True);
-- Initialize a wild card expansion. The next calls to Expansion will
-- return the next file name in Directory which match Pattern (Pattern
-- is a regular expression, using only the Unix shell and DOS syntax if
-- Basic_Regexp is True). When Directory is an empty string, the current
-- directory is searched.
--
-- Pattern may contain directory separators (as in "src/*/*.ada").
-- Subdirectories of Directory will also be searched, up to one
-- hundred levels deep.
--
-- When Start_Expansion has been called, function Expansion should
-- be called repeatedly until it returns an empty string, before
-- Start_Expansion can be called again with the same Expansion_Iterator
-- variable.
function Expansion (Iterator : Expansion_Iterator) return String;
-- Returns the next file in the directory matching the parameters given
-- to Start_Expansion and updates Iterator to point to the next entry.
-- Returns an empty string when there are no more files.
--
-- If Expansion is called again after an empty string has been returned,
-- then the exception GNAT.Directory_Operations.Directory_Error is raised.
-----------------
-- Configuring --
-----------------
-- The following subprograms are used to manipulate a command line
-- represented as a string (for instance "-g -O2"), as well as parsing
-- the switches from such a string. They provide high-level configurations
-- to define aliases (a switch is equivalent to one or more other switches)
-- or grouping of switches ("-gnatyac" is equivalent to "-gnatya" and
-- "-gnatyc").
-- See the top of this file for examples on how to use these subprograms
type Command_Line_Configuration is private;
procedure Define_Section
(Config : in out Command_Line_Configuration;
Section : String);
-- Indicates a new switch section. All switches belonging to the same
-- section are ordered together, preceded by the section. They are placed
-- at the end of the command line (as in "gnatmake somefile.adb -cargs -g")
--
-- The section name should not include the leading '-'. So for instance in
-- the case of gnatmake we would use:
--
-- Define_Section (Config, "cargs");
-- Define_Section (Config, "bargs");
procedure Define_Alias
(Config : in out Command_Line_Configuration;
Switch : String;
Expanded : String;
Section : String := "");
-- Indicates that whenever Switch appears on the command line, it should
-- be expanded as Expanded. For instance, for the GNAT compiler switches,
-- we would define "-gnatwa" as an alias for "-gnatwcfijkmopruvz", ie some
-- default warnings to be activated.
--
-- This expansion is only done within the specified section, which must
-- have been defined first through a call to [Define_Section].
procedure Define_Prefix
(Config : in out Command_Line_Configuration;
Prefix : String);
-- Indicates that all switches starting with the given prefix should be
-- grouped. For instance, for the GNAT compiler we would define "-gnatw" as
-- a prefix, so that "-gnatwu -gnatwv" can be grouped into "-gnatwuv" It is
-- assumed that the remainder of the switch ("uv") is a set of characters
-- whose order is irrelevant. In fact, this package will sort them
-- alphabetically.
--
-- When grouping switches that accept arguments (for instance "-gnatyL!"
-- as the definition, and "-gnatyaL12b" as the command line), only
-- numerical arguments are accepted. The above is equivalent to
-- "-gnatya -gnatyL12 -gnatyb".
procedure Define_Switch
(Config : in out Command_Line_Configuration;
Switch : String := "";
Long_Switch : String := "";
Help : String := "";
Section : String := "";
Argument : String := "ARG");
-- Indicates a new switch. The format of this switch follows the getopt
-- format (trailing ':', '?', etc for defining a switch with parameters).
--
-- Switch should also start with the leading '-' (or any other characters).
-- If this character is not '-', you need to call Initialize_Option_Scan to
-- set the proper character for the parser.
--
-- The switches defined in the command_line_configuration object are used
-- when ungrouping switches with more that one character after the prefix.
--
-- Switch and Long_Switch (when specified) are aliases and can be used
-- interchangeably. There is no check that they both take an argument or
-- both take no argument. Switch can be set to "*" to indicate that any
-- switch is supported (in which case Getopt will return '*', see its
-- documentation).
--
-- Help is used by the Display_Help procedure to describe the supported
-- switches.
--
-- In_Section indicates in which section the switch is valid (you need to
-- first define the section through a call to Define_Section).
--
-- Argument is the name of the argument, as displayed in the automatic
-- help message. It is always capitalized for consistency.
procedure Define_Switch
(Config : in out Command_Line_Configuration;
Output : access Boolean;
Switch : String := "";
Long_Switch : String := "";
Help : String := "";
Section : String := "";
Value : Boolean := True);
-- See Define_Switch for a description of the parameters.
-- When the switch is found on the command line, Getopt will set
-- Output.all to Value.
--
-- Output is always initially set to "not Value", so that if the switch is
-- not found on the command line, Output still has a valid value.
-- The switch must not take any parameter.
--
-- Output must exist at least as long as Config, otherwise an erroneous
-- memory access may occur.
procedure Define_Switch
(Config : in out Command_Line_Configuration;
Output : access Integer;
Switch : String := "";
Long_Switch : String := "";
Help : String := "";
Section : String := "";
Initial : Integer := 0;
Default : Integer := 1;
Argument : String := "ARG");
-- See Define_Switch for a description of the parameters. When the
-- switch is found on the command line, Getopt will set Output.all to the
-- value of the switch's parameter. If the parameter is not an integer,
-- Invalid_Parameter is raised.
-- Output is always initialized to Initial. If the switch has an optional
-- argument which isn't specified by the user, then Output will be set to
-- Default. The switch must accept an argument.
procedure Define_Switch
(Config : in out Command_Line_Configuration;
Output : access GNAT.Strings.String_Access;
Switch : String := "";
Long_Switch : String := "";
Help : String := "";
Section : String := "";
Argument : String := "ARG");
-- Set Output to the value of the switch's parameter when the switch is
-- found on the command line. Output is always initialized to the empty
-- string if it does not have a value already (otherwise it is left as is
-- so that you can specify the default value directly in the declaration
-- of the variable). The switch must accept an argument.
procedure Set_Usage
(Config : in out Command_Line_Configuration;
Usage : String := "[switches] [arguments]";
Help : String := "";
Help_Msg : String := "");
-- Defines the general format of the call to the application, and a short
-- help text. These are both displayed by Display_Help. When a non-empty
-- Help_Msg is given, it is used by Display_Help instead of the
-- automatically generated list of supported switches.
procedure Display_Help (Config : Command_Line_Configuration);
-- Display the help for the tool (ie its usage, and its supported switches)
function Get_Switches
(Config : Command_Line_Configuration;
Switch_Char : Character := '-';
Section : String := "") return String;
-- Get the switches list as expected by Getopt, for a specific section of
-- the command line. This list is built using all switches defined
-- previously via Define_Switch above.
function Section_Delimiters
(Config : Command_Line_Configuration) return String;
-- Return a string suitable for use in Initialize_Option_Scan
procedure Free (Config : in out Command_Line_Configuration);
-- Free the memory used by Config
type Switch_Handler is access procedure
(Switch : String;
Parameter : String;
Section : String);
-- Called when a switch is found on the command line. Switch includes
-- any leading '-' that was specified in Define_Switch. This is slightly
-- different from the functional version of Getopt above, for which
-- Full_Switch omits the first leading '-'.
Exit_From_Command_Line : exception;
-- Emitted when the program should exit. This is called when Getopt below
-- has seen -h, --help or an invalid switch.
procedure Getopt
(Config : Command_Line_Configuration;
Callback : Switch_Handler := null;
Parser : Opt_Parser := Command_Line_Parser;
Concatenate : Boolean := True);
-- Similar to the standard Getopt function. For each switch found on the
-- command line, this calls Callback, if the switch is not handled
-- automatically.
--
-- The list of valid switches are the ones from the configuration. The
-- switches that were declared through Define_Switch with an Output
-- parameter are never returned (and result in a modification of the Output
-- variable). This function will in fact never call [Callback] if all
-- switches were handled automatically and there is nothing left to do.
--
-- The option Concatenate is identical to the one of the standard Getopt
-- function.
--
-- This procedure automatically adds -h and --help to the valid switches,
-- to display the help message and raises Exit_From_Command_Line.
-- If an invalid switch is specified on the command line, this procedure
-- will display an error message and raises Invalid_Switch again.
--
-- This function automatically expands switches:
--
-- If Define_Prefix was called (for instance "-gnaty") and the user
-- specifies "-gnatycb" on the command line, then Getopt returns
-- "-gnatyc" and "-gnatyb" separately.
--
-- If Define_Alias was called (for instance "-gnatya = -gnatycb") then
-- the latter is returned (in this case it also expands -gnaty as per
-- the above.
--
-- The goal is to make handling as easy as possible by leaving as much
-- work as possible to this package.
--
-- As opposed to the standard Getopt, this one will analyze all sections
-- as defined by Define_Section, and automatically jump from one section to
-- the next.
------------------------------
-- Generating command lines --
------------------------------
-- Once the command line configuration has been created, you can build your
-- own command line. This will be done in general because you need to spawn
-- external tools from your application.
-- Although it could be done by concatenating strings, the following
-- subprograms will properly take care of grouping switches when possible,
-- so as to keep the command line as short as possible. They also provide a
-- way to remove a switch from an existing command line.
-- For instance:
-- declare
-- Config : Command_Line_Configuration;
-- Line : Command_Line;
-- Args : Argument_List_Access;
-- begin
-- Define_Switch (Config, "-gnatyc");
-- Define_Switch (Config, ...); -- for all valid switches
-- Define_Prefix (Config, "-gnaty");
-- Set_Configuration (Line, Config);
-- Add_Switch (Line, "-O2");
-- Add_Switch (Line, "-gnatyc");
-- Add_Switch (Line, "-gnatyd");
--
-- Build (Line, Args);
-- -- Args is now ["-O2", "-gnatycd"]
-- end;
type Command_Line is private;
procedure Set_Configuration
(Cmd : in out Command_Line;
Config : Command_Line_Configuration);
function Get_Configuration
(Cmd : Command_Line) return Command_Line_Configuration;
-- Set or retrieve the configuration used for that command line. The Config
-- must have been initialized first, by calling one of the Define_Switches
-- subprograms.
procedure Set_Command_Line
(Cmd : in out Command_Line;
Switches : String;
Getopt_Description : String := "";
Switch_Char : Character := '-');
-- Set the new content of the command line, by replacing the current
-- version with Switches.
--
-- The parsing of Switches is done through calls to Getopt, by passing
-- Getopt_Description as an argument. (A "*" is automatically prepended so
-- that all switches and command line arguments are accepted). If a config
-- was defined via Set_Configuration, the Getopt_Description parameter will
-- be ignored.
--
-- To properly handle switches that take parameters, you should document
-- them in Getopt_Description. Otherwise, the switch and its parameter will
-- be recorded as two separate command line arguments as returned by a
-- Command_Line_Iterator (which might be fine depending on your
-- application).
--
-- If the command line has sections (such as -bargs -cargs), then they
-- should be listed in the Sections parameter (as "-bargs -cargs").
--
-- This function can be used to reset Cmd by passing an empty string
--
-- If an invalid switch is found on the command line (ie wasn't defined in
-- the configuration via Define_Switch), and the configuration wasn't set
-- to accept all switches (by defining "*" as a valid switch), then an
-- exception Invalid_Switch is raised. The exception message indicates the
-- invalid switch.
procedure Add_Switch
(Cmd : in out Command_Line;
Switch : String;
Parameter : String := "";
Separator : Character := ASCII.NUL;
Section : String := "";
Add_Before : Boolean := False);
-- Add a new switch to the command line, and combine/group it with existing
-- switches if possible. Nothing is done if the switch already exists with
-- the same parameter.
--
-- If the Switch takes a parameter, the latter should be specified
-- separately, so that the association between the two is always correctly
-- recognized even if the order of switches on the command line changes.
-- For instance, you should pass "--check=full" as ("--check", "full") so
-- that Remove_Switch below can simply take "--check" in parameter. That
-- will automatically remove "full" as well. The value of the parameter is
-- never modified by this package.
--
-- On the other hand, you could decide to simply pass "--check=full" as
-- the Switch above, and then pass no parameter. This means that you need
-- to pass "--check=full" to Remove_Switch as well.
--
-- A Switch with a parameter will never be grouped with another switch to
-- avoid ambiguities as to what the parameter applies to.
--
-- If the switch is part of a section, then it should be specified so that
-- the switch is correctly placed in the command line, and the section
-- added if not already present. For example, to add the -g switch into the
-- -cargs section, you need to call (Cmd, "-g", Section => "-cargs").
--
-- [Separator], if specified, overrides the separator that was defined
-- through Define_Switch. For instance, if the switch was defined as
-- "-from:", the separator defaults to a space. But if your application
-- uses unusual separators not supported by GNAT.Command_Line (for instance
-- it requires ":"), you can specify this separator here.
--
-- For instance,
-- Add_Switch(Cmd, "-from", "bar", ':')
--
-- results in
-- -from:bar
--
-- rather than the default
-- -from bar
--
-- Note however that Getopt doesn't know how to handle ":" as a separator.
-- So the recommendation is to declare the switch as "-from!" (ie no
-- space between the switch and its parameter). Then Getopt will return
-- ":bar" as the parameter, and you can trim the ":" in your application.
--
-- Invalid_Section is raised if Section was not defined in the
-- configuration of the command line.
--
-- Add_Before allows insertion of the switch at the beginning of the
-- command line.
procedure Add_Switch
(Cmd : in out Command_Line;
Switch : String;
Parameter : String := "";
Separator : Character := ASCII.NUL;
Section : String := "";
Add_Before : Boolean := False;
Success : out Boolean);
-- Same as above, returning the status of the operation
procedure Remove_Switch
(Cmd : in out Command_Line;
Switch : String;
Remove_All : Boolean := False;
Has_Parameter : Boolean := False;
Section : String := "");
-- Remove Switch from the command line, and ungroup existing switches if
-- necessary.
--
-- The actual parameter to the switches are ignored. If for instance
-- you are removing "-foo", then "-foo param1" and "-foo param2" can
-- be removed.
--
-- If Remove_All is True, then all matching switches are removed, otherwise
-- only the first matching one is removed.
--
-- If Has_Parameter is set to True, then only switches having a parameter
-- are removed.
--
-- If the switch belongs to a section, then this section should be
-- specified: Remove_Switch (Cmd_Line, "-g", Section => "-cargs") called
-- on the command line "-g -cargs -g" will result in "-g", while if
-- called with (Cmd_Line, "-g") this will result in "-cargs -g".
-- If Remove_All is set, then both "-g" will be removed.
procedure Remove_Switch
(Cmd : in out Command_Line;
Switch : String;
Remove_All : Boolean := False;
Has_Parameter : Boolean := False;
Section : String := "";
Success : out Boolean);
-- Same as above, reporting the success of the operation (Success is False
-- if no switch was removed).
procedure Remove_Switch
(Cmd : in out Command_Line;
Switch : String;
Parameter : String;
Section : String := "");
-- Remove a switch with a specific parameter. If Parameter is the empty
-- string, then only a switch with no parameter will be removed.
procedure Free (Cmd : in out Command_Line);
-- Free the memory used by Cmd
---------------
-- Iteration --
---------------
-- When a command line was created with the above, you can then iterate
-- over its contents using the following iterator.
type Command_Line_Iterator is private;
procedure Start
(Cmd : in out Command_Line;
Iter : in out Command_Line_Iterator;
Expanded : Boolean := False);
-- Start iterating over the command line arguments. If Expanded is true,
-- then the arguments are not grouped and no alias is used. For instance,
-- "-gnatwv" and "-gnatwu" would be returned instead of "-gnatwuv".
--
-- The iterator becomes invalid if the command line is changed through a
-- call to Add_Switch, Remove_Switch or Set_Command_Line.
function Current_Switch (Iter : Command_Line_Iterator) return String;
function Is_New_Section (Iter : Command_Line_Iterator) return Boolean;
function Current_Section (Iter : Command_Line_Iterator) return String;
function Current_Separator (Iter : Command_Line_Iterator) return String;
function Current_Parameter (Iter : Command_Line_Iterator) return String;
-- Return the current switch and its parameter (or the empty string if
-- there is no parameter or the switch was added through Add_Switch
-- without specifying the parameter.
--
-- Separator is the string that goes between the switch and its separator.
-- It could be the empty string if they should be concatenated, or a space
-- for instance. When printing, you should not add any other character.
function Has_More (Iter : Command_Line_Iterator) return Boolean;
-- Return True if there are more switches to be returned
procedure Next (Iter : in out Command_Line_Iterator);
-- Move to the next switch
procedure Build
(Line : in out Command_Line;
Args : out GNAT.OS_Lib.Argument_List_Access;
Expanded : Boolean := False;
Switch_Char : Character := '-');
-- This is a wrapper using the Command_Line_Iterator. It provides a simple
-- way to get all switches (grouped as much as possible), and possibly
-- create an Opt_Parser.
--
-- Args must be freed by the caller.
--
-- Expanded has the same meaning as in Start.
procedure Try_Help;
-- Output a message on standard error to indicate how to get the usage for
-- the executable. This procedure should only be called when the executable
-- accepts switch --help. When this procedure is called by executable xxx,
-- the following message is displayed on standard error:
-- try "xxx --help" for more information.
private
Max_Depth : constant := 100;
-- Maximum depth of subdirectories
Max_Path_Length : constant := 1024;
-- Maximum length of relative path
type Depth is range 1 .. Max_Depth;
type Level is record
Name_Last : Natural := 0;
Dir : GNAT.Directory_Operations.Dir_Type;
end record;
type Level_Array is array (Depth) of Level;
type Section_Number is new Natural range 0 .. 65534;
for Section_Number'Size use 16;
type Parameter_Type is record
Arg_Num : Positive;
First : Positive;
Last : Natural;
Extra : Character;
end record;
type Is_Switch_Type is array (Natural range <>) of Boolean;
pragma Pack (Is_Switch_Type);
type Section_Type is array (Natural range <>) of Section_Number;
pragma Pack (Section_Type);
type Expansion_Iterator is limited record
Start : Positive := 1;
-- Position of the first character of the relative path to check against
-- the pattern.
Dir_Name : String (1 .. Max_Path_Length);
Current_Depth : Depth := 1;
Levels : Level_Array;
Regexp : GNAT.Regexp.Regexp;
-- Regular expression built with the pattern
Maximum_Depth : Depth := 1;
-- The maximum depth of directories, reflecting the number of directory
-- separators in the pattern.
end record;
type Opt_Parser_Data (Arg_Count : Natural) is record
Arguments : GNAT.OS_Lib.Argument_List_Access;
-- null if reading from the command line
The_Parameter : Parameter_Type;
The_Separator : Character;
The_Switch : Parameter_Type;
-- This type and this variable are provided to store the current switch
-- and parameter.
Is_Switch : Is_Switch_Type (1 .. Arg_Count) := (others => False);
-- Indicates wich arguments on the command line are considered not be
-- switches or parameters to switches (leaving e.g. filenames,...)
Section : Section_Type (1 .. Arg_Count) := (others => 1);
-- Contains the number of the section associated with the current
-- switch. If this number is 0, then it is a section delimiter, which is
-- never returned by GetOpt.
Current_Argument : Natural := 1;
-- Number of the current argument parsed on the command line
Current_Index : Natural := 1;
-- Index in the current argument of the character to be processed
Current_Section : Section_Number := 1;
Expansion_It : aliased Expansion_Iterator;
-- When Get_Argument is expanding a file name, this is the iterator used
In_Expansion : Boolean := False;
-- True if we are expanding a file
Switch_Character : Character := '-';
-- The character at the beginning of the command line arguments,
-- indicating the beginning of a switch.
Stop_At_First : Boolean := False;
-- If it is True then Getopt stops at the first non-switch argument
end record;
Command_Line_Parser_Data : aliased Opt_Parser_Data
(Ada.Command_Line.Argument_Count);
-- The internal data used when parsing the command line
type Opt_Parser is access all Opt_Parser_Data;
Command_Line_Parser : constant Opt_Parser :=
Command_Line_Parser_Data'Access;
type Switch_Type is (Switch_Untyped,
Switch_Boolean,
Switch_Integer,
Switch_String);
type Switch_Definition (Typ : Switch_Type := Switch_Untyped) is record
Switch : GNAT.OS_Lib.String_Access;
Long_Switch : GNAT.OS_Lib.String_Access;
Section : GNAT.OS_Lib.String_Access;
Help : GNAT.OS_Lib.String_Access;
Argument : GNAT.OS_Lib.String_Access;
-- null if "ARG".
-- Name of the argument for this switch.
case Typ is
when Switch_Untyped =>
null;
when Switch_Boolean =>
Boolean_Output : access Boolean;
Boolean_Value : Boolean; -- will set Output to that value
when Switch_Integer =>
Integer_Output : access Integer;
Integer_Initial : Integer;
Integer_Default : Integer;
when Switch_String =>
String_Output : access GNAT.Strings.String_Access;
end case;
end record;
type Switch_Definitions is array (Natural range <>) of Switch_Definition;
type Switch_Definitions_List is access all Switch_Definitions;
-- [Switch] includes the leading '-'
type Alias_Definition is record
Alias : GNAT.OS_Lib.String_Access;
Expansion : GNAT.OS_Lib.String_Access;
Section : GNAT.OS_Lib.String_Access;
end record;
type Alias_Definitions is array (Natural range <>) of Alias_Definition;
type Alias_Definitions_List is access all Alias_Definitions;
type Command_Line_Configuration_Record is record
Prefixes : GNAT.OS_Lib.Argument_List_Access;
-- The list of prefixes
Sections : GNAT.OS_Lib.Argument_List_Access;
-- The list of sections
Star_Switch : Boolean := False;
-- Whether switches not described in this configuration should be
-- returned to the user (True). If False, an exception Invalid_Switch
-- is raised.
Aliases : Alias_Definitions_List;
Usage : GNAT.OS_Lib.String_Access;
Help : GNAT.OS_Lib.String_Access;
Help_Msg : GNAT.OS_Lib.String_Access;
Switches : Switch_Definitions_List;
-- List of expected switches (Used when expanding switch groups)
end record;
type Command_Line_Configuration is access Command_Line_Configuration_Record;
type Command_Line is record
Config : Command_Line_Configuration;
Expanded : GNAT.OS_Lib.Argument_List_Access;
Params : GNAT.OS_Lib.Argument_List_Access;
-- Parameter for the corresponding switch in Expanded. The first
-- character is the separator (or ASCII.NUL if there is no separator).
Sections : GNAT.OS_Lib.Argument_List_Access;
-- The list of sections
Coalesce : GNAT.OS_Lib.Argument_List_Access;
Coalesce_Params : GNAT.OS_Lib.Argument_List_Access;
Coalesce_Sections : GNAT.OS_Lib.Argument_List_Access;
-- Cached version of the command line. This is recomputed every time
-- the command line changes. Switches are grouped as much as possible,
-- and aliases are used to reduce the length of the command line. The
-- parameters are not allocated, they point into Params, so they must
-- not be freed.
end record;
type Command_Line_Iterator is record
List : GNAT.OS_Lib.Argument_List_Access;
Sections : GNAT.OS_Lib.Argument_List_Access;
Params : GNAT.OS_Lib.Argument_List_Access;
Current : Natural;
end record;
end GNAT.Command_Line;
|
------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- G N A T . S E C U R E _ H A S H E S . M D 5 --
-- --
-- B o d y --
-- --
-- Copyright (C) 2002-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. --
-- --
------------------------------------------------------------------------------
with GNAT.Byte_Swapping; use GNAT.Byte_Swapping;
package body GNAT.Secure_Hashes.MD5 is
use Interfaces;
-- The sixteen values used to rotate the context words. Four for each
-- rounds. Used in procedure Transform.
-- Round 1
S11 : constant := 7;
S12 : constant := 12;
S13 : constant := 17;
S14 : constant := 22;
-- Round 2
S21 : constant := 5;
S22 : constant := 9;
S23 : constant := 14;
S24 : constant := 20;
-- Round 3
S31 : constant := 4;
S32 : constant := 11;
S33 : constant := 16;
S34 : constant := 23;
-- Round 4
S41 : constant := 6;
S42 : constant := 10;
S43 : constant := 15;
S44 : constant := 21;
-- The following functions (F, FF, G, GG, H, HH, I and II) are the
-- equivalent of the macros of the same name in the example C
-- implementation in the annex of RFC 1321.
function F (X, Y, Z : Unsigned_32) return Unsigned_32;
pragma Inline (F);
procedure FF
(A : in out Unsigned_32;
B, C, D : Unsigned_32;
X : Unsigned_32;
AC : Unsigned_32;
S : Positive);
pragma Inline (FF);
function G (X, Y, Z : Unsigned_32) return Unsigned_32;
pragma Inline (G);
procedure GG
(A : in out Unsigned_32;
B, C, D : Unsigned_32;
X : Unsigned_32;
AC : Unsigned_32;
S : Positive);
pragma Inline (GG);
function H (X, Y, Z : Unsigned_32) return Unsigned_32;
pragma Inline (H);
procedure HH
(A : in out Unsigned_32;
B, C, D : Unsigned_32;
X : Unsigned_32;
AC : Unsigned_32;
S : Positive);
pragma Inline (HH);
function I (X, Y, Z : Unsigned_32) return Unsigned_32;
pragma Inline (I);
procedure II
(A : in out Unsigned_32;
B, C, D : Unsigned_32;
X : Unsigned_32;
AC : Unsigned_32;
S : Positive);
pragma Inline (II);
-------
-- F --
-------
function F (X, Y, Z : Unsigned_32) return Unsigned_32 is
begin
return (X and Y) or ((not X) and Z);
end F;
--------
-- FF --
--------
procedure FF
(A : in out Unsigned_32;
B, C, D : Unsigned_32;
X : Unsigned_32;
AC : Unsigned_32;
S : Positive)
is
begin
A := A + F (B, C, D) + X + AC;
A := Rotate_Left (A, S);
A := A + B;
end FF;
-------
-- G --
-------
function G (X, Y, Z : Unsigned_32) return Unsigned_32 is
begin
return (X and Z) or (Y and (not Z));
end G;
--------
-- GG --
--------
procedure GG
(A : in out Unsigned_32;
B, C, D : Unsigned_32;
X : Unsigned_32;
AC : Unsigned_32;
S : Positive)
is
begin
A := A + G (B, C, D) + X + AC;
A := Rotate_Left (A, S);
A := A + B;
end GG;
-------
-- H --
-------
function H (X, Y, Z : Unsigned_32) return Unsigned_32 is
begin
return X xor Y xor Z;
end H;
--------
-- HH --
--------
procedure HH
(A : in out Unsigned_32;
B, C, D : Unsigned_32;
X : Unsigned_32;
AC : Unsigned_32;
S : Positive)
is
begin
A := A + H (B, C, D) + X + AC;
A := Rotate_Left (A, S);
A := A + B;
end HH;
-------
-- I --
-------
function I (X, Y, Z : Unsigned_32) return Unsigned_32 is
begin
return Y xor (X or (not Z));
end I;
--------
-- II --
--------
procedure II
(A : in out Unsigned_32;
B, C, D : Unsigned_32;
X : Unsigned_32;
AC : Unsigned_32;
S : Positive)
is
begin
A := A + I (B, C, D) + X + AC;
A := Rotate_Left (A, S);
A := A + B;
end II;
---------------
-- Transform --
---------------
procedure Transform
(H : in out Hash_State.State;
M : in out Message_State)
is
use System;
X : array (0 .. 15) of Interfaces.Unsigned_32;
for X'Address use M.Buffer'Address;
pragma Import (Ada, X);
AA : Unsigned_32 := H (0);
BB : Unsigned_32 := H (1);
CC : Unsigned_32 := H (2);
DD : Unsigned_32 := H (3);
begin
if Default_Bit_Order /= Low_Order_First then
for J in X'Range loop
Swap4 (X (J)'Address);
end loop;
end if;
-- Round 1
FF (AA, BB, CC, DD, X (00), 16#D76aa478#, S11); -- 1
FF (DD, AA, BB, CC, X (01), 16#E8c7b756#, S12); -- 2
FF (CC, DD, AA, BB, X (02), 16#242070db#, S13); -- 3
FF (BB, CC, DD, AA, X (03), 16#C1bdceee#, S14); -- 4
FF (AA, BB, CC, DD, X (04), 16#f57c0faf#, S11); -- 5
FF (DD, AA, BB, CC, X (05), 16#4787c62a#, S12); -- 6
FF (CC, DD, AA, BB, X (06), 16#a8304613#, S13); -- 7
FF (BB, CC, DD, AA, X (07), 16#fd469501#, S14); -- 8
FF (AA, BB, CC, DD, X (08), 16#698098d8#, S11); -- 9
FF (DD, AA, BB, CC, X (09), 16#8b44f7af#, S12); -- 10
FF (CC, DD, AA, BB, X (10), 16#ffff5bb1#, S13); -- 11
FF (BB, CC, DD, AA, X (11), 16#895cd7be#, S14); -- 12
FF (AA, BB, CC, DD, X (12), 16#6b901122#, S11); -- 13
FF (DD, AA, BB, CC, X (13), 16#fd987193#, S12); -- 14
FF (CC, DD, AA, BB, X (14), 16#a679438e#, S13); -- 15
FF (BB, CC, DD, AA, X (15), 16#49b40821#, S14); -- 16
-- Round 2
GG (AA, BB, CC, DD, X (01), 16#f61e2562#, S21); -- 17
GG (DD, AA, BB, CC, X (06), 16#c040b340#, S22); -- 18
GG (CC, DD, AA, BB, X (11), 16#265e5a51#, S23); -- 19
GG (BB, CC, DD, AA, X (00), 16#e9b6c7aa#, S24); -- 20
GG (AA, BB, CC, DD, X (05), 16#d62f105d#, S21); -- 21
GG (DD, AA, BB, CC, X (10), 16#02441453#, S22); -- 22
GG (CC, DD, AA, BB, X (15), 16#d8a1e681#, S23); -- 23
GG (BB, CC, DD, AA, X (04), 16#e7d3fbc8#, S24); -- 24
GG (AA, BB, CC, DD, X (09), 16#21e1cde6#, S21); -- 25
GG (DD, AA, BB, CC, X (14), 16#c33707d6#, S22); -- 26
GG (CC, DD, AA, BB, X (03), 16#f4d50d87#, S23); -- 27
GG (BB, CC, DD, AA, X (08), 16#455a14ed#, S24); -- 28
GG (AA, BB, CC, DD, X (13), 16#a9e3e905#, S21); -- 29
GG (DD, AA, BB, CC, X (02), 16#fcefa3f8#, S22); -- 30
GG (CC, DD, AA, BB, X (07), 16#676f02d9#, S23); -- 31
GG (BB, CC, DD, AA, X (12), 16#8d2a4c8a#, S24); -- 32
-- Round 3
HH (AA, BB, CC, DD, X (05), 16#fffa3942#, S31); -- 33
HH (DD, AA, BB, CC, X (08), 16#8771f681#, S32); -- 34
HH (CC, DD, AA, BB, X (11), 16#6d9d6122#, S33); -- 35
HH (BB, CC, DD, AA, X (14), 16#fde5380c#, S34); -- 36
HH (AA, BB, CC, DD, X (01), 16#a4beea44#, S31); -- 37
HH (DD, AA, BB, CC, X (04), 16#4bdecfa9#, S32); -- 38
HH (CC, DD, AA, BB, X (07), 16#f6bb4b60#, S33); -- 39
HH (BB, CC, DD, AA, X (10), 16#bebfbc70#, S34); -- 40
HH (AA, BB, CC, DD, X (13), 16#289b7ec6#, S31); -- 41
HH (DD, AA, BB, CC, X (00), 16#eaa127fa#, S32); -- 42
HH (CC, DD, AA, BB, X (03), 16#d4ef3085#, S33); -- 43
HH (BB, CC, DD, AA, X (06), 16#04881d05#, S34); -- 44
HH (AA, BB, CC, DD, X (09), 16#d9d4d039#, S31); -- 45
HH (DD, AA, BB, CC, X (12), 16#e6db99e5#, S32); -- 46
HH (CC, DD, AA, BB, X (15), 16#1fa27cf8#, S33); -- 47
HH (BB, CC, DD, AA, X (02), 16#c4ac5665#, S34); -- 48
-- Round 4
II (AA, BB, CC, DD, X (00), 16#f4292244#, S41); -- 49
II (DD, AA, BB, CC, X (07), 16#432aff97#, S42); -- 50
II (CC, DD, AA, BB, X (14), 16#ab9423a7#, S43); -- 51
II (BB, CC, DD, AA, X (05), 16#fc93a039#, S44); -- 52
II (AA, BB, CC, DD, X (12), 16#655b59c3#, S41); -- 53
II (DD, AA, BB, CC, X (03), 16#8f0ccc92#, S42); -- 54
II (CC, DD, AA, BB, X (10), 16#ffeff47d#, S43); -- 55
II (BB, CC, DD, AA, X (01), 16#85845dd1#, S44); -- 56
II (AA, BB, CC, DD, X (08), 16#6fa87e4f#, S41); -- 57
II (DD, AA, BB, CC, X (15), 16#fe2ce6e0#, S42); -- 58
II (CC, DD, AA, BB, X (06), 16#a3014314#, S43); -- 59
II (BB, CC, DD, AA, X (13), 16#4e0811a1#, S44); -- 60
II (AA, BB, CC, DD, X (04), 16#f7537e82#, S41); -- 61
II (DD, AA, BB, CC, X (11), 16#bd3af235#, S42); -- 62
II (CC, DD, AA, BB, X (02), 16#2ad7d2bb#, S43); -- 63
II (BB, CC, DD, AA, X (09), 16#eb86d391#, S44); -- 64
H (0) := H (0) + AA;
H (1) := H (1) + BB;
H (2) := H (2) + CC;
H (3) := H (3) + DD;
end Transform;
end GNAT.Secure_Hashes.MD5;
|
------------------------------------------------------------------------------
-- Copyright (c) 2011, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Ada.Strings;
with Ada.Strings.Fixed;
with Ada.Unchecked_Deallocation;
package body Natools.Chunked_Strings is
package Fixed renames Ada.Strings.Fixed;
type Relation is (Equal, Greater, Lesser);
-----------------------
-- Local subprograms --
-----------------------
function Allocated_Size (Source : in Chunked_String) return Natural;
pragma Inline (Allocated_Size);
-- Return the number of Characters that can currently fit in Source
function Chunks_For (Size : in Natural;
Chunk_Size : in Positive;
Allocation_Unit : in Positive)
return Natural;
pragma Inline (Chunks_For);
-- Return the number of chunks to accommodate Size characters
generic
type Map_Type is private;
with function Count (Source : in String;
Pattern : in String;
Mapping : in Map_Type)
return Natural;
function Count_Gen (Source : in Chunked_String;
Pattern : in String;
Mapping : in Map_Type)
return Natural;
-- Count the number of non-overlapping occurrences of the pattern
function Compare
(Left : in Chunk_Array;
Left_Size : in Natural;
Right : in Chunk_Array;
Right_Size : in Natural)
return Relation;
function Compare
(Left : in Chunk_Array_Access;
Left_Size : in Natural;
Right : in Chunk_Array_Access;
Right_Size : in Natural)
return Relation;
function Compare
(Left : in Chunk_Array;
Left_Size : in Natural;
Right : in String)
return Relation;
function Compare
(Left : in Chunk_Array_Access;
Left_Size : in Natural;
Right : in String)
return Relation;
-- String comparisons
procedure Fill (Data : in out Chunk_Array;
From : in Positive;
Count : in Natural;
C : in Character;
Chunk_Size : in Positive);
-- Fill an area of the chunks with the given Character
procedure Free (Data : in out Chunk_Array_Access);
-- Free data associated to all chunks and to the chunk array
generic
type Map_Type is private;
with function Index
(Source : String;
Pattern : String;
From : Positive;
Going : Ada.Strings.Direction;
Map : Map_Type)
return Natural;
function Index_Gen
(Source : Chunked_String;
Pattern : String;
From : Positive;
Going : Ada.Strings.Direction;
Map : Map_Type)
return Natural;
-- Search for a pattern in a source as described in the ARM
procedure Move (Target : in out Chunk_Array;
Target_Position : in Positive;
Source : in out Chunk_Array;
Source_Position : in Positive;
Length : in Natural);
-- Moves characters from one Chunk_Array to another, even when they
-- do not have the same chunk size
procedure Move (Target : in out Chunk_Array;
Source : in String;
Position : in Positive;
Chunk_Size : in Positive);
-- Writes the string in the chunk array, which must be large enough
procedure Move (Target : out String;
Source : in Chunk_Array;
From : in Positive);
-- Fills a string using characters from the Chunk_Array
procedure Move (Data : in out Chunk_Array;
Target_Position : in Positive;
Source_Position : in Positive;
Length : in Positive;
Chunk_Size : in Positive);
-- Move a slice of data inside a given chunk array
procedure Resize_Chunk (Chunk : in out String_Access;
Size : in Positive);
-- Resize a chunk to the target set
procedure Resize_Chunks (Data : in out Chunk_Array_Access;
Size : in Natural;
Chunk_Size : in Positive;
Allocation_Unit : in Positive;
Can_Shrink : in Boolean := True);
-- Resize Data to fit Size characters
procedure Trim_Bounds (Source : in Chunked_String;
Left : in Maps.Character_Set;
Right : in Maps.Character_Set;
Low : out Positive;
High : out Natural);
-- Compute slice bounds of the trimmed result
function Units_For (Size : in Natural;
Chunk_Size : in Positive;
Allocation_Unit : in Positive)
return Natural;
pragma Inline (Units_For);
-- Return the number of allocation units in the last chunk
---------------------------------------
-- Chunked_String memory subprograms --
---------------------------------------
function Allocated_Size (Source : in Chunked_String) return Natural is
begin
if Source.Data = null or else Source.Data'Last < 1 then
return 0;
end if;
return (Source.Data'Last - 1) * Source.Chunk_Size
+ Source.Data (Source.Data'Last)'Last;
end Allocated_Size;
function Chunks_For (Size : in Natural;
Chunk_Size : in Positive;
Allocation_Unit : in Positive)
return Natural is
begin
pragma Unreferenced (Allocation_Unit);
return (Size + Chunk_Size - 1) / Chunk_Size;
end Chunks_For;
procedure Free (Data : in out Chunk_Array_Access) is
procedure Deallocate is
new Ada.Unchecked_Deallocation (Chunk_Array, Chunk_Array_Access);
begin
if Data = null then
return;
end if;
for J in Data'Range loop
Free (Data (J));
end loop;
Deallocate (Data);
end Free;
procedure Resize_Chunk (Chunk : in out String_Access;
Size : in Positive)
is
New_Chunk : String_Access;
begin
if Size /= Chunk'Length then
New_Chunk := new String (1 .. Size);
if Size < Chunk'Length then
New_Chunk.all := Chunk (Chunk'First .. Chunk'First + Size - 1);
else
New_Chunk.all (1 .. Chunk'Length) := Chunk.all;
end if;
Free (Chunk);
Chunk := New_Chunk;
end if;
end Resize_Chunk;
procedure Resize_Chunks (Data : in out Chunk_Array_Access;
Size : in Natural;
Chunk_Size : in Positive;
Allocation_Unit : in Positive;
Can_Shrink : in Boolean := True)
is
procedure Deallocate is
new Ada.Unchecked_Deallocation (Chunk_Array, Chunk_Array_Access);
Chunk_Nb : constant Natural
:= Chunks_For (Size, Chunk_Size, Allocation_Unit);
Last_Chunk_Size : constant Natural
:= Units_For (Size, Chunk_Size, Allocation_Unit) * Allocation_Unit;
begin
if Size = 0 then
if Can_Shrink then
Free (Data);
end if;
return;
end if;
pragma Assert (Chunk_Nb > 0);
if Data = null or else Data'Length < Chunk_Nb then
declare
First_New : Positive := 1;
New_Data : constant Chunk_Array_Access
:= new Chunk_Array (1 .. Chunk_Nb);
begin
if Data /= null then
Resize_Chunk (Data (Data'Last), Chunk_Size);
New_Data (1 .. Data'Last) := Data.all;
First_New := Data'Last + 1;
Deallocate (Data);
end if;
Data := New_Data;
for J in First_New .. Data'Last - 1 loop
Data (J) := new String (1 .. Chunk_Size);
end loop;
Data (Data'Last) := new String (1 .. Last_Chunk_Size);
end;
elsif Data'Length > Chunk_Nb then
if Can_Shrink then
declare
New_Data : constant Chunk_Array_Access
:= new Chunk_Array (1 .. Chunk_Nb);
begin
Resize_Chunk (Data (Chunk_Nb), Last_Chunk_Size);
for J in Chunk_Nb + 1 .. Data'Last loop
Free (Data (J));
end loop;
New_Data.all := Data (1 .. Chunk_Nb);
Data := New_Data;
end;
end if;
else -- Data'Length = Chunk_Nb
if Last_Chunk_Size > Data (Data'Last).all'Last or Can_Shrink then
Resize_Chunk (Data (Data'Last), Last_Chunk_Size);
end if;
end if;
end Resize_Chunks;
function Units_For (Size : in Natural;
Chunk_Size : in Positive;
Allocation_Unit : in Positive)
return Natural is
begin
return (((Size + Chunk_Size - 1) mod Chunk_Size + 1)
+ Allocation_Unit - 1) / Allocation_Unit;
end Units_For;
---------------------------
-- Low-level subprograms --
---------------------------
function Compare
(Left : in Chunk_Array;
Left_Size : in Natural;
Right : in Chunk_Array;
Right_Size : in Natural)
return Relation
is
L_Chunk : Positive := Left'First;
L_Pos : Positive := Left (L_Chunk).all'First;
L_Remain : Natural := Left_Size;
R_Chunk : Positive := Right'First;
R_Pos : Positive := Right (R_Chunk).all'First;
R_Remain : Natural := Right_Size;
Step : Positive;
begin
loop
Step := Positive'Min
(Natural'Min (Left (L_Chunk).all'Last - L_Pos + 1,
L_Remain),
Natural'Min (Right (R_Chunk).all'Last - R_Pos + 1,
R_Remain));
declare
L_Part : String
renames Left (L_Chunk).all (L_Pos .. L_Pos + Step - 1);
R_Part : String
renames Right (R_Chunk).all (R_Pos .. R_Pos + Step - 1);
begin
if L_Part < R_Part then
return Lesser;
elsif L_Part > R_Part then
return Greater;
end if;
end;
L_Remain := L_Remain - Step;
R_Remain := R_Remain - Step;
if L_Remain = 0 and R_Remain = 0 then
return Equal;
elsif L_Remain = 0 then
return Lesser;
elsif R_Remain = 0 then
return Greater;
end if;
L_Pos := L_Pos + Step;
R_Pos := R_Pos + Step;
if L_Pos > Left (L_Chunk).all'Last then
-- L_Chunk cannot be Left'Last because L_Remain > 0
L_Chunk := L_Chunk + 1;
L_Pos := Left (L_Chunk).all'First;
end if;
if R_Pos > Right (R_Chunk).all'Last then
-- R_Chunk cannot be Right'Last because R_Remain > 0
R_Chunk := R_Chunk + 1;
R_Pos := Right (R_Chunk).all'First;
end if;
end loop;
end Compare;
function Compare
(Left : in Chunk_Array_Access;
Left_Size : in Natural;
Right : in Chunk_Array_Access;
Right_Size : in Natural)
return Relation is
begin
if Left = null or Left_Size = 0 then
if Right = null or Right_Size = 0 then
return Equal;
else
return Lesser;
end if;
else
if Right = null or Right_Size = 0 then
return Greater;
else
return Compare (Left.all, Left_Size, Right.all, Right_Size);
end if;
end if;
end Compare;
function Compare
(Left : in Chunk_Array;
Left_Size : in Natural;
Right : in String)
return Relation
is
Chunk : Positive := Left'First;
L_Pos : Positive := Left (Chunk).all'First;
L_Remain : Natural := Left_Size;
R_Pos : Positive := Right'First;
Step : Positive;
begin
loop
Step
:= Positive'Min (Positive'Min (Left (Chunk).all'Last - L_Pos + 1,
L_Remain),
Right'Last - R_Pos + 1);
declare
L_Part : String
renames Left (Chunk).all (L_Pos .. L_Pos + Step - 1);
R_Part : String
renames Right (R_Pos .. R_Pos + Step - 1);
begin
if L_Part < R_Part then
return Lesser;
elsif L_Part > R_Part then
return Greater;
end if;
end;
L_Remain := L_Remain - Step;
if L_Remain = 0 then
if R_Pos + Step > Right'Last then
return Equal;
else
return Lesser;
end if;
end if;
L_Pos := L_Pos + Step;
R_Pos := R_Pos + Step;
if L_Pos > Left (Chunk).all'Last then
-- _Chunk cannot be Left'Last because L_Remain > 0
Chunk := Chunk + 1;
L_Pos := Left (Chunk).all'First;
end if;
if R_Pos > Right'Last then
return Greater;
end if;
end loop;
end Compare;
function Compare
(Left : in Chunk_Array_Access;
Left_Size : in Natural;
Right : in String)
return Relation is
begin
if Left = null or Left_Size = 0 then
if Right'Length = 0 then
return Equal;
else
return Lesser;
end if;
else
if Right'Length = 0 then
return Greater;
else
return Compare (Left.all, Left_Size, Right);
end if;
end if;
end Compare;
procedure Fill (Data : in out Chunk_Array;
From : in Positive;
Count : in Natural;
C : in Character;
Chunk_Size : in Positive)
is
Chunk : Positive := (From - 1) / Chunk_Size + 1;
Offset : Positive := (From - 1) mod Chunk_Size + 1;
Done : Natural := 0;
Step : Positive;
begin
while Done < Count loop
Step := Positive'Min (Count - Done,
Data (Chunk).all'Last - Offset + 1);
Data (Chunk).all (Offset .. Offset + Step - 1)
:= Ada.Strings.Fixed."*" (Step, C);
Chunk := Chunk + 1;
Offset := 1;
Done := Done + Step;
end loop;
end Fill;
function Is_Valid (Source : in Chunked_String) return Boolean is
begin
-- Null data is only acceptable when the string is empty.
if Source.Data = null then
return Source.Size = 0;
end if;
-- Data array must contain non-null chunks of even size
declare
D : Chunk_Array renames Source.Data.all;
begin
if D'First /= 1 then
return False;
end if;
for J in D'Range loop
if D (J) = null then
return False;
end if;
if D (J).all'First /= 1 or
(J < D'Last and D (J).all'Last /= Source.Chunk_Size)
then
return False;
end if;
end loop;
end;
-- Real size must be smaller than allocated size
if Source.Size > Allocated_Size (Source) then
return False;
end if;
return True;
end Is_Valid;
procedure Move (Target : in out Chunk_Array;
Target_Position : in Positive;
Source : in out Chunk_Array;
Source_Position : in Positive;
Length : in Natural)
is
Count : Natural := 0;
S_Chunk : Positive;
S_Pos : Positive;
T_Chunk : Positive;
T_Pos : Positive;
begin
S_Chunk := Target'First;
S_Pos := 1;
while S_Pos + Source (S_Chunk).all'Length <= Source_Position loop
S_Pos := S_Pos + Source (S_Chunk).all'Length;
S_Chunk := S_Chunk + 1;
end loop;
S_Pos := Source_Position + 1 - S_Pos;
T_Chunk := Target'First;
T_Pos := 1;
while T_Pos + Target (T_Chunk).all'Length <= Target_Position loop
T_Pos := T_Pos + Target (T_Chunk).all'Length;
T_Chunk := T_Chunk + 1;
end loop;
T_Pos := Target_Position + 1 - T_Pos;
while Count < Length loop
declare
S_String : String renames Source (S_Chunk).all;
T_String : String renames Target (T_Chunk).all;
Step_C : constant Positive := Length - Count;
Step_S : constant Positive := S_String'Last - S_Pos + 1;
Step_T : constant Positive := T_String'Last - T_Pos + 1;
Step : constant Positive
:= Positive'Min (Step_C, Positive'Min (Step_S, Step_T));
begin
T_String (T_Pos .. T_Pos + Step - 1)
:= S_String (S_Pos .. S_Pos + Step - 1);
Count := Count + Step;
exit when Count >= Length;
S_Pos := S_Pos + Step;
T_Pos := T_Pos + Step;
if S_Pos > S_String'Last then
S_Chunk := S_Chunk + 1;
S_Pos := Source (S_Chunk).all'First;
end if;
if T_Pos > T_String'Last then
T_Chunk := T_Chunk + 1;
T_Pos := Target (T_Chunk).all'First;
end if;
end;
end loop;
end Move;
procedure Move (Target : in out Chunk_Array;
Source : in String;
Position : in Positive;
Chunk_Size : in Positive)
is
Last_Position : constant Positive := Position + Source'Length - 1;
First_Chunk : constant Positive := (Position - 1) / Chunk_Size + 1;
First_Offset : constant Positive := (Position - 1) mod Chunk_Size + 1;
Last_Chunk : constant Positive
:= (Last_Position - 1) / Chunk_Size + 1;
Last_Offset : constant Positive
:= (Last_Position - 1) mod Chunk_Size + 1;
Current : Positive;
begin
if First_Chunk = Last_Chunk then
Target (First_Chunk).all (First_Offset .. Last_Offset) := Source;
else
Current := Source'First + Chunk_Size - First_Offset + 1;
Target (First_Chunk).all (First_Offset .. Chunk_Size)
:= Source (Source'First .. Current - 1);
for J in First_Chunk + 1 .. Last_Chunk - 1 loop
Target (J).all := Source (Current .. Current + Chunk_Size - 1);
Current := Current + Chunk_Size;
end loop;
Target (Last_Chunk).all (1 .. Last_Offset)
:= Source (Current .. Source'Last);
end if;
end Move;
procedure Move (Target : out String;
Source : in Chunk_Array;
From : in Positive)
is
T_Pos : Positive := Target'First;
S_Pos : Positive := 1;
Chunk : Positive := 1;
Step : Positive;
begin
while S_Pos + Source (Chunk).all'Length <= From loop
S_Pos := S_Pos + Source (Chunk).all'Length;
Chunk := Chunk + 1;
end loop;
S_Pos := From - S_Pos + 1;
Step := Source (Chunk).all'Last - S_Pos + 1;
if Target'Length <= Step then
Target := Source (Chunk).all (S_Pos .. S_Pos + Target'Length - 1);
return;
end if;
Target (T_Pos .. T_Pos + Step - 1)
:= Source (Chunk).all (S_Pos .. Source (Chunk).all'Last);
T_Pos := T_Pos + Step;
Chunk := Chunk + 1;
while T_Pos <= Target'Last loop
Step := Positive'Min (Source (Chunk).all'Length,
Target'Last - T_Pos + 1);
Target (T_Pos .. T_Pos + Step - 1)
:= Source (Chunk).all (1 .. Step);
T_Pos := T_Pos + Step;
Chunk := Chunk + 1;
end loop;
end Move;
procedure Move (Data : in out Chunk_Array;
Target_Position : in Positive;
Source_Position : in Positive;
Length : in Positive;
Chunk_Size : in Positive) is
begin
if Target_Position < Source_Position then
declare
S_Chunk : Positive := (Source_Position - 1) / Chunk_Size + 1;
S_Pos : Positive := (Source_Position - 1) mod Chunk_Size + 1;
T_Chunk : Positive := (Target_Position - 1) / Chunk_Size + 1;
T_Pos : Positive := (Target_Position - 1) mod Chunk_Size + 1;
Count : Natural := 0;
Step : Positive;
begin
while Count < Length loop
Step := Positive'Min
(Positive'Min (Data (S_Chunk).all'Last - S_Pos + 1,
Data (T_Chunk).all'Last - T_Pos + 1),
Length - Count);
Data (T_Chunk).all (T_Pos .. T_Pos + Step - 1)
:= Data (S_Chunk).all (S_Pos .. S_Pos + Step - 1);
Count := Count + Step;
S_Pos := S_Pos + Step;
if S_Pos > Chunk_Size then
S_Chunk := S_Chunk + 1;
S_Pos := 1;
end if;
T_Pos := T_Pos + Step;
if T_Pos > Chunk_Size then
T_Chunk := T_Chunk + 1;
T_Pos := 1;
end if;
end loop;
end;
elsif Target_Position > Source_Position then
declare
S_End : constant Positive := Source_Position + Length - 1;
T_End : constant Positive := Target_Position + Length - 1;
S_Chunk : Positive := (S_End - 1) / Chunk_Size + 1;
S_Pos : Positive := (S_End - 1) mod Chunk_Size + 1;
T_Chunk : Positive := (T_End - 1) / Chunk_Size + 1;
T_Pos : Positive := (T_End - 1) mod Chunk_Size + 1;
Count : Natural := 0;
Step : Positive;
begin
loop
Step := Positive'Min (Positive'Min (S_Pos, T_Pos),
Length - Count);
Data (T_Chunk).all (T_Pos - Step + 1 .. T_Pos)
:= Data (S_Chunk).all (S_Pos - Step + 1 .. S_Pos);
Count := Count + Step;
exit when Count = Length;
pragma Assert (Count < Length);
if S_Pos <= Step then
S_Chunk := S_Chunk - 1;
S_Pos := Chunk_Size;
else
S_Pos := S_Pos - Step;
end if;
if T_Pos <= Step then
T_Chunk := T_Chunk - 1;
T_Pos := Chunk_Size;
else
T_Pos := T_Pos - Step;
end if;
end loop;
end;
end if;
end Move;
--------------------------------------------------
-- Public interface specific to Chunked_Strings --
--------------------------------------------------
function Build (Depth : Positive)
return Natools.Accumulators.String_Accumulator'Class
is
pragma Unreferenced (Depth);
begin
return Null_Chunked_String;
end Build;
function Duplicate (Source : in Chunked_String) return Chunked_String is
Data : Chunk_Array_Access := null;
begin
if Source.Data /= null then
Data := new Chunk_Array (Source.Data'Range);
for J in Source.Data'Range loop
Data (J) := new String'(Source.Data (J).all);
end loop;
end if;
return Chunked_String'(Ada.Finalization.Controlled with
Chunk_Size => Source.Chunk_Size,
Allocation_Unit => Source.Allocation_Unit,
Size => Source.Size,
Data => Data);
end Duplicate;
procedure Hard_Reset (Str : in out Chunked_String) is
begin
Str.Size := 0;
Free (Str.Data);
end Hard_Reset;
procedure Soft_Reset (Str : in out Chunked_String) is
begin
Str.Size := 0;
end Soft_Reset;
procedure To_String (Source : Chunked_String; Output : out String) is
Position : Positive := Output'First;
Step : Positive;
begin
if Source.Size > 0 then
for J in Source.Data'Range loop
Step := Positive'Min (Source.Data (J).all'Length,
Source.Size - Position + 1);
Output (Position .. Position + Step - 1)
:= Source.Data (J).all (1 .. Step);
Position := Position + Step;
exit when Position > Source.Size;
end loop;
pragma Assert (Position = Source.Size + 1);
end if;
end To_String;
-------------------------------------------
-- String_Accumulator specific interface --
-------------------------------------------
function Tail (Source : in Chunked_String; Size : in Natural)
return String
is
Actual_Size : constant Natural := Natural'Min (Size, Source.Size);
begin
return Slice (Source, Source.Size - Actual_Size + 1, Source.Size);
end Tail;
procedure Unappend (From : in out Chunked_String; Text : in String) is
begin
if Text'Length <= From.Size
and then String'(Tail (From, Text'Length)) = Text
then
From.Size := From.Size - Text'Length;
end if;
end Unappend;
------------------------
-- Standard interface --
------------------------
function Length (Source : in Chunked_String) return Natural is
begin
return Source.Size;
end Length;
procedure Deallocate is
new Ada.Unchecked_Deallocation (String, String_Access);
procedure Free (X : in out String_Access) is
begin
Deallocate (X);
end Free;
procedure Free_Extra_Memory (From : in out Chunked_String) is
begin
Resize_Chunks (From.Data, From.Size,
From.Chunk_Size, From.Allocation_Unit,
Can_Shrink => True);
end Free_Extra_Memory;
procedure Preallocate (Str : in out Chunked_String; Size : Natural) is
begin
Resize_Chunks (Str.Data, Size, Str.Chunk_Size, Str.Allocation_Unit,
Can_Shrink => False);
end Preallocate;
function To_Chunked_String
(Source : in String;
Chunk_Size : in Positive := Default_Chunk_Size;
Allocation_Unit : in Positive := Default_Allocation_Unit)
return Chunked_String
is
Data : Chunk_Array_Access := null;
begin
if Source'Length > 0 then
Resize_Chunks (Data, Source'Length, Chunk_Size, Allocation_Unit);
Move (Data.all, Source, 1, Chunk_Size);
end if;
return Chunked_String'(Ada.Finalization.Controlled with
Chunk_Size => Chunk_Size,
Allocation_Unit => Allocation_Unit,
Size => Source'Length,
Data => Data);
end To_Chunked_String;
function To_Chunked_String
(Length : in Natural;
Chunk_Size : in Positive := Default_Chunk_Size;
Allocation_Unit : in Positive := Default_Allocation_Unit)
return Chunked_String
is
Data : Chunk_Array_Access := null;
begin
Resize_Chunks (Data, Length, Chunk_Size, Allocation_Unit);
return Chunked_String'(Ada.Finalization.Controlled with
Chunk_Size => Chunk_Size,
Allocation_Unit => Allocation_Unit,
Size => Length,
Data => Data);
end To_Chunked_String;
function To_String (Source : in Chunked_String) return String is
Value : String (1 .. Source.Size);
begin
To_String (Source, Value);
return Value;
end To_String;
procedure Set_Chunked_String
(Target : out Chunked_String;
Source : in String;
Chunk_Size : in Positive := Default_Chunk_Size;
Allocation_Unit : in Positive := Default_Allocation_Unit) is
begin
Resize_Chunks (Target.Data, Source'Length,
Chunk_Size, Allocation_Unit,
Can_Shrink => True);
Target.Chunk_Size := Chunk_Size;
Target.Allocation_Unit := Allocation_Unit;
Target.Size := Source'Length;
if Target.Size > 0 then
Move (Target.Data.all, Source, 1, Chunk_Size);
end if;
end Set_Chunked_String;
procedure Append (Source : in out Chunked_String;
New_Item : in Chunked_String)
is
New_Size : constant Natural := Source.Size + New_Item.Size;
begin
Resize_Chunks (Source.Data, New_Size,
Source.Chunk_Size, Source.Allocation_Unit,
Can_Shrink => False);
Move (Source.Data.all, Source.Size + 1,
New_Item.Data.all, 1,
New_Item.Size);
Source.Size := New_Size;
end Append;
procedure Append (Source : in out Chunked_String;
New_Item : in String)
is
New_Size : constant Natural := Source.Size + New_Item'Length;
begin
Resize_Chunks (Source.Data, New_Size,
Source.Chunk_Size, Source.Allocation_Unit,
Can_Shrink => False);
Move (Source.Data.all, New_Item, Source.Size + 1, Source.Chunk_Size);
Source.Size := New_Size;
end Append;
procedure Append (Source : in out Chunked_String;
New_Item : in Character)
is
S : constant String (1 .. 1) := (1 => New_Item);
begin
Append (Source, S);
end Append;
function "&" (Left, Right : in Chunked_String)
return Chunked_String
is
Size : constant Natural := Left.Size + Right.Size;
Data : Chunk_Array_Access := null;
begin
Resize_Chunks (Data, Size, Default_Chunk_Size, Default_Allocation_Unit);
if Left.Size > 0 then
Move (Data.all, 1, Left.Data.all, 1, Left.Size);
end if;
if Right.Size > 0 then
Move (Data.all, 1 + Left.Size, Right.Data.all, 1, Right.Size);
end if;
return Chunked_String'(Ada.Finalization.Controlled with
Chunk_Size => Default_Chunk_Size,
Allocation_Unit => Default_Allocation_Unit,
Size => Size,
Data => Data);
end "&";
function "&" (Left : in Chunked_String; Right : in String)
return Chunked_String
is
Size : constant Natural := Left.Size + Right'Length;
Data : Chunk_Array_Access := null;
begin
Resize_Chunks (Data, Size, Default_Chunk_Size, Default_Allocation_Unit);
if Left.Size > 0 then
Move (Data.all, 1, Left.Data.all, 1, Left.Size);
end if;
if Right'Length > 0 then
Move (Data.all, Right, 1 + Left.Size, Default_Chunk_Size);
end if;
return Chunked_String'(Ada.Finalization.Controlled with
Chunk_Size => Default_Chunk_Size,
Allocation_Unit => Default_Allocation_Unit,
Size => Size,
Data => Data);
end "&";
function "&" (Left : in String; Right : in Chunked_String)
return Chunked_String
is
Size : constant Natural := Left'Length + Right.Size;
Data : Chunk_Array_Access := null;
begin
Resize_Chunks (Data, Size, Default_Chunk_Size, Default_Allocation_Unit);
if Left'Length > 0 then
Move (Data.all, Left, 1, Default_Chunk_Size);
end if;
if Right.Size > 0 then
Move (Data.all, 1 + Left'Length, Right.Data.all, 1, Right.Size);
end if;
return Chunked_String'(Ada.Finalization.Controlled with
Chunk_Size => Default_Chunk_Size,
Allocation_Unit => Default_Allocation_Unit,
Size => Size,
Data => Data);
end "&";
function "&" (Left : in Chunked_String; Right : in Character)
return Chunked_String
is
Size : constant Natural := Left.Size + 1;
Allocation_Unit : constant Positive := Default_Allocation_Unit;
Chunk_Size : constant Positive := Default_Chunk_Size;
Data : Chunk_Array_Access := null;
begin
Resize_Chunks (Data, Size, Chunk_Size, Allocation_Unit);
if Left.Size > 0 then
Move (Data.all, 1, Left.Data.all, 1, Left.Size);
end if;
declare
Position : constant Positive := Left.Size + 1;
Chunk : constant Positive := (Position - 1) / Chunk_Size + 1;
Offset : constant Positive := (Position - 1) mod Chunk_Size + 1;
begin
Data (Chunk).all (Offset) := Right;
end;
return Chunked_String'(Ada.Finalization.Controlled with
Chunk_Size => Chunk_Size,
Allocation_Unit => Allocation_Unit,
Size => Size,
Data => Data);
end "&";
function "&" (Left : in Character; Right : in Chunked_String)
return Chunked_String
is
Size : constant Natural := 1 + Right.Size;
Data : Chunk_Array_Access := null;
begin
Resize_Chunks (Data, Size, Default_Chunk_Size, Default_Allocation_Unit);
Data (1).all (1) := Left;
if Right.Size > 0 then
Move (Data.all, 2, Right.Data.all, 1, Right.Size);
end if;
return Chunked_String'(Ada.Finalization.Controlled with
Chunk_Size => Default_Chunk_Size,
Allocation_Unit => Default_Allocation_Unit,
Size => Size,
Data => Data);
end "&";
function Element (Source : in Chunked_String;
Index : in Positive)
return Character
is
Chunk : constant Positive := (Index - 1) / Source.Chunk_Size + 1;
Offset : constant Positive := (Index - 1) mod Source.Chunk_Size + 1;
begin
if Index > Source.Size then
raise Ada.Strings.Index_Error;
end if;
return Source.Data (Chunk).all (Offset);
end Element;
procedure Replace_Element (Source : in out Chunked_String;
Index : in Positive;
By : in Character)
is
Chunk : constant Positive := (Index - 1) / Source.Chunk_Size + 1;
Offset : constant Positive := (Index - 1) mod Source.Chunk_Size + 1;
begin
if Index > Source.Size then
raise Ada.Strings.Index_Error;
end if;
Source.Data (Chunk).all (Offset) := By;
end Replace_Element;
function Slice (Source : in Chunked_String;
Low : in Positive;
High : in Natural)
return String
is
Returned : String (Low .. High);
begin
if Low > Source.Size + 1 or High > Source.Size then
raise Ada.Strings.Index_Error;
end if;
if High >= Low then
Move (Returned, Source.Data.all, Low);
end if;
return Returned;
end Slice;
function Chunked_Slice
(Source : in Chunked_String;
Low : in Positive;
High : in Natural;
Chunk_Size : in Positive := Default_Chunk_Size;
Allocation_Unit : in Positive := Default_Allocation_Unit)
return Chunked_String
is
Data : Chunk_Array_Access := null;
Size : Natural := 0;
begin
if Low > Source.Size + 1 or High > Source.Size then
raise Ada.Strings.Index_Error;
end if;
if Low <= High then
Size := High - Low + 1;
Resize_Chunks (Data, Size, Chunk_Size, Allocation_Unit);
Move (Data.all, 1, Source.Data.all, Low, Size);
end if;
return Chunked_String'(Ada.Finalization.Controlled with
Chunk_Size => Chunk_Size,
Allocation_Unit => Allocation_Unit,
Size => Size,
Data => Data);
end Chunked_Slice;
procedure Chunked_Slice
(Source : in Chunked_String;
Target : out Chunked_String;
Low : in Positive;
High : in Natural;
Chunk_Size : in Positive := Default_Chunk_Size;
Allocation_Unit : in Positive := Default_Allocation_Unit) is
begin
if Low > Source.Size + 1 or High > Source.Size then
raise Ada.Strings.Index_Error;
end if;
Target.Chunk_Size := Chunk_Size;
Target.Allocation_Unit := Allocation_Unit;
if Low <= High then
Target.Size := High - Low + 1;
Resize_Chunks (Target.Data, Target.Size,
Chunk_Size, Allocation_Unit,
Can_Shrink => True);
Move (Target.Data.all, 1, Source.Data.all, Low, Target.Size);
else
Target.Size := 0;
Target.Data := null;
end if;
end Chunked_Slice;
function "=" (Left, Right : in Chunked_String) return Boolean is
begin
return Compare (Left.Data, Left.Size, Right.Data, Right.Size) = Equal;
end "=";
function "=" (Left : in Chunked_String; Right : in String)
return Boolean is
begin
return Compare (Left.Data, Left.Size, Right) = Equal;
end "=";
function "=" (Left : in String; Right : in Chunked_String)
return Boolean is
begin
return Compare (Right.Data, Right.Size, Left) = Equal;
end "=";
function "<" (Left, Right : in Chunked_String) return Boolean is
begin
return Compare (Left.Data, Left.Size, Right.Data, Right.Size) = Lesser;
end "<";
function "<" (Left : in Chunked_String; Right : in String)
return Boolean is
begin
return Compare (Left.Data, Left.Size, Right) = Lesser;
end "<";
function "<" (Left : in String; Right : in Chunked_String)
return Boolean is
begin
return Compare (Right.Data, Right.Size, Left) = Greater;
end "<";
function "<=" (Left, Right : in Chunked_String) return Boolean is
begin
return Compare (Left.Data, Left.Size, Right.Data, Right.Size) /= Greater;
end "<=";
function "<=" (Left : in Chunked_String; Right : in String)
return Boolean is
begin
return Compare (Left.Data, Left.Size, Right) /= Greater;
end "<=";
function "<=" (Left : in String; Right : in Chunked_String)
return Boolean is
begin
return Compare (Right.Data, Right.Size, Left) /= Lesser;
end "<=";
function ">" (Left, Right : in Chunked_String) return Boolean is
begin
return Compare (Left.Data, Left.Size, Right.Data, Right.Size) = Greater;
end ">";
function ">" (Left : in Chunked_String; Right : in String)
return Boolean is
begin
return Compare (Left.Data, Left.Size, Right) = Greater;
end ">";
function ">" (Left : in String; Right : in Chunked_String)
return Boolean is
begin
return Compare (Right.Data, Right.Size, Left) = Lesser;
end ">";
function ">=" (Left, Right : in Chunked_String) return Boolean is
begin
return Compare (Left.Data, Left.Size, Right.Data, Right.Size) /= Lesser;
end ">=";
function ">=" (Left : in Chunked_String; Right : in String)
return Boolean is
begin
return Compare (Left.Data, Left.Size, Right) /= Lesser;
end ">=";
function ">=" (Left : in String; Right : in Chunked_String)
return Boolean is
begin
return Compare (Right.Data, Right.Size, Left) /= Greater;
end ">=";
function Index_Gen
(Source : Chunked_String;
Pattern : String;
From : Positive;
Going : Ada.Strings.Direction;
Map : Map_Type)
return Natural is
begin
if Pattern = "" then
raise Ada.Strings.Pattern_Error;
end if;
if Source.Size = 0 and From = 1 then
return 0;
end if;
if From > Source.Size then
raise Ada.Strings.Index_Error;
end if;
declare
Chunk : Positive := (From - 1) / Source.Chunk_Size + 1;
Offset : Positive := (From - 1) mod Source.Chunk_Size + 1;
Buffer : String (1 .. Source.Chunk_Size + Pattern'Length - 1);
Result : Natural;
Span : Positive;
begin
case (Going) is
when Ada.Strings.Forward =>
while (Chunk - 1) * Source.Chunk_Size + Pattern'Length
<= Source.Size
loop
Span := Positive'Min
(Source.Chunk_Size + Pattern'Length - 1,
Source.Size - (Chunk - 1) * Source.Chunk_Size);
Move (Buffer (1 .. Span),
Source.Data.all,
(Chunk - 1) * Source.Chunk_Size + 1);
Result := Index (Buffer (1 .. Span),
Pattern, Offset, Going, Map);
if Result /= 0 then
return (Chunk - 1) * Source.Chunk_Size + Result;
end if;
Chunk := Chunk + 1;
Offset := 1;
end loop;
return 0;
when Ada.Strings.Backward =>
loop
Span := Positive'Min
(Source.Chunk_Size + Pattern'Length - 1,
Source.Size - (Chunk - 1) * Source.Chunk_Size);
Move (Buffer (1 .. Span),
Source.Data.all,
(Chunk - 1) * Source.Chunk_Size + 1);
Result := Index (Buffer (1 .. Span),
Pattern, Offset, Going, Map);
if Result /= 0 then
return (Chunk - 1) * Source.Chunk_Size + Result;
end if;
exit when Chunk = 1;
Chunk := Chunk - 1;
Offset := Positive'Min (Source.Chunk_Size + Pattern'Length - 1,
Source.Chunk_Size + Offset);
end loop;
return 0;
end case;
end;
end Index_Gen;
function Index_Mapping is
new Index_Gen (Maps.Character_Mapping, Ada.Strings.Fixed.Index);
function Index (Source : in Chunked_String;
Pattern : in String;
From : in Positive;
Going : in Ada.Strings.Direction := Ada.Strings.Forward;
Mapping : in Maps.Character_Mapping := Maps.Identity)
return Natural
renames Index_Mapping;
function Index_Mapping_Function is
new Index_Gen (Maps.Character_Mapping_Function, Ada.Strings.Fixed.Index);
function Index (Source : in Chunked_String;
Pattern : in String;
From : in Positive;
Going : in Ada.Strings.Direction := Ada.Strings.Forward;
Mapping : in Maps.Character_Mapping_Function)
return Natural
renames Index_Mapping_Function;
function Index (Source : in Chunked_String;
Pattern : in String;
Going : in Ada.Strings.Direction := Ada.Strings.Forward;
Mapping : in Maps.Character_Mapping := Maps.Identity)
return Natural is
begin
case (Going) is
when Ada.Strings.Forward =>
return Index (Source, Pattern, 1, Going, Mapping);
when Ada.Strings.Backward =>
return Index (Source, Pattern, Source.Size, Going, Mapping);
end case;
end Index;
function Index (Source : in Chunked_String;
Pattern : in String;
Going : in Ada.Strings.Direction := Ada.Strings.Forward;
Mapping : in Maps.Character_Mapping_Function)
return Natural is
begin
case (Going) is
when Ada.Strings.Forward =>
return Index (Source, Pattern, 1, Going, Mapping);
when Ada.Strings.Backward =>
return Index (Source, Pattern, Source.Size, Going, Mapping);
end case;
end Index;
function Index (Source : in Chunked_String;
Set : in Maps.Character_Set;
From : in Positive;
Test : in Ada.Strings.Membership := Ada.Strings.Inside;
Going : in Ada.Strings.Direction := Ada.Strings.Forward)
return Natural
is
Chunk : Positive := (From - 1) / Source.Chunk_Size + 1;
Offset : Positive := (From - 1) mod Source.Chunk_Size + 1;
Result : Natural;
begin
if From > Source.Size then
raise Ada.Strings.Index_Error;
end if;
case (Going) is
when Ada.Strings.Forward =>
loop
Result := Ada.Strings.Fixed.Index
(Source.Data (Chunk).all
(1 .. Positive'Min (Source.Size
- (Chunk - 1) * Source.Chunk_Size,
Source.Chunk_Size)),
Set, Offset, Test, Going);
if Result /= 0 then
return (Chunk - 1) * Source.Chunk_Size + Result;
end if;
if Chunk = Source.Data'Last then
return 0;
end if;
Chunk := Chunk + 1;
Offset := 1;
end loop;
when Ada.Strings.Backward =>
loop
Result := Ada.Strings.Fixed.Index
(Source.Data (Chunk).all
(1 .. Positive'Min (Source.Size
- (Chunk - 1) * Source.Chunk_Size,
Source.Chunk_Size)),
Set, Offset, Test, Going);
if Result /= 0 then
return (Chunk - 1) * Source.Chunk_Size + Result;
end if;
if Chunk = Source.Data'First then
return 0;
end if;
Chunk := Chunk - 1;
Offset := Source.Chunk_Size;
end loop;
end case;
end Index;
function Index (Source : in Chunked_String;
Set : in Maps.Character_Set;
Test : in Ada.Strings.Membership := Ada.Strings.Inside;
Going : in Ada.Strings.Direction := Ada.Strings.Forward)
return Natural is
begin
case Going is
when Ada.Strings.Forward =>
return Index (Source, Set, 1, Test, Going);
when Ada.Strings.Backward =>
return Index (Source, Set, Source.Size, Test, Going);
end case;
end Index;
function Index_Non_Blank (Source : in Chunked_String;
From : in Positive;
Going : in Ada.Strings.Direction
:= Ada.Strings.Forward)
return Natural is
begin
return Index (Source,
Maps.To_Set (Ada.Strings.Space),
From,
Ada.Strings.Outside,
Going);
end Index_Non_Blank;
function Index_Non_Blank (Source : in Chunked_String;
Going : in Ada.Strings.Direction
:= Ada.Strings.Forward)
return Natural is
begin
return Index (Source,
Maps.To_Set (Ada.Strings.Space),
Ada.Strings.Outside,
Going);
end Index_Non_Blank;
function Count_Gen (Source : in Chunked_String;
Pattern : in String;
Mapping : in Map_Type)
return Natural
is
Buffer : String (1 .. Source.Chunk_Size + Pattern'Length - 1);
Result : Natural := 0;
Step : Positive;
begin
if Pattern = "" then
raise Ada.Strings.Pattern_Error;
end if;
if Source.Size < Pattern'Length then
return 0;
end if;
for J in Source.Data'Range loop
Step := Positive'Min (Source.Size - (J - 1) * Source.Chunk_Size,
Source.Chunk_Size + Pattern'Length - 1);
Move (Buffer (1 .. Step),
Source.Data.all,
(J - 1) * Source.Chunk_Size + 1);
Result := Result + Count (Buffer (1 .. Step),
Pattern,
Mapping);
end loop;
return Result;
end Count_Gen;
function Count_Mapping is
new Count_Gen (Maps.Character_Mapping, Ada.Strings.Fixed.Count);
function Count (Source : in Chunked_String;
Pattern : in String;
Mapping : in Maps.Character_Mapping := Maps.Identity)
return Natural
renames Count_Mapping;
function Count_Mapping_Function is
new Count_Gen (Maps.Character_Mapping_Function, Ada.Strings.Fixed.Count);
function Count (Source : in Chunked_String;
Pattern : in String;
Mapping : in Maps.Character_Mapping_Function)
return Natural
renames Count_Mapping_Function;
function Count (Source : in Chunked_String;
Set : in Maps.Character_Set)
return Natural
is
Result : Natural := 0;
Done : Natural := 0;
begin
if Source.Size > 0 then
for C in Source.Data'Range loop
declare
Chunk : String renames Source.Data (C).all;
Step : constant Natural
:= Natural'Min (Source.Size - Done, Chunk'Length);
begin
Result := Result + Ada.Strings.Fixed.Count
(Chunk (Chunk'First .. Chunk'First + Step - 1), Set);
Done := Done + Step;
end;
end loop;
end if;
return Result;
end Count;
procedure Find_Token (Source : in Chunked_String;
Set : in Maps.Character_Set;
Test : in Ada.Strings.Membership;
First : out Positive;
Last : out Natural)
is
Invert : constant array (Ada.Strings.Membership)
of Ada.Strings.Membership
:= (Ada.Strings.Inside => Ada.Strings.Outside,
Ada.Strings.Outside => Ada.Strings.Inside);
N : Natural;
begin
N := Index (Source, Set, Test);
if N = 0 then
First := 1;
Last := 0;
else
First := N;
N := Index (Source, Set, First, Invert (Test));
if N = 0 then
Last := Source.Size;
else
Last := N - 1;
end if;
end if;
end Find_Token;
-- String translation subprograms
function Translate (Source : in Chunked_String;
Mapping : in Maps.Character_Mapping)
return Chunked_String
is
Data : Chunk_Array_Access := null;
begin
if Source.Data /= null then
Data := new Chunk_Array (Source.Data'Range);
for J in Source.Data'Range loop
Data (J) := new String (Source.Data (J).all'Range);
Data (J).all := Fixed.Translate (Source.Data (J).all, Mapping);
end loop;
end if;
return Chunked_String'(Ada.Finalization.Controlled with
Chunk_Size => Source.Chunk_Size,
Allocation_Unit => Source.Allocation_Unit,
Size => Source.Size,
Data => Data);
end Translate;
procedure Translate (Source : in out Chunked_String;
Mapping : in Maps.Character_Mapping) is
begin
if Source.Data /= null then
for J in Source.Data'Range loop
Fixed.Translate (Source.Data (J).all, Mapping);
end loop;
end if;
end Translate;
function Translate (Source : in Chunked_String;
Mapping : in Maps.Character_Mapping_Function)
return Chunked_String
is
Data : Chunk_Array_Access := null;
begin
if Source.Data /= null then
Data := new Chunk_Array (Source.Data'Range);
for J in Source.Data'Range loop
Data (J) := new String (Source.Data (J).all'Range);
Data (J).all := Fixed.Translate (Source.Data (J).all, Mapping);
end loop;
end if;
return Chunked_String'(Ada.Finalization.Controlled with
Chunk_Size => Source.Chunk_Size,
Allocation_Unit => Source.Allocation_Unit,
Size => Source.Size,
Data => Data);
end Translate;
procedure Translate (Source : in out Chunked_String;
Mapping : in Maps.Character_Mapping_Function) is
begin
if Source.Data /= null then
for J in Source.Data'Range loop
Fixed.Translate (Source.Data (J).all, Mapping);
end loop;
end if;
end Translate;
-- String transformation subprograms
function Replace_Slice (Source : in Chunked_String;
Low : in Positive;
High : in Natural;
By : in String)
return Chunked_String
is
Size : Natural := 0;
Data : Chunk_Array_Access := null;
Hi : Natural := High;
begin
if Low > Source.Size + 1 then
raise Ada.Strings.Index_Error;
end if;
if High < Low then
Hi := Low - 1;
end if;
Size := (Low - 1) + By'Length + (Source.Size - Hi);
Resize_Chunks (Data, Size, Source.Chunk_Size, Source.Allocation_Unit,
Can_Shrink => False);
if Low > 1 then
Move (Data.all, 1, Source.Data.all, 1, Low - 1);
end if;
if By'Length > 0 then
Move (Data.all, By, Low, Source.Chunk_Size);
end if;
if Hi < Source.Size then
Move (Data.all, Low + By'Length, Source.Data.all, Hi + 1,
Source.Size - Hi);
end if;
return Chunked_String'(Ada.Finalization.Controlled with
Chunk_Size => Source.Chunk_Size,
Allocation_Unit => Source.Allocation_Unit,
Size => Size,
Data => Data);
end Replace_Slice;
procedure Replace_Slice (Source : in out Chunked_String;
Low : in Positive;
High : in Natural;
By : in String)
is
Size : Natural := 0;
Hi : Natural := High;
begin
if Low > Source.Size + 1 then
raise Ada.Strings.Index_Error;
end if;
if High < Low then
Hi := Low - 1;
end if;
Size := (Low - 1) + By'Length + (Source.Size - Hi);
Resize_Chunks (Source.Data, Size,
Source.Chunk_Size, Source.Allocation_Unit,
Can_Shrink => False);
if Hi < Source.Size and Low + By'Length /= Hi + 1 then
Move (Data => Source.Data.all,
Target_Position => Low + By'Length,
Source_Position => Hi + 1,
Length => Source.Size - Hi,
Chunk_Size => Source.Chunk_Size);
end if;
if By'Length > 0 then
Move (Source.Data.all, By, Low, Source.Chunk_Size);
end if;
Source.Size := Size;
end Replace_Slice;
function Insert (Source : in Chunked_String;
Before : in Positive;
New_Item : in String)
return Chunked_String is
begin
return Replace_Slice (Source, Before, Before - 1, New_Item);
end Insert;
procedure Insert (Source : in out Chunked_String;
Before : in Positive;
New_Item : in String) is
begin
Replace_Slice (Source, Before, Before - 1, New_Item);
end Insert;
function Overwrite (Source : in Chunked_String;
Position : in Positive;
New_Item : in String)
return Chunked_String is
begin
return Replace_Slice (Source, Position, Source.Size, New_Item);
end Overwrite;
procedure Overwrite (Source : in out Chunked_String;
Position : in Positive;
New_Item : in String) is
begin
Replace_Slice (Source,
Low => Position,
High => Natural'Min (Source.Size,
Position + New_Item'Length - 1),
By => New_Item);
end Overwrite;
function Delete (Source : in Chunked_String;
From : in Positive;
Through : in Natural)
return Chunked_String is
begin
if From <= Through then
return Replace_Slice (Source, From, Through, "");
else
return Duplicate (Source);
end if;
end Delete;
procedure Delete (Source : in out Chunked_String;
From : in Positive;
Through : in Natural) is
begin
if From <= Through then
Replace_Slice (Source, From, Through, "");
end if;
end Delete;
function Trim (Source : in Chunked_String;
Side : in Ada.Strings.Trim_End)
return Chunked_String is
begin
case Side is
when Ada.Strings.Left =>
return Trim (Source,
Maps.To_Set (Ada.Strings.Space),
Maps.Null_Set);
when Ada.Strings.Right =>
return Trim (Source,
Maps.Null_Set,
Maps.To_Set (Ada.Strings.Space));
when Ada.Strings.Both =>
return Trim (Source,
Maps.To_Set (Ada.Strings.Space),
Maps.To_Set (Ada.Strings.Space));
end case;
end Trim;
procedure Trim (Source : in out Chunked_String;
Side : in Ada.Strings.Trim_End) is
begin
case Side is
when Ada.Strings.Left =>
Trim (Source,
Maps.To_Set (Ada.Strings.Space),
Maps.Null_Set);
when Ada.Strings.Right =>
Trim (Source,
Maps.Null_Set,
Maps.To_Set (Ada.Strings.Space));
when Ada.Strings.Both =>
Trim (Source,
Maps.To_Set (Ada.Strings.Space),
Maps.To_Set (Ada.Strings.Space));
end case;
end Trim;
procedure Trim_Bounds (Source : in Chunked_String;
Left : in Maps.Character_Set;
Right : in Maps.Character_Set;
Low : out Positive;
High : out Natural)
is
Chunk : Positive;
begin
Low := 1;
High := Source.Size;
Chunk := 1;
while Low <= High and then
Maps.Is_In (Source.Data (Chunk).all
(Low - (Chunk - 1) * Source.Chunk_Size),
Left)
loop
Low := Low + 1;
if Low mod Source.Chunk_Size = 1 then
Chunk := Chunk + 1;
end if;
end loop;
if High > 0 then
Chunk := (High - 1) / Source.Chunk_Size + 1;
while Low <= High and then
Maps.Is_In (Source.Data (Chunk).all
(High - (Chunk - 1) * Source.Chunk_Size),
Right)
loop
High := High - 1;
if High mod Source.Chunk_Size = 0 then
Chunk := Chunk - 1;
end if;
end loop;
end if;
end Trim_Bounds;
function Trim (Source : in Chunked_String;
Left : in Maps.Character_Set;
Right : in Maps.Character_Set)
return Chunked_String
is
Low : Positive;
High : Natural;
begin
Trim_Bounds (Source, Left, Right, Low, High);
return Chunked_Slice (Source, Low, High,
Source.Chunk_Size, Source.Allocation_Unit);
end Trim;
procedure Trim (Source : in out Chunked_String;
Left : in Maps.Character_Set;
Right : in Maps.Character_Set)
is
Low : Positive;
High : Natural;
begin
Trim_Bounds (Source, Left, Right, Low, High);
if Low > 1 then
Move (Data => Source.Data.all,
Target_Position => 1,
Source_Position => Low,
Length => High - Low + 1,
Chunk_Size => Source.Chunk_Size);
end if;
Source.Size := High - Low + 1;
end Trim;
function Head (Source : in Chunked_String;
Count : in Natural;
Pad : in Character := Ada.Strings.Space;
Chunk_Size : in Natural := 0; -- use value from Source
Allocation_Unit : in Natural := 0) -- use value from Source
return Chunked_String
is
Real_Chunk_Size : Positive := Default_Chunk_Size;
Real_Unit : Positive := Default_Allocation_Unit;
Data : Chunk_Array_Access := null;
begin
if Chunk_Size > 0 then
Real_Chunk_Size := Chunk_Size;
end if;
if Allocation_Unit > 0 then
Real_Unit := Allocation_Unit;
end if;
if Count > 0 then
Resize_Chunks (Data, Count, Real_Chunk_Size, Real_Unit);
if Count > Source.Size then
Move (Data.all, 1, Source.Data.all, 1, Source.Size);
Fill (Data.all, Source.Size + 1,
Count - Source.Size, Pad, Real_Chunk_Size);
else
Move (Data.all, 1, Source.Data.all, 1, Count);
end if;
end if;
return Chunked_String'(Ada.Finalization.Controlled with
Chunk_Size => Real_Chunk_Size,
Allocation_Unit => Real_Unit,
Size => Count,
Data => Data);
end Head;
procedure Head (Source : in out Chunked_String;
Count : in Natural;
Pad : in Character := Ada.Strings.Space) is
begin
if Count > Source.Size then
Resize_Chunks (Source.Data, Count,
Source.Chunk_Size, Source.Allocation_Unit,
Can_Shrink => False);
Fill (Source.Data.all, Source.Size + 1, Count - Source.Size, Pad,
Source.Chunk_Size);
end if;
Source.Size := Count;
end Head;
function Tail (Source : in Chunked_String;
Count : in Natural;
Pad : in Character := Ada.Strings.Space;
Chunk_Size : in Natural := 0; -- use value from Source
Allocation_Unit : in Natural := 0) -- use value from Source
return Chunked_String
is
Real_Chunk_Size : Positive := Default_Chunk_Size;
Real_Unit : Positive := Default_Allocation_Unit;
Data : Chunk_Array_Access := null;
begin
if Chunk_Size > 0 then
Real_Chunk_Size := Chunk_Size;
end if;
if Allocation_Unit > 0 then
Real_Unit := Allocation_Unit;
end if;
if Count > 0 then
Resize_Chunks (Data, Count, Real_Chunk_Size, Real_Unit);
if Count > Source.Size then
Fill (Data.all, 1, Count - Source.Size, Pad, Real_Chunk_Size);
Move (Data.all, Count - Source.Size + 1,
Source.Data.all, 1, Source.Size);
else
Move (Data.all, 1,
Source.Data.all, Source.Size - Count + 1, Count);
end if;
end if;
return Chunked_String'(Ada.Finalization.Controlled with
Chunk_Size => Real_Chunk_Size,
Allocation_Unit => Real_Unit,
Size => Count,
Data => Data);
end Tail;
procedure Tail (Source : in out Chunked_String;
Count : in Natural;
Pad : in Character := Ada.Strings.Space) is
begin
Resize_Chunks (Source.Data, Count,
Source.Chunk_Size, Source.Allocation_Unit,
Can_Shrink => False);
if Count > Source.Size then
if Source.Size > 0 then
Move (Data => Source.Data.all,
Target_Position => Count - Source.Size + 1,
Source_Position => 1,
Length => Source.Size,
Chunk_Size => Source.Chunk_Size);
end if;
Fill (Source.Data.all, 1, Count - Source.Size, Pad,
Source.Chunk_Size);
elsif Count > 0 then
Move (Data => Source.Data.all,
Target_Position => 1,
Source_Position => Source.Size - Count + 1,
Length => Count,
Chunk_Size => Source.Chunk_Size);
end if;
Source.Size := Count;
end Tail;
function "*" (Left : in Natural;
Right : in Character)
return Chunked_String
is
Chunk_Size : constant Positive := Default_Chunk_Size;
Allocation_Unit : constant Positive := Default_Allocation_Unit;
Size : constant Natural := Left;
Chunk_Nb : constant Natural
:= Chunks_For (Size, Chunk_Size, Allocation_Unit);
Last_Chunk_Size : constant Natural
:= Units_For (Size, Chunk_Size, Allocation_Unit) * Allocation_Unit;
Data : Chunk_Array_Access := null;
begin
if Size > 0 then
Data := new Chunk_Array (1 .. Chunk_Nb);
for J in 1 .. Chunk_Nb - 1 loop
Data (J) := new String'(Ada.Strings.Fixed."*" (Chunk_Size, Right));
end loop;
Data (Chunk_Nb) := new
String'(Ada.Strings.Fixed."*" (Last_Chunk_Size, Right));
end if;
return Chunked_String'(Ada.Finalization.Controlled with
Chunk_Size => Chunk_Size,
Allocation_Unit => Allocation_Unit,
Size => Size,
Data => Data);
end "*";
function "*" (Left : in Natural;
Right : in String)
return Chunked_String
is
Chunk_Size : constant Positive := Default_Chunk_Size;
Allocation_Unit : constant Positive := Default_Allocation_Unit;
Size : constant Natural := Left * Right'Length;
Chunk_Nb : constant Natural
:= Chunks_For (Size, Chunk_Size, Allocation_Unit);
Last_Chunk_Size : constant Natural
:= Units_For (Size, Chunk_Size, Allocation_Unit) * Allocation_Unit;
Data : Chunk_Array_Access := null;
begin
if Size > 0 then
if Chunk_Size mod Right'Length = 0 then
Data := new Chunk_Array (1 .. Chunk_Nb);
for J in 1 .. Chunk_Nb - 1 loop
Data (J) := new String'(Ada.Strings.Fixed."*"
(Chunk_Size / Right'Length, Right));
end loop;
Data (Chunk_Nb) := new String'(Ada.Strings.Fixed."*"
(Last_Chunk_Size / Right'Length, Right));
else
Resize_Chunks (Data, Size, Chunk_Size, Allocation_Unit);
for J in 1 .. Left loop
Move (Data.all, Right, (J - 1) * Right'Length + 1, Chunk_Size);
end loop;
end if;
end if;
return Chunked_String'(Ada.Finalization.Controlled with
Chunk_Size => Chunk_Size,
Allocation_Unit => Allocation_Unit,
Size => Size,
Data => Data);
end "*";
function "*" (Left : in Natural;
Right : in Chunked_String)
return Chunked_String
is
Chunk_Size : constant Positive := Default_Chunk_Size;
Allocation_Unit : constant Positive := Default_Allocation_Unit;
Size : constant Natural := Left * Right.Size;
Data : Chunk_Array_Access := null;
begin
if Size > 0 then
Resize_Chunks (Data, Size, Chunk_Size, Allocation_Unit);
for J in 1 .. Left loop
Move (Data.all, (J - 1) * Right.Size + 1,
Right.Data.all, 1, Right.Size);
end loop;
end if;
return Chunked_String'(Ada.Finalization.Controlled with
Chunk_Size => Chunk_Size,
Allocation_Unit => Allocation_Unit,
Size => Size,
Data => Data);
end "*";
-- Controlled object methods
overriding procedure Initialize (Object : in out Chunked_String) is
begin
Object.Size := 0;
Object.Data := null;
end Initialize;
overriding procedure Adjust (Object : in out Chunked_String) is
New_Data : Chunk_Array_Access;
begin
if Object.Data /= null then
New_Data := new Chunk_Array (Object.Data'Range);
for J in Object.Data'Range loop
New_Data (J) := new String'(Object.Data (J).all);
end loop;
Object.Data := New_Data;
end if;
end Adjust;
overriding procedure Finalize (Object : in out Chunked_String) is
begin
Free (Object.Data);
end Finalize;
end Natools.Chunked_Strings;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Generic_Collections;
package AMF.UML.Variables.Collections is
pragma Preelaborate;
package UML_Variable_Collections is
new AMF.Generic_Collections
(UML_Variable,
UML_Variable_Access);
type Set_Of_UML_Variable is
new UML_Variable_Collections.Set with null record;
Empty_Set_Of_UML_Variable : constant Set_Of_UML_Variable;
type Ordered_Set_Of_UML_Variable is
new UML_Variable_Collections.Ordered_Set with null record;
Empty_Ordered_Set_Of_UML_Variable : constant Ordered_Set_Of_UML_Variable;
type Bag_Of_UML_Variable is
new UML_Variable_Collections.Bag with null record;
Empty_Bag_Of_UML_Variable : constant Bag_Of_UML_Variable;
type Sequence_Of_UML_Variable is
new UML_Variable_Collections.Sequence with null record;
Empty_Sequence_Of_UML_Variable : constant Sequence_Of_UML_Variable;
private
Empty_Set_Of_UML_Variable : constant Set_Of_UML_Variable
:= (UML_Variable_Collections.Set with null record);
Empty_Ordered_Set_Of_UML_Variable : constant Ordered_Set_Of_UML_Variable
:= (UML_Variable_Collections.Ordered_Set with null record);
Empty_Bag_Of_UML_Variable : constant Bag_Of_UML_Variable
:= (UML_Variable_Collections.Bag with null record);
Empty_Sequence_Of_UML_Variable : constant Sequence_Of_UML_Variable
:= (UML_Variable_Collections.Sequence with null record);
end AMF.UML.Variables.Collections;
|
-- { dg-do compile }
-- { dg-options "-O3" }
procedure Opt45 is
type Index_T is mod 2 ** 32;
for Index_T'Size use 32;
for Index_T'Alignment use 1;
type Array_T is array (Index_T range <>) of Natural;
type Array_Ptr_T is access all Array_T;
My_Array_1 : aliased Array_T := (1, 2);
My_Array_2 : aliased Array_T := (3, 4);
Array_Ptr : Array_Ptr_T := null;
Index : Index_T := Index_T'First;
My_Value : Natural := Natural'First;
procedure Proc (Selection : Positive) is
begin
if Selection = 1 then
Array_Ptr := My_Array_1'Access;
Index := My_Array_1'First;
else
Array_Ptr := My_Array_2'Access;
Index := My_Array_2'First;
end if;
if My_Value = Natural'First then
My_Value := Array_Ptr.all (Index);
end if;
end;
begin
Proc (2);
end;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . L I B M _ S I N G L E --
-- --
-- S p e c --
-- --
-- Copyright (C) 2014-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This is the Ada Cert Math specific version of s-libsin.ads
with System.Libm_Prefix;
-- @llrset Libm
-- LLR Libm
-- ========
package System.Libm_Single is
pragma Pure;
package SLP renames System.Libm_Prefix;
-- This package provides an implementation of the various C99 functions
-- used in the Ada run time. It is intended to be used for targets that
-- do not have a C math library, or where the C math library isn't of
-- sufficient quality and accuracy to meet Ada requirements.
-- In case of error conditions, NaNs or infinities are returned as
-- recommended in clause F.9 of the C99 standard. When called from C code,
-- the implementation behaves as if the FENV_ACCESS state is off, assuming
-- default rounding behavior and exception behavior.
-- The following C99 elementary functions are provided for single
-- precision (with the "f" suffix):
-- Acos, Acosh, Asin, Asinh, Atan, Atan2, Atanh, Cosh, Exp, Exp2, Log,
-- Log1p, Log2, Pow, Sin, Sinh, Tan, Tanh
-- All functions with a NaN argument return a NaN result, except where
-- stated otherwise. Unless otherwise specified, where the symbol +- occurs
-- in both an argument and the result, the result has the same sign as
-- the argument.
-- Each function lists C special values, Ada expected values as well as
-- Ada accuracy requirements the function meets. For accuracy requirements
-- the maximum relative error (abbreviated as MRE) is given, as well as
-- the domain for which the accuracy is guaranteed, where applicable.
-- The maximum relative error is expressed as multiple of Eps,
-- where Eps is Float'Model_Epsilon.
-- What about principal branch ???
----------
-- Acos --
----------
function Acos (X : Float) return Float
with Export, Convention => C, External_Name => SLP.Prefix & "acosf";
-- @llr acos (Float) Special Values
-- The Acos function shall return the following special values:
--
-- C99 special values:
-- Acos (1) = +0
-- Acos (x) = NaN if abs (x) > 1
--
-- Ada expected values:
-- Acos (0) = Pi/2.0 (tightly approximated)
-- Acos (-1) = Pi (tightly approximated)
-- Acos (x) return a result in [0, Pi] radians
--
-- @llr acos (Float) Accuracy
-- The Acos function shall return the inverse cosine of <X> with the
-- following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 4.0 * Eps
-----------
-- Acosh --
-----------
function Acosh (X : Float) return Float
with Export, Convention => C, External_Name => SLP.Prefix & "acoshf";
-- @llr acosh (Float) Special Values
-- The Acosh function shall return the following special values:
--
-- C99 special values:
-- Acosh (1) = +0
-- Acosh (x) = NaN if abs X > 1
-- Acosh (+INF) = +INF
--
-- @llr acosh (Float) Accuracy
-- The Acosh function shall return the inverse hyperbolic tangent of <X>
-- with the following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 8.0 * Eps
----------
-- Asin --
----------
function Asin (X : Float) return Float
with Export, Convention => C, External_Name => SLP.Prefix & "asinf";
-- @llr asin (Float) Special Values
-- The Asin function shall return the following special values:
--
-- C99 special values:
-- Asin (+-0) = +-0
-- Asin (x) = NaN if abs (x) > 1
--
-- Ada expected values:
-- Asin (1) = Pi/2.0 (tightly approximated)
-- Asin (-1) = -Pi/2 (tightly approximated)
-- Asin (x) return a result in [-Pi/2, Pi/2] radians
--
-- @llr asin (Float) Accuracy
-- The Asin function shall return the inverse sine of <X> with the
-- following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 4.0 * Eps
-----------
-- Asinh --
-----------
function Asinh (X : Float) return Float
with Export, Convention => C, External_Name => SLP.Prefix & "asinhf";
-- @llr asinh (Float) Special Values
-- The Asinh function shall return the following special values:
--
-- C99 special values:
-- Asinh (0) = 0
-- Asinh (+INF) = +INF
--
-- @llr asinh (Float) Accuracy
-- The Asinh function shall return the inverse hyperbolic sine of <X>
-- with the following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 8.0 * Eps
----------
-- Atan --
----------
function Atan (X : Float) return Float
with Export, Convention => C, External_Name => SLP.Prefix & "atanf";
-- @llr atan (Float) Special Values
-- The Atan function shall return the following special values:
--
-- C99 special values:
-- Atan (+-0) = +-Pi
-- Atan2 (+-INF) = +-0.5 * Pi
--
-- C expected values:
-- Atan (x) return a result in [-Pi/2, Pi/2]
-----------
-- Atan2 --
-----------
function Atan2 (Y : Float; X : Float) return Float
with Export, Convention => C, External_Name => SLP.Prefix & "atan2f";
-- @llr atan2 (Float; Float) Special Values
-- The Atan2 function shall return the following special values:
--
-- C99 special values:
-- Atan2 (+-0, -0) = +-Pi
-- Atan2 (+-0, +0) = +-0
-- Atan2 (+-0, x) = +-Pi, if x < 0
-- Atan2 (+-0, x) = +-0, if x > 0
-- Atan2 (y, +-0) = -0.5 * Pi, if y < 0
-- Atan2 (y, +-0) = 0.5 * Pi, if y > 0
-- Atan2 (+-y, -INF) = +-Pi, if y > 0 and y is finite
-- (tightly approximated)
-- Atan2 (+-y, -INF) = +-0, if y < 0 and y is finite
-- Atan2 (+-INF, x) = +-0.5 * Pi, if x is finite
-- (tightly approximated)
-- Atan2 (+-INF, -INF) = +-0.75 * Pi (tightly approximated)
-- Atan2 (+-INF, +INF) = +-0.25 * Pi (tightly approximated)
--
-- Ada expected values:
-- Atan2 (y, x) return a result in [-Pi, Pi]
--
-- @llr atan2 (Float; Float) Accuracy
-- The Atan2 function shall return the inverse tangent of <Y> / <X>
-- with the following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 4.0 * Eps
-----------
-- Atanh --
-----------
function Atanh (X : Float) return Float
with Export, Convention => C, External_Name => SLP.Prefix & "atanhf";
-- @llr atanh (Float) Special Values
-- The Atanh function shall return the following special values:
--
-- C99 special values:
-- Atanh (0) = 0
-- Atanh (+-1) = +- INF
-- Atanh (X) = NaN for abs X > 1
--
-- @llr atanh (Float) Accuracy
-- The Atanh function shall return the inverse hyperbolic tangent of <X>
-- with the following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 8.0 * Eps
---------
-- Cos --
---------
function Cos (X : Float) return Float
with Export, Convention => C, External_Name => SLP.Prefix & "cosf";
-- @llr cos (Float) Special Values
-- The Cos function shall return the following special values:
--
-- C99 special values:
-- Cos (+-0) = 1
-- Cos (+-INF) = NaN
--
-- Ada expected values:
-- abs (Cos (x)) <= 1
--
-- @llr cos (Float) Accuracy
-- The Cos function shall return the cosine of <X>
-- with the following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 2.0 * Eps
----------
-- Cosh --
----------
function Cosh (X : Float) return Float
with Export, Convention => C, External_Name => SLP.Prefix & "coshf";
-- @llr cosh (Float) Special Values
-- The Cosh function shall return the following special values:
--
-- C99 special values:
-- Cosh (+-0) = 1
-- Cosh (+-INF) = +INF
--
-- Ada expected values:
-- abs (Cosh (x)) > 1
--
-- @llr cosh (Float) Accuracy
-- The Cosh function shall return the inverse cosine of <X>
-- with the following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 8.0 * Eps
---------
-- Exp --
---------
function Exp (X : Float) return Float
with Export, Convention => C, External_Name => SLP.Prefix & "expf";
-- @llr exp (Float) Special Values
-- The Exp function shall return the following special values:
--
-- C99 special values:
-- Exp (+-0) = 1
-- Exp (-INF) = +0
-- Exp (+INF) = +INF
--
-- @llr exp (Float) Accuracy
-- The Exp function shall return the exponential of <X>
-- with the following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 4.0 * Eps
----------
-- Exp2 --
----------
function Exp2 (X : Float) return Float
with Export, Convention => C, External_Name => SLP.Prefix & "exp2f";
-- @llr exp2 (Float) Special Values
-- The Exp2 function shall return the following special values:
--
-- C99 special values:
-- Exp2 (+-0) = 1
-- Exp2 (-INF) = +0
-- Exp2 (+INF) = +INF
--
-- @llr exp2 (Float) Accuracy
-- The Exp2 function shall return the exponential of <X> in base 2
-- with the following accuracy:
--
-- Accuracy requirements:
-- MRE <= 4.0 * Eps
---------
-- Log --
---------
function Log (X : Float) return Float
with Export, Convention => C, External_Name => SLP.Prefix & "logf";
-- @llr log (Float) Special Values
-- The Log function shall return the following special values:
--
-- C99 special values:
-- Log (+-0) = -INF
-- Log (1) = +0
-- Log (x) = NaN if x<0
-- Log (+INF) = +INF
--
-- @llr log (Float) Accuracy
-- The Log function shall return the logarithm of <X>
-- with the following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 4.0 * Eps
-----------
-- Log1p --
-----------
function Log1p (X : Float) return Float
with Export, Convention => C, External_Name => SLP.Prefix & "log1pf";
-- @llr log1p (Float) Special Values:
-- The Log1p function shall return the following special values:
--
-- C99 special values:
-- Log1p (+-0) = -INF
-- Log1p (1) = +0
-- Log1p (x) = NaN if x<0
-- Log1p (+INF) = +INF
--
-- @llr log1p (Float) Accuracy
-- The Log1p function shall return the logarithm of <X> + 1
-- with the following accuracy:
--
-- Accuracy requirements:
-- MRE <= 4.0 * Eps
----------
-- Log2 --
----------
function Log2 (X : Float) return Float
with Export, Convention => C, External_Name => SLP.Prefix & "log2f";
-- @llr log2 (Float) Special Values
-- The Log2 function shall return the following special values:
--
-- C99 Special values:
-- Log2 (+-0) = -INF
-- Log2 (1) = +0
-- Log2 (x) = NaN if x<0
-- Log2 (+INF) = +INF
--
-- @llr log2 (Float) Accuracy
-- The Log function shall return the logarithm of <X> in base 2
-- with the following accuracy:
--
-- Accuracy requirements:
-- MRE <= 4.0 * Eps
---------
-- Pow --
---------
function Pow (Left, Right : Float) return Float
with Export, Convention => C, External_Name => SLP.Prefix & "powf";
-- @llr pow (Float; Float) Special Values
-- The Pow function shall return the following special values
--
-- C99 Special values:
-- Pow (+-0, y) = +-INF, if y < 0 and y an odd integer
-- Pow (+-0, y) = +INF, if y < 0 and y not an odd integer
-- Pow (+-0, y) = +-0 if y > 0 and y an odd integer
-- Pow (+-0, y) = +0 if y > 0 and y not an odd integer
-- Pow (-1, +-INF) = 1
-- Pow (1, y) = 1 for any y, even a NaN
-- Pow (x, +-0) = 1 for any x, even a NaN
-- Pow (x, y) = NaN, if x < 0 and both x and y finite and not integer
-- Pow (x, -INF) = +INF if abs (x) < 1
-- Pow (x, -INF) = +0 if abs (x) > 1
-- Pow (x, +INF) = +0 if abs (x) < 1
-- Pow (x, +INF) = +INF if abs (x) > 1
-- Pow (-INF, y) = -0 if y < 0 and y an odd integer
-- Pow (-INF, y) = +0 if y < 0 and y not an odd integer
-- Pow (-INF, y) = -INF if y > 0 and y an odd integer
-- Pow (-INF, y) = +INF if y > 0 and y not an odd integer
-- Pow (+INF, y) = +0 if y < 0
-- Pow (+INF, y) = +INF if y > 0
--
-- @llr pow (Float; Float) Accuracy
-- The Pow function shall return <Left> to the power of <Right>
-- with the following accuracy:
--
-- Ada Accuracy requirements:
-- MRE <= (4.0 + abs (x * Log (y)) / 32) * Eps
---------
-- Sin --
---------
function Sin (X : Float) return Float
with Export, Convention => C, External_Name => SLP.Prefix & "sinf";
-- @llr sin (Float) Special Values
-- The Sin function shall return the following special values:
--
-- C99 special values:
-- Sin (+-0) = +-0
-- Sin (+-INF) = NaN
--
-- @llr sin (Float) Accuracy
-- The Sin function shall return the sine of <X>
-- with the following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 2.0 * Eps
----------
-- Sinh --
----------
function Sinh (X : Float) return Float
with Export, Convention => C, External_Name => SLP.Prefix & "sinhf";
-- @llr sinh (Float) Special Values
-- The Sinh function shall return the following special values:
--
-- C99 Special values:
-- Sinh (+-0) = +-0
-- Sinh (+-INF) = +-INF
--
-- @llr sinh (Float) Accuracy
-- The Sinh function shall return the hyperbolic sine of <X>
-- with the following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 8.0 * Eps
----------
-- Sqrt --
----------
function Sqrt (X : Float) return Float
with Convention => C;
-- @ignore
-- The Sqrt function shall return the following special values:
--
-- C99 special values:
-- Sqrt (+-0) = +-0
-- Sqrt (INF) = INF
-- Sqrt (X) = NaN, for X < 0.0
---------
-- Tan --
---------
function Tan (X : Float) return Float
with Export, Convention => C, External_Name => SLP.Prefix & "tanf";
-- @llr tan (Float) Special Values
-- The Tan function shall return the following special values:
--
-- C99 special values:
-- Tan (+-0) = +0
-- Tan (+-INF) = NaN
--
-- @llr tan (Float) Accuracy
-- The Tan function shall return the tangent of <X>
-- with the following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 4.0 * Eps
----------
-- Tanh --
----------
function Tanh (X : Float) return Float
with Export, Convention => C, External_Name => SLP.Prefix & "tanhf";
-- @llr tanh (Float) Special Values
-- The Tanh function shall return the following special values:
--
-- C99 special values:
-- Tanh (+-0) = +-0
-- Tanh (+-INF) = +-1
--
-- @llr tanh (Float) Accuracy
-- The Tanh function shall return the hyperbolic tangent of <X>
-- with the following accuracy:
--
-- Ada accuracy requirements:
-- MRE <= 8.0 * Eps
private
function Identity (X : Float) return Float is (X);
function Infinity return Float
with Import, Convention => Intrinsic, External_Name => "__builtin_inff";
function NaN return Float is (Infinity - Infinity);
function Exact (X : Long_Long_Float) return Float is (Float (X));
function Epsilon return Float is (Float'Model_Epsilon);
function Maximum_Relative_Error (X : Float) return Float is (0.0 * X);
end System.Libm_Single;
|
-- BinToAsc.Base85
-- Various binary data to ASCII codecs known as Base85, ASCII85 etc
-- Copyright (c) 2015, James Humphry - see LICENSE file for details
package body BinToAsc.Base85 is
Reverse_Alphabet : constant Reverse_Alphabet_Lookup
:= Make_Reverse_Alphabet(Alphabet, True);
type Bin_Frame is mod 2**32;
subtype String_Frame is String(1..5);
--
-- Base85_To_String
--
procedure Reset (C : out Base85_To_String) is
begin
C := (State => Ready,
Next_Index => 0,
Buffer => (others => 0));
end Reset;
procedure Process
(C : in out Base85_To_String;
Input : in Bin;
Output : out String;
Output_Length : out Natural)
is
Input_Frame : Bin_Frame;
Output_Frame : String_Frame;
begin
C.Buffer(C.Next_Index) := Input;
if C.Next_Index /= 3 then
Output := (others => ' ');
Output_Length := 0;
C.Next_Index := C.Next_Index + 1;
else
C.Next_Index := 0;
Input_Frame := Bin_Frame(C.Buffer(0)) * 2**24 or
Bin_Frame(C.Buffer(1)) * 2**16 or
Bin_Frame(C.Buffer(2)) * 2**8 or
Bin_Frame(C.Buffer(3));
for I in reverse 1..5 loop
Output_Frame(I) := Alphabet(Bin(Input_Frame mod 85));
Input_Frame := Input_Frame / 85;
end loop;
Output(Output'First..Output'First + 4) := Output_Frame;
Output_Length := 5;
end if;
end Process;
procedure Process
(C : in out Base85_To_String;
Input : in Bin_Array;
Output : out String;
Output_Length : out Natural)
is
Input_Frame : Bin_Frame;
Output_Frame : String_Frame;
Output_Index : Integer := Output'First;
begin
for I in Input'Range loop
C.Buffer(C.Next_Index) := Input(I);
if C.Next_Index /= 3 then
C.Next_Index := C.Next_Index + 1;
else
C.Next_Index := 0;
Input_Frame := Bin_Frame(C.Buffer(0)) * 2**24 or
Bin_Frame(C.Buffer(1)) * 2**16 or
Bin_Frame(C.Buffer(2)) * 2**8 or
Bin_Frame(C.Buffer(3));
for I in reverse 1..5 loop
Output_Frame(I) := Alphabet(Bin(Input_Frame mod 85));
Input_Frame := Input_Frame / 85;
end loop;
Output (Output_Index .. Output_Index + 4) := Output_Frame;
Output_Index := Output_Index + 5;
end if;
end loop;
Output_Length := Output_Index - Output'First;
end Process;
procedure Complete
(C : in out Base85_To_String;
Output : out String;
Output_Length : out Natural)
is
Input_Frame : Bin_Frame;
Output_Frame : String_Frame;
begin
C.State := Completed;
if C.Next_Index = 0 then
Output_Length := 0;
Output := (others => ' ');
else
C.Buffer(C.Next_Index .. 3) := (others => 0);
Input_Frame := Bin_Frame(C.Buffer(0)) * 2**24 or
Bin_Frame(C.Buffer(1)) * 2**16 or
Bin_Frame(C.Buffer(2)) * 2**8 or
Bin_Frame(C.Buffer(3));
for I in reverse 1..5 loop
Output_Frame(I) := Alphabet(Bin(Input_Frame mod 85));
Input_Frame := Input_Frame / 85;
end loop;
Output(Output'First..Output'First + 4) := Output_Frame;
Output_Length := 5 - (4 - Integer(C.Next_Index));
end if;
end Complete;
function To_String_Private is
new BinToAsc.To_String(Codec => Base85_To_String);
function To_String (Input : in Bin_Array) return String
renames To_String_Private;
--
-- Base85_To_Bin
--
procedure Reset (C : out Base85_To_Bin) is
begin
C := (State => Ready,
Next_Index => 0,
Buffer => (others => 0));
end Reset;
procedure Process (C : in out Base85_To_Bin;
Input : in Character;
Output : out Bin_Array;
Output_Length : out Bin_Array_Index)
is
Input_Bin : Bin;
Output_Frame : Bin_Frame;
MSB_Limit : Bin_Frame;
begin
Input_Bin := Reverse_Alphabet(Input);
if Input_Bin = Invalid_Character_Input then
C.State := Failed;
Output := (others => 0);
Output_Length := 0;
else
C.Buffer(C.Next_Index) := Input_Bin;
if C.Next_Index /= 4 then
Output := (others => 0);
Output_Length := 0;
C.Next_Index := C.Next_Index + 1;
else
C.Next_Index := 0;
Output_Frame := Bin_Frame(C.Buffer(4)) +
Bin_Frame(C.Buffer(3)) * 85 +
Bin_Frame(C.Buffer(2)) * 85 * 85 +
Bin_Frame(C.Buffer(1)) * 85 * 85 * 85;
MSB_Limit := (not Output_Frame) / (85*85*85*85);
if Bin_Frame(C.Buffer(0)) > MSB_Limit then
C.State := Failed;
Output := (others => 0);
Output_Length := 0;
else
Output_Frame := Output_Frame +
Bin_Frame(C.Buffer(0))*85*85*85*85;
Output(Output'First..Output'First+3) :=
(Bin((Output_Frame / 2**24)),
Bin((Output_Frame / 2**16) and 255),
Bin((Output_Frame / 2**8) and 255),
Bin((Output_Frame) and 255),
others => 0);
Output_Length := 4;
end if;
end if;
end if;
end Process;
procedure Process (C : in out Base85_To_Bin;
Input : in String;
Output : out Bin_Array;
Output_Length : out Bin_Array_Index)
is
Input_Bin : Bin;
Output_Frame : Bin_Frame;
MSB_Limit : Bin_Frame;
Output_Index : Bin_Array_Index := Output'First;
begin
for I in Input'Range loop
Input_Bin := Reverse_Alphabet(Input(I));
if Input_Bin = Invalid_Character_Input then
C.State := Failed;
exit;
end if;
C.Buffer(C.Next_Index) := Input_Bin;
if C.Next_Index /= 4 then
C.Next_Index := C.Next_Index + 1;
else
C.Next_Index := 0;
Output_Frame := Bin_Frame(C.Buffer(4)) +
Bin_Frame(C.Buffer(3)) * 85 +
Bin_Frame(C.Buffer(2)) * 85 * 85 +
Bin_Frame(C.Buffer(1)) * 85 * 85 * 85;
MSB_Limit := (not Output_Frame) / (85*85*85*85);
if Bin_Frame(C.Buffer(0)) > MSB_Limit then
C.State := Failed;
exit;
else
Output_Frame := Output_Frame +
Bin_Frame(C.Buffer(0))*85*85*85*85;
Output(Output_Index..Output_Index+3) :=
(
Bin((Output_Frame / 2**24)),
Bin((Output_Frame / 2**16) and 255),
Bin((Output_Frame / 2**8) and 255),
Bin((Output_Frame) and 255)
);
Output_Index := Output_Index + 4;
end if;
end if;
end loop;
if C.State = Failed then
Output := (others => 0);
Output_Length := 0;
else
Output(Output_Index .. Output'Last) := (others => 0);
Output_Length := Output_Index - Output'First;
end if;
end Process;
procedure Complete (C : in out Base85_To_Bin;
Output : out Bin_Array;
Output_Length : out Bin_Array_Index)
is
Output_Frame : Bin_Frame;
MSB_Limit : Bin_Frame;
begin
if C.State = Ready then
if C.Next_Index = 0 then
Output := (others => 0);
Output_Length := 0;
C.State := Completed;
elsif C.Next_Index = 1 then
-- This is an invalid state as one Base85 character is not enough
-- to represent a single byte.
Output := (others => 0);
Output_Length := 0;
C.State := Failed;
else
C.Buffer(C.Next_Index .. 4) := (others => 84);
-- Note padding must be all ones for decoding even though it
-- was all zeros for encoding. Base85 <-> Binary is not a
-- simple rearrangement of bits so high and low bits can interact.
Output_Frame := Bin_Frame(C.Buffer(4)) +
Bin_Frame(C.Buffer(3)) * 85 +
Bin_Frame(C.Buffer(2)) * 85 * 85 +
Bin_Frame(C.Buffer(1)) * 85 * 85 * 85;
MSB_Limit := (not Output_Frame) / (85*85*85*85);
if Bin_Frame(C.Buffer(0)) > MSB_Limit then
Output := (others => 0);
Output_Length := 0;
C.State := Failed;
else
Output_Frame := Output_Frame +
Bin_Frame(C.Buffer(0))*85*85*85*85;
Output :=
(Bin((Output_Frame / 2**24)),
Bin((Output_Frame / 2**16) and 255),
Bin((Output_Frame / 2**8) and 255),
Bin((Output_Frame) and 255),
others => 0);
Output_Length := Bin_Array_Index(C.Next_Index - 1);
C.State := Completed;
end if;
end if;
else
Output := (others => 0);
Output_Length := 0;
end if;
end Complete;
function To_Bin_Private is new BinToAsc.To_Bin(Codec => Base85_To_Bin);
function To_Bin (Input : in String) return Bin_Array renames To_Bin_Private;
begin
-- The following Compile_Time_Error test is silently ignored by GNAT GPL 2015,
-- although it does appear to be a static boolean expression as required by
-- the user guide. It works if converted to a run-time test so it has been
-- left in, in the hope that in a future version of GNAT it will actually be
-- tested.
pragma Warnings (GNATprove, Off, "Compile_Time_Error");
pragma Compile_Time_Error ((for some X in 1..Alphabet'Last =>
(for some Y in 0..X-1 =>
Alphabet(Y) = Alphabet(X)
)
),
"Duplicate letter in alphabet for Base85 codec.");
pragma Warnings (GNATprove, On, "Compile_Time_Error");
end BinToAsc.Base85;
|
-- WORDS, a Latin dictionary, by Colonel William Whitaker (USAF, Retired)
--
-- Copyright William A. Whitaker (1936–2010)
--
-- This is a free program, which means it is proper to copy it and pass
-- it on to your friends. Consider it a developmental item for which
-- there is no charge. However, just for form, it is Copyrighted
-- (c). Permission is hereby freely given for any and all use of program
-- and data. You can sell it as your own, but at least tell me.
--
-- This version is distributed without obligation, but the developer
-- would appreciate comments and suggestions.
--
-- All parts of the WORDS system, source code and data files, are made freely
-- available to anyone who wishes to use them, for whatever purpose.
package body Latin_Utils.Latin_File_Names is
function Add_File_Name_Extension (Name, Extension : String) return String is
-- This is the version that Creates a DOS file name
-- One that has a name, a '.', and an extension no longer than 3 chars
-- Arbitarily, we also truncate the NAME to 8 Characters
-- To port to another system, one needs to do this function appropriately
Name_Length : Integer := Name'Length;
Extension_Length : Integer := Extension'Length;
begin
if Name_Length >= 8 then
Name_Length := 8;
end if;
if Extension'Length >= 3 then
Extension_Length := 3;
end if;
return Name (Name'First .. Name_Length) & '.'
& Extension (Extension'First .. Extension_Length);
end Add_File_Name_Extension;
end Latin_Utils.Latin_File_Names;
|
-- Copyright 2015-2016 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Bar; use Bar;
procedure Foo_O525_013 is
R : Rec_Type;
I : Enum_Type := F (R);
begin
null;
end Foo_O525_013;
|
generic
type Element_Type is private;
-- The type of picture elements within the input.
type Element_Matrix is
array (Natural range <>, Natural range <>) of Element_Type;
-- The array type we'll take as input and provide as output.
-- We treat these as a toroidal surface which infinitely tiles.
with function "<" (E1, E2 : Element_Type) return Boolean is <>;
with function "=" (E1, E2 : Element_Type) return Boolean is <>;
-- Because the element type might be a record, we don't
-- constrain it to be discrete, but for various purposes
-- we at least require it to be orderable.
package WFC is
subtype Tile_ID is Positive;
-- A tile represents a part of the input array as a submatrix of elements.
-- Because passing around arrays by value is
-- more expensive, instead we represent tiles as
-- indices into arrays of their properties, for simplicity.
type Tile_Element_Array is
array (Tile_ID range <>) of Element_Type;
-- Mapping the id to the tile itself is somewhat
-- more than required, as each tile contributes only one
-- pixel to the output. Here, we map each tile to
-- the pixel it will contribute. The adjacency information
-- will guarantee their combined behavior is as desired.
type Frequency_Array is
array (Tile_ID range <>) of Natural;
-- Mapping each tile to its frequency in the input
type Adjacency_Direction is
(Upwards, Downwards, Leftwards, Rightwards);
-- The directions in which we record tile adjacency information.
type Adjacency is
array (Adjacency_Direction) of Boolean
with Pack;
-- A bitvector recording for each direction
-- whether there is an adjacency.
type Adjacency_Matrix is
array (Tile_ID range <>, Tile_ID range <>) of Adjacency
with Pack;
-- For every pair of tiles, we store whether they are
-- allowed to be adjacent to each other, in each direction.
-- For efficiency we also pack together the bitvectors;
-- when the number of tiles is large this still becomes the majority
-- of the data we need to store, even when each adjacency
-- is stored in one bit.
type Small_Integer is mod 2 ** 16;
-- This only needs to be large enough to hold a number
-- as high as a particular instance's Num_Tiles value.
--
-- The necessary size of adjacency matrices in the general case
-- becomes far larger than is reasonable long before
-- the number of tiles reaches 65536, but more than 255 tiles
-- is possible, so we just use two bytes to count enablers.
type Enablers_By_Direction is
array (Adjacency_Direction) of Small_Integer
with Pack;
type Enabler_Counts is
array (Tile_ID range <>) of Enablers_By_Direction;
-- The number of "enablers" of a particular tile
-- in a direction is the number of other tiles which
-- can be adjacent in that direction.
type Instance (Num_Tiles : Natural) is tagged record
Tile_Elements : Tile_Element_Array (1 .. Num_Tiles);
Frequency_Total : Natural;
Frequencies : Frequency_Array (1 .. Num_Tiles);
Adjacencies : Adjacency_Matrix (1 .. Num_Tiles, 1 .. Num_Tiles);
Enablers : Enabler_Counts (1 .. Num_Tiles);
end record;
-- All information we need to record about a particular input
-- in order to generate similar outputs via wave function collapse.
function Initialize_From_Sample
( Sample : in Element_Matrix;
Include_Rotations : in Boolean := False;
Include_Reflections : in Boolean := False;
N, M : in Positive := 2
) return Instance;
-- Create an instantiation representing the empirical tile and frequency
-- information from a sample matrix provided. If desired,
-- this information will be combined with rotated and reflected
-- versions of the tiles for more variety. The size of each tile
-- is specified with the N and M parameters.
function Collapse_Within
(Parameters : in Instance; World : out Element_Matrix) return Boolean;
-- Given an instance and a matrix to populate, attempt a wave function
-- collapse within the space with the tiles from the parameters.
-- This is an operation which is (although likely) not guaranteed to
-- succeed, and so the return value indicates whether it was successful.
--
-- If this fails many times it may indicate that the tileset is unable
-- to seamlessly tile a matrix of the size given; this may happen if
-- the size of a single tile is larger than the matrix especially, or
-- if every tile in the sample used to create the instance was unique,
-- leading to a tileset which can only tile spaces with size equal
-- to the sample modulo its dimensions.
--
-- In such cases the recommendation is simply to use larger samples,
-- or decrease the N/M tile parameter until there is wider representation
-- of different tiles and adjacencies.
generic
type X_Dim is range <>;
type Y_Dim is range <>;
package Extended_Interfaces is
-- If more control over generation, data structures, etc.
-- is required, then the extended interfaces package
-- provides an way of allowing more internals of the collapse
-- algorithm to be inspected or configured as need be.
type Collapse_Info is interface;
-- For the more generic collapsing procedure, we allow returning
-- information to the user by querying an instance of this type.
function Is_Possible
( Info : in Collapse_Info;
X : in X_Dim;
Y : in Y_Dim;
E : in Element_Type) return Boolean is abstract;
function Is_Possible
( Info : in Collapse_Info;
X : in X_Dim;
Y : in Y_Dim;
T : in Tile_ID) return Boolean is abstract;
-- Determine whether it's possible for a particular element or
-- tile_id to occur at the position specified.
type Collapse_Settings is interface and Collapse_Info;
-- This type not only allows querying information
-- about what is possible, but also configuring
-- certain requirements within the
procedure Require
(Info : in Collapse_Settings;
X : in X_Dim;
Y : in Y_Dim;
E : in Element_Type) is abstract;
procedure Require
(Info : in Collapse_Settings;
X : in X_Dim;
Y : in Y_Dim;
T : in Tile_ID) is abstract;
-- inject requirements for certain positions to have
-- certain tile or element values.
generic
with procedure Set_Resulting_Element
(X : X_Dim; Y : Y_Dim; Element : Element_Type) is <>;
with procedure Set_Initial_Requirements
(Info : in Collapse_Settings'Class) is null;
with procedure Upon_Collapse
(X : X_Dim; Y : Y_Dim; Info : in Collapse_Info'Class) is null;
with procedure Upon_Removal
(X : X_Dim; Y : Y_Dim; Info : in Collapse_Info'Class) is null;
function Generic_Collapse_Within (Parameters : in Instance) return Boolean;
end;
end;
|
-----------------------------------------------------------------------
-- atlas-microblog -- Module microblog
-- Copyright (C) 2012 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 Atlas.Microblog is
end Atlas.Microblog;
|
--
-- Copyright (C) 2017, AdaCore
--
-- This spec has been automatically generated from STM32F40x.svd
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package Interfaces.STM32.USART is
pragma Preelaborate;
pragma No_Elaboration_Code_All;
---------------
-- Registers --
---------------
subtype SR_PE_Field is Interfaces.STM32.Bit;
subtype SR_FE_Field is Interfaces.STM32.Bit;
subtype SR_NF_Field is Interfaces.STM32.Bit;
subtype SR_ORE_Field is Interfaces.STM32.Bit;
subtype SR_IDLE_Field is Interfaces.STM32.Bit;
subtype SR_RXNE_Field is Interfaces.STM32.Bit;
subtype SR_TC_Field is Interfaces.STM32.Bit;
subtype SR_TXE_Field is Interfaces.STM32.Bit;
subtype SR_LBD_Field is Interfaces.STM32.Bit;
-- Status register
type SR_Register is record
-- Read-only. Parity error
PE : SR_PE_Field := 16#0#;
-- Read-only. Framing error
FE : SR_FE_Field := 16#0#;
-- Read-only. Noise detected flag
NF : SR_NF_Field := 16#0#;
-- Read-only. Overrun error
ORE : SR_ORE_Field := 16#0#;
-- Read-only. IDLE line detected
IDLE : SR_IDLE_Field := 16#0#;
-- Read data register not empty
RXNE : SR_RXNE_Field := 16#0#;
-- Transmission complete
TC : SR_TC_Field := 16#0#;
-- Read-only. Transmit data register empty
TXE : SR_TXE_Field := 16#0#;
-- LIN break detection flag
LBD : SR_LBD_Field := 16#0#;
-- unspecified
Reserved_9_31 : Interfaces.STM32.UInt23 := 16#6000#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SR_Register use record
PE at 0 range 0 .. 0;
FE at 0 range 1 .. 1;
NF at 0 range 2 .. 2;
ORE at 0 range 3 .. 3;
IDLE at 0 range 4 .. 4;
RXNE at 0 range 5 .. 5;
TC at 0 range 6 .. 6;
TXE at 0 range 7 .. 7;
LBD at 0 range 8 .. 8;
Reserved_9_31 at 0 range 9 .. 31;
end record;
subtype DR_DR_Field is Interfaces.STM32.UInt9;
-- Data register
type DR_Register is record
-- Data value
DR : DR_DR_Field := 16#0#;
-- unspecified
Reserved_9_31 : Interfaces.STM32.UInt23 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DR_Register use record
DR at 0 range 0 .. 8;
Reserved_9_31 at 0 range 9 .. 31;
end record;
subtype BRR_DIV_Fraction_Field is Interfaces.STM32.UInt4;
subtype BRR_DIV_Mantissa_Field is Interfaces.STM32.UInt12;
-- Baud rate register
type BRR_Register is record
-- fraction of USARTDIV
DIV_Fraction : BRR_DIV_Fraction_Field := 16#0#;
-- mantissa of USARTDIV
DIV_Mantissa : BRR_DIV_Mantissa_Field := 16#0#;
-- unspecified
Reserved_16_31 : Interfaces.STM32.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BRR_Register use record
DIV_Fraction at 0 range 0 .. 3;
DIV_Mantissa at 0 range 4 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype CR1_SBK_Field is Interfaces.STM32.Bit;
subtype CR1_RWU_Field is Interfaces.STM32.Bit;
subtype CR1_RE_Field is Interfaces.STM32.Bit;
subtype CR1_TE_Field is Interfaces.STM32.Bit;
subtype CR1_IDLEIE_Field is Interfaces.STM32.Bit;
subtype CR1_RXNEIE_Field is Interfaces.STM32.Bit;
subtype CR1_TCIE_Field is Interfaces.STM32.Bit;
subtype CR1_TXEIE_Field is Interfaces.STM32.Bit;
subtype CR1_PEIE_Field is Interfaces.STM32.Bit;
subtype CR1_PS_Field is Interfaces.STM32.Bit;
subtype CR1_PCE_Field is Interfaces.STM32.Bit;
subtype CR1_WAKE_Field is Interfaces.STM32.Bit;
subtype CR1_M_Field is Interfaces.STM32.Bit;
subtype CR1_UE_Field is Interfaces.STM32.Bit;
subtype CR1_OVER8_Field is Interfaces.STM32.Bit;
-- Control register 1
type CR1_Register is record
-- Send break
SBK : CR1_SBK_Field := 16#0#;
-- Receiver wakeup
RWU : CR1_RWU_Field := 16#0#;
-- Receiver enable
RE : CR1_RE_Field := 16#0#;
-- Transmitter enable
TE : CR1_TE_Field := 16#0#;
-- IDLE interrupt enable
IDLEIE : CR1_IDLEIE_Field := 16#0#;
-- RXNE interrupt enable
RXNEIE : CR1_RXNEIE_Field := 16#0#;
-- Transmission complete interrupt enable
TCIE : CR1_TCIE_Field := 16#0#;
-- TXE interrupt enable
TXEIE : CR1_TXEIE_Field := 16#0#;
-- PE interrupt enable
PEIE : CR1_PEIE_Field := 16#0#;
-- Parity selection
PS : CR1_PS_Field := 16#0#;
-- Parity control enable
PCE : CR1_PCE_Field := 16#0#;
-- Wakeup method
WAKE : CR1_WAKE_Field := 16#0#;
-- Word length
M : CR1_M_Field := 16#0#;
-- USART enable
UE : CR1_UE_Field := 16#0#;
-- unspecified
Reserved_14_14 : Interfaces.STM32.Bit := 16#0#;
-- Oversampling mode
OVER8 : CR1_OVER8_Field := 16#0#;
-- unspecified
Reserved_16_31 : Interfaces.STM32.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR1_Register use record
SBK at 0 range 0 .. 0;
RWU at 0 range 1 .. 1;
RE at 0 range 2 .. 2;
TE at 0 range 3 .. 3;
IDLEIE at 0 range 4 .. 4;
RXNEIE at 0 range 5 .. 5;
TCIE at 0 range 6 .. 6;
TXEIE at 0 range 7 .. 7;
PEIE at 0 range 8 .. 8;
PS at 0 range 9 .. 9;
PCE at 0 range 10 .. 10;
WAKE at 0 range 11 .. 11;
M at 0 range 12 .. 12;
UE at 0 range 13 .. 13;
Reserved_14_14 at 0 range 14 .. 14;
OVER8 at 0 range 15 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype CR2_ADD_Field is Interfaces.STM32.UInt4;
subtype CR2_LBDL_Field is Interfaces.STM32.Bit;
subtype CR2_LBDIE_Field is Interfaces.STM32.Bit;
subtype CR2_STOP_Field is Interfaces.STM32.UInt2;
subtype CR2_LINEN_Field is Interfaces.STM32.Bit;
-- Control register 2
type CR2_Register is record
-- Address of the USART node
ADD : CR2_ADD_Field := 16#0#;
-- unspecified
Reserved_4_4 : Interfaces.STM32.Bit := 16#0#;
-- lin break detection length
LBDL : CR2_LBDL_Field := 16#0#;
-- LIN break detection interrupt enable
LBDIE : CR2_LBDIE_Field := 16#0#;
-- unspecified
Reserved_7_11 : Interfaces.STM32.UInt5 := 16#0#;
-- STOP bits
STOP : CR2_STOP_Field := 16#0#;
-- LIN mode enable
LINEN : CR2_LINEN_Field := 16#0#;
-- unspecified
Reserved_15_31 : Interfaces.STM32.UInt17 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR2_Register use record
ADD at 0 range 0 .. 3;
Reserved_4_4 at 0 range 4 .. 4;
LBDL at 0 range 5 .. 5;
LBDIE at 0 range 6 .. 6;
Reserved_7_11 at 0 range 7 .. 11;
STOP at 0 range 12 .. 13;
LINEN at 0 range 14 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
subtype CR3_EIE_Field is Interfaces.STM32.Bit;
subtype CR3_IREN_Field is Interfaces.STM32.Bit;
subtype CR3_IRLP_Field is Interfaces.STM32.Bit;
subtype CR3_HDSEL_Field is Interfaces.STM32.Bit;
subtype CR3_DMAR_Field is Interfaces.STM32.Bit;
subtype CR3_DMAT_Field is Interfaces.STM32.Bit;
subtype CR3_ONEBIT_Field is Interfaces.STM32.Bit;
-- Control register 3
type CR3_Register is record
-- Error interrupt enable
EIE : CR3_EIE_Field := 16#0#;
-- IrDA mode enable
IREN : CR3_IREN_Field := 16#0#;
-- IrDA low-power
IRLP : CR3_IRLP_Field := 16#0#;
-- Half-duplex selection
HDSEL : CR3_HDSEL_Field := 16#0#;
-- unspecified
Reserved_4_5 : Interfaces.STM32.UInt2 := 16#0#;
-- DMA enable receiver
DMAR : CR3_DMAR_Field := 16#0#;
-- DMA enable transmitter
DMAT : CR3_DMAT_Field := 16#0#;
-- unspecified
Reserved_8_10 : Interfaces.STM32.UInt3 := 16#0#;
-- One sample bit method enable
ONEBIT : CR3_ONEBIT_Field := 16#0#;
-- unspecified
Reserved_12_31 : Interfaces.STM32.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR3_Register use record
EIE at 0 range 0 .. 0;
IREN at 0 range 1 .. 1;
IRLP at 0 range 2 .. 2;
HDSEL at 0 range 3 .. 3;
Reserved_4_5 at 0 range 4 .. 5;
DMAR at 0 range 6 .. 6;
DMAT at 0 range 7 .. 7;
Reserved_8_10 at 0 range 8 .. 10;
ONEBIT at 0 range 11 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype SR_CTS_Field is Interfaces.STM32.Bit;
-- Status register
type SR_Register_1 is record
-- Read-only. Parity error
PE : SR_PE_Field := 16#0#;
-- Read-only. Framing error
FE : SR_FE_Field := 16#0#;
-- Read-only. Noise detected flag
NF : SR_NF_Field := 16#0#;
-- Read-only. Overrun error
ORE : SR_ORE_Field := 16#0#;
-- Read-only. IDLE line detected
IDLE : SR_IDLE_Field := 16#0#;
-- Read data register not empty
RXNE : SR_RXNE_Field := 16#0#;
-- Transmission complete
TC : SR_TC_Field := 16#0#;
-- Read-only. Transmit data register empty
TXE : SR_TXE_Field := 16#0#;
-- LIN break detection flag
LBD : SR_LBD_Field := 16#0#;
-- CTS flag
CTS : SR_CTS_Field := 16#0#;
-- unspecified
Reserved_10_31 : Interfaces.STM32.UInt22 := 16#3000#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SR_Register_1 use record
PE at 0 range 0 .. 0;
FE at 0 range 1 .. 1;
NF at 0 range 2 .. 2;
ORE at 0 range 3 .. 3;
IDLE at 0 range 4 .. 4;
RXNE at 0 range 5 .. 5;
TC at 0 range 6 .. 6;
TXE at 0 range 7 .. 7;
LBD at 0 range 8 .. 8;
CTS at 0 range 9 .. 9;
Reserved_10_31 at 0 range 10 .. 31;
end record;
subtype CR2_LBCL_Field is Interfaces.STM32.Bit;
subtype CR2_CPHA_Field is Interfaces.STM32.Bit;
subtype CR2_CPOL_Field is Interfaces.STM32.Bit;
subtype CR2_CLKEN_Field is Interfaces.STM32.Bit;
-- Control register 2
type CR2_Register_1 is record
-- Address of the USART node
ADD : CR2_ADD_Field := 16#0#;
-- unspecified
Reserved_4_4 : Interfaces.STM32.Bit := 16#0#;
-- lin break detection length
LBDL : CR2_LBDL_Field := 16#0#;
-- LIN break detection interrupt enable
LBDIE : CR2_LBDIE_Field := 16#0#;
-- unspecified
Reserved_7_7 : Interfaces.STM32.Bit := 16#0#;
-- Last bit clock pulse
LBCL : CR2_LBCL_Field := 16#0#;
-- Clock phase
CPHA : CR2_CPHA_Field := 16#0#;
-- Clock polarity
CPOL : CR2_CPOL_Field := 16#0#;
-- Clock enable
CLKEN : CR2_CLKEN_Field := 16#0#;
-- STOP bits
STOP : CR2_STOP_Field := 16#0#;
-- LIN mode enable
LINEN : CR2_LINEN_Field := 16#0#;
-- unspecified
Reserved_15_31 : Interfaces.STM32.UInt17 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR2_Register_1 use record
ADD at 0 range 0 .. 3;
Reserved_4_4 at 0 range 4 .. 4;
LBDL at 0 range 5 .. 5;
LBDIE at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
LBCL at 0 range 8 .. 8;
CPHA at 0 range 9 .. 9;
CPOL at 0 range 10 .. 10;
CLKEN at 0 range 11 .. 11;
STOP at 0 range 12 .. 13;
LINEN at 0 range 14 .. 14;
Reserved_15_31 at 0 range 15 .. 31;
end record;
subtype CR3_NACK_Field is Interfaces.STM32.Bit;
subtype CR3_SCEN_Field is Interfaces.STM32.Bit;
subtype CR3_RTSE_Field is Interfaces.STM32.Bit;
subtype CR3_CTSE_Field is Interfaces.STM32.Bit;
subtype CR3_CTSIE_Field is Interfaces.STM32.Bit;
-- Control register 3
type CR3_Register_1 is record
-- Error interrupt enable
EIE : CR3_EIE_Field := 16#0#;
-- IrDA mode enable
IREN : CR3_IREN_Field := 16#0#;
-- IrDA low-power
IRLP : CR3_IRLP_Field := 16#0#;
-- Half-duplex selection
HDSEL : CR3_HDSEL_Field := 16#0#;
-- Smartcard NACK enable
NACK : CR3_NACK_Field := 16#0#;
-- Smartcard mode enable
SCEN : CR3_SCEN_Field := 16#0#;
-- DMA enable receiver
DMAR : CR3_DMAR_Field := 16#0#;
-- DMA enable transmitter
DMAT : CR3_DMAT_Field := 16#0#;
-- RTS enable
RTSE : CR3_RTSE_Field := 16#0#;
-- CTS enable
CTSE : CR3_CTSE_Field := 16#0#;
-- CTS interrupt enable
CTSIE : CR3_CTSIE_Field := 16#0#;
-- One sample bit method enable
ONEBIT : CR3_ONEBIT_Field := 16#0#;
-- unspecified
Reserved_12_31 : Interfaces.STM32.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR3_Register_1 use record
EIE at 0 range 0 .. 0;
IREN at 0 range 1 .. 1;
IRLP at 0 range 2 .. 2;
HDSEL at 0 range 3 .. 3;
NACK at 0 range 4 .. 4;
SCEN at 0 range 5 .. 5;
DMAR at 0 range 6 .. 6;
DMAT at 0 range 7 .. 7;
RTSE at 0 range 8 .. 8;
CTSE at 0 range 9 .. 9;
CTSIE at 0 range 10 .. 10;
ONEBIT at 0 range 11 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype GTPR_PSC_Field is Interfaces.STM32.Byte;
subtype GTPR_GT_Field is Interfaces.STM32.Byte;
-- Guard time and prescaler register
type GTPR_Register is record
-- Prescaler value
PSC : GTPR_PSC_Field := 16#0#;
-- Guard time value
GT : GTPR_GT_Field := 16#0#;
-- unspecified
Reserved_16_31 : Interfaces.STM32.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for GTPR_Register use record
PSC at 0 range 0 .. 7;
GT at 0 range 8 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Universal synchronous asynchronous receiver transmitter
type UART4_Peripheral is record
-- Status register
SR : aliased SR_Register;
-- Data register
DR : aliased DR_Register;
-- Baud rate register
BRR : aliased BRR_Register;
-- Control register 1
CR1 : aliased CR1_Register;
-- Control register 2
CR2 : aliased CR2_Register;
-- Control register 3
CR3 : aliased CR3_Register;
end record
with Volatile;
for UART4_Peripheral use record
SR at 16#0# range 0 .. 31;
DR at 16#4# range 0 .. 31;
BRR at 16#8# range 0 .. 31;
CR1 at 16#C# range 0 .. 31;
CR2 at 16#10# range 0 .. 31;
CR3 at 16#14# range 0 .. 31;
end record;
-- Universal synchronous asynchronous receiver transmitter
UART4_Periph : aliased UART4_Peripheral
with Import, Address => System'To_Address (16#40004C00#);
-- Universal synchronous asynchronous receiver transmitter
UART5_Periph : aliased UART4_Peripheral
with Import, Address => System'To_Address (16#40005000#);
-- Universal synchronous asynchronous receiver transmitter
type USART1_Peripheral is record
-- Status register
SR : aliased SR_Register_1;
-- Data register
DR : aliased DR_Register;
-- Baud rate register
BRR : aliased BRR_Register;
-- Control register 1
CR1 : aliased CR1_Register;
-- Control register 2
CR2 : aliased CR2_Register_1;
-- Control register 3
CR3 : aliased CR3_Register_1;
-- Guard time and prescaler register
GTPR : aliased GTPR_Register;
end record
with Volatile;
for USART1_Peripheral use record
SR at 16#0# range 0 .. 31;
DR at 16#4# range 0 .. 31;
BRR at 16#8# range 0 .. 31;
CR1 at 16#C# range 0 .. 31;
CR2 at 16#10# range 0 .. 31;
CR3 at 16#14# range 0 .. 31;
GTPR at 16#18# range 0 .. 31;
end record;
-- Universal synchronous asynchronous receiver transmitter
USART1_Periph : aliased USART1_Peripheral
with Import, Address => System'To_Address (16#40011000#);
-- Universal synchronous asynchronous receiver transmitter
USART2_Periph : aliased USART1_Peripheral
with Import, Address => System'To_Address (16#40004400#);
-- Universal synchronous asynchronous receiver transmitter
USART3_Periph : aliased USART1_Peripheral
with Import, Address => System'To_Address (16#40004800#);
-- Universal synchronous asynchronous receiver transmitter
USART6_Periph : aliased USART1_Peripheral
with Import, Address => System'To_Address (16#40011400#);
end Interfaces.STM32.USART;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- M L I B . T G T --
-- (GNU/Linux Version) --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 2001, Ada Core Technologies, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
-- --
------------------------------------------------------------------------------
-- This package provides a set of target dependent routines to build
-- static, dynamic and shared libraries.
-- This is the GNU/Linux version of the body.
with Ada.Characters.Handling; use Ada.Characters.Handling;
with GNAT.Directory_Operations; use GNAT.Directory_Operations;
with MLib.Fil;
with MLib.Utl;
with Namet; use Namet;
with Opt;
with Osint; use Osint;
with Output; use Output;
with System;
package body MLib.Tgt is
use GNAT;
use MLib;
-- ??? serious lack of comments below, all these declarations need to
-- be commented, none are:
package Files renames MLib.Fil;
package Tools renames MLib.Utl;
Args : Argument_List_Access := new Argument_List (1 .. 20);
Last_Arg : Natural := 0;
Cp : constant String_Access := Locate_Exec_On_Path ("cp");
Force : constant String_Access := new String'("-f");
procedure Add_Arg (Arg : String);
-------------
-- Add_Arg --
-------------
procedure Add_Arg (Arg : String) is
begin
if Last_Arg = Args'Last then
declare
New_Args : constant Argument_List_Access :=
new Argument_List (1 .. Args'Last * 2);
begin
New_Args (Args'Range) := Args.all;
Args := New_Args;
end;
end if;
Last_Arg := Last_Arg + 1;
Args (Last_Arg) := new String'(Arg);
end Add_Arg;
-----------------
-- Archive_Ext --
-----------------
function Archive_Ext return String is
begin
return "a";
end Archive_Ext;
-----------------
-- Base_Option --
-----------------
function Base_Option return String is
begin
return "";
end Base_Option;
---------------------------
-- Build_Dynamic_Library --
---------------------------
procedure Build_Dynamic_Library
(Ofiles : Argument_List;
Foreign : Argument_List;
Afiles : Argument_List;
Options : Argument_List;
Lib_Filename : String;
Lib_Dir : String;
Lib_Address : String := "";
Lib_Version : String := "";
Relocatable : Boolean := False)
is
Lib_File : constant String :=
Lib_Dir & Directory_Separator & "lib" &
Files.Ext_To (Lib_Filename, DLL_Ext);
use type Argument_List;
use type String_Access;
Version_Arg : String_Access;
Symbolic_Link_Needed : Boolean := False;
begin
if Opt.Verbose_Mode then
Write_Str ("building relocatable shared library ");
Write_Line (Lib_File);
end if;
if Lib_Version = "" then
Tools.Gcc
(Output_File => Lib_File,
Objects => Ofiles,
Options => Options);
else
Version_Arg := new String'("-Wl,-soname," & Lib_Version);
if Is_Absolute_Path (Lib_Version) then
Tools.Gcc
(Output_File => Lib_Version,
Objects => Ofiles,
Options => Options & Version_Arg);
Symbolic_Link_Needed := Lib_Version /= Lib_File;
else
Tools.Gcc
(Output_File => Lib_Dir & Directory_Separator & Lib_Version,
Objects => Ofiles,
Options => Options & Version_Arg);
Symbolic_Link_Needed :=
Lib_Dir & Directory_Separator & Lib_Version /= Lib_File;
end if;
if Symbolic_Link_Needed then
declare
Success : Boolean;
Oldpath : String (1 .. Lib_Version'Length + 1);
Newpath : String (1 .. Lib_File'Length + 1);
Result : Integer;
function Symlink
(Oldpath : System.Address;
Newpath : System.Address)
return Integer;
pragma Import (C, Symlink, "__gnat_symlink");
begin
Oldpath (1 .. Lib_Version'Length) := Lib_Version;
Oldpath (Oldpath'Last) := ASCII.NUL;
Newpath (1 .. Lib_File'Length) := Lib_File;
Newpath (Newpath'Last) := ASCII.NUL;
Delete_File (Lib_File, Success);
Result := Symlink (Oldpath'Address, Newpath'Address);
end;
end if;
end if;
end Build_Dynamic_Library;
--------------------
-- Copy_ALI_Files --
--------------------
procedure Copy_ALI_Files
(From : Name_Id;
To : Name_Id)
is
Dir : Dir_Type;
Name : String (1 .. 1_000);
Last : Natural;
Success : Boolean;
From_Dir : constant String := Get_Name_String (From);
To_Dir : constant String_Access :=
new String'(Get_Name_String (To));
begin
Last_Arg := 0;
Open (Dir, From_Dir);
loop
Read (Dir, Name, Last);
exit when Last = 0;
if Last > 4
and then
To_Lower (Name (Last - 3 .. Last)) = ".ali"
then
Add_Arg (From_Dir & Directory_Separator & Name (1 .. Last));
end if;
end loop;
if Last_Arg /= 0 then
if not Opt.Quiet_Output then
Write_Str ("cp -f ");
for J in 1 .. Last_Arg loop
Write_Str (Args (J).all);
Write_Char (' ');
end loop;
Write_Line (To_Dir.all);
end if;
Spawn (Cp.all,
Force & Args (1 .. Last_Arg) & To_Dir,
Success);
if not Success then
Fail ("could not copy ALI files to library dir");
end if;
end if;
end Copy_ALI_Files;
-------------------------
-- Default_DLL_Address --
-------------------------
function Default_DLL_Address return String is
begin
return "";
end Default_DLL_Address;
-------------
-- DLL_Ext --
-------------
function DLL_Ext return String is
begin
return "so";
end DLL_Ext;
--------------------
-- Dynamic_Option --
--------------------
function Dynamic_Option return String is
begin
return "-shared";
end Dynamic_Option;
-------------------
-- Is_Object_Ext --
-------------------
function Is_Object_Ext (Ext : String) return Boolean is
begin
return Ext = ".o";
end Is_Object_Ext;
--------------
-- Is_C_Ext --
--------------
function Is_C_Ext (Ext : String) return Boolean is
begin
return Ext = ".c";
end Is_C_Ext;
--------------------
-- Is_Archive_Ext --
--------------------
function Is_Archive_Ext (Ext : String) return Boolean is
begin
return Ext = ".a" or else Ext = ".so";
end Is_Archive_Ext;
-------------
-- Libgnat --
-------------
function Libgnat return String is
begin
return "libgnat.a";
end Libgnat;
-----------------------------
-- Libraries_Are_Supported --
-----------------------------
function Libraries_Are_Supported return Boolean is
begin
return True;
end Libraries_Are_Supported;
--------------------------------
-- Linker_Library_Path_Option --
--------------------------------
function Linker_Library_Path_Option
(Directory : String)
return String_Access
is
begin
return new String'("-Wl,-rpath," & Directory);
end Linker_Library_Path_Option;
----------------
-- Object_Ext --
----------------
function Object_Ext return String is
begin
return "o";
end Object_Ext;
----------------
-- PIC_Option --
----------------
function PIC_Option return String is
begin
return "-fPIC";
end PIC_Option;
end MLib.Tgt;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . P A C K _ 6 1 --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
--
--
--
--
--
--
--
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- Handling of packed arrays with Component_Size = 61
package System.Pack_61 is
pragma Preelaborate;
Bits : constant := 61;
type Bits_61 is mod 2 ** Bits;
for Bits_61'Size use Bits;
function Get_61 (Arr : System.Address; N : Natural) return Bits_61;
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is extracted and returned.
procedure Set_61 (Arr : System.Address; N : Natural; E : Bits_61);
-- Arr is the address of the packed array, N is the zero-based
-- subscript. This element is set to the given value.
end System.Pack_61;
|
-- Copyright 2019 Simon Symeonidis (psyomn)
--
-- 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 AUnit;
with AUnit.Test_Fixtures;
package Common_Utils_Test is
type Test is new AUnit.Test_Fixtures.Test_Fixture with null record;
procedure Test_Integer_To_Trimmed_String (T : in out Test);
procedure Test_Header_String (T : in out Test);
procedure Test_Header_String_Integer (T : in out Test);
procedure Test_Empty_String (T : in out Test);
procedure Test_Empty_String_Range (T : in out Test);
procedure Test_Concat_Null_String (T : in out Test);
end Common_Utils_Test;
|
-------------------------------------------------------------------------------
-- This file is part of libsparkcrypto.
--
-- @author Alexander Senier
-- @date 2019-01-24
--
-- Copyright (C) 2018 Componolit GmbH
-- 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 nor the names of its contributors may be used
-- to endorse or promote products derived from this software without
-- specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS
-- BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with LSC.Internal.RIPEMD160;
with LSC.Internal.Convert_Hash;
package body LSC.RIPEMD160_Generic
is
----------
-- Hash --
----------
function Hash (Message : Message_Type) return Hash_Type
is
function Hash_Internal is new Internal.Convert_Hash.Hash
(64,
Message_Index_Type,
Message_Elem_Type,
Message_Type,
Hash_Index_Type,
Hash_Elem_Type,
Hash_Type,
Internal.RIPEMD160.Context_Type,
Internal.RIPEMD160.Block_Type,
Internal.RIPEMD160.Block_Length_Type,
Internal.RIPEMD160.Hash_Type,
Internal.RIPEMD160.Context_Init,
Internal.RIPEMD160.Context_Update,
Internal.RIPEMD160.Context_Finalize,
Internal.RIPEMD160.Get_Hash);
begin
return Hash_Internal (Message);
end Hash;
end LSC.RIPEMD160_Generic;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- A usage dependency among classifiers indicating that operations on the
-- client create instances of the supplier.
------------------------------------------------------------------------------
limited with AMF.UML.Usages;
package AMF.Standard_Profile_L2.Instantiates is
pragma Preelaborate;
type Standard_Profile_L2_Instantiate is limited interface;
type Standard_Profile_L2_Instantiate_Access is
access all Standard_Profile_L2_Instantiate'Class;
for Standard_Profile_L2_Instantiate_Access'Storage_Size use 0;
not overriding function Get_Base_Usage
(Self : not null access constant Standard_Profile_L2_Instantiate)
return AMF.UML.Usages.UML_Usage_Access is abstract;
-- Getter of Instantiate::base_Usage.
--
not overriding procedure Set_Base_Usage
(Self : not null access Standard_Profile_L2_Instantiate;
To : AMF.UML.Usages.UML_Usage_Access) is abstract;
-- Setter of Instantiate::base_Usage.
--
end AMF.Standard_Profile_L2.Instantiates;
|
-- NORX
-- an Ada implementation of the NORX Authenticated Encryption Algorithm
-- created by Jean-Philippe Aumasson, Philipp Jovanovic and Samuel Neves
-- Copyright (c) 2016-2017, James Humphry - see LICENSE file for details
pragma Restrictions(No_Implementation_Attributes,
No_Implementation_Units,
No_Obsolescent_Features);
with NORX.Compare_Tags;
package body NORX is
-- ***
-- Constants and types used internally
-- ***
p : constant Positive := 1; -- This implementation only supports parallelism
-- of degree 1 i.e. only serial NORX
Bytes : constant Storage_Offset := Storage_Offset(w / 8);
Rate_Bytes_SO : constant Storage_Offset := Storage_Offset(r / 8);
Rate_Words : constant Integer := r / w;
Key_Words : constant Integer := k / w;
Tag_Words : constant Integer := t / w;
Nonce_Words : constant Integer := n / w;
type Domains is (Header, Payload, Trailer, Tag, Branching, Merging);
Domain_Separation : constant array (Domains range <>) of Word :=
(Header => 16#01#,
Payload => 16#02#,
Trailer => 16#03#,
Tag => 16#04#,
Branching => 16#10#,
Merging => 16#20#);
subtype Rate_Storage_Array is Storage_Array(1..Rate_Bytes_SO);
-- The initialisation constants
u : State
with Constant_After_Elaboration;
-- ***
-- Implementation of the the permutation F^{l} as described in Figure 2.4
-- of the NORX specification
-- ***
procedure G (a, b, c, d : in out Word)
with Inline is
function H (x, y : in Word) return Word is
((x xor y) xor (Shift_Left((x and y), 1))) with Inline;
begin
a := H(a, b);
d := Rotate_Right(a xor d, rot(0));
c := H(c, d);
b := Rotate_Right(b xor c, rot(1));
a := H(a, b);
d := Rotate_Right(a xor d, rot(2));
c := H(c, d);
b := Rotate_Right(b xor c, rot(3));
end G;
procedure F_l (S : in out State)
with Inline is
begin
for I in 1..l loop
-- Column
G(S(0), S(4), S(8), S(12));
G(S(1), S(5), S(9), S(13));
G(S(2), S(6), S(10), S(14));
G(S(3), S(7), S(11), S(15));
-- Diagonal
G(S(0), S(5), S(10), S(15));
G(S(1), S(6), S(11), S(12));
G(S(2), S(7), S(8), S(13));
G(S(3), S(4), S(9), S(14));
end loop;
end F_l;
procedure F_2 (S : in out State) is
-- The initialisation constants are set up by two rounds of the diffusion
-- regardless of the number of rounds l
begin
for I in 1..2 loop
-- Column
G(S(0), S(4), S(8), S(12));
G(S(1), S(5), S(9), S(13));
G(S(2), S(6), S(10), S(14));
G(S(3), S(7), S(11), S(15));
-- Diagonal
G(S(0), S(5), S(10), S(15));
G(S(1), S(6), S(11), S(12));
G(S(2), S(7), S(8), S(13));
G(S(3), S(4), S(9), S(14));
end loop;
end F_2;
-- ***
-- Internal use routines
-- ***
function Valid_Paddable (X : in Storage_Array) return Boolean is
(
-- First check that the array can be padded without exceeding the range
-- of a Storage_Array
X'Last < Storage_Offset'Last - Rate_Bytes_SO and
(
-- now check X'Length < Rate_Bytes_I else padding is not needed...
-- but in a way that doesn't overflow given Storage_Offset can hold
-- a range greater than Long_Long_Integer
if X'Last < X'First then
True
elsif X'First < 0 then
(
(Long_Long_Integer (X'Last) < Long_Long_Integer'Last +
Long_Long_Integer (X'First))
and then
X'Last - X'First < Rate_Bytes_SO - 1)
else
X'Last - X'First < Rate_Bytes_SO - 1
)
)
with Ghost;
function Pad_r (X : in Storage_Array) return Rate_Storage_Array
with Inline, Pre=> Valid_Paddable(X) is
Result : Rate_Storage_Array;
Padding : constant Storage_Array(1 .. Rate_Bytes_SO - Storage_Offset(X'Length + 1))
:= (others => 0);
begin
Result := X & 16#01# & Padding;
Result(Result'Last) := Result(Result'Last) or 16#80#;
return Result;
end Pad_r;
function Compare_Tags_Constant_Time is new NORX.Compare_Tags;
-- ***
-- Low-level API (mainly) as described in Figure 2.6 of the NORX
-- specification
-- ***
function Make_State return State is (State'(others => 0));
function Get_Initialisation_Constants return State is (u);
function Initialise (Key : in Key_Type; Nonce : in Nonce_Type)
return State is
S : State := u;
begin
for I in 0..Nonce_Words-1 loop
S(I) :=
Storage_Array_To_Word(Nonce(Storage_Offset(I)*Bytes .. Storage_Offset(I+1)*Bytes-1));
end loop;
for I in 0..Key_Words-1 loop
S(I + Key_Position) :=
Storage_Array_To_Word(Key(Storage_Offset(I)*Bytes .. Storage_Offset(I+1)*Bytes-1));
end loop;
S(12) := S(12) xor Word(w);
S(13) := S(13) xor Word(l);
S(14) := S(14) xor Word(p);
S(15) := S(15) xor Word(t);
F_l(S);
for I in 0..Key_Words-1 loop
S(16-Key_Words+I) := S(16-Key_Words+I) xor
Storage_Array_To_Word(Key(Storage_Offset(I)*Bytes .. Storage_Offset(I+1)*Bytes-1));
end loop;
return S;
end Initialise;
procedure Absorb_Block (S : in out State;
X : in Rate_Storage_Array;
v : in Word)
with Inline is
X_Index : Storage_Offset := X'First;
begin
S(15) := S(15) xor v;
F_l(S);
for I in 0..Rate_Words - 1 loop
pragma Loop_Invariant (X_Index = X'First + Storage_Offset(I) * Bytes);
S(I) := S(I) xor
Storage_Array_To_Word(X(X_Index .. X_Index + Bytes - 1));
X_Index := X_Index + Bytes;
end loop;
pragma Assert (X_Index = X'Last + 1);
end Absorb_Block;
procedure Absorb (S : in out State; X : in Storage_Array; v : in Word) is
Number_Full_Blocks : constant Storage_Offset
:= X'Length / Rate_Bytes_SO;
X_Index : Storage_Offset := X'First;
begin
pragma Assert (X'Last < Storage_Offset'Last - Storage_Offset(r/8));
if X'Length > 0 then
for I in 1..Number_Full_Blocks loop
pragma Loop_Invariant (X_Index = X'First + (I-1) * Rate_Bytes_SO);
Absorb_Block(S,
X(X_Index .. X_Index + Rate_Bytes_SO-1),
v);
X_Index := X_Index + Rate_Bytes_SO;
end loop;
Absorb_Block(S, Pad_r(X(X_Index..X'Last)), v);
end if;
end Absorb;
procedure Encrypt_Block (S : in out State;
M : in Rate_Storage_Array;
C : out Rate_Storage_Array;
v : in Word)
with Inline is
M_Index : Storage_Offset := M'First;
C_Index : Storage_Offset := C'First;
begin
S(15) := S(15) xor v;
F_l(S);
for I in 0..Rate_Words - 1 loop
pragma Loop_Invariant(M_Index = M'First + Storage_Offset(I) * Bytes);
pragma Loop_Invariant(C_Index = C'First + Storage_Offset(I) * Bytes);
S(I) := S(I) xor
Storage_Array_To_Word(M(M_Index .. M_Index + Bytes - 1));
C(C_Index .. C_Index + Bytes - 1) := Word_To_Storage_Array(S(I));
M_Index := M_Index + Bytes;
C_Index := C_Index + Bytes;
end loop;
pragma Assert (M_Index = M'Last + 1);
pragma Assert (C_Index = C'Last + 1);
end Encrypt_Block;
procedure Encrypt (S : in out State;
M : in Storage_Array;
C : out Storage_Array;
v : in Word) is
Number_Full_Blocks : constant Storage_Offset := M'Length / Rate_Bytes_SO;
M_Index : Storage_Offset := M'First;
C_Index : Storage_Offset := C'First;
begin
if M'Length > 0 then
for I in 1..Number_Full_Blocks loop
pragma Loop_Invariant(M_Index = M'First + (I-1) * Rate_Bytes_SO);
pragma Loop_Invariant(C_Index = C'First + (I-1) * Rate_Bytes_SO);
Encrypt_Block(S => S,
M => M(M_Index..M_Index+Rate_Bytes_SO-1),
C => C(C_Index..C_Index+Rate_Bytes_SO-1),
v => v);
M_Index := M_Index + Rate_Bytes_SO;
C_Index := C_Index + Rate_Bytes_SO;
end loop;
declare
Last_M: constant Storage_Array := Pad_r(M(M_Index..M'Last));
Last_C : Storage_Array(1..Rate_Bytes_SO);
begin
Encrypt_Block(S => S,
M => Last_M,
C => Last_C,
v => v);
C(C_Index..C'Last) := Last_C(1..(C'Last - C_Index)+1);
end;
end if;
end Encrypt;
pragma Annotate (GNATprove, False_Positive,
"""C"" might not be initialized",
"The loop initialises C from C'First to C_Index-1 and the second block of code initialises C_Index to C'Last");
procedure Decrypt_Block (S : in out State;
C : in Rate_Storage_Array;
M : out Rate_Storage_Array;
v : in Word)
with Inline is
C_i : Word;
M_Index : Storage_Offset := M'First;
C_Index : Storage_Offset := C'First;
begin
S(15) := S(15) xor v;
F_l(S);
for I in 0..Rate_Words - 1 loop
pragma Loop_Invariant(M_Index = M'First + Storage_Offset(I) * Bytes);
pragma Loop_Invariant(C_Index = C'First + Storage_Offset(I) * Bytes);
C_i := Storage_Array_To_Word(C(C_Index .. C_Index + Bytes - 1));
M(M_Index .. M_Index + Bytes - 1) := Word_To_Storage_Array(S(I) xor C_i);
S(I) := C_i;
M_Index := M_Index + Bytes;
C_Index := C_Index + Bytes;
end loop;
pragma Assert (M_Index = M'Last + 1);
pragma Assert (C_Index = C'Last + 1);
end Decrypt_Block;
function Valid_Last_Ciphertext_Block (X : in Storage_Array) return Boolean is
(
if X'Last < X'First then
True
elsif X'First < 0 then
(
(Long_Long_Integer (X'Last) < Long_Long_Integer'Last +
Long_Long_Integer (X'First))
and then
X'Last - X'First < Rate_Bytes_SO - 1)
else
X'Last - X'First < Rate_Bytes_SO - 1
)
with Ghost;
procedure Decrypt_Last_Block (S : in out State;
C : in Storage_Array;
M : out Storage_Array;
v : in Word)
with Inline, Pre => ( (Valid_Storage_Array_Parameter(M'First, M'Last) and
Valid_Last_Ciphertext_Block(C) )
and then
M'Length = C'Length
) is
Last_Block : Storage_Array(1..Rate_Bytes_SO);
C_i : Word;
Index : Storage_Offset := Last_Block'First;
begin
S(15) := S(15) xor v;
F_l(S);
for I in 0..Rate_Words-1 loop
pragma Loop_Invariant (Index = Last_Block'First + Storage_Offset(I) * Bytes);
Last_Block(Index .. Index + Bytes-1) := Word_To_Storage_Array(S(I));
Index := Index + Bytes;
end loop;
Last_Block(1..C'Length) := C;
Last_Block(C'Length+1) := Last_Block(C'Length+1) xor 16#01#;
Last_Block(Last_Block'Last) := Last_Block(Last_Block'Last) xor 16#80#;
Index := Last_Block'First;
for I in 0..Rate_Words - 1 loop
pragma Loop_Invariant (Index = Last_Block'First + Storage_Offset(I) * Bytes);
C_i := Storage_Array_To_Word(Last_Block(Index .. Index + Bytes - 1));
Last_Block(Index .. Index + Bytes - 1)
:= Word_To_Storage_Array(S(I) xor C_i);
S(I) := C_i;
Index := Index + Bytes;
end loop;
pragma Assert (Index = Last_Block'Last + 1);
M := Last_Block(1..C'Length);
end Decrypt_Last_Block;
pragma Annotate (GNATprove, False_Positive,
"""Last_Block"" might not be initialized",
"Initialisation and assertion demonstrate that Index is incremented over every element of Last_Block");
procedure Decrypt (S : in out State;
C : in Storage_Array;
M : out Storage_Array;
v : in Word) is
Number_Full_Blocks : constant Storage_Offset := C'Length / Rate_Bytes_SO;
M_Index : Storage_Offset := M'First;
C_Index : Storage_Offset := C'First;
begin
if M'Length > 0 then
for I in 1..Number_Full_Blocks loop
pragma Loop_Invariant(M_Index = M'First + (I-1) * Rate_Bytes_SO);
pragma Loop_Invariant(C_Index = C'First + (I-1) * Rate_Bytes_SO);
Decrypt_Block(S => S,
C => C(C_Index..C_Index+Rate_Bytes_SO-1),
M => M(M_Index..M_Index+Rate_Bytes_SO-1),
v => v);
M_Index := M_Index + Rate_Bytes_SO;
C_Index := C_Index + Rate_Bytes_SO;
end loop;
Decrypt_Last_Block(S => S,
C => C(C_Index..C'Last),
M => M(M_Index..M'Last),
v => v);
end if;
end Decrypt;
pragma Annotate (GNATprove, False_Positive,
"""M"" might not be initialized",
"The loop initialises M from M'First to M_Index-1 and the call to Decrypt_Last_Block initialises M_Index to M'Last");
procedure Finalise (S : in out State;
Key : in Key_Type;
Tag : out Tag_Type;
v : in Word) is
Tag_Index : Storage_Offset := Tag'First;
begin
S(15) := S(15) xor v;
F_l(S);
for I in 0..Key_Words-1 loop
S(16-Key_Words+I) := S(16-Key_Words+I) xor
Storage_Array_To_Word(Key(Storage_Offset(I)*Bytes .. Storage_Offset(I+1)*Bytes-1));
end loop;
F_l(S);
for I in 0..Key_Words-1 loop
S(16-Key_Words+I) := S(16-Key_Words+I) xor
Storage_Array_To_Word(Key(Storage_Offset(I)*Bytes .. Storage_Offset(I+1)*Bytes-1));
end loop;
for I in 0..Tag_Words-1 loop
pragma Loop_Invariant (Tag_Index = Tag'First + Storage_Offset(I) * Bytes);
Tag(Tag_Index..Tag_Index+Bytes-1) :=
Word_To_Storage_Array(S(16-Tag_Words+I));
Tag_Index := Tag_Index + Bytes;
end loop;
pragma Assert (Tag_Index = Tag'Last + 1);
end Finalise;
pragma Annotate (GNATprove, False_Positive,
"""Tag"" might not be initialized",
"Initialisation and assertion demonstrate that Tag_Index is incremented over every element of Tag");
-- ***
-- High-level API as described in Figure 2.5 of the NORX specification
-- ***
procedure AEADEnc(K : in Key_Type;
N : in Nonce_Type;
A : in Storage_Array;
M : in Storage_Array;
Z : in Storage_Array;
C : out Storage_Array;
T : out Tag_Type) is
S : State := Initialise(K, N);
begin
Absorb(S, A, Domain_Separation(Header));
Encrypt(S, M, C, Domain_Separation(Payload));
Absorb(S, Z, Domain_Separation(Trailer));
Finalise(S, K, T, Domain_Separation(Tag));
pragma Unreferenced (S);
end AEADEnc;
procedure AEADDec(K : in Key_Type;
N : in Nonce_Type;
A : in Storage_Array;
C : in Storage_Array;
Z : in Storage_Array;
T : in Tag_Type;
M : out Storage_Array;
Valid : out Boolean) is
S : State := Initialise(K, N);
T2 : Tag_Type;
begin
Absorb(S, A, Domain_Separation(Header));
Decrypt(S, C, M, Domain_Separation(Payload));
Absorb(S, Z, Domain_Separation(Trailer));
Finalise(S, K, T2, Domain_Separation(Tag));
pragma Unreferenced (S);
if Compare_Tags_Constant_Time(T, T2) then
Valid := True;
else
-- Section 2.5 of the specification requires that the decrypted data
-- not be returned to the caller if verification fails, to try to
-- prevent callers from forgetting to check the validity of the result.
M := (others => 0);
Valid := False;
end if;
end AEADDec;
begin
-- Initialisation constants set up as in 2.5.2 of the specification
u := ( 0, 1, 2, 3,
4, 5, 6, 7,
8, 9, 10, 11,
12, 13, 14, 15);
F_2(u);
end NORX;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- A generalization set is a packageable element whose instances define
-- collections of subsets of generalization relationships.
------------------------------------------------------------------------------
limited with AMF.UML.Classifiers;
limited with AMF.UML.Generalizations.Collections;
with AMF.UML.Packageable_Elements;
package AMF.UML.Generalization_Sets is
pragma Preelaborate;
type UML_Generalization_Set is limited interface
and AMF.UML.Packageable_Elements.UML_Packageable_Element;
type UML_Generalization_Set_Access is
access all UML_Generalization_Set'Class;
for UML_Generalization_Set_Access'Storage_Size use 0;
not overriding function Get_Generalization
(Self : not null access constant UML_Generalization_Set)
return AMF.UML.Generalizations.Collections.Set_Of_UML_Generalization is abstract;
-- Getter of GeneralizationSet::generalization.
--
-- Designates the instances of Generalization which are members of a given
-- GeneralizationSet.
not overriding function Get_Is_Covering
(Self : not null access constant UML_Generalization_Set)
return Boolean is abstract;
-- Getter of GeneralizationSet::isCovering.
--
-- Indicates (via the associated Generalizations) whether or not the set
-- of specific Classifiers are covering for a particular general
-- classifier. When isCovering is true, every instance of a particular
-- general Classifier is also an instance of at least one of its specific
-- Classifiers for the GeneralizationSet. When isCovering is false, there
-- are one or more instances of the particular general Classifier that are
-- not instances of at least one of its specific Classifiers defined for
-- the GeneralizationSet.
not overriding procedure Set_Is_Covering
(Self : not null access UML_Generalization_Set;
To : Boolean) is abstract;
-- Setter of GeneralizationSet::isCovering.
--
-- Indicates (via the associated Generalizations) whether or not the set
-- of specific Classifiers are covering for a particular general
-- classifier. When isCovering is true, every instance of a particular
-- general Classifier is also an instance of at least one of its specific
-- Classifiers for the GeneralizationSet. When isCovering is false, there
-- are one or more instances of the particular general Classifier that are
-- not instances of at least one of its specific Classifiers defined for
-- the GeneralizationSet.
not overriding function Get_Is_Disjoint
(Self : not null access constant UML_Generalization_Set)
return Boolean is abstract;
-- Getter of GeneralizationSet::isDisjoint.
--
-- Indicates whether or not the set of specific Classifiers in a
-- Generalization relationship have instance in common. If isDisjoint is
-- true, the specific Classifiers for a particular GeneralizationSet have
-- no members in common; that is, their intersection is empty. If
-- isDisjoint is false, the specific Classifiers in a particular
-- GeneralizationSet have one or more members in common; that is, their
-- intersection is not empty. For example, Person could have two
-- Generalization relationships, each with the different specific
-- Classifier: Manager or Staff. This would be disjoint because every
-- instance of Person must either be a Manager or Staff. In contrast,
-- Person could have two Generalization relationships involving two
-- specific (and non-covering) Classifiers: Sales Person and Manager. This
-- GeneralizationSet would not be disjoint because there are instances of
-- Person which can be a Sales Person and a Manager.
not overriding procedure Set_Is_Disjoint
(Self : not null access UML_Generalization_Set;
To : Boolean) is abstract;
-- Setter of GeneralizationSet::isDisjoint.
--
-- Indicates whether or not the set of specific Classifiers in a
-- Generalization relationship have instance in common. If isDisjoint is
-- true, the specific Classifiers for a particular GeneralizationSet have
-- no members in common; that is, their intersection is empty. If
-- isDisjoint is false, the specific Classifiers in a particular
-- GeneralizationSet have one or more members in common; that is, their
-- intersection is not empty. For example, Person could have two
-- Generalization relationships, each with the different specific
-- Classifier: Manager or Staff. This would be disjoint because every
-- instance of Person must either be a Manager or Staff. In contrast,
-- Person could have two Generalization relationships involving two
-- specific (and non-covering) Classifiers: Sales Person and Manager. This
-- GeneralizationSet would not be disjoint because there are instances of
-- Person which can be a Sales Person and a Manager.
not overriding function Get_Powertype
(Self : not null access constant UML_Generalization_Set)
return AMF.UML.Classifiers.UML_Classifier_Access is abstract;
-- Getter of GeneralizationSet::powertype.
--
-- Designates the Classifier that is defined as the power type for the
-- associated GeneralizationSet.
not overriding procedure Set_Powertype
(Self : not null access UML_Generalization_Set;
To : AMF.UML.Classifiers.UML_Classifier_Access) is abstract;
-- Setter of GeneralizationSet::powertype.
--
-- Designates the Classifier that is defined as the power type for the
-- associated GeneralizationSet.
end AMF.UML.Generalization_Sets;
|
-----------------------------------------------------------------------
-- contexts-facelets -- Contexts for facelets
-- Copyright (C) 2009, 2010, 2011, 2018 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Strings;
with EL.Objects;
with EL.Contexts;
with EL.Expressions;
with EL.Functions;
with ASF.Components.Base;
with ASF.Converters;
with ASF.Validators;
with Ada.Strings.Unbounded;
with Ada.Containers.Vectors;
limited with ASF.Views.Nodes.Facelets;
package ASF.Contexts.Facelets is
use ASF.Components;
use Ada.Strings.Unbounded;
-- ------------------------------
-- Facelet context
-- ------------------------------
-- The <b>Facelet_Context</b> defines a context used exclusively when
-- building the component tree from the facelet nodes. It allows to
-- compose the component tree by using other facelet fragments.
type Facelet_Context is abstract tagged private;
type Facelet_Context_Access is access all Facelet_Context'Class;
-- Get the EL context for evaluating expressions.
function Get_ELContext (Context : in Facelet_Context)
return EL.Contexts.ELContext_Access;
-- Set the EL context for evaluating expressions.
procedure Set_ELContext (Context : in out Facelet_Context;
ELContext : in EL.Contexts.ELContext_Access);
-- Get the function mapper associated with the EL context.
function Get_Function_Mapper (Context : in Facelet_Context)
return EL.Functions.Function_Mapper_Access;
-- Set the attribute having given name with the value.
procedure Set_Attribute (Context : in out Facelet_Context;
Name : in String;
Value : in EL.Objects.Object);
-- Set the attribute having given name with the value.
procedure Set_Attribute (Context : in out Facelet_Context;
Name : in Unbounded_String;
Value : in EL.Objects.Object);
-- Set the attribute having given name with the expression.
procedure Set_Variable (Context : in out Facelet_Context;
Name : in Unbounded_String;
Value : in EL.Expressions.Expression);
-- Set the attribute having given name with the expression.
procedure Set_Variable (Context : in out Facelet_Context;
Name : in String;
Value : in EL.Expressions.Expression);
-- Include the facelet from the given source file.
-- The included views appended to the parent component tree.
procedure Include_Facelet (Context : in out Facelet_Context;
Source : in String;
Parent : in Base.UIComponent_Access);
-- Include the definition having the given name.
procedure Include_Definition (Context : in out Facelet_Context;
Name : in Unbounded_String;
Parent : in Base.UIComponent_Access;
Found : out Boolean);
-- Push into the current facelet context the <ui:define> nodes contained in
-- the composition/decorate tag.
procedure Push_Defines (Context : in out Facelet_Context;
Node : access ASF.Views.Nodes.Facelets.Composition_Tag_Node);
-- Pop from the current facelet context the <ui:define> nodes.
procedure Pop_Defines (Context : in out Facelet_Context);
-- Set the path to resolve relative facelet paths and get the previous path.
procedure Set_Relative_Path (Context : in out Facelet_Context;
Path : in String;
Previous : out Unbounded_String);
-- Set the path to resolve relative facelet paths.
procedure Set_Relative_Path (Context : in out Facelet_Context;
Path : in Unbounded_String);
-- Resolve the facelet relative path
function Resolve_Path (Context : Facelet_Context;
Path : String) return String;
-- Get a converter from a name.
-- Returns the converter object or null if there is no converter.
function Get_Converter (Context : in Facelet_Context;
Name : in EL.Objects.Object)
return ASF.Converters.Converter_Access is abstract;
-- Get a validator from a name.
-- Returns the validator object or null if there is no validator.
function Get_Validator (Context : in Facelet_Context;
Name : in EL.Objects.Object)
return ASF.Validators.Validator_Access is abstract;
private
type Composition_Tag_Node is access all ASF.Views.Nodes.Facelets.Composition_Tag_Node'Class;
package Defines_Vector is
new Ada.Containers.Vectors (Index_Type => Natural,
Element_Type => Composition_Tag_Node);
type Facelet_Context is abstract tagged record
-- The expression context;
Context : EL.Contexts.ELContext_Access := null;
Defines : Defines_Vector.Vector;
Path : Unbounded_String;
Inserts : Util.Strings.String_Set.Set;
end record;
end ASF.Contexts.Facelets;
|
-- Copyright (c) 2021 Devin Hill
-- zlib License -- see LICENSE for details.
package body GBA.Numerics.Vectors is
function Pointwise (V, W : Vec) return Vec is
begin
return
( 0 => Operator (V (0), W (0))
, 1 => Operator (V (1), W (1))
);
end;
function Scalar (V : Vec; E : Element) return Vec is
begin
return
( 0 => Operator (V (0), E)
, 1 => Operator (V (1), E)
);
end;
function EMul (X, Y : Element) return Element is
( X * Y ) with Inline_Always;
function EDiv (X, Y : Element) return Element is
( X / Y ) with Inline_Always;
function VAdd is new Pointwise ("+");
function VSub is new Pointwise ("-");
function VMul is new Pointwise (EMul);
function VDiv is new Pointwise (EDiv);
function VAdd is new Scalar ("+");
function VSub is new Scalar ("-");
function VMul is new Scalar (EMul);
function VDiv is new Scalar (EDiv);
function "+" (V, W : Vec) return Vec
renames VAdd;
function "-" (V, W : Vec) return Vec
renames VSub;
function "*" (V, W : Vec) return Vec
renames VMul;
function "/" (V, W : Vec) return Vec
renames VDiv;
function "+" (V : Vec; E : Element) return Vec
renames VAdd;
function "-" (V : Vec; E : Element) return Vec
renames VSub;
function "*" (V : Vec; E : Element) return Vec
renames VMul;
function "/" (V : Vec; E : Element) return Vec
renames VDiv;
function Dot (V, W : Vec) return Element is
begin
return Vec'(V * W)'Reduce ("+", 0.0);
end;
end GBA.Numerics.Vectors; |
-----------------------------------------------------------------------
-- wallet_password -- Open wallet with password and get values
-- Copyright (C) 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.Text_IO;
with Ada.Command_Line;
with Keystore.Files;
procedure Wallet_Password is
Count : constant Natural := Ada.Command_Line.Argument_Count;
begin
if Count <= 2 then
Ada.Text_IO.Put_Line ("Usage: wallet_password <keystore-path> <password> {name...}");
return;
end if;
declare
Path : constant String := Ada.Command_Line.Argument (1);
Pass : constant Keystore.Secret_Key := Keystore.Create (Ada.Command_Line.Argument (2));
WS : Keystore.Files.Wallet_File;
begin
WS.Open (Pass, Path);
for I in 3 .. Count loop
declare
Name : constant String := Ada.Command_Line.Argument (I);
begin
Ada.Text_IO.Put (Name);
Ada.Text_IO.Put (" = ");
if WS.Contains (Name) then
Ada.Text_IO.Put (WS.Get (Name));
end if;
Ada.Text_IO.New_Line;
end;
end loop;
exception
when Keystore.Bad_Password =>
Ada.Text_IO.Put_Line ("Invalid password!");
end;
end Wallet_Password;
|
-- Copyright (c) 2021 Devin Hill
-- zlib License -- see LICENSE for details.
with System.Allocation.Memory;
with System.Allocation.Arenas;
use System.Allocation.Arenas;
package GBA.Memory.Default_Heaps is
IWRAM_Heap_Start : constant Character
with Import, External_Name => "__iheap_start";
IWRAM_Heap : Heap_Arena
:= Create_Arena (IWRAM_Heap_Start'Address, Internal_WRAM_Address'Last);
EWRAM_Heap : Heap_Arena renames System.Allocation.Memory.Heap;
end GBA.Memory.Default_Heaps; |
-- Copyright 2014-2015 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package body Pck is
function New_Variable_Table (Low: Color; High: Color) return Variable_Table
is
Result : Variable_Table (Low .. High);
begin
for J in Low .. High loop
Result (J) := (J = Black or J = Green or J = White);
end loop;
return Result;
end New_Variable_Table;
procedure Do_Nothing (A : System.Address) is
begin
null;
end Do_Nothing;
end Pck;
|
------------------------------------------------------------------------------
-- Copyright (c) 2014, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Natools.S_Expressions.Printers.Pretty.Cofnig.Tests provides a test suite --
-- S-expression serialization and deserialization of pretty printer --
-- parameters. --
------------------------------------------------------------------------------
with Natools.Tests;
package Natools.S_Expressions.Printers.Pretty.Config.Tests is
pragma Preelaborate (Tests);
package NT renames Natools.Tests;
procedure All_Tests (Report : in out NT.Reporter'Class);
procedure Hash_Function_Test (Report : in out NT.Reporter'Class);
procedure Read_Test (Report : in out NT.Reporter'Class);
procedure Write_Test (Report : in out NT.Reporter'Class);
end Natools.S_Expressions.Printers.Pretty.Config.Tests;
|
-- { dg-do run }
procedure self_aggregate_with_zeros is
type Sensor is record
Value : Natural;
A, B, C, D, E, F, G, H, I, J, K, L, M : Natural;
end record;
Pressure : Sensor;
begin
Pressure.Value := 256;
Pressure := (Pressure.Value, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
if Pressure.Value /= 256 then
raise Program_Error;
end if;
end;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . N U M E R I C S . G E N E R I C _ C O M P L E X _ T Y P E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2019, Free Software Foundation, Inc. --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. The copyright notice above, and the license provisions that follow --
-- apply solely to the contents of the part following the private keyword. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 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. --
-- --
------------------------------------------------------------------------------
generic
type Real is digits <>;
package Ada.Numerics.Generic_Complex_Types is
pragma Pure;
type Complex is record
Re, Im : Real'Base;
end record;
pragma Complex_Representation (Complex);
type Imaginary is private;
pragma Preelaborable_Initialization (Imaginary);
i : constant Imaginary;
j : constant Imaginary;
function Re (X : Complex) return Real'Base;
function Im (X : Complex) return Real'Base;
function Im (X : Imaginary) return Real'Base;
procedure Set_Re (X : in out Complex; Re : Real'Base);
procedure Set_Im (X : in out Complex; Im : Real'Base);
procedure Set_Im (X : out Imaginary; Im : Real'Base);
function Compose_From_Cartesian (Re, Im : Real'Base) return Complex;
function Compose_From_Cartesian (Re : Real'Base) return Complex;
function Compose_From_Cartesian (Im : Imaginary) return Complex;
function Modulus (X : Complex) return Real'Base;
function "abs" (Right : Complex) return Real'Base renames Modulus;
function Argument (X : Complex) return Real'Base;
function Argument (X : Complex; Cycle : Real'Base) return Real'Base;
function Compose_From_Polar (
Modulus, Argument : Real'Base)
return Complex;
function Compose_From_Polar (
Modulus, Argument, Cycle : Real'Base)
return Complex;
function "+" (Right : Complex) return Complex;
function "-" (Right : Complex) return Complex;
function Conjugate (X : Complex) return Complex;
function "+" (Left, Right : Complex) return Complex;
function "-" (Left, Right : Complex) return Complex;
function "*" (Left, Right : Complex) return Complex;
function "/" (Left, Right : Complex) return Complex;
function "**" (Left : Complex; Right : Integer) return Complex;
function "+" (Right : Imaginary) return Imaginary;
function "-" (Right : Imaginary) return Imaginary;
function Conjugate (X : Imaginary) return Imaginary renames "-";
function "abs" (Right : Imaginary) return Real'Base;
function "+" (Left, Right : Imaginary) return Imaginary;
function "-" (Left, Right : Imaginary) return Imaginary;
function "*" (Left, Right : Imaginary) return Real'Base;
function "/" (Left, Right : Imaginary) return Real'Base;
function "**" (Left : Imaginary; Right : Integer) return Complex;
function "<" (Left, Right : Imaginary) return Boolean;
function "<=" (Left, Right : Imaginary) return Boolean;
function ">" (Left, Right : Imaginary) return Boolean;
function ">=" (Left, Right : Imaginary) return Boolean;
function "+" (Left : Complex; Right : Real'Base) return Complex;
function "+" (Left : Real'Base; Right : Complex) return Complex;
function "-" (Left : Complex; Right : Real'Base) return Complex;
function "-" (Left : Real'Base; Right : Complex) return Complex;
function "*" (Left : Complex; Right : Real'Base) return Complex;
function "*" (Left : Real'Base; Right : Complex) return Complex;
function "/" (Left : Complex; Right : Real'Base) return Complex;
function "/" (Left : Real'Base; Right : Complex) return Complex;
function "+" (Left : Complex; Right : Imaginary) return Complex;
function "+" (Left : Imaginary; Right : Complex) return Complex;
function "-" (Left : Complex; Right : Imaginary) return Complex;
function "-" (Left : Imaginary; Right : Complex) return Complex;
function "*" (Left : Complex; Right : Imaginary) return Complex;
function "*" (Left : Imaginary; Right : Complex) return Complex;
function "/" (Left : Complex; Right : Imaginary) return Complex;
function "/" (Left : Imaginary; Right : Complex) return Complex;
function "+" (Left : Imaginary; Right : Real'Base) return Complex;
function "+" (Left : Real'Base; Right : Imaginary) return Complex;
function "-" (Left : Imaginary; Right : Real'Base) return Complex;
function "-" (Left : Real'Base; Right : Imaginary) return Complex;
function "*" (Left : Imaginary; Right : Real'Base) return Imaginary;
function "*" (Left : Real'Base; Right : Imaginary) return Imaginary;
function "/" (Left : Imaginary; Right : Real'Base) return Imaginary;
function "/" (Left : Real'Base; Right : Imaginary) return Imaginary;
private
type Imaginary is new Real'Base;
i : constant Imaginary := 1.0;
j : constant Imaginary := 1.0;
pragma Inline ("+");
pragma Inline ("-");
pragma Inline ("*");
pragma Inline ("<");
pragma Inline ("<=");
pragma Inline (">");
pragma Inline (">=");
pragma Inline ("abs");
pragma Inline (Compose_From_Cartesian);
pragma Inline (Conjugate);
pragma Inline (Im);
pragma Inline (Re);
pragma Inline (Set_Im);
pragma Inline (Set_Re);
end Ada.Numerics.Generic_Complex_Types;
|
-----------------------------------------------------------------------
-- 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 ASF.Components.Html;
with ASF.Contexts.Faces;
package ASF.Components.Widgets.Progress is
VALUE_ATTR_NAME : constant String := "value";
MIN_VALUE_ATTR_NAME : constant String := "minValue";
MAX_VALUE_ATTR_NAME : constant String := "maxValue";
DIRECTION_ATTR_NAME : constant String := "direction";
type Progress_Type is delta 0.1 digits 4 range 0.0 .. 100.0;
-- ------------------------------
-- UIProgressBar
-- ------------------------------
-- The <b>UIProgressBar</b> component displays a simple progress bar component.
type UIProgressBar is new ASF.Components.Html.UIHtmlComponent with null record;
-- Get the progress value
function Get_Progress (UI : in UIProgressBar;
Context : in ASF.Contexts.Faces.Faces_Context'Class)
return Progress_Type;
-- Render the tab start.
overriding
procedure Encode_Begin (UI : in UIProgressBar;
Context : in out ASF.Contexts.Faces.Faces_Context'Class);
-- Render the tab close.
overriding
procedure Encode_End (UI : in UIProgressBar;
Context : in out ASF.Contexts.Faces.Faces_Context'Class);
end ASF.Components.Widgets.Progress;
|
-- Copyright 2012-2017 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Ops; use Ops;
procedure Ops_Test is
begin
Dummy (Make (31) + Make (11)); -- BEGIN
Dummy (Make (31) - Make (11));
Dummy (Make (31) * Make (11));
Dummy (Make (31) / Make (11));
Dummy (Make (31) mod Make (11));
Dummy (Make (31) rem Make (11));
Dummy (Make (31) ** Make (11));
Dummy (Make (31) < Make (11));
Dummy (Make (31) <= Make (11));
Dummy (Make (31) > Make (11));
Dummy (Make (31) >= Make (11));
Dummy (Make (31) = Make (11));
Dummy (Make (31) and Make (11));
Dummy (Make (31) or Make (11));
Dummy (Make (31) xor Make (11));
Dummy (Make (31) & Make (11));
Dummy (abs (Make (42)));
Dummy (not Make (11));
Dummy (+ Make (11));
Dummy (- Make (11));
end Ops_Test;
|
with Ada.Text_IO;
package body my_lib is
procedure Do_Stuff is
begin
Ada.Text_IO.Put_Line("Hello DLL land!");
end Do_Stuff;
-- procedure Initialize_API is
-- procedure Adainit;
-- pragma Import(C, Adainit);
-- begin
-- Adainit;
-- end Initialize_API;
-- procedure Finalize_API is
-- procedure Adafinal;
-- pragma Import(C, Adafinal);
-- begin
-- Adafinal;
-- end Finalize_API;
end my_lib; |
-- This spec has been automatically generated from STM32F429x.svd
pragma Ada_2012;
with Bit_Types; use Bit_Types;
with System;
package STM32_SVD.RCC is
pragma Preelaborate;
--pragma No_Elaboration_Code_All;
---------------
-- Registers --
---------------
-----------------
-- CR_Register --
-----------------
subtype CR_HSITRIM_Field is Bits_5;
subtype CR_HSICAL_Field is Byte;
-- clock control register
type CR_Register is record
-- Internal high-speed clock enable
HSION : Boolean := True;
-- Read-only. Internal high-speed clock ready flag
HSIRDY : Boolean := True;
-- unspecified
Reserved_2_2 : Bits_1 := 16#0#;
-- Internal high-speed clock trimming
HSITRIM : CR_HSITRIM_Field := 16#10#;
-- Read-only. Internal high-speed clock calibration
HSICAL : CR_HSICAL_Field := 16#0#;
-- HSE clock enable
HSEON : Boolean := False;
-- Read-only. HSE clock ready flag
HSERDY : Boolean := False;
-- HSE clock bypass
HSEBYP : Boolean := False;
-- Clock security system enable
CSSON : Boolean := False;
-- unspecified
Reserved_20_23 : Bits_4 := 16#0#;
-- Main PLL (PLL) enable
PLLON : Boolean := False;
-- Read-only. Main PLL (PLL) clock ready flag
PLLRDY : Boolean := False;
-- PLLI2S enable
PLLI2SON : Boolean := False;
-- Read-only. PLLI2S clock ready flag
PLLI2SRDY : Boolean := False;
-- unspecified
Reserved_28_31 : Bits_4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
HSION at 0 range 0 .. 0;
HSIRDY at 0 range 1 .. 1;
Reserved_2_2 at 0 range 2 .. 2;
HSITRIM at 0 range 3 .. 7;
HSICAL at 0 range 8 .. 15;
HSEON at 0 range 16 .. 16;
HSERDY at 0 range 17 .. 17;
HSEBYP at 0 range 18 .. 18;
CSSON at 0 range 19 .. 19;
Reserved_20_23 at 0 range 20 .. 23;
PLLON at 0 range 24 .. 24;
PLLRDY at 0 range 25 .. 25;
PLLI2SON at 0 range 26 .. 26;
PLLI2SRDY at 0 range 27 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
----------------------
-- PLLCFGR_Register --
----------------------
subtype PLLCFGR_PLLM_Field is Bits_6;
subtype PLLCFGR_PLLN_Field is Bits_9;
subtype PLLCFGR_PLLP_Field is Bits_2;
subtype PLLCFGR_PLLQ_Field is Bits_4;
-- PLL configuration register
type PLLCFGR_Register is record
-- Division factor for the main PLL (PLL) and audio PLL (PLLI2S) input
-- clock
PLLM : PLLCFGR_PLLM_Field := 16#10#;
-- Main PLL (PLL) multiplication factor for VCO
PLLN : PLLCFGR_PLLN_Field := 16#C0#;
-- unspecified
Reserved_15_15 : Bits_1 := 16#0#;
-- Main PLL (PLL) division factor for main system clock
PLLP : PLLCFGR_PLLP_Field := 16#0#;
-- unspecified
Reserved_18_21 : Bits_4 := 16#0#;
-- Main PLL(PLL) and audio PLL (PLLI2S) entry clock source
PLLSRC : Boolean := False;
-- unspecified
Reserved_23_23 : Bits_1 := 16#0#;
-- Main PLL (PLL) division factor for USB OTG FS, SDIO and random number
-- generator clocks
PLLQ : PLLCFGR_PLLQ_Field := 16#4#;
-- unspecified
Reserved_28_31 : Bits_4 := 16#2#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PLLCFGR_Register use record
PLLM at 0 range 0 .. 5;
PLLN at 0 range 6 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
PLLP at 0 range 16 .. 17;
Reserved_18_21 at 0 range 18 .. 21;
PLLSRC at 0 range 22 .. 22;
Reserved_23_23 at 0 range 23 .. 23;
PLLQ at 0 range 24 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
-------------------
-- CFGR_Register --
-------------------
subtype CFGR_SW_Field is Bits_2;
subtype CFGR_SWS_Field is Bits_2;
subtype CFGR_HPRE_Field is Bits_4;
---------------
-- CFGR.PPRE --
---------------
-- CFGR_PPRE array element
subtype CFGR_PPRE_Element is Bits_3;
-- CFGR_PPRE array
type CFGR_PPRE_Field_Array is array (1 .. 2) of CFGR_PPRE_Element
with Component_Size => 3, Size => 6;
-- Type definition for CFGR_PPRE
type CFGR_PPRE_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- PPRE as a value
Val : Bits_6;
when True =>
-- PPRE as an array
Arr : CFGR_PPRE_Field_Array;
end case;
end record
with Unchecked_Union, Size => 6;
for CFGR_PPRE_Field use record
Val at 0 range 0 .. 5;
Arr at 0 range 0 .. 5;
end record;
subtype CFGR_RTCPRE_Field is Bits_5;
subtype CFGR_MCO1_Field is Bits_2;
subtype CFGR_MCO1PRE_Field is Bits_3;
subtype CFGR_MCO2PRE_Field is Bits_3;
subtype CFGR_MCO2_Field is Bits_2;
-- clock configuration register
type CFGR_Register is record
-- System clock switch
SW : CFGR_SW_Field := 16#0#;
-- Read-only. System clock switch status
SWS : CFGR_SWS_Field := 16#0#;
-- AHB prescaler
HPRE : CFGR_HPRE_Field := 16#0#;
-- unspecified
Reserved_8_9 : Bits_2 := 16#0#;
-- APB Low speed prescaler (APB1)
PPRE : CFGR_PPRE_Field := (As_Array => False, Val => 16#0#);
-- HSE division factor for RTC clock
RTCPRE : CFGR_RTCPRE_Field := 16#0#;
-- Microcontroller clock output 1
MCO1 : CFGR_MCO1_Field := 16#0#;
-- I2S clock selection
I2SSRC : Boolean := False;
-- MCO1 prescaler
MCO1PRE : CFGR_MCO1PRE_Field := 16#0#;
-- MCO2 prescaler
MCO2PRE : CFGR_MCO2PRE_Field := 16#0#;
-- Microcontroller clock output 2
MCO2 : CFGR_MCO2_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CFGR_Register use record
SW at 0 range 0 .. 1;
SWS at 0 range 2 .. 3;
HPRE at 0 range 4 .. 7;
Reserved_8_9 at 0 range 8 .. 9;
PPRE at 0 range 10 .. 15;
RTCPRE at 0 range 16 .. 20;
MCO1 at 0 range 21 .. 22;
I2SSRC at 0 range 23 .. 23;
MCO1PRE at 0 range 24 .. 26;
MCO2PRE at 0 range 27 .. 29;
MCO2 at 0 range 30 .. 31;
end record;
------------------
-- CIR_Register --
------------------
-- clock interrupt register
type CIR_Register is record
-- Read-only. LSI ready interrupt flag
LSIRDYF : Boolean := False;
-- Read-only. LSE ready interrupt flag
LSERDYF : Boolean := False;
-- Read-only. HSI ready interrupt flag
HSIRDYF : Boolean := False;
-- Read-only. HSE ready interrupt flag
HSERDYF : Boolean := False;
-- Read-only. Main PLL (PLL) ready interrupt flag
PLLRDYF : Boolean := False;
-- Read-only. PLLI2S ready interrupt flag
PLLI2SRDYF : Boolean := False;
-- Read-only. PLLSAI ready interrupt flag
PLLSAIRDYF : Boolean := False;
-- Read-only. Clock security system interrupt flag
CSSF : Boolean := False;
-- LSI ready interrupt enable
LSIRDYIE : Boolean := False;
-- LSE ready interrupt enable
LSERDYIE : Boolean := False;
-- HSI ready interrupt enable
HSIRDYIE : Boolean := False;
-- HSE ready interrupt enable
HSERDYIE : Boolean := False;
-- Main PLL (PLL) ready interrupt enable
PLLRDYIE : Boolean := False;
-- PLLI2S ready interrupt enable
PLLI2SRDYIE : Boolean := False;
-- PLLSAI Ready Interrupt Enable
PLLSAIRDYIE : Boolean := False;
-- unspecified
Reserved_15_15 : Bits_1 := 16#0#;
-- Write-only. LSI ready interrupt clear
LSIRDYC : Boolean := False;
-- Write-only. LSE ready interrupt clear
LSERDYC : Boolean := False;
-- Write-only. HSI ready interrupt clear
HSIRDYC : Boolean := False;
-- Write-only. HSE ready interrupt clear
HSERDYC : Boolean := False;
-- Write-only. Main PLL(PLL) ready interrupt clear
PLLRDYC : Boolean := False;
-- Write-only. PLLI2S ready interrupt clear
PLLI2SRDYC : Boolean := False;
-- Write-only. PLLSAI Ready Interrupt Clear
PLLSAIRDYC : Boolean := False;
-- Write-only. Clock security system interrupt clear
CSSC : Boolean := False;
-- unspecified
Reserved_24_31 : Byte := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CIR_Register use record
LSIRDYF at 0 range 0 .. 0;
LSERDYF at 0 range 1 .. 1;
HSIRDYF at 0 range 2 .. 2;
HSERDYF at 0 range 3 .. 3;
PLLRDYF at 0 range 4 .. 4;
PLLI2SRDYF at 0 range 5 .. 5;
PLLSAIRDYF at 0 range 6 .. 6;
CSSF at 0 range 7 .. 7;
LSIRDYIE at 0 range 8 .. 8;
LSERDYIE at 0 range 9 .. 9;
HSIRDYIE at 0 range 10 .. 10;
HSERDYIE at 0 range 11 .. 11;
PLLRDYIE at 0 range 12 .. 12;
PLLI2SRDYIE at 0 range 13 .. 13;
PLLSAIRDYIE at 0 range 14 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
LSIRDYC at 0 range 16 .. 16;
LSERDYC at 0 range 17 .. 17;
HSIRDYC at 0 range 18 .. 18;
HSERDYC at 0 range 19 .. 19;
PLLRDYC at 0 range 20 .. 20;
PLLI2SRDYC at 0 range 21 .. 21;
PLLSAIRDYC at 0 range 22 .. 22;
CSSC at 0 range 23 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
-----------------------
-- AHB1RSTR_Register --
-----------------------
-- AHB1 peripheral reset register
type AHB1RSTR_Register is record
-- IO port A reset
GPIOARST : Boolean := False;
-- IO port B reset
GPIOBRST : Boolean := False;
-- IO port C reset
GPIOCRST : Boolean := False;
-- IO port D reset
GPIODRST : Boolean := False;
-- IO port E reset
GPIOERST : Boolean := False;
-- IO port F reset
GPIOFRST : Boolean := False;
-- IO port G reset
GPIOGRST : Boolean := False;
-- IO port H reset
GPIOHRST : Boolean := False;
-- IO port I reset
GPIOIRST : Boolean := False;
-- IO port J reset
GPIOJRST : Boolean := False;
-- IO port K reset
GPIOKRST : Boolean := False;
-- unspecified
Reserved_11_11 : Bits_1 := 16#0#;
-- CRC reset
CRCRST : Boolean := False;
-- unspecified
Reserved_13_20 : Byte := 16#0#;
-- DMA2 reset
DMA1RST : Boolean := False;
-- DMA2 reset
DMA2RST : Boolean := False;
-- DMA2D reset
DMA2DRST : Boolean := False;
-- unspecified
Reserved_24_24 : Bits_1 := 16#0#;
-- Ethernet MAC reset
ETHMACRST : Boolean := False;
-- unspecified
Reserved_26_28 : Bits_3 := 16#0#;
-- USB OTG HS module reset
OTGHSRST : Boolean := False;
-- unspecified
Reserved_30_31 : Bits_2 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AHB1RSTR_Register use record
GPIOARST at 0 range 0 .. 0;
GPIOBRST at 0 range 1 .. 1;
GPIOCRST at 0 range 2 .. 2;
GPIODRST at 0 range 3 .. 3;
GPIOERST at 0 range 4 .. 4;
GPIOFRST at 0 range 5 .. 5;
GPIOGRST at 0 range 6 .. 6;
GPIOHRST at 0 range 7 .. 7;
GPIOIRST at 0 range 8 .. 8;
GPIOJRST at 0 range 9 .. 9;
GPIOKRST at 0 range 10 .. 10;
Reserved_11_11 at 0 range 11 .. 11;
CRCRST at 0 range 12 .. 12;
Reserved_13_20 at 0 range 13 .. 20;
DMA1RST at 0 range 21 .. 21;
DMA2RST at 0 range 22 .. 22;
DMA2DRST at 0 range 23 .. 23;
Reserved_24_24 at 0 range 24 .. 24;
ETHMACRST at 0 range 25 .. 25;
Reserved_26_28 at 0 range 26 .. 28;
OTGHSRST at 0 range 29 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
-----------------------
-- AHB2RSTR_Register --
-----------------------
-- AHB2 peripheral reset register
type AHB2RSTR_Register is record
-- Camera interface reset
DCMIRST : Boolean := False;
-- unspecified
Reserved_1_5 : Bits_5 := 16#0#;
-- Random number generator module reset
RNGRST : Boolean := False;
-- USB OTG FS module reset
OTGFSRST : Boolean := False;
-- unspecified
Reserved_8_31 : Bits_24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AHB2RSTR_Register use record
DCMIRST at 0 range 0 .. 0;
Reserved_1_5 at 0 range 1 .. 5;
RNGRST at 0 range 6 .. 6;
OTGFSRST at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-----------------------
-- AHB3RSTR_Register --
-----------------------
-- AHB3 peripheral reset register
type AHB3RSTR_Register is record
-- Flexible memory controller module reset
FMCRST : Boolean := False;
-- unspecified
Reserved_1_31 : Bits_31 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AHB3RSTR_Register use record
FMCRST at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-----------------------
-- APB1RSTR_Register --
-----------------------
-- APB1 peripheral reset register
type APB1RSTR_Register is record
-- TIM2 reset
TIM2RST : Boolean := False;
-- TIM3 reset
TIM3RST : Boolean := False;
-- TIM4 reset
TIM4RST : Boolean := False;
-- TIM5 reset
TIM5RST : Boolean := False;
-- TIM6 reset
TIM6RST : Boolean := False;
-- TIM7 reset
TIM7RST : Boolean := False;
-- TIM12 reset
TIM12RST : Boolean := False;
-- TIM13 reset
TIM13RST : Boolean := False;
-- TIM14 reset
TIM14RST : Boolean := False;
-- unspecified
Reserved_9_10 : Bits_2 := 16#0#;
-- Window watchdog reset
WWDGRST : Boolean := False;
-- unspecified
Reserved_12_13 : Bits_2 := 16#0#;
-- SPI 2 reset
SPI2RST : Boolean := False;
-- SPI 3 reset
SPI3RST : Boolean := False;
-- unspecified
Reserved_16_16 : Bits_1 := 16#0#;
-- USART 2 reset
UART2RST : Boolean := False;
-- USART 3 reset
UART3RST : Boolean := False;
-- USART 4 reset
UART4RST : Boolean := False;
-- USART 5 reset
UART5RST : Boolean := False;
-- I2C 1 reset
I2C1RST : Boolean := False;
-- I2C 2 reset
I2C2RST : Boolean := False;
-- I2C3 reset
I2C3RST : Boolean := False;
-- unspecified
Reserved_24_24 : Bits_1 := 16#0#;
-- CAN1 reset
CAN1RST : Boolean := False;
-- CAN2 reset
CAN2RST : Boolean := False;
-- unspecified
Reserved_27_27 : Bits_1 := 16#0#;
-- Power interface reset
PWRRST : Boolean := False;
-- DAC reset
DACRST : Boolean := False;
-- UART7 reset
UART7RST : Boolean := False;
-- UART8 reset
UART8RST : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for APB1RSTR_Register use record
TIM2RST at 0 range 0 .. 0;
TIM3RST at 0 range 1 .. 1;
TIM4RST at 0 range 2 .. 2;
TIM5RST at 0 range 3 .. 3;
TIM6RST at 0 range 4 .. 4;
TIM7RST at 0 range 5 .. 5;
TIM12RST at 0 range 6 .. 6;
TIM13RST at 0 range 7 .. 7;
TIM14RST at 0 range 8 .. 8;
Reserved_9_10 at 0 range 9 .. 10;
WWDGRST at 0 range 11 .. 11;
Reserved_12_13 at 0 range 12 .. 13;
SPI2RST at 0 range 14 .. 14;
SPI3RST at 0 range 15 .. 15;
Reserved_16_16 at 0 range 16 .. 16;
UART2RST at 0 range 17 .. 17;
UART3RST at 0 range 18 .. 18;
UART4RST at 0 range 19 .. 19;
UART5RST at 0 range 20 .. 20;
I2C1RST at 0 range 21 .. 21;
I2C2RST at 0 range 22 .. 22;
I2C3RST at 0 range 23 .. 23;
Reserved_24_24 at 0 range 24 .. 24;
CAN1RST at 0 range 25 .. 25;
CAN2RST at 0 range 26 .. 26;
Reserved_27_27 at 0 range 27 .. 27;
PWRRST at 0 range 28 .. 28;
DACRST at 0 range 29 .. 29;
UART7RST at 0 range 30 .. 30;
UART8RST at 0 range 31 .. 31;
end record;
-----------------------
-- APB2RSTR_Register --
-----------------------
-- APB2 peripheral reset register
type APB2RSTR_Register is record
-- TIM1 reset
TIM1RST : Boolean := False;
-- TIM8 reset
TIM8RST : Boolean := False;
-- unspecified
Reserved_2_3 : Bits_2 := 16#0#;
-- USART1 reset
USART1RST : Boolean := False;
-- USART6 reset
USART6RST : Boolean := False;
-- unspecified
Reserved_6_7 : Bits_2 := 16#0#;
-- ADC interface reset (common to all ADCs)
ADCRST : Boolean := False;
-- unspecified
Reserved_9_10 : Bits_2 := 16#0#;
-- SDIO reset
SDIORST : Boolean := False;
-- SPI 1 reset
SPI1RST : Boolean := False;
-- SPI4 reset
SPI4RST : Boolean := False;
-- System configuration controller reset
SYSCFGRST : Boolean := False;
-- unspecified
Reserved_15_15 : Bits_1 := 16#0#;
-- TIM9 reset
TIM9RST : Boolean := False;
-- TIM10 reset
TIM10RST : Boolean := False;
-- TIM11 reset
TIM11RST : Boolean := False;
-- unspecified
Reserved_19_19 : Bits_1 := 16#0#;
-- SPI5 reset
SPI5RST : Boolean := False;
-- SPI6 reset
SPI6RST : Boolean := False;
-- SAI1 reset
SAI1RST : Boolean := False;
-- unspecified
Reserved_23_25 : Bits_3 := 16#0#;
-- LTDC reset
LTDCRST : Boolean := False;
-- unspecified
Reserved_27_31 : Bits_5 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for APB2RSTR_Register use record
TIM1RST at 0 range 0 .. 0;
TIM8RST at 0 range 1 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
USART1RST at 0 range 4 .. 4;
USART6RST at 0 range 5 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
ADCRST at 0 range 8 .. 8;
Reserved_9_10 at 0 range 9 .. 10;
SDIORST at 0 range 11 .. 11;
SPI1RST at 0 range 12 .. 12;
SPI4RST at 0 range 13 .. 13;
SYSCFGRST at 0 range 14 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
TIM9RST at 0 range 16 .. 16;
TIM10RST at 0 range 17 .. 17;
TIM11RST at 0 range 18 .. 18;
Reserved_19_19 at 0 range 19 .. 19;
SPI5RST at 0 range 20 .. 20;
SPI6RST at 0 range 21 .. 21;
SAI1RST at 0 range 22 .. 22;
Reserved_23_25 at 0 range 23 .. 25;
LTDCRST at 0 range 26 .. 26;
Reserved_27_31 at 0 range 27 .. 31;
end record;
----------------------
-- AHB1ENR_Register --
----------------------
-- AHB1 peripheral clock register
type AHB1ENR_Register is record
-- IO port A clock enable
GPIOAEN : Boolean := False;
-- IO port B clock enable
GPIOBEN : Boolean := False;
-- IO port C clock enable
GPIOCEN : Boolean := False;
-- IO port D clock enable
GPIODEN : Boolean := False;
-- IO port E clock enable
GPIOEEN : Boolean := False;
-- IO port F clock enable
GPIOFEN : Boolean := False;
-- IO port G clock enable
GPIOGEN : Boolean := False;
-- IO port H clock enable
GPIOHEN : Boolean := False;
-- IO port I clock enable
GPIOIEN : Boolean := False;
-- IO port J clock enable
GPIOJEN : Boolean := False;
-- IO port K clock enable
GPIOKEN : Boolean := False;
-- unspecified
Reserved_11_11 : Bits_1 := 16#0#;
-- CRC clock enable
CRCEN : Boolean := False;
-- unspecified
Reserved_13_17 : Bits_5 := 16#0#;
-- Backup SRAM interface clock enable
BKPSRAMEN : Boolean := False;
-- unspecified
Reserved_19_19 : Bits_1 := 16#0#;
-- CCM data RAM clock enable
CCMDATARAMEN : Boolean := True;
-- DMA1 clock enable
DMA1EN : Boolean := False;
-- DMA2 clock enable
DMA2EN : Boolean := False;
-- DMA2D clock enable
DMA2DEN : Boolean := False;
-- unspecified
Reserved_24_24 : Bits_1 := 16#0#;
-- Ethernet MAC clock enable
ETHMACEN : Boolean := False;
-- Ethernet Transmission clock enable
ETHMACTXEN : Boolean := False;
-- Ethernet Reception clock enable
ETHMACRXEN : Boolean := False;
-- Ethernet PTP clock enable
ETHMACPTPEN : Boolean := False;
-- USB OTG HS clock enable
OTGHSEN : Boolean := False;
-- USB OTG HSULPI clock enable
OTGHSULPIEN : Boolean := False;
-- unspecified
Reserved_31_31 : Bits_1 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AHB1ENR_Register use record
GPIOAEN at 0 range 0 .. 0;
GPIOBEN at 0 range 1 .. 1;
GPIOCEN at 0 range 2 .. 2;
GPIODEN at 0 range 3 .. 3;
GPIOEEN at 0 range 4 .. 4;
GPIOFEN at 0 range 5 .. 5;
GPIOGEN at 0 range 6 .. 6;
GPIOHEN at 0 range 7 .. 7;
GPIOIEN at 0 range 8 .. 8;
GPIOJEN at 0 range 9 .. 9;
GPIOKEN at 0 range 10 .. 10;
Reserved_11_11 at 0 range 11 .. 11;
CRCEN at 0 range 12 .. 12;
Reserved_13_17 at 0 range 13 .. 17;
BKPSRAMEN at 0 range 18 .. 18;
Reserved_19_19 at 0 range 19 .. 19;
CCMDATARAMEN at 0 range 20 .. 20;
DMA1EN at 0 range 21 .. 21;
DMA2EN at 0 range 22 .. 22;
DMA2DEN at 0 range 23 .. 23;
Reserved_24_24 at 0 range 24 .. 24;
ETHMACEN at 0 range 25 .. 25;
ETHMACTXEN at 0 range 26 .. 26;
ETHMACRXEN at 0 range 27 .. 27;
ETHMACPTPEN at 0 range 28 .. 28;
OTGHSEN at 0 range 29 .. 29;
OTGHSULPIEN at 0 range 30 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
----------------------
-- AHB2ENR_Register --
----------------------
-- AHB2 peripheral clock enable register
type AHB2ENR_Register is record
-- Camera interface enable
DCMIEN : Boolean := False;
-- unspecified
Reserved_1_5 : Bits_5 := 16#0#;
-- Random number generator clock enable
RNGEN : Boolean := False;
-- USB OTG FS clock enable
OTGFSEN : Boolean := False;
-- unspecified
Reserved_8_31 : Bits_24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AHB2ENR_Register use record
DCMIEN at 0 range 0 .. 0;
Reserved_1_5 at 0 range 1 .. 5;
RNGEN at 0 range 6 .. 6;
OTGFSEN at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
----------------------
-- AHB3ENR_Register --
----------------------
-- AHB3 peripheral clock enable register
type AHB3ENR_Register is record
-- Flexible memory controller module clock enable
FMCEN : Boolean := False;
-- unspecified
Reserved_1_31 : Bits_31 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AHB3ENR_Register use record
FMCEN at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
----------------------
-- APB1ENR_Register --
----------------------
-- APB1 peripheral clock enable register
type APB1ENR_Register is record
-- TIM2 clock enable
TIM2EN : Boolean := False;
-- TIM3 clock enable
TIM3EN : Boolean := False;
-- TIM4 clock enable
TIM4EN : Boolean := False;
-- TIM5 clock enable
TIM5EN : Boolean := False;
-- TIM6 clock enable
TIM6EN : Boolean := False;
-- TIM7 clock enable
TIM7EN : Boolean := False;
-- TIM12 clock enable
TIM12EN : Boolean := False;
-- TIM13 clock enable
TIM13EN : Boolean := False;
-- TIM14 clock enable
TIM14EN : Boolean := False;
-- unspecified
Reserved_9_10 : Bits_2 := 16#0#;
-- Window watchdog clock enable
WWDGEN : Boolean := False;
-- unspecified
Reserved_12_13 : Bits_2 := 16#0#;
-- SPI2 clock enable
SPI2EN : Boolean := False;
-- SPI3 clock enable
SPI3EN : Boolean := False;
-- unspecified
Reserved_16_16 : Bits_1 := 16#0#;
-- USART 2 clock enable
USART2EN : Boolean := False;
-- USART3 clock enable
USART3EN : Boolean := False;
-- UART4 clock enable
UART4EN : Boolean := False;
-- UART5 clock enable
UART5EN : Boolean := False;
-- I2C1 clock enable
I2C1EN : Boolean := False;
-- I2C2 clock enable
I2C2EN : Boolean := False;
-- I2C3 clock enable
I2C3EN : Boolean := False;
-- unspecified
Reserved_24_24 : Bits_1 := 16#0#;
-- CAN 1 clock enable
CAN1EN : Boolean := False;
-- CAN 2 clock enable
CAN2EN : Boolean := False;
-- unspecified
Reserved_27_27 : Bits_1 := 16#0#;
-- Power interface clock enable
PWREN : Boolean := False;
-- DAC interface clock enable
DACEN : Boolean := False;
-- UART7 clock enable
UART7ENR : Boolean := False;
-- UART8 clock enable
UART8ENR : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for APB1ENR_Register use record
TIM2EN at 0 range 0 .. 0;
TIM3EN at 0 range 1 .. 1;
TIM4EN at 0 range 2 .. 2;
TIM5EN at 0 range 3 .. 3;
TIM6EN at 0 range 4 .. 4;
TIM7EN at 0 range 5 .. 5;
TIM12EN at 0 range 6 .. 6;
TIM13EN at 0 range 7 .. 7;
TIM14EN at 0 range 8 .. 8;
Reserved_9_10 at 0 range 9 .. 10;
WWDGEN at 0 range 11 .. 11;
Reserved_12_13 at 0 range 12 .. 13;
SPI2EN at 0 range 14 .. 14;
SPI3EN at 0 range 15 .. 15;
Reserved_16_16 at 0 range 16 .. 16;
USART2EN at 0 range 17 .. 17;
USART3EN at 0 range 18 .. 18;
UART4EN at 0 range 19 .. 19;
UART5EN at 0 range 20 .. 20;
I2C1EN at 0 range 21 .. 21;
I2C2EN at 0 range 22 .. 22;
I2C3EN at 0 range 23 .. 23;
Reserved_24_24 at 0 range 24 .. 24;
CAN1EN at 0 range 25 .. 25;
CAN2EN at 0 range 26 .. 26;
Reserved_27_27 at 0 range 27 .. 27;
PWREN at 0 range 28 .. 28;
DACEN at 0 range 29 .. 29;
UART7ENR at 0 range 30 .. 30;
UART8ENR at 0 range 31 .. 31;
end record;
----------------------
-- APB2ENR_Register --
----------------------
-- APB2 peripheral clock enable register
type APB2ENR_Register is record
-- TIM1 clock enable
TIM1EN : Boolean := False;
-- TIM8 clock enable
TIM8EN : Boolean := False;
-- unspecified
Reserved_2_3 : Bits_2 := 16#0#;
-- USART1 clock enable
USART1EN : Boolean := False;
-- USART6 clock enable
USART6EN : Boolean := False;
-- unspecified
Reserved_6_7 : Bits_2 := 16#0#;
-- ADC1 clock enable
ADC1EN : Boolean := False;
-- ADC2 clock enable
ADC2EN : Boolean := False;
-- ADC3 clock enable
ADC3EN : Boolean := False;
-- SDIO clock enable
SDIOEN : Boolean := False;
-- SPI1 clock enable
SPI1EN : Boolean := False;
-- SPI4 clock enable
SPI4ENR : Boolean := False;
-- System configuration controller clock enable
SYSCFGEN : Boolean := False;
-- unspecified
Reserved_15_15 : Bits_1 := 16#0#;
-- TIM9 clock enable
TIM9EN : Boolean := False;
-- TIM10 clock enable
TIM10EN : Boolean := False;
-- TIM11 clock enable
TIM11EN : Boolean := False;
-- unspecified
Reserved_19_19 : Bits_1 := 16#0#;
-- SPI5 clock enable
SPI5ENR : Boolean := False;
-- SPI6 clock enable
SPI6ENR : Boolean := False;
-- SAI1 clock enable
SAI1EN : Boolean := False;
-- unspecified
Reserved_23_25 : Bits_3 := 16#0#;
-- LTDC clock enable
LTDCEN : Boolean := False;
-- unspecified
Reserved_27_31 : Bits_5 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for APB2ENR_Register use record
TIM1EN at 0 range 0 .. 0;
TIM8EN at 0 range 1 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
USART1EN at 0 range 4 .. 4;
USART6EN at 0 range 5 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
ADC1EN at 0 range 8 .. 8;
ADC2EN at 0 range 9 .. 9;
ADC3EN at 0 range 10 .. 10;
SDIOEN at 0 range 11 .. 11;
SPI1EN at 0 range 12 .. 12;
SPI4ENR at 0 range 13 .. 13;
SYSCFGEN at 0 range 14 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
TIM9EN at 0 range 16 .. 16;
TIM10EN at 0 range 17 .. 17;
TIM11EN at 0 range 18 .. 18;
Reserved_19_19 at 0 range 19 .. 19;
SPI5ENR at 0 range 20 .. 20;
SPI6ENR at 0 range 21 .. 21;
SAI1EN at 0 range 22 .. 22;
Reserved_23_25 at 0 range 23 .. 25;
LTDCEN at 0 range 26 .. 26;
Reserved_27_31 at 0 range 27 .. 31;
end record;
------------------------
-- AHB1LPENR_Register --
------------------------
-- AHB1 peripheral clock enable in low power mode register
type AHB1LPENR_Register is record
-- IO port A clock enable during sleep mode
GPIOALPEN : Boolean := True;
-- IO port B clock enable during Sleep mode
GPIOBLPEN : Boolean := True;
-- IO port C clock enable during Sleep mode
GPIOCLPEN : Boolean := True;
-- IO port D clock enable during Sleep mode
GPIODLPEN : Boolean := True;
-- IO port E clock enable during Sleep mode
GPIOELPEN : Boolean := True;
-- IO port F clock enable during Sleep mode
GPIOFLPEN : Boolean := True;
-- IO port G clock enable during Sleep mode
GPIOGLPEN : Boolean := True;
-- IO port H clock enable during Sleep mode
GPIOHLPEN : Boolean := True;
-- IO port I clock enable during Sleep mode
GPIOILPEN : Boolean := True;
-- IO port J clock enable during Sleep mode
GPIOJLPEN : Boolean := False;
-- IO port K clock enable during Sleep mode
GPIOKLPEN : Boolean := False;
-- unspecified
Reserved_11_11 : Bits_1 := 16#0#;
-- CRC clock enable during Sleep mode
CRCLPEN : Boolean := True;
-- unspecified
Reserved_13_14 : Bits_2 := 16#0#;
-- Flash interface clock enable during Sleep mode
FLITFLPEN : Boolean := True;
-- SRAM 1interface clock enable during Sleep mode
SRAM1LPEN : Boolean := True;
-- SRAM 2 interface clock enable during Sleep mode
SRAM2LPEN : Boolean := True;
-- Backup SRAM interface clock enable during Sleep mode
BKPSRAMLPEN : Boolean := True;
-- SRAM 3 interface clock enable during Sleep mode
SRAM3LPEN : Boolean := False;
-- unspecified
Reserved_20_20 : Bits_1 := 16#0#;
-- DMA1 clock enable during Sleep mode
DMA1LPEN : Boolean := True;
-- DMA2 clock enable during Sleep mode
DMA2LPEN : Boolean := True;
-- DMA2D clock enable during Sleep mode
DMA2DLPEN : Boolean := False;
-- unspecified
Reserved_24_24 : Bits_1 := 16#0#;
-- Ethernet MAC clock enable during Sleep mode
ETHMACLPEN : Boolean := True;
-- Ethernet transmission clock enable during Sleep mode
ETHMACTXLPEN : Boolean := True;
-- Ethernet reception clock enable during Sleep mode
ETHMACRXLPEN : Boolean := True;
-- Ethernet PTP clock enable during Sleep mode
ETHMACPTPLPEN : Boolean := True;
-- USB OTG HS clock enable during Sleep mode
OTGHSLPEN : Boolean := True;
-- USB OTG HS ULPI clock enable during Sleep mode
OTGHSULPILPEN : Boolean := True;
-- unspecified
Reserved_31_31 : Bits_1 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AHB1LPENR_Register use record
GPIOALPEN at 0 range 0 .. 0;
GPIOBLPEN at 0 range 1 .. 1;
GPIOCLPEN at 0 range 2 .. 2;
GPIODLPEN at 0 range 3 .. 3;
GPIOELPEN at 0 range 4 .. 4;
GPIOFLPEN at 0 range 5 .. 5;
GPIOGLPEN at 0 range 6 .. 6;
GPIOHLPEN at 0 range 7 .. 7;
GPIOILPEN at 0 range 8 .. 8;
GPIOJLPEN at 0 range 9 .. 9;
GPIOKLPEN at 0 range 10 .. 10;
Reserved_11_11 at 0 range 11 .. 11;
CRCLPEN at 0 range 12 .. 12;
Reserved_13_14 at 0 range 13 .. 14;
FLITFLPEN at 0 range 15 .. 15;
SRAM1LPEN at 0 range 16 .. 16;
SRAM2LPEN at 0 range 17 .. 17;
BKPSRAMLPEN at 0 range 18 .. 18;
SRAM3LPEN at 0 range 19 .. 19;
Reserved_20_20 at 0 range 20 .. 20;
DMA1LPEN at 0 range 21 .. 21;
DMA2LPEN at 0 range 22 .. 22;
DMA2DLPEN at 0 range 23 .. 23;
Reserved_24_24 at 0 range 24 .. 24;
ETHMACLPEN at 0 range 25 .. 25;
ETHMACTXLPEN at 0 range 26 .. 26;
ETHMACRXLPEN at 0 range 27 .. 27;
ETHMACPTPLPEN at 0 range 28 .. 28;
OTGHSLPEN at 0 range 29 .. 29;
OTGHSULPILPEN at 0 range 30 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
------------------------
-- AHB2LPENR_Register --
------------------------
-- AHB2 peripheral clock enable in low power mode register
type AHB2LPENR_Register is record
-- Camera interface enable during Sleep mode
DCMILPEN : Boolean := True;
-- unspecified
Reserved_1_5 : Bits_5 := 16#18#;
-- Random number generator clock enable during Sleep mode
RNGLPEN : Boolean := True;
-- USB OTG FS clock enable during Sleep mode
OTGFSLPEN : Boolean := True;
-- unspecified
Reserved_8_31 : Bits_24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AHB2LPENR_Register use record
DCMILPEN at 0 range 0 .. 0;
Reserved_1_5 at 0 range 1 .. 5;
RNGLPEN at 0 range 6 .. 6;
OTGFSLPEN at 0 range 7 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
------------------------
-- AHB3LPENR_Register --
------------------------
-- AHB3 peripheral clock enable in low power mode register
type AHB3LPENR_Register is record
-- Flexible memory controller module clock enable during Sleep mode
FMCLPEN : Boolean := True;
-- unspecified
Reserved_1_31 : Bits_31 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for AHB3LPENR_Register use record
FMCLPEN at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
------------------------
-- APB1LPENR_Register --
------------------------
-- APB1 peripheral clock enable in low power mode register
type APB1LPENR_Register is record
-- TIM2 clock enable during Sleep mode
TIM2LPEN : Boolean := True;
-- TIM3 clock enable during Sleep mode
TIM3LPEN : Boolean := True;
-- TIM4 clock enable during Sleep mode
TIM4LPEN : Boolean := True;
-- TIM5 clock enable during Sleep mode
TIM5LPEN : Boolean := True;
-- TIM6 clock enable during Sleep mode
TIM6LPEN : Boolean := True;
-- TIM7 clock enable during Sleep mode
TIM7LPEN : Boolean := True;
-- TIM12 clock enable during Sleep mode
TIM12LPEN : Boolean := True;
-- TIM13 clock enable during Sleep mode
TIM13LPEN : Boolean := True;
-- TIM14 clock enable during Sleep mode
TIM14LPEN : Boolean := True;
-- unspecified
Reserved_9_10 : Bits_2 := 16#0#;
-- Window watchdog clock enable during Sleep mode
WWDGLPEN : Boolean := True;
-- unspecified
Reserved_12_13 : Bits_2 := 16#0#;
-- SPI2 clock enable during Sleep mode
SPI2LPEN : Boolean := True;
-- SPI3 clock enable during Sleep mode
SPI3LPEN : Boolean := True;
-- unspecified
Reserved_16_16 : Bits_1 := 16#0#;
-- USART2 clock enable during Sleep mode
USART2LPEN : Boolean := True;
-- USART3 clock enable during Sleep mode
USART3LPEN : Boolean := True;
-- UART4 clock enable during Sleep mode
UART4LPEN : Boolean := True;
-- UART5 clock enable during Sleep mode
UART5LPEN : Boolean := True;
-- I2C1 clock enable during Sleep mode
I2C1LPEN : Boolean := True;
-- I2C2 clock enable during Sleep mode
I2C2LPEN : Boolean := True;
-- I2C3 clock enable during Sleep mode
I2C3LPEN : Boolean := True;
-- unspecified
Reserved_24_24 : Bits_1 := 16#0#;
-- CAN 1 clock enable during Sleep mode
CAN1LPEN : Boolean := True;
-- CAN 2 clock enable during Sleep mode
CAN2LPEN : Boolean := True;
-- unspecified
Reserved_27_27 : Bits_1 := 16#0#;
-- Power interface clock enable during Sleep mode
PWRLPEN : Boolean := True;
-- DAC interface clock enable during Sleep mode
DACLPEN : Boolean := True;
-- UART7 clock enable during Sleep mode
UART7LPEN : Boolean := False;
-- UART8 clock enable during Sleep mode
UART8LPEN : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for APB1LPENR_Register use record
TIM2LPEN at 0 range 0 .. 0;
TIM3LPEN at 0 range 1 .. 1;
TIM4LPEN at 0 range 2 .. 2;
TIM5LPEN at 0 range 3 .. 3;
TIM6LPEN at 0 range 4 .. 4;
TIM7LPEN at 0 range 5 .. 5;
TIM12LPEN at 0 range 6 .. 6;
TIM13LPEN at 0 range 7 .. 7;
TIM14LPEN at 0 range 8 .. 8;
Reserved_9_10 at 0 range 9 .. 10;
WWDGLPEN at 0 range 11 .. 11;
Reserved_12_13 at 0 range 12 .. 13;
SPI2LPEN at 0 range 14 .. 14;
SPI3LPEN at 0 range 15 .. 15;
Reserved_16_16 at 0 range 16 .. 16;
USART2LPEN at 0 range 17 .. 17;
USART3LPEN at 0 range 18 .. 18;
UART4LPEN at 0 range 19 .. 19;
UART5LPEN at 0 range 20 .. 20;
I2C1LPEN at 0 range 21 .. 21;
I2C2LPEN at 0 range 22 .. 22;
I2C3LPEN at 0 range 23 .. 23;
Reserved_24_24 at 0 range 24 .. 24;
CAN1LPEN at 0 range 25 .. 25;
CAN2LPEN at 0 range 26 .. 26;
Reserved_27_27 at 0 range 27 .. 27;
PWRLPEN at 0 range 28 .. 28;
DACLPEN at 0 range 29 .. 29;
UART7LPEN at 0 range 30 .. 30;
UART8LPEN at 0 range 31 .. 31;
end record;
------------------------
-- APB2LPENR_Register --
------------------------
-- APB2 peripheral clock enabled in low power mode register
type APB2LPENR_Register is record
-- TIM1 clock enable during Sleep mode
TIM1LPEN : Boolean := True;
-- TIM8 clock enable during Sleep mode
TIM8LPEN : Boolean := True;
-- unspecified
Reserved_2_3 : Bits_2 := 16#0#;
-- USART1 clock enable during Sleep mode
USART1LPEN : Boolean := True;
-- USART6 clock enable during Sleep mode
USART6LPEN : Boolean := True;
-- unspecified
Reserved_6_7 : Bits_2 := 16#0#;
-- ADC1 clock enable during Sleep mode
ADC1LPEN : Boolean := True;
-- ADC2 clock enable during Sleep mode
ADC2LPEN : Boolean := True;
-- ADC 3 clock enable during Sleep mode
ADC3LPEN : Boolean := True;
-- SDIO clock enable during Sleep mode
SDIOLPEN : Boolean := True;
-- SPI 1 clock enable during Sleep mode
SPI1LPEN : Boolean := True;
-- SPI 4 clock enable during Sleep mode
SPI4LPEN : Boolean := False;
-- System configuration controller clock enable during Sleep mode
SYSCFGLPEN : Boolean := True;
-- unspecified
Reserved_15_15 : Bits_1 := 16#0#;
-- TIM9 clock enable during sleep mode
TIM9LPEN : Boolean := True;
-- TIM10 clock enable during Sleep mode
TIM10LPEN : Boolean := True;
-- TIM11 clock enable during Sleep mode
TIM11LPEN : Boolean := True;
-- unspecified
Reserved_19_19 : Bits_1 := 16#0#;
-- SPI 5 clock enable during Sleep mode
SPI5LPEN : Boolean := False;
-- SPI 6 clock enable during Sleep mode
SPI6LPEN : Boolean := False;
-- SAI1 clock enable
SAI1LPEN : Boolean := False;
-- unspecified
Reserved_23_25 : Bits_3 := 16#0#;
-- LTDC clock enable
LTDCLPEN : Boolean := False;
-- unspecified
Reserved_27_31 : Bits_5 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for APB2LPENR_Register use record
TIM1LPEN at 0 range 0 .. 0;
TIM8LPEN at 0 range 1 .. 1;
Reserved_2_3 at 0 range 2 .. 3;
USART1LPEN at 0 range 4 .. 4;
USART6LPEN at 0 range 5 .. 5;
Reserved_6_7 at 0 range 6 .. 7;
ADC1LPEN at 0 range 8 .. 8;
ADC2LPEN at 0 range 9 .. 9;
ADC3LPEN at 0 range 10 .. 10;
SDIOLPEN at 0 range 11 .. 11;
SPI1LPEN at 0 range 12 .. 12;
SPI4LPEN at 0 range 13 .. 13;
SYSCFGLPEN at 0 range 14 .. 14;
Reserved_15_15 at 0 range 15 .. 15;
TIM9LPEN at 0 range 16 .. 16;
TIM10LPEN at 0 range 17 .. 17;
TIM11LPEN at 0 range 18 .. 18;
Reserved_19_19 at 0 range 19 .. 19;
SPI5LPEN at 0 range 20 .. 20;
SPI6LPEN at 0 range 21 .. 21;
SAI1LPEN at 0 range 22 .. 22;
Reserved_23_25 at 0 range 23 .. 25;
LTDCLPEN at 0 range 26 .. 26;
Reserved_27_31 at 0 range 27 .. 31;
end record;
-------------------
-- BDCR_Register --
-------------------
-----------------
-- BDCR.RTCSEL --
-----------------
-- BDCR_RTCSEL array
type BDCR_RTCSEL_Field_Array is array (0 .. 1) of Boolean
with Component_Size => 1, Size => 2;
-- Type definition for BDCR_RTCSEL
type BDCR_RTCSEL_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- RTCSEL as a value
Val : Bits_2;
when True =>
-- RTCSEL as an array
Arr : BDCR_RTCSEL_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for BDCR_RTCSEL_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- Backup domain control register
type BDCR_Register is record
-- External low-speed oscillator enable
LSEON : Boolean := False;
-- Read-only. External low-speed oscillator ready
LSERDY : Boolean := False;
-- External low-speed oscillator bypass
LSEBYP : Boolean := False;
-- unspecified
Reserved_3_7 : Bits_5 := 16#0#;
-- RTC clock source selection
RTCSEL : BDCR_RTCSEL_Field := (As_Array => False, Val => 16#0#);
-- unspecified
Reserved_10_14 : Bits_5 := 16#0#;
-- RTC clock enable
RTCEN : Boolean := False;
-- Backup domain software reset
BDRST : Boolean := False;
-- unspecified
Reserved_17_31 : Bits_15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BDCR_Register use record
LSEON at 0 range 0 .. 0;
LSERDY at 0 range 1 .. 1;
LSEBYP at 0 range 2 .. 2;
Reserved_3_7 at 0 range 3 .. 7;
RTCSEL at 0 range 8 .. 9;
Reserved_10_14 at 0 range 10 .. 14;
RTCEN at 0 range 15 .. 15;
BDRST at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
------------------
-- CSR_Register --
------------------
-- clock control & status register
type CSR_Register is record
-- Internal low-speed oscillator enable
LSION : Boolean := False;
-- Read-only. Internal low-speed oscillator ready
LSIRDY : Boolean := False;
-- unspecified
Reserved_2_23 : Bits_22 := 16#0#;
-- Remove reset flag
RMVF : Boolean := False;
-- BOR reset flag
BORRSTF : Boolean := True;
-- PIN reset flag
PADRSTF : Boolean := True;
-- POR/PDR reset flag
PORRSTF : Boolean := True;
-- Software reset flag
SFTRSTF : Boolean := False;
-- Independent watchdog reset flag
WDGRSTF : Boolean := False;
-- Window watchdog reset flag
WWDGRSTF : Boolean := False;
-- Low-power reset flag
LPWRRSTF : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CSR_Register use record
LSION at 0 range 0 .. 0;
LSIRDY at 0 range 1 .. 1;
Reserved_2_23 at 0 range 2 .. 23;
RMVF at 0 range 24 .. 24;
BORRSTF at 0 range 25 .. 25;
PADRSTF at 0 range 26 .. 26;
PORRSTF at 0 range 27 .. 27;
SFTRSTF at 0 range 28 .. 28;
WDGRSTF at 0 range 29 .. 29;
WWDGRSTF at 0 range 30 .. 30;
LPWRRSTF at 0 range 31 .. 31;
end record;
--------------------
-- SSCGR_Register --
--------------------
subtype SSCGR_MODPER_Field is Bits_13;
subtype SSCGR_INCSTEP_Field is Bits_15;
-- spread spectrum clock generation register
type SSCGR_Register is record
-- Modulation period
MODPER : SSCGR_MODPER_Field := 16#0#;
-- Incrementation step
INCSTEP : SSCGR_INCSTEP_Field := 16#0#;
-- unspecified
Reserved_28_29 : Bits_2 := 16#0#;
-- Spread Select
SPREADSEL : Boolean := False;
-- Spread spectrum modulation enable
SSCGEN : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SSCGR_Register use record
MODPER at 0 range 0 .. 12;
INCSTEP at 0 range 13 .. 27;
Reserved_28_29 at 0 range 28 .. 29;
SPREADSEL at 0 range 30 .. 30;
SSCGEN at 0 range 31 .. 31;
end record;
-------------------------
-- PLLI2SCFGR_Register --
-------------------------
subtype PLLI2SCFGR_PLLI2SN_Field is Bits_9;
subtype PLLI2SCFGR_PLLI2SQ_Field is Bits_4;
subtype PLLI2SCFGR_PLLI2SR_Field is Bits_3;
-- PLLI2S configuration register
type PLLI2SCFGR_Register is record
-- unspecified
Reserved_0_5 : Bits_6 := 16#0#;
-- PLLI2S multiplication factor for VCO
PLLI2SN : PLLI2SCFGR_PLLI2SN_Field := 16#C0#;
-- unspecified
Reserved_15_23 : Bits_9 := 16#0#;
-- PLLI2S division factor for SAI1 clock
PLLI2SQ : PLLI2SCFGR_PLLI2SQ_Field := 16#0#;
-- PLLI2S division factor for I2S clocks
PLLI2SR : PLLI2SCFGR_PLLI2SR_Field := 16#2#;
-- unspecified
Reserved_31_31 : Bits_1 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PLLI2SCFGR_Register use record
Reserved_0_5 at 0 range 0 .. 5;
PLLI2SN at 0 range 6 .. 14;
Reserved_15_23 at 0 range 15 .. 23;
PLLI2SQ at 0 range 24 .. 27;
PLLI2SR at 0 range 28 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
-------------------------
-- PLLSAICFGR_Register --
-------------------------
subtype PLLSAICFGR_PLLSAIN_Field is Bits_9;
subtype PLLSAICFGR_PLLSAIQ_Field is Bits_4;
subtype PLLSAICFGR_PLLSAIR_Field is Bits_3;
-- PLLSAICFGR
type PLLSAICFGR_Register is record
-- unspecified
Reserved_0_5 : Bits_6 := 16#0#;
-- PLLSAIN
PLLSAIN : PLLSAICFGR_PLLSAIN_Field := 16#C0#;
-- unspecified
Reserved_15_23 : Bits_9 := 16#0#;
-- PLLSAIN
PLLSAIQ : PLLSAICFGR_PLLSAIQ_Field := 16#4#;
-- PLLSAIN
PLLSAIR : PLLSAICFGR_PLLSAIR_Field := 16#2#;
-- unspecified
Reserved_31_31 : Bits_1 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PLLSAICFGR_Register use record
Reserved_0_5 at 0 range 0 .. 5;
PLLSAIN at 0 range 6 .. 14;
Reserved_15_23 at 0 range 15 .. 23;
PLLSAIQ at 0 range 24 .. 27;
PLLSAIR at 0 range 28 .. 30;
Reserved_31_31 at 0 range 31 .. 31;
end record;
----------------------
-- DCKCFGR_Register --
----------------------
subtype DCKCFGR_PLLI2SDIVQ_Field is Bits_5;
subtype DCKCFGR_PLLSAIDIVQ_Field is Bits_5;
subtype DCKCFGR_PLLSAIDIVR_Field is Bits_2;
subtype DCKCFGR_SAI1ASRC_Field is Bits_2;
subtype DCKCFGR_SAI1BSRC_Field is Bits_2;
-- DCKCFGR
type DCKCFGR_Register is record
-- PLLI2SDIVQ
PLLI2SDIVQ : DCKCFGR_PLLI2SDIVQ_Field := 16#0#;
-- unspecified
Reserved_5_7 : Bits_3 := 16#0#;
-- PLLSAIDIVQ
PLLSAIDIVQ : DCKCFGR_PLLSAIDIVQ_Field := 16#0#;
-- unspecified
Reserved_13_15 : Bits_3 := 16#0#;
-- PLLSAIDIVR
PLLSAIDIVR : DCKCFGR_PLLSAIDIVR_Field := 16#0#;
-- unspecified
Reserved_18_19 : Bits_2 := 16#0#;
-- SAI1ASRC
SAI1ASRC : DCKCFGR_SAI1ASRC_Field := 16#0#;
-- SAI1BSRC
SAI1BSRC : DCKCFGR_SAI1BSRC_Field := 16#0#;
-- TIMPRE
TIMPRE : Boolean := False;
-- unspecified
Reserved_25_31 : Bits_7 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DCKCFGR_Register use record
PLLI2SDIVQ at 0 range 0 .. 4;
Reserved_5_7 at 0 range 5 .. 7;
PLLSAIDIVQ at 0 range 8 .. 12;
Reserved_13_15 at 0 range 13 .. 15;
PLLSAIDIVR at 0 range 16 .. 17;
Reserved_18_19 at 0 range 18 .. 19;
SAI1ASRC at 0 range 20 .. 21;
SAI1BSRC at 0 range 22 .. 23;
TIMPRE at 0 range 24 .. 24;
Reserved_25_31 at 0 range 25 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Reset and clock control
type RCC_Peripheral is record
-- clock control register
CR : CR_Register;
-- PLL configuration register
PLLCFGR : PLLCFGR_Register;
-- clock configuration register
CFGR : CFGR_Register;
-- clock interrupt register
CIR : CIR_Register;
-- AHB1 peripheral reset register
AHB1RSTR : AHB1RSTR_Register;
-- AHB2 peripheral reset register
AHB2RSTR : AHB2RSTR_Register;
-- AHB3 peripheral reset register
AHB3RSTR : AHB3RSTR_Register;
-- APB1 peripheral reset register
APB1RSTR : APB1RSTR_Register;
-- APB2 peripheral reset register
APB2RSTR : APB2RSTR_Register;
-- AHB1 peripheral clock register
AHB1ENR : AHB1ENR_Register;
-- AHB2 peripheral clock enable register
AHB2ENR : AHB2ENR_Register;
-- AHB3 peripheral clock enable register
AHB3ENR : AHB3ENR_Register;
-- APB1 peripheral clock enable register
APB1ENR : APB1ENR_Register;
-- APB2 peripheral clock enable register
APB2ENR : APB2ENR_Register;
-- AHB1 peripheral clock enable in low power mode register
AHB1LPENR : AHB1LPENR_Register;
-- AHB2 peripheral clock enable in low power mode register
AHB2LPENR : AHB2LPENR_Register;
-- AHB3 peripheral clock enable in low power mode register
AHB3LPENR : AHB3LPENR_Register;
-- APB1 peripheral clock enable in low power mode register
APB1LPENR : APB1LPENR_Register;
-- APB2 peripheral clock enabled in low power mode register
APB2LPENR : APB2LPENR_Register;
-- Backup domain control register
BDCR : BDCR_Register;
-- clock control & status register
CSR : CSR_Register;
-- spread spectrum clock generation register
SSCGR : SSCGR_Register;
-- PLLI2S configuration register
PLLI2SCFGR : PLLI2SCFGR_Register;
-- PLLSAICFGR
PLLSAICFGR : PLLSAICFGR_Register;
-- DCKCFGR
DCKCFGR : DCKCFGR_Register;
end record
with Volatile;
for RCC_Peripheral use record
CR at 0 range 0 .. 31;
PLLCFGR at 4 range 0 .. 31;
CFGR at 8 range 0 .. 31;
CIR at 12 range 0 .. 31;
AHB1RSTR at 16 range 0 .. 31;
AHB2RSTR at 20 range 0 .. 31;
AHB3RSTR at 24 range 0 .. 31;
APB1RSTR at 32 range 0 .. 31;
APB2RSTR at 36 range 0 .. 31;
AHB1ENR at 48 range 0 .. 31;
AHB2ENR at 52 range 0 .. 31;
AHB3ENR at 56 range 0 .. 31;
APB1ENR at 64 range 0 .. 31;
APB2ENR at 68 range 0 .. 31;
AHB1LPENR at 80 range 0 .. 31;
AHB2LPENR at 84 range 0 .. 31;
AHB3LPENR at 88 range 0 .. 31;
APB1LPENR at 96 range 0 .. 31;
APB2LPENR at 100 range 0 .. 31;
BDCR at 112 range 0 .. 31;
CSR at 116 range 0 .. 31;
SSCGR at 128 range 0 .. 31;
PLLI2SCFGR at 132 range 0 .. 31;
PLLSAICFGR at 136 range 0 .. 31;
DCKCFGR at 140 range 0 .. 31;
end record;
-- Reset and clock control
RCC_Periph : aliased RCC_Peripheral
with Import, Address => RCC_Base;
end STM32_SVD.RCC;
|
-- This spec has been automatically generated from STM32L4x3.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package STM32_SVD.VREF is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- VREF control and status register
type CSR_Register is record
-- Voltage reference buffer enable
ENVR : Boolean := False;
-- High impedance mode
HIZ : Boolean := True;
-- Voltage reference scale
VRS : Boolean := False;
-- Read-only. Voltage reference buffer ready
VRR : Boolean := False;
-- unspecified
Reserved_4_31 : HAL.UInt28 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CSR_Register use record
ENVR at 0 range 0 .. 0;
HIZ at 0 range 1 .. 1;
VRS at 0 range 2 .. 2;
VRR at 0 range 3 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
subtype CCR_TRIM_Field is HAL.UInt6;
-- calibration control register
type CCR_Register is record
-- Trimming code
TRIM : CCR_TRIM_Field := 16#0#;
-- unspecified
Reserved_6_31 : HAL.UInt26 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CCR_Register use record
TRIM at 0 range 0 .. 5;
Reserved_6_31 at 0 range 6 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Voltage reference buffer
type VREFBUF_Peripheral is record
-- VREF control and status register
CSR : aliased CSR_Register;
-- calibration control register
CCR : aliased CCR_Register;
end record
with Volatile;
for VREFBUF_Peripheral use record
CSR at 16#0# range 0 .. 31;
CCR at 16#4# range 0 .. 31;
end record;
-- Voltage reference buffer
VREFBUF_Periph : aliased VREFBUF_Peripheral
with Import, Address => VREFBUF_Base;
end STM32_SVD.VREF;
|
with Globals_Example1;
with Ada.Finalization;
package Md_Example6 is
type T is new Ada.Finalization.Controlled with record
Attribute : Globals_Example1.Itype;
end record;
-- Ada Rules state that all tagged operations must be defined here
function Do_It (The_T : T) return Globals_Example1.Itype;
procedure Initialize(The_T : in out T);
-- Did not declare procedure Finalize and thus there is no destructor
end Md_Example6;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-2012, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
-- An action with implementation-specific semantics.
------------------------------------------------------------------------------
with AMF.String_Collections;
with AMF.UML.Actions;
limited with AMF.UML.Input_Pins.Collections;
limited with AMF.UML.Output_Pins.Collections;
package AMF.UML.Opaque_Actions is
pragma Preelaborate;
type UML_Opaque_Action is limited interface
and AMF.UML.Actions.UML_Action;
type UML_Opaque_Action_Access is
access all UML_Opaque_Action'Class;
for UML_Opaque_Action_Access'Storage_Size use 0;
not overriding function Get_Body
(Self : not null access constant UML_Opaque_Action)
return AMF.String_Collections.Sequence_Of_String is abstract;
-- Getter of OpaqueAction::body.
--
-- Specifies the action in one or more languages.
not overriding function Get_Input_Value
(Self : not null access constant UML_Opaque_Action)
return AMF.UML.Input_Pins.Collections.Set_Of_UML_Input_Pin is abstract;
-- Getter of OpaqueAction::inputValue.
--
-- Provides input to the action.
not overriding function Get_Language
(Self : not null access constant UML_Opaque_Action)
return AMF.String_Collections.Ordered_Set_Of_String is abstract;
-- Getter of OpaqueAction::language.
--
-- Languages the body strings use, in the same order as the body strings
not overriding function Get_Output_Value
(Self : not null access constant UML_Opaque_Action)
return AMF.UML.Output_Pins.Collections.Set_Of_UML_Output_Pin is abstract;
-- Getter of OpaqueAction::outputValue.
--
-- Takes output from the action.
end AMF.UML.Opaque_Actions;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2017, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This package provides utility sub-program to quicly configure the STM32
-- drivers. The intent factorize code by enabling and configuring device and
-- associated GPIO points with a standard/most common setup.
--
-- The devices are configured for the most common usage, but if you need
-- something more specific you can still do it by directly using
-- confguration sub-programs of the device or reconfigure it after using the
-- standard setup.
with STM32.I2C; use STM32.I2C;
with STM32.GPIO; use STM32.GPIO;
package STM32.Setup is
procedure Setup_I2C_Master (Port : in out I2C_Port;
SDA, SCL : GPIO_Point;
SDA_AF, SCL_AF : GPIO_Alternate_Function;
Clock_Speed : UInt32);
-- GPIO : Alternate function, High speed, open drain, floating
-- I2C : 7bit address, stretching enabled, general call disabled
end STM32.Setup;
|
procedure mv_l(point : in out point_t; delta_x : integer) is
begin
mv_l(point, float(delta_x));
end;
procedure int_mv(point : in out point_t; delta_axis : integer; mv : access procedure(point : in out point_t; delta_axis : float)) is
begin
mv(point, float(delta_axis));
end;
int_mv(point, delta_x, mv_l_ptr);
mv_l(point, float(delta_x));
mv_l(point, delta_x);
generic
mv : mv_ptr;
procedure int_mv(point : in out point_t; delta_axis : integer);
procedure int_mv(point : in out point_t; delta_axis : integer) is
begin
mv(point, float(delta_axis * mult));
end;
procedure internal_int_mv_l is new int_mv(mv_l_ptr);
procedure internal_int_mv_r is new int_mv(mv_r_ptr);
procedure internal_int_mv_u is new int_mv(mv_u_ptr);
procedure internal_int_mv_d is new int_mv(mv_d_ptr);
-- definition des fonctions de mouvement (celles-ci sont déclarées dans le package)
procedure mv_l(point : in out point_t; delta_x : integer) renames internal_int_mv_l;
procedure mv_r(point : in out point_t; delta_x : integer) renames internal_int_mv_r;
procedure mv_u(point : in out point_t; delta_y : integer) renames internal_int_mv_u;
procedure mv_d(point : in out point_t; delta_y : integer) renames internal_int_mv_d;
|
procedure Puzzle_04 is
begin
null;
end Puzzle_04;
|
-- This spec has been automatically generated from STM32F103.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package STM32_SVD.DAC is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype CR_EN1_Field is STM32_SVD.Bit;
subtype CR_BOFF1_Field is STM32_SVD.Bit;
subtype CR_TEN1_Field is STM32_SVD.Bit;
subtype CR_TSEL1_Field is STM32_SVD.UInt3;
subtype CR_WAVE1_Field is STM32_SVD.UInt2;
subtype CR_MAMP1_Field is STM32_SVD.UInt4;
subtype CR_DMAEN1_Field is STM32_SVD.Bit;
subtype CR_EN2_Field is STM32_SVD.Bit;
subtype CR_BOFF2_Field is STM32_SVD.Bit;
subtype CR_TEN2_Field is STM32_SVD.Bit;
subtype CR_TSEL2_Field is STM32_SVD.UInt3;
subtype CR_WAVE2_Field is STM32_SVD.UInt2;
subtype CR_MAMP2_Field is STM32_SVD.UInt4;
subtype CR_DMAEN2_Field is STM32_SVD.Bit;
-- Control register (DAC_CR)
type CR_Register is record
-- DAC channel1 enable
EN1 : CR_EN1_Field := 16#0#;
-- DAC channel1 output buffer disable
BOFF1 : CR_BOFF1_Field := 16#0#;
-- DAC channel1 trigger enable
TEN1 : CR_TEN1_Field := 16#0#;
-- DAC channel1 trigger selection
TSEL1 : CR_TSEL1_Field := 16#0#;
-- DAC channel1 noise/triangle wave generation enable
WAVE1 : CR_WAVE1_Field := 16#0#;
-- DAC channel1 mask/amplitude selector
MAMP1 : CR_MAMP1_Field := 16#0#;
-- DAC channel1 DMA enable
DMAEN1 : CR_DMAEN1_Field := 16#0#;
-- unspecified
Reserved_13_15 : STM32_SVD.UInt3 := 16#0#;
-- DAC channel2 enable
EN2 : CR_EN2_Field := 16#0#;
-- DAC channel2 output buffer disable
BOFF2 : CR_BOFF2_Field := 16#0#;
-- DAC channel2 trigger enable
TEN2 : CR_TEN2_Field := 16#0#;
-- DAC channel2 trigger selection
TSEL2 : CR_TSEL2_Field := 16#0#;
-- DAC channel2 noise/triangle wave generation enable
WAVE2 : CR_WAVE2_Field := 16#0#;
-- DAC channel2 mask/amplitude selector
MAMP2 : CR_MAMP2_Field := 16#0#;
-- DAC channel2 DMA enable
DMAEN2 : CR_DMAEN2_Field := 16#0#;
-- unspecified
Reserved_29_31 : STM32_SVD.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
EN1 at 0 range 0 .. 0;
BOFF1 at 0 range 1 .. 1;
TEN1 at 0 range 2 .. 2;
TSEL1 at 0 range 3 .. 5;
WAVE1 at 0 range 6 .. 7;
MAMP1 at 0 range 8 .. 11;
DMAEN1 at 0 range 12 .. 12;
Reserved_13_15 at 0 range 13 .. 15;
EN2 at 0 range 16 .. 16;
BOFF2 at 0 range 17 .. 17;
TEN2 at 0 range 18 .. 18;
TSEL2 at 0 range 19 .. 21;
WAVE2 at 0 range 22 .. 23;
MAMP2 at 0 range 24 .. 27;
DMAEN2 at 0 range 28 .. 28;
Reserved_29_31 at 0 range 29 .. 31;
end record;
-- SWTRIGR_SWTRIG array element
subtype SWTRIGR_SWTRIG_Element is STM32_SVD.Bit;
-- SWTRIGR_SWTRIG array
type SWTRIGR_SWTRIG_Field_Array is array (1 .. 2)
of SWTRIGR_SWTRIG_Element
with Component_Size => 1, Size => 2;
-- Type definition for SWTRIGR_SWTRIG
type SWTRIGR_SWTRIG_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SWTRIG as a value
Val : STM32_SVD.UInt2;
when True =>
-- SWTRIG as an array
Arr : SWTRIGR_SWTRIG_Field_Array;
end case;
end record
with Unchecked_Union, Size => 2;
for SWTRIGR_SWTRIG_Field use record
Val at 0 range 0 .. 1;
Arr at 0 range 0 .. 1;
end record;
-- DAC software trigger register (DAC_SWTRIGR)
type SWTRIGR_Register is record
-- Write-only. DAC channel1 software trigger
SWTRIG : SWTRIGR_SWTRIG_Field :=
(As_Array => False, Val => 16#0#);
-- unspecified
Reserved_2_31 : STM32_SVD.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SWTRIGR_Register use record
SWTRIG at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
subtype DHR12R1_DACC1DHR_Field is STM32_SVD.UInt12;
-- DAC channel1 12-bit right-aligned data holding register(DAC_DHR12R1)
type DHR12R1_Register is record
-- DAC channel1 12-bit right-aligned data
DACC1DHR : DHR12R1_DACC1DHR_Field := 16#0#;
-- unspecified
Reserved_12_31 : STM32_SVD.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DHR12R1_Register use record
DACC1DHR at 0 range 0 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype DHR12L1_DACC1DHR_Field is STM32_SVD.UInt12;
-- DAC channel1 12-bit left aligned data holding register (DAC_DHR12L1)
type DHR12L1_Register is record
-- unspecified
Reserved_0_3 : STM32_SVD.UInt4 := 16#0#;
-- DAC channel1 12-bit left-aligned data
DACC1DHR : DHR12L1_DACC1DHR_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DHR12L1_Register use record
Reserved_0_3 at 0 range 0 .. 3;
DACC1DHR at 0 range 4 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype DHR8R1_DACC1DHR_Field is STM32_SVD.Byte;
-- DAC channel1 8-bit right aligned data holding register (DAC_DHR8R1)
type DHR8R1_Register is record
-- DAC channel1 8-bit right-aligned data
DACC1DHR : DHR8R1_DACC1DHR_Field := 16#0#;
-- unspecified
Reserved_8_31 : STM32_SVD.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DHR8R1_Register use record
DACC1DHR at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype DHR12R2_DACC2DHR_Field is STM32_SVD.UInt12;
-- DAC channel2 12-bit right aligned data holding register (DAC_DHR12R2)
type DHR12R2_Register is record
-- DAC channel2 12-bit right-aligned data
DACC2DHR : DHR12R2_DACC2DHR_Field := 16#0#;
-- unspecified
Reserved_12_31 : STM32_SVD.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DHR12R2_Register use record
DACC2DHR at 0 range 0 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype DHR12L2_DACC2DHR_Field is STM32_SVD.UInt12;
-- DAC channel2 12-bit left aligned data holding register (DAC_DHR12L2)
type DHR12L2_Register is record
-- unspecified
Reserved_0_3 : STM32_SVD.UInt4 := 16#0#;
-- DAC channel2 12-bit left-aligned data
DACC2DHR : DHR12L2_DACC2DHR_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DHR12L2_Register use record
Reserved_0_3 at 0 range 0 .. 3;
DACC2DHR at 0 range 4 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype DHR8R2_DACC2DHR_Field is STM32_SVD.Byte;
-- DAC channel2 8-bit right-aligned data holding register (DAC_DHR8R2)
type DHR8R2_Register is record
-- DAC channel2 8-bit right-aligned data
DACC2DHR : DHR8R2_DACC2DHR_Field := 16#0#;
-- unspecified
Reserved_8_31 : STM32_SVD.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DHR8R2_Register use record
DACC2DHR at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
subtype DHR12RD_DACC1DHR_Field is STM32_SVD.UInt12;
subtype DHR12RD_DACC2DHR_Field is STM32_SVD.UInt12;
-- Dual DAC 12-bit right-aligned data holding register (DAC_DHR12RD), Bits
-- 31:28 Reserved, Bits 15:12 Reserved
type DHR12RD_Register is record
-- DAC channel1 12-bit right-aligned data
DACC1DHR : DHR12RD_DACC1DHR_Field := 16#0#;
-- unspecified
Reserved_12_15 : STM32_SVD.UInt4 := 16#0#;
-- DAC channel2 12-bit right-aligned data
DACC2DHR : DHR12RD_DACC2DHR_Field := 16#0#;
-- unspecified
Reserved_28_31 : STM32_SVD.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DHR12RD_Register use record
DACC1DHR at 0 range 0 .. 11;
Reserved_12_15 at 0 range 12 .. 15;
DACC2DHR at 0 range 16 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
subtype DHR12LD_DACC1DHR_Field is STM32_SVD.UInt12;
subtype DHR12LD_DACC2DHR_Field is STM32_SVD.UInt12;
-- DUAL DAC 12-bit left aligned data holding register (DAC_DHR12LD), Bits
-- 19:16 Reserved, Bits 3:0 Reserved
type DHR12LD_Register is record
-- unspecified
Reserved_0_3 : STM32_SVD.UInt4 := 16#0#;
-- DAC channel1 12-bit left-aligned data
DACC1DHR : DHR12LD_DACC1DHR_Field := 16#0#;
-- unspecified
Reserved_16_19 : STM32_SVD.UInt4 := 16#0#;
-- DAC channel2 12-bit right-aligned data
DACC2DHR : DHR12LD_DACC2DHR_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DHR12LD_Register use record
Reserved_0_3 at 0 range 0 .. 3;
DACC1DHR at 0 range 4 .. 15;
Reserved_16_19 at 0 range 16 .. 19;
DACC2DHR at 0 range 20 .. 31;
end record;
subtype DHR8RD_DACC1DHR_Field is STM32_SVD.Byte;
subtype DHR8RD_DACC2DHR_Field is STM32_SVD.Byte;
-- DUAL DAC 8-bit right aligned data holding register (DAC_DHR8RD), Bits
-- 31:16 Reserved
type DHR8RD_Register is record
-- DAC channel1 8-bit right-aligned data
DACC1DHR : DHR8RD_DACC1DHR_Field := 16#0#;
-- DAC channel2 8-bit right-aligned data
DACC2DHR : DHR8RD_DACC2DHR_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DHR8RD_Register use record
DACC1DHR at 0 range 0 .. 7;
DACC2DHR at 0 range 8 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype DOR1_DACC1DOR_Field is STM32_SVD.UInt12;
-- DAC channel1 data output register (DAC_DOR1)
type DOR1_Register is record
-- Read-only. DAC channel1 data output
DACC1DOR : DOR1_DACC1DOR_Field;
-- unspecified
Reserved_12_31 : STM32_SVD.UInt20;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DOR1_Register use record
DACC1DOR at 0 range 0 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype DOR2_DACC2DOR_Field is STM32_SVD.UInt12;
-- DAC channel2 data output register (DAC_DOR2)
type DOR2_Register is record
-- Read-only. DAC channel2 data output
DACC2DOR : DOR2_DACC2DOR_Field;
-- unspecified
Reserved_12_31 : STM32_SVD.UInt20;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DOR2_Register use record
DACC2DOR at 0 range 0 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Digital to analog converter
type DAC_Peripheral is record
-- Control register (DAC_CR)
CR : aliased CR_Register;
-- DAC software trigger register (DAC_SWTRIGR)
SWTRIGR : aliased SWTRIGR_Register;
-- DAC channel1 12-bit right-aligned data holding register(DAC_DHR12R1)
DHR12R1 : aliased DHR12R1_Register;
-- DAC channel1 12-bit left aligned data holding register (DAC_DHR12L1)
DHR12L1 : aliased DHR12L1_Register;
-- DAC channel1 8-bit right aligned data holding register (DAC_DHR8R1)
DHR8R1 : aliased DHR8R1_Register;
-- DAC channel2 12-bit right aligned data holding register (DAC_DHR12R2)
DHR12R2 : aliased DHR12R2_Register;
-- DAC channel2 12-bit left aligned data holding register (DAC_DHR12L2)
DHR12L2 : aliased DHR12L2_Register;
-- DAC channel2 8-bit right-aligned data holding register (DAC_DHR8R2)
DHR8R2 : aliased DHR8R2_Register;
-- Dual DAC 12-bit right-aligned data holding register (DAC_DHR12RD),
-- Bits 31:28 Reserved, Bits 15:12 Reserved
DHR12RD : aliased DHR12RD_Register;
-- DUAL DAC 12-bit left aligned data holding register (DAC_DHR12LD),
-- Bits 19:16 Reserved, Bits 3:0 Reserved
DHR12LD : aliased DHR12LD_Register;
-- DUAL DAC 8-bit right aligned data holding register (DAC_DHR8RD), Bits
-- 31:16 Reserved
DHR8RD : aliased DHR8RD_Register;
-- DAC channel1 data output register (DAC_DOR1)
DOR1 : aliased DOR1_Register;
-- DAC channel2 data output register (DAC_DOR2)
DOR2 : aliased DOR2_Register;
end record
with Volatile;
for DAC_Peripheral use record
CR at 16#0# range 0 .. 31;
SWTRIGR at 16#4# range 0 .. 31;
DHR12R1 at 16#8# range 0 .. 31;
DHR12L1 at 16#C# range 0 .. 31;
DHR8R1 at 16#10# range 0 .. 31;
DHR12R2 at 16#14# range 0 .. 31;
DHR12L2 at 16#18# range 0 .. 31;
DHR8R2 at 16#1C# range 0 .. 31;
DHR12RD at 16#20# range 0 .. 31;
DHR12LD at 16#24# range 0 .. 31;
DHR8RD at 16#28# range 0 .. 31;
DOR1 at 16#2C# range 0 .. 31;
DOR2 at 16#30# range 0 .. 31;
end record;
-- Digital to analog converter
DAC_Periph : aliased DAC_Peripheral
with Import, Address => System'To_Address (16#40007400#);
end STM32_SVD.DAC;
|
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Expressions;
with Program.Lexical_Elements;
with Program.Elements.Assignment_Statements;
with Program.Element_Visitors;
package Program.Nodes.Assignment_Statements is
pragma Preelaborate;
type Assignment_Statement is
new Program.Nodes.Node
and Program.Elements.Assignment_Statements.Assignment_Statement
and Program.Elements.Assignment_Statements.Assignment_Statement_Text
with private;
function Create
(Variable_Name : not null Program.Elements.Expressions
.Expression_Access;
Assignment_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Expression : not null Program.Elements.Expressions
.Expression_Access;
Semicolon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access)
return Assignment_Statement;
type Implicit_Assignment_Statement is
new Program.Nodes.Node
and Program.Elements.Assignment_Statements.Assignment_Statement
with private;
function Create
(Variable_Name : not null Program.Elements.Expressions
.Expression_Access;
Expression : not null Program.Elements.Expressions
.Expression_Access;
Is_Part_Of_Implicit : Boolean := False;
Is_Part_Of_Inherited : Boolean := False;
Is_Part_Of_Instance : Boolean := False)
return Implicit_Assignment_Statement
with Pre =>
Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance;
private
type Base_Assignment_Statement is
abstract new Program.Nodes.Node
and Program.Elements.Assignment_Statements.Assignment_Statement
with record
Variable_Name : not null Program.Elements.Expressions
.Expression_Access;
Expression : not null Program.Elements.Expressions
.Expression_Access;
end record;
procedure Initialize
(Self : aliased in out Base_Assignment_Statement'Class);
overriding procedure Visit
(Self : not null access Base_Assignment_Statement;
Visitor : in out Program.Element_Visitors.Element_Visitor'Class);
overriding function Variable_Name
(Self : Base_Assignment_Statement)
return not null Program.Elements.Expressions.Expression_Access;
overriding function Expression
(Self : Base_Assignment_Statement)
return not null Program.Elements.Expressions.Expression_Access;
overriding function Is_Assignment_Statement_Element
(Self : Base_Assignment_Statement)
return Boolean;
overriding function Is_Statement_Element
(Self : Base_Assignment_Statement)
return Boolean;
type Assignment_Statement is
new Base_Assignment_Statement
and Program.Elements.Assignment_Statements.Assignment_Statement_Text
with record
Assignment_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
Semicolon_Token : not null Program.Lexical_Elements
.Lexical_Element_Access;
end record;
overriding function To_Assignment_Statement_Text
(Self : aliased in out Assignment_Statement)
return Program.Elements.Assignment_Statements
.Assignment_Statement_Text_Access;
overriding function Assignment_Token
(Self : Assignment_Statement)
return not null Program.Lexical_Elements.Lexical_Element_Access;
overriding function Semicolon_Token
(Self : Assignment_Statement)
return not null Program.Lexical_Elements.Lexical_Element_Access;
type Implicit_Assignment_Statement is
new Base_Assignment_Statement
with record
Is_Part_Of_Implicit : Boolean;
Is_Part_Of_Inherited : Boolean;
Is_Part_Of_Instance : Boolean;
end record;
overriding function To_Assignment_Statement_Text
(Self : aliased in out Implicit_Assignment_Statement)
return Program.Elements.Assignment_Statements
.Assignment_Statement_Text_Access;
overriding function Is_Part_Of_Implicit
(Self : Implicit_Assignment_Statement)
return Boolean;
overriding function Is_Part_Of_Inherited
(Self : Implicit_Assignment_Statement)
return Boolean;
overriding function Is_Part_Of_Instance
(Self : Implicit_Assignment_Statement)
return Boolean;
end Program.Nodes.Assignment_Statements;
|
-- Ada_GUI implementation based on Gnoga. Adapted 2021
-- --
-- GNOGA - The GNU Omnificent GUI for Ada --
-- --
-- G N O G A . G U I . E L E M E N T . F O R M --
-- --
-- S p e c --
-- --
-- --
-- Copyright (C) 2014 David Botton --
-- --
-- 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 --
-- 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/>. --
-- --
-- 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. --
-- --
-- For more information please go to http://www.gnoga.com --
------------------------------------------------------------------------------
with Ada_GUI.Gnoga.Gui.View;
package Ada_GUI.Gnoga.Gui.Element.Form is
-------------------------------------------------------------------------
-- Form_Types
-------------------------------------------------------------------------
type Form_Type is new Gnoga.Gui.View.View_Base_Type with private;
type Form_Access is access all Form_Type;
type Pointer_To_Form_Class is access all Form_Type'Class;
-------------------------------------------------------------------------
-- Form_Type - Creation Methods
-------------------------------------------------------------------------
type Form_Method_Type is (Get, Post);
procedure Create (Form : in out Form_Type;
Parent : in out Gnoga.Gui.Base_Type'Class;
Action : in String := "";
Method : in Form_Method_Type := Get;
Target : in String := "_self";
ID : in String := "");
-- Create a Form element. This is used to group and set the action
-- taken on a submit of the form.
--
-- In Gnoga forms in general should be processed by handling the
-- On_Submit event and accessing each element's value directly.
-- However it is possible to set an action (URL for form to submit to)
-- and that page can process the results. For submitted forms access
-- using Gnoga.Gui.Window.Window_Type.Form_Parameters.
-------------------------------------------------------------------------
-- From_Type - Properties
-------------------------------------------------------------------------
procedure Action (Form : in out Form_Type; Value : in String);
function Action (Form : Form_Type) return String;
-- URL to submit form to using Method
procedure Method (Form : in out Form_Type; Value : in Form_Method_Type);
function Method (Form : Form_Type) return Form_Method_Type;
type Encoding_Type is (URL_Encode, Multi_Part, Text);
-- application/x-www-form-urlencoded / multipart/form-data / text/plain
-- The default for forms is URL_Encode
procedure Encoding (Form : in out Form_Type; Value : in Encoding_Type);
function Encoding (Form : Form_Type) return Encoding_Type;
-- Encoding affects how the form is send via the POST method only.
procedure Autocomplete (Form : in out Form_Type;
Value : in Boolean := True);
function Autocomplete (Form : Form_Type) return Boolean;
procedure Validate_On_Submit (Form : in out Form_Type;
Value : in Boolean := True);
function Validate_On_Submit (Form : Form_Type) return Boolean;
function Number_Of_Elements_In_Form (Form : Form_Type) return Integer;
procedure Target (Form : in out Form_Type; Value : in String);
function Target (Form : Form_Type) return String;
-- Target of link, name (set as attribute on a frame or windows) of
-- a frame or:
-- _blank = new window
-- _top = top most frame (full browser window)
-- _parent = parent frame or window
-- _self = current frame or window
-------------------------------------------------------------------------
-- Form_Type - Methods
-------------------------------------------------------------------------
procedure Submit (Form : in out Form_Type);
-- Submit form
procedure Reset (Form : in out Form_Type);
-- Reset form to original defaults
-------------------------------------------------------------------------
-- Form_Element_Types
-------------------------------------------------------------------------
-- Parent type for all form elements
type Form_Element_Type is new Gnoga.Gui.Element.Element_Type with private;
type Form_Element_Access is access all Form_Element_Type;
type Pointer_To_Form_Element_Class is access all Form_Element_Type'Class;
type Data_List_Type is new Gnoga.Gui.View.View_Base_Type with private;
-- Forward declaration of Data_List_Type used for drop down /
-- autocomplete.
-------------------------------------------------------------------------
-- Form_Element_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create_Element (Element : in out Form_Element_Type;
Form : in out Form_Type'Class;
Input_Type : in String;
Value : in String := "";
Name : in String := "";
ID : in String := "");
-- Create a form element of Input_Type. Setting Name on form element
-- is only important if the form will be submitted via a GET or POST.
-- Value is the initial value for the element.
--
-- Valid HTML5 Input_Types are:
-- button, checkbox, color, date, datetime, datetime-local, email
-- file, hidden, image, month, number, password, radio, range
-- reset, search, submit, tel, text, time, url, week
-------------------------------------------------------------------------
-- Form_Element_Type - Properties
-------------------------------------------------------------------------
procedure Autocomplete (Element : in out Form_Element_Type;
Value : in Boolean := True);
function Autocomplete (Element : Form_Element_Type) return Boolean;
procedure Autofocus (Element : in out Form_Element_Type;
Value : in Boolean := True);
function Autofocus (Element : Form_Element_Type) return Boolean;
procedure Data_List (Element : in out Form_Element_Type;
Data_List : in out Data_List_Type'Class);
-- Set the data list for Autocomplete
procedure Disabled (Element : in out Form_Element_Type;
Value : in Boolean := True);
function Disabled (Element : Form_Element_Type) return Boolean;
procedure Read_Only (Element : in out Form_Element_Type;
Value : in Boolean := True);
function Read_Only (Element : Form_Element_Type) return Boolean;
procedure Validate_On_Submit (Element : in out Form_Element_Type;
Value : in Boolean := True);
function Validate_On_Submit (Element : Form_Element_Type) return Boolean;
procedure Name (Element : in out Form_Element_Type; Value : in String);
function Name (Element : Form_Element_Type) return String;
-- Form element name, name is not the id of the element but rather how
-- the data returned from the element will be named in the submit to the
-- server. For example if Name is My_Field a GET request could look like
-- http://localhost:8080?My_Field=xxxx
procedure Default_Value (Element : in out Form_Element_Type;
Value : in String);
procedure Default_Value (Element : in out Form_Element_Type;
Value : in Integer);
function Default_Value (Element : Form_Element_Type) return String;
function Default_Value (Element : Form_Element_Type) return Integer;
-- If the form is reset the value will be set to default value
-- If Value is set at time of creation it also sets it as the Default_Value
procedure Value (Element : in out Form_Element_Type; Value : in String);
procedure Value (Element : in out Form_Element_Type; Value : in Integer);
function Value (Element : Form_Element_Type) return String;
function Value (Element : Form_Element_Type) return Integer;
-- Form element values are not accessible through the Text property but
-- instead through the value property.
-- Text oriented properties
procedure Place_Holder (Element : in out Form_Element_Type;
Value : in String);
function Place_Holder (Element : Form_Element_Type) return String;
procedure Pattern (Element : in out Form_Element_Type; Value : in String);
function Pattern (Element : Form_Element_Type) return String;
-- Form validation pattern. Validate_On_Submit fields with input
-- will validate against their Pattern if set on submit.
-- Pattern is included in Form_Element_Type since in cases where a specific
-- input type is not supported like (date, week, etc.) Pattern can be set
-- to ensure the expected results. This works since Input type will fall
-- back to a text input.
procedure Required (Element : in out Form_Element_Type;
Value : in Boolean := True);
function Required (Element : Form_Element_Type) return Boolean;
-- If Required is true on submit Element must be set/contain a value
-- Range oriented inputs
procedure Minimum (Element : in out Form_Element_Type; Value : in String);
procedure Minimum (Element : in out Form_Element_Type; Value : in Integer);
function Minimum (Element : Form_Element_Type) return String;
function Minimum (Element : Form_Element_Type) return Integer;
procedure Maximum (Element : in out Form_Element_Type; Value : in String);
procedure Maximum (Element : in out Form_Element_Type; Value : in Integer);
function Maximum (Element : Form_Element_Type) return String;
function Maximum (Element : Form_Element_Type) return Integer;
procedure Step (Element : in out Form_Element_Type; Value : in String);
procedure Step (Element : in out Form_Element_Type; Value : in Integer);
function Step (Element : Form_Element_Type) return String;
function Step (Element : Form_Element_Type) return Integer;
-------------------------------------------------------------------------
-- Form_Element_Type - Methods
-------------------------------------------------------------------------
procedure Select_Text (Element : in out Form_Element_Type);
-- Selects and highlights the context of Element
-------------------------------------------------------------------------
-- Data_List_Types
-------------------------------------------------------------------------
type Data_List_Access is access all Data_List_Type;
type Pointer_To_Data_List_Class is access all Data_List_Type'Class;
-------------------------------------------------------------------------
-- Data_List_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create
(List : in out Data_List_Type;
Parent : in out Gnoga.Gui.Base_Type'Class;
ID : in String := "");
-------------------------------------------------------------------------
-- Data_List_Type - Methods
-------------------------------------------------------------------------
procedure Add_Option (List : in out Data_List_Type;
Value : in String);
-- Add option to Data_List
-------------------------------------------------------------------------
-- Text_Area_Types
-------------------------------------------------------------------------
type Text_Area_Type is new Form_Element_Type with private;
type Text_Area_Access is access all Text_Area_Type;
type Pointer_To_Text_Area_Class is access all Text_Area_Type'Class;
-------------------------------------------------------------------------
-- Text_Area_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create (Element : in out Text_Area_Type;
Form : in out Form_Type'Class;
Columns : in Natural := 20;
Rows : in Natural := 2;
Value : in String := "";
Name : in String := "";
ID : in String := "");
-------------------------------------------------------------------------
-- Text_Area_Type - Properties
-------------------------------------------------------------------------
procedure Word_Wrap (Element : in out Text_Area_Type;
Value : in Boolean := True);
function Word_Wrap (Element : Text_Area_Type) return Boolean;
procedure Columns (Element : in out Text_Area_Type;
Value : in Integer);
function Columns (Element : Text_Area_Type) return Integer;
procedure Rows (Element : in out Text_Area_Type;
Value : in Integer);
function Rows (Element : Text_Area_Type) return Integer;
-------------------------------------------------------------------------
-- Hidden_Types
-------------------------------------------------------------------------
type Hidden_Type is new Form_Element_Type with private;
type Hidden_Access is access all Hidden_Type;
type Pointer_To_Hidden_Class is access all Hidden_Type'Class;
-------------------------------------------------------------------------
-- Hidden_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create (Element : in out Hidden_Type;
Form : in out Form_Type'Class;
Value : in String := "";
Name : in String := "";
ID : in String := "");
-------------------------------------------------------------------------
-- Input_Button_Types
-------------------------------------------------------------------------
type Input_Button_Type is new Form_Element_Type with private;
type Input_Button_Access is access all Input_Button_Type;
type Pointer_To_Input_Button_Class is access all Input_Button_Type'Class;
-------------------------------------------------------------------------
-- Input_Button_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create (Element : in out Input_Button_Type;
Form : in out Form_Type'Class;
Value : in String := "";
Name : in String := "";
ID : in String := "");
-------------------------------------------------------------------------
-- Submit_Button_Types
-------------------------------------------------------------------------
-- An Input Button that On_Click will fire On_Submit
type Submit_Button_Type is new Input_Button_Type with private;
type Submit_Button_Access is access all Submit_Button_Type;
type Pointer_To_Submit_Button_Class is access all Submit_Button_Type'Class;
-------------------------------------------------------------------------
-- Submit_Button_Type - Creation Methods
-------------------------------------------------------------------------
overriding
procedure Create (Element : in out Submit_Button_Type;
Form : in out Form_Type'Class;
Value : in String := "";
Name : in String := "";
ID : in String := "");
-------------------------------------------------------------------------
-- Reset_Button_Types
-------------------------------------------------------------------------
-- An Input Button that On_Click will fire On_Reset
type Reset_Button_Type is new Input_Button_Type with private;
type Reset_Button_Access is access all Reset_Button_Type;
type Pointer_To_Reset_Button_Class is access all Reset_Button_Type'Class;
-------------------------------------------------------------------------
-- Reset_Button_Type - Creation Methods
-------------------------------------------------------------------------
overriding
procedure Create (Element : in out Reset_Button_Type;
Form : in out Form_Type'Class;
Value : in String := "";
Name : in String := "";
ID : in String := "");
-------------------------------------------------------------------------
-- Check_Box_Types
-------------------------------------------------------------------------
type Check_Box_Type is new Form_Element_Type with private;
type Check_Box_Access is access all Check_Box_Type;
type Pointer_To_Check_Box_Class is access all Check_Box_Type'Class;
-------------------------------------------------------------------------
-- Check_Box_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create (Element : in out Check_Box_Type;
Form : in out Form_Type'Class;
Checked : in Boolean := False;
Value : in String := "";
Name : in String := "";
ID : in String := "");
-- Value will be what is submitted if Checked is true for Name.
-------------------------------------------------------------------------
-- Check_Box_Type - Properties
-------------------------------------------------------------------------
procedure Checked (Element : in out Check_Box_Type;
Value : in Boolean := True);
function Checked (Element : Check_Box_Type) return Boolean;
procedure Indeterminate (Element : in out Check_Box_Type;
Value : in Boolean := True);
function Indeterminate (Element : Check_Box_Type) return Boolean;
-------------------------------------------------------------------------
-- Radio_Button_Types
-------------------------------------------------------------------------
type Radio_Button_Type is new Form_Element_Type with private;
type Radio_Button_Access is access all Radio_Button_Type;
type Pointer_To_Radio_Button_Class is access all Radio_Button_Type'Class;
-- These radio buttons will operate as groups based on having a common
-- Name attribute.
-------------------------------------------------------------------------
-- Radio_Button_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create (Element : in out Radio_Button_Type;
Form : in out Form_Type'Class;
Checked : in Boolean := False;
Value : in String := "";
Name : in String := "";
ID : in String := "");
----------------------------------------------------------
-- Radio_Button_Type - Properties
-------------------------------------------------------------------------
procedure Checked (Element : in out Radio_Button_Type;
Value : in Boolean := True);
function Checked (Element : Radio_Button_Type) return Boolean;
-------------------------------------------------------------------------
-- Input_Image_Types
-------------------------------------------------------------------------
type Input_Image_Type is new Form_Element_Type with private;
type Input_Image_Access is access all Input_Image_Type;
type Pointer_To_Input_Image_Class is access all Input_Image_Type'Class;
-------------------------------------------------------------------------
-- Input_Image_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create (Element : in out Input_Image_Type;
Form : in out Form_Type'Class;
Source : in String := "";
Value : in String := "";
Name : in String := "";
ID : in String := "");
-------------------------------------------------------------------------
-- Input_Image_Type - Properties
-------------------------------------------------------------------------
procedure Source (Element : in out Input_Image_Type; Value : String);
function Source (Element : Input_Image_Type) return String;
-- URL source for image
-------------------------------------------------------------------------
-- Text_Types
-------------------------------------------------------------------------
type Text_Type is new Form_Element_Type with private;
type Text_Access is access all Text_Type;
type Pointer_To_Text_Class is access all Text_Type'Class;
-------------------------------------------------------------------------
-- Text_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create (Element : in out Text_Type;
Form : in out Form_Type'Class;
Size : in Integer := 20;
Value : in String := "";
Name : in String := "";
ID : in String := "");
-------------------------------------------------------------------------
-- Text_Type - Properties
-------------------------------------------------------------------------
procedure Size (Element : in out Text_Type; Value : Integer);
function Size (Element : Text_Type) return Integer;
-- Length of visible field in characters
procedure Max_Length (Element : in out Text_Type; Value : Integer);
function Max_Length (Element : Text_Type) return Integer;
-- Maximum length of Value
-------------------------------------------------------------------------
-- Email_Types
-------------------------------------------------------------------------
type Email_Type is new Text_Type with private;
type Email_Access is access all Email_Type;
type Pointer_To_Email_Class is access all Email_Type'Class;
-------------------------------------------------------------------------
-- Email_Type - Creation Methods
-------------------------------------------------------------------------
overriding
procedure Create (Element : in out Email_Type;
Form : in out Form_Type'Class;
Size : in Integer := 20;
Value : in String := "";
Name : in String := "";
ID : in String := "");
-------------------------------------------------------------------------
-- Email_Type - Properties
-------------------------------------------------------------------------
procedure Multiple_Emails (Element : in out Email_Type;
Value : in Boolean := True);
function Multiple_Emails (Element : Email_Type) return Boolean;
-------------------------------------------------------------------------
-- Password_Types
-------------------------------------------------------------------------
type Password_Type is new Text_Type with private;
type Password_Access is access all Password_Type;
type Pointer_To_Password_Class is access all Password_Type'Class;
-------------------------------------------------------------------------
-- Password_Type - Creation Methods
-------------------------------------------------------------------------
overriding
procedure Create (Element : in out Password_Type;
Form : in out Form_Type'Class;
Size : in Integer := 20;
Value : in String := "";
Name : in String := "";
ID : in String := "");
-------------------------------------------------------------------------
-- URL_Types
-------------------------------------------------------------------------
type URL_Type is new Text_Type with private;
type URL_Access is access all URL_Type;
type Pointer_To_URL_Class is access all URL_Type'Class;
-------------------------------------------------------------------------
-- URL_Type - Creation Methods
-------------------------------------------------------------------------
overriding
procedure Create (Element : in out URL_Type;
Form : in out Form_Type'Class;
Size : in Integer := 20;
Value : in String := "";
Name : in String := "";
ID : in String := "");
-------------------------------------------------------------------------
-- Search_Types
-------------------------------------------------------------------------
type Search_Type is new Text_Type with private;
type Search_Access is access all Search_Type;
type Pointer_To_Search_Class is access all Search_Type'Class;
-------------------------------------------------------------------------
-- Search_Type - Creation Methods
-------------------------------------------------------------------------
overriding
procedure Create (Element : in out Search_Type;
Form : in out Form_Type'Class;
Size : in Integer := 20;
Value : in String := "";
Name : in String := "";
ID : in String := "");
-------------------------------------------------------------------------
-- Color_Picker_Types
-------------------------------------------------------------------------
type Color_Picker_Type is new Form_Element_Type with private;
type Color_Picker_Access is access all Color_Picker_Type;
type Pointer_To_Color_Picker_Class is access all Color_Picker_Type'Class;
-------------------------------------------------------------------------
-- Color_Picker_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create (Element : in out Color_Picker_Type;
Form : in out Form_Type'Class;
Value : in String := "";
Name : in String := "";
ID : in String := "");
procedure Create (Element : in out Color_Picker_Type;
Form : in out Form_Type'Class;
Value : in Gnoga.RGBA_Type;
Name : in String := "";
ID : in String := "");
procedure Create (Element : in out Color_Picker_Type;
Form : in out Form_Type'Class;
Value : in Gnoga.Colors.Color_Enumeration;
Name : in String := "";
ID : in String := "");
-------------------------------------------------------------------------
-- Color_Picker_Type - Properties
-------------------------------------------------------------------------
overriding
procedure Color (Element : in out Color_Picker_Type;
Value : in String);
overriding
procedure Color (Element : in out Color_Picker_Type;
RGBA : in Gnoga.RGBA_Type);
overriding
procedure Color (Element : in out Color_Picker_Type;
Enum : in Gnoga.Colors.Color_Enumeration);
overriding
function Color (Element : Color_Picker_Type) return Gnoga.RGBA_Type;
-------------------------------------------------------------------------
-- Date_Types
-------------------------------------------------------------------------
type Date_Type is new Form_Element_Type with private;
type Date_Access is access all Date_Type;
type Pointer_To_Date_Class is access all Date_Type'Class;
-------------------------------------------------------------------------
-- Date_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create (Element : in out Date_Type;
Form : in out Form_Type'Class;
Value : in String := "";
Name : in String := "";
ID : in String := "");
-- Value format yyyy-mm-dd for Date_Type
-------------------------------------------------------------------------
-- Time_Types
-------------------------------------------------------------------------
type Time_Type is new Form_Element_Type with private;
type Time_Access is access all Time_Type;
type Pointer_To_Time_Class is access all Time_Type'Class;
-------------------------------------------------------------------------
-- Time_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create (Element : in out Time_Type;
Form : in out Form_Type'Class;
Value : in String := "";
Name : in String := "";
ID : in String := "");
-- Value format HH:MM no time zone 24hour format
-------------------------------------------------------------------------
-- Month_Types
-------------------------------------------------------------------------
type Month_Type is new Form_Element_Type with private;
type Month_Access is access all Month_Type;
type Pointer_To_Month_Class is access all Month_Type'Class;
-------------------------------------------------------------------------
-- Month_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create (Element : in out Month_Type;
Form : in out Form_Type'Class;
Value : in String := "";
Name : in String := "";
ID : in String := "");
-- Value format yyyy-mm for Month_Type
-- Months are 1-12
-------------------------------------------------------------------------
-- Week_Types
-------------------------------------------------------------------------
type Week_Type is new Form_Element_Type with private;
type Week_Access is access all Week_Type;
type Pointer_To_Week_Class is access all Week_Type'Class;
-------------------------------------------------------------------------
-- Week_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create (Element : in out Week_Type;
Form : in out Form_Type'Class;
Value : in String := "";
Name : in String := "";
ID : in String := "");
-- Value format yyyy-Www for Week_Type
-- Date with the year and a W followed by the week number, with no time
-- zone. A "week" goes from Monday to Sunday, with week 1 being the week
-- containing the first Wednesday of the year, so could start on December
-- 30 or even January 2.
-------------------------------------------------------------------------
-- Date_Time_Types
-------------------------------------------------------------------------
type Date_Time_Type is new Form_Element_Type with private;
type Date_Time_Access is access all Date_Time_Type;
type Pointer_To_Date_Time_Class is access all Date_Time_Type'Class;
-------------------------------------------------------------------------
-- Date_Time_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create (Element : in out Date_Time_Type;
Form : in out Form_Type'Class;
Value : in String := "";
Name : in String := "";
ID : in String := "");
-- Value format yyyy-mm-ddTHH:MMZ
-- Hour, minute, second, and fraction of a second based on UTC time zone
-------------------------------------------------------------------------
-- Date_Time_Local_Types
-------------------------------------------------------------------------
type Date_Time_Local_Type is new Form_Element_Type with private;
type Date_Time_Local_Access is access all Date_Time_Local_Type;
type Pointer_To_Date_Time_Local_Class is
access all Date_Time_Local_Type'Class;
-------------------------------------------------------------------------
-- Date_Time_Local_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create (Element : in out Date_Time_Local_Type;
Form : in out Form_Type'Class;
Value : in String := "";
Name : in String := "";
ID : in String := "");
-- Value format yyyy-mm-ddTHH:MMZ
-- Hour, minute, second, and fraction of a second based on UTC time zone
-------------------------------------------------------------------------
-- Number_Types
-------------------------------------------------------------------------
type Number_Type is new Form_Element_Type with private;
type Number_Access is access all Number_Type;
type Pointer_To_Number_Class is access all Number_Type'Class;
-------------------------------------------------------------------------
-- Number_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create (Element : in out Number_Type;
Form : in out Form_Type'Class;
Value : in String := "";
Name : in String := "";
ID : in String := "");
-------------------------------------------------------------------------
-- Range_Types
-------------------------------------------------------------------------
type Range_Type is new Number_Type with private;
type Range_Access is access all Range_Type;
type Pointer_To_Range_Class is access all Range_Type'Class;
-------------------------------------------------------------------------
-- Range_Type - Creation Methods
-------------------------------------------------------------------------
overriding
procedure Create (Element : in out Range_Type;
Form : in out Form_Type'Class;
Value : in String := "";
Name : in String := "";
ID : in String := "");
-------------------------------------------------------------------------
-- Label_Types
-------------------------------------------------------------------------
type Label_Type is new Gnoga.Gui.Element.Element_Type with private;
type Label_Access is access all Label_Type;
type Pointer_To_Label_Class is access all Label_Type'Class;
-------------------------------------------------------------------------
-- Label_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create (Element : in out Label_Type;
Form : in out Form_Type'Class;
Label_For : in out Element_Type'Class;
Content : in String := "";
Auto_Place : in Boolean := True;
ID : in String := "");
-- Creates a Label_For a form element in Form with Content as label.
-- If Auto_Place is true, the label element will be moved in the DOM
-- to just before Label_For.
-------------------------------------------------------------------------
-- Selection_Types
-------------------------------------------------------------------------
-- As an alternative to using the Add_Option method you can add
-- as children Option_Type and Option_Group_Types. Option_Type
-- and Option_Group_Type are added with Item.Create, they can
-- be removed using Item.Remove and their order can be changed using
-- the standard Element_Type.Place_* methods.
type Selection_Type is new Form_Element_Type with private;
type Selection_Access is access all Selection_Type;
type Pointer_To_Selection_Class is access all Selection_Type'Class;
-------------------------------------------------------------------------
-- Selection_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create
(Element : in out Selection_Type;
Form : in out Form_Type'Class;
Multiple_Select : in Boolean := False;
Visible_Lines : in Positive := 1;
Name : in String := "";
ID : in String := "");
-- If Parent is a Window_Type'Class will automatically set itself
-- as the View on Parent if Attach is True
-------------------------------------------------------------------------
-- Selection_Type - Properties
-------------------------------------------------------------------------
procedure Multiple_Select (Element : in out Selection_Type;
Value : in Boolean := True);
function Multiple_Select (Element : Selection_Type) return Boolean;
procedure Visible_Lines (Element : in out Selection_Type;
Value : in Positive);
function Visible_Lines (Element : Selection_Type) return Positive;
function Selected_Index (Element : Selection_Type) return Natural;
-- If no item currently selected returns 0, in multiple select boxes
-- traverse the options using Selected.
overriding
function Value (Element : Selection_Type) return String;
-- Returns the value of the currently selected item. For multiple select
-- boxes get the value based on Index. The Value is the non-displayed
-- value of the currently selected item.
function Length (Element : Selection_Type) return Natural;
-- Number of options in Selection_Type
procedure Selected (Element : in out Selection_Type;
Index : in Positive;
Value : in Boolean := True);
function Selected (Element : Selection_Type; Index : Positive)
return Boolean;
procedure Disabled (Element : in out Selection_Type;
Index : in Positive;
Value : in Boolean := True);
function Disabled (Element : Selection_Type; Index : Positive)
return Boolean;
procedure Value (Element : in out Selection_Type;
Index : in Positive;
Value : in String);
function Value (Element : Selection_Type; Index : Positive)
return String;
-- Value is the non-displayed value of the the item at Index. If the form
-- is submitted, the value not the "Text" is sent to the form's action
-- URL.
procedure Text (Element : in out Selection_Type;
Index : in Positive;
Value : in String);
function Text (Element : Selection_Type; Index : Positive)
return String;
-- The displayed text of the item at Index. The text is not submitted by
-- the form only its value if the form is submitted to its action URL.
-------------------------------------------------------------------------
-- Selection_Type - Methods
-------------------------------------------------------------------------
procedure Add_Option (Element : in out Selection_Type;
Value : in String;
Text : in String;
Index : in Natural := 0;
Selected : in Boolean := False;
Disabled : in Boolean := False;
ID : in String := "");
-- Call to add options to the Selection_Type Element. If Index is 0
-- adds to end of list. Otherwise inserts at Index.
procedure Remove_Option (Element : in out Selection_Type;
Index : in Positive);
procedure Empty_Options (Element : in out Selection_Type);
-------------------------------------------------------------------------
-- Option_Type
-------------------------------------------------------------------------
type Option_Type is new Gnoga.Gui.Element.Element_Type with private;
type Option_Access is access all Option_Type;
type Pointer_To_Option_Class is access all Option_Type'Class;
-------------------------------------------------------------------------
-- Option_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create (Element : in out Option_Type;
Form : in out Form_Type'Class;
Selection : in out Gnoga.Gui.Element.Element_Type'Class;
Value : in String;
Text : in String;
Selected : in Boolean := False;
Disabled : in Boolean := False;
ID : in String := "");
-- Creates an Option for Selection, this is an alternative to using
-- Selection_Type.Add_Option that allows attaching events to the option.
-- Depending on browser, some styling may be possible also.
-- Will be added to end of Selection, the placement can be changed using
-- standard Element_Type.Place_* methods and can also be removed using
-- Element.Remove
-- Selection can be an element of Selection_Type or Option_Group_Type
-- NOTE: A few browsers allow limited styling of Element such as color
-- some do not allow any. Test across your expected delivery
-- platforms to insure the styling you use works as expected.
-------------------------------------------------------------------------
-- Option_Type - Properties
-------------------------------------------------------------------------
procedure Selected (Element : in out Option_Type;
Value : in Boolean := True);
function Selected (Element : Option_Type)
return Boolean;
procedure Disabled (Element : in out Option_Type;
Value : in Boolean := True);
function Disabled (Element : Option_Type)
return Boolean;
procedure Value (Element : in out Option_Type;
Value : in String);
function Value (Element : Option_Type)
return String;
overriding
procedure Text (Element : in out Option_Type;
Value : in String);
overriding
function Text (Element : Option_Type)
return String;
-------------------------------------------------------------------------
-- Option_Group_Type
-------------------------------------------------------------------------
type Option_Group_Type is new Gnoga.Gui.Element.Element_Type with private;
type Option_Group_Access is access all Option_Group_Type;
type Pointer_To_Option_Group_Class is access all Option_Group_Type'Class;
-------------------------------------------------------------------------
-- Option_Group_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create (Element : in out Option_Group_Type;
Form : in out Form_Type'Class;
Selection : in out Selection_Type'Class;
Label : in String;
Disabled : in Boolean := False;
ID : in String := "");
-- Option Groups create a tree like selection hierarchy in the Select.
-- once added
-------------------------------------------------------------------------
-- Option_Group_Type - Properties
-------------------------------------------------------------------------
procedure Disabled (Element : in out Option_Group_Type;
Value : in Boolean := True);
function Disabled (Element : Option_Group_Type)
return Boolean;
procedure Label (Element : in out Option_Group_Type;
Value : in String);
function Label (Element : Option_Group_Type)
return String;
-------------------------------------------------------------------------
-- File_Types
-------------------------------------------------------------------------
type File_Type is new Form_Element_Type with private;
type File_Access is access all File_Type;
type Pointer_To_File_Class is access all File_Type'Class;
-------------------------------------------------------------------------
-- File_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create (Element : in out File_Type;
Form : in out Form_Type'Class;
Multiple : in Boolean := False;
Name : in String := "";
ID : in String := "");
-------------------------------------------------------------------------
-- File_Type - Properties
-------------------------------------------------------------------------
procedure Accept_List (Element : in out File_Type;
Value : in String);
function Accept_List (Element : File_Type)
return String;
-- One or more unique file type specifiers describing file types to allow
procedure Capture (Element : in out File_Type;
Value : in String);
function Capture (Element : File_Type)
return String;
-- What source to use for capturing image or video data
procedure Multiple (Element : in out File_Type;
Value : in Boolean := True);
function Multiple (Element : File_Type)
return Boolean;
-- A Boolean which, if present, indicates that the user may choose more than one file
procedure WebkitDirectory (Element : in out File_Type;
Value : in Boolean := True);
function WebkitDirectory (Element : File_Type)
return Boolean;
-- A Boolean indicating whether or not to only allow the user to choose a directory
-- (or directories, if multiple is also present)
function File_Count (Element : File_Type) return Natural;
-- Return the number of selected files
function File_Name (Element : File_Type; Index : Positive := 1) return String;
-- Return the name of the specified file by its index
function File_Size (Element : File_Type; Index : Positive := 1) return Natural;
-- Return the size of the specified file by its index
function File_MIME_Type (Element : File_Type; Index : Positive := 1) return String;
-- Return the MIME type of the specified file by its index
function File_Last_Modified (Element : File_Type; Index : Positive := 1) return Natural;
-- Return the last modification time in millisecond of the specified file by its index
function File_WebkitRelativePath (Element : File_Type; Index : Positive := 1) return String;
-- Return the path of the file is relative to.
-------------------------------------------------------------------------
-- Tel_Types
-------------------------------------------------------------------------
type Tel_Type is new Form_Element_Type with private;
type Tel_Access is access all Tel_Type;
type Pointer_To_Tel_Class is access all Tel_Type'Class;
-------------------------------------------------------------------------
-- Tel_Type - Creation Methods
-------------------------------------------------------------------------
procedure Create (Element : in out Tel_Type;
Form : in out Form_Type'Class;
Value : in String := "";
Name : in String := "";
ID : in String := "");
private
type Form_Type is new Gnoga.Gui.View.View_Base_Type with null record;
type Form_Element_Type is
new Gnoga.Gui.Element.Element_Type with null record;
type Text_Area_Type is new Form_Element_Type with null record;
type Hidden_Type is new Form_Element_Type with null record;
type Input_Image_Type is new Form_Element_Type with null record;
type Input_Button_Type is new Form_Element_Type with null record;
type Submit_Button_Type is new Input_Button_Type with null record;
type Reset_Button_Type is new Input_Button_Type with null record;
type Text_Type is new Form_Element_Type with null record;
type Email_Type is new Text_Type with null record;
type Password_Type is new Text_Type with null record;
type Search_Type is new Text_Type with null record;
type URL_Type is new Text_Type with null record;
type Check_Box_Type is new Form_Element_Type with null record;
type Radio_Button_Type is new Form_Element_Type with null record;
type Color_Picker_Type is new Form_Element_Type with null record;
type Date_Type is new Form_Element_Type with null record;
type Time_Type is new Form_Element_Type with null record;
type Month_Type is new Form_Element_Type with null record;
type Week_Type is new Form_Element_Type with null record;
type Date_Time_Type is new Form_Element_Type with null record;
type Date_Time_Local_Type is new Form_Element_Type with null record;
type Number_Type is new Form_Element_Type with null record;
type Range_Type is new Number_Type with null record;
type Label_Type is new Gnoga.Gui.Element.Element_Type with null record;
type Data_List_Type is new Gnoga.Gui.View.View_Base_Type with null record;
type Selection_Type is new Form_Element_Type with null record;
type Option_Type is new Gnoga.Gui.Element.Element_Type with null record;
type Option_Group_Type is
new Gnoga.Gui.Element.Element_Type with null record;
type File_Type is new Form_Element_Type with null record;
type Tel_Type is new Form_Element_Type with null record;
end Ada_GUI.Gnoga.Gui.Element.Form;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.