repo_name
stringlengths 9
74
| language
stringclasses 1
value | length_bytes
int64 11
9.34M
| extension
stringclasses 2
values | content
stringlengths 11
9.34M
|
---|---|---|---|---|
micahwelf/FLTK-Ada | Ada | 12,012 | adb |
with
Interfaces.C,
System;
use type
Interfaces.C.int,
System.Address;
package body FLTK.Widgets.Groups is
procedure group_set_draw_hook
(W, D : in System.Address);
pragma Import (C, group_set_draw_hook, "group_set_draw_hook");
pragma Inline (group_set_draw_hook);
procedure group_set_handle_hook
(W, H : in System.Address);
pragma Import (C, group_set_handle_hook, "group_set_handle_hook");
pragma Inline (group_set_handle_hook);
function new_fl_group
(X, Y, W, H : in Interfaces.C.int;
Text : in Interfaces.C.char_array)
return System.Address;
pragma Import (C, new_fl_group, "new_fl_group");
pragma Inline (new_fl_group);
procedure free_fl_group
(G : in System.Address);
pragma Import (C, free_fl_group, "free_fl_group");
pragma Inline (free_fl_group);
procedure fl_group_add
(G, W : in System.Address);
pragma Import (C, fl_group_add, "fl_group_add");
pragma Inline (fl_group_add);
procedure fl_group_insert
(G, W : in System.Address;
P : in Interfaces.C.int);
pragma Import (C, fl_group_insert, "fl_group_insert");
pragma Inline (fl_group_insert);
procedure fl_group_insert2
(G, W, B : in System.Address);
pragma Import (C, fl_group_insert2, "fl_group_insert2");
pragma Inline (fl_group_insert2);
procedure fl_group_remove
(G, W : in System.Address);
pragma Import (C, fl_group_remove, "fl_group_remove");
pragma Inline (fl_group_remove);
procedure fl_group_remove2
(G : in System.Address;
P : in Interfaces.C.int);
pragma Import (C, fl_group_remove2, "fl_group_remove2");
pragma Inline (fl_group_remove2);
function fl_group_child
(G : in System.Address;
I : in Interfaces.C.int)
return System.Address;
pragma Import (C, fl_group_child, "fl_group_child");
pragma Inline (fl_group_child);
function fl_group_find
(G, W : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_group_find, "fl_group_find");
pragma Inline (fl_group_find);
function fl_group_children
(G : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_group_children, "fl_group_children");
pragma Inline (fl_group_children);
-- function fl_group_get_clip_children
-- (G : in System.Address)
-- return Interfaces.C.unsigned;
-- pragma Import (C, fl_group_get_clip_children, "fl_group_get_clip_children");
-- pragma Inline (fl_group_get_clip_children);
-- procedure fl_group_set_clip_children
-- (G : in System.Address;
-- C : in Interfaces.C.unsigned);
-- pragma Import (C, fl_group_set_clip_children, "fl_group_set_clip_children");
-- pragma Inline (fl_group_set_clip_children);
function fl_group_get_resizable
(G : in System.Address)
return System.Address;
pragma Import (C, fl_group_get_resizable, "fl_group_get_resizable");
pragma Inline (fl_group_get_resizable);
procedure fl_group_set_resizable
(G, W : in System.Address);
pragma Import (C, fl_group_set_resizable, "fl_group_set_resizable");
pragma Inline (fl_group_set_resizable);
procedure fl_group_init_sizes
(G : in System.Address);
pragma Import (C, fl_group_init_sizes, "fl_group_init_sizes");
pragma Inline (fl_group_init_sizes);
function fl_group_get_current
return System.Address;
pragma Import (C, fl_group_get_current, "fl_group_get_current");
pragma Inline (fl_group_get_current);
procedure fl_group_set_current
(G : in System.Address);
pragma Import (C, fl_group_set_current, "fl_group_set_current");
pragma Inline (fl_group_set_current);
procedure fl_group_draw
(W : in System.Address);
pragma Import (C, fl_group_draw, "fl_group_draw");
pragma Inline (fl_group_draw);
function fl_group_handle
(W : in System.Address;
E : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_group_handle, "fl_group_handle");
pragma Inline (fl_group_handle);
procedure Finalize
(This : in out Group) is
begin
if This.Void_Ptr /= System.Null_Address and then
This in Group'Class
then
This.Clear;
free_fl_group (This.Void_Ptr);
This.Void_Ptr := System.Null_Address;
end if;
Finalize (Widget (This));
end Finalize;
package body Forge is
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Group is
begin
return This : Group do
This.Void_Ptr := new_fl_group
(Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H),
Interfaces.C.To_C (Text));
fl_group_end (This.Void_Ptr);
fl_widget_set_user_data
(This.Void_Ptr,
Widget_Convert.To_Address (This'Unchecked_Access));
group_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
group_set_handle_hook (This.Void_Ptr, Handle_Hook'Address);
end return;
end Create;
end Forge;
procedure Add
(This : in out Group;
Item : in out Widget'Class) is
begin
fl_group_add (This.Void_Ptr, Item.Void_Ptr);
end Add;
procedure Insert
(This : in out Group;
Item : in out Widget'Class;
Place : in Index) is
begin
fl_group_insert
(This.Void_Ptr,
Item.Void_Ptr,
Interfaces.C.int (Place) - 1);
end Insert;
procedure Insert
(This : in out Group;
Item : in out Widget'Class;
Before : in Widget'Class) is
begin
fl_group_insert2
(This.Void_Ptr,
Item.Void_Ptr,
Before.Void_Ptr);
end Insert;
procedure Remove
(This : in out Group;
Item : in out Widget'Class) is
begin
fl_group_remove (This.Void_Ptr, Item.Void_Ptr);
end Remove;
procedure Remove
(This : in out Group;
Place : in Index) is
begin
fl_group_remove2 (This.Void_Ptr, Interfaces.C.int (Place) - 1);
end Remove;
procedure Clear
(This : in out Group) is
begin
for I in reverse 1 .. This.Number_Of_Children loop
This.Remove (Index (I));
end loop;
end Clear;
function Has_Child
(This : in Group;
Place : in Index)
return Boolean is
begin
return Place in 1 .. This.Number_Of_Children;
end Has_Child;
function Has_Child
(Place : in Cursor)
return Boolean is
begin
return Place.My_Container.Has_Child (Place.My_Index);
end Has_Child;
function Child
(This : in Group;
Place : in Index)
return Widget_Reference
is
Widget_Ptr : System.Address :=
fl_group_child (This.Void_Ptr, Interfaces.C.int (Place) - 1);
Actual_Widget : access Widget'Class :=
Widget_Convert.To_Pointer (fl_widget_get_user_data (Widget_Ptr));
begin
return (Data => Actual_Widget);
end Child;
function Child
(This : in Group;
Place : in Cursor)
return Widget_Reference is
begin
return This.Child (Place.My_Index);
end Child;
function Find
(This : in Group;
Item : in out Widget'Class)
return Extended_Index
is
Ret : Interfaces.C.int;
begin
Ret := fl_group_find (This.Void_Ptr, Item.Void_Ptr);
if Ret = fl_group_children (This.Void_Ptr) then
return No_Index;
end if;
return Extended_Index (Ret + 1);
end Find;
function Number_Of_Children
(This : in Group)
return Natural is
begin
return Natural (fl_group_children (This.Void_Ptr));
end Number_Of_Children;
function Iterate
(This : in Group)
return Group_Iterators.Reversible_Iterator'Class is
begin
return It : Iterator := (My_Container => This'Unrestricted_Access);
end Iterate;
function First
(Object : in Iterator)
return Cursor is
begin
return Cu : Cursor :=
(My_Container => Object.My_Container,
My_Index => 1);
end First;
function Next
(Object : in Iterator;
Place : in Cursor)
return Cursor is
begin
if Object.My_Container /= Place.My_Container then
raise Program_Error;
end if;
return Cu : Cursor :=
(My_Container => Place.My_Container,
My_Index => Place.My_Index + 1);
end Next;
function Last
(Object : in Iterator)
return Cursor is
begin
return Cu : Cursor :=
(My_Container => Object.My_Container,
My_Index => Object.My_Container.Number_Of_Children);
end Last;
function Previous
(Object : in Iterator;
Place : in Cursor)
return Cursor is
begin
if Object.My_Container /= Place.My_Container then
raise Program_Error;
end if;
return Cu : Cursor :=
(My_Container => Place.My_Container,
My_Index => Place.My_Index - 1);
end Previous;
-- function Get_Clip_Mode
-- (This : in Group)
-- return Clip_Mode is
-- begin
-- return Clip_Mode'Val (fl_group_get_clip_children (This.Void_Ptr));
-- end Get_Clip_Mode;
-- procedure Set_Clip_Mode
-- (This : in out Group;
-- Mode : in Clip_Mode) is
-- begin
-- fl_group_set_clip_children (This.Void_Ptr, Clip_Mode'Pos (Mode));
-- end Set_Clip_Mode;
function Get_Resizable
(This : in Group)
return access Widget'Class
is
Widget_Ptr : System.Address :=
fl_group_get_resizable (This.Void_Ptr);
Actual_Widget : access Widget'Class :=
Widget_Convert.To_Pointer (fl_widget_get_user_data (Widget_Ptr));
begin
return Actual_Widget;
end Get_Resizable;
procedure Set_Resizable
(This : in out Group;
Item : in Widget'Class) is
begin
fl_group_set_resizable (This.Void_Ptr, Item.Void_Ptr);
end Set_Resizable;
procedure Reset_Initial_Sizes
(This : in out Group) is
begin
fl_group_init_sizes (This.Void_Ptr);
end Reset_Initial_Sizes;
function Get_Current
return access Group'Class
is
Group_Ptr : System.Address := fl_group_get_current;
Actual_Group : access Group'Class;
begin
if Group_Ptr /= System.Null_Address then
Actual_Group := Group_Convert.To_Pointer (Group_Ptr);
end if;
return Actual_Group;
end Get_Current;
procedure Set_Current
(To : in Group'Class) is
begin
fl_group_set_current (To.Void_Ptr);
end Set_Current;
procedure Draw
(This : in out Group) is
begin
fl_group_draw (This.Void_Ptr);
end Draw;
function Handle
(This : in out Group;
Event : in Event_Kind)
return Event_Outcome is
begin
return Event_Outcome'Val
(fl_group_handle (This.Void_Ptr, Event_Kind'Pos (Event)));
end Handle;
end FLTK.Widgets.Groups;
|
joakim-strandberg/wayland_ada_binding | Ada | 1,118 | adb | package body C_Binding.Linux.GnuTLS.Certificate_Credentials is
procedure Allocate_Credentials is
Result : constant Interfaces.C.int
:= C_Certificate_Allocate_Credentials (This.My_Credentials'Access);
begin
if Result = GNUTLS_E_SUCCESS then
begin
Handle_Success;
C_Certificate_Free_Credentials (This.My_Credentials);
exception
when Error : others =>
C_Certificate_Free_Credentials (This.My_Credentials);
raise;
end;
else
Handle_Failure;
end if;
end Allocate_Credentials;
function Set_Session_Credentials
(This : Credentials;
Session : Sessions.Session) return Success_Flag
is
Result : constant Interfaces.C.int
:= C_Credentials_Set
(Session.My_Session,
Certificate_Credential,
This.My_Credentials);
begin
if Result = GNUTLS_E_SUCCESS then
return Success;
else
return Failure;
end if;
end Set_Session_Credentials;
end C_Binding.Linux.GnuTLS.Certificate_Credentials;
|
Kidev/Ada_Drivers_Library | Ada | 1,742 | ads | -- This package was generated by the Ada_Drivers_Library project wizard script
package ADL_Config is
Vendor : constant String := "STMicro"; -- From board definition
Max_Mount_Points : constant := 2; -- From default value
Max_Mount_Name_Length : constant := 128; -- From default value
Runtime_Profile : constant String := "ravenscar-full"; -- From command line
Device_Name : constant String := "STM32F746NGHx"; -- From board definition
Device_Family : constant String := "STM32F7"; -- From board definition
Runtime_Name : constant String := "ravenscar-full-stm32f746disco"; -- From default value
Has_Ravenscar_Full_Runtime : constant String := "True"; -- From board definition
CPU_Core : constant String := "ARM Cortex-M7F"; -- From mcu definition
Board : constant String := "STM32F746_Discovery"; -- From command line
Has_ZFP_Runtime : constant String := "False"; -- From board definition
Has_Ravenscar_SFP_Runtime : constant String := "True"; -- From board definition
High_Speed_External_Clock : constant := 25000000; -- From board definition
Max_Path_Length : constant := 1024; -- From default value
Runtime_Name_Suffix : constant String := "stm32f746disco"; -- From board definition
Architecture : constant String := "ARM"; -- From board definition
end ADL_Config;
|
tum-ei-rcs/StratoX | Ada | 1,849 | adb | with ublox8.Driver; use ublox8;
with Bounded_Image; use Bounded_Image;
package body GPS with SPARK_Mode,
Refined_State => (State => (null))
is
--overriding
procedure initialize (Self : in out GPS_Tag) is
begin
Driver.init;
Self.state := READY;
end initialize;
--overriding
procedure read_Measurement(Self : in out GPS_Tag) is
pragma Unreferenced (Self);
begin
Driver.update_val;
end read_Measurement;
function get_Position(Self : GPS_Tag) return GPS_Data_Type is
pragma Unreferenced (Self);
begin
return Driver.get_Position;
end get_Position;
function get_GPS_Fix(Self : GPS_Tag) return GPS_Fix_Type is
pragma Unreferenced (Self);
begin
return Driver.get_Fix;
end get_GPS_Fix;
function get_Speed(Self : GPS_Tag) return Units.Linear_Velocity_Type is
pragma Unreferenced (Self);
begin
return Driver.get_Velo;
end get_Speed;
function get_Pos_Accuracy(Self : GPS_Tag) return Units.Length_Type is
pragma Unreferenced (Self);
begin
return Driver.get_Vertical_Accuracy; -- vertical is always worse than horizontal
end get_Pos_Accuracy;
function get_Time(Self : GPS_Tag) return GPS_DateTime
is
pragma Unreferenced (Self);
begin
return Driver.get_Time;
end get_Time;
function get_Num_Sats(Self : GPS_Tag) return Unsigned_8 is
pragma Unreferenced (Self);
begin
return Driver.get_Nsat;
end get_Num_Sats;
function Image (tm : GPS_DateTime) return String is
begin
return Natural_Img ( Natural (tm.year)) & "-" & Unsigned8_Img ( Unsigned_8 (tm.mon)) & "-" & Unsigned8_Img ( Unsigned_8 (tm.day)) & " "
& Unsigned8_Img (Unsigned_8 (tm.hour)) & ":" & Unsigned8_Img ( Unsigned_8 (tm.min)) & ":" & Unsigned8_Img ( Unsigned_8 (tm.sec));
end Image;
end GPS;
|
charlie5/aIDE | Ada | 1,204 | ads | with
Ada.Containers.Vectors,
Ada.Streams;
package AdaM.Declaration.of_null_procedure
is
type Item is new Declaration.item with private;
-- View
--
type View is access all Item'Class;
procedure View_write (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Self : in View);
procedure View_read (Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Self : out View);
for View'write use View_write;
for View'read use View_read;
-- Vector
--
package Vectors is new ada.Containers.Vectors (Positive, View);
subtype Vector is Vectors.Vector;
-- Forge
--
function new_Declaration return Declaration.of_null_procedure.view;
procedure free (Self : in out Declaration.of_null_procedure.view);
overriding
procedure destruct (Self : in out Declaration.of_null_procedure.item);
-- Attributes
--
overriding
function Id (Self : access Item) return AdaM.Id;
private
type Item is new Declaration.item with
record
null;
end record;
end AdaM.Declaration.of_null_procedure;
|
Letractively/ada-ado | Ada | 18,820 | ads | -----------------------------------------------------------------------
-- ADO Objects -- Database objects
-- Copyright (C) 2009, 2010, 2011, 2012, 2013 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.Finalization;
with Ada.Strings.Unbounded;
with Ada.Containers;
with ADO.SQL;
with ADO.Schemas;
with Util.Beans.Basic;
with Util.Beans.Objects;
with Util.Strings;
with Util.Concurrent.Counters;
limited with ADO.Sessions;
package ADO.Objects is
-- The object was modified by a another transaction.
-- This exception is raised by 'Save'.
LAZY_LOCK : exception;
INSERT_ERROR : exception;
UPDATE_ERROR : exception;
-- The session associated with the object is missing or has expired.
SESSION_EXPIRED : exception;
-- The object record was not found in the database.
NOT_FOUND : exception;
-- The object identifier could not be allocated.
ALLOCATE_ID_ERROR : exception;
-- The object is NULL.
NULL_ERROR : exception;
-- --------------------
-- Object Key
-- --------------------
-- The <b>Object_Key</b> represents the primary key for an object.
-- It is composed of the key value and a class mapping identification.
-- The key value can be an integer or a string and is saved in the database.
-- The class mapping is used to know in which table the object is stored.
-- In comparison and hashing, the class mapping is used to distinguish
-- objects of different tables.
--
-- Limitations:
-- --------------------
-- o The primary key must be a single column represented as an integer or a string
type Object_Key_Type is (KEY_INTEGER, KEY_STRING);
type Object_Key (Of_Type : Object_Key_Type;
Of_Class : Schemas.Class_Mapping_Access) is private;
-- Compute the hash of the object key.
function Hash (Key : Object_Key) return Ada.Containers.Hash_Type;
-- Compare whether the two objects pointed to by Left and Right have the same
-- object key. The object key is identical if the object key type, the class
-- mapping and the key value are identical.
function Equivalent_Elements (Left, Right : Object_Key)
return Boolean;
-- Check if the two objects are the same database objects.
-- The comparison is only made on the primary key.
-- Returns true if the two objects have the same primary key.
function "=" (Left : Object_Key; Right : Object_Key) return Boolean
renames Equivalent_Elements;
-- Get the key value
function Get_Value (Key : Object_Key) return Identifier;
-- Get the key value
function Get_Value (Key : Object_Key) return Ada.Strings.Unbounded.Unbounded_String;
-- Return the key value in a bean object.
function To_Object (Key : Object_Key) return Util.Beans.Objects.Object;
-- Get the key as a string
function To_String (Key : Object_Key) return String;
-- Set the key value
procedure Set_Value (Key : in out Object_Key;
Value : in Identifier);
-- Set the key value
procedure Set_Value (Key : in out Object_Key;
Value : in String);
-- --------------------
-- Database Object representation
-- --------------------
-- The <b>Object_Record</b> is the root type of any database record row.
-- It holds the primary key as well as the class mapping associated with the record.
-- Applications do not use the <b>Object_Record</b> directly but instead they receive
-- and use an <b>Object_Ref</b>.
type Object_Record (Key_Type : Object_Key_Type;
Of_Class : ADO.Schemas.Class_Mapping_Access) is abstract
new Ada.Finalization.Limited_Controlled with private;
type Object_Record_Access is access all Object_Record'Class;
-- Get the object key
function Get_Key (Ref : in Object_Record'Class) return Object_Key;
-- Get the object key value as a string.
function Get_Key_Value (Ref : in Object_Record'Class)
return Ada.Strings.Unbounded.Unbounded_String;
-- Get the object key value as an identifier
function Get_Key_Value (Ref : in Object_Record'Class)
return Identifier;
-- Set the object key
procedure Set_Key (Ref : in out Object_Record'Class;
Key : in Object_Key);
procedure Set_Key_Value (Ref : in out Object_Record'Class;
Value : in Identifier);
procedure Set_Key_Value (Ref : in out Object_Record'Class;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Key_Value (Ref : in out Object_Record'Class;
Value : in String);
-- Get the table name associated with the object record.
function Get_Table_Name (Ref : in Object_Record'Class) return Util.Strings.Name_Access;
-- Check if this is a new object.
-- Returns True if an insert is necessary to persist this object.
function Is_Created (Ref : in Object_Record'Class) return Boolean;
-- Mark the object as created in the database.
procedure Set_Created (Ref : in out Object_Record'Class);
-- Check if the field at position <b>Field</b> was modified.
function Is_Modified (Ref : in Object_Record'Class;
Field : in Positive) return Boolean;
pragma Inline (Is_Modified);
-- Clear the modification flag associated with the field at
-- position <b>Field</b>.
procedure Clear_Modified (Ref : in out Object_Record'Class;
Field : in Positive);
pragma Inline (Clear_Modified);
-- Frees the storage held by the object. The database record is not deleted.
procedure Destroy (Object : access Object_Record) is abstract;
-- Release the object.
overriding
procedure Finalize (Object : in out Object_Record);
-- Find the object using a specific query
procedure Find (Object : in out Object_Record;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is abstract;
-- Save the object in the database.
procedure Save (Object : in out Object_Record;
Session : in out ADO.Sessions.Master_Session'Class) is abstract;
-- Create the object in the database.
procedure Create (Object : in out Object_Record;
Session : in out ADO.Sessions.Master_Session'Class) is abstract;
-- Delete the object from the database
procedure Delete (Object : in out Object_Record;
Session : in out ADO.Sessions.Master_Session'Class) is abstract;
-- Load the object from the database. The object has been lazy loaded and only its
-- primary key is known. This is called from <b>Lazy_Load</b>.
procedure Load (Object : in out Object_Record;
Session : in out ADO.Sessions.Session'Class) is abstract;
-- Copy the source object record into the target.
procedure Copy (To : in out Object_Record;
From : in Object_Record'Class);
-- --------------------
-- Reference to a database object representation
-- --------------------
-- The <b>Object_Ref</b> is the root type of any database record reference.
-- The reference is the object that applications can use to access the record object.
type Object_Ref is abstract
new Ada.Finalization.Controlled and Util.Beans.Basic.Readonly_Bean with private;
-- Mark the field identified by <b>Field</b> as modified.
procedure Set_Field (Object : in out Object_Ref'Class;
Field : in Positive);
-- Prepare the object to be modified. If the reference is empty, an object record
-- instance is allocated by calling <b>Allocate</b>.
procedure Prepare_Modify (Object : in out Object_Ref'Class;
Result : out Object_Record_Access);
-- Check whether this object is initialized or not.
function Is_Null (Object : in Object_Ref'Class) return Boolean;
pragma Inline (Is_Null);
-- Check whether this object is saved in the database.
-- Returns True if the object was saved in the database.
function Is_Inserted (Object : in Object_Ref'Class) return Boolean;
-- Check whether this object is loaded from the database.
function Is_Loaded (Object : in Object_Ref'Class) return Boolean;
-- Internal method to get the object record instance and make sure it is fully loaded.
-- If the object was not yet loaded, calls <b>Lazy_Load</b> to get the values from the
-- database. Raises SESSION_EXPIRED if the session associated with the object is closed.
function Get_Load_Object (Ref : in Object_Ref'Class) return Object_Record_Access;
pragma Inline (Get_Load_Object);
-- Internal method to get the object record instance.
function Get_Object (Ref : in Object_Ref'Class) return Object_Record_Access;
pragma Inline (Get_Object);
-- Get the object key
function Get_Key (Ref : in Object_Ref'Class) return Object_Key;
-- Set the object key.
procedure Set_Key_Value (Ref : in out Object_Ref'Class;
Value : in Identifier;
Session : in ADO.Sessions.Session'Class);
-- Set the object key.
procedure Set_Key_Value (Ref : in out Object_Ref'Class;
Value : in Ada.Strings.Unbounded.Unbounded_String;
Session : in ADO.Sessions.Session'Class);
-- Check if the two objects are the same database objects.
-- The comparison is only made on the primary key.
-- Returns true if the two objects have the same primary key.
function "=" (Left : Object_Ref; Right : Object_Ref) return Boolean;
procedure Set_Object (Ref : in out Object_Ref'Class;
Object : in Object_Record_Access);
procedure Set_Object (Ref : in out Object_Ref'Class;
Object : in Object_Record_Access;
Session : in ADO.Sessions.Session'Class);
-- Internal method to allocate the Object_Record instance
procedure Allocate (Ref : in out Object_Ref) is abstract;
-- Load the database object having the given identifier.
procedure Find (Object : in out Object_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is abstract;
-- Save the object in the database. A unique identifier is allocated
-- if this is the first time this object is saved.
procedure Save (Object : in out Object_Ref;
Save : in out ADO.Sessions.Master_Session'Class) is abstract;
-- Delete the object from the database.
procedure Delete (Object : in out Object_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is abstract;
type Modified_Map is array (1 .. 64) of Boolean;
pragma Pack (Modified_Map);
type Session_Proxy is limited private;
type Session_Proxy_Access is access all Session_Proxy;
-- Release the session proxy, deleting the instance if it is no longer used.
procedure Release_Proxy (Proxy : in out Session_Proxy_Access);
pragma Inline (Release_Proxy);
function Create_Session_Proxy (S : access ADO.Sessions.Session_Record)
return Session_Proxy_Access;
-- Set the object field to the new value in <b>Into</b>. If the new value is identical,
-- the operation does nothing. Otherwise, the new value <b>Value</b> is copied
-- to <b>Into</b> and the field identified by <b>Field</b> is marked as modified on
-- the object. The <b>Set_Field_XXX</b> procedures are used by the Dynamo generated
-- code for the implementation of Set procedures.
procedure Set_Field_Unbounded_String (Object : in out Object_Record'Class;
Field : in Positive;
Into : in out Ada.Strings.Unbounded.Unbounded_String;
Value : in Ada.Strings.Unbounded.Unbounded_String);
procedure Set_Field_String (Object : in out Object_Record'Class;
Field : in Positive;
Into : in out Ada.Strings.Unbounded.Unbounded_String;
Value : in String);
procedure Set_Field_Time (Object : in out Object_Record'Class;
Field : in Positive;
Into : in out Ada.Calendar.Time;
Value : in Ada.Calendar.Time);
procedure Set_Field_Time (Object : in out Object_Record'Class;
Field : in Positive;
Into : in out ADO.Nullable_Time;
Value : in ADO.Nullable_Time);
procedure Set_Field_Integer (Object : in out Object_Record'Class;
Field : in Positive;
Into : in out Integer;
Value : in Integer);
procedure Set_Field_Natural (Object : in out Object_Record'Class;
Field : in Positive;
Into : in out Natural;
Value : in Natural);
procedure Set_Field_Positive (Object : in out Object_Record'Class;
Field : in Positive;
Into : in out Positive;
Value : in Positive);
procedure Set_Field_Boolean (Object : in out Object_Record'Class;
Field : in Positive;
Into : in out Boolean;
Value : in Boolean);
procedure Set_Field_Object (Object : in out Object_Record'Class;
Field : in Positive;
Into : in out Object_Ref'Class;
Value : in Object_Ref'Class);
procedure Set_Field_Identifier (Object : in out Object_Record'Class;
Field : in Positive;
Into : in out ADO.Identifier;
Value : in ADO.Identifier);
procedure Set_Field_Entity_Type (Object : in out Object_Record'Class;
Field : in Positive;
Into : in out ADO.Entity_Type;
Value : in ADO.Entity_Type);
procedure Set_Field_Blob (Object : in out Object_Record'Class;
Field : in Positive;
Into : in out ADO.Blob_Ref;
Value : in ADO.Blob_Ref);
procedure Set_Field_Key_Value (Object : in out Object_Record'Class;
Field : in Positive;
Value : in ADO.Identifier);
procedure Set_Field_Key_Value (Object : in out Object_Record'Class;
Field : in Positive;
Value : in String);
procedure Set_Field_Key_Value (Object : in out Object_Record'Class;
Field : in Positive;
Value : in Ada.Strings.Unbounded.Unbounded_String);
generic
type T is private;
procedure Set_Field_Operation (Object : in out Object_Record'Class;
Field : in Positive;
Into : in out T;
Value : in T);
-- SCz 2011-11-15: ??? setting the Inline_Always pragma crashes gcc 4.4;
-- pragma Inline_Always (Set_Field_Operation);
private
-- Load the object from the database if it was not already loaded.
-- For a lazy association, the <b>Object_Record</b> is allocated and holds the primary key.
-- The <b>Is_Loaded</b> boolean is cleared thus indicating the other values are not loaded.
-- This procedure makes sure these values are loaded by invoking <b>Load</b> if necessary.
-- Raises SESSION_EXPIRED if the session associated with the object is closed.
procedure Lazy_Load (Ref : in Object_Ref'Class);
type Object_Key (Of_Type : Object_Key_Type;
Of_Class : ADO.Schemas.Class_Mapping_Access) is
new Ada.Finalization.Controlled with record
case Of_Type is
when KEY_INTEGER =>
Id : Identifier := NO_IDENTIFIER;
when KEY_STRING =>
Str : Ada.Strings.Unbounded.Unbounded_String;
end case;
end record;
type Object_Ref is abstract new Ada.Finalization.Controlled
and Util.Beans.Basic.Readonly_Bean with record
Object : Object_Record_Access := null;
end record;
-- Update the reference counter.
overriding
procedure Adjust (Object : in out Object_Ref);
-- Decrement the reference counter and release the object record.
overriding
procedure Finalize (Object : in out Object_Ref);
type Session_Proxy is limited record
Counter : Util.Concurrent.Counters.Counter := Util.Concurrent.Counters.ONE;
Session : access ADO.Sessions.Session_Record;
end record;
-- The Object_Record represents the base class for any database object.
-- A reference counter is used by Object_Ref to release correctly the memory.
--
type Object_Record (Key_Type : Object_Key_Type;
Of_Class : ADO.Schemas.Class_Mapping_Access) is abstract
new Ada.Finalization.Limited_Controlled with record
Counter : Util.Concurrent.Counters.Counter := Util.Concurrent.Counters.ONE;
Session : Session_Proxy_Access := null;
Key : Object_Key (Of_Type => Key_Type, Of_Class => Of_Class);
Is_Created : Boolean := False;
Is_Loaded : Boolean := False;
Modified : Modified_Map := (others => False);
end record;
end ADO.Objects;
|
charlie5/cBound | Ada | 1,480 | ads | -- This file is generated by SWIG. Please do not modify by hand.
--
with Interfaces;
with Interfaces.C;
with Interfaces.C.Pointers;
package xcb.xcb_glx_finish_reply_t is
-- Item
--
type Item is record
response_type : aliased Interfaces.Unsigned_8;
pad0 : aliased Interfaces.Unsigned_8;
sequence : aliased Interfaces.Unsigned_16;
length : aliased Interfaces.Unsigned_32;
end record;
-- Item_Array
--
type Item_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_glx_finish_reply_t
.Item;
-- Pointer
--
package C_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_finish_reply_t.Item,
Element_Array => xcb.xcb_glx_finish_reply_t.Item_Array,
Default_Terminator => (others => <>));
subtype Pointer is C_Pointers.Pointer;
-- Pointer_Array
--
type Pointer_Array is
array
(Interfaces.C.size_t range <>) of aliased xcb.xcb_glx_finish_reply_t
.Pointer;
-- Pointer_Pointer
--
package C_Pointer_Pointers is new Interfaces.C.Pointers
(Index => Interfaces.C.size_t,
Element => xcb.xcb_glx_finish_reply_t.Pointer,
Element_Array => xcb.xcb_glx_finish_reply_t.Pointer_Array,
Default_Terminator => null);
subtype Pointer_Pointer is C_Pointer_Pointers.Pointer;
end xcb.xcb_glx_finish_reply_t;
|
reznikmm/matreshka | Ada | 4,672 | 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_Style.Font_Family_Asian_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Style_Font_Family_Asian_Attribute_Node is
begin
return Self : Style_Font_Family_Asian_Attribute_Node do
Matreshka.ODF_Style.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Style_Prefix);
end return;
end Create;
--------------------
-- Get_Local_Name --
--------------------
overriding function Get_Local_Name
(Self : not null access constant Style_Font_Family_Asian_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Font_Family_Asian_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Style_URI,
Matreshka.ODF_String_Constants.Font_Family_Asian_Attribute,
Style_Font_Family_Asian_Attribute_Node'Tag);
end Matreshka.ODF_Style.Font_Family_Asian_Attributes;
|
AdaCore/Ada_Drivers_Library | Ada | 5,406 | ads | -- This spec has been automatically generated from cm4.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
-- 24Bit System Tick Timer for use in RTOS
package Cortex_M_SVD.SysTick is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- Enable SysTick Timer
type CSR_ENABLE_Field is
(
-- counter disabled
Disable,
-- counter enabled
Enable)
with Size => 1;
for CSR_ENABLE_Field use
(Disable => 0,
Enable => 1);
-- Generate Tick Interrupt
type CSR_TICKINT_Field is
(-- Counting down to zero asserts the SysTick exception request
Disable,
-- Counting down to zero does not assert the SysTick exception request
Enable)
with Size => 1;
for CSR_TICKINT_Field use
(Disable => 0,
Enable => 1);
-- Source to count from
type CSR_CLKSOURCE_Field is
(
-- External Clock
External_Clk,
-- CPU Clock
Cpu_Clk)
with Size => 1;
for CSR_CLKSOURCE_Field use
(External_Clk => 0,
Cpu_Clk => 1);
-- SysTick Control and Status Register
type SYST_CSR_Register is record
-- Enable SysTick Timer
ENABLE : CSR_ENABLE_Field := Cortex_M_SVD.SysTick.Disable;
-- Generate Tick Interrupt
TICKINT : CSR_TICKINT_Field := Cortex_M_SVD.SysTick.Disable;
-- Source to count from
CLKSOURCE : CSR_CLKSOURCE_Field := Cortex_M_SVD.SysTick.Cpu_Clk;
-- unspecified
Reserved_3_15 : HAL.UInt13 := 16#0#;
-- SysTick counted to zero
COUNTFLAG : Boolean := False;
-- unspecified
Reserved_17_31 : HAL.UInt15 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SYST_CSR_Register use record
ENABLE at 0 range 0 .. 0;
TICKINT at 0 range 1 .. 1;
CLKSOURCE at 0 range 2 .. 2;
Reserved_3_15 at 0 range 3 .. 15;
COUNTFLAG at 0 range 16 .. 16;
Reserved_17_31 at 0 range 17 .. 31;
end record;
subtype SYST_RVR_RELOAD_Field is HAL.UInt24;
-- SysTick Reload Value Register
type SYST_RVR_Register is record
-- Value to auto reload SysTick after reaching zero
RELOAD : SYST_RVR_RELOAD_Field := 16#0#;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SYST_RVR_Register use record
RELOAD at 0 range 0 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype SYST_CVR_CURRENT_Field is HAL.UInt24;
-- SysTick Current Value Register
type SYST_CVR_Register is record
-- Current value
CURRENT : SYST_CVR_CURRENT_Field := 16#0#;
-- unspecified
Reserved_24_31 : HAL.UInt8 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SYST_CVR_Register use record
CURRENT at 0 range 0 .. 23;
Reserved_24_31 at 0 range 24 .. 31;
end record;
subtype SYST_CALIB_TENMS_Field is HAL.UInt24;
-- Clock Skew
type CALIB_SKEW_Field is
(
-- 10ms calibration value is exact
Exact,
-- 10ms calibration value is inexact, because of the clock frequency
Inexact)
with Size => 1;
for CALIB_SKEW_Field use
(Exact => 0,
Inexact => 1);
-- No Ref
type CALIB_NOREF_Field is
(
-- Ref Clk available
Ref_Clk_Available,
-- Ref Clk not available
Ref_Clk_Unavailable)
with Size => 1;
for CALIB_NOREF_Field use
(Ref_Clk_Available => 0,
Ref_Clk_Unavailable => 1);
-- SysTick Calibration Value Register
type SYST_CALIB_Register is record
-- Read-only. Reload value to use for 10ms timing
TENMS : SYST_CALIB_TENMS_Field;
-- unspecified
Reserved_24_29 : HAL.UInt6;
-- Read-only. Clock Skew
SKEW : CALIB_SKEW_Field;
-- Read-only. No Ref
NOREF : CALIB_NOREF_Field;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for SYST_CALIB_Register use record
TENMS at 0 range 0 .. 23;
Reserved_24_29 at 0 range 24 .. 29;
SKEW at 0 range 30 .. 30;
NOREF at 0 range 31 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- 24Bit System Tick Timer for use in RTOS
type SysTick_Peripheral is record
-- SysTick Control and Status Register
CSR : aliased SYST_CSR_Register;
-- SysTick Reload Value Register
RVR : aliased SYST_RVR_Register;
-- SysTick Current Value Register
CVR : aliased SYST_CVR_Register;
-- SysTick Calibration Value Register
CALIB : aliased SYST_CALIB_Register;
end record
with Volatile;
for SysTick_Peripheral use record
CSR at 16#0# range 0 .. 31;
RVR at 16#4# range 0 .. 31;
CVR at 16#8# range 0 .. 31;
CALIB at 16#C# range 0 .. 31;
end record;
-- 24Bit System Tick Timer for use in RTOS
SysTick_Periph : aliased SysTick_Peripheral
with Import, Address => SysTick_Base;
end Cortex_M_SVD.SysTick;
|
sungyeon/drake | Ada | 36 | adb | ../machine-apple-darwin/a-hifina.adb |
Louis-Aime/Milesian_calendar_Ada | Ada | 5,462 | adb | -- Computus_test : Comparison of Easter date computations methods.
-- copyright Miletus 2015-2017 - no transformation allowed, no commercial use
-- application developed using GPS GPL 2014 of Adacore
-- inquiries: see www.calendriermilesien.org
-- Versions
-- M2017-11-14 : several tests possible within one single session.
-- M2019-01-16 : minor presentation enhancement
----------------------------------------------------------------------------
-- Copyright Miletus 2015-2019
-- 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:
-- 1. The above copyright notice and this permission notice shall be included
-- in all copies or substantial portions of the Software.
-- 2. Changes with respect to any former version shall be documented.
--
-- The software is provided "as is", without warranty of any kind,
-- express of implied, including but not limited to the warranties of
-- merchantability, fitness for a particular purpose and noninfringement.
-- In no event shall the authors of 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.
-- Inquiries: www.calendriermilesien.org
-------------------------------------------------------------------------------
with Julian_calendar; use Julian_calendar;
with Computus_meeus; use Computus_meeus;
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
with Text_IO; use Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure computus_test is
NL : constant String := CR & LF ;
Prompter : constant String := "Type command and figure, or H for Help:";
Help_text : constant String :=
"This line mode program challenges the Milesian Easter computation method"
& NL & "with standard Meeus methods." & NL &
"Copyright Louis-A. de Fouquieres, Miletus, 2015-2017." & NL &
"More at www.calendriermilesien.org." & NL &
"Syntax: <Command> <End year>." & NL &
"<Command> is one character as described hereunder." & NL &
"<End year> is an integer, the final year for the test." & NL &
"Tests begin with year 0 for both Julian and Gregorian algorithms, " & NL &
"although there is no historical sense" & NL &
"before around 525 (julian) or 1583 (gregorian)." & NL &
"Result of Eater computation is Easter day rank, i.e. " & NL &
"number of days after March 21st when Easter Sunday occurs." & NL &
"Available commands:" & NL &
"S: Silent mode (by default), list discrepancies only." & NL &
"V: Verbose mode, report year per year results." & NL &
"J <End year>: test Julian calendar computus from 0 to <End year>." & NL &
"G <End year: test Gregorian computus from 0 to <End year>." & NL &
"H: Help, display this text." & NL &
"X: Exit program.";
Command : Character := ' ';
Verbose : Boolean := False;
Level, D1, D2 : Natural := 0;
Help_request, Command_error : exception;
begin
Put ("Copyright Louis-A. de Fouquieres, Miletus, 2015-2019, calendriermilesien.org");
New_Line;
loop
begin -- a block with exception handler
Put (Prompter); New_Line;
Get (Command);
case Command is
when 'X' => Put ("Bye !");
when 'H' => Skip_Line; raise Help_request;
when 'V' => Verbose := True; Put ("Verbose mode on");
when 'S' => Verbose := False; Put ("Verbose mode off");
when 'G' | 'J' =>
Get (Level);
Put("Calendar: "); Put (Command);
Put (", final year: "); Put (Level, 7);
case Command is
when 'G' =>
For Year in 0 .. Level loop
D1 := Butcher (Year); D2 := Easter_days (Year, Gregorian);
if Verbose or D1 /= D2 then
New_Line; Put ("Year: "); Put (Year);
Put (", Butcher: "); Put (D1,2);
Put (", Milesian: "); Put (D2,2);
end if;
end loop;
when 'J' =>
For Year in 0 .. Level loop
D1 := Delambre (Year); D2 := Easter_days (Year, Julian);
if Verbose or D1 /= D2 then
New_Line; Put ("Year: "); Put (Year);
Put (", Delambre: "); Put (D1,2);
Put (", Milesian: "); Put (D2,2);
end if;
end loop;
when others => raise Command_error;
end case;
New_Line; Put ("== End comparison ==");
when others => raise Command_error;
end case;
exception
when Help_request => Put (Help_text);
when Command_error => Put (" Invalid command !"); Skip_Line;
when others => Put (" Unknown error !"); Skip_Line;
end;
exit when Command = 'X';
New_Line;
end loop;
end computus_test;
|
tum-ei-rcs/StratoX | Ada | 3,836 | 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 stm32f4xx_hal_rng.h --
-- @author MCD Application Team --
-- @version V1.1.0 --
-- @date 19-June-2014 --
-- @brief Header file of RNG HAL module. --
-- --
-- COPYRIGHT(c) 2014 STMicroelectronics --
------------------------------------------------------------------------------
-- This file provides the API for the random number generator on the STM32F4
-- (ARM Cortex M4F) microcontrollers from ST Microelectronics.
--
-- Random numbers are acquired by polling the on-board generator.
package STM32.RNG.Polling is
procedure Initialize_RNG with
Post => not RNG_Interrupt_Enabled;
-- Must be called once, prior to any call to get a random number via
-- polling. Both necessary and sufficient.
-- Enables the clock as well.
function Random return Interfaces.Unsigned_32;
-- Polls the RNG directly to get the next available number.
-- NB: call Initialize_RNG before any calls to this function.
end STM32.RNG.Polling;
|
reznikmm/matreshka | Ada | 3,432 | 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$
------------------------------------------------------------------------------
package AMF.Standard_Profile_L3 is
pragma Preelaborate;
end AMF.Standard_Profile_L3;
|
etorri/protobuf-ada | Ada | 30,136 | adb | pragma Ada_2012;
with Interfaces;
with Ada.Unchecked_Conversion;
with Protocol_Buffers.Message;
with Protocol_Buffers.IO.Invalid_Protocol_Buffer_Exception;
with Ada.Containers.Indefinite_Vectors;
package body Protocol_Buffers.IO.Coded_Input_Stream is
-----------------------
-- Decode_Zig_Zag_32 --
-----------------------
function Decode_Zig_Zag_32
(Value : in PB_UInt32)
return PB_UInt32
is
Value_To_Unsigned_32 : constant Interfaces.Unsigned_32 := Interfaces.Unsigned_32 (Value);
use type Interfaces.Unsigned_32;
begin
return PB_UInt32 (Interfaces.Shift_Right (Value_To_Unsigned_32, 1) xor - (Value_To_Unsigned_32 and 1));
end Decode_Zig_Zag_32;
-----------------------
-- Decode_Zig_Zag_64 --
-----------------------
function Decode_Zig_Zag_64
(Value : in PB_UInt64)
return PB_UInt64
is
Value_To_Unsigned_64 : constant Interfaces.Unsigned_64 := Interfaces.Unsigned_64 (Value);
use type Interfaces.Unsigned_64;
begin
return PB_UInt64 (Interfaces.Shift_Right (Value_To_Unsigned_64, 1) xor - (Value_To_Unsigned_64 and 1));
end Decode_Zig_Zag_64;
------------------
-- Read_Boolean --
------------------
function Read_Boolean
(This : in out Coded_Input_Stream.Instance)
return PB_Bool
is
function BOOLEAN_TO_PB_Bool is new
Ada.Unchecked_Conversion (Source => Boolean,
Target => PB_Bool);
use type PB_Byte;
begin
return BOOLEAN_TO_PB_Bool (This.Read_Raw_Byte /= 0);
end Read_Boolean;
-----------------
-- Read_Double --
-----------------
function Read_Double
(This : in out Coded_Input_Stream.Instance)
return PB_Double
is
function PB_UInt64_To_PB_Double is new
Ada.Unchecked_Conversion (Source => PB_UInt64,
Target => PB_Double);
begin
return PB_UInt64_To_PB_Double (This.Read_Raw_Little_Endian_64);
end Read_Double;
----------------------
-- Read_Enumeration --
----------------------
function Read_Enumeration
(This : in out Coded_Input_Stream.Instance)
return PB_Int32
is
function PB_UInt32_To_PB_Int32 is new
Ada.Unchecked_Conversion (Source => PB_UInt32,
Target => PB_Int32);
begin
return PB_UInt32_To_PB_Int32 (This.Read_Raw_Varint_32);
end Read_Enumeration;
-------------------
-- Read_Fixed_32 --
-------------------
function Read_Fixed_32
(This : in out Coded_Input_Stream.Instance)
return PB_UInt32
is
begin
return This.Read_Raw_Little_Endian_32;
end Read_Fixed_32;
-------------------
-- Read_Fixed_64 --
-------------------
function Read_Fixed_64
(This : in out Coded_Input_Stream.Instance)
return PB_UInt64
is
begin
return This.Read_Raw_Little_Endian_64;
end Read_Fixed_64;
----------------
-- Read_Float --
----------------
function Read_Float
(This : in out Coded_Input_Stream.Instance)
return PB_Float
is
function PB_UInt32_To_PB_Float is new
Ada.Unchecked_Conversion (Source => PB_UInt32,
Target => PB_Float);
begin
return PB_UInt32_To_PB_Float (This.Read_Raw_Little_Endian_32);
end Read_Float;
---------------------
-- Read_Integer_32 --
---------------------
function Read_Integer_32
(This : in out Coded_Input_Stream.Instance)
return PB_Int32
is
function PB_UInt32_To_PB_Int32 is new
Ada.Unchecked_Conversion (Source => PB_UInt32,
Target => PB_Int32);
begin
return PB_UInt32_To_PB_Int32 (This.Read_Raw_Varint_32);
end Read_Integer_32;
---------------------
-- Read_Integer_64 --
---------------------
function Read_Integer_64
(This : in out Coded_Input_Stream.Instance)
return PB_Int64
is
function PB_UInt64_To_PB_Int64 is new
Ada.Unchecked_Conversion (Source => PB_UInt64,
Target => PB_Int64);
begin
return PB_UInt64_To_PB_Int64 (This.Read_Raw_Varint_64);
end Read_Integer_64;
-------------------------------
-- Read_Raw_Little_Endian_32 --
-------------------------------
function Read_Raw_Little_Endian_32
(This : in out Coded_Input_Stream.Instance)
return PB_UInt32
is
Value : PB_UInt32;
Byte_1 : constant PB_Byte := This.Read_Raw_Byte;
Byte_2 : constant PB_Byte := This.Read_Raw_Byte;
Byte_3 : constant PB_Byte := This.Read_Raw_Byte;
Byte_4 : constant PB_Byte := This.Read_Raw_Byte;
use type PB_UInt32;
begin
Value := PB_UInt32 (Byte_4);
Value := Shift_Left (Value, 8);
Value := Value or PB_UInt32 (Byte_3);
Value := Shift_Left (Value, 8);
Value := Value or PB_UInt32 (Byte_2);
Value := Shift_Left (Value, 8);
Value := Value or PB_UInt32 (Byte_1);
return Value;
end Read_Raw_Little_Endian_32;
-------------------------------
-- Read_Raw_Little_Endian_64 --
-------------------------------
function Read_Raw_Little_Endian_64
(This : in out Coded_Input_Stream.Instance)
return PB_UInt64
is
Value : PB_UInt64;
Byte_1 : constant PB_Byte := This.Read_Raw_Byte;
Byte_2 : constant PB_Byte := This.Read_Raw_Byte;
Byte_3 : constant PB_Byte := This.Read_Raw_Byte;
Byte_4 : constant PB_Byte := This.Read_Raw_Byte;
Byte_5 : constant PB_Byte := This.Read_Raw_Byte;
Byte_6 : constant PB_Byte := This.Read_Raw_Byte;
Byte_7 : constant PB_Byte := This.Read_Raw_Byte;
Byte_8 : constant PB_Byte := This.Read_Raw_Byte;
use type PB_UInt64;
begin
Value := PB_UInt64 (Byte_8);
Value := Shift_Left (Value, 8);
Value := Value or PB_UInt64 (Byte_7);
Value := Shift_Left (Value, 8);
Value := Value or PB_UInt64 (Byte_6);
Value := Shift_Left (Value, 8);
Value := Value or PB_UInt64 (Byte_5);
Value := Shift_Left (Value, 8);
Value := Value or PB_UInt64 (Byte_4);
Value := Shift_Left (Value, 8);
Value := Value or PB_UInt64 (Byte_3);
Value := Shift_Left (Value, 8);
Value := Value or PB_UInt64 (Byte_2);
Value := Shift_Left (Value, 8);
Value := Value or PB_UInt64 (Byte_1);
return Value;
end Read_Raw_Little_Endian_64;
------------------------
-- Read_Raw_Varint_32 --
------------------------
function Read_Raw_Varint_32
(This : in out Coded_Input_Stream.Instance)
return PB_UInt32
is
Result : PB_UInt32 := 0;
Temp : PB_Byte := This.Read_Raw_Byte;
Byte_MSB_Set : constant := 16#80#;
use type PB_Byte;
use type PB_UInt32;
begin
-- MSB not set, which means that varint consist of only one byte. See Base 128 Varints:
-- https://developers.google.com/protocol-buffers/docs/encoding
if Temp < Byte_MSB_Set then
return PB_UInt32 (Temp);
end if;
Result := PB_UInt32 (Temp and 16#7F#); -- (TMP and 16#7F#) == set MSB to 0
Temp := This.Read_Raw_Byte;
if Temp < Byte_MSB_Set then
Result := Result or Shift_Left (PB_UInt32 (Temp), 7);
else
Result := Result or Shift_Left (PB_UInt32 (Temp and 16#7F#), 7);
Temp := This.Read_Raw_Byte;
if Temp < Byte_MSB_Set then
Result := Result or Shift_Left (PB_UInt32 (Temp), 14);
else
Result := Result or Shift_Left (PB_UInt32 (Temp and 16#7F#), 14);
Temp := This.Read_Raw_Byte;
if Temp < Byte_MSB_Set then
Result := Result or Shift_Left (PB_UInt32 (Temp), 21);
else
Result := Result or Shift_Left (PB_UInt32 (Temp and 16#7F#), 21);
Temp := This.Read_Raw_Byte;
Result := Result or Shift_Left (PB_UInt32 (Temp), 28);
-- Tests if last byte has MSB set in which case the varint is
-- malformed, since it cannot be represented by a 32-bit type.
if Temp >= Byte_MSB_Set then
-- Discard upper 32-bits
for I in 1 .. 5 loop
Temp := This.Read_Raw_Byte;
if Temp < Byte_MSB_Set then
return Result;
end if;
end loop;
Invalid_Protocol_Buffer_Exception.Malformed_Varint;
end if;
end if;
end if;
end if;
return Result;
end Read_Raw_Varint_32;
------------------------
-- Read_Raw_Varint_64 --
------------------------
function Read_Raw_Varint_64
(This : in out Coded_Input_Stream.Instance)
return PB_UInt64
is
Shift : Natural := 0;
Result : PB_UInt64 := 0;
Tmp : PB_Byte;
Byte_MSB_Set : constant := 16#80#;
use type PB_Byte;
use type PB_UInt64;
begin
while Shift < 64 loop
Tmp := This.Read_Raw_Byte;
Result := Result or Shift_Left (PB_UInt64 (Tmp and 16#7F#), Shift);
if (Tmp and Byte_MSB_Set) = 0 then
return Result;
end if;
Shift := Shift + 7;
end loop;
Invalid_Protocol_Buffer_Exception.Malformed_Varint;
return Result;
end Read_Raw_Varint_64;
--------------------------
-- Read_Signed_Fixed_32 --
--------------------------
function Read_Signed_Fixed_32
(This : in out Coded_Input_Stream.Instance)
return PB_Int32
is
function PB_UInt32_To_PB_Int32 is new
Ada.Unchecked_Conversion (Source => PB_UInt32,
Target => PB_Int32);
begin
return PB_UInt32_To_PB_Int32 (This.Read_Raw_Little_Endian_32);
end Read_Signed_Fixed_32;
--------------------------
-- Read_Signed_Fixed_64 --
--------------------------
function Read_Signed_Fixed_64
(This : in out Coded_Input_Stream.Instance)
return PB_Int64
is
function PB_UInt64_To_PB_Int64 is new
Ada.Unchecked_Conversion (Source => PB_UInt64,
Target => PB_Int64);
begin
return PB_UInt64_To_PB_Int64 (This.Read_Raw_Little_Endian_64);
end Read_Signed_Fixed_64;
----------------------------
-- Read_Signed_Integer_32 --
----------------------------
function Read_Signed_Integer_32
(This : in out Coded_Input_Stream.Instance)
return PB_Int32
is
function PB_UInt32_To_PB_Int32 is new
Ada.Unchecked_Conversion (Source => PB_UInt32,
Target => PB_Int32);
begin
return PB_UInt32_To_PB_Int32 (Decode_Zig_Zag_32 (This.Read_Raw_Varint_32));
end Read_Signed_Integer_32;
----------------------------
-- Read_Signed_Integer_64 --
----------------------------
function Read_Signed_Integer_64
(This : in out Coded_Input_Stream.Instance)
return PB_Int64
is
function PB_UInt64_To_PB_Int64 is new
Ada.Unchecked_Conversion (Source => PB_UInt64,
Target => PB_Int64);
begin
return PB_UInt64_To_PB_Int64 (Decode_Zig_Zag_64 (This.Read_Raw_Varint_64));
end Read_Signed_Integer_64;
-----------------
-- Read_String --
-----------------
function Read_String
(This : in out Coded_Input_Stream.Instance)
return PB_String_Access
is
Size : constant Stream_Element_Offset := Stream_Element_Offset (This.Read_Raw_Varint_32);
subtype Return_String_Type is PB_String (1 .. Integer (Size));
function Convert is new Ada.Unchecked_Conversion (Stream_Element_Array, Return_String_Type);
begin
if Size <= (This.Buffer_Size - This.Buffer_Position) and then Size > 0 then
-- Fast Path : We already have the bytes in a contiguous buffer, so
-- just copy directly from it.
declare
Result : PB_String_Access :=
new PB_String'(Convert (
This.Buffer
(This.Buffer_Position .. This.Buffer_Position + Size - 1)));
begin
This.Buffer_Position := This.Buffer_Position + Size;
return Result;
end;
else
return Result : PB_String_Access do
Result := new PB_String'(
Convert (
This.Read_Raw_Bytes (Size) (0 .. Size - 1)));
end return;
end if;
end Read_String;
--------------
-- Read_Tag --
--------------
function Read_Tag
(This : in out Coded_Input_Stream.Instance)
return PB_UInt32
is
use type PB_UInt32;
begin
if This.Is_At_End then
This.Last_Tag := 0;
return 0;
end if;
This.Last_Tag := This.Read_Raw_Varint_32;
if Get_Tag_Field_Number (This.Last_Tag) = 0 then
Invalid_Protocol_Buffer_Exception.Invalid_Tag;
end if;
return This.Last_Tag;
end Read_Tag;
------------------------------
-- Read_Unsigned_Integer_32 --
------------------------------
function Read_Unsigned_Integer_32
(This : in out Coded_Input_Stream.Instance)
return PB_UInt32
is
begin
return This.Read_Raw_Varint_32;
end Read_Unsigned_Integer_32;
------------------------------
-- Read_Unsigned_Integer_64 --
------------------------------
function Read_Unsigned_Integer_64
(This : in out Coded_Input_Stream.Instance)
return PB_UInt64
is
begin
return This.Read_Raw_Varint_64;
end Read_Unsigned_Integer_64;
----------------
-- Skip_Field --
----------------
function Skip_Field
(This : in out Coded_Input_Stream.Instance;
Tag : in PB_UInt32)
return Boolean
is
Dummy_1 : PB_Int32;
Dummy_2 : PB_UInt32;
Dummy_3 : PB_UInt64;
pragma Unreferenced (Dummy_1, Dummy_2, Dummy_3);
begin
case Get_Tag_Wire_Type (Tag) is
when VARINT =>
Dummy_1 := This.Read_Integer_32;
return True;
when FIXED_32 =>
Dummy_2 := This.Read_Raw_Little_Endian_32;
return True;
when FIXED_64 =>
Dummy_3 := This.Read_Raw_Little_Endian_64;
return True;
when LENGTH_DELIMITED =>
declare
Length : constant PB_UInt32 := This.Read_Raw_Varint_32;
begin
This.Skip_Raw_Bytes (Stream_Element_Count (Length));
end;
return True;
when START_GROUP =>
return True;
when END_GROUP =>
return False;
end case;
end Skip_Field;
------------------------
-- Check_Last_Tag_Was --
------------------------
procedure Check_Last_Tag_Was
(This : in Coded_Input_Stream.Instance;
Tag : in PB_UInt32)
is
use type PB_UInt32;
begin
if This.Last_Tag /= Tag then
Invalid_Protocol_Buffer_Exception.Invalid_End_Tag;
end if;
end Check_Last_Tag_Was;
------------------
-- Skip_Message --
------------------
procedure Skip_Message
(This : in out Coded_Input_Stream.Instance)
is
Tag : PB_UInt32;
use type PB_UInt32;
begin
loop
Tag := This.Read_Tag;
if Tag = 0 or else (not This.Skip_Field (Tag)) then
return;
end if;
end loop;
end Skip_Message;
------------------
-- Read_Message --
------------------
procedure Read_Message
(This : in out Coded_Input_Stream.Instance;
Value : in out Protocol_Buffers.Message.Instance'Class)
is
Length : constant PB_UInt32 := This.Read_Raw_Varint_32;
use type PB_UInt32;
begin
if This.Recursion_Depth >= This.Recursion_Limit then
Invalid_Protocol_Buffer_Exception.Recursion_Limit_Exceeded;
return;
end if;
declare
Old_Limit : constant Ada.Streams.Stream_Element_Count := This.Push_Limit (Stream_Element_Offset (Length));
begin
This.Recursion_Depth := This.Recursion_Depth + 1;
Value.Merge_Partial_From_Coded_Input_Stream (This);
This.Check_Last_Tag_Was (0);
This.Recursion_Depth := This.Recursion_Depth - 1;
This.Pop_Limit (Old_Limit);
end;
end Read_Message;
-- ==========================================================================
--------------------
-- Set_Size_Limit --
--------------------
function Set_Size_Limit
(This : in out Coded_Input_Stream.Instance;
Limit : in Stream_Element_Count) return Stream_Element_Count
is
Old_Limit : Stream_Element_Count := This.Size_Limit;
begin
This.Size_Limit := Limit;
return Old_Limit;
end Set_Size_Limit;
------------------------
-- Reset_Size_Counter --
------------------------
procedure Reset_Size_Counter
(This : in out Coded_Input_Stream.Instance)
is
begin
This.Total_Bytes_Retired := -This.Buffer_Position;
end Reset_Size_Counter;
----------------
-- Push_Limit --
----------------
function Push_Limit
(This : in out Coded_Input_Stream.Instance;
Byte_Limit : in Stream_Element_Count) return Stream_Element_Count
is
New_Current_Limit : Stream_Element_Count;
Old_Limit : constant Stream_Element_Count := This.Current_Limit;
begin
New_Current_Limit := Byte_Limit + This.Total_Bytes_Retired + This.Buffer_Position;
if Byte_Limit > Old_Limit then
Invalid_Protocol_Buffer_Exception.Truncated_Message;
end if;
This.Current_Limit := New_Current_Limit;
This.Recompute_Buffer_Size_After_Limit;
return Old_Limit;
end Push_Limit;
---------------
-- Pop_Limit --
---------------
procedure Pop_Limit
(This : in out Coded_Input_Stream.Instance;
Old_Limit : in Stream_Element_Count)
is
begin
This.Current_Limit := Old_Limit;
This.Recompute_Buffer_Size_After_Limit;
end Pop_Limit;
---------------------------
-- Get_Bytes_Until_Limit --
---------------------------
function Get_Bytes_Until_Limit
(This : in Coded_Input_Stream.Instance) return Stream_Element_Offset
is
begin
if This.Current_Limit = Stream_Element_Count'Last then
return -1;
end if;
declare
Current_Absolute_Position : constant Stream_Element_Offset :=
This.Total_Bytes_Retired + This.Buffer_Position;
begin
return This.Current_Limit - Current_Absolute_Position;
end;
end Get_Bytes_Until_Limit;
---------------
-- Is_At_End --
---------------
function Is_At_End
(This : in out Coded_Input_Stream.Instance) return Boolean
is
begin
return (This.Buffer_Position = This.Buffer_Size)
and then (not This.Refill_Buffer (False));
end Is_At_End;
--------------------------
-- Get_Total_Bytes_Read --
--------------------------
function Get_Total_Bytes_Read
(This : in Coded_Input_Stream.Instance) return Ada.Streams.Stream_Element_Count
is
begin
return This.Total_Bytes_Retired + This.Buffer_Position;
end Get_Total_Bytes_Read;
-------------------
-- Refill_Buffer --
-------------------
function Refill_Buffer
(This : in out Coded_Input_Stream.Instance;
Must_Succeed : in Boolean) return Boolean
is
begin
if This.Buffer_Position < This.Buffer_Size then
raise Invalid_Protocol_Buffer_Exception.Protocol_Buffer_Exception with
"Refill_Buffer called when buffer wasn't empty.";
return False;
end if;
-- Have we hit the Current_Limit?
if This.Total_Bytes_Retired + This.Buffer_Size = This.Current_Limit then
if Must_Succeed then
Invalid_Protocol_Buffer_Exception.Truncated_Message;
return False;
else
return False;
end if;
end if;
This.Total_Bytes_Retired := This.Total_Bytes_Retired + This.Buffer_Size;
This.Buffer_Position := 0;
declare
Last : Stream_Element_Offset;
Total_Bytes_Read : Stream_Element_Count;
begin
This.Input_Stream.Read (This.Buffer, Last);
-- Check for end of stream
if This.Buffer'First - 1 = Last then
This.Buffer_Size := 0;
if Must_Succeed then
Invalid_Protocol_Buffer_Exception.Truncated_Message;
return False;
else
return False;
end if;
else
This.Buffer_Size := Last + 1;
This.Recompute_Buffer_Size_After_Limit;
Total_Bytes_Read := This.Total_Bytes_Retired + This.Buffer_Size + This.Buffer_Size_After_Limit;
if Total_Bytes_Read > This.Size_Limit then
Invalid_Protocol_Buffer_Exception.Size_Limit_Exceeded;
return False;
end if;
return True;
end if;
end;
end Refill_Buffer;
-------------------
-- Read_Raw_Byte --
-------------------
function Read_Raw_Byte
(This : in out Coded_Input_Stream.Instance) return PB_Byte
is
Dummy : Boolean;
pragma Unreferenced (Dummy);
-- Move???
function Stream_Element_To_PB_Byte is new Ada.Unchecked_Conversion (Stream_Element, PB_Byte);
begin
if This.Buffer_Position = This.Buffer_Size then
Dummy := This.Refill_Buffer (True);
end if;
declare
Old_Buffer_Position : constant Stream_Element_Offset := This.Buffer_Position;
begin
This.Buffer_Position := This.Buffer_Position + 1;
return Stream_Element_To_PB_Byte (This.Buffer (Old_Buffer_Position));
end;
end Read_Raw_Byte;
---------------------------------------
-- Recompute_Buffer_Size_After_Limit --
---------------------------------------
procedure Recompute_Buffer_Size_After_Limit
(This : in out Coded_Input_Stream.Instance)
is
begin
This.Buffer_Size := This.Buffer_Size + This.Buffer_Size_After_Limit;
declare
Buffer_End : constant Stream_Element_Count := This.Total_Bytes_Retired + This.Buffer_Size;
begin
if Buffer_End > This.Current_Limit then
This.Buffer_Size_After_Limit := Buffer_End - This.Current_Limit;
This.Buffer_Size := This.Buffer_Size - This.Buffer_Size_After_Limit;
else
This.Buffer_Size_After_Limit := 0;
end if;
end;
end Recompute_Buffer_Size_After_Limit;
--------------------
-- Read_Raw_Bytes --
--------------------
function Read_Raw_Bytes
(This : in out Coded_Input_Stream.Instance;
Size : in Stream_Element_Count) return Stream_Element_Array
is
Dummy : Boolean;
pragma Unreferenced (Dummy);
begin
-- Are we reading outside the current limit?
if This.Total_Bytes_Retired + This.Buffer_Position + Size > This.Current_Limit then
-- Skip bytes up to limit
This.Skip_Raw_Bytes (This.Current_Limit - This.Total_Bytes_Retired - This.Buffer_Position);
-- Fail here
Invalid_Protocol_Buffer_Exception.Truncated_Message;
return Stream_Element_Array'(0 => <>);
end if;
if Size <= This.Buffer_Size - This.Buffer_Position then
-- All bytes needed are already buffered
return Bytes : Stream_Element_Array (0 .. Size - 1) do
Bytes := This.Buffer (This.Buffer_Position .. This.Buffer_Position + Size - 1);
This.Buffer_Position := This.Buffer_Position + Size;
end return;
elsif Size < BUFFER_SIZE then
-- Reading more bytes than are in the buffer, but not an excessive number
-- of bytes. We can safely allocate the resulting array ahead of time.
declare
Bytes : Stream_Element_Array (0 .. Size - 1);
Position : Stream_Element_Offset := This.Buffer_Size - This.Buffer_Position;
begin
-- First copy what we have.
Bytes (0 .. Position - 1) := This.Buffer (This.Buffer_Position .. This.Buffer_Position + Position - 1);
This.Buffer_Position := This.Buffer_Size;
Dummy := This.Refill_Buffer (True);
while Size - Position > This.Buffer_Size loop
Bytes (Position .. This.Buffer_Size - 1) := This.Buffer (0 .. This.Buffer_Size - 1);
Position := Position + This.Buffer_Size;
This.Buffer_Position := This.Buffer_Size;
Dummy := This.Refill_Buffer (True);
end loop;
Bytes (Position .. Size - 1) := This.Buffer (0 .. Size - Position - 1);
This.Buffer_Position := Size - Position;
return Bytes;
end;
else
-- The size is very large. For security reasons, we can't allocate the
-- entire byte array yet. The size comes directly from the input, so a
-- maliciously-crafted message could provide a bogus very large size in
-- order to trick the app into allocating a lot of memory. We avoid this
-- by allocating and reading only a small chunk at a time, so that the
-- malicious message must actually *be* extremely large to cause
-- problems. Meanwhile, we limit the allowed size of a message elsewhere.
-- Remember the buffer markers since we'll have to copy the bytes out of
-- it later.
-- Consider replacing this code which might be _very_ inefficient!
declare
subtype Buffer_Type is Stream_Element_Array (0 .. BUFFER_SIZE - 1);
package Buffer_Vector is new Ada.Containers.Indefinite_Vectors (Natural, Stream_Element_Array);
Chunks : Buffer_Vector.Vector;
Original_Buffer_Size : constant Stream_Element_Count := This.Buffer_Size;
Original_Buffer_Position : constant Stream_Element_Offset := This.Buffer_Position;
Size_Left : Stream_Element_Count := Size - (Original_Buffer_Size - Original_Buffer_Position);
begin
This.Total_Bytes_Retired := This.Total_Bytes_Retired + This.Buffer_Size;
This.Buffer_Position := 0;
This.Buffer_Size := 0;
while Size_Left > 0 loop
declare
Chunk : Buffer_Type;
Position : Stream_Element_Offset := 0;
Read_Size : constant Stream_Element_Count := Stream_Element_Count'Min (Size_Left, BUFFER_SIZE);
Last : Stream_Element_Offset;
begin
while Position < Read_Size loop
This.Input_Stream.Read (Chunk (Position .. Read_Size - Position - 1), Last);
if This.Buffer'First - 1 = Last then
Invalid_Protocol_Buffer_Exception.Truncated_Message;
return Stream_Element_Array'(0 => <>);
end if;
This.Total_Bytes_Retired := This.Total_Bytes_Retired + Last + 1;
Position := Last + 1;
end loop;
Size_Left := Size_Left - Read_Size;
Chunks.Append (Chunk (0 .. Read_Size - 1));
end;
end loop;
-- OK, got everything. Now concatenate it all into one buffer.
declare
Bytes : Stream_Element_Array (0 .. Size - 1);
Position : Stream_Element_Offset := Original_Buffer_Size - Original_Buffer_Position;
begin
-- Start by copying the leftover bytes from This.Buffer
Bytes (0 .. Position - 1) := This.Buffer (Original_Buffer_Position .. Original_Buffer_Position + Position - 1);
for E of Chunks loop
Bytes (Position .. Position + E'Length - 1) := E;
Position := Position + E'Length;
end loop;
return Bytes;
end;
end;
end if;
end Read_Raw_Bytes;
--------------------
-- Skip_Raw_Bytes --
--------------------
procedure Skip_Raw_Bytes
(This : in out Coded_Input_Stream.Instance;
Size : in Stream_Element_Count)
is
Dummy : Boolean;
pragma Unreferenced (Dummy);
begin
-- Are we reading outside the current limit?
if This.Total_Bytes_Retired + This.Buffer_Position + Size > This.Current_Limit then
-- Skip bytes up to limit
This.Skip_Raw_Bytes (This.Current_Limit - This.Total_Bytes_Retired - This.Buffer_Position);
-- Fail here
Invalid_Protocol_Buffer_Exception.Truncated_Message;
end if;
if Size <= This.Buffer_Size - This.Buffer_Position then
-- All bytes needed are already buffered
This.Buffer_Position := This.Buffer_Position + Size;
else
-- Skipping more bytes than are in the buffer. First skip what we have.
declare
Position : Stream_Element_Offset := This.Buffer_Size - This.Buffer_Position;
begin
This.Buffer_Position := This.Buffer_Size;
-- Keep refilling the buffer until we get to the point we wanted to skip
-- to. This has the side effect of ensuring the limits are updated
-- correctly.
Dummy := This.Refill_Buffer (True);
while Size - Position > This.Buffer_Size loop
Position := Position + This.Buffer_Size;
This.Buffer_Position := This.Buffer_Size;
Dummy := This.Refill_Buffer (True);
end loop;
This.Buffer_Position := Size - Position;
end;
end if;
end Skip_Raw_Bytes;
end Protocol_Buffers.IO.Coded_Input_Stream;
|
reznikmm/matreshka | Ada | 3,744 | 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.Style_Paper_Tray_Name_Attributes is
pragma Preelaborate;
type ODF_Style_Paper_Tray_Name_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Style_Paper_Tray_Name_Attribute_Access is
access all ODF_Style_Paper_Tray_Name_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Style_Paper_Tray_Name_Attributes;
|
reznikmm/matreshka | Ada | 11,030 | 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$
------------------------------------------------------------------------------
with AMF.Elements;
with AMF.Internals.Helpers;
with AMF.Internals.Tables.UML_Attributes;
with AMF.Visitors.UMLDI_Iterators;
with AMF.Visitors.UMLDI_Visitors;
with League.Strings.Internals;
package body AMF.Internals.UMLDI_UML_Multiplicity_Labels is
-----------------------
-- Get_Model_Element --
-----------------------
overriding function Get_Model_Element
(Self : not null access constant UMLDI_UML_Multiplicity_Label_Proxy)
return AMF.UML.Multiplicity_Elements.UML_Multiplicity_Element_Access is
begin
return
AMF.UML.Multiplicity_Elements.UML_Multiplicity_Element_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Model_Element
(Self.Element)));
end Get_Model_Element;
-----------------------
-- Set_Model_Element --
-----------------------
overriding procedure Set_Model_Element
(Self : not null access UMLDI_UML_Multiplicity_Label_Proxy;
To : AMF.UML.Multiplicity_Elements.UML_Multiplicity_Element_Access) is
begin
raise Program_Error;
-- AMF.Internals.Tables.UML_Attributes.Internal_Set_Model_Element
-- (Self.Element,
-- AMF.Internals.Helpers.To_Element
-- (AMF.Elements.Element_Access (To)));
end Set_Model_Element;
--------------
-- Get_Text --
--------------
overriding function Get_Text
(Self : not null access constant UMLDI_UML_Multiplicity_Label_Proxy)
return League.Strings.Universal_String is
begin
null;
return
League.Strings.Internals.Create
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Text (Self.Element));
end Get_Text;
--------------
-- Set_Text --
--------------
overriding procedure Set_Text
(Self : not null access UMLDI_UML_Multiplicity_Label_Proxy;
To : League.Strings.Universal_String) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Text
(Self.Element,
League.Strings.Internals.Internal (To));
end Set_Text;
-----------------
-- Get_Is_Icon --
-----------------
overriding function Get_Is_Icon
(Self : not null access constant UMLDI_UML_Multiplicity_Label_Proxy)
return Boolean is
begin
return
AMF.Internals.Tables.UML_Attributes.Internal_Get_Is_Icon
(Self.Element);
end Get_Is_Icon;
-----------------
-- Set_Is_Icon --
-----------------
overriding procedure Set_Is_Icon
(Self : not null access UMLDI_UML_Multiplicity_Label_Proxy;
To : Boolean) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Is_Icon
(Self.Element, To);
end Set_Is_Icon;
---------------------
-- Get_Local_Style --
---------------------
overriding function Get_Local_Style
(Self : not null access constant UMLDI_UML_Multiplicity_Label_Proxy)
return AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access is
begin
return
AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Local_Style
(Self.Element)));
end Get_Local_Style;
---------------------
-- Set_Local_Style --
---------------------
overriding procedure Set_Local_Style
(Self : not null access UMLDI_UML_Multiplicity_Label_Proxy;
To : AMF.UMLDI.UML_Styles.UMLDI_UML_Style_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Local_Style
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Local_Style;
-----------------------
-- Get_Model_Element --
-----------------------
overriding function Get_Model_Element
(Self : not null access constant UMLDI_UML_Multiplicity_Label_Proxy)
return AMF.UML.Elements.Collections.Set_Of_UML_Element is
begin
raise Program_Error;
return X : AMF.UML.Elements.Collections.Set_Of_UML_Element;
-- return
-- AMF.UML.Elements.Collections.Wrap
-- (AMF.Internals.Element_Collections.Wrap
-- (AMF.Internals.Tables.UML_Attributes.Internal_Get_Model_Element
-- (Self.Element)));
end Get_Model_Element;
-----------------------
-- Get_Model_Element --
-----------------------
overriding function Get_Model_Element
(Self : not null access constant UMLDI_UML_Multiplicity_Label_Proxy)
return AMF.CMOF.Elements.CMOF_Element_Access is
begin
return
AMF.CMOF.Elements.CMOF_Element_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Model_Element
(Self.Element)));
end Get_Model_Element;
---------------------
-- Get_Local_Style --
---------------------
overriding function Get_Local_Style
(Self : not null access constant UMLDI_UML_Multiplicity_Label_Proxy)
return AMF.DI.Styles.DI_Style_Access is
begin
return
AMF.DI.Styles.DI_Style_Access
(AMF.Internals.Helpers.To_Element
(AMF.Internals.Tables.UML_Attributes.Internal_Get_Local_Style
(Self.Element)));
end Get_Local_Style;
---------------------
-- Set_Local_Style --
---------------------
overriding procedure Set_Local_Style
(Self : not null access UMLDI_UML_Multiplicity_Label_Proxy;
To : AMF.DI.Styles.DI_Style_Access) is
begin
AMF.Internals.Tables.UML_Attributes.Internal_Set_Local_Style
(Self.Element,
AMF.Internals.Helpers.To_Element
(AMF.Elements.Element_Access (To)));
end Set_Local_Style;
-------------------
-- Enter_Element --
-------------------
overriding procedure Enter_Element
(Self : not null access constant UMLDI_UML_Multiplicity_Label_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.UMLDI_Visitors.UMLDI_Visitor'Class then
AMF.Visitors.UMLDI_Visitors.UMLDI_Visitor'Class
(Visitor).Enter_UML_Multiplicity_Label
(AMF.UMLDI.UML_Multiplicity_Labels.UMLDI_UML_Multiplicity_Label_Access (Self),
Control);
end if;
end Enter_Element;
-------------------
-- Leave_Element --
-------------------
overriding procedure Leave_Element
(Self : not null access constant UMLDI_UML_Multiplicity_Label_Proxy;
Visitor : in out AMF.Visitors.Abstract_Visitor'Class;
Control : in out AMF.Visitors.Traverse_Control) is
begin
if Visitor in AMF.Visitors.UMLDI_Visitors.UMLDI_Visitor'Class then
AMF.Visitors.UMLDI_Visitors.UMLDI_Visitor'Class
(Visitor).Leave_UML_Multiplicity_Label
(AMF.UMLDI.UML_Multiplicity_Labels.UMLDI_UML_Multiplicity_Label_Access (Self),
Control);
end if;
end Leave_Element;
-------------------
-- Visit_Element --
-------------------
overriding procedure Visit_Element
(Self : not null access constant UMLDI_UML_Multiplicity_Label_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.UMLDI_Iterators.UMLDI_Iterator'Class then
AMF.Visitors.UMLDI_Iterators.UMLDI_Iterator'Class
(Iterator).Visit_UML_Multiplicity_Label
(Visitor,
AMF.UMLDI.UML_Multiplicity_Labels.UMLDI_UML_Multiplicity_Label_Access (Self),
Control);
end if;
end Visit_Element;
end AMF.Internals.UMLDI_UML_Multiplicity_Labels;
|
AdaCore/gpr | Ada | 48 | ads | package Pack3 is
procedure Dummy;
end Pack3;
|
Gabriel-Degret/adalib | Ada | 551 | ads | -- Standard Ada library specification
-- Copyright (c) 2003-2018 Maxim Reznik <[email protected]>
-- Copyright (c) 2004-2016 AXE Consultants
-- Copyright (c) 2004, 2005, 2006 Ada-Europe
-- Copyright (c) 2000 The MITRE Corporation, Inc.
-- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
-- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
---------------------------------------------------------------------------
package Ada.Characters is
pragma Pure (Characters);
end Ada.Characters;
|
gabemgem/LITEC | Ada | 13,373 | adb | M:kpdlcdtestPCA
F:G$SYSCLK_Init$0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$UART0_Init$0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$Sys_Init$0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$putchar$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$getchar$0$0({2}DF,SC:U),Z,0,0,0,0,0
F:G$getchar_nw$0$0({2}DF,SC:U),C,0,0,0,0,0
F:G$lcd_print$0$0({2}DF,SV:S),Z,0,0,0,0,0
S:LkpdlcdtestPCA.lcd_print$fmt$1$80({3}DG,SC:U),B,1,-5
S:LkpdlcdtestPCA.lcd_print$len$1$81({1}SC:U),R,0,0,[r6]
S:LkpdlcdtestPCA.lcd_print$i$1$81({1}SC:U),R,0,0,[]
S:LkpdlcdtestPCA.lcd_print$ap$1$81({1}DD,SC:U),R,0,0,[]
F:G$lcd_clear$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$read_keypad$0$0({2}DF,SC:U),C,0,0,0,0,0
F:G$kpd_input$0$0({2}DF,SI:U),Z,0,0,0,0,0
F:G$delay_time$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$i2c_start$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$i2c_write$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$i2c_write_and_stop$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$i2c_read$0$0({2}DF,SC:U),Z,0,0,0,0,0
F:G$i2c_read_and_stop$0$0({2}DF,SC:U),Z,0,0,0,0,0
F:G$i2c_write_data$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$i2c_read_data$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$Accel_Init$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$Accel_Init_C$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$main$0$0({2}DF,SV:S),C,0,0,0,0,0
F:G$Port_Init$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$Interrupt_Init$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$PCA_Init$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$SMB0_Init$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$PCA_ISR$0$0({2}DF,SV:S),Z,0,0,1,9,0
F:G$pause$0$0({2}DF,SV:S),Z,0,0,0,0,0
F:G$wait$0$0({2}DF,SV:S),Z,0,0,0,0,0
S:LkpdlcdtestPCA.getchar$c$1$43({1}SC:U),R,0,0,[]
S:LkpdlcdtestPCA.getchar_nw$c$1$45({1}SC:U),R,0,0,[]
S:G$Data2$0$0({3}DA3d,SC:U),E,0,0
S:LkpdlcdtestPCA.lcd_clear$NumBytes$1$85({1}SC:U),E,0,0
S:LkpdlcdtestPCA.lcd_clear$Cmd$1$85({2}DA2d,SC:U),E,0,0
S:LkpdlcdtestPCA.read_keypad$i$1$86({1}SC:U),R,0,0,[r7]
S:LkpdlcdtestPCA.read_keypad$Data$1$86({2}DA2d,SC:U),E,0,0
S:LkpdlcdtestPCA.kpd_input$mode$1$88({1}SC:U),R,0,0,[r7]
S:LkpdlcdtestPCA.kpd_input$sum$1$89({2}SI:U),R,0,0,[r5,r6]
S:LkpdlcdtestPCA.kpd_input$key$1$89({1}SC:U),R,0,0,[r3]
S:LkpdlcdtestPCA.kpd_input$i$1$89({1}SC:U),R,0,0,[]
S:LkpdlcdtestPCA.i2c_write_data$start_reg$1$105({1}SC:U),E,0,0
S:LkpdlcdtestPCA.i2c_write_data$buffer$1$105({3}DG,SC:U),E,0,0
S:LkpdlcdtestPCA.i2c_write_data$num_bytes$1$105({1}SC:U),E,0,0
S:LkpdlcdtestPCA.i2c_write_data$addr$1$105({1}SC:U),R,0,0,[r7]
S:LkpdlcdtestPCA.i2c_write_data$i$1$106({1}SC:U),R,0,0,[]
S:LkpdlcdtestPCA.i2c_read_data$start_reg$1$107({1}SC:U),E,0,0
S:LkpdlcdtestPCA.i2c_read_data$buffer$1$107({3}DG,SC:U),E,0,0
S:LkpdlcdtestPCA.i2c_read_data$num_bytes$1$107({1}SC:U),E,0,0
S:LkpdlcdtestPCA.i2c_read_data$addr$1$107({1}SC:U),R,0,0,[r7]
S:LkpdlcdtestPCA.i2c_read_data$j$1$108({1}SC:U),R,0,0,[]
S:G$Counts$0$0({2}SI:U),E,0,0
S:G$nCounts$0$0({2}SI:U),E,0,0
S:G$nOverflows$0$0({2}SI:U),E,0,0
S:LkpdlcdtestPCA.main$keypad$1$122({2}SI:U),R,0,0,[r6,r7]
S:LkpdlcdtestPCA.lcd_print$text$1$81({80}DA80d,SC:U),F,0,0
S:G$P0$0$0({1}SC:U),I,0,0
S:G$SP$0$0({1}SC:U),I,0,0
S:G$DPL$0$0({1}SC:U),I,0,0
S:G$DPH$0$0({1}SC:U),I,0,0
S:G$P4$0$0({1}SC:U),I,0,0
S:G$P5$0$0({1}SC:U),I,0,0
S:G$P6$0$0({1}SC:U),I,0,0
S:G$PCON$0$0({1}SC:U),I,0,0
S:G$TCON$0$0({1}SC:U),I,0,0
S:G$TMOD$0$0({1}SC:U),I,0,0
S:G$TL0$0$0({1}SC:U),I,0,0
S:G$TL1$0$0({1}SC:U),I,0,0
S:G$TH0$0$0({1}SC:U),I,0,0
S:G$TH1$0$0({1}SC:U),I,0,0
S:G$CKCON$0$0({1}SC:U),I,0,0
S:G$PSCTL$0$0({1}SC:U),I,0,0
S:G$P1$0$0({1}SC:U),I,0,0
S:G$TMR3CN$0$0({1}SC:U),I,0,0
S:G$TMR3RLL$0$0({1}SC:U),I,0,0
S:G$TMR3RLH$0$0({1}SC:U),I,0,0
S:G$TMR3L$0$0({1}SC:U),I,0,0
S:G$TMR3H$0$0({1}SC:U),I,0,0
S:G$P7$0$0({1}SC:U),I,0,0
S:G$SCON$0$0({1}SC:U),I,0,0
S:G$SCON0$0$0({1}SC:U),I,0,0
S:G$SBUF$0$0({1}SC:U),I,0,0
S:G$SBUF0$0$0({1}SC:U),I,0,0
S:G$SPI0CFG$0$0({1}SC:U),I,0,0
S:G$SPI0DAT$0$0({1}SC:U),I,0,0
S:G$ADC1$0$0({1}SC:U),I,0,0
S:G$SPI0CKR$0$0({1}SC:U),I,0,0
S:G$CPT0CN$0$0({1}SC:U),I,0,0
S:G$CPT1CN$0$0({1}SC:U),I,0,0
S:G$P2$0$0({1}SC:U),I,0,0
S:G$EMI0TC$0$0({1}SC:U),I,0,0
S:G$EMI0CF$0$0({1}SC:U),I,0,0
S:G$PRT0CF$0$0({1}SC:U),I,0,0
S:G$P0MDOUT$0$0({1}SC:U),I,0,0
S:G$PRT1CF$0$0({1}SC:U),I,0,0
S:G$P1MDOUT$0$0({1}SC:U),I,0,0
S:G$PRT2CF$0$0({1}SC:U),I,0,0
S:G$P2MDOUT$0$0({1}SC:U),I,0,0
S:G$PRT3CF$0$0({1}SC:U),I,0,0
S:G$P3MDOUT$0$0({1}SC:U),I,0,0
S:G$IE$0$0({1}SC:U),I,0,0
S:G$SADDR0$0$0({1}SC:U),I,0,0
S:G$ADC1CN$0$0({1}SC:U),I,0,0
S:G$ADC1CF$0$0({1}SC:U),I,0,0
S:G$AMX1SL$0$0({1}SC:U),I,0,0
S:G$P3IF$0$0({1}SC:U),I,0,0
S:G$SADEN1$0$0({1}SC:U),I,0,0
S:G$EMI0CN$0$0({1}SC:U),I,0,0
S:G$_XPAGE$0$0({1}SC:U),I,0,0
S:G$P3$0$0({1}SC:U),I,0,0
S:G$OSCXCN$0$0({1}SC:U),I,0,0
S:G$OSCICN$0$0({1}SC:U),I,0,0
S:G$P74OUT$0$0({1}SC:U),I,0,0
S:G$FLSCL$0$0({1}SC:U),I,0,0
S:G$FLACL$0$0({1}SC:U),I,0,0
S:G$IP$0$0({1}SC:U),I,0,0
S:G$SADEN0$0$0({1}SC:U),I,0,0
S:G$AMX0CF$0$0({1}SC:U),I,0,0
S:G$AMX0SL$0$0({1}SC:U),I,0,0
S:G$ADC0CF$0$0({1}SC:U),I,0,0
S:G$P1MDIN$0$0({1}SC:U),I,0,0
S:G$ADC0L$0$0({1}SC:U),I,0,0
S:G$ADC0H$0$0({1}SC:U),I,0,0
S:G$SMB0CN$0$0({1}SC:U),I,0,0
S:G$SMB0STA$0$0({1}SC:U),I,0,0
S:G$SMB0DAT$0$0({1}SC:U),I,0,0
S:G$SMB0ADR$0$0({1}SC:U),I,0,0
S:G$ADC0GTL$0$0({1}SC:U),I,0,0
S:G$ADC0GTH$0$0({1}SC:U),I,0,0
S:G$ADC0LTL$0$0({1}SC:U),I,0,0
S:G$ADC0LTH$0$0({1}SC:U),I,0,0
S:G$T2CON$0$0({1}SC:U),I,0,0
S:G$T4CON$0$0({1}SC:U),I,0,0
S:G$RCAP2L$0$0({1}SC:U),I,0,0
S:G$RCAP2H$0$0({1}SC:U),I,0,0
S:G$TL2$0$0({1}SC:U),I,0,0
S:G$TH2$0$0({1}SC:U),I,0,0
S:G$SMB0CR$0$0({1}SC:U),I,0,0
S:G$PSW$0$0({1}SC:U),I,0,0
S:G$REF0CN$0$0({1}SC:U),I,0,0
S:G$DAC0L$0$0({1}SC:U),I,0,0
S:G$DAC0H$0$0({1}SC:U),I,0,0
S:G$DAC0CN$0$0({1}SC:U),I,0,0
S:G$DAC1L$0$0({1}SC:U),I,0,0
S:G$DAC1H$0$0({1}SC:U),I,0,0
S:G$DAC1CN$0$0({1}SC:U),I,0,0
S:G$PCA0CN$0$0({1}SC:U),I,0,0
S:G$PCA0MD$0$0({1}SC:U),I,0,0
S:G$PCA0CPM0$0$0({1}SC:U),I,0,0
S:G$PCA0CPM1$0$0({1}SC:U),I,0,0
S:G$PCA0CPM2$0$0({1}SC:U),I,0,0
S:G$PCA0CPM3$0$0({1}SC:U),I,0,0
S:G$PCA0CPM4$0$0({1}SC:U),I,0,0
S:G$ACC$0$0({1}SC:U),I,0,0
S:G$XBR0$0$0({1}SC:U),I,0,0
S:G$XBR1$0$0({1}SC:U),I,0,0
S:G$XBR2$0$0({1}SC:U),I,0,0
S:G$RCAP4L$0$0({1}SC:U),I,0,0
S:G$RCAP4H$0$0({1}SC:U),I,0,0
S:G$EIE1$0$0({1}SC:U),I,0,0
S:G$EIE2$0$0({1}SC:U),I,0,0
S:G$ADC0CN$0$0({1}SC:U),I,0,0
S:G$PCA0L$0$0({1}SC:U),I,0,0
S:G$PCA0CPL0$0$0({1}SC:U),I,0,0
S:G$PCA0CPL1$0$0({1}SC:U),I,0,0
S:G$PCA0CPL2$0$0({1}SC:U),I,0,0
S:G$PCA0CPL3$0$0({1}SC:U),I,0,0
S:G$PCA0CPL4$0$0({1}SC:U),I,0,0
S:G$RSTSRC$0$0({1}SC:U),I,0,0
S:G$B$0$0({1}SC:U),I,0,0
S:G$SCON1$0$0({1}SC:U),I,0,0
S:G$SBUF1$0$0({1}SC:U),I,0,0
S:G$SADDR1$0$0({1}SC:U),I,0,0
S:G$TL4$0$0({1}SC:U),I,0,0
S:G$TH4$0$0({1}SC:U),I,0,0
S:G$EIP1$0$0({1}SC:U),I,0,0
S:G$EIP2$0$0({1}SC:U),I,0,0
S:G$SPI0CN$0$0({1}SC:U),I,0,0
S:G$PCA0H$0$0({1}SC:U),I,0,0
S:G$PCA0CPH0$0$0({1}SC:U),I,0,0
S:G$PCA0CPH1$0$0({1}SC:U),I,0,0
S:G$PCA0CPH2$0$0({1}SC:U),I,0,0
S:G$PCA0CPH3$0$0({1}SC:U),I,0,0
S:G$PCA0CPH4$0$0({1}SC:U),I,0,0
S:G$WDTCN$0$0({1}SC:U),I,0,0
S:G$TMR0$0$0({2}SI:U),I,0,0
S:G$TMR1$0$0({2}SI:U),I,0,0
S:G$TMR2$0$0({2}SI:U),I,0,0
S:G$RCAP2$0$0({2}SI:U),I,0,0
S:G$TMR3$0$0({2}SI:U),I,0,0
S:G$TMR3RL$0$0({2}SI:U),I,0,0
S:G$TMR4$0$0({2}SI:U),I,0,0
S:G$RCAP4$0$0({2}SI:U),I,0,0
S:G$ADC0$0$0({2}SI:U),I,0,0
S:G$ADC0GT$0$0({2}SI:U),I,0,0
S:G$ADC0LT$0$0({2}SI:U),I,0,0
S:G$DAC0$0$0({2}SI:U),I,0,0
S:G$DAC1$0$0({2}SI:U),I,0,0
S:G$PCA0$0$0({2}SI:U),I,0,0
S:G$PCA0CP0$0$0({2}SI:U),I,0,0
S:G$PCA0CP1$0$0({2}SI:U),I,0,0
S:G$PCA0CP2$0$0({2}SI:U),I,0,0
S:G$PCA0CP3$0$0({2}SI:U),I,0,0
S:G$PCA0CP4$0$0({2}SI:U),I,0,0
S:G$P0_0$0$0({1}SX:U),J,0,0
S:G$P0_1$0$0({1}SX:U),J,0,0
S:G$P0_2$0$0({1}SX:U),J,0,0
S:G$P0_3$0$0({1}SX:U),J,0,0
S:G$P0_4$0$0({1}SX:U),J,0,0
S:G$P0_5$0$0({1}SX:U),J,0,0
S:G$P0_6$0$0({1}SX:U),J,0,0
S:G$P0_7$0$0({1}SX:U),J,0,0
S:G$IT0$0$0({1}SX:U),J,0,0
S:G$IE0$0$0({1}SX:U),J,0,0
S:G$IT1$0$0({1}SX:U),J,0,0
S:G$IE1$0$0({1}SX:U),J,0,0
S:G$TR0$0$0({1}SX:U),J,0,0
S:G$TF0$0$0({1}SX:U),J,0,0
S:G$TR1$0$0({1}SX:U),J,0,0
S:G$TF1$0$0({1}SX:U),J,0,0
S:G$P1_0$0$0({1}SX:U),J,0,0
S:G$P1_1$0$0({1}SX:U),J,0,0
S:G$P1_2$0$0({1}SX:U),J,0,0
S:G$P1_3$0$0({1}SX:U),J,0,0
S:G$P1_4$0$0({1}SX:U),J,0,0
S:G$P1_5$0$0({1}SX:U),J,0,0
S:G$P1_6$0$0({1}SX:U),J,0,0
S:G$P1_7$0$0({1}SX:U),J,0,0
S:G$RI$0$0({1}SX:U),J,0,0
S:G$RI0$0$0({1}SX:U),J,0,0
S:G$TI$0$0({1}SX:U),J,0,0
S:G$TI0$0$0({1}SX:U),J,0,0
S:G$RB8$0$0({1}SX:U),J,0,0
S:G$RB80$0$0({1}SX:U),J,0,0
S:G$TB8$0$0({1}SX:U),J,0,0
S:G$TB80$0$0({1}SX:U),J,0,0
S:G$REN$0$0({1}SX:U),J,0,0
S:G$REN0$0$0({1}SX:U),J,0,0
S:G$SM2$0$0({1}SX:U),J,0,0
S:G$SM20$0$0({1}SX:U),J,0,0
S:G$MCE0$0$0({1}SX:U),J,0,0
S:G$SM1$0$0({1}SX:U),J,0,0
S:G$SM10$0$0({1}SX:U),J,0,0
S:G$SM0$0$0({1}SX:U),J,0,0
S:G$SM00$0$0({1}SX:U),J,0,0
S:G$S0MODE$0$0({1}SX:U),J,0,0
S:G$P2_0$0$0({1}SX:U),J,0,0
S:G$P2_1$0$0({1}SX:U),J,0,0
S:G$P2_2$0$0({1}SX:U),J,0,0
S:G$P2_3$0$0({1}SX:U),J,0,0
S:G$P2_4$0$0({1}SX:U),J,0,0
S:G$P2_5$0$0({1}SX:U),J,0,0
S:G$P2_6$0$0({1}SX:U),J,0,0
S:G$P2_7$0$0({1}SX:U),J,0,0
S:G$EX0$0$0({1}SX:U),J,0,0
S:G$ET0$0$0({1}SX:U),J,0,0
S:G$EX1$0$0({1}SX:U),J,0,0
S:G$ET1$0$0({1}SX:U),J,0,0
S:G$ES0$0$0({1}SX:U),J,0,0
S:G$ES$0$0({1}SX:U),J,0,0
S:G$ET2$0$0({1}SX:U),J,0,0
S:G$EA$0$0({1}SX:U),J,0,0
S:G$P3_0$0$0({1}SX:U),J,0,0
S:G$P3_1$0$0({1}SX:U),J,0,0
S:G$P3_2$0$0({1}SX:U),J,0,0
S:G$P3_3$0$0({1}SX:U),J,0,0
S:G$P3_4$0$0({1}SX:U),J,0,0
S:G$P3_5$0$0({1}SX:U),J,0,0
S:G$P3_6$0$0({1}SX:U),J,0,0
S:G$P3_7$0$0({1}SX:U),J,0,0
S:G$PX0$0$0({1}SX:U),J,0,0
S:G$PT0$0$0({1}SX:U),J,0,0
S:G$PX1$0$0({1}SX:U),J,0,0
S:G$PT1$0$0({1}SX:U),J,0,0
S:G$PS0$0$0({1}SX:U),J,0,0
S:G$PS$0$0({1}SX:U),J,0,0
S:G$PT2$0$0({1}SX:U),J,0,0
S:G$SMBTOE$0$0({1}SX:U),J,0,0
S:G$SMBFTE$0$0({1}SX:U),J,0,0
S:G$AA$0$0({1}SX:U),J,0,0
S:G$SI$0$0({1}SX:U),J,0,0
S:G$STO$0$0({1}SX:U),J,0,0
S:G$STA$0$0({1}SX:U),J,0,0
S:G$ENSMB$0$0({1}SX:U),J,0,0
S:G$BUSY$0$0({1}SX:U),J,0,0
S:G$CPRL2$0$0({1}SX:U),J,0,0
S:G$CT2$0$0({1}SX:U),J,0,0
S:G$TR2$0$0({1}SX:U),J,0,0
S:G$EXEN2$0$0({1}SX:U),J,0,0
S:G$TCLK$0$0({1}SX:U),J,0,0
S:G$RCLK$0$0({1}SX:U),J,0,0
S:G$EXF2$0$0({1}SX:U),J,0,0
S:G$TF2$0$0({1}SX:U),J,0,0
S:G$P$0$0({1}SX:U),J,0,0
S:G$F1$0$0({1}SX:U),J,0,0
S:G$OV$0$0({1}SX:U),J,0,0
S:G$RS0$0$0({1}SX:U),J,0,0
S:G$RS1$0$0({1}SX:U),J,0,0
S:G$F0$0$0({1}SX:U),J,0,0
S:G$AC$0$0({1}SX:U),J,0,0
S:G$CY$0$0({1}SX:U),J,0,0
S:G$CCF0$0$0({1}SX:U),J,0,0
S:G$CCF1$0$0({1}SX:U),J,0,0
S:G$CCF2$0$0({1}SX:U),J,0,0
S:G$CCF3$0$0({1}SX:U),J,0,0
S:G$CCF4$0$0({1}SX:U),J,0,0
S:G$CR$0$0({1}SX:U),J,0,0
S:G$CF$0$0({1}SX:U),J,0,0
S:G$ADLJST$0$0({1}SX:U),J,0,0
S:G$AD0LJST$0$0({1}SX:U),J,0,0
S:G$ADWINT$0$0({1}SX:U),J,0,0
S:G$AD0WINT$0$0({1}SX:U),J,0,0
S:G$ADSTM0$0$0({1}SX:U),J,0,0
S:G$AD0CM0$0$0({1}SX:U),J,0,0
S:G$ADSTM1$0$0({1}SX:U),J,0,0
S:G$AD0CM1$0$0({1}SX:U),J,0,0
S:G$ADBUSY$0$0({1}SX:U),J,0,0
S:G$AD0BUSY$0$0({1}SX:U),J,0,0
S:G$ADCINT$0$0({1}SX:U),J,0,0
S:G$AD0INT$0$0({1}SX:U),J,0,0
S:G$ADCTM$0$0({1}SX:U),J,0,0
S:G$AD0TM$0$0({1}SX:U),J,0,0
S:G$ADCEN$0$0({1}SX:U),J,0,0
S:G$AD0EN$0$0({1}SX:U),J,0,0
S:G$SPIEN$0$0({1}SX:U),J,0,0
S:G$MSTEN$0$0({1}SX:U),J,0,0
S:G$SLVSEL$0$0({1}SX:U),J,0,0
S:G$TXBSY$0$0({1}SX:U),J,0,0
S:G$RXOVRN$0$0({1}SX:U),J,0,0
S:G$MODF$0$0({1}SX:U),J,0,0
S:G$WCOL$0$0({1}SX:U),J,0,0
S:G$SPIF$0$0({1}SX:U),J,0,0
S:G$BUS_BUSY$0$0({1}SX:U),J,0,0
S:G$BUS_EN$0$0({1}SX:U),J,0,0
S:G$BUS_START$0$0({1}SX:U),J,0,0
S:G$BUS_STOP$0$0({1}SX:U),J,0,0
S:G$BUS_INT$0$0({1}SX:U),J,0,0
S:G$BUS_AA$0$0({1}SX:U),J,0,0
S:G$BUS_FTE$0$0({1}SX:U),J,0,0
S:G$BUS_TOE$0$0({1}SX:U),J,0,0
S:G$BUS_SCL$0$0({1}SX:U),J,0,0
S:G$_print_format$0$0({2}DF,SI:S),C,0,0
S:G$printf_small$0$0({2}DF,SV:S),C,0,0
S:G$printf$0$0({2}DF,SI:S),C,0,0
S:G$vprintf$0$0({2}DF,SI:S),C,0,0
S:G$sprintf$0$0({2}DF,SI:S),C,0,0
S:G$vsprintf$0$0({2}DF,SI:S),C,0,0
S:G$puts$0$0({2}DF,SI:S),C,0,0
S:G$printf_fast$0$0({2}DF,SV:S),C,0,0
S:G$printf_fast_f$0$0({2}DF,SV:S),C,0,0
S:G$printf_tiny$0$0({2}DF,SV:S),C,0,0
S:G$atof$0$0({2}DF,SF:S),C,0,0
S:G$atoi$0$0({2}DF,SI:S),C,0,0
S:G$atol$0$0({2}DF,SL:S),C,0,0
S:G$_uitoa$0$0({2}DF,SV:S),C,0,0
S:G$_itoa$0$0({2}DF,SV:S),C,0,0
S:G$_ultoa$0$0({2}DF,SV:S),C,0,0
S:G$_ltoa$0$0({2}DF,SV:S),C,0,0
S:G$rand$0$0({2}DF,SI:S),C,0,0
S:G$srand$0$0({2}DF,SV:S),C,0,0
S:G$calloc$0$0({2}DF,DX,SV:S),C,0,0
S:G$malloc$0$0({2}DF,DX,SV:S),C,0,0
S:G$realloc$0$0({2}DF,DX,SV:S),C,0,0
S:G$aligned_alloc$0$0({2}DF,DG,SV:S),C,0,0
S:G$free$0$0({2}DF,SV:S),C,0,0
S:G$abs$0$0({2}DF,SI:S),C,0,0
S:G$labs$0$0({2}DF,SL:S),C,0,0
S:G$mblen$0$0({2}DF,SI:S),C,0,0
S:G$mbtowc$0$0({2}DF,SI:S),C,0,0
S:G$wctomb$0$0({2}DF,SI:S),C,0,0
S:G$SYSCLK_Init$0$0({2}DF,SV:S),C,0,0
S:G$UART0_Init$0$0({2}DF,SV:S),C,0,0
S:G$Sys_Init$0$0({2}DF,SV:S),C,0,0
S:G$getchar_nw$0$0({2}DF,SC:U),C,0,0
S:G$memcpy$0$0({2}DF,DG,SV:S),C,0,0
S:G$memmove$0$0({2}DF,DG,SV:S),C,0,0
S:G$strcpy$0$0({2}DF,DG,SC:U),C,0,0
S:G$strncpy$0$0({2}DF,DG,SC:U),C,0,0
S:G$strcat$0$0({2}DF,DG,SC:U),C,0,0
S:G$strncat$0$0({2}DF,DG,SC:U),C,0,0
S:G$memcmp$0$0({2}DF,SI:S),C,0,0
S:G$strcmp$0$0({2}DF,SI:S),C,0,0
S:G$strncmp$0$0({2}DF,SI:S),C,0,0
S:G$strxfrm$0$0({2}DF,SI:U),C,0,0
S:G$memchr$0$0({2}DF,DG,SV:S),C,0,0
S:G$strchr$0$0({2}DF,DG,SC:U),C,0,0
S:G$strcspn$0$0({2}DF,SI:U),C,0,0
S:G$strpbrk$0$0({2}DF,DG,SC:U),C,0,0
S:G$strrchr$0$0({2}DF,DG,SC:U),C,0,0
S:G$strspn$0$0({2}DF,SI:U),C,0,0
S:G$strstr$0$0({2}DF,DG,SC:U),C,0,0
S:G$strtok$0$0({2}DF,DG,SC:U),C,0,0
S:G$memset$0$0({2}DF,DG,SV:S),C,0,0
S:G$strlen$0$0({2}DF,SI:U),C,0,0
S:G$key_test$0$0({2}DF,SV:S),C,0,0
S:G$i2c_stop_and_read$0$0({2}DF,SC:U),C,0,0
S:G$read_keypad$0$0({2}DF,SC:U),C,0,0
S:G$main$0$0({2}DF,SV:S),C,0,0
S:FkpdlcdtestPCA$__str_0$0$0({22}DA22d,SC:S),D,0,0
S:FkpdlcdtestPCA$__str_1$0$0({16}DA16d,SC:S),D,0,0
S:FkpdlcdtestPCA$__str_2$0$0({3}DA3d,SC:S),D,0,0
S:FkpdlcdtestPCA$__str_3$0$0({9}DA9d,SC:S),D,0,0
S:FkpdlcdtestPCA$__str_4$0$0({52}DA52d,SC:S),D,0,0
S:FkpdlcdtestPCA$__str_5$0$0({29}DA29d,SC:S),D,0,0
S:FkpdlcdtestPCA$__str_6$0$0({30}DA30d,SC:S),D,0,0
|
zhmu/ananas | Ada | 14,857 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . I M A G E _ F --
-- --
-- B o d y --
-- --
-- Copyright (C) 2020-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. --
-- --
------------------------------------------------------------------------------
with System.Image_I;
with System.Img_Util; use System.Img_Util;
package body System.Image_F is
Maxdigs : constant Natural := Int'Width - 2;
-- Maximum number of decimal digits that can be represented in an Int.
-- The "-2" accounts for the sign and one extra digit, since we need the
-- maximum number of 9's that can be represented, e.g. for the 64-bit case,
-- Integer_64'Width is 20 since the maximum value is approximately 9.2E+18
-- and has 19 digits, but the maximum number of 9's that can be represented
-- in Integer_64 is only 18.
-- The first prerequisite of the implementation is that the first scaled
-- divide does not overflow, which means that the absolute value of the
-- input X must always be smaller than 10**Maxdigs * 2**(Int'Size - 1).
-- Otherwise Constraint_Error is raised by the scaled divide operation.
-- The second prerequisite of the implementation is that the computation
-- of the operands does not overflow when the small is neither an integer
-- nor the reciprocal of an integer, which means that its numerator and
-- denominator must be smaller than 10**(2*Maxdigs-1) / 2**(Int'Size - 1)
-- if the small is larger than 1, and smaller than 2**(Int'Size - 1) / 10
-- if the small is smaller than 1.
package Image_I is new System.Image_I (Int);
procedure Set_Image_Integer
(V : Int;
S : in out String;
P : in out Natural)
renames Image_I.Set_Image_Integer;
-- The following section describes a specific implementation choice for
-- performing base conversions needed for output of values of a fixed
-- point type T with small T'Small. The goal is to be able to output
-- all values of fixed point types with a precision of 64 bits and a
-- small in the range 2.0**(-63) .. 2.0**63. The reasoning can easily
-- be adapted to fixed point types with a precision of 32 or 128 bits.
-- The chosen algorithm uses fixed precision integer arithmetic for
-- reasons of simplicity and efficiency. It is important to understand
-- in what ways the most simple and accurate approach to fixed point I/O
-- is limiting, before considering more complicated schemes.
-- Without loss of generality assume T has a range (-2.0**63) * T'Small
-- .. (2.0**63 - 1) * T'Small, and is output with Aft digits after the
-- decimal point and T'Fore - 1 before. If T'Small is integer, or
-- 1.0 / T'Small is integer, let S = T'Small.
-- The idea is to convert a value X * S of type T to a 64-bit integer value
-- Q equal to 10.0**D * (X * S) rounded to the nearest integer, using only
-- a scaled integer divide of the form
-- Q = (X * Y) / Z,
-- where the variables X, Y, Z are 64-bit integers, and both multiplication
-- and division are done using full intermediate precision. Then the final
-- decimal value to be output is
-- Q * 10**(-D)
-- This value can be written to the output file or to the result string
-- according to the format described in RM A.3.10. The details of this
-- operation are omitted here.
-- A 64-bit value can represent all integers with 18 decimal digits, but
-- not all with 19 decimal digits. If the total number of requested ouput
-- digits (Fore - 1) + Aft is greater than 18 then, for purposes of the
-- conversion, Aft is adjusted to 18 - (Fore - 1). In that case, trailing
-- zeros can complete the output after writing the first 18 significant
-- digits, or the technique described in the next section can be used.
-- In addition, D cannot be smaller than -18, in order for 10.0**(-D) to
-- fit in a 64-bit integer.
-- The final expression for D is
-- D = Integer'Max (-18, Integer'Min (Aft, 18 - (Fore - 1)));
-- For Y and Z the following expressions can be derived:
-- Q = X * S * (10.0**D) = (X * Y) / Z
-- If S is an integer greater than or equal to one, then Fore must be at
-- least 20 in order to print T'First, which is at most -2.0**63. This
-- means that D < 0, so use
-- (1) Y = -S and Z = -10**(-D)
-- If 1.0 / S is an integer greater than one, use
-- (2) Y = -10**D and Z = -(1.0 / S), for D >= 0
-- or
-- (3) Y = -1 and Z = -(1.0 / S) * 10**(-D), for D < 0
-- Negative values are used for nominator Y and denominator Z, so that S
-- can have a maximum value of 2.0**63 and a minimum of 2.0**(-63). For
-- -(1.0 / S) in -1 .. -9, Fore will still be 20, and D will be negative,
-- as (-2.0**63) / -9 is greater than 10**18. In these cases there is room
-- in the denominator for the extra decimal scaling required, so case (3)
-- will not overflow.
-- In fact this reasoning can be generalized to most S which are the ratio
-- of two integers with bounded magnitude. Let S = Num / Den and rewrite
-- case (1) above where Den = 1 into
-- (1b) Y = -Num and Z = -Den * 10**(-D)
-- Suppose that Num corresponds to the maximum value of -D, i.e. 18 and
-- 10**(-D) = 10**18. If you change Den into 10, then S becomes 10 times
-- smaller and, therefore, Fore is decremented by 1, which means that -D
-- is as well, provided that Fore was initially not larger than 37, so the
-- multiplication for Z still does not overflow. But you need to reach 10
-- to trigger this effect, which means that a leeway of 10 is required, so
-- let's restrict this to a Num for which 10**(-D) <= 10**17. To summarize
-- this case, if S is the ratio of two integers with
-- Den < Num <= B1
-- where B1 is a fixed limit, then case (1b) does not overflow. B1 can be
-- taken as the largest integer Small such that D = -17, i.e. Fore = 36,
-- which means that B1 * 2.0**63 must be smaller than 10**35.
-- Let's continue and rewrite case (2) above when Num = 1 into
-- (2b) Y = -Num * 10**D and Z = -Den, for D >= 0
-- Note that D <= 18 - (Fore - 1) and Fore >= 2 so D <= 17, thus you can
-- safely change Num into 10 in the product, but then S becomes 10 times
-- larger and, therefore, Fore is incremented by 1, which means that D is
-- decremented by 1 so you again have a product lesser or equal to 10**17.
-- To sum up, if S is the ratio of two integers with
-- Num <= Den * S0
-- where S0 is the largest Small such that D >= 0, then case (2b) does not
-- overflow.
-- Let's conclude and rewrite case (3) above when Num = 1 into
-- (3b) Y = -Num and Z = -Den * 10**(-D), for D < 0
-- As explained above, this occurs only if both S0 < S < 1 and D = -1 and
-- is preserved if you scale up Num and Den simultaneously, what you can
-- do until Den * 10 tops the upper bound. To sum up, if S is the ratio of
-- two integers with
-- Den * S0 < Num < Den <= B2
-- where B2 is a fixed limit, then case (3b) does not overflow. B2 can be
-- taken as the largest integer such that B2 * 10 is smaller than 2.0**63.
-- The conclusion is that the algorithm works if the small is the ratio of
-- two integers in the range 1 .. 2**63 if either is equal to 1, or of two
-- integers in the range 1 .. B1 if the small is larger than 1, or of two
-- integers in the range 1 .. B2 if the small is smaller than 1.
-- Using a scaled divide which truncates and returns a remainder R,
-- another K trailing digits can be calculated by computing the value
-- (R * (10.0**K)) / Z using another scaled divide. This procedure
-- can be repeated to compute an arbitrary number of digits in linear
-- time and storage. The last scaled divide should be rounded, with
-- a possible carry propagating to the more significant digits, to
-- ensure correct rounding of the unit in the last place.
-----------------
-- Image_Fixed --
-----------------
procedure Image_Fixed
(V : Int;
S : in out String;
P : out Natural;
Num : Int;
Den : Int;
For0 : Natural;
Aft0 : Natural)
is
pragma Assert (S'First = 1);
begin
-- Add space at start for non-negative numbers
if V >= 0 then
S (1) := ' ';
P := 1;
else
P := 0;
end if;
Set_Image_Fixed (V, S, P, Num, Den, For0, Aft0, 1, Aft0, 0);
end Image_Fixed;
---------------------
-- Set_Image_Fixed --
---------------------
procedure Set_Image_Fixed
(V : Int;
S : in out String;
P : in out Natural;
Num : Int;
Den : Int;
For0 : Natural;
Aft0 : Natural;
Fore : Natural;
Aft : Natural;
Exp : Natural)
is
pragma Assert (Num < 0 and then Den < 0);
-- Accept only negative numbers to allow -2**(Int'Size - 1)
A : constant Natural :=
Boolean'Pos (Exp > 0) * Aft0 + Natural'Max (Aft, 1) + 1;
-- Number of digits after the decimal point to be computed. If Exp is
-- positive, we need to compute Aft decimal digits after the first non
-- zero digit and we are guaranteed there is at least one in the first
-- Aft0 digits (unless V is zero). In both cases, we compute one more
-- digit than requested so that Set_Decimal_Digits can round at Aft.
D : constant Integer :=
Integer'Max (-Maxdigs, Integer'Min (A, Maxdigs - (For0 - 1)));
Y : constant Int := Num * 10**Integer'Max (0, D);
Z : constant Int := Den * 10**Integer'Max (0, -D);
-- See the description of the algorithm above
AF : constant Natural := A - D;
-- Number of remaining digits to be computed after the first round. It
-- is larger than A if the first round does not compute all the digits
-- before the decimal point, i.e. (For0 - 1) larger than Maxdigs.
N : constant Natural := 1 + (AF + Maxdigs - 1) / Maxdigs;
-- Number of rounds of scaled divide to be performed
Q : Int;
-- Quotient of the scaled divide in this round. Only the first round may
-- yield more than Maxdigs digits and has a significant sign.
Buf : String (1 .. Maxdigs);
Len : Natural;
-- Buffer for the image of the quotient
Digs : String (1 .. 2 + N * Maxdigs);
Ndigs : Natural;
-- Concatenated image of the successive quotients
Scale : Integer := 0;
-- Exponent such that the result is Digs (1 .. NDigs) * 10**(-Scale)
XX : Int := V;
YY : Int := Y;
-- First two operands of the scaled divide
begin
-- Set the first character like Image
if V >= 0 then
Digs (1) := ' ';
Ndigs := 1;
else
Ndigs := 0;
end if;
for J in 1 .. N loop
exit when XX = 0;
Scaled_Divide (XX, YY, Z, Q, R => XX, Round => False);
if J = 1 then
if Q /= 0 then
Set_Image_Integer (Q, Digs, Ndigs);
end if;
Scale := Scale + D;
-- Prepare for next round, if any
YY := 10**Maxdigs;
else
pragma Assert (-10**Maxdigs < Q and then Q < 10**Maxdigs);
Len := 0;
Set_Image_Integer (abs Q, Buf, Len);
pragma Assert (1 <= Len and then Len <= Maxdigs);
-- If no character but the space has been written, write the
-- minus if need be, since Set_Image_Integer did not do it.
if Ndigs <= 1 then
if Q /= 0 then
if Ndigs = 0 then
Digs (1) := '-';
end if;
Digs (2 .. Len + 1) := Buf (1 .. Len);
Ndigs := Len + 1;
end if;
-- Or else pad the output with zeroes up to Maxdigs
else
for K in 1 .. Maxdigs - Len loop
Digs (Ndigs + K) := '0';
end loop;
for K in 1 .. Len loop
Digs (Ndigs + Maxdigs - Len + K) := Buf (K);
end loop;
Ndigs := Ndigs + Maxdigs;
end if;
Scale := Scale + Maxdigs;
end if;
end loop;
-- If no digit was output, this is zero
if Ndigs <= 1 then
Digs (1 .. 2) := " 0";
Ndigs := 2;
end if;
Set_Decimal_Digits (Digs, Ndigs, S, P, Scale, Fore, Aft, Exp);
end Set_Image_Fixed;
end System.Image_F;
|
reznikmm/matreshka | Ada | 3,603 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2011-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.Generic_Hash;
function AMF.UML.Input_Pins.Hash is
new AMF.Elements.Generic_Hash (UML_Input_Pin, UML_Input_Pin_Access);
|
albinjal/ada_basic | Ada | 966 | adb | with Ada.Numerics.Discrete_Random;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
procedure Upg2 is
function Generate
return Integer is
subtype Nums is Integer range 0..99;
package RN is
new Ada.Numerics.Discrete_Random(Nums);
Gen : RN.Generator;
begin
RN.Reset(Gen);
return RN.Random(Gen);
end;
type Data_Type is
record
Name: String(1..20);
Len: Integer;
end record;
type StringArray_Type is
array(1..5) of Data_Type;
Revolvers : StringArray_Type;
begin
Put("Mata in revolvrar:");
New_Line;
for I in StringArray_Type'Range loop
Get_Line(Revolvers(I).Name,Revolvers(I).Len);
end loop;
New_Line;
Put("Nya Priser:");
New_Line;
for X in reverse StringArray_Type'Range loop
Put(Revolvers(X).Name(1..Revolvers(X).Len)); Put(" - $"); Put(Generate,1); Put(".99");
New_Line;
end loop;
end;
|
stcarrez/dynamo | Ada | 6,570 | ads | ------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A 4 G . N O R M --
-- --
-- S p e c --
-- --
-- Copyright (c) 1995-2006, Free Software Foundation, Inc. --
-- --
-- ASIS-for-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 --
-- Software Foundation; either version 2, or (at your option) any later --
-- version. ASIS-for-GNAT is distributed in the hope that it will be use- --
-- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- --
-- CHANTABILITY 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 ASIS-for-GNAT; see file --
-- COPYING. If not, write to the Free Software Foundation, 51 Franklin --
-- Street, Fifth Floor, Boston, MA 02110-1301, USA. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the --
-- Software Engineering Laboratory of the Swiss Federal Institute of --
-- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the --
-- Scientific Research Computer Center of Moscow State University (SRCC --
-- MSU), Russia, with funding partially provided by grants from the Swiss --
-- National Science Foundation and the Swiss Academy of Engineering --
-- Sciences. ASIS-for-GNAT is now maintained by AdaCore --
-- (http://www.adacore.com). --
-- --
------------------------------------------------------------------------------
-- This package defines routines needed for yielding and processing
-- normalized associations and their components
with Asis;
with Types; use Types;
package A4G.Norm is
---------------------------------------
-- Obtaining normalized associations --
---------------------------------------
function Normalized_Param_Associations
(Call_Elem : Asis.Element)
return Asis.Association_List;
-- Creates the list of normalized associations for a given call to an
-- entry, a procedure or to a function (is intended to be used in the
-- implementation of Asis.Expressions.Function_Call_Parameters and
-- Asis.Statements.Call_Statement_Parameters). This function assumes that
-- the association list to be returned is not empty. It is an error to call
-- it when Sinfo.Parameter_Assoccciations function gives No_List for
-- the node representing the call in question
function Normalized_Discriminant_Associations
(Constr_Elem : Asis.Element;
Constr_Node : Node_Id)
return Asis.Association_List;
-- creates the list of normalized associations for a given discriminant
-- constraint; is intended to be used in the implementation of
-- Asis.Definitions.Discriminant_Associations. This function assumes,
-- that Constr_Node is of N_Index_Or_Discriminant_Constraint,
-- it is an error to call it for other nodes.
function Normalized_Generic_Associations
(Inst_Elem : Asis.Element;
Templ_Node : Node_Id)
return Asis.Association_List;
-- Creates the list of normalized associations for a given generic
-- instantiation (is intended to be used in the implementation of
-- Asis.Decalarations.Generic_Actual_Part. Templ_Node should be the
-- node representing the corresponding generic template declaration.
-- This function is supposed to be called if it is known that the list
-- of normalized associations is not empty
--
-- See the documentation of the body for the description of the
-- representation of the normalized generic associations.
function Normalized_Record_Component_Associations
(Aggregate : Asis.Element)
return Asis.Element_List;
-- Creates a list of normalized associations for a record aggregate
function Defining_Gen_Parameter (Gen_Form_Par : Node_Id) return Node_Id;
-- Assuming that Gen_Form_Par is a node representing a
-- generic_formal_parameter_SELECTOR_NAME (it is an error to call this
-- function for another actual!!!), this function finds the node
-- representing the defining occurrence of this generic formal
-- parameter.
--
-- ??? Is here a really good place for this function?
--
-- ??? And do we really need it???
--
-- For now this function is PARTIALLY IMPLEMENTED - it can work only
-- with a generic_formal_parameter_SELECTOR_NAME which is
-- operator_symbol "+" or "-"
----------------------------------------
-- Processing normalized associations --
----------------------------------------
function Discr_Def_Name
(Association : Asis.Discriminant_Association)
return Asis.Defining_Name;
-- from a normalized discriminant association this function creates
-- the ASIS Element representing the defining occurrence of the
-- discriminant. (Is intended to be used in
-- Asis.Expressions.Discriminant_Selector_Names).
--
-- !!!NOTE: for now the implementation is unstable and definitely
-- contains holes.
end A4G.Norm;
|
sungyeon/drake | Ada | 1,914 | ads | pragma License (Unrestricted);
-- extended unit
with Ada.Colors;
private with System.Native_Text_IO.Terminal_Colors;
package Ada.Text_IO.Terminal.Colors is
-- Additional terminal-color handling subprograms.
type Color is private;
function To_Color (Item : Ada.Colors.RGB) return Color;
function To_Grayscale_Color (Item : Ada.Colors.Brightness) return Color;
pragma Inline (To_Color); -- renamed
pragma Inline (To_Grayscale_Color); -- renamed
type Boolean_Parameter (Changing : Boolean := False) is record
case Changing is
when False =>
null;
when True =>
Item : Boolean;
end case;
end record;
type Color_Parameter (Changing : Boolean := False) is record
case Changing is
when False =>
null;
when True =>
Item : Color;
end case;
end record;
-- for shorthand
function "+" (Item : Boolean) return Boolean_Parameter;
function "+" (Item : Color) return Color_Parameter;
pragma Inline ("+");
procedure Set_Color (
File : File_Type; -- Output_File_Type
Reset : Boolean := False;
Bold : Boolean_Parameter := (Changing => False); -- only POSIX
Underline : Boolean_Parameter := (Changing => False);
Blink : Boolean_Parameter := (Changing => False); -- only POSIX
Reversed : Boolean_Parameter := (Changing => False);
Foreground : Color_Parameter := (Changing => False);
Background : Color_Parameter := (Changing => False));
procedure Reset_Color (
File : File_Type); -- Output_File_Type
private
type Color is new System.Native_Text_IO.Terminal_Colors.Color;
function To_Color (Item : Ada.Colors.RGB) return Color
renames RGB_To_Color;
function To_Grayscale_Color (Item : Ada.Colors.Brightness) return Color
renames Brightness_To_Grayscale_Color;
end Ada.Text_IO.Terminal.Colors;
|
silentTeee/IBM-8b-10b-encoder | Ada | 10,536 | adb | --Copyright (c) 2019 Alex Tsantilis under the MIT License
package body IBM_8b_10b_Encoder is
type Encoder_Entry is
record
RD_Neg_Val: Ten_Bits;
RD_Pos_Val: Ten_Bits;
RD_Changes: Boolean;
end record;
type Decoder_Entry is
record
Key: Ten_Bits := 0;
Value: Byte := 0;
end record;
type Decoder_Table is array(Natural range 0 .. 255) of Decoder_Entry;
Encoder_Table: array(Byte) of Encoder_Entry;
Decoder_Table_RD_Neg: Decoder_Table;
Decoder_Table_RD_Pos: Decoder_Table;
procedure Encode( B: in Byte;
T: out Ten_Bits;
RD: in out Running_Disp) is
begin
case RD is
when Neg_1 => T := Encoder_Table(B).RD_Neg_Val;
case Encoder_Table(B).RD_Changes is
when False => RD := Neg_1;
when True => RD := Pos_1;
end case;
when Pos_1 => T := Encoder_Table(B).RD_Pos_Val;
case Encoder_Table(B).RD_Changes is
when False => RD := Pos_1;
when True => RD := Neg_1;
end case;
end case;
end Encode;
function Compute_Hash_Index(K: Ten_Bits;
Table_Size: Natural) return Natural is
begin
return Natural(K) mod Table_Size;
end Compute_Hash_Index;
procedure Insert( Table: in out Decoder_Table;
Key: in Ten_Bits;
Value: in Byte;
Success: out Boolean ) is
I: Natural := 0;
Idx, Idx_Modded: Natural;
begin
Success := False;
Idx := Compute_Hash_Index(Key, Table'Length);
Idx_Modded := Idx;
loop
if Table(Idx_Modded).Key = 0 or Table(Idx_Modded).Key = Key then
Table(Idx_Modded).Key := Key;
Table(Idx_Modded).Value := Value;
Success := True;
else
I := I + 1;
--Note: this variant of the quadratic probing algorithm
--is most effective with tables with 2^n entries, where
--n is any positive integer. Coincidentally, this works
--perfectly for our encoding table. :D
Idx_Modded := (Idx + (I + I**2)/2) mod Table'Length;
end if;
exit when Success or I >= Table'Length;
end loop;
end Insert;
procedure Find_Entry( Table: in Decoder_Table;
Key: in Ten_Bits;
Value: out Byte;
Success: out Boolean) is
I: Natural := 0;
Idx, Idx_Modded: Natural;
begin
Success := False;
Idx := Compute_Hash_Index(Key, Table'Length);
Idx_Modded := Idx;
loop
if Table(Idx_Modded).Key = Key then
Value := Table(Idx_Modded).Value;
Success := True;
else
I := I + 1;
Idx_Modded := (Idx + (I + I**2)/2) mod Table'Length;
end if;
exit when Success or I >= Table'Length;
end loop;
end Find_Entry;
--To verify that Running Disparity is being preserved, use this version.
procedure Decode( T: in Ten_Bits;
B: out Byte;
RD: in out Running_Disp;
Success: out Boolean) is
begin
case RD is
when Neg_1 =>
Find_Entry(Decoder_Table_RD_Neg, T, B, Success);
case Encoder_Table(B).RD_Changes is
when False => RD := Neg_1;
when True => RD := Pos_1;
end case;
when Pos_1 =>
Find_Entry(Decoder_Table_RD_Pos, T, B, Success);
case Encoder_Table(B).RD_Changes is
when False => RD := Pos_1;
when True => RD := Neg_1;
end case;
end case;
end Decode;
procedure Decode( T: in Ten_Bits;
B: out Byte;
Success: out Boolean) is
begin
Find_Entry(Decoder_Table_RD_Neg, T, B, Success);
if not Success then
Find_Entry(Decoder_Table_RD_Pos, T, B, Success);
end if;
end Decode;
begin
declare
--8 to 10 bit encoding table construction necessities (all are temporary)
Table_5to6_Bits: array(Byte range 0 .. 31, 0 .. 1) of Ten_Bits :=
((2#111001#, 2#000110#),
(2#101110#, 2#010001#),
(2#101101#, 2#010010#),
(2#100011#, 2#100011#),
(2#101011#, 2#010100#),
(2#100101#, 2#100101#),
(2#100110#, 2#100110#),
(2#000111#, 2#111000#),
(2#100111#, 2#011000#),
(2#101001#, 2#101001#),
(2#101010#, 2#101010#),
(2#001011#, 2#001011#),
(2#101100#, 2#101100#),
(2#001101#, 2#001101#),
(2#001110#, 2#001110#),
(2#111010#, 2#000101#),
(2#110110#, 2#001001#),
(2#110001#, 2#110001#),
(2#110010#, 2#110010#),
(2#010011#, 2#010011#),
(2#110100#, 2#110100#),
(2#010101#, 2#010101#),
(2#010110#, 2#010110#),
(2#010111#, 2#101000#),
(2#110011#, 2#001100#),
(2#011001#, 2#011001#),
(2#011010#, 2#011010#),
(2#011011#, 2#100100#),
(2#011100#, 2#011100#),
(2#011101#, 2#100010#),
(2#011110#, 2#100001#),
(2#110101#, 2#001010#));
Table_3to4_Bits: array(Byte range 0 .. 7, 0 .. 3) of Ten_Bits :=
--RD -1, RD +1
((2#1101#, 2#0010#, -1, -1),
(2#1001#, 2#1001#, -1, -1),
(2#1010#, 2#1010#, -1, -1),
(2#0011#, 2#1100#, -1, -1),
(2#1011#, 2#0100#, -1, -1),
(2#0101#, 2#0101#, -1, -1),
(2#0110#, 2#0110#, -1, -1),
--||---Primary----|||---Alternate---||
--RD -1 , RD +1 | RD -1 , RD +1
(2#0111#, 2#1000#, 2#1110#, 2#0001#));
NO : Boolean := False;
YES : Boolean := True;
Changes_Running_Disp: array(Byte range 0 .. 31) of Boolean :=
(
NO ,
NO ,
NO ,
YES,
NO ,
YES,
YES,
YES,
NO ,
YES,
YES,
YES,
YES,
YES,
YES,
NO ,
NO ,
YES,
YES,
YES,
YES,
YES,
YES,
NO ,
NO ,
YES,
YES,
NO ,
YES,
NO ,
NO ,
NO
);
Old_Right, Old_Left: Byte := 0;
Encoded_Left_Pos, Encoded_Left_Neg,
Encoded_Right_Pos, Encoded_Right_Neg: Ten_Bits := 0;
RD_Change_Idx: Byte;
Insertion_Error: exception;
begin
for I in Byte range 0 .. 255 loop
Old_Right := I and 2#000_11111#;
Old_Left := (I and 2#111_00000#) / 2**5;
--Encoding the right 5 bits is easy, but encoding the left
--3 bits requires following a very specific pattern...
Encoded_Right_Neg := Table_5to6_Bits(Old_Right, 0);
Encoded_Right_Pos := Table_5to6_Bits(Old_Right, 1);
if Old_Left < 2#111# then
--when the encoding of the right bits is the same regardless
--of the running disparity (7 is an exception because it has
--equal 0s and 1s), the 5 bit encoding for (-) RD is paired with
--the 3 bit encoding for (-) RD, and (+) with (+)
if Encoded_Right_Neg = Encoded_Right_Pos or Old_Right = 7 then
Encoded_Left_Neg := Table_3to4_Bits(Old_Left, 0);
Encoded_Left_Pos := Table_3to4_Bits(Old_Left, 1);
else
Encoded_Left_Neg := Table_3to4_Bits(Old_Left, 1);
Encoded_Left_Pos := Table_3to4_Bits(Old_Left, 0);
end if;
--when the 3 left bits to encode are "111", there are unique
--circumstances where an alternate output needs to be used
else
if Encoded_Right_Neg = Encoded_Right_Pos or Old_Right = 7 then
if Old_Right /= 17 and Old_Right /= 18 and Old_Right /= 20 then
Encoded_Left_Neg := Table_3to4_Bits(Old_Left, 0);
else
Encoded_Left_Neg := Table_3to4_Bits(Old_Left, 2);
end if;
if Old_Right /= 11 and Old_Right /= 13 and Old_Right /= 14 then
Encoded_Left_Pos := Table_3to4_Bits(Old_Left, 1);
else
Encoded_Left_Pos := Table_3to4_Bits(Old_Left, 3);
end if;
else
Encoded_Left_Neg := Table_3to4_Bits(Old_Left, 1);
Encoded_Left_Pos := Table_3to4_Bits(Old_Left, 0);
end if;
end if;
RD_Change_Idx := I mod 32;
declare
E: Encoder_Entry;
Check: Boolean;
begin
--Add an entry to the encoding table...
E.RD_Neg_Val := (Encoded_Left_Neg * 2**6) or Encoded_Right_Neg;
E.RD_Pos_Val := (Encoded_Left_Pos * 2**6) or Encoded_Right_Pos;
if Old_Left = 2#000# or Old_Left = 2#100# or Old_Left = 2#111# then
E.RD_Changes := Changes_Running_Disp(RD_Change_Idx);
else
E.RD_Changes := not Changes_Running_Disp(RD_Change_Idx);
end if;
Encoder_Table(I) := E;
--...and add the flipped keys and values to the decoding tables
Insert(Decoder_Table_RD_Neg, E.RD_Neg_Val, I, Check);
Insert(Decoder_Table_RD_Pos, E.RD_Pos_Val, I, Check);
if not Check then raise Insertion_Error; end if;
end;
end loop;
end;
end IBM_8b_10b_Encoder;
|
AaronC98/PlaneSystem | Ada | 2,920 | ads | ------------------------------------------------------------------------------
-- Ada Web Server --
-- --
-- Copyright (C) 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;
private package AWS.Net.SSL.RSA_DH_Generators is
procedure Start_Parameters_Generation
(DH : Boolean; Logging : access procedure (Text : String) := null);
-- Start SSL parameters regeneration in background.
-- DH is False mean only RSA parameters generated.
-- DH is True mean RSA and DH both parameters generated.
function Parameters_Filename (Kind : String; Exist : Boolean) return String;
-- Returns DH parameters filename in internal AWS security storage
-- directory. Returns empty string if filename does not exist and could
-- not be created. Common code for use in GNUTLS and OpenSSL
-- implementations.
end AWS.Net.SSL.RSA_DH_Generators;
|
reznikmm/spawn | Ada | 6,055 | adb | --
-- Copyright (C) 2018-2023, AdaCore
--
-- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
--
with Ada.Strings.UTF_Encoding.Wide_Strings;
with Ada.Wide_Characters.Unicode;
with Spawn.Internal.Monitor;
with Spawn.Internal.Windows;
package body Spawn.Internal is
use type Ada.Streams.Stream_Element_Offset;
use all type Spawn.Common.Pipe_Kinds;
package body Environments is
---------
-- "=" --
---------
function "=" (Left, Right : UTF_8_String) return Boolean is
begin
return To_Key (Left) = To_Key (Right);
end "=";
---------
-- "<" --
---------
function "<" (Left, Right : UTF_8_String) return Boolean is
begin
return To_Key (Left) < To_Key (Right);
end "<";
------------
-- To_Key --
------------
function To_Key (Text : UTF_8_String) return Wide_String is
Value : Wide_String :=
Ada.Strings.UTF_Encoding.Wide_Strings.Decode (Text);
begin
for Char of Value loop
Char := Ada.Wide_Characters.Unicode.To_Upper_Case (Char);
end loop;
return Value;
end To_Key;
end Environments;
--------------------------
-- Close_Standard_Error --
--------------------------
procedure Close_Standard_Error (Self : in out Process'Class) is
begin
Monitor.Enqueue ((Monitor.Close_Pipe, Self'Unchecked_Access, Stderr));
end Close_Standard_Error;
--------------------------
-- Close_Standard_Input --
--------------------------
procedure Close_Standard_Input (Self : in out Process'Class) is
begin
Monitor.Enqueue ((Monitor.Close_Pipe, Self'Unchecked_Access, Stdin));
end Close_Standard_Input;
---------------------------
-- Close_Standard_Output --
---------------------------
procedure Close_Standard_Output (Self : in out Process'Class) is
begin
Monitor.Enqueue ((Monitor.Close_Pipe, Self'Unchecked_Access, Stdout));
end Close_Standard_Output;
--------------
-- Finalize --
--------------
overriding procedure Finalize (Self : in out Process) is
begin
if Self.Status = Running then
raise Program_Error;
end if;
end Finalize;
----------------
-- Identifier --
----------------
function Identifier (Self : Process'Class) return String is
use type Spawn.Windows_API.DWORD;
Image : constant String := Self.pid.dwProcessId'Image;
begin
return (if Self.pid.dwProcessId = 0 then ""
else Image (2 .. Image'Last));
end Identifier;
------------------
-- Kill_Process --
------------------
procedure Kill_Process (Self : in out Process'Class) is
begin
Windows.Do_Kill_Process (Self);
end Kill_Process;
----------------
-- Loop_Cycle --
----------------
procedure Loop_Cycle (Timeout : Duration)
renames Spawn.Internal.Monitor.Loop_Cycle;
-------------------------
-- Read_Standard_Error --
-------------------------
procedure Read_Standard_Error
(Self : in out Process'Class;
Data : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Success : in out Boolean)
is
pragma Unreferenced (Success);
-- There are no synchronous IO errors in this implementation
procedure On_No_Data;
----------------
-- On_No_Data --
----------------
procedure On_No_Data is
begin
Monitor.Enqueue ((Monitor.Watch_Pipe, Self'Unchecked_Access, Stderr));
end On_No_Data;
begin
if Self.Status /= Running then
Last := Data'First - 1;
return;
end if;
Windows.Do_Read (Self, Data, Last, Stderr, On_No_Data'Access);
end Read_Standard_Error;
--------------------------
-- Read_Standard_Output --
--------------------------
procedure Read_Standard_Output
(Self : in out Process'Class;
Data : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Success : in out Boolean)
is
pragma Unreferenced (Success);
-- There are no synchronous IO errors in this implementation
procedure On_No_Data;
----------------
-- On_No_Data --
----------------
procedure On_No_Data is
begin
Monitor.Enqueue ((Monitor.Watch_Pipe, Self'Unchecked_Access, Stdout));
end On_No_Data;
begin
if Self.Status /= Running then
Last := Data'First - 1;
return;
end if;
Windows.Do_Read (Self, Data, Last, Stdout, On_No_Data'Access);
end Read_Standard_Output;
-----------
-- Start --
-----------
procedure Start (Self : in out Process'Class) is
begin
Self.Status := Starting;
Self.Exit_Code := -1;
Monitor.Enqueue ((Monitor.Start, Self'Unchecked_Access));
end Start;
-----------------------
-- Terminate_Process --
-----------------------
procedure Terminate_Process (Self : in out Process'Class) is
begin
Windows.Do_Terminate_Process (Self);
end Terminate_Process;
--------------------------
-- Write_Standard_Input --
--------------------------
procedure Write_Standard_Input
(Self : in out Process'Class;
Data : Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Success : in out Boolean)
is
pragma Unreferenced (Success);
-- There are no synchronous IO errors in this implementation
procedure On_Has_Data;
-----------------
-- On_Has_Data --
-----------------
procedure On_Has_Data is
begin
Monitor.Enqueue ((Monitor.Watch_Pipe, Self'Unchecked_Access, Stdin));
end On_Has_Data;
begin
if Self.Status /= Running or Data'Length = 0 then
Last := Data'First - 1;
return;
end if;
Windows.Do_Write (Self, Data, Last, On_Has_Data'Access);
end Write_Standard_Input;
end Spawn.Internal;
|
reznikmm/matreshka | Ada | 18,390 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Tools Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-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 Ada.Wide_Wide_Text_IO;
with League.Strings;
with XML.SAX.Attributes;
with XML.SAX.String_Output_Destinations;
with XML.SAX.Pretty_Writers;
with WSDL.AST.Bindings;
pragma Unreferenced (WSDL.AST.Bindings);
-- GNAT Pro 7.2.0w (20130423): package is needed to access to type's
-- components.
with WSDL.AST.Descriptions;
pragma Unreferenced (WSDL.AST.Descriptions);
-- GNAT Pro 7.2.0w (20130423): package is needed to access to type's
-- components.
with WSDL.AST.Endpoints;
with WSDL.AST.Interfaces;
pragma Unreferenced (WSDL.AST.Interfaces);
-- GNAT Pro 7.2.0w (20130423): package is needed to access to type's
-- components.
with WSDL.AST.Messages;
pragma Unreferenced (WSDL.AST.Messages);
-- GNAT Pro 7.2.0w (20130423): package is needed to access to type's
-- components.
with WSDL.AST.Operations;
pragma Unreferenced (WSDL.AST.Operations);
-- GNAT Pro 7.2.0w (20130423): package is needed to access to type's
-- components.
with WSDL.AST.Services;
with WSDL.AST.Types;
with WSDL.Constants;
with WSDL.Iterators.Containment;
with WSDL.Visitors;
package body WSDL.Debug is
use WSDL.Constants;
type WSDL_Printer is
limited new WSDL.Visitors.WSDL_Visitor with
record
Output : aliased
XML.SAX.String_Output_Destinations.String_Output_Destination;
Writer : XML.SAX.Pretty_Writers.XML_Pretty_Writer;
end record;
overriding procedure Enter_Binding
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Binding_Access;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Leave_Binding
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Binding_Access;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Enter_Binding_Fault
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Binding_Fault_Access;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Leave_Binding_Fault
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Binding_Fault_Access;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Enter_Binding_Operation
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Binding_Operation_Access;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Leave_Binding_Operation
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Binding_Operation_Access;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Enter_Description
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Description_Access;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Leave_Description
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Description_Access;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Enter_Endpoint
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Endpoints.Endpoint_Access;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Leave_Endpoint
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Endpoints.Endpoint_Access;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Enter_Interface
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Interface_Access;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Leave_Interface
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Interface_Access;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Enter_Interface_Message
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Interface_Message_Access;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Leave_Interface_Message
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Interface_Message_Access;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Enter_Interface_Operation
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Interface_Operation_Access;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Leave_Interface_Operation
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Interface_Operation_Access;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Enter_Service
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Services.Service_Access;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Leave_Service
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Services.Service_Access;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Enter_Types
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Types.Types_Access;
Control : in out WSDL.Iterators.Traverse_Control);
overriding procedure Leave_Types
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Types.Types_Access;
Control : in out WSDL.Iterators.Traverse_Control);
----------
-- Dump --
----------
procedure Dump (Description : WSDL.AST.Description_Access) is
Printer : WSDL_Printer;
Iterator : WSDL.Iterators.Containment.Containment_Iterator;
Control : WSDL.Iterators.Traverse_Control := WSDL.Iterators.Continue;
begin
Printer.Writer.Set_Output_Destination (Printer.Output'Unchecked_Access);
Iterator.Visit (Printer, WSDL.AST.Node_Access (Description), Control);
end Dump;
-------------------
-- Enter_Binding --
-------------------
overriding procedure Enter_Binding
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Binding_Access;
Control : in out WSDL.Iterators.Traverse_Control)
is
Attributes : XML.SAX.Attributes.SAX_Attributes;
begin
Attributes.Set_Value (Name_Attribute, Node.Local_Name);
Attributes.Set_Value (Type_Attribute, Node.Binding_Type);
Self.Writer.Start_Element
(WSDL_Namespace_URI, Binding_Element, Attributes);
end Enter_Binding;
-------------------------
-- Enter_Binding_Fault --
-------------------------
overriding procedure Enter_Binding_Fault
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Binding_Fault_Access;
Control : in out WSDL.Iterators.Traverse_Control) is
begin
Self.Writer.Start_Element (WSDL_Namespace_URI, Fault_Element);
end Enter_Binding_Fault;
-----------------------------
-- Enter_Binding_Operation --
-----------------------------
overriding procedure Enter_Binding_Operation
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Binding_Operation_Access;
Control : in out WSDL.Iterators.Traverse_Control) is
begin
Self.Writer.Start_Element (WSDL_Namespace_URI, Operation_Element);
end Enter_Binding_Operation;
-----------------------
-- Enter_Description --
-----------------------
overriding procedure Enter_Description
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Description_Access;
Control : in out WSDL.Iterators.Traverse_Control)
is
Attributes : XML.SAX.Attributes.SAX_Attributes;
begin
Self.Writer.Set_Offset (2);
Self.Writer.Start_Document;
Self.Writer.Start_Prefix_Mapping
(League.Strings.To_Universal_String ("wsdl"), WSDL_Namespace_URI);
Attributes.Set_Value
(Target_Namespace_Attribute, Node.Target_Namespace);
Self.Writer.Start_Element
(WSDL_Namespace_URI, Description_Element, Attributes);
end Enter_Description;
--------------------
-- Enter_Endpoint --
--------------------
overriding procedure Enter_Endpoint
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Endpoints.Endpoint_Access;
Control : in out WSDL.Iterators.Traverse_Control)
is
Attributes : XML.SAX.Attributes.SAX_Attributes;
begin
Attributes.Set_Value (Name_Attribute, Node.Local_Name);
if not Node.Address.Is_Empty then
Attributes.Set_Value (Address_Attribute, Node.Address);
end if;
Self.Writer.Start_Element
(WSDL_Namespace_URI, Endpoint_Element, Attributes);
end Enter_Endpoint;
---------------------
-- Enter_Interface --
---------------------
overriding procedure Enter_Interface
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Interface_Access;
Control : in out WSDL.Iterators.Traverse_Control)
is
Attributes : XML.SAX.Attributes.SAX_Attributes;
begin
Attributes.Set_Value (Name_Attribute, Node.Local_Name);
Self.Writer.Start_Element
(WSDL_Namespace_URI, Interface_Element, Attributes);
end Enter_Interface;
-----------------------------
-- Enter_Interface_Message --
-----------------------------
overriding procedure Enter_Interface_Message
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Interface_Message_Access;
Control : in out WSDL.Iterators.Traverse_Control) is
begin
case Node.Direction is
when WSDL.AST.In_Message =>
Self.Writer.Start_Element (WSDL_Namespace_URI, Input_Element);
when WSDL.AST.Out_Message =>
Self.Writer.Start_Element (WSDL_Namespace_URI, Output_Element);
end case;
end Enter_Interface_Message;
-------------------------------
-- Enter_Interface_Operation --
-------------------------------
overriding procedure Enter_Interface_Operation
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Interface_Operation_Access;
Control : in out WSDL.Iterators.Traverse_Control)
is
Attributes : XML.SAX.Attributes.SAX_Attributes;
begin
Attributes.Set_Value (Name_Attribute, Node.Local_Name);
Self.Writer.Start_Element
(WSDL_Namespace_URI, Operation_Element, Attributes);
end Enter_Interface_Operation;
-------------------
-- Enter_Service --
-------------------
overriding procedure Enter_Service
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Services.Service_Access;
Control : in out WSDL.Iterators.Traverse_Control)
is
Attributes : XML.SAX.Attributes.SAX_Attributes;
begin
Attributes.Set_Value (Name_Attribute, Node.Local_Name);
Self.Writer.Start_Element
(WSDL_Namespace_URI, Service_Element, Attributes);
end Enter_Service;
-----------------
-- Enter_Types --
-----------------
overriding procedure Enter_Types
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Types.Types_Access;
Control : in out WSDL.Iterators.Traverse_Control) is
begin
Self.Writer.Start_Element (WSDL_Namespace_URI, Types_Element);
end Enter_Types;
-------------------
-- Leave_Binding --
-------------------
overriding procedure Leave_Binding
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Binding_Access;
Control : in out WSDL.Iterators.Traverse_Control) is
begin
Self.Writer.End_Element (WSDL_Namespace_URI, Binding_Element);
end Leave_Binding;
-------------------------
-- Leave_Binding_Fault --
-------------------------
overriding procedure Leave_Binding_Fault
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Binding_Fault_Access;
Control : in out WSDL.Iterators.Traverse_Control) is
begin
Self.Writer.End_Element (WSDL_Namespace_URI, Fault_Element);
end Leave_Binding_Fault;
-----------------------------
-- Leave_Binding_Operation --
-----------------------------
overriding procedure Leave_Binding_Operation
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Binding_Operation_Access;
Control : in out WSDL.Iterators.Traverse_Control) is
begin
Self.Writer.End_Element (WSDL_Namespace_URI, Operation_Element);
end Leave_Binding_Operation;
-----------------------
-- Leave_Description --
-----------------------
overriding procedure Leave_Description
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Description_Access;
Control : in out WSDL.Iterators.Traverse_Control) is
begin
Self.Writer.End_Element (WSDL_Namespace_URI, Description_Element);
Self.Writer.End_Document;
Ada.Wide_Wide_Text_IO.Put_Line
(Self.Output.Get_Text.To_Wide_Wide_String);
end Leave_Description;
--------------------
-- Leave_Endpoint --
--------------------
overriding procedure Leave_Endpoint
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Endpoints.Endpoint_Access;
Control : in out WSDL.Iterators.Traverse_Control) is
begin
Self.Writer.End_Element (WSDL_Namespace_URI, Endpoint_Element);
end Leave_Endpoint;
---------------------
-- Leave_Interface --
---------------------
overriding procedure Leave_Interface
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Interface_Access;
Control : in out WSDL.Iterators.Traverse_Control) is
begin
Self.Writer.End_Element (WSDL_Namespace_URI, Interface_Element);
end Leave_Interface;
-----------------------------
-- Leave_Interface_Message --
-----------------------------
overriding procedure Leave_Interface_Message
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Interface_Message_Access;
Control : in out WSDL.Iterators.Traverse_Control) is
begin
case Node.Direction is
when WSDL.AST.In_Message =>
Self.Writer.End_Element (WSDL_Namespace_URI, Input_Element);
when WSDL.AST.Out_Message =>
Self.Writer.End_Element (WSDL_Namespace_URI, Output_Element);
end case;
end Leave_Interface_Message;
-------------------------------
-- Leave_Interface_Operation --
-------------------------------
overriding procedure Leave_Interface_Operation
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Interface_Operation_Access;
Control : in out WSDL.Iterators.Traverse_Control) is
begin
Self.Writer.End_Element (WSDL_Namespace_URI, Operation_Element);
end Leave_Interface_Operation;
-------------------
-- Leave_Service --
-------------------
overriding procedure Leave_Service
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Services.Service_Access;
Control : in out WSDL.Iterators.Traverse_Control) is
begin
Self.Writer.End_Element (WSDL_Namespace_URI, Service_Element);
end Leave_Service;
-----------------
-- Leave_Types --
-----------------
overriding procedure Leave_Types
(Self : in out WSDL_Printer;
Node : not null WSDL.AST.Types.Types_Access;
Control : in out WSDL.Iterators.Traverse_Control) is
begin
Self.Writer.End_Element (WSDL_Namespace_URI, Types_Element);
end Leave_Types;
end WSDL.Debug;
|
AdaCore/gpr | Ada | 1,078 | adb | with p1_1; use p1_1;
with p2_0; use p2_0;
package body p1_0 is
function p1_0_0 (Item : Integer) return Integer is
Result : Long_Long_Integer;
begin
if Item < 0 then
return -Item;
end if;
Result := Long_Long_Integer (p1_1_0 (Item - 1)) + Long_Long_Integer (p2_0_0 (Item - 2));
return Integer (Result rem Long_Long_Integer (Integer'Last));
end p1_0_0;
function p1_0_1 (Item : Integer) return Integer is
Result : Long_Long_Integer;
begin
if Item < 0 then
return -Item;
end if;
Result := Long_Long_Integer (p1_1_1 (Item - 1)) + Long_Long_Integer (p2_0_1 (Item - 2));
return Integer (Result rem Long_Long_Integer (Integer'Last));
end p1_0_1;
function p1_0_2 (Item : Integer) return Integer is
Result : Long_Long_Integer;
begin
if Item < 0 then
return -Item;
end if;
Result := Long_Long_Integer (p1_1_2 (Item - 1)) + Long_Long_Integer (p2_0_2 (Item - 2));
return Integer (Result rem Long_Long_Integer (Integer'Last));
end p1_0_2;
end p1_0;
|
AdaCore/langkit | Ada | 401 | adb | with Ada.Text_IO; use Ada.Text_IO;
package body Support is
--------------
-- Put_Line --
--------------
procedure Put_Line (Elements : Envs.Entity_Array) is
begin
if Elements'Length = 0 then
Put_Line (" <none>");
else
for E of Elements loop
Put_Line (" * '" & E.Node & "'");
end loop;
end if;
end Put_Line;
end Support;
|
jscparker/math_packages | Ada | 10,932 | adb |
-----------------------------------------------------------------------
-- package body Clenshaw. Generates functions from recurrance relations.
-- Copyright (C) 2018 Jonathan S. Parker
--
-- 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.
---------------------------------------------------------------------------
package body Clenshaw is
Zero : constant Real := +0.0;
-----------------
-- Evaluate_Qs --
-----------------
-- The recurrance relation for the Q's at X is easily written as matrix
-- equation. In the following, f(X) is the given function for Q_0:
--
-- Q(0) = Q_0(p,X);
-- Q(1) = 0 + Alpha_1*Q_0;
-- Q(2) = 0 + Alpha_2*Q_1 + Beta_2*Q_0;
-- Q(3) = 0 + Alpha_3*Q_2 + Beta_3*Q_1;
-- ...
-- Q(N) = 0 + Alpha_N*Q_N-1 + Beta_N*Q_N-2
--
-- In matrix form, M*Q = (f(X), 0, 0, ...) , this becomes:
--
-- | 1 0 0 0 | |Q(0)| | Q_0(p,X)| | C_0 |
-- | E_1 1 0 0 | |Q(1)| = | 0 | = | C_1 |
-- | B_2 E_2 1 0 | |Q(2)| | 0 | | C_2 |
-- | 0 B_3 E_3 1 | |Q(3)| | 0 | | C_3 |
--
-- where E_m = -Alpha_m, B_m = -Beta_m.
--
-- So Q = M_inverse * C is the desired solution, but there may be numerical
-- error in the calculation of M_inverse by back-substitution. The
-- solution vector Q can be improved numerically by iterative refinement
-- via Newton's method:
--
-- Q_new = Q_old + M_inverse * (C - M*Q_old)
--
-- where Q = M_inverse * C is the calculation of Q given at the top.
--
procedure Evaluate_Qs
(X : in Real;
Q : in out Poly_Values;
Max_Poly_ID : in Poly_ID_Type;
P : in Real := 0.0;
No_Of_Iterations : in Positive := 1)
is
Product, Del : Poly_Values;
m : Poly_ID_Type;
begin
--
-- Step 0. Initialize excess values of Q to Zero.
--
if Max_Poly_ID < Poly_ID_Type'Last then
for m in Max_Poly_ID+1 .. Poly_ID_Type'Last loop
Q(m) := Zero;
end loop;
end if;
--
-- Step 0. Want zeroth order poly Q_0(p,X). No work to do.
--
if Max_Poly_ID = Poly_ID_Type'First then
m := Poly_ID_Type'First;
Q(m) := Q_0(p,X);
end if;
--
-- Step 0b. Poly is 1st order. Almost no work to do.
-- Don't do any iteration.
--
if Max_Poly_ID = Poly_ID_Type'First + 1 then
m := Poly_ID_Type'First;
Q(m) := Q_0(p,X);
m := Poly_ID_Type'First+1;
Q(m) := Alpha(m,p,X) * Q(m-1);
end if;
--
-- Step 1. We now know that Max_Poly_ID > 1.
-- Start by getting starting value of Q by solving M*Q = f.
-- Use recurrence relation to get Q at X.
-- Start with special formulas for the 1st two Q's:
--
if Max_Poly_ID > Poly_ID_Type'First + 1 then
m := Poly_ID_Type'First;
Q(m) := Q_0(p,X);
m := Poly_ID_Type'First+1;
Q(m) := Alpha(m,p,X) * Q(m-1);
for m in Poly_ID_Type'First+2..Max_Poly_ID loop
Q(m) := Alpha(m,p,X) * Q(m-1)
+ Beta(m,p,X) * Q(m-2);
end loop;
--
-- Step 2. Improve Q numerically through Newton iteration.
-- Q_new = Q_old + M_inverse * (C - M*Q_old)
--
Iterate: for Iter in 2..No_Of_Iterations loop
-- Get Product = M*Q_old:
m := Poly_ID_Type'First;
Product(m) := Q(m);
m := Poly_ID_Type'First+1;
Product(m) := Q(m) - Alpha(m,p,X)*Q(m-1);
for m in Poly_ID_Type'First+2..Max_Poly_ID loop
Product(m) := Q(m) - Alpha(m,p,X)*Q(m-1)
- Beta(m,p,X)*Q(m-2);
end loop;
-- Get Residual = (Q_0(p,X), 0, ... , 0) - M*D_old. Reuse the
-- array Product to hold the value of Residual:
Product(Poly_ID_Type'First) := Zero;
-- Residual is always exactly 0.0 here
for m in Poly_ID_Type'First+1 .. Max_Poly_ID loop
Product(m) := - Product(m);
end loop;
-- Get Del = M_inverse * (C - M*Q_old) = M_inverse * Product:
m := Max_Poly_ID;
Del(m) := Product(m);
m := Max_Poly_ID - 1;
Del(m) := Product(m) + Alpha(m,p,X)*Del(m-1);
for m in Poly_ID_Type'First+2 .. Max_Poly_ID loop
Del(m) := Product(m) + Alpha(m,p,X)*Del(m-1)
+ Beta(m,p,X)*Del(m-2);
end loop;
-- Get Q_new = Q_old + Del;
for m in Poly_ID_Type'First..Max_Poly_ID loop
Q(m) := Q(m) + Del(m);
end loop;
end loop Iterate;
end if;
end Evaluate_Qs;
-------------
-- M_times --
-------------
-- M is Upper-Triangular.
-- The elements of M are 1 down the diagonal, and -Alpha(m,p,X) and
-- -Beta(m,p,X) down the the off-diagonals.
--
function M_times
(D : in Coefficients;
X : in Real;
P : in Real;
Sum_Limit : in Poly_ID_Type)
return Coefficients
is
Product : Coefficients;
m : Poly_ID_Type;
begin
-- These inits are amazingly slow!
for m in Sum_Limit .. Poly_ID_Type'Last loop
Product(m) := Zero;
end loop;
-- Get Product = M*D:
m := Sum_Limit;
Product(m) := D(m);
if Sum_Limit > Poly_ID_Type'First then
m := Sum_Limit - 1;
Product(m) := D(m) - Alpha(m+1,p,X)*D(m+1);
end if;
if Sum_Limit > Poly_ID_Type'First+1 then
for m in Poly_ID_Type'First .. Sum_Limit-2 loop
Product(m) := D(m) - Alpha(m+1,p,X)*D(m+1)
- Beta(m+2,p,X)*D(m+2);
end loop;
end if;
return Product;
end M_times;
pragma Inline (M_times);
---------------------
-- M_inverse_times --
---------------------
-- M is Upper-Triangular so solution is by back-substitution.
-- The elements of M are 1 down the diagonal, and -Alpha and
-- -Beta down the off-diagonals.
--
function M_inverse_times
(C : in Coefficients;
X : in Real;
P : in Real;
Sum_Limit : in Poly_ID_Type)
return Coefficients
is
Result : Coefficients;
m : Poly_ID_Type;
begin
-- These inits are amazingly slow!
for m in Sum_Limit .. Poly_ID_Type'Last loop
Result(m) := Zero;
end loop;
m := Sum_Limit;
Result(m) := C(m);
if Sum_Limit > Poly_ID_Type'First then
m := Sum_Limit - 1;
Result(m) := C(m) + Alpha(m+1,p,X) * Result(m+1);
end if;
if Sum_Limit > Poly_ID_Type'First+1 then
for m in reverse Poly_ID_Type'First .. Sum_Limit-2 loop
Result(m) := C(m) + Alpha(m+1,p,X) * Result(m+1)
+ Beta(m+2,p,X) * Result(m+2);
end loop;
end if;
return Result;
end M_inverse_times;
pragma Inline (M_inverse_times);
---------
-- Sum --
---------
-- This is easily written as matrix equation, with Sum = D(0):
--
-- D_n = C_n;
-- D_n-1 = C_n-1 + Alpha_n*D_n;
-- D_n-2 = C_n-2 + Alpha_n-1*D_n-1 + Beta_n-2*D_n-2;
-- ...
-- D_1 = C_1 + Alpha_2*D_2 + Beta_3*D_3
-- D_0 = C_0 + Alpha_1*D_1 + Beta_2*D_2
--
-- In matrix form, M*D = C, this becomes:
--
--
-- | 1 E_1 B_2 0 | |D(0) | | C(0) |
-- | 0 1 E_2 B_3 | |D(1) | | C(1) |
--
-- ...
--
-- | 1 E_n-2 B_n-1 0 | |D(n-3)| = | C(n-3) |
-- | 0 1 E_n-1 B_n | |D(n-2)| | C(n-2) |
-- | 0 0 1 E_n | |D(n-1)| | C(n-1) |
-- | 0 0 0 1 | |D(n) | | C(n) |
--
-- where E_m = -Alpha_m, B_m = -Beta_m.
--
-- Can attemp iterative refinement of D with Newton's
-- method:
-- D_new = D_old + M_inverse * (C - M*D_old)
--
-- where D = M_inverse * C is the calculation of D given at the top. if the
-- said calculation of D is numerically imperfect, then the iteration above
-- will produce improved values of D. Of course, if the Coefficients of
-- the polynomials C are numerically poor, then this effort may be wasted.
--
function Sum
(X : in Real;
C : in Coefficients;
Sum_Limit : in Poly_ID_Type;
P : in Real := 0.0;
No_Of_Iterations : in Positive := 1)
return Real
is
Product, Del : Coefficients; -- initialized by M_inverse_times and M_times.
D : Coefficients; -- initialized by M_inverse_times.
Result : Real := Zero;
begin
--
-- Step 1. Getting starting value of D (D_old) by solving M*D = C.
--
D := M_inverse_times (C, X, p, Sum_Limit);
--
-- Step 2. Improve D numerically through Newton iteration.
-- D_new = D_old + M_inverse * (C - M*D_old)
--
Iterate: for k in 2..No_Of_Iterations loop
-- Get Product = M*D_old:
Product := M_times (D, X, p, Sum_Limit);
-- Get Residual = C - M*D_old. Reuse the array Product
-- to hold the value of Residual:
for m in Poly_ID_Type'First..Sum_Limit loop
Product(m) := C(m) - Product(m);
end loop;
-- Get Del = M_inverse * (A - M*D_old) = M_inverse * Product:
Del := M_inverse_times (Product, X, p, Sum_Limit);
-- Get D_new = D_old + Del;
for m in Poly_ID_Type'First..Sum_Limit loop
D(m) := D(m) + Del(m);
end loop;
end loop Iterate;
Result := D(0) * Q_0 (p, X);
return Result;
end Sum;
end Clenshaw;
|
98devin/ada-wfc | Ada | 13,739 | ads | ------------------------------------------------------------------------------
-- EMAIL: <[email protected]> --
-- License: ISC --
-- --
-- Copyright © 2015 - 2016 darkestkhan --
------------------------------------------------------------------------------
-- Permission to use, copy, modify, and/or distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- The software is provided "as is" and the author disclaims all warranties --
-- with regard to this software including all implied warranties of --
-- merchantability and fitness. In no event shall the author be liable for --
-- any special, direct, indirect, or consequential damages or any damages --
-- whatsoever resulting from loss of use, data or profits, whether in an --
-- action of contract, negligence or other tortious action, arising out of --
-- or in connection with the use or performance of this software. --
------------------------------------------------------------------------------
with Imago.IL;
use Imago;
package Imago.ILU is
--------------------------------------------------------------------------
---------------
-- T Y P E S --
---------------
--------------------------------------------------------------------------
-- NOTE: Really, this one should be replaced with type whose definition
-- is much more Ada-like.
type Info is
record
ID : IL.UInt; -- the image's ID
Data : IL.Pointer; -- the image's data
Width : IL.UInt; -- the image's width
Height : IL.UInt; -- the image's height
Depth : IL.UInt; -- the image's depth
Bpp : IL.UByte; -- bytes per pixel (not bits) of the image
Size_Of_Data: IL.UInt; -- the total size of the data (in bytes)
Format : IL.Enum; -- image format (in IL.Enum style)
Of_Type : IL.Enum; -- image type (in IL.Enum style)
Origin : IL.Enum; -- origin of the image
Palette : IL.Pointer; -- the image's palette
Palette_Type: IL.Enum; -- palette size
Palette_Size: IL.UInt; -- palette type
Cube_Flags : IL.Enum; -- flags for what cube map sides are present
Num_Next : IL.UInt; -- number of images following
Num_Mips : IL.UInt; -- number of mipmaps
Num_Layers : IL.UInt; -- number of layers
end record
with Convention => C;
type Point_F is
record
X: Float;
Y: Float;
end record
with Convention => C;
type Point_I is
record
X: IL.Int;
Y: IL.Int;
end record
with Convention => C;
--------------------------------------------------------------------------
-----------------------
-- C O N S T A N T S --
-----------------------
--------------------------------------------------------------------------
ILU_VERSION_1_7_8 : constant IL.Enum := 1;
ILU_VERSION : constant IL.Enum := 178;
ILU_FILTER : constant IL.Enum := 16#2600#;
ILU_NEAREST : constant IL.Enum := 16#2601#;
ILU_LINEAR : constant IL.Enum := 16#2602#;
ILU_BILINEAR : constant IL.Enum := 16#2603#;
ILU_SCALE_BOX : constant IL.Enum := 16#2604#;
ILU_SCALE_TRIANGLE : constant IL.Enum := 16#2605#;
ILU_SCALE_BELL : constant IL.Enum := 16#2606#;
ILU_SCALE_BSPLINE : constant IL.Enum := 16#2607#;
ILU_SCALE_LANCZOS3 : constant IL.Enum := 16#2608#;
ILU_SCALE_MITCHELL : constant IL.Enum := 16#2609#;
-- Error types.
ILU_INVALID_ENUM : constant IL.Enum := 16#0501#;
ILU_OUT_OF_MEMORY : constant IL.Enum := 16#0502#;
ILU_INTERNAL_ERROR : constant IL.Enum := 16#0504#;
ILU_INVALID_VALUE : constant IL.Enum := 16#0505#;
ILU_ILLEGAL_OPERATION : constant IL.Enum := 16#0506#;
ILU_INVALID_PARAM : constant IL.Enum := 16#0509#;
-- Values.
ILU_PLACEMENT : constant IL.Enum := 16#0700#;
ILU_LOWER_LEFT : constant IL.Enum := 16#0701#;
ILU_LOWER_RIGHT : constant IL.Enum := 16#0702#;
ILU_UPPER_LEFT : constant IL.Enum := 16#0703#;
ILU_UPPER_RIGHT : constant IL.Enum := 16#0704#;
ILU_CENTER : constant IL.Enum := 16#0705#;
ILU_CONVOLUTION_MATRIX : constant IL.Enum := 16#0710#;
ILU_VERSION_NUM : constant IL.Enum := IL.IL_VERSION_NUM;
ILU_VENDOR : constant IL.Enum := IL.IL_VENDOR;
-- Languages.
ILU_ENGLISH : constant IL.Enum := 16#0800#;
ILU_ARABIC : constant IL.Enum := 16#0801#;
ILU_DUTCH : constant IL.Enum := 16#0802#;
ILU_JAPANESE : constant IL.Enum := 16#0803#;
ILU_SPANISH : constant IL.Enum := 16#0804#;
ILU_GERMAN : constant IL.Enum := 16#0805#;
ILU_FRENCH : constant IL.Enum := 16#0806#;
--------------------------------------------------------------------------
---------------------------
-- S U B P R O G R A M S --
---------------------------
--------------------------------------------------------------------------
function Alienify return IL.Bool
with Import => True, Convention => StdCall, External_Name => "iluAlienify";
function Blur_Avg (Iter: in IL.UInt) return IL.Bool
with Import => True, Convention => StdCall, External_Name => "iluBlurAvg";
function Blur_Gaussian (Iter: in IL.UInt) return IL.Bool
with Import => True, Convention => StdCall,
External_Name => "iluBlurGaussian";
function Build_Mipmaps return IL.Bool
with Import => True, Convention => StdCall,
External_Name => "iluBuildMipmaps";
function Colors_Used return IL.UInt
with Import => True, Convention => StdCall,
External_Name => "iluColoursUsed";
function Colours_Used return IL.UInt
with Import => True, Convention => StdCall,
External_Name => "iluColoursUsed";
function Compare_Image (Comp: in IL.UInt) return IL.Bool
with Import => True, Convention => StdCall,
External_Name => "iluCompareImage";
function Contrast (Contrats: in Float) return IL.Bool
with Import => True, Convention => StdCall, External_Name => "iluContrast";
function Crop
( XOff: in IL.UInt; YOff: in IL.UInt; ZOff: in IL.UInt;
Width: in IL.UInt; Height: in IL.UInt; Depth: in IL.UInt
) return IL.Bool
with Import => True, Convention => StdCall, External_Name => "iluCrop";
procedure Delete_Image (ID: in IL.UInt)
with Import => True, Convention => StdCall,
External_Name => "iluDeleteImage";
function Edge_Detect_E return IL.Bool
with Import => True, Convention => StdCall,
External_Name => "iluEdgeDetectE";
function Edge_Detect_P return IL.Bool
with Import => True, Convention => StdCall,
External_Name => "iluEdgeDetectP";
function Edge_Detect_S return IL.Bool
with Import => True, Convention => StdCall,
External_Name => "iluEdgeDetectS";
function Emboss return IL.Bool
with Import => True, Convention => StdCall, External_Name => "iluEmboss";
function Enlarge_Canvas
( Width: in IL.UInt; Height: in IL.UInt; Depth: in IL.UInt
) return IL.Bool
with Import => True, Convention => StdCall,
External_Name => "iluEnlargeCanvas";
function Enlarge_Image
( XDim: in Float; YDim: in Float; ZDim: in Float
) return IL.Bool
with Import => True, Convention => StdCall,
External_Name => "iluEnlargeImage";
function Error_String (String_Name: in IL.Enum) return String
with Inline => True;
function Equalize return IL.Bool
with Import => True, Convention => StdCall, External_Name => "iluEqualize";
function Convolution
( Matrix: in IL.Pointer; Scale: in IL.Int; Bias: in IL.Int
) return IL.Bool
with Import => True, Convention => StdCall,
External_Name => "iluConvolution";
function Flip_Image return IL.Bool
with Import => True, Convention => StdCall, External_Name => "iluFlipImage";
function Gamma_Correct (Gamma: in Float) return IL.Bool
with Import => True, Convention => StdCall,
External_Name => "iluGammaCorrect";
function Gen_Image return IL.UInt
with Import => True, Convention => StdCall, External_Name => "iluGenImage";
procedure Get_Image_Info (Item: out Info)
with Import => True, Convention => StdCall,
External_Name => "iluGetImageInfo";
function Get_Integer (Mode: in IL.Enum) return IL.Int
with Import => True, Convention => StdCall,
External_Name => "iluGetInteger";
procedure Get_Integer (Mode: in IL.Enum; Param: in IL.Pointer)
with Import => True, Convention => StdCall,
External_Name => "iluGetIntegerv";
function Get_String (String_Name: in IL.Enum) return String
with Inline => True;
procedure Image_Parameter (P_Name: in IL.Enum; Param: in IL.Enum)
with Import => True, Convention => StdCall,
External_Name => "iluImageParameter";
procedure Init
with Import => True, Convention => StdCall, External_Name => "iluInit";
function Invert_Alpha return IL.Bool
with Import => True, Convention => StdCall,
External_Name => "iluInvertAlpha";
function Load_Image (File_Name: in String) return IL.UInt
with Inline => True;
function Mirror return IL.Bool
with Import => True, Convention => StdCall, External_Name => "iluMirror";
function Negative return IL.Bool
with Import => True, Convention => StdCall, External_Name => "iluNegative";
function Noisify (Tolerance: in IL.ClampF) return IL.Bool
with Import => True, Convention => StdCall, External_Name => "iluNoisify";
function Pixelize (Pix_Size: in IL.UInt) return IL.Bool
with Import => True, Convention => StdCall, External_Name => "iluPixelize";
procedure Region_F (Points: in IL.Pointer; N: in IL.UInt)
with Import => True, Convention => StdCall, External_Name => "iluRegionfv";
procedure Region_I (Points: in IL.Pointer; N: in IL.UInt)
with Import => True, Convention => StdCall, External_Name => "iluRegioniv";
function Replace_Color
( Red: in IL.UByte; Green: in IL.UByte;
Blue: in IL.UByte; Tolerance: in Float
) return IL.Bool
with Import => True, Convention => StdCall,
External_Name => "iluReplaceColour";
function Replace_Colour
( Red: in IL.UByte; Green: in IL.UByte;
Blue: in IL.UByte; Tolerance: in Float
) return IL.Bool
with Import => True, Convention => StdCall,
External_Name => "iluReplaceColour";
function Rotate (Angle: in Float) return IL.Bool
with Import => True, Convention => StdCall, External_Name => "iluRotate";
function Rotate
( X: in Float; Y: in Float; Z: in Float; Angle: in Float
) return IL.Bool
with Import => True, Convention => StdCall, External_Name => "iluRotate3D";
function Saturate (Saturation: in Float) return IL.Bool
with Import => True, Convention => StdCall,
External_Name => "iluSaturate1f";
function Saturate
( R: in Float; G: in Float; B: in Float; Saturation: in Float
) return IL.Bool
with Import => True, Convention => StdCall,
External_Name => "iluSaturate4f";
function Scale
( Width: in IL.UInt; Height: in IL.UInt; Depth: in IL.UInt
) return IL.Bool
with Import => True, Convention => StdCall, External_Name => "iluScale";
function Scale_Alpha (Scale: in Float) return IL.Bool
with Import => True, Convention => StdCall,
External_Name => "iluScaleAlpha";
function Scale_Colors (R: in Float; G: in Float; B: in Float) return IL.Bool
with Import => True, Convention => StdCall,
External_Name => "iluScaleColours";
function Scale_Colours (R: in Float; G: in Float; B: in Float) return IL.Bool
with Import => True, Convention => StdCall,
External_Name => "iluScaleColours";
function Set_Language (Language: in IL.Enum) return IL.Bool
with Import => True, Convention => StdCall,
External_Name => "iluSetLanguage";
function Sharpen (Factor: in Float; Iter: in IL.UInt) return IL.Bool
with Import => True, Convention => StdCall, External_Name => "iluSharpen";
function Swap_Colors return IL.Bool
with Import => True, Convention => StdCall,
External_Name => "iluSwapColours";
function Swap_Colours return IL.Bool
with Import => True, Convention => StdCall,
External_Name => "iluSwapColours";
function Wave (Angle: in Float) return IL.Bool
with Import => True, Convention => StdCall, External_Name => "iluWave";
--------------------------------------------------------------------------
end Imago.ILU;
|
optikos/oasis | Ada | 2,274 | ads | -- Copyright (c) 2019 Maxim Reznik <[email protected]>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with Program.Elements.Declarations;
with Program.Lexical_Elements;
with Program.Elements.Defining_Identifiers;
with Program.Elements.Subtype_Indications;
with Program.Elements.Aspect_Specifications;
package Program.Elements.Subtype_Declarations is
pragma Pure (Program.Elements.Subtype_Declarations);
type Subtype_Declaration is
limited interface and Program.Elements.Declarations.Declaration;
type Subtype_Declaration_Access is access all Subtype_Declaration'Class
with Storage_Size => 0;
not overriding function Name
(Self : Subtype_Declaration)
return not null Program.Elements.Defining_Identifiers
.Defining_Identifier_Access is abstract;
not overriding function Subtype_Indication
(Self : Subtype_Declaration)
return not null Program.Elements.Subtype_Indications
.Subtype_Indication_Access is abstract;
not overriding function Aspects
(Self : Subtype_Declaration)
return Program.Elements.Aspect_Specifications
.Aspect_Specification_Vector_Access is abstract;
type Subtype_Declaration_Text is limited interface;
type Subtype_Declaration_Text_Access is
access all Subtype_Declaration_Text'Class with Storage_Size => 0;
not overriding function To_Subtype_Declaration_Text
(Self : aliased in out Subtype_Declaration)
return Subtype_Declaration_Text_Access is abstract;
not overriding function Subtype_Token
(Self : Subtype_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Is_Token
(Self : Subtype_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function With_Token
(Self : Subtype_Declaration_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Semicolon_Token
(Self : Subtype_Declaration_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Subtype_Declarations;
|
wiremoons/apass | Ada | 572 | ads | -------------------------------------------------------------------------------
-- Package : Cmd_Flags --
-- Description : Manage user provided CLI flags for the program. --
-- Author : Simon Rowe <[email protected]> --
-- License : MIT Open Source. --
-------------------------------------------------------------------------------
package Cmd_Flags is
function Command_Line_Flags_Exist return Boolean;
end Cmd_Flags;
|
ekoeppen/MSP430_Generic_Ada_Drivers | Ada | 526 | adb | with Interfaces; use Interfaces;
with MSPGD.Board;
with Drivers.Text_IO;
procedure Main is
pragma Preelaborate;
package Board renames MSPGD.Board;
package Text_IO is new Drivers.Text_IO (USART => Board.UART);
N : Unsigned_32 := 0;
begin
Board.Init;
Text_IO.Put_Line ("Hello, World!");
loop
if not Board.BUTTON.Is_Set then
Board.LED_GREEN.Set;
Text_IO.Put_Hex (N, 8); Text_IO.New_Line;
Board.LED_GREEN.Clear;
N := N + 1;
end if;
end loop;
end Main;
|
AdaCore/langkit | Ada | 333 | adb | package body Libfoolang.Implementation.C.Extensions is
procedure foo_do_something is
begin
Clear_Last_Exception;
Set_Last_Exception
(Id => Property_Error'Identity,
Message => (1 => 'A', 2 .. 9_999 => 'B', 10_000 => 'C'));
end foo_do_something;
end Libfoolang.Implementation.C.Extensions;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 588 | ads | with Ada.Interrupts; use Ada.Interrupts;
with Ada.Real_Time; use Ada.Real_Time;
with STM32_SVD.Interrupts; use STM32_SVD.Interrupts;
with STM32_SVD.TIM; use STM32_SVD.TIM;
generic
Timer : in out TIM6_Peripheral;
IRQ : Interrupt_ID;
package STM32GD.Timer is
procedure Init;
procedure Stop;
procedure After (Time : Time_Span; Callback : Callback_Type);
procedure Every (Interval : Time_Span; Callback : Callback_Type);
private
protected IRQ_Handler is
procedure Handler;
pragma Attach_Handler (Handler, IRQ);
end IRQ_Handler;
end STM32GD.Timer;
|
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.Db_Is_Clustered_Attributes is
pragma Preelaborate;
type ODF_Db_Is_Clustered_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Db_Is_Clustered_Attribute_Access is
access all ODF_Db_Is_Clustered_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Db_Is_Clustered_Attributes;
|
reznikmm/matreshka | Ada | 4,616 | 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.Date_Start_Attributes is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Table_Date_Start_Attribute_Node is
begin
return Self : Table_Date_Start_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_Date_Start_Attribute_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Date_Start_Attribute;
end Get_Local_Name;
begin
Matreshka.DOM_Documents.Register_Attribute
(Matreshka.ODF_String_Constants.Table_URI,
Matreshka.ODF_String_Constants.Date_Start_Attribute,
Table_Date_Start_Attribute_Node'Tag);
end Matreshka.ODF_Table.Date_Start_Attributes;
|
godunko/adawebpack | Ada | 9,435 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . S O F T _ L I N K S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2020, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This is the WASM version of this package
pragma Style_Checks (Off);
pragma Warnings (Off);
-- Disable warnings as System.Soft_Links.Initialize is not Preelaborate. It is
-- safe to with this unit as its elaboration routine will only be initializing
-- NT_TSD, which is part of this package spec.
--with System.Soft_Links.Initialize;
pragma Warnings (On);
package body System.Soft_Links is
-- Stack_Limit : aliased System.Address := System.Null_Address;
-- pragma Export (C, Stack_Limit, "__gnat_stack_limit");
-- -- Needed for Vx6Cert (Vx653mc) GOS cert and ravenscar-cert runtimes,
-- -- VxMILS cert, ravenscar-cert and full runtimes, Vx 5 default runtime
--
-- --------------------
-- -- Abort_Defer_NT --
-- --------------------
--
-- procedure Abort_Defer_NT is
-- begin
-- null;
-- end Abort_Defer_NT;
--
-- ----------------------
-- -- Abort_Handler_NT --
-- ----------------------
--
-- procedure Abort_Handler_NT is
-- begin
-- null;
-- end Abort_Handler_NT;
----------------------
-- Abort_Undefer_NT --
----------------------
procedure Abort_Undefer_NT is
begin
null;
end Abort_Undefer_NT;
-----------------
-- Adafinal_NT --
-----------------
procedure Adafinal_NT is
begin
-- Handle normal task termination by the environment task, but only
-- for the normal task termination. In the case of Abnormal and
-- Unhandled_Exception they must have been handled before, and the
-- task termination soft link must have been changed so the task
-- termination routine is not executed twice.
-- Task_Termination_Handler.all (Ada.Exceptions.Null_Occurrence);
-- Finalize all library-level controlled objects if needed
if Finalize_Library_Objects /= null then
Finalize_Library_Objects.all;
end if;
end Adafinal_NT;
-- ---------------------------
-- -- Check_Abort_Status_NT --
-- ---------------------------
--
-- function Check_Abort_Status_NT return Integer is
-- begin
-- return Boolean'Pos (False);
-- end Check_Abort_Status_NT;
--
-- ------------------------
-- -- Complete_Master_NT --
-- ------------------------
--
-- procedure Complete_Master_NT is
-- begin
-- null;
-- end Complete_Master_NT;
--
-- ----------------
-- -- Create_TSD --
-- ----------------
--
-- procedure Create_TSD
-- (New_TSD : in out TSD;
-- Sec_Stack : SST.SS_Stack_Ptr;
-- Sec_Stack_Size : System.Parameters.Size_Type)
-- is
-- begin
-- New_TSD.Jmpbuf_Address := Null_Address;
--
-- New_TSD.Sec_Stack_Ptr := Sec_Stack;
-- SST.SS_Init (New_TSD.Sec_Stack_Ptr, Sec_Stack_Size);
-- end Create_TSD;
--
-- -----------------------
-- -- Current_Master_NT --
-- -----------------------
--
-- function Current_Master_NT return Integer is
-- begin
-- return 0;
-- end Current_Master_NT;
--
-- -----------------
-- -- Destroy_TSD --
-- -----------------
--
-- procedure Destroy_TSD (Old_TSD : in out TSD) is
-- begin
-- SST.SS_Free (Old_TSD.Sec_Stack_Ptr);
-- end Destroy_TSD;
--
-- ---------------------
-- -- Enter_Master_NT --
-- ---------------------
--
-- procedure Enter_Master_NT is
-- begin
-- null;
-- end Enter_Master_NT;
--
-- --------------------------
-- -- Get_Current_Excep_NT --
-- --------------------------
--
-- function Get_Current_Excep_NT return EOA is
-- begin
-- return NT_TSD.Current_Excep'Access;
-- end Get_Current_Excep_NT;
--
-- ------------------------
-- -- Get_GNAT_Exception --
-- ------------------------
--
-- function Get_GNAT_Exception return Ada.Exceptions.Exception_Id is
-- begin
-- return Ada.Exceptions.Exception_Identity (Get_Current_Excep.all.all);
-- end Get_GNAT_Exception;
--
-- ---------------------------
-- -- Get_Jmpbuf_Address_NT --
-- ---------------------------
--
-- function Get_Jmpbuf_Address_NT return Address is
-- begin
-- return NT_TSD.Jmpbuf_Address;
-- end Get_Jmpbuf_Address_NT;
--
-- -----------------------------
-- -- Get_Jmpbuf_Address_Soft --
-- -----------------------------
--
-- function Get_Jmpbuf_Address_Soft return Address is
-- begin
-- return Get_Jmpbuf_Address.all;
-- end Get_Jmpbuf_Address_Soft;
----------------------
-- Get_Sec_Stack_NT --
----------------------
function Get_Sec_Stack_NT return SST.SS_Stack_Ptr is
begin
return NT_TSD.Sec_Stack_Ptr;
end Get_Sec_Stack_NT;
-- -----------------------------
-- -- Get_Sec_Stack_Soft --
-- -----------------------------
--
-- function Get_Sec_Stack_Soft return SST.SS_Stack_Ptr is
-- begin
-- return Get_Sec_Stack.all;
-- end Get_Sec_Stack_Soft;
--
-- -----------------------
-- -- Get_Stack_Info_NT --
-- -----------------------
--
-- function Get_Stack_Info_NT return Stack_Checking.Stack_Access is
-- begin
-- return NT_TSD.Pri_Stack_Info'Access;
-- end Get_Stack_Info_NT;
-----------------------------
-- Save_Library_Occurrence --
-----------------------------
-- procedure Save_Library_Occurrence (E : EOA) is
-- use Ada.Exceptions;
-- begin
-- if not Library_Exception_Set then
-- Library_Exception_Set := True;
-- if E /= null then
-- Ada.Exceptions.Save_Occurrence (Library_Exception, E.all);
-- end if;
-- end if;
-- null;
-- end Save_Library_Occurrence;
-- ---------------------------
-- -- Set_Jmpbuf_Address_NT --
-- ---------------------------
--
-- procedure Set_Jmpbuf_Address_NT (Addr : Address) is
-- begin
-- NT_TSD.Jmpbuf_Address := Addr;
-- end Set_Jmpbuf_Address_NT;
--
-- procedure Set_Jmpbuf_Address_Soft (Addr : Address) is
-- begin
-- Set_Jmpbuf_Address (Addr);
-- end Set_Jmpbuf_Address_Soft;
--
-- ----------------------
-- -- Set_Sec_Stack_NT --
-- ----------------------
--
-- procedure Set_Sec_Stack_NT (Stack : SST.SS_Stack_Ptr) is
-- begin
-- NT_TSD.Sec_Stack_Ptr := Stack;
-- end Set_Sec_Stack_NT;
--
-- ------------------------
-- -- Set_Sec_Stack_Soft --
-- ------------------------
--
-- procedure Set_Sec_Stack_Soft (Stack : SST.SS_Stack_Ptr) is
-- begin
-- Set_Sec_Stack (Stack);
-- end Set_Sec_Stack_Soft;
------------------
-- Task_Lock_NT --
------------------
procedure Task_Lock_NT is
begin
null;
end Task_Lock_NT;
-- ------------------
-- -- Task_Name_NT --
-- -------------------
--
-- function Task_Name_NT return String is
-- begin
-- return "main_task";
-- end Task_Name_NT;
--
-- -------------------------
-- -- Task_Termination_NT --
-- -------------------------
--
-- procedure Task_Termination_NT (Excep : EO) is
-- pragma Unreferenced (Excep);
-- begin
-- null;
-- end Task_Termination_NT;
--------------------
-- Task_Unlock_NT --
--------------------
procedure Task_Unlock_NT is
begin
null;
end Task_Unlock_NT;
end System.Soft_Links;
|
reznikmm/matreshka | Ada | 4,011 | 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 ODF.DOM.Chart_Mean_Value_Attributes;
package Matreshka.ODF_Chart.Mean_Value_Attributes is
type Chart_Mean_Value_Attribute_Node is
new Matreshka.ODF_Chart.Abstract_Chart_Attribute_Node
and ODF.DOM.Chart_Mean_Value_Attributes.ODF_Chart_Mean_Value_Attribute
with null record;
overriding function Create
(Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters)
return Chart_Mean_Value_Attribute_Node;
overriding function Get_Local_Name
(Self : not null access constant Chart_Mean_Value_Attribute_Node)
return League.Strings.Universal_String;
end Matreshka.ODF_Chart.Mean_Value_Attributes;
|
reznikmm/matreshka | Ada | 7,305 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- 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$
------------------------------------------------------------------------------
-- This package provides implementation of 'visitors' pattern to process XML
-- DOM.
------------------------------------------------------------------------------
with XML.DOM.Attributes;
with XML.DOM.Documents;
with XML.DOM.Elements;
with XML.DOM.Nodes;
with XML.DOM.Texts;
package XML.DOM.Visitors is
pragma Preelaborate;
type Traverse_Control is
(Continue,
Abandon_Children,
Abandon_Sibling,
Terminate_Immediately);
----------------------
-- Abstract_Visitor --
----------------------
type Abstract_Visitor is limited interface;
not overriding procedure Enter_Attribute
(Self : in out Abstract_Visitor;
Node : XML.DOM.Attributes.DOM_Attribute;
Control : in out XML.DOM.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Attribute
(Self : in out Abstract_Visitor;
Node : XML.DOM.Attributes.DOM_Attribute;
Control : in out XML.DOM.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Document
(Self : in out Abstract_Visitor;
Node : XML.DOM.Documents.DOM_Document;
Control : in out XML.DOM.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Document
(Self : in out Abstract_Visitor;
Node : XML.DOM.Documents.DOM_Document;
Control : in out XML.DOM.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Element
(Self : in out Abstract_Visitor;
Node : XML.DOM.Elements.DOM_Element;
Control : in out XML.DOM.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Element
(Self : in out Abstract_Visitor;
Node : XML.DOM.Elements.DOM_Element;
Control : in out XML.DOM.Visitors.Traverse_Control) is null;
not overriding procedure Enter_Text
(Self : in out Abstract_Visitor;
Node : XML.DOM.Texts.DOM_Text;
Control : in out XML.DOM.Visitors.Traverse_Control) is null;
not overriding procedure Leave_Text
(Self : in out Abstract_Visitor;
Node : XML.DOM.Texts.DOM_Text;
Control : in out XML.DOM.Visitors.Traverse_Control) is null;
-----------------------
-- Abstract_Iterator --
-----------------------
type Abstract_Iterator is limited interface;
procedure Visit
(Self : in out Abstract_Iterator'Class;
Visitor : in out Abstract_Visitor'Class;
Node : XML.DOM.Nodes.DOM_Node'Class;
Control : in out Traverse_Control);
-- Visit specified element by calling:
--
-- - Enter_<Node> operation on visitor;
--
-- - Visit_<Node> operation on iterator;
--
-- - Leave_<Node> operation on visitor.
procedure Visit_Children
(Self : in out Abstract_Iterator'Class;
Visitor : in out Abstract_Visitor'Class;
Node : XML.DOM.Nodes.DOM_Node'Class;
Control : in out Traverse_Control);
-- Visit all children nodes of the node.
not overriding procedure Visit_Attribute
(Self : in out Abstract_Iterator;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Node : XML.DOM.Attributes.DOM_Attribute;
Control : in out XML.DOM.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Document
(Self : in out Abstract_Iterator;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Node : XML.DOM.Documents.DOM_Document;
Control : in out XML.DOM.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Element
(Self : in out Abstract_Iterator;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Node : XML.DOM.Elements.DOM_Element;
Control : in out XML.DOM.Visitors.Traverse_Control) is null;
not overriding procedure Visit_Text
(Self : in out Abstract_Iterator;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Node : XML.DOM.Texts.DOM_Text;
Control : in out XML.DOM.Visitors.Traverse_Control) is null;
end XML.DOM.Visitors;
|
ZinebZaad/ENSEEIHT | Ada | 7,855 | adb | with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with System.Multiprocessors; use System.Multiprocessors;
with System.Multiprocessors.Dispatching_Domains; use System.Multiprocessors.Dispatching_Domains;
package body Google_Creuse is
procedure Initialiser(Google: out T_Google) is
begin
Vecteur_Matrice.Initialiser(Google.Matrice_Creuse, Taille);
Google.Addition := (1.0-Alpha)/T_Precision(Taille);
Google.PreVide := Alpha/T_Precision(Taille) + Google.Addition;
end Initialiser;
procedure Creer(Google: in out T_Google; Liens: in LC_Integer_Integer.T_LC) is
TH: TH_Matrice.T_TH;
LCA: TH_Matrice.T_LCA_C.T_LCA;
Vecteur: Vecteur_Matrice.T_Vecteur;
procedure Incrementer(Gauche: Integer; Droit: Integer) is
begin
if not TH_Matrice.Cle_Presente(TH, (Gauche, Droit)) then -- Verifier si il n'existe pas plusieurs liaisons identiques.
TH_Matrice.Enregistrer(TH, (Gauche, Droit), 1.0);
Vecteur_Integer.Modifier(Google.Sortants, Gauche, Vecteur_Integer.Valeur(Google.Sortants, Gauche) + 1);
end if;
end Incrementer;
procedure Calculer_Sortants is
new LC_Integer_Integer.Pour_Chaque(Incrementer);
procedure Populer(Gauche: Integer; Droit: Integer) is
begin
TH_Matrice.Enregistrer(TH, (Droit, Gauche), T_Precision(Alpha)*1.0/T_Precision(Vecteur_Integer.Valeur(Google.Sortants,Gauche)) + Google.Addition);
end Populer;
procedure Populer_Liste is
new LC_Integer_Integer.Pour_Chaque(Populer);
procedure Inserer (Indice: T_Indice; Valeur: T_Precision) is
Valeur_Matrice: T_Matrice_Valeur;
begin
Valeur_Matrice.Indice := Indice;
Valeur_Matrice.Valeur := Valeur;
Vecteur_Matrice.Ajouter(Vecteur, Valeur_Matrice);
end Inserer;
procedure Convertir_Vecteur is
new TH_Matrice.T_LCA_C.Pour_Chaque (Inserer);
function Comparer_Indice(Val1: T_Matrice_Valeur; Val2: T_Matrice_Valeur) return Boolean is
begin
return Val1.Indice.Y > Val2.Indice.Y;
end Comparer_Indice;
procedure Ordonner_Vecteur is
new Vecteur_Matrice.Trier(Comparer_Indice);
procedure Ajouter(Valeur_Matrice: T_Matrice_Valeur) is
begin
Vecteur_Matrice.Ajouter(Google.Matrice_Creuse, Valeur_Matrice);
end Ajouter;
procedure Combiner_Vecteurs is
new Vecteur_Matrice.Pour_Chaque(Ajouter);
begin
TH_Matrice.Initialiser(TH, Taille);
Vecteur_Integer.Initialiser(Google.Sortants, Taille);
for J in 0..Taille-1 loop
Vecteur_Integer.Ajouter(Google.Sortants, 0);
end loop;
Calculer_Sortants(Liens);
TH_Matrice.Vider(TH);
Populer_Liste(Liens);
Vecteur_Matrice.Initialiser(Google.Matrice_Creuse, TH_Matrice.Taille(TH));
for I in 0..Taille-1 loop
LCA := TH_Matrice.LCA(TH, (I, 0));
if TH_Matrice.T_LCA_C.Taille(LCA) /= 0 then
Vecteur_Matrice.Initialiser(Vecteur, TH_Matrice.T_LCA_C.Taille(LCA));
Convertir_Vecteur(LCA);
Ordonner_Vecteur(Vecteur);
Combiner_Vecteurs(Vecteur);
Vecteur_Matrice.Vider(Vecteur);
end if;
end loop;
end Creer;
procedure Calculer_Rangs(Google: in out T_Google; Rangs: out Vecteur_Poids.T_Vecteur) is
Poids: Vecteur_Precision.T_Vecteur;
Poids_Original: Vecteur_Precision.T_Vecteur;
Finished: array (1..4) of Boolean;
Bords: array (1..5) of Integer;
Count: Integer;
Matrice_Val: T_Matrice_Valeur;
task type TT(Id: Integer; CPU_Id: CPU_Range)
with CPU => CPU_Id
is
entry Start(Matrice: Vecteur_Matrice.T_Vecteur; Poids_Original: Vecteur_Precision.T_Vecteur);
end TT;
task body TT is
Matrice_Valeur: T_Matrice_Valeur;
pCount: Integer;
Temp: T_Precision;
begin
loop select
accept Start(Matrice: Vecteur_Matrice.T_Vecteur; Poids_Original: Vecteur_Precision.T_Vecteur) do
Finished(Id) := false;
end Start;
pCount := Bords(Id);
Matrice_Valeur := Vecteur_Matrice.Valeur(Google.Matrice_Creuse, pCount);
for I in Taille*(Id-1)/4..Taille*Id/4-1 loop
Temp := 0.0;
for J in 0..Taille-1 loop
if Matrice_Valeur.Indice.X = I and Matrice_Valeur.Indice.Y = J then
Temp := Temp + Vecteur_Precision.Valeur(Poids_Original, J)*Matrice_Valeur.Valeur;
if Bords(Id+1) = pCount+1 then
Matrice_Valeur.Indice.X := Taille;
else
pCount := pCount + 1;
Matrice_Valeur := Vecteur_Matrice.Valeur(Google.Matrice_Creuse, pCount);
end if;
else
Temp := Temp + Vecteur_Precision.Valeur(Poids_Original, J)*Google.Addition;
null;
end if;
end loop;
Vecteur_Precision.Modifier(Poids, I, Temp);
end loop;
Finished(Id) := true;
or
terminate;
end select; end loop;
end TT;
Task1: TT(1, Not_A_Specific_CPU);
Task2: TT(2, Not_A_Specific_CPU);
Task3: TT(3, Not_A_Specific_CPU);
Task4: TT(4, Not_A_Specific_CPU);
begin
Vecteur_Precision.Initialiser(Poids, Taille);
for I in 0..Taille-1 loop
Vecteur_Precision.Ajouter(Poids, 1.0/T_Precision(Taille));
end loop;
Bords(1) := 0;
Count := 1;
for I in 0..Vecteur_Matrice.Taille(Google.Matrice_Creuse)-1 loop
Matrice_Val := Vecteur_Matrice.Valeur(Google.Matrice_Creuse, I);
while Matrice_Val.Indice.X >= Taille*Count/4 loop
Count := Count + 1;
Bords(Count) := I;
end loop;
end loop;
Count := Count + 1;
Bords(Count) := Vecteur_Matrice.Taille(Google.Matrice_Creuse);
for tmp in 1..MaxIterations loop
Count := 1;
Vecteur_Precision.Copier(Poids_Original, Poids);
for I in 0..Taille-1 loop
if Vecteur_Integer.Valeur(Google.Sortants, I) = 0 then
Vecteur_Precision.Modifier(Poids_Original, I, Vecteur_Precision.Valeur(Poids_Original, I)*Google.PreVide/Google.Addition);
end if;
end loop;
Task1.Start(Google.Matrice_Creuse, Poids_Original);
Task2.Start(Google.Matrice_Creuse, Poids_Original);
Task3.Start(Google.Matrice_Creuse, Poids_Original);
Task4.Start(Google.Matrice_Creuse, Poids_Original);
while not Finished(1) or else not Finished(2) or else not Finished(3) or else not Finished(4) loop
null; -- Attendre le resultat...
end loop;
Vecteur_Precision.Vider(Poids_Original);
end loop;
Put_Line("Fin des itérations");
Vecteur_Poids.Initialiser(Rangs, Taille);
for I in 0..Taille-1 loop
declare
Rank: T_Rank := (Rang => I, Poid => T_Digits(Vecteur_Precision.Valeur(Poids, I)));
begin
Vecteur_Poids.Ajouter(Rangs, Rank);
end;
end loop;
Vecteur_Precision.Vider(Poids);
end Calculer_Rangs;
end Google_Creuse;
|
AdaCore/libadalang | Ada | 1,683 | adb | with GNATCOLL.Projects;
with GNATCOLL.VFS;
with Libadalang.Project_Provider;
package body Helpers is
package VFS renames GNATCOLL.VFS;
package GPR renames GNATCOLL.Projects;
function Initialize
(Project_Path : String;
Sources : out Unit_Vectors.Vector) return LAL.Analysis_Context
is
Project : GPR.Project_Tree_Access;
function Load_Project return LAL.Unit_Provider_Reference;
------------------
-- Load_Project --
------------------
function Load_Project return LAL.Unit_Provider_Reference is
use Libadalang.Project_Provider;
Env : GPR.Project_Environment_Access;
begin
-- Load the project and create a unit provider wrapping it
Project := new GPR.Project_Tree;
GPR.Initialize (Env);
Project.Load (VFS.Create (VFS."+" (Project_Path)));
return Create_Project_Unit_Provider
(Project, Env => Env, Is_Project_Owner => True);
end Load_Project;
Provider : constant LAL.Unit_Provider_Reference := Load_Project;
Context : constant LAL.Analysis_Context := LAL.Create_Context
(Unit_Provider => Provider);
Files : VFS.File_Array_Access;
begin
-- Extract the list of source files to process from this project
Files := Project.Root_Project.Source_Files;
for F of Files.all loop
declare
Unit : constant LAL.Analysis_Unit :=
LAL.Get_From_File (Context, VFS."+" (F.Full_Name));
begin
Sources.Append (Unit);
end;
end loop;
VFS.Unchecked_Free (Files);
return Context;
end Initialize;
end Helpers;
|
NCommander/dnscatcher | Ada | 4,944 | ads | -- Copyright 2019 Michael Casadevall <[email protected]>
--
-- Permission is hereby granted, free of charge, to any person obtaining a copy
-- of this software and associated documentation files (the "Software"), to
-- deal in the Software without restriction, including without limitation the
-- rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
-- sell copies of the Software, and to permit persons to whom the Software is
-- furnished to do so, subject to the following conditions:
--
-- The above copyright notice and this permission notice shall be included in
-- all copies or substantial portions of the Software.
--
-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
-- THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
-- FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
-- DEALINGS IN THE SOFTWARE.
with Ada.Unchecked_Deallocation;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Streams; use Ada.Streams;
with Interfaces.C.Extensions; use Interfaces.C.Extensions;
with DNSCatcher.Types; use DNSCatcher.Types;
-- @summary
-- Generic utility functions used throughout DNSCatcher are collected here.
--
-- @description
-- Some functionality is either very generic (such as ntohs), or otherwise is
-- a standalone subprogram that is used throughout the code, and this package
-- provides a home and organization pointer for them
--
-- Wrapper functions are provided for network byte order conversion as in
-- certain places, the values must be flipped on the fly, and GNAT.Sockets
-- doesn't provide an easy interface for this
--
package DNSCatcher.Utils is
-- Network Byteorder to Host Short
--
-- @value Network_Short
-- An unsigned 16-bit integer
--
-- @returns
-- Local machine byte order 16-bit integer
--
function Ntohs
(Network_Short : Unsigned_16)
return Unsigned_16;
-- Network Byteorder to Host Long
--
-- @value Network_Long
-- An unsigned 32-bit integer
--
-- @returns
-- Local machine byte order 32-bit integer
--
function Ntohl
(Network_Long : Unsigned_32)
return Unsigned_32;
-- Host Short to Network Byteorder
--
-- @value Host_Short
-- An unsigned 16-bit integer
--
-- @returns
-- Network byte order 16-bit integer
--
function Htons
(Host_Short : Unsigned_16)
return Unsigned_16;
-- Host Long to Network Byteorder
--
-- @value Host_Long
-- An unsigned 32-bit integer
--
-- @returns
-- Network byte order 32-bit integer
--
function Htonl
(Host_Long : Unsigned_32)
return Unsigned_32;
-- Reads a 16-bit integer from a network stream and converts it to an
-- Unsigned_16 for further evaluation
--
-- @value Raw_Data
-- Pointer to a Stream_Element Array
--
-- @value Offset
-- Location which to read the uint16 from
--
-- @returns
-- Unsigned_16
--
function Read_Unsigned_16
(Raw_Data : Stream_Element_Array_Ptr;
Offset : in out Stream_Element_Offset)
return Unsigned_16;
-- Reads a 32-bit integer from a network stream and converts it to an
-- Unsigned_32 for further evaluation
--
-- @value Raw_Data
-- Pointer to a Stream_Element Array
--
-- @value Offset
-- Location which to read the uint32 from
--
-- @returns
-- Unsigned_32
--
function Read_Unsigned_32
(Raw_Data : Stream_Element_Array_Ptr;
Offset : in out Stream_Element_Offset)
return Unsigned_32;
-- IP_Addr_Family
--
-- This is a wrapper for Inet_Ntop that abstracts the values of AF_INET and
-- AF_INET6 from the C preprocessor; allowing it to work across platforms
-- without concern for varying preprocessor types
--
type IP_Addr_Family is
(IPv4, -- IPv4 input address
IPv6 -- IPv6 input address
);
for IP_Addr_Family use (IPv4 => 1, IPv6 => 2);
-- Converts binary IPs to text form
--
-- @value Family
-- IP_Addr_Family on if we're reading an IPv4 or IPv6 address
--
-- @value Raw_Data
-- The raw data stored in Unbounded_String format
--
-- @returns
-- Unbounded String with the IP address formatted in conventional style by
-- the underlying inet_ntop() C function
--
function Inet_Ntop
(Family : IP_Addr_Family;
Raw_Data : Unbounded_String)
return Unbounded_String;
-- Deallocators
-- Helper function to free Stream_Element_Arrays
procedure Free_Stream_Element_Array_Ptr is new Ada.Unchecked_Deallocation
(Object => Stream_Element_Array, Name => Stream_Element_Array_Ptr);
end DNSCatcher.Utils;
|
zhmu/ananas | Ada | 5,576 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T A S K _ P R I M I T I V E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1991-2017, Florida State University --
-- Copyright (C) 1995-2022, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- This is a POSIX-like version of this package
-- Note: this file can only be used for POSIX compliant systems
with System.OS_Interface;
package System.Task_Primitives is
pragma Preelaborate;
type Lock is limited private;
-- Should be used for implementation of protected objects
type RTS_Lock is limited private;
-- Should be used inside the runtime system. The difference between Lock
-- and the RTS_Lock is that the latter serves only as a semaphore so that
-- we do not check for ceiling violations.
type Suspension_Object is limited private;
-- Should be used for the implementation of Ada.Synchronous_Task_Control
type Task_Body_Access is access procedure;
-- Pointer to the task body's entry point (or possibly a wrapper declared
-- local to the GNARL).
type Private_Data is limited private;
-- Any information that the GNULLI needs maintained on a per-task basis.
-- A component of this type is guaranteed to be included in the
-- Ada_Task_Control_Block.
subtype Task_Address is System.Address;
Task_Address_Size : constant := Standard'Address_Size;
-- Type used for task addresses and its size
Alternate_Stack_Size : constant := System.OS_Interface.Alternate_Stack_Size;
-- Import value from System.OS_Interface
private
type RTS_Lock is new System.OS_Interface.pthread_mutex_t;
type Lock is record
RW : aliased System.OS_Interface.pthread_rwlock_t;
WO : aliased RTS_Lock;
end record;
type Suspension_Object is record
State : Boolean;
pragma Atomic (State);
-- Boolean that indicates whether the object is open. This field is
-- marked Atomic to ensure that we can read its value without locking
-- the access to the Suspension_Object.
Waiting : Boolean;
-- Flag showing if there is a task already suspended on this object
L : aliased RTS_Lock;
-- Protection for ensuring mutual exclusion on the Suspension_Object
CV : aliased System.OS_Interface.pthread_cond_t;
-- Condition variable used to queue threads until condition is signaled
end record;
type Private_Data is limited record
Thread : aliased System.OS_Interface.pthread_t;
pragma Atomic (Thread);
-- Thread field may be updated by two different threads of control.
-- (See, Enter_Task and Create_Task in s-taprop.adb). They put the same
-- value (thr_self value). We do not want to use lock on those
-- operations and the only thing we have to make sure is that they are
-- updated in atomic fashion.
LWP : aliased System.Address;
-- The purpose of this field is to provide a better tasking support on
-- gdb. The order of the two first fields (Thread and LWP) is important.
-- On targets where lwp is not relevant, this is equivalent to Thread.
CV : aliased System.OS_Interface.pthread_cond_t;
-- Should be commented ??? (in all versions of taspri)
L : aliased RTS_Lock;
-- Protection for all components is lock L
end record;
end System.Task_Primitives;
|
Fabien-Chouteau/GESTE-examples | Ada | 3,330 | adb | with Ada.Real_Time;
with Render;
with Keyboard;
with Levels;
with Player;
with GESTE;
with GESTE.Text;
with GESTE_Config;
with GESTE_Fonts.FreeMono5pt7b;
package body Game is
package RT renames Ada.Real_Time;
use type RT.Time;
use type RT.Time_Span;
Text : aliased GESTE.Text.Instance
(GESTE_Fonts.FreeMono5pt7b.Font,
15, 1,
Render.Black,
GESTE_Config.Transparent);
Frame_Counter : Natural := 0;
Next_FPS_Update : RT.Time := RT.Clock + RT.Seconds (1);
Period : constant RT.Time_Span := RT.Seconds (1) / 60;
Next_Release : RT.Time := RT.Clock + Period;
Lvl : Levels.Level_Id := Levels.Lvl_1;
---------------
-- Game_Loop --
---------------
procedure Game_Loop is
begin
loop
if Player.Position.X > 320 - 3 then
case Lvl is
when Levels.Lvl_1 =>
Levels.Leave (Levels.Lvl_1);
Levels.Enter (Levels.Lvl_2);
Lvl := Levels.Lvl_2;
Player.Move ((3, 125));
when Levels.Lvl_2 =>
Levels.Leave (Levels.Lvl_2);
Levels.Enter (Levels.Lvl_3);
Lvl := Levels.Lvl_3;
Player.Move ((3, 183));
when Levels.Lvl_3 =>
Levels.Leave (Levels.Lvl_3);
Levels.Enter (Levels.Lvl_1);
Lvl := Levels.Lvl_1;
Player.Move ((3, 142));
end case;
elsif Player.Position.X < 2 then
case Lvl is
when Levels.Lvl_1 =>
Levels.Leave (Levels.Lvl_1);
Levels.Enter (Levels.Lvl_3);
Lvl := Levels.Lvl_3;
Player.Move ((320 - 4, 183));
when Levels.Lvl_2 =>
Levels.Leave (Levels.Lvl_2);
Levels.Enter (Levels.Lvl_1);
Lvl := Levels.Lvl_1;
Player.Move ((320 - 4, 120));
when Levels.Lvl_3 =>
Levels.Leave (Levels.Lvl_3);
Levels.Enter (Levels.Lvl_2);
Lvl := Levels.Lvl_2;
Player.Move ((320 - 4, 25));
end case;
end if;
Keyboard.Update;
if Keyboard.Pressed (Keyboard.Up) then
Player.Jump;
end if;
if Keyboard.Pressed (Keyboard.Left) then
Player.Move_Left;
end if;
if Keyboard.Pressed (Keyboard.Right) then
Player.Move_Right;
end if;
if Keyboard.Pressed (Keyboard.Esc) then
Render.Kill;
return;
end if;
Player.Update;
Frame_Counter := Frame_Counter + 1;
if Next_FPS_Update <= RT.Clock then
Next_FPS_Update := RT.Clock + RT.Seconds (1);
Text.Clear;
Text.Cursor (1, 1);
Text.Put ("FPS:" & Frame_Counter'Img);
Frame_Counter := 0;
end if;
Render.Render_Dirty (Render.Dark_Cyan);
delay until Next_Release;
Next_Release := RT.Clock + Period;
end loop;
end Game_Loop;
begin
Levels.Enter (Levels.Lvl_1);
Player.Move ((3, 142));
Text.Move ((0, 0));
GESTE.Add (Text'Access, 10);
Render.Render_All (Render.Dark_Cyan);
end Game;
|
reznikmm/matreshka | Ada | 4,048 | 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.
------------------------------------------------------------------------------
package AMF.Internals.Tables.Primitive_Types_Metamodel.Links is
procedure Initialize;
private
procedure Initialize_1;
procedure Initialize_2;
procedure Initialize_3;
procedure Initialize_4;
procedure Initialize_5;
procedure Initialize_6;
procedure Initialize_7;
procedure Initialize_8;
procedure Initialize_9;
procedure Initialize_10;
procedure Initialize_11;
procedure Initialize_12;
procedure Initialize_13;
procedure Initialize_14;
procedure Initialize_15;
end AMF.Internals.Tables.Primitive_Types_Metamodel.Links;
|
gspu/synth | Ada | 55,291 | adb | -- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
with Ada.Numerics.Discrete_Random;
with GNAT.String_Split;
with PortScan.Buildcycle.Pkgsrc;
with PortScan.Buildcycle.Ports;
with Replicant.Platform;
with Signals;
with Unix;
package body PortScan.Ops is
package GSS renames GNAT.String_Split;
package CYC renames PortScan.Buildcycle;
package FPC renames PortScan.Buildcycle.Ports;
package NPS renames PortScan.Buildcycle.Pkgsrc;
package REP renames Replicant;
package SIG renames Signals;
--------------------------
-- initialize_display --
--------------------------
procedure initialize_display (num_builders : builders) is
begin
if PM.configuration.avec_ncurses then
curses_support := DPY.launch_monitor (num_builders);
end if;
end initialize_display;
-------------------------
-- parallel_bulk_run --
-------------------------
procedure parallel_bulk_run (num_builders : builders; logs : dim_handlers)
is
subtype cycle_count is Natural range 1 .. 9;
subtype refresh_count is Natural range 1 .. 4;
subtype www_count is Natural range 1 .. 3;
subtype alert_count is Natural range 1 .. 200;
instructions : dim_instruction := (others => port_match_failed);
builder_states : dim_builder_state := (others => idle);
cntcycle : cycle_count := cycle_count'First;
cntrefresh : refresh_count := refresh_count'First;
cntalert : alert_count := alert_count'First;
cntwww : www_count := www_count'First;
run_complete : Boolean := False;
available : Positive := Integer (num_builders);
target : port_id;
all_idle : Boolean;
cntskip : Natural;
sumdata : DPY.summary_rec;
task type build (builder : builders);
task body build
is
type Rand_Draw is range 1 .. 20;
package Rand20 is new Ada.Numerics.Discrete_Random (Rand_Draw);
seed : Rand20.Generator;
build_result : Boolean;
opts : REP.slave_options;
begin
if builder <= num_builders then
if not curses_support then
TIO.Put_Line (CYC.elapsed_now & " => [" &
JT.zeropad (Integer (builder), 2) &
"] Builder launched");
end if;
loop
exit when builder_states (builder) = shutdown;
if builder_states (builder) = tasked then
builder_states (builder) := busy;
opts.need_procfs :=
all_ports (instructions (builder)).use_procfs;
opts.need_linprocfs :=
all_ports (instructions (builder)).use_linprocfs;
REP.launch_slave (id => builder, opts => opts);
case software_framework is
when ports_collection =>
build_result :=
FPC.build_package (builder, instructions (builder));
when pkgsrc =>
if not REP.Platform.standalone_pkg8_install (builder)
then
build_result := False;
else
build_result := NPS.build_package
(builder, instructions (builder));
end if;
end case;
REP.destroy_slave (id => builder, opts => opts);
if build_result then
builder_states (builder) := done_success;
else
builder_states (builder) := done_failure;
end if;
else
-- idle or done-(failure|success), just wait a bit
delay 0.1;
end if;
end loop;
if not curses_support then
TIO.Put_Line (CYC.elapsed_now & " => [" &
JT.zeropad (Integer (builder), 2) &
"] Shutting down");
end if;
end if;
end build;
builder_01 : build (builder => 1);
builder_02 : build (builder => 2);
builder_03 : build (builder => 3);
builder_04 : build (builder => 4);
builder_05 : build (builder => 5);
builder_06 : build (builder => 6);
builder_07 : build (builder => 7);
builder_08 : build (builder => 8);
builder_09 : build (builder => 9);
builder_10 : build (builder => 10);
builder_11 : build (builder => 11);
builder_12 : build (builder => 12);
builder_13 : build (builder => 13);
builder_14 : build (builder => 14);
builder_15 : build (builder => 15);
builder_16 : build (builder => 16);
builder_17 : build (builder => 17);
builder_18 : build (builder => 18);
builder_19 : build (builder => 19);
builder_20 : build (builder => 20);
builder_21 : build (builder => 21);
builder_22 : build (builder => 22);
builder_23 : build (builder => 23);
builder_24 : build (builder => 24);
builder_25 : build (builder => 25);
builder_26 : build (builder => 26);
builder_27 : build (builder => 27);
builder_28 : build (builder => 28);
builder_29 : build (builder => 29);
builder_30 : build (builder => 30);
builder_31 : build (builder => 31);
builder_32 : build (builder => 32);
builder_33 : build (builder => 33);
builder_34 : build (builder => 34);
builder_35 : build (builder => 35);
builder_36 : build (builder => 36);
builder_37 : build (builder => 37);
builder_38 : build (builder => 38);
builder_39 : build (builder => 39);
builder_40 : build (builder => 40);
builder_41 : build (builder => 41);
builder_42 : build (builder => 42);
builder_43 : build (builder => 43);
builder_44 : build (builder => 44);
builder_45 : build (builder => 45);
builder_46 : build (builder => 46);
builder_47 : build (builder => 47);
builder_48 : build (builder => 48);
builder_49 : build (builder => 49);
builder_50 : build (builder => 50);
builder_51 : build (builder => 51);
builder_52 : build (builder => 52);
builder_53 : build (builder => 53);
builder_54 : build (builder => 54);
builder_55 : build (builder => 55);
builder_56 : build (builder => 56);
builder_57 : build (builder => 57);
builder_58 : build (builder => 58);
builder_59 : build (builder => 59);
builder_60 : build (builder => 60);
builder_61 : build (builder => 61);
builder_62 : build (builder => 62);
builder_63 : build (builder => 63);
builder_64 : build (builder => 64);
-- Expansion of cpu_range from 32 to 64 means 128 possible builders
builder_65 : build (builder => 65);
builder_66 : build (builder => 66);
builder_67 : build (builder => 67);
builder_68 : build (builder => 68);
builder_69 : build (builder => 69);
builder_70 : build (builder => 70);
builder_71 : build (builder => 71);
builder_72 : build (builder => 72);
builder_73 : build (builder => 73);
builder_74 : build (builder => 74);
builder_75 : build (builder => 75);
builder_76 : build (builder => 76);
builder_77 : build (builder => 77);
builder_78 : build (builder => 78);
builder_79 : build (builder => 79);
builder_80 : build (builder => 80);
builder_81 : build (builder => 81);
builder_82 : build (builder => 82);
builder_83 : build (builder => 83);
builder_84 : build (builder => 84);
builder_85 : build (builder => 85);
builder_86 : build (builder => 86);
builder_87 : build (builder => 87);
builder_88 : build (builder => 88);
builder_89 : build (builder => 89);
builder_90 : build (builder => 90);
builder_91 : build (builder => 91);
builder_92 : build (builder => 92);
builder_93 : build (builder => 93);
builder_94 : build (builder => 94);
builder_95 : build (builder => 95);
builder_96 : build (builder => 96);
builder_97 : build (builder => 97);
builder_98 : build (builder => 98);
builder_99 : build (builder => 99);
builder_100 : build (builder => 100);
builder_101 : build (builder => 101);
builder_102 : build (builder => 102);
builder_103 : build (builder => 103);
builder_104 : build (builder => 104);
builder_105 : build (builder => 105);
builder_106 : build (builder => 106);
builder_107 : build (builder => 107);
builder_108 : build (builder => 108);
builder_109 : build (builder => 109);
builder_110 : build (builder => 110);
builder_111 : build (builder => 111);
builder_112 : build (builder => 112);
builder_113 : build (builder => 113);
builder_114 : build (builder => 114);
builder_115 : build (builder => 115);
builder_116 : build (builder => 116);
builder_117 : build (builder => 117);
builder_118 : build (builder => 118);
builder_119 : build (builder => 119);
builder_120 : build (builder => 120);
builder_121 : build (builder => 121);
builder_122 : build (builder => 122);
builder_123 : build (builder => 123);
builder_124 : build (builder => 124);
builder_125 : build (builder => 125);
builder_126 : build (builder => 126);
builder_127 : build (builder => 127);
builder_128 : build (builder => 128);
begin
loop
all_idle := True;
for slave in 1 .. num_builders loop
declare
begin
case builder_states (slave) is
when busy | tasked =>
all_idle := False;
when shutdown =>
null;
when idle =>
if run_complete then
builder_states (slave) := shutdown;
else
target := top_buildable_port;
if target = port_match_failed then
if SIG.graceful_shutdown_requested or else
nothing_left (num_builders)
then
run_complete := True;
builder_states (slave) := shutdown;
DPY.insert_history (assemble_HR (slave, 0,
DPY.action_shutdown));
else
if shutdown_recommended (available) then
builder_states (slave) := shutdown;
DPY.insert_history (assemble_HR (slave, 0,
DPY.action_shutdown));
available := available - 1;
end if;
end if;
else
lock_package (target);
instructions (slave) := target;
builder_states (slave) := tasked;
TIO.Put_Line (logs (total), CYC.elapsed_now & " [" &
JT.zeropad (Integer (slave), 2) & "] => " &
port_name (instructions (slave)));
if not curses_support then
TIO.Put_Line (CYC.elapsed_now & " => [" &
JT.zeropad (Integer (slave), 2) &
"] Kickoff " &
port_name (instructions (slave)));
end if;
end if;
end if;
when done_success | done_failure =>
all_idle := False;
if builder_states (slave) = done_success then
if curses_support then
DPY.insert_history
(assemble_HR (slave, instructions (slave),
DPY.action_success));
else
TIO.Put_Line (CYC.elapsed_now & " => [" &
JT.zeropad (Integer (slave), 2) &
"] " & CYC.elapsed_build (slave) &
" Success " &
port_name (instructions (slave)));
end if;
record_history_built (elapsed => CYC.elapsed_now,
slave_id => slave,
origin => port_name (instructions (slave)),
duration => CYC.elapsed_build (slave));
run_package_hook (pkg_success, instructions (slave));
cascade_successful_build (instructions (slave));
bld_counter (success) := bld_counter (success) + 1;
TIO.Put_Line (logs (success), CYC.elapsed_now & " " &
port_name (instructions (slave)));
TIO.Put_Line (logs (total), CYC.elapsed_now & " " &
port_name (instructions (slave)) &
" success");
else
TIO.Put_Line (logs (total), CYC.elapsed_now & " " &
port_name (instructions (slave)) &
" FAILED!");
cascade_failed_build (instructions (slave), cntskip, logs);
bld_counter (skipped) := bld_counter (skipped) + cntskip;
bld_counter (failure) := bld_counter (failure) + 1;
TIO.Put_Line (logs (total), CYC.elapsed_now & " " &
port_name (instructions (slave)) &
" failure skips:" & JT.int2str (cntskip));
TIO.Put_Line (logs (failure), CYC.elapsed_now & " " &
port_name (instructions (slave)) &
" (skipped" & cntskip'Img & ")");
if curses_support then
DPY.insert_history
(assemble_HR (slave, instructions (slave),
DPY.action_failure));
else
TIO.Put_Line (CYC.elapsed_now & " => [" &
JT.zeropad (Integer (slave), 2) &
"] " & CYC.elapsed_build (slave) &
" Failure " &
port_name (instructions (slave)));
end if;
case software_framework is
when ports_collection =>
record_history_failed
(elapsed => CYC.elapsed_now,
slave_id => slave,
origin => port_name (instructions (slave)),
duration => CYC.elapsed_build (slave),
die_phase => FPC.last_build_phase (slave),
skips => cntskip);
when pkgsrc =>
record_history_failed
(elapsed => CYC.elapsed_now,
slave_id => slave,
origin => port_name (instructions (slave)),
duration => CYC.elapsed_build (slave),
die_phase => NPS.last_build_phase (slave),
skips => cntskip);
end case;
run_package_hook (pkg_failure, instructions (slave));
end if;
instructions (slave) := port_match_failed;
if run_complete then
builder_states (slave) := shutdown;
DPY.insert_history (assemble_HR (slave, 0,
DPY.action_shutdown));
else
builder_states (slave) := idle;
end if;
end case;
exception
when earthquake : others => TIO.Put_Line
(logs (total), CYC.elapsed_now & " UNHANDLED EXCEPTION: " &
EX.Exception_Information (earthquake));
end;
end loop;
exit when run_complete and all_idle;
if cntcycle = cycle_count'Last then
cntcycle := cycle_count'First;
TIO.Flush (logs (success));
TIO.Flush (logs (failure));
TIO.Flush (logs (skipped));
TIO.Flush (logs (total));
if curses_support then
if cntrefresh = refresh_count'Last then
cntrefresh := refresh_count'First;
DPY.set_full_redraw_next_update;
else
cntrefresh := cntrefresh + 1;
end if;
sumdata.Initially := bld_counter (total);
sumdata.Built := bld_counter (success);
sumdata.Failed := bld_counter (failure);
sumdata.Ignored := bld_counter (ignored);
sumdata.Skipped := bld_counter (skipped);
sumdata.elapsed := CYC.elapsed_now;
sumdata.swap := get_swap_status;
sumdata.load := REP.Platform.get_instant_load;
sumdata.pkg_hour := hourly_build_rate;
sumdata.impulse := impulse_rate;
DPY.summarize (sumdata);
for b in builders'First .. num_builders loop
case software_framework is
when ports_collection =>
if builder_states (b) = shutdown then
DPY.update_builder (FPC.builder_status (b, True, False));
elsif builder_states (b) = idle then
DPY.update_builder (FPC.builder_status (b, False, True));
else
CYC.set_log_lines (b);
DPY.update_builder (FPC.builder_status (b));
end if;
when pkgsrc =>
if builder_states (b) = shutdown then
DPY.update_builder (NPS.builder_status (b, True, False));
elsif builder_states (b) = idle then
DPY.update_builder (NPS.builder_status (b, False, True));
else
CYC.set_log_lines (b);
DPY.update_builder (NPS.builder_status (b));
end if;
end case;
end loop;
DPY.refresh_builder_window;
DPY.refresh_history_window;
else
-- text mode support, periodic status reports
if cntalert = alert_count'Last then
cntalert := alert_count'First;
declare
Remaining : constant Integer := bld_counter (total) -
bld_counter (success) - bld_counter (failure) -
bld_counter (ignored) - bld_counter (skipped);
begin
TIO.Put_Line (CYC.elapsed_now & " => " &
" Left:" & Remaining'Img &
" Succ:" & bld_counter (success)'Img &
" Fail:" & bld_counter (failure)'Img &
" Skip:" & bld_counter (skipped)'Img &
" Ign:" & bld_counter (ignored)'Img);
end;
else
cntalert := cntalert + 1;
end if;
-- Update log lines every 4 seconds for the watchdog
if cntrefresh = refresh_count'Last then
cntrefresh := refresh_count'First;
for b in builders'First .. num_builders loop
if builder_states (b) /= shutdown and then
builder_states (b) /= idle
then
CYC.set_log_lines (b);
end if;
end loop;
else
cntrefresh := cntrefresh + 1;
end if;
end if;
-- Generate latest history file every 3 seconds.
-- With a poll period of 6 seconds, we need twice that frequency to avoid aliasing
-- Note that in text mode, the logs are updated every 4 seconds, so in this mode
-- the log lines will often be identical for a cycle.
if cntwww = www_count'Last then
cntwww := www_count'First;
write_history_json;
write_summary_json (active => True,
states => builder_states,
num_builders => num_builders,
num_history_files => history.segment);
else
cntwww := cntwww + 1;
end if;
else
cntcycle := cntcycle + 1;
end if;
delay 0.10;
end loop;
if PM.configuration.avec_ncurses and then curses_support
then
DPY.terminate_monitor;
end if;
write_history_json;
write_summary_json (active => False,
states => builder_states,
num_builders => num_builders,
num_history_files => history.segment);
run_hook (run_end, "PORTS_BUILT=" & JT.int2str (bld_counter (success)) &
" PORTS_FAILED=" & JT.int2str (bld_counter (failure)) &
" PORTS_IGNORED=" & JT.int2str (bld_counter (ignored)) &
" PORTS_SKIPPED=" & JT.int2str (bld_counter (skipped)));
end parallel_bulk_run;
--------------------
-- lock_package --
--------------------
procedure lock_package (id : port_id) is
begin
if id /= port_match_failed then
all_ports (id).work_locked := True;
end if;
end lock_package;
----------------------------
-- cascade_failed_build --
----------------------------
procedure cascade_failed_build (id : port_id; numskipped : out Natural;
logs : dim_handlers)
is
purged : PortScan.port_id;
culprit : constant String := port_name (id);
begin
numskipped := 0;
loop
purged := skip_next_reverse_dependency (id);
exit when purged = port_match_failed;
if skip_verified (purged) then
numskipped := numskipped + 1;
TIO.Put_Line (logs (total), " Skipped: " &
port_name (purged));
TIO.Put_Line (logs (skipped),
port_name (purged) & " by " & culprit);
DPY.insert_history (assemble_HR (1, purged, DPY.action_skipped));
record_history_skipped (elapsed => CYC.elapsed_now,
origin => port_name (purged),
reason => culprit);
run_package_hook (pkg_skipped, purged);
end if;
end loop;
unlist_port (id);
end cascade_failed_build;
--------------------------------
-- cascade_successful_build --
--------------------------------
procedure cascade_successful_build (id : port_id)
is
procedure cycle (cursor : block_crate.Cursor);
procedure cycle (cursor : block_crate.Cursor)
is
target : constant port_index := block_crate.Element (cursor);
begin
if all_ports (target).blocked_by.Contains (Key => id) then
all_ports (target).blocked_by.Delete (Key => id);
else
raise seek_failure
with port_name (target) & " was expected to be blocked by " &
port_name (id);
end if;
end cycle;
begin
all_ports (id).blocks.Iterate (cycle'Access);
delete_rank (id);
end cascade_successful_build;
--------------------------
-- top_buildable_port --
--------------------------
function top_buildable_port return port_id
is
list_len : constant Integer := Integer (rank_queue.Length);
cursor : ranking_crate.Cursor;
QR : queue_record;
result : port_id := port_match_failed;
begin
if list_len = 0 then
return result;
end if;
cursor := rank_queue.First;
for k in 1 .. list_len loop
QR := ranking_crate.Element (Position => cursor);
if not all_ports (QR.ap_index).work_locked and then
all_ports (QR.ap_index).blocked_by.Is_Empty
then
result := QR.ap_index;
exit;
end if;
cursor := ranking_crate.Next (Position => cursor);
end loop;
if SIG.graceful_shutdown_requested then
return port_match_failed;
end if;
return result;
end top_buildable_port;
----------------------------
-- shutdown_recommended --
----------------------------
function shutdown_recommended (active_builders : Positive) return Boolean
is
list_len : constant Natural := Integer (rank_queue.Length);
list_max : constant Positive := 2 * active_builders;
num_wait : Natural := 0;
cursor : ranking_crate.Cursor;
QR : queue_record;
begin
if list_len = 0 or else list_len >= list_max then
return False;
end if;
cursor := rank_queue.First;
for k in 1 .. list_len loop
QR := ranking_crate.Element (Position => cursor);
if not all_ports (QR.ap_index).work_locked then
num_wait := num_wait + 1;
if num_wait >= active_builders then
return False;
end if;
end if;
cursor := ranking_crate.Next (Position => cursor);
end loop;
return True;
end shutdown_recommended;
--------------------
-- nothing_left --
--------------------
function nothing_left (num_builders : builders) return Boolean
is
list_len : constant Integer := Integer (rank_queue.Length);
begin
return list_len = 0;
end nothing_left;
------------------
-- rank_arrow --
------------------
function rank_arrow (id : port_id) return ranking_crate.Cursor
is
rscore : constant port_index := all_ports (id).reverse_score;
seek_target : constant queue_record := (ap_index => id,
reverse_score => rscore);
begin
return rank_queue.Find (seek_target);
end rank_arrow;
-------------------
-- delete_rank --
-------------------
procedure delete_rank (id : port_id)
is
rank_cursor : ranking_crate.Cursor := rank_arrow (id);
use type ranking_crate.Cursor;
begin
if rank_cursor /= ranking_crate.No_Element then
rank_queue.Delete (Position => rank_cursor);
end if;
end delete_rank;
--------------------
-- still_ranked --
--------------------
function still_ranked (id : port_id) return Boolean
is
rank_cursor : ranking_crate.Cursor := rank_arrow (id);
use type ranking_crate.Cursor;
begin
return rank_cursor /= ranking_crate.No_Element;
end still_ranked;
------------------------
-- integrity_intact --
------------------------
function integrity_intact return Boolean
is
procedure check_dep (cursor : block_crate.Cursor);
procedure check_rank (cursor : ranking_crate.Cursor);
intact : Boolean := True;
procedure check_dep (cursor : block_crate.Cursor)
is
did : constant port_index := block_crate.Element (cursor);
begin
if not still_ranked (did) then
intact := False;
end if;
end check_dep;
procedure check_rank (cursor : ranking_crate.Cursor)
is
QR : constant queue_record := ranking_crate.Element (cursor);
begin
if intact then
all_ports (QR.ap_index).blocked_by.Iterate (check_dep'Access);
end if;
end check_rank;
begin
rank_queue.Iterate (check_rank'Access);
return intact;
end integrity_intact;
---------------------
-- skip_verified --
---------------------
function skip_verified (id : port_id) return Boolean is
begin
if id = port_match_failed then
return False;
end if;
return not all_ports (id).unlist_failed;
end skip_verified;
--------------------
-- queue_length --
--------------------
function queue_length return Integer is
begin
return Integer (rank_queue.Length);
end queue_length;
-------------------
-- unlist_port --
-------------------
procedure unlist_port (id : port_id) is
begin
if id = port_match_failed then
return;
end if;
if still_ranked (id) then
delete_rank (id);
else
-- don't raise exception. Since we don't prune all_reverse as
-- we go, there's no guarantee the reverse dependency hasn't already
-- been removed (e.g. when it is a common reverse dep)
all_ports (id).unlist_failed := True;
end if;
end unlist_port;
------------------------------------
-- skip_next_reverse_dependency --
------------------------------------
function skip_next_reverse_dependency (pinnacle : port_id) return port_id
is
rev_cursor : block_crate.Cursor;
next_dep : port_index;
begin
if all_ports (pinnacle).all_reverse.Is_Empty then
return port_match_failed;
end if;
rev_cursor := all_ports (pinnacle).all_reverse.First;
next_dep := block_crate.Element (rev_cursor);
unlist_port (id => next_dep);
all_ports (pinnacle).all_reverse.Delete (rev_cursor);
return next_dep;
end skip_next_reverse_dependency;
---------------------
-- ignore_reason --
---------------------
function ignore_reason (id : port_id) return String is
begin
if id = port_match_failed or else
id > last_port
then
return "Invalid port ID";
end if;
return JT.USS (all_ports (id).ignore_reason);
end ignore_reason;
-------------------------
-- next_ignored_port --
-------------------------
function next_ignored_port return port_id
is
list_len : constant Integer := Integer (rank_queue.Length);
cursor : ranking_crate.Cursor;
QR : queue_record;
result : port_id := port_match_failed;
begin
if list_len = 0 then
return result;
end if;
cursor := rank_queue.First;
for k in 1 .. list_len loop
QR := ranking_crate.Element (Position => cursor);
if all_ports (QR.ap_index).ignored then
result := QR.ap_index;
DPY.insert_history (assemble_HR (1, QR.ap_index,
DPY.action_ignored));
run_package_hook (pkg_ignored, QR.ap_index);
exit;
end if;
cursor := ranking_crate.Next (Position => cursor);
end loop;
return result;
end next_ignored_port;
-----------------
-- port_name --
-----------------
function port_name (id : port_id) return String is
begin
if id = port_match_failed or else
id > last_port
then
return "Invalid port ID";
end if;
return get_catport (all_ports (id));
end port_name;
-----------------------
-- get_swap_status --
-----------------------
function get_swap_status return Float
is
type memtype is mod 2**64;
command : String := REP.Platform.swapinfo_command;
status : Integer;
comres : JT.Text;
blocks_total : memtype := 0;
blocks_used : memtype := 0;
begin
comres := Unix.piped_command (command, status);
if status /= 0 then
return 200.0; -- [ERROR] Signal to set swap display to "N/A"
end if;
-- Throw first line away, e.g "Device 1K-blocks Used Avail ..."
-- Distinguishes platforms though:
-- Net/Free/Dragon start with "Device"
-- Linux starts with "NAME"
-- Solaris starts with "swapfile"
-- On FreeBSD (DragonFly too?), when multiple swap used, ignore line starting "Total"
declare
command_result : String := JT.USS (comres);
markers : JT.Line_Markers;
line_present : Boolean;
begin
JT.initialize_markers (command_result, markers);
-- Throw first line away (valid for all platforms
line_present := JT.next_line_present (command_result, markers);
if line_present then
declare
line : String := JT.extract_line (command_result, markers);
begin
null;
end;
else
return 200.0; -- [ERROR] Signal to set swap display to "N/A"
end if;
loop
exit when not JT.next_line_present (command_result, markers);
declare
line : constant String :=
JT.strip_excessive_spaces (JT.extract_line (command_result, markers));
begin
if JT.specific_field (line, 1) /= "Total" then
blocks_total := blocks_total + memtype'Value (JT.specific_field (line, 2));
blocks_used := blocks_used + memtype'Value (JT.specific_field (line, 3));
end if;
exception
when Constraint_Error =>
return 200.0; -- [ERROR] Signal to set swap display to "N/A"
end;
end loop;
end;
if blocks_total = 0 then
return 200.0; -- Signal to set swap display to "N/A"
else
return 100.0 * Float (blocks_used) / Float (blocks_total);
end if;
end get_swap_status;
-------------------------
-- hourly_build_rate --
-------------------------
function hourly_build_rate return Natural
is
pkg_that_count : constant Natural := bld_counter (success) +
bld_counter (failure);
begin
return CYC.get_packages_per_hour (pkg_that_count, start_time);
end hourly_build_rate;
--------------------
-- impulse_rate --
--------------------
function impulse_rate return Natural
is
pkg_that_count : constant Natural := bld_counter (success) +
bld_counter (failure);
pkg_diff : Natural;
result : Natural;
begin
if impulse_counter = impulse_range'Last then
impulse_counter := impulse_range'First;
else
impulse_counter := impulse_counter + 1;
end if;
if impulse_data (impulse_counter).virgin then
impulse_data (impulse_counter).hack := CAL.Clock;
impulse_data (impulse_counter).packages := pkg_that_count;
impulse_data (impulse_counter).virgin := False;
return CYC.get_packages_per_hour (pkg_that_count, start_time);
end if;
pkg_diff := pkg_that_count - impulse_data (impulse_counter).packages;
result := CYC.get_packages_per_hour
(packages_done => pkg_diff,
from_when => impulse_data (impulse_counter).hack);
impulse_data (impulse_counter).hack := CAL.Clock;
impulse_data (impulse_counter).packages := pkg_that_count;
return result;
exception
when others => return 0;
end impulse_rate;
-------------------
-- assemble_HR --
-------------------
function assemble_HR (slave : builders; pid : port_id;
action : DPY.history_action)
return DPY.history_rec
is
HR : DPY.history_rec;
HOLast : constant Natural := DPY.history_origin'Last;
catport : String := port_name (pid);
hyphens : constant DPY.history_elapsed := "--:--:--";
begin
HR.id := slave;
HR.slavid := JT.zeropad (Integer (slave), 2);
HR.established := True;
HR.action := action;
HR.origin := (others => ' ');
HR.run_elapsed := CYC.elapsed_now;
if action = DPY.action_shutdown then
HR.pkg_elapsed := hyphens;
else
if action = DPY.action_skipped or else
action = DPY.action_ignored
then
HR.pkg_elapsed := hyphens;
else
HR.pkg_elapsed := CYC.elapsed_build (slave);
end if;
if catport'Last > HOLast then
HR.origin (1 .. HOLast - 1) := catport (1 .. HOLast - 1);
HR.origin (HOLast) := LAT.Asterisk;
else
HR.origin (1 .. catport'Last) := catport;
end if;
end if;
return HR;
end assemble_HR;
------------------------
-- initialize_hooks --
------------------------
procedure initialize_hooks is
begin
for hook in hook_type'Range loop
declare
script : constant String := JT.USS (hook_location (hook));
begin
active_hook (hook) := AD.Exists (script) and then
REP.Platform.file_is_executable (script);
end;
end loop;
end initialize_hooks;
----------------------
-- run_start_hook --
----------------------
procedure run_start_hook is
begin
run_hook (run_start, "PORTS_QUEUED=" & JT.int2str (queue_length) & " ");
end run_start_hook;
----------------
-- run_hook --
----------------
procedure run_hook (hook : hook_type; envvar_list : String)
is
function nvpair (name : String; value : JT.Text) return String;
function nvpair (name : String; value : JT.Text) return String is
begin
return name & LAT.Equals_Sign & LAT.Quotation &
JT.USS (value) & LAT.Quotation & LAT.Space;
end nvpair;
common_env : constant String :=
nvpair ("PROFILE", PM.configuration.profile) &
nvpair ("DIR_PACKAGES", PM.configuration.dir_packages) &
nvpair ("DIR_REPOSITORY", PM.configuration.dir_repository) &
nvpair ("DIR_PORTS", PM.configuration.dir_portsdir) &
nvpair ("DIR_OPTIONS", PM.configuration.dir_options) &
nvpair ("DIR_DISTFILES", PM.configuration.dir_distfiles) &
nvpair ("DIR_LOGS", PM.configuration.dir_logs) &
nvpair ("DIR_BUILDBASE", PM.configuration.dir_buildbase);
-- The follow command works on every platform
command : constant String := "/usr/bin/env -i " & common_env &
envvar_list & " " & JT.USS (hook_location (hook));
begin
if not active_hook (hook) then
return;
end if;
if Unix.external_command (command) then
null;
end if;
end run_hook;
------------------------
-- run_package_hook --
------------------------
procedure run_package_hook (hook : hook_type; id : port_id)
is
pn : constant String := port_name (id);
tail : String := " ORIGIN=" & JT.part_1 (pn, "@") &
" FLAVOR=" & JT.part_2 (pn, "@") &
" PKGNAME=" & package_name (id) & " ";
begin
case hook is
when pkg_success => run_hook (hook, "RESULT=success" & tail);
when pkg_failure => run_hook (hook, "RESULT=failure" & tail);
when pkg_ignored => run_hook (hook, "RESULT=ignored" & tail);
when pkg_skipped => run_hook (hook, "RESULT=skipped" & tail);
when others => null;
end case;
end run_package_hook;
----------------------------
-- run_hook_after_build --
----------------------------
procedure run_hook_after_build (built : Boolean; id : port_id) is
begin
if built then
run_package_hook (pkg_success, id);
else
run_package_hook (pkg_failure, id);
end if;
end run_hook_after_build;
--------------------
-- package_name --
--------------------
function package_name (id : port_id) return String is
begin
if id = port_match_failed or else
id > last_port
then
return "Invalid port ID";
end if;
declare
fullname : constant String := JT.USS (all_ports (id).package_name);
begin
return fullname (1 .. fullname'Length - 4);
end;
end package_name;
-----------------------------
-- initialize_web_report --
-----------------------------
procedure initialize_web_report (num_builders : builders) is
idle_slaves : constant dim_builder_state := (others => idle);
reportdir : constant String := JT.USS (PM.configuration.dir_logs) & "/Report";
sharedir : constant String := host_localbase & "/share/synth";
begin
AD.Create_Path (reportdir);
AD.Copy_File (sharedir & "/synth.png", reportdir & "/synth.png");
AD.Copy_File (sharedir & "/favicon.png", reportdir & "/favicon.png");
AD.Copy_File (sharedir & "/progress.js", reportdir & "/progress.js");
AD.Copy_File (sharedir & "/progress.css", reportdir & "/progress.css");
AD.Copy_File (sharedir & "/progress.html", reportdir & "/index.html");
write_summary_json (active => True,
states => idle_slaves,
num_builders => num_builders,
num_history_files => 0);
end initialize_web_report;
-----------------------------------------
-- delete_existing_web_history_files --
-----------------------------------------
procedure delete_existing_web_history_files
is
search : AD.Search_Type;
dirent : AD.Directory_Entry_Type;
pattern : constant String := "*_history.json";
filter : constant AD.Filter_Type := (AD.Ordinary_File => True, others => False);
reportdir : constant String := JT.USS (PM.configuration.dir_logs) & "/Report";
begin
if not AD.Exists (reportdir) then
return;
end if;
AD.Start_Search (Search => search,
Directory => reportdir,
Pattern => pattern,
Filter => filter);
while AD.More_Entries (search) loop
AD.Get_Next_Entry (search, dirent);
AD.Delete_File (reportdir & "/" & AD.Simple_Name (dirent));
end loop;
exception
when AD.Name_Error => null;
end delete_existing_web_history_files;
-----------------------
-- nv (2 versions) --
-----------------------
function nv (name, value : String) return String is
begin
return ASCII.Quotation & name & ASCII.Quotation & ASCII.Colon &
ASCII.Quotation & value & ASCII.Quotation;
end nv;
function nv (name : String; value : Integer) return String is
begin
return ASCII.Quotation & name & ASCII.Quotation & ASCII.Colon & JT.int2str (value);
end nv;
--------------------------
-- write_summary_json --
--------------------------
procedure write_summary_json
(active : Boolean;
states : dim_builder_state;
num_builders : builders;
num_history_files : Natural)
is
function TF (value : Boolean) return Natural;
function TF (value : Boolean) return Natural is
begin
if value then
return 1;
else
return 0;
end if;
end TF;
jsonfile : TIO.File_Type;
filename : constant String := JT.USS (PM.configuration.dir_logs) & "/Report/summary.json";
leftover : constant Integer := bld_counter (total) - bld_counter (success) -
bld_counter (failure) - bld_counter (ignored) - bld_counter (skipped);
slave : DPY.builder_rec;
begin
-- Try to defend malicious symlink: https://en.wikipedia.org/wiki/Symlink_race
if AD.Exists (filename) then
AD.Delete_File (filename);
end if;
TIO.Create (File => jsonfile,
Mode => TIO.Out_File,
Name => filename);
TIO.Put (jsonfile, "{" & ASCII.LF &
" " & nv ("profile", JT.USS (PM.configuration.profile)) & ASCII.LF);
TIO.Put
(jsonfile,
" ," & nv ("kickoff", timestamp (start_time, True)) & ASCII.LF &
" ," & nv ("kfiles", num_history_files) & ASCII.LF &
" ," & nv ("active", TF (active)) & ASCII.LF &
" ," & ASCII.Quotation & "stats" & ASCII.Quotation & ASCII.Colon & "{" & ASCII.LF);
TIO.Put
(jsonfile,
" " & nv ("queued", bld_counter (total)) & ASCII.LF &
" ," & nv ("built", bld_counter (success)) & ASCII.LF &
" ," & nv ("failed", bld_counter (failure)) & ASCII.LF &
" ," & nv ("ignored", bld_counter (ignored)) & ASCII.LF &
" ," & nv ("skipped", bld_counter (skipped)) & ASCII.LF &
" ," & nv ("remains", leftover) & ASCII.LF &
" ," & nv ("elapsed", CYC.elapsed_now) & ASCII.LF &
" ," & nv ("pkghour", hourly_build_rate) & ASCII.LF &
" ," & nv ("impulse", impulse_rate) & ASCII.LF &
" ," & nv ("swapinfo", DPY.fmtpc (get_swap_status, True)) & ASCII.LF &
" ," & nv ("load", DPY.fmtload (REP.Platform.get_instant_load)) & ASCII.LF &
" }" & ASCII.LF &
" ," & ASCII.Quotation & "builders" & ASCII.Quotation & ASCII.Colon & "[" & ASCII.LF);
for b in builders'First .. num_builders loop
case software_framework is
when ports_collection =>
if states (b) = shutdown then
slave := FPC.builder_status (b, True, False);
elsif states (b) = idle then
slave := FPC.builder_status (b, False, True);
else
slave := FPC.builder_status (b);
end if;
when pkgsrc =>
if states (b) = shutdown then
slave := NPS.builder_status (b, True, False);
elsif states (b) = idle then
slave := NPS.builder_status (b, False, True);
else
slave := NPS.builder_status (b);
end if;
end case;
if b = builders'First then
TIO.Put (jsonfile, " {" & ASCII.LF);
else
TIO.Put (jsonfile, " ,{" & ASCII.LF);
end if;
TIO.Put
(jsonfile,
" " & nv ("ID", slave.slavid) & ASCII.LF &
" ," & nv ("elapsed", JT.trim (slave.Elapsed)) & ASCII.LF &
" ," & nv ("phase", JT.trim (slave.phase)) & ASCII.LF &
" ," & nv ("origin", JT.trim (slave.origin)) & ASCII.LF &
" ," & nv ("lines", JT.trim (slave.LLines)) & ASCII.LF &
" }" & ASCII.LF);
end loop;
TIO.Put (jsonfile, " ]" & ASCII.LF & "}" & ASCII.LF);
TIO.Close (jsonfile);
exception
when others =>
if TIO.Is_Open (jsonfile) then
TIO.Close (jsonfile);
end if;
end write_summary_json;
----------------------------
-- write_history_json --
----------------------------
procedure write_history_json
is
jsonfile : TIO.File_Type;
filename : constant String := JT.USS (PM.configuration.dir_logs) &
"/Report/" & JT.zeropad (history.segment, 2) & "_history.json";
begin
if history.segment_count = 0 then
return;
end if;
if history.last_written = history.last_index then
return;
end if;
TIO.Create (File => jsonfile,
Mode => TIO.Out_File,
Name => filename);
TIO.Put (jsonfile, history.content (1 .. history.last_index));
TIO.Put (jsonfile, "]");
TIO.Close (jsonfile);
history.last_written := history.last_index;
exception
when others =>
if TIO.Is_Open (jsonfile) then
TIO.Close (jsonfile);
end if;
end write_history_json;
----------------------------
-- assimulate_substring --
----------------------------
procedure assimulate_substring
(history : in out progress_history;
substring : String)
is
first : constant Positive := history.last_index + 1;
last : constant Positive := history.last_index + substring'Length;
begin
-- silently fail (this shouldn't be practically possible)
if last < kfile_content'Last then
history.content (first .. last) := substring;
end if;
history.last_index := last;
end assimulate_substring;
----------------------------
-- record_history_built --
----------------------------
procedure handle_first_history_entry is
begin
if history.segment_count = 1 then
assimulate_substring (history, "[" & ASCII.LF & " {" & ASCII.LF);
else
assimulate_substring (history, " ,{" & ASCII.LF);
end if;
end handle_first_history_entry;
----------------------------
-- record_history_built --
----------------------------
procedure record_history_built
(elapsed : String;
slave_id : builders;
origin : String;
duration : String)
is
ID : constant String := JT.zeropad (Integer (slave_id), 2);
begin
history.log_entry := history.log_entry + 1;
history.segment_count := history.segment_count + 1;
handle_first_history_entry;
assimulate_substring (history, " " & nv ("entry", history.log_entry) & ASCII.LF);
assimulate_substring (history, " ," & nv ("elapsed", elapsed) & ASCII.LF);
assimulate_substring (history, " ," & nv ("ID", ID) & ASCII.LF);
assimulate_substring (history, " ," & nv ("result", "built") & ASCII.LF);
assimulate_substring (history, " ," & nv ("origin", origin) & ASCII.LF);
assimulate_substring (history, " ," & nv ("info", "") & ASCII.LF);
assimulate_substring (history, " ," & nv ("duration", duration) & ASCII.LF);
assimulate_substring (history, " }" & ASCII.LF);
check_history_segment_capacity;
end record_history_built;
-----------------------------
-- record_history_failed --
-----------------------------
procedure record_history_failed
(elapsed : String;
slave_id : builders;
origin : String;
duration : String;
die_phase : String;
skips : Natural)
is
info : constant String := die_phase & ":" & JT.int2str (skips);
ID : constant String := JT.zeropad (Integer (slave_id), 2);
begin
history.log_entry := history.log_entry + 1;
history.segment_count := history.segment_count + 1;
handle_first_history_entry;
assimulate_substring (history, " " & nv ("entry", history.log_entry) & ASCII.LF);
assimulate_substring (history, " ," & nv ("elapsed", elapsed) & ASCII.LF);
assimulate_substring (history, " ," & nv ("ID", ID) & ASCII.LF);
assimulate_substring (history, " ," & nv ("result", "failed") & ASCII.LF);
assimulate_substring (history, " ," & nv ("origin", origin) & ASCII.LF);
assimulate_substring (history, " ," & nv ("info", info) & ASCII.LF);
assimulate_substring (history, " ," & nv ("duration", duration) & ASCII.LF);
assimulate_substring (history, " }" & ASCII.LF);
check_history_segment_capacity;
end record_history_failed;
------------------------------
-- record_history_ignored --
------------------------------
procedure record_history_ignored
(elapsed : String;
origin : String;
reason : String;
skips : Natural)
is
cleantxt : constant String := JT.strip_control (reason);
info : constant String :=
JT.replace_char
(JT.replace_char (cleantxt, ASCII.Quotation, " "), ASCII.Back_Slash, "\")
& ":|:" & JT.int2str (skips);
begin
history.log_entry := history.log_entry + 1;
history.segment_count := history.segment_count + 1;
handle_first_history_entry;
assimulate_substring (history, " " & nv ("entry", history.log_entry) & ASCII.LF);
assimulate_substring (history, " ," & nv ("elapsed", elapsed) & ASCII.LF);
assimulate_substring (history, " ," & nv ("ID", "--") & ASCII.LF);
assimulate_substring (history, " ," & nv ("result", "ignored") & ASCII.LF);
assimulate_substring (history, " ," & nv ("origin", origin) & ASCII.LF);
assimulate_substring (history, " ," & nv ("info", info) & ASCII.LF);
assimulate_substring (history, " ," & nv ("duration", "--:--:--") & ASCII.LF);
assimulate_substring (history, " }" & ASCII.LF);
check_history_segment_capacity;
end record_history_ignored;
------------------------------
-- record_history_skipped --
------------------------------
procedure record_history_skipped
(elapsed : String;
origin : String;
reason : String)
is
begin
history.log_entry := history.log_entry + 1;
history.segment_count := history.segment_count + 1;
handle_first_history_entry;
assimulate_substring (history, " " & nv ("entry", history.log_entry) & ASCII.LF);
assimulate_substring (history, " ," & nv ("elapsed", elapsed) & ASCII.LF);
assimulate_substring (history, " ," & nv ("ID", "--") & ASCII.LF);
assimulate_substring (history, " ," & nv ("result", "skipped") & ASCII.LF);
assimulate_substring (history, " ," & nv ("origin", origin) & ASCII.LF);
assimulate_substring (history, " ," & nv ("info", reason) & ASCII.LF);
assimulate_substring (history, " ," & nv ("duration", "--:--:--") & ASCII.LF);
assimulate_substring (history, " }" & ASCII.LF);
check_history_segment_capacity;
end record_history_skipped;
--------------------------------------
-- check_history_segment_capacity --
--------------------------------------
procedure check_history_segment_capacity is
begin
if history.segment_count = 1 then
history.segment := history.segment + 1;
return;
end if;
if history.segment_count < kfile_units_limit then
return;
end if;
write_history_json;
history.last_index := 0;
history.last_written := 0;
history.segment_count := 0;
end check_history_segment_capacity;
end PortScan.Ops;
|
reznikmm/matreshka | Ada | 3,749 | 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_Restart_Numbering_Attributes is
pragma Preelaborate;
type ODF_Text_Restart_Numbering_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Text_Restart_Numbering_Attribute_Access is
access all ODF_Text_Restart_Numbering_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Text_Restart_Numbering_Attributes;
|
alexcamposruiz/dds-requestreply | Ada | 5,117 | ads | with DDS.DataReader_Impl;
with DDS.DataReaderListener;
with DDS.DataWriter_Impl;
with DDS.DomainParticipant;
with DDS.Publisher;
with DDS.ReadCondition;
with DDS.Subscriber;
with DDS.WaitSet;
with Dds.Topic;
with DDS.TopicDescription;
with Interfaces.C.Extensions;
with RTIDDS.Low_Level.Ndds_Reda_Reda_FastBuffer_H;
with Ada.Finalization;
with System;
with DDS.Request_Reply.Connext_C_Entity_Params; use DDS.Request_Reply.Connext_C_Entity_Params;
package DDS.Request_Reply.Untypedcommon is
use Dds;
type RTI_Connext_EntityUntypedImpl is abstract new Ada.Finalization.Limited_Controlled with record
Participant : DDS.DomainParticipant.Ref_Access;
Publisher : DDS.Publisher.Ref_Access;
Subscriber : DDS.Subscriber.Ref_Access;
Writer_Topic : DDS.Topic.Ref_Access;
Reader_Topic : DDS.TopicDescription.Ref_Access;
Writer : DDS.DataWriter_Impl.Ref_Access;
Reader : DDS.DataReader_Impl.Ref_Access;
Waitset : DDS.WaitSet.Ref_Access;
Not_Read_Sample_Cond : DDS.ReadCondition.Ref_Access;
Any_Sample_Cond : DDS.ReadCondition.Ref_Access;
Sample_Size : DDS.long := -1;
-- waitset_pool : RTIDDS.Low_Level.ndds_reda_reda_fastBuffer_h.REDAFastBufferPool;
Waitset_Pool : Interfaces.C.Extensions.Void_Ptr;
Max_Samples_Per_Read : DDS.long;
end record;
type RTI_Connext_EntityUntypedImpl_Access is access all RTI_Connext_EntityUntypedImpl'Class;
function RTI_Connext_CreateWriterTopicFunc
(Self : access RTI_Connext_EntityUntypedImpl;
Params : access RTI_Connext_EntityParams;
Name : DDS.String) return DDS.TopicDescription.Ref_Access is abstract;
function Create_Writer_Topic
(Self : access RTI_Connext_EntityUntypedImpl;
Params : access RTI_Connext_EntityParams;
Name : DDS.String) return DDS.TopicDescription.Ref_Access is abstract;
function RTI_Connext_Get_Or_Create_Topic
(Participant : DDS.DomainParticipant.Ref_Access;
Name : DDS.String;
Type_Name : DDS.String;
Allow_Cft : DDS.Boolean) return DDS.TopicDescription.Ref_Access
is (Participant.Get_Or_Create_Topic (Name, Type_Name).As_Topicdescription);
function RTI_Connext_Create_Request_Topic_Name_From_Service_Name (Service_Name : DDS.String) return DDS.String is
(DDS.To_DDS_String (DDS.To_Standard_String (Service_Name) & "Request"));
function RTI_Connext_Create_Reply_Topic_Name_From_Service_Name (Service_Name : DDS.String) return DDS.String is
(DDS.To_DDS_String (DDS.To_Standard_String (Service_Name) & "Reply"));
--
function RTI_Connext_EntityUntypedImpl_Initialize (Self : in out RTI_Connext_EntityUntypedImpl;
Params : RTI_Connext_EntityParams;
Writer_Type_Name : DDS.String;
Reader_Type_Name : DDS.String;
Sample_Size : DDS.long;
Reader_Listener : DDS.DataReaderListener.Ref_Access;
Role_Name : DDS.String) return DDS.ReturnCode_T;
function RTI_Connext_EntityUntypedImpl_Touch_Samples
(Self : not null access RTI_Connext_EntityUntypedImpl;
Max_Count : DDS.Integer;
Read_Condition : DDS.ReadCondition.Ref_Access) return Integer;
function RTI_Connext_EntityUntypedImpl_Wait_For_Any_Sample
(Self : not null access RTI_Connext_EntityUntypedImpl;
Max_Wait : DDS.Duration_T;
Min_Sample_Count : DDS.Integer) return DDS.ReturnCode_T;
function RTI_Connext_EntityUntypedImpl_Get_Sample_Loaned_W_Len
(Self : not null access RTI_Connext_EntityUntypedImpl;
Received_Data : System.Address;
Data_Count : in out DDS.Natural;
Is_Loan : in out DDS.Boolean;
DataSeqContiguousBuffer : System.Address;
Info_Seq : not null access DDS.SampleInfo_Seq.Sequence;
Data_Seq_Len : DDS.long;
Data_Seq_Max_Len : DDS.long;
Data_Seq_Has_Ownership : DDS.Boolean;
Max_Samples : DDS.long;
Read_Condition : DDS.ReadCondition.Ref_Access;
Take : DDS.Boolean) return DDS.ReturnCode_T;
function RTI_Connext_SimpleReplierParams_To_Entityparams
(Self : RTI_Connext_EntityParams'Class;
ToParams : out RTI_Connext_EntityParams) return ReturnCode_T;
function To_Entityparams
(Self : RTI_Connext_EntityParams'Class;
ToParams : out RTI_Connext_EntityParams) return ReturnCode_T renames RTI_Connext_SimpleReplierParams_To_Entityparams;
end DDS.Request_Reply.Untypedcommon;
|
AdaCore/training_material | Ada | 3,543 | adb | with Radar_Internals; use Radar_Internals;
with PragmARC.Randomness.KISS;
with Ada.Real_Time; use Ada.Real_Time;
with Ada.Text_IO;
package body Devices.Radars is
protected body Radar is
entry Wait_Event (Event : out Event_T)
--$ begin question
-- TODO: Fill guard
when True is
--$ end question
--$ line answer
when New_Event is
begin
--$ line question
null;
--$ begin answer
Event := Radar.Event;
New_Event := False;
--$ end answer
end Wait_Event;
procedure Ping (Object : Object_Type_T) is
begin
--$ line question
null;
--$ begin answer
Event := (Object, Tracked);
New_Event := True;
--$ end answer
end Ping;
procedure Mark (Object : Object_Type_T) is
begin
--$ line question
null;
--$ begin answer
if Event.Object = Object and Event.Status = Tracked then
Event := (Object, Selected);
New_Event := True;
end if;
--$ end answer
end Mark;
procedure Lost (Object : Object_Type_T) is
begin
--$ line question
null;
--$ begin answer
if Event.Object = Object and Event.Status /= Out_Of_Range then
Event := (Object, Out_Of_Range);
New_Event := True;
end if;
--$ end answer
end Lost;
procedure Rotate is
begin
--$ line question
null;
--$ line answer
Rotation := Rotation + 10;
end Rotate;
function Angle return Radar_Internals.Angle_Degrees_T is
--$ line question
(0);
--$ line answer
(Rotation);
end Radar;
type Detect_Op is (Ping, Mark, Lost);
package Pkg_Rng_Op is new PragmARC.Randomness.KISS (Detect_Op);
package Pkg_Rng_Obj is new PragmARC.Randomness.KISS (Object_Type_T);
task body Radar_Detect is
Rng_Op : Pkg_Rng_Op.Generator;
--$ line question
-- TODO : Instantiate an Rng for Object_Type_T
--$ begin answer
Rng_Obj : Pkg_Rng_Obj.Generator;
Wait_Time : Time := Clock;
--$ end answer
begin
Pkg_Rng_Op.Set_Seed (Rng_Op, 1);
while True loop
-- TODO: Send random events to the radar
--$ line question
null;
--$ begin answer
declare
Obj : Object_Type_T := Pkg_Rng_Obj.Random (Rng_Obj);
begin
case Pkg_Rng_Op.Random (Rng_Op) is
when Ping => Radar.Ping (Obj);
when Mark => Radar.Mark (Obj);
when Lost => Radar.Lost (Obj);
end case;
end;
--$ end answer
-- TODO: Add timing or otherwise blocking behaviour
--$ begin answer
Wait_Time := Wait_Time + Milliseconds (1000 / 10);
delay until Wait_Time;
--$ end answer
end loop;
end Radar_Detect;
task body Radar_Rotate is
Wait_Time : Time := Clock;
begin
while True loop
Radar.Rotate;
Wait_Time := Wait_Time + Milliseconds (1000 / 25);
delay until Wait_Time;
end loop;
end Radar_Rotate;
end Devices.Radars;
|
tum-ei-rcs/StratoX | Ada | 8,962 | 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 STMicroelectronics nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
-- --
-- This file is based on: --
-- --
-- @file stm32f4xx_hal_usart.h --
-- @author MCD Application Team --
-- @version V1.1.0 --
-- @date 19-June-2014 --
-- @brief Header file of USARTS HAL module. --
-- --
-- COPYRIGHT(c) 2014 STMicroelectronics --
------------------------------------------------------------------------------
-- This file provides register definitions for the STM32F4 (ARM Cortex M4F)
-- USART from ST Microelectronics.
-- Note that there are board implementation assumptions represented by the
-- private function APB_Clock.
pragma Restrictions (No_Elaboration_Code);
with System;
private with STM32_SVD.USART;
package STM32.USARTs is
type USART is limited private;
procedure Enable (This : in out USART)
with
Post => Enabled (This),
Inline;
procedure Disable (This : in out USART)
with
Post => not Enabled (This),
Inline;
function Enabled (This : USART) return Boolean with Inline;
procedure Receive (This : USART; Data : out UInt9) with Inline;
-- reads Device.DR into Data
function Current_Input (This : USART) return UInt9 with Inline;
-- returns Device.DR
procedure Transmit (This : in out USART; Data : UInt9) with Inline;
function Tx_Ready (This : USART) return Boolean with Inline;
function Rx_Ready (This : USART) return Boolean with Inline;
type Stop_Bits is (Stopbits_1, Stopbits_2)
with Size => 2;
for Stop_Bits use (Stopbits_1 => 0, Stopbits_2 => 2#10#);
procedure Set_Stop_Bits (This : in out USART; To : Stop_Bits);
type Word_Lengths is (Word_Length_8, Word_Length_9);
procedure Set_Word_Length (This : in out USART; To : Word_Lengths);
type Parities is (No_Parity, Even_Parity, Odd_Parity);
procedure Set_Parity (This : in out USART; To : Parities);
subtype Baud_Rates is Word;
procedure Set_Baud_Rate (This : in out USART; To : Baud_Rates);
type Oversampling_Modes is (Oversampling_By_8, Oversampling_By_16);
-- oversampling by 16 is the default
procedure Set_Oversampling_Mode
(This : in out USART;
To : Oversampling_Modes);
type UART_Modes is (Rx_Mode, Tx_Mode, Tx_Rx_Mode);
procedure Set_Mode (This : in out USART; To : UART_Modes);
type Flow_Control is
(No_Flow_Control,
RTS_Flow_Control,
CTS_Flow_Control,
RTS_CTS_Flow_Control);
procedure Set_Flow_Control (This : in out USART; To : Flow_Control);
type USART_Interrupt is
(Parity_Error,
Transmit_Data_Register_Empty,
Transmission_Complete,
Received_Data_Not_Empty,
Idle_Line_Detection,
Line_Break_Detection,
Clear_To_Send,
Error);
procedure Enable_Interrupts
(This : in out USART;
Source : USART_Interrupt)
with
Post => Interrupt_Enabled (This, Source),
Inline;
procedure Disable_Interrupts
(This : in out USART;
Source : USART_Interrupt)
with
Post => not Interrupt_Enabled (This, Source),
Inline;
function Interrupt_Enabled
(This : USART;
Source : USART_Interrupt)
return Boolean
with Inline;
type USART_Status_Flag is
(Parity_Error_Indicated,
Framing_Error_Indicated,
USART_Noise_Error_Indicated,
Overrun_Error_Indicated,
Idle_Line_Detection_Indicated,
Read_Data_Register_Not_Empty,
Transmission_Complete_Indicated,
Transmit_Data_Register_Empty,
Line_Break_Detection_Indicated,
Clear_To_Send_Indicated);
function Status (This : USART; Flag : USART_Status_Flag) return Boolean
with Inline;
procedure Clear_Status (This : in out USART; Flag : USART_Status_Flag)
with Inline;
procedure Enable_DMA_Transmit_Requests (This : in out USART)
with
Inline,
Post => DMA_Transmit_Requests_Enabled (This);
procedure Disable_DMA_Transmit_Requests (This : in out USART)
with
Inline,
Post => not DMA_Transmit_Requests_Enabled (This);
function DMA_Transmit_Requests_Enabled (This : USART) return Boolean
with Inline;
procedure Enable_DMA_Receive_Requests (This : in out USART)
with
Inline,
Post => DMA_Receive_Requests_Enabled (This);
procedure Disable_DMA_Receive_Requests (This : in out USART)
with
Inline,
Post => not DMA_Receive_Requests_Enabled (This);
function DMA_Receive_Requests_Enabled (This : USART) return Boolean
with Inline;
procedure Pause_DMA_Transmission (This : in out USART)
renames Disable_DMA_Transmit_Requests;
procedure Resume_DMA_Transmission (This : in out USART)
with
Inline,
Post => DMA_Transmit_Requests_Enabled (This) and
Enabled (This);
procedure Pause_DMA_Reception (This : in out USART)
renames Disable_DMA_Receive_Requests;
procedure Resume_DMA_Reception (This : in out USART)
with
Inline,
Post => DMA_Receive_Requests_Enabled (This) and
Enabled (This);
function Data_Register_Address (This : USART) return System.Address
with Inline;
-- Returns the address of the USART Data Register. This is exported
-- STRICTLY for the sake of clients driving a USART via DMA. All other
-- clients of this package should use the procedural interfaces Transmit
-- and Receive instead of directly accessing the Data Register!
-- Seriously, don't use this function otherwise.
private
function APB_Clock (This : USART) return Word with Inline;
-- Returns either APB1 or APB2 clock rate, in Hertz, depending on the
-- USART. For the sake of not making this package board-specific, we assume
-- that we are given a valid USART object at a valid address, AND that the
-- USART devices really are configured such that only 1 and 6 are on APB2.
-- Therefore, if a board has additional USARTs beyond USART6, eg USART8 on
-- the F429I Discovery board, they better conform to that assumption.
-- See Note # 2 in each of Tables 139-141 of the RM on pages 970 - 972.
type USART is new STM32_SVD.USART.USART2_Peripheral;
end STM32.USARTs;
|
Lucretia/Cherry | Ada | 1,279 | adb | --
-- The author disclaims copyright to this source code. In place of
-- a legal notice, here is a blessing:
--
-- May you do good and not evil.
-- May you find forgiveness for yourself and forgive others.
-- May you share freely, not taking more than you give.
--
package body Parser_Data is
function Current_Char (Scanner : in Scanner_Record)
return Character
is
begin
return Scanner.Item (Scanner.First);
end Current_Char;
function Current_Line (Scanner : in Scanner_Record)
return String
is
begin
return Scanner.Item (Scanner.First .. Scanner.Last);
end Current_Line;
function Current_Token_Char (Scanner : in Scanner_Record)
return Character
is
begin
return Scanner.Item (Scanner.Token);
end Current_Token_Char;
function Current_Token_Line (Scanner : in Scanner_Record)
return String
is
begin
return Scanner.Item (Scanner.Token .. Scanner.Last);
end Current_Token_Line;
procedure Advance (Scanner : in out Scanner_Record;
By : in Positive)
is
begin
Scanner.Token := Scanner.Token + By;
end Advance;
end Parser_Data;
|
Fabien-Chouteau/GESTE | Ada | 11,749 | ads | pragma Ada_2005;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings;
with Interfaces.C.Extensions;
with System;
package basetsd_h is
-- unsupported macro: SPOINTER_32 POINTER_SIGNED POINTER_32
-- unsupported macro: UPOINTER_32 POINTER_UNSIGNED POINTER_32
ADDRESS_TAG_BIT : constant := 16#80000000#; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:97
-- arg-macro: function HandleToULong (h)
-- return (ULONG)(ULONG_PTR)(h);
-- arg-macro: function HandleToLong (h)
-- return (LONG)(LONG_PTR) (h);
-- arg-macro: function ULongToHandle (ul)
-- return (HANDLE)(ULONG_PTR) (ul);
-- arg-macro: function LongToHandle (h)
-- return (HANDLE)(LONG_PTR) (h);
-- arg-macro: function PtrToUlong (p)
-- return (ULONG)(ULONG_PTR) (p);
-- arg-macro: function PtrToLong (p)
-- return (LONG)(LONG_PTR) (p);
-- arg-macro: function PtrToUint (p)
-- return (UINT)(UINT_PTR) (p);
-- arg-macro: function PtrToInt (p)
-- return (INT)(INT_PTR) (p);
-- arg-macro: function PtrToUshort (p)
-- return (unsigned short)(ULONG_PTR)(p);
-- arg-macro: function PtrToShort (p)
-- return (short)(LONG_PTR)(p);
-- arg-macro: function IntToPtr (i)
-- return (VOID *)(INT_PTR)((int)i);
-- arg-macro: function UIntToPtr (ui)
-- return (VOID *)(UINT_PTR)((unsigned int)ui);
-- arg-macro: function LongToPtr (l)
-- return (VOID *)(LONG_PTR)((long)l);
-- arg-macro: function ULongToPtr (ul)
-- return (VOID *)(ULONG_PTR)((unsigned long)ul);
-- arg-macro: function Ptr32ToPtr (p)
-- return (void *) (ULONG_PTR) p;
-- arg-macro: function Handle32ToHandle (h)
-- return Ptr32ToPtr(h);
-- arg-macro: function PtrToPtr32 (p)
-- return (void *) (ULONG_PTR) p;
-- arg-macro: function HandleToHandle32 (h)
-- return PtrToPtr32(h);
-- arg-macro: procedure HandleToUlong (h)
-- HandleToULong(h)
-- arg-macro: procedure UlongToHandle (ul)
-- ULongToHandle(ul)
-- arg-macro: procedure UlongToPtr (ul)
-- ULongToPtr(ul)
-- arg-macro: procedure UintToPtr (ui)
-- UIntToPtr(ui)
-- unsupported macro: MAXUINT_PTR (~((UINT_PTR)0))
-- unsupported macro: MAXINT_PTR ((INT_PTR)(MAXUINT_PTR >> 1))
-- unsupported macro: MININT_PTR (~MAXINT_PTR)
-- unsupported macro: MAXULONG_PTR (~((ULONG_PTR)0))
-- unsupported macro: MAXLONG_PTR ((LONG_PTR)(MAXULONG_PTR >> 1))
-- unsupported macro: MINLONG_PTR (~MAXLONG_PTR)
-- unsupported macro: MAXUHALF_PTR ((UHALF_PTR)~0)
-- unsupported macro: MAXHALF_PTR ((HALF_PTR)(MAXUHALF_PTR >> 1))
-- unsupported macro: MINHALF_PTR (~MAXHALF_PTR)
subtype POINTER_64_INT is unsigned_long; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:14
subtype INT8 is char; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:30
type PINT8 is new Interfaces.C.Strings.chars_ptr; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:30
subtype INT16 is short; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:31
type PINT16 is access all short; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:31
subtype INT32 is int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:32
type PINT32 is access all int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:32
subtype INT64 is Long_Long_Integer; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:33
type PINT64 is access all Long_Long_Integer; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:33
subtype UINT8 is unsigned_char; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:34
type PUINT8 is access all unsigned_char; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:34
subtype UINT16 is unsigned_short; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:35
type PUINT16 is access all unsigned_short; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:35
subtype UINT32 is unsigned; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:36
type PUINT32 is access all unsigned; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:36
subtype UINT64 is Extensions.unsigned_long_long; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:37
type PUINT64 is access all Extensions.unsigned_long_long; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:37
subtype LONG32 is int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:38
type PLONG32 is access all int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:38
subtype ULONG32 is unsigned; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:39
type PULONG32 is access all unsigned; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:39
subtype DWORD32 is unsigned; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:40
type PDWORD32 is access all unsigned; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:40
subtype INT_PTR is int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:53
type PINT_PTR is access all int; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:53
subtype UINT_PTR is unsigned; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:54
type PUINT_PTR is access all unsigned; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:54
subtype LONG_PTR is long; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:55
type PLONG_PTR is access all long; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:55
subtype ULONG_PTR is unsigned_long; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:56
type PULONG_PTR is access all unsigned_long; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:56
subtype UHALF_PTR is unsigned_short; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:99
type PUHALF_PTR is access all unsigned_short; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:99
subtype HALF_PTR is short; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:100
type PHALF_PTR is access all short; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:100
subtype SHANDLE_PTR is long; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:101
subtype HANDLE_PTR is unsigned_long; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:102
function PtrToPtr64 (p : System.Address) return System.Address; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:120
pragma Import (C, PtrToPtr64, "PtrToPtr64");
function Ptr64ToPtr (p : System.Address) return System.Address; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:121
pragma Import (C, Ptr64ToPtr, "Ptr64ToPtr");
function HandleToHandle64 (h : System.Address) return System.Address; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:122
pragma Import (C, HandleToHandle64, "HandleToHandle64");
function Handle64ToHandle (h : System.Address) return System.Address; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:123
pragma Import (C, Handle64ToHandle, "Handle64ToHandle");
subtype SIZE_T is ULONG_PTR; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:149
type PSIZE_T is access all ULONG_PTR; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:149
subtype SSIZE_T is LONG_PTR; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:150
type PSSIZE_T is access all LONG_PTR; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:150
subtype DWORD_PTR is ULONG_PTR; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:151
type PDWORD_PTR is access all ULONG_PTR; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:151
subtype LONG64 is Long_Long_Integer; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:152
type PLONG64 is access all Long_Long_Integer; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:152
subtype ULONG64 is Extensions.unsigned_long_long; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:153
type PULONG64 is access all Extensions.unsigned_long_long; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:153
subtype DWORD64 is Extensions.unsigned_long_long; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:154
type PDWORD64 is access all Extensions.unsigned_long_long; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:154
subtype KAFFINITY is ULONG_PTR; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:155
type PKAFFINITY is access all KAFFINITY; -- c:\home\ochem\install\bin\../lib/gcc/i686-pc-mingw32/4.7.3/../../../../i686-pc-mingw32/include/basetsd.h:156
end basetsd_h;
|
edin/raytracer | Ada | 1,505 | ads | --
-- Raytracer implementation in Ada
-- by John Perry (github: johnperry-math)
-- 2021
--
-- specification for types, constants, and operators used throughout
--
-- Ada packages
with Interfaces;
-- @summary types, constants, and operators used throughout the project
-- @description
-- Makes precise the meaning of floating-point and integer types that we need.
--
package RayTracing_Constants is
type Float15 is digits 15;
-- floating point with 15 digit precision; i.e.,
-- 64-bit floating point will suffice
Far_Away: constant Float15 := 1_000_000.0;
-- an point too far away to be considered useful
subtype UInt8 is Interfaces.Unsigned_8;
function "="(First, Second: UInt8) return Boolean renames Interfaces."=";
subtype UInt16 is Interfaces.Unsigned_16;
function "+"(First, Second: UInt16) return UInt16 renames Interfaces."+";
function "*"(First, Second: UInt16) return UInt16 renames Interfaces."*";
subtype UInt32 is Interfaces.Unsigned_32;
function "+"(First, Second: UInt32) return UInt32 renames Interfaces."+";
subtype Int32 is Interfaces.Integer_32;
function "-"(It: Int32) return Int32 renames Interfaces."-";
function "+"(First, Second: Int32) return Int32 renames Interfaces."+";
function "-"(First, Second: Int32) return Int32 renames Interfaces."-";
function "*"(First, Second: Int32) return Int32 renames Interfaces."*";
function "/"(First, Second: Int32) return Int32 renames Interfaces."/";
end RayTracing_Constants;
|
zhmu/ananas | Ada | 1,313 | ads | ------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- ADA.NUMERICS.SHORT_ELEMENTARY_FUNCTIONS --
-- --
-- S p e c --
-- --
-- This specification is derived from the Ada Reference Manual for use with --
-- GNAT. In accordance with the copyright of that document, you can freely --
-- copy and modify this specification, provided that if you redistribute a --
-- modified version, any changes that you have made are clearly indicated. --
-- --
------------------------------------------------------------------------------
with Ada.Numerics.Generic_Elementary_Functions;
package Ada.Numerics.Short_Elementary_Functions is
new Ada.Numerics.Generic_Elementary_Functions (Short_Float);
pragma Pure (Short_Elementary_Functions);
|
MinimSecure/unum-sdk | Ada | 794 | ads | -- Copyright 2010-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 Pack is
procedure Print (I1 : Positive; I2 : Positive);
end Pack;
|
sungyeon/drake | Ada | 556 | ads | pragma License (Unrestricted);
-- implementation unit
package System.Formatting.Fixed is
pragma Pure;
procedure Image (
Value : Long_Long_Float;
Item : out String; -- To'Length >= T'Fore + T'Aft + 5 (16#.#)
Fore_Last, Last : out Natural;
Signs : Sign_Marks := ('-', ' ', ' ');
Base : Number_Base := 10;
Base_Form : Boolean := False;
Set : Type_Set := Upper_Case;
Fore_Digits_Width : Positive := 1;
Fore_Digits_Fill : Character := '0';
Aft_Width : Positive);
end System.Formatting.Fixed;
|
reznikmm/matreshka | Ada | 3,883 | 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_Attributes.Style.Text_Autospace;
package ODF.DOM.Attributes.Style.Text_Autospace.Internals is
function Create
(Node : Matreshka.ODF_Attributes.Style.Text_Autospace.Style_Text_Autospace_Access)
return ODF.DOM.Attributes.Style.Text_Autospace.ODF_Style_Text_Autospace;
function Wrap
(Node : Matreshka.ODF_Attributes.Style.Text_Autospace.Style_Text_Autospace_Access)
return ODF.DOM.Attributes.Style.Text_Autospace.ODF_Style_Text_Autospace;
end ODF.DOM.Attributes.Style.Text_Autospace.Internals;
|
stcarrez/ada-security | Ada | 2,001 | ads | -----------------------------------------------------------------------
-- security-controllers-roles -- Simple role base security
-- 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 Security.Contexts;
with Security.Permissions;
with Security.Policies.Roles;
package Security.Controllers.Roles is
-- ------------------------------
-- Security Controller
-- ------------------------------
-- The <b>Role_Controller</b> implements a simple role based permissions check.
-- The permission is granted if the user has the role defined by the controller.
type Role_Controller (Count : Positive) is limited new Controller with record
Roles : Policies.Roles.Role_Type_Array (1 .. Count);
end record;
type Role_Controller_Access is access all Role_Controller'Class;
-- Returns true if the user associated with the security context <b>Context</b> has
-- one of the role defined in the <b>Handler</b>.
overriding
function Has_Permission (Handler : in Role_Controller;
Context : in Security.Contexts.Security_Context'Class;
Permission : in Security.Permissions.Permission'Class)
return Boolean;
end Security.Controllers.Roles;
|
vpodzime/ada-util | Ada | 1,514 | ads | -----------------------------------------------------------------------
-- serialize-io-json-tests -- Unit tests for JSON parser
-- Copyright (C) 2011, 2016, 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 Util.Tests;
package Util.Serialize.IO.JSON.Tests is
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite);
type Test is new Util.Tests.Test with null record;
procedure Test_Parse_Error (T : in out Test);
procedure Test_Parser (T : in out Test);
-- Generate some output stream for the test.
procedure Write_Stream (Stream : in out Util.Serialize.IO.Output_Stream'Class);
-- Test the JSON output stream generation.
procedure Test_Output (T : in out Test);
-- Test reading a JSON content into an Object tree.
procedure Test_Read (T : in out Test);
end Util.Serialize.IO.JSON.Tests;
|
reznikmm/matreshka | Ada | 3,769 | 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_Default_Cell_Style_Name_Attributes is
pragma Preelaborate;
type ODF_Db_Default_Cell_Style_Name_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Db_Default_Cell_Style_Name_Attribute_Access is
access all ODF_Db_Default_Cell_Style_Name_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Db_Default_Cell_Style_Name_Attributes;
|
sungyeon/drake | Ada | 264 | ads | pragma License (Unrestricted);
-- implementation unit required by compiler
package System.Wid_Bool is
pragma Pure;
-- required for Boolean'Width by compiler (s-widboo.ads)
function Width_Boolean (Lo, Hi : Boolean) return Natural;
end System.Wid_Bool;
|
charlie5/lace | Ada | 179 | ads | with
any_Math.any_Algebra.any_linear.any_d2;
package float_Math.Algebra.linear.d2 is new float_Math.Algebra.linear.any_d2;
pragma Pure (float_Math.Algebra.linear.d2);
|
thieryw/sorting_algo | Ada | 7,722 | adb | pragma Ada_95;
pragma Warnings (Off);
pragma Source_File_Name (ada_main, Spec_File_Name => "b~sorting_exercise.ads");
pragma Source_File_Name (ada_main, Body_File_Name => "b~sorting_exercise.adb");
pragma Suppress (Overflow_Check);
with Ada.Exceptions;
package body ada_main is
E079 : Short_Integer; pragma Import (Ada, E079, "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");
E054 : Short_Integer; pragma Import (Ada, E054, "ada__io_exceptions_E");
E103 : Short_Integer; pragma Import (Ada, E103, "ada__numerics_E");
E056 : Short_Integer; pragma Import (Ada, E056, "ada__tags_E");
E053 : Short_Integer; pragma Import (Ada, E053, "ada__streams_E");
E077 : Short_Integer; pragma Import (Ada, E077, "interfaces__c_E");
E025 : Short_Integer; pragma Import (Ada, E025, "system__exceptions_E");
E082 : Short_Integer; pragma Import (Ada, E082, "system__file_control_block_E");
E072 : Short_Integer; pragma Import (Ada, E072, "system__file_io_E");
E075 : Short_Integer; pragma Import (Ada, E075, "system__finalization_root_E");
E073 : Short_Integer; pragma Import (Ada, E073, "ada__finalization_E");
E111 : Short_Integer; pragma Import (Ada, E111, "ada__calendar_E");
E109 : Short_Integer; pragma Import (Ada, E109, "system__random_seed_E");
E017 : Short_Integer; pragma Import (Ada, E017, "system__secondary_stack_E");
E051 : Short_Integer; pragma Import (Ada, E051, "ada__text_io_E");
Local_Priority_Specific_Dispatching : constant String := "";
Local_Interrupt_States : constant String := "";
Is_Elaborated : Boolean := False;
procedure finalize_library is
begin
E051 := E051 - 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
E072 := E072 - 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");
Bind_Env_Addr : System.Address;
pragma Import (C, Bind_Env_Addr, "__gl_bind_env_addr");
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;
E054 := E054 + 1;
Ada.Numerics'Elab_Spec;
E103 := E103 + 1;
Ada.Tags'Elab_Spec;
Ada.Streams'Elab_Spec;
E053 := E053 + 1;
Interfaces.C'Elab_Spec;
System.Exceptions'Elab_Spec;
E025 := E025 + 1;
System.File_Control_Block'Elab_Spec;
E082 := E082 + 1;
System.Finalization_Root'Elab_Spec;
E075 := E075 + 1;
Ada.Finalization'Elab_Spec;
E073 := E073 + 1;
Ada.Calendar'Elab_Spec;
Ada.Calendar'Elab_Body;
E111 := E111 + 1;
System.Random_Seed'Elab_Body;
E109 := E109 + 1;
System.File_Io'Elab_Body;
E072 := E072 + 1;
E077 := E077 + 1;
Ada.Tags'Elab_Body;
E056 := E056 + 1;
System.Soft_Links'Elab_Body;
E013 := E013 + 1;
System.Os_Lib'Elab_Body;
E079 := E079 + 1;
System.Secondary_Stack'Elab_Body;
E017 := E017 + 1;
Ada.Text_Io'Elab_Spec;
Ada.Text_Io'Elab_Body;
E051 := E051 + 1;
end adainit;
procedure Ada_Main_Program;
pragma Import (Ada, Ada_Main_Program, "_ada_sorting_exercise");
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
-- ./sorting_exercise.o
-- -L./
-- -L/usr/lib/gcc/x86_64-linux-gnu/6/adalib/
-- -shared
-- -lgnat-6
-- END Object file/option list
end ada_main;
|
reznikmm/gela | Ada | 4,793 | adb | with Ada.Streams.Stream_IO;
with League.String_Vectors;
with Gela.Naming_Schemas;
package body Gela.Path_Source_Finders is
procedure Read_File
(Name : String;
Text : out League.Strings.Universal_String;
Found : out Boolean);
type Path_Source_Finder_Access is access all Source_Finder'Class;
------------
-- Create --
------------
function Create
(Path : League.Strings.Universal_String;
Context : access Gela.Contexts.Context'Class;
Next : Gela.Source_Finders.Source_Finder_Access := null)
return Gela.Source_Finders.Source_Finder_Access
is
begin
if Path.Index (':') > 0 then
declare
Result : Gela.Source_Finders.Source_Finder_Access;
List : League.String_Vectors.Universal_String_Vector;
begin
List := Path.Split (':', League.Strings.Skip_Empty);
for J in reverse 1 .. List.Length loop
Result := Create (List.Element (J), Context, Result);
end loop;
return Result;
end;
else
declare
Result : Path_Source_Finder_Access;
begin
Result := new Source_Finder'(Context, Path, Next);
return Gela.Source_Finders.Source_Finder_Access (Result);
end;
end if;
end Create;
-----------------
-- Lookup_Body --
-----------------
overriding procedure Lookup_Body
(Self : Source_Finder;
Symbol : Gela.Lexical_Types.Symbol;
Found : out Boolean;
File : out League.Strings.Universal_String;
Source : out League.Strings.Universal_String)
is
Schema : constant Gela.Naming_Schemas.Naming_Schema_Access :=
Self.Context.Naming_Schema;
Name : constant League.Strings.Universal_String :=
Schema.Body_Name (Symbol);
begin
Self.Lookup_Compilation (Name, Found, File, Source);
end Lookup_Body;
------------------------
-- Lookup_Compilation --
------------------------
overriding procedure Lookup_Compilation
(Self : Source_Finder;
Name : League.Strings.Universal_String;
Found : out Boolean;
File : out League.Strings.Universal_String;
Source : out League.Strings.Universal_String)
is
use type Gela.Source_Finders.Source_Finder_Access;
Result : League.Strings.Universal_String := Self.Directory;
begin
if not Result.Is_Empty and then not Result.Ends_With ("/") then
Result.Append ("/");
end if;
Result.Append (Name);
declare
-- Shell we use here Codec_For_Application_Locale?
Full_Name : constant String := Result.To_UTF_8_String;
begin
Read_File (Full_Name, Source, Found);
if Found then
File := Result;
elsif Self.Next /= null then
Self.Next.Lookup_Compilation (Name, Found, File, Source);
else
Found := False;
end if;
end;
end Lookup_Compilation;
------------------------
-- Lookup_Declaration --
------------------------
overriding procedure Lookup_Declaration
(Self : Source_Finder;
Symbol : Gela.Lexical_Types.Symbol;
Found : out Boolean;
File : out League.Strings.Universal_String;
Source : out League.Strings.Universal_String)
is
Schema : constant Gela.Naming_Schemas.Naming_Schema_Access :=
Self.Context.Naming_Schema;
Name : constant League.Strings.Universal_String :=
Schema.Declaration_Name (Symbol);
begin
Self.Lookup_Compilation (Name, Found, File, Source);
end Lookup_Declaration;
---------------
-- Read_File --
---------------
procedure Read_File
(Name : String;
Text : out League.Strings.Universal_String;
Found : out Boolean)
is
File : Ada.Streams.Stream_IO.File_Type;
begin
Ada.Streams.Stream_IO.Open
(File, Ada.Streams.Stream_IO.In_File, Name);
declare
Size : constant Ada.Streams.Stream_IO.Count :=
Ada.Streams.Stream_IO.Size (File);
Length : constant Ada.Streams.Stream_Element_Offset :=
Ada.Streams.Stream_Element_Count (Size);
Data : Ada.Streams.Stream_Element_Array (1 .. Length);
Aux : String (1 .. Natural (Length));
for Aux'Address use Data'Address;
Last : Ada.Streams.Stream_Element_Offset;
begin
Ada.Streams.Stream_IO.Read (File, Data, Last);
Ada.Streams.Stream_IO.Close (File);
Text := League.Strings.From_UTF_8_String (Aux (1 .. Natural (Last)));
Found := True;
end;
exception
when Ada.Streams.Stream_IO.Name_Error =>
Found := False;
end Read_File;
end Gela.Path_Source_Finders;
|
1Crazymoney/LearnAda | Ada | 257 | adb | function Duplication ( T: Tomb ) return Boolean is
J: Index := T'First;
Re: Boolean := False;
begin
for I in T'Range loop
if T(Mh) < T(I) then
Mh := I;
end if;
end loop;
return Mh;
end Duplication;
|
AdaCore/langkit | Ada | 1,145 | ads | --
-- Copyright (C) 2014-2022, AdaCore
-- SPDX-License-Identifier: Apache-2.0
--
with Ada.Containers; use Ada.Containers;
with System;
-- Various helpers to work with hashes for standard containers
package Langkit_Support.Hashes is
Initial_Hash : constant Hash_Type;
type Hash_Array is array (Positive range <>) of Hash_Type;
function Combine (L, R : Hash_Type) return Hash_Type;
-- Combine two hashes into a single one
function Combine (Hashes : Hash_Array) return Hash_Type;
-- Combine several hashes into a single one. This is like hashing a tuple.
generic
Ignored_LSB : Natural;
-- Amount of least significant bits to ignore for hashing
function Hash_Address (Addr : System.Address) return Hash_Type;
-- Compute the hash of an address, ignoring the given amount of least
-- significant bits.
generic
type Object_Type (<>) is limited private;
type Object_Access is access Object_Type;
function Hash_Access (Acc : Object_Access) return Hash_Type;
-- Generic access hash function
private
Initial_Hash : constant Hash_Type := 0;
end Langkit_Support.Hashes;
|
ytomino/gnat4drake | Ada | 921 | ads | pragma License (Unrestricted);
package GNAT.Command_Line is
-- Parsing
type Opt_Parser is null record;
Command_Line_Parser : constant Opt_Parser := (null record);
procedure Initialize_Option_Scan (
Switch_Char : Character := '-';
Stop_At_First_Non_Switch : Boolean := False;
Section_Delimiters : String := "") is null;
function Full_Switch (Parser : Opt_Parser := Command_Line_Parser)
return String;
function Getopt (
Switches : String;
Concatenate : Boolean := True;
Parser : Opt_Parser := Command_Line_Parser)
return Character;
function Get_Argument (
Do_Expansion : Boolean := False;
Parser : Opt_Parser := Command_Line_Parser)
return String;
function Parameter (Parser : Opt_Parser := Command_Line_Parser)
return String;
Invalid_Switch : exception;
Invalid_Parameter : exception;
end GNAT.Command_Line;
|
AdaCore/gpr | Ada | 97 | ads | with AAA;
package BBBBBBBB is
procedure Inst is new AAA.Proc;
procedure P;
end BBBBBBBB;
|
micahwelf/FLTK-Ada | Ada | 1,592 | adb |
with
Interfaces.C,
System;
use type
System.Address;
package body FLTK.Images.RGB.PNG is
function new_fl_png_image
(F : in Interfaces.C.char_array)
return System.Address;
pragma Import (C, new_fl_png_image, "new_fl_png_image");
pragma Inline (new_fl_png_image);
procedure free_fl_png_image
(P : in System.Address);
pragma Import (C, free_fl_png_image, "free_fl_png_image");
pragma Inline (free_fl_png_image);
overriding procedure Finalize
(This : in out PNG_Image) is
begin
if This.Void_Ptr /= System.Null_Address and then
This in PNG_Image'Class
then
free_fl_png_image (This.Void_Ptr);
This.Void_Ptr := System.Null_Address;
end if;
Finalize (RGB_Image (This));
end Finalize;
package body Forge is
function Create
(Filename : in String)
return PNG_Image is
begin
return This : PNG_Image do
This.Void_Ptr := new_fl_png_image
(Interfaces.C.To_C (Filename));
case fl_image_fail (This.Void_Ptr) is
when 1 =>
raise No_Image_Error;
when 2 =>
raise File_Access_Error;
when 3 =>
raise Format_Error;
when others =>
null;
end case;
end return;
end Create;
end Forge;
end FLTK.Images.RGB.PNG;
|
szstonelee/redisoo | Ada | 47,056 | adb | -- Copyright (C) 2008-2011 Maciej Sobczak
-- Distributed under the Boost Software License, Version 1.0.
-- (See accompanying file LICENSE_1_0.txt or copy at
-- http://www.boost.org/LICENSE_1_0.txt)
with Ada.Strings.Fixed;
with Interfaces.C.Strings;
package body SOCI is
procedure Check_Session_State (Handle : in Session_Handle) is
function Soci_Session_State (S : in Session_Handle) return Interfaces.C.int;
pragma Import (C, Soci_Session_State, "soci_session_state");
function Soci_Session_Error_Message
(S : in Session_Handle)
return Interfaces.C.Strings.chars_ptr;
pragma Import (C, Soci_Session_Error_Message, "soci_session_error_message");
State : constant Interfaces.C.int := Soci_Session_State (Handle);
Bad_State : constant Interfaces.C.int := 0;
use type Interfaces.C.int;
begin
if State = Bad_State then
declare
Message : constant String :=
Interfaces.C.Strings.Value (Soci_Session_Error_Message (Handle));
begin
raise Database_Error with Message;
end;
end if;
end Check_Session_State;
function Make_Session_Handle (Connection_String : in String) return Session_Handle is
function Soci_Create_Session (C : in Interfaces.C.char_array) return Session_Handle;
pragma Import (C, Soci_Create_Session, "soci_create_session");
Connection_String_C : constant Interfaces.C.char_array :=
Interfaces.C.To_C (Connection_String);
Handle : constant Session_Handle :=
Soci_Create_Session (Connection_String_C);
begin
if Handle = Null_Session_Handle then
raise Database_Error with "Cannot create session object.";
else
return Handle;
end if;
end Make_Session_Handle;
function Data_State_To_Int (State : in Data_State) return Interfaces.C.int is
begin
if State = Data_Not_Null then
return 1;
else
return 0;
end if;
end Data_State_To_Int;
function Int_To_Data_State (State : in Interfaces.C.int) return Data_State is
use type Interfaces.C.int;
begin
if State /= 0 then
return Data_Not_Null;
else
return Data_Null;
end if;
end Int_To_Data_State;
procedure Check_Is_Open (This : in Session'Class) is
begin
if not This.Initialized then
raise Database_Error with "Session is not initialized.";
end if;
end Check_Is_Open;
procedure Check_Statement_State (Handle : in Statement_Handle) is
function Soci_Statement_State (S : in Statement_Handle) return Interfaces.C.int;
pragma Import (C, Soci_Statement_State, "soci_statement_state");
function Soci_Statement_Error_Message
(S : in Statement_Handle)
return Interfaces.C.Strings.chars_ptr;
pragma Import (C, Soci_Statement_Error_Message, "soci_statement_error_message");
State : constant Interfaces.C.int := Soci_Statement_State (Handle);
Bad_State : constant Interfaces.C.int := 0;
use type Interfaces.C.int;
begin
if State = Bad_State then
declare
Message : constant String :=
Interfaces.C.Strings.Value (Soci_Statement_Error_Message (Handle));
begin
raise Database_Error with Message;
end;
end if;
end Check_Statement_State;
function String_To_Time (Source : in String) return Ada.Calendar.Time is
Year_N : Natural;
Month_N : Natural;
Day_N : Natural;
Hour_N : Natural;
Minute_N : Natural;
Second_N : Natural;
procedure Get_Next_Number
(Source : in String;
Position : in out Natural;
Result : out Natural) is
I : Natural;
begin
I := Ada.Strings.Fixed.Index (Source => Source,
Pattern => " ",
From => Position);
if I /= 0 then
Result := Natural'Value (Source (Position .. I));
Position := I + 1;
else
Result := Natural'Value (Source (Position .. Source'Last));
Position := 0;
end if;
end Get_Next_Number;
Pos : Natural := 1;
begin
Get_Next_Number (Source => Source, Position => Pos, Result => Year_N);
Get_Next_Number (Source => Source, Position => Pos, Result => Month_N);
Get_Next_Number (Source => Source, Position => Pos, Result => Day_N);
Get_Next_Number (Source => Source, Position => Pos, Result => Hour_N);
Get_Next_Number (Source => Source, Position => Pos, Result => Minute_N);
Get_Next_Number (Source => Source, Position => Pos, Result => Second_N);
return Ada.Calendar.Time_Of (Year_N, Month_N, Day_N,
Duration (Hour_N * 3_600 + Minute_N * 60 + Second_N));
end String_To_Time;
function Time_To_String (Date : in Ada.Calendar.Time) return String is
Year : Ada.Calendar.Year_Number;
Month : Ada.Calendar.Month_Number;
Day : Ada.Calendar.Day_Number;
Seconds : Ada.Calendar.Day_Duration;
Hour : Natural;
Minute : Natural;
Seconds_N : Natural;
begin
Ada.Calendar.Split (Date, Year, Month, Day, Seconds);
Seconds_N := Natural (Seconds);
Hour := Seconds_N / 3_600;
Minute := (Seconds_N - Natural (Hour) * 3_600) / 60;
Seconds_N := Seconds_N - Natural (Hour) * 3_600 - Natural (Minute) * 60;
return Ada.Calendar.Year_Number'Image (Year) & " " &
Ada.Calendar.Month_Number'Image (Month) & " " &
Ada.Calendar.Day_Number'Image (Day) & " " &
Natural'Image (Hour) & " " &
Natural'Image (Minute) & " " &
Natural'Image (Seconds_N);
end Time_To_String;
function Make_Session (Connection_String : in String) return Session is
begin
return S : Session do
S.Handle := Make_Session_Handle (Connection_String);
S.Initialized := True;
Check_Session_State (S.Handle);
end return;
end Make_Session;
procedure Open (This : in out Session; Connection_String : in String) is
begin
if This.Initialized then
raise Database_Error with "Session is already initialized.";
else
declare
Handle : constant Session_Handle :=
Make_Session_Handle (Connection_String);
begin
Check_Session_State (Handle);
This.Handle := Handle;
This.Initialized := True;
end;
end if;
end Open;
procedure Close (This : in out Session) is
procedure Soci_Destroy_Session (S : in Session_Handle);
pragma Import (C, Soci_Destroy_Session, "soci_destroy_session");
begin
if This.Initialized then
if This.Belongs_To_Pool then
raise Database_Error with "Cannot close session - not an owner (session in pool).";
else
Soci_Destroy_Session (This.Handle);
This.Initialized := False;
end if;
end if;
end Close;
function Is_Open (This : in Session) return Boolean is
begin
return This.Initialized;
end Is_Open;
procedure Finalize (This : in out Session) is
begin
if This.Initialized then
if This.Belongs_To_Pool then
This.Pool.all.Give_Back (This.Position_In_Pool);
This.Initialized := False;
else
This.Close;
end if;
end if;
end Finalize;
procedure Start (This : in Session) is
procedure Soci_Begin (S : in Session_Handle);
pragma Import (C, Soci_Begin, "soci_begin");
begin
Check_Is_Open (This);
Soci_Begin (This.Handle);
Check_Session_State (This.Handle);
end Start;
procedure Commit (This : in Session) is
procedure Soci_Commit (S : in Session_Handle);
pragma Import (C, Soci_Commit, "soci_commit");
begin
Check_Is_Open (This);
Soci_Commit (This.Handle);
Check_Session_State (This.Handle);
end Commit;
procedure Rollback (This : in Session) is
procedure Soci_Rollback (S : in Session_Handle);
pragma Import (C, Soci_Rollback, "soci_rollback");
begin
Check_Is_Open (This);
Soci_Rollback (This.Handle);
Check_Session_State (This.Handle);
end Rollback;
procedure Execute (This : in Session; Query : in String) is
S : Statement := Make_Statement (This);
begin
S.Prepare (Query);
S.Execute;
end Execute;
protected body Connection_Pool_PS is
procedure Open (Position : in Positive; Connection_String : in String) is
begin
if Position > Size then
raise Database_Error with "Index out of range.";
end if;
Connections (Position).Open (Connection_String);
end Open;
procedure Close (Position : in Positive) is
begin
if Position > Size then
raise Database_Error with "Index out of range.";
end if;
if Is_Used (Position) then
raise Database_Error with "Cannot close connection that is currently in use.";
end if;
Connections (Position).Close;
end Close;
entry Lease (S : in out Session'Class) when Available is
Found : Boolean := False;
begin
if S.Initialized then
raise Database_Error with "This session is already initialized.";
end if;
-- Find some connection in the pool that is not currently used.
for I in 1 .. Size loop
if not Is_Used (I) then
Check_Is_Open (Connections (I));
S.Handle := Connections (I).Handle;
S.Initialized := True;
S.Belongs_To_Pool := True;
S.Position_In_Pool := I;
-- WORKAROUND:
-- The S.Pool component is set in the Lease procedure
-- of the Connection_Pool type, because here the access
-- to the protected object could not be taken (compiler bug).
Is_Used (I) := True;
Found := True;
exit;
end if;
end loop;
if not Found then
raise Database_Error with "Internal error.";
end if;
-- Update the Available flag.
Found := False;
for I in 1 .. Size loop
if not Is_Used (I) then
Found := True;
exit;
end if;
end loop;
Available := Found;
end Lease;
procedure Give_Back (Position : in Positive) is
begin
if Position > Size then
raise Database_Error with "Index out of range.";
end if;
if not Is_Used (Position) then
raise Database_Error with "Cannot give back connection that is not in use.";
end if;
Is_Used (Position) := False;
Available := True;
end Give_Back;
end Connection_Pool_PS;
procedure Open
(This : in out Connection_Pool;
Position : in Positive;
Connection_String : in String) is
begin
This.Pool.Open (Position, Connection_String);
end Open;
procedure Close (This : in out Connection_Pool; Position : in Positive) is
begin
This.Pool.Close (Position);
end Close;
procedure Lease (This : in out Connection_Pool; S : in out Session'Class) is
begin
This.Pool.Lease (S);
-- WORKAROUND:
-- The S.Pool component is set here because the access
-- to protected object cannot be taken in protected body (compiler bug.)
-- JUSTIFICATION:
-- The Unchecked_Access is taken here to enable the session to properly
-- "unregister" from the pool in Session's Finalize.
-- An alternative would be to rely on the user to explicitly unlock
-- the appropriate entry in the pool, which is too error prone.
-- It is assumed that connection pool always has wider lifetime
-- than that of the session which is temporarily leased from the pool
-- - this guarantees that S.Pool always points to a valid pool object.
S.Pool := This.Pool'Unchecked_Access;
end Lease;
function Make_Statement (Sess : in Session'Class) return Statement is
function Soci_Create_Statement (Sess : in Session_Handle) return Statement_Handle;
pragma Import (C, Soci_Create_Statement, "soci_create_statement");
begin
Check_Is_Open (Sess);
declare
Handle : constant Statement_Handle :=
Soci_Create_Statement (Sess.Handle);
begin
return S : Statement do
S.Handle := Handle;
S.Initialized := True;
Check_Statement_State (S.Handle);
end return;
end;
end Make_Statement;
procedure Finalize (This : in out Statement) is
procedure Soci_Destroy_Statement (S : in Statement_Handle);
pragma Import (C, Soci_Destroy_Statement, "soci_destroy_statement");
begin
if This.Initialized then
Soci_Destroy_Statement (This.Handle);
This.Initialized := False;
end if;
end Finalize;
procedure Prepare (This : in Statement; Query : in String) is
procedure Soci_Prepare (St : in Statement_Handle; Q : in Interfaces.C.char_array);
pragma Import (C, Soci_Prepare, "soci_prepare");
Query_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Query);
begin
Soci_Prepare (This.Handle, Query_C);
Check_Statement_State (This.Handle);
end Prepare;
procedure Execute (This : in Statement; With_Data_Exchange : in Boolean := False) is
Result : constant Boolean := This.Execute (With_Data_Exchange);
begin
null;
end Execute;
function Execute
(This : in Statement;
With_Data_Exchange : in Boolean := False)
return Boolean is
function Soci_Execute
(St : in Statement_Handle;
WDE : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, Soci_Execute, "soci_execute");
WDE_C : Interfaces.C.int;
Result : Interfaces.C.int;
use type Interfaces.C.int;
begin
if With_Data_Exchange then
WDE_C := 1;
else
WDE_C := 0;
end if;
Result := Soci_Execute (This.Handle, WDE_C);
Check_Statement_State (This.Handle);
return Result /= 0;
end Execute;
function Fetch (This : in Statement) return Boolean is
function Soci_Fetch (St : in Statement_Handle) return Interfaces.C.int;
pragma Import (C, Soci_Fetch, "soci_fetch");
Result : constant Interfaces.C.int := Soci_Fetch (This.Handle);
use type Interfaces.C.int;
begin
Check_Statement_State (This.Handle);
return Result /= 0;
end Fetch;
function Got_Data (This : in Statement) return Boolean is
function Soci_Got_Data (St : in Statement_Handle) return Interfaces.C.int;
pragma Import (C, Soci_Got_Data, "soci_got_data");
Result : constant Interfaces.C.int := Soci_Got_Data (This.Handle);
use type Interfaces.C.int;
begin
Check_Statement_State (This.Handle);
return Result /= 0;
end Got_Data;
function Into_String (This : in Statement) return Into_Position is
function Soci_Into_String (St : in Statement_Handle) return Interfaces.C.int;
pragma Import (C, Soci_Into_String, "soci_into_string");
Result : constant Interfaces.C.int := Soci_Into_String (This.Handle);
begin
Check_Statement_State (This.Handle);
return Into_Position (Result);
end Into_String;
function Into_Integer (This : in Statement) return Into_Position is
function Soci_Into_Int (St : in Statement_Handle) return Interfaces.C.int;
pragma Import (C, Soci_Into_Int, "soci_into_int");
Result : constant Interfaces.C.int := Soci_Into_Int (This.Handle);
begin
Check_Statement_State (This.Handle);
return Into_Position (Result);
end Into_Integer;
function Into_Long_Long_Integer (This : in Statement) return Into_Position is
function Soci_Into_Long_Long (St : in Statement_Handle) return Interfaces.C.int;
pragma Import (C, Soci_Into_Long_Long, "soci_into_long_long");
Result : constant Interfaces.C.int := Soci_Into_Long_Long (This.Handle);
begin
Check_Statement_State (This.Handle);
return Into_Position (Result);
end Into_Long_Long_Integer;
function Into_Long_Float (This : in Statement) return Into_Position is
function Soci_Into_Double (St : in Statement_Handle) return Interfaces.C.int;
pragma Import (C, Soci_Into_Double, "soci_into_double");
Result : constant Interfaces.C.int := Soci_Into_Double (This.Handle);
begin
Check_Statement_State (This.Handle);
return Into_Position (Result);
end Into_Long_Float;
function Into_Time (This : in Statement) return Into_Position is
function Soci_Into_Date (St : in Statement_Handle) return Interfaces.C.int;
pragma Import (C, Soci_Into_Date, "soci_into_date");
Result : constant Interfaces.C.int := Soci_Into_Date (This.Handle);
begin
Check_Statement_State (This.Handle);
return Into_Position (Result);
end Into_Time;
function Into_Vector_String (This : in Statement) return Into_Position is
function Soci_Into_String_V (St : in Statement_Handle) return Interfaces.C.int;
pragma Import (C, Soci_Into_String_V, "soci_into_string_v");
Result : constant Interfaces.C.int := Soci_Into_String_V (This.Handle);
begin
Check_Statement_State (This.Handle);
return Into_Position (Result);
end Into_Vector_String;
function Into_Vector_Integer (This : in Statement) return Into_Position is
function Soci_Into_Int_V (St : in Statement_Handle) return Interfaces.C.int;
pragma Import (C, Soci_Into_Int_V, "soci_into_int_v");
Result : constant Interfaces.C.int := Soci_Into_Int_V (This.Handle);
begin
Check_Statement_State (This.Handle);
return Into_Position (Result);
end Into_Vector_Integer;
function Into_Vector_Long_Long_Integer (This : in Statement) return Into_Position is
function Soci_Into_Long_Long_V (St : in Statement_Handle) return Interfaces.C.int;
pragma Import (C, Soci_Into_Long_Long_V, "soci_into_long_long_v");
Result : constant Interfaces.C.int := Soci_Into_Long_Long_V (This.Handle);
begin
Check_Statement_State (This.Handle);
return Into_Position (Result);
end Into_Vector_Long_Long_Integer;
function Into_Vector_Long_Float (This : in Statement) return Into_Position is
function Soci_Into_Double_V (St : in Statement_Handle) return Interfaces.C.int;
pragma Import (C, Soci_Into_Double_V, "soci_into_double_v");
Result : constant Interfaces.C.int := Soci_Into_Double_V (This.Handle);
begin
Check_Statement_State (This.Handle);
return Into_Position (Result);
end Into_Vector_Long_Float;
function Into_Vector_Time (This : in Statement) return Into_Position is
function Soci_Into_Date_V (St : in Statement_Handle) return Interfaces.C.int;
pragma Import (C, Soci_Into_Date_V, "soci_into_date_v");
Result : constant Interfaces.C.int := Soci_Into_Date_V (This.Handle);
begin
Check_Statement_State (This.Handle);
return Into_Position (Result);
end Into_Vector_Time;
function Get_Into_State
(This : in Statement;
Position : in Into_Position)
return Data_State is
function Soci_Get_Into_State
(St : in Statement_Handle;
P : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, Soci_Get_Into_State, "soci_get_into_state");
Result : constant Interfaces.C.int :=
Soci_Get_Into_State (This.Handle, Interfaces.C.int (Position));
use type Interfaces.C.int;
begin
Check_Statement_State (This.Handle);
return Int_To_Data_State (Result);
end Get_Into_State;
function Get_Into_String
(This : in Statement;
Position : in Into_Position)
return String is
function Soci_Get_Into_String
(St : in Statement_Handle;
P : in Interfaces.C.int)
return Interfaces.C.Strings.chars_ptr;
pragma Import (C, Soci_Get_Into_String, "soci_get_into_string");
Result : constant Interfaces.C.Strings.chars_ptr :=
Soci_Get_Into_String (This.Handle, Interfaces.C.int (Position));
begin
Check_Statement_State (This.Handle);
return Interfaces.C.Strings.Value (Result);
end Get_Into_String;
function Get_Into_Integer
(This : in Statement;
Position : in Into_Position)
return DB_Integer is
function Soci_Get_Into_Int
(St : in Statement_Handle;
P : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, Soci_Get_Into_Int, "soci_get_into_int");
Result : constant Interfaces.C.int :=
Soci_Get_Into_Int (This.Handle, Interfaces.C.int (Position));
begin
Check_Statement_State (This.Handle);
return DB_Integer (Result);
end Get_Into_Integer;
function Get_Into_Long_Long_Integer
(This : in Statement;
Position : in Into_Position)
return DB_Long_Long_Integer is
function Soci_Get_Into_Long_Long
(St : in Statement_Handle;
P : in Interfaces.C.int)
return Interfaces.Integer_64;
pragma Import (C, Soci_Get_Into_Long_Long, "soci_get_into_long_long");
Result : constant Interfaces.Integer_64 :=
Soci_Get_Into_Long_Long (This.Handle, Interfaces.C.int (Position));
begin
Check_Statement_State (This.Handle);
return DB_Long_Long_Integer (Result);
end Get_Into_Long_Long_Integer;
function Get_Into_Long_Float
(This : in Statement;
Position : in Into_Position)
return DB_Long_Float is
function Soci_Get_Into_Double
(St : in Statement_Handle;
P : in Interfaces.C.int)
return Interfaces.C.double;
pragma Import (C, Soci_Get_Into_Double, "soci_get_into_double");
Result : constant Interfaces.C.double :=
Soci_Get_Into_Double (This.Handle, Interfaces.C.int (Position));
begin
Check_Statement_State (This.Handle);
return DB_Long_Float (Result);
end Get_Into_Long_Float;
function Get_Into_Time
(This : in Statement;
Position : in Into_Position)
return Ada.Calendar.Time is
function Soci_Get_Into_Date
(St : in Statement_Handle;
P : in Interfaces.C.int)
return Interfaces.C.Strings.chars_ptr;
pragma Import (C, Soci_Get_Into_Date, "soci_get_into_date");
Result_C : constant Interfaces.C.Strings.chars_ptr :=
Soci_Get_Into_Date (This.Handle, Interfaces.C.int (Position));
Result : constant String := Interfaces.C.Strings.Value (Result_C);
begin
Check_Statement_State (This.Handle);
return String_To_Time (Result);
end Get_Into_Time;
function Get_Into_Vectors_Size (This : in Statement) return Natural is
function Soci_Into_Get_Size_V
(St : in Statement_Handle)
return Interfaces.C.int;
pragma Import (C, Soci_Into_Get_Size_V, "soci_into_get_size_v");
Result_C : constant Interfaces.C.int := Soci_Into_Get_Size_V (This.Handle);
begin
Check_Statement_State (This.Handle);
return Natural (Result_C);
end Get_Into_Vectors_Size;
function Into_Vectors_First_Index (This : in Statement) return Vector_Index is
begin
return 0;
end Into_Vectors_First_Index;
function Into_Vectors_Last_Index (This : in Statement) return Vector_Index is
begin
return Vector_Index (This.Get_Into_Vectors_Size - 1);
end Into_Vectors_Last_Index;
procedure Into_Vectors_Resize (This : in Statement; New_Size : in Natural) is
procedure Soci_Into_Resize_V
(St : in Statement_Handle;
New_Size : in Interfaces.C.int);
pragma Import (C, Soci_Into_Resize_V, "soci_into_resize_v");
begin
Soci_Into_Resize_V (This.Handle, Interfaces.C.int (New_Size));
Check_Statement_State (This.Handle);
end Into_Vectors_Resize;
function Get_Into_Vector_State
(This : in Statement;
Position : in Into_Position;
Index : in Vector_Index)
return Data_State is
function Soci_Get_Into_State_V
(St : in Statement_Handle;
P : in Interfaces.C.int;
I : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, Soci_Get_Into_State_V, "soci_get_into_state_v");
Result : constant Interfaces.C.int :=
Soci_Get_Into_State_V
(This.Handle,
Interfaces.C.int (Position),
Interfaces.C.int (Index));
use type Interfaces.C.int;
begin
Check_Statement_State (This.Handle);
return Int_To_Data_State (Result);
end Get_Into_Vector_State;
function Get_Into_Vector_String
(This : in Statement;
Position : in Into_Position;
Index : in Vector_Index) return String is
function Soci_Get_Into_String_V
(St : in Statement_Handle;
P : in Interfaces.C.int;
I : in Interfaces.C.int)
return Interfaces.C.Strings.chars_ptr;
pragma Import (C, Soci_Get_Into_String_V, "soci_get_into_string_v");
Result : constant Interfaces.C.Strings.chars_ptr :=
Soci_Get_Into_String_V (This.Handle,
Interfaces.C.int (Position),
Interfaces.C.int (Index));
begin
Check_Statement_State (This.Handle);
return Interfaces.C.Strings.Value (Result);
end Get_Into_Vector_String;
function Get_Into_Vector_Integer
(This : in Statement;
Position : in Into_Position;
Index : in Vector_Index)
return DB_Integer is
function Soci_Get_Into_Int_V
(St : in Statement_Handle;
P : in Interfaces.C.int;
I : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, Soci_Get_Into_Int_V, "soci_get_into_int_v");
Result : constant Interfaces.C.int :=
Soci_Get_Into_Int_V (This.Handle,
Interfaces.C.int (Position),
Interfaces.C.int (Index));
begin
Check_Statement_State (This.Handle);
return DB_Integer (Result);
end Get_Into_Vector_Integer;
function Get_Into_Vector_Long_Long_Integer
(This : in Statement;
Position : in Into_Position;
Index : in Vector_Index)
return DB_Long_Long_Integer is
function Soci_Get_Into_Long_Long_V
(St : in Statement_Handle;
P : in Interfaces.C.int;
I : in Interfaces.C.int)
return Interfaces.Integer_64;
pragma Import (C, Soci_Get_Into_Long_Long_V, "soci_get_into_long_long_v");
Result : constant Interfaces.Integer_64 :=
Soci_Get_Into_Long_Long_V (This.Handle,
Interfaces.C.int (Position),
Interfaces.C.int (Index));
begin
Check_Statement_State (This.Handle);
return DB_Long_Long_Integer (Result);
end Get_Into_Vector_Long_Long_Integer;
function Get_Into_Vector_Long_Float
(This : in Statement;
Position : in Into_Position;
Index : in Vector_Index)
return DB_Long_Float is
function Soci_Get_Into_Double_V
(St : in Statement_Handle;
P : in Interfaces.C.int;
I : in Interfaces.C.int)
return Interfaces.C.double;
pragma Import (C, Soci_Get_Into_Double_V, "soci_get_into_double_v");
Result : constant Interfaces.C.double :=
Soci_Get_Into_Double_V (This.Handle,
Interfaces.C.int (Position),
Interfaces.C.int (Index));
begin
Check_Statement_State (This.Handle);
return DB_Long_Float (Result);
end Get_Into_Vector_Long_Float;
function Get_Into_Vector_Time
(This : in Statement;
Position : in Into_Position;
Index : in Vector_Index)
return Ada.Calendar.Time is
function Soci_Get_Into_Date_V
(St : in Statement_Handle;
P : in Interfaces.C.int;
I : in Interfaces.C.int)
return Interfaces.C.Strings.chars_ptr;
pragma Import (C, Soci_Get_Into_Date_V, "soci_get_into_date_v");
Result_C : constant Interfaces.C.Strings.chars_ptr :=
Soci_Get_Into_Date_V (This.Handle,
Interfaces.C.int (Position),
Interfaces.C.int (Index));
Result : constant String := Interfaces.C.Strings.Value (Result_C);
begin
Check_Statement_State (This.Handle);
return String_To_Time (Result);
end Get_Into_Vector_Time;
procedure Use_String (This : in Statement; Name : in String) is
procedure Soci_Use_String
(St : in Statement_Handle;
Name : in Interfaces.C.char_array);
pragma Import (C, Soci_Use_String, "soci_use_string");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
begin
Soci_Use_String (This.Handle, Name_C);
Check_Statement_State (This.Handle);
end Use_String;
procedure Use_Integer (This : in Statement; Name : in String) is
procedure Soci_Use_Int
(St : in Statement_Handle;
Name : in Interfaces.C.char_array);
pragma Import (C, Soci_Use_Int, "soci_use_int");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
begin
Soci_Use_Int (This.Handle, Name_C);
Check_Statement_State (This.Handle);
end Use_Integer;
procedure Use_Long_Long_Integer (This : in Statement; Name : in String) is
procedure Soci_Use_Long_Long
(St : in Statement_Handle;
Name : in Interfaces.C.char_array);
pragma Import (C, Soci_Use_Long_Long, "soci_use_long_long");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
begin
Soci_Use_Long_Long (This.Handle, Name_C);
Check_Statement_State (This.Handle);
end Use_Long_Long_Integer;
procedure Use_Long_Float (This : in Statement; Name : in String) is
procedure Soci_Use_Double
(St : in Statement_Handle;
Name : in Interfaces.C.char_array);
pragma Import (C, Soci_Use_Double, "soci_use_double");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
begin
Soci_Use_Double (This.Handle, Name_C);
Check_Statement_State (This.Handle);
end Use_Long_Float;
procedure Use_Time (This : in Statement; Name : in String) is
procedure Soci_Use_Date
(St : in Statement_Handle;
Name : in Interfaces.C.char_array);
pragma Import (C, Soci_Use_Date, "soci_use_date");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
begin
Soci_Use_Date (This.Handle, Name_C);
Check_Statement_State (This.Handle);
end Use_Time;
procedure Use_Vector_String (This : in Statement; Name : in String) is
procedure Soci_Use_String_V
(St : in Statement_Handle;
Name : in Interfaces.C.char_array);
pragma Import (C, Soci_Use_String_V, "soci_use_string_v");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
begin
Soci_Use_String_V (This.Handle, Name_C);
Check_Statement_State (This.Handle);
end Use_Vector_String;
procedure Use_Vector_Integer (This : in Statement; Name : in String) is
procedure Soci_Use_Int_V
(St : in Statement_Handle;
Name : in Interfaces.C.char_array);
pragma Import (C, Soci_Use_Int_V, "soci_use_int_v");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
begin
Soci_Use_Int_V (This.Handle, Name_C);
Check_Statement_State (This.Handle);
end Use_Vector_Integer;
procedure Use_Vector_Long_Long_Integer (This : in Statement; Name : in String) is
procedure Soci_Use_Long_Long_V
(St : in Statement_Handle;
Name : in Interfaces.C.char_array);
pragma Import (C, Soci_Use_Long_Long_V, "soci_use_long_long_v");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
begin
Soci_Use_Long_Long_V (This.Handle, Name_C);
Check_Statement_State (This.Handle);
end Use_Vector_Long_Long_Integer;
procedure Use_Vector_Long_Float (This : in Statement; Name : in String) is
procedure Soci_Use_Double_V
(St : in Statement_Handle;
Name : in Interfaces.C.char_array);
pragma Import (C, Soci_Use_Double_V, "soci_use_double_v");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
begin
Soci_Use_Double_V (This.Handle, Name_C);
Check_Statement_State (This.Handle);
end Use_Vector_Long_Float;
procedure Use_Vector_Time (This : in Statement; Name : in String) is
procedure Soci_Use_Date_V
(St : in Statement_Handle;
Name : in Interfaces.C.char_array);
pragma Import (C, Soci_Use_Date_V, "soci_use_date_v");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
begin
Soci_Use_Date_V (This.Handle, Name_C);
Check_Statement_State (This.Handle);
end Use_Vector_Time;
procedure Set_Use_State
(This : in Statement;
Name : in String;
State : in Data_State) is
procedure Soci_Set_Use_State
(St : in Statement_Handle;
Name : in Interfaces.C.char_array;
State : in Interfaces.C.int);
pragma Import (C, Soci_Set_Use_State, "soci_set_use_state");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
State_C : constant Interfaces.C.int := Data_State_To_Int (State);
begin
Soci_Set_Use_State (This.Handle, Name_C, State_C);
Check_Statement_State (This.Handle);
end Set_Use_State;
procedure Set_Use_String
(This : in Statement;
Name : in String;
Value : in String) is
procedure Soci_Set_Use_String
(St : in Statement_Handle;
Name : in Interfaces.C.char_array;
Value : in Interfaces.C.char_array);
pragma Import (C, Soci_Set_Use_String, "soci_set_use_string");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
Value_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Value);
begin
Soci_Set_Use_String (This.Handle, Name_C, Value_C);
Check_Statement_State (This.Handle);
end Set_Use_String;
procedure Set_Use_Integer
(This : in Statement;
Name : in String;
Value : in DB_Integer) is
procedure Soci_Set_Use_Int
(St : in Statement_Handle;
Name : in Interfaces.C.char_array;
Value : in Interfaces.C.int);
pragma Import (C, Soci_Set_Use_Int, "soci_set_use_int");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
Value_C : constant Interfaces.C.int := Interfaces.C.int (Value);
begin
Soci_Set_Use_Int (This.Handle, Name_C, Value_C);
Check_Statement_State (This.Handle);
end Set_Use_Integer;
procedure Set_Use_Long_Long_Integer
(This : in Statement;
Name : in String;
Value : in DB_Long_Long_Integer) is
procedure Soci_Set_Use_Long_Long
(St : in Statement_Handle;
Name : in Interfaces.C.char_array;
Value : in Interfaces.Integer_64);
pragma Import (C, Soci_Set_Use_Long_Long, "soci_set_use_long_long");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
Value_C : constant Interfaces.Integer_64 := Interfaces.Integer_64 (Value);
begin
Soci_Set_Use_Long_Long (This.Handle, Name_C, Value_C);
Check_Statement_State (This.Handle);
end Set_Use_Long_Long_Integer;
procedure Set_Use_Long_Float
(This : in Statement;
Name : in String;
Value : in DB_Long_Float) is
procedure Soci_Set_Use_Double
(St : in Statement_Handle;
Name : in Interfaces.C.char_array;
Value : in Interfaces.C.double);
pragma Import (C, Soci_Set_Use_Double, "soci_set_use_double");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
Value_C : constant Interfaces.C.double := Interfaces.C.double (Value);
begin
Soci_Set_Use_Double (This.Handle, Name_C, Value_C);
Check_Statement_State (This.Handle);
end Set_Use_Long_Float;
procedure Set_Use_Time
(This : in Statement;
Name : in String;
Value : in Ada.Calendar.Time) is
procedure Soci_Set_Use_Date
(St : in Statement_Handle;
Name : in Interfaces.C.char_array;
Value : in Interfaces.C.char_array);
pragma Import (C, Soci_Set_Use_Date, "soci_set_use_date");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
Value_C : constant Interfaces.C.char_array :=
Interfaces.C.To_C (Time_To_String (Value));
begin
Soci_Set_Use_Date (This.Handle, Name_C, Value_C);
Check_Statement_State (This.Handle);
end Set_Use_Time;
function Get_Use_Vectors_Size (This : in Statement) return Natural is
function Soci_Use_Get_Size_V
(St : in Statement_Handle)
return Interfaces.C.int;
pragma Import (C, Soci_Use_Get_Size_V, "soci_use_get_size_v");
Result_C : constant Interfaces.C.int := Soci_Use_Get_Size_V (This.Handle);
begin
Check_Statement_State (This.Handle);
return Natural (Result_C);
end Get_Use_Vectors_Size;
function Use_Vectors_First_Index (This : in Statement) return Vector_Index is
begin
return 0;
end Use_Vectors_First_Index;
function Use_Vectors_Last_Index (This : in Statement) return Vector_Index is
begin
return Vector_Index (This.Get_Use_Vectors_Size - 1);
end Use_Vectors_Last_Index;
procedure Use_Vectors_Resize (This : in Statement; New_Size : in Natural) is
procedure Soci_Use_Resize_V
(St : in Statement_Handle;
New_Size : in Interfaces.C.int);
pragma Import (C, Soci_Use_Resize_V, "soci_use_resize_v");
begin
Soci_Use_Resize_V (This.Handle, Interfaces.C.int (New_Size));
Check_Statement_State (This.Handle);
end Use_Vectors_Resize;
procedure Set_Use_Vector_State
(This : in Statement;
Name : in String;
Index : in Vector_Index;
State : in Data_State) is
procedure Soci_Set_Use_State_V
(St : in Statement_Handle;
Name : in Interfaces.C.char_array;
Index : in Interfaces.C.int;
State : in Interfaces.C.int);
pragma Import (C, Soci_Set_Use_State_V, "soci_set_use_state_v");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
Index_C : constant Interfaces.C.int := Interfaces.C.int (Index);
State_C : constant Interfaces.C.int := Data_State_To_Int (State);
begin
Soci_Set_Use_State_V (This.Handle, Name_C, Index_C, State_C);
Check_Statement_State (This.Handle);
end Set_Use_Vector_State;
procedure Set_Use_Vector_String
(This : in Statement;
Name : in String;
Index : in Vector_Index;
Value : in String) is
procedure Soci_Set_Use_String_V
(St : in Statement_Handle;
Name : in Interfaces.C.char_array;
Index : in Interfaces.C.int;
Value : in Interfaces.C.char_array);
pragma Import (C, Soci_Set_Use_String_V, "soci_set_use_string_v");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
Index_C : constant Interfaces.C.int := Interfaces.C.int (Index);
Value_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Value);
begin
Soci_Set_Use_String_V (This.Handle, Name_C, Index_C, Value_C);
Check_Statement_State (This.Handle);
end Set_Use_Vector_String;
procedure Set_Use_Vector_Integer
(This : in Statement;
Name : in String;
Index : in Vector_Index;
Value : in DB_Integer) is
procedure Soci_Set_Use_Int_V
(St : in Statement_Handle;
Name : in Interfaces.C.char_array;
Index : in Interfaces.C.int;
Value : in Interfaces.C.int);
pragma Import (C, Soci_Set_Use_Int_V, "soci_set_use_int_v");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
Index_C : constant Interfaces.C.int := Interfaces.C.int (Index);
Value_C : constant Interfaces.C.int := Interfaces.C.int (Value);
begin
Soci_Set_Use_Int_V (This.Handle, Name_C, Index_C, Value_C);
Check_Statement_State (This.Handle);
end Set_Use_Vector_Integer;
procedure Set_Use_Vector_Long_Long_Integer
(This : in Statement;
Name : in String;
Index : in Vector_Index;
Value : in DB_Long_Long_Integer) is
procedure Soci_Set_Use_Long_Long_V
(St : in Statement_Handle;
Name : in Interfaces.C.char_array;
Index : in Interfaces.C.int;
Value : in Interfaces.Integer_64);
pragma Import (C, Soci_Set_Use_Long_Long_V, "soci_set_use_long_long_v");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
Index_C : constant Interfaces.C.int := Interfaces.C.int (Index);
Value_C : constant Interfaces.Integer_64 := Interfaces.Integer_64 (Value);
begin
Soci_Set_Use_Long_Long_V (This.Handle, Name_C, Index_C, Value_C);
Check_Statement_State (This.Handle);
end Set_Use_Vector_Long_Long_Integer;
procedure Set_Use_Vector_Long_Float
(This : in Statement;
Name : in String;
Index : in Vector_Index;
Value : in DB_Long_Float) is
procedure Soci_Set_Use_Double_V
(St : in Statement_Handle;
Name : in Interfaces.C.char_array;
Index : in Interfaces.C.int;
Value : in Interfaces.C.double);
pragma Import (C, Soci_Set_Use_Double_V, "soci_set_use_double_v");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
Index_C : constant Interfaces.C.int := Interfaces.C.int (Index);
Value_C : constant Interfaces.C.double := Interfaces.C.double (Value);
begin
Soci_Set_Use_Double_V (This.Handle, Name_C, Index_C, Value_C);
Check_Statement_State (This.Handle);
end Set_Use_Vector_Long_Float;
procedure Set_Use_Vector_Time
(This : in Statement;
Name : in String;
Index : in Vector_Index;
Value : in Ada.Calendar.Time) is
procedure Soci_Set_Use_Date_V
(St : in Statement_Handle;
Name : in Interfaces.C.char_array;
Index : in Interfaces.C.int;
Value : in Interfaces.C.char_array);
pragma Import (C, Soci_Set_Use_Date_V, "soci_set_use_date_v");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
Index_C : constant Interfaces.C.int := Interfaces.C.int (Index);
Value_C : constant Interfaces.C.char_array :=
Interfaces.C.To_C (Time_To_String (Value));
begin
Soci_Set_Use_Date_V (This.Handle, Name_C, Index_C, Value_C);
Check_Statement_State (This.Handle);
end Set_Use_Vector_Time;
function Get_Use_State
(This : in Statement;
Name : in String) return Data_State is
function Soci_Get_Use_State
(St : in Statement_Handle;
Name : in Interfaces.C.char_array)
return Interfaces.C.int;
pragma Import (C, Soci_Get_Use_State, "soci_get_use_state");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
Result : constant Interfaces.C.int :=
Soci_Get_Use_State (This.Handle, Name_C);
use type Interfaces.C.int;
begin
Check_Statement_State (This.Handle);
return Int_To_Data_State (Result);
end Get_Use_State;
function Get_Use_String
(This : in Statement;
Name : in String)
return String is
function Soci_Get_Use_String
(St : in Statement_Handle;
Name : in Interfaces.C.char_array)
return Interfaces.C.Strings.chars_ptr;
pragma Import (C, Soci_Get_Use_String, "soci_get_use_string");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
Result : constant Interfaces.C.Strings.chars_ptr :=
Soci_Get_Use_String (This.Handle, Name_C);
begin
Check_Statement_State (This.Handle);
return Interfaces.C.Strings.Value (Result);
end Get_Use_String;
function Get_Use_Integer
(This : in Statement;
Name : in String)
return DB_Integer is
function Soci_Get_Use_Int
(St : in Statement_Handle;
Name : in Interfaces.C.char_array)
return Interfaces.C.int;
pragma Import (C, Soci_Get_Use_Int, "soci_get_use_int");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
Result : constant Interfaces.C.int :=
Soci_Get_Use_Int (This.Handle, Name_C);
begin
Check_Statement_State (This.Handle);
return DB_Integer (Result);
end Get_Use_Integer;
function Get_Use_Long_Long_Integer
(This : in Statement;
Name : in String)
return DB_Long_Long_Integer is
function Soci_Get_Use_Long_Long
(St : in Statement_Handle;
Name : in Interfaces.C.char_array)
return Interfaces.Integer_64;
pragma Import (C, Soci_Get_Use_Long_Long, "soci_get_use_long_long");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
Result : constant Interfaces.Integer_64 :=
Soci_Get_Use_Long_Long (This.Handle, Name_C);
begin
Check_Statement_State (This.Handle);
return DB_Long_Long_Integer (Result);
end Get_Use_Long_Long_Integer;
function Get_Use_Long_Float
(This : in Statement;
Name : in String)
return DB_Long_Float is
function Soci_Get_Use_Double
(St : in Statement_Handle;
Name : in Interfaces.C.char_array)
return Interfaces.C.double;
pragma Import (C, Soci_Get_Use_Double, "soci_get_use_double");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
Result : constant Interfaces.C.double :=
Soci_Get_Use_Double (This.Handle, Name_C);
begin
Check_Statement_State (This.Handle);
return DB_Long_Float (Result);
end Get_Use_Long_Float;
function Get_Use_Time
(This : in Statement;
Name : in String)
return Ada.Calendar.Time is
function Soci_Get_Use_Date
(St : in Statement_Handle;
Name : in Interfaces.C.char_array)
return Interfaces.C.Strings.chars_ptr;
pragma Import (C, Soci_Get_Use_Date, "soci_get_use_date");
Name_C : constant Interfaces.C.char_array := Interfaces.C.To_C (Name);
Result_C : constant Interfaces.C.Strings.chars_ptr :=
Soci_Get_Use_Date (This.Handle, Name_C);
Result : constant String := Interfaces.C.Strings.Value (Result_C);
begin
Check_Statement_State (This.Handle);
return String_To_Time (Result);
end Get_Use_Time;
end SOCI;
|
reznikmm/matreshka | Ada | 4,112 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- 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$
------------------------------------------------------------------------------
generic
type Enum is (<>);
package League.Holders.Generic_Enumerations is
pragma Preelaborate;
Value_Tag : constant Tag;
function Element (Self : Holder) return Enum;
-- Returns internal value.
procedure Replace_Element (Self : in out Holder; To : Enum);
-- Set value. Tag of the value must be set before this call.
function To_Holder (Item : Enum) return Holder;
-- Creates new Value from specified value.
private
type Enumeration_Container is new Abstract_Container with record
Value : Enum;
end record;
overriding function Constructor
(Is_Empty : not null access Boolean) return Enumeration_Container;
Value_Tag : constant Tag := Tag (Enumeration_Container'Tag);
end League.Holders.Generic_Enumerations;
|
Fabien-Chouteau/AGATE | Ada | 2,712 | adb | ------------------------------------------------------------------------------
-- --
-- Copyright (C) 2018, Fabien Chouteau --
-- --
-- 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 body AGATE.Console is
-----------
-- Print --
-----------
procedure Print (C : Character) is null;
-----------
-- Print --
-----------
procedure Print (Str : String) is null;
----------------
-- Print_Line --
----------------
procedure Print_Line (Str : String) is null;
end AGATE.Console;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 381 | ads | with STM32_SVD.SPI;
with STM32_SVD; use STM32_SVD;
package STM32GD.SPI is
pragma Preelaborate;
SPI_1 : STM32_SVD.SPI.SPI_Peripheral renames STM32_SVD.SPI.SPI1_Periph;
type SPI_Data_Size is
(Data_Size_8b,
Data_Size_16b);
type SPI_Data_8b is array (Natural range <>) of Byte;
type SPI_Data_16b is array (Natural range <>) of UInt16;
end STM32GD.SPI;
|
PThierry/ewok-kernel | Ada | 24 | ads | ../stm32f439/soc-rcc.ads |
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 551 | adb | with System; use System;
with Ada.Unchecked_Conversion;
with STM32_SVD.DMA; use STM32_SVD.DMA;
package body STM32GD.USART.IRQ is
protected body IRQ_Handler is
entry Wait when Data_Available is
begin
Data_Available := False;
end Wait;
procedure Handler is
begin
USART.ICR.TCCF := 1;
USART.ICR.IDLECF := 1;
USART.ICR.EOBCF := 1;
Data_Available := True;
end Handler;
end IRQ_Handler;
procedure Init is
begin
null;
end Init;
end STM32GD.USART.IRQ;
|
stcarrez/ada-wiki | Ada | 1,077 | ads | -----------------------------------------------------------------------
-- wiki-parsers-google -- Google Code parser operations
-- Copyright (C) 2011 - 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.
-----------------------------------------------------------------------
private package Wiki.Parsers.Google with Preelaborate is
procedure Parse_Line (Parser : in out Parser_Type;
Text : in Wiki.Buffers.Buffer_Access);
end Wiki.Parsers.Google;
|
reznikmm/gela | Ada | 3,607 | adb | with Asis;
with Asis.Errors;
with Asis.Exceptions;
with Asis.Implementation;
with Asis.Ada_Environments;
with Asis.Compilation_Units;
with Ada.Exceptions;
with Ada.Wide_Text_IO;
with Ada.Strings.Wide_Unbounded; use Ada.Strings.Wide_Unbounded;
with Ada.Command_Line; use Ada.Command_Line;
with Ada.Characters.Handling; use Ada.Characters.Handling;
procedure Asis_Hello_World is
procedure Help is
begin
Ada.Wide_Text_IO.Put_Line ("prog [-I/path/to/adalib] -I/path/to/sources/ [--debug=<Prop_List>] unit.adb");
Ada.Wide_Text_IO.Put_Line (" <Prop_List> ::= <prop>[,<Prop_List>]");
Ada.Wide_Text_IO.Put_Line (" <Prop> ::= UP | DOWN | EN_IN | ENV_OUT | FULL_NAME");
Ada.Wide_Text_IO.Put_Line ("");
Ada.Wide_Text_IO.Put_Line ("Note: You should provide a path to standard library files through -I");
Ada.Wide_Text_IO.Put_Line ("or through GELA_INCLUDE_PATH environment variable.");
end Help;
Invalid_Number_Of_Arguments : exception;
My_Context_Name : constant Wide_String := Asis.Ada_Environments.Default_Name;
Initialization_Parameters : constant Wide_String := "";
Finalization_Parameters : constant Wide_String := "";
My_Context_Parameters : Unbounded_Wide_String := Null_Unbounded_Wide_String;
My_Context : Asis.Context;
begin
if Argument_Count not in 2 .. 4 then
if Argument_Count = 0 then
Help;
else
raise Invalid_Number_Of_Arguments;
end if;
end if;
Append (My_Context_Parameters, To_Wide_String (Argument (1)));
for I in 2 .. Argument_Count loop
Append (My_Context_Parameters, " " & To_Wide_String (Argument (I)));
end loop;
Asis.Implementation.Initialize (Initialization_Parameters);
Asis.Ada_Environments.Associate
(The_Context => My_Context,
Name => My_Context_Name,
Parameters => To_Wide_String (My_Context_Parameters));
Asis.Ada_Environments.Open (My_Context);
declare
use Asis.Compilation_Units;
Units : Asis.Compilation_Unit_List := Compilation_Units (My_Context);
begin
for J in Units'Range loop
Ada.Wide_Text_IO.Put_Line
(Text_Name (Units (J)) & " => " & Unit_Full_Name (Units (J)));
end loop;
end;
Asis.Ada_Environments.Close (My_Context);
Asis.Ada_Environments.Dissociate (My_Context);
Asis.Implementation.Finalize (Finalization_Parameters);
Set_Exit_Status (Success);
exception
when E : Asis.Exceptions.ASIS_Inappropriate_Context |
Asis.Exceptions.ASIS_Inappropriate_Container |
Asis.Exceptions.ASIS_Inappropriate_Compilation_Unit |
Asis.Exceptions.ASIS_Inappropriate_Element |
Asis.Exceptions.ASIS_Inappropriate_Line |
Asis.Exceptions.ASIS_Inappropriate_Line_Number |
Asis.Exceptions.ASIS_Failed =>
Ada.Wide_Text_IO.Put_Line
("ASIS exception (" &
To_Wide_String (Ada.Exceptions.Exception_Name (E)) &
") is raised");
Ada.Wide_Text_IO.Put_Line
("ASIS Error Status is " &
Asis.Errors.Error_Kinds'Wide_Image (Asis.Implementation.Status));
Ada.Wide_Text_IO.Put_Line ("ASIS Diagnosis is ");
Ada.Wide_Text_IO.Put_Line (Asis.Implementation.Diagnosis);
Asis.Implementation.Set_Status;
when Invalid_Number_Of_Arguments =>
Ada.Wide_Text_IO.Put_Line (">>> Invalid number of arguments");
Help;
end Asis_Hello_World;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 24,817 | ads | -- This spec has been automatically generated from STM32F303xE.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with System;
package STM32_SVD.USART is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype CR1_UE_Field is STM32_SVD.Bit;
subtype CR1_UESM_Field is STM32_SVD.Bit;
subtype CR1_RE_Field is STM32_SVD.Bit;
subtype CR1_TE_Field is STM32_SVD.Bit;
subtype CR1_IDLEIE_Field is STM32_SVD.Bit;
subtype CR1_RXNEIE_Field is STM32_SVD.Bit;
subtype CR1_TCIE_Field is STM32_SVD.Bit;
subtype CR1_TXEIE_Field is STM32_SVD.Bit;
subtype CR1_PEIE_Field is STM32_SVD.Bit;
subtype CR1_PS_Field is STM32_SVD.Bit;
subtype CR1_PCE_Field is STM32_SVD.Bit;
subtype CR1_WAKE_Field is STM32_SVD.Bit;
subtype CR1_M_Field is STM32_SVD.Bit;
subtype CR1_MME_Field is STM32_SVD.Bit;
subtype CR1_CMIE_Field is STM32_SVD.Bit;
subtype CR1_OVER8_Field is STM32_SVD.Bit;
subtype CR1_DEDT_Field is STM32_SVD.UInt5;
subtype CR1_DEAT_Field is STM32_SVD.UInt5;
subtype CR1_RTOIE_Field is STM32_SVD.Bit;
subtype CR1_EOBIE_Field is STM32_SVD.Bit;
-- Control register 1
type CR1_Register is record
-- USART enable
UE : CR1_UE_Field := 16#0#;
-- USART enable in Stop mode
UESM : CR1_UESM_Field := 16#0#;
-- Receiver enable
RE : CR1_RE_Field := 16#0#;
-- Transmitter enable
TE : CR1_TE_Field := 16#0#;
-- IDLE interrupt enable
IDLEIE : CR1_IDLEIE_Field := 16#0#;
-- RXNE interrupt enable
RXNEIE : CR1_RXNEIE_Field := 16#0#;
-- Transmission complete interrupt enable
TCIE : CR1_TCIE_Field := 16#0#;
-- interrupt enable
TXEIE : CR1_TXEIE_Field := 16#0#;
-- PE interrupt enable
PEIE : CR1_PEIE_Field := 16#0#;
-- Parity selection
PS : CR1_PS_Field := 16#0#;
-- Parity control enable
PCE : CR1_PCE_Field := 16#0#;
-- Receiver wakeup method
WAKE : CR1_WAKE_Field := 16#0#;
-- Word length
M : CR1_M_Field := 16#0#;
-- Mute mode enable
MME : CR1_MME_Field := 16#0#;
-- Character match interrupt enable
CMIE : CR1_CMIE_Field := 16#0#;
-- Oversampling mode
OVER8 : CR1_OVER8_Field := 16#0#;
-- Driver Enable deassertion time
DEDT : CR1_DEDT_Field := 16#0#;
-- Driver Enable assertion time
DEAT : CR1_DEAT_Field := 16#0#;
-- Receiver timeout interrupt enable
RTOIE : CR1_RTOIE_Field := 16#0#;
-- End of Block interrupt enable
EOBIE : CR1_EOBIE_Field := 16#0#;
-- unspecified
Reserved_28_31 : STM32_SVD.UInt4 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR1_Register use record
UE at 0 range 0 .. 0;
UESM at 0 range 1 .. 1;
RE at 0 range 2 .. 2;
TE at 0 range 3 .. 3;
IDLEIE at 0 range 4 .. 4;
RXNEIE at 0 range 5 .. 5;
TCIE at 0 range 6 .. 6;
TXEIE at 0 range 7 .. 7;
PEIE at 0 range 8 .. 8;
PS at 0 range 9 .. 9;
PCE at 0 range 10 .. 10;
WAKE at 0 range 11 .. 11;
M at 0 range 12 .. 12;
MME at 0 range 13 .. 13;
CMIE at 0 range 14 .. 14;
OVER8 at 0 range 15 .. 15;
DEDT at 0 range 16 .. 20;
DEAT at 0 range 21 .. 25;
RTOIE at 0 range 26 .. 26;
EOBIE at 0 range 27 .. 27;
Reserved_28_31 at 0 range 28 .. 31;
end record;
subtype CR2_ADDM7_Field is STM32_SVD.Bit;
subtype CR2_LBDL_Field is STM32_SVD.Bit;
subtype CR2_LBDIE_Field is STM32_SVD.Bit;
subtype CR2_LBCL_Field is STM32_SVD.Bit;
subtype CR2_CPHA_Field is STM32_SVD.Bit;
subtype CR2_CPOL_Field is STM32_SVD.Bit;
subtype CR2_CLKEN_Field is STM32_SVD.Bit;
subtype CR2_STOP_Field is STM32_SVD.UInt2;
subtype CR2_LINEN_Field is STM32_SVD.Bit;
subtype CR2_SWAP_Field is STM32_SVD.Bit;
subtype CR2_RXINV_Field is STM32_SVD.Bit;
subtype CR2_TXINV_Field is STM32_SVD.Bit;
subtype CR2_DATAINV_Field is STM32_SVD.Bit;
subtype CR2_MSBFIRST_Field is STM32_SVD.Bit;
subtype CR2_ABREN_Field is STM32_SVD.Bit;
subtype CR2_ABRMOD_Field is STM32_SVD.UInt2;
subtype CR2_RTOEN_Field is STM32_SVD.Bit;
-- CR2_ADD array element
subtype CR2_ADD_Element is STM32_SVD.UInt4;
-- CR2_ADD array
type CR2_ADD_Field_Array is array (0 .. 1) of CR2_ADD_Element
with Component_Size => 4, Size => 8;
-- Type definition for CR2_ADD
type CR2_ADD_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- ADD as a value
Val : STM32_SVD.Byte;
when True =>
-- ADD as an array
Arr : CR2_ADD_Field_Array;
end case;
end record
with Unchecked_Union, Size => 8;
for CR2_ADD_Field use record
Val at 0 range 0 .. 7;
Arr at 0 range 0 .. 7;
end record;
-- Control register 2
type CR2_Register is record
-- unspecified
Reserved_0_3 : STM32_SVD.UInt4 := 16#0#;
-- 7-bit Address Detection/4-bit Address Detection
ADDM7 : CR2_ADDM7_Field := 16#0#;
-- LIN break detection length
LBDL : CR2_LBDL_Field := 16#0#;
-- LIN break detection interrupt enable
LBDIE : CR2_LBDIE_Field := 16#0#;
-- unspecified
Reserved_7_7 : STM32_SVD.Bit := 16#0#;
-- Last bit clock pulse
LBCL : CR2_LBCL_Field := 16#0#;
-- Clock phase
CPHA : CR2_CPHA_Field := 16#0#;
-- Clock polarity
CPOL : CR2_CPOL_Field := 16#0#;
-- Clock enable
CLKEN : CR2_CLKEN_Field := 16#0#;
-- STOP bits
STOP : CR2_STOP_Field := 16#0#;
-- LIN mode enable
LINEN : CR2_LINEN_Field := 16#0#;
-- Swap TX/RX pins
SWAP : CR2_SWAP_Field := 16#0#;
-- RX pin active level inversion
RXINV : CR2_RXINV_Field := 16#0#;
-- TX pin active level inversion
TXINV : CR2_TXINV_Field := 16#0#;
-- Binary data inversion
DATAINV : CR2_DATAINV_Field := 16#0#;
-- Most significant bit first
MSBFIRST : CR2_MSBFIRST_Field := 16#0#;
-- Auto baud rate enable
ABREN : CR2_ABREN_Field := 16#0#;
-- Auto baud rate mode
ABRMOD : CR2_ABRMOD_Field := 16#0#;
-- Receiver timeout enable
RTOEN : CR2_RTOEN_Field := 16#0#;
-- Address of the USART node
ADD : CR2_ADD_Field := (As_Array => False, Val => 16#0#);
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR2_Register use record
Reserved_0_3 at 0 range 0 .. 3;
ADDM7 at 0 range 4 .. 4;
LBDL at 0 range 5 .. 5;
LBDIE at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
LBCL at 0 range 8 .. 8;
CPHA at 0 range 9 .. 9;
CPOL at 0 range 10 .. 10;
CLKEN at 0 range 11 .. 11;
STOP at 0 range 12 .. 13;
LINEN at 0 range 14 .. 14;
SWAP at 0 range 15 .. 15;
RXINV at 0 range 16 .. 16;
TXINV at 0 range 17 .. 17;
DATAINV at 0 range 18 .. 18;
MSBFIRST at 0 range 19 .. 19;
ABREN at 0 range 20 .. 20;
ABRMOD at 0 range 21 .. 22;
RTOEN at 0 range 23 .. 23;
ADD at 0 range 24 .. 31;
end record;
subtype CR3_EIE_Field is STM32_SVD.Bit;
subtype CR3_IREN_Field is STM32_SVD.Bit;
subtype CR3_IRLP_Field is STM32_SVD.Bit;
subtype CR3_HDSEL_Field is STM32_SVD.Bit;
subtype CR3_NACK_Field is STM32_SVD.Bit;
subtype CR3_SCEN_Field is STM32_SVD.Bit;
subtype CR3_DMAR_Field is STM32_SVD.Bit;
subtype CR3_DMAT_Field is STM32_SVD.Bit;
subtype CR3_RTSE_Field is STM32_SVD.Bit;
subtype CR3_CTSE_Field is STM32_SVD.Bit;
subtype CR3_CTSIE_Field is STM32_SVD.Bit;
subtype CR3_ONEBIT_Field is STM32_SVD.Bit;
subtype CR3_OVRDIS_Field is STM32_SVD.Bit;
subtype CR3_DDRE_Field is STM32_SVD.Bit;
subtype CR3_DEM_Field is STM32_SVD.Bit;
subtype CR3_DEP_Field is STM32_SVD.Bit;
subtype CR3_SCARCNT_Field is STM32_SVD.UInt3;
subtype CR3_WUS_Field is STM32_SVD.UInt2;
subtype CR3_WUFIE_Field is STM32_SVD.Bit;
-- Control register 3
type CR3_Register is record
-- Error interrupt enable
EIE : CR3_EIE_Field := 16#0#;
-- IrDA mode enable
IREN : CR3_IREN_Field := 16#0#;
-- IrDA low-power
IRLP : CR3_IRLP_Field := 16#0#;
-- Half-duplex selection
HDSEL : CR3_HDSEL_Field := 16#0#;
-- Smartcard NACK enable
NACK : CR3_NACK_Field := 16#0#;
-- Smartcard mode enable
SCEN : CR3_SCEN_Field := 16#0#;
-- DMA enable receiver
DMAR : CR3_DMAR_Field := 16#0#;
-- DMA enable transmitter
DMAT : CR3_DMAT_Field := 16#0#;
-- RTS enable
RTSE : CR3_RTSE_Field := 16#0#;
-- CTS enable
CTSE : CR3_CTSE_Field := 16#0#;
-- CTS interrupt enable
CTSIE : CR3_CTSIE_Field := 16#0#;
-- One sample bit method enable
ONEBIT : CR3_ONEBIT_Field := 16#0#;
-- Overrun Disable
OVRDIS : CR3_OVRDIS_Field := 16#0#;
-- DMA Disable on Reception Error
DDRE : CR3_DDRE_Field := 16#0#;
-- Driver enable mode
DEM : CR3_DEM_Field := 16#0#;
-- Driver enable polarity selection
DEP : CR3_DEP_Field := 16#0#;
-- unspecified
Reserved_16_16 : STM32_SVD.Bit := 16#0#;
-- Smartcard auto-retry count
SCARCNT : CR3_SCARCNT_Field := 16#0#;
-- Wakeup from Stop mode interrupt flag selection
WUS : CR3_WUS_Field := 16#0#;
-- Wakeup from Stop mode interrupt enable
WUFIE : CR3_WUFIE_Field := 16#0#;
-- unspecified
Reserved_23_31 : STM32_SVD.UInt9 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CR3_Register use record
EIE at 0 range 0 .. 0;
IREN at 0 range 1 .. 1;
IRLP at 0 range 2 .. 2;
HDSEL at 0 range 3 .. 3;
NACK at 0 range 4 .. 4;
SCEN at 0 range 5 .. 5;
DMAR at 0 range 6 .. 6;
DMAT at 0 range 7 .. 7;
RTSE at 0 range 8 .. 8;
CTSE at 0 range 9 .. 9;
CTSIE at 0 range 10 .. 10;
ONEBIT at 0 range 11 .. 11;
OVRDIS at 0 range 12 .. 12;
DDRE at 0 range 13 .. 13;
DEM at 0 range 14 .. 14;
DEP at 0 range 15 .. 15;
Reserved_16_16 at 0 range 16 .. 16;
SCARCNT at 0 range 17 .. 19;
WUS at 0 range 20 .. 21;
WUFIE at 0 range 22 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
subtype BRR_DIV_Fraction_Field is STM32_SVD.UInt4;
subtype BRR_DIV_Mantissa_Field is STM32_SVD.UInt12;
-- Baud rate register
type BRR_Register is record
-- fraction of USARTDIV
DIV_Fraction : BRR_DIV_Fraction_Field := 16#0#;
-- mantissa of USARTDIV
DIV_Mantissa : BRR_DIV_Mantissa_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for BRR_Register use record
DIV_Fraction at 0 range 0 .. 3;
DIV_Mantissa at 0 range 4 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype GTPR_PSC_Field is STM32_SVD.Byte;
subtype GTPR_GT_Field is STM32_SVD.Byte;
-- Guard time and prescaler register
type GTPR_Register is record
-- Prescaler value
PSC : GTPR_PSC_Field := 16#0#;
-- Guard time value
GT : GTPR_GT_Field := 16#0#;
-- unspecified
Reserved_16_31 : STM32_SVD.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for GTPR_Register use record
PSC at 0 range 0 .. 7;
GT at 0 range 8 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype RTOR_RTO_Field is STM32_SVD.UInt24;
subtype RTOR_BLEN_Field is STM32_SVD.Byte;
-- Receiver timeout register
type RTOR_Register is record
-- Receiver timeout value
RTO : RTOR_RTO_Field := 16#0#;
-- Block Length
BLEN : RTOR_BLEN_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RTOR_Register use record
RTO at 0 range 0 .. 23;
BLEN at 0 range 24 .. 31;
end record;
subtype RQR_ABRRQ_Field is STM32_SVD.Bit;
subtype RQR_SBKRQ_Field is STM32_SVD.Bit;
subtype RQR_MMRQ_Field is STM32_SVD.Bit;
subtype RQR_RXFRQ_Field is STM32_SVD.Bit;
subtype RQR_TXFRQ_Field is STM32_SVD.Bit;
-- Request register
type RQR_Register is record
-- Auto baud rate request
ABRRQ : RQR_ABRRQ_Field := 16#0#;
-- Send break request
SBKRQ : RQR_SBKRQ_Field := 16#0#;
-- Mute mode request
MMRQ : RQR_MMRQ_Field := 16#0#;
-- Receive data flush request
RXFRQ : RQR_RXFRQ_Field := 16#0#;
-- Transmit data flush request
TXFRQ : RQR_TXFRQ_Field := 16#0#;
-- unspecified
Reserved_5_31 : STM32_SVD.UInt27 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RQR_Register use record
ABRRQ at 0 range 0 .. 0;
SBKRQ at 0 range 1 .. 1;
MMRQ at 0 range 2 .. 2;
RXFRQ at 0 range 3 .. 3;
TXFRQ at 0 range 4 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
subtype ISR_PE_Field is STM32_SVD.Bit;
subtype ISR_FE_Field is STM32_SVD.Bit;
subtype ISR_NF_Field is STM32_SVD.Bit;
subtype ISR_ORE_Field is STM32_SVD.Bit;
subtype ISR_IDLE_Field is STM32_SVD.Bit;
subtype ISR_RXNE_Field is STM32_SVD.Bit;
subtype ISR_TC_Field is STM32_SVD.Bit;
subtype ISR_TXE_Field is STM32_SVD.Bit;
subtype ISR_LBDF_Field is STM32_SVD.Bit;
subtype ISR_CTSIF_Field is STM32_SVD.Bit;
subtype ISR_CTS_Field is STM32_SVD.Bit;
subtype ISR_RTOF_Field is STM32_SVD.Bit;
subtype ISR_EOBF_Field is STM32_SVD.Bit;
subtype ISR_ABRE_Field is STM32_SVD.Bit;
subtype ISR_ABRF_Field is STM32_SVD.Bit;
subtype ISR_BUSY_Field is STM32_SVD.Bit;
subtype ISR_CMF_Field is STM32_SVD.Bit;
subtype ISR_SBKF_Field is STM32_SVD.Bit;
subtype ISR_RWU_Field is STM32_SVD.Bit;
subtype ISR_WUF_Field is STM32_SVD.Bit;
subtype ISR_TEACK_Field is STM32_SVD.Bit;
subtype ISR_REACK_Field is STM32_SVD.Bit;
-- Interrupt & status register
type ISR_Register is record
-- Read-only. Parity error
PE : ISR_PE_Field;
-- Read-only. Framing error
FE : ISR_FE_Field;
-- Read-only. Noise detected flag
NF : ISR_NF_Field;
-- Read-only. Overrun error
ORE : ISR_ORE_Field;
-- Read-only. Idle line detected
IDLE : ISR_IDLE_Field;
-- Read-only. Read data register not empty
RXNE : ISR_RXNE_Field;
-- Read-only. Transmission complete
TC : ISR_TC_Field;
-- Read-only. Transmit data register empty
TXE : ISR_TXE_Field;
-- Read-only. LIN break detection flag
LBDF : ISR_LBDF_Field;
-- Read-only. CTS interrupt flag
CTSIF : ISR_CTSIF_Field;
-- Read-only. CTS flag
CTS : ISR_CTS_Field;
-- Read-only. Receiver timeout
RTOF : ISR_RTOF_Field;
-- Read-only. End of block flag
EOBF : ISR_EOBF_Field;
-- unspecified
Reserved_13_13 : STM32_SVD.Bit;
-- Read-only. Auto baud rate error
ABRE : ISR_ABRE_Field;
-- Read-only. Auto baud rate flag
ABRF : ISR_ABRF_Field;
-- Read-only. Busy flag
BUSY : ISR_BUSY_Field;
-- Read-only. character match flag
CMF : ISR_CMF_Field;
-- Read-only. Send break flag
SBKF : ISR_SBKF_Field;
-- Read-only. Receiver wakeup from Mute mode
RWU : ISR_RWU_Field;
-- Read-only. Wakeup from Stop mode flag
WUF : ISR_WUF_Field;
-- Read-only. Transmit enable acknowledge flag
TEACK : ISR_TEACK_Field;
-- Read-only. Receive enable acknowledge flag
REACK : ISR_REACK_Field;
-- unspecified
Reserved_23_31 : STM32_SVD.UInt9;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ISR_Register use record
PE at 0 range 0 .. 0;
FE at 0 range 1 .. 1;
NF at 0 range 2 .. 2;
ORE at 0 range 3 .. 3;
IDLE at 0 range 4 .. 4;
RXNE at 0 range 5 .. 5;
TC at 0 range 6 .. 6;
TXE at 0 range 7 .. 7;
LBDF at 0 range 8 .. 8;
CTSIF at 0 range 9 .. 9;
CTS at 0 range 10 .. 10;
RTOF at 0 range 11 .. 11;
EOBF at 0 range 12 .. 12;
Reserved_13_13 at 0 range 13 .. 13;
ABRE at 0 range 14 .. 14;
ABRF at 0 range 15 .. 15;
BUSY at 0 range 16 .. 16;
CMF at 0 range 17 .. 17;
SBKF at 0 range 18 .. 18;
RWU at 0 range 19 .. 19;
WUF at 0 range 20 .. 20;
TEACK at 0 range 21 .. 21;
REACK at 0 range 22 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
subtype ICR_PECF_Field is STM32_SVD.Bit;
subtype ICR_FECF_Field is STM32_SVD.Bit;
subtype ICR_NCF_Field is STM32_SVD.Bit;
subtype ICR_ORECF_Field is STM32_SVD.Bit;
subtype ICR_IDLECF_Field is STM32_SVD.Bit;
subtype ICR_TCCF_Field is STM32_SVD.Bit;
subtype ICR_LBDCF_Field is STM32_SVD.Bit;
subtype ICR_CTSCF_Field is STM32_SVD.Bit;
subtype ICR_RTOCF_Field is STM32_SVD.Bit;
subtype ICR_EOBCF_Field is STM32_SVD.Bit;
subtype ICR_CMCF_Field is STM32_SVD.Bit;
subtype ICR_WUCF_Field is STM32_SVD.Bit;
-- Interrupt flag clear register
type ICR_Register is record
-- Parity error clear flag
PECF : ICR_PECF_Field := 16#0#;
-- Framing error clear flag
FECF : ICR_FECF_Field := 16#0#;
-- Noise detected clear flag
NCF : ICR_NCF_Field := 16#0#;
-- Overrun error clear flag
ORECF : ICR_ORECF_Field := 16#0#;
-- Idle line detected clear flag
IDLECF : ICR_IDLECF_Field := 16#0#;
-- unspecified
Reserved_5_5 : STM32_SVD.Bit := 16#0#;
-- Transmission complete clear flag
TCCF : ICR_TCCF_Field := 16#0#;
-- unspecified
Reserved_7_7 : STM32_SVD.Bit := 16#0#;
-- LIN break detection clear flag
LBDCF : ICR_LBDCF_Field := 16#0#;
-- CTS clear flag
CTSCF : ICR_CTSCF_Field := 16#0#;
-- unspecified
Reserved_10_10 : STM32_SVD.Bit := 16#0#;
-- Receiver timeout clear flag
RTOCF : ICR_RTOCF_Field := 16#0#;
-- End of timeout clear flag
EOBCF : ICR_EOBCF_Field := 16#0#;
-- unspecified
Reserved_13_16 : STM32_SVD.UInt4 := 16#0#;
-- Character match clear flag
CMCF : ICR_CMCF_Field := 16#0#;
-- unspecified
Reserved_18_19 : STM32_SVD.UInt2 := 16#0#;
-- Wakeup from Stop mode clear flag
WUCF : ICR_WUCF_Field := 16#0#;
-- unspecified
Reserved_21_31 : STM32_SVD.UInt11 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for ICR_Register use record
PECF at 0 range 0 .. 0;
FECF at 0 range 1 .. 1;
NCF at 0 range 2 .. 2;
ORECF at 0 range 3 .. 3;
IDLECF at 0 range 4 .. 4;
Reserved_5_5 at 0 range 5 .. 5;
TCCF at 0 range 6 .. 6;
Reserved_7_7 at 0 range 7 .. 7;
LBDCF at 0 range 8 .. 8;
CTSCF at 0 range 9 .. 9;
Reserved_10_10 at 0 range 10 .. 10;
RTOCF at 0 range 11 .. 11;
EOBCF at 0 range 12 .. 12;
Reserved_13_16 at 0 range 13 .. 16;
CMCF at 0 range 17 .. 17;
Reserved_18_19 at 0 range 18 .. 19;
WUCF at 0 range 20 .. 20;
Reserved_21_31 at 0 range 21 .. 31;
end record;
subtype RDR_RDR_Field is STM32_SVD.UInt9;
-- Receive data register
type RDR_Register is record
-- Read-only. Receive data value
RDR : RDR_RDR_Field;
-- unspecified
Reserved_9_31 : STM32_SVD.UInt23;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RDR_Register use record
RDR at 0 range 0 .. 8;
Reserved_9_31 at 0 range 9 .. 31;
end record;
subtype TDR_TDR_Field is STM32_SVD.UInt9;
-- Transmit data register
type TDR_Register is record
-- Transmit data value
TDR : TDR_TDR_Field := 16#0#;
-- unspecified
Reserved_9_31 : STM32_SVD.UInt23 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for TDR_Register use record
TDR at 0 range 0 .. 8;
Reserved_9_31 at 0 range 9 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Universal synchronous asynchronous receiver transmitter
type USART_Peripheral is record
-- Control register 1
CR1 : aliased CR1_Register;
-- Control register 2
CR2 : aliased CR2_Register;
-- Control register 3
CR3 : aliased CR3_Register;
-- Baud rate register
BRR : aliased BRR_Register;
-- Guard time and prescaler register
GTPR : aliased GTPR_Register;
-- Receiver timeout register
RTOR : aliased RTOR_Register;
-- Request register
RQR : aliased RQR_Register;
-- Interrupt & status register
ISR : aliased ISR_Register;
-- Interrupt flag clear register
ICR : aliased ICR_Register;
-- Receive data register
RDR : aliased RDR_Register;
-- Transmit data register
TDR : aliased TDR_Register;
end record
with Volatile;
for USART_Peripheral use record
CR1 at 16#0# range 0 .. 31;
CR2 at 16#4# range 0 .. 31;
CR3 at 16#8# range 0 .. 31;
BRR at 16#C# range 0 .. 31;
GTPR at 16#10# range 0 .. 31;
RTOR at 16#14# range 0 .. 31;
RQR at 16#18# range 0 .. 31;
ISR at 16#1C# range 0 .. 31;
ICR at 16#20# range 0 .. 31;
RDR at 16#24# range 0 .. 31;
TDR at 16#28# range 0 .. 31;
end record;
-- Universal synchronous asynchronous receiver transmitter
UART4_Periph : aliased USART_Peripheral
with Import, Address => System'To_Address (16#40004C00#);
-- Universal synchronous asynchronous receiver transmitter
UART5_Periph : aliased USART_Peripheral
with Import, Address => System'To_Address (16#40005000#);
-- Universal synchronous asynchronous receiver transmitter
USART1_Periph : aliased USART_Peripheral
with Import, Address => System'To_Address (16#40013800#);
-- Universal synchronous asynchronous receiver transmitter
USART2_Periph : aliased USART_Peripheral
with Import, Address => System'To_Address (16#40004400#);
-- Universal synchronous asynchronous receiver transmitter
USART3_Periph : aliased USART_Peripheral
with Import, Address => System'To_Address (16#40004800#);
end STM32_SVD.USART;
|
stcarrez/swagger-ada | Ada | 5,282 | ads | -----------------------------------------------------------------------
-- openapi-streams-forms -- x-www-form-urlencoded streams
-- Copyright (C) 2018, 2022, 2023 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.Streams;
with Util.Streams.Texts;
with Util.Serialize.IO;
package OpenAPI.Streams.Forms is
type Output_Stream is limited new Util.Serialize.IO.Output_Stream with private;
procedure Initialize (Stream : in out Output_Stream;
Buffer : in Util.Streams.Texts.Print_Stream_Access);
-- Flush the buffer (if any) to the sink.
overriding
procedure Flush (Stream : in out Output_Stream);
-- Close the sink.
overriding
procedure Close (Stream : in out Output_Stream);
-- Write the buffer array to the output stream.
overriding
procedure Write (Stream : in out Output_Stream;
Buffer : in Ada.Streams.Stream_Element_Array);
-- Start a document.
overriding
procedure Start_Document (Stream : in out Output_Stream) is null;
-- Finish a document.
overriding
procedure End_Document (Stream : in out Output_Stream) is null;
overriding
procedure Start_Entity (Stream : in out Output_Stream;
Name : in String) is null;
overriding
procedure End_Entity (Stream : in out Output_Stream;
Name : in String) is null;
-- Write the attribute name/value pair.
overriding
procedure Write_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in String);
overriding
procedure Write_Wide_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in Wide_Wide_String);
overriding
procedure Write_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in Integer);
overriding
procedure Write_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in Boolean);
overriding
procedure Write_Attribute (Stream : in out Output_Stream;
Name : in String;
Value : in Util.Beans.Objects.Object);
-- Write the attribute with a null value.
overriding
procedure Write_Null_Attribute (Stream : in out Output_Stream;
Name : in String);
-- Write the entity value.
overriding
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in String);
overriding
procedure Write_Wide_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Wide_Wide_String);
overriding
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Boolean);
overriding
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Integer);
overriding
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Ada.Calendar.Time);
overriding
procedure Write_Long_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Long_Long_Integer);
overriding
procedure Write_Long_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Long_Long_Float);
overriding
procedure Write_Enum_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in String);
overriding
procedure Write_Entity (Stream : in out Output_Stream;
Name : in String;
Value : in Util.Beans.Objects.Object);
-- Write an entity with a null value.
overriding
procedure Write_Null_Entity (Stream : in out Output_Stream;
Name : in String);
private
type Output_Stream is limited new Util.Serialize.IO.Output_Stream with record
Stream : Util.Streams.Texts.Print_Stream_Access;
Has_Param : Boolean := False;
end record;
end OpenAPI.Streams.Forms;
|
sungyeon/drake | Ada | 40,358 | ads | pragma License (Unrestricted);
-- implementation unit,
-- translated from UnicodeData.txt (6), CompositionExclusions.txt
package Ada.UCD.Normalization is
pragma Pure;
-- excluding U+2000..U+2FFF, U+F900..U+FAFF, and U+2F800..U+2FAFF
NFD_Total : constant := 999;
NFC_Total : constant := 889;
NFD_D_Table_XXXX : constant Map_16x2_Type (1 .. 884) := (
(16#00C0#, (16#0041#, 16#0300#)),
(16#00C1#, (16#0041#, 16#0301#)),
(16#00C2#, (16#0041#, 16#0302#)),
(16#00C3#, (16#0041#, 16#0303#)),
(16#00C4#, (16#0041#, 16#0308#)),
(16#00C5#, (16#0041#, 16#030A#)),
(16#00C7#, (16#0043#, 16#0327#)),
(16#00C8#, (16#0045#, 16#0300#)),
(16#00C9#, (16#0045#, 16#0301#)),
(16#00CA#, (16#0045#, 16#0302#)),
(16#00CB#, (16#0045#, 16#0308#)),
(16#00CC#, (16#0049#, 16#0300#)),
(16#00CD#, (16#0049#, 16#0301#)),
(16#00CE#, (16#0049#, 16#0302#)),
(16#00CF#, (16#0049#, 16#0308#)),
(16#00D1#, (16#004E#, 16#0303#)),
(16#00D2#, (16#004F#, 16#0300#)),
(16#00D3#, (16#004F#, 16#0301#)),
(16#00D4#, (16#004F#, 16#0302#)),
(16#00D5#, (16#004F#, 16#0303#)),
(16#00D6#, (16#004F#, 16#0308#)),
(16#00D9#, (16#0055#, 16#0300#)),
(16#00DA#, (16#0055#, 16#0301#)),
(16#00DB#, (16#0055#, 16#0302#)),
(16#00DC#, (16#0055#, 16#0308#)),
(16#00DD#, (16#0059#, 16#0301#)),
(16#00E0#, (16#0061#, 16#0300#)),
(16#00E1#, (16#0061#, 16#0301#)),
(16#00E2#, (16#0061#, 16#0302#)),
(16#00E3#, (16#0061#, 16#0303#)),
(16#00E4#, (16#0061#, 16#0308#)),
(16#00E5#, (16#0061#, 16#030A#)),
(16#00E7#, (16#0063#, 16#0327#)),
(16#00E8#, (16#0065#, 16#0300#)),
(16#00E9#, (16#0065#, 16#0301#)),
(16#00EA#, (16#0065#, 16#0302#)),
(16#00EB#, (16#0065#, 16#0308#)),
(16#00EC#, (16#0069#, 16#0300#)),
(16#00ED#, (16#0069#, 16#0301#)),
(16#00EE#, (16#0069#, 16#0302#)),
(16#00EF#, (16#0069#, 16#0308#)),
(16#00F1#, (16#006E#, 16#0303#)),
(16#00F2#, (16#006F#, 16#0300#)),
(16#00F3#, (16#006F#, 16#0301#)),
(16#00F4#, (16#006F#, 16#0302#)),
(16#00F5#, (16#006F#, 16#0303#)),
(16#00F6#, (16#006F#, 16#0308#)),
(16#00F9#, (16#0075#, 16#0300#)),
(16#00FA#, (16#0075#, 16#0301#)),
(16#00FB#, (16#0075#, 16#0302#)),
(16#00FC#, (16#0075#, 16#0308#)),
(16#00FD#, (16#0079#, 16#0301#)),
(16#00FF#, (16#0079#, 16#0308#)),
(16#0100#, (16#0041#, 16#0304#)),
(16#0101#, (16#0061#, 16#0304#)),
(16#0102#, (16#0041#, 16#0306#)),
(16#0103#, (16#0061#, 16#0306#)),
(16#0104#, (16#0041#, 16#0328#)),
(16#0105#, (16#0061#, 16#0328#)),
(16#0106#, (16#0043#, 16#0301#)),
(16#0107#, (16#0063#, 16#0301#)),
(16#0108#, (16#0043#, 16#0302#)),
(16#0109#, (16#0063#, 16#0302#)),
(16#010A#, (16#0043#, 16#0307#)),
(16#010B#, (16#0063#, 16#0307#)),
(16#010C#, (16#0043#, 16#030C#)),
(16#010D#, (16#0063#, 16#030C#)),
(16#010E#, (16#0044#, 16#030C#)),
(16#010F#, (16#0064#, 16#030C#)),
(16#0112#, (16#0045#, 16#0304#)),
(16#0113#, (16#0065#, 16#0304#)),
(16#0114#, (16#0045#, 16#0306#)),
(16#0115#, (16#0065#, 16#0306#)),
(16#0116#, (16#0045#, 16#0307#)),
(16#0117#, (16#0065#, 16#0307#)),
(16#0118#, (16#0045#, 16#0328#)),
(16#0119#, (16#0065#, 16#0328#)),
(16#011A#, (16#0045#, 16#030C#)),
(16#011B#, (16#0065#, 16#030C#)),
(16#011C#, (16#0047#, 16#0302#)),
(16#011D#, (16#0067#, 16#0302#)),
(16#011E#, (16#0047#, 16#0306#)),
(16#011F#, (16#0067#, 16#0306#)),
(16#0120#, (16#0047#, 16#0307#)),
(16#0121#, (16#0067#, 16#0307#)),
(16#0122#, (16#0047#, 16#0327#)),
(16#0123#, (16#0067#, 16#0327#)),
(16#0124#, (16#0048#, 16#0302#)),
(16#0125#, (16#0068#, 16#0302#)),
(16#0128#, (16#0049#, 16#0303#)),
(16#0129#, (16#0069#, 16#0303#)),
(16#012A#, (16#0049#, 16#0304#)),
(16#012B#, (16#0069#, 16#0304#)),
(16#012C#, (16#0049#, 16#0306#)),
(16#012D#, (16#0069#, 16#0306#)),
(16#012E#, (16#0049#, 16#0328#)),
(16#012F#, (16#0069#, 16#0328#)),
(16#0130#, (16#0049#, 16#0307#)),
(16#0134#, (16#004A#, 16#0302#)),
(16#0135#, (16#006A#, 16#0302#)),
(16#0136#, (16#004B#, 16#0327#)),
(16#0137#, (16#006B#, 16#0327#)),
(16#0139#, (16#004C#, 16#0301#)),
(16#013A#, (16#006C#, 16#0301#)),
(16#013B#, (16#004C#, 16#0327#)),
(16#013C#, (16#006C#, 16#0327#)),
(16#013D#, (16#004C#, 16#030C#)),
(16#013E#, (16#006C#, 16#030C#)),
(16#0143#, (16#004E#, 16#0301#)),
(16#0144#, (16#006E#, 16#0301#)),
(16#0145#, (16#004E#, 16#0327#)),
(16#0146#, (16#006E#, 16#0327#)),
(16#0147#, (16#004E#, 16#030C#)),
(16#0148#, (16#006E#, 16#030C#)),
(16#014C#, (16#004F#, 16#0304#)),
(16#014D#, (16#006F#, 16#0304#)),
(16#014E#, (16#004F#, 16#0306#)),
(16#014F#, (16#006F#, 16#0306#)),
(16#0150#, (16#004F#, 16#030B#)),
(16#0151#, (16#006F#, 16#030B#)),
(16#0154#, (16#0052#, 16#0301#)),
(16#0155#, (16#0072#, 16#0301#)),
(16#0156#, (16#0052#, 16#0327#)),
(16#0157#, (16#0072#, 16#0327#)),
(16#0158#, (16#0052#, 16#030C#)),
(16#0159#, (16#0072#, 16#030C#)),
(16#015A#, (16#0053#, 16#0301#)),
(16#015B#, (16#0073#, 16#0301#)),
(16#015C#, (16#0053#, 16#0302#)),
(16#015D#, (16#0073#, 16#0302#)),
(16#015E#, (16#0053#, 16#0327#)),
(16#015F#, (16#0073#, 16#0327#)),
(16#0160#, (16#0053#, 16#030C#)),
(16#0161#, (16#0073#, 16#030C#)),
(16#0162#, (16#0054#, 16#0327#)),
(16#0163#, (16#0074#, 16#0327#)),
(16#0164#, (16#0054#, 16#030C#)),
(16#0165#, (16#0074#, 16#030C#)),
(16#0168#, (16#0055#, 16#0303#)),
(16#0169#, (16#0075#, 16#0303#)),
(16#016A#, (16#0055#, 16#0304#)),
(16#016B#, (16#0075#, 16#0304#)),
(16#016C#, (16#0055#, 16#0306#)),
(16#016D#, (16#0075#, 16#0306#)),
(16#016E#, (16#0055#, 16#030A#)),
(16#016F#, (16#0075#, 16#030A#)),
(16#0170#, (16#0055#, 16#030B#)),
(16#0171#, (16#0075#, 16#030B#)),
(16#0172#, (16#0055#, 16#0328#)),
(16#0173#, (16#0075#, 16#0328#)),
(16#0174#, (16#0057#, 16#0302#)),
(16#0175#, (16#0077#, 16#0302#)),
(16#0176#, (16#0059#, 16#0302#)),
(16#0177#, (16#0079#, 16#0302#)),
(16#0178#, (16#0059#, 16#0308#)),
(16#0179#, (16#005A#, 16#0301#)),
(16#017A#, (16#007A#, 16#0301#)),
(16#017B#, (16#005A#, 16#0307#)),
(16#017C#, (16#007A#, 16#0307#)),
(16#017D#, (16#005A#, 16#030C#)),
(16#017E#, (16#007A#, 16#030C#)),
(16#01A0#, (16#004F#, 16#031B#)),
(16#01A1#, (16#006F#, 16#031B#)),
(16#01AF#, (16#0055#, 16#031B#)),
(16#01B0#, (16#0075#, 16#031B#)),
(16#01CD#, (16#0041#, 16#030C#)),
(16#01CE#, (16#0061#, 16#030C#)),
(16#01CF#, (16#0049#, 16#030C#)),
(16#01D0#, (16#0069#, 16#030C#)),
(16#01D1#, (16#004F#, 16#030C#)),
(16#01D2#, (16#006F#, 16#030C#)),
(16#01D3#, (16#0055#, 16#030C#)),
(16#01D4#, (16#0075#, 16#030C#)),
(16#01D5#, (16#00DC#, 16#0304#)),
(16#01D6#, (16#00FC#, 16#0304#)),
(16#01D7#, (16#00DC#, 16#0301#)),
(16#01D8#, (16#00FC#, 16#0301#)),
(16#01D9#, (16#00DC#, 16#030C#)),
(16#01DA#, (16#00FC#, 16#030C#)),
(16#01DB#, (16#00DC#, 16#0300#)),
(16#01DC#, (16#00FC#, 16#0300#)),
(16#01DE#, (16#00C4#, 16#0304#)),
(16#01DF#, (16#00E4#, 16#0304#)),
(16#01E0#, (16#0226#, 16#0304#)),
(16#01E1#, (16#0227#, 16#0304#)),
(16#01E2#, (16#00C6#, 16#0304#)),
(16#01E3#, (16#00E6#, 16#0304#)),
(16#01E6#, (16#0047#, 16#030C#)),
(16#01E7#, (16#0067#, 16#030C#)),
(16#01E8#, (16#004B#, 16#030C#)),
(16#01E9#, (16#006B#, 16#030C#)),
(16#01EA#, (16#004F#, 16#0328#)),
(16#01EB#, (16#006F#, 16#0328#)),
(16#01EC#, (16#01EA#, 16#0304#)),
(16#01ED#, (16#01EB#, 16#0304#)),
(16#01EE#, (16#01B7#, 16#030C#)),
(16#01EF#, (16#0292#, 16#030C#)),
(16#01F0#, (16#006A#, 16#030C#)),
(16#01F4#, (16#0047#, 16#0301#)),
(16#01F5#, (16#0067#, 16#0301#)),
(16#01F8#, (16#004E#, 16#0300#)),
(16#01F9#, (16#006E#, 16#0300#)),
(16#01FA#, (16#00C5#, 16#0301#)),
(16#01FB#, (16#00E5#, 16#0301#)),
(16#01FC#, (16#00C6#, 16#0301#)),
(16#01FD#, (16#00E6#, 16#0301#)),
(16#01FE#, (16#00D8#, 16#0301#)),
(16#01FF#, (16#00F8#, 16#0301#)),
(16#0200#, (16#0041#, 16#030F#)),
(16#0201#, (16#0061#, 16#030F#)),
(16#0202#, (16#0041#, 16#0311#)),
(16#0203#, (16#0061#, 16#0311#)),
(16#0204#, (16#0045#, 16#030F#)),
(16#0205#, (16#0065#, 16#030F#)),
(16#0206#, (16#0045#, 16#0311#)),
(16#0207#, (16#0065#, 16#0311#)),
(16#0208#, (16#0049#, 16#030F#)),
(16#0209#, (16#0069#, 16#030F#)),
(16#020A#, (16#0049#, 16#0311#)),
(16#020B#, (16#0069#, 16#0311#)),
(16#020C#, (16#004F#, 16#030F#)),
(16#020D#, (16#006F#, 16#030F#)),
(16#020E#, (16#004F#, 16#0311#)),
(16#020F#, (16#006F#, 16#0311#)),
(16#0210#, (16#0052#, 16#030F#)),
(16#0211#, (16#0072#, 16#030F#)),
(16#0212#, (16#0052#, 16#0311#)),
(16#0213#, (16#0072#, 16#0311#)),
(16#0214#, (16#0055#, 16#030F#)),
(16#0215#, (16#0075#, 16#030F#)),
(16#0216#, (16#0055#, 16#0311#)),
(16#0217#, (16#0075#, 16#0311#)),
(16#0218#, (16#0053#, 16#0326#)),
(16#0219#, (16#0073#, 16#0326#)),
(16#021A#, (16#0054#, 16#0326#)),
(16#021B#, (16#0074#, 16#0326#)),
(16#021E#, (16#0048#, 16#030C#)),
(16#021F#, (16#0068#, 16#030C#)),
(16#0226#, (16#0041#, 16#0307#)),
(16#0227#, (16#0061#, 16#0307#)),
(16#0228#, (16#0045#, 16#0327#)),
(16#0229#, (16#0065#, 16#0327#)),
(16#022A#, (16#00D6#, 16#0304#)),
(16#022B#, (16#00F6#, 16#0304#)),
(16#022C#, (16#00D5#, 16#0304#)),
(16#022D#, (16#00F5#, 16#0304#)),
(16#022E#, (16#004F#, 16#0307#)),
(16#022F#, (16#006F#, 16#0307#)),
(16#0230#, (16#022E#, 16#0304#)),
(16#0231#, (16#022F#, 16#0304#)),
(16#0232#, (16#0059#, 16#0304#)),
(16#0233#, (16#0079#, 16#0304#)),
(16#0385#, (16#00A8#, 16#0301#)),
(16#0386#, (16#0391#, 16#0301#)),
(16#0388#, (16#0395#, 16#0301#)),
(16#0389#, (16#0397#, 16#0301#)),
(16#038A#, (16#0399#, 16#0301#)),
(16#038C#, (16#039F#, 16#0301#)),
(16#038E#, (16#03A5#, 16#0301#)),
(16#038F#, (16#03A9#, 16#0301#)),
(16#0390#, (16#03CA#, 16#0301#)),
(16#03AA#, (16#0399#, 16#0308#)),
(16#03AB#, (16#03A5#, 16#0308#)),
(16#03AC#, (16#03B1#, 16#0301#)),
(16#03AD#, (16#03B5#, 16#0301#)),
(16#03AE#, (16#03B7#, 16#0301#)),
(16#03AF#, (16#03B9#, 16#0301#)),
(16#03B0#, (16#03CB#, 16#0301#)),
(16#03CA#, (16#03B9#, 16#0308#)),
(16#03CB#, (16#03C5#, 16#0308#)),
(16#03CC#, (16#03BF#, 16#0301#)),
(16#03CD#, (16#03C5#, 16#0301#)),
(16#03CE#, (16#03C9#, 16#0301#)),
(16#03D3#, (16#03D2#, 16#0301#)),
(16#03D4#, (16#03D2#, 16#0308#)),
(16#0400#, (16#0415#, 16#0300#)),
(16#0401#, (16#0415#, 16#0308#)),
(16#0403#, (16#0413#, 16#0301#)),
(16#0407#, (16#0406#, 16#0308#)),
(16#040C#, (16#041A#, 16#0301#)),
(16#040D#, (16#0418#, 16#0300#)),
(16#040E#, (16#0423#, 16#0306#)),
(16#0419#, (16#0418#, 16#0306#)),
(16#0439#, (16#0438#, 16#0306#)),
(16#0450#, (16#0435#, 16#0300#)),
(16#0451#, (16#0435#, 16#0308#)),
(16#0453#, (16#0433#, 16#0301#)),
(16#0457#, (16#0456#, 16#0308#)),
(16#045C#, (16#043A#, 16#0301#)),
(16#045D#, (16#0438#, 16#0300#)),
(16#045E#, (16#0443#, 16#0306#)),
(16#0476#, (16#0474#, 16#030F#)),
(16#0477#, (16#0475#, 16#030F#)),
(16#04C1#, (16#0416#, 16#0306#)),
(16#04C2#, (16#0436#, 16#0306#)),
(16#04D0#, (16#0410#, 16#0306#)),
(16#04D1#, (16#0430#, 16#0306#)),
(16#04D2#, (16#0410#, 16#0308#)),
(16#04D3#, (16#0430#, 16#0308#)),
(16#04D6#, (16#0415#, 16#0306#)),
(16#04D7#, (16#0435#, 16#0306#)),
(16#04DA#, (16#04D8#, 16#0308#)),
(16#04DB#, (16#04D9#, 16#0308#)),
(16#04DC#, (16#0416#, 16#0308#)),
(16#04DD#, (16#0436#, 16#0308#)),
(16#04DE#, (16#0417#, 16#0308#)),
(16#04DF#, (16#0437#, 16#0308#)),
(16#04E2#, (16#0418#, 16#0304#)),
(16#04E3#, (16#0438#, 16#0304#)),
(16#04E4#, (16#0418#, 16#0308#)),
(16#04E5#, (16#0438#, 16#0308#)),
(16#04E6#, (16#041E#, 16#0308#)),
(16#04E7#, (16#043E#, 16#0308#)),
(16#04EA#, (16#04E8#, 16#0308#)),
(16#04EB#, (16#04E9#, 16#0308#)),
(16#04EC#, (16#042D#, 16#0308#)),
(16#04ED#, (16#044D#, 16#0308#)),
(16#04EE#, (16#0423#, 16#0304#)),
(16#04EF#, (16#0443#, 16#0304#)),
(16#04F0#, (16#0423#, 16#0308#)),
(16#04F1#, (16#0443#, 16#0308#)),
(16#04F2#, (16#0423#, 16#030B#)),
(16#04F3#, (16#0443#, 16#030B#)),
(16#04F4#, (16#0427#, 16#0308#)),
(16#04F5#, (16#0447#, 16#0308#)),
(16#04F8#, (16#042B#, 16#0308#)),
(16#04F9#, (16#044B#, 16#0308#)),
(16#0622#, (16#0627#, 16#0653#)),
(16#0623#, (16#0627#, 16#0654#)),
(16#0624#, (16#0648#, 16#0654#)),
(16#0625#, (16#0627#, 16#0655#)),
(16#0626#, (16#064A#, 16#0654#)),
(16#06C0#, (16#06D5#, 16#0654#)),
(16#06C2#, (16#06C1#, 16#0654#)),
(16#06D3#, (16#06D2#, 16#0654#)),
(16#0929#, (16#0928#, 16#093C#)),
(16#0931#, (16#0930#, 16#093C#)),
(16#0934#, (16#0933#, 16#093C#)),
(16#09CB#, (16#09C7#, 16#09BE#)),
(16#09CC#, (16#09C7#, 16#09D7#)),
(16#0B48#, (16#0B47#, 16#0B56#)),
(16#0B4B#, (16#0B47#, 16#0B3E#)),
(16#0B4C#, (16#0B47#, 16#0B57#)),
(16#0B94#, (16#0B92#, 16#0BD7#)),
(16#0BCA#, (16#0BC6#, 16#0BBE#)),
(16#0BCB#, (16#0BC7#, 16#0BBE#)),
(16#0BCC#, (16#0BC6#, 16#0BD7#)),
(16#0C48#, (16#0C46#, 16#0C56#)),
(16#0CC0#, (16#0CBF#, 16#0CD5#)),
(16#0CC7#, (16#0CC6#, 16#0CD5#)),
(16#0CC8#, (16#0CC6#, 16#0CD6#)),
(16#0CCA#, (16#0CC6#, 16#0CC2#)),
(16#0CCB#, (16#0CCA#, 16#0CD5#)),
(16#0D4A#, (16#0D46#, 16#0D3E#)),
(16#0D4B#, (16#0D47#, 16#0D3E#)),
(16#0D4C#, (16#0D46#, 16#0D57#)),
(16#0DDA#, (16#0DD9#, 16#0DCA#)),
(16#0DDC#, (16#0DD9#, 16#0DCF#)),
(16#0DDD#, (16#0DDC#, 16#0DCA#)),
(16#0DDE#, (16#0DD9#, 16#0DDF#)),
(16#1026#, (16#1025#, 16#102E#)),
(16#1B06#, (16#1B05#, 16#1B35#)),
(16#1B08#, (16#1B07#, 16#1B35#)),
(16#1B0A#, (16#1B09#, 16#1B35#)),
(16#1B0C#, (16#1B0B#, 16#1B35#)),
(16#1B0E#, (16#1B0D#, 16#1B35#)),
(16#1B12#, (16#1B11#, 16#1B35#)),
(16#1B3B#, (16#1B3A#, 16#1B35#)),
(16#1B3D#, (16#1B3C#, 16#1B35#)),
(16#1B40#, (16#1B3E#, 16#1B35#)),
(16#1B41#, (16#1B3F#, 16#1B35#)),
(16#1B43#, (16#1B42#, 16#1B35#)),
(16#1E00#, (16#0041#, 16#0325#)),
(16#1E01#, (16#0061#, 16#0325#)),
(16#1E02#, (16#0042#, 16#0307#)),
(16#1E03#, (16#0062#, 16#0307#)),
(16#1E04#, (16#0042#, 16#0323#)),
(16#1E05#, (16#0062#, 16#0323#)),
(16#1E06#, (16#0042#, 16#0331#)),
(16#1E07#, (16#0062#, 16#0331#)),
(16#1E08#, (16#00C7#, 16#0301#)),
(16#1E09#, (16#00E7#, 16#0301#)),
(16#1E0A#, (16#0044#, 16#0307#)),
(16#1E0B#, (16#0064#, 16#0307#)),
(16#1E0C#, (16#0044#, 16#0323#)),
(16#1E0D#, (16#0064#, 16#0323#)),
(16#1E0E#, (16#0044#, 16#0331#)),
(16#1E0F#, (16#0064#, 16#0331#)),
(16#1E10#, (16#0044#, 16#0327#)),
(16#1E11#, (16#0064#, 16#0327#)),
(16#1E12#, (16#0044#, 16#032D#)),
(16#1E13#, (16#0064#, 16#032D#)),
(16#1E14#, (16#0112#, 16#0300#)),
(16#1E15#, (16#0113#, 16#0300#)),
(16#1E16#, (16#0112#, 16#0301#)),
(16#1E17#, (16#0113#, 16#0301#)),
(16#1E18#, (16#0045#, 16#032D#)),
(16#1E19#, (16#0065#, 16#032D#)),
(16#1E1A#, (16#0045#, 16#0330#)),
(16#1E1B#, (16#0065#, 16#0330#)),
(16#1E1C#, (16#0228#, 16#0306#)),
(16#1E1D#, (16#0229#, 16#0306#)),
(16#1E1E#, (16#0046#, 16#0307#)),
(16#1E1F#, (16#0066#, 16#0307#)),
(16#1E20#, (16#0047#, 16#0304#)),
(16#1E21#, (16#0067#, 16#0304#)),
(16#1E22#, (16#0048#, 16#0307#)),
(16#1E23#, (16#0068#, 16#0307#)),
(16#1E24#, (16#0048#, 16#0323#)),
(16#1E25#, (16#0068#, 16#0323#)),
(16#1E26#, (16#0048#, 16#0308#)),
(16#1E27#, (16#0068#, 16#0308#)),
(16#1E28#, (16#0048#, 16#0327#)),
(16#1E29#, (16#0068#, 16#0327#)),
(16#1E2A#, (16#0048#, 16#032E#)),
(16#1E2B#, (16#0068#, 16#032E#)),
(16#1E2C#, (16#0049#, 16#0330#)),
(16#1E2D#, (16#0069#, 16#0330#)),
(16#1E2E#, (16#00CF#, 16#0301#)),
(16#1E2F#, (16#00EF#, 16#0301#)),
(16#1E30#, (16#004B#, 16#0301#)),
(16#1E31#, (16#006B#, 16#0301#)),
(16#1E32#, (16#004B#, 16#0323#)),
(16#1E33#, (16#006B#, 16#0323#)),
(16#1E34#, (16#004B#, 16#0331#)),
(16#1E35#, (16#006B#, 16#0331#)),
(16#1E36#, (16#004C#, 16#0323#)),
(16#1E37#, (16#006C#, 16#0323#)),
(16#1E38#, (16#1E36#, 16#0304#)),
(16#1E39#, (16#1E37#, 16#0304#)),
(16#1E3A#, (16#004C#, 16#0331#)),
(16#1E3B#, (16#006C#, 16#0331#)),
(16#1E3C#, (16#004C#, 16#032D#)),
(16#1E3D#, (16#006C#, 16#032D#)),
(16#1E3E#, (16#004D#, 16#0301#)),
(16#1E3F#, (16#006D#, 16#0301#)),
(16#1E40#, (16#004D#, 16#0307#)),
(16#1E41#, (16#006D#, 16#0307#)),
(16#1E42#, (16#004D#, 16#0323#)),
(16#1E43#, (16#006D#, 16#0323#)),
(16#1E44#, (16#004E#, 16#0307#)),
(16#1E45#, (16#006E#, 16#0307#)),
(16#1E46#, (16#004E#, 16#0323#)),
(16#1E47#, (16#006E#, 16#0323#)),
(16#1E48#, (16#004E#, 16#0331#)),
(16#1E49#, (16#006E#, 16#0331#)),
(16#1E4A#, (16#004E#, 16#032D#)),
(16#1E4B#, (16#006E#, 16#032D#)),
(16#1E4C#, (16#00D5#, 16#0301#)),
(16#1E4D#, (16#00F5#, 16#0301#)),
(16#1E4E#, (16#00D5#, 16#0308#)),
(16#1E4F#, (16#00F5#, 16#0308#)),
(16#1E50#, (16#014C#, 16#0300#)),
(16#1E51#, (16#014D#, 16#0300#)),
(16#1E52#, (16#014C#, 16#0301#)),
(16#1E53#, (16#014D#, 16#0301#)),
(16#1E54#, (16#0050#, 16#0301#)),
(16#1E55#, (16#0070#, 16#0301#)),
(16#1E56#, (16#0050#, 16#0307#)),
(16#1E57#, (16#0070#, 16#0307#)),
(16#1E58#, (16#0052#, 16#0307#)),
(16#1E59#, (16#0072#, 16#0307#)),
(16#1E5A#, (16#0052#, 16#0323#)),
(16#1E5B#, (16#0072#, 16#0323#)),
(16#1E5C#, (16#1E5A#, 16#0304#)),
(16#1E5D#, (16#1E5B#, 16#0304#)),
(16#1E5E#, (16#0052#, 16#0331#)),
(16#1E5F#, (16#0072#, 16#0331#)),
(16#1E60#, (16#0053#, 16#0307#)),
(16#1E61#, (16#0073#, 16#0307#)),
(16#1E62#, (16#0053#, 16#0323#)),
(16#1E63#, (16#0073#, 16#0323#)),
(16#1E64#, (16#015A#, 16#0307#)),
(16#1E65#, (16#015B#, 16#0307#)),
(16#1E66#, (16#0160#, 16#0307#)),
(16#1E67#, (16#0161#, 16#0307#)),
(16#1E68#, (16#1E62#, 16#0307#)),
(16#1E69#, (16#1E63#, 16#0307#)),
(16#1E6A#, (16#0054#, 16#0307#)),
(16#1E6B#, (16#0074#, 16#0307#)),
(16#1E6C#, (16#0054#, 16#0323#)),
(16#1E6D#, (16#0074#, 16#0323#)),
(16#1E6E#, (16#0054#, 16#0331#)),
(16#1E6F#, (16#0074#, 16#0331#)),
(16#1E70#, (16#0054#, 16#032D#)),
(16#1E71#, (16#0074#, 16#032D#)),
(16#1E72#, (16#0055#, 16#0324#)),
(16#1E73#, (16#0075#, 16#0324#)),
(16#1E74#, (16#0055#, 16#0330#)),
(16#1E75#, (16#0075#, 16#0330#)),
(16#1E76#, (16#0055#, 16#032D#)),
(16#1E77#, (16#0075#, 16#032D#)),
(16#1E78#, (16#0168#, 16#0301#)),
(16#1E79#, (16#0169#, 16#0301#)),
(16#1E7A#, (16#016A#, 16#0308#)),
(16#1E7B#, (16#016B#, 16#0308#)),
(16#1E7C#, (16#0056#, 16#0303#)),
(16#1E7D#, (16#0076#, 16#0303#)),
(16#1E7E#, (16#0056#, 16#0323#)),
(16#1E7F#, (16#0076#, 16#0323#)),
(16#1E80#, (16#0057#, 16#0300#)),
(16#1E81#, (16#0077#, 16#0300#)),
(16#1E82#, (16#0057#, 16#0301#)),
(16#1E83#, (16#0077#, 16#0301#)),
(16#1E84#, (16#0057#, 16#0308#)),
(16#1E85#, (16#0077#, 16#0308#)),
(16#1E86#, (16#0057#, 16#0307#)),
(16#1E87#, (16#0077#, 16#0307#)),
(16#1E88#, (16#0057#, 16#0323#)),
(16#1E89#, (16#0077#, 16#0323#)),
(16#1E8A#, (16#0058#, 16#0307#)),
(16#1E8B#, (16#0078#, 16#0307#)),
(16#1E8C#, (16#0058#, 16#0308#)),
(16#1E8D#, (16#0078#, 16#0308#)),
(16#1E8E#, (16#0059#, 16#0307#)),
(16#1E8F#, (16#0079#, 16#0307#)),
(16#1E90#, (16#005A#, 16#0302#)),
(16#1E91#, (16#007A#, 16#0302#)),
(16#1E92#, (16#005A#, 16#0323#)),
(16#1E93#, (16#007A#, 16#0323#)),
(16#1E94#, (16#005A#, 16#0331#)),
(16#1E95#, (16#007A#, 16#0331#)),
(16#1E96#, (16#0068#, 16#0331#)),
(16#1E97#, (16#0074#, 16#0308#)),
(16#1E98#, (16#0077#, 16#030A#)),
(16#1E99#, (16#0079#, 16#030A#)),
(16#1E9B#, (16#017F#, 16#0307#)),
(16#1EA0#, (16#0041#, 16#0323#)),
(16#1EA1#, (16#0061#, 16#0323#)),
(16#1EA2#, (16#0041#, 16#0309#)),
(16#1EA3#, (16#0061#, 16#0309#)),
(16#1EA4#, (16#00C2#, 16#0301#)),
(16#1EA5#, (16#00E2#, 16#0301#)),
(16#1EA6#, (16#00C2#, 16#0300#)),
(16#1EA7#, (16#00E2#, 16#0300#)),
(16#1EA8#, (16#00C2#, 16#0309#)),
(16#1EA9#, (16#00E2#, 16#0309#)),
(16#1EAA#, (16#00C2#, 16#0303#)),
(16#1EAB#, (16#00E2#, 16#0303#)),
(16#1EAC#, (16#1EA0#, 16#0302#)),
(16#1EAD#, (16#1EA1#, 16#0302#)),
(16#1EAE#, (16#0102#, 16#0301#)),
(16#1EAF#, (16#0103#, 16#0301#)),
(16#1EB0#, (16#0102#, 16#0300#)),
(16#1EB1#, (16#0103#, 16#0300#)),
(16#1EB2#, (16#0102#, 16#0309#)),
(16#1EB3#, (16#0103#, 16#0309#)),
(16#1EB4#, (16#0102#, 16#0303#)),
(16#1EB5#, (16#0103#, 16#0303#)),
(16#1EB6#, (16#1EA0#, 16#0306#)),
(16#1EB7#, (16#1EA1#, 16#0306#)),
(16#1EB8#, (16#0045#, 16#0323#)),
(16#1EB9#, (16#0065#, 16#0323#)),
(16#1EBA#, (16#0045#, 16#0309#)),
(16#1EBB#, (16#0065#, 16#0309#)),
(16#1EBC#, (16#0045#, 16#0303#)),
(16#1EBD#, (16#0065#, 16#0303#)),
(16#1EBE#, (16#00CA#, 16#0301#)),
(16#1EBF#, (16#00EA#, 16#0301#)),
(16#1EC0#, (16#00CA#, 16#0300#)),
(16#1EC1#, (16#00EA#, 16#0300#)),
(16#1EC2#, (16#00CA#, 16#0309#)),
(16#1EC3#, (16#00EA#, 16#0309#)),
(16#1EC4#, (16#00CA#, 16#0303#)),
(16#1EC5#, (16#00EA#, 16#0303#)),
(16#1EC6#, (16#1EB8#, 16#0302#)),
(16#1EC7#, (16#1EB9#, 16#0302#)),
(16#1EC8#, (16#0049#, 16#0309#)),
(16#1EC9#, (16#0069#, 16#0309#)),
(16#1ECA#, (16#0049#, 16#0323#)),
(16#1ECB#, (16#0069#, 16#0323#)),
(16#1ECC#, (16#004F#, 16#0323#)),
(16#1ECD#, (16#006F#, 16#0323#)),
(16#1ECE#, (16#004F#, 16#0309#)),
(16#1ECF#, (16#006F#, 16#0309#)),
(16#1ED0#, (16#00D4#, 16#0301#)),
(16#1ED1#, (16#00F4#, 16#0301#)),
(16#1ED2#, (16#00D4#, 16#0300#)),
(16#1ED3#, (16#00F4#, 16#0300#)),
(16#1ED4#, (16#00D4#, 16#0309#)),
(16#1ED5#, (16#00F4#, 16#0309#)),
(16#1ED6#, (16#00D4#, 16#0303#)),
(16#1ED7#, (16#00F4#, 16#0303#)),
(16#1ED8#, (16#1ECC#, 16#0302#)),
(16#1ED9#, (16#1ECD#, 16#0302#)),
(16#1EDA#, (16#01A0#, 16#0301#)),
(16#1EDB#, (16#01A1#, 16#0301#)),
(16#1EDC#, (16#01A0#, 16#0300#)),
(16#1EDD#, (16#01A1#, 16#0300#)),
(16#1EDE#, (16#01A0#, 16#0309#)),
(16#1EDF#, (16#01A1#, 16#0309#)),
(16#1EE0#, (16#01A0#, 16#0303#)),
(16#1EE1#, (16#01A1#, 16#0303#)),
(16#1EE2#, (16#01A0#, 16#0323#)),
(16#1EE3#, (16#01A1#, 16#0323#)),
(16#1EE4#, (16#0055#, 16#0323#)),
(16#1EE5#, (16#0075#, 16#0323#)),
(16#1EE6#, (16#0055#, 16#0309#)),
(16#1EE7#, (16#0075#, 16#0309#)),
(16#1EE8#, (16#01AF#, 16#0301#)),
(16#1EE9#, (16#01B0#, 16#0301#)),
(16#1EEA#, (16#01AF#, 16#0300#)),
(16#1EEB#, (16#01B0#, 16#0300#)),
(16#1EEC#, (16#01AF#, 16#0309#)),
(16#1EED#, (16#01B0#, 16#0309#)),
(16#1EEE#, (16#01AF#, 16#0303#)),
(16#1EEF#, (16#01B0#, 16#0303#)),
(16#1EF0#, (16#01AF#, 16#0323#)),
(16#1EF1#, (16#01B0#, 16#0323#)),
(16#1EF2#, (16#0059#, 16#0300#)),
(16#1EF3#, (16#0079#, 16#0300#)),
(16#1EF4#, (16#0059#, 16#0323#)),
(16#1EF5#, (16#0079#, 16#0323#)),
(16#1EF6#, (16#0059#, 16#0309#)),
(16#1EF7#, (16#0079#, 16#0309#)),
(16#1EF8#, (16#0059#, 16#0303#)),
(16#1EF9#, (16#0079#, 16#0303#)),
(16#1F00#, (16#03B1#, 16#0313#)),
(16#1F01#, (16#03B1#, 16#0314#)),
(16#1F02#, (16#1F00#, 16#0300#)),
(16#1F03#, (16#1F01#, 16#0300#)),
(16#1F04#, (16#1F00#, 16#0301#)),
(16#1F05#, (16#1F01#, 16#0301#)),
(16#1F06#, (16#1F00#, 16#0342#)),
(16#1F07#, (16#1F01#, 16#0342#)),
(16#1F08#, (16#0391#, 16#0313#)),
(16#1F09#, (16#0391#, 16#0314#)),
(16#1F0A#, (16#1F08#, 16#0300#)),
(16#1F0B#, (16#1F09#, 16#0300#)),
(16#1F0C#, (16#1F08#, 16#0301#)),
(16#1F0D#, (16#1F09#, 16#0301#)),
(16#1F0E#, (16#1F08#, 16#0342#)),
(16#1F0F#, (16#1F09#, 16#0342#)),
(16#1F10#, (16#03B5#, 16#0313#)),
(16#1F11#, (16#03B5#, 16#0314#)),
(16#1F12#, (16#1F10#, 16#0300#)),
(16#1F13#, (16#1F11#, 16#0300#)),
(16#1F14#, (16#1F10#, 16#0301#)),
(16#1F15#, (16#1F11#, 16#0301#)),
(16#1F18#, (16#0395#, 16#0313#)),
(16#1F19#, (16#0395#, 16#0314#)),
(16#1F1A#, (16#1F18#, 16#0300#)),
(16#1F1B#, (16#1F19#, 16#0300#)),
(16#1F1C#, (16#1F18#, 16#0301#)),
(16#1F1D#, (16#1F19#, 16#0301#)),
(16#1F20#, (16#03B7#, 16#0313#)),
(16#1F21#, (16#03B7#, 16#0314#)),
(16#1F22#, (16#1F20#, 16#0300#)),
(16#1F23#, (16#1F21#, 16#0300#)),
(16#1F24#, (16#1F20#, 16#0301#)),
(16#1F25#, (16#1F21#, 16#0301#)),
(16#1F26#, (16#1F20#, 16#0342#)),
(16#1F27#, (16#1F21#, 16#0342#)),
(16#1F28#, (16#0397#, 16#0313#)),
(16#1F29#, (16#0397#, 16#0314#)),
(16#1F2A#, (16#1F28#, 16#0300#)),
(16#1F2B#, (16#1F29#, 16#0300#)),
(16#1F2C#, (16#1F28#, 16#0301#)),
(16#1F2D#, (16#1F29#, 16#0301#)),
(16#1F2E#, (16#1F28#, 16#0342#)),
(16#1F2F#, (16#1F29#, 16#0342#)),
(16#1F30#, (16#03B9#, 16#0313#)),
(16#1F31#, (16#03B9#, 16#0314#)),
(16#1F32#, (16#1F30#, 16#0300#)),
(16#1F33#, (16#1F31#, 16#0300#)),
(16#1F34#, (16#1F30#, 16#0301#)),
(16#1F35#, (16#1F31#, 16#0301#)),
(16#1F36#, (16#1F30#, 16#0342#)),
(16#1F37#, (16#1F31#, 16#0342#)),
(16#1F38#, (16#0399#, 16#0313#)),
(16#1F39#, (16#0399#, 16#0314#)),
(16#1F3A#, (16#1F38#, 16#0300#)),
(16#1F3B#, (16#1F39#, 16#0300#)),
(16#1F3C#, (16#1F38#, 16#0301#)),
(16#1F3D#, (16#1F39#, 16#0301#)),
(16#1F3E#, (16#1F38#, 16#0342#)),
(16#1F3F#, (16#1F39#, 16#0342#)),
(16#1F40#, (16#03BF#, 16#0313#)),
(16#1F41#, (16#03BF#, 16#0314#)),
(16#1F42#, (16#1F40#, 16#0300#)),
(16#1F43#, (16#1F41#, 16#0300#)),
(16#1F44#, (16#1F40#, 16#0301#)),
(16#1F45#, (16#1F41#, 16#0301#)),
(16#1F48#, (16#039F#, 16#0313#)),
(16#1F49#, (16#039F#, 16#0314#)),
(16#1F4A#, (16#1F48#, 16#0300#)),
(16#1F4B#, (16#1F49#, 16#0300#)),
(16#1F4C#, (16#1F48#, 16#0301#)),
(16#1F4D#, (16#1F49#, 16#0301#)),
(16#1F50#, (16#03C5#, 16#0313#)),
(16#1F51#, (16#03C5#, 16#0314#)),
(16#1F52#, (16#1F50#, 16#0300#)),
(16#1F53#, (16#1F51#, 16#0300#)),
(16#1F54#, (16#1F50#, 16#0301#)),
(16#1F55#, (16#1F51#, 16#0301#)),
(16#1F56#, (16#1F50#, 16#0342#)),
(16#1F57#, (16#1F51#, 16#0342#)),
(16#1F59#, (16#03A5#, 16#0314#)),
(16#1F5B#, (16#1F59#, 16#0300#)),
(16#1F5D#, (16#1F59#, 16#0301#)),
(16#1F5F#, (16#1F59#, 16#0342#)),
(16#1F60#, (16#03C9#, 16#0313#)),
(16#1F61#, (16#03C9#, 16#0314#)),
(16#1F62#, (16#1F60#, 16#0300#)),
(16#1F63#, (16#1F61#, 16#0300#)),
(16#1F64#, (16#1F60#, 16#0301#)),
(16#1F65#, (16#1F61#, 16#0301#)),
(16#1F66#, (16#1F60#, 16#0342#)),
(16#1F67#, (16#1F61#, 16#0342#)),
(16#1F68#, (16#03A9#, 16#0313#)),
(16#1F69#, (16#03A9#, 16#0314#)),
(16#1F6A#, (16#1F68#, 16#0300#)),
(16#1F6B#, (16#1F69#, 16#0300#)),
(16#1F6C#, (16#1F68#, 16#0301#)),
(16#1F6D#, (16#1F69#, 16#0301#)),
(16#1F6E#, (16#1F68#, 16#0342#)),
(16#1F6F#, (16#1F69#, 16#0342#)),
(16#1F70#, (16#03B1#, 16#0300#)),
(16#1F72#, (16#03B5#, 16#0300#)),
(16#1F74#, (16#03B7#, 16#0300#)),
(16#1F76#, (16#03B9#, 16#0300#)),
(16#1F78#, (16#03BF#, 16#0300#)),
(16#1F7A#, (16#03C5#, 16#0300#)),
(16#1F7C#, (16#03C9#, 16#0300#)),
(16#1F80#, (16#1F00#, 16#0345#)),
(16#1F81#, (16#1F01#, 16#0345#)),
(16#1F82#, (16#1F02#, 16#0345#)),
(16#1F83#, (16#1F03#, 16#0345#)),
(16#1F84#, (16#1F04#, 16#0345#)),
(16#1F85#, (16#1F05#, 16#0345#)),
(16#1F86#, (16#1F06#, 16#0345#)),
(16#1F87#, (16#1F07#, 16#0345#)),
(16#1F88#, (16#1F08#, 16#0345#)),
(16#1F89#, (16#1F09#, 16#0345#)),
(16#1F8A#, (16#1F0A#, 16#0345#)),
(16#1F8B#, (16#1F0B#, 16#0345#)),
(16#1F8C#, (16#1F0C#, 16#0345#)),
(16#1F8D#, (16#1F0D#, 16#0345#)),
(16#1F8E#, (16#1F0E#, 16#0345#)),
(16#1F8F#, (16#1F0F#, 16#0345#)),
(16#1F90#, (16#1F20#, 16#0345#)),
(16#1F91#, (16#1F21#, 16#0345#)),
(16#1F92#, (16#1F22#, 16#0345#)),
(16#1F93#, (16#1F23#, 16#0345#)),
(16#1F94#, (16#1F24#, 16#0345#)),
(16#1F95#, (16#1F25#, 16#0345#)),
(16#1F96#, (16#1F26#, 16#0345#)),
(16#1F97#, (16#1F27#, 16#0345#)),
(16#1F98#, (16#1F28#, 16#0345#)),
(16#1F99#, (16#1F29#, 16#0345#)),
(16#1F9A#, (16#1F2A#, 16#0345#)),
(16#1F9B#, (16#1F2B#, 16#0345#)),
(16#1F9C#, (16#1F2C#, 16#0345#)),
(16#1F9D#, (16#1F2D#, 16#0345#)),
(16#1F9E#, (16#1F2E#, 16#0345#)),
(16#1F9F#, (16#1F2F#, 16#0345#)),
(16#1FA0#, (16#1F60#, 16#0345#)),
(16#1FA1#, (16#1F61#, 16#0345#)),
(16#1FA2#, (16#1F62#, 16#0345#)),
(16#1FA3#, (16#1F63#, 16#0345#)),
(16#1FA4#, (16#1F64#, 16#0345#)),
(16#1FA5#, (16#1F65#, 16#0345#)),
(16#1FA6#, (16#1F66#, 16#0345#)),
(16#1FA7#, (16#1F67#, 16#0345#)),
(16#1FA8#, (16#1F68#, 16#0345#)),
(16#1FA9#, (16#1F69#, 16#0345#)),
(16#1FAA#, (16#1F6A#, 16#0345#)),
(16#1FAB#, (16#1F6B#, 16#0345#)),
(16#1FAC#, (16#1F6C#, 16#0345#)),
(16#1FAD#, (16#1F6D#, 16#0345#)),
(16#1FAE#, (16#1F6E#, 16#0345#)),
(16#1FAF#, (16#1F6F#, 16#0345#)),
(16#1FB0#, (16#03B1#, 16#0306#)),
(16#1FB1#, (16#03B1#, 16#0304#)),
(16#1FB2#, (16#1F70#, 16#0345#)),
(16#1FB3#, (16#03B1#, 16#0345#)),
(16#1FB4#, (16#03AC#, 16#0345#)),
(16#1FB6#, (16#03B1#, 16#0342#)),
(16#1FB7#, (16#1FB6#, 16#0345#)),
(16#1FB8#, (16#0391#, 16#0306#)),
(16#1FB9#, (16#0391#, 16#0304#)),
(16#1FBA#, (16#0391#, 16#0300#)),
(16#1FBC#, (16#0391#, 16#0345#)),
(16#1FC1#, (16#00A8#, 16#0342#)),
(16#1FC2#, (16#1F74#, 16#0345#)),
(16#1FC3#, (16#03B7#, 16#0345#)),
(16#1FC4#, (16#03AE#, 16#0345#)),
(16#1FC6#, (16#03B7#, 16#0342#)),
(16#1FC7#, (16#1FC6#, 16#0345#)),
(16#1FC8#, (16#0395#, 16#0300#)),
(16#1FCA#, (16#0397#, 16#0300#)),
(16#1FCC#, (16#0397#, 16#0345#)),
(16#1FCD#, (16#1FBF#, 16#0300#)),
(16#1FCE#, (16#1FBF#, 16#0301#)),
(16#1FCF#, (16#1FBF#, 16#0342#)),
(16#1FD0#, (16#03B9#, 16#0306#)),
(16#1FD1#, (16#03B9#, 16#0304#)),
(16#1FD2#, (16#03CA#, 16#0300#)),
(16#1FD6#, (16#03B9#, 16#0342#)),
(16#1FD7#, (16#03CA#, 16#0342#)),
(16#1FD8#, (16#0399#, 16#0306#)),
(16#1FD9#, (16#0399#, 16#0304#)),
(16#1FDA#, (16#0399#, 16#0300#)),
(16#1FDD#, (16#1FFE#, 16#0300#)),
(16#1FDE#, (16#1FFE#, 16#0301#)),
(16#1FDF#, (16#1FFE#, 16#0342#)),
(16#1FE0#, (16#03C5#, 16#0306#)),
(16#1FE1#, (16#03C5#, 16#0304#)),
(16#1FE2#, (16#03CB#, 16#0300#)),
(16#1FE4#, (16#03C1#, 16#0313#)),
(16#1FE5#, (16#03C1#, 16#0314#)),
(16#1FE6#, (16#03C5#, 16#0342#)),
(16#1FE7#, (16#03CB#, 16#0342#)),
(16#1FE8#, (16#03A5#, 16#0306#)),
(16#1FE9#, (16#03A5#, 16#0304#)),
(16#1FEA#, (16#03A5#, 16#0300#)),
(16#1FEC#, (16#03A1#, 16#0314#)),
(16#1FED#, (16#00A8#, 16#0300#)),
(16#1FF2#, (16#1F7C#, 16#0345#)),
(16#1FF3#, (16#03C9#, 16#0345#)),
(16#1FF4#, (16#03CE#, 16#0345#)),
(16#1FF6#, (16#03C9#, 16#0342#)),
(16#1FF7#, (16#1FF6#, 16#0345#)),
(16#1FF8#, (16#039F#, 16#0300#)),
(16#1FFA#, (16#03A9#, 16#0300#)),
(16#1FFC#, (16#03A9#, 16#0345#)),
(16#304C#, (16#304B#, 16#3099#)),
(16#304E#, (16#304D#, 16#3099#)),
(16#3050#, (16#304F#, 16#3099#)),
(16#3052#, (16#3051#, 16#3099#)),
(16#3054#, (16#3053#, 16#3099#)),
(16#3056#, (16#3055#, 16#3099#)),
(16#3058#, (16#3057#, 16#3099#)),
(16#305A#, (16#3059#, 16#3099#)),
(16#305C#, (16#305B#, 16#3099#)),
(16#305E#, (16#305D#, 16#3099#)),
(16#3060#, (16#305F#, 16#3099#)),
(16#3062#, (16#3061#, 16#3099#)),
(16#3065#, (16#3064#, 16#3099#)),
(16#3067#, (16#3066#, 16#3099#)),
(16#3069#, (16#3068#, 16#3099#)),
(16#3070#, (16#306F#, 16#3099#)),
(16#3071#, (16#306F#, 16#309A#)),
(16#3073#, (16#3072#, 16#3099#)),
(16#3074#, (16#3072#, 16#309A#)),
(16#3076#, (16#3075#, 16#3099#)),
(16#3077#, (16#3075#, 16#309A#)),
(16#3079#, (16#3078#, 16#3099#)),
(16#307A#, (16#3078#, 16#309A#)),
(16#307C#, (16#307B#, 16#3099#)),
(16#307D#, (16#307B#, 16#309A#)),
(16#3094#, (16#3046#, 16#3099#)),
(16#309E#, (16#309D#, 16#3099#)),
(16#30AC#, (16#30AB#, 16#3099#)),
(16#30AE#, (16#30AD#, 16#3099#)),
(16#30B0#, (16#30AF#, 16#3099#)),
(16#30B2#, (16#30B1#, 16#3099#)),
(16#30B4#, (16#30B3#, 16#3099#)),
(16#30B6#, (16#30B5#, 16#3099#)),
(16#30B8#, (16#30B7#, 16#3099#)),
(16#30BA#, (16#30B9#, 16#3099#)),
(16#30BC#, (16#30BB#, 16#3099#)),
(16#30BE#, (16#30BD#, 16#3099#)),
(16#30C0#, (16#30BF#, 16#3099#)),
(16#30C2#, (16#30C1#, 16#3099#)),
(16#30C5#, (16#30C4#, 16#3099#)),
(16#30C7#, (16#30C6#, 16#3099#)),
(16#30C9#, (16#30C8#, 16#3099#)),
(16#30D0#, (16#30CF#, 16#3099#)),
(16#30D1#, (16#30CF#, 16#309A#)),
(16#30D3#, (16#30D2#, 16#3099#)),
(16#30D4#, (16#30D2#, 16#309A#)),
(16#30D6#, (16#30D5#, 16#3099#)),
(16#30D7#, (16#30D5#, 16#309A#)),
(16#30D9#, (16#30D8#, 16#3099#)),
(16#30DA#, (16#30D8#, 16#309A#)),
(16#30DC#, (16#30DB#, 16#3099#)),
(16#30DD#, (16#30DB#, 16#309A#)),
(16#30F4#, (16#30A6#, 16#3099#)),
(16#30F7#, (16#30EF#, 16#3099#)),
(16#30F8#, (16#30F0#, 16#3099#)),
(16#30F9#, (16#30F1#, 16#3099#)),
(16#30FA#, (16#30F2#, 16#3099#)),
(16#30FE#, (16#30FD#, 16#3099#)));
NFD_D_Table_XXXXXXXX : constant Map_32x2_Type (1 .. 5) := (
(16#1109A#, (16#11099#, 16#110BA#)),
(16#1109C#, (16#1109B#, 16#110BA#)),
(16#110AB#, (16#110A5#, 16#110BA#)),
(16#1112E#, (16#11131#, 16#11127#)),
(16#1112F#, (16#11132#, 16#11127#)));
NFD_E_Table_XXXX : constant Map_16x2_Type (1 .. 71) := (
(16#0344#, (16#0308#, 16#0301#)),
(16#0958#, (16#0915#, 16#093C#)),
(16#0959#, (16#0916#, 16#093C#)),
(16#095A#, (16#0917#, 16#093C#)),
(16#095B#, (16#091C#, 16#093C#)),
(16#095C#, (16#0921#, 16#093C#)),
(16#095D#, (16#0922#, 16#093C#)),
(16#095E#, (16#092B#, 16#093C#)),
(16#095F#, (16#092F#, 16#093C#)),
(16#09DC#, (16#09A1#, 16#09BC#)),
(16#09DD#, (16#09A2#, 16#09BC#)),
(16#09DF#, (16#09AF#, 16#09BC#)),
(16#0A33#, (16#0A32#, 16#0A3C#)),
(16#0A36#, (16#0A38#, 16#0A3C#)),
(16#0A59#, (16#0A16#, 16#0A3C#)),
(16#0A5A#, (16#0A17#, 16#0A3C#)),
(16#0A5B#, (16#0A1C#, 16#0A3C#)),
(16#0A5E#, (16#0A2B#, 16#0A3C#)),
(16#0B5C#, (16#0B21#, 16#0B3C#)),
(16#0B5D#, (16#0B22#, 16#0B3C#)),
(16#0F43#, (16#0F42#, 16#0FB7#)),
(16#0F4D#, (16#0F4C#, 16#0FB7#)),
(16#0F52#, (16#0F51#, 16#0FB7#)),
(16#0F57#, (16#0F56#, 16#0FB7#)),
(16#0F5C#, (16#0F5B#, 16#0FB7#)),
(16#0F69#, (16#0F40#, 16#0FB5#)),
(16#0F73#, (16#0F71#, 16#0F72#)),
(16#0F75#, (16#0F71#, 16#0F74#)),
(16#0F76#, (16#0FB2#, 16#0F80#)),
(16#0F78#, (16#0FB3#, 16#0F80#)),
(16#0F81#, (16#0F71#, 16#0F80#)),
(16#0F93#, (16#0F92#, 16#0FB7#)),
(16#0F9D#, (16#0F9C#, 16#0FB7#)),
(16#0FA2#, (16#0FA1#, 16#0FB7#)),
(16#0FA7#, (16#0FA6#, 16#0FB7#)),
(16#0FAC#, (16#0FAB#, 16#0FB7#)),
(16#0FB9#, (16#0F90#, 16#0FB5#)),
(16#FB1D#, (16#05D9#, 16#05B4#)),
(16#FB1F#, (16#05F2#, 16#05B7#)),
(16#FB2A#, (16#05E9#, 16#05C1#)),
(16#FB2B#, (16#05E9#, 16#05C2#)),
(16#FB2C#, (16#FB49#, 16#05C1#)),
(16#FB2D#, (16#FB49#, 16#05C2#)),
(16#FB2E#, (16#05D0#, 16#05B7#)),
(16#FB2F#, (16#05D0#, 16#05B8#)),
(16#FB30#, (16#05D0#, 16#05BC#)),
(16#FB31#, (16#05D1#, 16#05BC#)),
(16#FB32#, (16#05D2#, 16#05BC#)),
(16#FB33#, (16#05D3#, 16#05BC#)),
(16#FB34#, (16#05D4#, 16#05BC#)),
(16#FB35#, (16#05D5#, 16#05BC#)),
(16#FB36#, (16#05D6#, 16#05BC#)),
(16#FB38#, (16#05D8#, 16#05BC#)),
(16#FB39#, (16#05D9#, 16#05BC#)),
(16#FB3A#, (16#05DA#, 16#05BC#)),
(16#FB3B#, (16#05DB#, 16#05BC#)),
(16#FB3C#, (16#05DC#, 16#05BC#)),
(16#FB3E#, (16#05DE#, 16#05BC#)),
(16#FB40#, (16#05E0#, 16#05BC#)),
(16#FB41#, (16#05E1#, 16#05BC#)),
(16#FB43#, (16#05E3#, 16#05BC#)),
(16#FB44#, (16#05E4#, 16#05BC#)),
(16#FB46#, (16#05E6#, 16#05BC#)),
(16#FB47#, (16#05E7#, 16#05BC#)),
(16#FB48#, (16#05E8#, 16#05BC#)),
(16#FB49#, (16#05E9#, 16#05BC#)),
(16#FB4A#, (16#05EA#, 16#05BC#)),
(16#FB4B#, (16#05D5#, 16#05B9#)),
(16#FB4C#, (16#05D1#, 16#05BF#)),
(16#FB4D#, (16#05DB#, 16#05BF#)),
(16#FB4E#, (16#05E4#, 16#05BF#)));
NFD_E_Table_XXXXXXXX : constant Map_32x2_Type (1 .. 13) := (
(16#1D15E#, (16#1D157#, 16#1D165#)),
(16#1D15F#, (16#1D158#, 16#1D165#)),
(16#1D160#, (16#1D15F#, 16#1D16E#)),
(16#1D161#, (16#1D15F#, 16#1D16F#)),
(16#1D162#, (16#1D15F#, 16#1D170#)),
(16#1D163#, (16#1D15F#, 16#1D171#)),
(16#1D164#, (16#1D15F#, 16#1D172#)),
(16#1D1BB#, (16#1D1B9#, 16#1D165#)),
(16#1D1BC#, (16#1D1BA#, 16#1D165#)),
(16#1D1BD#, (16#1D1BB#, 16#1D16E#)),
(16#1D1BE#, (16#1D1BC#, 16#1D16E#)),
(16#1D1BF#, (16#1D1BB#, 16#1D16F#)),
(16#1D1C0#, (16#1D1BC#, 16#1D16F#)));
NFD_S_Table_XXXX : constant Map_16x1_Type (1 .. 26) := (
(16#0340#, 16#0300#),
(16#0341#, 16#0301#),
(16#0343#, 16#0313#),
(16#0374#, 16#02B9#),
(16#037E#, 16#003B#),
(16#0387#, 16#00B7#),
(16#1F71#, 16#03AC#),
(16#1F73#, 16#03AD#),
(16#1F75#, 16#03AE#),
(16#1F77#, 16#03AF#),
(16#1F79#, 16#03CC#),
(16#1F7B#, 16#03CD#),
(16#1F7D#, 16#03CE#),
(16#1FBB#, 16#0386#),
(16#1FBE#, 16#03B9#),
(16#1FC9#, 16#0388#),
(16#1FCB#, 16#0389#),
(16#1FD3#, 16#0390#),
(16#1FDB#, 16#038A#),
(16#1FE3#, 16#03B0#),
(16#1FEB#, 16#038E#),
(16#1FEE#, 16#0385#),
(16#1FEF#, 16#0060#),
(16#1FF9#, 16#038C#),
(16#1FFB#, 16#038F#),
(16#1FFD#, 16#00B4#));
end Ada.UCD.Normalization;
|
io7m/coreland-c_string | Ada | 542 | adb | with Ada.Text_IO;
with C_String;
with Interfaces.C;
with Test;
procedure t_assume is
package IO renames Ada.Text_IO;
package C renames Interfaces.C;
use type C.int;
function ccall_assume (Value : C_String.String_Ptr_t) return C.int;
pragma Import (c, ccall_assume, "ccall_assume");
begin
IO.Put_Line ("-- Ada begin");
Test.Assert
(Check => ccall_assume (null) = 1,
Pass_Message => "null = String_Ptr'(null)",
Fail_Message => "null /= String_Ptr'(null)");
IO.Put_Line ("-- Ada exit");
end t_assume;
|
GPUWorks/lumen2 | Ada | 1,270 | ads |
-- Lumen -- A simple graphical user interface library based on OpenGL
--
-- Chip Richards, NiEstu, Phoenix AZ, Spring 2010
-- Lumen would not be possible without the support and contributions of a cast
-- of thousands, including and primarily Rod Kay.
-- This code is covered by the ISC License:
--
-- Copyright © 2010, NiEstu
--
-- 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.
package Lumen is
---------------------------------------------------------------------------
pragma Pure;
---------------------------------------------------------------------------
end Lumen;
|
reznikmm/matreshka | Ada | 3,639 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-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$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.Elements.Generic_Hash;
function AMF.OCL.Unspecified_Value_Exps.Hash is
new AMF.Elements.Generic_Hash (OCL_Unspecified_Value_Exp, OCL_Unspecified_Value_Exp_Access);
|
jwarwick/aoc_2020 | Ada | 2,603 | adb | -- AoC 2020, Day 10
with Ada.Text_IO;
with Ada.Containers.Ordered_Maps;
package body Day is
package TIO renames Ada.Text_IO;
function load_file(filename : in String) return Adaptors.Vector is
package Natural_Text_IO is new Ada.Text_IO.Integer_IO(Natural);
package Adaptor_Sorter is new Adaptors.Generic_Sorting;
file : TIO.File_Type;
v : Adaptors.Vector := Empty_Vector;
n : Natural := 0;
begin
TIO.open(File => file, Mode => TIO.In_File, Name => filename);
while not TIO.end_of_file(file) loop
Natural_Text_IO.get(file, n);
v.append(n);
end loop;
TIO.close(file);
Adaptor_Sorter.sort(Container => v);
return v;
end load_file;
function mult_diffs(v : in Adaptors.Vector) return Natural is
diff_1 : Natural := 0;
diff_3 : Natural := 0;
curr : Natural;
last : Natural := v.first_element;
begin
for idx in v.first_index+1 .. v.last_index loop
curr := v(idx);
case curr - last is
when 3 => diff_3 := diff_3 + 1;
when 1 => diff_1 := diff_1 + 1;
when others => null;
end case;
last := curr;
end loop;
return diff_1 * diff_3;
end mult_diffs;
function mult_1_3_differences(v : in Adaptors.Vector) return Natural is
remaining : Adaptors.Vector := v;
begin
remaining.prepend(0);
remaining.append(remaining.last_element + 3);
return mult_diffs(remaining);
end mult_1_3_differences;
package Reachable_Map is new Ada.Containers.Ordered_Maps
(Element_Type => Long_Integer,
Key_Type => Natural);
use Reachable_Map;
reach_map : Reachable_Map.Map := Empty_Map;
function count(curr_idx : in Natural; v : in Adaptors.Vector) return Long_Integer is
curr_value : constant Natural := v(curr_idx);
total : Long_Integer := 0;
last_idx : constant Natural := Natural'Min(curr_idx+3, v.last_index);
begin
if contains(reach_map, curr_value) then
return reach_map(curr_value);
end if;
for next_idx in curr_idx+1..last_idx loop
if v(next_idx) + 3 >= curr_value then
total := total + count(next_idx, v);
end if;
end loop;
reach_map.insert(curr_value, total);
return total;
end count;
function total_arrangments(v : in Adaptors.Vector) return Long_Integer is
v_first_last : Adaptors.Vector := v;
begin
v_first_last.prepend(0);
v_first_last.append(v_first_last.last_element + 3);
reverse_elements(v_first_last);
clear(reach_map);
reach_map.insert(0, 1);
return count(v_first_last.first_index, v_first_last);
end total_arrangments;
end Day;
|
AaronC98/PlaneSystem | Ada | 5,320 | ads | ------------------------------------------------------------------------------
-- Generic memory stream --
-- --
-- Copyright (C) 2003-2015, 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. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
------------------------------------------------------------------------------
generic
type Element is private;
type Element_Index is range <>;
type Element_Array is array (Element_Index range <>) of Element;
type Element_Access is access Element_Array;
type Constant_Access is access constant Element_Array;
First_Block_Length : in Element_Index := 256;
Next_Block_Length : in Element_Index := 1_024;
package Memory_Streams is
type Stream_Type is limited private;
subtype Element_Offset is Element_Index'Base range 0 .. Element_Index'Last;
procedure Append
(Stream : in out Stream_Type;
Value : in Element_Array;
Trim : in Boolean := False);
-- Append the data to the resource.
-- Set Trim to true disable remaining free spaces at the end of stream,
-- Set Trim to true for every call to stream would decrease performance.
procedure Append
(Stream : in out Stream_Type;
Data : in Element_Access);
-- Append dynamically allocated data or access to the static data
-- to the stream. Application must not use Data after send it to the
-- Stream. Stream would care about it, and free when necessary.
procedure Append
(Stream : in out Stream_Type;
Data : in Constant_Access);
-- Append dynamically allocated data or access to the static data
-- to the stream. Application could use Data after send it to the
-- Stream.
function Size (Stream : in Stream_Type) return Element_Offset;
-- Returns the size of the stream in bytes (total number of bytes)
function Pending (Stream : in Stream_Type) return Element_Offset;
-- Returns the number of byte from current position to the end
procedure Reset (Stream : in out Stream_Type);
-- Set read index at the start of the stream
procedure Set_Index
(Stream : in out Stream_Type;
To : in Element_Offset);
-- Set the position in the stream, next Read will start at the position
-- whose index is To. If To is outside the content the index is set to
-- Last + 1 to ensure that next End_Of_File will return True.
function End_Of_File (Stream : in Stream_Type) return Boolean;
-- Returns true if there is no more data to read on the stream
procedure Read
(Stream : in out Stream_Type;
Buffer : out Element_Array;
Last : out Element_Offset);
-- Read a chunk of data from File and put them into Buffer. Last is the
-- index of the last item returned in Buffer.
procedure Close (Stream : in out Stream_Type);
-- Close File, release all data currently in this stream
procedure Clear (Stream : in out Stream_Type) renames Close;
private
type Buffer_Type;
type Buffer_Access is access all Buffer_Type;
type Buffer_Type (Steady : Boolean) is record
Next : Buffer_Access;
case Steady is
when True => Const : Constant_Access;
when False => Data : Element_Access;
end case;
end record;
type Stream_Type is limited record
First : Buffer_Access;
Current : Buffer_Access;
Last : Buffer_Access;
Last_Length : Element_Offset := 0;
Length : Element_Offset := 0;
Current_Offset : Element_Index := 1;
end record;
end Memory_Streams;
|
reznikmm/matreshka | Ada | 4,337 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2010-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 League.Stream_Element_Vectors.Internals is
--------------
-- Internal --
--------------
function Internal
(Item : Stream_Element_Vector)
return MISEV.Shared_Stream_Element_Vector_Access is
begin
return Item.Data;
end Internal;
-------------
-- Replace --
-------------
procedure Replace
(Vector : in out Stream_Element_Vector;
Item : not null MISEV.Shared_Stream_Element_Vector_Access)
is
use type MISEV.Shared_Stream_Element_Vector_Access;
begin
if Vector.Data /= Item then
MISEV.Dereference (Vector.Data);
Vector.Data := Item;
end if;
end Replace;
----------
-- Wrap --
----------
function Wrap
(Item : not null MISEV.Shared_Stream_Element_Vector_Access)
return Stream_Element_Vector is
begin
return
Stream_Element_Vector'(Ada.Finalization.Controlled with Data => Item);
end Wrap;
end League.Stream_Element_Vectors.Internals;
|
zenharris/ada-bbs | Ada | 514 | ads | with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Calendar; use Ada.Calendar;
with Ada.Calendar.Formatting; use Ada.Calendar.Formatting;
package Display_Warning is
Cancel : Boolean := False;
procedure Warning (Message : String; Down : Integer := 0; D : Duration := 0.0);
function GetYN (Message : String; Down : Integer := 0) return Boolean;
end Display_Warning;
|
reznikmm/matreshka | Ada | 6,861 | 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.Null_Date_Elements is
------------
-- Create --
------------
overriding function Create
(Parameters : not null access Matreshka.DOM_Elements.Element_L2_Parameters)
return Table_Null_Date_Element_Node is
begin
return Self : Table_Null_Date_Element_Node do
Matreshka.ODF_Table.Constructors.Initialize
(Self'Unchecked_Access,
Parameters.Document,
Matreshka.ODF_String_Constants.Table_Prefix);
end return;
end Create;
----------------
-- Enter_Node --
----------------
overriding procedure Enter_Node
(Self : not null access Table_Null_Date_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_Table_Null_Date
(ODF.DOM.Table_Null_Date_Elements.ODF_Table_Null_Date_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 Table_Null_Date_Element_Node)
return League.Strings.Universal_String
is
pragma Unreferenced (Self);
begin
return Matreshka.ODF_String_Constants.Null_Date_Element;
end Get_Local_Name;
----------------
-- Leave_Node --
----------------
overriding procedure Leave_Node
(Self : not null access Table_Null_Date_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_Table_Null_Date
(ODF.DOM.Table_Null_Date_Elements.ODF_Table_Null_Date_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 Table_Null_Date_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_Table_Null_Date
(Visitor,
ODF.DOM.Table_Null_Date_Elements.ODF_Table_Null_Date_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.Table_URI,
Matreshka.ODF_String_Constants.Null_Date_Element,
Table_Null_Date_Element_Node'Tag);
end Matreshka.ODF_Table.Null_Date_Elements;
|
charlie5/lace | Ada | 1,685 | ads | -- This file is generated by SWIG. Please do *not* modify by hand.
--
with Interfaces.C;
package osmesa_c.Pointers is
-- GLenum_Pointer
--
type GLenum_Pointer is access all osmesa_c.GLenum;
-- GLenum_Pointers
--
type GLenum_Pointers is
array
(Interfaces.C
.size_t range <>) of aliased osmesa_c.Pointers.GLenum_Pointer;
-- GLint_Pointer
--
type GLint_Pointer is access all osmesa_c.GLint;
-- GLint_Pointers
--
type GLint_Pointers is
array
(Interfaces.C
.size_t range <>) of aliased osmesa_c.Pointers.GLint_Pointer;
-- GLsizei_Pointer
--
type GLsizei_Pointer is access all osmesa_c.GLsizei;
-- GLsizei_Pointers
--
type GLsizei_Pointers is
array
(Interfaces.C
.size_t range <>) of aliased osmesa_c.Pointers.GLsizei_Pointer;
-- GLboolean_Pointer
--
type GLboolean_Pointer is access all osmesa_c.GLboolean;
-- GLboolean_Pointers
--
type GLboolean_Pointers is
array
(Interfaces.C
.size_t range <>) of aliased osmesa_c.Pointers.GLboolean_Pointer;
-- OSMesaContext_Pointer
--
type OSMesaContext_Pointer is access all osmesa_c.OSMesaContext;
-- OSMesaContext_Pointers
--
type OSMesaContext_Pointers is
array
(Interfaces.C
.size_t range <>) of aliased osmesa_c.Pointers.OSMesaContext_Pointer;
-- OSMESAproc_Pointer
--
type OSMESAproc_Pointer is access all osmesa_c.OSMESAproc;
-- OSMESAproc_Pointers
--
type OSMESAproc_Pointers is
array
(Interfaces.C
.size_t range <>) of aliased osmesa_c.Pointers.OSMESAproc_Pointer;
end osmesa_c.Pointers;
|
reznikmm/matreshka | Ada | 5,817 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- XML Processor --
-- --
-- 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 League.Strings;
private with Matreshka.Atomics.Counters;
limited with XML.DOM.Visitors;
package XML.DOM.Nodes is
type DOM_Node is abstract tagged limited private;
type DOM_Node_Access is access all DOM_Node'Class;
function Get_First_Child
(Self : not null access constant DOM_Node'Class) return DOM_Node_Access;
not overriding function Get_Local_Name
(Self : not null access constant DOM_Node)
return League.Strings.Universal_String is abstract;
not overriding function Get_Namespace_URI
(Self : not null access constant DOM_Node)
return League.Strings.Universal_String is abstract;
function Get_Next_Sibling
(Self : not null access constant DOM_Node'Class) return DOM_Node_Access;
procedure Append_Child
(Self : not null access DOM_Node'Class; Node : not null DOM_Node_Access);
---------------
-- Internals --
---------------
procedure Dereference (Node : in out DOM_Node_Access);
-- Decrements reference counter; deallocate node when counter reachs zero.
-- Sets Node to null on return.
not overriding procedure Enter_Element
(Self : not null access DOM_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is abstract;
-- Dispatch call to corresponding subprogram of visitor interface.
not overriding procedure Leave_Element
(Self : not null access DOM_Node;
Visitor : in out XML.DOM.Visitors.Abstract_Visitor'Class;
Control : in out XML.DOM.Visitors.Traverse_Control) is abstract;
-- Dispatch call to corresponding subprogram of visitor interface.
not overriding procedure Visit_Element
(Self : not null access DOM_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 abstract;
-- Dispatch call to corresponding subprogram of iterator interface.
private
type DOM_Node is abstract tagged limited record
Counter : Matreshka.Atomics.Counters.Counter;
Parent_Node : DOM_Node_Access;
First_Child : DOM_Node_Access;
Last_Child : DOM_Node_Access;
Next_Sibling : DOM_Node_Access;
Previous_Sibling : DOM_Node_Access;
end record;
procedure Reference (Node : not null DOM_Node_Access);
-- Increments reference counter.
end XML.DOM.Nodes;
|
AdaCore/training_material | Ada | 1,058 | ads | package Basics is
type Rec is record
A, B : Integer;
end record;
type Index is range 1 .. 10;
type Table is array (Index range <>) of Integer;
procedure Swap (X, Y : in out Integer)
with Global => null;
The_Rec : Rec;
The_Table : Table (1 .. 10);
procedure Swap_Rec (R : in out Rec)
with Global => null;
procedure Swap_Table (T : in out Table; I, J : Index)
with Global => null;
procedure Swap_The_Rec
with Global => (In_Out => The_Rec);
procedure Swap_The_Table (I, J : Index)
with Global => (In_Out => The_Table);
procedure Init_Rec (R : out Rec)
with Global => null;
procedure Init_Table (T : out Table)
with Global => null;
procedure Init_The_Rec
with Global => (Output => Basics.The_Rec);
procedure Init_The_Table
with Global => (Output => Basics.The_Table);
procedure Strange_Init_Rec (R : out Rec; Cond : Boolean)
with Global => null;
procedure Strange_Init_Table (T : out Table; Val : Integer)
with Global => null;
end Basics;
|
AdaCore/libadalang | Ada | 235,212 | adb | ------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S E M _ E V A L --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2017, 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. --
-- --
------------------------------------------------------------------------------
with Aspects; use Aspects;
with Atree; use Atree;
with Checks; use Checks;
with Debug; use Debug;
with Einfo; use Einfo;
with Elists; use Elists;
with Errout; use Errout;
with Eval_Fat; use Eval_Fat;
with Exp_Util; use Exp_Util;
with Freeze; use Freeze;
with Lib; use Lib;
with Namet; use Namet;
with Nmake; use Nmake;
with Nlists; use Nlists;
with Opt; use Opt;
with Par_SCO; use Par_SCO;
with Rtsfind; use Rtsfind;
with Sem; use Sem;
with Sem_Aux; use Sem_Aux;
with Sem_Cat; use Sem_Cat;
with Sem_Ch6; use Sem_Ch6;
with Sem_Ch8; use Sem_Ch8;
with Sem_Res; use Sem_Res;
with Sem_Util; use Sem_Util;
with Sem_Type; use Sem_Type;
with Sem_Warn; use Sem_Warn;
with Sinfo; use Sinfo;
with Snames; use Snames;
with Stand; use Stand;
with Stringt; use Stringt;
with Tbuild; use Tbuild;
package body Sem_Eval is
-----------------------------------------
-- Handling of Compile Time Evaluation --
-----------------------------------------
-- The compile time evaluation of expressions is distributed over several
-- Eval_xxx procedures. These procedures are called immediately after
-- a subexpression is resolved and is therefore accomplished in a bottom
-- up fashion. The flags are synthesized using the following approach.
-- Is_Static_Expression is determined by following the detailed rules
-- in RM 4.9(4-14). This involves testing the Is_Static_Expression
-- flag of the operands in many cases.
-- Raises_Constraint_Error is set if any of the operands have the flag
-- set or if an attempt to compute the value of the current expression
-- results in detection of a runtime constraint error.
-- As described in the spec, the requirement is that Is_Static_Expression
-- be accurately set, and in addition for nodes for which this flag is set,
-- Raises_Constraint_Error must also be set. Furthermore a node which has
-- Is_Static_Expression set, and Raises_Constraint_Error clear, then the
-- requirement is that the expression value must be precomputed, and the
-- node is either a literal, or the name of a constant entity whose value
-- is a static expression.
-- The general approach is as follows. First compute Is_Static_Expression.
-- If the node is not static, then the flag is left off in the node and
-- we are all done. Otherwise for a static node, we test if any of the
-- operands will raise constraint error, and if so, propagate the flag
-- Raises_Constraint_Error to the result node and we are done (since the
-- error was already posted at a lower level).
-- For the case of a static node whose operands do not raise constraint
-- error, we attempt to evaluate the node. If this evaluation succeeds,
-- then the node is replaced by the result of this computation. If the
-- evaluation raises constraint error, then we rewrite the node with
-- Apply_Compile_Time_Constraint_Error to raise the exception and also
-- to post appropriate error messages.
----------------
-- Local Data --
----------------
type Bits is array (Nat range <>) of Boolean;
-- Used to convert unsigned (modular) values for folding logical ops
-- The following declarations are used to maintain a cache of nodes that
-- have compile time known values. The cache is maintained only for
-- discrete types (the most common case), and is populated by calls to
-- Compile_Time_Known_Value and Expr_Value, but only used by Expr_Value
-- since it is possible for the status to change (in particular it is
-- possible for a node to get replaced by a constraint error node).
CV_Bits : constant := 5;
-- Number of low order bits of Node_Id value used to reference entries
-- in the cache table.
CV_Cache_Size : constant Nat := 2 ** CV_Bits;
-- Size of cache for compile time values
subtype CV_Range is Nat range 0 .. CV_Cache_Size;
type CV_Entry is record
N : Node_Id;
V : Uint;
end record;
type Match_Result is (Match, No_Match, Non_Static);
-- Result returned from functions that test for a matching result. If the
-- operands are not OK_Static then Non_Static will be returned. Otherwise
-- Match/No_Match is returned depending on whether the match succeeds.
type CV_Cache_Array is array (CV_Range) of CV_Entry;
CV_Cache : CV_Cache_Array := (others => (Node_High_Bound, Uint_0));
-- This is the actual cache, with entries consisting of node/value pairs,
-- and the impossible value Node_High_Bound used for unset entries.
type Range_Membership is (In_Range, Out_Of_Range, Unknown);
-- Range membership may either be statically known to be in range or out
-- of range, or not statically known. Used for Test_In_Range below.
-----------------------
-- Local Subprograms --
-----------------------
function Choice_Matches
(Expr : Node_Id;
Choice : Node_Id) return Match_Result;
-- Determines whether given value Expr matches the given Choice. The Expr
-- can be of discrete, real, or string type and must be a compile time
-- known value (it is an error to make the call if these conditions are
-- not met). The choice can be a range, subtype name, subtype indication,
-- or expression. The returned result is Non_Static if Choice is not
-- OK_Static, otherwise either Match or No_Match is returned depending
-- on whether Choice matches Expr. This is used for case expression
-- alternatives, and also for membership tests. In each case, more
-- possibilities are tested than the syntax allows (e.g. membership allows
-- subtype indications and non-discrete types, and case allows an OTHERS
-- choice), but it does not matter, since we have already done a full
-- semantic and syntax check of the construct, so the extra possibilities
-- just will not arise for correct expressions.
--
-- Note: if Choice_Matches finds that a choice raises Constraint_Error, e.g
-- a reference to a type, one of whose bounds raises Constraint_Error, then
-- it also sets the Raises_Constraint_Error flag on the Choice itself.
function Choices_Match
(Expr : Node_Id;
Choices : List_Id) return Match_Result;
-- This function applies Choice_Matches to each element of Choices. If the
-- result is No_Match, then it continues and checks the next element. If
-- the result is Match or Non_Static, this result is immediately given
-- as the result without checking the rest of the list. Expr can be of
-- discrete, real, or string type and must be a compile time known value
-- (it is an error to make the call if these conditions are not met).
function Find_Universal_Operator_Type (N : Node_Id) return Entity_Id;
-- Check whether an arithmetic operation with universal operands which is a
-- rewritten function call with an explicit scope indication is ambiguous:
-- P."+" (1, 2) will be ambiguous if there is more than one visible numeric
-- type declared in P and the context does not impose a type on the result
-- (e.g. in the expression of a type conversion). If ambiguous, emit an
-- error and return Empty, else return the result type of the operator.
function From_Bits (B : Bits; T : Entity_Id) return Uint;
-- Converts a bit string of length B'Length to a Uint value to be used for
-- a target of type T, which is a modular type. This procedure includes the
-- necessary reduction by the modulus in the case of a nonbinary modulus
-- (for a binary modulus, the bit string is the right length any way so all
-- is well).
function Get_String_Val (N : Node_Id) return Node_Id;
-- Given a tree node for a folded string or character value, returns the
-- corresponding string literal or character literal (one of the two must
-- be available, or the operand would not have been marked as foldable in
-- the earlier analysis of the operation).
function Is_OK_Static_Choice (Choice : Node_Id) return Boolean;
-- Given a choice (from a case expression or membership test), returns
-- True if the choice is static and does not raise a Constraint_Error.
function Is_OK_Static_Choice_List (Choices : List_Id) return Boolean;
-- Given a choice list (from a case expression or membership test), return
-- True if all choices are static in the sense of Is_OK_Static_Choice.
function Is_Static_Choice (Choice : Node_Id) return Boolean;
-- Given a choice (from a case expression or membership test), returns
-- True if the choice is static. No test is made for raising of constraint
-- error, so this function is used only for legality tests.
function Is_Static_Choice_List (Choices : List_Id) return Boolean;
-- Given a choice list (from a case expression or membership test), return
-- True if all choices are static in the sense of Is_Static_Choice.
function Is_Static_Range (N : Node_Id) return Boolean;
-- Determine if range is static, as defined in RM 4.9(26). The only allowed
-- argument is an N_Range node (but note that the semantic analysis of
-- equivalent range attribute references already turned them into the
-- equivalent range). This differs from Is_OK_Static_Range (which is what
-- must be used by clients) in that it does not care whether the bounds
-- raise Constraint_Error or not. Used for checking whether expressions are
-- static in the 4.9 sense (without worrying about exceptions).
function OK_Bits (N : Node_Id; Bits : Uint) return Boolean;
-- Bits represents the number of bits in an integer value to be computed
-- (but the value has not been computed yet). If this value in Bits is
-- reasonable, a result of True is returned, with the implication that the
-- caller should go ahead and complete the calculation. If the value in
-- Bits is unreasonably large, then an error is posted on node N, and
-- False is returned (and the caller skips the proposed calculation).
procedure Out_Of_Range (N : Node_Id);
-- This procedure is called if it is determined that node N, which appears
-- in a non-static context, is a compile time known value which is outside
-- its range, i.e. the range of Etype. This is used in contexts where
-- this is an illegality if N is static, and should generate a warning
-- otherwise.
function Real_Or_String_Static_Predicate_Matches
(Val : Node_Id;
Typ : Entity_Id) return Boolean;
-- This is the function used to evaluate real or string static predicates.
-- Val is an unanalyzed N_Real_Literal or N_String_Literal node, which
-- represents the value to be tested against the predicate. Typ is the
-- type with the predicate, from which the predicate expression can be
-- extracted. The result returned is True if the given value satisfies
-- the predicate.
procedure Rewrite_In_Raise_CE (N : Node_Id; Exp : Node_Id);
-- N and Exp are nodes representing an expression, Exp is known to raise
-- CE. N is rewritten in term of Exp in the optimal way.
function String_Type_Len (Stype : Entity_Id) return Uint;
-- Given a string type, determines the length of the index type, or, if
-- this index type is non-static, the length of the base type of this index
-- type. Note that if the string type is itself static, then the index type
-- is static, so the second case applies only if the string type passed is
-- non-static.
function Test (Cond : Boolean) return Uint;
pragma Inline (Test);
-- This function simply returns the appropriate Boolean'Pos value
-- corresponding to the value of Cond as a universal integer. It is
-- used for producing the result of the static evaluation of the
-- logical operators
procedure Test_Expression_Is_Foldable
(N : Node_Id;
Op1 : Node_Id;
Stat : out Boolean;
Fold : out Boolean);
-- Tests to see if expression N whose single operand is Op1 is foldable,
-- i.e. the operand value is known at compile time. If the operation is
-- foldable, then Fold is True on return, and Stat indicates whether the
-- result is static (i.e. the operand was static). Note that it is quite
-- possible for Fold to be True, and Stat to be False, since there are
-- cases in which we know the value of an operand even though it is not
-- technically static (e.g. the static lower bound of a range whose upper
-- bound is non-static).
--
-- If Stat is set False on return, then Test_Expression_Is_Foldable makes
-- a call to Check_Non_Static_Context on the operand. If Fold is False on
-- return, then all processing is complete, and the caller should return,
-- since there is nothing else to do.
--
-- If Stat is set True on return, then Is_Static_Expression is also set
-- true in node N. There are some cases where this is over-enthusiastic,
-- e.g. in the two operand case below, for string comparison, the result is
-- not static even though the two operands are static. In such cases, the
-- caller must reset the Is_Static_Expression flag in N.
--
-- If Fold and Stat are both set to False then this routine performs also
-- the following extra actions:
--
-- If either operand is Any_Type then propagate it to result to prevent
-- cascaded errors.
--
-- If some operand raises constraint error, then replace the node N
-- with the raise constraint error node. This replacement inherits the
-- Is_Static_Expression flag from the operands.
procedure Test_Expression_Is_Foldable
(N : Node_Id;
Op1 : Node_Id;
Op2 : Node_Id;
Stat : out Boolean;
Fold : out Boolean;
CRT_Safe : Boolean := False);
-- Same processing, except applies to an expression N with two operands
-- Op1 and Op2. The result is static only if both operands are static. If
-- CRT_Safe is set True, then CRT_Safe_Compile_Time_Known_Value is used
-- for the tests that the two operands are known at compile time. See
-- spec of this routine for further details.
function Test_In_Range
(N : Node_Id;
Typ : Entity_Id;
Assume_Valid : Boolean;
Fixed_Int : Boolean;
Int_Real : Boolean) return Range_Membership;
-- Common processing for Is_In_Range and Is_Out_Of_Range: Returns In_Range
-- or Out_Of_Range if it can be guaranteed at compile time that expression
-- N is known to be in or out of range of the subtype Typ. If not compile
-- time known, Unknown is returned. See documentation of Is_In_Range for
-- complete description of parameters.
procedure To_Bits (U : Uint; B : out Bits);
-- Converts a Uint value to a bit string of length B'Length
-----------------------------------------------
-- Check_Expression_Against_Static_Predicate --
-----------------------------------------------
procedure Check_Expression_Against_Static_Predicate
(Expr : Node_Id;
Typ : Entity_Id)
is
begin
-- Nothing to do if expression is not known at compile time, or the
-- type has no static predicate set (will be the case for all non-scalar
-- types, so no need to make a special test for that).
if not (Has_Static_Predicate (Typ)
and then Compile_Time_Known_Value (Expr))
then
return;
end if;
-- Here we have a static predicate (note that it could have arisen from
-- an explicitly specified Dynamic_Predicate whose expression met the
-- rules for being predicate-static). If the expression is known at
-- compile time and obeys the predicate, then it is static and must be
-- labeled as such, which matters e.g. for case statements. The original
-- expression may be a type conversion of a variable with a known value,
-- which might otherwise not be marked static.
-- Case of real static predicate
if Is_Real_Type (Typ) then
if Real_Or_String_Static_Predicate_Matches
(Val => Make_Real_Literal (Sloc (Expr), Expr_Value_R (Expr)),
Typ => Typ)
then
Set_Is_Static_Expression (Expr);
return;
end if;
-- Case of string static predicate
elsif Is_String_Type (Typ) then
if Real_Or_String_Static_Predicate_Matches
(Val => Expr_Value_S (Expr), Typ => Typ)
then
Set_Is_Static_Expression (Expr);
return;
end if;
-- Case of discrete static predicate
else
pragma Assert (Is_Discrete_Type (Typ));
-- If static predicate matches, nothing to do
if Choices_Match (Expr, Static_Discrete_Predicate (Typ)) = Match then
Set_Is_Static_Expression (Expr);
return;
end if;
end if;
-- Here we know that the predicate will fail
-- Special case of static expression failing a predicate (other than one
-- that was explicitly specified with a Dynamic_Predicate aspect). This
-- is the case where the expression is no longer considered static.
if Is_Static_Expression (Expr)
and then not Has_Dynamic_Predicate_Aspect (Typ)
then
Error_Msg_NE
("??static expression fails static predicate check on &",
Expr, Typ);
Error_Msg_N
("\??expression is no longer considered static", Expr);
Set_Is_Static_Expression (Expr, False);
-- In all other cases, this is just a warning that a test will fail.
-- It does not matter if the expression is static or not, or if the
-- predicate comes from a dynamic predicate aspect or not.
else
Error_Msg_NE
("??expression fails predicate check on &", Expr, Typ);
end if;
end Check_Expression_Against_Static_Predicate;
------------------------------
-- Check_Non_Static_Context --
------------------------------
procedure Check_Non_Static_Context (N : Node_Id) is
T : constant Entity_Id := Etype (N);
Checks_On : constant Boolean :=
not Index_Checks_Suppressed (T)
and not Range_Checks_Suppressed (T);
begin
-- Ignore cases of non-scalar types, error types, or universal real
-- types that have no usable bounds.
if T = Any_Type
or else not Is_Scalar_Type (T)
or else T = Universal_Fixed
or else T = Universal_Real
then
return;
end if;
-- At this stage we have a scalar type. If we have an expression that
-- raises CE, then we already issued a warning or error msg so there is
-- nothing more to be done in this routine.
if Raises_Constraint_Error (N) then
return;
end if;
-- Now we have a scalar type which is not marked as raising a constraint
-- error exception. The main purpose of this routine is to deal with
-- static expressions appearing in a non-static context. That means
-- that if we do not have a static expression then there is not much
-- to do. The one case that we deal with here is that if we have a
-- floating-point value that is out of range, then we post a warning
-- that an infinity will result.
if not Is_Static_Expression (N) then
if Is_Floating_Point_Type (T) then
if Is_Out_Of_Range (N, Base_Type (T), Assume_Valid => True) then
Error_Msg_N
("??float value out of range, infinity will be generated", N);
-- The literal may be the result of constant-folding of a non-
-- static subexpression of a larger expression (e.g. a conversion
-- of a non-static variable whose value happens to be known). At
-- this point we must reduce the value of the subexpression to a
-- machine number (RM 4.9 (38/2)).
elsif Nkind (N) = N_Real_Literal
and then Nkind (Parent (N)) in N_Subexpr
then
Rewrite (N, New_Copy (N));
Set_Realval
(N, Machine (Base_Type (T), Realval (N), Round_Even, N));
end if;
end if;
return;
end if;
-- Here we have the case of outer level static expression of scalar
-- type, where the processing of this procedure is needed.
-- For real types, this is where we convert the value to a machine
-- number (see RM 4.9(38)). Also see ACVC test C490001. We should only
-- need to do this if the parent is a constant declaration, since in
-- other cases, gigi should do the necessary conversion correctly, but
-- experimentation shows that this is not the case on all machines, in
-- particular if we do not convert all literals to machine values in
-- non-static contexts, then ACVC test C490001 fails on Sparc/Solaris
-- and SGI/Irix.
-- This conversion is always done by GNATprove on real literals in
-- non-static expressions, by calling Check_Non_Static_Context from
-- gnat2why, as GNATprove cannot do the conversion later contrary
-- to gigi. The frontend computes the information about which
-- expressions are static, which is used by gnat2why to call
-- Check_Non_Static_Context on exactly those real literals that are
-- not subexpressions of static expressions.
if Nkind (N) = N_Real_Literal
and then not Is_Machine_Number (N)
and then not Is_Generic_Type (Etype (N))
and then Etype (N) /= Universal_Real
then
-- Check that value is in bounds before converting to machine
-- number, so as not to lose case where value overflows in the
-- least significant bit or less. See B490001.
if Is_Out_Of_Range (N, Base_Type (T), Assume_Valid => True) then
Out_Of_Range (N);
return;
end if;
-- Note: we have to copy the node, to avoid problems with conformance
-- of very similar numbers (see ACVC tests B4A010C and B63103A).
Rewrite (N, New_Copy (N));
if not Is_Floating_Point_Type (T) then
Set_Realval
(N, Corresponding_Integer_Value (N) * Small_Value (T));
elsif not UR_Is_Zero (Realval (N)) then
-- Note: even though RM 4.9(38) specifies biased rounding, this
-- has been modified by AI-100 in order to prevent confusing
-- differences in rounding between static and non-static
-- expressions. AI-100 specifies that the effect of such rounding
-- is implementation dependent, and in GNAT we round to nearest
-- even to match the run-time behavior. Note that this applies
-- to floating point literals, not fixed points ones, even though
-- their compiler representation is also as a universal real.
Set_Realval
(N, Machine (Base_Type (T), Realval (N), Round_Even, N));
Set_Is_Machine_Number (N);
end if;
end if;
-- Check for out of range universal integer. This is a non-static
-- context, so the integer value must be in range of the runtime
-- representation of universal integers.
-- We do this only within an expression, because that is the only
-- case in which non-static universal integer values can occur, and
-- furthermore, Check_Non_Static_Context is currently (incorrectly???)
-- called in contexts like the expression of a number declaration where
-- we certainly want to allow out of range values.
if Etype (N) = Universal_Integer
and then Nkind (N) = N_Integer_Literal
and then Nkind (Parent (N)) in N_Subexpr
and then
(Intval (N) < Expr_Value (Type_Low_Bound (Universal_Integer))
or else
Intval (N) > Expr_Value (Type_High_Bound (Universal_Integer)))
then
Apply_Compile_Time_Constraint_Error
(N, "non-static universal integer value out of range<<",
CE_Range_Check_Failed);
-- Check out of range of base type
elsif Is_Out_Of_Range (N, Base_Type (T), Assume_Valid => True) then
Out_Of_Range (N);
-- Give warning if outside subtype (where one or both of the bounds of
-- the subtype is static). This warning is omitted if the expression
-- appears in a range that could be null (warnings are handled elsewhere
-- for this case).
elsif T /= Base_Type (T) and then Nkind (Parent (N)) /= N_Range then
if Is_In_Range (N, T, Assume_Valid => True) then
null;
elsif Is_Out_Of_Range (N, T, Assume_Valid => True) then
Apply_Compile_Time_Constraint_Error
(N, "value not in range of}<<", CE_Range_Check_Failed);
elsif Checks_On then
Enable_Range_Check (N);
else
Set_Do_Range_Check (N, False);
end if;
end if;
end Check_Non_Static_Context;
---------------------------------
-- Check_String_Literal_Length --
---------------------------------
procedure Check_String_Literal_Length (N : Node_Id; Ttype : Entity_Id) is
begin
if not Raises_Constraint_Error (N) and then Is_Constrained (Ttype) then
if UI_From_Int (String_Length (Strval (N))) /= String_Type_Len (Ttype)
then
Apply_Compile_Time_Constraint_Error
(N, "string length wrong for}??",
CE_Length_Check_Failed,
Ent => Ttype,
Typ => Ttype);
end if;
end if;
end Check_String_Literal_Length;
--------------------
-- Choice_Matches --
--------------------
function Choice_Matches
(Expr : Node_Id;
Choice : Node_Id) return Match_Result
is
Etyp : constant Entity_Id := Etype (Expr);
Val : Uint;
ValR : Ureal;
ValS : Node_Id;
begin
pragma Assert (Compile_Time_Known_Value (Expr));
pragma Assert (Is_Scalar_Type (Etyp) or else Is_String_Type (Etyp));
if not Is_OK_Static_Choice (Choice) then
Set_Raises_Constraint_Error (Choice);
return Non_Static;
-- When the choice denotes a subtype with a static predictate, check the
-- expression against the predicate values. Different procedures apply
-- to discrete and non-discrete types.
elsif (Nkind (Choice) = N_Subtype_Indication
or else (Is_Entity_Name (Choice)
and then Is_Type (Entity (Choice))))
and then Has_Predicates (Etype (Choice))
and then Has_Static_Predicate (Etype (Choice))
then
if Is_Discrete_Type (Etype (Choice)) then
return
Choices_Match
(Expr, Static_Discrete_Predicate (Etype (Choice)));
elsif Real_Or_String_Static_Predicate_Matches (Expr, Etype (Choice))
then
return Match;
else
return No_Match;
end if;
-- Discrete type case only
elsif Is_Discrete_Type (Etyp) then
Val := Expr_Value (Expr);
if Nkind (Choice) = N_Range then
if Val >= Expr_Value (Low_Bound (Choice))
and then
Val <= Expr_Value (High_Bound (Choice))
then
return Match;
else
return No_Match;
end if;
elsif Nkind (Choice) = N_Subtype_Indication
or else (Is_Entity_Name (Choice) and then Is_Type (Entity (Choice)))
then
if Val >= Expr_Value (Type_Low_Bound (Etype (Choice)))
and then
Val <= Expr_Value (Type_High_Bound (Etype (Choice)))
then
return Match;
else
return No_Match;
end if;
elsif Nkind (Choice) = N_Others_Choice then
return Match;
else
if Val = Expr_Value (Choice) then
return Match;
else
return No_Match;
end if;
end if;
-- Real type case
elsif Is_Real_Type (Etyp) then
ValR := Expr_Value_R (Expr);
if Nkind (Choice) = N_Range then
if ValR >= Expr_Value_R (Low_Bound (Choice))
and then
ValR <= Expr_Value_R (High_Bound (Choice))
then
return Match;
else
return No_Match;
end if;
elsif Nkind (Choice) = N_Subtype_Indication
or else (Is_Entity_Name (Choice) and then Is_Type (Entity (Choice)))
then
if ValR >= Expr_Value_R (Type_Low_Bound (Etype (Choice)))
and then
ValR <= Expr_Value_R (Type_High_Bound (Etype (Choice)))
then
return Match;
else
return No_Match;
end if;
else
if ValR = Expr_Value_R (Choice) then
return Match;
else
return No_Match;
end if;
end if;
-- String type cases
else
pragma Assert (Is_String_Type (Etyp));
ValS := Expr_Value_S (Expr);
if Nkind (Choice) = N_Subtype_Indication
or else (Is_Entity_Name (Choice) and then Is_Type (Entity (Choice)))
then
if not Is_Constrained (Etype (Choice)) then
return Match;
else
declare
Typlen : constant Uint :=
String_Type_Len (Etype (Choice));
Strlen : constant Uint :=
UI_From_Int (String_Length (Strval (ValS)));
begin
if Typlen = Strlen then
return Match;
else
return No_Match;
end if;
end;
end if;
else
if String_Equal (Strval (ValS), Strval (Expr_Value_S (Choice)))
then
return Match;
else
return No_Match;
end if;
end if;
end if;
end Choice_Matches;
-------------------
-- Choices_Match --
-------------------
function Choices_Match
(Expr : Node_Id;
Choices : List_Id) return Match_Result
is
Choice : Node_Id;
Result : Match_Result;
begin
Choice := First (Choices);
while Present (Choice) loop
Result := Choice_Matches (Expr, Choice);
if Result /= No_Match then
return Result;
end if;
Next (Choice);
end loop;
return No_Match;
end Choices_Match;
--------------------------
-- Compile_Time_Compare --
--------------------------
function Compile_Time_Compare
(L, R : Node_Id;
Assume_Valid : Boolean) return Compare_Result
is
Discard : aliased Uint;
begin
return Compile_Time_Compare (L, R, Discard'Access, Assume_Valid);
end Compile_Time_Compare;
function Compile_Time_Compare
(L, R : Node_Id;
Diff : access Uint;
Assume_Valid : Boolean;
Rec : Boolean := False) return Compare_Result
is
Ltyp : Entity_Id := Etype (L);
Rtyp : Entity_Id := Etype (R);
Discard : aliased Uint;
procedure Compare_Decompose
(N : Node_Id;
R : out Node_Id;
V : out Uint);
-- This procedure decomposes the node N into an expression node and a
-- signed offset, so that the value of N is equal to the value of R plus
-- the value V (which may be negative). If no such decomposition is
-- possible, then on return R is a copy of N, and V is set to zero.
function Compare_Fixup (N : Node_Id) return Node_Id;
-- This function deals with replacing 'Last and 'First references with
-- their corresponding type bounds, which we then can compare. The
-- argument is the original node, the result is the identity, unless we
-- have a 'Last/'First reference in which case the value returned is the
-- appropriate type bound.
function Is_Known_Valid_Operand (Opnd : Node_Id) return Boolean;
-- Even if the context does not assume that values are valid, some
-- simple cases can be recognized.
function Is_Same_Value (L, R : Node_Id) return Boolean;
-- Returns True iff L and R represent expressions that definitely have
-- identical (but not necessarily compile time known) values Indeed the
-- caller is expected to have already dealt with the cases of compile
-- time known values, so these are not tested here.
-----------------------
-- Compare_Decompose --
-----------------------
procedure Compare_Decompose
(N : Node_Id;
R : out Node_Id;
V : out Uint)
is
begin
if Nkind (N) = N_Op_Add
and then Nkind (Right_Opnd (N)) = N_Integer_Literal
then
R := Left_Opnd (N);
V := Intval (Right_Opnd (N));
return;
elsif Nkind (N) = N_Op_Subtract
and then Nkind (Right_Opnd (N)) = N_Integer_Literal
then
R := Left_Opnd (N);
V := UI_Negate (Intval (Right_Opnd (N)));
return;
elsif Nkind (N) = N_Attribute_Reference then
if Attribute_Name (N) = Name_Succ then
R := First (Expressions (N));
V := Uint_1;
return;
elsif Attribute_Name (N) = Name_Pred then
R := First (Expressions (N));
V := Uint_Minus_1;
return;
end if;
end if;
R := N;
V := Uint_0;
end Compare_Decompose;
-------------------
-- Compare_Fixup --
-------------------
function Compare_Fixup (N : Node_Id) return Node_Id is
Indx : Node_Id;
Xtyp : Entity_Id;
Subs : Nat;
begin
-- Fixup only required for First/Last attribute reference
if Nkind (N) = N_Attribute_Reference
and then Nam_In (Attribute_Name (N), Name_First, Name_Last)
then
Xtyp := Etype (Prefix (N));
-- If we have no type, then just abandon the attempt to do
-- a fixup, this is probably the result of some other error.
if No (Xtyp) then
return N;
end if;
-- Dereference an access type
if Is_Access_Type (Xtyp) then
Xtyp := Designated_Type (Xtyp);
end if;
-- If we don't have an array type at this stage, something is
-- peculiar, e.g. another error, and we abandon the attempt at
-- a fixup.
if not Is_Array_Type (Xtyp) then
return N;
end if;
-- Ignore unconstrained array, since bounds are not meaningful
if not Is_Constrained (Xtyp) then
return N;
end if;
if Ekind (Xtyp) = E_String_Literal_Subtype then
if Attribute_Name (N) = Name_First then
return String_Literal_Low_Bound (Xtyp);
else
return
Make_Integer_Literal (Sloc (N),
Intval => Intval (String_Literal_Low_Bound (Xtyp)) +
String_Literal_Length (Xtyp));
end if;
end if;
-- Find correct index type
Indx := First_Index (Xtyp);
if Present (Expressions (N)) then
Subs := UI_To_Int (Expr_Value (First (Expressions (N))));
for J in 2 .. Subs loop
Indx := Next_Index (Indx);
end loop;
end if;
Xtyp := Etype (Indx);
if Attribute_Name (N) = Name_First then
return Type_Low_Bound (Xtyp);
else
return Type_High_Bound (Xtyp);
end if;
end if;
return N;
end Compare_Fixup;
----------------------------
-- Is_Known_Valid_Operand --
----------------------------
function Is_Known_Valid_Operand (Opnd : Node_Id) return Boolean is
begin
return (Is_Entity_Name (Opnd)
and then
(Is_Known_Valid (Entity (Opnd))
or else Ekind (Entity (Opnd)) = E_In_Parameter
or else
(Ekind (Entity (Opnd)) in Object_Kind
and then Present (Current_Value (Entity (Opnd))))))
or else Is_OK_Static_Expression (Opnd);
end Is_Known_Valid_Operand;
-------------------
-- Is_Same_Value --
-------------------
function Is_Same_Value (L, R : Node_Id) return Boolean is
Lf : constant Node_Id := Compare_Fixup (L);
Rf : constant Node_Id := Compare_Fixup (R);
function Is_Same_Subscript (L, R : List_Id) return Boolean;
-- L, R are the Expressions values from two attribute nodes for First
-- or Last attributes. Either may be set to No_List if no expressions
-- are present (indicating subscript 1). The result is True if both
-- expressions represent the same subscript (note one case is where
-- one subscript is missing and the other is explicitly set to 1).
-----------------------
-- Is_Same_Subscript --
-----------------------
function Is_Same_Subscript (L, R : List_Id) return Boolean is
begin
if L = No_List then
if R = No_List then
return True;
else
return Expr_Value (First (R)) = Uint_1;
end if;
else
if R = No_List then
return Expr_Value (First (L)) = Uint_1;
else
return Expr_Value (First (L)) = Expr_Value (First (R));
end if;
end if;
end Is_Same_Subscript;
-- Start of processing for Is_Same_Value
begin
-- Values are the same if they refer to the same entity and the
-- entity is non-volatile. This does not however apply to Float
-- types, since we may have two NaN values and they should never
-- compare equal.
-- If the entity is a discriminant, the two expressions may be bounds
-- of components of objects of the same discriminated type. The
-- values of the discriminants are not static, and therefore the
-- result is unknown.
-- It would be better to comment individual branches of this test ???
if Nkind_In (Lf, N_Identifier, N_Expanded_Name)
and then Nkind_In (Rf, N_Identifier, N_Expanded_Name)
and then Entity (Lf) = Entity (Rf)
and then Ekind (Entity (Lf)) /= E_Discriminant
and then Present (Entity (Lf))
and then not Is_Floating_Point_Type (Etype (L))
and then not Is_Volatile_Reference (L)
and then not Is_Volatile_Reference (R)
then
return True;
-- Or if they are compile time known and identical
elsif Compile_Time_Known_Value (Lf)
and then
Compile_Time_Known_Value (Rf)
and then Expr_Value (Lf) = Expr_Value (Rf)
then
return True;
-- False if Nkind of the two nodes is different for remaining cases
elsif Nkind (Lf) /= Nkind (Rf) then
return False;
-- True if both 'First or 'Last values applying to the same entity
-- (first and last don't change even if value does). Note that we
-- need this even with the calls to Compare_Fixup, to handle the
-- case of unconstrained array attributes where Compare_Fixup
-- cannot find useful bounds.
elsif Nkind (Lf) = N_Attribute_Reference
and then Attribute_Name (Lf) = Attribute_Name (Rf)
and then Nam_In (Attribute_Name (Lf), Name_First, Name_Last)
and then Nkind_In (Prefix (Lf), N_Identifier, N_Expanded_Name)
and then Nkind_In (Prefix (Rf), N_Identifier, N_Expanded_Name)
and then Entity (Prefix (Lf)) = Entity (Prefix (Rf))
and then Is_Same_Subscript (Expressions (Lf), Expressions (Rf))
then
return True;
-- True if the same selected component from the same record
elsif Nkind (Lf) = N_Selected_Component
and then Selector_Name (Lf) = Selector_Name (Rf)
and then Is_Same_Value (Prefix (Lf), Prefix (Rf))
then
return True;
-- True if the same unary operator applied to the same operand
elsif Nkind (Lf) in N_Unary_Op
and then Is_Same_Value (Right_Opnd (Lf), Right_Opnd (Rf))
then
return True;
-- True if the same binary operator applied to the same operands
elsif Nkind (Lf) in N_Binary_Op
and then Is_Same_Value (Left_Opnd (Lf), Left_Opnd (Rf))
and then Is_Same_Value (Right_Opnd (Lf), Right_Opnd (Rf))
then
return True;
-- All other cases, we can't tell, so return False
else
return False;
end if;
end Is_Same_Value;
-- Start of processing for Compile_Time_Compare
begin
Diff.all := No_Uint;
-- In preanalysis mode, always return Unknown unless the expression
-- is static. It is too early to be thinking we know the result of a
-- comparison, save that judgment for the full analysis. This is
-- particularly important in the case of pre and postconditions, which
-- otherwise can be prematurely collapsed into having True or False
-- conditions when this is inappropriate.
if not (Full_Analysis
or else (Is_OK_Static_Expression (L)
and then
Is_OK_Static_Expression (R)))
then
return Unknown;
end if;
-- If either operand could raise constraint error, then we cannot
-- know the result at compile time (since CE may be raised).
if not (Cannot_Raise_Constraint_Error (L)
and then
Cannot_Raise_Constraint_Error (R))
then
return Unknown;
end if;
-- Identical operands are most certainly equal
if L = R then
return EQ;
end if;
-- If expressions have no types, then do not attempt to determine if
-- they are the same, since something funny is going on. One case in
-- which this happens is during generic template analysis, when bounds
-- are not fully analyzed.
if No (Ltyp) or else No (Rtyp) then
return Unknown;
end if;
-- These get reset to the base type for the case of entities where
-- Is_Known_Valid is not set. This takes care of handling possible
-- invalid representations using the value of the base type, in
-- accordance with RM 13.9.1(10).
Ltyp := Underlying_Type (Ltyp);
Rtyp := Underlying_Type (Rtyp);
-- Same rationale as above, but for Underlying_Type instead of Etype
if No (Ltyp) or else No (Rtyp) then
return Unknown;
end if;
-- We do not attempt comparisons for packed arrays represented as
-- modular types, where the semantics of comparison is quite different.
if Is_Packed_Array_Impl_Type (Ltyp)
and then Is_Modular_Integer_Type (Ltyp)
then
return Unknown;
-- For access types, the only time we know the result at compile time
-- (apart from identical operands, which we handled already) is if we
-- know one operand is null and the other is not, or both operands are
-- known null.
elsif Is_Access_Type (Ltyp) then
if Known_Null (L) then
if Known_Null (R) then
return EQ;
elsif Known_Non_Null (R) then
return NE;
else
return Unknown;
end if;
elsif Known_Non_Null (L) and then Known_Null (R) then
return NE;
else
return Unknown;
end if;
-- Case where comparison involves two compile time known values
elsif Compile_Time_Known_Value (L)
and then
Compile_Time_Known_Value (R)
then
-- For the floating-point case, we have to be a little careful, since
-- at compile time we are dealing with universal exact values, but at
-- runtime, these will be in non-exact target form. That's why the
-- returned results are LE and GE below instead of LT and GT.
if Is_Floating_Point_Type (Ltyp)
or else
Is_Floating_Point_Type (Rtyp)
then
declare
Lo : constant Ureal := Expr_Value_R (L);
Hi : constant Ureal := Expr_Value_R (R);
begin
if Lo < Hi then
return LE;
elsif Lo = Hi then
return EQ;
else
return GE;
end if;
end;
-- For string types, we have two string literals and we proceed to
-- compare them using the Ada style dictionary string comparison.
elsif not Is_Scalar_Type (Ltyp) then
declare
Lstring : constant String_Id := Strval (Expr_Value_S (L));
Rstring : constant String_Id := Strval (Expr_Value_S (R));
Llen : constant Nat := String_Length (Lstring);
Rlen : constant Nat := String_Length (Rstring);
begin
for J in 1 .. Nat'Min (Llen, Rlen) loop
declare
LC : constant Char_Code := Get_String_Char (Lstring, J);
RC : constant Char_Code := Get_String_Char (Rstring, J);
begin
if LC < RC then
return LT;
elsif LC > RC then
return GT;
end if;
end;
end loop;
if Llen < Rlen then
return LT;
elsif Llen > Rlen then
return GT;
else
return EQ;
end if;
end;
-- For remaining scalar cases we know exactly (note that this does
-- include the fixed-point case, where we know the run time integer
-- values now).
else
declare
Lo : constant Uint := Expr_Value (L);
Hi : constant Uint := Expr_Value (R);
begin
if Lo < Hi then
Diff.all := Hi - Lo;
return LT;
elsif Lo = Hi then
return EQ;
else
Diff.all := Lo - Hi;
return GT;
end if;
end;
end if;
-- Cases where at least one operand is not known at compile time
else
-- Remaining checks apply only for discrete types
if not Is_Discrete_Type (Ltyp)
or else
not Is_Discrete_Type (Rtyp)
then
return Unknown;
end if;
-- Defend against generic types, or actually any expressions that
-- contain a reference to a generic type from within a generic
-- template. We don't want to do any range analysis of such
-- expressions for two reasons. First, the bounds of a generic type
-- itself are junk and cannot be used for any kind of analysis.
-- Second, we may have a case where the range at run time is indeed
-- known, but we don't want to do compile time analysis in the
-- template based on that range since in an instance the value may be
-- static, and able to be elaborated without reference to the bounds
-- of types involved. As an example, consider:
-- (F'Pos (F'Last) + 1) > Integer'Last
-- The expression on the left side of > is Universal_Integer and thus
-- acquires the type Integer for evaluation at run time, and at run
-- time it is true that this condition is always False, but within
-- an instance F may be a type with a static range greater than the
-- range of Integer, and the expression statically evaluates to True.
if References_Generic_Formal_Type (L)
or else
References_Generic_Formal_Type (R)
then
return Unknown;
end if;
-- Replace types by base types for the case of values which are not
-- known to have valid representations. This takes care of properly
-- dealing with invalid representations.
if not Assume_Valid then
if not (Is_Entity_Name (L)
and then (Is_Known_Valid (Entity (L))
or else Assume_No_Invalid_Values))
then
Ltyp := Underlying_Type (Base_Type (Ltyp));
end if;
if not (Is_Entity_Name (R)
and then (Is_Known_Valid (Entity (R))
or else Assume_No_Invalid_Values))
then
Rtyp := Underlying_Type (Base_Type (Rtyp));
end if;
end if;
-- First attempt is to decompose the expressions to extract a
-- constant offset resulting from the use of any of the forms:
-- expr + literal
-- expr - literal
-- typ'Succ (expr)
-- typ'Pred (expr)
-- Then we see if the two expressions are the same value, and if so
-- the result is obtained by comparing the offsets.
-- Note: the reason we do this test first is that it returns only
-- decisive results (with diff set), where other tests, like the
-- range test, may not be as so decisive. Consider for example
-- J .. J + 1. This code can conclude LT with a difference of 1,
-- even if the range of J is not known.
declare
Lnode : Node_Id;
Loffs : Uint;
Rnode : Node_Id;
Roffs : Uint;
begin
Compare_Decompose (L, Lnode, Loffs);
Compare_Decompose (R, Rnode, Roffs);
if Is_Same_Value (Lnode, Rnode) then
if Loffs = Roffs then
return EQ;
end if;
-- When the offsets are not equal, we can go farther only if
-- the types are not modular (e.g. X < X + 1 is False if X is
-- the largest number).
if not Is_Modular_Integer_Type (Ltyp)
and then not Is_Modular_Integer_Type (Rtyp)
then
if Loffs < Roffs then
Diff.all := Roffs - Loffs;
return LT;
else
Diff.all := Loffs - Roffs;
return GT;
end if;
end if;
end if;
end;
-- Next, try range analysis and see if operand ranges are disjoint
declare
LOK, ROK : Boolean;
LLo, LHi : Uint;
RLo, RHi : Uint;
Single : Boolean;
-- True if each range is a single point
begin
Determine_Range (L, LOK, LLo, LHi, Assume_Valid);
Determine_Range (R, ROK, RLo, RHi, Assume_Valid);
if LOK and ROK then
Single := (LLo = LHi) and then (RLo = RHi);
if LHi < RLo then
if Single and Assume_Valid then
Diff.all := RLo - LLo;
end if;
return LT;
elsif RHi < LLo then
if Single and Assume_Valid then
Diff.all := LLo - RLo;
end if;
return GT;
elsif Single and then LLo = RLo then
-- If the range includes a single literal and we can assume
-- validity then the result is known even if an operand is
-- not static.
if Assume_Valid then
return EQ;
else
return Unknown;
end if;
elsif LHi = RLo then
return LE;
elsif RHi = LLo then
return GE;
elsif not Is_Known_Valid_Operand (L)
and then not Assume_Valid
then
if Is_Same_Value (L, R) then
return EQ;
else
return Unknown;
end if;
end if;
-- If the range of either operand cannot be determined, nothing
-- further can be inferred.
else
return Unknown;
end if;
end;
-- Here is where we check for comparisons against maximum bounds of
-- types, where we know that no value can be outside the bounds of
-- the subtype. Note that this routine is allowed to assume that all
-- expressions are within their subtype bounds. Callers wishing to
-- deal with possibly invalid values must in any case take special
-- steps (e.g. conversions to larger types) to avoid this kind of
-- optimization, which is always considered to be valid. We do not
-- attempt this optimization with generic types, since the type
-- bounds may not be meaningful in this case.
-- We are in danger of an infinite recursion here. It does not seem
-- useful to go more than one level deep, so the parameter Rec is
-- used to protect ourselves against this infinite recursion.
if not Rec then
-- See if we can get a decisive check against one operand and a
-- bound of the other operand (four possible tests here). Note
-- that we avoid testing junk bounds of a generic type.
if not Is_Generic_Type (Rtyp) then
case Compile_Time_Compare (L, Type_Low_Bound (Rtyp),
Discard'Access,
Assume_Valid, Rec => True)
is
when LT => return LT;
when LE => return LE;
when EQ => return LE;
when others => null;
end case;
case Compile_Time_Compare (L, Type_High_Bound (Rtyp),
Discard'Access,
Assume_Valid, Rec => True)
is
when GT => return GT;
when GE => return GE;
when EQ => return GE;
when others => null;
end case;
end if;
if not Is_Generic_Type (Ltyp) then
case Compile_Time_Compare (Type_Low_Bound (Ltyp), R,
Discard'Access,
Assume_Valid, Rec => True)
is
when GT => return GT;
when GE => return GE;
when EQ => return GE;
when others => null;
end case;
case Compile_Time_Compare (Type_High_Bound (Ltyp), R,
Discard'Access,
Assume_Valid, Rec => True)
is
when LT => return LT;
when LE => return LE;
when EQ => return LE;
when others => null;
end case;
end if;
end if;
-- Next attempt is to see if we have an entity compared with a
-- compile time known value, where there is a current value
-- conditional for the entity which can tell us the result.
declare
Var : Node_Id;
-- Entity variable (left operand)
Val : Uint;
-- Value (right operand)
Inv : Boolean;
-- If False, we have reversed the operands
Op : Node_Kind;
-- Comparison operator kind from Get_Current_Value_Condition call
Opn : Node_Id;
-- Value from Get_Current_Value_Condition call
Opv : Uint;
-- Value of Opn
Result : Compare_Result;
-- Known result before inversion
begin
if Is_Entity_Name (L)
and then Compile_Time_Known_Value (R)
then
Var := L;
Val := Expr_Value (R);
Inv := False;
elsif Is_Entity_Name (R)
and then Compile_Time_Known_Value (L)
then
Var := R;
Val := Expr_Value (L);
Inv := True;
-- That was the last chance at finding a compile time result
else
return Unknown;
end if;
Get_Current_Value_Condition (Var, Op, Opn);
-- That was the last chance, so if we got nothing return
if No (Opn) then
return Unknown;
end if;
Opv := Expr_Value (Opn);
-- We got a comparison, so we might have something interesting
-- Convert LE to LT and GE to GT, just so we have fewer cases
if Op = N_Op_Le then
Op := N_Op_Lt;
Opv := Opv + 1;
elsif Op = N_Op_Ge then
Op := N_Op_Gt;
Opv := Opv - 1;
end if;
-- Deal with equality case
if Op = N_Op_Eq then
if Val = Opv then
Result := EQ;
elsif Opv < Val then
Result := LT;
else
Result := GT;
end if;
-- Deal with inequality case
elsif Op = N_Op_Ne then
if Val = Opv then
Result := NE;
else
return Unknown;
end if;
-- Deal with greater than case
elsif Op = N_Op_Gt then
if Opv >= Val then
Result := GT;
elsif Opv = Val - 1 then
Result := GE;
else
return Unknown;
end if;
-- Deal with less than case
else pragma Assert (Op = N_Op_Lt);
if Opv <= Val then
Result := LT;
elsif Opv = Val + 1 then
Result := LE;
else
return Unknown;
end if;
end if;
-- Deal with inverting result
if Inv then
case Result is
when GT => return LT;
when GE => return LE;
when LT => return GT;
when LE => return GE;
when others => return Result;
end case;
end if;
return Result;
end;
end if;
end Compile_Time_Compare;
-------------------------------
-- Compile_Time_Known_Bounds --
-------------------------------
function Compile_Time_Known_Bounds (T : Entity_Id) return Boolean is
Indx : Node_Id;
Typ : Entity_Id;
begin
if T = Any_Composite or else not Is_Array_Type (T) then
return False;
end if;
Indx := First_Index (T);
while Present (Indx) loop
Typ := Underlying_Type (Etype (Indx));
-- Never look at junk bounds of a generic type
if Is_Generic_Type (Typ) then
return False;
end if;
-- Otherwise check bounds for compile time known
if not Compile_Time_Known_Value (Type_Low_Bound (Typ)) then
return False;
elsif not Compile_Time_Known_Value (Type_High_Bound (Typ)) then
return False;
else
Next_Index (Indx);
end if;
end loop;
return True;
end Compile_Time_Known_Bounds;
------------------------------
-- Compile_Time_Known_Value --
------------------------------
function Compile_Time_Known_Value (Op : Node_Id) return Boolean is
K : constant Node_Kind := Nkind (Op);
CV_Ent : CV_Entry renames CV_Cache (Nat (Op) mod CV_Cache_Size);
begin
-- Never known at compile time if bad type or raises constraint error
-- or empty (latter case occurs only as a result of a previous error).
if No (Op) then
Check_Error_Detected;
return False;
elsif Op = Error
or else Etype (Op) = Any_Type
or else Raises_Constraint_Error (Op)
then
return False;
end if;
-- If we have an entity name, then see if it is the name of a constant
-- and if so, test the corresponding constant value, or the name of
-- an enumeration literal, which is always a constant.
if Present (Etype (Op)) and then Is_Entity_Name (Op) then
declare
E : constant Entity_Id := Entity (Op);
V : Node_Id;
begin
-- Never known at compile time if it is a packed array value.
-- We might want to try to evaluate these at compile time one
-- day, but we do not make that attempt now.
if Is_Packed_Array_Impl_Type (Etype (Op)) then
return False;
end if;
if Ekind (E) = E_Enumeration_Literal then
return True;
elsif Ekind (E) = E_Constant then
V := Constant_Value (E);
return Present (V) and then Compile_Time_Known_Value (V);
end if;
end;
-- We have a value, see if it is compile time known
else
-- Integer literals are worth storing in the cache
if K = N_Integer_Literal then
CV_Ent.N := Op;
CV_Ent.V := Intval (Op);
return True;
-- Other literals and NULL are known at compile time
elsif
Nkind_In (K, N_Character_Literal,
N_Real_Literal,
N_String_Literal,
N_Null)
then
return True;
end if;
end if;
-- If we fall through, not known at compile time
return False;
-- If we get an exception while trying to do this test, then some error
-- has occurred, and we simply say that the value is not known after all
exception
when others =>
return False;
end Compile_Time_Known_Value;
--------------------------------------
-- Compile_Time_Known_Value_Or_Aggr --
--------------------------------------
function Compile_Time_Known_Value_Or_Aggr (Op : Node_Id) return Boolean is
begin
-- If we have an entity name, then see if it is the name of a constant
-- and if so, test the corresponding constant value, or the name of
-- an enumeration literal, which is always a constant.
if Is_Entity_Name (Op) then
declare
E : constant Entity_Id := Entity (Op);
V : Node_Id;
begin
if Ekind (E) = E_Enumeration_Literal then
return True;
elsif Ekind (E) /= E_Constant then
return False;
else
V := Constant_Value (E);
return Present (V)
and then Compile_Time_Known_Value_Or_Aggr (V);
end if;
end;
-- We have a value, see if it is compile time known
else
if Compile_Time_Known_Value (Op) then
return True;
elsif Nkind (Op) = N_Aggregate then
if Present (Expressions (Op)) then
declare
Expr : Node_Id;
begin
Expr := First (Expressions (Op));
while Present (Expr) loop
if not Compile_Time_Known_Value_Or_Aggr (Expr) then
return False;
else
Next (Expr);
end if;
end loop;
end;
end if;
if Present (Component_Associations (Op)) then
declare
Cass : Node_Id;
begin
Cass := First (Component_Associations (Op));
while Present (Cass) loop
if not
Compile_Time_Known_Value_Or_Aggr (Expression (Cass))
then
return False;
end if;
Next (Cass);
end loop;
end;
end if;
return True;
-- All other types of values are not known at compile time
else
return False;
end if;
end if;
end Compile_Time_Known_Value_Or_Aggr;
---------------------------------------
-- CRT_Safe_Compile_Time_Known_Value --
---------------------------------------
function CRT_Safe_Compile_Time_Known_Value (Op : Node_Id) return Boolean is
begin
if (Configurable_Run_Time_Mode or No_Run_Time_Mode)
and then not Is_OK_Static_Expression (Op)
then
return False;
else
return Compile_Time_Known_Value (Op);
end if;
end CRT_Safe_Compile_Time_Known_Value;
-----------------
-- Eval_Actual --
-----------------
-- This is only called for actuals of functions that are not predefined
-- operators (which have already been rewritten as operators at this
-- stage), so the call can never be folded, and all that needs doing for
-- the actual is to do the check for a non-static context.
procedure Eval_Actual (N : Node_Id) is
begin
Check_Non_Static_Context (N);
end Eval_Actual;
--------------------
-- Eval_Allocator --
--------------------
-- Allocators are never static, so all we have to do is to do the
-- check for a non-static context if an expression is present.
procedure Eval_Allocator (N : Node_Id) is
Expr : constant Node_Id := Expression (N);
begin
if Nkind (Expr) = N_Qualified_Expression then
Check_Non_Static_Context (Expression (Expr));
end if;
end Eval_Allocator;
------------------------
-- Eval_Arithmetic_Op --
------------------------
-- Arithmetic operations are static functions, so the result is static
-- if both operands are static (RM 4.9(7), 4.9(20)).
procedure Eval_Arithmetic_Op (N : Node_Id) is
Left : constant Node_Id := Left_Opnd (N);
Right : constant Node_Id := Right_Opnd (N);
Ltype : constant Entity_Id := Etype (Left);
Rtype : constant Entity_Id := Etype (Right);
Otype : Entity_Id := Empty;
Stat : Boolean;
Fold : Boolean;
begin
-- If not foldable we are done
Test_Expression_Is_Foldable (N, Left, Right, Stat, Fold);
if not Fold then
return;
end if;
-- Otherwise attempt to fold
if Is_Universal_Numeric_Type (Etype (Left))
and then
Is_Universal_Numeric_Type (Etype (Right))
then
Otype := Find_Universal_Operator_Type (N);
end if;
-- Fold for cases where both operands are of integer type
if Is_Integer_Type (Ltype) and then Is_Integer_Type (Rtype) then
declare
Left_Int : constant Uint := Expr_Value (Left);
Right_Int : constant Uint := Expr_Value (Right);
Result : Uint;
begin
case Nkind (N) is
when N_Op_Add =>
Result := Left_Int + Right_Int;
when N_Op_Subtract =>
Result := Left_Int - Right_Int;
when N_Op_Multiply =>
if OK_Bits
(N, UI_From_Int
(Num_Bits (Left_Int) + Num_Bits (Right_Int)))
then
Result := Left_Int * Right_Int;
else
Result := Left_Int;
end if;
when N_Op_Divide =>
-- The exception Constraint_Error is raised by integer
-- division, rem and mod if the right operand is zero.
if Right_Int = 0 then
-- When SPARK_Mode is On, force a warning instead of
-- an error in that case, as this likely corresponds
-- to deactivated code.
Apply_Compile_Time_Constraint_Error
(N, "division by zero", CE_Divide_By_Zero,
Warn => not Stat or SPARK_Mode = On);
Set_Raises_Constraint_Error (N);
return;
-- Otherwise we can do the division
else
Result := Left_Int / Right_Int;
end if;
when N_Op_Mod =>
-- The exception Constraint_Error is raised by integer
-- division, rem and mod if the right operand is zero.
if Right_Int = 0 then
-- When SPARK_Mode is On, force a warning instead of
-- an error in that case, as this likely corresponds
-- to deactivated code.
Apply_Compile_Time_Constraint_Error
(N, "mod with zero divisor", CE_Divide_By_Zero,
Warn => not Stat or SPARK_Mode = On);
return;
else
Result := Left_Int mod Right_Int;
end if;
when N_Op_Rem =>
-- The exception Constraint_Error is raised by integer
-- division, rem and mod if the right operand is zero.
if Right_Int = 0 then
-- When SPARK_Mode is On, force a warning instead of
-- an error in that case, as this likely corresponds
-- to deactivated code.
Apply_Compile_Time_Constraint_Error
(N, "rem with zero divisor", CE_Divide_By_Zero,
Warn => not Stat or SPARK_Mode = On);
return;
else
Result := Left_Int rem Right_Int;
end if;
when others =>
raise Program_Error;
end case;
-- Adjust the result by the modulus if the type is a modular type
if Is_Modular_Integer_Type (Ltype) then
Result := Result mod Modulus (Ltype);
-- For a signed integer type, check non-static overflow
elsif (not Stat) and then Is_Signed_Integer_Type (Ltype) then
declare
BT : constant Entity_Id := Base_Type (Ltype);
Lo : constant Uint := Expr_Value (Type_Low_Bound (BT));
Hi : constant Uint := Expr_Value (Type_High_Bound (BT));
begin
if Result < Lo or else Result > Hi then
Apply_Compile_Time_Constraint_Error
(N, "value not in range of }??",
CE_Overflow_Check_Failed,
Ent => BT);
return;
end if;
end;
end if;
-- If we get here we can fold the result
Fold_Uint (N, Result, Stat);
end;
-- Cases where at least one operand is a real. We handle the cases of
-- both reals, or mixed/real integer cases (the latter happen only for
-- divide and multiply, and the result is always real).
elsif Is_Real_Type (Ltype) or else Is_Real_Type (Rtype) then
declare
Left_Real : Ureal;
Right_Real : Ureal;
Result : Ureal;
begin
if Is_Real_Type (Ltype) then
Left_Real := Expr_Value_R (Left);
else
Left_Real := UR_From_Uint (Expr_Value (Left));
end if;
if Is_Real_Type (Rtype) then
Right_Real := Expr_Value_R (Right);
else
Right_Real := UR_From_Uint (Expr_Value (Right));
end if;
if Nkind (N) = N_Op_Add then
Result := Left_Real + Right_Real;
elsif Nkind (N) = N_Op_Subtract then
Result := Left_Real - Right_Real;
elsif Nkind (N) = N_Op_Multiply then
Result := Left_Real * Right_Real;
else pragma Assert (Nkind (N) = N_Op_Divide);
if UR_Is_Zero (Right_Real) then
Apply_Compile_Time_Constraint_Error
(N, "division by zero", CE_Divide_By_Zero);
return;
end if;
Result := Left_Real / Right_Real;
end if;
Fold_Ureal (N, Result, Stat);
end;
end if;
-- If the operator was resolved to a specific type, make sure that type
-- is frozen even if the expression is folded into a literal (which has
-- a universal type).
if Present (Otype) then
Freeze_Before (N, Otype);
end if;
end Eval_Arithmetic_Op;
----------------------------
-- Eval_Character_Literal --
----------------------------
-- Nothing to be done
procedure Eval_Character_Literal (N : Node_Id) is
pragma Warnings (Off, N);
begin
null;
end Eval_Character_Literal;
---------------
-- Eval_Call --
---------------
-- Static function calls are either calls to predefined operators
-- with static arguments, or calls to functions that rename a literal.
-- Only the latter case is handled here, predefined operators are
-- constant-folded elsewhere.
-- If the function is itself inherited (see 7423-001) the literal of
-- the parent type must be explicitly converted to the return type
-- of the function.
procedure Eval_Call (N : Node_Id) is
Loc : constant Source_Ptr := Sloc (N);
Typ : constant Entity_Id := Etype (N);
Lit : Entity_Id;
begin
if Nkind (N) = N_Function_Call
and then No (Parameter_Associations (N))
and then Is_Entity_Name (Name (N))
and then Present (Alias (Entity (Name (N))))
and then Is_Enumeration_Type (Base_Type (Typ))
then
Lit := Ultimate_Alias (Entity (Name (N)));
if Ekind (Lit) = E_Enumeration_Literal then
if Base_Type (Etype (Lit)) /= Base_Type (Typ) then
Rewrite
(N, Convert_To (Typ, New_Occurrence_Of (Lit, Loc)));
else
Rewrite (N, New_Occurrence_Of (Lit, Loc));
end if;
Resolve (N, Typ);
end if;
end if;
end Eval_Call;
--------------------------
-- Eval_Case_Expression --
--------------------------
-- A conditional expression is static if all its conditions and dependent
-- expressions are static. Note that we do not care if the dependent
-- expressions raise CE, except for the one that will be selected.
procedure Eval_Case_Expression (N : Node_Id) is
Alt : Node_Id;
Choice : Node_Id;
begin
Set_Is_Static_Expression (N, False);
if not Is_Static_Expression (Expression (N)) then
Check_Non_Static_Context (Expression (N));
return;
end if;
-- First loop, make sure all the alternatives are static expressions
-- none of which raise Constraint_Error. We make the constraint error
-- check because part of the legality condition for a correct static
-- case expression is that the cases are covered, like any other case
-- expression. And we can't do that if any of the conditions raise an
-- exception, so we don't even try to evaluate if that is the case.
Alt := First (Alternatives (N));
while Present (Alt) loop
-- The expression must be static, but we don't care at this stage
-- if it raises Constraint_Error (the alternative might not match,
-- in which case the expression is statically unevaluated anyway).
if not Is_Static_Expression (Expression (Alt)) then
Check_Non_Static_Context (Expression (Alt));
return;
end if;
-- The choices of a case always have to be static, and cannot raise
-- an exception. If this condition is not met, then the expression
-- is plain illegal, so just abandon evaluation attempts. No need
-- to check non-static context when we have something illegal anyway.
if not Is_OK_Static_Choice_List (Discrete_Choices (Alt)) then
return;
end if;
Next (Alt);
end loop;
-- OK, if the above loop gets through it means that all choices are OK
-- static (don't raise exceptions), so the whole case is static, and we
-- can find the matching alternative.
Set_Is_Static_Expression (N);
-- Now to deal with propagating a possible constraint error
-- If the selecting expression raises CE, propagate and we are done
if Raises_Constraint_Error (Expression (N)) then
Set_Raises_Constraint_Error (N);
-- Otherwise we need to check the alternatives to find the matching
-- one. CE's in other than the matching one are not relevant. But we
-- do need to check the matching one. Unlike the first loop, we do not
-- have to go all the way through, when we find the matching one, quit.
else
Alt := First (Alternatives (N));
Search : loop
-- We must find a match among the alternatives. If not, this must
-- be due to other errors, so just ignore, leaving as non-static.
if No (Alt) then
Set_Is_Static_Expression (N, False);
return;
end if;
-- Otherwise loop through choices of this alternative
Choice := First (Discrete_Choices (Alt));
while Present (Choice) loop
-- If we find a matching choice, then the Expression of this
-- alternative replaces N (Raises_Constraint_Error flag is
-- included, so we don't have to special case that).
if Choice_Matches (Expression (N), Choice) = Match then
Rewrite (N, Relocate_Node (Expression (Alt)));
return;
end if;
Next (Choice);
end loop;
Next (Alt);
end loop Search;
end if;
end Eval_Case_Expression;
------------------------
-- Eval_Concatenation --
------------------------
-- Concatenation is a static function, so the result is static if both
-- operands are static (RM 4.9(7), 4.9(21)).
procedure Eval_Concatenation (N : Node_Id) is
Left : constant Node_Id := Left_Opnd (N);
Right : constant Node_Id := Right_Opnd (N);
C_Typ : constant Entity_Id := Root_Type (Component_Type (Etype (N)));
Stat : Boolean;
Fold : Boolean;
begin
-- Concatenation is never static in Ada 83, so if Ada 83 check operand
-- non-static context.
if Ada_Version = Ada_83
and then Comes_From_Source (N)
then
Check_Non_Static_Context (Left);
Check_Non_Static_Context (Right);
return;
end if;
-- If not foldable we are done. In principle concatenation that yields
-- any string type is static (i.e. an array type of character types).
-- However, character types can include enumeration literals, and
-- concatenation in that case cannot be described by a literal, so we
-- only consider the operation static if the result is an array of
-- (a descendant of) a predefined character type.
Test_Expression_Is_Foldable (N, Left, Right, Stat, Fold);
if not (Is_Standard_Character_Type (C_Typ) and then Fold) then
Set_Is_Static_Expression (N, False);
return;
end if;
-- Compile time string concatenation
-- ??? Note that operands that are aggregates can be marked as static,
-- so we should attempt at a later stage to fold concatenations with
-- such aggregates.
declare
Left_Str : constant Node_Id := Get_String_Val (Left);
Left_Len : Nat;
Right_Str : constant Node_Id := Get_String_Val (Right);
Folded_Val : String_Id;
begin
-- Establish new string literal, and store left operand. We make
-- sure to use the special Start_String that takes an operand if
-- the left operand is a string literal. Since this is optimized
-- in the case where that is the most recently created string
-- literal, we ensure efficient time/space behavior for the
-- case of a concatenation of a series of string literals.
if Nkind (Left_Str) = N_String_Literal then
Left_Len := String_Length (Strval (Left_Str));
-- If the left operand is the empty string, and the right operand
-- is a string literal (the case of "" & "..."), the result is the
-- value of the right operand. This optimization is important when
-- Is_Folded_In_Parser, to avoid copying an enormous right
-- operand.
if Left_Len = 0 and then Nkind (Right_Str) = N_String_Literal then
Folded_Val := Strval (Right_Str);
else
Start_String (Strval (Left_Str));
end if;
else
Start_String;
Store_String_Char (UI_To_CC (Char_Literal_Value (Left_Str)));
Left_Len := 1;
end if;
-- Now append the characters of the right operand, unless we
-- optimized the "" & "..." case above.
if Nkind (Right_Str) = N_String_Literal then
if Left_Len /= 0 then
Store_String_Chars (Strval (Right_Str));
Folded_Val := End_String;
end if;
else
Store_String_Char (UI_To_CC (Char_Literal_Value (Right_Str)));
Folded_Val := End_String;
end if;
Set_Is_Static_Expression (N, Stat);
-- If left operand is the empty string, the result is the
-- right operand, including its bounds if anomalous.
if Left_Len = 0
and then Is_Array_Type (Etype (Right))
and then Etype (Right) /= Any_String
then
Set_Etype (N, Etype (Right));
end if;
Fold_Str (N, Folded_Val, Static => Stat);
end;
end Eval_Concatenation;
----------------------
-- Eval_Entity_Name --
----------------------
-- This procedure is used for identifiers and expanded names other than
-- named numbers (see Eval_Named_Integer, Eval_Named_Real. These are
-- static if they denote a static constant (RM 4.9(6)) or if the name
-- denotes an enumeration literal (RM 4.9(22)).
procedure Eval_Entity_Name (N : Node_Id) is
Def_Id : constant Entity_Id := Entity (N);
Val : Node_Id;
begin
-- Enumeration literals are always considered to be constants
-- and cannot raise constraint error (RM 4.9(22)).
if Ekind (Def_Id) = E_Enumeration_Literal then
Set_Is_Static_Expression (N);
return;
-- A name is static if it denotes a static constant (RM 4.9(5)), and
-- we also copy Raise_Constraint_Error. Notice that even if non-static,
-- it does not violate 10.2.1(8) here, since this is not a variable.
elsif Ekind (Def_Id) = E_Constant then
-- Deferred constants must always be treated as nonstatic outside the
-- scope of their full view.
if Present (Full_View (Def_Id))
and then not In_Open_Scopes (Scope (Def_Id))
then
Val := Empty;
else
Val := Constant_Value (Def_Id);
end if;
if Present (Val) then
Set_Is_Static_Expression
(N, Is_Static_Expression (Val)
and then Is_Static_Subtype (Etype (Def_Id)));
Set_Raises_Constraint_Error (N, Raises_Constraint_Error (Val));
if not Is_Static_Expression (N)
and then not Is_Generic_Type (Etype (N))
then
Validate_Static_Object_Name (N);
end if;
-- Mark constant condition in SCOs
if Generate_SCO
and then Comes_From_Source (N)
and then Is_Boolean_Type (Etype (Def_Id))
and then Compile_Time_Known_Value (N)
then
Set_SCO_Condition (N, Expr_Value_E (N) = Standard_True);
end if;
return;
end if;
end if;
-- Fall through if the name is not static
Validate_Static_Object_Name (N);
end Eval_Entity_Name;
------------------------
-- Eval_If_Expression --
------------------------
-- We can fold to a static expression if the condition and both dependent
-- expressions are static. Otherwise, the only required processing is to do
-- the check for non-static context for the then and else expressions.
procedure Eval_If_Expression (N : Node_Id) is
Condition : constant Node_Id := First (Expressions (N));
Then_Expr : constant Node_Id := Next (Condition);
Else_Expr : constant Node_Id := Next (Then_Expr);
Result : Node_Id;
Non_Result : Node_Id;
Rstat : constant Boolean :=
Is_Static_Expression (Condition)
and then
Is_Static_Expression (Then_Expr)
and then
Is_Static_Expression (Else_Expr);
-- True if result is static
begin
-- If result not static, nothing to do, otherwise set static result
if not Rstat then
return;
else
Set_Is_Static_Expression (N);
end if;
-- If any operand is Any_Type, just propagate to result and do not try
-- to fold, this prevents cascaded errors.
if Etype (Condition) = Any_Type or else
Etype (Then_Expr) = Any_Type or else
Etype (Else_Expr) = Any_Type
then
Set_Etype (N, Any_Type);
Set_Is_Static_Expression (N, False);
return;
end if;
-- If condition raises constraint error then we have already signaled
-- an error, and we just propagate to the result and do not fold.
if Raises_Constraint_Error (Condition) then
Set_Raises_Constraint_Error (N);
return;
end if;
-- Static case where we can fold. Note that we don't try to fold cases
-- where the condition is known at compile time, but the result is
-- non-static. This avoids possible cases of infinite recursion where
-- the expander puts in a redundant test and we remove it. Instead we
-- deal with these cases in the expander.
-- Select result operand
if Is_True (Expr_Value (Condition)) then
Result := Then_Expr;
Non_Result := Else_Expr;
else
Result := Else_Expr;
Non_Result := Then_Expr;
end if;
-- Note that it does not matter if the non-result operand raises a
-- Constraint_Error, but if the result raises constraint error then we
-- replace the node with a raise constraint error. This will properly
-- propagate Raises_Constraint_Error since this flag is set in Result.
if Raises_Constraint_Error (Result) then
Rewrite_In_Raise_CE (N, Result);
Check_Non_Static_Context (Non_Result);
-- Otherwise the result operand replaces the original node
else
Rewrite (N, Relocate_Node (Result));
Set_Is_Static_Expression (N);
end if;
end Eval_If_Expression;
----------------------------
-- Eval_Indexed_Component --
----------------------------
-- Indexed components are never static, so we need to perform the check
-- for non-static context on the index values. Then, we check if the
-- value can be obtained at compile time, even though it is non-static.
procedure Eval_Indexed_Component (N : Node_Id) is
Expr : Node_Id;
begin
-- Check for non-static context on index values
Expr := First (Expressions (N));
while Present (Expr) loop
Check_Non_Static_Context (Expr);
Next (Expr);
end loop;
-- If the indexed component appears in an object renaming declaration
-- then we do not want to try to evaluate it, since in this case we
-- need the identity of the array element.
if Nkind (Parent (N)) = N_Object_Renaming_Declaration then
return;
-- Similarly if the indexed component appears as the prefix of an
-- attribute we don't want to evaluate it, because at least for
-- some cases of attributes we need the identify (e.g. Access, Size)
elsif Nkind (Parent (N)) = N_Attribute_Reference then
return;
end if;
-- Note: there are other cases, such as the left side of an assignment,
-- or an OUT parameter for a call, where the replacement results in the
-- illegal use of a constant, But these cases are illegal in the first
-- place, so the replacement, though silly, is harmless.
-- Now see if this is a constant array reference
if List_Length (Expressions (N)) = 1
and then Is_Entity_Name (Prefix (N))
and then Ekind (Entity (Prefix (N))) = E_Constant
and then Present (Constant_Value (Entity (Prefix (N))))
then
declare
Loc : constant Source_Ptr := Sloc (N);
Arr : constant Node_Id := Constant_Value (Entity (Prefix (N)));
Sub : constant Node_Id := First (Expressions (N));
Atyp : Entity_Id;
-- Type of array
Lin : Nat;
-- Linear one's origin subscript value for array reference
Lbd : Node_Id;
-- Lower bound of the first array index
Elm : Node_Id;
-- Value from constant array
begin
Atyp := Etype (Arr);
if Is_Access_Type (Atyp) then
Atyp := Designated_Type (Atyp);
end if;
-- If we have an array type (we should have but perhaps there are
-- error cases where this is not the case), then see if we can do
-- a constant evaluation of the array reference.
if Is_Array_Type (Atyp) and then Atyp /= Any_Composite then
if Ekind (Atyp) = E_String_Literal_Subtype then
Lbd := String_Literal_Low_Bound (Atyp);
else
Lbd := Type_Low_Bound (Etype (First_Index (Atyp)));
end if;
if Compile_Time_Known_Value (Sub)
and then Nkind (Arr) = N_Aggregate
and then Compile_Time_Known_Value (Lbd)
and then Is_Discrete_Type (Component_Type (Atyp))
then
Lin := UI_To_Int (Expr_Value (Sub) - Expr_Value (Lbd)) + 1;
if List_Length (Expressions (Arr)) >= Lin then
Elm := Pick (Expressions (Arr), Lin);
-- If the resulting expression is compile time known,
-- then we can rewrite the indexed component with this
-- value, being sure to mark the result as non-static.
-- We also reset the Sloc, in case this generates an
-- error later on (e.g. 136'Access).
if Compile_Time_Known_Value (Elm) then
Rewrite (N, Duplicate_Subexpr_No_Checks (Elm));
Set_Is_Static_Expression (N, False);
Set_Sloc (N, Loc);
end if;
end if;
-- We can also constant-fold if the prefix is a string literal.
-- This will be useful in an instantiation or an inlining.
elsif Compile_Time_Known_Value (Sub)
and then Nkind (Arr) = N_String_Literal
and then Compile_Time_Known_Value (Lbd)
and then Expr_Value (Lbd) = 1
and then Expr_Value (Sub) <=
String_Literal_Length (Etype (Arr))
then
declare
C : constant Char_Code :=
Get_String_Char (Strval (Arr),
UI_To_Int (Expr_Value (Sub)));
begin
Set_Character_Literal_Name (C);
Elm :=
Make_Character_Literal (Loc,
Chars => Name_Find,
Char_Literal_Value => UI_From_CC (C));
Set_Etype (Elm, Component_Type (Atyp));
Rewrite (N, Duplicate_Subexpr_No_Checks (Elm));
Set_Is_Static_Expression (N, False);
end;
end if;
end if;
end;
end if;
end Eval_Indexed_Component;
--------------------------
-- Eval_Integer_Literal --
--------------------------
-- Numeric literals are static (RM 4.9(1)), and have already been marked
-- as static by the analyzer. The reason we did it that early is to allow
-- the possibility of turning off the Is_Static_Expression flag after
-- analysis, but before resolution, when integer literals are generated in
-- the expander that do not correspond to static expressions.
procedure Eval_Integer_Literal (N : Node_Id) is
T : constant Entity_Id := Etype (N);
function In_Any_Integer_Context return Boolean;
-- If the literal is resolved with a specific type in a context where
-- the expected type is Any_Integer, there are no range checks on the
-- literal. By the time the literal is evaluated, it carries the type
-- imposed by the enclosing expression, and we must recover the context
-- to determine that Any_Integer is meant.
----------------------------
-- In_Any_Integer_Context --
----------------------------
function In_Any_Integer_Context return Boolean is
Par : constant Node_Id := Parent (N);
K : constant Node_Kind := Nkind (Par);
begin
-- Any_Integer also appears in digits specifications for real types,
-- but those have bounds smaller that those of any integer base type,
-- so we can safely ignore these cases.
return Nkind_In (K, N_Number_Declaration,
N_Attribute_Reference,
N_Attribute_Definition_Clause,
N_Modular_Type_Definition,
N_Signed_Integer_Type_Definition);
end In_Any_Integer_Context;
-- Start of processing for Eval_Integer_Literal
begin
-- If the literal appears in a non-expression context, then it is
-- certainly appearing in a non-static context, so check it. This is
-- actually a redundant check, since Check_Non_Static_Context would
-- check it, but it seems worthwhile to optimize out the call.
-- An exception is made for a literal in an if or case expression
if (Nkind_In (Parent (N), N_If_Expression, N_Case_Expression_Alternative)
or else Nkind (Parent (N)) not in N_Subexpr)
and then not In_Any_Integer_Context
then
Check_Non_Static_Context (N);
end if;
-- Modular integer literals must be in their base range
if Is_Modular_Integer_Type (T)
and then Is_Out_Of_Range (N, Base_Type (T), Assume_Valid => True)
then
Out_Of_Range (N);
end if;
end Eval_Integer_Literal;
---------------------
-- Eval_Logical_Op --
---------------------
-- Logical operations are static functions, so the result is potentially
-- static if both operands are potentially static (RM 4.9(7), 4.9(20)).
procedure Eval_Logical_Op (N : Node_Id) is
Left : constant Node_Id := Left_Opnd (N);
Right : constant Node_Id := Right_Opnd (N);
Stat : Boolean;
Fold : Boolean;
begin
-- If not foldable we are done
Test_Expression_Is_Foldable (N, Left, Right, Stat, Fold);
if not Fold then
return;
end if;
-- Compile time evaluation of logical operation
declare
Left_Int : constant Uint := Expr_Value (Left);
Right_Int : constant Uint := Expr_Value (Right);
begin
if Is_Modular_Integer_Type (Etype (N)) then
declare
Left_Bits : Bits (0 .. UI_To_Int (Esize (Etype (N))) - 1);
Right_Bits : Bits (0 .. UI_To_Int (Esize (Etype (N))) - 1);
begin
To_Bits (Left_Int, Left_Bits);
To_Bits (Right_Int, Right_Bits);
-- Note: should really be able to use array ops instead of
-- these loops, but they weren't working at the time ???
if Nkind (N) = N_Op_And then
for J in Left_Bits'Range loop
Left_Bits (J) := Left_Bits (J) and Right_Bits (J);
end loop;
elsif Nkind (N) = N_Op_Or then
for J in Left_Bits'Range loop
Left_Bits (J) := Left_Bits (J) or Right_Bits (J);
end loop;
else
pragma Assert (Nkind (N) = N_Op_Xor);
for J in Left_Bits'Range loop
Left_Bits (J) := Left_Bits (J) xor Right_Bits (J);
end loop;
end if;
Fold_Uint (N, From_Bits (Left_Bits, Etype (N)), Stat);
end;
else
pragma Assert (Is_Boolean_Type (Etype (N)));
if Nkind (N) = N_Op_And then
Fold_Uint (N,
Test (Is_True (Left_Int) and then Is_True (Right_Int)), Stat);
elsif Nkind (N) = N_Op_Or then
Fold_Uint (N,
Test (Is_True (Left_Int) or else Is_True (Right_Int)), Stat);
else
pragma Assert (Nkind (N) = N_Op_Xor);
Fold_Uint (N,
Test (Is_True (Left_Int) xor Is_True (Right_Int)), Stat);
end if;
end if;
end;
end Eval_Logical_Op;
------------------------
-- Eval_Membership_Op --
------------------------
-- A membership test is potentially static if the expression is static, and
-- the range is a potentially static range, or is a subtype mark denoting a
-- static subtype (RM 4.9(12)).
procedure Eval_Membership_Op (N : Node_Id) is
Alts : constant List_Id := Alternatives (N);
Choice : constant Node_Id := Right_Opnd (N);
Expr : constant Node_Id := Left_Opnd (N);
Result : Match_Result;
begin
-- Ignore if error in either operand, except to make sure that Any_Type
-- is properly propagated to avoid junk cascaded errors.
if Etype (Expr) = Any_Type
or else (Present (Choice) and then Etype (Choice) = Any_Type)
then
Set_Etype (N, Any_Type);
return;
end if;
-- If left operand non-static, then nothing to do
if not Is_Static_Expression (Expr) then
return;
end if;
-- If choice is non-static, left operand is in non-static context
if (Present (Choice) and then not Is_Static_Choice (Choice))
or else (Present (Alts) and then not Is_Static_Choice_List (Alts))
then
Check_Non_Static_Context (Expr);
return;
end if;
-- Otherwise we definitely have a static expression
Set_Is_Static_Expression (N);
-- If left operand raises constraint error, propagate and we are done
if Raises_Constraint_Error (Expr) then
Set_Raises_Constraint_Error (N, True);
-- See if we match
else
if Present (Choice) then
Result := Choice_Matches (Expr, Choice);
else
Result := Choices_Match (Expr, Alts);
end if;
-- If result is Non_Static, it means that we raise Constraint_Error,
-- since we already tested that the operands were themselves static.
if Result = Non_Static then
Set_Raises_Constraint_Error (N);
-- Otherwise we have our result (flipped if NOT IN case)
else
Fold_Uint
(N, Test ((Result = Match) xor (Nkind (N) = N_Not_In)), True);
Warn_On_Known_Condition (N);
end if;
end if;
end Eval_Membership_Op;
------------------------
-- Eval_Named_Integer --
------------------------
procedure Eval_Named_Integer (N : Node_Id) is
begin
Fold_Uint (N,
Expr_Value (Expression (Declaration_Node (Entity (N)))), True);
end Eval_Named_Integer;
---------------------
-- Eval_Named_Real --
---------------------
procedure Eval_Named_Real (N : Node_Id) is
begin
Fold_Ureal (N,
Expr_Value_R (Expression (Declaration_Node (Entity (N)))), True);
end Eval_Named_Real;
-------------------
-- Eval_Op_Expon --
-------------------
-- Exponentiation is a static functions, so the result is potentially
-- static if both operands are potentially static (RM 4.9(7), 4.9(20)).
procedure Eval_Op_Expon (N : Node_Id) is
Left : constant Node_Id := Left_Opnd (N);
Right : constant Node_Id := Right_Opnd (N);
Stat : Boolean;
Fold : Boolean;
begin
-- If not foldable we are done
Test_Expression_Is_Foldable
(N, Left, Right, Stat, Fold, CRT_Safe => True);
-- Return if not foldable
if not Fold then
return;
end if;
if Configurable_Run_Time_Mode and not Stat then
return;
end if;
-- Fold exponentiation operation
declare
Right_Int : constant Uint := Expr_Value (Right);
begin
-- Integer case
if Is_Integer_Type (Etype (Left)) then
declare
Left_Int : constant Uint := Expr_Value (Left);
Result : Uint;
begin
-- Exponentiation of an integer raises Constraint_Error for a
-- negative exponent (RM 4.5.6).
if Right_Int < 0 then
Apply_Compile_Time_Constraint_Error
(N, "integer exponent negative", CE_Range_Check_Failed,
Warn => not Stat);
return;
else
if OK_Bits (N, Num_Bits (Left_Int) * Right_Int) then
Result := Left_Int ** Right_Int;
else
Result := Left_Int;
end if;
if Is_Modular_Integer_Type (Etype (N)) then
Result := Result mod Modulus (Etype (N));
end if;
Fold_Uint (N, Result, Stat);
end if;
end;
-- Real case
else
declare
Left_Real : constant Ureal := Expr_Value_R (Left);
begin
-- Cannot have a zero base with a negative exponent
if UR_Is_Zero (Left_Real) then
if Right_Int < 0 then
Apply_Compile_Time_Constraint_Error
(N, "zero ** negative integer", CE_Range_Check_Failed,
Warn => not Stat);
return;
else
Fold_Ureal (N, Ureal_0, Stat);
end if;
else
Fold_Ureal (N, Left_Real ** Right_Int, Stat);
end if;
end;
end if;
end;
end Eval_Op_Expon;
-----------------
-- Eval_Op_Not --
-----------------
-- The not operation is a static functions, so the result is potentially
-- static if the operand is potentially static (RM 4.9(7), 4.9(20)).
procedure Eval_Op_Not (N : Node_Id) is
Right : constant Node_Id := Right_Opnd (N);
Stat : Boolean;
Fold : Boolean;
begin
-- If not foldable we are done
Test_Expression_Is_Foldable (N, Right, Stat, Fold);
if not Fold then
return;
end if;
-- Fold not operation
declare
Rint : constant Uint := Expr_Value (Right);
Typ : constant Entity_Id := Etype (N);
begin
-- Negation is equivalent to subtracting from the modulus minus one.
-- For a binary modulus this is equivalent to the ones-complement of
-- the original value. For a nonbinary modulus this is an arbitrary
-- but consistent definition.
if Is_Modular_Integer_Type (Typ) then
Fold_Uint (N, Modulus (Typ) - 1 - Rint, Stat);
else pragma Assert (Is_Boolean_Type (Typ));
Fold_Uint (N, Test (not Is_True (Rint)), Stat);
end if;
Set_Is_Static_Expression (N, Stat);
end;
end Eval_Op_Not;
-------------------------------
-- Eval_Qualified_Expression --
-------------------------------
-- A qualified expression is potentially static if its subtype mark denotes
-- a static subtype and its expression is potentially static (RM 4.9 (11)).
procedure Eval_Qualified_Expression (N : Node_Id) is
Operand : constant Node_Id := Expression (N);
Target_Type : constant Entity_Id := Entity (Subtype_Mark (N));
Stat : Boolean;
Fold : Boolean;
Hex : Boolean;
begin
-- Can only fold if target is string or scalar and subtype is static.
-- Also, do not fold if our parent is an allocator (this is because the
-- qualified expression is really part of the syntactic structure of an
-- allocator, and we do not want to end up with something that
-- corresponds to "new 1" where the 1 is the result of folding a
-- qualified expression).
if not Is_Static_Subtype (Target_Type)
or else Nkind (Parent (N)) = N_Allocator
then
Check_Non_Static_Context (Operand);
-- If operand is known to raise constraint_error, set the flag on the
-- expression so it does not get optimized away.
if Nkind (Operand) = N_Raise_Constraint_Error then
Set_Raises_Constraint_Error (N);
end if;
return;
end if;
-- If not foldable we are done
Test_Expression_Is_Foldable (N, Operand, Stat, Fold);
if not Fold then
return;
-- Don't try fold if target type has constraint error bounds
elsif not Is_OK_Static_Subtype (Target_Type) then
Set_Raises_Constraint_Error (N);
return;
end if;
-- Here we will fold, save Print_In_Hex indication
Hex := Nkind (Operand) = N_Integer_Literal
and then Print_In_Hex (Operand);
-- Fold the result of qualification
if Is_Discrete_Type (Target_Type) then
Fold_Uint (N, Expr_Value (Operand), Stat);
-- Preserve Print_In_Hex indication
if Hex and then Nkind (N) = N_Integer_Literal then
Set_Print_In_Hex (N);
end if;
elsif Is_Real_Type (Target_Type) then
Fold_Ureal (N, Expr_Value_R (Operand), Stat);
else
Fold_Str (N, Strval (Get_String_Val (Operand)), Stat);
if not Stat then
Set_Is_Static_Expression (N, False);
else
Check_String_Literal_Length (N, Target_Type);
end if;
return;
end if;
-- The expression may be foldable but not static
Set_Is_Static_Expression (N, Stat);
if Is_Out_Of_Range (N, Etype (N), Assume_Valid => True) then
Out_Of_Range (N);
end if;
end Eval_Qualified_Expression;
-----------------------
-- Eval_Real_Literal --
-----------------------
-- Numeric literals are static (RM 4.9(1)), and have already been marked
-- as static by the analyzer. The reason we did it that early is to allow
-- the possibility of turning off the Is_Static_Expression flag after
-- analysis, but before resolution, when integer literals are generated
-- in the expander that do not correspond to static expressions.
procedure Eval_Real_Literal (N : Node_Id) is
PK : constant Node_Kind := Nkind (Parent (N));
begin
-- If the literal appears in a non-expression context and not as part of
-- a number declaration, then it is appearing in a non-static context,
-- so check it.
if PK not in N_Subexpr and then PK /= N_Number_Declaration then
Check_Non_Static_Context (N);
end if;
end Eval_Real_Literal;
------------------------
-- Eval_Relational_Op --
------------------------
-- Relational operations are static functions, so the result is static if
-- both operands are static (RM 4.9(7), 4.9(20)), except that for strings,
-- the result is never static, even if the operands are.
-- However, for internally generated nodes, we allow string equality and
-- inequality to be static. This is because we rewrite A in "ABC" as an
-- equality test A = "ABC", and the former is definitely static.
procedure Eval_Relational_Op (N : Node_Id) is
Left : constant Node_Id := Left_Opnd (N);
Right : constant Node_Id := Right_Opnd (N);
procedure Decompose_Expr
(Expr : Node_Id;
Ent : out Entity_Id;
Kind : out Character;
Cons : out Uint;
Orig : Boolean := True);
-- Given expression Expr, see if it is of the form X [+/- K]. If so, Ent
-- is set to the entity in X, Kind is 'F','L','E' for 'First or 'Last or
-- simple entity, and Cons is the value of K. If the expression is not
-- of the required form, Ent is set to Empty.
--
-- Orig indicates whether Expr is the original expression to consider,
-- or if we are handling a subexpression (e.g. recursive call to
-- Decompose_Expr).
procedure Fold_General_Op (Is_Static : Boolean);
-- Attempt to fold arbitrary relational operator N. Flag Is_Static must
-- be set when the operator denotes a static expression.
procedure Fold_Static_Real_Op;
-- Attempt to fold static real type relational operator N
function Static_Length (Expr : Node_Id) return Uint;
-- If Expr is an expression for a constrained array whose length is
-- known at compile time, return the non-negative length, otherwise
-- return -1.
--------------------
-- Decompose_Expr --
--------------------
procedure Decompose_Expr
(Expr : Node_Id;
Ent : out Entity_Id;
Kind : out Character;
Cons : out Uint;
Orig : Boolean := True)
is
Exp : Node_Id;
begin
-- Assume that the expression does not meet the expected form
Cons := No_Uint;
Ent := Empty;
Kind := '?';
if Nkind (Expr) = N_Op_Add
and then Compile_Time_Known_Value (Right_Opnd (Expr))
then
Exp := Left_Opnd (Expr);
Cons := Expr_Value (Right_Opnd (Expr));
elsif Nkind (Expr) = N_Op_Subtract
and then Compile_Time_Known_Value (Right_Opnd (Expr))
then
Exp := Left_Opnd (Expr);
Cons := -Expr_Value (Right_Opnd (Expr));
-- If the bound is a constant created to remove side effects, recover
-- the original expression to see if it has one of the recognizable
-- forms.
elsif Nkind (Expr) = N_Identifier
and then not Comes_From_Source (Entity (Expr))
and then Ekind (Entity (Expr)) = E_Constant
and then Nkind (Parent (Entity (Expr))) = N_Object_Declaration
then
Exp := Expression (Parent (Entity (Expr)));
Decompose_Expr (Exp, Ent, Kind, Cons, Orig => False);
-- If original expression includes an entity, create a reference
-- to it for use below.
if Present (Ent) then
Exp := New_Occurrence_Of (Ent, Sloc (Ent));
else
return;
end if;
else
-- Only consider the case of X + 0 for a full expression, and
-- not when recursing, otherwise we may end up with evaluating
-- expressions not known at compile time to 0.
if Orig then
Exp := Expr;
Cons := Uint_0;
else
return;
end if;
end if;
-- At this stage Exp is set to the potential X
if Nkind (Exp) = N_Attribute_Reference then
if Attribute_Name (Exp) = Name_First then
Kind := 'F';
elsif Attribute_Name (Exp) = Name_Last then
Kind := 'L';
else
return;
end if;
Exp := Prefix (Exp);
else
Kind := 'E';
end if;
if Is_Entity_Name (Exp) and then Present (Entity (Exp)) then
Ent := Entity (Exp);
end if;
end Decompose_Expr;
---------------------
-- Fold_General_Op --
---------------------
procedure Fold_General_Op (Is_Static : Boolean) is
CR : constant Compare_Result :=
Compile_Time_Compare (Left, Right, Assume_Valid => False);
Result : Boolean;
begin
if CR = Unknown then
return;
end if;
case Nkind (N) is
when N_Op_Eq =>
if CR = EQ then
Result := True;
elsif CR = NE or else CR = GT or else CR = LT then
Result := False;
else
return;
end if;
when N_Op_Ge =>
if CR = GT or else CR = EQ or else CR = GE then
Result := True;
elsif CR = LT then
Result := False;
else
return;
end if;
when N_Op_Gt =>
if CR = GT then
Result := True;
elsif CR = EQ or else CR = LT or else CR = LE then
Result := False;
else
return;
end if;
when N_Op_Le =>
if CR = LT or else CR = EQ or else CR = LE then
Result := True;
elsif CR = GT then
Result := False;
else
return;
end if;
when N_Op_Lt =>
if CR = LT then
Result := True;
elsif CR = EQ or else CR = GT or else CR = GE then
Result := False;
else
return;
end if;
when N_Op_Ne =>
if CR = NE or else CR = GT or else CR = LT then
Result := True;
elsif CR = EQ then
Result := False;
else
return;
end if;
when others =>
raise Program_Error;
end case;
-- Determine the potential outcome of the relation assuming the
-- operands are valid and emit a warning when the relation yields
-- True or False only in the presence of invalid values.
Warn_On_Constant_Valid_Condition (N);
Fold_Uint (N, Test (Result), Is_Static);
end Fold_General_Op;
-------------------------
-- Fold_Static_Real_Op --
-------------------------
procedure Fold_Static_Real_Op is
Left_Real : constant Ureal := Expr_Value_R (Left);
Right_Real : constant Ureal := Expr_Value_R (Right);
Result : Boolean;
begin
case Nkind (N) is
when N_Op_Eq => Result := (Left_Real = Right_Real);
when N_Op_Ge => Result := (Left_Real >= Right_Real);
when N_Op_Gt => Result := (Left_Real > Right_Real);
when N_Op_Le => Result := (Left_Real <= Right_Real);
when N_Op_Lt => Result := (Left_Real < Right_Real);
when N_Op_Ne => Result := (Left_Real /= Right_Real);
when others => raise Program_Error;
end case;
Fold_Uint (N, Test (Result), True);
end Fold_Static_Real_Op;
-------------------
-- Static_Length --
-------------------
function Static_Length (Expr : Node_Id) return Uint is
Cons1 : Uint;
Cons2 : Uint;
Ent1 : Entity_Id;
Ent2 : Entity_Id;
Kind1 : Character;
Kind2 : Character;
Typ : Entity_Id;
begin
-- First easy case string literal
if Nkind (Expr) = N_String_Literal then
return UI_From_Int (String_Length (Strval (Expr)));
-- Second easy case, not constrained subtype, so no length
elsif not Is_Constrained (Etype (Expr)) then
return Uint_Minus_1;
end if;
-- General case
Typ := Etype (First_Index (Etype (Expr)));
-- The simple case, both bounds are known at compile time
if Is_Discrete_Type (Typ)
and then Compile_Time_Known_Value (Type_Low_Bound (Typ))
and then Compile_Time_Known_Value (Type_High_Bound (Typ))
then
return
UI_Max (Uint_0, Expr_Value (Type_High_Bound (Typ)) -
Expr_Value (Type_Low_Bound (Typ)) + 1);
end if;
-- A more complex case, where the bounds are of the form X [+/- K1]
-- .. X [+/- K2]), where X is an expression that is either A'First or
-- A'Last (with A an entity name), or X is an entity name, and the
-- two X's are the same and K1 and K2 are known at compile time, in
-- this case, the length can also be computed at compile time, even
-- though the bounds are not known. A common case of this is e.g.
-- (X'First .. X'First+5).
Decompose_Expr
(Original_Node (Type_Low_Bound (Typ)), Ent1, Kind1, Cons1);
Decompose_Expr
(Original_Node (Type_High_Bound (Typ)), Ent2, Kind2, Cons2);
if Present (Ent1) and then Ent1 = Ent2 and then Kind1 = Kind2 then
return Cons2 - Cons1 + 1;
else
return Uint_Minus_1;
end if;
end Static_Length;
-- Local variables
Left_Typ : constant Entity_Id := Etype (Left);
Right_Typ : constant Entity_Id := Etype (Right);
Fold : Boolean;
Left_Len : Uint;
Op_Typ : Entity_Id := Empty;
Right_Len : Uint;
Is_Static_Expression : Boolean;
-- Start of processing for Eval_Relational_Op
begin
-- One special case to deal with first. If we can tell that the result
-- will be false because the lengths of one or more index subtypes are
-- compile-time known and different, then we can replace the entire
-- result by False. We only do this for one-dimensional arrays, because
-- the case of multidimensional arrays is rare and too much trouble. If
-- one of the operands is an illegal aggregate, its type might still be
-- an arbitrary composite type, so nothing to do.
if Is_Array_Type (Left_Typ)
and then Left_Typ /= Any_Composite
and then Number_Dimensions (Left_Typ) = 1
and then Nkind_In (N, N_Op_Eq, N_Op_Ne)
then
if Raises_Constraint_Error (Left)
or else
Raises_Constraint_Error (Right)
then
return;
-- OK, we have the case where we may be able to do this fold
else
Left_Len := Static_Length (Left);
Right_Len := Static_Length (Right);
if Left_Len /= Uint_Minus_1
and then Right_Len /= Uint_Minus_1
and then Left_Len /= Right_Len
then
Fold_Uint (N, Test (Nkind (N) = N_Op_Ne), False);
Warn_On_Known_Condition (N);
return;
end if;
end if;
-- General case
else
-- Initialize the value of Is_Static_Expression. The value of Fold
-- returned by Test_Expression_Is_Foldable is not needed since, even
-- when some operand is a variable, we can still perform the static
-- evaluation of the expression in some cases (for example, for a
-- variable of a subtype of Integer we statically know that any value
-- stored in such variable is smaller than Integer'Last).
Test_Expression_Is_Foldable
(N, Left, Right, Is_Static_Expression, Fold);
-- Only comparisons of scalars can give static results. A comparison
-- of strings never yields a static result, even if both operands are
-- static strings, except that as noted above, we allow equality and
-- inequality for strings.
if Is_String_Type (Left_Typ)
and then not Comes_From_Source (N)
and then Nkind_In (N, N_Op_Eq, N_Op_Ne)
then
null;
elsif not Is_Scalar_Type (Left_Typ) then
Is_Static_Expression := False;
Set_Is_Static_Expression (N, False);
end if;
-- For operators on universal numeric types called as functions with
-- an explicit scope, determine appropriate specific numeric type,
-- and diagnose possible ambiguity.
if Is_Universal_Numeric_Type (Left_Typ)
and then
Is_Universal_Numeric_Type (Right_Typ)
then
Op_Typ := Find_Universal_Operator_Type (N);
end if;
-- Attempt to fold the relational operator
if Is_Static_Expression and then Is_Real_Type (Left_Typ) then
Fold_Static_Real_Op;
else
Fold_General_Op (Is_Static_Expression);
end if;
end if;
-- For the case of a folded relational operator on a specific numeric
-- type, freeze the operand type now.
if Present (Op_Typ) then
Freeze_Before (N, Op_Typ);
end if;
Warn_On_Known_Condition (N);
end Eval_Relational_Op;
----------------
-- Eval_Shift --
----------------
-- Shift operations are intrinsic operations that can never be static, so
-- the only processing required is to perform the required check for a non
-- static context for the two operands.
-- Actually we could do some compile time evaluation here some time ???
procedure Eval_Shift (N : Node_Id) is
begin
Check_Non_Static_Context (Left_Opnd (N));
Check_Non_Static_Context (Right_Opnd (N));
end Eval_Shift;
------------------------
-- Eval_Short_Circuit --
------------------------
-- A short circuit operation is potentially static if both operands are
-- potentially static (RM 4.9 (13)).
procedure Eval_Short_Circuit (N : Node_Id) is
Kind : constant Node_Kind := Nkind (N);
Left : constant Node_Id := Left_Opnd (N);
Right : constant Node_Id := Right_Opnd (N);
Left_Int : Uint;
Rstat : constant Boolean :=
Is_Static_Expression (Left)
and then
Is_Static_Expression (Right);
begin
-- Short circuit operations are never static in Ada 83
if Ada_Version = Ada_83 and then Comes_From_Source (N) then
Check_Non_Static_Context (Left);
Check_Non_Static_Context (Right);
return;
end if;
-- Now look at the operands, we can't quite use the normal call to
-- Test_Expression_Is_Foldable here because short circuit operations
-- are a special case, they can still be foldable, even if the right
-- operand raises constraint error.
-- If either operand is Any_Type, just propagate to result and do not
-- try to fold, this prevents cascaded errors.
if Etype (Left) = Any_Type or else Etype (Right) = Any_Type then
Set_Etype (N, Any_Type);
return;
-- If left operand raises constraint error, then replace node N with
-- the raise constraint error node, and we are obviously not foldable.
-- Is_Static_Expression is set from the two operands in the normal way,
-- and we check the right operand if it is in a non-static context.
elsif Raises_Constraint_Error (Left) then
if not Rstat then
Check_Non_Static_Context (Right);
end if;
Rewrite_In_Raise_CE (N, Left);
Set_Is_Static_Expression (N, Rstat);
return;
-- If the result is not static, then we won't in any case fold
elsif not Rstat then
Check_Non_Static_Context (Left);
Check_Non_Static_Context (Right);
return;
end if;
-- Here the result is static, note that, unlike the normal processing
-- in Test_Expression_Is_Foldable, we did *not* check above to see if
-- the right operand raises constraint error, that's because it is not
-- significant if the left operand is decisive.
Set_Is_Static_Expression (N);
-- It does not matter if the right operand raises constraint error if
-- it will not be evaluated. So deal specially with the cases where
-- the right operand is not evaluated. Note that we will fold these
-- cases even if the right operand is non-static, which is fine, but
-- of course in these cases the result is not potentially static.
Left_Int := Expr_Value (Left);
if (Kind = N_And_Then and then Is_False (Left_Int))
or else
(Kind = N_Or_Else and then Is_True (Left_Int))
then
Fold_Uint (N, Left_Int, Rstat);
return;
end if;
-- If first operand not decisive, then it does matter if the right
-- operand raises constraint error, since it will be evaluated, so
-- we simply replace the node with the right operand. Note that this
-- properly propagates Is_Static_Expression and Raises_Constraint_Error
-- (both are set to True in Right).
if Raises_Constraint_Error (Right) then
Rewrite_In_Raise_CE (N, Right);
Check_Non_Static_Context (Left);
return;
end if;
-- Otherwise the result depends on the right operand
Fold_Uint (N, Expr_Value (Right), Rstat);
return;
end Eval_Short_Circuit;
----------------
-- Eval_Slice --
----------------
-- Slices can never be static, so the only processing required is to check
-- for non-static context if an explicit range is given.
procedure Eval_Slice (N : Node_Id) is
Drange : constant Node_Id := Discrete_Range (N);
begin
if Nkind (Drange) = N_Range then
Check_Non_Static_Context (Low_Bound (Drange));
Check_Non_Static_Context (High_Bound (Drange));
end if;
-- A slice of the form A (subtype), when the subtype is the index of
-- the type of A, is redundant, the slice can be replaced with A, and
-- this is worth a warning.
if Is_Entity_Name (Prefix (N)) then
declare
E : constant Entity_Id := Entity (Prefix (N));
T : constant Entity_Id := Etype (E);
begin
if Ekind (E) = E_Constant
and then Is_Array_Type (T)
and then Is_Entity_Name (Drange)
then
if Is_Entity_Name (Original_Node (First_Index (T)))
and then Entity (Original_Node (First_Index (T)))
= Entity (Drange)
then
if Warn_On_Redundant_Constructs then
Error_Msg_N ("redundant slice denotes whole array?r?", N);
end if;
-- The following might be a useful optimization???
-- Rewrite (N, New_Occurrence_Of (E, Sloc (N)));
end if;
end if;
end;
end if;
end Eval_Slice;
-------------------------
-- Eval_String_Literal --
-------------------------
procedure Eval_String_Literal (N : Node_Id) is
Typ : constant Entity_Id := Etype (N);
Bas : constant Entity_Id := Base_Type (Typ);
Xtp : Entity_Id;
Len : Nat;
Lo : Node_Id;
begin
-- Nothing to do if error type (handles cases like default expressions
-- or generics where we have not yet fully resolved the type).
if Bas = Any_Type or else Bas = Any_String then
return;
end if;
-- String literals are static if the subtype is static (RM 4.9(2)), so
-- reset the static expression flag (it was set unconditionally in
-- Analyze_String_Literal) if the subtype is non-static. We tell if
-- the subtype is static by looking at the lower bound.
if Ekind (Typ) = E_String_Literal_Subtype then
if not Is_OK_Static_Expression (String_Literal_Low_Bound (Typ)) then
Set_Is_Static_Expression (N, False);
return;
end if;
-- Here if Etype of string literal is normal Etype (not yet possible,
-- but may be possible in future).
elsif not Is_OK_Static_Expression
(Type_Low_Bound (Etype (First_Index (Typ))))
then
Set_Is_Static_Expression (N, False);
return;
end if;
-- If original node was a type conversion, then result if non-static
if Nkind (Original_Node (N)) = N_Type_Conversion then
Set_Is_Static_Expression (N, False);
return;
end if;
-- Test for illegal Ada 95 cases. A string literal is illegal in Ada 95
-- if its bounds are outside the index base type and this index type is
-- static. This can happen in only two ways. Either the string literal
-- is too long, or it is null, and the lower bound is type'First. Either
-- way it is the upper bound that is out of range of the index type.
if Ada_Version >= Ada_95 then
if Is_Standard_String_Type (Bas) then
Xtp := Standard_Positive;
else
Xtp := Etype (First_Index (Bas));
end if;
if Ekind (Typ) = E_String_Literal_Subtype then
Lo := String_Literal_Low_Bound (Typ);
else
Lo := Type_Low_Bound (Etype (First_Index (Typ)));
end if;
-- Check for string too long
Len := String_Length (Strval (N));
if UI_From_Int (Len) > String_Type_Len (Bas) then
-- Issue message. Note that this message is a warning if the
-- string literal is not marked as static (happens in some cases
-- of folding strings known at compile time, but not static).
-- Furthermore in such cases, we reword the message, since there
-- is no string literal in the source program.
if Is_Static_Expression (N) then
Apply_Compile_Time_Constraint_Error
(N, "string literal too long for}", CE_Length_Check_Failed,
Ent => Bas,
Typ => First_Subtype (Bas));
else
Apply_Compile_Time_Constraint_Error
(N, "string value too long for}", CE_Length_Check_Failed,
Ent => Bas,
Typ => First_Subtype (Bas),
Warn => True);
end if;
-- Test for null string not allowed
elsif Len = 0
and then not Is_Generic_Type (Xtp)
and then
Expr_Value (Lo) = Expr_Value (Type_Low_Bound (Base_Type (Xtp)))
then
-- Same specialization of message
if Is_Static_Expression (N) then
Apply_Compile_Time_Constraint_Error
(N, "null string literal not allowed for}",
CE_Length_Check_Failed,
Ent => Bas,
Typ => First_Subtype (Bas));
else
Apply_Compile_Time_Constraint_Error
(N, "null string value not allowed for}",
CE_Length_Check_Failed,
Ent => Bas,
Typ => First_Subtype (Bas),
Warn => True);
end if;
end if;
end if;
end Eval_String_Literal;
--------------------------
-- Eval_Type_Conversion --
--------------------------
-- A type conversion is potentially static if its subtype mark is for a
-- static scalar subtype, and its operand expression is potentially static
-- (RM 4.9(10)).
procedure Eval_Type_Conversion (N : Node_Id) is
Operand : constant Node_Id := Expression (N);
Source_Type : constant Entity_Id := Etype (Operand);
Target_Type : constant Entity_Id := Etype (N);
function To_Be_Treated_As_Integer (T : Entity_Id) return Boolean;
-- Returns true if type T is an integer type, or if it is a fixed-point
-- type to be treated as an integer (i.e. the flag Conversion_OK is set
-- on the conversion node).
function To_Be_Treated_As_Real (T : Entity_Id) return Boolean;
-- Returns true if type T is a floating-point type, or if it is a
-- fixed-point type that is not to be treated as an integer (i.e. the
-- flag Conversion_OK is not set on the conversion node).
------------------------------
-- To_Be_Treated_As_Integer --
------------------------------
function To_Be_Treated_As_Integer (T : Entity_Id) return Boolean is
begin
return
Is_Integer_Type (T)
or else (Is_Fixed_Point_Type (T) and then Conversion_OK (N));
end To_Be_Treated_As_Integer;
---------------------------
-- To_Be_Treated_As_Real --
---------------------------
function To_Be_Treated_As_Real (T : Entity_Id) return Boolean is
begin
return
Is_Floating_Point_Type (T)
or else (Is_Fixed_Point_Type (T) and then not Conversion_OK (N));
end To_Be_Treated_As_Real;
-- Local variables
Fold : Boolean;
Stat : Boolean;
-- Start of processing for Eval_Type_Conversion
begin
-- Cannot fold if target type is non-static or if semantic error
if not Is_Static_Subtype (Target_Type) then
Check_Non_Static_Context (Operand);
return;
elsif Error_Posted (N) then
return;
end if;
-- If not foldable we are done
Test_Expression_Is_Foldable (N, Operand, Stat, Fold);
if not Fold then
return;
-- Don't try fold if target type has constraint error bounds
elsif not Is_OK_Static_Subtype (Target_Type) then
Set_Raises_Constraint_Error (N);
return;
end if;
-- Remaining processing depends on operand types. Note that in the
-- following type test, fixed-point counts as real unless the flag
-- Conversion_OK is set, in which case it counts as integer.
-- Fold conversion, case of string type. The result is not static
if Is_String_Type (Target_Type) then
Fold_Str (N, Strval (Get_String_Val (Operand)), Static => False);
return;
-- Fold conversion, case of integer target type
elsif To_Be_Treated_As_Integer (Target_Type) then
declare
Result : Uint;
begin
-- Integer to integer conversion
if To_Be_Treated_As_Integer (Source_Type) then
Result := Expr_Value (Operand);
-- Real to integer conversion
else
Result := UR_To_Uint (Expr_Value_R (Operand));
end if;
-- If fixed-point type (Conversion_OK must be set), then the
-- result is logically an integer, but we must replace the
-- conversion with the corresponding real literal, since the
-- type from a semantic point of view is still fixed-point.
if Is_Fixed_Point_Type (Target_Type) then
Fold_Ureal
(N, UR_From_Uint (Result) * Small_Value (Target_Type), Stat);
-- Otherwise result is integer literal
else
Fold_Uint (N, Result, Stat);
end if;
end;
-- Fold conversion, case of real target type
elsif To_Be_Treated_As_Real (Target_Type) then
declare
Result : Ureal;
begin
if To_Be_Treated_As_Real (Source_Type) then
Result := Expr_Value_R (Operand);
else
Result := UR_From_Uint (Expr_Value (Operand));
end if;
Fold_Ureal (N, Result, Stat);
end;
-- Enumeration types
else
Fold_Uint (N, Expr_Value (Operand), Stat);
end if;
if Is_Out_Of_Range (N, Etype (N), Assume_Valid => True) then
Out_Of_Range (N);
end if;
end Eval_Type_Conversion;
-------------------
-- Eval_Unary_Op --
-------------------
-- Predefined unary operators are static functions (RM 4.9(20)) and thus
-- are potentially static if the operand is potentially static (RM 4.9(7)).
procedure Eval_Unary_Op (N : Node_Id) is
Right : constant Node_Id := Right_Opnd (N);
Otype : Entity_Id := Empty;
Stat : Boolean;
Fold : Boolean;
begin
-- If not foldable we are done
Test_Expression_Is_Foldable (N, Right, Stat, Fold);
if not Fold then
return;
end if;
if Etype (Right) = Universal_Integer
or else
Etype (Right) = Universal_Real
then
Otype := Find_Universal_Operator_Type (N);
end if;
-- Fold for integer case
if Is_Integer_Type (Etype (N)) then
declare
Rint : constant Uint := Expr_Value (Right);
Result : Uint;
begin
-- In the case of modular unary plus and abs there is no need
-- to adjust the result of the operation since if the original
-- operand was in bounds the result will be in the bounds of the
-- modular type. However, in the case of modular unary minus the
-- result may go out of the bounds of the modular type and needs
-- adjustment.
if Nkind (N) = N_Op_Plus then
Result := Rint;
elsif Nkind (N) = N_Op_Minus then
if Is_Modular_Integer_Type (Etype (N)) then
Result := (-Rint) mod Modulus (Etype (N));
else
Result := (-Rint);
end if;
else
pragma Assert (Nkind (N) = N_Op_Abs);
Result := abs Rint;
end if;
Fold_Uint (N, Result, Stat);
end;
-- Fold for real case
elsif Is_Real_Type (Etype (N)) then
declare
Rreal : constant Ureal := Expr_Value_R (Right);
Result : Ureal;
begin
if Nkind (N) = N_Op_Plus then
Result := Rreal;
elsif Nkind (N) = N_Op_Minus then
Result := UR_Negate (Rreal);
else
pragma Assert (Nkind (N) = N_Op_Abs);
Result := abs Rreal;
end if;
Fold_Ureal (N, Result, Stat);
end;
end if;
-- If the operator was resolved to a specific type, make sure that type
-- is frozen even if the expression is folded into a literal (which has
-- a universal type).
if Present (Otype) then
Freeze_Before (N, Otype);
end if;
end Eval_Unary_Op;
-------------------------------
-- Eval_Unchecked_Conversion --
-------------------------------
-- Unchecked conversions can never be static, so the only required
-- processing is to check for a non-static context for the operand.
procedure Eval_Unchecked_Conversion (N : Node_Id) is
begin
Check_Non_Static_Context (Expression (N));
end Eval_Unchecked_Conversion;
--------------------
-- Expr_Rep_Value --
--------------------
function Expr_Rep_Value (N : Node_Id) return Uint is
Kind : constant Node_Kind := Nkind (N);
Ent : Entity_Id;
begin
if Is_Entity_Name (N) then
Ent := Entity (N);
-- An enumeration literal that was either in the source or created
-- as a result of static evaluation.
if Ekind (Ent) = E_Enumeration_Literal then
return Enumeration_Rep (Ent);
-- A user defined static constant
else
pragma Assert (Ekind (Ent) = E_Constant);
return Expr_Rep_Value (Constant_Value (Ent));
end if;
-- An integer literal that was either in the source or created as a
-- result of static evaluation.
elsif Kind = N_Integer_Literal then
return Intval (N);
-- A real literal for a fixed-point type. This must be the fixed-point
-- case, either the literal is of a fixed-point type, or it is a bound
-- of a fixed-point type, with type universal real. In either case we
-- obtain the desired value from Corresponding_Integer_Value.
elsif Kind = N_Real_Literal then
pragma Assert (Is_Fixed_Point_Type (Underlying_Type (Etype (N))));
return Corresponding_Integer_Value (N);
-- Otherwise must be character literal
else
pragma Assert (Kind = N_Character_Literal);
Ent := Entity (N);
-- Since Character literals of type Standard.Character don't have any
-- defining character literals built for them, they do not have their
-- Entity set, so just use their Char code. Otherwise for user-
-- defined character literals use their Pos value as usual which is
-- the same as the Rep value.
if No (Ent) then
return Char_Literal_Value (N);
else
return Enumeration_Rep (Ent);
end if;
end if;
end Expr_Rep_Value;
----------------
-- Expr_Value --
----------------
function Expr_Value (N : Node_Id) return Uint is
Kind : constant Node_Kind := Nkind (N);
CV_Ent : CV_Entry renames CV_Cache (Nat (N) mod CV_Cache_Size);
Ent : Entity_Id;
Val : Uint;
begin
-- If already in cache, then we know it's compile time known and we can
-- return the value that was previously stored in the cache since
-- compile time known values cannot change.
if CV_Ent.N = N then
return CV_Ent.V;
end if;
-- Otherwise proceed to test value
if Is_Entity_Name (N) then
Ent := Entity (N);
-- An enumeration literal that was either in the source or created as
-- a result of static evaluation.
if Ekind (Ent) = E_Enumeration_Literal then
Val := Enumeration_Pos (Ent);
-- A user defined static constant
else
pragma Assert (Ekind (Ent) = E_Constant);
Val := Expr_Value (Constant_Value (Ent));
end if;
-- An integer literal that was either in the source or created as a
-- result of static evaluation.
elsif Kind = N_Integer_Literal then
Val := Intval (N);
-- A real literal for a fixed-point type. This must be the fixed-point
-- case, either the literal is of a fixed-point type, or it is a bound
-- of a fixed-point type, with type universal real. In either case we
-- obtain the desired value from Corresponding_Integer_Value.
elsif Kind = N_Real_Literal then
pragma Assert (Is_Fixed_Point_Type (Underlying_Type (Etype (N))));
Val := Corresponding_Integer_Value (N);
-- Otherwise must be character literal
else
pragma Assert (Kind = N_Character_Literal);
Ent := Entity (N);
-- Since Character literals of type Standard.Character don't
-- have any defining character literals built for them, they
-- do not have their Entity set, so just use their Char
-- code. Otherwise for user-defined character literals use
-- their Pos value as usual.
if No (Ent) then
Val := Char_Literal_Value (N);
else
Val := Enumeration_Pos (Ent);
end if;
end if;
-- Come here with Val set to value to be returned, set cache
CV_Ent.N := N;
CV_Ent.V := Val;
return Val;
end Expr_Value;
------------------
-- Expr_Value_E --
------------------
function Expr_Value_E (N : Node_Id) return Entity_Id is
Ent : constant Entity_Id := Entity (N);
begin
if Ekind (Ent) = E_Enumeration_Literal then
return Ent;
else
pragma Assert (Ekind (Ent) = E_Constant);
return Expr_Value_E (Constant_Value (Ent));
end if;
end Expr_Value_E;
------------------
-- Expr_Value_R --
------------------
function Expr_Value_R (N : Node_Id) return Ureal is
Kind : constant Node_Kind := Nkind (N);
Ent : Entity_Id;
begin
if Kind = N_Real_Literal then
return Realval (N);
elsif Kind = N_Identifier or else Kind = N_Expanded_Name then
Ent := Entity (N);
pragma Assert (Ekind (Ent) = E_Constant);
return Expr_Value_R (Constant_Value (Ent));
elsif Kind = N_Integer_Literal then
return UR_From_Uint (Expr_Value (N));
-- Here, we have a node that cannot be interpreted as a compile time
-- constant. That is definitely an error.
else
raise Program_Error;
end if;
end Expr_Value_R;
------------------
-- Expr_Value_S --
------------------
function Expr_Value_S (N : Node_Id) return Node_Id is
begin
if Nkind (N) = N_String_Literal then
return N;
else
pragma Assert (Ekind (Entity (N)) = E_Constant);
return Expr_Value_S (Constant_Value (Entity (N)));
end if;
end Expr_Value_S;
----------------------------------
-- Find_Universal_Operator_Type --
----------------------------------
function Find_Universal_Operator_Type (N : Node_Id) return Entity_Id is
PN : constant Node_Id := Parent (N);
Call : constant Node_Id := Original_Node (N);
Is_Int : constant Boolean := Is_Integer_Type (Etype (N));
Is_Fix : constant Boolean :=
Nkind (N) in N_Binary_Op
and then Nkind (Right_Opnd (N)) /= Nkind (Left_Opnd (N));
-- A mixed-mode operation in this context indicates the presence of
-- fixed-point type in the designated package.
Is_Relational : constant Boolean := Etype (N) = Standard_Boolean;
-- Case where N is a relational (or membership) operator (else it is an
-- arithmetic one).
In_Membership : constant Boolean :=
Nkind (PN) in N_Membership_Test
and then
Nkind (Right_Opnd (PN)) = N_Range
and then
Is_Universal_Numeric_Type (Etype (Left_Opnd (PN)))
and then
Is_Universal_Numeric_Type
(Etype (Low_Bound (Right_Opnd (PN))))
and then
Is_Universal_Numeric_Type
(Etype (High_Bound (Right_Opnd (PN))));
-- Case where N is part of a membership test with a universal range
E : Entity_Id;
Pack : Entity_Id;
Typ1 : Entity_Id := Empty;
Priv_E : Entity_Id;
function Is_Mixed_Mode_Operand (Op : Node_Id) return Boolean;
-- Check whether one operand is a mixed-mode operation that requires the
-- presence of a fixed-point type. Given that all operands are universal
-- and have been constant-folded, retrieve the original function call.
---------------------------
-- Is_Mixed_Mode_Operand --
---------------------------
function Is_Mixed_Mode_Operand (Op : Node_Id) return Boolean is
Onod : constant Node_Id := Original_Node (Op);
begin
return Nkind (Onod) = N_Function_Call
and then Present (Next_Actual (First_Actual (Onod)))
and then Etype (First_Actual (Onod)) /=
Etype (Next_Actual (First_Actual (Onod)));
end Is_Mixed_Mode_Operand;
-- Start of processing for Find_Universal_Operator_Type
begin
if Nkind (Call) /= N_Function_Call
or else Nkind (Name (Call)) /= N_Expanded_Name
then
return Empty;
-- There are several cases where the context does not imply the type of
-- the operands:
-- - the universal expression appears in a type conversion;
-- - the expression is a relational operator applied to universal
-- operands;
-- - the expression is a membership test with a universal operand
-- and a range with universal bounds.
elsif Nkind (Parent (N)) = N_Type_Conversion
or else Is_Relational
or else In_Membership
then
Pack := Entity (Prefix (Name (Call)));
-- If the prefix is a package declared elsewhere, iterate over its
-- visible entities, otherwise iterate over all declarations in the
-- designated scope.
if Ekind (Pack) = E_Package
and then not In_Open_Scopes (Pack)
then
Priv_E := First_Private_Entity (Pack);
else
Priv_E := Empty;
end if;
Typ1 := Empty;
E := First_Entity (Pack);
while Present (E) and then E /= Priv_E loop
if Is_Numeric_Type (E)
and then Nkind (Parent (E)) /= N_Subtype_Declaration
and then Comes_From_Source (E)
and then Is_Integer_Type (E) = Is_Int
and then (Nkind (N) in N_Unary_Op
or else Is_Relational
or else Is_Fixed_Point_Type (E) = Is_Fix)
then
if No (Typ1) then
Typ1 := E;
-- Before emitting an error, check for the presence of a
-- mixed-mode operation that specifies a fixed point type.
elsif Is_Relational
and then
(Is_Mixed_Mode_Operand (Left_Opnd (N))
or else Is_Mixed_Mode_Operand (Right_Opnd (N)))
and then Is_Fixed_Point_Type (E) /= Is_Fixed_Point_Type (Typ1)
then
if Is_Fixed_Point_Type (E) then
Typ1 := E;
end if;
else
-- More than one type of the proper class declared in P
Error_Msg_N ("ambiguous operation", N);
Error_Msg_Sloc := Sloc (Typ1);
Error_Msg_N ("\possible interpretation (inherited)#", N);
Error_Msg_Sloc := Sloc (E);
Error_Msg_N ("\possible interpretation (inherited)#", N);
return Empty;
end if;
end if;
Next_Entity (E);
end loop;
end if;
return Typ1;
end Find_Universal_Operator_Type;
--------------------------
-- Flag_Non_Static_Expr --
--------------------------
procedure Flag_Non_Static_Expr (Msg : String; Expr : Node_Id) is
begin
if Error_Posted (Expr) and then not All_Errors_Mode then
return;
else
Error_Msg_F (Msg, Expr);
Why_Not_Static (Expr);
end if;
end Flag_Non_Static_Expr;
--------------
-- Fold_Str --
--------------
procedure Fold_Str (N : Node_Id; Val : String_Id; Static : Boolean) is
Loc : constant Source_Ptr := Sloc (N);
Typ : constant Entity_Id := Etype (N);
begin
if Raises_Constraint_Error (N) then
Set_Is_Static_Expression (N, Static);
return;
end if;
Rewrite (N, Make_String_Literal (Loc, Strval => Val));
-- We now have the literal with the right value, both the actual type
-- and the expected type of this literal are taken from the expression
-- that was evaluated. So now we do the Analyze and Resolve.
-- Note that we have to reset Is_Static_Expression both after the
-- analyze step (because Resolve will evaluate the literal, which
-- will cause semantic errors if it is marked as static), and after
-- the Resolve step (since Resolve in some cases resets this flag).
Analyze (N);
Set_Is_Static_Expression (N, Static);
Set_Etype (N, Typ);
Resolve (N);
Set_Is_Static_Expression (N, Static);
end Fold_Str;
---------------
-- Fold_Uint --
---------------
procedure Fold_Uint (N : Node_Id; Val : Uint; Static : Boolean) is
Loc : constant Source_Ptr := Sloc (N);
Typ : Entity_Id := Etype (N);
Ent : Entity_Id;
begin
if Raises_Constraint_Error (N) then
Set_Is_Static_Expression (N, Static);
return;
end if;
-- If we are folding a named number, retain the entity in the literal,
-- for ASIS use.
if Is_Entity_Name (N) and then Ekind (Entity (N)) = E_Named_Integer then
Ent := Entity (N);
else
Ent := Empty;
end if;
if Is_Private_Type (Typ) then
Typ := Full_View (Typ);
end if;
-- For a result of type integer, substitute an N_Integer_Literal node
-- for the result of the compile time evaluation of the expression.
-- For ASIS use, set a link to the original named number when not in
-- a generic context.
if Is_Integer_Type (Typ) then
Rewrite (N, Make_Integer_Literal (Loc, Val));
Set_Original_Entity (N, Ent);
-- Otherwise we have an enumeration type, and we substitute either
-- an N_Identifier or N_Character_Literal to represent the enumeration
-- literal corresponding to the given value, which must always be in
-- range, because appropriate tests have already been made for this.
else pragma Assert (Is_Enumeration_Type (Typ));
Rewrite (N, Get_Enum_Lit_From_Pos (Etype (N), Val, Loc));
end if;
-- We now have the literal with the right value, both the actual type
-- and the expected type of this literal are taken from the expression
-- that was evaluated. So now we do the Analyze and Resolve.
-- Note that we have to reset Is_Static_Expression both after the
-- analyze step (because Resolve will evaluate the literal, which
-- will cause semantic errors if it is marked as static), and after
-- the Resolve step (since Resolve in some cases sets this flag).
Analyze (N);
Set_Is_Static_Expression (N, Static);
Set_Etype (N, Typ);
Resolve (N);
Set_Is_Static_Expression (N, Static);
end Fold_Uint;
----------------
-- Fold_Ureal --
----------------
procedure Fold_Ureal (N : Node_Id; Val : Ureal; Static : Boolean) is
Loc : constant Source_Ptr := Sloc (N);
Typ : constant Entity_Id := Etype (N);
Ent : Entity_Id;
begin
if Raises_Constraint_Error (N) then
Set_Is_Static_Expression (N, Static);
return;
end if;
-- If we are folding a named number, retain the entity in the literal,
-- for ASIS use.
if Is_Entity_Name (N) and then Ekind (Entity (N)) = E_Named_Real then
Ent := Entity (N);
else
Ent := Empty;
end if;
Rewrite (N, Make_Real_Literal (Loc, Realval => Val));
-- Set link to original named number, for ASIS use
Set_Original_Entity (N, Ent);
-- We now have the literal with the right value, both the actual type
-- and the expected type of this literal are taken from the expression
-- that was evaluated. So now we do the Analyze and Resolve.
-- Note that we have to reset Is_Static_Expression both after the
-- analyze step (because Resolve will evaluate the literal, which
-- will cause semantic errors if it is marked as static), and after
-- the Resolve step (since Resolve in some cases sets this flag).
Analyze (N);
Set_Is_Static_Expression (N, Static);
Set_Etype (N, Typ);
Resolve (N);
Set_Is_Static_Expression (N, Static);
end Fold_Ureal;
---------------
-- From_Bits --
---------------
function From_Bits (B : Bits; T : Entity_Id) return Uint is
V : Uint := Uint_0;
begin
for J in 0 .. B'Last loop
if B (J) then
V := V + 2 ** J;
end if;
end loop;
if Non_Binary_Modulus (T) then
V := V mod Modulus (T);
end if;
return V;
end From_Bits;
--------------------
-- Get_String_Val --
--------------------
function Get_String_Val (N : Node_Id) return Node_Id is
begin
if Nkind_In (N, N_String_Literal, N_Character_Literal) then
return N;
else
pragma Assert (Is_Entity_Name (N));
return Get_String_Val (Constant_Value (Entity (N)));
end if;
end Get_String_Val;
----------------
-- Initialize --
----------------
procedure Initialize is
begin
CV_Cache := (others => (Node_High_Bound, Uint_0));
end Initialize;
--------------------
-- In_Subrange_Of --
--------------------
function In_Subrange_Of
(T1 : Entity_Id;
T2 : Entity_Id;
Fixed_Int : Boolean := False) return Boolean
is
L1 : Node_Id;
H1 : Node_Id;
L2 : Node_Id;
H2 : Node_Id;
begin
if T1 = T2 or else Is_Subtype_Of (T1, T2) then
return True;
-- Never in range if both types are not scalar. Don't know if this can
-- actually happen, but just in case.
elsif not Is_Scalar_Type (T1) or else not Is_Scalar_Type (T2) then
return False;
-- If T1 has infinities but T2 doesn't have infinities, then T1 is
-- definitely not compatible with T2.
elsif Is_Floating_Point_Type (T1)
and then Has_Infinities (T1)
and then Is_Floating_Point_Type (T2)
and then not Has_Infinities (T2)
then
return False;
else
L1 := Type_Low_Bound (T1);
H1 := Type_High_Bound (T1);
L2 := Type_Low_Bound (T2);
H2 := Type_High_Bound (T2);
-- Check bounds to see if comparison possible at compile time
if Compile_Time_Compare (L1, L2, Assume_Valid => True) in Compare_GE
and then
Compile_Time_Compare (H1, H2, Assume_Valid => True) in Compare_LE
then
return True;
end if;
-- If bounds not comparable at compile time, then the bounds of T2
-- must be compile time known or we cannot answer the query.
if not Compile_Time_Known_Value (L2)
or else not Compile_Time_Known_Value (H2)
then
return False;
end if;
-- If the bounds of T1 are know at compile time then use these
-- ones, otherwise use the bounds of the base type (which are of
-- course always static).
if not Compile_Time_Known_Value (L1) then
L1 := Type_Low_Bound (Base_Type (T1));
end if;
if not Compile_Time_Known_Value (H1) then
H1 := Type_High_Bound (Base_Type (T1));
end if;
-- Fixed point types should be considered as such only if
-- flag Fixed_Int is set to False.
if Is_Floating_Point_Type (T1) or else Is_Floating_Point_Type (T2)
or else (Is_Fixed_Point_Type (T1) and then not Fixed_Int)
or else (Is_Fixed_Point_Type (T2) and then not Fixed_Int)
then
return
Expr_Value_R (L2) <= Expr_Value_R (L1)
and then
Expr_Value_R (H2) >= Expr_Value_R (H1);
else
return
Expr_Value (L2) <= Expr_Value (L1)
and then
Expr_Value (H2) >= Expr_Value (H1);
end if;
end if;
-- If any exception occurs, it means that we have some bug in the compiler
-- possibly triggered by a previous error, or by some unforeseen peculiar
-- occurrence. However, this is only an optimization attempt, so there is
-- really no point in crashing the compiler. Instead we just decide, too
-- bad, we can't figure out the answer in this case after all.
exception
when others =>
-- Debug flag K disables this behavior (useful for debugging)
if Debug_Flag_K then
raise;
else
return False;
end if;
end In_Subrange_Of;
-----------------
-- Is_In_Range --
-----------------
function Is_In_Range
(N : Node_Id;
Typ : Entity_Id;
Assume_Valid : Boolean := False;
Fixed_Int : Boolean := False;
Int_Real : Boolean := False) return Boolean
is
begin
return
Test_In_Range (N, Typ, Assume_Valid, Fixed_Int, Int_Real) = In_Range;
end Is_In_Range;
-------------------
-- Is_Null_Range --
-------------------
function Is_Null_Range (Lo : Node_Id; Hi : Node_Id) return Boolean is
Typ : constant Entity_Id := Etype (Lo);
begin
if not Compile_Time_Known_Value (Lo)
or else not Compile_Time_Known_Value (Hi)
then
return False;
end if;
if Is_Discrete_Type (Typ) then
return Expr_Value (Lo) > Expr_Value (Hi);
else pragma Assert (Is_Real_Type (Typ));
return Expr_Value_R (Lo) > Expr_Value_R (Hi);
end if;
end Is_Null_Range;
-------------------------
-- Is_OK_Static_Choice --
-------------------------
function Is_OK_Static_Choice (Choice : Node_Id) return Boolean is
begin
-- Check various possibilities for choice
-- Note: for membership tests, we test more cases than are possible
-- (in particular subtype indication), but it doesn't matter because
-- it just won't occur (we have already done a syntax check).
if Nkind (Choice) = N_Others_Choice then
return True;
elsif Nkind (Choice) = N_Range then
return Is_OK_Static_Range (Choice);
elsif Nkind (Choice) = N_Subtype_Indication
or else (Is_Entity_Name (Choice) and then Is_Type (Entity (Choice)))
then
return Is_OK_Static_Subtype (Etype (Choice));
else
return Is_OK_Static_Expression (Choice);
end if;
end Is_OK_Static_Choice;
------------------------------
-- Is_OK_Static_Choice_List --
------------------------------
function Is_OK_Static_Choice_List (Choices : List_Id) return Boolean is
Choice : Node_Id;
begin
if not Is_Static_Choice_List (Choices) then
return False;
end if;
Choice := First (Choices);
while Present (Choice) loop
if not Is_OK_Static_Choice (Choice) then
Set_Raises_Constraint_Error (Choice);
return False;
end if;
Next (Choice);
end loop;
return True;
end Is_OK_Static_Choice_List;
-----------------------------
-- Is_OK_Static_Expression --
-----------------------------
function Is_OK_Static_Expression (N : Node_Id) return Boolean is
begin
return Is_Static_Expression (N) and then not Raises_Constraint_Error (N);
end Is_OK_Static_Expression;
------------------------
-- Is_OK_Static_Range --
------------------------
-- A static range is a range whose bounds are static expressions, or a
-- Range_Attribute_Reference equivalent to such a range (RM 4.9(26)).
-- We have already converted range attribute references, so we get the
-- "or" part of this rule without needing a special test.
function Is_OK_Static_Range (N : Node_Id) return Boolean is
begin
return Is_OK_Static_Expression (Low_Bound (N))
and then Is_OK_Static_Expression (High_Bound (N));
end Is_OK_Static_Range;
--------------------------
-- Is_OK_Static_Subtype --
--------------------------
-- Determines if Typ is a static subtype as defined in (RM 4.9(26)) where
-- neither bound raises constraint error when evaluated.
function Is_OK_Static_Subtype (Typ : Entity_Id) return Boolean is
Base_T : constant Entity_Id := Base_Type (Typ);
Anc_Subt : Entity_Id;
begin
-- First a quick check on the non static subtype flag. As described
-- in further detail in Einfo, this flag is not decisive in all cases,
-- but if it is set, then the subtype is definitely non-static.
if Is_Non_Static_Subtype (Typ) then
return False;
end if;
Anc_Subt := Ancestor_Subtype (Typ);
if Anc_Subt = Empty then
Anc_Subt := Base_T;
end if;
if Is_Generic_Type (Root_Type (Base_T))
or else Is_Generic_Actual_Type (Base_T)
then
return False;
elsif Has_Dynamic_Predicate_Aspect (Typ) then
return False;
-- String types
elsif Is_String_Type (Typ) then
return
Ekind (Typ) = E_String_Literal_Subtype
or else
(Is_OK_Static_Subtype (Component_Type (Typ))
and then Is_OK_Static_Subtype (Etype (First_Index (Typ))));
-- Scalar types
elsif Is_Scalar_Type (Typ) then
if Base_T = Typ then
return True;
else
-- Scalar_Range (Typ) might be an N_Subtype_Indication, so use
-- Get_Type_{Low,High}_Bound.
return Is_OK_Static_Subtype (Anc_Subt)
and then Is_OK_Static_Expression (Type_Low_Bound (Typ))
and then Is_OK_Static_Expression (Type_High_Bound (Typ));
end if;
-- Types other than string and scalar types are never static
else
return False;
end if;
end Is_OK_Static_Subtype;
---------------------
-- Is_Out_Of_Range --
---------------------
function Is_Out_Of_Range
(N : Node_Id;
Typ : Entity_Id;
Assume_Valid : Boolean := False;
Fixed_Int : Boolean := False;
Int_Real : Boolean := False) return Boolean
is
begin
return Test_In_Range (N, Typ, Assume_Valid, Fixed_Int, Int_Real) =
Out_Of_Range;
end Is_Out_Of_Range;
----------------------
-- Is_Static_Choice --
----------------------
function Is_Static_Choice (Choice : Node_Id) return Boolean is
begin
-- Check various possibilities for choice
-- Note: for membership tests, we test more cases than are possible
-- (in particular subtype indication), but it doesn't matter because
-- it just won't occur (we have already done a syntax check).
if Nkind (Choice) = N_Others_Choice then
return True;
elsif Nkind (Choice) = N_Range then
return Is_Static_Range (Choice);
elsif Nkind (Choice) = N_Subtype_Indication
or else (Is_Entity_Name (Choice) and then Is_Type (Entity (Choice)))
then
return Is_Static_Subtype (Etype (Choice));
else
return Is_Static_Expression (Choice);
end if;
end Is_Static_Choice;
---------------------------
-- Is_Static_Choice_List --
---------------------------
function Is_Static_Choice_List (Choices : List_Id) return Boolean is
Choice : Node_Id;
begin
Choice := First (Choices);
while Present (Choice) loop
if not Is_Static_Choice (Choice) then
return False;
end if;
Next (Choice);
end loop;
return True;
end Is_Static_Choice_List;
---------------------
-- Is_Static_Range --
---------------------
-- A static range is a range whose bounds are static expressions, or a
-- Range_Attribute_Reference equivalent to such a range (RM 4.9(26)).
-- We have already converted range attribute references, so we get the
-- "or" part of this rule without needing a special test.
function Is_Static_Range (N : Node_Id) return Boolean is
begin
return Is_Static_Expression (Low_Bound (N))
and then
Is_Static_Expression (High_Bound (N));
end Is_Static_Range;
-----------------------
-- Is_Static_Subtype --
-----------------------
-- Determines if Typ is a static subtype as defined in (RM 4.9(26))
function Is_Static_Subtype (Typ : Entity_Id) return Boolean is
Base_T : constant Entity_Id := Base_Type (Typ);
Anc_Subt : Entity_Id;
begin
-- First a quick check on the non static subtype flag. As described
-- in further detail in Einfo, this flag is not decisive in all cases,
-- but if it is set, then the subtype is definitely non-static.
if Is_Non_Static_Subtype (Typ) then
return False;
end if;
Anc_Subt := Ancestor_Subtype (Typ);
if Anc_Subt = Empty then
Anc_Subt := Base_T;
end if;
if Is_Generic_Type (Root_Type (Base_T))
or else Is_Generic_Actual_Type (Base_T)
then
return False;
-- If there is a dynamic predicate for the type (declared or inherited)
-- the expression is not static.
elsif Has_Dynamic_Predicate_Aspect (Typ)
or else (Is_Derived_Type (Typ)
and then Has_Aspect (Typ, Aspect_Dynamic_Predicate))
then
return False;
-- String types
elsif Is_String_Type (Typ) then
return
Ekind (Typ) = E_String_Literal_Subtype
or else (Is_Static_Subtype (Component_Type (Typ))
and then Is_Static_Subtype (Etype (First_Index (Typ))));
-- Scalar types
elsif Is_Scalar_Type (Typ) then
if Base_T = Typ then
return True;
else
return Is_Static_Subtype (Anc_Subt)
and then Is_Static_Expression (Type_Low_Bound (Typ))
and then Is_Static_Expression (Type_High_Bound (Typ));
end if;
-- Types other than string and scalar types are never static
else
return False;
end if;
end Is_Static_Subtype;
-------------------------------
-- Is_Statically_Unevaluated --
-------------------------------
function Is_Statically_Unevaluated (Expr : Node_Id) return Boolean is
function Check_Case_Expr_Alternative
(CEA : Node_Id) return Match_Result;
-- We have a message emanating from the Expression of a case expression
-- alternative. We examine this alternative, as follows:
--
-- If the selecting expression of the parent case is non-static, or
-- if any of the discrete choices of the given case alternative are
-- non-static or raise Constraint_Error, return Non_Static.
--
-- Otherwise check if the selecting expression matches any of the given
-- discrete choices. If so, the alternative is executed and we return
-- Match, otherwise, the alternative can never be executed, and so we
-- return No_Match.
---------------------------------
-- Check_Case_Expr_Alternative --
---------------------------------
function Check_Case_Expr_Alternative
(CEA : Node_Id) return Match_Result
is
Case_Exp : constant Node_Id := Parent (CEA);
Choice : Node_Id;
Prev_CEA : Node_Id;
begin
pragma Assert (Nkind (Case_Exp) = N_Case_Expression);
-- Check that selecting expression is static
if not Is_OK_Static_Expression (Expression (Case_Exp)) then
return Non_Static;
end if;
if not Is_OK_Static_Choice_List (Discrete_Choices (CEA)) then
return Non_Static;
end if;
-- All choices are now known to be static. Now see if alternative
-- matches one of the choices.
Choice := First (Discrete_Choices (CEA));
while Present (Choice) loop
-- Check various possibilities for choice, returning Match if we
-- find the selecting value matches any of the choices. Note that
-- we know we are the last choice, so we don't have to keep going.
if Nkind (Choice) = N_Others_Choice then
-- Others choice is a bit annoying, it matches if none of the
-- previous alternatives matches (note that we know we are the
-- last alternative in this case, so we can just go backwards
-- from us to see if any previous one matches).
Prev_CEA := Prev (CEA);
while Present (Prev_CEA) loop
if Check_Case_Expr_Alternative (Prev_CEA) = Match then
return No_Match;
end if;
Prev (Prev_CEA);
end loop;
return Match;
-- Else we have a normal static choice
elsif Choice_Matches (Expression (Case_Exp), Choice) = Match then
return Match;
end if;
-- If we fall through, it means that the discrete choice did not
-- match the selecting expression, so continue.
Next (Choice);
end loop;
-- If we get through that loop then all choices were static, and none
-- of them matched the selecting expression. So return No_Match.
return No_Match;
end Check_Case_Expr_Alternative;
-- Local variables
P : Node_Id;
OldP : Node_Id;
Choice : Node_Id;
-- Start of processing for Is_Statically_Unevaluated
begin
-- The (32.x) references here are from RM section 4.9
-- (32.1) An expression is statically unevaluated if it is part of ...
-- This means we have to climb the tree looking for one of the cases
P := Expr;
loop
OldP := P;
P := Parent (P);
-- (32.2) The right operand of a static short-circuit control form
-- whose value is determined by its left operand.
-- AND THEN with False as left operand
if Nkind (P) = N_And_Then
and then Compile_Time_Known_Value (Left_Opnd (P))
and then Is_False (Expr_Value (Left_Opnd (P)))
then
return True;
-- OR ELSE with True as left operand
elsif Nkind (P) = N_Or_Else
and then Compile_Time_Known_Value (Left_Opnd (P))
and then Is_True (Expr_Value (Left_Opnd (P)))
then
return True;
-- (32.3) A dependent_expression of an if_expression whose associated
-- condition is static and equals False.
elsif Nkind (P) = N_If_Expression then
declare
Cond : constant Node_Id := First (Expressions (P));
Texp : constant Node_Id := Next (Cond);
Fexp : constant Node_Id := Next (Texp);
begin
if Compile_Time_Known_Value (Cond) then
-- Condition is True and we are in the right operand
if Is_True (Expr_Value (Cond)) and then OldP = Fexp then
return True;
-- Condition is False and we are in the left operand
elsif Is_False (Expr_Value (Cond)) and then OldP = Texp then
return True;
end if;
end if;
end;
-- (32.4) A condition or dependent_expression of an if_expression
-- where the condition corresponding to at least one preceding
-- dependent_expression of the if_expression is static and equals
-- True.
-- This refers to cases like
-- (if True then 1 elsif 1/0=2 then 2 else 3)
-- But we expand elsif's out anyway, so the above looks like:
-- (if True then 1 else (if 1/0=2 then 2 else 3))
-- So for us this is caught by the above check for the 32.3 case.
-- (32.5) A dependent_expression of a case_expression whose
-- selecting_expression is static and whose value is not covered
-- by the corresponding discrete_choice_list.
elsif Nkind (P) = N_Case_Expression_Alternative then
-- First, we have to be in the expression to suppress messages.
-- If we are within one of the choices, we want the message.
if OldP = Expression (P) then
-- Statically unevaluated if alternative does not match
if Check_Case_Expr_Alternative (P) = No_Match then
return True;
end if;
end if;
-- (32.6) A choice_expression (or a simple_expression of a range
-- that occurs as a membership_choice of a membership_choice_list)
-- of a static membership test that is preceded in the enclosing
-- membership_choice_list by another item whose individual
-- membership test (see (RM 4.5.2)) statically yields True.
elsif Nkind (P) in N_Membership_Test then
-- Only possibly unevaluated if simple expression is static
if not Is_OK_Static_Expression (Left_Opnd (P)) then
null;
-- All members of the choice list must be static
elsif (Present (Right_Opnd (P))
and then not Is_OK_Static_Choice (Right_Opnd (P)))
or else (Present (Alternatives (P))
and then
not Is_OK_Static_Choice_List (Alternatives (P)))
then
null;
-- If expression is the one and only alternative, then it is
-- definitely not statically unevaluated, so we only have to
-- test the case where there are alternatives present.
elsif Present (Alternatives (P)) then
-- Look for previous matching Choice
Choice := First (Alternatives (P));
while Present (Choice) loop
-- If we reached us and no previous choices matched, this
-- is not the case where we are statically unevaluated.
exit when OldP = Choice;
-- If a previous choice matches, then that is the case where
-- we know our choice is statically unevaluated.
if Choice_Matches (Left_Opnd (P), Choice) = Match then
return True;
end if;
Next (Choice);
end loop;
-- If we fall through the loop, we were not one of the choices,
-- we must have been the expression, so that is not covered by
-- this rule, and we keep going.
null;
end if;
end if;
-- OK, not statically unevaluated at this level, see if we should
-- keep climbing to look for a higher level reason.
-- Special case for component association in aggregates, where
-- we want to keep climbing up to the parent aggregate.
if Nkind (P) = N_Component_Association
and then Nkind (Parent (P)) = N_Aggregate
then
null;
-- All done if not still within subexpression
else
exit when Nkind (P) not in N_Subexpr;
end if;
end loop;
-- If we fall through the loop, not one of the cases covered!
return False;
end Is_Statically_Unevaluated;
--------------------
-- Not_Null_Range --
--------------------
function Not_Null_Range (Lo : Node_Id; Hi : Node_Id) return Boolean is
Typ : constant Entity_Id := Etype (Lo);
begin
if not Compile_Time_Known_Value (Lo)
or else not Compile_Time_Known_Value (Hi)
then
return False;
end if;
if Is_Discrete_Type (Typ) then
return Expr_Value (Lo) <= Expr_Value (Hi);
else pragma Assert (Is_Real_Type (Typ));
return Expr_Value_R (Lo) <= Expr_Value_R (Hi);
end if;
end Not_Null_Range;
-------------
-- OK_Bits --
-------------
function OK_Bits (N : Node_Id; Bits : Uint) return Boolean is
begin
-- We allow a maximum of 500,000 bits which seems a reasonable limit
if Bits < 500_000 then
return True;
-- Error if this maximum is exceeded
else
Error_Msg_N ("static value too large, capacity exceeded", N);
return False;
end if;
end OK_Bits;
------------------
-- Out_Of_Range --
------------------
procedure Out_Of_Range (N : Node_Id) is
begin
-- If we have the static expression case, then this is an illegality
-- in Ada 95 mode, except that in an instance, we never generate an
-- error (if the error is legitimate, it was already diagnosed in the
-- template).
if Is_Static_Expression (N)
and then not In_Instance
and then not In_Inlined_Body
and then Ada_Version >= Ada_95
then
-- No message if we are statically unevaluated
if Is_Statically_Unevaluated (N) then
null;
-- The expression to compute the length of a packed array is attached
-- to the array type itself, and deserves a separate message.
elsif Nkind (Parent (N)) = N_Defining_Identifier
and then Is_Array_Type (Parent (N))
and then Present (Packed_Array_Impl_Type (Parent (N)))
and then Present (First_Rep_Item (Parent (N)))
then
Error_Msg_N
("length of packed array must not exceed Integer''Last",
First_Rep_Item (Parent (N)));
Rewrite (N, Make_Integer_Literal (Sloc (N), Uint_1));
-- All cases except the special array case
else
Apply_Compile_Time_Constraint_Error
(N, "value not in range of}", CE_Range_Check_Failed);
end if;
-- Here we generate a warning for the Ada 83 case, or when we are in an
-- instance, or when we have a non-static expression case.
else
Apply_Compile_Time_Constraint_Error
(N, "value not in range of}??", CE_Range_Check_Failed);
end if;
end Out_Of_Range;
----------------------
-- Predicates_Match --
----------------------
function Predicates_Match (T1, T2 : Entity_Id) return Boolean is
Pred1 : Node_Id;
Pred2 : Node_Id;
begin
if Ada_Version < Ada_2012 then
return True;
-- Both types must have predicates or lack them
elsif Has_Predicates (T1) /= Has_Predicates (T2) then
return False;
-- Check matching predicates
else
Pred1 :=
Get_Rep_Item
(T1, Name_Static_Predicate, Check_Parents => False);
Pred2 :=
Get_Rep_Item
(T2, Name_Static_Predicate, Check_Parents => False);
-- Subtypes statically match if the predicate comes from the
-- same declaration, which can only happen if one is a subtype
-- of the other and has no explicit predicate.
-- Suppress warnings on order of actuals, which is otherwise
-- triggered by one of the two calls below.
pragma Warnings (Off);
return Pred1 = Pred2
or else (No (Pred1) and then Is_Subtype_Of (T1, T2))
or else (No (Pred2) and then Is_Subtype_Of (T2, T1));
pragma Warnings (On);
end if;
end Predicates_Match;
---------------------------------------------
-- Real_Or_String_Static_Predicate_Matches --
---------------------------------------------
function Real_Or_String_Static_Predicate_Matches
(Val : Node_Id;
Typ : Entity_Id) return Boolean
is
Expr : constant Node_Id := Static_Real_Or_String_Predicate (Typ);
-- The predicate expression from the type
Pfun : constant Entity_Id := Predicate_Function (Typ);
-- The entity for the predicate function
Ent_Name : constant Name_Id := Chars (First_Formal (Pfun));
-- The name of the formal of the predicate function. Occurrences of the
-- type name in Expr have been rewritten as references to this formal,
-- and it has a unique name, so we can identify references by this name.
Copy : Node_Id;
-- Copy of the predicate function tree
function Process (N : Node_Id) return Traverse_Result;
-- Function used to process nodes during the traversal in which we will
-- find occurrences of the entity name, and replace such occurrences
-- by a real literal with the value to be tested.
procedure Traverse is new Traverse_Proc (Process);
-- The actual traversal procedure
-------------
-- Process --
-------------
function Process (N : Node_Id) return Traverse_Result is
begin
if Nkind (N) = N_Identifier and then Chars (N) = Ent_Name then
declare
Nod : constant Node_Id := New_Copy (Val);
begin
Set_Sloc (Nod, Sloc (N));
Rewrite (N, Nod);
return Skip;
end;
-- The predicate function may contain string-comparison operations
-- that have been converted into calls to run-time array-comparison
-- routines. To evaluate the predicate statically, we recover the
-- original comparison operation and replace the occurrence of the
-- formal by the static string value. The actuals of the generated
-- call are of the form X'Address.
elsif Nkind (N) in N_Op_Compare
and then Nkind (Left_Opnd (N)) = N_Function_Call
then
declare
C : constant Node_Id := Left_Opnd (N);
F : constant Node_Id := First (Parameter_Associations (C));
L : constant Node_Id := Prefix (F);
R : constant Node_Id := Prefix (Next (F));
begin
-- If an operand is an entity name, it is the formal of the
-- predicate function, so replace it with the string value.
-- It may be either operand in the call. The other operand
-- is a static string from the original predicate.
if Is_Entity_Name (L) then
Rewrite (Left_Opnd (N), New_Copy (Val));
Rewrite (Right_Opnd (N), New_Copy (R));
else
Rewrite (Left_Opnd (N), New_Copy (L));
Rewrite (Right_Opnd (N), New_Copy (Val));
end if;
return Skip;
end;
else
return OK;
end if;
end Process;
-- Start of processing for Real_Or_String_Static_Predicate_Matches
begin
-- First deal with special case of inherited predicate, where the
-- predicate expression looks like:
-- xxPredicate (typ (Ent)) and then Expr
-- where Expr is the predicate expression for this level, and the
-- left operand is the call to evaluate the inherited predicate.
if Nkind (Expr) = N_And_Then
and then Nkind (Left_Opnd (Expr)) = N_Function_Call
and then Is_Predicate_Function (Entity (Name (Left_Opnd (Expr))))
then
-- OK we have the inherited case, so make a call to evaluate the
-- inherited predicate. If that fails, so do we!
if not
Real_Or_String_Static_Predicate_Matches
(Val => Val,
Typ => Etype (First_Formal (Entity (Name (Left_Opnd (Expr))))))
then
return False;
end if;
-- Use the right operand for the continued processing
Copy := Copy_Separate_Tree (Right_Opnd (Expr));
-- Case where call to predicate function appears on its own (this means
-- that the predicate at this level is just inherited from the parent).
elsif Nkind (Expr) = N_Function_Call then
declare
Typ : constant Entity_Id :=
Etype (First_Formal (Entity (Name (Expr))));
begin
-- If the inherited predicate is dynamic, just ignore it. We can't
-- go trying to evaluate a dynamic predicate as a static one!
if Has_Dynamic_Predicate_Aspect (Typ) then
return True;
-- Otherwise inherited predicate is static, check for match
else
return Real_Or_String_Static_Predicate_Matches (Val, Typ);
end if;
end;
-- If not just an inherited predicate, copy whole expression
else
Copy := Copy_Separate_Tree (Expr);
end if;
-- Now we replace occurrences of the entity by the value
Traverse (Copy);
-- And analyze the resulting static expression to see if it is True
Analyze_And_Resolve (Copy, Standard_Boolean);
return Is_True (Expr_Value (Copy));
end Real_Or_String_Static_Predicate_Matches;
-------------------------
-- Rewrite_In_Raise_CE --
-------------------------
procedure Rewrite_In_Raise_CE (N : Node_Id; Exp : Node_Id) is
Typ : constant Entity_Id := Etype (N);
Stat : constant Boolean := Is_Static_Expression (N);
begin
-- If we want to raise CE in the condition of a N_Raise_CE node, we
-- can just clear the condition if the reason is appropriate. We do
-- not do this operation if the parent has a reason other than range
-- check failed, because otherwise we would change the reason.
if Present (Parent (N))
and then Nkind (Parent (N)) = N_Raise_Constraint_Error
and then Reason (Parent (N)) =
UI_From_Int (RT_Exception_Code'Pos (CE_Range_Check_Failed))
then
Set_Condition (Parent (N), Empty);
-- Else build an explicit N_Raise_CE
else
Rewrite (N,
Make_Raise_Constraint_Error (Sloc (Exp),
Reason => CE_Range_Check_Failed));
Set_Raises_Constraint_Error (N);
Set_Etype (N, Typ);
end if;
-- Set proper flags in result
Set_Raises_Constraint_Error (N, True);
Set_Is_Static_Expression (N, Stat);
end Rewrite_In_Raise_CE;
---------------------
-- String_Type_Len --
---------------------
function String_Type_Len (Stype : Entity_Id) return Uint is
NT : constant Entity_Id := Etype (First_Index (Stype));
T : Entity_Id;
begin
if Is_OK_Static_Subtype (NT) then
T := NT;
else
T := Base_Type (NT);
end if;
return Expr_Value (Type_High_Bound (T)) -
Expr_Value (Type_Low_Bound (T)) + 1;
end String_Type_Len;
------------------------------------
-- Subtypes_Statically_Compatible --
------------------------------------
function Subtypes_Statically_Compatible
(T1 : Entity_Id;
T2 : Entity_Id;
Formal_Derived_Matching : Boolean := False) return Boolean
is
begin
-- Scalar types
if Is_Scalar_Type (T1) then
-- Definitely compatible if we match
if Subtypes_Statically_Match (T1, T2) then
return True;
-- If either subtype is nonstatic then they're not compatible
elsif not Is_OK_Static_Subtype (T1)
or else
not Is_OK_Static_Subtype (T2)
then
return False;
-- If either type has constraint error bounds, then consider that
-- they match to avoid junk cascaded errors here.
elsif not Is_OK_Static_Subtype (T1)
or else not Is_OK_Static_Subtype (T2)
then
return True;
-- Base types must match, but we don't check that (should we???) but
-- we do at least check that both types are real, or both types are
-- not real.
elsif Is_Real_Type (T1) /= Is_Real_Type (T2) then
return False;
-- Here we check the bounds
else
declare
LB1 : constant Node_Id := Type_Low_Bound (T1);
HB1 : constant Node_Id := Type_High_Bound (T1);
LB2 : constant Node_Id := Type_Low_Bound (T2);
HB2 : constant Node_Id := Type_High_Bound (T2);
begin
if Is_Real_Type (T1) then
return
(Expr_Value_R (LB1) > Expr_Value_R (HB1))
or else
(Expr_Value_R (LB2) <= Expr_Value_R (LB1)
and then
Expr_Value_R (HB1) <= Expr_Value_R (HB2));
else
return
(Expr_Value (LB1) > Expr_Value (HB1))
or else
(Expr_Value (LB2) <= Expr_Value (LB1)
and then
Expr_Value (HB1) <= Expr_Value (HB2));
end if;
end;
end if;
-- Access types
elsif Is_Access_Type (T1) then
return (not Is_Constrained (T2)
or else (Subtypes_Statically_Match
(Designated_Type (T1), Designated_Type (T2))))
and then not (Can_Never_Be_Null (T2)
and then not Can_Never_Be_Null (T1));
-- All other cases
else
return (Is_Composite_Type (T1) and then not Is_Constrained (T2))
or else Subtypes_Statically_Match (T1, T2, Formal_Derived_Matching);
end if;
end Subtypes_Statically_Compatible;
-------------------------------
-- Subtypes_Statically_Match --
-------------------------------
-- Subtypes statically match if they have statically matching constraints
-- (RM 4.9.1(2)). Constraints statically match if there are none, or if
-- they are the same identical constraint, or if they are static and the
-- values match (RM 4.9.1(1)).
-- In addition, in GNAT, the object size (Esize) values of the types must
-- match if they are set (unless checking an actual for a formal derived
-- type). The use of 'Object_Size can cause this to be false even if the
-- types would otherwise match in the RM sense.
function Subtypes_Statically_Match
(T1 : Entity_Id;
T2 : Entity_Id;
Formal_Derived_Matching : Boolean := False) return Boolean
is
begin
-- A type always statically matches itself
if T1 = T2 then
return True;
-- No match if sizes different (from use of 'Object_Size). This test
-- is excluded if Formal_Derived_Matching is True, as the base types
-- can be different in that case and typically have different sizes
-- (and Esizes can be set when Frontend_Layout_On_Target is True).
elsif not Formal_Derived_Matching
and then Known_Static_Esize (T1)
and then Known_Static_Esize (T2)
and then Esize (T1) /= Esize (T2)
then
return False;
-- No match if predicates do not match
elsif not Predicates_Match (T1, T2) then
return False;
-- Scalar types
elsif Is_Scalar_Type (T1) then
-- Base types must be the same
if Base_Type (T1) /= Base_Type (T2) then
return False;
end if;
-- A constrained numeric subtype never matches an unconstrained
-- subtype, i.e. both types must be constrained or unconstrained.
-- To understand the requirement for this test, see RM 4.9.1(1).
-- As is made clear in RM 3.5.4(11), type Integer, for example is
-- a constrained subtype with constraint bounds matching the bounds
-- of its corresponding unconstrained base type. In this situation,
-- Integer and Integer'Base do not statically match, even though
-- they have the same bounds.
-- We only apply this test to types in Standard and types that appear
-- in user programs. That way, we do not have to be too careful about
-- setting Is_Constrained right for Itypes.
if Is_Numeric_Type (T1)
and then (Is_Constrained (T1) /= Is_Constrained (T2))
and then (Scope (T1) = Standard_Standard
or else Comes_From_Source (T1))
and then (Scope (T2) = Standard_Standard
or else Comes_From_Source (T2))
then
return False;
-- A generic scalar type does not statically match its base type
-- (AI-311). In this case we make sure that the formals, which are
-- first subtypes of their bases, are constrained.
elsif Is_Generic_Type (T1)
and then Is_Generic_Type (T2)
and then (Is_Constrained (T1) /= Is_Constrained (T2))
then
return False;
end if;
-- If there was an error in either range, then just assume the types
-- statically match to avoid further junk errors.
if No (Scalar_Range (T1)) or else No (Scalar_Range (T2))
or else Error_Posted (Scalar_Range (T1))
or else Error_Posted (Scalar_Range (T2))
then
return True;
end if;
-- Otherwise both types have bounds that can be compared
declare
LB1 : constant Node_Id := Type_Low_Bound (T1);
HB1 : constant Node_Id := Type_High_Bound (T1);
LB2 : constant Node_Id := Type_Low_Bound (T2);
HB2 : constant Node_Id := Type_High_Bound (T2);
begin
-- If the bounds are the same tree node, then match (common case)
if LB1 = LB2 and then HB1 = HB2 then
return True;
-- Otherwise bounds must be static and identical value
else
if not Is_OK_Static_Subtype (T1)
or else not Is_OK_Static_Subtype (T2)
then
return False;
-- If either type has constraint error bounds, then say that
-- they match to avoid junk cascaded errors here.
elsif not Is_OK_Static_Subtype (T1)
or else not Is_OK_Static_Subtype (T2)
then
return True;
elsif Is_Real_Type (T1) then
return
(Expr_Value_R (LB1) = Expr_Value_R (LB2))
and then
(Expr_Value_R (HB1) = Expr_Value_R (HB2));
else
return
Expr_Value (LB1) = Expr_Value (LB2)
and then
Expr_Value (HB1) = Expr_Value (HB2);
end if;
end if;
end;
-- Type with discriminants
elsif Has_Discriminants (T1) or else Has_Discriminants (T2) then
-- Because of view exchanges in multiple instantiations, conformance
-- checking might try to match a partial view of a type with no
-- discriminants with a full view that has defaulted discriminants.
-- In such a case, use the discriminant constraint of the full view,
-- which must exist because we know that the two subtypes have the
-- same base type.
if Has_Discriminants (T1) /= Has_Discriminants (T2) then
-- A generic actual type is declared through a subtype declaration
-- and may have an inconsistent indication of the presence of
-- discriminants, so check the type it renames.
if Is_Generic_Actual_Type (T1)
and then not Has_Discriminants (Etype (T1))
and then not Has_Discriminants (T2)
then
return True;
elsif In_Instance then
if Is_Private_Type (T2)
and then Present (Full_View (T2))
and then Has_Discriminants (Full_View (T2))
then
return Subtypes_Statically_Match (T1, Full_View (T2));
elsif Is_Private_Type (T1)
and then Present (Full_View (T1))
and then Has_Discriminants (Full_View (T1))
then
return Subtypes_Statically_Match (Full_View (T1), T2);
else
return False;
end if;
else
return False;
end if;
end if;
declare
DL1 : constant Elist_Id := Discriminant_Constraint (T1);
DL2 : constant Elist_Id := Discriminant_Constraint (T2);
DA1 : Elmt_Id;
DA2 : Elmt_Id;
begin
if DL1 = DL2 then
return True;
elsif Is_Constrained (T1) /= Is_Constrained (T2) then
return False;
end if;
-- Now loop through the discriminant constraints
-- Note: the guard here seems necessary, since it is possible at
-- least for DL1 to be No_Elist. Not clear this is reasonable ???
if Present (DL1) and then Present (DL2) then
DA1 := First_Elmt (DL1);
DA2 := First_Elmt (DL2);
while Present (DA1) loop
declare
Expr1 : constant Node_Id := Node (DA1);
Expr2 : constant Node_Id := Node (DA2);
begin
if not Is_OK_Static_Expression (Expr1)
or else not Is_OK_Static_Expression (Expr2)
then
return False;
-- If either expression raised a constraint error,
-- consider the expressions as matching, since this
-- helps to prevent cascading errors.
elsif Raises_Constraint_Error (Expr1)
or else Raises_Constraint_Error (Expr2)
then
null;
elsif Expr_Value (Expr1) /= Expr_Value (Expr2) then
return False;
end if;
end;
Next_Elmt (DA1);
Next_Elmt (DA2);
end loop;
end if;
end;
return True;
-- A definite type does not match an indefinite or classwide type.
-- However, a generic type with unknown discriminants may be
-- instantiated with a type with no discriminants, and conformance
-- checking on an inherited operation may compare the actual with the
-- subtype that renames it in the instance.
elsif Has_Unknown_Discriminants (T1) /= Has_Unknown_Discriminants (T2)
then
return
Is_Generic_Actual_Type (T1) or else Is_Generic_Actual_Type (T2);
-- Array type
elsif Is_Array_Type (T1) then
-- If either subtype is unconstrained then both must be, and if both
-- are unconstrained then no further checking is needed.
if not Is_Constrained (T1) or else not Is_Constrained (T2) then
return not (Is_Constrained (T1) or else Is_Constrained (T2));
end if;
-- Both subtypes are constrained, so check that the index subtypes
-- statically match.
declare
Index1 : Node_Id := First_Index (T1);
Index2 : Node_Id := First_Index (T2);
begin
while Present (Index1) loop
if not
Subtypes_Statically_Match (Etype (Index1), Etype (Index2))
then
return False;
end if;
Next_Index (Index1);
Next_Index (Index2);
end loop;
return True;
end;
elsif Is_Access_Type (T1) then
if Can_Never_Be_Null (T1) /= Can_Never_Be_Null (T2) then
return False;
elsif Ekind_In (T1, E_Access_Subprogram_Type,
E_Anonymous_Access_Subprogram_Type)
then
return
Subtype_Conformant
(Designated_Type (T1),
Designated_Type (T2));
else
return
Subtypes_Statically_Match
(Designated_Type (T1),
Designated_Type (T2))
and then Is_Access_Constant (T1) = Is_Access_Constant (T2);
end if;
-- All other types definitely match
else
return True;
end if;
end Subtypes_Statically_Match;
----------
-- Test --
----------
function Test (Cond : Boolean) return Uint is
begin
if Cond then
return Uint_1;
else
return Uint_0;
end if;
end Test;
---------------------
-- Test_Comparison --
---------------------
procedure Test_Comparison
(Op : Node_Id;
Assume_Valid : Boolean;
True_Result : out Boolean;
False_Result : out Boolean)
is
Left : constant Node_Id := Left_Opnd (Op);
Left_Typ : constant Entity_Id := Etype (Left);
Orig_Op : constant Node_Id := Original_Node (Op);
procedure Replacement_Warning (Msg : String);
-- Emit a warning on a comparison that can be replaced by '='
-------------------------
-- Replacement_Warning --
-------------------------
procedure Replacement_Warning (Msg : String) is
begin
if Constant_Condition_Warnings
and then Comes_From_Source (Orig_Op)
and then Is_Integer_Type (Left_Typ)
and then not Error_Posted (Op)
and then not Has_Warnings_Off (Left_Typ)
and then not In_Instance
then
Error_Msg_N (Msg, Op);
end if;
end Replacement_Warning;
-- Local variables
Res : constant Compare_Result :=
Compile_Time_Compare (Left, Right_Opnd (Op), Assume_Valid);
-- Start of processing for Test_Comparison
begin
case N_Op_Compare (Nkind (Op)) is
when N_Op_Eq =>
True_Result := Res = EQ;
False_Result := Res = LT or else Res = GT or else Res = NE;
when N_Op_Ge =>
True_Result := Res in Compare_GE;
False_Result := Res = LT;
if Res = LE and then Nkind (Orig_Op) = N_Op_Ge then
Replacement_Warning
("can never be greater than, could replace by ""'=""?c?");
end if;
when N_Op_Gt =>
True_Result := Res = GT;
False_Result := Res in Compare_LE;
when N_Op_Le =>
True_Result := Res in Compare_LE;
False_Result := Res = GT;
if Res = GE and then Nkind (Orig_Op) = N_Op_Le then
Replacement_Warning
("can never be less than, could replace by ""'=""?c?");
end if;
when N_Op_Lt =>
True_Result := Res = LT;
False_Result := Res in Compare_GE;
when N_Op_Ne =>
True_Result := Res = NE or else Res = GT or else Res = LT;
False_Result := Res = EQ;
end case;
end Test_Comparison;
---------------------------------
-- Test_Expression_Is_Foldable --
---------------------------------
-- One operand case
procedure Test_Expression_Is_Foldable
(N : Node_Id;
Op1 : Node_Id;
Stat : out Boolean;
Fold : out Boolean)
is
begin
Stat := False;
Fold := False;
if Debug_Flag_Dot_F and then In_Extended_Main_Source_Unit (N) then
return;
end if;
-- If operand is Any_Type, just propagate to result and do not
-- try to fold, this prevents cascaded errors.
if Etype (Op1) = Any_Type then
Set_Etype (N, Any_Type);
return;
-- If operand raises constraint error, then replace node N with the
-- raise constraint error node, and we are obviously not foldable.
-- Note that this replacement inherits the Is_Static_Expression flag
-- from the operand.
elsif Raises_Constraint_Error (Op1) then
Rewrite_In_Raise_CE (N, Op1);
return;
-- If the operand is not static, then the result is not static, and
-- all we have to do is to check the operand since it is now known
-- to appear in a non-static context.
elsif not Is_Static_Expression (Op1) then
Check_Non_Static_Context (Op1);
Fold := Compile_Time_Known_Value (Op1);
return;
-- An expression of a formal modular type is not foldable because
-- the modulus is unknown.
elsif Is_Modular_Integer_Type (Etype (Op1))
and then Is_Generic_Type (Etype (Op1))
then
Check_Non_Static_Context (Op1);
return;
-- Here we have the case of an operand whose type is OK, which is
-- static, and which does not raise constraint error, we can fold.
else
Set_Is_Static_Expression (N);
Fold := True;
Stat := True;
end if;
end Test_Expression_Is_Foldable;
-- Two operand case
procedure Test_Expression_Is_Foldable
(N : Node_Id;
Op1 : Node_Id;
Op2 : Node_Id;
Stat : out Boolean;
Fold : out Boolean;
CRT_Safe : Boolean := False)
is
Rstat : constant Boolean := Is_Static_Expression (Op1)
and then
Is_Static_Expression (Op2);
begin
Stat := False;
Fold := False;
-- Inhibit folding if -gnatd.f flag set
if Debug_Flag_Dot_F and then In_Extended_Main_Source_Unit (N) then
return;
end if;
-- If either operand is Any_Type, just propagate to result and
-- do not try to fold, this prevents cascaded errors.
if Etype (Op1) = Any_Type or else Etype (Op2) = Any_Type then
Set_Etype (N, Any_Type);
return;
-- If left operand raises constraint error, then replace node N with the
-- Raise_Constraint_Error node, and we are obviously not foldable.
-- Is_Static_Expression is set from the two operands in the normal way,
-- and we check the right operand if it is in a non-static context.
elsif Raises_Constraint_Error (Op1) then
if not Rstat then
Check_Non_Static_Context (Op2);
end if;
Rewrite_In_Raise_CE (N, Op1);
Set_Is_Static_Expression (N, Rstat);
return;
-- Similar processing for the case of the right operand. Note that we
-- don't use this routine for the short-circuit case, so we do not have
-- to worry about that special case here.
elsif Raises_Constraint_Error (Op2) then
if not Rstat then
Check_Non_Static_Context (Op1);
end if;
Rewrite_In_Raise_CE (N, Op2);
Set_Is_Static_Expression (N, Rstat);
return;
-- Exclude expressions of a generic modular type, as above
elsif Is_Modular_Integer_Type (Etype (Op1))
and then Is_Generic_Type (Etype (Op1))
then
Check_Non_Static_Context (Op1);
return;
-- If result is not static, then check non-static contexts on operands
-- since one of them may be static and the other one may not be static.
elsif not Rstat then
Check_Non_Static_Context (Op1);
Check_Non_Static_Context (Op2);
if CRT_Safe then
Fold := CRT_Safe_Compile_Time_Known_Value (Op1)
and then CRT_Safe_Compile_Time_Known_Value (Op2);
else
Fold := Compile_Time_Known_Value (Op1)
and then Compile_Time_Known_Value (Op2);
end if;
return;
-- Else result is static and foldable. Both operands are static, and
-- neither raises constraint error, so we can definitely fold.
else
Set_Is_Static_Expression (N);
Fold := True;
Stat := True;
return;
end if;
end Test_Expression_Is_Foldable;
-------------------
-- Test_In_Range --
-------------------
function Test_In_Range
(N : Node_Id;
Typ : Entity_Id;
Assume_Valid : Boolean;
Fixed_Int : Boolean;
Int_Real : Boolean) return Range_Membership
is
Val : Uint;
Valr : Ureal;
pragma Warnings (Off, Assume_Valid);
-- For now Assume_Valid is unreferenced since the current implementation
-- always returns Unknown if N is not a compile time known value, but we
-- keep the parameter to allow for future enhancements in which we try
-- to get the information in the variable case as well.
begin
-- If an error was posted on expression, then return Unknown, we do not
-- want cascaded errors based on some false analysis of a junk node.
if Error_Posted (N) then
return Unknown;
-- Expression that raises constraint error is an odd case. We certainly
-- do not want to consider it to be in range. It might make sense to
-- consider it always out of range, but this causes incorrect error
-- messages about static expressions out of range. So we just return
-- Unknown, which is always safe.
elsif Raises_Constraint_Error (N) then
return Unknown;
-- Universal types have no range limits, so always in range
elsif Typ = Universal_Integer or else Typ = Universal_Real then
return In_Range;
-- Never known if not scalar type. Don't know if this can actually
-- happen, but our spec allows it, so we must check.
elsif not Is_Scalar_Type (Typ) then
return Unknown;
-- Never known if this is a generic type, since the bounds of generic
-- types are junk. Note that if we only checked for static expressions
-- (instead of compile time known values) below, we would not need this
-- check, because values of a generic type can never be static, but they
-- can be known at compile time.
elsif Is_Generic_Type (Typ) then
return Unknown;
-- Case of a known compile time value, where we can check if it is in
-- the bounds of the given type.
elsif Compile_Time_Known_Value (N) then
declare
Lo : Node_Id;
Hi : Node_Id;
LB_Known : Boolean;
HB_Known : Boolean;
begin
Lo := Type_Low_Bound (Typ);
Hi := Type_High_Bound (Typ);
LB_Known := Compile_Time_Known_Value (Lo);
HB_Known := Compile_Time_Known_Value (Hi);
-- Fixed point types should be considered as such only if flag
-- Fixed_Int is set to False.
if Is_Floating_Point_Type (Typ)
or else (Is_Fixed_Point_Type (Typ) and then not Fixed_Int)
or else Int_Real
then
Valr := Expr_Value_R (N);
if LB_Known and HB_Known then
if Valr >= Expr_Value_R (Lo)
and then
Valr <= Expr_Value_R (Hi)
then
return In_Range;
else
return Out_Of_Range;
end if;
elsif (LB_Known and then Valr < Expr_Value_R (Lo))
or else
(HB_Known and then Valr > Expr_Value_R (Hi))
then
return Out_Of_Range;
else
return Unknown;
end if;
else
Val := Expr_Value (N);
if LB_Known and HB_Known then
if Val >= Expr_Value (Lo) and then Val <= Expr_Value (Hi)
then
return In_Range;
else
return Out_Of_Range;
end if;
elsif (LB_Known and then Val < Expr_Value (Lo))
or else
(HB_Known and then Val > Expr_Value (Hi))
then
return Out_Of_Range;
else
return Unknown;
end if;
end if;
end;
-- Here for value not known at compile time. Case of expression subtype
-- is Typ or is a subtype of Typ, and we can assume expression is valid.
-- In this case we know it is in range without knowing its value.
elsif Assume_Valid
and then (Etype (N) = Typ or else Is_Subtype_Of (Etype (N), Typ))
then
return In_Range;
-- Another special case. For signed integer types, if the target type
-- has Is_Known_Valid set, and the source type does not have a larger
-- size, then the source value must be in range. We exclude biased
-- types, because they bizarrely can generate out of range values.
elsif Is_Signed_Integer_Type (Etype (N))
and then Is_Known_Valid (Typ)
and then Esize (Etype (N)) <= Esize (Typ)
and then not Has_Biased_Representation (Etype (N))
then
return In_Range;
-- For all other cases, result is unknown
else
return Unknown;
end if;
end Test_In_Range;
--------------
-- To_Bits --
--------------
procedure To_Bits (U : Uint; B : out Bits) is
begin
for J in 0 .. B'Last loop
B (J) := (U / (2 ** J)) mod 2 /= 0;
end loop;
end To_Bits;
--------------------
-- Why_Not_Static --
--------------------
procedure Why_Not_Static (Expr : Node_Id) is
N : constant Node_Id := Original_Node (Expr);
Typ : Entity_Id;
E : Entity_Id;
Alt : Node_Id;
Exp : Node_Id;
procedure Why_Not_Static_List (L : List_Id);
-- A version that can be called on a list of expressions. Finds all
-- non-static violations in any element of the list.
-------------------------
-- Why_Not_Static_List --
-------------------------
procedure Why_Not_Static_List (L : List_Id) is
N : Node_Id;
begin
if Is_Non_Empty_List (L) then
N := First (L);
while Present (N) loop
Why_Not_Static (N);
Next (N);
end loop;
end if;
end Why_Not_Static_List;
-- Start of processing for Why_Not_Static
begin
-- Ignore call on error or empty node
if No (Expr) or else Nkind (Expr) = N_Error then
return;
end if;
-- Preprocessing for sub expressions
if Nkind (Expr) in N_Subexpr then
-- Nothing to do if expression is static
if Is_OK_Static_Expression (Expr) then
return;
end if;
-- Test for constraint error raised
if Raises_Constraint_Error (Expr) then
-- Special case membership to find out which piece to flag
if Nkind (N) in N_Membership_Test then
if Raises_Constraint_Error (Left_Opnd (N)) then
Why_Not_Static (Left_Opnd (N));
return;
elsif Present (Right_Opnd (N))
and then Raises_Constraint_Error (Right_Opnd (N))
then
Why_Not_Static (Right_Opnd (N));
return;
else
pragma Assert (Present (Alternatives (N)));
Alt := First (Alternatives (N));
while Present (Alt) loop
if Raises_Constraint_Error (Alt) then
Why_Not_Static (Alt);
return;
else
Next (Alt);
end if;
end loop;
end if;
-- Special case a range to find out which bound to flag
elsif Nkind (N) = N_Range then
if Raises_Constraint_Error (Low_Bound (N)) then
Why_Not_Static (Low_Bound (N));
return;
elsif Raises_Constraint_Error (High_Bound (N)) then
Why_Not_Static (High_Bound (N));
return;
end if;
-- Special case attribute to see which part to flag
elsif Nkind (N) = N_Attribute_Reference then
if Raises_Constraint_Error (Prefix (N)) then
Why_Not_Static (Prefix (N));
return;
end if;
if Present (Expressions (N)) then
Exp := First (Expressions (N));
while Present (Exp) loop
if Raises_Constraint_Error (Exp) then
Why_Not_Static (Exp);
return;
end if;
Next (Exp);
end loop;
end if;
-- Special case a subtype name
elsif Is_Entity_Name (Expr) and then Is_Type (Entity (Expr)) then
Error_Msg_NE
("!& is not a static subtype (RM 4.9(26))", N, Entity (Expr));
return;
end if;
-- End of special cases
Error_Msg_N
("!expression raises exception, cannot be static (RM 4.9(34))",
N);
return;
end if;
-- If no type, then something is pretty wrong, so ignore
Typ := Etype (Expr);
if No (Typ) then
return;
end if;
-- Type must be scalar or string type (but allow Bignum, since this
-- is really a scalar type from our point of view in this diagnosis).
if not Is_Scalar_Type (Typ)
and then not Is_String_Type (Typ)
and then not Is_RTE (Typ, RE_Bignum)
then
Error_Msg_N
("!static expression must have scalar or string type " &
"(RM 4.9(2))", N);
return;
end if;
end if;
-- If we got through those checks, test particular node kind
case Nkind (N) is
-- Entity name
when N_Expanded_Name
| N_Identifier
| N_Operator_Symbol
=>
E := Entity (N);
if Is_Named_Number (E) then
null;
elsif Ekind (E) = E_Constant then
-- One case we can give a metter message is when we have a
-- string literal created by concatenating an aggregate with
-- an others expression.
Entity_Case : declare
CV : constant Node_Id := Constant_Value (E);
CO : constant Node_Id := Original_Node (CV);
function Is_Aggregate (N : Node_Id) return Boolean;
-- See if node N came from an others aggregate, if so
-- return True and set Error_Msg_Sloc to aggregate.
------------------
-- Is_Aggregate --
------------------
function Is_Aggregate (N : Node_Id) return Boolean is
begin
if Nkind (Original_Node (N)) = N_Aggregate then
Error_Msg_Sloc := Sloc (Original_Node (N));
return True;
elsif Is_Entity_Name (N)
and then Ekind (Entity (N)) = E_Constant
and then
Nkind (Original_Node (Constant_Value (Entity (N)))) =
N_Aggregate
then
Error_Msg_Sloc :=
Sloc (Original_Node (Constant_Value (Entity (N))));
return True;
else
return False;
end if;
end Is_Aggregate;
-- Start of processing for Entity_Case
begin
if Is_Aggregate (CV)
or else (Nkind (CO) = N_Op_Concat
and then (Is_Aggregate (Left_Opnd (CO))
or else
Is_Aggregate (Right_Opnd (CO))))
then
Error_Msg_N ("!aggregate (#) is never static", N);
elsif No (CV) or else not Is_Static_Expression (CV) then
Error_Msg_NE
("!& is not a static constant (RM 4.9(5))", N, E);
end if;
end Entity_Case;
elsif Is_Type (E) then
Error_Msg_NE
("!& is not a static subtype (RM 4.9(26))", N, E);
else
Error_Msg_NE
("!& is not static constant or named number "
& "(RM 4.9(5))", N, E);
end if;
-- Binary operator
when N_Binary_Op
| N_Membership_Test
| N_Short_Circuit
=>
if Nkind (N) in N_Op_Shift then
Error_Msg_N
("!shift functions are never static (RM 4.9(6,18))", N);
else
Why_Not_Static (Left_Opnd (N));
Why_Not_Static (Right_Opnd (N));
end if;
-- Unary operator
when N_Unary_Op =>
Why_Not_Static (Right_Opnd (N));
-- Attribute reference
when N_Attribute_Reference =>
Why_Not_Static_List (Expressions (N));
E := Etype (Prefix (N));
if E = Standard_Void_Type then
return;
end if;
-- Special case non-scalar'Size since this is a common error
if Attribute_Name (N) = Name_Size then
Error_Msg_N
("!size attribute is only static for static scalar type "
& "(RM 4.9(7,8))", N);
-- Flag array cases
elsif Is_Array_Type (E) then
if not Nam_In (Attribute_Name (N), Name_First,
Name_Last,
Name_Length)
then
Error_Msg_N
("!static array attribute must be Length, First, or Last "
& "(RM 4.9(8))", N);
-- Since we know the expression is not-static (we already
-- tested for this, must mean array is not static).
else
Error_Msg_N
("!prefix is non-static array (RM 4.9(8))", Prefix (N));
end if;
return;
-- Special case generic types, since again this is a common source
-- of confusion.
elsif Is_Generic_Actual_Type (E) or else Is_Generic_Type (E) then
Error_Msg_N
("!attribute of generic type is never static "
& "(RM 4.9(7,8))", N);
elsif Is_OK_Static_Subtype (E) then
null;
elsif Is_Scalar_Type (E) then
Error_Msg_N
("!prefix type for attribute is not static scalar subtype "
& "(RM 4.9(7))", N);
else
Error_Msg_N
("!static attribute must apply to array/scalar type "
& "(RM 4.9(7,8))", N);
end if;
-- String literal
when N_String_Literal =>
Error_Msg_N
("!subtype of string literal is non-static (RM 4.9(4))", N);
-- Explicit dereference
when N_Explicit_Dereference =>
Error_Msg_N
("!explicit dereference is never static (RM 4.9)", N);
-- Function call
when N_Function_Call =>
Why_Not_Static_List (Parameter_Associations (N));
-- Complain about non-static function call unless we have Bignum
-- which means that the underlying expression is really some
-- scalar arithmetic operation.
if not Is_RTE (Typ, RE_Bignum) then
Error_Msg_N ("!non-static function call (RM 4.9(6,18))", N);
end if;
-- Parameter assocation (test actual parameter)
when N_Parameter_Association =>
Why_Not_Static (Explicit_Actual_Parameter (N));
-- Indexed component
when N_Indexed_Component =>
Error_Msg_N ("!indexed component is never static (RM 4.9)", N);
-- Procedure call
when N_Procedure_Call_Statement =>
Error_Msg_N ("!procedure call is never static (RM 4.9)", N);
-- Qualified expression (test expression)
when N_Qualified_Expression =>
Why_Not_Static (Expression (N));
-- Aggregate
when N_Aggregate
| N_Extension_Aggregate
=>
Error_Msg_N ("!an aggregate is never static (RM 4.9)", N);
-- Range
when N_Range =>
Why_Not_Static (Low_Bound (N));
Why_Not_Static (High_Bound (N));
-- Range constraint, test range expression
when N_Range_Constraint =>
Why_Not_Static (Range_Expression (N));
-- Subtype indication, test constraint
when N_Subtype_Indication =>
Why_Not_Static (Constraint (N));
-- Selected component
when N_Selected_Component =>
Error_Msg_N ("!selected component is never static (RM 4.9)", N);
-- Slice
when N_Slice =>
Error_Msg_N ("!slice is never static (RM 4.9)", N);
when N_Type_Conversion =>
Why_Not_Static (Expression (N));
if not Is_Scalar_Type (Entity (Subtype_Mark (N)))
or else not Is_OK_Static_Subtype (Entity (Subtype_Mark (N)))
then
Error_Msg_N
("!static conversion requires static scalar subtype result "
& "(RM 4.9(9))", N);
end if;
-- Unchecked type conversion
when N_Unchecked_Type_Conversion =>
Error_Msg_N
("!unchecked type conversion is never static (RM 4.9)", N);
-- All other cases, no reason to give
when others =>
null;
end case;
end Why_Not_Static;
end Sem_Eval;
|
reznikmm/matreshka | Ada | 4,251 | ads | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2017, 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$
------------------------------------------------------------------------------
-- Generic slot with one parameter.
------------------------------------------------------------------------------
generic
type Parameter_2_Type (<>) is limited private;
package Core.Connectables.Slots_0.Slots_1.Slots_2 is
pragma Preelaborate;
type Slot (<>) is abstract tagged limited private;
type Signal is limited interface and Slots_1.Signal;
not overriding procedure Connect
(Self : in out Signal;
Slot : Slots_2.Slot'Class) is abstract;
private
type Slot_End_2 is abstract new Slot_End_Base with null record;
not overriding procedure Invoke
(Self : in out Slot_End_2;
Parameter_1 : Parameter_1_Type;
Parameter_2 : Parameter_2_Type) is abstract;
type Slot is abstract tagged limited null record;
not overriding function Create_Slot_End
(Self : Slot) return not null Slot_End_Access;
end Core.Connectables.Slots_0.Slots_1.Slots_2;
|
reznikmm/matreshka | Ada | 3,739 | 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.Style_Vertical_Align_Attributes is
pragma Preelaborate;
type ODF_Style_Vertical_Align_Attribute is limited interface
and XML.DOM.Attributes.DOM_Attribute;
type ODF_Style_Vertical_Align_Attribute_Access is
access all ODF_Style_Vertical_Align_Attribute'Class
with Storage_Size => 0;
end ODF.DOM.Style_Vertical_Align_Attributes;
|
reznikmm/matreshka | Ada | 7,174 | adb | ------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012-2017, 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.Internals.Strings.Configuration;
with Matreshka.Internals.Unicode.Characters.Latin;
with Matreshka.Internals.Utf16;
package body Matreshka.Internals.Text_Codecs.ASCII is
use Matreshka.Internals.Strings.Configuration;
use Matreshka.Internals.Unicode.Characters.Latin;
use type Matreshka.Internals.Utf16.Utf16_String_Index;
-------------------
-- Decode_Append --
-------------------
overriding procedure Decode_Append
(Self : in out ASCII_Decoder;
Data : Ada.Streams.Stream_Element_Array;
String : in out Matreshka.Internals.Strings.Shared_String_Access) is
begin
Matreshka.Internals.Strings.Mutate (String, String.Unused + Data'Length);
for J in Data'Range loop
if Data (J) in 16#00# .. 16#7F# then
Self.Unchecked_Append
(Self,
String,
Matreshka.Internals.Unicode.Code_Point (Data (J)));
else
Self.Error := True;
exit;
end if;
end loop;
String_Handler.Fill_Null_Terminator (String);
end Decode_Append;
-------------
-- Decoder --
-------------
function Decoder (Mode : Decoder_Mode) return Abstract_Decoder'Class is
begin
case Mode is
when Raw =>
return
ASCII_Decoder'
(Skip_LF => False,
Unchecked_Append => Unchecked_Append_Raw'Access,
Error => False);
when XML_1_0 =>
return
ASCII_Decoder'
(Skip_LF => False,
Unchecked_Append => Unchecked_Append_XML10'Access,
Error => False);
when XML_1_1 =>
return
ASCII_Decoder'
(Skip_LF => False,
Unchecked_Append => Unchecked_Append_XML11'Access,
Error => False);
end case;
end Decoder;
------------
-- Encode --
------------
overriding procedure Encode
(Self : in out ASCII_Encoder;
String : not null Matreshka.Internals.Strings.Shared_String_Access;
Buffer : out MISEV.Shared_Stream_Element_Vector_Access)
is
pragma Unreferenced (Self);
use Matreshka.Internals.Stream_Element_Vectors;
use Ada.Streams;
Code : Matreshka.Internals.Unicode.Code_Point;
Position : Matreshka.Internals.Utf16.Utf16_String_Index := 0;
Element : Ada.Streams.Stream_Element;
begin
null;
if String.Unused = 0 then
Buffer := Empty_Shared_Stream_Element_Vector'Access;
else
Buffer :=
Allocate (Ada.Streams.Stream_Element_Offset (String.Unused));
while Position < String.Unused loop
Matreshka.Internals.Utf16.Unchecked_Next
(String.Value, Position, Code);
if Code in 16#0000# .. 16#007F# then
-- Direct mapping.
Element := Stream_Element (Code);
else
Element := Question_Mark;
end if;
Buffer.Value (Buffer.Length) := Element;
Buffer.Length := Buffer.Length + 1;
end loop;
end if;
end Encode;
-------------
-- Encoder --
-------------
function Encoder return Abstract_Encoder'Class is
begin
return ASCII_Encoder'(null record);
end Encoder;
--------------
-- Is_Error --
--------------
overriding function Is_Error (Self : ASCII_Decoder) return Boolean is
begin
return Self.Error;
end Is_Error;
-------------------
-- Is_Mailformed --
-------------------
overriding function Is_Mailformed (Self : ASCII_Decoder) return Boolean is
begin
return Self.Error;
end Is_Mailformed;
end Matreshka.Internals.Text_Codecs.ASCII;
|
ekoeppen/STM32_Generic_Ada_Drivers | Ada | 870 | ads | with STM32_SVD.Interrupts; use STM32_SVD.Interrupts;
with STM32_SVD.EXTI;
package STM32GD.EXTI.IRQ is
protected IRQ_Handler is
entry Wait;
procedure Cancel;
function Status (Line : External_Line_Number) return Boolean;
procedure Reset_Status (Line : External_Line_Number);
procedure Handler;
pragma Attach_Handler (Handler, EXTI0);
pragma Attach_Handler (Handler, EXTI1);
pragma Attach_Handler (Handler, EXTI2_TSC);
pragma Attach_Handler (Handler, EXTI3);
pragma Attach_Handler (Handler, EXTI4);
pragma Attach_Handler (Handler, EXTI9_5);
pragma Attach_Handler (Handler, EXTI15_10);
private
EXTI_Status_1 : STM32_SVD.EXTI.PR1_Register;
EXTI_Status_2 : STM32_SVD.EXTI.PR2_Register;
Cancelled : Boolean;
Triggered : Boolean;
end IRQ_Handler;
end STM32GD.EXTI.IRQ;
|
tum-ei-rcs/StratoX | Ada | 2,464 | adb | -- Institution: Technische Universität München
-- Department: Realtime Computer Systems (RCS)
-- Project: StratoX
--
-- Authors: Emanuel Regnath ([email protected])
with STM32.Device;
with HIL.Config;
-- @summary
-- Target-specific mapping for HIL of Clock
package body HIL.Clock with
SPARK_Mode => Off
is
procedure configure is
begin
-- GPIOs
STM32.Device.Enable_Clock(STM32.Device.GPIO_A );
STM32.Device.Enable_Clock(STM32.Device.GPIO_B);
STM32.Device.Enable_Clock(STM32.Device.GPIO_C);
STM32.Device.Enable_Clock(STM32.Device.GPIO_D);
STM32.Device.Enable_Clock(STM32.Device.GPIO_E);
-- SPI
STM32.Device.Enable_Clock(STM32.Device.SPI_1);
-- I2C
STM32.Device.Enable_Clock( STM32.Device.I2C_1 ); -- I2C
-- UART (UART3 is Ser2 is Telemtrie2)
STM32.Device.Enable_Clock( STM32.Device.USART_3 );
STM32.Device.Enable_Clock( STM32.Device.UART_4 ); -- GPS
STM32.Device.Enable_Clock( STM32.Device.USART_6 ); -- PX4IO
STM32.Device.Enable_Clock( STM32.Device.USART_7 ); -- SER 5
-- Timers
case HIL.Config.BUZZER_PORT is
when HIL.Config.BUZZER_USE_AUX5 =>
STM32.Device.Enable_Clock (STM32.Device.Timer_4); -- AUX buzzer
STM32.Device.Reset (STM32.Device.Timer_4); -- without this not reliable
when HIL.Config.BUZZER_USE_PORT =>
STM32.Device.Enable_Clock (STM32.Device.Timer_2); -- regular buzzer port
STM32.Device.Reset (STM32.Device.Timer_2); -- without this not reliable
end case;
STM32.Device.Reset( STM32.Device.GPIO_A );
STM32.Device.Reset( STM32.Device.GPIO_B );
STM32.Device.Reset( STM32.Device.GPIO_C );
STM32.Device.Reset( STM32.Device.GPIO_D );
STM32.Device.Reset( STM32.Device.GPIO_E );
STM32.Device.Reset( STM32.Device.SPI_1 );
STM32.Device.Reset( STM32.Device.USART_3 );
STM32.Device.Reset( STM32.Device.UART_4 );
STM32.Device.Reset( STM32.Device.USART_6 );
STM32.Device.Reset( STM32.Device.USART_7 );
end configure;
-- get number of systicks since POR
function getSysTick return Natural is
begin
null;
return 0;
end getSysTick;
-- get system time since POR
function getSysTime return Ada.Real_Time.Time is
begin
return Ada.Real_Time.Clock;
end getSysTime;
end HIL.Clock;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.