repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
sebsgit/textproc | Ada | 359 | ads | with Ada.Calendar;
package Timer is
type T is tagged private;
function start return T;
function reset(tm: in out T) return Float;
procedure reset(tm: in out T);
procedure report(tm: in out T);
procedure report(tm: in out T; message: in String);
private
type T is tagged record
clock: Ada.Calendar.Time;
end record;
end Timer;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 5,118 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of STMicroelectronics nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
-- --
-- This file is based on: --
-- --
-- @file stm32f407xx.h et al. --
-- @author MCD Application Team --
-- @version V1.1.0 --
-- @date 19-June-2014 --
-- @brief CMSIS STM32F407xx Device Peripheral Access Layer Header File. --
-- --
-- COPYRIGHT(c) 2014 STMicroelectronics --
------------------------------------------------------------------------------
-- This file provides register definitions for the STM32 (ARM Cortex M4/7F)
-- microcontrollers from ST Microelectronics.
package STM32GD.EXTI is
pragma Preelaborate;
type External_Line_Number is
(EXTI_Line_0,
EXTI_Line_1,
EXTI_Line_2,
EXTI_Line_3,
EXTI_Line_4,
EXTI_Line_5,
EXTI_Line_6,
EXTI_Line_7,
EXTI_Line_8,
EXTI_Line_9,
EXTI_Line_10,
EXTI_Line_11,
EXTI_Line_12,
EXTI_Line_13,
EXTI_Line_14,
EXTI_Line_15,
EXTI_Line_16,
EXTI_Line_17,
EXTI_Line_18,
EXTI_Line_19,
EXTI_Line_20,
EXTI_Line_21,
EXTI_Line_22,
EXTI_Line_29,
EXTI_Line_30,
EXTI_Line_31,
EXTI_Line_32,
EXTI_Line_33,
EXTI_Line_34,
EXTI_Line_35);
type External_Triggers is
(Interrupt_Rising_Edge,
Interrupt_Falling_Edge,
Interrupt_Rising_Falling_Edge,
Event_Rising_Edge,
Event_Falling_Edge,
Event_Rising_Falling_Edge);
subtype Interrupt_Triggers is External_Triggers
range Interrupt_Rising_Edge .. Interrupt_Rising_Falling_Edge;
subtype Event_Triggers is External_Triggers
range Event_Rising_Edge .. Event_Rising_Falling_Edge;
procedure Enable_External_Interrupt
(Line : External_Line_Number;
Trigger : Interrupt_Triggers)
with Inline;
procedure Disable_External_Interrupt (Line : External_Line_Number)
with Inline;
procedure Enable_External_Event
(Line : External_Line_Number;
Trigger : Event_Triggers)
with Inline;
procedure Disable_External_Event (Line : External_Line_Number)
with Inline;
procedure Generate_SWI (Line : External_Line_Number)
with Inline;
function External_Interrupt_Pending (Line : External_Line_Number)
return Boolean
with Inline;
procedure Clear_External_Interrupt (Line : External_Line_Number)
with Inline;
end STM32GD.EXTI;
|
afrl-rq/OpenUxAS | Ada | 993 | adb | package body String_Utils is
---------------
-- To_String --
---------------
function To_String (Input : Int32) return String is
Result : constant String := Input'Image;
begin
if Input < 0 then
return Result; -- including the first char, which is the minus sign
else
return Result (2 .. Result'Last);
end if;
end To_String;
---------------
-- To_String --
---------------
function To_String (Input : Int64) return String is
Result : constant String := Input'Image;
begin
if Input < 0 then
return Result; -- including the first char, which is the minus sign
else
return Result (2 .. Result'Last);
end if;
end To_String;
---------------
-- To_String --
---------------
function To_String (Input : UInt32) return String is
Result : constant String := Input'Image;
begin
return Result (2 .. Result'Last);
end To_String;
end String_Utils;
|
ashleygay/adaboy | Ada | 5,861 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with word_operations_hpp;
with Interfaces.C.Extensions;
package cartridge_hpp is
-- We use this method to change the currently running game.
-- The gameboy should not be running while calling it.
-- It initializes the rom and the ram to zero.
-- FIXME: actually implement permissions
--the actual assembly of the cartridge separated in banks of 32kB
type Cartridge_rom_array is array (0 .. 2097151) of aliased word_operations_hpp.uint8_t;
type Cartridge_boot_rom_array is array (0 .. 255) of aliased word_operations_hpp.uint8_t;
type Cartridge_ram_array is array (0 .. 32767) of aliased word_operations_hpp.uint8_t;
package Class_Cartridge is
type Cartridge is limited record
rom : aliased Cartridge_rom_array; -- ./cartridge.hpp:41
boot_rom : aliased Cartridge_boot_rom_array; -- ./cartridge.hpp:68
c_type : aliased word_operations_hpp.uint8_t; -- ./cartridge.hpp:71
mbc : aliased int; -- ./cartridge.hpp:76
ram : aliased Cartridge_ram_array; -- ./cartridge.hpp:79
rom_size : aliased word_operations_hpp.size_t; -- ./cartridge.hpp:81
ram_size : aliased word_operations_hpp.size_t; -- ./cartridge.hpp:82
current_rom_bank : aliased word_operations_hpp.uint8_t; -- ./cartridge.hpp:84
current_ram_bank : aliased word_operations_hpp.uint8_t; -- ./cartridge.hpp:85
ram_enable_u : aliased Extensions.bool; -- ./cartridge.hpp:87
rom_ram_mode_u : aliased Extensions.bool; -- ./cartridge.hpp:88
has_ram_u : aliased Extensions.bool; -- ./cartridge.hpp:90
has_battery_u : aliased Extensions.bool; -- ./cartridge.hpp:91
has_timer_u : aliased Extensions.bool; -- ./cartridge.hpp:92
has_rumble_u : aliased Extensions.bool; -- ./cartridge.hpp:93
has_boot_u : aliased Extensions.bool; -- ./cartridge.hpp:95
initialized : aliased Extensions.bool; -- ./cartridge.hpp:97
end record;
pragma Import (CPP, Cartridge);
function New_Cartridge return Cartridge; -- ./cartridge.hpp:9
pragma CPP_Constructor (New_Cartridge, "_ZN9CartridgeC1Ev");
procedure change_game (this : access Cartridge; cart : access word_operations_hpp.uint8_t); -- ./cartridge.hpp:14
pragma Import (CPP, change_game, "_ZN9Cartridge11change_gameEPh");
function in_range (this : access Cartridge; address : word_operations_hpp.uint16_t) return Extensions.bool; -- ./cartridge.hpp:16
pragma Import (CPP, in_range, "_ZN9Cartridge8in_rangeEt");
function addr_in_range
(this : access Cartridge;
address : word_operations_hpp.uint16_t;
min : word_operations_hpp.uint16_t;
max : word_operations_hpp.uint16_t) return Extensions.bool; -- ./cartridge.hpp:18
pragma Import (CPP, addr_in_range, "_ZN9Cartridge13addr_in_rangeEttt");
function read (this : access Cartridge; address : word_operations_hpp.uint16_t) return word_operations_hpp.uint8_t; -- ./cartridge.hpp:20
pragma Import (CPP, read, "_ZN9Cartridge4readEt");
procedure write
(this : access Cartridge;
byte : word_operations_hpp.uint8_t;
address : word_operations_hpp.uint16_t); -- ./cartridge.hpp:21
pragma Import (CPP, write, "_ZN9Cartridge5writeEht");
function can_read (this : access Cartridge; address : word_operations_hpp.uint16_t) return Extensions.bool; -- ./cartridge.hpp:24
pragma Import (CPP, can_read, "_ZN9Cartridge8can_readEt");
function can_write (this : access Cartridge; address : word_operations_hpp.uint16_t) return Extensions.bool; -- ./cartridge.hpp:25
pragma Import (CPP, can_write, "_ZN9Cartridge9can_writeEt");
function ram_enable (this : access Cartridge) return Extensions.bool; -- ./cartridge.hpp:27
pragma Import (CPP, ram_enable, "_ZN9Cartridge10ram_enableEv");
function has_boot (this : access Cartridge) return Extensions.bool; -- ./cartridge.hpp:28
pragma Import (CPP, has_boot, "_ZN9Cartridge8has_bootEv");
function rom_ram_mode (this : access Cartridge) return Extensions.bool; -- ./cartridge.hpp:30
pragma Import (CPP, rom_ram_mode, "_ZN9Cartridge12rom_ram_modeEv");
function has_ram (this : access Cartridge) return Extensions.bool; -- ./cartridge.hpp:31
pragma Import (CPP, has_ram, "_ZN9Cartridge7has_ramEv");
function has_battery (this : access Cartridge) return Extensions.bool; -- ./cartridge.hpp:32
pragma Import (CPP, has_battery, "_ZN9Cartridge11has_batteryEv");
function has_timer (this : access Cartridge) return Extensions.bool; -- ./cartridge.hpp:33
pragma Import (CPP, has_timer, "_ZN9Cartridge9has_timerEv");
function has_rumble (this : access Cartridge) return Extensions.bool; -- ./cartridge.hpp:34
pragma Import (CPP, has_rumble, "_ZN9Cartridge10has_rumbleEv");
procedure fill_zeroes
(this : access Cartridge;
memory : access word_operations_hpp.uint8_t;
size : word_operations_hpp.size_t); -- ./cartridge.hpp:36
pragma Import (CPP, fill_zeroes, "_ZN9Cartridge11fill_zeroesEPhy");
end;
use Class_Cartridge;
-- a program inside the gameboy that boots the machine
-- and jumps to the location of the animated sequence
-- inside the rom
--This array has been generated with the xd utility tool.
-- the type of the cartidge see manual
-- the MBC of the cartridge, chip that will extend address space,
-- no MBC is a simple 32kb cartidge like Tetris
-- no MBC is 0, MM01 is 4
-- the internal ram of the cartridge
-- can be upper 2 bit of rom_bank_number
-- false if rom mode, true if ram mode
-- true when boot rom is finished
end cartridge_hpp;
|
reznikmm/matreshka | Ada | 3,845 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package body Servlet.Contexts is
-----------------
-- Add_Servlet --
-----------------
procedure Add_Servlet
(Self : not null access Servlet_Context'Class;
Name : League.Strings.Universal_String;
Instance : not null access Servlet.Servlets.Servlet'Class)
is
Aux : constant access
Servlet.Servlet_Registrations.Servlet_Registration'Class
:= Self.Add_Servlet (Name, Instance);
begin
null;
end Add_Servlet;
end Servlet.Contexts;
|
burratoo/Acton | Ada | 2,999 | ads | ------------------------------------------------------------------------------------------
-- --
-- OAK CORE SUPPORT PACKAGE --
-- ATMEL AVR --
-- --
-- OAK.CORE_SUPPORT_PACKAGE.TASK_SUPPORT --
-- --
-- Copyright (C) 2012-2021, Patrick Bernardi --
-- --
------------------------------------------------------------------------------------------
--
-- Processor Support Package for the e200z6 PowerPC Core.
--
with Oak.Oak_Time;
package Oak.Core_Support_Package.Task_Support with Preelaborate is
-- This procedure saves the Kernel's registers to its respective store,
-- loads in the task's registers, enables Oak's wakeup call and then
-- switches the Instruction Register. On Power Architectures, we'll just
-- place the instruction pointer and its stack pointer into a SPR. All this
-- has to be in one function as we do not want to touch the stack as we
-- carry out these steps. They all have to be done using assembly
-- instructions as well. Store and load the registers from onto their
-- respective task's or kernel's stack. If we are using a processor without
-- SPRs we have to look up the kernel's SP either through a fixed memory
-- address or reserve a register, the latter being unlikely.
-- In the future we may want to speed things up by creating specialised
-- context switch functions for switching between the kernel and the
-- scheduler agents. The scheduler agents do not need to store all their
-- registers on the call stack when they are switched out of context, as
-- they only loose context once they have finished their one of their
-- functions. Since this involves calling a Parameterless function the only
-- registers to store is the Stack Pointer. Even then, this could just be
-- set up by the kernel before the context switch... mmmm........
procedure Initialise_Task_Enviroment;
procedure Context_Switch_To_Task with Inline_Always;
procedure Context_Switch_To_Kernel with Inline_Always;
procedure Context_Switch_To_Scheduler_Agent with Inline_Always;
procedure Yield_Processor_To_Kernel with Inline_Always;
procedure Set_Oak_Wake_Up_Timer (Wake_Up_At : Oak_Time.Time);
procedure Sleep_Agent;
procedure Task_Interruptible with Inline_Always;
procedure Task_Not_Interruptible with Inline_Always;
private
Interrupts_Disabled : Boolean := False;
end Oak.Core_Support_Package.Task_Support;
|
zhmu/ananas | Ada | 175 | adb | -- { dg-options "-gnatws" }
package body G_Tables is
function Create (L : Natural) return Table is
begin
return T : Table (1 .. L);
end Create;
end G_Tables;
|
optikos/ada-lsp | Ada | 1,642 | ads | -- Copyright (c) 2017 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Ada.Containers.Hashed_Maps;
with Ada.Streams;
with League.Strings;
private with League.Strings.Hash;
with LSP.Messages;
with LSP.Message_Handlers;
with LSP.Types;
package LSP.Request_Dispatchers is
pragma Preelaborate;
type Request_Dispatcher is tagged limited private;
type Parameter_Handler_Access is access function
(Stream : access Ada.Streams.Root_Stream_Type'Class;
Handler : not null LSP.Message_Handlers.Request_Handler_Access)
return LSP.Messages.ResponseMessage'Class;
not overriding procedure Register
(Self : in out Request_Dispatcher;
Method : League.Strings.Universal_String;
Value : Parameter_Handler_Access);
not overriding function Dispatch
(Self : in out Request_Dispatcher;
Method : LSP.Types.LSP_String;
Stream : access Ada.Streams.Root_Stream_Type'Class;
Handler : not null LSP.Message_Handlers.Request_Handler_Access)
return LSP.Messages.ResponseMessage'Class;
private
package Maps is new Ada.Containers.Hashed_Maps
(Key_Type => League.Strings.Universal_String,
Element_Type => Parameter_Handler_Access,
Hash => League.Strings.Hash,
Equivalent_Keys => League.Strings."=",
"=" => "=");
type Request_Dispatcher is tagged limited record
Map : Maps.Map;
Value : LSP.Message_Handlers.Request_Handler_Access;
end record;
end LSP.Request_Dispatchers;
|
Rodeo-McCabe/orka | Ada | 3,048 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2013 Felix Krause <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with System;
package Glfw.Monitors is
pragma Preelaborate;
type Event is (Connected, Disconnected);
type Video_Mode is record
Width, Height : Interfaces.C.int;
Red_Bits, Green_Bits, Blue_Bits : Interfaces.C.int;
Refresh_Rate : Interfaces.C.int;
end record;
type Gamma_Value_Array is array (Positive range <>) of aliased
Interfaces.C.unsigned_short;
type Gamma_Ramp (Size : Positive) is record
Red, Green, Blue : Gamma_Value_Array (1 .. Size);
end record;
type Monitor is tagged limited private;
function "=" (Left, Right : Monitor) return Boolean;
function No_Monitor return Monitor;
function To_Monitor (Raw : System.Address) return Monitor;
type Monitor_List is array (Positive range <>) of aliased Monitor;
type Video_Mode_List is array (Positive range <>) of aliased Video_Mode;
pragma Convention (C, Video_Mode);
pragma Convention (C, Video_Mode_List);
function Monitors return Monitor_List;
function Primary_Monitor return Monitor;
procedure Get_Position (Object : Monitor; X, Y : out Integer);
procedure Get_Physical_Size (Object : Monitor; Width, Height : out Integer);
procedure Get_Content_Scale (Object : Monitor; X, Y : out Float);
procedure Get_Workarea (Object : Monitor; X, Y, Width, Height : out Integer);
function Name (Object : Monitor) return String;
function Video_Modes (Object : Monitor) return Video_Mode_List;
function Current_Video_Mode (Object : Monitor) return Video_Mode;
procedure Set_Gamma (Object : Monitor; Gamma : Float);
function Current_Gamma_Ramp (Object : Monitor) return Gamma_Ramp;
procedure Set_Gamma_Ramp (Object : Monitor; Value : Gamma_Ramp);
procedure Event_Occurred
(Object : not null access Monitor;
State : Event) is null;
procedure Set_Callback (Object : Monitor; Enable : Boolean);
-- Enable or disable a callback to receive monitor (dis)connection
-- events
--
-- Task safety: Must only be called from the environment task.
-- used internally
function Raw_Pointer (Object : Monitor) return System.Address;
private
type Monitor is tagged limited record
Handle : System.Address;
end record;
for Event use (Connected => 16#00040001#,
Disconnected => 16#00040002#);
for Event'Size use Interfaces.C.int'Size;
end Glfw.Monitors;
|
reznikmm/matreshka | Ada | 3,659 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Elements;
package ODF.DOM.Style_Header_Elements is
pragma Preelaborate;
type ODF_Style_Header is limited interface
and XML.DOM.Elements.DOM_Element;
type ODF_Style_Header_Access is
access all ODF_Style_Header'Class
with Storage_Size => 0;
end ODF.DOM.Style_Header_Elements;
|
bhayward93/Ada-Traffic-Light-Sim | Ada | 370 | adb | --with HWIF;
package body Tasks is
--Pressed Button Task
task ButtonPressed (this: in Direction) is
end ButtonPressed;
task body ButtonPressed is
(this: in Direction)
begin
Traffic_Light(this) := 4;
delay 1.0;
Traffic_Light(this) := 2;
delay 1.0;
Traffic_Light(this) := 1;
end ButtonPressed;
end Tasks;
|
reznikmm/gela | Ada | 2,487 | ads | with Gela.Interpretations;
with Gela.Int;
package Gela.Int_Sets is
pragma Preelaborate;
type Interpretation_Set is abstract tagged null record;
type Interpretation_Set_Access is access all Interpretation_Set'Class;
not overriding function Element
(Self : Interpretation_Set;
Index : Gela.Interpretations.Interpretation_Index)
return Gela.Int.Interpretation_Access is abstract;
not overriding function Categories
(Self : access Interpretation_Set;
Index : Gela.Interpretations.Interpretation_Set_Index)
return Gela.Interpretations.Category_Iterators
.Forward_Iterator'Class is abstract;
not overriding function Defining_Names
(Self : access Interpretation_Set;
Index : Gela.Interpretations.Interpretation_Set_Index)
return Gela.Interpretations.Defining_Name_Iterators
.Forward_Iterator'Class is abstract;
not overriding function Expressions
(Self : access Interpretation_Set;
Index : Gela.Interpretations.Interpretation_Set_Index)
return Gela.Interpretations.Expression_Iterators
.Forward_Iterator'Class is abstract;
not overriding function Profiles
(Self : access Interpretation_Set;
Index : Gela.Interpretations.Interpretation_Set_Index)
return Gela.Interpretations.Profile_Iterators
.Forward_Iterator'Class is abstract;
not overriding function Symbols
(Self : access Interpretation_Set;
Index : Gela.Interpretations.Interpretation_Set_Index)
return Gela.Interpretations.Symbol_Iterators
.Forward_Iterator'Class is abstract;
not overriding function Each
(Self : access Interpretation_Set;
Index : Gela.Interpretations.Interpretation_Set_Index)
return Gela.Interpretations.Any_Iterators
.Forward_Iterator'Class is abstract;
type Index_Provider is limited interface;
not overriding procedure Reserve_Indexes
(Self : in out Index_Provider;
Set : Interpretation_Set_Access;
From : out Gela.Interpretations.Interpretation_Set_Index;
To : out Gela.Interpretations.Interpretation_Set_Index) is abstract;
not overriding procedure Reserve_Indexes
(Self : in out Index_Provider;
Set : Interpretation_Set_Access;
From : out Gela.Interpretations.Interpretation_Index;
To : out Gela.Interpretations.Interpretation_Index) is abstract;
end Gela.Int_Sets;
|
reznikmm/matreshka | Ada | 4,688 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Table.Identify_Categories_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Table_Identify_Categories_Attribute_Node is
begin
return Self : Table_Identify_Categories_Attribute_Node do
Matreshka.ODF_Table.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Table_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Table_Identify_Categories_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Identify_Categories_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Table_URI,
Matreshka.ODF_String_Constants.Identify_Categories_Attribute,
Table_Identify_Categories_Attribute_Node'Tag);
end Matreshka.ODF_Table.Identify_Categories_Attributes;
|
reznikmm/matreshka | Ada | 3,542 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with AMF.Elements;
with League.Holders.Generic_Holders;
package AMF.Holders.Elements is
new League.Holders.Generic_Holders (AMF.Elements.Element_Access);
pragma Preelaborate (AMF.Holders.Elements);
|
faelys/natools | Ada | 921 | adb | with Interfaces; use Interfaces;
package body Natools.S_Expressions.Printers.Pretty.Config.Hex_Casing is
P : constant array (0 .. 1) of Natural :=
(1, 6);
T1 : constant array (0 .. 1) of Unsigned_8 :=
(8, 7);
T2 : constant array (0 .. 1) of Unsigned_8 :=
(9, 5);
G : constant array (0 .. 9) of Unsigned_8 :=
(0, 0, 0, 0, 0, 0, 2, 0, 3, 1);
function Hash (S : String) return Natural is
F : constant Natural := S'First - 1;
L : constant Natural := S'Length;
F1, F2 : Natural := 0;
J : Natural;
begin
for K in P'Range loop
exit when L < P (K);
J := Character'Pos (S (P (K) + F));
F1 := (F1 + Natural (T1 (K)) * J) mod 10;
F2 := (F2 + Natural (T2 (K)) * J) mod 10;
end loop;
return (Natural (G (F1)) + Natural (G (F2))) mod 4;
end Hash;
end Natools.S_Expressions.Printers.Pretty.Config.Hex_Casing;
|
LionelDraghi/smk | Ada | 1,666 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with asm_generic_int_ll64_h;
package linux_types_h is
-- SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note
-- * Below are truly Linux-specific types that should never collide with
-- * any application/library that wants linux/types.h.
--
subtype uu_le16 is asm_generic_int_ll64_h.uu_u16; -- /usr/include/linux/types.h:24
subtype uu_be16 is asm_generic_int_ll64_h.uu_u16; -- /usr/include/linux/types.h:25
subtype uu_le32 is asm_generic_int_ll64_h.uu_u32; -- /usr/include/linux/types.h:26
subtype uu_be32 is asm_generic_int_ll64_h.uu_u32; -- /usr/include/linux/types.h:27
subtype uu_le64 is asm_generic_int_ll64_h.uu_u64; -- /usr/include/linux/types.h:28
subtype uu_be64 is asm_generic_int_ll64_h.uu_u64; -- /usr/include/linux/types.h:29
subtype uu_sum16 is asm_generic_int_ll64_h.uu_u16; -- /usr/include/linux/types.h:31
subtype uu_wsum is asm_generic_int_ll64_h.uu_u32; -- /usr/include/linux/types.h:32
-- * aligned_u64 should be used in defining kernel<->userspace ABIs to avoid
-- * common 32/64-bit compat problems.
-- * 64-bit values align to 4-byte boundaries on x86_32 (and possibly other
-- * architectures) and to 8-byte boundaries on 64-bit architectures. The new
-- * aligned_64 type enforces 8-byte alignment so that structs containing
-- * aligned_64 values have the same alignment on 32-bit and 64-bit architectures.
-- * No conversions are necessary between 32-bit user-space and a 64-bit kernel.
--
subtype uu_poll_t is unsigned; -- /usr/include/linux/types.h:47
end linux_types_h;
|
jwarwick/aoc_2020 | Ada | 330 | ads | -- AOC 2020, Day X
with Ada.Containers.Vectors;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
package Day is
-- type Orbit_Checksum is new Natural;
-- function load_orbits(filename : in String) return Orbit_List.Vector;
-- function orbit_count_checksum(ol : in Orbit_List.Vector) return Orbit_Checksum;
end Day;
|
onox/sdlada | Ada | 5,877 | ads | --------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2013-2018 Luke A. Guest
--
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
--
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
--
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
--
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
--
-- 3. This notice may not be removed or altered from any source
-- distribution.
--------------------------------------------------------------------------------------------------------------------
-- SDL.Video.Windows.Manager
--
-- Access to the underlying window system.
--
-- Due to the nature of free OSes like Linux, one user may be using X11, another XCB, another Wayland and another
-- using Mir. We don't want to use build specific data for all these three, that makes sense for the varying OSes,
-- such as Linux, Windows, MacOS X, etc. So, if building on Windows, the compiler should only allow access to the
-- Windows/WinRT specific stuff, Linux, then X11/Wayland/Mir, etc.
--------------------------------------------------------------------------------------------------------------------
with Interfaces.C;
with SDL.Versions;
package SDL.Video.Windows.Manager is
type WM_Types is (WM_Unknown,
WM_Windows,
WM_X11,
WM_Direct_FB,
WM_Cocoa,
WM_UI_Kit,
WM_Wayland,
WM_Mir,
WM_Win_RT,
WM_Android) with
Convention => C;
type C_Address is access all Interfaces.Unsigned_32 with
Convention => C;
-- These are dummy types that (should) match what a real binding would provide so that the end user can
-- convert these using Unchecked_Conversion to pass into any other API's.
package Windows is
type HWNDs is new C_Address;
type HDCs is new C_Address;
end Windows;
-- WinRT only available since version 2.0.3.
package Win_RT is
type Inspectable is new C_Address;
end Win_RT;
package X11 is
type Display is new C_Address;
type Window is new Interfaces.Unsigned_32;
end X11;
package Direct_FB is
type Direct_FB is new C_Address;
type Direct_FB_Window is new C_Address;
type Direct_FB_Surface is new C_Address;
end Direct_FB;
package Cocoa is
type NS_Window is new C_Address;
end Cocoa;
package UI_Kit is
package C renames Interfaces.C;
type Window is new C_Address;
Frame_Buffer : C.unsigned;
Colour_Buffer : C.unsigned;
Resolve_Frame_Buffer : C.unsigned;
end UI_Kit;
-- Wayland only available since version 2.0.2.
package Wayland is
type Display is new C_Address;
type Surface is new C_Address;
type Shell_Surface is new C_Address;
end Wayland;
-- Mir only available since version 2.0.2.
package Mir is
type Connection is new C_Address;
type Surface is new C_Address;
end Mir;
-- Android only available since version 2.0.4.
package Android is
type Native_Window is new C_Address;
type EGL_Surface is new C_Address;
end Android;
type Information (WM : WM_Types) is
record
case WM is
when WM_Unknown =>
null;
when WM_Windows =>
HWND : Windows.HWNDs;
HDC : Windows.HDCs;
when WM_Win_RT =>
RT_Inspectable : Win_RT.Inspectable;
when WM_X11 =>
X11_Display : X11.Display;
X11_Window : X11.Window;
when WM_Direct_FB =>
DFB_Main_Interface : Direct_FB.Direct_FB;
DFB_Window : Direct_FB.Direct_FB_Window;
DFB_Surface : Direct_FB.Direct_FB_Surface;
when WM_Cocoa =>
Cocoa_Window : Cocoa.NS_Window;
when WM_UI_Kit =>
UIK_Window : UI_Kit.Window;
UIK_Frame_Buffer : UI_Kit.Window;
UIK_Colour_Buffer : UI_Kit.Window;
UIK_Resolve_Frame_Buffer : UI_Kit.Window;
when WM_Wayland =>
Wayland_Display : Wayland.Display;
Wayland_Surface : Wayland.Surface;
Wayland_Shell_Surface : Wayland.Shell_Surface;
when WM_Mir =>
Mir_Connection : Mir.Connection;
Mir_Surface : Mir.Surface;
when WM_Android =>
Android_Window : Android.Native_Window;
Android_Surface : Android.EGL_Surface;
end case;
end record with
Unchecked_Union;
type WM_Info is
record
Version : SDL.Versions.Version;
Sub_System : WM_Types;
Info : Information (WM => WM_Unknown);
end record with
Convention => C;
function Get_WM_Info (Win : in Window; Info : out WM_Info) return Boolean with
Inline => True;
end SDL.Video.Windows.Manager;
|
zhmu/ananas | Ada | 1,195 | adb | -- { dg-do run }
with System;
procedure SSO4 is
type Short_Int is mod 2**16;
type Rec1 is record
F1 : Short_Int;
F2 : Short_Int;
end record;
for Rec1 use record
F1 at 0 range 0 .. 15;
F2 at 0 range 16 .. 31;
end record;
for Rec1'Bit_Order use System.High_Order_First;
for Rec1'Scalar_Storage_Order use System.High_Order_First;
type Rec2 is record
I1 : Integer;
R1 : Rec1;
end record;
for Rec2 use record
I1 at 0 range 0 .. 31;
R1 at 4 range 0 .. 31;
end record;
for Rec2'Bit_Order use System.High_Order_First;
for Rec2'Scalar_Storage_Order use System.High_Order_First;
type Rec3 is record
Data : Rec1;
end record;
for Rec3 use record
Data at 0 range 0 .. 31;
end record;
for Rec3'Bit_Order use System.High_Order_First;
for Rec3'Scalar_Storage_Order use System.High_Order_First;
procedure Copy (Message : in Rec3) is
Local : Rec2;
begin
Local := (I1 => 1, R1 => Message.Data);
if Local.R1 /= Message.Data then
raise Program_Error;
end if;
end;
Message : Rec3;
begin
Message := (Data => (2, 3));
Copy(Message);
end;
|
AdaCore/libadalang | Ada | 407 | adb | procedure Test is
Value : constant Integer;
Var : Integer;
generic
X : in out Integer;
Y : in Integer;
package P is
procedure Foo;
end P;
package body P is
procedure Foo is
begin
X := Y;
end Foo;
end P;
package P_1 is new P (X => Var, Y => Value);
package P_2 is new P (X => Var, Y => 13);
begin
P_1.Foo;
P_2.Foo;
end Test;
|
kjseefried/coreland-cgbc | Ada | 2,017 | adb | with BHT_Support;
with Test;
procedure T_BHT_10 is
package BST4 renames BHT_Support.String_Tables4;
TC : Test.Context_t;
Expected_Value : constant Natural := 17;
Retrieved_Value : Natural := 0;
Exists : Boolean;
Inserted : Boolean;
begin
Test.Initialize
(Test_Context => TC,
Program => "t_bht_10",
Test_DB => "TEST_DB",
Test_Results => "TEST_RESULTS");
-- Retrieved_Value unreferenced.
pragma Warnings (Off);
BST4.Element
(Container => BHT_Support.Map,
Key => BHT_Support.Keys (1),
Element => Retrieved_Value,
Exists => Exists);
pragma Warnings (On);
Test.Check
(Test_Context => TC,
Test => 39,
Condition => Exists = False,
Statement => "Exists = False");
BST4.Insert
(Container => BHT_Support.Map,
Key => BHT_Support.Keys (2),
Element => Expected_Value,
Inserted => Inserted);
pragma Assert (Inserted);
-- Retrieved_Value unreferenced.
pragma Warnings (Off);
BST4.Element
(Container => BHT_Support.Map,
Key => BHT_Support.Keys (1),
Element => Retrieved_Value,
Exists => Exists);
pragma Warnings (On);
Test.Check
(Test_Context => TC,
Test => 36,
Condition => Exists = False,
Statement => "Exists = False");
BST4.Insert
(Container => BHT_Support.Map,
Key => BHT_Support.Keys (1),
Element => Expected_Value,
Inserted => Inserted);
pragma Assert (Inserted);
BST4.Element
(Container => BHT_Support.Map,
Key => BHT_Support.Keys (1),
Element => Retrieved_Value,
Exists => Exists);
Test.Check
(Test_Context => TC,
Test => 37,
Condition => Exists,
Statement => "Exists");
Test.Check
(Test_Context => TC,
Test => 38,
Condition => Retrieved_Value = Expected_Value,
Statement => "Retrieved_Value = Expected_Value");
end T_BHT_10;
|
1Crazymoney/LearnAda | Ada | 7,636 | adb | pragma Ada_95;
pragma Source_File_Name (ada_main, Spec_File_Name => "b__paros.ads");
pragma Source_File_Name (ada_main, Body_File_Name => "b__paros.adb");
pragma Suppress (Overflow_Check);
with Ada.Exceptions;
package body ada_main is
pragma Warnings (Off);
E074 : Short_Integer; pragma Import (Ada, E074, "system__os_lib_E");
E013 : Short_Integer; pragma Import (Ada, E013, "system__soft_links_E");
E023 : Short_Integer; pragma Import (Ada, E023, "system__exception_table_E");
E048 : Short_Integer; pragma Import (Ada, E048, "ada__io_exceptions_E");
E050 : Short_Integer; pragma Import (Ada, E050, "ada__tags_E");
E047 : Short_Integer; pragma Import (Ada, E047, "ada__streams_E");
E072 : Short_Integer; pragma Import (Ada, E072, "interfaces__c_E");
E025 : Short_Integer; pragma Import (Ada, E025, "system__exceptions_E");
E077 : Short_Integer; pragma Import (Ada, E077, "system__file_control_block_E");
E066 : Short_Integer; pragma Import (Ada, E066, "system__file_io_E");
E070 : Short_Integer; pragma Import (Ada, E070, "system__finalization_root_E");
E068 : Short_Integer; pragma Import (Ada, E068, "ada__finalization_E");
E017 : Short_Integer; pragma Import (Ada, E017, "system__secondary_stack_E");
E045 : Short_Integer; pragma Import (Ada, E045, "ada__text_io_E");
E099 : Short_Integer; pragma Import (Ada, E099, "mat_E");
Local_Priority_Specific_Dispatching : constant String := "";
Local_Interrupt_States : constant String := "";
Is_Elaborated : Boolean := False;
procedure finalize_library is
begin
E045 := E045 - 1;
declare
procedure F1;
pragma Import (Ada, F1, "ada__text_io__finalize_spec");
begin
F1;
end;
declare
procedure F2;
pragma Import (Ada, F2, "system__file_io__finalize_body");
begin
E066 := E066 - 1;
F2;
end;
declare
procedure Reraise_Library_Exception_If_Any;
pragma Import (Ada, Reraise_Library_Exception_If_Any, "__gnat_reraise_library_exception_if_any");
begin
Reraise_Library_Exception_If_Any;
end;
end finalize_library;
procedure adafinal is
procedure s_stalib_adafinal;
pragma Import (C, s_stalib_adafinal, "system__standard_library__adafinal");
procedure Runtime_Finalize;
pragma Import (C, Runtime_Finalize, "__gnat_runtime_finalize");
begin
if not Is_Elaborated then
return;
end if;
Is_Elaborated := False;
Runtime_Finalize;
s_stalib_adafinal;
end adafinal;
type No_Param_Proc is access procedure;
procedure adainit is
Main_Priority : Integer;
pragma Import (C, Main_Priority, "__gl_main_priority");
Time_Slice_Value : Integer;
pragma Import (C, Time_Slice_Value, "__gl_time_slice_val");
WC_Encoding : Character;
pragma Import (C, WC_Encoding, "__gl_wc_encoding");
Locking_Policy : Character;
pragma Import (C, Locking_Policy, "__gl_locking_policy");
Queuing_Policy : Character;
pragma Import (C, Queuing_Policy, "__gl_queuing_policy");
Task_Dispatching_Policy : Character;
pragma Import (C, Task_Dispatching_Policy, "__gl_task_dispatching_policy");
Priority_Specific_Dispatching : System.Address;
pragma Import (C, Priority_Specific_Dispatching, "__gl_priority_specific_dispatching");
Num_Specific_Dispatching : Integer;
pragma Import (C, Num_Specific_Dispatching, "__gl_num_specific_dispatching");
Main_CPU : Integer;
pragma Import (C, Main_CPU, "__gl_main_cpu");
Interrupt_States : System.Address;
pragma Import (C, Interrupt_States, "__gl_interrupt_states");
Num_Interrupt_States : Integer;
pragma Import (C, Num_Interrupt_States, "__gl_num_interrupt_states");
Unreserve_All_Interrupts : Integer;
pragma Import (C, Unreserve_All_Interrupts, "__gl_unreserve_all_interrupts");
Detect_Blocking : Integer;
pragma Import (C, Detect_Blocking, "__gl_detect_blocking");
Default_Stack_Size : Integer;
pragma Import (C, Default_Stack_Size, "__gl_default_stack_size");
Leap_Seconds_Support : Integer;
pragma Import (C, Leap_Seconds_Support, "__gl_leap_seconds_support");
procedure Runtime_Initialize (Install_Handler : Integer);
pragma Import (C, Runtime_Initialize, "__gnat_runtime_initialize");
Finalize_Library_Objects : No_Param_Proc;
pragma Import (C, Finalize_Library_Objects, "__gnat_finalize_library_objects");
begin
if Is_Elaborated then
return;
end if;
Is_Elaborated := True;
Main_Priority := -1;
Time_Slice_Value := -1;
WC_Encoding := 'b';
Locking_Policy := ' ';
Queuing_Policy := ' ';
Task_Dispatching_Policy := ' ';
Priority_Specific_Dispatching :=
Local_Priority_Specific_Dispatching'Address;
Num_Specific_Dispatching := 0;
Main_CPU := -1;
Interrupt_States := Local_Interrupt_States'Address;
Num_Interrupt_States := 0;
Unreserve_All_Interrupts := 0;
Detect_Blocking := 0;
Default_Stack_Size := -1;
Leap_Seconds_Support := 0;
Runtime_Initialize (1);
Finalize_Library_Objects := finalize_library'access;
System.Soft_Links'Elab_Spec;
System.Exception_Table'Elab_Body;
E023 := E023 + 1;
Ada.Io_Exceptions'Elab_Spec;
E048 := E048 + 1;
Ada.Tags'Elab_Spec;
Ada.Streams'Elab_Spec;
E047 := E047 + 1;
Interfaces.C'Elab_Spec;
System.Exceptions'Elab_Spec;
E025 := E025 + 1;
System.File_Control_Block'Elab_Spec;
E077 := E077 + 1;
System.Finalization_Root'Elab_Spec;
E070 := E070 + 1;
Ada.Finalization'Elab_Spec;
E068 := E068 + 1;
System.File_Io'Elab_Body;
E066 := E066 + 1;
E072 := E072 + 1;
Ada.Tags'Elab_Body;
E050 := E050 + 1;
System.Soft_Links'Elab_Body;
E013 := E013 + 1;
System.Os_Lib'Elab_Body;
E074 := E074 + 1;
System.Secondary_Stack'Elab_Body;
E017 := E017 + 1;
Ada.Text_Io'Elab_Spec;
Ada.Text_Io'Elab_Body;
E045 := E045 + 1;
E099 := E099 + 1;
end adainit;
procedure Ada_Main_Program;
pragma Import (Ada, Ada_Main_Program, "_ada_paros");
function main
(argc : Integer;
argv : System.Address;
envp : System.Address)
return Integer
is
procedure Initialize (Addr : System.Address);
pragma Import (C, Initialize, "__gnat_initialize");
procedure Finalize;
pragma Import (C, Finalize, "__gnat_finalize");
SEH : aliased array (1 .. 2) of Integer;
Ensure_Reference : aliased System.Address := Ada_Main_Program_Name'Address;
pragma Volatile (Ensure_Reference);
begin
gnat_argc := argc;
gnat_argv := argv;
gnat_envp := envp;
Initialize (SEH'Address);
adainit;
Ada_Main_Program;
adafinal;
Finalize;
return (gnat_exit_status);
end;
-- BEGIN Object file/option list
-- C:\Users\Soba95\Desktop\ada\mat.o
-- C:\Users\Soba95\Desktop\ada\paros.o
-- -LC:\Users\Soba95\Desktop\ada\
-- -LC:\Users\Soba95\Desktop\ada\
-- -LC:/gnat/2015/lib/gcc/i686-pc-mingw32/4.9.3/adalib/
-- -static
-- -lgnat
-- -Wl,--stack=0x2000000
-- END Object file/option list
end ada_main;
|
stcarrez/ada-wiki | Ada | 10,792 | adb | -----------------------------------------------------------------------
-- wiki-filters -- Wiki filters
-- Copyright (C) 2015, 2016, 2020, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body Wiki.Filters is
-- ------------------------------
-- Add a simple node such as N_LINE_BREAK, N_HORIZONTAL_RULE or N_PARAGRAPH to the document.
-- ------------------------------
procedure Add_Node (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Kind : in Wiki.Nodes.Simple_Node_Kind) is
begin
if Filter.Next /= null then
Filter.Next.Add_Node (Document, Kind);
else
Document.Append (Kind);
end if;
end Add_Node;
-- ------------------------------
-- Add a text content with the given format to the document.
-- ------------------------------
procedure Add_Text (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Text : in Wiki.Strings.WString;
Format : in Wiki.Format_Map) is
begin
if Filter.Next /= null then
Filter.Next.Add_Text (Document, Text, Format);
else
Wiki.Documents.Append (Document, Text, Format);
end if;
end Add_Text;
-- ------------------------------
-- Add a definition item at end of the document.
-- ------------------------------
procedure Add_Definition (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Definition : in Wiki.Strings.WString) is
begin
if Filter.Next /= null then
Filter.Next.Add_Definition (Document, Definition);
else
Wiki.Documents.Add_Definition (Document, Definition);
end if;
end Add_Definition;
procedure Start_Block (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Kind : in Wiki.Nodes.Node_Kind;
Level : in Natural) is
begin
if Filter.Next /= null then
Filter.Next.Start_Block (Document, Kind, Level);
else
Document.Start_Block (Kind, Level);
end if;
end Start_Block;
procedure End_Block (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Kind : in Wiki.Nodes.Node_Kind) is
begin
if Filter.Next /= null then
Filter.Next.End_Block (Document, Kind);
else
Document.End_Block (Kind);
end if;
end End_Block;
-- ------------------------------
-- Push a HTML node with the given tag to the document.
-- ------------------------------
procedure Push_Node (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Tag : in Wiki.Html_Tag;
Attributes : in out Wiki.Attributes.Attribute_List) is
begin
if Filter.Next /= null then
Filter.Next.Push_Node (Document, Tag, Attributes);
else
Document.Push_Node (Tag, Attributes);
end if;
end Push_Node;
-- ------------------------------
-- Pop a HTML node with the given tag.
-- ------------------------------
procedure Pop_Node (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Tag : in Wiki.Html_Tag) is
begin
if Filter.Next /= null then
Filter.Next.Pop_Node (Document, Tag);
else
Document.Pop_Node (Tag);
end if;
end Pop_Node;
-- ------------------------------
-- Add a blockquote (<blockquote>). The level indicates the blockquote nested level.
-- The blockquote must be closed at the next header.
-- ------------------------------
procedure Add_Blockquote (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Level : in Natural) is
begin
if Filter.Next /= null then
Filter.Next.Add_Blockquote (Document, Level);
else
Document.Add_Blockquote (Level);
end if;
end Add_Blockquote;
-- ------------------------------
-- Add a list (<ul> or <ol>) starting at the given number.
-- ------------------------------
procedure Add_List (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Level : in Natural;
Ordered : in Boolean) is
begin
if Filter.Next /= null then
Filter.Next.Add_List (Document, Level, Ordered);
else
Document.Add_List (Level, Ordered);
end if;
end Add_List;
-- ------------------------------
-- Add a link.
-- ------------------------------
procedure Add_Link (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Name : in Wiki.Strings.WString;
Attributes : in out Wiki.Attributes.Attribute_List) is
begin
if Filter.Next /= null then
Filter.Next.Add_Link (Document, Name, Attributes);
else
Document.Add_Link (Name, Attributes);
end if;
end Add_Link;
-- ------------------------------
-- Add a link reference with the given label.
-- ------------------------------
procedure Add_Link_Ref (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Label : in Wiki.Strings.WString) is
begin
if Filter.Next /= null then
Filter.Next.Add_Link_Ref (Document, Label);
else
Document.Add_Link_Ref (Label);
end if;
end Add_Link_Ref;
-- ------------------------------
-- Add an image.
-- ------------------------------
procedure Add_Image (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Name : in Wiki.Strings.WString;
Attributes : in out Wiki.Attributes.Attribute_List) is
begin
if Filter.Next /= null then
Filter.Next.Add_Image (Document, Name, Attributes);
else
Document.Add_Image (Name, Attributes);
end if;
end Add_Image;
-- ------------------------------
-- Add a quote.
-- ------------------------------
procedure Add_Quote (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Name : in Wiki.Strings.WString;
Attributes : in out Wiki.Attributes.Attribute_List) is
begin
if Filter.Next /= null then
Filter.Next.Add_Quote (Document, Name, Attributes);
else
Document.Add_Quote (Name, Attributes);
end if;
end Add_Quote;
-- ------------------------------
-- Add a text block that is pre-formatted.
-- ------------------------------
procedure Add_Preformatted (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Text : in Wiki.Strings.WString;
Format : in Wiki.Strings.WString) is
begin
if Filter.Next /= null then
Filter.Next.Add_Preformatted (Document, Text, Format);
else
Document.Add_Preformatted (Text, Format);
end if;
end Add_Preformatted;
-- ------------------------------
-- Add a new row to the current table.
-- ------------------------------
procedure Add_Row (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document) is
begin
if Filter.Next /= null then
Filter.Next.Add_Row (Document);
else
Document.Add_Row;
end if;
end Add_Row;
-- ------------------------------
-- Add a column to the current table row. The column is configured with the
-- given attributes. The column content is provided through calls to Append.
-- ------------------------------
procedure Add_Column (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document;
Attributes : in out Wiki.Attributes.Attribute_List) is
begin
if Filter.Next /= null then
Filter.Next.Add_Column (Document, Attributes);
else
Document.Add_Column (Attributes);
end if;
end Add_Column;
-- ------------------------------
-- Finish the creation of the table.
-- ------------------------------
procedure Finish_Table (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document) is
begin
if Filter.Next /= null then
Filter.Next.Finish_Table (Document);
else
Document.Finish_Table;
end if;
end Finish_Table;
-- ------------------------------
-- Finish the document after complete wiki text has been parsed.
-- ------------------------------
procedure Finish (Filter : in out Filter_Type;
Document : in out Wiki.Documents.Document) is
begin
if Filter.Next /= null then
Filter.Next.Finish (Document);
end if;
end Finish;
-- ------------------------------
-- Add the filter at beginning of the filter chain.
-- ------------------------------
procedure Add_Filter (Chain : in out Filter_Chain;
Filter : in Filter_Type_Access) is
begin
Filter.Next := Chain.Next;
Chain.Next := Filter;
end Add_Filter;
-- ------------------------------
-- Internal operation to copy the filter chain.
-- ------------------------------
procedure Set_Chain (Chain : in out Filter_Chain;
From : in Filter_Chain'Class) is
begin
Chain.Next := From.Next;
end Set_Chain;
end Wiki.Filters;
|
ytomino/gnat4drake | Ada | 2,226 | ads | pragma License (Unrestricted);
with System.Storage_Elements;
with System.Storage_Pools.Standard_Pools;
package GNAT.Debug_Pools is
type Debug_Pool is new System.Storage_Pools.Standard_Pools.Standard_Pool
with null record;
subtype SSC is System.Storage_Elements.Storage_Count;
Default_Max_Freed : constant SSC := 50_000_000;
Default_Stack_Trace_Depth : constant Natural := 20;
Default_Reset_Content : constant Boolean := False;
Default_Raise_Exceptions : constant Boolean := True;
Default_Advanced_Scanning : constant Boolean := False;
Default_Min_Freed : constant SSC := 0;
Default_Errors_To_Stdout : constant Boolean := True;
Default_Low_Level_Traces : constant Boolean := False;
procedure Configure (
Pool : in out Debug_Pool;
Stack_Trace_Depth : Natural := Default_Stack_Trace_Depth;
Maximum_Logically_Freed_Memory : SSC := Default_Max_Freed;
Minimum_To_Free : SSC := Default_Min_Freed;
Reset_Content_On_Free : Boolean := Default_Reset_Content;
Raise_Exceptions : Boolean := Default_Raise_Exceptions;
Advanced_Scanning : Boolean := Default_Advanced_Scanning;
Errors_To_Stdout : Boolean := Default_Errors_To_Stdout;
Low_Level_Traces : Boolean := Default_Low_Level_Traces) is null;
-- unimplemented
type Report_Type is (All_Reports);
generic
with procedure Put_Line (S : String) is <>;
with procedure Put (S : String) is <>;
procedure Dump (
Pool : Debug_Pool;
Size : Positive;
Report : Report_Type := All_Reports);
procedure Dump_Stdout (
Pool : Debug_Pool;
Size : Positive;
Report : Report_Type := All_Reports);
procedure Reset is null; -- unimplemented
procedure Get_Size (
Storage_Address : System.Address;
Size_In_Storage_Elements : out System.Storage_Elements.Storage_Count;
Valid : out Boolean);
type Byte_Count is mod System.Max_Binary_Modulus;
function High_Water_Mark (Pool : Debug_Pool) return Byte_Count;
function Current_Water_Mark (Pool : Debug_Pool) return Byte_Count;
procedure System_Memory_Debug_Pool (
Has_Unhandled_Memory : Boolean := True) is null; -- unimplemented
end GNAT.Debug_Pools;
|
AdaCore/Ada_Drivers_Library | Ada | 24,234 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with System; use System;
with ADL_Config;
with STM32_SVD.RCC; use STM32_SVD.RCC;
package body STM32.Device is
HSE_VALUE : constant := ADL_Config.High_Speed_External_Clock;
-- External oscillator in Hz
HSI_VALUE : constant := 16_000_000;
-- Internal oscillator in Hz
HPRE_Presc_Table : constant array (UInt4) of UInt32 :=
(1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 8, 16, 64, 128, 256, 512);
PPRE_Presc_Table : constant array (UInt3) of UInt32 :=
(1, 1, 1, 1, 2, 4, 8, 16);
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (This : aliased in out GPIO_Port) is
begin
if This'Address = GPIOA_Base then
RCC_Periph.AHB1ENR.GPIOAEN := True;
elsif This'Address = GPIOB_Base then
RCC_Periph.AHB1ENR.GPIOBEN := True;
elsif This'Address = GPIOC_Base then
RCC_Periph.AHB1ENR.GPIOCEN := True;
elsif This'Address = GPIOD_Base then
RCC_Periph.AHB1ENR.GPIODEN := True;
elsif This'Address = GPIOE_Base then
RCC_Periph.AHB1ENR.GPIOEEN := True;
elsif This'Address = GPIOF_Base then
RCC_Periph.AHB1ENR.GPIOFEN := True;
elsif This'Address = GPIOG_Base then
RCC_Periph.AHB1ENR.GPIOGEN := True;
elsif This'Address = GPIOH_Base then
RCC_Periph.AHB1ENR.GPIOHEN := True;
elsif This'Address = GPIOI_Base then
RCC_Periph.AHB1ENR.GPIOIEN := True;
else
raise Unknown_Device;
end if;
end Enable_Clock;
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (Point : GPIO_Point)
is
begin
Enable_Clock (Point.Periph.all);
end Enable_Clock;
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (Points : GPIO_Points)
is
begin
for Point of Points loop
Enable_Clock (Point.Periph.all);
end loop;
end Enable_Clock;
-----------
-- Reset --
-----------
procedure Reset (This : aliased in out GPIO_Port) is
begin
if This'Address = GPIOA_Base then
RCC_Periph.AHB1RSTR.GPIOARST := True;
RCC_Periph.AHB1RSTR.GPIOARST := False;
elsif This'Address = GPIOB_Base then
RCC_Periph.AHB1RSTR.GPIOBRST := True;
RCC_Periph.AHB1RSTR.GPIOBRST := False;
elsif This'Address = GPIOC_Base then
RCC_Periph.AHB1RSTR.GPIOCRST := True;
RCC_Periph.AHB1RSTR.GPIOCRST := False;
elsif This'Address = GPIOD_Base then
RCC_Periph.AHB1RSTR.GPIODRST := True;
RCC_Periph.AHB1RSTR.GPIODRST := False;
elsif This'Address = GPIOE_Base then
RCC_Periph.AHB1RSTR.GPIOERST := True;
RCC_Periph.AHB1RSTR.GPIOERST := False;
elsif This'Address = GPIOF_Base then
RCC_Periph.AHB1RSTR.GPIOFRST := True;
RCC_Periph.AHB1RSTR.GPIOFRST := False;
elsif This'Address = GPIOG_Base then
RCC_Periph.AHB1RSTR.GPIOGRST := True;
RCC_Periph.AHB1RSTR.GPIOGRST := False;
elsif This'Address = GPIOH_Base then
RCC_Periph.AHB1RSTR.GPIOHRST := True;
RCC_Periph.AHB1RSTR.GPIOHRST := False;
elsif This'Address = GPIOI_Base then
RCC_Periph.AHB1RSTR.GPIOIRST := True;
RCC_Periph.AHB1RSTR.GPIOIRST := False;
else
raise Unknown_Device;
end if;
end Reset;
-----------
-- Reset --
-----------
procedure Reset (Point : GPIO_Point) is
begin
Reset (Point.Periph.all);
end Reset;
-----------
-- Reset --
-----------
procedure Reset (Points : GPIO_Points)
is
Do_Reset : Boolean;
begin
for J in Points'Range loop
Do_Reset := True;
for K in Points'First .. J - 1 loop
if Points (K).Periph = Points (J).Periph then
Do_Reset := False;
exit;
end if;
end loop;
if Do_Reset then
Reset (Points (J).Periph.all);
end if;
end loop;
end Reset;
------------------------------
-- GPIO_Port_Representation --
------------------------------
function GPIO_Port_Representation (Port : GPIO_Port) return UInt4 is
begin
-- TODO: rather ugly to have this board-specific range here
if Port'Address = GPIOA_Base then
return 0;
elsif Port'Address = GPIOB_Base then
return 1;
elsif Port'Address = GPIOC_Base then
return 2;
elsif Port'Address = GPIOD_Base then
return 3;
elsif Port'Address = GPIOE_Base then
return 4;
elsif Port'Address = GPIOF_Base then
return 5;
elsif Port'Address = GPIOG_Base then
return 6;
elsif Port'Address = GPIOH_Base then
return 7;
elsif Port'Address = GPIOI_Base then
return 8;
else
raise Program_Error;
end if;
end GPIO_Port_Representation;
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (This : aliased in out Analog_To_Digital_Converter)
is
begin
if This'Address = ADC1_Base then
RCC_Periph.APB2ENR.ADC1EN := True;
elsif This'Address = ADC2_Base then
RCC_Periph.APB2ENR.ADC2EN := True;
elsif This'Address = ADC3_Base then
RCC_Periph.APB2ENR.ADC3EN := True;
else
raise Unknown_Device;
end if;
end Enable_Clock;
-------------------------
-- Reset_All_ADC_Units --
-------------------------
procedure Reset_All_ADC_Units is
begin
RCC_Periph.APB2RSTR.ADCRST := True;
RCC_Periph.APB2RSTR.ADCRST := False;
end Reset_All_ADC_Units;
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (This : aliased in out Digital_To_Analog_Converter)
is
pragma Unreferenced (This);
begin
RCC_Periph.APB1ENR.DACEN := True;
end Enable_Clock;
-----------
-- Reset --
-----------
procedure Reset (This : aliased in out Digital_To_Analog_Converter) is
pragma Unreferenced (This);
begin
RCC_Periph.APB1RSTR.DACRST := True;
RCC_Periph.APB1RSTR.DACRST := False;
end Reset;
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (This : aliased in out USART) is
begin
if This.Periph.all'Address = USART1_Base then
RCC_Periph.APB2ENR.USART1EN := True;
elsif This.Periph.all'Address = USART2_Base then
RCC_Periph.APB1ENR.USART2EN := True;
elsif This.Periph.all'Address = USART3_Base then
RCC_Periph.APB1ENR.USART3EN := True;
elsif This.Periph.all'Address = USART6_Base then
RCC_Periph.APB2ENR.USART6EN := True;
else
raise Unknown_Device;
end if;
end Enable_Clock;
-----------
-- Reset --
-----------
procedure Reset (This : aliased in out USART) is
begin
if This.Periph.all'Address = USART1_Base then
RCC_Periph.APB2RSTR.USART1RST := True;
RCC_Periph.APB2RSTR.USART1RST := False;
elsif This.Periph.all'Address = USART2_Base then
RCC_Periph.APB1RSTR.UART2RST := True;
RCC_Periph.APB1RSTR.UART2RST := False;
elsif This.Periph.all'Address = USART3_Base then
RCC_Periph.APB1RSTR.UART3RST := True;
RCC_Periph.APB1RSTR.UART3RST := False;
elsif This.Periph.all'Address = USART6_Base then
RCC_Periph.APB2RSTR.USART6RST := True;
RCC_Periph.APB2RSTR.USART6RST := False;
else
raise Unknown_Device;
end if;
end Reset;
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (This : aliased in out DMA_Controller) is
begin
if This'Address = STM32_SVD.DMA1_Base then
RCC_Periph.AHB1ENR.DMA1EN := True;
elsif This'Address = STM32_SVD.DMA2_Base then
RCC_Periph.AHB1ENR.DMA2EN := True;
else
raise Unknown_Device;
end if;
end Enable_Clock;
-----------
-- Reset --
-----------
procedure Reset (This : aliased in out DMA_Controller) is
begin
if This'Address = STM32_SVD.DMA1_Base then
RCC_Periph.AHB1RSTR.DMA1RST := True;
RCC_Periph.AHB1RSTR.DMA1RST := False;
elsif This'Address = STM32_SVD.DMA2_Base then
RCC_Periph.AHB1RSTR.DMA2RST := True;
RCC_Periph.AHB1RSTR.DMA2RST := False;
else
raise Unknown_Device;
end if;
end Reset;
----------------
-- As_Port_Id --
----------------
function As_Port_Id (Port : I2C_Port'Class) return I2C_Port_Id is
begin
if Port.Periph.all'Address = I2C1_Base then
return I2C_Id_1;
elsif Port.Periph.all'Address = I2C2_Base then
return I2C_Id_2;
elsif Port.Periph.all'Address = I2C3_Base then
return I2C_Id_3;
else
raise Unknown_Device;
end if;
end As_Port_Id;
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (This : aliased I2C_Port'Class) is
begin
Enable_Clock (As_Port_Id (This));
end Enable_Clock;
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (This : I2C_Port_Id) is
begin
case This is
when I2C_Id_1 =>
RCC_Periph.APB1ENR.I2C1EN := True;
when I2C_Id_2 =>
RCC_Periph.APB1ENR.I2C2EN := True;
when I2C_Id_3 =>
RCC_Periph.APB1ENR.I2C3EN := True;
end case;
end Enable_Clock;
-----------
-- Reset --
-----------
procedure Reset (This : I2C_Port'Class) is
begin
Reset (As_Port_Id (This));
end Reset;
-----------
-- Reset --
-----------
procedure Reset (This : I2C_Port_Id) is
begin
case This is
when I2C_Id_1 =>
RCC_Periph.APB1RSTR.I2C1RST := True;
RCC_Periph.APB1RSTR.I2C1RST := False;
when I2C_Id_2 =>
RCC_Periph.APB1RSTR.I2C2RST := True;
RCC_Periph.APB1RSTR.I2C2RST := False;
when I2C_Id_3 =>
RCC_Periph.APB1RSTR.I2C3RST := True;
RCC_Periph.APB1RSTR.I2C3RST := False;
end case;
end Reset;
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (This : SPI_Port'Class) is
begin
if This.Periph.all'Address = SPI1_Base then
RCC_Periph.APB2ENR.SPI1EN := True;
elsif This.Periph.all'Address = SPI2_Base then
RCC_Periph.APB1ENR.SPI2EN := True;
elsif This.Periph.all'Address = SPI3_Base then
RCC_Periph.APB1ENR.SPI3EN := True;
else
raise Unknown_Device;
end if;
end Enable_Clock;
-----------
-- Reset --
-----------
procedure Reset (This : in out SPI_Port'Class) is
begin
if This.Periph.all'Address = SPI1_Base then
RCC_Periph.APB2RSTR.SPI1RST := True;
RCC_Periph.APB2RSTR.SPI1RST := False;
elsif This.Periph.all'Address = SPI2_Base then
RCC_Periph.APB1RSTR.SPI2RST := True;
RCC_Periph.APB1RSTR.SPI2RST := False;
elsif This.Periph.all'Address = SPI3_Base then
RCC_Periph.APB1RSTR.SPI3RST := True;
RCC_Periph.APB1RSTR.SPI3RST := False;
else
raise Unknown_Device;
end if;
end Reset;
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (This : I2S_Port) is
begin
if This.Periph.all'Address = SPI1_Base then
RCC_Periph.APB2ENR.SPI1EN := True;
elsif This.Periph.all'Address = SPI2_Base
or else
This.Periph.all'Address = I2S2ext_Base
then
RCC_Periph.APB1ENR.SPI2EN := True;
elsif This.Periph.all'Address = SPI3_Base
or else
This.Periph.all'Address = I2S3ext_Base
then
RCC_Periph.APB1ENR.SPI3EN := True;
else
raise Unknown_Device;
end if;
end Enable_Clock;
-----------
-- Reset --
-----------
procedure Reset (This : in out I2S_Port) is
begin
if This.Periph.all'Address = SPI1_Base then
RCC_Periph.APB2RSTR.SPI1RST := True;
RCC_Periph.APB2RSTR.SPI1RST := False;
elsif This.Periph.all'Address = SPI2_Base then
RCC_Periph.APB1RSTR.SPI2RST := True;
RCC_Periph.APB1RSTR.SPI2RST := False;
elsif This.Periph.all'Address = SPI3_Base then
RCC_Periph.APB1RSTR.SPI3RST := True;
RCC_Periph.APB1RSTR.SPI3RST := False;
else
raise Unknown_Device;
end if;
end Reset;
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (This : in out Timer) is
begin
if This'Address = TIM1_Base then
RCC_Periph.APB2ENR.TIM1EN := True;
elsif This'Address = TIM2_Base then
RCC_Periph.APB1ENR.TIM2EN := True;
elsif This'Address = TIM3_Base then
RCC_Periph.APB1ENR.TIM3EN := True;
elsif This'Address = TIM4_Base then
RCC_Periph.APB1ENR.TIM4EN := True;
elsif This'Address = TIM5_Base then
RCC_Periph.APB1ENR.TIM5EN := True;
elsif This'Address = TIM6_Base then
RCC_Periph.APB1ENR.TIM6EN := True;
elsif This'Address = TIM7_Base then
RCC_Periph.APB1ENR.TIM7EN := True;
elsif This'Address = TIM8_Base then
RCC_Periph.APB2ENR.TIM8EN := True;
elsif This'Address = TIM9_Base then
RCC_Periph.APB2ENR.TIM9EN := True;
elsif This'Address = TIM10_Base then
RCC_Periph.APB2ENR.TIM10EN := True;
elsif This'Address = TIM11_Base then
RCC_Periph.APB2ENR.TIM11EN := True;
elsif This'Address = TIM12_Base then
RCC_Periph.APB1ENR.TIM12EN := True;
elsif This'Address = TIM13_Base then
RCC_Periph.APB1ENR.TIM13EN := True;
elsif This'Address = TIM14_Base then
RCC_Periph.APB1ENR.TIM14EN := True;
else
raise Unknown_Device;
end if;
end Enable_Clock;
-----------
-- Reset --
-----------
procedure Reset (This : in out Timer) is
begin
if This'Address = TIM1_Base then
RCC_Periph.APB2RSTR.TIM1RST := True;
RCC_Periph.APB2RSTR.TIM1RST := False;
elsif This'Address = TIM2_Base then
RCC_Periph.APB1RSTR.TIM2RST := True;
RCC_Periph.APB1RSTR.TIM2RST := False;
elsif This'Address = TIM3_Base then
RCC_Periph.APB1RSTR.TIM3RST := True;
RCC_Periph.APB1RSTR.TIM3RST := False;
elsif This'Address = TIM4_Base then
RCC_Periph.APB1RSTR.TIM4RST := True;
RCC_Periph.APB1RSTR.TIM4RST := False;
elsif This'Address = TIM5_Base then
RCC_Periph.APB1RSTR.TIM5RST := True;
RCC_Periph.APB1RSTR.TIM5RST := False;
elsif This'Address = TIM6_Base then
RCC_Periph.APB1RSTR.TIM6RST := True;
RCC_Periph.APB1RSTR.TIM6RST := False;
elsif This'Address = TIM7_Base then
RCC_Periph.APB1RSTR.TIM7RST := True;
RCC_Periph.APB1RSTR.TIM7RST := False;
elsif This'Address = TIM8_Base then
RCC_Periph.APB2RSTR.TIM8RST := True;
RCC_Periph.APB2RSTR.TIM8RST := False;
elsif This'Address = TIM9_Base then
RCC_Periph.APB2RSTR.TIM9RST := True;
RCC_Periph.APB2RSTR.TIM9RST := False;
elsif This'Address = TIM10_Base then
RCC_Periph.APB2RSTR.TIM10RST := True;
RCC_Periph.APB2RSTR.TIM10RST := False;
elsif This'Address = TIM11_Base then
RCC_Periph.APB2RSTR.TIM11RST := True;
RCC_Periph.APB2RSTR.TIM11RST := False;
elsif This'Address = TIM12_Base then
RCC_Periph.APB1RSTR.TIM12RST := True;
RCC_Periph.APB1RSTR.TIM12RST := False;
elsif This'Address = TIM13_Base then
RCC_Periph.APB1RSTR.TIM13RST := True;
RCC_Periph.APB1RSTR.TIM13RST := False;
elsif This'Address = TIM14_Base then
RCC_Periph.APB1RSTR.TIM14RST := True;
RCC_Periph.APB1RSTR.TIM14RST := False;
else
raise Unknown_Device;
end if;
end Reset;
------------------------------
-- System_Clock_Frequencies --
------------------------------
function System_Clock_Frequencies return RCC_System_Clocks
is
Source : constant UInt2 := RCC_Periph.CFGR.SWS;
Result : RCC_System_Clocks;
begin
Result.I2SCLK := 0;
case Source is
when 0 =>
-- HSI as source
Result.SYSCLK := HSI_VALUE;
when 1 =>
-- HSE as source
Result.SYSCLK := HSE_VALUE;
when 2 =>
-- PLL as source
declare
HSE_Source : constant Boolean := RCC_Periph.PLLCFGR.PLLSRC;
Pllm : constant UInt32 :=
UInt32 (RCC_Periph.PLLCFGR.PLLM);
Plln : constant
UInt32 :=
UInt32 (RCC_Periph.PLLCFGR.PLLN);
Pllp : constant
UInt32 :=
(UInt32 (RCC_Periph.PLLCFGR.PLLP) + 1) * 2;
Pllvco : UInt32;
begin
if not HSE_Source then
Pllvco := HSI_VALUE;
else
Pllvco := HSE_VALUE;
end if;
Pllvco := Pllvco / Pllm;
Result.I2SCLK := Pllvco;
Pllvco := Pllvco * Plln;
Result.SYSCLK := Pllvco / Pllp;
end;
when others =>
Result.SYSCLK := HSI_VALUE;
end case;
declare
HPRE : constant UInt4 := RCC_Periph.CFGR.HPRE;
PPRE1 : constant UInt3 := RCC_Periph.CFGR.PPRE.Arr (1);
PPRE2 : constant UInt3 := RCC_Periph.CFGR.PPRE.Arr (2);
begin
Result.HCLK := Result.SYSCLK / HPRE_Presc_Table (HPRE);
Result.PCLK1 := Result.HCLK / PPRE_Presc_Table (PPRE1);
Result.PCLK2 := Result.HCLK / PPRE_Presc_Table (PPRE2);
-- Timer clocks
-- If the APB prescaler (PPRE1, PPRE2 in the RCC_CFGR register)
-- is configured to a division factor of 1, TIMxCLK = PCLKx.
-- Otherwise, the timer clock frequencies are set to twice to the
-- frequency of the APB domain to which the timers are connected :
-- TIMxCLK = 2xPCLKx.
if PPRE_Presc_Table (PPRE1) = 1 then
Result.TIMCLK1 := Result.PCLK1;
else
Result.TIMCLK1 := Result.PCLK1 * 2;
end if;
if PPRE_Presc_Table (PPRE2) = 1 then
Result.TIMCLK2 := Result.PCLK2;
else
Result.TIMCLK2 := Result.PCLK2 * 2;
end if;
end;
-- I2S Clock --
if RCC_Periph.CFGR.I2SSRC then
-- External clock source
Result.I2SCLK := 0;
raise Program_Error with "External I2S clock value is unknown";
else
-- Pll clock source
declare
Plli2sn : constant UInt32 :=
UInt32 (RCC_Periph.PLLI2SCFGR.PLLI2SNx);
Plli2sr : constant UInt32
:= UInt32 (RCC_Periph.PLLI2SCFGR.PLLI2SRx);
begin
Result.I2SCLK := (Result.I2SCLK * Plli2sn) / Plli2sr;
end;
end if;
return Result;
end System_Clock_Frequencies;
--------------------
-- PLLI2S_Enabled --
--------------------
function PLLI2S_Enabled return Boolean is
(RCC_Periph.CR.PLLI2SRDY);
------------------------
-- Set_PLLI2S_Factors --
------------------------
procedure Set_PLLI2S_Factors (Pll_N : UInt9;
Pll_R : UInt3)
is
begin
RCC_Periph.PLLI2SCFGR.PLLI2SNx := Pll_N;
RCC_Periph.PLLI2SCFGR.PLLI2SRx := Pll_R;
end Set_PLLI2S_Factors;
-------------------
-- Enable_PLLI2S --
-------------------
procedure Enable_PLLI2S is
begin
RCC_Periph.CR.PLLI2SON := True;
loop
exit when PLLI2S_Enabled;
end loop;
end Enable_PLLI2S;
--------------------
-- Disable_PLLI2S --
--------------------
procedure Disable_PLLI2S is
begin
RCC_Periph.CR.PLLI2SON := False;
loop
exit when not PLLI2S_Enabled;
end loop;
end Disable_PLLI2S;
-----------------------
-- Enable_DCMI_Clock --
-----------------------
procedure Enable_DCMI_Clock is
begin
RCC_Periph.AHB2ENR.DCMIEN := True;
end Enable_DCMI_Clock;
----------------
-- Reset_DCMI --
----------------
procedure Reset_DCMI is
begin
RCC_Periph.AHB2RSTR.DCMIRST := True;
RCC_Periph.AHB2RSTR.DCMIRST := False;
end Reset_DCMI;
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (This : in out SDMMC_Controller)
is
begin
if This.Periph.all'Address /= SDIO_Base then
raise Unknown_Device;
end if;
RCC_Periph.APB2ENR.SDIOEN := True;
end Enable_Clock;
-----------
-- Reset --
-----------
procedure Reset (This : in out SDMMC_Controller)
is
begin
if This.Periph.all'Address /= SDIO_Base then
raise Unknown_Device;
end if;
RCC_Periph.APB2RSTR.SDIORST := True;
RCC_Periph.APB2RSTR.SDIORST := False;
end Reset;
------------------
-- Enable_Clock --
------------------
procedure Enable_Clock (This : in out CRC_32) is
pragma Unreferenced (This);
begin
RCC_Periph.AHB1ENR.CRCEN := True;
end Enable_Clock;
-------------------
-- Disable_Clock --
-------------------
procedure Disable_Clock (This : in out CRC_32) is
pragma Unreferenced (This);
begin
RCC_Periph.AHB1ENR.CRCEN := False;
end Disable_Clock;
-----------
-- Reset --
-----------
procedure Reset (This : in out CRC_32) is
pragma Unreferenced (This);
begin
RCC_Periph.AHB1RSTR.CRCRST := True;
RCC_Periph.AHB1RSTR.CRCRST := False;
end Reset;
end STM32.Device;
|
acornagl/Control_flow_graph-wcet | Ada | 98 | adb | with Ada.Text_IO; use Ada.Text_IO;
procedure main is
begin
Put_Line("Hello world");
end main;
|
charlie5/lace | Ada | 16,828 | ads | with
interfaces.C.Pointers,
interfaces.C.Strings,
system.Address_To_Access_Conversions;
package swig.Pointers
--
-- Contains pointers to Swig related C type definitions not found in the 'interfaces.C' family.
--
is
-- void_ptr
--
package C_void_ptr_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => swig.void_ptr,
element_Array => void_ptr_Array,
default_Terminator => system.null_Address);
subtype void_ptr_Pointer is C_void_ptr_Pointers.Pointer;
-- opaque struct_ptr
--
type opaque_structure_ptr is access swig.opaque_structure;
type opaque_structure_ptr_array is array (interfaces.c.Size_t range <>) of aliased opaque_structure_ptr;
package C_opaque_structure_ptr_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => opaque_structure_ptr,
element_Array => opaque_structure_ptr_array,
default_Terminator => null);
subtype opaque_structure_ptr_Pointer is C_opaque_structure_ptr_Pointers.Pointer;
-- incomplete class
--
type incomplete_class_ptr is access swig.incomplete_class;
type incomplete_class_ptr_array is array (interfaces.c.Size_t range <>) of aliased incomplete_class_ptr;
package C_incomplete_class_ptr_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => incomplete_class_ptr,
element_Array => incomplete_class_ptr_array,
default_Terminator => null);
subtype incomplete_class_ptr_Pointer is C_incomplete_class_ptr_Pointers.Pointer;
-- bool*
--
package c_bool_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => swig.bool,
element_Array => bool_Array,
default_Terminator => 0);
subtype bool_Pointer is c_bool_Pointers.Pointer;
type bool_Pointer_array is array (interfaces.c.Size_t range <>) of aliased bool_Pointer;
-- bool**
--
package C_bool_pointer_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => bool_Pointer,
element_Array => bool_Pointer_array,
default_Terminator => null);
subtype bool_pointer_Pointer is C_bool_pointer_Pointers.Pointer;
-- char* []
--
type chars_ptr_array is array (interfaces.c.Size_t range <>) of aliased interfaces.c.strings.chars_Ptr; -- standard Ada does not have 'aliased'
package C_chars_ptr_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.strings.chars_ptr,
element_Array => chars_ptr_array,
default_Terminator => interfaces.c.strings.Null_Ptr);
subtype chars_ptr_Pointer is C_chars_ptr_Pointers.Pointer;
-- char** []
--
type chars_ptr_Pointer_array is array (interfaces.c.Size_t range <>) of aliased chars_ptr_Pointer;
package C_chars_ptr_pointer_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => chars_ptr_Pointer,
element_Array => chars_ptr_Pointer_array,
default_Terminator => null);
subtype chars_ptr_pointer_Pointer is C_chars_ptr_pointer_Pointers.Pointer;
-- wchar_t*
--
package c_wchar_t_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.wchar_t,
element_Array => interfaces.c.wchar_array,
default_Terminator => interfaces.c.wchar_t'First);
subtype wchar_t_Pointer is c_wchar_t_Pointers.Pointer;
-- signed char*
--
package c_signed_char_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.signed_Char,
element_Array => swig.signed_char_Array,
default_Terminator => 0);
subtype signed_char_Pointer is c_signed_char_Pointers.Pointer;
-- unsigned char*
--
package c_unsigned_char_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.unsigned_Char,
element_Array => unsigned_char_Array,
default_Terminator => 0);
subtype unsigned_char_Pointer is c_unsigned_char_Pointers.Pointer;
-- short*
--
package c_short_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.Short,
element_Array => short_Array,
default_Terminator => 0);
subtype short_Pointer is c_short_Pointers.Pointer;
-- unsigned short*
--
package c_unsigned_short_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.unsigned_Short,
element_Array => unsigned_short_Array,
default_Terminator => 0);
subtype unsigned_short_Pointer is c_unsigned_short_Pointers.Pointer;
-- int*
--
package c_int_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.Int,
element_Array => int_Array,
default_Terminator => 0);
subtype int_Pointer is c_int_Pointers.Pointer;
-- int**
--
type int_pointer_Array is array (interfaces.c.size_t range <>) of aliased int_Pointer;
package c_int_pointer_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => int_Pointer,
element_Array => int_pointer_Array,
default_Terminator => null);
subtype int_pointer_Pointer is c_int_pointer_Pointers.Pointer;
-- size_t*
--
package c_size_t_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.Size_t,
element_Array => size_t_Array,
default_Terminator => 0);
subtype size_t_Pointer is c_size_t_Pointers.Pointer;
-- unsigned*
--
package c_unsigned_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.Unsigned,
element_Array => unsigned_Array,
default_Terminator => 0);
subtype unsigned_Pointer is c_unsigned_Pointers.Pointer;
-- long*
--
package c_long_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.Long,
element_Array => long_Array,
default_Terminator => 0);
subtype long_Pointer is c_long_Pointers.Pointer;
-- unsigned long*
--
package c_unsigned_long_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.unsigned_Long,
element_Array => unsigned_long_Array,
default_Terminator => 0);
subtype unsigned_long_Pointer is c_unsigned_long_Pointers.Pointer;
-- long long*
--
package c_long_long_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => swig.long_Long,
element_Array => long_long_Array,
default_Terminator => 0);
subtype long_long_Pointer is c_long_long_Pointers.Pointer;
-- unsigned long long*
--
package c_unsigned_long_long_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => swig.unsigned_long_Long,
element_Array => unsigned_long_long_Array,
default_Terminator => 0);
subtype unsigned_long_long_Pointer is c_unsigned_long_long_Pointers.Pointer;
-- int8_t*
--
package c_int8_t_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => swig.int8_t,
element_Array => swig.int8_t_Array,
default_Terminator => 0);
subtype int8_t_Pointer is c_int8_t_Pointers.Pointer;
-- int16_t*
--
package c_int16_t_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => swig.int16_t,
element_Array => swig.int16_t_Array,
default_Terminator => 0);
subtype int16_t_Pointer is c_int16_t_Pointers.Pointer;
-- int32_t*
--
package c_int32_t_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => swig.int32_t,
element_Array => swig.int32_t_Array,
default_Terminator => 0);
subtype int32_t_Pointer is c_int32_t_Pointers.Pointer;
-- int64_t*
--
package c_int64_t_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => swig.int64_t,
element_Array => swig.int64_t_Array,
default_Terminator => 0);
subtype int64_t_Pointer is c_int64_t_Pointers.Pointer;
-- uint8_t*'
--
package c_uint8_t_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => swig.uint8_t,
element_Array => swig.uint8_t_Array,
default_Terminator => 0);
subtype uint8_t_Pointer is c_uint8_t_Pointers.Pointer;
-- uint16_t*'
--
package c_uint16_t_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => swig.uint16_t,
element_Array => swig.uint16_t_Array,
default_Terminator => 0);
subtype uint16_t_Pointer is c_uint16_t_Pointers.Pointer;
-- uint32_t*'
--
package c_uint32_t_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => swig.uint32_t,
element_Array => swig.uint32_t_Array,
default_Terminator => 0);
subtype uint32_t_Pointer is c_uint32_t_Pointers.Pointer;
-- uint64_t*'
--
package c_uint64_t_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => swig.uint64_t,
element_Array => swig.uint64_t_Array,
default_Terminator => 0);
subtype uint64_t_Pointer is c_uint64_t_Pointers.Pointer;
-- float*'
package c_float_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.c_Float,
element_Array => float_Array,
default_Terminator => 0.0);
subtype float_Pointer is c_float_Pointers.Pointer;
-- double*'
--
package c_double_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.Double,
element_Array => double_Array,
default_Terminator => 0.0);
subtype double_Pointer is c_double_Pointers.Pointer;
-- long double*'
--
package c_long_double_Pointers is new interfaces.c.Pointers (Index => interfaces.c.size_t,
Element => interfaces.c.long_Double,
element_Array => long_double_Array,
default_Terminator => 0.0);
subtype long_double_Pointer is c_long_double_Pointers.Pointer;
-- std::string
--
type std_string is private;
type std_string_Pointer is access all std_String;
type std_string_Array is array (interfaces.c.size_t range <>) of aliased std_String;
-- Utility
--
package void_Conversions is new system.Address_To_Access_Conversions (swig.Void);
private
type std_String is
record
M_dataplus : swig.void_ptr; -- which is a subtype of system.Address
end record;
end Swig.Pointers;
-- tbd: use sensible default_Terminator's.
|
burratoo/Acton | Ada | 1,078 | ads | ------------------------------------------------------------------------------------------
-- --
-- OAK CORE SUPPORT PACKAGE --
-- ATMEL AVR --
-- --
-- OAK.CORE_SUPPORT_PACKAGE.PROCESSOR --
-- --
-- Copyright (C) 2012-2021, Patrick Bernardi --
-- --
------------------------------------------------------------------------------------------
package Oak.Core_Support_Package.Processor with Pure is
function Proccessor_Id return Oak_Instance_Id with Inline_Always;
end Oak.Core_Support_Package.Processor;
|
RREE/build-avr-ada-toolchain | Ada | 3,814 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . E X C E P T I O N S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2011, Free Software Foundation, Inc. --
-- Copyright (C) 2012, Rolf Ebert --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
-- This version of Ada.Exceptions is a simplified version for use in
-- AVR-Ada. It supports simplified exception handling without
-- exception propagation, i.e. restriction No_Exception_Propagation
-- is set.
--
-- You also have to define __gnat_last_chance_handler somewhere in
-- your code as the typical binder generated last-chance-handler is
-- stripped in AVR-Ada.
with System;
package Ada.Exceptions is
pragma Preelaborate;
type Exception_Id is private;
pragma Preelaborable_Initialization (Exception_Id);
Null_Id : constant Exception_Id;
procedure Raise_Exception (E : Exception_Id; Message : String := "");
pragma No_Return (Raise_Exception);
-- will always call __gnat_last_chance_handler. The Message
-- string should be null terminated for easier debugging.
private
------------------
-- Exception_Id --
------------------
type Exception_Id is access all System.Address;
Null_Id : constant Exception_Id := null;
pragma Inline_Always (Raise_Exception);
end Ada.Exceptions;
|
VitalijBondarenko/adanls | Ada | 4,894 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (c) 2014-2022 Vitalii Bondarenko <[email protected]> --
-- --
------------------------------------------------------------------------------
-- --
-- The MIT License (MIT) --
-- --
-- Permission is hereby granted, free of charge, to any person obtaining a --
-- copy of this software and associated documentation files (the --
-- "Software"), to deal in the Software without restriction, including --
-- without limitation the rights to use, copy, modify, merge, publish, --
-- distribute, sublicense, and/or sell copies of the Software, and to --
-- permit persons to whom the Software is furnished to do so, subject to --
-- the following conditions: --
-- --
-- The above copyright notice and this permission notice shall be included --
-- in all copies or substantial portions of the Software. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS --
-- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF --
-- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. --
-- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY --
-- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, --
-- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE --
-- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. --
------------------------------------------------------------------------------
-- The functions to access the information for the locale.
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
package body L10n.Localeinfo is
function From_Chars_Ptr (C : chars_ptr) return Unbounded_String;
function Print_Grouping (Grouping : chars_ptr) return Unbounded_String;
--------------------
-- From_Chars_Ptr --
--------------------
function From_Chars_Ptr (C : chars_ptr) return Unbounded_String is
begin
if C = Null_Ptr then
return Null_Unbounded_String;
else
return To_Unbounded_String (Value (C));
end if;
end From_Chars_Ptr;
--------------------
-- Print_Grouping --
--------------------
function Print_Grouping (Grouping : chars_ptr) return Unbounded_String is
S : String := Value (Grouping);
U : Unbounded_String := Null_Unbounded_String;
P : Integer;
begin
for I in S'Range loop
P := Character'Pos (S (I));
U := U & Trim (P'Img, Both);
end loop;
return U;
end Print_Grouping;
----------------
-- Localeconv --
----------------
function Localeconv return Lconv_Access is
C_L : C_Lconv_Access := C_Localeconv;
L : Lconv_Access := new Lconv_Record;
begin
L.Decimal_Point := From_Chars_Ptr (C_L.Decimal_Point);
L.Thousands_Sep := From_Chars_Ptr (C_L.Thousands_Sep);
L.Grouping := Print_Grouping (C_L.Grouping);
L.Int_Curr_Symbol := From_Chars_Ptr (C_L.Int_Curr_Symbol);
L.Currency_Symbol := From_Chars_Ptr (C_L.Currency_Symbol);
L.Mon_Decimal_Point := From_Chars_Ptr (C_L.Mon_Decimal_Point);
L.Mon_Thousands_Sep := From_Chars_Ptr (C_L.Mon_Thousands_Sep);
L.Mon_Grouping := Print_Grouping (C_L.Mon_Grouping);
L.Positive_Sign := From_Chars_Ptr (C_L.Positive_Sign);
L.Negative_Sign := From_Chars_Ptr (C_L.Negative_Sign);
L.Int_Frac_Digits := Natural (C_L.Int_Frac_Digits);
L.Frac_Digits := Natural (C_L.Frac_Digits);
L.P_Cs_Precedes := Natural (C_L.P_Cs_Precedes);
L.P_Sep_By_Space := Natural (C_L.P_Sep_By_Space);
L.N_Cs_Precedes := Natural (C_L.N_Cs_Precedes);
L.N_Sep_By_Space := Natural (C_L.N_Sep_By_Space);
L.P_Sign_Posn := Natural (C_L.P_Sign_Posn);
L.N_Sign_Posn := Natural (C_L.N_Sign_Posn);
L.Int_P_Cs_Precedes := Natural (C_L.Int_P_Cs_Precedes);
L.Int_P_Sep_By_Space := Natural (C_L.Int_P_Sep_By_Space);
L.Int_N_Cs_Precedes := Natural (C_L.Int_N_Cs_Precedes);
L.Int_N_Sep_By_Space := Natural (C_L.Int_N_Sep_By_Space);
L.Int_P_Sign_Posn := Natural (C_L.Int_P_Sign_Posn);
L.Int_N_Sign_Posn := Natural (C_L.Int_N_Sign_Posn);
return L;
end Localeconv;
end L10n.Localeinfo;
|
reznikmm/matreshka | Ada | 3,719 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Db_Max_Row_Count_Attributes is
pragma Preelaborate;
type ODF_Db_Max_Row_Count_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Db_Max_Row_Count_Attribute_Access is
access all ODF_Db_Max_Row_Count_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Db_Max_Row_Count_Attributes;
|
AdaCore/libadalang | Ada | 442 | ads | package State_Xrefs
with Abstract_State => State,
Initializes => State
is
procedure Proc (Param_1 : Integer; Param_2 : out Integer)
with Global => (In_Out => State),
Depends => ((Param_2, State) => (Param_1, State));
private
package Nested_Private
with Abstract_State => (Nested_State with Part_Of => State)
is
Var : Integer := 1234;
end Nested_Private;
end State_Xrefs;
pragma Test_Block;
|
AdaCore/ada-traits-containers | Ada | 5,126 | ads | --
-- Copyright (C) 2015-2016, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
pragma Ada_2012;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Report; use Report;
with System;
package Perf_Support is
--------------------
-- Unary functors --
--------------------
-- These packages provide objects that act like functions, except it is
-- possible to store data in them. They can thus be used to write
-- accumulators, or to curry binary functions into unary functions.
generic
type Param is private;
type Ret is private;
package Unary_Functors is
-- Define the types so that we can access the generic formals from an
-- instance of this package.
subtype Param_Type is Param;
subtype Returned_Type is Ret;
type Obj is interface;
function Call (Self : Obj; P : Param) return Ret is abstract;
end Unary_Functors;
generic
with package F is new Unary_Functors (others => <>);
with function Call (P : F.Param_Type) return F.Returned_Type;
package Unary_Functions is
package Functors renames F;
type Obj is new F.Obj with null record;
overriding function Call
(Self : Obj; P : F.Param_Type) return F.Returned_Type
is (Call (P));
Make : constant Obj := (null record);
end Unary_Functions;
--------------------
-- Using generics --
--------------------
generic
type Param1 is private;
type Param2 is private;
type Ret is private;
with function Call (P : Param1; Q : Param2) return Ret;
package Binary_Functions is
-- Define the types so that we can access the generic formals from an
-- instance of this package.
subtype Param1_Type is Param1;
subtype Param2_Type is Param2;
subtype Returned_Type is Ret;
end Binary_Functions;
generic
type Param1 is private;
type Param2 is private;
B : Param2;
type Ret is private;
with function Call (P : Param1; Q : Param2) return Ret;
package Binder2nd is
-- Define the types so that we can access the generic formals from an
-- instance of this package.
subtype Param1_Type is Param1;
subtype Param2_Type is Param2;
subtype Returned_Type is Ret;
function Binder_Call (P : Param1_Type) return Returned_Type
is (Call (P, B));
-- package Funcs is new Unary_Functors
-- (Param => Param1_Type,
-- Ret => Returned_Type,
-- Call => Binder_Call);
end Binder2nd;
-- ??? Not the same as in C++ STL: since we do not have a class, there is
-- no constructor to pass the value of the constant, which is therefore
-- part of the generic formals, so we need a different instantiation for
-- every possible value we might want for B.
-----------
-- Tests --
-----------
Items_Count : constant := 200_000; -- untyped, for standard containers
Integer_Items_Count : constant Integer := Items_Count;
pragma Export (C, Integer_Items_Count, "items_count");
-- For some reason, using 600_000 results in a storage error when
-- allocating the bounded limited containers (but not the Ada arrays)
Repeat_Count : constant Natural := 5;
pragma Export (C, Repeat_Count, "repeat_count");
-- Number of times that tests should be repeated
function Predicate (P : Integer) return Boolean is (P <= 2)
with Inline;
function Predicate (P : String) return Boolean is (P (P'First) = 'f')
with Inline;
function Predicate (P : Unbounded_String) return Boolean is
(Element (P, 1) = 'f')
with Inline;
procedure Assert (Count, Expected : Natural; Reason : String := "")
with Inline;
function Image (P : Integer) return String with Inline;
procedure Test_Cpp_Int_List (Stdout : System.Address)
with Import, Convention => C, External_Name => "test_cpp_int_list";
procedure Test_Cpp_Str_List (Stdout : System.Address)
with Import, Convention => C, External_Name => "test_cpp_str_list";
procedure Test_Cpp_Int_Vector (Stdout : System.Address)
with Import, Convention => C, External_Name => "test_cpp_int_vector";
procedure Test_Cpp_Str_Vector (Stdout : System.Address)
with Import, Convention => C, External_Name => "test_cpp_str_vector";
procedure Test_Cpp_Str_Str_Map (Stdout : System.Address)
with Import, Convention => C, External_Name => "test_cpp_str_str_map";
procedure Test_Cpp_Str_Str_Unordered_Map (Stdout : System.Address)
with Import, Convention => C,
External_Name => "test_cpp_str_str_unordered_map";
procedure Test_Cpp_Int_Int_Map (Stdout : System.Address)
with Import, Convention => C, External_Name => "test_cpp_int_int_map";
procedure Test_Cpp_Int_Int_Unordered_Map (Stdout : System.Address)
with Import, Convention => C,
External_Name => "test_cpp_int_int_unordered_map";
-- Perform C++ testing
procedure Test_Arrays_Int (Stdout : not null access Output'Class);
-- Test standard Ada arrays
end Perf_Support;
|
zhmu/ananas | Ada | 13,951 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- O P T --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
package body Opt is
-------------------------
-- Back_End_Exceptions --
-------------------------
function Back_End_Exceptions return Boolean is
begin
return
Exception_Mechanism = Back_End_SJLJ
or else
Exception_Mechanism = Back_End_ZCX;
end Back_End_Exceptions;
-------------------------
-- Front_End_Exceptions --
-------------------------
function Front_End_Exceptions return Boolean is
begin
return Exception_Mechanism = Front_End_SJLJ;
end Front_End_Exceptions;
--------------------
-- SJLJ_Exceptions --
--------------------
function SJLJ_Exceptions return Boolean is
begin
return
Exception_Mechanism = Back_End_SJLJ
or else
Exception_Mechanism = Front_End_SJLJ;
end SJLJ_Exceptions;
--------------------
-- ZCX_Exceptions --
--------------------
function ZCX_Exceptions return Boolean is
begin
return Exception_Mechanism = Back_End_ZCX;
end ZCX_Exceptions;
------------------------------
-- Register_Config_Switches --
------------------------------
procedure Register_Config_Switches is
begin
Ada_Version_Config := Ada_Version;
Ada_Version_Pragma_Config := Ada_Version_Pragma;
Ada_Version_Explicit_Config := Ada_Version_Explicit;
Assertions_Enabled_Config := Assertions_Enabled;
Assume_No_Invalid_Values_Config := Assume_No_Invalid_Values;
Check_Float_Overflow_Config := Check_Float_Overflow;
Check_Policy_List_Config := Check_Policy_List;
Default_Pool_Config := Default_Pool;
Default_SSO_Config := Default_SSO;
Dynamic_Elaboration_Checks_Config := Dynamic_Elaboration_Checks;
Exception_Locations_Suppressed_Config := Exception_Locations_Suppressed;
External_Name_Exp_Casing_Config := External_Name_Exp_Casing;
External_Name_Imp_Casing_Config := External_Name_Imp_Casing;
Fast_Math_Config := Fast_Math;
Initialize_Scalars_Config := Initialize_Scalars;
No_Component_Reordering_Config := No_Component_Reordering;
Optimize_Alignment_Config := Optimize_Alignment;
Persistent_BSS_Mode_Config := Persistent_BSS_Mode;
Prefix_Exception_Messages_Config := Prefix_Exception_Messages;
SPARK_Mode_Config := SPARK_Mode;
SPARK_Mode_Pragma_Config := SPARK_Mode_Pragma;
Uneval_Old_Config := Uneval_Old;
Use_VADS_Size_Config := Use_VADS_Size;
Warnings_As_Errors_Count_Config := Warnings_As_Errors_Count;
-- Reset the indication that Optimize_Alignment was set locally, since
-- if we had a pragma in the config file, it would set this flag True,
-- but that's not a local setting.
Optimize_Alignment_Local := False;
end Register_Config_Switches;
-----------------------------
-- Restore_Config_Switches --
-----------------------------
procedure Restore_Config_Switches (Save : Config_Switches_Type) is
begin
Ada_Version := Save.Ada_Version;
Ada_Version_Pragma := Save.Ada_Version_Pragma;
Ada_Version_Explicit := Save.Ada_Version_Explicit;
Assertions_Enabled := Save.Assertions_Enabled;
Assume_No_Invalid_Values := Save.Assume_No_Invalid_Values;
Check_Float_Overflow := Save.Check_Float_Overflow;
Check_Policy_List := Save.Check_Policy_List;
Default_Pool := Save.Default_Pool;
Default_SSO := Save.Default_SSO;
Dynamic_Elaboration_Checks := Save.Dynamic_Elaboration_Checks;
Exception_Locations_Suppressed := Save.Exception_Locations_Suppressed;
External_Name_Exp_Casing := Save.External_Name_Exp_Casing;
External_Name_Imp_Casing := Save.External_Name_Imp_Casing;
Fast_Math := Save.Fast_Math;
Initialize_Scalars := Save.Initialize_Scalars;
No_Component_Reordering := Save.No_Component_Reordering;
Optimize_Alignment := Save.Optimize_Alignment;
Optimize_Alignment_Local := Save.Optimize_Alignment_Local;
Persistent_BSS_Mode := Save.Persistent_BSS_Mode;
Prefix_Exception_Messages := Save.Prefix_Exception_Messages;
SPARK_Mode := Save.SPARK_Mode;
SPARK_Mode_Pragma := Save.SPARK_Mode_Pragma;
Uneval_Old := Save.Uneval_Old;
Use_VADS_Size := Save.Use_VADS_Size;
Warnings_As_Errors_Count := Save.Warnings_As_Errors_Count;
-- Update consistently the value of Init_Or_Norm_Scalars. The value of
-- Normalize_Scalars is not saved/restored because after set to True its
-- value is never changed. That is, if a compilation unit has pragma
-- Normalize_Scalars then it forces that value for all with'ed units.
Init_Or_Norm_Scalars := Initialize_Scalars or Normalize_Scalars;
end Restore_Config_Switches;
--------------------------
-- Save_Config_Switches --
--------------------------
function Save_Config_Switches return Config_Switches_Type is
begin
return
(Ada_Version => Ada_Version,
Ada_Version_Pragma => Ada_Version_Pragma,
Ada_Version_Explicit => Ada_Version_Explicit,
Assertions_Enabled => Assertions_Enabled,
Assume_No_Invalid_Values => Assume_No_Invalid_Values,
Check_Float_Overflow => Check_Float_Overflow,
Check_Policy_List => Check_Policy_List,
Default_Pool => Default_Pool,
Default_SSO => Default_SSO,
Dynamic_Elaboration_Checks => Dynamic_Elaboration_Checks,
Exception_Locations_Suppressed => Exception_Locations_Suppressed,
External_Name_Exp_Casing => External_Name_Exp_Casing,
External_Name_Imp_Casing => External_Name_Imp_Casing,
Fast_Math => Fast_Math,
Initialize_Scalars => Initialize_Scalars,
No_Component_Reordering => No_Component_Reordering,
Normalize_Scalars => Normalize_Scalars,
Optimize_Alignment => Optimize_Alignment,
Optimize_Alignment_Local => Optimize_Alignment_Local,
Persistent_BSS_Mode => Persistent_BSS_Mode,
Prefix_Exception_Messages => Prefix_Exception_Messages,
SPARK_Mode => SPARK_Mode,
SPARK_Mode_Pragma => SPARK_Mode_Pragma,
Uneval_Old => Uneval_Old,
Use_VADS_Size => Use_VADS_Size,
Warnings_As_Errors_Count => Warnings_As_Errors_Count);
end Save_Config_Switches;
-------------------------
-- Set_Config_Switches --
-------------------------
procedure Set_Config_Switches
(Internal_Unit : Boolean;
Main_Unit : Boolean)
is
begin
-- Case of internal unit
if Internal_Unit then
-- Set standard switches. Note we do NOT set Ada_Version_Explicit
-- since the whole point of this is that it still properly indicates
-- the configuration setting even in a run time unit.
Ada_Version := Ada_Version_Runtime;
Ada_Version_Pragma := Empty;
Default_SSO := ' ';
Dynamic_Elaboration_Checks := False;
External_Name_Exp_Casing := As_Is;
External_Name_Imp_Casing := Lowercase;
No_Component_Reordering := False;
Optimize_Alignment := 'O';
Optimize_Alignment_Local := True;
Persistent_BSS_Mode := False;
Prefix_Exception_Messages := True;
Uneval_Old := 'E';
Use_VADS_Size := False;
-- Note: we do not need to worry about Warnings_As_Errors_Count since
-- we do not expect to get any warnings from compiling such a unit.
-- For an internal unit, assertions/debug pragmas are off unless this
-- is the main unit and they were explicitly enabled, or unless the
-- main unit was compiled in GNAT mode. We also make sure we do not
-- assume that values are necessarily valid and that SPARK_Mode is
-- set to its configuration value.
if Main_Unit then
Assertions_Enabled := Assertions_Enabled_Config;
Assume_No_Invalid_Values := Assume_No_Invalid_Values_Config;
Check_Policy_List := Check_Policy_List_Config;
SPARK_Mode := SPARK_Mode_Config;
SPARK_Mode_Pragma := SPARK_Mode_Pragma_Config;
else
-- In GNATprove mode assertions should be always enabled, even
-- when analysing internal units.
if GNATprove_Mode then
pragma Assert (Assertions_Enabled);
null;
elsif GNAT_Mode_Config then
Assertions_Enabled := Assertions_Enabled_Config;
else
Assertions_Enabled := False;
end if;
Assume_No_Invalid_Values := False;
Check_Policy_List := Empty;
SPARK_Mode := None;
SPARK_Mode_Pragma := Empty;
end if;
-- Case of non-internal unit
else
Ada_Version := Ada_Version_Config;
Ada_Version_Pragma := Ada_Version_Pragma_Config;
Ada_Version_Explicit := Ada_Version_Explicit_Config;
Assertions_Enabled := Assertions_Enabled_Config;
Assume_No_Invalid_Values := Assume_No_Invalid_Values_Config;
Check_Float_Overflow := Check_Float_Overflow_Config;
Check_Policy_List := Check_Policy_List_Config;
Default_SSO := Default_SSO_Config;
Dynamic_Elaboration_Checks := Dynamic_Elaboration_Checks_Config;
External_Name_Exp_Casing := External_Name_Exp_Casing_Config;
External_Name_Imp_Casing := External_Name_Imp_Casing_Config;
Fast_Math := Fast_Math_Config;
Initialize_Scalars := Initialize_Scalars_Config;
No_Component_Reordering := No_Component_Reordering_Config;
Optimize_Alignment := Optimize_Alignment_Config;
Optimize_Alignment_Local := False;
Persistent_BSS_Mode := Persistent_BSS_Mode_Config;
Prefix_Exception_Messages := Prefix_Exception_Messages_Config;
SPARK_Mode := SPARK_Mode_Config;
SPARK_Mode_Pragma := SPARK_Mode_Pragma_Config;
Uneval_Old := Uneval_Old_Config;
Use_VADS_Size := Use_VADS_Size_Config;
Warnings_As_Errors_Count := Warnings_As_Errors_Count_Config;
-- Update consistently the value of Init_Or_Norm_Scalars. The value
-- of Normalize_Scalars is not saved/restored because once set to
-- True its value is never changed. That is, if a compilation unit
-- has pragma Normalize_Scalars then it forces that value for all
-- with'ed units.
Init_Or_Norm_Scalars := Initialize_Scalars or Normalize_Scalars;
end if;
-- Values set for all units
Default_Pool := Default_Pool_Config;
Exception_Locations_Suppressed := Exception_Locations_Suppressed_Config;
Fast_Math := Fast_Math_Config;
end Set_Config_Switches;
end Opt;
|
AdaCore/libadalang | Ada | 574 | adb | procedure Proc is
type Primary_Color is (Red, Green, Blue);
type PC1 is new Primary_Color;
type PC2 is new Primary_Color;
type PC3 is new Primary_Color;
for PC1 use (-3, 8, 456);
--% node.p_params
for PC2 use (Red => -3, Green => 8, Blue => 456);
--% node.p_params
for PC3 use (Green => 8, Red => -3, Blue => 456);
--% node.p_params
type My_Bool3 is new Boolean;
for My_Bool3 use (True => 2, False => 0);
--% node.p_params
type My_Bool4 is new My_Bool3;
for My_Bool4 use (0, 1);
--% node.p_params
begin
null;
end Proc;
|
DrenfongWong/tkm-rpc | Ada | 421 | ads | with Ada.Unchecked_Conversion;
package Tkmrpc.Request.Ike.Esa_Create_First.Convert is
function To_Request is new Ada.Unchecked_Conversion (
Source => Esa_Create_First.Request_Type,
Target => Request.Data_Type);
function From_Request is new Ada.Unchecked_Conversion (
Source => Request.Data_Type,
Target => Esa_Create_First.Request_Type);
end Tkmrpc.Request.Ike.Esa_Create_First.Convert;
|
stcarrez/ada-css | Ada | 1,324 | ads | -----------------------------------------------------------------------
-- css-core-compare -- Comparision on CSS rule references
-- Copyright (C) 2017 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with CSS.Core.Refs;
package CSS.Core.Compare is
function "=" (Left, Right : in CSS.Core.Refs.Ref) return Boolean;
-- Compare the two rules to order them. Rules are compared on their
-- source location. The comparison is intended to be used by the
-- <tt>CSS.Core.Sets</tt> package to allow the creation of sets that
-- contain unique rules.
function "<" (Left, Right : in CSS.Core.Refs.Ref) return Boolean;
end CSS.Core.Compare;
|
jwarwick/aoc_2020 | Ada | 3,832 | adb | -- AoC 2020, Day 17
with Ada.Text_IO;
package body Day is
package TIO renames Ada.Text_IO;
function location_hash(key : in Location) return Hash_Type is
begin
return Hash_Type(abs((key.x * 137) + (key.y * 149) + (key.z * 163) + (key.w * 13)));
end location_hash;
procedure parse_line(line : in String; y : in Natural; g : in out Grid_Set.Set) is
x : Natural := 0;
begin
for c of line loop
if c = '#' then
g.insert(Location'(X => x, Y => y, Z=> 0, W => 0));
end if;
x := x + 1;
end loop;
end parse_line;
function load_file(filename : in String) return Grid_Set.Set is
file : TIO.File_Type;
g : Grid_Set.Set := Empty_Set;
y : Natural := 0;
begin
TIO.open(File => file, Mode => TIO.In_File, Name => filename);
while not TIO.end_of_file(file) loop
parse_line(TIO.get_line(file), y, g);
y := y + 1;
end loop;
TIO.close(file);
return g;
end load_file;
pragma Warnings (Off);
procedure put_line(l : in Location) is
pragma Warnings (On);
begin
TIO.put_line(l.x'IMAGE & "," & l.y'IMAGE & "," & l.z'IMAGE & "," & l.w'IMAGE);
end put_line;
function neighbors(l : in Location) return Grid_Set.Set is
g : Grid_Set.Set := Empty_Set;
begin
for x in l.x-1 .. l.x+1 loop
for y in l.y-1 .. l.y+1 loop
for z in l.z-1 .. l.z+1 loop
g.include(Location'(X=>x, Y=>y, Z=>z, W=>0));
end loop;
end loop;
end loop;
g.exclude(l);
return g;
end neighbors;
function neighbors_4d(l : in Location) return Grid_Set.Set is
g : Grid_Set.Set := Empty_Set;
begin
for x in l.x-1 .. l.x+1 loop
for y in l.y-1 .. l.y+1 loop
for z in l.z-1 .. l.z+1 loop
for w in l.w-1 .. l.w+1 loop
g.include(Location'(X=>x, Y=>y, Z=>z, W=>w));
end loop;
end loop;
end loop;
end loop;
g.exclude(l);
return g;
end neighbors_4d;
function active(to_check : in Grid_Set.Set; active : in Grid_Set.Set) return Natural is
cnt : Natural := 0;
begin
for l of to_check loop
if active.contains(l) then
cnt := cnt + 1;
end if;
end loop;
return cnt;
end active;
procedure step(g : in out Grid_Set.Set; fourd : in Boolean) is
old_grid : constant Grid_Set.Set := g;
new_grid : Grid_Set.Set := Empty_Set;
all_possible : Grid_Set.Set := Empty_Set;
begin
for p of old_grid loop
all_possible.include(p);
if fourd then
all_possible := all_possible or neighbors_4d(p);
else
all_possible := all_possible or neighbors(p);
end if;
end loop;
for p of all_possible loop
declare
neighs : Grid_Set.Set := Empty_Set;
active_neigh : Natural := 0;
was_active : constant Boolean := old_grid.contains(p);
begin
if fourd then
neighs := neighbors_4d(p);
else
neighs := neighbors(p);
end if;
active_neigh := active(neighs, old_grid);
if was_active then
if active_neigh = 2 or active_neigh = 3 then
new_grid.include(p);
end if;
else
if active_neigh = 3 then
new_grid.include(p);
end if;
end if;
end;
end loop;
g := new_grid;
end step;
function active_count(g : in Grid_Set.Set; cycles : in Natural) return Natural is
grid : Grid_Set.Set := g;
begin
for i in 1..cycles loop
step(grid, false);
end loop;
return Natural(grid.length);
end active_count;
function active_count_4d(g : in Grid_Set.Set; cycles : in Natural) return Natural is
grid : Grid_Set.Set := g;
begin
for i in 1..cycles loop
step(grid, true);
end loop;
return Natural(grid.length);
end active_count_4d;
end Day;
|
reznikmm/matreshka | Ada | 7,092 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2009-2011, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
package body League.Holders.Decimals.Generic_Decimals is
Max_Mantissa : constant Mantissa := Mantissa (10 ** Num'Digits);
function To_Num (Value : Universal_Decimal) return Num;
function To_Universal (Value : Num) return Universal_Decimal;
-----------------
-- Constructor --
-----------------
overriding function Constructor
(Is_Empty : not null access Boolean)
return Decimal_Container
is
pragma Assert (Is_Empty.all);
begin
return
(Counter => <>,
Is_Empty => Is_Empty.all,
Value => <>);
end Constructor;
-------------
-- Element --
-------------
function Element (Self : Holder) return Num is
begin
if Self.Data.all not in Abstract_Decimal_Container'Class then
raise Constraint_Error with "invalid type of value";
end if;
if Self.Data.Is_Empty then
raise Constraint_Error with "value is empty";
end if;
if Self.Data.all in Decimal_Container'Class then
return Decimal_Container'Class (Self.Data.all).Value;
else
return To_Num (Abstract_Decimal_Container'Class (Self.Data.all).Get);
end if;
end Element;
---------
-- Get --
---------
overriding function Get
(Self : not null access constant Decimal_Container)
return Universal_Decimal is
begin
return To_Universal (Self.Value);
end Get;
---------------------
-- Replace_Element --
---------------------
procedure Replace_Element (Self : in out Holder; To : Num) is
begin
if Self.Data.all not in Decimal_Container
and Self.Data.all not in Universal_Decimal_Container
then
raise Constraint_Error with "invalid type of value";
end if;
-- XXX This subprogram can be improved to reuse shared segment when
-- possible.
if Self.Data.all in Universal_Decimal_Container then
Dereference (Self.Data);
Self.Data :=
new Universal_Decimal_Container'
(Counter => <>,
Is_Empty => False,
Value => To_Universal (To));
else
Dereference (Self.Data);
Self.Data :=
new Decimal_Container'
(Counter => <>, Is_Empty => False, Value => To);
end if;
end Replace_Element;
---------
-- Set --
---------
overriding procedure Set
(Self : not null access Decimal_Container;
To : Universal_Decimal)
is
begin
Self.Is_Empty := False;
Self.Value := To_Num (To);
end Set;
---------------
-- To_Holder --
---------------
function To_Holder (Item : Num) return Holder is
begin
return
(Ada.Finalization.Controlled with
new Decimal_Container'
(Counter => <>, Is_Empty => False, Value => Item));
end To_Holder;
------------
-- To_Num --
------------
function To_Num (Value : Universal_Decimal) return Num is
begin
if abs Value.Value >= Max_Mantissa then
raise Constraint_Error with "lost precision";
end if;
if Value.Small >= 0 then
return Value.Value * Value.Small * Num'Small;
else
return Value.Value / abs Value.Small * Num'Small;
end if;
end To_Num;
------------------
-- To_Universal --
------------------
function To_Universal (Value : Num) return Universal_Decimal is
begin
if Num'Small > 0.0 then
return (Value => Value / Num'Small,
Small => Integer (Num'Small));
else
return (Value => Value * Num'Small,
Small => -Integer (10.0 / Num'Small));
end if;
end To_Universal;
end League.Holders.Decimals.Generic_Decimals;
|
onox/orka | Ada | 1,882 | ads | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2020 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Orka.SIMD.SSE2.Doubles;
with Orka.SIMD.AVX.Doubles;
package Orka.SIMD.FMA.Doubles.Arithmetic is
pragma Pure;
use SSE2.Doubles;
use AVX.Doubles;
function Multiply_Add (A, B, C : m128d) return m128d
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_vfmaddpd";
function Multiply_Add_Sub (A, B, C : m128d) return m128d
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_vfmaddsubpd";
function Multiply_Add (A, B, C : m256d) return m256d
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_vfmaddpd256";
function Multiply_Add_Sub (A, B, C : m256d) return m256d
with Import, Convention => Intrinsic, External_Name => "__builtin_ia32_vfmaddsubpd256";
function "*" (Left, Right : m256d_Array) return m256d_Array
with Inline_Always;
-- Multiplies the left matrix with the right matrix. Matrix multiplication
-- is associative, but not commutative.
function "*" (Left : m256d_Array; Right : m256d) return m256d
with Inline_Always;
-- Multiplies the left matrix with the right vector. Matrix multiplication
-- is associative, but not commutative.
end Orka.SIMD.FMA.Doubles.Arithmetic;
|
rui314/mold | Ada | 13,595 | ads | ------------------------------------------------------------------------------
-- ZLib for Ada thick binding. --
-- --
-- Copyright (C) 2002-2004 Dmitriy Anisimkov --
-- --
-- This library is free software; you can redistribute it and/or modify --
-- it under the terms of the GNU General Public License as published by --
-- the Free Software Foundation; either version 2 of the License, or (at --
-- your option) any later version. --
-- --
-- This library is distributed in the hope that it will be useful, but --
-- WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. --
-- --
-- You should have received a copy of the GNU General Public License --
-- along with this library; if not, write to the Free Software Foundation, --
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
------------------------------------------------------------------------------
-- $Id: zlib.ads,v 1.26 2004/09/06 06:53:19 vagul Exp $
with Ada.Streams;
with Interfaces;
package ZLib is
ZLib_Error : exception;
Status_Error : exception;
type Compression_Level is new Integer range -1 .. 9;
type Flush_Mode is private;
type Compression_Method is private;
type Window_Bits_Type is new Integer range 8 .. 15;
type Memory_Level_Type is new Integer range 1 .. 9;
type Unsigned_32 is new Interfaces.Unsigned_32;
type Strategy_Type is private;
type Header_Type is (None, Auto, Default, GZip);
-- Header type usage have a some limitation for inflate.
-- See comment for Inflate_Init.
subtype Count is Ada.Streams.Stream_Element_Count;
Default_Memory_Level : constant Memory_Level_Type := 8;
Default_Window_Bits : constant Window_Bits_Type := 15;
----------------------------------
-- Compression method constants --
----------------------------------
Deflated : constant Compression_Method;
-- Only one method allowed in this ZLib version
---------------------------------
-- Compression level constants --
---------------------------------
No_Compression : constant Compression_Level := 0;
Best_Speed : constant Compression_Level := 1;
Best_Compression : constant Compression_Level := 9;
Default_Compression : constant Compression_Level := -1;
--------------------------
-- Flush mode constants --
--------------------------
No_Flush : constant Flush_Mode;
-- Regular way for compression, no flush
Partial_Flush : constant Flush_Mode;
-- Will be removed, use Z_SYNC_FLUSH instead
Sync_Flush : constant Flush_Mode;
-- All pending output is flushed to the output buffer and the output
-- is aligned on a byte boundary, so that the decompressor can get all
-- input data available so far. (In particular avail_in is zero after the
-- call if enough output space has been provided before the call.)
-- Flushing may degrade compression for some compression algorithms and so
-- it should be used only when necessary.
Block_Flush : constant Flush_Mode;
-- Z_BLOCK requests that inflate() stop
-- if and when it get to the next deflate block boundary. When decoding the
-- zlib or gzip format, this will cause inflate() to return immediately
-- after the header and before the first block. When doing a raw inflate,
-- inflate() will go ahead and process the first block, and will return
-- when it gets to the end of that block, or when it runs out of data.
Full_Flush : constant Flush_Mode;
-- All output is flushed as with SYNC_FLUSH, and the compression state
-- is reset so that decompression can restart from this point if previous
-- compressed data has been damaged or if random access is desired. Using
-- Full_Flush too often can seriously degrade the compression.
Finish : constant Flush_Mode;
-- Just for tell the compressor that input data is complete.
------------------------------------
-- Compression strategy constants --
------------------------------------
-- RLE strategy could be used only in version 1.2.0 and later.
Filtered : constant Strategy_Type;
Huffman_Only : constant Strategy_Type;
RLE : constant Strategy_Type;
Default_Strategy : constant Strategy_Type;
Default_Buffer_Size : constant := 4096;
type Filter_Type is tagged limited private;
-- The filter is for compression and for decompression.
-- The usage of the type is depend of its initialization.
function Version return String;
pragma Inline (Version);
-- Return string representation of the ZLib version.
procedure Deflate_Init
(Filter : in out Filter_Type;
Level : in Compression_Level := Default_Compression;
Strategy : in Strategy_Type := Default_Strategy;
Method : in Compression_Method := Deflated;
Window_Bits : in Window_Bits_Type := Default_Window_Bits;
Memory_Level : in Memory_Level_Type := Default_Memory_Level;
Header : in Header_Type := Default);
-- Compressor initialization.
-- When Header parameter is Auto or Default, then default zlib header
-- would be provided for compressed data.
-- When Header is GZip, then gzip header would be set instead of
-- default header.
-- When Header is None, no header would be set for compressed data.
procedure Inflate_Init
(Filter : in out Filter_Type;
Window_Bits : in Window_Bits_Type := Default_Window_Bits;
Header : in Header_Type := Default);
-- Decompressor initialization.
-- Default header type mean that ZLib default header is expecting in the
-- input compressed stream.
-- Header type None mean that no header is expecting in the input stream.
-- GZip header type mean that GZip header is expecting in the
-- input compressed stream.
-- Auto header type mean that header type (GZip or Native) would be
-- detected automatically in the input stream.
-- Note that header types parameter values None, GZip and Auto are
-- supported for inflate routine only in ZLib versions 1.2.0.2 and later.
-- Deflate_Init is supporting all header types.
function Is_Open (Filter : in Filter_Type) return Boolean;
pragma Inline (Is_Open);
-- Is the filter opened for compression or decompression.
procedure Close
(Filter : in out Filter_Type;
Ignore_Error : in Boolean := False);
-- Closing the compression or decompressor.
-- If stream is closing before the complete and Ignore_Error is False,
-- The exception would be raised.
generic
with procedure Data_In
(Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
with procedure Data_Out
(Item : in Ada.Streams.Stream_Element_Array);
procedure Generic_Translate
(Filter : in out Filter_Type;
In_Buffer_Size : in Integer := Default_Buffer_Size;
Out_Buffer_Size : in Integer := Default_Buffer_Size);
-- Compress/decompress data fetch from Data_In routine and pass the result
-- to the Data_Out routine. User should provide Data_In and Data_Out
-- for compression/decompression data flow.
-- Compression or decompression depend on Filter initialization.
function Total_In (Filter : in Filter_Type) return Count;
pragma Inline (Total_In);
-- Returns total number of input bytes read so far
function Total_Out (Filter : in Filter_Type) return Count;
pragma Inline (Total_Out);
-- Returns total number of bytes output so far
function CRC32
(CRC : in Unsigned_32;
Data : in Ada.Streams.Stream_Element_Array)
return Unsigned_32;
pragma Inline (CRC32);
-- Compute CRC32, it could be necessary for make gzip format
procedure CRC32
(CRC : in out Unsigned_32;
Data : in Ada.Streams.Stream_Element_Array);
pragma Inline (CRC32);
-- Compute CRC32, it could be necessary for make gzip format
-------------------------------------------------
-- Below is more complex low level routines. --
-------------------------------------------------
procedure Translate
(Filter : in out Filter_Type;
In_Data : in Ada.Streams.Stream_Element_Array;
In_Last : out Ada.Streams.Stream_Element_Offset;
Out_Data : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode);
-- Compress/decompress the In_Data buffer and place the result into
-- Out_Data. In_Last is the index of last element from In_Data accepted by
-- the Filter. Out_Last is the last element of the received data from
-- Filter. To tell the filter that incoming data are complete put the
-- Flush parameter to Finish.
function Stream_End (Filter : in Filter_Type) return Boolean;
pragma Inline (Stream_End);
-- Return the true when the stream is complete.
procedure Flush
(Filter : in out Filter_Type;
Out_Data : out Ada.Streams.Stream_Element_Array;
Out_Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode);
pragma Inline (Flush);
-- Flushing the data from the compressor.
generic
with procedure Write
(Item : in Ada.Streams.Stream_Element_Array);
-- User should provide this routine for accept
-- compressed/decompressed data.
Buffer_Size : in Ada.Streams.Stream_Element_Offset
:= Default_Buffer_Size;
-- Buffer size for Write user routine.
procedure Write
(Filter : in out Filter_Type;
Item : in Ada.Streams.Stream_Element_Array;
Flush : in Flush_Mode := No_Flush);
-- Compress/Decompress data from Item to the generic parameter procedure
-- Write. Output buffer size could be set in Buffer_Size generic parameter.
generic
with procedure Read
(Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset);
-- User should provide data for compression/decompression
-- thru this routine.
Buffer : in out Ada.Streams.Stream_Element_Array;
-- Buffer for keep remaining data from the previous
-- back read.
Rest_First, Rest_Last : in out Ada.Streams.Stream_Element_Offset;
-- Rest_First have to be initialized to Buffer'Last + 1
-- Rest_Last have to be initialized to Buffer'Last
-- before usage.
Allow_Read_Some : in Boolean := False;
-- Is it allowed to return Last < Item'Last before end of data.
procedure Read
(Filter : in out Filter_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Flush : in Flush_Mode := No_Flush);
-- Compress/Decompress data from generic parameter procedure Read to the
-- Item. User should provide Buffer and initialized Rest_First, Rest_Last
-- indicators. If Allow_Read_Some is True, Read routines could return
-- Last < Item'Last only at end of stream.
private
use Ada.Streams;
pragma Assert (Ada.Streams.Stream_Element'Size = 8);
pragma Assert (Ada.Streams.Stream_Element'Modulus = 2**8);
type Flush_Mode is new Integer range 0 .. 5;
type Compression_Method is new Integer range 8 .. 8;
type Strategy_Type is new Integer range 0 .. 3;
No_Flush : constant Flush_Mode := 0;
Partial_Flush : constant Flush_Mode := 1;
Sync_Flush : constant Flush_Mode := 2;
Full_Flush : constant Flush_Mode := 3;
Finish : constant Flush_Mode := 4;
Block_Flush : constant Flush_Mode := 5;
Filtered : constant Strategy_Type := 1;
Huffman_Only : constant Strategy_Type := 2;
RLE : constant Strategy_Type := 3;
Default_Strategy : constant Strategy_Type := 0;
Deflated : constant Compression_Method := 8;
type Z_Stream;
type Z_Stream_Access is access all Z_Stream;
type Filter_Type is tagged limited record
Strm : Z_Stream_Access;
Compression : Boolean;
Stream_End : Boolean;
Header : Header_Type;
CRC : Unsigned_32;
Offset : Stream_Element_Offset;
-- Offset for gzip header/footer output.
end record;
end ZLib;
|
reznikmm/matreshka | Ada | 4,816 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Visitors;
with ODF.DOM.Text_Notes_Configuration_Elements;
package Matreshka.ODF_Text.Notes_Configuration_Elements is
type Text_Notes_Configuration_Element_Node is
new Matreshka.ODF_Text.Abstract_Text_Element_Node
and ODF.DOM.Text_Notes_Configuration_Elements.ODF_Text_Notes_Configuration
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Text_Notes_Configuration_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Text_Notes_Configuration_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Text_Notes_Configuration_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Text_Notes_Configuration_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Text_Notes_Configuration_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Text.Notes_Configuration_Elements;
|
zhmu/ananas | Ada | 40,199 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . G E N E R I C _ B I G N U M S --
-- --
-- B o d y --
-- --
-- Copyright (C) 2012-2022, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- 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 provides arbitrary precision signed integer arithmetic.
package body System.Generic_Bignums is
use Interfaces;
-- So that operations on Unsigned_32/Unsigned_64 are available
use Shared_Bignums;
type DD is mod Base ** 2;
-- Double length digit used for intermediate computations
function MSD (X : DD) return SD is (SD (X / Base));
function LSD (X : DD) return SD is (SD (X mod Base));
-- Most significant and least significant digit of double digit value
function "&" (X, Y : SD) return DD is (DD (X) * Base + DD (Y));
-- Compose double digit value from two single digit values
subtype LLI is Long_Long_Integer;
One_Data : constant Digit_Vector (1 .. 1) := [1];
-- Constant one
Zero_Data : constant Digit_Vector (1 .. 0) := [];
-- Constant zero
-----------------------
-- Local Subprograms --
-----------------------
function Add
(X, Y : Digit_Vector;
X_Neg : Boolean;
Y_Neg : Boolean) return Big_Integer
with
Pre => X'First = 1 and then Y'First = 1;
-- This procedure adds two signed numbers returning the Sum, it is used
-- for both addition and subtraction. The value computed is X + Y, with
-- X_Neg and Y_Neg giving the signs of the operands.
type Compare_Result is (LT, EQ, GT);
-- Indicates result of comparison in following call
function Compare
(X, Y : Digit_Vector;
X_Neg, Y_Neg : Boolean) return Compare_Result
with
Pre => X'First = 1 and then Y'First = 1;
-- Compare (X with sign X_Neg) with (Y with sign Y_Neg), and return the
-- result of the signed comparison.
procedure Div_Rem
(X, Y : Bignum;
Quotient : out Big_Integer;
Remainder : out Big_Integer;
Discard_Quotient : Boolean := False;
Discard_Remainder : Boolean := False);
-- Returns the Quotient and Remainder from dividing abs (X) by abs (Y). The
-- values of X and Y are not modified. If Discard_Quotient is True, then
-- Quotient is undefined on return, and if Discard_Remainder is True, then
-- Remainder is undefined on return. Service routine for Big_Div/Rem/Mod.
function Normalize
(X : Digit_Vector;
Neg : Boolean := False) return Big_Integer;
-- Given a digit vector and sign, allocate and construct a big integer
-- value. Note that X may have leading zeroes which must be removed, and if
-- the result is zero, the sign is forced positive.
-- If X is too big, Storage_Error is raised.
function "**" (X : Bignum; Y : SD) return Big_Integer;
-- Exponentiation routine where we know right operand is one word
---------
-- Add --
---------
function Add
(X, Y : Digit_Vector;
X_Neg : Boolean;
Y_Neg : Boolean) return Big_Integer
is
begin
-- If signs are the same, we are doing an addition, it is convenient to
-- ensure that the first operand is the longer of the two.
if X_Neg = Y_Neg then
if X'Last < Y'Last then
return Add (X => Y, Y => X, X_Neg => Y_Neg, Y_Neg => X_Neg);
-- Here signs are the same, and the first operand is the longer
else
pragma Assert (X_Neg = Y_Neg and then X'Last >= Y'Last);
-- Do addition, putting result in Sum (allowing for carry)
declare
Sum : Digit_Vector (0 .. X'Last);
RD : DD;
begin
RD := 0;
for J in reverse 1 .. X'Last loop
RD := RD + DD (X (J));
if J >= 1 + (X'Last - Y'Last) then
RD := RD + DD (Y (J - (X'Last - Y'Last)));
end if;
Sum (J) := LSD (RD);
RD := RD / Base;
end loop;
Sum (0) := SD (RD);
return Normalize (Sum, X_Neg);
end;
end if;
-- Signs are different so really this is a subtraction, we want to make
-- sure that the largest magnitude operand is the first one, and then
-- the result will have the sign of the first operand.
else
declare
CR : constant Compare_Result := Compare (X, Y, False, False);
begin
if CR = EQ then
return Normalize (Zero_Data);
elsif CR = LT then
return Add (X => Y, Y => X, X_Neg => Y_Neg, Y_Neg => X_Neg);
else
pragma Assert (X_Neg /= Y_Neg and then CR = GT);
-- Do subtraction, putting result in Diff
declare
Diff : Digit_Vector (1 .. X'Length);
RD : DD;
begin
RD := 0;
for J in reverse 1 .. X'Last loop
RD := RD + DD (X (J));
if J >= 1 + (X'Last - Y'Last) then
RD := RD - DD (Y (J - (X'Last - Y'Last)));
end if;
Diff (J) := LSD (RD);
RD := (if RD < Base then 0 else -1);
end loop;
return Normalize (Diff, X_Neg);
end;
end if;
end;
end if;
end Add;
-------------
-- Big_Abs --
-------------
function Big_Abs (X : Bignum) return Big_Integer is
begin
return Normalize (X.D);
end Big_Abs;
-------------
-- Big_Add --
-------------
function Big_Add (X, Y : Bignum) return Big_Integer is
begin
return Add (X.D, Y.D, X.Neg, Y.Neg);
end Big_Add;
-------------
-- Big_Div --
-------------
-- This table is excerpted from RM 4.5.5(28-30) and shows how the result
-- varies with the signs of the operands.
-- A B A/B A B A/B
--
-- 10 5 2 -10 5 -2
-- 11 5 2 -11 5 -2
-- 12 5 2 -12 5 -2
-- 13 5 2 -13 5 -2
-- 14 5 2 -14 5 -2
--
-- A B A/B A B A/B
--
-- 10 -5 -2 -10 -5 2
-- 11 -5 -2 -11 -5 2
-- 12 -5 -2 -12 -5 2
-- 13 -5 -2 -13 -5 2
-- 14 -5 -2 -14 -5 2
function Big_Div (X, Y : Bignum) return Big_Integer is
Q, R : aliased Big_Integer;
begin
Div_Rem (X, Y, Q, R, Discard_Remainder => True);
To_Bignum (Q).Neg := To_Bignum (Q).Len > 0 and then (X.Neg xor Y.Neg);
return Q;
end Big_Div;
----------
-- "**" --
----------
function "**" (X : Bignum; Y : SD) return Big_Integer is
begin
case Y is
-- X ** 0 is 1
when 0 =>
return Normalize (One_Data);
-- X ** 1 is X
when 1 =>
return Normalize (X.D);
-- X ** 2 is X * X
when 2 =>
return Big_Mul (X, X);
-- For X greater than 2, use the recursion
-- X even, X ** Y = (X ** (Y/2)) ** 2;
-- X odd, X ** Y = (X ** (Y/2)) ** 2 * X;
when others =>
declare
XY2 : aliased Big_Integer := X ** (Y / 2);
XY2S : aliased Big_Integer :=
Big_Mul (To_Bignum (XY2), To_Bignum (XY2));
begin
Free_Big_Integer (XY2);
if (Y and 1) = 0 then
return XY2S;
else
return Res : constant Big_Integer :=
Big_Mul (To_Bignum (XY2S), X)
do
Free_Big_Integer (XY2S);
end return;
end if;
end;
end case;
end "**";
-------------
-- Big_Exp --
-------------
function Big_Exp (X, Y : Bignum) return Big_Integer is
begin
-- Error if right operand negative
if Y.Neg then
raise Constraint_Error with "exponentiation to negative power";
-- X ** 0 is always 1 (including 0 ** 0, so do this test first)
elsif Y.Len = 0 then
return Normalize (One_Data);
-- 0 ** X is always 0 (for X non-zero)
elsif X.Len = 0 then
return Normalize (Zero_Data);
-- (+1) ** Y = 1
-- (-1) ** Y = +/-1 depending on whether Y is even or odd
elsif X.Len = 1 and then X.D (1) = 1 then
return Normalize
(X.D, Neg => X.Neg and then ((Y.D (Y.Len) and 1) = 1));
-- If the absolute value of the base is greater than 1, then the
-- exponent must not be bigger than one word, otherwise the result
-- is ludicrously large, and we just signal Storage_Error right away.
elsif Y.Len > 1 then
raise Storage_Error with "exponentiation result is too large";
-- Special case (+/-)2 ** K, where K is 1 .. 31 using a shift
elsif X.Len = 1 and then X.D (1) = 2 and then Y.D (1) < 32 then
declare
D : constant Digit_Vector (1 .. 1) :=
[Shift_Left (SD'(1), Natural (Y.D (1)))];
begin
return Normalize (D, X.Neg);
end;
-- Remaining cases have right operand of one word
else
return X ** Y.D (1);
end if;
end Big_Exp;
-------------
-- Big_And --
-------------
function Big_And (X, Y : Bignum) return Big_Integer is
begin
if X.Len > Y.Len then
return Big_And (X => Y, Y => X);
end if;
-- X is the smallest integer
declare
Result : Digit_Vector (1 .. X.Len);
Diff : constant Length := Y.Len - X.Len;
begin
for J in 1 .. X.Len loop
Result (J) := X.D (J) and Y.D (J + Diff);
end loop;
return Normalize (Result, X.Neg and Y.Neg);
end;
end Big_And;
------------
-- Big_Or --
------------
function Big_Or (X, Y : Bignum) return Big_Integer is
begin
if X.Len < Y.Len then
return Big_Or (X => Y, Y => X);
end if;
-- X is the largest integer
declare
Result : Digit_Vector (1 .. X.Len);
Index : Length;
Diff : constant Length := X.Len - Y.Len;
begin
Index := 1;
while Index <= Diff loop
Result (Index) := X.D (Index);
Index := Index + 1;
end loop;
for J in 1 .. Y.Len loop
Result (Index) := X.D (Index) or Y.D (J);
Index := Index + 1;
end loop;
return Normalize (Result, X.Neg or Y.Neg);
end;
end Big_Or;
--------------------
-- Big_Shift_Left --
--------------------
function Big_Shift_Left (X : Bignum; Amount : Natural) return Big_Integer is
begin
if X.Neg then
raise Constraint_Error;
elsif Amount = 0 then
return Allocate_Big_Integer (X.D, False);
end if;
declare
Shift : constant Natural := Amount rem SD'Size;
Result : Digit_Vector (0 .. X.Len + Amount / SD'Size);
Carry : SD := 0;
begin
for J in X.Len + 1 .. Result'Last loop
Result (J) := 0;
end loop;
for J in reverse 1 .. X.Len loop
Result (J) := Shift_Left (X.D (J), Shift) or Carry;
Carry := Shift_Right (X.D (J), SD'Size - Shift);
end loop;
Result (0) := Carry;
return Normalize (Result, False);
end;
end Big_Shift_Left;
---------------------
-- Big_Shift_Right --
---------------------
function Big_Shift_Right
(X : Bignum; Amount : Natural) return Big_Integer is
begin
if X.Neg then
raise Constraint_Error;
elsif Amount = 0 then
return Allocate_Big_Integer (X.D, False);
end if;
declare
Shift : constant Natural := Amount rem SD'Size;
Result : Digit_Vector (1 .. X.Len - Amount / SD'Size);
Carry : SD := 0;
begin
for J in 1 .. Result'Last - 1 loop
Result (J) := Shift_Right (X.D (J), Shift) or Carry;
Carry := Shift_Left (X.D (J), SD'Size - Shift);
end loop;
Result (Result'Last) :=
Shift_Right (X.D (Result'Last), Shift) or Carry;
return Normalize (Result, False);
end;
end Big_Shift_Right;
------------
-- Big_EQ --
------------
function Big_EQ (X, Y : Bignum) return Boolean is
begin
return Compare (X.D, Y.D, X.Neg, Y.Neg) = EQ;
end Big_EQ;
------------
-- Big_GE --
------------
function Big_GE (X, Y : Bignum) return Boolean is
begin
return Compare (X.D, Y.D, X.Neg, Y.Neg) /= LT;
end Big_GE;
------------
-- Big_GT --
------------
function Big_GT (X, Y : Bignum) return Boolean is
begin
return Compare (X.D, Y.D, X.Neg, Y.Neg) = GT;
end Big_GT;
------------
-- Big_LE --
------------
function Big_LE (X, Y : Bignum) return Boolean is
begin
return Compare (X.D, Y.D, X.Neg, Y.Neg) /= GT;
end Big_LE;
------------
-- Big_LT --
------------
function Big_LT (X, Y : Bignum) return Boolean is
begin
return Compare (X.D, Y.D, X.Neg, Y.Neg) = LT;
end Big_LT;
-------------
-- Big_Mod --
-------------
-- This table is excerpted from RM 4.5.5(28-30) and shows how the result
-- of Rem and Mod vary with the signs of the operands.
-- A B A mod B A rem B A B A mod B A rem B
-- 10 5 0 0 -10 5 0 0
-- 11 5 1 1 -11 5 4 -1
-- 12 5 2 2 -12 5 3 -2
-- 13 5 3 3 -13 5 2 -3
-- 14 5 4 4 -14 5 1 -4
-- A B A mod B A rem B A B A mod B A rem B
-- 10 -5 0 0 -10 -5 0 0
-- 11 -5 -4 1 -11 -5 -1 -1
-- 12 -5 -3 2 -12 -5 -2 -2
-- 13 -5 -2 3 -13 -5 -3 -3
-- 14 -5 -1 4 -14 -5 -4 -4
function Big_Mod (X, Y : Bignum) return Big_Integer is
Q, R : aliased Big_Integer;
begin
-- If signs are same, result is same as Rem
if X.Neg = Y.Neg then
return Big_Rem (X, Y);
-- Case where Mod is different
else
-- Do division
Div_Rem (X, Y, Q, R, Discard_Quotient => True);
-- Zero result is unchanged
if To_Bignum (R).Len = 0 then
return R;
-- Otherwise adjust result
else
declare
T1 : aliased Big_Integer := Big_Sub (Y, To_Bignum (R));
begin
To_Bignum (T1).Neg := Y.Neg;
Free_Big_Integer (R);
return T1;
end;
end if;
end if;
end Big_Mod;
-------------
-- Big_Mul --
-------------
function Big_Mul (X, Y : Bignum) return Big_Integer is
Result : Digit_Vector (1 .. X.Len + Y.Len) := [others => 0];
-- Accumulate result (max length of result is sum of operand lengths)
L : Length;
-- Current result digit
D : DD;
-- Result digit
begin
for J in 1 .. X.Len loop
for K in 1 .. Y.Len loop
L := Result'Last - (X.Len - J) - (Y.Len - K);
D := DD (X.D (J)) * DD (Y.D (K)) + DD (Result (L));
Result (L) := LSD (D);
D := D / Base;
-- D is carry which must be propagated
while D /= 0 and then L >= 1 loop
L := L - 1;
D := D + DD (Result (L));
Result (L) := LSD (D);
D := D / Base;
end loop;
-- Must not have a carry trying to extend max length
pragma Assert (D = 0);
end loop;
end loop;
-- Return result
return Normalize (Result, X.Neg xor Y.Neg);
end Big_Mul;
------------
-- Big_NE --
------------
function Big_NE (X, Y : Bignum) return Boolean is
begin
return Compare (X.D, Y.D, X.Neg, Y.Neg) /= EQ;
end Big_NE;
-------------
-- Big_Neg --
-------------
function Big_Neg (X : Bignum) return Big_Integer is
begin
return Normalize (X.D, not X.Neg);
end Big_Neg;
-------------
-- Big_Rem --
-------------
-- This table is excerpted from RM 4.5.5(28-30) and shows how the result
-- varies with the signs of the operands.
-- A B A rem B A B A rem B
-- 10 5 0 -10 5 0
-- 11 5 1 -11 5 -1
-- 12 5 2 -12 5 -2
-- 13 5 3 -13 5 -3
-- 14 5 4 -14 5 -4
-- A B A rem B A B A rem B
-- 10 -5 0 -10 -5 0
-- 11 -5 1 -11 -5 -1
-- 12 -5 2 -12 -5 -2
-- 13 -5 3 -13 -5 -3
-- 14 -5 4 -14 -5 -4
function Big_Rem (X, Y : Bignum) return Big_Integer is
Q, R : aliased Big_Integer;
begin
Div_Rem (X, Y, Q, R, Discard_Quotient => True);
To_Bignum (R).Neg := To_Bignum (R).Len > 0 and then X.Neg;
return R;
end Big_Rem;
-------------
-- Big_Sub --
-------------
function Big_Sub (X, Y : Bignum) return Big_Integer is
begin
-- If right operand zero, return left operand (avoiding sharing)
if Y.Len = 0 then
return Normalize (X.D, X.Neg);
-- Otherwise add negative of right operand
else
return Add (X.D, Y.D, X.Neg, not Y.Neg);
end if;
end Big_Sub;
-------------
-- Compare --
-------------
function Compare
(X, Y : Digit_Vector;
X_Neg, Y_Neg : Boolean) return Compare_Result
is
begin
-- Signs are different, that's decisive, since 0 is always plus
if X_Neg /= Y_Neg then
return (if X_Neg then LT else GT);
-- Lengths are different, that's decisive since no leading zeroes
elsif X'Last /= Y'Last then
return (if (X'Last > Y'Last) xor X_Neg then GT else LT);
-- Need to compare data
else
for J in X'Range loop
if X (J) /= Y (J) then
return (if (X (J) > Y (J)) xor X_Neg then GT else LT);
end if;
end loop;
return EQ;
end if;
end Compare;
-------------
-- Div_Rem --
-------------
procedure Div_Rem
(X, Y : Bignum;
Quotient : out Big_Integer;
Remainder : out Big_Integer;
Discard_Quotient : Boolean := False;
Discard_Remainder : Boolean := False) is
begin
-- Error if division by zero
if Y.Len = 0 then
raise Constraint_Error with "division by zero";
end if;
-- Handle simple cases with special tests
-- If X < Y then quotient is zero and remainder is X
if Compare (X.D, Y.D, False, False) = LT then
if not Discard_Quotient then
Quotient := Normalize (Zero_Data);
end if;
if not Discard_Remainder then
Remainder := Normalize (X.D);
end if;
return;
-- If both X and Y are less than 2**63-1, we can use Long_Long_Integer
-- arithmetic. Note it is good not to do an accurate range check against
-- Long_Long_Integer since -2**63 / -1 overflows.
elsif (X.Len <= 1 or else (X.Len = 2 and then X.D (1) < 2**31))
and then
(Y.Len <= 1 or else (Y.Len = 2 and then Y.D (1) < 2**31))
then
declare
A : constant LLI := abs (From_Bignum (X));
B : constant LLI := abs (From_Bignum (Y));
begin
if not Discard_Quotient then
Quotient := To_Bignum (A / B);
end if;
if not Discard_Remainder then
Remainder := To_Bignum (A rem B);
end if;
return;
end;
-- Easy case if divisor is one digit
elsif Y.Len = 1 then
declare
ND : DD;
Div : constant DD := DD (Y.D (1));
Result : Digit_Vector (1 .. X.Len);
Remdr : Digit_Vector (1 .. 1);
begin
ND := 0;
for J in 1 .. X.Len loop
ND := Base * ND + DD (X.D (J));
pragma Assert (Div /= 0);
Result (J) := SD (ND / Div);
ND := ND rem Div;
end loop;
if not Discard_Quotient then
Quotient := Normalize (Result);
end if;
if not Discard_Remainder then
Remdr (1) := SD (ND);
Remainder := Normalize (Remdr);
end if;
return;
end;
end if;
-- The complex full multi-precision case. We will employ algorithm
-- D defined in the section "The Classical Algorithms" (sec. 4.3.1)
-- of Donald Knuth's "The Art of Computer Programming", Vol. 2, 2nd
-- edition. The terminology is adjusted for this section to match that
-- reference.
-- We are dividing X.Len digits of X (called u here) by Y.Len digits
-- of Y (called v here), developing the quotient and remainder. The
-- numbers are represented using Base, which was chosen so that we have
-- the operations of multiplying to single digits (SD) to form a double
-- digit (DD), and dividing a double digit (DD) by a single digit (SD)
-- to give a single digit quotient and a single digit remainder.
-- Algorithm D from Knuth
-- Comments here with square brackets are directly from Knuth
Algorithm_D : declare
-- The following lower case variables correspond exactly to the
-- terminology used in algorithm D.
m : constant Length := X.Len - Y.Len;
n : constant Length := Y.Len;
b : constant DD := Base;
u : Digit_Vector (0 .. m + n);
v : Digit_Vector (1 .. n);
q : Digit_Vector (0 .. m);
r : Digit_Vector (1 .. n);
u0 : SD renames u (0);
v1 : SD renames v (1);
v2 : SD renames v (2);
d : DD;
j : Length;
qhat : DD;
rhat : DD;
temp : DD;
begin
-- Initialize data of left and right operands
for J in 1 .. m + n loop
u (J) := X.D (J);
end loop;
for J in 1 .. n loop
v (J) := Y.D (J);
end loop;
-- [Division of nonnegative integers.] Given nonnegative integers u
-- = (ul,u2..um+n) and v = (v1,v2..vn), where v1 /= 0 and n > 1, we
-- form the quotient u / v = (q0,ql..qm) and the remainder u mod v =
-- (r1,r2..rn).
pragma Assert (v1 /= 0);
pragma Assert (n > 1);
-- Dl. [Normalize.] Set d = b/(vl + 1). Then set (u0,u1,u2..um+n)
-- equal to (u1,u2..um+n) times d, and set (v1,v2..vn) equal to
-- (v1,v2..vn) times d. Note the introduction of a new digit position
-- u0 at the left of u1; if d = 1 all we need to do in this step is
-- to set u0 = 0.
d := b / (DD (v1) + 1);
if d = 1 then
u0 := 0;
else
declare
Carry : DD;
Tmp : DD;
begin
-- Multiply Dividend (u) by d
Carry := 0;
for J in reverse 1 .. m + n loop
Tmp := DD (u (J)) * d + Carry;
u (J) := LSD (Tmp);
Carry := Tmp / Base;
end loop;
u0 := SD (Carry);
-- Multiply Divisor (v) by d
Carry := 0;
for J in reverse 1 .. n loop
Tmp := DD (v (J)) * d + Carry;
v (J) := LSD (Tmp);
Carry := Tmp / Base;
end loop;
pragma Assert (Carry = 0);
end;
end if;
-- D2. [Initialize j.] Set j = 0. The loop on j, steps D2 through D7,
-- will be essentially a division of (uj, uj+1..uj+n) by (v1,v2..vn)
-- to get a single quotient digit qj.
j := 0;
-- Loop through digits
loop
-- Note: In the original printing, step D3 was as follows:
-- D3. [Calculate qhat.] If uj = v1, set qhat to b-l; otherwise
-- set qhat to (uj,uj+1)/v1. Now test if v2 * qhat is greater than
-- (uj*b + uj+1 - qhat*v1)*b + uj+2. If so, decrease qhat by 1 and
-- repeat this test
-- This had a bug not discovered till 1995, see Vol 2 errata:
-- http://www-cs-faculty.stanford.edu/~uno/err2-2e.ps.gz. Under
-- rare circumstances the expression in the test could overflow.
-- This version was further corrected in 2005, see Vol 2 errata:
-- http://www-cs-faculty.stanford.edu/~uno/all2-pre.ps.gz.
-- The code below is the fixed version of this step.
-- D3. [Calculate qhat.] Set qhat to (uj,uj+1)/v1 and rhat to
-- to (uj,uj+1) mod v1.
temp := u (j) & u (j + 1);
qhat := temp / DD (v1);
rhat := temp mod DD (v1);
-- D3 (continued). Now test if qhat >= b or v2*qhat > (rhat,uj+2):
-- if so, decrease qhat by 1, increase rhat by v1, and repeat this
-- test if rhat < b. [The test on v2 determines at high speed
-- most of the cases in which the trial value qhat is one too
-- large, and eliminates all cases where qhat is two too large.]
while qhat >= b
or else DD (v2) * qhat > LSD (rhat) & u (j + 2)
loop
qhat := qhat - 1;
rhat := rhat + DD (v1);
exit when rhat >= b;
end loop;
-- D4. [Multiply and subtract.] Replace (uj,uj+1..uj+n) by
-- (uj,uj+1..uj+n) minus qhat times (v1,v2..vn). This step
-- consists of a simple multiplication by a one-place number,
-- combined with a subtraction.
-- The digits (uj,uj+1..uj+n) are always kept positive; if the
-- result of this step is actually negative then (uj,uj+1..uj+n)
-- is left as the true value plus b**(n+1), i.e. as the b's
-- complement of the true value, and a "borrow" to the left is
-- remembered.
declare
Borrow : SD;
Carry : DD;
Temp : DD;
Negative : Boolean;
-- Records if subtraction causes a negative result, requiring
-- an add back (case where qhat turned out to be 1 too large).
begin
Borrow := 0;
for K in reverse 1 .. n loop
Temp := qhat * DD (v (K)) + DD (Borrow);
Borrow := MSD (Temp);
if LSD (Temp) > u (j + K) then
Borrow := Borrow + 1;
end if;
u (j + K) := u (j + K) - LSD (Temp);
end loop;
Negative := u (j) < Borrow;
u (j) := u (j) - Borrow;
-- D5. [Test remainder.] Set qj = qhat. If the result of step
-- D4 was negative, we will do the add back step (step D6).
q (j) := LSD (qhat);
if Negative then
-- D6. [Add back.] Decrease qj by 1, and add (0,v1,v2..vn)
-- to (uj,uj+1,uj+2..uj+n). (A carry will occur to the left
-- of uj, and it is be ignored since it cancels with the
-- borrow that occurred in D4.)
q (j) := q (j) - 1;
Carry := 0;
for K in reverse 1 .. n loop
Temp := DD (v (K)) + DD (u (j + K)) + Carry;
u (j + K) := LSD (Temp);
Carry := Temp / Base;
end loop;
u (j) := u (j) + SD (Carry);
end if;
end;
-- D7. [Loop on j.] Increase j by one. Now if j <= m, go back to
-- D3 (the start of the loop on j).
j := j + 1;
exit when not (j <= m);
end loop;
-- D8. [Unnormalize.] Now (qo,ql..qm) is the desired quotient, and
-- the desired remainder may be obtained by dividing (um+1..um+n)
-- by d.
if not Discard_Quotient then
Quotient := Normalize (q);
end if;
if not Discard_Remainder then
declare
Remdr : DD;
begin
Remdr := 0;
for K in 1 .. n loop
Remdr := Base * Remdr + DD (u (m + K));
r (K) := SD (Remdr / d);
Remdr := Remdr rem d;
end loop;
pragma Assert (Remdr = 0);
end;
Remainder := Normalize (r);
end if;
end Algorithm_D;
end Div_Rem;
-----------------
-- From_Bignum --
-----------------
function From_Bignum (X : Bignum) return Long_Long_Integer is
begin
if X.Len = 0 then
return 0;
elsif X.Len = 1 then
return (if X.Neg then -LLI (X.D (1)) else LLI (X.D (1)));
elsif X.Len = 2 then
declare
Mag : constant DD := X.D (1) & X.D (2);
begin
if X.Neg and then Mag <= 2 ** 63 then
return -LLI (Mag);
elsif Mag < 2 ** 63 then
return LLI (Mag);
end if;
end;
end if;
raise Constraint_Error with "expression value out of range";
end From_Bignum;
-------------------------
-- Bignum_In_LLI_Range --
-------------------------
function Bignum_In_LLI_Range (X : Bignum) return Boolean is
begin
-- If length is 0 or 1, definitely fits
if X.Len <= 1 then
return True;
-- If length is greater than 2, definitely does not fit
elsif X.Len > 2 then
return False;
-- Length is 2, more tests needed
else
declare
Mag : constant DD := X.D (1) & X.D (2);
begin
return Mag < 2 ** 63 or else (X.Neg and then Mag = 2 ** 63);
end;
end if;
end Bignum_In_LLI_Range;
---------------
-- Normalize --
---------------
Bignum_Limit : constant := 200;
function Normalize
(X : Digit_Vector;
Neg : Boolean := False) return Big_Integer
is
J : Length;
begin
J := X'First;
while J <= X'Last and then X (J) = 0 loop
J := J + 1;
end loop;
if X'Last - J > Bignum_Limit then
raise Storage_Error with "big integer limit exceeded";
end if;
return Allocate_Big_Integer (X (J .. X'Last), J <= X'Last and then Neg);
end Normalize;
---------------
-- To_Bignum --
---------------
function To_Bignum (X : Long_Long_Long_Integer) return Big_Integer is
function Convert_128
(X : Long_Long_Long_Integer; Neg : Boolean) return Big_Integer;
-- Convert a 128 bits natural integer to a Big_Integer
-----------------
-- Convert_128 --
-----------------
function Convert_128
(X : Long_Long_Long_Integer; Neg : Boolean) return Big_Integer
is
Vector : Digit_Vector (1 .. 4);
High : constant Unsigned_64 :=
Unsigned_64 (Shift_Right (Unsigned_128 (X), 64));
Low : constant Unsigned_64 :=
Unsigned_64 (Unsigned_128 (X) and 16#FFFF_FFFF_FFFF_FFFF#);
begin
Vector (1) := SD (High / Base);
Vector (2) := SD (High mod Base);
Vector (3) := SD (Low / Base);
Vector (4) := SD (Low mod Base);
return Normalize (Vector, Neg);
end Convert_128;
begin
if X = 0 then
return Allocate_Big_Integer ([], False);
-- One word result
elsif X in -(2 ** 32 - 1) .. +(2 ** 32 - 1) then
return Allocate_Big_Integer ([SD (abs X)], X < 0);
-- Large negative number annoyance
elsif X = -2 ** 63 then
return Allocate_Big_Integer ([2 ** 31, 0], True);
elsif Long_Long_Long_Integer'Size = 128
and then X = Long_Long_Long_Integer'First
then
return Allocate_Big_Integer ([2 ** 31, 0, 0, 0], True);
-- Other negative numbers
elsif X < 0 then
if Long_Long_Long_Integer'Size = 64 then
return Allocate_Big_Integer
((SD ((-X) / Base), SD ((-X) mod Base)), True);
else
return Convert_128 (-X, True);
end if;
-- Positive numbers
else
if Long_Long_Long_Integer'Size = 64 then
return Allocate_Big_Integer
((SD (X / Base), SD (X mod Base)), False);
else
return Convert_128 (X, False);
end if;
end if;
end To_Bignum;
function To_Bignum (X : Long_Long_Integer) return Big_Integer is
begin
return To_Bignum (Long_Long_Long_Integer (X));
end To_Bignum;
function To_Bignum (X : Unsigned_128) return Big_Integer is
begin
if X = 0 then
return Allocate_Big_Integer ([], False);
-- One word result
elsif X < 2 ** 32 then
return Allocate_Big_Integer ([SD (X)], False);
-- Two word result
elsif Shift_Right (X, 32) < 2 ** 32 then
return Allocate_Big_Integer ([SD (X / Base), SD (X mod Base)], False);
-- Three or four word result
else
declare
Vector : Digit_Vector (1 .. 4);
High : constant Unsigned_64 := Unsigned_64 (Shift_Right (X, 64));
Low : constant Unsigned_64 :=
Unsigned_64 (X and 16#FFFF_FFFF_FFFF_FFFF#);
begin
Vector (1) := SD (High / Base);
Vector (2) := SD (High mod Base);
Vector (3) := SD (Low / Base);
Vector (4) := SD (Low mod Base);
return Normalize (Vector, False);
end;
end if;
end To_Bignum;
function To_Bignum (X : Unsigned_64) return Big_Integer is
begin
return To_Bignum (Unsigned_128 (X));
end To_Bignum;
---------------
-- To_String --
---------------
Hex_Chars : constant array (0 .. 15) of Character := "0123456789ABCDEF";
function To_String
(X : Bignum; Width : Natural := 0; Base : Positive := 10) return String
is
Big_Base : aliased Bignum_Data := (1, False, [SD (Base)]);
function Add_Base (S : String) return String;
-- Add base information if Base /= 10
function Leading_Padding
(Str : String;
Min_Length : Natural;
Char : Character := ' ') return String;
-- Return padding of Char concatenated with Str so that the resulting
-- string is at least Min_Length long.
function Image (Arg : Bignum) return String;
-- Return image of Arg, assuming Arg is positive.
function Image (N : Natural) return String;
-- Return image of N, with no leading space.
--------------
-- Add_Base --
--------------
function Add_Base (S : String) return String is
begin
if Base = 10 then
return S;
else
return Image (Base) & "#" & S & "#";
end if;
end Add_Base;
-----------
-- Image --
-----------
function Image (N : Natural) return String is
S : constant String := Natural'Image (N);
begin
return S (2 .. S'Last);
end Image;
function Image (Arg : Bignum) return String is
begin
if Big_LT (Arg, Big_Base'Unchecked_Access) then
return [Hex_Chars (Natural (From_Bignum (Arg)))];
else
declare
Div : aliased Big_Integer;
Remain : aliased Big_Integer;
R : Natural;
begin
Div_Rem (Arg, Big_Base'Unchecked_Access, Div, Remain);
R := Natural (From_Bignum (To_Bignum (Remain)));
Free_Big_Integer (Remain);
return S : constant String :=
Image (To_Bignum (Div)) & Hex_Chars (R)
do
Free_Big_Integer (Div);
end return;
end;
end if;
end Image;
---------------------
-- Leading_Padding --
---------------------
function Leading_Padding
(Str : String;
Min_Length : Natural;
Char : Character := ' ') return String is
begin
return [1 .. Integer'Max (Integer (Min_Length) - Str'Length, 0)
=> Char] & Str;
end Leading_Padding;
Zero : aliased Bignum_Data := (0, False, D => Zero_Data);
begin
if Big_LT (X, Zero'Unchecked_Access) then
declare
X_Pos : aliased Bignum_Data := (X.Len, not X.Neg, X.D);
begin
return Leading_Padding
("-" & Add_Base (Image (X_Pos'Unchecked_Access)), Width);
end;
else
return Leading_Padding (" " & Add_Base (Image (X)), Width);
end if;
end To_String;
-------------
-- Is_Zero --
-------------
function Is_Zero (X : Bignum) return Boolean is
(X /= null and then X.D = Zero_Data);
end System.Generic_Bignums;
|
AdaCore/gpr | Ada | 51 | ads |
package P is
function F return Boolean;
end P;
|
jscparker/math_packages | Ada | 13,284 | adb |
with Text_IO; use Text_IO;
with Ada.Numerics.Generic_Elementary_Functions;
with Spline;
procedure Spline_tst_1 is
type Real is digits 15;
package math is new Ada.Numerics.Generic_Elementary_Functions (Real);
use math;
package rio is new Float_IO (Real);
use rio;
type Index is range 1 .. 178;
type Data_Vector is array(Index) of Real;
package Sin_Spline is new Spline (Real, Index, Data_Vector);
use Sin_Spline;
X_Data, Y_Data : Data_Vector := (others => 0.0);
S : Spline_Coefficients;
Pii : constant Real := Ada.Numerics.Pi;
DeltaX : Real := Pii / (Real (Index'Last) - Real (Index'First));
X, Y : Real;
Y_true : Real;
dY, ddY : Real;
DeltaX1, DeltaX2, DeltaX3 : Real;
Integral_of_Sin, Err : Real;
Bound_First, Bound_Last : Boundary;
X_Stuff : X_Structure;
-- Requires Text_IO.
procedure Pause (s1,s2,s3,s4,s5,s6 : string := " ") is
Continuation : Character := ' ';
begin
Text_IO.New_Line;
if S1 /= " " then put_line (S1); end if;
if S2 /= " " then put_line (S2); end if;
if S3 /= " " then put_line (S3); end if;
if S4 /= " " then put_line (S4); end if;
if S5 /= " " then put_line (S5); end if;
if S6 /= " " then put_line (S6); end if;
Text_IO.New_Line;
begin
Text_IO.Put ("Type a character to continue: ");
Text_IO.Get_Immediate (Continuation);
exception
when others => null;
end;
Text_IO.New_Line;
end pause;
begin
-- Start by making natural splines
DeltaX := Pii / (Real (Index'Last) - Real (Index'First));
for I in Index loop
X := DeltaX * (Real (I) - Real(Index'First));
X_Data(I) := X;
Y_Data(I) := Sin (X);
end loop;
-- Natural boundary conditions:
Bound_First := (Alpha => 1.0, Beta => 0.0, Boundary_Val => 0.0);
Bound_Last := (Alpha => 1.0, Beta => 0.0, Boundary_Val => 0.0);
Prepare_X_Data (X_Stuff, X_Data, Index'First, Index'Last,
Bound_First, Bound_Last);
Get_Spline (S, X_Stuff, Y_Data);
-- Check that Spline is continuous
Pause
("Test 1: Verify that the Spline is continuous at the knots.",
"Recall that the spline equations were derived via this assumption",
"(along with the assumption that the first 2 derivatives of the curve",
"are also continuous at the knots.)");
for I in Index'First .. Index'Last-1 loop
DeltaX1 := X_Data(I+1) - X_Data(I);
DeltaX2 := DeltaX1*DeltaX1;
DeltaX3 := DeltaX1*DeltaX2;
Y := Y_Data(I) + S.F(1)(I)*DeltaX1 + S.F(2)(I)*DeltaX2 + S.F(3)(I)*DeltaX3;
-- This is the Y at I+1 due to spline starting at point I.
-- Compare with Y at I+1 = Y_Data(I+1)
Put (Y - Y_Data(I+1)); New_Line;
end loop;
-- Check that derivative is continuous
Pause ("Verify that the derivative of the spline is continuous.");
for I in Index'First .. Index'Last-1 loop
DeltaX1 := X_Data(I+1) - X_Data(I);
DeltaX2 := DeltaX1*DeltaX1;
DeltaX3 := DeltaX1*DeltaX2;
dY := S.F(1)(I) + 2.0*S.F(2)(I)*DeltaX1 + 3.0*S.F(3)(I)*DeltaX2;
-- This is the dY at I+1 due to spline starting at point I.
-- Compare with dY at I+1 = S.F(1)(I+1)
Put (dY - S.F(1)(I+1)); New_Line;
end loop;
-- Check that 2nd derivative is continuous
Pause ("Verify that the 2nd derivative of the spline is continuous.");
for I in Index'First .. Index'Last-1 loop
DeltaX1 := X_Data(I+1) - X_Data(I);
DeltaX2 := DeltaX1*DeltaX1;
DeltaX3 := DeltaX1*DeltaX2;
ddY := 2.0*S.F(2)(I) + 6.0*S.F(3)(I)*DeltaX1;
-- This is the ddY at I+1 due to spline starting at point I.
-- Compare with ddY at I+1 = 2.0*S.F(2)(I+1)
Put (ddY - 2.0*S.F(2)(I+1)); New_Line;
end loop;
Pause ("Subtract Spline prediction from true value.");
for I in Index'first .. Index'last-1 loop
X := X_Data(I) + DeltaX/2.0;
Y := Value_At (X, X_Data, Y_Data, S);
Y_true := Sin (X);
Put (Y - Y_true); New_Line;
end loop;
New_line;
Pause ("Subtract Spline prediction of 1st derivative from true value.");
for I in Index'first .. Index'last-1 loop
X := X_Data(I) + DeltaX/2.0;
Y := First_Derivative_At (X, X_Data, S);
Y_true := Cos (X);
Put (Y - Y_true); New_Line;
end loop;
New_line;
Pause
("Subtract Spline prediction of 2nd derivative from true value.",
"You will notice that the error is much larger this time.");
for I in Index'first .. Index'last-1 loop
X := X_Data(I) + DeltaX/2.0;
Y := Second_Derivative_At (X, X_Data, S);
Y_true := -Sin (X);
Put (Y - Y_true); New_Line;
end loop;
New_line;
-- Check quadrature:
Pause
("Test 1b: Calculate area under the curve.");
Integral_of_Sin := -(Cos (X_Data(Index'Last)) - Cos (X_Data(Index'First)));
Err := Abs (Integral_of_Sin - Integral (X_Data, Y_Data, S));
New_Line;
Put ("Error in numerical quadrature ="); Put (Err);
--Put (Integral_of_Sin); Put (Integral (X_Data, Y_Data, S));
New_Line;
-- make natural splines, test Cos.
DeltaX := Pii / (Real (Index'Last) - Real (Index'First));
for I in Index loop
X := DeltaX * (Real (I) - Real(Index'First));
X_Data(I) := X;
Y_Data(I) := Cos (X);
end loop;
-- Natural boundary conditions:
Bound_First := (Alpha => 1.0, Beta => 0.0, Boundary_Val => -1.0);
Bound_Last := (Alpha => 1.0, Beta => 0.0, Boundary_Val => 1.0);
Prepare_X_Data (X_Stuff, X_Data, Index'First, Index'Last,
Bound_First, Bound_Last);
Get_Spline (S, X_Stuff, Y_Data);
--Check that Spline is continuous
Pause
("Test 1c: Verify that the Spline is continuous at the knots.",
"In this test the boundary conditions are given by values of",
"the second derivative at the end points, but this second derivative",
"is not 0.0 as in the case of true natural splines.");
for I in Index'First .. Index'Last-1 loop
DeltaX1 := X_Data(I+1) - X_Data(I);
DeltaX2 := DeltaX1*DeltaX1;
DeltaX3 := DeltaX1*DeltaX2;
Y := Y_Data(I) + S.F(1)(I)*DeltaX1 + S.F(2)(I)*DeltaX2 + S.F(3)(I)*DeltaX3;
-- This is the Y at I+1 due to spline starting at point I.
-- Compare with Y at I+1 = Y_Data(I+1)
Put (Y - Y_Data(I+1)); New_Line;
end loop;
-- Check that derivative is continuous
Pause ("Verify that the derivative of the spline is continuous.");
for I in Index'First .. Index'Last-1 loop
DeltaX1 := X_Data(I+1) - X_Data(I);
DeltaX2 := DeltaX1*DeltaX1;
DeltaX3 := DeltaX1*DeltaX2;
dY := S.F(1)(I) + 2.0*S.F(2)(I)*DeltaX1 + 3.0*S.F(3)(I)*DeltaX2;
-- This is the dY at I+1 due to spline starting at point I.
-- Compare with dY at I+1 = S.F(1)(I+1)
Put (dY - S.F(1)(I+1)); New_Line;
end loop;
-- Check that 2nd derivative is continuous
Pause ("Verify that the 2nd derivative of the spline is continuous.");
for I in Index'First .. Index'Last-1 loop
DeltaX1 := X_Data(I+1) - X_Data(I);
DeltaX2 := DeltaX1*DeltaX1;
DeltaX3 := DeltaX1*DeltaX2;
ddY := 2.0*S.F(2)(I) + 6.0*S.F(3)(I)*DeltaX1;
-- This is the ddY at I+1 due to spline starting at point I.
-- Compare with ddY at I+1 = 2.0*S.F(2)(I+1)
Put (ddY - 2.0*S.F(2)(I+1)); New_Line;
end loop;
Pause ("Subtract Spline prediction from true value.");
for I in Index'first .. Index'last-1 loop
X := X_Data(I) + DeltaX/2.0;
Y := Value_At (X, X_Data, Y_Data, S);
Y_true := Cos (X);
Put (Y - Y_true); New_Line;
end loop;
New_line;
-- Make mixed splines: natural at one end, clamped at the other.
DeltaX := 1.5 * Pii / (Real (Index'Last) - Real (Index'First));
for I in Index loop
X := DeltaX * (Real (I) - Real(Index'First));
X_Data(I) := X;
Y_Data(I) := Sin (X);
end loop;
-- Natural:
Bound_First := (Alpha => 1.0, Beta => 0.0, Boundary_Val => 0.0);
-- Clamped with derivative = 0.0:
Bound_Last := (Alpha => 0.0, Beta => 1.0, Boundary_Val => 0.0);
Prepare_X_Data (X_Stuff, X_Data, Index'First, Index'Last,
Bound_First, Bound_Last);
Get_Spline (S, X_Stuff, Y_Data);
-- Verify that Spline is continuous:
Pause
("Test 2: Verify that the mixed-boundary Spline is continuous at the knots.",
"Recall that the spline equations were derived via this assumption",
"(along with the assumption that the first 2 derivatives of the curve",
"are also continuous at the knots.)");
for I in Index'First .. Index'Last-1 loop
DeltaX1 := X_Data(I+1) - X_Data(I);
DeltaX2 := DeltaX1*DeltaX1;
DeltaX3 := DeltaX1*DeltaX2;
Y := Y_Data(I) + S.F(1)(I)*DeltaX1 + S.F(2)(I)*DeltaX2 + S.F(3)(I)*DeltaX3;
-- This is the Y at I+1 due to spline starting at point I.
-- Compare with Y at I+1 = Y_Data(I+1)
Put (Y - Y_Data(I+1)); New_Line;
end loop;
-- Check that derivative is continuous:
Pause ("Verify that the derivative of the spline is continuous.");
for I in Index'First .. Index'Last-1 loop
DeltaX1 := X_Data(I+1) - X_Data(I);
DeltaX2 := DeltaX1*DeltaX1;
DeltaX3 := DeltaX1*DeltaX2;
dY := S.F(1)(I) + 2.0*S.F(2)(I)*DeltaX1 + 3.0*S.F(3)(I)*DeltaX2;
-- This is the dY at I+1 due to spline starting at point I.
-- Compare with dY at I+1 = S.F(1)(I+1)
Put (dY - S.F(1)(I+1)); New_Line;
end loop;
-- Check that 2nd derivative is continuous:
Pause ("Verify that the 2nd derivative of the spline is continuous.");
for I in Index'First .. Index'Last-1 loop
DeltaX1 := X_Data(I+1) - X_Data(I);
DeltaX2 := DeltaX1*DeltaX1;
DeltaX3 := DeltaX1*DeltaX2;
ddY := 2.0*S.F(2)(I) + 6.0*S.F(3)(I)*DeltaX1;
-- This is the ddY at I+1 due to spline starting at point I.
-- Compare with ddY at I+1 = 2.0*S.F(2)(I+1)
Put (ddY - 2.0*S.F(2)(I+1)); New_Line;
end loop;
Pause ("Subtract Spline prediction from true value.");
for I in Index'first .. Index'last-1 loop
X := X_Data(I) + DeltaX/2.0;
Y := Value_At (X, X_Data, Y_Data, S);
Y_true := Sin (X);
Put (Y - Y_true); New_Line;
end loop;
New_line;
-- Make mixed splines: natural at one end, clamped at the other.
-- This time we get them wrong.
DeltaX := 1.5 * Pii / (Real (Index'Last) - Real (Index'First));
for I in Index loop
X := DeltaX * (Real (I) - Real(Index'First));
X_Data(I) := X;
Y_Data(I) := Sin (X);
end loop;
-- Now we have the boundary conditions wrong for the Sin curve:
-- Natural:
Bound_First := (Alpha => 0.0, Beta => 1.0, Boundary_Val => 0.0);
-- Clamped with derivative = 1.0:
Bound_Last := (Alpha => 1.0, Beta => 0.0, Boundary_Val => 0.0);
Prepare_X_Data (X_Stuff, X_Data, Index'First, Index'Last,
Bound_First, Bound_Last);
Get_Spline (S, X_Stuff, Y_Data);
--Check that Spline is continuous:
Pause
("Test 3: Make sure the mixed-boundary Spline is continuous at the knots.",
"Recall that the spline equations were derived via this assumption",
"(along with the assumption that the first 2 derivatives of the curve",
"are also continuous at the knots.)");
for I in Index'First .. Index'Last-1 loop
DeltaX1 := X_Data(I+1) - X_Data(I);
DeltaX2 := DeltaX1*DeltaX1;
DeltaX3 := DeltaX1*DeltaX2;
Y := Y_Data(I) + S.F(1)(I)*DeltaX1 + S.F(2)(I)*DeltaX2 + S.F(3)(I)*DeltaX3;
-- This is the Y at I+1 due to spline starting at point I.
-- Compare with Y at I+1 = Y_Data(I+1)
Put (Y - Y_Data(I+1)); New_Line;
end loop;
-- Check that derivative is continuous:
Pause ("Verify that the derivative of the spline is continuous.");
for I in Index'First .. Index'Last-1 loop
DeltaX1 := X_Data(I+1) - X_Data(I);
DeltaX2 := DeltaX1*DeltaX1;
DeltaX3 := DeltaX1*DeltaX2;
dY := S.F(1)(I) + 2.0*S.F(2)(I)*DeltaX1 + 3.0*S.F(3)(I)*DeltaX2;
-- This is the dY at I+1 due to spline starting at point I.
-- Compare with dY at I+1 = S.F(1)(I+1)
Put (dY - S.F(1)(I+1)); New_Line;
end loop;
-- Check that 2nd derivative is continuous:
Pause ("Verify that the 2nd derivative of the spline is continuous.");
for I in Index'First .. Index'Last-1 loop
DeltaX1 := X_Data(I+1) - X_Data(I);
DeltaX2 := DeltaX1*DeltaX1;
DeltaX3 := DeltaX1*DeltaX2;
ddY := 2.0*S.F(2)(I) + 6.0*S.F(3)(I)*DeltaX1;
-- This is the ddY at I+1 due to spline starting at point I.
-- Compare with ddY at I+1 = 2.0*S.F(2)(I+1)
Put (ddY - 2.0*S.F(2)(I+1)); New_Line;
end loop;
Pause
("Subtract Spline prediction from true value.",
"In this test we deliberately made the Boundary conditions",
"wrong, so the answers should be dreadful at the end points.");
for I in Index'first .. Index'last-1 loop
X := X_Data(I) + DeltaX/2.0;
Y := Value_At (X, X_Data, Y_Data, S);
Y_true := Sin (X);
Put (Y - Y_true); New_Line;
end loop;
New_line;
end;
|
reznikmm/matreshka | Ada | 5,382 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
private with Interfaces;
with League.Calendars;
with League.Strings;
with Servlet.HTTP_Sessions;
limited private with AWFC.Accounts.Sessions.Stores;
with AWFC.Accounts.Users;
package AWFC.Accounts.Sessions is
type Session_Identifier is private;
type Session is limited new Servlet.HTTP_Sessions.HTTP_Session with private;
type Session_Access is access all Session'Class;
function Get_Session_Identifier
(Self : not null access constant Session'Class) return Session_Identifier;
-- Returns session identifier of specified session.
function Get_User
(Self : not null access constant Session'Class)
return AWFC.Accounts.Users.User_Access;
-- Returns user.
procedure Set_User
(Self : not null access Session'Class;
User : not null AWFC.Accounts.Users.User_Access);
-- Sets session's user. New session identifier is generated for session.
private
type Session_Identifier is
array (Positive range 1 .. 2) of Interfaces.Unsigned_64
with Size => 128;
type Session is limited new Servlet.HTTP_Sessions.HTTP_Session with record
Store :
access AWFC.Accounts.Sessions.Stores.Session_Manager'Class;
Identifier : Session_Identifier;
User : AWFC.Accounts.Users.User_Access;
Creation_Time : League.Calendars.Date_Time;
Last_Accessed_Time : League.Calendars.Date_Time;
end record;
overriding function Get_Id
(Self : Session) return League.Strings.Universal_String;
-- Returns a string containing the unique identifier assigned to this
-- session. The identifier is assigned by the servlet container and is
-- implementation dependent.
function Generate_Session_Identifier return Session_Identifier;
-- Generates session identifer.
function To_Universal_String
(Item : Session_Identifier) return League.Strings.Universal_String;
-- Converts session identifier from internal representation into textual
-- representation.
end AWFC.Accounts.Sessions;
|
doug16rogers/solitaire | Ada | 386 | adb | with Solitaire_Operations.Text_Representation;
with Ada.Text_IO;
use Ada;
procedure Null_Key is
Deck : Solitaire_Operations.Deck_List := Solitaire_Operations.Standard_Deck;
begin -- Null_Key
Output : for I in Deck'range loop
Text_IO.Put (Item => Solitaire_Operations.Text_Representation.Short_Card_Name (Deck (I) ) );
end loop Output;
Text_IO.New_Line;
end Null_Key; |
reznikmm/matreshka | Ada | 3,714 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Dr3d_Projection_Attributes is
pragma Preelaborate;
type ODF_Dr3d_Projection_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Dr3d_Projection_Attribute_Access is
access all ODF_Dr3d_Projection_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Dr3d_Projection_Attributes;
|
reznikmm/matreshka | Ada | 3,542 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- Configure default set of wiki parser capabilities.
------------------------------------------------------------------------------
package Wiki.Setup is
pragma Elaborate_Body;
end Wiki.Setup;
|
reznikmm/matreshka | Ada | 3,689 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Db_Visible_Attributes is
pragma Preelaborate;
type ODF_Db_Visible_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Db_Visible_Attribute_Access is
access all ODF_Db_Visible_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Db_Visible_Attributes;
|
reznikmm/matreshka | Ada | 4,662 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Visitors;
with ODF.DOM.Anim_Param_Elements;
package Matreshka.ODF_Anim.Param_Elements is
type Anim_Param_Element_Node is
new Matreshka.ODF_Anim.Abstract_Anim_Element_Node
and ODF.DOM.Anim_Param_Elements.ODF_Anim_Param
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Anim_Param_Element_Node;
overriding function Get_Local_Name
(Self : not null access constant Anim_Param_Element_Node)
return League.Strings.Universal_String;
overriding procedure Enter_Node
(Self : not null access Anim_Param_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Leave_Node
(Self : not null access Anim_Param_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
overriding procedure Visit_Node
(Self : not null access Anim_Param_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control);
end Matreshka.ODF_Anim.Param_Elements;
|
jhumphry/auto_counters | Ada | 4,054 | ads | -- kvflyweights-refcounted_ptrs.ads
-- A package of reference-counting generalised references which point to
-- resources inside a KVFlyweight. Resources are associated with a key that can
-- be used to create them if they have not already been created.
-- Copyright (c) 2016-2023, James Humphry
--
-- 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.
pragma Profile (No_Implementation_Extensions);
with Ada.Containers;
with Ada.Finalization;
with KVFlyweights_Hashtables_Spec;
generic
type Key(<>) is private;
type Key_Access is access Key;
type Value(<>) is limited private;
type Value_Access is access Value;
with package KVFlyweight_Hashtables is
new KVFlyweights_Hashtables_Spec(Key => Key,
Key_Access => Key_Access,
Value_Access => Value_Access,
others => <>);
package KVFlyweights.Refcounted_Ptrs is
type V_Ref(V : access Value) is null record
with Implicit_Dereference => V;
type Refcounted_Value_Ptr is
new Ada.Finalization.Controlled with private;
function P (P : Refcounted_Value_Ptr) return V_Ref
with Inline;
function Get (P : Refcounted_Value_Ptr) return Value_Access
with Inline;
function Insert_Ptr (F : aliased in out KVFlyweight_Hashtables.KVFlyweight;
K : in Key) return Refcounted_Value_Ptr
with Inline;
type Refcounted_Value_Ref (V : not null access Value) is
new Ada.Finalization.Controlled with private
with Implicit_Dereference => V;
function Get (P : Refcounted_Value_Ref) return Value_Access
with Inline;
function Insert_Ref (F : aliased in out KVFlyweight_Hashtables.KVFlyweight;
K : in Key) return Refcounted_Value_Ref
with Inline;
function Make_Ptr (R : Refcounted_Value_Ref'Class)
return Refcounted_Value_Ptr
with Inline;
function Make_Ref (P : Refcounted_Value_Ptr'Class)
return Refcounted_Value_Ref
with Inline, Pre => (Get(P) /= null or else
(raise KVFlyweights_Error with "Cannot make a " &
"Refcounted_Value_Ref from a null Refcounted_Value_Ptr"));
private
type KVFlyweight_Ptr is access all KVFlyweight_Hashtables.KVFlyweight;
type Refcounted_Value_Ptr is
new Ada.Finalization.Controlled with
record
V : Value_Access := null;
K : Key_Access := null;
Containing_KVFlyweight : KVFlyweight_Ptr := null;
Containing_Bucket : Ada.Containers.Hash_Type;
end record;
overriding procedure Adjust (Object : in out Refcounted_Value_Ptr);
overriding procedure Finalize (Object : in out Refcounted_Value_Ptr);
type Refcounted_Value_Ref (V : access Value) is
new Ada.Finalization.Controlled with
record
K : Key_Access := null;
Containing_KVFlyweight : KVFlyweight_Ptr := null;
Containing_Bucket : Ada.Containers.Hash_Type;
Underlying_V : Value_Access := null;
end record;
overriding procedure Initialize (Object : in out Refcounted_Value_Ref);
overriding procedure Adjust (Object : in out Refcounted_Value_Ref);
overriding procedure Finalize (Object : in out Refcounted_Value_Ref);
end KVFlyweights.Refcounted_Ptrs;
|
houey/Amass | Ada | 8,409 | ads | -- Copyright 2017-2021 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
name = "Alterations"
type = "alt"
ldh_chars = "_abcdefghijklmnopqrstuvwxyz0123456789-"
function resolved(ctx, name, domain, records)
local nparts = split(name, ".")
local dparts = split(domain, ".")
-- Do not process resolved root domain names
if #nparts <= #dparts then
return
end
local cfg = config(ctx)
if (cfg.mode == "passive" or not cfg['alterations'].active) then
return
end
makenames(ctx, cfg.alterations, name)
end
function makenames(ctx, cfg, name)
local words = alt_wordlist(ctx)
if cfg['flip_words'] then
for i, n in pairs(flip_words(name, words)) do
local expired = sendnames(ctx, n)
if expired then
return
end
end
end
if cfg['flip_numbers'] then
for i, n in pairs(flip_numbers(name)) do
local expired = sendnames(ctx, n)
if expired then
return
end
end
end
if cfg['add_numbers'] then
for i, n in pairs(append_numbers(name)) do
local expired = sendnames(ctx, n)
if expired then
return
end
end
end
if cfg['add_words'] then
for i, n in pairs(add_prefix_word(name, words)) do
local expired = sendnames(ctx, n)
if expired then
return
end
end
for i, n in pairs(add_suffix_word(name, words)) do
local expired = sendnames(ctx, n)
if expired then
return
end
end
end
local distance = cfg['edit_distance']
if distance > 0 then
for i, n in pairs(fuzzy_label_searches(name, distance)) do
local expired = sendnames(ctx, n)
if expired then
return
end
end
end
end
function flip_words(name, words)
local s = {}
local parts = split(name, ".")
local hostname = parts[1]
local base = partial_join(parts, ".", 2, #parts)
parts = split(hostname, "-")
if #parts < 2 then
return s
end
local post = partial_join(parts, "-", 2, #parts)
for i, word in pairs(words) do
set_insert(s, word .. "-" .. post .. "." .. base)
end
local pre = partial_join(parts, "-", 1, #parts - 1)
for i, word in pairs(words) do
set_insert(s, pre .. "-" .. word .. "." .. base)
end
return set_elements(s)
end
function flip_numbers(name)
local parts = split(name, ".")
local hostname = parts[1]
local base = partial_join(parts, ".", 2, #parts)
local s = {}
local start = 1
while true do
local b, e = string.find(hostname, "%d+", start)
if b == nil then
break
end
start = e + 1
local pre = string.sub(hostname, 1, b - 1)
local post = string.sub(hostname, e + 1)
-- Create an entry with the number removed
set_insert(s, pre .. post .. "." .. base)
local seq = numseq(tonumber(string.sub(hostname, b, e)))
for i, sn in pairs(seq) do
set_insert(s, pre .. sn .. post .. "." .. base)
end
end
return set_elements(s)
end
function numseq(num)
local s = {}
local start = num - 50
if start < 1 then
start = 1
end
local max = num + 50
for i=start,max do
set_insert(s, tostring(i))
end
return set_elements(s)
end
function append_numbers(name)
local s = {}
local parts = split(name, ".")
local hostname = parts[1]
local base = partial_join(parts, ".", 2, #parts)
for i=0,9 do
set_insert(s, hostname .. tostring(i) .. "." .. base)
set_insert(s, hostname .. "-" .. tostring(i) .. "." .. base)
end
return set_elements(s)
end
function add_prefix_word(name, words)
local s = {}
local parts = split(name, ".")
local hostname = parts[1]
local base = partial_join(parts, ".", 2, #parts)
for i, w in pairs(words) do
set_insert(s, w .. hostname .. "." .. base)
set_insert(s, w .. "-" .. hostname .. "." .. base)
end
return set_elements(s)
end
function add_suffix_word(name, words)
local s = {}
local parts = split(name, ".")
local hostname = parts[1]
local base = partial_join(parts, ".", 2, #parts)
for i, w in pairs(words) do
set_insert(s, hostname .. w .. "." .. base)
set_insert(s, hostname .. "-" .. w .. "." .. base)
end
return set_elements(s)
end
function fuzzy_label_searches(name, distance)
local parts = split(name, ".")
local hostname = parts[1]
local base = partial_join(parts, ".", 2, #parts)
local s = {hostname}
for i=1,distance do
local tb = set_elements(s)
set_insert_many(s, additions(tb))
set_insert_many(s, deletions(tb))
set_insert_many(s, substitutions(tb))
end
local results = {}
for i, n in pairs(set_elements(s)) do
set_insert(results, n .. "." .. base)
end
return set_elements(results)
end
function additions(set)
local results = {}
local l = string.len(ldh_chars)
for x, name in pairs(set) do
local nlen = string.len(name)
for i=1,nlen do
for j=1,l do
local c = string.sub(ldh_chars, j, j)
local post = string.sub(name, i)
local pre = ""
if i > 1 then
pre = string.sub(name, 1, i - 1)
end
set_insert(results, pre .. c .. post)
end
end
end
return set_elements(results)
end
function deletions(set)
local results = {}
for x, name in pairs(set) do
local nlen = string.len(name)
for i=1,nlen do
local post = string.sub(name, i + 1)
local pre = ""
if i > 1 then
pre = string.sub(name, 1, i - 1)
end
set_insert(results, pre .. post)
end
end
return set_elements(results)
end
function substitutions(set)
local results = {}
local l = string.len(ldh_chars)
for x, name in pairs(set) do
local nlen = string.len(name)
for i=1,nlen do
for j=1,l do
local c = string.sub(ldh_chars, j, j)
local post = string.sub(name, i + 1)
local pre = ""
if i > 1 then
pre = string.sub(name, 1, i - 1)
end
set_insert(results, pre .. c .. post)
end
end
end
return set_elements(results)
end
function split(str, delim)
local result = {}
local pattern = "[^%" .. delim .. "]+"
local matches = find(str, pattern)
if (matches == nil or #matches == 0) then
return result
end
for i, match in pairs(matches) do
table.insert(result, match)
end
return result
end
function join(parts, sep)
local result = ""
for i, v in pairs(parts) do
result = result .. sep .. v
end
return result
end
function partial_join(parts, sep, first, last)
if (first < 1 or last > #parts) then
return ""
end
local result = parts[first]
first = first + 1
for i=first,last do
result = result .. sep .. parts[i]
end
return result
end
function set_insert(tb, name)
if name ~= "" then
tb[name] = true
end
return tb
end
function set_insert_many(tb, list)
if list == nil then
return tb
end
for i, v in pairs(list) do
tb[v] = true
end
return tb
end
function set_elements(tb)
local result = {}
if tb == nil then
return result
end
for k, v in pairs(tb) do
table.insert(result, k)
end
return result
end
function sendnames(ctx, content)
local names = find(content, subdomainre)
if names == nil then
return false
end
local found = {}
for i, v in pairs(names) do
if found[v] == nil then
local expired = newname(ctx, v)
if expired then
return expired
end
found[v] = true
end
end
return false
end
|
zhmu/ananas | Ada | 390 | adb | -- { dg-do compile }
-- { dg-options "-O -gnatws" }
with Pack22_Pkg; use Pack22_Pkg;
procedure Pack22 is
package Role_Map is new Bit_Map_Generic;
type Role_List is new Role_Map.List;
Roles_1 : Role_List;
Roles_2 : Role_List;
Roles_3 : Role_List;
begin
Temp_buffer := (others => 1);
Temp_Buffer(2) := (0);
Roles_1 := Roles_2 xor Roles_3;
end;
|
reznikmm/matreshka | Ada | 6,740 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Draw.Page_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Draw_Page_Element_Node is
begin
return Self : Draw_Page_Element_Node do
Matreshka.ODF_Draw.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Draw_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Draw_Page_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Enter_Draw_Page
(ODF.DOM.Draw_Page_Elements.ODF_Draw_Page_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Enter_Node (Visitor, Control);
end if;
end Enter_Node;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Draw_Page_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Page_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Draw_Page_Element_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Visitor in ODF.DOM.Visitors.Abstract_ODF_Visitor'Class then
ODF.DOM.Visitors.Abstract_ODF_Visitor'Class
(Visitor).Leave_Draw_Page
(ODF.DOM.Draw_Page_Elements.ODF_Draw_Page_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Leave_Node (Visitor, Control);
end if;
end Leave_Node;
----------------
-- Visit_Node --
----------------
overriding procedure Visit_Node
(Self : not null access Draw_Page_Element_Node;
Iterator : in out XML.DOM.Visitors.Abstract_Iterator'Class;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is
begin
if Iterator in ODF.DOM.Iterators.Abstract_ODF_Iterator'Class then
ODF.DOM.Iterators.Abstract_ODF_Iterator'Class
(Iterator).Visit_Draw_Page
(Visitor,
ODF.DOM.Draw_Page_Elements.ODF_Draw_Page_Access
(Self),
Control);
else
Matreshka.DOM_Elements.Abstract_Element_Node
(Self.all).Visit_Node (Iterator, Visitor, Control);
end if;
end Visit_Node;
begin
Matreshka.DOM_Documents.Register_Element
(Matreshka.ODF_String_Constants.Draw_URI,
Matreshka.ODF_String_Constants.Page_Element,
Draw_Page_Element_Node'Tag);
end Matreshka.ODF_Draw.Page_Elements;
|
zhmu/ananas | Ada | 203 | adb | with Generic_Inst9_Pkg1.Operator;
package body Generic_Inst9_Pkg2 is
package My_Operator is new Generic_Inst9_Pkg1.Operator (Bound_T);
procedure Dummy is begin null; end;
end Generic_Inst9_Pkg2;
|
AdaCore/training_material | Ada | 222 | adb | with Example; use Example;
with Strings; use Strings;
procedure Main is
S1 : constant String_T := From_String ("Hello ");
S2 : constant String_T := From_String ("World");
begin
Example.Example (S1, S2);
end Main;
|
BrickBot/Bound-T-H8-300 | Ada | 88,507 | adb | -- Arithmetic.Evaluation (body)
--
-- A component of the Bound-T Worst-Case Execution Time Tool.
--
-------------------------------------------------------------------------------
-- Copyright (c) 1999 .. 2015 Tidorum Ltd
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- 1. Redistributions of source code must retain the above copyright notice, this
-- list of conditions and the following disclaimer.
-- 2. Redistributions in binary form must reproduce the above copyright notice,
-- this list of conditions and the following disclaimer in the documentation
-- and/or other materials provided with the distribution.
--
-- 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.
--
-- Other modules (files) of this software composition should contain their
-- own copyright statements, which may have different copyright and usage
-- conditions. The above conditions apply to this file.
-------------------------------------------------------------------------------
--
-- $Revision: 1.19 $
-- $Date: 2015/10/24 20:05:44 $
--
-- $Log: arithmetic-evaluation.adb,v $
-- Revision 1.19 2015/10/24 20:05:44 niklas
-- Moved to free licence.
--
-- Revision 1.18 2013-02-05 20:19:00 niklas
-- Extended Value_Ref (Expr_Ref) to trace the resolved data reference,
-- optional on Options.General.Trace_Resolution.
--
-- Revision 1.17 2010-03-23 07:46:35 niklas
-- Updated Unary_Operation to use the new functions Truncate_Low/High.
--
-- Revision 1.16 2010-01-01 12:37:05 niklas
-- BT-CH-0209: Trace refinements from Combine_Terms.
--
-- Revision 1.15 2009-11-27 11:28:06 niklas
-- BT-CH-0184: Bit-widths, Word_T, failed modular analysis.
--
-- Revision 1.14 2009/02/13 19:07:33 niklas
-- Corrected Eval (Assignment, .., Target, ..) to check Value2, when
-- evaluated, for bounded dynamic references, instead of Value1.
--
-- Revision 1.13 2008/07/20 09:08:59 niklas
-- BT-CH-0138: Handling Relative value of resolved referent.
--
-- Revision 1.12 2008/06/20 10:11:52 niklas
-- BT-CH-0132: Data pointers using Difference (Expr, Cell, Bounds).
--
-- Revision 1.11 2008/06/18 20:52:55 niklas
-- BT-CH-0130: Data pointers relative to initial-value cells.
--
-- Revision 1.10 2007/10/04 19:48:51 niklas
-- BT-CH-0083: Resolving dynamic access to constant data.
--
-- Revision 1.9 2007/10/02 20:37:58 niklas
-- BT-CH-0080: One-bit bitwise Boolean arithmetic operators.
--
-- Revision 1.8 2007/07/26 11:08:52 niklas
-- BT-CH-0066. Fracture assignments.
--
-- Revision 1.7 2006/11/07 15:55:23 niklas
-- Corrected function Bitwise_Not to mask the negated value
-- to the word-size of the "not" operation. Otherwise the value
-- is not only (probably) incorrect but may overflow the range
-- of Processor.Value_T for no good reason.
--
-- Revision 1.6 2006/10/14 13:52:14 niklas
-- Corrected Binary_Operation.Bitwise_Xor, when one operand is
-- all 1's, to use the new function Bitwise_Xor_Ones which knows
-- that the original expression is a binary one while the residual
-- expression is a unary operation. This replaces the wrong use
-- of Binary_Not which assumes that the original expression is
-- a unary "not" and raises constraint-error otherwise.
-- Added the function Unary_Residual_From_Binary to make a unary
-- residual from a binary operation with one remaining non-constant
-- operand.
--
-- Revision 1.5 2006/05/06 06:59:18 niklas
-- BT-CH-0021.
--
-- Revision 1.4 2006/02/27 09:59:47 niklas
-- Extended function Residual (Result_T) to further simplify the
-- residual expression by combining similar terms, including
-- constant cell values from the evaluation domain.
--
-- Revision 1.3 2005/02/16 21:11:36 niklas
-- BT-CH-0002.
--
-- Revision 1.2 2004/08/09 19:51:25 niklas
-- BT-CH-0001.
--
-- Revision 1.1 2004/04/25 16:54:26 niklas
-- First version.
--
with Arithmetic.Algebra;
with Arithmetic.Evaluation.Opt;
with Options.General;
with Output;
with Storage;
package body Arithmetic.Evaluation is
use type Value_T;
use type Width_T;
--
--- Levels of evaluation
--
function Signed_Value (Item : Known_Cell_Value_T) return Value_T
is
begin
return Signed_Value (Word => Item.Value, Width => Item.Width);
end Signed_Value;
function Image (Item : Cell_Value_T) return String
is
begin
case Item.Level is
when Unknown =>
return Unknown_Image;
when Variable =>
return Variable_Image;
when Relative =>
if Item.Offset >= 0 then
return Storage.Image (Item.Base) & '+' & Image (Item.Offset);
else
return Storage.Image (Item.Base) & Image (Item.Offset);
end if;
when Known =>
return Image (
Item => Item.Value,
Width => Item.Width,
Signed => Item.Signed);
end case;
end Image;
function To_Value (
Word : Word_T;
Width : Width_T;
Signed : Boolean)
return Cell_Value_T
is
begin
return (
Level => Known,
Value => Word and Max_Word (Width),
Width => Width,
Signed => Signed);
end To_Value;
function Width_Of (Item : Result_T) return Width_T
is
begin
return Width_Of (Item.Expr);
end Width_Of;
function Signed_Value (Item : Known_Result_T) return Value_T
is
begin
return Signed_Value (
Word => Item.Value,
Width => Item.Expr.Width);
end Signed_Value;
function Image (Item : Result_T) return String
is
Pref : constant String :=
Level_T'Image (Item.Level)
& ", "
& Image (Item.Expr)
& ", rb "
& Boolean'Image (Item.Ref_Bounded);
begin
case Item.Level is
when Unknown | Variable =>
return Pref;
when Relative =>
return Pref
& " = "
& Storage.Image (Item.Base)
& " + "
& Image (Item.Offset);
when Known =>
return Pref
& " ="
& Image (
Item => Item.Value,
Width => Width_Of (Item),
Signed => Item.Signed);
end case;
end Image;
function Image (Item : Target_Result_T) return String
is
Prefix : constant String :=
Target_Level_T'Image (Item.Level)
& ", rb "
& Boolean'Image (Item.Ref_Bounded)
& ", source "
& Image (Item.Source);
begin
case Item.Level is
when Dynamic_Ref =>
return Prefix & ", ref " & Storage.References.Image (Item.Ref.all);
when Known_Cell =>
return Prefix & ", cell " & Storage.Image (Item.Cell);
end case;
end Image;
function Image (Item : Assignment_Result_T) return String
is
Prefix : constant String :=
Defining_Kind_T'Image (Item.Kind)
& ", target "
& Image (Item.Target)
& "; refined "
& Boolean'Image (Item.Refined)
& ", rb "
& Boolean'Image (Item.Ref_Bounded)
& ", value "
& Image (Item.Value);
begin
case Item.Kind is
when Regular | Fracture =>
return Prefix;
when Conditional =>
return Prefix
& ", if ("
& Image (Item.Cond)
& ") then ("
& Image (Item.Value1)
& ") else ("
& Image (Item.Value2);
end case;
end Image;
--
--- Creating results and residual expressions
--
function Fuzzy_Cond_Level (
Cond : Unk_Var_T;
Value1 : Level_T;
Value2 : Level_T)
return Unk_Var_T
--
-- The evaluation level of a conditional expression where the
-- condition value is not (yet) Known and the two alternative
-- expressions have either Known or Fuzzy levels and are not
-- known to be the same expression or have the same value (so
-- the result strictly depends on the condition).
--
is
begin
case Cond is
when Unknown =>
-- The condition is yet Unknown.
if Value1 = Variable and Value2 = Variable then
-- Whatever the condition turns out to be, the
-- final result must be variable.
return Variable;
else
-- One of the alternative expressions is Unknown,
-- Relative or Known, not Variable, and we may still
-- find out later which alternative is chosen.
return Unknown;
end if;
when Variable =>
-- The condition itself is already considered variable,
-- so we must consider both alternatives.
if Value1 = Variable or Value2 = Variable then
-- Variability is and will remain a possible choice.
return Variable;
elsif Value1 = Unknown or Value2 = Unknown then
-- One alternative is Known or Relative, and the other
-- is Unknown. The Unknown alternative may become Known or
-- Relative and found to equal the other alternative, so
-- there is still some (slight) hope that the result
-- can be Known or Relative.
return Unknown;
else
-- Both alternatives are Known or Relative, but different,
-- so we have variation between (at least) two values.
return Variable;
end if;
end case;
end Fuzzy_Cond_Level;
function Result (
Value : Word_T;
Signed : Boolean;
Source : Expr_Ref;
Ref_Bounded : Boolean)
return Result_T
--
-- A constant result Value, evaluated from a Source expression,
-- which may be hinted to be Signed.
--
is
Refined : constant Boolean := Source.Kind /= Const;
begin
if Refined and Opt.Trace_Refinement_Path then
Output.Trace (
"Source expression "
& Image (Source)
& " refined to constant "
& Image (
Item => Value,
Width => Width_Of (Source),
Signed => Signed));
end if;
return (
Level => Known,
Expr => Source,
Refined => Refined,
Ref_Bounded => Ref_Bounded,
Value => Value,
Signed => Signed);
end Result;
function Result (
Base : Storage.Cell_T;
Offset : Value_T;
Source : Expr_Ref;
Refined : Boolean;
Ref_Bounded : Boolean)
return Result_T
--
-- A result of the form Base + Offset, evaluated from a Source
-- expression.
--
is
begin
if Refined and Opt.Trace_Refinement_Path then
Output.Trace (
"Source expression "
& Image (Source)
& " refined to relative "
& Storage.Image (Base)
& " + "
& Image (Offset));
end if;
return (
Level => Relative,
Expr => Source,
Refined => Refined,
Ref_Bounded => Ref_Bounded,
Base => Base,
Offset => Offset);
end Result;
function Result (
Expr : Expr_Ref;
Level : Unk_Var_T;
Refined : Boolean;
Ref_Bounded : Boolean)
return Result_T
--
-- A non-constant, non-relative expression result.
--
is
begin
case Level is
when Unknown =>
if Refined and Opt.Trace_Refinement_Path then
Output.Trace (
"Source expression "
& Image (Expr)
& " refined to unknown value.");
end if;
return (
Level => Unknown,
Expr => Expr,
Refined => Refined,
Ref_Bounded => Ref_Bounded);
when Variable =>
if Refined and Opt.Trace_Refinement_Path then
Output.Trace (
"Source expression "
& Image (Expr)
& " refined to variable value.");
end if;
return (
Level => Variable,
Expr => Expr,
Refined => Refined,
Ref_Bounded => Ref_Bounded);
end case;
end Result;
function Result (
Expr : Expr_Ref;
Only : Result_T;
Other : Result_T)
return Result_T
--
-- A result that is refined to Only one of two operands in the
-- source Expression and does not depend on the Other operand.
-- However, the result shows if the evaluation of the Other
-- operand has bounded any references in the Other operand (or
-- in the Only operand).
--
-- This function is useful when the result of a binary operation is
-- just one of its operands (for example, x + 0 = x), but we still
-- want to record if some dynamic references were bounded in the
-- other operand, and also that the result is a refined expression.
--
is
Res : Result_T := Only;
-- The result to be.
begin
Res.Refined := True;
Res.Ref_Bounded := Res.Ref_Bounded or Other.Ref_Bounded;
if Opt.Trace_Refinement_Path then
Output.Trace (
"Source expression "
& Image (Expr)
& " refined to operand "
& Image (Only));
end if;
return Res;
end Result;
function "=" (Left : Result_T; Right : Word_T)
return Boolean
--
-- Whether the Left operand is a constant and equal to Right.
--
is
begin
return Left.Level = Known and then Left.Value = Right;
end "=";
function Same (Left, Right : Result_T) return Boolean
is
begin
if Left.Level = Known and Right.Level = Known then
-- We can compare the known values, not expressions.
return Left.Value = Right.Value;
else
return Left = Right;
-- For two Relative results we compare the Base cells
-- and the Offset values. This is safe and rather exact,
-- giving a false negative only if the Base cells are
-- different but their initial values are such as to make
-- the same Base + Offset, which is rather out of the model.
--
-- For Unknown and Variable results we compare only
-- expressions (and levels). This is safe but very
-- conservative.
end if;
end Same;
function Value_Of (Result : Result_T) return Cell_Value_T
is
begin
case Result.Level is
when Unknown =>
return (Level => Unknown);
when Variable =>
return (Level => Variable);
when Relative =>
return (
Level => Relative,
Base => Result.Base,
Offset => Result.Offset);
when Known =>
return (
Level => Known,
Value => Result.Value,
Width => Width_Of (Result),
Signed => Result.Signed);
end case;
end Value_Of;
function To_Condition (Result : Result_T) return Condition_T
is
begin
case Result.Level is
when Fuzzy_Level_T =>
return Result.Expr;
when Known =>
if Result.Value in Bit_T then
return Boolean_Cond(Result.Value);
else
Output.Fault (
Location => "Arithmetic.Evaluation.To_Condition",
Text =>
"Non-boolean value"
& Output.Field_Separator
& Image (Result.Expr)
& " = "
& Image (Result.Value));
return Arithmetic.Unknown;
end if;
end case;
end To_Condition;
function Residual (
From : Expr_Ref;
Operand : Result_T;
Partly : Boolean)
return Result_T
--
-- Residual expression From a unary-operation expression, with
-- the single operand evaluated, but to an Operand expression
-- (rather than to a Known constant value).
--
-- The original expression is returned if partial evaluation
-- is inhibited by Partly = False, or if the evaluation of
-- the Operand had no effect on it.
--
is
Residual_Level : Level_T;
-- The level of the residual expression.
begin
case Fuzzy_Level_T (Operand.Level) is
when Unk_Var_T =>
-- A unary operation on an Unknown value yields Unknown,
-- and ditto for a Variable value.
Residual_Level := Operand.Level;
when Relative =>
-- This unary operation on a Relative value is taken to
-- give a Variable result, since we have not handled this
-- operation-operand combination specifically.
Residual_Level := Variable;
end case;
if Partly and Operand.Refined then
-- The operand was partially evaluated and changed
-- into a residual expression that differs substantially
-- from the original. Also, partial evaluation is allowed.
-- We make a new expression that has the same unary operator
-- and result-width, but the residual Operand:
return Result (
Expr => Unary (
Operation => From.Unary,
Operand => Residual (Operand),
Width => From.Width),
Level => Residual_Level,
Refined => Operand.Refined,
Ref_Bounded => Operand.Ref_Bounded);
else
-- Partial evaluation not allowed, or had no significant
-- effect on the operand.
--
-- Return the original expression but with new level
-- information from the Operand:
return Result (
Expr => From,
Level => Residual_Level,
Refined => False,
Ref_Bounded => Operand.Ref_Bounded);
end if;
end Residual;
function Fuzzier (Left, Right : Level_T) return Level_T
--
-- The less known level of the binary operation that combines
-- the Left and Right operands, in the general case (ie.
-- special cases like x*1 = x are not included).
--
is
Min : constant Level_T := Level_T'Min (Left, Right);
begin
if Min = Relative then
-- The combinations of Relative and Known values that
-- yield Relative or Known values are considered special
-- cases.
return Variable;
else
return Min;
end if;
end Fuzzier;
function Residual (
From : Expr_Ref;
Op : Binary_Op_T;
Left : Result_T;
Right : Result_T;
Partly : Boolean)
return Result_T
--
-- Residual binary expression From a binary or ternary operation
-- expression with the given (residual) binary Op, with Left and
-- Right operands evaluated, but in which one or both of the two
-- operands was evaluated to an expression (rather than both to
-- constants) and for which no special case such as x*1 = x applies.
-- In this case the result of the expression depends strictly on
-- both the (residual) operands, in so far as we know.
--
-- The original (binary or ternary) expression is returned if
-- partial evaluation is inhibited by Partly = False, or if the
-- evaluation of the operands had no effect on them.
--
is
New_Level : constant Level_T := Fuzzier (Left.Level, Right.Level);
-- The combined evaluation level.
Refs_Bounded : constant Boolean :=
Left.Ref_Bounded or Right.Ref_Bounded;
-- Whether some dynamic references were bounded, Left or Right.
begin
if Partly
and then (
Left.Refined
or Right.Refined
or From.Kind /= Binary_Kind)
then
-- One or both operands were partially evaluated and
-- changed into a residual expression that differs
-- substantially from the original, or a ternary
-- operation is refined to a binary operation since the
-- third operand (not visible here) was eliminated.
-- Also, partial evaluation (refining) is allowed.
--
-- We make a new, refined expression that has the same
-- operator (or the binary operator equivalent to the
-- original ternary one) but the residual operands:
return Result (
Expr => Binary (
Operation => Op,
Left => Residual (Left ),
Right => Residual (Right),
Width => From.Width),
Level => New_Level,
Refined => True,
Ref_Bounded => Refs_Bounded);
else
-- Partial evaluation not allowed, or had no significant
-- effect on any operand (binary or ternary).
-- Return the original expression but with new level
-- information from the operands:
return Result (
Expr => From,
Level => New_Level,
Refined => False,
Ref_Bounded => Refs_Bounded);
end if;
end Residual;
function Residual (
From : Expr_Ref;
Left : Result_T;
Right : Result_T;
Carry : Result_T;
Partly : Boolean)
return Result_T
--
-- Residual expression From a ternary operation expression, with
-- Left, Right, and Carry operands evaluated, but in which one or
-- more operand was evaluated to an expression (rather than
-- all to constants) and for which no special case such as
-- x*1 = x applies. In this case the result of the expression
-- depends strictly on all the operands, in so far as we know.
--
-- The original expression is returned if partial evaluation
-- is inhibited by Partly = False, or if the evaluation of
-- the operands had no effect on them.
--
is
New_Level : constant Level_T :=
Fuzzier (Left.Level, Fuzzier (Right.Level, Carry.Level));
-- The combined evaluation level.
Refs_Bounded : constant Boolean :=
Left.Ref_Bounded
or Right.Ref_Bounded
or Carry.Ref_Bounded;
-- Whether some dynamic references were bounded in
-- some operand.
Residue : Expr_T;
-- The residual expression, if not the same as From.
Rez : Result_T; -- TBM, debug
begin
if Partly
and then (Left.Refined or Right.Refined or Carry.Refined)
then
-- One or more operands were partially evaluated into
-- residual expressions that differ substantially from the
-- originals. Also, partial evaluation (refining) is allowed.
-- Thus we make a new (refined) expression that has the same
-- operator but the residual operands:
Residue := From.all;
Residue.L3_Expr := Residual (Left );
Residue.R3_Expr := Residual (Right);
Residue.C3_Expr := Residual (Carry);
Rez := Result (
Expr => new Expr_T'(Residue),
Level => New_Level,
Refined => True,
Ref_Bounded => Refs_Bounded);
return Rez;
else
-- Partial evaluation not allowed, or had no significant
-- effect on any operand, so this expression is not refined.
-- Return the original expression but with new level
-- information from the operands:
return Result (
Expr => From,
Level => New_Level,
Refined => False,
Ref_Bounded => Refs_Bounded);
end if;
end Residual;
function Unary_Residual_From_Binary (
From : Expr_Ref;
Operand : Result_T;
Other : Result_T;
Unary_Op : Unary_Op_T;
Partly : Boolean)
return Result_T
--
-- Residual unary expression From a binary-operation expression
-- where one Operand was evaluated to an expression (rather than
-- to a constant value) and the Other operand was evaluated "away"
-- (to a constant result). The remaining non-constant Operand becomes
-- the single operand of the residual Unary_Op expression.
--
-- There are not many binary operations that turn into a unary
-- operation when one operand is a constant. One case is a bitwise
-- "xor" when the constant operand is all ones (2#11..1#) which
-- turns into a bitwise "not" of the remaining operand.
--
-- The original expression is returned if partial evaluation
-- is inhibited by Partly = False.
--
is
New_Level : constant Level_T := Level_T'Min (Operand.Level, Other.Level);
-- The combined evaluation level.
Refs_Bounded : constant Boolean :=
Operand.Ref_Bounded or Other.Ref_Bounded;
-- Whether some dynamic references were bounded in
-- either operand of the original binary expression.
begin
if Partly then
-- Form the partially evaluated residual expression
-- with the remaining (non-constant) operand, whether or
-- not the remaining operand was refined by the evaluation.
return Result (
Expr => Unary (
Operation => Unary_Op,
Operand => Residual (Operand),
Width => From.Width),
Level => New_Level,
Refined => True,
Ref_Bounded => Refs_Bounded);
else
-- Partial evaluation not allowed.
-- Return the original expression but with new level
-- information from the two operands:
return Result (
Expr => From,
Level => New_Level,
Refined => False,
Ref_Bounded => Refs_Bounded);
end if;
end Unary_Residual_From_Binary;
--
--- Bitwise logical expressions
--
function ">=" (Left : Result_T; Right : Width_T)
return Boolean
--
-- Whether the Left operand is a constant and greater than
-- or equal to the number of bits, Right.
--
is
begin
return Left.Level = Known and then Left.Value >= Word_T (Right);
end ">=";
--
--- Evaluation domains (sources of cell values)
--
-- overriding
function Interval (Cell : Cell_T; Under : Domain_T)
return Storage.Bounds.Interval_T
is
Val : constant Cell_Value_T := Value_Of (
Cell => Cell,
Within => Domain_T'Class (Under));
-- What the domain tells us about the value.
begin
case Val.Level is
when Fuzzy_Level_T =>
return Storage.Bounds.Universal_Interval;
when Known =>
return Storage.Bounds.Singleton (Signed_Value (Val));
end case;
end Interval;
-- overriding
function Difference (To, From : Cell_T; Under : Domain_T)
return Storage.Bounds.Interval_T
is
use type Storage.Cell_T;
To_Val : constant Cell_Value_T := Value_Of (
Cell => To,
Within => Domain_T'Class (Under));
From_Val : constant Cell_Value_T := Value_Of (
Cell => From,
Within => Domain_T'Class (Under));
--
-- What the domain tells us of the values of the To
-- and From cells.
begin
if To_Val.Level = Known
and From_Val.Level = Known
then
return Storage.Bounds.Singleton (
Signed_Value (To_Val) - Signed_Value (From_Val));
elsif ( To_Val.Level = Relative
and From_Val.Level = Relative)
and then To_Val.Base = From_Val.Base
then
return Storage.Bounds.Singleton (To_Val.Offset - From_Val.Offset);
else
return Interval (
Expr => Expr (To) - Expr (From),
Under => Domain_T'Class (Under));
--
-- TBM this leaks an Expr_T object.
end if;
end Difference;
-- overriding
function Interval (Expr : Expr_Ref; Under : Domain_T)
return Storage.Bounds.Interval_T
is
Val : constant Result_T := Eval (
Expr => Expr,
Within => Domain_T'Class (Under),
Partly => False);
-- The value of the Expression, Under this domain.
begin
case Val.Level is
when Fuzzy_Level_T =>
return Storage.Bounds.Universal_Interval;
when Known =>
return Storage.Bounds.Singleton (Signed_Value (Val));
end case;
end Interval;
-- overriding
function Difference (
To : Expr_Ref;
From : Storage.Cell_T;
Under : Domain_T)
return Storage.Bounds.Interval_T
is
use type Storage.Cell_T;
From_Val : constant Cell_Value_T := Value_Of (
Cell => From,
Within => Domain_T'Class (Under));
--
-- What the domain tells us of the values of the From cell.
To_Res : constant Result_T :=
Eval (Expr => To, Within => Under, Partly => False);
-- The result of evaluating To, Under this domain.
begin
if To_Res.Level = Known
and From_Val.Level = Known
then
return Storage.Bounds.Singleton (
Signed_Value (To_Res) - Signed_Value (From_Val));
elsif ( To_Res.Level = Relative
and From_Val.Level = Relative)
and then To_Res.Base = From_Val.Base
then
return Storage.Bounds.Singleton (To_Res.Offset - From_Val.Offset);
else
-- Some more heterogeneus combination of To_Res, From_Val.
-- We may hope to that the complexity cancels out in
-- the difference expression.
return Interval (
Expr => To - Expr (From),
Under => Domain_T'Class (Under));
--
-- TBM this leaks an Expr_T object.
end if;
end Difference;
--
--- Evaluation of expressions and assignments within a domain
--
function Bitwise_Xor_Ones (
Expr : Expr_Ref;
Operand : Result_T;
Other : Result_T;
Partly : Boolean)
return Result_T
--
-- Evaluates a bit-wise exclusive-or ("xor") operation (Expr) where
-- the Other operand is an all-ones word (2#11...11#), which means
-- that the operation simply negates the remaining Operand.
-- The Partly parameter has the same role as in the function Eval.
--
is
Refs_Bounded : constant Boolean :=
Operand.Ref_Bounded or Other.Ref_Bounded;
-- Whether some dynamic references were bounded in
-- either operand of the original Xor expression.
begin
if Operand.Level = Known then
-- We can compute the final value.
return Result (
Value => (not Operand.Value) and Max_Word (Expr.Width),
Signed => False,
Ref_Bounded => Refs_Bounded,
Source => Expr);
else
-- We have a bitwise-not as the residual expression.
return Unary_Residual_From_Binary (
From => Expr,
Operand => Operand,
Other => Other,
Unary_Op => Notw,
Partly => Partly);
end if;
end Bitwise_Xor_Ones;
function Unary_Operation (
Expr : Expr_Ref;
Op : Unary_Op_T;
Operand : Result_T;
Partly : Boolean)
return Result_T
--
-- Evaluates a unary operation (Expr with Unary = Op) on its sole
-- Operand expressed as a Result_T object and returns the value
-- as a Result_T. The Partly parameter has the same role as
-- in the function Eval.
--
is
Value : Word_T;
-- The result of evaluating the operation on a known operand.
begin
if Operand.Level /= Known then
-- Nothing we can do.
return Residual (
From => Expr,
Operand => Operand,
Partly => Partly);
else
-- The operand value is known, so we can evaluate
-- the operation.
case Op is
when Notw =>
Value := (not Operand.Value) and Max_Word (Expr.Width);
when Notx =>
if Operand.Value in Bit_T then
Value := (not Operand.Value) and 1;
else
Output.Fault (
Location => "Arithmetic.Evaluation.Unary_Operation",
Text => "Logical negation of " & Image (Operand.Value));
Value := Operand.Value;
end if;
when EqZero =>
Value := Boolean_Value (Operand.Value = 0);
when EqOne =>
Value := Boolean_Value (Operand.Value = 1);
when Signw =>
Value := Boolean_Value (
Negative (Operand.Value, Width_Of (Operand)));
when Exts =>
Value := Sign_Extend (
Value => Operand.Value,
From => Width_Of (Operand),
To => Expr.Width);
when Extz =>
Value := Zero_Extend (
Value => Operand.Value,
From => Width_Of (Operand));
when Trunl =>
Value := Truncate_Low (
Value => Operand.Value,
To => Expr.Width);
when Trunh =>
Value := Truncate_High (
Value => Operand.Value,
From => Width_Of (Operand),
To => Expr.Width);
end case;
return Result (
Value => Value,
Signed => Width_Of (Expr) > 1
and then Operand.Signed,
Source => Expr,
Ref_Bounded => Operand.Ref_Bounded);
end if;
end Unary_Operation;
function Binary_Operation (
Expr : Expr_Ref;
Op : Binary_Op_T;
Left : Result_T;
Right : Result_T;
Partly : Boolean)
return Result_T
--
-- Evaluates a binary operation (Expr with Kind Op) on its Left
-- and Right operands expressed as Result_T objects and returns
-- the value as a Result_T. The Partly parameter has the same
-- role as in the function Eval. The Expr expression may also
-- be a ternary expression in which one operand has been evaluated
-- to a constant and eliminated, converting the Expr to the
-- equivalent binary expression Left Op Right.
--
is
use type Storage.Cell_T;
Width : constant Width_T := Expr.Width;
-- The width of the result, and usually also of Left and Right.
Both_Known : constant Boolean :=
Left.Level = Known and Right.Level = Known;
-- Whether both operands were evaluated to constants so that
-- we can concretely execute the Op on the operand values.
Refs_Bounded : constant Boolean :=
Left.Ref_Bounded or Right.Ref_Bounded;
-- Whether some references were bounded, Left or Right.
procedure Warn_If_Overflow (L, R, Value : Word_T)
--
-- Warns if the Op on known Left and Right operand values
-- causes overflow so that the resulting Value (not yet
-- limited to this Width) will be wrapped.
--
is
Overflow : Word_T;
-- Whether (we know that) there is overflow.
begin
case Op is
when Plus => Overflow := Overflow_From_Plus (L, R, Width);
when Minus => Overflow := Overflow_From_Minus (L, R, Width);
-- For other operations, we do not check:
when others => Overflow := 0;
end case;
if Overflow /= 0
or Value > Max_Word (Width)
then
Output.Warning (
"Overflow in"
& Width_T'Image (Width)
& "-bit expression "
& Image (Expr)
& " with operands "
& Image (L)
& " and "
& Image (R)
& " giving "
& Image (Value and Max_Word (Width)));
end if;
end Warn_If_Overflow;
function Op_On_Known (L, R : Word_T) return Result_T
--
-- The result of Op on known Left and Right operand values.
--
is
Value : Word_T;
-- The value of the result.
begin
case Op is
when Plus => Value := L + R;
when Minus => Value := L - R;
when Mulu => Value := Mulu (L, R, Width);
when Muls => Value := Muls (L, R, Width);
when Plus_C => Value := Carry_From_Plus (L, R, Width_Of (Left));
when Plus_N => Value := Negative_From_Plus (L, R, Width_Of (Left));
when Plus_V => Value := Overflow_From_Plus (L, R, Width_Of (Left));
when Minus_B => Value := Borrow_From_Minus (L, R, Width_Of (Left));
when Minus_C => Value := Carry_From_Minus (L, R, Width_Of (Left));
when Minus_N => Value := Negative_From_Minus (L, R, Width_Of (Left));
when Minus_V => Value := Overflow_From_Minus (L, R, Width_Of (Left));
when Eq => Value := Boolean_Value (L = R);
when Lts => Value := Boolean_Value (Lts (L, R, Width_Of (Left)));
when Gts => Value := Boolean_Value (Gts (L, R, Width_Of (Left)));
when Les => Value := Boolean_Value (Les (L, R, Width_Of (Left)));
when Ges => Value := Boolean_Value (Ges (L, R, Width_Of (Left)));
when Ltu => Value := Boolean_Value (L < R);
when Gtu => Value := Boolean_Value (L > R);
when Leu => Value := Boolean_Value (L <= R);
when Geu => Value := Boolean_Value (L >= R);
when Andx => Value := Bit_T (L and R);
when Orx => Value := Bit_T (L or R);
when Andw => Value := L and R;
when Orw => Value := L or R;
when Xorw => Value := L xor R;
when Slz =>
Value := Shift_Left (
Value => L,
Amount => Natural (Word_T'Min (R, Word_T (Width))),
Width => Width);
when Srz =>
Value := Shift_Right (
Value => L,
Amount => Natural (Word_T'Min (R, Word_T (Width))),
Width => Width_Of (Left));
when Sra =>
Value := Shift_Right_Arithmetic (
Value => L,
Amount => Natural (Word_T'Min (R, Word_T (Width))),
Width => Width_Of (Left));
when Rotl =>
Value := Rotate_Left (
Value => L,
Amount => Natural (R mod Word_T (Width)),
Width => Width);
when Rotr =>
Value := Rotate_Right (
Value => L,
Amount => Natural (R mod Word_T (Width)),
Width => Width);
when Conc =>
Value :=
Shift_Left (
Value => L,
Amount => Natural (Width_Of (Right)),
Width => Width)
or (R and Max_Word (Width_Of (Right)));
end case;
if Opt.Warn_Overflow then
Warn_If_Overflow (L, R, Value);
end if;
return Result (
Value => Value and Max_Word (Width),
Signed => Width > 1
and then (Left.Signed or Right.Signed),
Source => Expr,
Ref_Bounded => Refs_Bounded);
end Op_On_Known;
function Residue return Result_T
--
-- The residual expression, if needed.
--
is
begin
return Residual (
From => Expr,
Op => Op,
Left => Left,
Right => Right,
Partly => Partly);
end Residue;
-- The following functions are used when at least one of
-- the operands, Left and Right, is not Known. These functions
-- check for special cases in which the result is still known,
-- or where the expression can be simplified to depend only
-- on one of the operands.
function Only_Left return Result_T
--
-- The result is only the Left operand.
--
is
begin
return Result (
Expr => Expr,
Only => Left,
Other => Right);
end Only_Left;
function Only_Right return Result_T
--
-- The result is only the Right operand.
--
is
begin
return Result (
Expr => Expr,
Only => Right,
Other => Left);
end Only_Right;
function Product return Result_T
--
-- Evaluates a multiplication (Mulu or Muls) operation.
--
is
begin
if Left = 0 or Right = 0 then
-- Zero times x = zero, for all x.
return Result (
Value => Word_T'(0),
Signed => Op = Muls,
Source => Expr,
Ref_Bounded => Refs_Bounded);
elsif Left = 1 then
-- One times x = x, for all x.
return Only_Right;
elsif Right = 1 then
-- X times one = x, for all x.
return Only_Left;
else
return Residue;
end if;
end Product;
function Sum return Result_T
--
-- Evaluates an addition (Plus) operation.
--
is
begin
if Left = 0 then
-- Zero plus x = x, for all x.
return Only_Right;
elsif Right = 0 then
-- X plus zero = x, for all x.
return Only_Left;
elsif Left.Level = Relative
and Right.Level = Known
then
-- Adding more offset to a relative value.
-- This is not itself considered a refinement because it
-- happens for every expression of the form base-cell + constant
-- and so refinement would not terminate.
return Result (
Base => Left.Base,
Offset => Left.Offset
+ Signed_Value (Right),
Source => Expr,
Refined => Left.Refined or Right.Refined,
Ref_Bounded => Refs_Bounded);
elsif Right.Level = Relative
and Left.Level = Known
then
-- Ditto, the other way around.
-- Not itself considered a refinement; see above.
return Result (
Base => Right.Base,
Offset => Right.Offset
+ Signed_Value (Left),
Source => Expr,
Refined => Left.Refined or Right.Refined,
Ref_Bounded => Refs_Bounded);
else
return Residue;
end if;
end Sum;
function Difference return Result_T
--
-- Evaluates a subtraction (Minus) operation.
--
is
begin
-- TBA when we add an "invert sign" op:
-- if Left = 0 then
--
-- return Invert_Sign (Right);
if Right = 0 then
-- X minus zero = x, for all x.
return Only_Left;
elsif Left = Right then
-- X minus x = zero, for all x.
-- Perhaps too special a case: same expression.
return Result (
Value => Word_T'(0),
Signed => False,
Source => Expr,
Ref_Bounded => Refs_Bounded);
elsif Left.Level = Relative
and Right.Level = Known
then
-- Subtracting some offset from a relative value.
-- Not itself considered a refinement; see above in
-- the function Sum.
return Result (
Base => Left.Base,
Offset => Left.Offset
- Signed_Value (Right),
Source => Expr,
Refined => Left.Refined or Right.Refined,
Ref_Bounded => Refs_Bounded);
elsif ( Left.Level = Relative
and Right.Level = Relative)
and then Left.Base = Right.Base
then
-- Difference between two offsets from the same Base.
return Result (
Value => Unsigned_Word (Left.Offset - Right.Offset, Width),
Signed => True,
Source => Expr,
Ref_Bounded => Refs_Bounded);
else
return Residue;
end if;
end Difference;
function Relation (Equal : Boolean) return Result_T
--
-- Common evaluation of all relational operators, with
-- Equal giving the result in case Left = Right.
--
is
begin
if Left = Right then
return Result (
Value => Boolean_Value(Equal),
Signed => False,
Source => Expr,
Ref_Bounded => Refs_Bounded);
else
return Residue;
end if;
end Relation;
procedure Report_Many_Bits
--
-- Reports the fault that the width of a Boolean expression
-- is more than one bit.
--
is
begin
Output.Fault (
Location => "Arithmetic.Evaluation.Binary_Operation",
Text =>
"Boolean operation width is"
& Width_T'Image (Width)
& Output.Field_Separator
& Image (Expr));
end Report_Many_Bits;
function Bitwise_And return Result_T
--
-- Evaluates a bit-wise conjunction ("and") operation.
--
is
begin
if Left = 0 or Right = 0 then
-- Zero and x = x and zero = zero, for all x.
return Result (
Value => Word_T'(0),
Signed => False,
Source => Expr,
Ref_Bounded => Refs_Bounded);
elsif Left = Max_Word (Width) then
-- "All ones" and x = x, for all x.
return Only_Right;
elsif Right = Max_Word (Width) then
-- X and "all ones" = x, for all x.
return Only_Left;
elsif Left = Right then
-- X and x = x, for all x.
return Only_Left;
else
return Residue;
end if;
end Bitwise_And;
function Bitwise_Or return Result_T
--
-- Evaluates a bit-wise disjunction ("or") operation.
--
is
begin
if Left = Max_Word (Width)
or Right = Max_Word (Width)
then
-- "All ones" or x = x or "all ones" = "all ones", for all x.
return Result (
Value => Max_Word (Width),
Signed => False,
Source => Expr,
Ref_Bounded => Refs_Bounded);
elsif Left = 0 then
-- Zero or x = x, for all x.
return Only_Right;
elsif Right = 0 then
-- X or zero = x, for all x.
return Only_Left;
elsif Left = Right then
-- X or x = x, for all x.
return Only_Left;
else
return Residue;
end if;
end Bitwise_Or;
function Bitwise_Xor return Result_T
--
-- Evaluates a bit-wise exclusive disjunction ("xor") operation.
--
is
begin
if Left = Max_Word (Width) then
-- "All ones" xor x = not x, for all x.
return Bitwise_Xor_Ones (
Expr => Expr,
Operand => Right,
Other => Left,
Partly => Partly);
elsif Right = Max_Word (Width) then
-- X xor "all ones" = not x, for all x.
return Bitwise_Xor_Ones (
Expr => Expr,
Operand => Left,
Other => Right,
Partly => Partly);
elsif Left = 0 then
-- Zero xor x = x, for all x.
return Only_Right;
elsif Right = 0 then
-- X xor zero = x, for all x.
return Only_Left;
elsif Left = Right then
-- X xor x = zero, for all x.
return Result (
Value => Word_T'(0),
Signed => False,
Source => Expr,
Ref_Bounded => Refs_Bounded);
else
return Residue;
end if;
end Bitwise_Xor;
function Shift_Left_Z return Result_T
--
-- Evaluates a shift left, zero fill (Slz).
-- The Left operand is the value to be shifted, the Right
-- operand is the amount of shift (number of bits).
--
is
begin
if Left = 0
or else Right >= Width
then
-- Shifting left a zero for any number of bits, or
-- shifting left any value for at least its width (with
-- zero fill) both result in zero.
return Result (
Value => Word_T'(0),
Signed => False,
Source => Expr,
Ref_Bounded => Refs_Bounded);
elsif Right = 0 then
-- Shifting any value for zero bits leaves the same value.
return Only_Left;
else
return Residue;
end if;
end Shift_Left_Z;
function Shift_Right_Z return Result_T
--
-- Evaluates a shift right, zero fill (Srz).
-- The Left operand is the value to be shifted, the Right
-- operand is the amount of shift (number of bits).
--
is
begin
if Left = 0
or else Right >= Width
then
-- Shifting right a zero for any number of bits, or
-- shifting right any value for at least its width (with
-- zero fill) both result in zero.
return Result (
Value => Word_T'(0),
Signed => False,
Source => Expr,
Ref_Bounded => Refs_Bounded);
elsif Right = 0 then
-- Shifting any value for zero bits leaves the same value.
return Only_Left;
else
return Residue;
end if;
end Shift_Right_Z;
function Shift_Right_A return Result_T
--
-- Evaluates a shift right, sign fill (Sra).
-- The Left operand is the value to be shifted, the Right
-- operand is the amount of shift (number of bits).
--
is
begin
if Left = 0 then
-- Shifting right a zero for any number of bits gives zero.
return Result (
Value => Word_T'(0),
Signed => True,
Source => Expr,
Ref_Bounded => Refs_Bounded);
elsif Left = Max_Word (Width) then
-- Shifting right (arithmetic) an all-ones value, by
-- any amount, gives an all-ones value.
return Result (
Value => Max_Word (Width),
Signed => True,
Source => Expr,
Ref_Bounded => Refs_Bounded);
elsif Right = 0 then
-- Shifting any value for zero bits leaves the same value.
return Only_Left;
else
return Residue;
end if;
end Shift_Right_A;
function Rots return Result_T
--
-- Common cases for left/right rotations (Rotl and Rotr).
-- The Left operand is the value to be rotated, the Right
-- operand is the amount of rotation (number of bits).
--
is
begin
if Left = 0 then
-- Rotating a zero for any number of bits gives zero still.
return Result (
Value => Word_T'(0),
Signed => False,
Source => Expr,
Ref_Bounded => Refs_Bounded);
elsif Left = Max_Word (Width) then
-- Rotating all ones for any number of bits gives all ones still.
return Result (
Value => Max_Word (Width),
Signed => False,
Source => Expr,
Ref_Bounded => Refs_Bounded);
elsif Right = 0 then
-- Rotating any value for zero bits leaves the same value.
-- TBA TBD same if Right mod Width = 0.
return Only_Left;
else
return Residue;
end if;
end Rots;
function Concatenation return Result_T
--
-- Evaluates the concatenation of Left and Right.
--
is
begin
if Left = 0 then
-- This operation just zero-extends Right.
return Unary_Residual_From_Binary (
From => Expr,
Operand => Right,
Other => Left,
Unary_Op => Extz,
Partly => Partly);
else
return Residue;
end if;
end Concatenation;
begin -- Binary_Operation
if Both_Known then
return Op_On_Known (L => Left.Value, R => Right.Value);
else
-- One or both of Left and Right is another expression,
-- not a known constant.
case Op is
when Mulu | Muls =>
return Product;
when Plus =>
return Sum;
when Minus =>
return Difference;
when Plus_C | Plus_V =>
if Left = 0 or Right = 0 then
-- Adding nothing cannot give a carry or overflow.
return Result (
Value => Bit_T'(0),
Signed => False,
Source => Expr,
Ref_Bounded => Refs_Bounded);
else
return Residue;
end if;
when Minus_B | Minus_V =>
if Right = 0 then
-- Subtracting nothing cannot give a borrow or overflow.
return Result (
Value => Bit_T'(0),
Signed => False,
Source => Expr,
Ref_Bounded => Refs_Bounded);
else
return Residue;
end if;
when Minus_C =>
if Right = 0 then
-- Subtracting nothing gives a carry.
return Result (
Value => Bit_T'(1),
Signed => False,
Source => Expr,
Ref_Bounded => Refs_Bounded);
else
return Residue;
end if;
when Plus_N =>
if Left = 0 then
-- The sign is that of Right.
return Unary_Residual_From_Binary (
From => Expr,
Operand => Right,
Other => Left,
Unary_Op => Signw,
Partly => Partly);
elsif Right = 0 then
-- The sign is that of Left.
return Unary_Residual_From_Binary (
From => Expr,
Operand => Left,
Other => Right,
Unary_Op => Signw,
Partly => Partly);
else
return Residue;
end if;
when Minus_N =>
if Right = 0 then
-- The sign is that of Left.
return Unary_Residual_From_Binary (
From => Expr,
Operand => Left,
Other => Right,
Unary_Op => Signw,
Partly => Partly);
else
return Residue;
end if;
-- TBD: Whether in the relational operators, below, we
-- should have special cases when exactly one of the
-- operands is constant and either Value_T'First or
-- Value_T'Last (or the processor-specific smallest
-- and largest values TBD). In such cases the result for
-- many comparisons is known in principle and does not
-- depend on the other operand.
--
-- TBD: Whether the domain should also include information
-- on the intrinsic range of cells (e.g. signed vs unsigned,
-- number of bits in cell, symbol-table information on the
-- range of the variable, or ranges deduced from data flow).
-- Such info could also imply the result of comparisons
-- without more exact knowledge of cell values.
--
-- TBC: It is doubtful if the special cases for Left = Right
-- (representation identity) are worth-while.
--
-- TBD: If it is worth-while to add cases for comparing two
-- offsets to the same Base register.
when Lts | Gts | Ltu | Gtu =>
return Relation (Equal => False);
when Eq | Les | Ges | Leu | Geu =>
return Relation (Equal => True);
when Andx =>
if Width /= 1 then
Report_Many_Bits;
end if;
return Bitwise_And;
when Orx =>
if Width /= 1 then
Report_Many_Bits;
end if;
return Bitwise_Or;
when Andw =>
return Bitwise_And;
when Orw =>
return Bitwise_Or;
when Xorw =>
return Bitwise_Xor;
when Slz =>
return Shift_Left_Z;
when Srz =>
return Shift_Right_Z;
when Sra =>
return Shift_Right_A;
when Rotl | Rotr =>
return Rots;
when Conc =>
return Concatenation;
end case;
end if;
exception
when Word_Out_Of_Range =>
return (
Level => Variable,
Refined => False,
Ref_Bounded => Refs_Bounded,
Expr => Expr);
end Binary_Operation;
Neutral_Third : constant array (Ternary_Op_T) of Bit_T := (
Plus => 0,
Minus_With_B => 0,
Minus_With_C => 1,
Plus_C => 0,
Plus_N => 0,
Plus_V => 0,
Minus_B => 0,
Minus_C => 1,
Minus_BN => 0,
Minus_CN => 1,
Minus_BV => 0,
Minus_CV => 1);
--
-- The "neutral" value of the third (carry/borrow) operand for
-- each of the ternary operations. That is, the carry/borrow
-- value that has no effect on the total result.
Equivalent_Binary : constant array (Ternary_Op_T) of Binary_Op_T := (
Plus => Plus,
Minus_With_B => Minus,
Minus_With_C => Minus,
Plus_C => Plus_C,
Plus_N => Plus_N,
Plus_V => Plus_V,
Minus_B => Minus_B,
Minus_C => Minus_C,
Minus_BN => Minus_N,
Minus_CN => Minus_N,
Minus_BV => Minus_V,
Minus_CV => Minus_V);
--
-- The binary operation that is equivalent to a given ternary
-- operation when the third (carry/borrow) operand of the ternary
-- operation is Neutral_Third.
function Ternary_Operation (
Expr : Expr_Ref;
Op : Ternary_Op_T;
Left : Result_T;
Right : Result_T;
Carry : Result_T;
Partly : Boolean)
return Result_T
--
-- Evaluates a ternary operation (Expr with Kind Op) on its Left,
-- Right, and Carry operands expressed as Result_T objects and returns
-- the value as a Result_T. The Partly parameter has the same
-- role as in the function Eval.
--
is
use type Storage.Cell_T;
All_Known : constant Boolean :=
Left.Level = Known
and Right.Level = Known
and Carry.Level = Known;
-- Whether all operands were evaluated to constants so that
-- we can concretely execute the Op on the operand values.
Refs_Bounded : constant Boolean :=
Left.Ref_Bounded
or Right.Ref_Bounded
or Carry.Ref_Bounded;
-- Whether some references were bounded, in Left, Right, or Carry.
procedure Warn_If_Overflow (L, R, C, Value : Word_T)
--
-- Warns if the Op on known Left, Right, and Carry/Borrow operand
-- values causes overflow so that the resulting Value (not yet
-- limited to this Width) will be wrapped.
--
is
Width : constant Width_T := Width_Of (Left);
Overflow : Word_T;
-- Whether (we know that) there is overflow.
begin
case Op is
when Plus =>
Overflow := Overflow_From_Plus (L, R, C, Width);
when Minus_With_B =>
Overflow := Overflow_From_Minus_Borrow (L, R, C, Width);
when Minus_With_C =>
Overflow := Overflow_From_Minus_Carry (L, R, C, Width);
-- For other operations, we do not check:
when others =>
Overflow := 0;
end case;
if Overflow /= 0
or Value > Max_Word (Expr.Width)
then
Output.Warning (
"Overflow in"
& Width_T'Image (Expr.Width)
& "-bit expression "
& Image (Expr)
& " with operands "
& Image (L)
& ", "
& Image (R)
& ", and "
& Image (C)
& " giving "
& Image (Value and Max_Word (Expr.Width)));
end if;
end Warn_If_Overflow;
function Op_On_Known (L, R, C : Word_T) return Result_T
--
-- The result of Op on known Left, Right, and Carry operand values.
--
is
Width : constant Width_T := Width_Of (Left);
Value : Word_T;
-- The value of the result.
begin
case Op is
when Plus => Value := L + R + C;
when Minus_With_B => Value := L - R - C;
when Minus_With_C => Value := L - R + C - 1;
when Plus_C =>
Value := Carry_From_Plus (L, R, C, Width);
when Plus_N =>
Value := Negative_From_Plus (L, R, C, Width);
when Plus_V =>
Value := Overflow_From_Plus (L, R, C, Width);
when Minus_B =>
Value := Borrow_From_Minus (L, R, C, Width);
when Minus_C =>
Value := Carry_From_Minus (L, R, C, Width);
when Minus_BN =>
Value := Negative_From_Minus_Borrow (L, R, C, Width);
when Minus_CN =>
Value := Negative_From_Minus_Carry (L, R, C, Width);
when Minus_BV =>
Value := Overflow_From_Minus_Borrow (L, R, C, Width);
when Minus_CV =>
Value := Overflow_From_Minus_Carry (L, R, C, Width);
end case;
if Opt.Warn_Overflow then
Warn_If_Overflow (L, R, C, Value);
end if;
return Result (
Value => Value and Max_Word (Expr.Width),
Signed => Expr.Width > 1
and then (Left.Signed or Right.Signed),
Source => Expr,
Ref_Bounded => Refs_Bounded);
end Op_On_Known;
begin -- Ternary_Operation
if All_Known then
return Op_On_Known (
L => Left.Value,
R => Right.Value,
C => Carry.Value);
elsif Carry = Neutral_Third(Op) then
-- Equivalent to the binary operation on Left and Right.
return Binary_Operation (
Expr => Expr,
Op => Equivalent_Binary(Op),
Left => Left,
Right => Right,
Partly => Partly);
else
-- One operand is not Known, and Carry is not "neutral".
-- Give up for now. TBA handling other partly known values.
return Residual (
From => Expr,
Left => Left,
Right => Right,
Carry => Carry,
Partly => Partly);
end if;
exception
when Word_Out_Of_Range =>
return (
Level => Variable,
Refined => False,
Ref_Bounded => Refs_Bounded,
Expr => Expr);
end Ternary_Operation;
function Value_Ref (
Expr : Expr_Ref;
Within : Domain_T'Class;
Partly : Boolean)
return Result_T
--
-- Evaluates a dynamic reference Expression (Expr.Kind = Ref) Within
-- a domain and with possible partial evaluation. The evaluation
-- returns a value, ie. the reference Expression is assumed to
-- occur within an expression and not as the target of an assignment.
--
is
use type Storage.Cell_T;
use type Storage.References.Boundable_Ref;
Pointee : Storage.Cell_T;
-- The cell to which the Expr refers.
Const_Cell : Boolean;
-- Whether the Pointee is known as a constant cell.
Const_Value : Word_T;
-- The value of Pointee when it is a Const_Cell.
Cell_Value: Cell_Value_T;
-- The value of the Pointee cell.
Bounded_Reference : Storage.References.Boundable_Ref;
-- The partly bounded reference, when it is not bounded to a
-- single Pointee cell.
begin
Pointee := Storage.References.Referent (
Ref => Expr.Ref.all,
Under => Within);
if Pointee /= Storage.No_Cell then
-- The reference is resolved to a single cell.
if Options.General.Trace_Resolution then
Output.Trace (
"Resolved pointer "
& Storage.References.Image (Expr.Ref.all)
& " to cell "
& Storage.Image (Pointee)
& " under "
& Image (Within));
end if;
Storage.References.Check_Constancy (
Cell => Pointee,
Ref => Expr.Ref.all,
Const => Const_Cell,
Value => Arithmetic_Base.Word_T (Const_Value));
if Const_Cell then
-- The Pointee has a constant value, whatever the
-- computation does.
Cell_Value := (
Level => Known,
Value => Const_Value,
Width => Expr.Ref.Width,
Signed => False);
--
-- The choice of an unsigned value is arbitrary, TBM.
-- If the "Signed" flag is retained, the choice should
-- be made by Check_Constancy.
else
-- The Pointee is a variable cell, but its value may
-- be defined by the computation:
Cell_Value := Value_Of (Pointee, Within);
end if;
if Cell_Value.Level = Known then
-- The referent even has a known value, gee!
return Result (
Value => Cell_Value.Value,
Signed => Cell_Value.Signed,
Source => Expr,
Ref_Bounded => True);
elsif Cell_Value.Level = Relative then
-- The referent has a value of the form Base + Offset.
return Result (
Base => Cell_Value.Base,
Offset => Cell_Value.Offset,
Source => Expr,
Refined => True,
Ref_Bounded => True);
elsif Partly then
-- The referent cell has no known value, or has
-- possibly a variable value, but we can still
-- refine away the pointer.
return Result (
Expr => Arithmetic.Expr (Pointee),
Level => Cell_Value.Level,
Refined => True,
Ref_Bounded => True);
else
-- The reference cell has no known value, or has
-- possibly a variable value, and the expression is
-- not to be refined.
return Result (
Expr => Expr,
Level => Cell_Value.Level,
Refined => False,
Ref_Bounded => True);
end if;
elsif not Partly then
-- The reference is unresolved and partial evaluation is
-- not requested.
return Result (
Expr => Expr,
Level => Variable,
Refined => False,
Ref_Bounded => False);
else
-- We can try to bound the unresolved reference a bit.
Storage.References.Apply (
Bounds => Within,
Upon => Expr.Ref.all,
Giving => Bounded_Reference);
if Bounded_Reference = null then
-- No change in the reference.
return Result (
Expr => Expr,
Level => Variable,
Refined => False,
Ref_Bounded => False);
else
-- Managed to refine the reference.
return Result (
Expr => Reference (Bounded_Reference),
Level => Variable,
Refined => True,
Ref_Bounded => True);
end if;
end if;
end Value_Ref;
--
--- Provided operations
--
function Eval (
Expr : Expr_Ref;
Within : Domain_T'Class;
Partly : Boolean)
return Result_T
is
use type Storage.Cell_T;
Cell_Value: Cell_Value_T;
-- The value of the cell, when the Expr is a cell.
begin
case Expr.Kind is
when Opaque =>
return Result (
Expr => Expr,
Level => Variable,
Refined => False,
Ref_Bounded => False);
when Const =>
return Result (
Value => Expr.Value,
Source => Expr,
Ref_Bounded => False,
Signed => Expr.Signed);
when Cell =>
Cell_Value := Value_Of (Expr.Cell, Within);
case Cell_Value.Level is
when Unk_Var_T =>
return Result (
Expr => Expr,
Level => Cell_Value.Level,
Refined => False,
Ref_Bounded => False);
when Relative =>
return Result (
Base => Cell_Value.Base,
Offset => Cell_Value.Offset,
Source => Expr,
Refined => Cell_Value.Base /= Expr.Cell,
Ref_Bounded => False);
when Known =>
return Result (
Value => Cell_Value.Value,
Signed => Cell_Value.Signed,
Source => Expr,
Ref_Bounded => False);
end case;
when Ref =>
return Value_Ref (
Expr => Expr,
Within => Within,
Partly => Partly);
when Unary_Kind =>
return Unary_Operation (
Expr => Expr,
Op => Expr.Unary,
Operand => Eval (Expr.Expr, Within, Partly),
Partly => Partly);
when Binary_Kind =>
return Binary_Operation (
Expr => Expr,
Op => Expr.Binary,
Left => Eval (Expr.L_Expr, Within, Partly),
Right => Eval (Expr.R_Expr, Within, Partly),
Partly => Partly);
when Ternary_Kind =>
return Ternary_Operation (
Expr => Expr,
Op => Expr.Ternary,
Left => Eval (Expr.L3_Expr, Within, Partly),
Right => Eval (Expr.R3_Expr, Within, Partly),
Carry => Eval (Expr.C3_Expr, Within, Partly),
Partly => Partly);
end case;
end Eval;
function Eval (
Target : Variable_T;
Within : Domain_T'Class;
Partly : Boolean)
return Target_Result_T
is
use type Storage.Cell_T;
use type Storage.References.Boundable_Ref;
Pointee : Storage.Cell_T;
-- The cell to which the Target refers, when Target is a reference.
Bounded_Reference : Storage.References.Boundable_Ref;
-- The partly bounded pointer, when Target is a reference and the
-- reference is not bounded to a single Pointee cell.
begin
case Variable_Kind_T (Target.Kind) is
when Cell =>
-- A known cell.
return (
Level => Known_Cell,
Ref_Bounded => False,
Source => Target,
Cell => Target.Cell);
when Ref =>
-- A dynamic reference to a cell.
Pointee := Storage.References.Referent (
Ref => Target.Ref.all,
Under => Within);
if Pointee /= Storage.No_Cell then
-- The reference is resolved to a single cell.
return (
Level => Known_Cell,
Ref_Bounded => True,
Source => Target,
Cell => Pointee);
elsif not Partly then
-- The reference is unresolved and partial evaluation is
-- not requested.
return (
Level => Dynamic_Ref,
Ref_Bounded => False,
Source => Target,
Ref => Target.Ref);
else
-- We can try to bound the unresolved reference a bit.
Storage.References.Apply (
Bounds => Within,
Upon => Target.Ref.all,
Giving => Bounded_Reference);
if Bounded_Reference = null then
-- No change in the reference.
return (
Level => Dynamic_Ref,
Ref_Bounded => False,
Source => Target,
Ref => Target.Ref);
else
-- Managed to refine the reference.
return (
Level => Dynamic_Ref,
Ref_Bounded => True,
Source => Target,
Ref => Bounded_Reference);
end if;
end if;
end case;
end Eval;
function Eval (
Assignment : Assignment_T;
Within : Domain_T'Class;
Target : Target_Result_T;
Partly : Boolean)
return Assignment_Result_T
is
Refined : Boolean := Target.Ref_Bounded;
-- Whether some parts of the assignment were refined in
-- the evaluation. Initialized to show the possible refinement
-- of a dynamic-reference Target.
Refs_Bounded : Boolean := Target.Ref_Bounded;
-- Whether some dynamic references were bounded in the evaluation.
-- Initialized to show this for the Target.
Value : Result_T;
-- The single value of an unconditional assignment, or the
-- final result (choice) of a conditional assignment.
Cond, Value1, Value2 : Result_T;
-- The results of evaluating the parts of a conditional assignment.
begin
-- Evaluate the assigned expression(s):
case Defining_Kind_T (Assignment.Kind) is
when Arithmetic.Regular =>
Value := Eval (
Expr => Assignment.Value,
Within => Within,
Partly => Partly);
Refined := Refined or Value.Refined;
Refs_Bounded := Refs_Bounded or Value.Ref_Bounded;
return (
Kind => Regular,
Refined => Refined or Refs_Bounded,
Ref_Bounded => Refs_Bounded,
Target => Target,
Value => Value);
when Arithmetic.Conditional =>
Cond := Eval (
Expr => Assignment.Cond,
Within => Within,
Partly => Partly);
Refined := Refined or Cond.Refined;
Refs_Bounded := Refs_Bounded or Cond.Ref_Bounded;
if Cond.Level /= Known
or else Cond.Value = True_Value
then
-- Condition not known or True.
-- We must evaluate the first alternative value.
Value1 := Eval (
Expr => Assignment.Value1,
Within => Within,
Partly => Partly);
Refined := Refined or Value1.Refined;
Refs_Bounded := Refs_Bounded or Value1.Ref_Bounded;
end if;
if Cond.Level /= Known
or else Cond.Value = False_Value
then
-- Condition not known or False.
-- We must evaluate the second alternative value.
Value2 := Eval (
Expr => Assignment.Value2,
Within => Within,
Partly => Partly);
Refined := Refined or Value2.Refined;
Refs_Bounded := Refs_Bounded or Value2.Ref_Bounded;
end if;
if Cond.Level = Known then
-- The condition is constant, so we can here
-- choose which value to use (and we have in
-- fact evaluated just this value):
if Cond.Value = True_Value then
return (
Kind => Regular,
Refined => True,
Ref_Bounded => Refs_Bounded,
Target => Target,
Value => Value1);
else
return (
Kind => Regular,
Refined => True,
Ref_Bounded => Refs_Bounded,
Target => Target,
Value => Value2);
end if;
elsif Same (Value1, Value2) then
-- We have the same value whatever the condition:
return (
Kind => Regular,
Refined => True,
Ref_Bounded => Refs_Bounded,
Target => Target,
Value => Value1);
else
-- The condition is not known, so neither is the
-- assigned value. The level of the value can be
-- computed, but not the Value itself:
case Fuzzy_Cond_Level (
Cond => Cond.Level,
Value1 => Value1.Level,
Value2 => Value2.Level)
is
when Unknown =>
Value := (
Level => Unknown,
Refined => False,
Ref_Bounded => False,
Expr => null);
when Variable =>
Value := (
Level => Variable,
Refined => False,
Ref_Bounded => False,
Expr => null);
end case;
return (
Kind => Conditional,
Refined => Refined or Refs_Bounded,
Ref_Bounded => Refs_Bounded,
Target => Target,
Value => Value,
Cond => Cond,
Value1 => Value1,
Value2 => Value2);
end if;
when Arithmetic.Fracture =>
-- There is no value to evaluate.
Value := Eval (
Expr => Arithmetic.Unknown,
Within => Within,
Partly => Partly);
Refined := Refined or Value.Refined;
Refs_Bounded := Refs_Bounded or Value.Ref_Bounded;
-- It would be quite surprising if Value.Refined or
-- Value.Ref_Bounded were True, but let's be very formal.
return (
Kind => Fracture,
Refined => Refined or Refs_Bounded,
Ref_Bounded => Refs_Bounded,
Target => Target,
Value => Value);
end case;
end Eval;
function Eval (
Assignment : Assignment_T;
Within : Domain_T'Class;
Partly : Boolean)
return Assignment_Result_T
is
begin
return Eval (
Assignment => Assignment,
Within => Within,
Target => Eval (Assignment.Target, Within, Partly),
Partly => Partly);
end Eval;
--
--- Understanding the results
--
function Same (Left : Result_T; Right : Expr_Ref)
return Boolean
is
Konst : Boolean;
Diff : Value_T;
-- From Find_Difference between Left.Base and Right.
begin
case Left.Level is
when Unk_Var_T =>
return Left.Expr = Right;
--
-- The Right expression is identical with the Left result
-- (as expression references, so this is a conservative
-- but incomplete comparison).
-- Comparing Expr_Ref values means that we check representation
-- identity, not semantic identity. This is a safe check
-- ("equal" is correct) but not a complete check (two
-- expressions may be "not equal" by this check but still
-- be semantically equivalent).
when Relative =>
Algebra.Find_Difference (
From => Left.Base,
To => Right,
Const => Konst,
Diff => Diff);
return Konst and then Diff = Left.Offset;
--
-- The Right expression is of the form Left.Base + Diff,
-- or Left.Base - (-Diff), or Diff + Left.Base. Safe but
-- incomplete equality.
when Known =>
return Right.Kind = Const and then Right.Value = Left.Value;
--
-- The Right expression is a constant expression with
-- the same value as the Left constant result.
--
-- This is a stronger check of semantic identity than
-- the above check of Expr_Refs, but still incomplete.
-- However, if the check falsely claims that Left and
-- Right are not the same, then the Right expression must
-- always evaluate to Left.Value, so a Const expression
-- derived from Left.Value will be simpler than the
-- Right expression, but fully equivalent.
end case;
end Same;
function Same (Left : Assignment_Result_T; Right : Assignment_T)
return Boolean
is
begin
if Left.Kind /= Right.Kind
or Left.Ref_Bounded
then
return False;
else
-- The Kind was not changed and no references were bounded.
-- The assumption Left = Eval (Right, Partly => True) means
-- that Left and Right have the same target variable.
-- Thus, the changes are in the value(s), if anywhere.
case Left.Kind is
when Regular =>
return Same (Left.Value, Right.Value);
when Conditional =>
return Same (Left.Cond , Right.Cond)
and Same (Left.Value1, Right.Value1)
and Same (Left.Value2, Right.Value2);
when Fracture =>
return True;
end case;
end if;
end Same;
function Identity (Result : Assignment_Result_T)
return Boolean
is
use type Storage.Cell_T;
begin
return Result.Kind = Regular
and then Result.Value.Level in Fuzzy_Level_T
and then Result.Value.Expr.Kind = Cell
and then Result.Target.Level = Known_Cell
and then Result.Value.Expr.Cell = Result.Target.Cell;
end Identity;
function Residual (From : Result_T) return Expr_Ref
is
Combined : Expr_Ref;
-- An unknown or variable result after combining terms and
-- thus possibly refining it.
begin
-- To form the residual expression from a partially or
-- completely evaluated result, we try to re-use as much
-- as possible of the existing expressions.
--
-- The evaluation level of the residual expression, although
-- not explicitly returned, is logically the same as From.Level.
case From.Level is
when Unknown | Variable =>
-- The residual expression is not constant yet, but it may
-- have gained new constant parts, so it may be useful to try
-- to combine similar terms, including combining multiple
-- constant terms that represent known cell values from the
-- evaluation domain.
Combined := Algebra.Combine_Terms (From.Expr);
if Opt.Trace_Refinement_Path
and then Combined /= From.Expr
then
Output.Trace (
"Source expression "
& Image (From.Expr)
& " refined by combining terms to "
& Image (Combined));
end if;
return Combined;
when Relative =>
-- The residual expression is the unknown value of a Base
-- cell plus a constant Offset. The Base cell is a constant
-- throughout the subprogram, so we can replace the original
-- expression with Base + Offset.
return Cell (From.Base)
+ Const (Value => From.Offset,
Width => From.Expr.Width,
Signed => True);
when Known =>
-- The residual expression will be a constant.
if From.Expr.Kind = Const
and then (From.Expr.Value = From.Value
and From.Expr.Signed = From.Signed)
then
-- The source Expr is a constant expression with the
-- same value as was evaluated.
-- No need to create a new expression, it would
-- be the same as From.Expr.
return From.Expr;
else
-- No such luck, so we create a new constant
-- expression to hold the evaluated value.
return Const (
Value => From.Value,
Width => From.Expr.Width,
Signed => From.Signed);
end if;
end case;
end Residual;
function Target_Cell (From : Target_Result_T) return Cell_T
is
begin
case From.Level is
when Dynamic_Ref => return Storage.No_Cell;
when Known_Cell => return From.Cell;
end case;
end Target_Cell;
function Residual (From : Target_Result_T)
return Variable_T
is
begin
if not From.Ref_Bounded then
-- The target was not modified by evaluation.
return From.Source;
else
-- The target was resolved, at least to some extent.
case From.Level is
when Dynamic_Ref =>
return Reference (From.Ref);
when Known_Cell =>
return Cell (From.Cell);
end case;
end if;
end Residual;
function Residual (From : Assignment_Result_T)
return Assignment_T
is
Target : constant Variable_T := Residual (From.Target);
-- The residual target.
begin
case From.Kind is
when Regular =>
return (
Kind => Regular,
Target => Target,
Value => Residual (From.Value));
when Conditional =>
return (
Kind => Conditional,
Target => Target,
Cond => Residual (From.Cond),
Value1 => Residual (From.Value1),
Value2 => Residual (From.Value2));
when Fracture =>
return (
Kind => Fracture,
Target => Target);
end case;
end Residual;
end Arithmetic.Evaluation;
|
dannyboywoop/AdventOfCode2019 | Ada | 227 | ads | with Ada.Text_IO, Array_Stuff;
use Ada.Text_IO, Array_Stuff;
package File_IO is
function Count_Lines(file: in out File_Type) return Integer;
function Read_File(filename: String:="input.txt") return Str_Arr;
end File_IO;
|
sungyeon/drake | Ada | 173 | ads | pragma License (Unrestricted);
with Ada.Numerics.Complex_Types;
with Ada.Text_IO.Complex_IO;
package Ada.Complex_Text_IO is new Text_IO.Complex_IO (Numerics.Complex_Types);
|
Letractively/ada-el | Ada | 3,073 | adb | -----------------------------------------------------------------------
-- Test_Bean - A simple bean for unit tests
-- Copyright (C) 2009, 2010, 2011 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body Test_Bean is
use EL.Objects;
FIRST_NAME : constant String := "firstName";
LAST_NAME : constant String := "lastName";
AGE : constant String := "age";
WEIGHT : constant String := "weight";
function Create_Person (First_Name, Last_Name : String;
Age : Natural) return Person_Access is
begin
return new Person '(First_Name => To_Unbounded_String (First_Name),
Last_Name => To_Unbounded_String (Last_Name),
Age => Age,
Date => Ada.Calendar.Clock,
Weight => 12.0);
end Create_Person;
-- Get the value identified by the name.
function Get_Value (From : Person; Name : String) return EL.Objects.Object is
begin
if Name = FIRST_NAME then
return To_Object (From.First_Name);
elsif Name = LAST_NAME then
return To_Object (From.Last_Name);
elsif Name = AGE then
return To_Object (From.Age);
elsif Name = WEIGHT then
return To_Object (From.Weight);
-- elsif Name = DATE then
-- return To_Object (From.Date);
else
return EL.Objects.Null_Object;
end if;
end Get_Value;
-- Set the value identified by the name.
procedure Set_Value (From : in out Person;
Name : in String;
Value : in EL.Objects.Object) is
begin
if Name = FIRST_NAME then
From.First_Name := To_Unbounded_String (Value);
elsif Name = LAST_NAME then
From.Last_Name := To_Unbounded_String (Value);
elsif Name = AGE then
From.Age := Natural (To_Integer (Value));
elsif Name = WEIGHT then
From.Weight := To_Long_Long_Float (Value);
-- elsif Name = DATE then
-- From.Date := To_Time (Value);
else
raise EL.Objects.No_Value;
end if;
end Set_Value;
-- Function to format a string
function Format (Arg : EL.Objects.Object) return EL.Objects.Object is
S : constant String := To_String (Arg);
begin
return To_Object ("[" & S & "]");
end Format;
end Test_Bean;
|
stcarrez/ada-servlet | Ada | 1,232 | adb | -----------------------------------------------------------------------
-- servlet-streams-xml -- XML Print streams for servlets
-- Copyright (C) 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body Servlet.Streams.XML is
-- ------------------------------
-- Initialize the stream
-- ------------------------------
procedure Initialize (Stream : in out Print_Stream;
To : in Servlet.Streams.Print_Stream'Class) is
begin
Stream.Initialize (To.Target);
end Initialize;
end Servlet.Streams.XML;
|
reznikmm/matreshka | Ada | 3,784 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2013, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.ODF_Elements.Office.Bodies;
package ODF.DOM.Elements.Office.Bodies.Internals is
function Create
(Node : Matreshka.ODF_Elements.Office.Bodies.Office_Body_Access)
return ODF.DOM.Elements.Office.Bodies.ODF_Office_Body;
function Wrap
(Node : Matreshka.ODF_Elements.Office.Bodies.Office_Body_Access)
return ODF.DOM.Elements.Office.Bodies.ODF_Office_Body;
end ODF.DOM.Elements.Office.Bodies.Internals;
|
charlie5/lace | Ada | 4,512 | ads | with
openGL.Texture,
openGL.GlyphImpl.texture,
freetype_c.FT_GlyphSlot,
ada.Containers.Vectors;
private
with
GL;
package openGL.FontImpl.texture
--
-- Implements a texture font.
--
is
type Item is new FontImpl.item with private;
type View is access all Item'Class;
---------
-- Forge
--
function to_FontImpl_texture (ftFont : access openGL.Font.item'Class;
fontFilePath : in String) return fontImpl.texture.item;
function new_FontImpl_texture (ftFont : access openGL.Font.item'Class;
fontFilePath : in String) return access fontImpl.texture.item'Class;
function to_FontImpl_texture (ftFont : access openGL.Font.item'Class;
pBufferBytes : in unsigned_char_Pointer;
bufferSizeInBytes : in Natural) return fontImpl.texture.item;
function new_FontImpl_texture (ftFont : access openGL.Font.item'Class;
pBufferBytes : in unsigned_char_Pointer;
bufferSizeInBytes : in Natural) return fontImpl.texture.view;
overriding
procedure destruct (Self : in out Item);
--------------
-- Attributes
--
overriding
function FaceSize (Self : access Item; Size : in Natural;
x_Res,
y_Res : in Natural := 72) return Boolean;
--
-- Set the char size for the current face.
--
-- Returns True if size was set correctly.
function render (Self : access Item; Text : in String;
Length : in Integer;
Position : in Vector_3;
Spacing : in Vector_3;
Mode : in renderMode) return Vector_3;
function Quad (Self : access Item; for_Character : in Character) return openGL.GlyphImpl.Texture.Quad_t;
---------------
--- 'Protected'
--
function MakeGlyphImpl (Self : access Item; ftGlyph : in freetype_c.FT_GlyphSlot.item) return access Glyph.item'Class;
--
-- Create an FTTextureGlyph object for the base class.
function gl_Texture (Self : in Item) return openGL.Texture.texture_Name;
private
use type openGL.Texture.texture_Name;
package texture_name_Vectors is new ada.Containers.Vectors (Positive, openGL.Texture.texture_Name);
type Item is new FontImpl.item with
record
maximumGLTextureSize : aliased gl.GLsizei := 0; -- The max texture dimension on this openGL implemetation.
textureWidth : gl.GLsizei := 0; -- The min texture width required to hold the glyphs.
textureHeight : gl.GLsizei := 0; -- The min texture height required to hold the glyphs.
textureIDList : texture_name_Vectors.Vector;
-- An array of texture ids.
glyphHeight : Integer := 0; -- The max height for glyphs in the current font.
glyphWidth : Integer := 0; -- The max width for glyphs in the current font.
Padding : Natural := 3; -- A value to be added to the height and width to ensure that
numGlyphs : Natural; -- glyphs don't overlap in the texture.
remGlyphs : Natural;
xOffset, yOffset : Integer := 0;
end record;
procedure CalculateTextureSize (Self : in out Item);
--
-- Get the size of a block of memory required to layout the glyphs
--
-- Calculates a width and height based on the glyph sizes and the
-- number of glyphs. It over estimates.
function CreateTexture (Self : access Item) return openGL.Texture.texture_Name;
--
-- Creates a 'blank' openGL texture object.
--
-- The format is GL_ALPHA and the params are
-- * GL_TEXTURE_WRAP_S = GL_CLAMP
-- * GL_TEXTURE_WRAP_T = GL_CLAMP
-- * GL_TEXTURE_MAG_FILTER = GL_LINEAR
-- * GL_TEXTURE_MIN_FILTER = GL_LINEAR
-- * Note that mipmapping is NOT used
procedure free_Textures (Self : in out Item);
end openGL.FontImpl.Texture;
|
charlie5/lace | Ada | 169 | ads | package openGL.surface_Profile.privvy
is
-- function to_glx (Self : in Item'Class) return glx.GLXFBConfig;
procedure dummy;
end openGL.surface_Profile.privvy;
|
onox/json-ada | Ada | 1,480 | adb | -- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <[email protected]>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with AUnit.Reporter.Text;
with AUnit.Run;
with AUnit.Test_Suites;
with Test_Tokenizers;
with Test_Parsers;
with Test_Streams;
with Test_Images;
procedure Test_Bindings is
function Suite return AUnit.Test_Suites.Access_Test_Suite;
function Suite return AUnit.Test_Suites.Access_Test_Suite is
Result : constant AUnit.Test_Suites.Access_Test_Suite :=
AUnit.Test_Suites.New_Suite;
begin
Result.Add_Test (Test_Tokenizers.Suite);
Result.Add_Test (Test_Parsers.Suite);
Result.Add_Test (Test_Streams.Suite);
Result.Add_Test (Test_Images.Suite);
return Result;
end Suite;
procedure Runner is new AUnit.Run.Test_Runner (Suite);
Reporter : AUnit.Reporter.Text.Text_Reporter;
begin
Reporter.Set_Use_ANSI_Colors (True);
Runner (Reporter);
end Test_Bindings;
|
MinimSecure/unum-sdk | Ada | 944 | adb | -- Copyright 2008-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/>.
package body Types is
function Ident (O : Object'Class) return Object'Class is
begin
return O;
end Ident;
procedure Do_Nothing (O : in out Object'Class) is
begin
null;
end Do_Nothing;
end Types;
|
google-code/ada-security | Ada | 10,715 | adb | -----------------------------------------------------------------------
-- security-contexts -- Context to provide security information and verify permissions
-- Copyright (C) 2011, 2012 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Task_Attributes;
with Ada.Unchecked_Deallocation;
package body Security.Contexts is
use type Security.Policies.Policy_Context_Array_Access;
use type Security.Policies.Policy_Access;
use type Security.Policies.Policy_Context_Access;
package Task_Context is new Ada.Task_Attributes
(Security_Context_Access, null);
procedure Free is
new Ada.Unchecked_Deallocation (Object => Security.Policies.Policy_Context'Class,
Name => Security.Policies.Policy_Context_Access);
-- ------------------------------
-- Get the application associated with the current service operation.
-- ------------------------------
function Get_User_Principal (Context : in Security_Context'Class)
return Security.Principal_Access is
begin
return Context.Principal;
end Get_User_Principal;
-- ------------------------------
-- Get the permission manager.
-- ------------------------------
function Get_Permission_Manager (Context : in Security_Context'Class)
return Security.Policies.Policy_Manager_Access is
begin
return Context.Manager;
end Get_Permission_Manager;
-- ------------------------------
-- Get the policy with the name <b>Name</b> registered in the policy manager.
-- Returns null if there is no such policy.
-- ------------------------------
function Get_Policy (Context : in Security_Context'Class;
Name : in String) return Security.Policies.Policy_Access is
use type Security.Policies.Policy_Manager_Access;
begin
if Context.Manager = null then
return null;
else
return Context.Manager.Get_Policy (Name);
end if;
end Get_Policy;
-- ------------------------------
-- Check if the permission identified by <b>Permission</b> is allowed according to
-- the current security context.
-- Returns True if the permission is granted.
-- ------------------------------
function Has_Permission (Context : in Security_Context;
Permission : in Permissions.Permission_Index) return Boolean is
use type Security.Policies.Policy_Manager_Access;
begin
if Context.Manager = null then
return False;
end if;
declare
Perm : Security.Permissions.Permission (Permission);
begin
return Context.Manager.Has_Permission (Context, Perm);
end;
end Has_Permission;
-- ------------------------------
-- Check if the permission identified by <b>Permission</b> is allowed according to
-- the current security context.
-- Returns True if the permission is granted.
-- ------------------------------
function Has_Permission (Context : in Security_Context;
Permission : in String) return Boolean is
Index : constant Permissions.Permission_Index
:= Permissions.Get_Permission_Index (Permission);
begin
return Security_Context'Class (Context).Has_Permission (Index);
end Has_Permission;
-- ------------------------------
-- Check if the permission identified by <b>Permission</b> is allowed according to
-- the current security context.
-- Returns True if the permission is granted.
-- ------------------------------
function Has_Permission (Context : in Security_Context;
Permission : in Permissions.Permission'Class) return Boolean is
use type Security.Policies.Policy_Manager_Access;
begin
if Context.Manager = null then
return False;
else
return Context.Manager.Has_Permission (Context, Permission);
end if;
end Has_Permission;
-- ------------------------------
-- Initializes the service context. By creating the <b>Security_Context</b> variable,
-- the instance will be associated with the current task attribute. If the current task
-- already has a security context, the new security context is installed, the old one
-- being kept.
-- ------------------------------
overriding
procedure Initialize (Context : in out Security_Context) is
begin
Context.Previous := Task_Context.Value;
Task_Context.Set_Value (Context'Unchecked_Access);
end Initialize;
-- ------------------------------
-- Finalize the security context releases any object. The previous security context is
-- restored to the current task attribute.
-- ------------------------------
overriding
procedure Finalize (Context : in out Security_Context) is
procedure Free is
new Ada.Unchecked_Deallocation (Object => Security.Policies.Policy_Context_Array,
Name => Security.Policies.Policy_Context_Array_Access);
begin
Task_Context.Set_Value (Context.Previous);
if Context.Contexts /= null then
for I in Context.Contexts'Range loop
Free (Context.Contexts (I));
end loop;
Free (Context.Contexts);
end if;
end Finalize;
-- ------------------------------
-- Set a policy context information represented by <b>Value</b> and associated with
-- the policy index <b>Policy</b>.
-- ------------------------------
procedure Set_Policy_Context (Context : in out Security_Context;
Policy : in Security.Policies.Policy_Access;
Value : in Security.Policies.Policy_Context_Access) is
begin
if Context.Contexts = null then
Context.Contexts := Context.Manager.Create_Policy_Contexts;
end if;
Free (Context.Contexts (Policy.Get_Policy_Index));
Context.Contexts (Policy.Get_Policy_Index) := Value;
end Set_Policy_Context;
-- ------------------------------
-- Get the policy context information registered for the given security policy in the security
-- context <b>Context</b>.
-- Raises <b>Invalid_Context</b> if there is no such information.
-- Raises <b>Invalid_Policy</b> if the policy was not set.
-- ------------------------------
function Get_Policy_Context (Context : in Security_Context;
Policy : in Security.Policies.Policy_Access)
return Security.Policies.Policy_Context_Access is
Result : Security.Policies.Policy_Context_Access;
begin
if Policy = null then
raise Invalid_Policy;
end if;
if Context.Contexts = null then
raise Invalid_Context;
end if;
Result := Context.Contexts (Policy.Get_Policy_Index);
return Result;
end Get_Policy_Context;
-- ------------------------------
-- Returns True if a context information was registered for the security policy.
-- ------------------------------
function Has_Policy_Context (Context : in Security_Context;
Policy : in Security.Policies.Policy_Access) return Boolean is
begin
return Policy /= null and then Context.Contexts /= null
and then Context.Contexts (Policy.Get_Policy_Index) /= null;
end Has_Policy_Context;
-- ------------------------------
-- Set the current application and user context.
-- ------------------------------
procedure Set_Context (Context : in out Security_Context;
Manager : in Security.Policies.Policy_Manager_Access;
Principal : in Security.Principal_Access) is
begin
Context.Manager := Manager;
Context.Principal := Principal;
end Set_Context;
-- ------------------------------
-- Get the current security context.
-- Returns null if the current thread is not associated with any security context.
-- ------------------------------
function Current return Security_Context_Access is
begin
return Task_Context.Value;
end Current;
-- ------------------------------
-- Check if the permission identified by <b>Permission</b> is allowed according to
-- the current security context.
-- ------------------------------
function Has_Permission (Permission : in Permissions.Permission_Index) return Boolean is
Context : constant Security_Context_Access := Current;
begin
if Context = null then
return False;
else
return Context.Has_Permission (Permission);
end if;
end Has_Permission;
-- ------------------------------
-- Check if the permission identified by <b>Permission</b> is allowed according to
-- the current security context.
-- ------------------------------
function Has_Permission (Permission : in String) return Boolean is
Context : constant Security_Context_Access := Current;
begin
if Context = null then
return False;
else
return Context.Has_Permission (Permission);
end if;
end Has_Permission;
-- ------------------------------
-- Check if the permission identified by <b>Permission</b> is allowed according to
-- the current security context.
-- ------------------------------
function Has_Permission (Permission : in Permissions.Permission'Class) return Boolean is
Context : constant Security_Context_Access := Current;
begin
if Context = null then
return False;
else
return Context.Has_Permission (Permission);
end if;
end Has_Permission;
end Security.Contexts;
|
MinimSecure/unum-sdk | Ada | 1,002 | adb | -- Copyright 2015-2019 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 Pck; use Pck;
procedure Foo_O115_002 is
My_Object : Object := (N => 3, Data => (3, 5, 8));
My_Small_Object : Small_Object := (N => 3, Data => (3, 5, 8));
begin
Do_Nothing (My_Object'Address); -- STOP
Do_Nothing (My_Small_Object'Address);
end Foo_O115_002;
|
stcarrez/helios | Ada | 907 | ads | -----------------------------------------------------------------------
-- helios-rest -- Helios Fast Reliable Monitoring Agent
-- Copyright (C) 2018 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package Helios.Rest is
end Helios.Rest;
|
Fabien-Chouteau/Ada_Drivers_Library | Ada | 3,751 | ads | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2016, 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. --
-- --
------------------------------------------------------------------------------
package HAL.SPI is
type SPI_Status is
(Ok,
Err_Error,
Err_Timeout,
Busy);
type SPI_Data_Size is
(Data_Size_8b,
Data_Size_16b);
type SPI_Data_8b is array (Natural range <>) of UInt8;
type SPI_Data_16b is array (Natural range <>) of UInt16;
type SPI_Port is limited interface;
type Any_SPI_Port is access all SPI_Port'Class;
function Data_Size (This : SPI_Port) return SPI_Data_Size is abstract;
procedure Transmit
(This : in out SPI_Port;
Data : SPI_Data_8b;
Status : out SPI_Status;
Timeout : Natural := 1000) is abstract
with
Pre'Class => Data_Size (This) = Data_Size_8b;
procedure Transmit
(This : in out SPI_Port;
Data : SPI_Data_16b;
Status : out SPI_Status;
Timeout : Natural := 1000) is abstract
with
Pre'Class => Data_Size (This) = Data_Size_16b;
procedure Receive
(This : in out SPI_Port;
Data : out SPI_Data_8b;
Status : out SPI_Status;
Timeout : Natural := 1000) is abstract
with
Pre'Class => Data_Size (This) = Data_Size_8b;
procedure Receive
(This : in out SPI_Port;
Data : out SPI_Data_16b;
Status : out SPI_Status;
Timeout : Natural := 1000) is abstract
with
Pre'Class => Data_Size (This) = Data_Size_16b;
end HAL.SPI;
|
reznikmm/matreshka | Ada | 1,811 | adb | with Matreshka.Opts.parsers; use Matreshka.Opts.parsers;
with Ada.Wide_Wide_Text_IO;
with League.Strings; use League.Strings;
with League.Characters;
with League.Text_Codecs;
with League.String_Vectors; use League.String_Vectors;
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Streams;
procedure adaopts is
myparser : parser_access := new parser;
function "+"
(Item : Wide_Wide_String) return League.Strings.Universal_String
renames League.Strings.To_Universal_String;
function "+"
(Item : Wide_Wide_Character) return League.Characters.Universal_Character
renames League.Characters.To_Universal_Character;
function To_Universal_String(Str : String) return Universal_String is
use Ada.Streams;
US : Universal_String;
Result : Stream_Element_Array (Stream_Element_Offset (Str'First) ..
Stream_Element_Offset (Str'Last));
for Result'Address use Str'Address;
begin
US := League.Text_Codecs.Codec_For_Application_Locale.Decode(Result);
return US;
end To_Universal_String;
Vect : Universal_String_Vector := Empty_Universal_String_Vector;
begin
myparser.add_option (Name => +"Filename",
Long => +"fname",
Short => +'f',
Help => +"Name of file",
Required => True,
Has_Value => True);
myparser.add_option (Name => +"filetype",
Long => +"ftype",
Short => +'t',
Help => +"Type of the file");
for I in 1..Ada.Command_Line.Argument_Count loop
Vect.Append(To_Universal_String(Ada.Command_Line.Argument(I)));
end loop;
myparser.parse(Vect);
end adaopts;
|
Asier98/AdaCar | Ada | 142 | ads | package AdaCar.Organizador_Movimiento is
procedure Nueva_Distancia_Sensor(Valor: Unidades_Distancia);
end AdaCar.Organizador_Movimiento;
|
DrenfongWong/tkm-rpc | Ada | 397 | ads | with Ada.Unchecked_Conversion;
package Tkmrpc.Request.Ike.Esa_Select.Convert is
function To_Request is new Ada.Unchecked_Conversion (
Source => Esa_Select.Request_Type,
Target => Request.Data_Type);
function From_Request is new Ada.Unchecked_Conversion (
Source => Request.Data_Type,
Target => Esa_Select.Request_Type);
end Tkmrpc.Request.Ike.Esa_Select.Convert;
|
reznikmm/matreshka | Ada | 4,567 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Matreshka.DOM_Documents;
with Matreshka.ODF_String_Constants;
with ODF.DOM.Iterators;
with ODF.DOM.Visitors;
package body Matreshka.ODF_Text.Level_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Text_Level_Attribute_Node is
begin
return Self : Text_Level_Attribute_Node do
Matreshka.ODF_Text.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Text_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Text_Level_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Level_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Text_URI,
Matreshka.ODF_String_Constants.Level_Attribute,
Text_Level_Attribute_Node'Tag);
end Matreshka.ODF_Text.Level_Attributes;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 8,611 | ads | -- This spec has been automatically generated from STM32F411xx.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package STM32_SVD.SYSCFG is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype MEMRM_MEM_MODE_Field is STM32_SVD.UInt2;
-- memory remap register
type MEMRM_Register is record
-- MEM_MODE
MEM_MODE : MEMRM_MEM_MODE_Field := 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 MEMRM_Register use record
MEM_MODE at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
subtype PMC_ADC1DC2_Field is STM32_SVD.Bit;
-- peripheral mode configuration register
type PMC_Register is record
-- unspecified
Reserved_0_15 : STM32_SVD.UInt16 := 16#0#;
-- ADC1DC2
ADC1DC2 : PMC_ADC1DC2_Field := 16#0#;
-- unspecified
Reserved_17_31 : STM32_SVD.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for PMC_Register use record
Reserved_0_15 at 0 range 0 .. 15;
ADC1DC2 at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
-- EXTICR1_EXTI array element
subtype EXTICR1_EXTI_Element is STM32_SVD.UInt4;
-- EXTICR1_EXTI array
type EXTICR1_EXTI_Field_Array is array (0 .. 3) of EXTICR1_EXTI_Element
with Component_Size => 4, Size => 16;
-- Type definition for EXTICR1_EXTI
type EXTICR1_EXTI_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- EXTI as a value
Val : STM32_SVD.UInt16;
when True =>
-- EXTI as an array
Arr : EXTICR1_EXTI_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for EXTICR1_EXTI_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- external interrupt configuration register 1
type EXTICR1_Register is record
-- EXTI x configuration (x = 0 to 3)
EXTI : EXTICR1_EXTI_Field :=
(As_Array => False, Val => 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 EXTICR1_Register use record
EXTI at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- EXTICR2_EXTI array element
subtype EXTICR2_EXTI_Element is STM32_SVD.UInt4;
-- EXTICR2_EXTI array
type EXTICR2_EXTI_Field_Array is array (4 .. 7) of EXTICR2_EXTI_Element
with Component_Size => 4, Size => 16;
-- Type definition for EXTICR2_EXTI
type EXTICR2_EXTI_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- EXTI as a value
Val : STM32_SVD.UInt16;
when True =>
-- EXTI as an array
Arr : EXTICR2_EXTI_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for EXTICR2_EXTI_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- external interrupt configuration register 2
type EXTICR2_Register is record
-- EXTI x configuration (x = 4 to 7)
EXTI : EXTICR2_EXTI_Field :=
(As_Array => False, Val => 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 EXTICR2_Register use record
EXTI at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- EXTICR3_EXTI array element
subtype EXTICR3_EXTI_Element is STM32_SVD.UInt4;
-- EXTICR3_EXTI array
type EXTICR3_EXTI_Field_Array is array (8 .. 11) of EXTICR3_EXTI_Element
with Component_Size => 4, Size => 16;
-- Type definition for EXTICR3_EXTI
type EXTICR3_EXTI_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- EXTI as a value
Val : STM32_SVD.UInt16;
when True =>
-- EXTI as an array
Arr : EXTICR3_EXTI_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for EXTICR3_EXTI_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- external interrupt configuration register 3
type EXTICR3_Register is record
-- EXTI x configuration (x = 8 to 11)
EXTI : EXTICR3_EXTI_Field :=
(As_Array => False, Val => 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 EXTICR3_Register use record
EXTI at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- EXTICR4_EXTI array element
subtype EXTICR4_EXTI_Element is STM32_SVD.UInt4;
-- EXTICR4_EXTI array
type EXTICR4_EXTI_Field_Array is array (12 .. 15) of EXTICR4_EXTI_Element
with Component_Size => 4, Size => 16;
-- Type definition for EXTICR4_EXTI
type EXTICR4_EXTI_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- EXTI as a value
Val : STM32_SVD.UInt16;
when True =>
-- EXTI as an array
Arr : EXTICR4_EXTI_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for EXTICR4_EXTI_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- external interrupt configuration register 4
type EXTICR4_Register is record
-- EXTI x configuration (x = 12 to 15)
EXTI : EXTICR4_EXTI_Field :=
(As_Array => False, Val => 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 EXTICR4_Register use record
EXTI at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype CMPCR_CMP_PD_Field is STM32_SVD.Bit;
subtype CMPCR_READY_Field is STM32_SVD.Bit;
-- Compensation cell control register
type CMPCR_Register is record
-- Read-only. Compensation cell power-down
CMP_PD : CMPCR_CMP_PD_Field;
-- unspecified
Reserved_1_7 : STM32_SVD.UInt7;
-- Read-only. READY
READY : CMPCR_READY_Field;
-- unspecified
Reserved_9_31 : STM32_SVD.UInt23;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CMPCR_Register use record
CMP_PD at 0 range 0 .. 0;
Reserved_1_7 at 0 range 1 .. 7;
READY at 0 range 8 .. 8;
Reserved_9_31 at 0 range 9 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- System configuration controller
type SYSCFG_Peripheral is record
-- memory remap register
MEMRM : aliased MEMRM_Register;
-- peripheral mode configuration register
PMC : aliased PMC_Register;
-- external interrupt configuration register 1
EXTICR1 : aliased EXTICR1_Register;
-- external interrupt configuration register 2
EXTICR2 : aliased EXTICR2_Register;
-- external interrupt configuration register 3
EXTICR3 : aliased EXTICR3_Register;
-- external interrupt configuration register 4
EXTICR4 : aliased EXTICR4_Register;
-- Compensation cell control register
CMPCR : aliased CMPCR_Register;
end record
with Volatile;
for SYSCFG_Peripheral use record
MEMRM at 16#0# range 0 .. 31;
PMC at 16#4# range 0 .. 31;
EXTICR1 at 16#8# range 0 .. 31;
EXTICR2 at 16#C# range 0 .. 31;
EXTICR3 at 16#10# range 0 .. 31;
EXTICR4 at 16#14# range 0 .. 31;
CMPCR at 16#20# range 0 .. 31;
end record;
-- System configuration controller
SYSCFG_Periph : aliased SYSCFG_Peripheral
with Import, Address => System'To_Address (16#40013800#);
end STM32_SVD.SYSCFG;
|
AdaCore/gpr | Ada | 1,621 | adb | ------------------------------------------------------------------------------
-- --
-- GPR2 PROJECT MANAGER --
-- --
-- Copyright (C) 2019-2023, AdaCore --
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. This software is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with GNAT; see file COPYING. If not, --
-- see <http://www.gnu.org/licenses/>. --
-- --
------------------------------------------------------------------------------
with Ada.Text_IO;
with GNAT.OS_Lib;
package body GPRtools.Sigint is
-------------
-- Handler --
-------------
procedure Handler is
begin
Ada.Text_IO.Put_Line ("*** Interrupted ***");
GNAT.OS_Lib.OS_Exit (2);
end Handler;
end GPRtools.Sigint;
|
reznikmm/matreshka | Ada | 17,192 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements;
with AMF.Internals.Element_Collections;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.OCL_Attributes;
with AMF.UML.Comments.Collections;
with AMF.UML.Dependencies.Collections;
with AMF.UML.Elements.Collections;
with AMF.UML.Named_Elements;
with AMF.UML.Namespaces.Collections;
with AMF.UML.Packages.Collections;
with AMF.UML.String_Expressions;
with AMF.UML.Types;
with AMF.Visitors.OCL_Iterators;
with AMF.Visitors.OCL_Visitors;
with League.Strings.Internals;
with Matreshka.Internals.Strings;
package body AMF.Internals.OCL_Null_Literal_Exps is
--------------
-- Get_Type --
--------------
overriding function Get_Type
(Self : not null access constant OCL_Null_Literal_Exp_Proxy)
return AMF.UML.Types.UML_Type_Access is
begin
return
AMF.UML.Types.UML_Type_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Type
(Self.Element)));
end Get_Type;
--------------
-- Set_Type --
--------------
overriding procedure Set_Type
(Self : not null access OCL_Null_Literal_Exp_Proxy;
To : AMF.UML.Types.UML_Type_Access) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Type
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Type;
---------------------------
-- Get_Client_Dependency --
---------------------------
overriding function Get_Client_Dependency
(Self : not null access constant OCL_Null_Literal_Exp_Proxy)
return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency is
begin
return
AMF.UML.Dependencies.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Client_Dependency
(Self.Element)));
end Get_Client_Dependency;
--------------
-- Get_Name --
--------------
overriding function Get_Name
(Self : not null access constant OCL_Null_Literal_Exp_Proxy)
return AMF.Optional_String is
begin
declare
use type Matreshka.Internals.Strings.Shared_String_Access;
Aux : constant Matreshka.Internals.Strings.Shared_String_Access
:= AMF.Internals.Tables.OCL_Attributes.Internal_Get_Name (Self.Element);
begin
if Aux = null then
return (Is_Empty => True);
else
return (False, League.Strings.Internals.Create (Aux));
end if;
end;
end Get_Name;
--------------
-- Set_Name --
--------------
overriding procedure Set_Name
(Self : not null access OCL_Null_Literal_Exp_Proxy;
To : AMF.Optional_String) is
begin
if To.Is_Empty then
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Name
(Self.Element, null);
else
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Name
(Self.Element,
League.Strings.Internals.Internal (To.Value));
end if;
end Set_Name;
-------------------------
-- Get_Name_Expression --
-------------------------
overriding function Get_Name_Expression
(Self : not null access constant OCL_Null_Literal_Exp_Proxy)
return AMF.UML.String_Expressions.UML_String_Expression_Access is
begin
return
AMF.UML.String_Expressions.UML_String_Expression_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Name_Expression
(Self.Element)));
end Get_Name_Expression;
-------------------------
-- Set_Name_Expression --
-------------------------
overriding procedure Set_Name_Expression
(Self : not null access OCL_Null_Literal_Exp_Proxy;
To : AMF.UML.String_Expressions.UML_String_Expression_Access) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Name_Expression
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Name_Expression;
-------------------
-- Get_Namespace --
-------------------
overriding function Get_Namespace
(Self : not null access constant OCL_Null_Literal_Exp_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access is
begin
return
AMF.UML.Namespaces.UML_Namespace_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Namespace
(Self.Element)));
end Get_Namespace;
------------------------
-- Get_Qualified_Name --
------------------------
overriding function Get_Qualified_Name
(Self : not null access constant OCL_Null_Literal_Exp_Proxy)
return AMF.Optional_String is
begin
declare
use type Matreshka.Internals.Strings.Shared_String_Access;
Aux : constant Matreshka.Internals.Strings.Shared_String_Access
:= AMF.Internals.Tables.OCL_Attributes.Internal_Get_Qualified_Name (Self.Element);
begin
if Aux = null then
return (Is_Empty => True);
else
return (False, League.Strings.Internals.Create (Aux));
end if;
end;
end Get_Qualified_Name;
--------------------
-- Get_Visibility --
--------------------
overriding function Get_Visibility
(Self : not null access constant OCL_Null_Literal_Exp_Proxy)
return AMF.UML.Optional_UML_Visibility_Kind is
begin
return
AMF.Internals.Tables.OCL_Attributes.Internal_Get_Visibility
(Self.Element);
end Get_Visibility;
--------------------
-- Set_Visibility --
--------------------
overriding procedure Set_Visibility
(Self : not null access OCL_Null_Literal_Exp_Proxy;
To : AMF.UML.Optional_UML_Visibility_Kind) is
begin
AMF.Internals.Tables.OCL_Attributes.Internal_Set_Visibility
(Self.Element, To);
end Set_Visibility;
-----------------------
-- Get_Owned_Comment --
-----------------------
overriding function Get_Owned_Comment
(Self : not null access constant OCL_Null_Literal_Exp_Proxy)
return AMF.UML.Comments.Collections.Set_Of_UML_Comment is
begin
return
AMF.UML.Comments.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Comment
(Self.Element)));
end Get_Owned_Comment;
-----------------------
-- Get_Owned_Element --
-----------------------
overriding function Get_Owned_Element
(Self : not null access constant OCL_Null_Literal_Exp_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element is
begin
return
AMF.UML.Elements.Collections.Wrap
(AMF.Internals.Element_Collections.Wrap
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owned_Element
(Self.Element)));
end Get_Owned_Element;
---------------
-- Get_Owner --
---------------
overriding function Get_Owner
(Self : not null access constant OCL_Null_Literal_Exp_Proxy)
return AMF.UML.Elements.UML_Element_Access is
begin
return
AMF.UML.Elements.UML_Element_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.OCL_Attributes.Internal_Get_Owner
(Self.Element)));
end Get_Owner;
--------------------
-- All_Namespaces --
--------------------
overriding function All_Namespaces
(Self : not null access constant OCL_Null_Literal_Exp_Proxy)
return AMF.UML.Namespaces.Collections.Ordered_Set_Of_UML_Namespace is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Namespaces unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Null_Literal_Exp_Proxy.All_Namespaces";
return All_Namespaces (Self);
end All_Namespaces;
-------------------------
-- All_Owning_Packages --
-------------------------
overriding function All_Owning_Packages
(Self : not null access constant OCL_Null_Literal_Exp_Proxy)
return AMF.UML.Packages.Collections.Set_Of_UML_Package is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Owning_Packages unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Null_Literal_Exp_Proxy.All_Owning_Packages";
return All_Owning_Packages (Self);
end All_Owning_Packages;
-----------------------------
-- Is_Distinguishable_From --
-----------------------------
overriding function Is_Distinguishable_From
(Self : not null access constant OCL_Null_Literal_Exp_Proxy;
N : AMF.UML.Named_Elements.UML_Named_Element_Access;
Ns : AMF.UML.Namespaces.UML_Namespace_Access)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Is_Distinguishable_From unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Null_Literal_Exp_Proxy.Is_Distinguishable_From";
return Is_Distinguishable_From (Self, N, Ns);
end Is_Distinguishable_From;
---------------
-- Namespace --
---------------
overriding function Namespace
(Self : not null access constant OCL_Null_Literal_Exp_Proxy)
return AMF.UML.Namespaces.UML_Namespace_Access is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Namespace unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Null_Literal_Exp_Proxy.Namespace";
return Namespace (Self);
end Namespace;
--------------------
-- Qualified_Name --
--------------------
overriding function Qualified_Name
(Self : not null access constant OCL_Null_Literal_Exp_Proxy)
return League.Strings.Universal_String is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Qualified_Name unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Null_Literal_Exp_Proxy.Qualified_Name";
return Qualified_Name (Self);
end Qualified_Name;
---------------
-- Separator --
---------------
overriding function Separator
(Self : not null access constant OCL_Null_Literal_Exp_Proxy)
return League.Strings.Universal_String is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Separator unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Null_Literal_Exp_Proxy.Separator";
return Separator (Self);
end Separator;
------------------------
-- All_Owned_Elements --
------------------------
overriding function All_Owned_Elements
(Self : not null access constant OCL_Null_Literal_Exp_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "All_Owned_Elements unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Null_Literal_Exp_Proxy.All_Owned_Elements";
return All_Owned_Elements (Self);
end All_Owned_Elements;
-------------------
-- Must_Be_Owned --
-------------------
overriding function Must_Be_Owned
(Self : not null access constant OCL_Null_Literal_Exp_Proxy)
return Boolean is
begin
-- Generated stub: replace with real body!
pragma Compile_Time_Warning (Standard.True, "Must_Be_Owned unimplemented");
raise Program_Error with "Unimplemented procedure OCL_Null_Literal_Exp_Proxy.Must_Be_Owned";
return Must_Be_Owned (Self);
end Must_Be_Owned;
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant OCL_Null_Literal_Exp_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.OCL_Visitors.OCL_Visitor'Class then
AMF.Visitors.OCL_Visitors.OCL_Visitor'Class
(Visitor).Enter_Null_Literal_Exp
(AMF.OCL.Null_Literal_Exps.OCL_Null_Literal_Exp_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant OCL_Null_Literal_Exp_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.OCL_Visitors.OCL_Visitor'Class then
AMF.Visitors.OCL_Visitors.OCL_Visitor'Class
(Visitor).Leave_Null_Literal_Exp
(AMF.OCL.Null_Literal_Exps.OCL_Null_Literal_Exp_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant OCL_Null_Literal_Exp_Proxy;
Iterator : in out AMF.Visitors.Abstract_Iterator'Class;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Iterator in AMF.Visitors.OCL_Iterators.OCL_Iterator'Class then
AMF.Visitors.OCL_Iterators.OCL_Iterator'Class
(Iterator).Visit_Null_Literal_Exp
(Visitor,
AMF.OCL.Null_Literal_Exps.OCL_Null_Literal_Exp_Access (Self),
Control);
end if;
end Visit_Element;
end AMF.Internals.OCL_Null_Literal_Exps;
|
AdaCore/libadalang | Ada | 185 | adb | package body Test_Pragma is
package body Inner is
function F (A : Address_Type) return Boolean is
begin
return True;
end F;
end Inner;
end Test_Pragma;
|
msrLi/portingSources | Ada | 836 | adb | -- Copyright 2008-2014 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
package body Pck is
procedure Do_Nothing (A : System.Address) is
begin
null;
end Do_Nothing;
end Pck;
|
stcarrez/ada-awa | Ada | 10,182 | adb | -----------------------------------------------------------------------
-- awa-questions-modules -- Module questions
-- Copyright (C) 2012, 2013, 2015, 2016, 2018, 2022 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Calendar;
with Ada.Characters.Conversions;
with AWA.Permissions;
with AWA.Services.Contexts;
with AWA.Users.Models;
with AWA.Workspaces.Models;
with AWA.Workspaces.Modules;
with Wiki;
with Wiki.Utils;
with ADO.Sessions;
with ADO.Statements;
with Util.Log.Loggers;
with AWA.Modules.Beans;
with AWA.Modules.Get;
with AWA.Questions.Beans;
with AWA.Applications;
package body AWA.Questions.Modules is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Questions.Module");
package Register is new AWA.Modules.Beans (Module => Question_Module,
Module_Access => Question_Module_Access);
-- ------------------------------
-- Initialize the questions module.
-- ------------------------------
overriding
procedure Initialize (Plugin : in out Question_Module;
App : in AWA.Modules.Application_Access;
Props : in ASF.Applications.Config) is
begin
Log.Info ("Initializing the questions module");
-- Setup the resource bundles.
App.Register ("questionMsg", "questions");
-- Edit and save a question.
Register.Register (Plugin => Plugin,
Name => "AWA.Questions.Beans.Question_Bean",
Handler => AWA.Questions.Beans.Create_Question_Bean'Access);
-- Edit and save an answer.
Register.Register (Plugin => Plugin,
Name => "AWA.Questions.Beans.Answer_Bean",
Handler => AWA.Questions.Beans.Create_Answer_Bean'Access);
-- List of questions.
Register.Register (Plugin => Plugin,
Name => "AWA.Questions.Beans.Question_List_Bean",
Handler => AWA.Questions.Beans.Create_Question_List_Bean'Access);
-- Display a question with its answers.
Register.Register (Plugin => Plugin,
Name => "AWA.Questions.Beans.Question_Display_Bean",
Handler => AWA.Questions.Beans.Create_Question_Display_Bean'Access);
AWA.Modules.Module (Plugin).Initialize (App, Props);
end Initialize;
-- ------------------------------
-- Get the questions module.
-- ------------------------------
function Get_Question_Module return Question_Module_Access is
function Get is new AWA.Modules.Get (Question_Module, Question_Module_Access, NAME);
begin
return Get;
end Get_Question_Module;
-- ------------------------------
-- Create or save the question.
-- ------------------------------
procedure Save_Question (Model : in Question_Module;
Question : in out AWA.Questions.Models.Question_Ref'Class) is
pragma Unreferenced (Model);
function To_Wide (Item : in String) return Wide_Wide_String
renames Ada.Characters.Conversions.To_Wide_Wide_String;
Ctx : constant Services.Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
User : constant AWA.Users.Models.User_Ref := Ctx.Get_User;
DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx);
WS : AWA.Workspaces.Models.Workspace_Ref;
begin
Ctx.Start;
if Question.Is_Inserted then
Log.Info ("Updating question {0}", ADO.Identifier'Image (Question.Get_Id));
WS := AWA.Workspaces.Models.Workspace_Ref (Question.Get_Workspace);
else
Log.Info ("Creating new question {0}", String '(Question.Get_Title));
AWA.Workspaces.Modules.Get_Workspace (DB, Ctx, WS);
-- Check that the user has the create permission on the given workspace.
AWA.Permissions.Check (Permission => ACL_Create_Questions.Permission,
Entity => WS);
Question.Set_Workspace (WS);
Question.Set_Author (User);
end if;
declare
Text : constant String := Wiki.Utils.To_Text (To_Wide (Question.Get_Description),
Wiki.SYNTAX_MARKDOWN);
Last : Natural;
begin
if Text'Length < SHORT_DESCRIPTION_LENGTH then
Last := Text'Last;
else
Last := SHORT_DESCRIPTION_LENGTH;
end if;
Question.Set_Short_Description (Text (Text'First .. Last) & "...");
end;
if not Question.Is_Inserted then
Question.Set_Create_Date (Ada.Calendar.Clock);
else
Question.Set_Edit_Date (ADO.Nullable_Time '(Is_Null => False,
Value => Ada.Calendar.Clock));
end if;
Question.Save (DB);
Ctx.Commit;
end Save_Question;
-- ------------------------------
-- Delete the question.
-- ------------------------------
procedure Delete_Question (Model : in Question_Module;
Question : in out AWA.Questions.Models.Question_Ref'Class) is
pragma Unreferenced (Model);
Ctx : constant Services.Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx);
begin
Ctx.Start;
-- Check that the user has the delete permission on the given question.
AWA.Permissions.Check (Permission => ACL_Delete_Questions.Permission,
Entity => Question);
-- Before deleting the question, delete the associated answers.
declare
Stmt : ADO.Statements.Delete_Statement
:= DB.Create_Statement (AWA.Questions.Models.ANSWER_TABLE);
begin
Stmt.Set_Filter (Filter => "question_id = ?");
Stmt.Add_Param (Value => Question);
Stmt.Execute;
end;
Question.Delete (DB);
Ctx.Commit;
end Delete_Question;
-- ------------------------------
-- Load the question.
-- ------------------------------
procedure Load_Question (Model : in Question_Module;
Question : in out AWA.Questions.Models.Question_Ref'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
DB : ADO.Sessions.Session := Model.Get_Session;
begin
Question.Load (DB, Id, Found);
end Load_Question;
-- ------------------------------
-- Create or save the answer.
-- ------------------------------
procedure Save_Answer (Model : in Question_Module;
Question : in AWA.Questions.Models.Question_Ref'Class;
Answer : in out AWA.Questions.Models.Answer_Ref'Class) is
pragma Unreferenced (Model);
Ctx : constant Services.Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
User : constant AWA.Users.Models.User_Ref := Ctx.Get_User;
DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx);
begin
Ctx.Start;
if Answer.Is_Inserted then
Log.Info ("Updating question {0}", ADO.Identifier'Image (Answer.Get_Id));
else
Log.Info ("Creating new answer for {0}", ADO.Identifier'Image (Question.Get_Id));
-- Check that the user has the create permission on the given workspace.
AWA.Permissions.Check (Permission => ACL_Answer_Questions.Permission,
Entity => Question);
Answer.Set_Author (User);
end if;
if not Answer.Is_Inserted then
Answer.Set_Create_Date (Ada.Calendar.Clock);
Answer.Set_Question (Question);
else
Answer.Set_Edit_Date (ADO.Nullable_Time '(Value => Ada.Calendar.Clock,
Is_Null => False));
end if;
Answer.Save (DB);
Ctx.Commit;
end Save_Answer;
-- ------------------------------
-- Delete the answer.
-- ------------------------------
procedure Delete_Answer (Model : in Question_Module;
Answer : in out AWA.Questions.Models.Answer_Ref'Class) is
pragma Unreferenced (Model);
Ctx : constant Services.Contexts.Service_Context_Access := AWA.Services.Contexts.Current;
DB : ADO.Sessions.Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx);
begin
Ctx.Start;
-- Check that the user has the delete permission on the given answer.
AWA.Permissions.Check (Permission => ACL_Delete_Answer.Permission,
Entity => Answer);
Answer.Delete (DB);
Ctx.Commit;
end Delete_Answer;
-- ------------------------------
-- Load the answer.
-- ------------------------------
procedure Load_Answer (Model : in Question_Module;
Answer : in out AWA.Questions.Models.Answer_Ref'Class;
Question : in out AWA.Questions.Models.Question_Ref'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
DB : ADO.Sessions.Session := Model.Get_Session;
begin
Answer.Load (DB, Id, Found);
Question := Answer.Get_Question;
end Load_Answer;
end AWA.Questions.Modules;
|
wookey-project/ewok-legacy | Ada | 2,494 | ads | --
-- Copyright 2018 The wookey project team <[email protected]>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with ada.unchecked_conversion;
with ewok.perm;
with ewok.exported.dma;
with ewok.exported.devices;
with soc.interrupts;
with types.c;
package c.socinfo
with spark_mode => off
is
subtype t_dev_interrupt_range is
unsigned_8 range 1 .. ewok.exported.devices.MAX_INTERRUPTS;
type t_interrupt_list is array (t_dev_interrupt_range) of soc.interrupts.t_interrupt;
type t_device_soc_infos is record
name_ptr : system_address;
base_addr : system_address;
rcc_enr : system_address;
rcc_enb : unsigned_32;
size : unsigned_32;
subregions : unsigned_8;
interrupt_list : t_interrupt_list;
ro : types.c.bool;
minperm : ewok.perm.t_perm_name;
end record;
type t_device_soc_infos_access is access all t_device_soc_infos;
function to_device_soc_infos is new ada.unchecked_conversion
(system_address, t_device_soc_infos_access);
function soc_devmap_find_device
(addr : system_address;
size : unsigned_32)
return t_device_soc_infos_access
with
convention => c,
import => true,
external_name => "soc_devmap_find_device";
function soc_devmap_find_dma_device
(dma_controller : ewok.exported.dma.t_controller;
stream : ewok.exported.dma.t_stream)
return t_device_soc_infos_access
with
convention => c,
import => true,
external_name => "soc_devices_get_dma";
procedure soc_devmap_enable_clock
(socdev : t_device_soc_infos)
with
convention => c,
import => true,
external_name => "soc_devmap_enable_clock";
end c.socinfo;
|
sonneveld/adazmq | Ada | 2,172 | adb | -- Weather update server
-- Binds PUB socket to tcp://*:5556
-- Publishes random weather updates
with Ada.Command_Line;
with Ada.Text_IO;
with Ada.Numerics.Discrete_Random;
with GNAT.Formatted_String;
with ZMQ;
procedure WUServer is
use type GNAT.Formatted_String.Formatted_String;
type Zip_Code_T is range 0 .. 100000;
type Temperature_T is range -80 .. 135;
type Rel_Humidity_T is range 10 .. 60;
package Random_Zip_Code is new Ada.Numerics.Discrete_Random (Zip_Code_T);
package Random_Temperature is new Ada.Numerics.Discrete_Random (Temperature_T);
package Random_Rel_Humidity is new Ada.Numerics.Discrete_Random (Rel_Humidity_T);
function Main return Ada.Command_Line.Exit_Status
is
Random_Zip_Code_Seed : Random_Zip_Code.Generator;
Random_Temperature_Seed : Random_Temperature.Generator;
Random_Rel_Humidity_Seed : Random_Rel_Humidity.Generator;
begin
-- Initialize random number generator
Random_Zip_Code.Reset (Random_Zip_Code_Seed);
Random_Temperature.Reset (Random_Temperature_Seed);
Random_Rel_Humidity.Reset (Random_Rel_Humidity_Seed);
declare
-- Prepare our context and publisher
Context : ZMQ.Context_Type := ZMQ.New_Context;
Publisher : constant ZMQ.Socket_Type'Class := Context.New_Socket (ZMQ.ZMQ_PUB);
begin
Publisher.Bind ("tcp://*:5556");
loop
-- Get values that will fool the boss
declare
Zip_Code : constant Zip_Code_T := Random_Zip_Code.Random (Random_Zip_Code_Seed);
Temperature : constant Temperature_T := Random_Temperature.Random (Random_Temperature_Seed);
Rel_Humidity : constant Rel_Humidity_T := Random_Rel_Humidity.Random (Random_Rel_Humidity_Seed);
begin
-- Send message to all subscribers
Publisher.Send (-(+"%05d %d %d"&Integer (Zip_Code) & Integer (Temperature) & Integer (Rel_Humidity)));
end;
end loop;
Publisher.Close;
Context.Term;
end;
return 0;
end Main;
begin
Ada.Command_Line.Set_Exit_Status (Main);
end WUServer;
|
AdaCore/training_material | Ada | 770 | ads | pragma Unevaluated_Use_Of_Old (Allow);
with Loop_Types; use Loop_Types;
use Loop_Types.Vectors; use Loop_Types.Lists;
package Loop_Init is
type Index is range 1 .. 10;
type Table is array (Index range <>) of Integer;
procedure Init_Table (T : out Table)
with
Relaxed_Initialization => T,
Post => (for all J in T'Range => T(J) = 0);
procedure Bump_Table (T : in out Table)
with
Pre => (for all J in T'Range => T(J) < Integer'Last),
Post => (for all J in T'Range => T(J) = T'Old(J) + 1);
procedure Init_Vector (V : in out Vector)
with
Post => (for all J in V.First_Index .. V.Last_Index => V.Element (J) = 0);
procedure Init_List (L : in out List)
with
Post => (for all E of L => E = 0);
end Loop_Init;
|
reznikmm/matreshka | Ada | 3,689 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Text_Month_Attributes is
pragma Preelaborate;
type ODF_Text_Month_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Text_Month_Attribute_Access is
access all ODF_Text_Month_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Text_Month_Attributes;
|
johnperry-math/hac | Ada | 12,216 | adb | -------------------------------------------------------------------------------------
--
-- HAC - HAC Ada Compiler
--
-- A compiler in Ada for an Ada subset
--
-- Copyright, license, etc. : see top package.
--
-------------------------------------------------------------------------------------
--
with HAC_Sys.Parser.Enter_Def,
HAC_Sys.Parser.Helpers,
HAC_Sys.Parser.Ranges,
HAC_Sys.Scanner,
HAC_Sys.UErrors;
package body HAC_Sys.Parser.Type_Def is
use Enter_Def, Helpers, PCode, UErrors;
procedure Number_Declaration_or_Enum_Item_or_Literal_Char (
CD : in out Compiler_Data;
Level : in PCode.Nesting_level;
FSys_ND : in Symset;
C : out Constant_Rec
)
is
-- This covers number declarations (RM 3.3.2) and enumeration items (RM 3.5.1).
-- Additionally this compiler does on-the-fly declarations for static values:
-- bounds in ranges (FOR, ARRAY), and values in CASE statements.
-- Was: Constant in the Pascal compiler.
X : Integer;
Sign : HAC_Integer;
use type HAC_Integer;
signed : Boolean := False;
procedure InSymbol is begin Scanner.InSymbol (CD); end InSymbol;
begin
C.TP := Type_Undefined;
C.I := 0;
Test (CD, Constant_Definition_Begin_Symbol, FSys_ND, err_illegal_symbol_for_a_number_declaration);
if not Constant_Definition_Begin_Symbol (CD.Sy) then
return;
end if;
if CD.Sy = CharCon then -- Untyped character constant, occurs only in ranges.
C.TP := (Chars, 0);
C.I := CD.INum;
InSymbol;
else
Sign := 1;
if Plus_Minus (CD.Sy) then
signed := True;
if CD.Sy = Minus then
Sign := -1;
end if;
InSymbol;
end if;
if CD.Sy = IDent then
-- Number defined using another one: "minus_pi : constant := -pi;"
-- ... or, we have an enumeration item.
X := Locate_Identifier (CD, CD.Id, Level);
if X /= 0 then
if CD.IdTab (X).Obj /= Declared_Number_or_Enum_Item then
Error (CD, err_illegal_constant_or_constant_identifier);
else
C.TP := CD.IdTab (X).xTyp;
if C.TP.TYP = Floats then
C.R := HAC_Float (Sign) * CD.Float_Constants_Table (CD.IdTab (X).Adr_or_Sz);
else
C.I := Sign * HAC_Integer (CD.IdTab (X).Adr_or_Sz);
if signed and then C.TP.TYP not in Numeric_Typ then
Error (CD, err_numeric_constant_expected);
end if;
end if;
end if;
end if; -- X /= 0
InSymbol;
elsif CD.Sy = IntCon then
C.TP := (Ints, 0);
C.I := Sign * CD.INum;
InSymbol;
elsif CD.Sy = FloatCon then
C.TP := (Floats, 0);
C.R := HAC_Float (Sign) * CD.RNum;
InSymbol;
else
Skip (CD, FSys_ND, err_illegal_symbol_for_a_number_declaration);
end if;
end if;
Test (CD, FSys_ND, Empty_Symset, err_incorrectly_used_symbol);
end Number_Declaration_or_Enum_Item_or_Literal_Char;
procedure Type_Declaration (
CD : in out Compiler_Data;
Level : in PCode.Nesting_level;
FSys_NTD : in Symset
)
is
T1 : Integer;
procedure InSymbol is begin Scanner.InSymbol (CD); end InSymbol;
begin
InSymbol; -- Consume TYPE or SUBTYPE symbol.
Test (CD, IDent_Set, Semicolon_Set, err_identifier_missing);
Enter (CD, Level, CD.Id, CD.Id_with_case, TypeMark);
T1 := CD.Id_Count;
InSymbol;
Need (CD, IS_Symbol, err_IS_missing);
declare
New_T : IdTabEntry renames CD.IdTab (T1);
begin
Type_Definition (
CD, Level,
FSys_TD => Comma_IDent_Semicolon + FSys_NTD,
xTP => New_T.xTyp,
Size => New_T.Adr_or_Sz,
First => New_T.Discrete_First,
Last => New_T.Discrete_Last
);
end;
--
Test_Semicolon_in_Declaration (CD, FSys_NTD);
end Type_Declaration;
procedure Type_Definition (
CD : in out Compiler_Data;
Initial_Level : in PCode.Nesting_level;
FSys_TD : in Symset;
xTP : out Exact_Typ;
Size : out Integer;
First : out HAC_Integer; -- T'First value if discrete
Last : out HAC_Integer -- T'Last value if discrete
)
is
Level : Nesting_level := Initial_Level;
procedure InSymbol is begin Scanner.InSymbol (CD); end InSymbol;
--
-- constrained_array_definition 3.6 (5)
--
procedure Array_Typ (
Arr_Tab_Ref, Arr_Size : out Integer;
String_Constrained_Subtype : Boolean
)
is
Element_Exact_Typ : Exact_Typ;
Element_Size : Integer;
Lower_Bound : Constant_Rec;
Higher_Bound : Constant_Rec;
Dummy_First : HAC_Integer;
Dummy_Last : HAC_Integer;
use Ranges;
begin
Static_Range (CD, Level, FSys_TD, err_illegal_array_bounds, Lower_Bound, Higher_Bound);
Enter_Array (CD, Lower_Bound.TP, Integer (Lower_Bound.I), Integer (Higher_Bound.I));
Arr_Tab_Ref := CD.Arrays_Count;
if String_Constrained_Subtype then
-- We define String (L .. H) exactly as an "array (L .. H) of Character".
Element_Exact_Typ := (TYP => Chars, Ref => 0);
Element_Size := 1;
Need (CD, RParent, err_closing_parenthesis_missing, Forgive => RBrack);
elsif CD.Sy = Comma then
-- Multidimensional array is equivalant to: array (range_1) of array (range_2,...).
InSymbol; -- Consume ',' symbol.
Element_Exact_Typ.TYP := Arrays; -- Recursion for next array dimension.
Array_Typ (Element_Exact_Typ.Ref, Element_Size, False);
else
Need (CD, RParent, err_closing_parenthesis_missing, Forgive => RBrack);
Need (CD, OF_Symbol, err_missing_OF); -- "of" in "array (...) of Some_Type"
Type_Definition (
CD, Level, FSys_TD,
Element_Exact_Typ, Element_Size, Dummy_First, Dummy_Last
);
end if;
Arr_Size := (Integer (Higher_Bound.I) - Integer (Lower_Bound.I) + 1) * Element_Size;
declare
New_A : ATabEntry renames CD.Arrays_Table (Arr_Tab_Ref);
begin
New_A.Array_Size := Arr_Size; -- Index_xTyp, Low, High already set by Enter_Array.
New_A.Element_xTyp := Element_Exact_Typ;
New_A.Element_Size := Element_Size;
end;
end Array_Typ;
procedure Enumeration_Typ is -- RM 3.5.1 Enumeration Types
enum_count : Natural := 0;
begin
xTP := (TYP => Enums, Ref => CD.Id_Count);
loop
InSymbol; -- Consume '(' symbol.
if CD.Sy = IDent then
enum_count := enum_count + 1;
Enter (CD, Level, CD.Id, CD.Id_with_case, Declared_Number_or_Enum_Item);
declare
New_Enum_Item : IdTabEntry renames CD.IdTab (CD.Id_Count);
begin
New_Enum_Item.Read_only := True;
New_Enum_Item.xTyp := xTP;
New_Enum_Item.Adr_or_Sz := enum_count - 1; -- RM 3.5.1 (7): position begins with 0.
end;
else
Error (CD, err_identifier_missing);
end if;
InSymbol;
exit when CD.Sy /= Comma;
end loop;
Size := 1;
First := 0;
Last := HAC_Integer (enum_count - 1);
Need (CD, RParent, err_closing_parenthesis_missing);
end Enumeration_Typ;
procedure Record_Typ is
Field_Exact_Typ : Exact_Typ;
Field_Size, Offset, T0, T1 : Integer;
Dummy_First : HAC_Integer;
Dummy_Last : HAC_Integer;
begin
InSymbol; -- Consume RECORD symbol.
Enter_Block (CD, CD.Id_Count);
xTP := (TYP => Records, Ref => CD.Blocks_Count);
if Level = Nesting_Level_Max then
Fatal (LEVELS); -- Exception is raised there.
end if;
Level := Level + 1;
CD.Display (Level) := CD.Blocks_Count;
Offset := 0;
--
loop
if CD.Sy /= IDent then
Error (CD, err_identifier_missing, stop => True);
else -- RM 3.8 Component declaration
T0 := CD.Id_Count;
Enter_Variables (CD, Level);
Need (CD, Colon, err_colon_missing); -- ':' in "a, b, c : Integer;"
T1 := CD.Id_Count;
Type_Definition (
CD, Level, FSys_TD + Comma_END_IDent_Semicolon,
Field_Exact_Typ, Field_Size, Dummy_First, Dummy_Last
);
while T0 < T1 loop
T0 := T0 + 1;
CD.IdTab (T0).xTyp := Field_Exact_Typ;
CD.IdTab (T0).Adr_or_Sz := Offset;
Offset := Offset + Field_Size;
end loop;
end if;
Need (CD, Semicolon, err_semicolon_missing, Forgive => Comma);
Ignore_Extra_Semicolons (CD);
exit when CD.Sy = END_Symbol;
end loop;
--
CD.Blocks_Table (xTP.Ref).VSize := Offset;
Size := Offset;
CD.Blocks_Table (xTP.Ref).PSize := 0;
InSymbol;
Need (CD, RECORD_Symbol, err_RECORD_missing); -- (END) RECORD
Level := Level - 1;
end Record_Typ;
procedure String_Sub_Typ is
-- Prototype of constraining an array type: String -> String (1 .. 26)
-- !! Need to implement general constraints...
begin
InSymbol;
Need (CD, LParent, err_missing_an_opening_parenthesis, Forgive => LBrack);
xTP.TYP := Arrays;
Array_Typ (xTP.Ref, Size, String_Constrained_Subtype => True);
end String_Sub_Typ;
-- Here we are sitting on `Character` in `subtype My_Chars is Character` [range 'a' .. 'z']
--
procedure Sub_Typ is
Ident_Index : constant Integer := Locate_Identifier (CD, CD.Id, Level);
Low, High : Constant_Rec;
begin
if Ident_Index = No_Id then
return; -- Error already issued due to undefined identifier
end if;
declare
Id_T : IdTabEntry renames CD.IdTab (Ident_Index);
begin
if Id_T.Obj = TypeMark then
xTP := Id_T.xTyp;
Size := Id_T.Adr_or_Sz;
First := Id_T.Discrete_First;
Last := Id_T.Discrete_Last;
if xTP.TYP = NOTYP then
Error (CD, err_undefined_type);
end if;
else
Error (CD, err_missing_a_type_identifier);
end if;
end;
InSymbol;
if CD.Sy = RANGE_Keyword_Symbol then
-- Here comes the optional ` range 'a' .. 'z' ` constraint.
InSymbol;
Ranges.Explicit_Static_Range (CD, Level, FSys_TD, err_range_constraint_error, Low, High);
if Low.TP /= xTP then
Error (CD, err_range_constraint_error, "type of bounds don't match with the parent type");
elsif Low.I not in First .. Last then
Error (CD, err_range_constraint_error, "lower bound is out of parent type's range");
elsif High.I not in First .. Last then
Error (CD, err_range_constraint_error, "higher bound is out of parent type's range");
else
First := Low.I;
Last := High.I;
end if;
end if;
end Sub_Typ;
begin
xTP := Type_Undefined;
Size := 0;
First := 0;
Last := 0;
Test (CD, Type_Begin_Symbol, FSys_TD, err_missing_ARRAY_RECORD_or_ident);
if Type_Begin_Symbol (CD.Sy) then
case CD.Sy is
when IDent =>
if Equal (CD.Id, "STRING") then
String_Sub_Typ;
else
Sub_Typ;
end if;
when ARRAY_Symbol =>
InSymbol;
Need (CD, LParent, err_missing_an_opening_parenthesis, Forgive => LBrack);
xTP.TYP := Arrays;
Array_Typ (xTP.Ref, Size, String_Constrained_Subtype => False);
when RECORD_Symbol =>
Record_Typ;
when LParent =>
Enumeration_Typ;
when others =>
null;
end case; -- CD.Sy
Test (CD, FSys_TD, Empty_Symset, err_incorrectly_used_symbol);
end if;
if CD.Err_Count = 0 then
pragma Assert (Level = Initial_Level);
end if;
end Type_Definition;
end HAC_Sys.Parser.Type_Def;
|
AaronC98/PlaneSystem | Ada | 3,927 | ads | ------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 2000-2014, AdaCore --
-- --
-- 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. --
-- --
-- --
-- --
-- --
-- --
-- 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/>. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
pragma Ada_2012;
-- Some utilities for HTTP digest authentication
with GNAT.MD5;
package AWS.Digest is
subtype Digest_String is GNAT.MD5.Message_Digest with
Dynamic_Predicate =>
(for all C of Digest_String
=> C in 'a' .. 'z' | 'A' .. 'Z' | '0' .. '9' | '+' | '/' | '=');
subtype Nonce is String (1 .. 40);
-- 4 bytes base64 seconds, 4 bytes base64 global counter, 32 bytes digest
-- of the private key, creation time and global counter.
function Create_Nonce return Nonce;
-- Create a Nonce value for the digest authentication
-- see [RFC-2617 - 3.2.1]
function Check_Nonce (Value : String) return Boolean;
-- Check Nonce for validity and expiration.
-- We could not send a type Nonce here, because Nonce received from
-- HTTP client, and have to checked for the length too.
function Create
(Username, Realm, Password : String;
Nonce : String;
Method, URI : String) return Digest_String with Inline;
-- Returns a simple MD5 Digest
function Create
(Username, Realm, Password : String;
Nonce, NC, CNonce, QOP : String;
Method, URI : String) return Digest_String;
-- Returns a more complex MD5 Digest if QOP field is not empty
function Tail
(Nonce, NC, CNonce, QOP, Method, URI : String) return String with Inline;
-- Returns the precalculated tail part of the digest
-- if QOP field is not empty
-- Tail := ':' & Nonce & ':' & NC & ':' & CNonce & ':' & QOP & ':'
-- & MD5.Digest (Method & ':' & URI);
-- otherwise
-- Tail := ':' & Nonce & ':' & MD5.Digest (Method & ':' & URI);
end AWS.Digest;
|
reznikmm/matreshka | Ada | 5,031 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2015, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
pragma Restrictions (No_Elaboration_Code);
-- GNAT: enforce generation of preinitialized data section instead of
-- generation of elaboration code.
package Matreshka.Internals.Unicode.Ucd.Core_0100 is
pragma Preelaborate;
Group_0100 : aliased constant Core_Second_Stage
:= (16#0C# => -- 01000C
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#27# => -- 010027
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#3B# => -- 01003B
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#3E# => -- 01003E
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#4E# .. 16#4F# => -- 01004E .. 01004F
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#5E# .. 16#7F# => -- 01005E .. 01007F
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
16#FB# .. 16#FF# => -- 0100FB .. 0100FF
(Unassigned, Neutral,
Other, Other, Other, Unknown,
(others => False)),
others =>
(Other_Letter, Neutral,
Other, A_Letter, O_Letter, Alphabetic,
(Alphabetic
| Grapheme_Base
| ID_Continue
| ID_Start
| XID_Continue
| XID_Start => True,
others => False)));
end Matreshka.Internals.Unicode.Ucd.Core_0100;
|
ytomino/vampire | Ada | 5,424 | adb | -- The Village of Vampire by YT, このソースコードはNYSLです
package body Vampire.Forms.Full is
use type Villages.Village_State;
function Create return Form_Type is
begin
return (null record);
end Create;
overriding function HTML_Version (Form : Form_Type)
return Web.HTML.HTML_Version is
begin
return Web.HTML.XHTML;
end HTML_Version;
overriding function Template_Set (Form : Form_Type) return Template_Set_Type is
begin
return For_Full;
end Template_Set;
overriding function Parameters_To_Index_Page (
Form : Form_Type;
User_Id : String;
User_Password : String)
return Web.Query_Strings is
begin
return Web.String_Maps.Empty_Map;
end Parameters_To_Index_Page;
overriding function Parameters_To_User_Page (
Form : Form_Type;
User_Id : String;
User_Password : String)
return Web.Query_Strings is
begin
return Parameters : Web.Query_Strings do
Web.Include (Parameters, "user", User_Id);
end return;
end Parameters_To_User_Page;
overriding function Parameters_To_Village_Page (
Form : Form_Type;
Village_Id : Villages.Village_Id;
Day : Integer := -1;
First : Tabula.Villages.Speech_Index'Base := -1;
Last : Tabula.Villages.Speech_Index'Base := -1;
Latest : Tabula.Villages.Speech_Positive_Count'Base := -1;
User_Id : String;
User_Password : String)
return Web.Query_Strings is
begin
return Parameters : Web.Query_Strings do
Web.Include (Parameters, "village", Village_Id);
if Day >= 0 then
Web.Include (Parameters, "day", Image (Day));
end if;
if Day = 0 and then First = 0 then
Web.Include (Parameters, "range", "all");
end if;
end return;
end Parameters_To_Village_Page;
overriding procedure Write_In_HTML (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Form : in Form_Type;
Item : in String;
Pre : in Boolean := False) is
begin
Web.HTML.Write_In_HTML (Stream, Web.HTML.XHTML, Item, Pre);
end Write_In_HTML;
overriding procedure Write_In_Attribute (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Form : in Form_Type;
Item : in String) is
begin
Web.HTML.Write_In_Attribute (Stream, Web.HTML.XHTML, Item);
end Write_In_Attribute;
overriding function Paging (Form : Form_Type) return Boolean is
begin
return False;
end Paging;
overriding function Speeches_Per_Page (Form : Form_Type)
return Tabula.Villages.Speech_Positive_Count'Base is
begin
return 0;
end Speeches_Per_Page;
overriding function Get_User_Id (
Form : Form_Type;
Query_Strings : Web.Query_Strings;
Cookie : Web.Cookie)
return String is
begin
return Web.Element (Cookie, "id");
end Get_User_Id;
overriding function Get_User_Password (
Form : Form_Type;
Query_Strings : Web.Query_Strings;
Cookie : Web.Cookie)
return String is
begin
return Web.Element (Cookie, "password");
end Get_User_Password;
overriding procedure Set_User (
Form : in out Form_Type;
Cookie : in out Web.Cookie;
New_User_Id : in String;
New_User_Password : in String) is
begin
Web.String_Maps.Include (Cookie, "id", New_User_Id);
Web.String_Maps.Include (Cookie, "password", New_User_Password);
end Set_User;
overriding function Is_User_Page (
Form : Form_Type;
Query_Strings : Web.Query_Strings;
Cookie : Web.Cookie)
return Boolean
is
User_Id : constant String := Form.Get_User_Id (Query_Strings, Cookie);
begin
if User_Id'Length = 0 then
return False;
else
return Web.Element (Query_Strings, "user") = User_Id;
end if;
end Is_User_Page;
overriding function Get_Village_Id (
Form : Form_Type;
Query_Strings : Web.Query_Strings)
return Villages.Village_Id
is
S : constant String := Web.Element (Query_Strings, "village");
begin
if S'Length = Villages.Village_Id'Length then
return S;
else
return Villages.Invalid_Village_Id;
end if;
end Get_Village_Id;
overriding function Get_Day (
Form : Form_Type;
Village : Villages.Village_Type'Class;
Query_Strings : Web.Query_Strings)
return Natural
is
S : constant String := Web.Element (Query_Strings, "day");
begin
return Natural'Value (S);
exception
when Constraint_Error =>
declare
State : Villages.Village_State;
Today : Natural;
begin
Village.Get_State (State, Today);
if State /= Villages.Closed then
return Today;
else
return 0;
end if;
end;
end Get_Day;
overriding function Get_Range (
Form : Form_Type;
Village : Villages.Village_Type'Class;
Day : Natural;
Now : Ada.Calendar.Time;
Query_Strings : Web.Query_Strings)
return Villages.Speech_Range_Type
is
Speech_Range : Villages.Speech_Range_Type;
begin
if String'(Web.Element (Query_Strings, "range"))'Length = 0 then
Speech_Range := Village.Recent_Only_Speech_Range (Day, Now => Now);
else
Speech_Range := Village.Speech_Range (Day);
end if;
return (
First => Speech_Range.First,
Last => Tabula.Villages.Speech_Index'Base'Max (
Speech_Range.First,
Speech_Range.Last));
end Get_Range;
overriding function Get_New_Village_Name (
Form : Form_Type;
Inputs : Web.Query_Strings)
return String is
begin
return Trim_Name (Web.Element (Inputs, "name"));
end Get_New_Village_Name;
overriding function Get_Text (
Form : Form_Type;
Inputs : Web.Query_Strings)
return String is
begin
return Trim_Text (Web.Element (Inputs, "text"));
end Get_Text;
end Vampire.Forms.Full;
|
stcarrez/ada-keystore | Ada | 1,049 | ads | -----------------------------------------------------------------------
-- keystore-verifier -- Toolbox to explore raw content of keystore
-- Copyright (C) 2019 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package Keystore.Verifier is
procedure Print_Information (Path : in String;
Is_Keystore : out Boolean);
end Keystore.Verifier;
|
iyan22/AprendeAda | Ada | 3,098 | adb | with ada.Text_IO; use ada.Text_IO;
with lluvia;use lluvia;
with calcular_max_pico_de_lluvia;
procedure prueba_calcular_max_pico_de_lluvia is
Lluvia : T_Lluvias_Por_Pais;
Pais_Max: T_Pais;
Mes_Max: T_Mes;
package Mes_Io is new Ada.Text_Io.Enumeration_Io(T_Mes);
use Mes_Io;
begin
Lluvia:=((1,2,3,4,5,6,7,8,9,10,11,12),
(0,9,8,7,6,5,4,3,2, 1, 0, 1),
(3,5,7,6,23,2,56,7,54,3,2,4));
calcular_max_pico_de_lluvia (Lluvia,Pais_Max,Mes_Max);
Put_Line("El pais mas lluvioso es CANADA, y tu programa dice que:");
Put_Line(T_Pais'Image(Pais_Max));
Put_Line("El mes mas lluvioso es JULIO, y tu programa dice que:");
Put(Mes_Max);
new_line(3);
put_line("Pulsa return para continuar");
skip_line;
new_line(3);
Lluvia:=((1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12),
(0, 9, 8, 7, 6, 5, 9, 3, 2, 1,99, 1),
(3, 5, 7, 6,23, 2,56, 7,54, 3, 2, 4));
calcular_max_pico_de_lluvia (Lluvia,Pais_Max,Mes_Max);
Put_Line("El pais mas lluvioso es MEJICO, y tu programa dice que:");
Put_Line(T_Pais'Image(Pais_Max));
Put_Line("El mes mas lluvioso es NOVIEMBRE, y tu programa dice que:");
Put(Mes_Max);
new_line(3);
put_line("Pulsa return para continuar");
skip_line;
new_line(3);
Lluvia:=((99,2,3,4,5,6,7,8,9,10,11,12),
(0,9,8,7,6,5,4,3,2, 1, 0, 1),
(3,5,7,6,23,2,56,7,54,3,2,4));
calcular_max_pico_de_lluvia (Lluvia,Pais_Max,Mes_Max);
Put_Line("El pais mas lluvioso es EEUU, y tu programa dice que:");
Put_Line(T_Pais'Image(Pais_Max));
Put_Line("El mes mas lluvioso es ENERO, y tu programa dice que:");
Put(Mes_Max);
new_line(3);
put_line("Pulsa return para continuar");
skip_line;
new_line(3);
Lluvia:=((9,2,3,4,5,6,7,8,9,10,11,12),
(0,9,98,7,6,5,4,3,2, 1, 0, 1),
(3,5,7,6,23,2,56,7,54,3,2,4));
calcular_max_pico_de_lluvia (Lluvia,Pais_Max,Mes_Max);
Put_Line("El pais mas lluvioso es MEJICO, y tu programa dice que:");
Put_Line(T_Pais'Image(Pais_Max));
Put_Line("El mes mas lluvioso es MARZO, y tu programa dice que:");
Put(Mes_Max);
new_line(3);
put_line("Pulsa return para continuar");
skip_line;
new_line(3);
Put_Line("Este caso es especial ya que los dos paises tienen un mes en común en el que llovio, la misma cantidad");
Put_Line("Nuestro programa nos dara el ultimo valor de los iguales ya que en la comparación hemos usado >=");
Put_Line("Si hubieramos utilizado solo >, nos daría el primer valor de los iguales");
Lluvia:=((99,2,3,4,5,6,7,8,9,10,11,12),
(0,9,8,7,6,5,4,3,2, 1, 1000, 1),
(3,5,7,6,1000,2,56,7,54,3,2,4));
calcular_max_pico_de_lluvia (Lluvia,Pais_Max,Mes_Max);
Put_Line("El pais mas lluvioso es MEJICO y CANADA, y tu programa dice que:");
Put_Line(T_Pais'Image(Pais_Max));
Put_Line("El mes mas lluvioso es NOVIEMBRE y MAYO, y tu programa dice que:");
Put(Mes_Max);
new_line(3);
put_line("Pulsa return para continuar");
skip_line;
new_line(3);
end prueba_calcular_max_pico_de_lluvia; |
RREE/ada-util | Ada | 9,522 | adb | -----------------------------------------------------------------------
-- util-http-cookies-tests - Unit tests for Cookies
-- Copyright (C) 2011, 2012, 2015 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Test_Caller;
with Util.Log.Loggers;
with Util.Measures;
with Ada.Strings.Fixed;
with Ada.Unchecked_Deallocation;
package body Util.Http.Cookies.Tests is
use Ada.Strings.Fixed;
use Util.Tests;
use Util.Log;
-- The logger
Log : constant Loggers.Logger := Loggers.Create ("ASF.Cookies.Tests");
procedure Free is new Ada.Unchecked_Deallocation (Cookie_Array, Cookie_Array_Access);
package Caller is new Util.Test_Caller (Test, "Cookies");
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test ASF.Cookies.Create_Cookie",
Test_Create_Cookie'Access);
Caller.Add_Test (Suite, "Test ASF.Cookies.To_Http_Header",
Test_To_Http_Header'Access);
Caller.Add_Test (Suite, "Test ASF.Cookies.Get_Cookies",
Test_Parse_Http_Header'Access);
end Add_Tests;
-- ------------------------------
-- Test creation of cookie
-- ------------------------------
procedure Test_Create_Cookie (T : in out Test) is
C : constant Cookie := Create ("cookie", "value");
begin
T.Assert_Equals ("cookie", Get_Name (C), "Invalid name");
T.Assert_Equals ("value", Get_Value (C), "Invalid value");
T.Assert (not Is_Secure (C), "Invalid is_secure");
end Test_Create_Cookie;
-- ------------------------------
-- Test conversion of cookie for HTTP header
-- ------------------------------
procedure Test_To_Http_Header (T : in out Test) is
procedure Test_Cookie (C : in Cookie);
procedure Test_Cookie (Name : in String; Value : in String);
procedure Test_Cookie (C : in Cookie) is
S : constant String := To_Http_Header (C);
begin
Log.Info ("Cookie {0}: {1}", Get_Name (C), S);
T.Assert (S'Length > 0, "Invalid cookie length for: " & S);
T.Assert (Index (S, "=") > 0, "Invalid cookie format; " & S);
end Test_Cookie;
procedure Test_Cookie (Name : in String; Value : in String) is
C : Cookie := Create (Name, Value);
begin
Test_Cookie (C);
for I in 1 .. 24 loop
Set_Max_Age (C, I * 3600 + I);
Test_Cookie (C);
end loop;
Set_Secure (C, True);
Test_Cookie (C);
Set_Http_Only (C, True);
Test_Cookie (C);
Set_Domain (C, "world.com");
Test_Cookie (C);
Set_Path (C, "/some-path");
Test_Cookie (C);
end Test_Cookie;
begin
Test_Cookie ("a", "b");
Test_Cookie ("session_id", "79e2317bcabe731e2f681f5725bbc621-&v=1");
Test_Cookie ("p_41_zy", "");
Test_Cookie ("p_34", """quoted\t""");
Test_Cookie ("d", "s");
declare
C : Cookie := Create ("cookie-name", "79e2317bcabe731e2f681f5725bbc621");
Start : Util.Measures.Stamp;
begin
Set_Path (C, "/home");
Set_Domain (C, ".mydomain.example.com");
Set_Max_Age (C, 1000);
Set_Http_Only (C, True);
Set_Secure (C, True);
Set_Comment (C, "some comment");
for I in 1 .. 1000 loop
declare
S : constant String := To_Http_Header (C);
begin
if S'Length < 10 then
T.Assert (S'Length > 10, "Invalid cookie generation");
end if;
end;
end loop;
Util.Measures.Report (S => Start,
Title => "Generation of 1000 cookies");
end;
end Test_To_Http_Header;
-- ------------------------------
-- Test parsing of client cookie to build a list of Cookie objects
-- ------------------------------
procedure Test_Parse_Http_Header (T : in out Test) is
procedure Test_Parse (Header : in String;
Count : in Natural;
Name : in String;
Value : in String);
-- ------------------------------
-- Parse the header and check for the expected cookie count and verify
-- the value of a specific cookie
-- ------------------------------
procedure Test_Parse (Header : in String;
Count : in Natural;
Name : in String;
Value : in String) is
Start : Util.Measures.Stamp;
C : Cookie_Array_Access := Get_Cookies (Header);
Found : Boolean := False;
begin
Util.Measures.Report (S => Start,
Title => "Parsing of cookie " & Name);
T.Assert (C /= null, "Null value returned by Get_Cookies");
Assert_Equals (T, Count, C'Length, "Invalid count in result array");
for I in C'Range loop
Log.Debug ("Cookie: {0}={1}", Get_Name (C (I)), Get_Value (C (I)));
if Name = Get_Name (C (I)) then
Assert_Equals (T, Value, Get_Value (C (I)), "Invalid cookie: " & Name);
Found := True;
end if;
end loop;
T.Assert (Found, "Cookie " & Name & " not found");
Free (C);
end Test_Parse;
begin
Test_Parse ("A=B", 1, "A", "B");
Test_Parse ("A=B=", 1, "A", "B=");
Test_Parse ("CONTEXTE=mar=101&nab=84fbbe2a81887732fe9c635d9ac319b5"
& "&pfl=afide0&typsrv=we&sc=1&soumar=1011&srcurlconfigchapeau"
& "=sous_ouv_formulaire_chapeau_dei_config&nag=550®=14505; "
& "xtvrn=$354249$354336$; CEPORM=321169600.8782.0000; SES=auth=0&"
& "cartridge_url=&return_url=; CEPORC=344500416.8782.0000", 5,
"SES", "auth=0&cartridge_url=&return_url=");
Test_Parse ("s_nr=1298652863627; s_sq=%5B%5BB%5D%5D; s_cc=true; oraclelicense="
& "accept-dbindex-cookie; gpv_p24=no%20value; gpw_e24=no%20value",
6, "gpw_e24", "no%20value");
-- Parse a set of cookies from microsoft.com
Test_Parse ("WT_FPC=id=00.06.036.020-2037773472.29989343:lv=1300442685103:ss=1300442685103; "
& "MC1=GUID=9d86c397c1a5ea4cab48d9fe19b76b4e&HASH=97c3&LV=20092&V=3; "
& "A=I&I=AxUFAAAAAABwBwAALSllub5HorZBtWWX8ZeXcQ!!&CS=114[3B002j2p[0302g3V309; "
& "WT_NVR_RU=0=technet|msdn:1=:2=; mcI=Fri, 31 Dec 2010 10:44:31 GMT; "
& "omniID=beb780dd_ab6d_4802_9f37_e33dde280adb; CodeSnippetContainerLang="
& "Visual Basic; MSID=Microsoft.CreationDate=11/09/2010 10:08:25&Microsoft."
& "LastVisitDate=03/01/2011 17:08:34&Microsoft.VisitStartDate=03/01/2011 "
& "17:08:34&Microsoft.CookieId=882efa27-ee6c-40c5-96ba-2297f985d9e3&Microsoft"
& ".TokenId=0c0a5e07-37a6-4ca3-afc0-0edf3de329f6&Microsoft.NumberOfVisits="
& "60&Microsoft.IdentityToken=RojEm8r/0KbCYeKasdfwekl3FtctotD5ocj7WVR72795"
& "dBj23rXVz5/xeldkkKHr/NtXFN3xAvczHlHQHKw14/9f/VAraQFIzEYpypGE24z1AuPCzVwU"
& "l4HZPnOFH+IA0u2oarcR1n3IMC4Gk8D1UOPBwGlYMB2Xl2W+Up8kJikc4qUxmFG+X5SRrZ3m7"
& "LntAv92B4v7c9FPewcQHDSAJAmTOuy7+sl6zEwW2fGWjqGe3G7bh+qqUWPs4LrvSyyi7T3UCW"
& "anSWn6jqJInP/MSeAxAvjbTrBwlJlE3AoUfXUJgL81boPYsIXZ30lPpqjMkyc0Jd70dffNNTo5"
& "qwkvfFhyOvnfYoQ7dZ0REw+TRA01xHyyUSPINOVgM5Vcu4SdvcUoIlMR3Y097nK+lvx8SqV4UU"
& "+QENW1wbBDa7/u6AQqUuk0616tWrBQMR9pYKwYsORUqLkQY5URzhVVA7Py28dLX002Nehqjbh68"
& "4xQv/gQYbPZMZUq/wgmPsqA5mJU/lki6A0S/H/ULGbrJE0PBQr8T+Hd+Op4HxEHvjvkTs=&Micr"
& "osoft.MicrosoftId=0004-1282-6244-7365; msresearch=%7B%22version%22%3A%224.6"
& "%22%2C%22state%22%3A%7B%22name%22%3A%22IDLE%22%2C%22url%22%3Aundefined%2C%2"
& "2timestamp%22%3A1296211850175%7D%2C%22lastinvited%22%3A1296211850175%2C%22u"
& "serid%22%3A%2212962118501758905232121057759%22%2C%22vendorid%22%3A1%2C%22su"
& "rveys%22%3A%5Bundefined%5D%7D; s_sq=%5B%5BB%5D%5D; s_cc=true; "
& "GsfxStatsLog=true; GsfxSessionCookie=231210164895294015; ADS=SN=175A21EF;"
& ".ASPXANONYMOUS=HJbsF8QczAEkAAAAMGU4YjY4YTctNDJhNy00NmQ3LWJmOWEtNjVjMzFmODY"
& "1ZTA5dhasChFIbRm1YpxPXPteSbwdTE01",
15, "s_sq", "%5B%5BB%5D%5D");
Test_Parse ("A=B;", 1, "A", "B");
Test_Parse ("A=B; ", 1, "A", "B");
Test_Parse ("A=B; C&3", 1, "A", "B");
Test_Parse ("A=C; C<3=4", 2, "A", "C");
end Test_Parse_Http_Header;
end Util.Http.Cookies.Tests;
|
DrenfongWong/tkm-rpc | Ada | 263 | ads | with Tkmrpc.Request;
with Tkmrpc.Response;
package Tkmrpc.Operation_Handlers.Ike.Nc_Create is
procedure Handle (Req : Request.Data_Type; Res : out Response.Data_Type);
-- Handler for the nc_create operation.
end Tkmrpc.Operation_Handlers.Ike.Nc_Create;
|
Kensan/tamp2 | Ada | 4,908 | adb | -- -*- Mode: Ada -*-
-- Filename : tamp.adb
-- Description : A "hello world" style OS kernel written in Ada.
-- Author : Luke A. Guest
-- Created On : Thu Jun 14 11:59:53 2012
-- Licence : See LICENCE in the root directory.
pragma Restrictions (No_Obsolescent_Features);
with Console; use Console;
with Multiboot; use Multiboot;
-- with System.Address_To_Access_Conversions;
-- with Ada.Unchecked_Conversion;
use type Multiboot.Magic_Values;
procedure TAMP is
Line : Screen_Height_Range := Screen_Height_Range'First;
begin
null;
Clear;
Put ("Hello, TAMP in Ada",
Screen_Width_Range'First,
Line);
Line := Line + 1;
if Magic = Magic_Value then
Put ("Magic numbers match!", Screen_Width_Range'First, Line);
else
Put ("Magic numbers don't match!", Screen_Width_Range'First, Line);
raise Program_Error;
end if;
-- Line := Line + 1;
-- if Info.Flags.Memory then
-- Put ("Memory info present", Screen_Width_Range'First, Line);
-- Line := Line + 1;
-- end if;
-- if Info.Flags.Boot_Device then
-- Put ("Boot device info present", Screen_Width_Range'First, Line);
-- Line := Line + 1;
-- end if;
-- if Info.Flags.Command_Line then
-- Put ("Command line info present", Screen_Width_Range'First, Line);
-- Line := Line + 1;
-- end if;
-- if Info.Flags.Modules then
-- Put ("Modules info present", Screen_Width_Range'First, Line);
-- Line := Line + 1;
-- if Info.Modules.Count = 2 then
-- declare
-- type My_Modules_Array is new Modules_Array
-- (1 .. Natural (Info.Modules.Count));
-- type My_Modules_Array_Access is access all My_Modules_Array;
-- -- My_Modules : aliased Modules_Array
-- -- (1 .. Natural (Info.Modules.Count));
-- -- pragma Unreferenced (My_Modules);
-- package To_Modules is new System.Address_To_Access_Conversions
-- (Object => My_Modules_Array_Access);
-- function Conv is new Ada.Unchecked_Conversion
-- (Source => To_Modules.Object_Pointer,
-- Target => My_Modules_Array_Access);
-- Modules : constant My_Modules_Array_Access :=
-- Conv (To_Modules.To_Pointer
-- (Info.Modules.First));
-- M : Multiboot.Modules;
-- pragma Unreferenced (M);
-- begin
-- Put ("2 modules loaded is correct",
-- Screen_Width_Range'First, Line);
-- for I in 1 .. Info.Modules.Count loop
-- M := Modules (Natural (I));
-- end loop;
-- Line := Line + 1;
-- end;
-- end if;
-- end if;
-- if Info.Flags.Symbol_Table then
-- Put ("Symbol table info present", Screen_Width_Range'First, Line);
-- Line := Line + 1;
-- end if;
-- if Info.Flags.Section_Header_Table then
-- Put ("Section header table info present",
-- Screen_Width_Range'First, Line);
-- Line := Line + 1;
-- end if;
-- if Info.Flags.BIOS_Memory_Map then
-- Put ("BIOS memory map info present", Screen_Width_Range'First, Line);
-- Line := Line + 1;
-- declare
-- Map : Memory_Map_Entry_Access := Multiboot.First_Memory_Map_Entry;
-- begin
-- while Map /= null loop
-- Map := Multiboot.Next_Memory_Map_Entry (Map);
-- end loop;
-- end;
-- end if;
-- if Info.Flags.Drives then
-- Put ("Drives info present", Screen_Width_Range'First, Line);
-- Line := Line + 1;
-- end if;
-- if Info.Flags.ROM_Configuration then
-- Put ("ROM configuration info present",
-- Screen_Width_Range'First, Line);
-- Line := Line + 1;
-- end if;
-- if Info.Flags.Boot_Loader then
-- Put ("Boot loader info present", Screen_Width_Range'First, Line);
-- Line := Line + 1;
-- end if;
-- if Info.Flags.APM_Table then
-- Put ("APM table info present", Screen_Width_Range'First, Line);
-- Line := Line + 1;
-- end if;
-- if Info.Flags.Graphics_Table then
-- Put ("Graphics table info present", Screen_Width_Range'First, Line);
-- Line := Line + 1;
-- end if;
-- raise Constraint_Error;
-- raise Console.TE;
-- raise Constraint_Error;
-- Put (Natural 'Image (54),
-- Screen_Width_Range'First,
-- Screen_Height_Range'First + 1);
-- exception
-- when Constraint_Error =>
-- Put ("Constraint Error caught", 1, 15);
-- when Program_Error =>
-- null;
-- when Console.TE =>
-- Put ("TE caught", 1, 2);
end TAMP;
pragma No_Return (TAMP);
|
charlie5/aShell | Ada | 550 | adb | with
Ada.Text_IO,
Ada.Characters.Latin_1;
package body Shell.Testing
is
procedure Pause_Til_Tester_Is_Ready
is
use Ada.Text_IO;
begin
New_Line;
Put_Line ("Press <Enter> to run the next test.");
declare
Unused : String := Get_Line;
begin
Clear_Screen;
end;
end Pause_Til_Tester_Is_Ready;
procedure Clear_Screen
is
use Ada.Text_IO;
begin
Put (Ada.Characters.Latin_1.ESC & "[2J"); -- Clear the screen.
end Clear_Screen;
end Shell.Testing;
|
stcarrez/helios | Ada | 1,501 | ads | -----------------------------------------------------------------------
-- helios-monitor-sysfile -- Generic system file monitor
-- Copyright (C) 2017 Stephane Carrez
-- Written by Stephane Carrez ([email protected])
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
package Helios.Monitor.Sysfile is
type Agent_Type is new Helios.Monitor.Agent_Type with record
Path : Ada.Strings.Unbounded.Unbounded_String;
Value : Schemas.Definition_Type_Access;
end record;
-- Start the agent and build the definition tree.
overriding
procedure Start (Agent : in out Agent_Type;
Config : in Util.Properties.Manager);
-- Collect the values in the snapshot.
overriding
procedure Collect (Agent : in out Agent_Type;
Values : in out Datas.Snapshot_Type);
end Helios.Monitor.Sysfile;
|
clairvoyant/anagram | Ada | 1,125 | ads | -- Copyright (c) 2010-2017 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
-- This package resolves conflict in a parse table using precedence and
-- associativiti information of terminals and productions.
with Anagram.Grammars.LR;
with Anagram.Grammars.LR_Tables;
with Ada.Containers.Ordered_Maps;
package Anagram.Grammars.Conflicts is
type Resolver is tagged private;
procedure Resolve
(Self : in out Resolver;
Input : Grammar;
Table : in out LR_Tables.Table);
private
package Priority_Maps is new Ada.Containers.Ordered_Maps
(Precedence_Level, Associate_Kind);
type Resolver is tagged record
Checks : Priority_Maps.Map;
end record;
procedure Check_Priority
(Self : in out Resolver;
Prec : Precedence_Value);
procedure Try_To_Resolve
(Self : in out Resolver;
Input : Grammar;
Table : in out LR_Tables.Table;
State : LR.State_Index;
Terminal : Terminal_Index);
end Anagram.Grammars.Conflicts;
|
reznikmm/matreshka | Ada | 3,714 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Open Document Toolkit --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with XML.DOM.Attributes;
package ODF.DOM.Draw_Fill_Color_Attributes is
pragma Preelaborate;
type ODF_Draw_Fill_Color_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Draw_Fill_Color_Attribute_Access is
access all ODF_Draw_Fill_Color_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Draw_Fill_Color_Attributes;
|
zhmu/ananas | Ada | 185 | ads | generic
type T is private;
package Compile_Time_Error1_Pkg is
pragma Compile_Time_Error (T'Size not in 8 | 16 | 32, "type too large");
Data : T;
end Compile_Time_Error1_Pkg;
|
reznikmm/matreshka | Ada | 11,229 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <[email protected]> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.DG.Canvases;
with AMF.DG.Circles;
with AMF.DG.Clip_Paths;
with AMF.DG.Ellipses;
with AMF.DG.Groups;
with AMF.DG.Images;
with AMF.DG.Linear_Gradients;
with AMF.DG.Lines;
with AMF.DG.Marked_Elements;
with AMF.DG.Markers;
with AMF.DG.Paths;
with AMF.DG.Patterns;
with AMF.DG.Polygons;
with AMF.DG.Polylines;
with AMF.DG.Radial_Gradients;
with AMF.DG.Rectangles;
with AMF.DG.Styles;
with AMF.DG.Texts;
package AMF.Visitors.DG_Visitors is
pragma Preelaborate;
type DG_Visitor is limited interface and AMF.Visitors.Abstract_Visitor;
not overriding procedure Enter_Canvas
(Self : in out DG_Visitor;
Element : not null AMF.DG.Canvases.DG_Canvas_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Canvas
(Self : in out DG_Visitor;
Element : not null AMF.DG.Canvases.DG_Canvas_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Circle
(Self : in out DG_Visitor;
Element : not null AMF.DG.Circles.DG_Circle_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Circle
(Self : in out DG_Visitor;
Element : not null AMF.DG.Circles.DG_Circle_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Clip_Path
(Self : in out DG_Visitor;
Element : not null AMF.DG.Clip_Paths.DG_Clip_Path_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Clip_Path
(Self : in out DG_Visitor;
Element : not null AMF.DG.Clip_Paths.DG_Clip_Path_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Ellipse
(Self : in out DG_Visitor;
Element : not null AMF.DG.Ellipses.DG_Ellipse_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Ellipse
(Self : in out DG_Visitor;
Element : not null AMF.DG.Ellipses.DG_Ellipse_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Group
(Self : in out DG_Visitor;
Element : not null AMF.DG.Groups.DG_Group_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Group
(Self : in out DG_Visitor;
Element : not null AMF.DG.Groups.DG_Group_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Image
(Self : in out DG_Visitor;
Element : not null AMF.DG.Images.DG_Image_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Image
(Self : in out DG_Visitor;
Element : not null AMF.DG.Images.DG_Image_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Line
(Self : in out DG_Visitor;
Element : not null AMF.DG.Lines.DG_Line_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Line
(Self : in out DG_Visitor;
Element : not null AMF.DG.Lines.DG_Line_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Linear_Gradient
(Self : in out DG_Visitor;
Element : not null AMF.DG.Linear_Gradients.DG_Linear_Gradient_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Linear_Gradient
(Self : in out DG_Visitor;
Element : not null AMF.DG.Linear_Gradients.DG_Linear_Gradient_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Marked_Element
(Self : in out DG_Visitor;
Element : not null AMF.DG.Marked_Elements.DG_Marked_Element_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Marked_Element
(Self : in out DG_Visitor;
Element : not null AMF.DG.Marked_Elements.DG_Marked_Element_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Marker
(Self : in out DG_Visitor;
Element : not null AMF.DG.Markers.DG_Marker_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Marker
(Self : in out DG_Visitor;
Element : not null AMF.DG.Markers.DG_Marker_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Path
(Self : in out DG_Visitor;
Element : not null AMF.DG.Paths.DG_Path_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Path
(Self : in out DG_Visitor;
Element : not null AMF.DG.Paths.DG_Path_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Pattern
(Self : in out DG_Visitor;
Element : not null AMF.DG.Patterns.DG_Pattern_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Pattern
(Self : in out DG_Visitor;
Element : not null AMF.DG.Patterns.DG_Pattern_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Polygon
(Self : in out DG_Visitor;
Element : not null AMF.DG.Polygons.DG_Polygon_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Polygon
(Self : in out DG_Visitor;
Element : not null AMF.DG.Polygons.DG_Polygon_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Polyline
(Self : in out DG_Visitor;
Element : not null AMF.DG.Polylines.DG_Polyline_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Polyline
(Self : in out DG_Visitor;
Element : not null AMF.DG.Polylines.DG_Polyline_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Radial_Gradient
(Self : in out DG_Visitor;
Element : not null AMF.DG.Radial_Gradients.DG_Radial_Gradient_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Radial_Gradient
(Self : in out DG_Visitor;
Element : not null AMF.DG.Radial_Gradients.DG_Radial_Gradient_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Rectangle
(Self : in out DG_Visitor;
Element : not null AMF.DG.Rectangles.DG_Rectangle_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Rectangle
(Self : in out DG_Visitor;
Element : not null AMF.DG.Rectangles.DG_Rectangle_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Style
(Self : in out DG_Visitor;
Element : not null AMF.DG.Styles.DG_Style_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Style
(Self : in out DG_Visitor;
Element : not null AMF.DG.Styles.DG_Style_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Text
(Self : in out DG_Visitor;
Element : not null AMF.DG.Texts.DG_Text_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Text
(Self : in out DG_Visitor;
Element : not null AMF.DG.Texts.DG_Text_Access;
Control : in out AMF.Visitors.Traverse_Control) is null;
end AMF.Visitors.DG_Visitors;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.