content stringlengths 23 1.05M |
|---|
-----------------------------------------------------------------------
-- keystore-passwords-keys -- Key provider
-- Copyright (C) 2019 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Encoders.SHA256;
with Util.Encoders.HMAC.SHA256;
package body Keystore.Passwords.Keys is
type Raw_Key_Provider (Len : Key_Length) is limited new Key_Provider
and Internal_Key_Provider with record
Password : Ada.Streams.Stream_Element_Array (1 .. Len);
end record;
type Raw_Key_Provider_Access is access all Raw_Key_Provider'Class;
-- Get the Key, IV and signature.
overriding
procedure Get_Keys (From : in Raw_Key_Provider;
Key : out Secret_Key;
IV : out Secret_Key;
Sign : out Secret_Key);
overriding
procedure Save_Key (Provider : in Raw_Key_Provider;
Data : out Ada.Streams.Stream_Element_Array);
-- ------------------------------
-- Create a key, iv, sign provider from the string.
-- ------------------------------
function Create (Password : in String;
Length : in Key_Length := DEFAULT_KEY_LENGTH)
return Key_Provider_Access is
Result : Raw_Key_Provider_Access;
Hash : Util.Encoders.SHA256.Hash_Array;
begin
Result := new Raw_Key_Provider '(Len => Length, others => <>);
Hash := Util.Encoders.HMAC.SHA256.Sign (Password, Password);
for I in 1 .. Length loop
Result.Password (I) := Hash (I mod Hash'Length);
Util.Encoders.HMAC.SHA256.Sign (Hash, Hash, Hash);
end loop;
return Result.all'Access;
end Create;
function Create (Password : in Ada.Streams.Stream_Element_Array)
return Key_Provider_Access is
begin
return new Raw_Key_Provider '(Len => Password'Length,
Password => Password);
end Create;
-- ------------------------------
-- Get the Key, IV and signature.
-- ------------------------------
overriding
procedure Get_Keys (From : in Raw_Key_Provider;
Key : out Secret_Key;
IV : out Secret_Key;
Sign : out Secret_Key) is
First : Ada.Streams.Stream_Element_Offset := 1;
Last : Ada.Streams.Stream_Element_Offset := First + Key.Length - 1;
begin
if From.Len /= Key.Length + IV.Length + Sign.Length then
raise Keystore.Bad_Password with "Invalid length for the key file";
end if;
Util.Encoders.Create (From.Password (First .. Last), Key);
First := Last + 1;
Last := First + IV.Length - 1;
Util.Encoders.Create (From.Password (First .. Last), IV);
First := Last + 1;
Last := First + Sign.Length - 1;
Util.Encoders.Create (From.Password (First .. Last), Sign);
end Get_Keys;
overriding
procedure Save_Key (Provider : in Raw_Key_Provider;
Data : out Ada.Streams.Stream_Element_Array) is
begin
Data := Provider.Password;
end Save_Key;
end Keystore.Passwords.Keys;
|
------------------------------------------------------------------------------
-- G P S --
-- --
-- Copyright (C) 2000-2016, AdaCore --
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. This software is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with this software; see file --
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
-- of the license. --
------------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Ada.Strings.Maps.Constants;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Wide_Wide_Characters.Unicode; use Ada.Wide_Wide_Characters.Unicode;
with Ada.Characters.Wide_Wide_Latin_1;
with GNAT.Expect; use GNAT.Expect;
with GNAT.Regpat; use GNAT.Regpat;
with GNATCOLL.Symbols; use GNATCOLL.Symbols;
with GNATCOLL.Utils; use GNATCOLL.Utils;
with String_Utils; use String_Utils;
with UTF8_Utils; use UTF8_Utils;
package body Language is
Default_Word_Character_Set : constant Character_Set :=
Constants.Letter_Set or Constants.Decimal_Digit_Set or To_Set ("_");
-- Default character set for keywords and indentifiers
procedure Looking_At
(Lang : access Language_Root;
Buffer : String;
First : Natural;
Entity : out Language_Entity;
Next_Char : out Positive;
Line : out Natural;
Column : out Natural);
-- Internal version of Looking_At, which also returns the Line and Column,
-- considering that Buffer (First) is at line 1 column 1.
-- Column is a byte index, not a character index.
---------------------------
-- Can_Tooltip_On_Entity --
---------------------------
function Can_Tooltip_On_Entity
(Lang : access Language_Root;
Entity : String) return Boolean
is
pragma Unreferenced (Lang, Entity);
begin
return True;
end Can_Tooltip_On_Entity;
---------------------
-- Scope_Separator --
---------------------
function Scope_Separator
(Lang : access Language_Root) return String
is
pragma Unreferenced (Lang);
begin
return ".";
end Scope_Separator;
----------------------
-- Explorer_Regexps --
----------------------
function Explorer_Regexps
(Lang : access Language_Root) return Explorer_Categories
is
pragma Unreferenced (Lang);
E : Explorer_Categories (1 .. 0);
begin
return E;
end Explorer_Regexps;
----------
-- Free --
----------
procedure Free (Context : in out Language_Context_Access) is
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Language_Context, Language_Context_Access);
Var : GNAT.Expect.Pattern_Matcher_Access :=
GNAT.Expect.Pattern_Matcher_Access
(Context.Syntax.New_Line_Comment_Start_Regexp);
begin
if Context /= null then
GNAT.Strings.Free (Context.Syntax.Comment_Start);
GNAT.Strings.Free (Context.Syntax.Comment_End);
Basic_Types.Unchecked_Free (Var);
GNAT.Strings.Free (Context.Syntax.New_Line_Comment_Start);
Unchecked_Free (Context);
end if;
end Free;
----------
-- Free --
----------
procedure Free (Lang : in out Language_Access) is
procedure Internal is new Ada.Unchecked_Deallocation
(Language_Root'Class, Language_Access);
begin
if Lang /= null then
Free (Lang.all);
Internal (Lang);
end if;
end Free;
procedure Free (List : in out Construct_List) is
Info, Tmp : Construct_Access;
procedure Free is new
Ada.Unchecked_Deallocation (Construct_Information, Construct_Access);
begin
Info := List.First;
loop
exit when Info = null;
GNAT.Strings.Free (Info.Profile);
Tmp := Info;
Info := Info.Next;
Free (Tmp);
end loop;
List.First := null;
List.Current := null;
List.Last := null;
end Free;
----------
-- Free --
----------
procedure Free (Category : in out Explorer_Category) is
begin
Basic_Types.Unchecked_Free (Category.Regexp);
end Free;
----------
-- Free --
----------
procedure Free (Categories : in out Explorer_Categories) is
begin
for C in Categories'Range loop
Free (Categories (C));
end loop;
end Free;
--------------------
-- Is_System_File --
--------------------
function Is_System_File
(Lang : access Language_Root;
File_Name : String) return Boolean
is
pragma Unreferenced (Lang, File_Name);
begin
return False;
end Is_System_File;
----------------
-- Looking_At --
----------------
procedure Looking_At
(Lang : access Language_Root;
Buffer : String;
First : Natural;
Entity : out Language_Entity;
Next_Char : out Positive)
is
Line, Column : Natural;
begin
Looking_At (Lang, Buffer, First, Entity, Next_Char, Line, Column);
end Looking_At;
procedure Looking_At
(Lang : access Language_Root;
Buffer : String;
First : Natural;
Entity : out Language_Entity;
Next_Char : out Positive;
Line : out Natural;
Column : out Natural)
is
Context : constant Language_Context_Access :=
Get_Language_Context (Language_Access (Lang));
Keys : constant GNAT.Expect.Pattern_Matcher_Access :=
Keywords (Language_Access (Lang));
Buffer_Length : constant Natural := Buffer'Last - First + 1;
Matched : Match_Array (0 .. 1);
C : Wide_Wide_Character;
Tmp : Natural;
Found : Boolean;
use GNAT.Strings;
begin
Line := 1;
Column := 1;
if Buffer (First) = ASCII.LF then
Next_Char := First + 1;
Line := Line + 1;
Column := 1;
Entity := Normal_Text;
return;
end if;
-- Do we have a comment ?
if Context.Syntax.Comment_Start /= null
and then Starts_With
(Buffer (First .. Buffer'Last), Context.Syntax.Comment_Start.all)
then
Entity := Comment_Text;
Next_Char := First + Context.Syntax.Comment_Start'Length;
Column := Column + Context.Syntax.Comment_Start'Length;
while Starts_With
(Buffer (Next_Char .. Buffer'Last), Context.Syntax.Comment_End.all)
loop
Tmp := UTF8_Next_Char (Buffer, Next_Char);
Column := Column + (Tmp - Next_Char);
Next_Char := Tmp;
if Next_Char <= Buffer'Last
and then Buffer (Next_Char) = ASCII.LF
then
Column := 1;
Line := Line + 1;
end if;
end loop;
Next_Char := Next_Char + Context.Syntax.Comment_End'Length;
Column := Column + Context.Syntax.Comment_End'Length;
return;
end if;
-- Do we have a comment that ends on newline ?
if Context.Syntax.New_Line_Comment_Start /= null then
Found := Starts_With
(Buffer (First .. Buffer'Last),
Context.Syntax.New_Line_Comment_Start.all);
elsif Context.Syntax.New_Line_Comment_Start_Regexp /= null then
Found := Match (Context.Syntax.New_Line_Comment_Start_Regexp.all,
Buffer (First .. Buffer'Last));
else
Found := False;
end if;
if Found then
Entity := Comment_Text;
Next_Char := UTF8_Next_Char (Buffer, First);
while Next_Char <= Buffer'Last
and then Buffer (Next_Char) /= ASCII.LF
loop
Tmp := UTF8_Next_Char (Buffer, Next_Char);
Column := Column + (Tmp - Next_Char);
Next_Char := Tmp;
end loop;
return;
end if;
-- Do we have a string ?
-- Note that we consider that strings never span over multiple lines...
if Buffer (First) = Context.String_Delimiter then
Entity := String_Text;
Next_Char := First;
if Next_Char < Buffer'Last
and then Buffer (Next_Char + 1) /= ASCII.LF
then
loop
Next_Char := UTF8_Next_Char (Buffer, Next_Char);
Column := Column + 1;
exit when Next_Char >= Buffer'Last
or else Buffer (Next_Char + 1) = ASCII.LF
or else
(Buffer (Next_Char) = Context.String_Delimiter
and then
(Context.Quote_Character = ASCII.NUL
or else
Buffer (Next_Char - 1) /= Context.Quote_Character));
end loop;
end if;
if Next_Char <= Buffer'Last then
Tmp := UTF8_Next_Char (Buffer, Next_Char);
Column := Column + (Tmp - Next_Char);
Next_Char := Tmp;
end if;
return;
end if;
-- A protected constant character
-- ??? The following test still does not handle cases such as
-- '\012' for instance, or multi-byte character constants.
if Buffer_Length > 4
and then Buffer (First) = Context.Constant_Character
and then Buffer (First + 1) = Context.Quote_Character
and then Buffer (First + 3) = Context.Constant_Character
then
Entity := Character_Text;
Next_Char := First + 4;
Column := Column + 4;
return;
end if;
-- A constant character
if Buffer_Length > 3
and then Buffer (First) = Context.Constant_Character
and then Buffer (First + 2) = Context.Constant_Character
then
Entity := Character_Text;
Next_Char := First + 3;
Column := Column + 3;
return;
end if;
-- Do we have a keyword ?
-- ??? It is assumed the regexp should check at the current char
-- only, not beyond for efficiency...
if Keys /= null then
Match (Keys.all, Buffer (First .. Buffer'Last), Matched);
if Matched (0) /= No_Match then
Next_Char := UTF8_Next_Char (Buffer, Matched (0).Last);
Column := Column + Matched (0).Last - Matched (0).First + 1;
Entity := Keyword_Text;
return;
end if;
end if;
-- Another special character, not part of a word: just skip it, before
-- doing some regexp matching
-- It is better to return a pointer to the newline, so that the icons
-- on the side might be displayed properly.
if not Is_Word_Char
(Language_Access (Lang),
UTF8_Get_Char (Buffer (First .. Buffer'Last)))
then
Entity := Normal_Text;
Next_Char := UTF8_Next_Char (Buffer, First);
Column := Column + (Next_Char - First);
while Next_Char <= Buffer'Last loop
C := UTF8_Get_Char (Buffer (Next_Char .. Buffer'Last));
exit when C = Ada.Characters.Wide_Wide_Latin_1.LF
or else not Is_Space (C);
Tmp := UTF8_Next_Char (Buffer, Next_Char);
Column := Column + (Tmp - Next_Char);
Next_Char := Tmp;
end loop;
return;
end if;
-- Skip to the next meaningful character. we know we are
-- starting with a letter
Next_Char := UTF8_Next_Char (Buffer, First);
Column := Column + (Next_Char - First);
Entity := Normal_Text;
if Buffer (Next_Char) = ASCII.LF then
return;
end if;
-- Skip the current word. We only take into account Is_Entity_Letter,
-- not the full set of chars supported by the language for its keywords
-- because of cases like "<foo>bar</foo>" in XML, which would otherwise
-- consider this as a single word when they are in fact several.
while Next_Char <= Buffer'Last
and then Is_Entity_Letter
(UTF8_Get_Char (Buffer (Next_Char .. Buffer'Last)))
loop
Tmp := UTF8_Next_Char (Buffer, Next_Char);
Column := Column + (Tmp - Next_Char);
Next_Char := Tmp;
end loop;
end Looking_At;
-------------------------------------
-- To_Simple_Construct_Information --
-------------------------------------
procedure To_Simple_Construct_Information
(Construct : Construct_Information;
Simple : out Simple_Construct_Information;
Full_Copy : Boolean)
is
pragma Unreferenced (Full_Copy);
begin
Simple :=
(Category => Construct.Category,
Is_Declaration => Construct.Is_Declaration,
Is_Generic_Spec => Construct.Is_Generic_Spec,
Visibility => Construct.Visibility,
Name => Construct.Name,
Sloc_Start => Construct.Sloc_Start,
Sloc_Entity => Construct.Sloc_Entity,
Sloc_End => Construct.Sloc_End,
Attributes => Construct.Attributes,
Profile_Cache => null);
end To_Simple_Construct_Information;
------------------
-- Comment_Line --
------------------
function Comment_Line
(Lang : access Language_Root;
Line : String;
Comment : Boolean := True;
Clean : Boolean := False) return String
is
pragma Unreferenced (Lang, Comment, Clean);
begin
return Line;
end Comment_Line;
------------------
-- Comment_Block --
------------------
function Comment_Block
(Lang : access Language_Root;
Block : String;
Comment : Boolean := True;
Clean : Boolean := False) return String
is
Start_Of_Line : Natural := Block'First;
End_Of_Line : Natural;
New_Block : Unbounded_String := Null_Unbounded_String;
begin
loop
End_Of_Line := Next_Line (Block, Start_Of_Line);
if End_Of_Line /= Block'Last and then End_Of_Line /= Block'First then
End_Of_Line := End_Of_Line - 1;
end if;
Append
(New_Block,
Comment_Line
(Language_Access (Lang),
Block (Start_Of_Line .. End_Of_Line),
Comment,
Clean));
Start_Of_Line := Next_Line (Block, Start_Of_Line);
exit when Start_Of_Line = Block'Last;
end loop;
return To_String (New_Block);
end Comment_Block;
----------------------
-- Parse_Constructs --
----------------------
procedure Parse_Constructs
(Lang : access Language_Root;
File : GNATCOLL.VFS.Virtual_File;
Buffer : UTF8_String;
Result : out Construct_List)
is
pragma Unreferenced (File);
Matches : Match_Array (0 .. 10);
Categories : constant Explorer_Categories :=
Explorer_Regexps (Language_Access (Lang));
First : Natural;
Line : Natural;
Line_Pos : Natural;
Sloc_Entity : Source_Location;
Sloc_Start : Source_Location;
Sloc_End : Source_Location;
Info : Construct_Access;
Match_Index : Natural;
End_Index : Natural;
procedure Forward
(Index : Natural;
Sloc : in out Source_Location);
-- Compute Line and Column fields in Sloc and update Line and Line_Pos
-------------
-- Forward --
-------------
procedure Forward
(Index : Natural;
Sloc : in out Source_Location) is
begin
for J in Index .. Sloc.Index loop
if Buffer (J) = ASCII.LF then
Line := Line + 1;
Line_Pos := J;
end if;
end loop;
Sloc.Line := Line;
Sloc.Column := Sloc.Index - Line_Pos;
end Forward;
begin
Result := (null, null, null, 0);
-- For each category, parse the buffer
for C in Categories'Range loop
First := Buffer'First;
Line := 1;
Line_Pos := 0;
loop
Match (Categories (C).Regexp.all,
Buffer (First .. Buffer'Last),
Matches);
exit when Matches (0) = No_Match;
Match_Index := Categories (C).Position_Index;
End_Index := Categories (C).End_Index;
if Matches (Match_Index) /= No_Match then
Sloc_Start.Index := Matches (0).First;
Sloc_Entity.Index := Matches (Match_Index).First;
Sloc_End.Index := Matches (End_Index).Last;
Forward (First, Sloc_Start);
Forward (Sloc_Start.Index + 1, Sloc_Entity);
Forward (Sloc_Entity.Index + 1, Sloc_End);
Info := Result.Current;
Result.Current := new Construct_Information;
if Result.First = null then
Result.First := Result.Current;
else
Result.Current.Prev := Info;
Result.Current.Next := Info.Next;
Info.Next := Result.Current;
end if;
Result.Last := Result.Current;
Result.Current.Category := Categories (C).Category;
Result.Current.Category_Name := Categories (C).Category_Name;
Result.Size := Result.Size + 1;
if Categories (C).Make_Entry /= null then
Result.Current.Name := Lang.Symbols.Find
(Categories (C).Make_Entry (Buffer, Matches));
else
Result.Current.Name := Lang.Symbols.Find
(Buffer (Matches (Match_Index).First ..
Matches (Match_Index).Last));
end if;
-- Result.Current.Profile := ???
Result.Current.Sloc_Entity := Sloc_Entity;
Result.Current.Sloc_Start := Sloc_Start;
Result.Current.Sloc_End := Sloc_End;
Result.Current.Is_Declaration := False;
end if;
First := Matches (End_Index).Last + 1;
end loop;
end loop;
end Parse_Constructs;
--------------------
-- Parse_Entities --
--------------------
procedure Parse_Entities
(Lang : access Language_Root;
Buffer : String;
Callback : Entity_Callback)
is
use type GNAT.Strings.String_Access;
Index : Natural := Buffer'First;
Next_Char : Natural;
End_Char : Natural;
Entity : Language_Entity;
Line : Natural;
Line_Inc : Natural;
Col : Natural;
Column : Natural;
Column_Inc : Natural;
begin
Line := 1;
Column := 1;
while Index < Buffer'Last loop
Looking_At
(Lang, Buffer, Index, Entity, Next_Char, Line_Inc, Column_Inc);
if Next_Char = Buffer'Last then
End_Char := Buffer'Last;
else
End_Char := Next_Char - 1;
end if;
-- If we are still on the same line, Column_Inc is an increment
-- compared to what we have initially, otherwise it is an absolute
-- column.
if Line_Inc = 1 then
Column_Inc := Column + Column_Inc - 1;
end if;
-- Looking_At goes always one character beyond characters and
-- strings, otherwise next call to Looking_At would start on
-- a string or character delimiter. Keywords are also set one
-- character beyond.
if Column_Inc > 1
and then (Entity = String_Text
or else Entity = Character_Text
or else Entity = Keyword_Text)
then
Col := Column_Inc - 1;
else
Col := Column_Inc;
end if;
exit when Callback
(Entity,
(Line, Column, Index),
(Line + Line_Inc - 1, Col, End_Char),
Get_Language_Context
(Language_Access (Lang)).Syntax.Comment_Start /= null
and then Entity = Comment_Text and then Next_Char > Buffer'Last);
Line := Line + Line_Inc - 1;
Column := Column_Inc;
Index := Next_Char;
end loop;
end Parse_Entities;
---------------------------
-- Get_Referenced_Entity --
---------------------------
procedure Get_Referenced_Entity
(Lang : access Language_Root;
Buffer : String;
Construct : Simple_Construct_Information;
Sloc_Start : out Source_Location;
Sloc_End : out Source_Location;
Success : out Boolean;
From_Index : Natural := 0)
is
pragma Unreferenced
(Lang, Buffer, Construct, Sloc_Start, Sloc_End, From_Index);
begin
Success := False;
end Get_Referenced_Entity;
-------------------
-- Format_Buffer --
-------------------
procedure Format_Buffer
(Lang : access Language_Root;
Buffer : String;
Replace : Replace_Text_Callback;
From, To : Natural := 0;
Indent_Params : Indent_Parameters := Default_Indent_Parameters;
Indent_Offset : Natural := 0;
Case_Exceptions : Case_Handling.Casing_Exceptions :=
Case_Handling.No_Casing_Exception;
Is_Optional_Keyword : access function (S : String)
return Boolean := null)
is
pragma Unreferenced
(Lang, Indent_Offset, Case_Exceptions, Is_Optional_Keyword);
Use_Tabs : Boolean renames Indent_Params.Use_Tabs;
Index : Natural;
Indent : Natural := 0;
Start_Of_Line : Natural;
Start_Prev_Line : Natural;
function Find_Line_Start
(Buffer : String; Index : Natural) return Natural;
-- Find the starting ASCII.LF character of the line positioned at
-- Buffer (Index).
---------------------
-- Find_Line_Start --
---------------------
function Find_Line_Start
(Buffer : String; Index : Natural) return Natural
is
Result : Natural := Index;
begin
while Result > Buffer'First
and then Buffer (Result) /= ASCII.LF
loop
Result := Result - 1;
end loop;
return Result;
end Find_Line_Start;
begin
if Buffer'Length <= 1 or else To > From + 1 then
return;
end if;
Start_Of_Line := Find_Line_Start (Buffer, Buffer'Last - 1);
Start_Prev_Line := Find_Line_Start (Buffer, Start_Of_Line - 1);
-- Compute the indentation level
for J in Start_Prev_Line + 1 .. Start_Of_Line - 1 loop
if Buffer (J) = ' ' then
Indent := Indent + 1;
elsif Buffer (J) = ASCII.HT then
Indent := Indent + Tab_Width - (Indent mod Tab_Width);
else
exit;
end if;
end loop;
-- Find the blank slice to replace
Index := Start_Of_Line + 1;
while Index < Buffer'Last
and then (Buffer (Index) = ' ' or else Buffer (Index) = ASCII.HT)
loop
Index := Index + 1;
end loop;
Replace
(To, 1, Index - Start_Of_Line,
Blank_Slice (Indent, Use_Tabs, Tab_Width));
end Format_Buffer;
-------------------
-- Category_Name --
-------------------
function Category_Name
(Category : Language.Language_Category;
Name : GNATCOLL.Symbols.Symbol := GNATCOLL.Symbols.No_Symbol)
return String
is
use type Strings.String_Access;
begin
if Name /= No_Symbol then
return Get (Name).all;
end if;
case Category is
when Cat_Unknown => return "";
when Cat_Custom => return "custom";
when Cat_Package => return "package";
when Cat_Namespace => return "namespace";
when Cat_Task => return "task";
when Cat_Procedure => return "subprogram";
when Cat_Function => return "subprogram";
when Cat_Method => return "method";
when Cat_Constructor => return "constructor";
when Cat_Destructor => return "destructor";
when Cat_Protected => return "protected";
when Cat_Entry => return "entry";
when Cat_Class => return "class";
when Cat_Structure => return "structure";
when Cat_Case_Inside_Record => return "structure variant part";
when Cat_Union => return "union";
when Cat_Type => return "type";
when Cat_Subtype => return "subtype";
when Cat_Variable => return "variable";
when Cat_Local_Variable => return "variable";
when Cat_Parameter => return "parameter";
when Cat_Discriminant => return "discriminant";
when Cat_Field => return "field";
when Cat_Literal => return "literal";
when Cat_Representation_Clause => return "representation clause";
when Cat_With => return "with";
when Cat_Use => return "use";
when Cat_Include => return "include";
when Construct_Category => return "";
when Cat_Exception_Handler => return "";
when Cat_Pragma => return "pragma";
when Cat_Aspect => return "aspect";
end case;
end Category_Name;
--------------------------------
-- Get_Indentation_Parameters --
--------------------------------
procedure Get_Indentation_Parameters
(Lang : access Language_Root;
Params : out Indent_Parameters;
Indent_Style : out Indentation_Kind) is
begin
Params := Lang.Indent_Params;
Indent_Style := Lang.Indent_Style;
end Get_Indentation_Parameters;
--------------------------------
-- Set_Indentation_Parameters --
--------------------------------
procedure Set_Indentation_Parameters
(Lang : access Language_Root;
Params : Indent_Parameters;
Indent_Style : Indentation_Kind) is
begin
Lang.Indent_Params := Params;
Lang.Indent_Style := Indent_Style;
end Set_Indentation_Parameters;
----------
-- Free --
----------
procedure Free (Fields : in out Project_Field_Array) is
begin
for F in Fields'Range loop
Strings.Free (Fields (F).Attribute_Name);
Strings.Free (Fields (F).Attribute_Index);
Strings.Free (Fields (F).Description);
end loop;
end Free;
------------------------
-- Word_Character_Set --
------------------------
function Word_Character_Set
(Lang : access Language_Root)
return Character_Set
is
pragma Unreferenced (Lang);
begin
return Default_Word_Character_Set;
end Word_Character_Set;
------------------
-- Is_Word_Char --
------------------
function Is_Word_Char
(Lang : access Language_Root; Char : Wide_Wide_Character) return Boolean
is
pragma Unreferenced (Lang);
begin
return Is_Entity_Letter (Char);
end Is_Word_Char;
---------
-- "=" --
---------
overriding function "=" (S1, S2 : Source_Location) return Boolean is
begin
if S1.Index > 0 and then S2.Index > 0 then
return S1.Index = S2.Index;
else
return S1.Line = S2.Line
and then S1.Column = S2.Column;
end if;
end "=";
---------
-- "<" --
---------
function "<" (S1, S2 : Source_Location) return Boolean is
begin
if S1.Index > 0 and then S2.Index > 0 then
return S1.Index < S2.Index;
elsif S1.Line = S2.Line then
return S1.Column < S2.Column;
else
return S1.Line < S2.Line;
end if;
end "<";
----------
-- "<=" --
----------
function "<=" (S1, S2 : Source_Location) return Boolean is
begin
return S1 = S2 or else S1 < S2;
end "<=";
---------
-- ">" --
---------
function ">" (S1, S2 : Source_Location) return Boolean is
begin
return S2 < S1;
end ">";
----------
-- ">=" --
----------
function ">=" (S1, S2 : Source_Location) return Boolean is
begin
return not (S1 < S2);
end ">=";
---------------------------
-- Parse_Tokens_Backward --
---------------------------
procedure Parse_Tokens_Backwards
(Lang : access Language_Root;
Buffer : UTF8_String;
Start_Offset : String_Index_Type;
End_Offset : String_Index_Type := 0;
-- ??? This analysis should be done when looking for comments !!!
Callback :
access procedure (Token : Token_Record;
Stop : in out Boolean))
is
pragma Unreferenced (Lang);
Lowest : constant String_Index_Type :=
String_Index_Type'Max (End_Offset, String_Index_Type (Buffer'First));
Index : String_Index_Type := Start_Offset;
Stop : Boolean := False;
begin
if Index not in Lowest .. String_Index_Type (Buffer'Last) then
return;
else
Skip_Word
(Buffer (Natural (Lowest) .. Natural (Index)),
Natural (Index),
Step => -1);
Callback
((Tok_Type => No_Token,
Token_First => Index + 1,
Token_Last => Start_Offset),
Stop);
end if;
end Parse_Tokens_Backwards;
------------------------------
-- Parse_Reference_Backward --
------------------------------
function Parse_Reference_Backwards
(Lang : access Language_Root;
Buffer : UTF8_String;
Start_Offset : String_Index_Type;
End_Offset : String_Index_Type := 0) return String
is
Buf_Start : Integer := 1;
Buf_End : Integer := 0;
procedure Callback
(Token : Token_Record;
Stop : in out Boolean);
procedure Callback
(Token : Token_Record;
Stop : in out Boolean)
is
begin
Buf_End := Integer (Token.Token_Last);
Buf_Start := Integer (Token.Token_First);
Stop := True;
end Callback;
begin
Lang.Parse_Tokens_Backwards
(Buffer => Buffer,
Start_Offset => Start_Offset,
End_Offset => End_Offset,
Callback => Callback'Access);
return Buffer (Buf_Start .. Buf_End);
end Parse_Reference_Backwards;
-----------------
-- Set_Symbols --
-----------------
procedure Set_Symbols
(Self : access Language_Root'Class;
Symbols : not null access GNATCOLL.Symbols.Symbol_Table_Record'Class) is
begin
Self.Symbols := Symbol_Table_Access (Symbols);
end Set_Symbols;
-------------
-- Symbols --
-------------
function Symbols
(Self : access Language_Root'Class)
return GNATCOLL.Symbols.Symbol_Table_Access is
begin
return Self.Symbols;
end Symbols;
----------------------
-- Entities_Indexed --
----------------------
function Entities_Indexed (Self : Language_Root) return Boolean is
pragma Unreferenced (Self);
begin
return False;
end Entities_Indexed;
end Language;
|
with Ada.Text_IO; use Ada.Text_IO;
with GNAT.OS_Lib;
with System;
with Interfaces; use Interfaces;
with Interfaces.C; use Interfaces.C;
with Sf.Audio; use Sf.Audio;
with Sf.Audio.SoundStream; use Sf.Audio.SoundStream;
with Sf; use Sf;
package body PyGamer.Audio is
Stream : sfSoundStream_Ptr;
User_Callback : Audio_Callback := null
with Atomic, Volatile;
Stream_Data : array (1 .. 1024) of aliased sfInt16;
function SFML_Audio_Callback (chunk : access sfSoundStreamChunk;
Unused : System.Address)
return sfBool
with Convention => C;
function Convert (Sample : Unsigned_16) return sfInt16
is (sfInt16 (Integer_32 (Sample) - 32_768));
-------------------------
-- SFML_Audio_Callback --
-------------------------
function SFML_Audio_Callback (chunk : access sfSoundStreamChunk;
Unused : System.Address)
return sfBool
is
Len : constant Natural := Stream_Data'Length;
Left : Data_Array (1 .. Integer (Len) / 2);
Right : Data_Array (1 .. Integer (Len) / 2);
Stream_Index : Natural := Stream_Data'First;
CB : Audio_Callback := User_Callback;
begin
if CB /= null then
CB (Left, Right);
for Index in Left'Range loop
Stream_Data (Stream_Index) := Convert (Left (Index));
Stream_Data (Stream_Index + 1) := Convert (Right (Index));
Stream_Index := Stream_Index + 2;
end loop;
else
Stream_Data := (others => 0);
end if;
chunk.Samples := Stream_Data (Stream_Data'First)'access;
chunk.NbSamples := Stream_Data'Length;
return True;
end SFML_Audio_Callback;
------------------
-- Set_Callback --
------------------
procedure Set_Callback (Callback : Audio_Callback;
Sample_Rate : Sample_Rate_Kind) is
begin
User_Callback := Callback;
if Stream /= null then
Stop (Stream);
destroy (Stream);
end if;
Stream := create (onGetData => SFML_Audio_Callback'Access,
onSeek => null,
channelCount => 2,
sampleRate => (case Sample_Rate is
when SR_11025 => 11_025,
when SR_22050 => 22_050,
when SR_44100 => 44_110,
when SR_96000 => 96_000),
userData => System.Null_Address);
if Stream = null then
Put_Line ("Could not create audio stream");
GNAT.OS_Lib.OS_Exit (1);
else
play (Stream);
end if;
end Set_Callback;
begin
if GNAT.OS_Lib.Getenv ("OS").all = "Windows_NT" then
-- Select driver for openal on Windows
GNAT.OS_Lib.Setenv ("ALSOFT_DRIVERS", "dsound");
end if;
end PyGamer.Audio;
|
-- The Village of Vampire by YT, このソースコードはNYSLです
package Vampire.Forms.Selecting is
function Select_Form (
Query_Strings : Web.Query_Strings;
Speeches_Per_Page : Tabula.Villages.Speech_Positive_Count'Base)
return Root_Form_Type'Class;
end Vampire.Forms.Selecting;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Print_Line is
Printer : File_Type;
begin
begin
Open (Printer, Mode => Out_File, Name => "/dev/lp0");
exception
when others =>
Put_Line ("Unable to open printer.");
return;
end;
Set_Output (Printer);
Put_Line ("Hello World!");
Close (Printer);
end Print_Line;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . A L T I V E C --
-- --
-- S p e c --
-- --
-- Copyright (C) 2004-2011, 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. --
-- --
------------------------------------------------------------------------------
-------------------------
-- General description --
-------------------------
-- This is the root of a package hierarchy offering an Ada binding to the
-- PowerPC AltiVec extensions, a set of 128bit vector types together with a
-- set of subprograms operating on them. Relevant documents are:
-- o AltiVec Technology, Programming Interface Manual (1999-06)
-- to which we will refer as [PIM], describes the data types, the
-- functional interface and the ABI conventions.
-- o AltiVec Technology, Programming Environments Manual (2002-02)
-- to which we will refer as [PEM], describes the hardware architecture
-- and instruction set.
-- These documents, as well as a number of others of general interest on the
-- AltiVec technology, are available from the Motorola/AltiVec Web site at:
-- http://www.freescale.com/altivec
-- The binding interface is structured to allow alternate implementations:
-- for real AltiVec capable targets, and for other targets. In the latter
-- case, everything is emulated in software. The two versions are referred
-- to as:
-- o The Hard binding for AltiVec capable targets (with the appropriate
-- hardware support and corresponding instruction set)
-- o The Soft binding for other targets (with the low level primitives
-- emulated in software).
-- In addition, interfaces that are not strictly part of the base AltiVec API
-- are provided, such as vector conversions to and from array representations,
-- which are of interest for client applications (e.g. for vector
-- initialization purposes).
-- Only the soft binding is available today
-----------------------------------------
-- General package architecture survey --
-----------------------------------------
-- The various vector representations are all "containers" of elementary
-- values, the possible types of which are declared in this root package to
-- be generally accessible.
-- From the user standpoint, the binding materializes as a consistent
-- hierarchy of units:
-- GNAT.Altivec
-- (component types)
-- |
-- o----------------o----------------o-------------o
-- | | | |
-- Vector_Types Vector_Operations Vector_Views Conversions
-- The user can manipulate vectors through two families of types: Vector
-- types and View types.
-- Vector types are defined in the GNAT.Altivec.Vector_Types package
-- On these types, users can apply the Altivec operations defined in
-- GNAT.Altivec.Vector_Operations. Their layout is opaque and may vary across
-- configurations, for it is typically target-endianness dependant.
-- Vector_Types and Vector_Operations implement the core binding to the
-- AltiVec API, as described in [PIM-2.1 data types] and [PIM-4 AltiVec
-- operations and predicates].
-- View types are defined in the GNAT.Altivec.Vector_Views package
-- These types do not represent Altivec vectors per se, in the sense that the
-- Altivec_Operations are not available for them. They are intended to allow
-- Vector initializations as well as access to the Vector component values.
-- The GNAT.Altivec.Conversions package is provided to convert a View to the
-- corresponding Vector and vice-versa.
---------------------------
-- Underlying principles --
---------------------------
-- Internally, the binding relies on an abstraction of the Altivec API, a
-- rich set of functions around a core of low level primitives mapping to
-- AltiVec instructions. See for instance "vec_add" in [PIM-4.4 Generic and
-- Specific AltiVec operations], with no less than six result/arguments
-- combinations of byte vector types that map to "vaddubm".
-- The "soft" version is a software emulation of the low level primitives.
-- The "hard" version would map to real AltiVec instructions via GCC builtins
-- and inlining.
-------------------
-- Example usage --
-------------------
-- Here is a sample program declaring and initializing two vectors, 'add'ing
-- them and displaying the result components:
-- with GNAT.Altivec.Vector_Types; use GNAT.Altivec.Vector_Types;
-- with GNAT.Altivec.Vector_Operations; use GNAT.Altivec.Vector_Operations;
-- with GNAT.Altivec.Vector_Views; use GNAT.Altivec.Vector_Views;
-- with GNAT.Altivec.Conversions; use GNAT.Altivec.Conversions;
-- use GNAT.Altivec;
-- with Ada.Text_IO; use Ada.Text_IO;
-- procedure Sample is
-- Va : Vector_Unsigned_Int := To_Vector ((Values => (1, 2, 3, 4)));
-- Vb : Vector_Unsigned_Int := To_Vector ((Values => (1, 2, 3, 4)));
-- Vs : Vector_Unsigned_Int;
-- Vs_View : VUI_View;
-- begin
-- Vs := Vec_Add (Va, Vb);
-- Vs_View := To_View (Vs);
-- for I in Vs_View.Values'Range loop
-- Put_Line (Unsigned_Int'Image (Vs_View.Values (I)));
-- end loop;
-- end;
-- $ gnatmake sample.adb
-- [...]
-- $ ./sample
-- 2
-- 4
-- 6
-- 8
------------------------------------------------------------------------------
with System;
package GNAT.Altivec is
-- Definitions of constants and vector/array component types common to all
-- the versions of the binding.
-- All the vector types are 128bits
VECTOR_BIT : constant := 128;
-------------------------------------------
-- [PIM-2.3.1 Alignment of vector types] --
-------------------------------------------
-- "A defined data item of any vector data type in memory is always
-- aligned on a 16-byte boundary. A pointer to any vector data type always
-- points to a 16-byte boundary. The compiler is responsible for aligning
-- vector data types on 16-byte boundaries."
VECTOR_ALIGNMENT : constant := Natural'Min (16, Standard'Maximum_Alignment);
-- This value is used to set the alignment of vector datatypes in both the
-- hard and the soft binding implementations.
--
-- We want this value to never be greater than 16, because none of the
-- binding implementations requires larger alignments and such a value
-- would cause useless space to be allocated/wasted for vector objects.
-- Furthermore, the alignment of 16 matches the hard binding leading to
-- a more faithful emulation.
--
-- It needs to be exactly 16 for the hard binding, and the initializing
-- expression is just right for this purpose since Maximum_Alignment is
-- expected to be 16 for the real Altivec ABI.
--
-- The soft binding doesn't rely on strict 16byte alignment, and we want
-- the value to be no greater than Standard'Maximum_Alignment in this case
-- to ensure it is supported on every possible target.
-------------------------------------------------------
-- [PIM-2.1] Data Types - Interpretation of contents --
-------------------------------------------------------
---------------------
-- char components --
---------------------
CHAR_BIT : constant := 8;
SCHAR_MIN : constant := -2 ** (CHAR_BIT - 1);
SCHAR_MAX : constant := 2 ** (CHAR_BIT - 1) - 1;
UCHAR_MAX : constant := 2 ** CHAR_BIT - 1;
type unsigned_char is mod UCHAR_MAX + 1;
for unsigned_char'Size use CHAR_BIT;
type signed_char is range SCHAR_MIN .. SCHAR_MAX;
for signed_char'Size use CHAR_BIT;
subtype bool_char is unsigned_char;
-- ??? There is a difference here between what the Altivec Technology
-- Programming Interface Manual says and what GCC says. In the manual,
-- vector_bool_char is a vector_unsigned_char, while in altivec.h it
-- is a vector_signed_char.
bool_char_True : constant bool_char := bool_char'Last;
bool_char_False : constant bool_char := 0;
----------------------
-- short components --
----------------------
SHORT_BIT : constant := 16;
SSHORT_MIN : constant := -2 ** (SHORT_BIT - 1);
SSHORT_MAX : constant := 2 ** (SHORT_BIT - 1) - 1;
USHORT_MAX : constant := 2 ** SHORT_BIT - 1;
type unsigned_short is mod USHORT_MAX + 1;
for unsigned_short'Size use SHORT_BIT;
subtype unsigned_short_int is unsigned_short;
type signed_short is range SSHORT_MIN .. SSHORT_MAX;
for signed_short'Size use SHORT_BIT;
subtype signed_short_int is signed_short;
subtype bool_short is unsigned_short;
-- ??? See bool_char
bool_short_True : constant bool_short := bool_short'Last;
bool_short_False : constant bool_short := 0;
subtype bool_short_int is bool_short;
--------------------
-- int components --
--------------------
INT_BIT : constant := 32;
SINT_MIN : constant := -2 ** (INT_BIT - 1);
SINT_MAX : constant := 2 ** (INT_BIT - 1) - 1;
UINT_MAX : constant := 2 ** INT_BIT - 1;
type unsigned_int is mod UINT_MAX + 1;
for unsigned_int'Size use INT_BIT;
type signed_int is range SINT_MIN .. SINT_MAX;
for signed_int'Size use INT_BIT;
subtype bool_int is unsigned_int;
-- ??? See bool_char
bool_int_True : constant bool_int := bool_int'Last;
bool_int_False : constant bool_int := 0;
----------------------
-- float components --
----------------------
FLOAT_BIT : constant := 32;
FLOAT_DIGIT : constant := 6;
FLOAT_MIN : constant := -16#0.FFFF_FF#E+32;
FLOAT_MAX : constant := 16#0.FFFF_FF#E+32;
type C_float is digits FLOAT_DIGIT range FLOAT_MIN .. FLOAT_MAX;
for C_float'Size use FLOAT_BIT;
-- Altivec operations always use the standard native floating-point
-- support of the target. Note that this means that there may be
-- minor differences in results between targets when the floating-
-- point implementations are slightly different, as would happen
-- with normal non-Altivec floating-point operations. In particular
-- the Altivec simulations may yield slightly different results
-- from those obtained on a true hardware Altivec target if the
-- floating-point implementation is not 100% compatible.
----------------------
-- pixel components --
----------------------
subtype pixel is unsigned_short;
-----------------------------------------------------------
-- Subtypes for variants found in the GCC implementation --
-----------------------------------------------------------
subtype c_int is signed_int;
subtype c_short is c_int;
LONG_BIT : constant := 32;
-- Some of the GCC builtins are built with "long" arguments and
-- expect SImode to come in.
SLONG_MIN : constant := -2 ** (LONG_BIT - 1);
SLONG_MAX : constant := 2 ** (LONG_BIT - 1) - 1;
ULONG_MAX : constant := 2 ** LONG_BIT - 1;
type signed_long is range SLONG_MIN .. SLONG_MAX;
type unsigned_long is mod ULONG_MAX + 1;
subtype c_long is signed_long;
subtype c_ptr is System.Address;
---------------------------------------------------------
-- Access types, for the sake of some argument passing --
---------------------------------------------------------
type signed_char_ptr is access all signed_char;
type unsigned_char_ptr is access all unsigned_char;
type short_ptr is access all c_short;
type signed_short_ptr is access all signed_short;
type unsigned_short_ptr is access all unsigned_short;
type int_ptr is access all c_int;
type signed_int_ptr is access all signed_int;
type unsigned_int_ptr is access all unsigned_int;
type long_ptr is access all c_long;
type signed_long_ptr is access all signed_long;
type unsigned_long_ptr is access all unsigned_long;
type float_ptr is access all Float;
--
type const_signed_char_ptr is access constant signed_char;
type const_unsigned_char_ptr is access constant unsigned_char;
type const_short_ptr is access constant c_short;
type const_signed_short_ptr is access constant signed_short;
type const_unsigned_short_ptr is access constant unsigned_short;
type const_int_ptr is access constant c_int;
type const_signed_int_ptr is access constant signed_int;
type const_unsigned_int_ptr is access constant unsigned_int;
type const_long_ptr is access constant c_long;
type const_signed_long_ptr is access constant signed_long;
type const_unsigned_long_ptr is access constant unsigned_long;
type const_float_ptr is access constant Float;
-- Access to const volatile arguments need specialized types
type volatile_float is new Float;
pragma Volatile (volatile_float);
type volatile_signed_char is new signed_char;
pragma Volatile (volatile_signed_char);
type volatile_unsigned_char is new unsigned_char;
pragma Volatile (volatile_unsigned_char);
type volatile_signed_short is new signed_short;
pragma Volatile (volatile_signed_short);
type volatile_unsigned_short is new unsigned_short;
pragma Volatile (volatile_unsigned_short);
type volatile_signed_int is new signed_int;
pragma Volatile (volatile_signed_int);
type volatile_unsigned_int is new unsigned_int;
pragma Volatile (volatile_unsigned_int);
type volatile_signed_long is new signed_long;
pragma Volatile (volatile_signed_long);
type volatile_unsigned_long is new unsigned_long;
pragma Volatile (volatile_unsigned_long);
type constv_char_ptr is access constant volatile_signed_char;
type constv_signed_char_ptr is access constant volatile_signed_char;
type constv_unsigned_char_ptr is access constant volatile_unsigned_char;
type constv_short_ptr is access constant volatile_signed_short;
type constv_signed_short_ptr is access constant volatile_signed_short;
type constv_unsigned_short_ptr is access constant volatile_unsigned_short;
type constv_int_ptr is access constant volatile_signed_int;
type constv_signed_int_ptr is access constant volatile_signed_int;
type constv_unsigned_int_ptr is access constant volatile_unsigned_int;
type constv_long_ptr is access constant volatile_signed_long;
type constv_signed_long_ptr is access constant volatile_signed_long;
type constv_unsigned_long_ptr is access constant volatile_unsigned_long;
type constv_float_ptr is access constant volatile_float;
private
-----------------------
-- Various constants --
-----------------------
CR6_EQ : constant := 0;
CR6_EQ_REV : constant := 1;
CR6_LT : constant := 2;
CR6_LT_REV : constant := 3;
end GNAT.Altivec;
|
package body Datastore is
-- create a global array of elements that can be referenced by 'access
-- Implement functions that return the different access types
-- based on the index into the array
end Datastore;
|
-- Copyright 2017 Georgios Migdos
--
-- 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 Interfaces.C;
with Interfaces.C.Strings;
package body XPATH_UTILS is
use type Interfaces.C.int;
use type Interfaces.C.Strings.chars_ptr;
XPATH_PROC_RET_CODE_SUCCESS_C : constant := 0;
XPATH_PROC_RET_CODE_FAILURE_C : constant := 1;
XPATH_PROC_RET_CODE_FAILED_TO_PARSE_FILE_C : constant := 2;
XPATH_PROC_RET_CODE_XPATH_CONTEXT_CREATION_FAILED_C : constant := 3;
XPATH_PROC_RET_CODE_INVALID_XPATH_EXPR_C : constant := 4;
-- void xpath_proc_initialize()
procedure XPath_Proc_Initialize;
pragma Import(C, XPath_Proc_Initialize, "xpath_proc_initialize");
-- void xpath_proc_finalize()
procedure XPath_Proc_Finalize;
pragma Import(C, XPath_Proc_Finalize, "xpath_proc_finalize");
-- xpath_proc_parse(char* filename, xmlDoc **xml_doc, xmlXPathContext **xpath_context, int *ret_code)
procedure XPath_Proc_Parse(Filename : in Interfaces.C.Strings.chars_ptr;
Suppress_Error_Msgs : in Interfaces.C.int;
Xml_Doc : in out System.Address;
XPath_Context : in out System.Address;
Ret_Code : out Interfaces.C.int);
pragma Import(C, XPath_Proc_Parse, "xpath_proc_parse");
-- void xpath_proc_cleanup(xmlDoc *xml_doc, xmlXPathContext *xpath_context)
procedure XPath_Proc_Cleanup(Xml_Doc : in System.Address;
XPath_Context : in System.Address);
pragma Import(C, XPath_Proc_Cleanup, "xpath_proc_cleanup");
-- void xpath_proc_get_value(const char *xpath_expr, xmlXPathContext *xpath_context, char **result, int *ret_code)
procedure XPath_Proc_Get_Value(XPath_Expr : in Interfaces.C.Strings.chars_ptr;
XPath_Context : in System.Address;
Result : in out Interfaces.C.Strings.chars_ptr;
Ret_Code : out Interfaces.C.int);
pragma Import(C, XPath_Proc_Get_Value, "xpath_proc_get_value");
procedure Initialize
is
begin
XPath_Proc_Initialize;
end Initialize;
procedure Finalize
is
begin
XPath_Proc_Finalize;
end Finalize;
procedure Parse_File(Filename : in Ada.Strings.Unbounded.Unbounded_String;
Context : out Context_T;
Success : out Boolean;
Silent : in Boolean := True)
is
RC : Interfaces.C.int := XPATH_PROC_RET_CODE_FAILURE_C;
Fname : Interfaces.C.Strings.chars_ptr := Interfaces.C.Strings.Null_Ptr;
Suppress_Error_Msgs : Interfaces.C.int := 0;
begin
Fname := Interfaces.C.Strings.New_String(Ada.Strings.Unbounded.To_String(Filename));
if Silent then
Suppress_Error_Msgs := 1;
else
Suppress_Error_Msgs := 0;
end if;
XPath_Proc_Parse(Filename => Fname,
Suppress_Error_Msgs => Suppress_Error_Msgs,
Xml_Doc => Context.Xml_Doc,
XPath_Context => Context.XPath_Ctx,
Ret_Code => RC);
Success := RC = XPATH_PROC_RET_CODE_SUCCESS_C;
if Fname /= Interfaces.C.Strings.Null_Ptr then
Interfaces.C.Strings.Free(Fname);
end if;
end Parse_File;
procedure Get_Value(XPath_Expression : in Ada.Strings.Unbounded.Unbounded_String;
Context : in Context_T;
Value : out Ada.Strings.Unbounded.Unbounded_String)
is
XPath_Expr : Interfaces.C.Strings.chars_ptr := Interfaces.C.Strings.Null_Ptr;
Result : Interfaces.C.Strings.chars_ptr := Interfaces.C.Strings.Null_Ptr;
RC : Interfaces.C.int := XPATH_PROC_RET_CODE_FAILURE_C;
begin
XPath_Expr := Interfaces.C.Strings.New_String(Ada.Strings.Unbounded.To_String(XPath_Expression));
XPath_Proc_Get_Value(XPath_Expr => XPath_Expr,
XPath_Context => Context.XPath_Ctx,
Result => Result,
Ret_Code => RC);
if RC = XPATH_PROC_RET_CODE_SUCCESS_C then
Value := Ada.Strings.Unbounded.To_Unbounded_String(Interfaces.C.Strings.Value(Result));
else
Value := Empty_String_C;
end if;
Interfaces.C.Strings.Free(XPath_Expr);
end Get_Value;
procedure Free_Resources(Context : in Context_T)
is
begin
XPath_Proc_Cleanup(Xml_Doc => Context.Xml_Doc,
XPath_Context => Context.XPath_Ctx);
end Free_Resources;
end XPATH_UTILS;
|
--::::::::::
--screen.ads
--::::::::::
PACKAGE Screen IS
-- Procedures for drawing pictures on ANSI Terminal Screen
ScreenDepth : CONSTANT Integer := 24;
ScreenWidth : CONSTANT Integer := 80;
SUBTYPE Depth IS Integer RANGE 1..ScreenDepth;
SUBTYPE Width IS Integer RANGE 1..ScreenWidth;
PROCEDURE Beep;
PROCEDURE ClearScreen;
PROCEDURE MoveCursor (Column : Width; Row : Depth);
END Screen;
--::::::::::
--windows.ads
--::::::::::
WITH Screen;
USE Screen;
PACKAGE Windows IS
TYPE Window IS PRIVATE;
PROCEDURE Open (W : IN OUT Window; -- Window variable returned
Row : Depth; -- Upper left corner
Column : Width;
Height : Depth; -- Size of window
Width : Screen.Width);
-- Create a window variable and open the window for writing.
-- No checks for overlap of windows are made.
PROCEDURE Close (W : IN OUT Window);
-- Close window and clear window variable.
PROCEDURE Title (W : IN OUT Window;
Name : String;
Under : Character);
-- Put a title name at the top of the window. If the parameter
-- under <> 0C or ' ', underline the title with the specified character.
PROCEDURE Borders (W : IN OUT Window;
Corner, Down, Across : Character);
-- Draw border around current writable area in window with characters
-- specified. Call this BEFORE Title.
PROCEDURE Gotorowcolumn (W : IN OUT Window;
Row : Depth;
Column : Width);
-- Goto the row and column specified. Coordinates are relative to the
-- upper left corner of window, which is (1, 1)
PROCEDURE Put (W : IN OUT Window;
Ch : Character);
-- put one character to the window.
-- If end of column, go to the next row.
-- If end of window, go to the top of the window.
PROCEDURE Put_String (W : IN OUT Window;
S : String);
-- put a string to window.
PROCEDURE New_Line (W : IN OUT Window);
-- Go to beginning of next line. Next line is
-- not blanked until next character is written
PRIVATE
TYPE Window IS
RECORD
Currentrow, -- Current cursor row
Firstrow,
Lastrow : Depth;
Currentcolumn, -- Current cursor column
Firstcolumn,
Lastcolumn : Width;
END RECORD;
END Windows;
--::::::::::
--screen.adb
--::::::::::
WITH Text_IO;
WITH My_Int_IO;
PACKAGE BODY Screen IS
-- Procedures for drawing pictures on ANSI Terminal Screen
PROCEDURE Beep IS
BEGIN
Text_IO.Put (Item => ASCII.BEL);
END Beep;
PROCEDURE ClearScreen IS
BEGIN
Text_IO.Put (Item => ASCII.ESC);
Text_IO.Put (Item => "[2J");
END ClearScreen;
PROCEDURE MoveCursor (Column : Width; Row : Depth) IS
BEGIN
Text_IO.New_Line;
Text_IO.Put (Item => ASCII.ESC);
Text_IO.Put ("[");
My_Int_IO.Put (Item => Row, Width => 1);
Text_IO.Put (Item => ';');
My_Int_IO.Put (Item => Column, Width => 1);
Text_IO.Put (Item => 'f');
END MoveCursor;
END Screen;
--::::::::::
--windows.adb
--::::::::::
WITH Text_IO, My_Int_IO, Screen;
USE Text_IO, My_Int_IO, Screen;
PACKAGE BODY Windows IS
CursorRow : Depth := 1; -- Current cursor position
CursorCol : Width := 1;
PROCEDURE Open (W : IN OUT Window;
Row : Depth;
Column : Width;
Height : Depth;
Width : Screen.Width) IS
--Put the Window's cursor in upper left corner
BEGIN
W.CurrentRow := Row;
W.FirstRow := Row;
W.LastRow := Row + Height - 1;
W.CurrentColumn := Column;
W.FirstColumn := Column;
W.LastColumn := Column + Width - 1;
END Open;
PROCEDURE Close (W : IN OUT Window) IS
BEGIN
NULL;
END Close;
PROCEDURE Title (W : IN OUT Window;
name : String;
under : CHARACTER) IS
-- Put name at the top of the Window. If under <> ' ', underline
-- the title.
i : Width;
BEGIN
-- Put name on top line
W.CurrentColumn := W.FirstColumn;
W.CurrentRow := W.FirstRow;
Put_String (w, name);
new_line (w);
-- Underline name if desired, and move the First line of the Window
-- below the title
IF under = ' ' THEN
W.FirstRow := W.FirstRow + 1;
ELSE
FOR i IN W.FirstColumn .. W.LastColumn LOOP
Put (w, under);
END LOOP;
new_line (w);
W.FirstRow := W.FirstRow + 2;
END IF;
END Title;
PROCEDURE GotoRowColumn (w : IN OUT Window;
Row : Depth;
Column : Width) IS
-- Relative to writable Window boundaries, of course
BEGIN
W.CurrentRow := W.FirstRow + Row;
W.CurrentColumn := W.FirstColumn + Column;
END GotoRowColumn;
PROCEDURE Borders (w : IN OUT Window;
corner, down, across : CHARACTER) IS
-- Draw border around current writable area in Window with characters.
-- Call this BEFORE Title.
i : Depth;
j : Width;
BEGIN
-- Put top line of border
MoveCursor (W.FirstColumn, W.FirstRow);
Text_IO.Put (corner);
FOR j IN W.FirstColumn + 1 .. W.LastColumn - 1 LOOP
Text_IO.Put (across);
END LOOP;
Text_IO.Put (corner);
-- Put the two side lines
FOR i IN W.FirstRow + 1 .. W.LastRow - 1 LOOP
MoveCursor (W.FirstColumn, i);
Text_IO.Put (down);
MoveCursor (W.LastColumn, i);
Text_IO.Put (down);
END LOOP;
-- Put the bottom line of the border
MoveCursor (W.FirstColumn, W.LastRow);
Text_IO.Put (corner);
FOR j IN W.FirstColumn + 1 .. W.LastColumn - 1 LOOP
Text_IO.Put (across);
END LOOP;
Text_IO.Put (corner);
-- Put the cursor at the very end of the Window
CursorRow := W.LastRow;
CursorCol := W.LastColumn + 1;
-- Make the Window smaller by one character on each side
W.FirstRow := W.FirstRow + 1;
W.CurrentRow := W.FirstRow;
W.LastRow := W.LastRow - 1;
W.FirstColumn := W.FirstColumn + 1;
W.CurrentColumn := W.FirstColumn;
W.LastColumn := W.LastColumn - 1;
END Borders;
PROCEDURE EraseToEndOfLine (W : IN OUT Window) IS
i : Width;
BEGIN
MoveCursor (W.CurrentColumn, W.CurrentRow);
FOR i IN W.CurrentColumn .. W.LastColumn LOOP
Text_IO.Put (' ');
END LOOP;
MoveCursor (W.CurrentColumn, W.CurrentRow);
CursorCol := W.CurrentColumn;
CursorRow := W.CurrentRow;
END EraseToEndOfLine;
PROCEDURE Put (W : IN OUT Window;
ch : CHARACTER) IS
-- If after end of line, move to First character of next line
-- If about to write First character on line, blank rest of line.
-- Put character.
BEGIN
IF Ch = ASCII.CR THEN
New_Line (W);
RETURN;
END IF;
-- If at end of current line, move to next line
IF W.CurrentColumn > W.LastColumn THEN
IF W.CurrentRow = W.LastRow THEN
W.CurrentRow := W.FirstRow;
ELSE
W.CurrentRow := W.CurrentRow + 1;
END IF;
W.CurrentColumn := W.FirstColumn;
END IF;
-- If at W.First char, erase line
IF W.CurrentColumn = W.FirstColumn THEN
EraseToEndOfLine (W);
END IF;
-- Put physical cursor at Window's cursor
IF (CursorCol /= W.CurrentColumn) OR (CursorRow /= W.CurrentRow) THEN
MoveCursor (W.CurrentColumn, W.CurrentRow);
CursorRow := W.CurrentRow;
END IF;
IF Ch = ASCII.BS THEN
-- Special backspace handling
IF W.CurrentColumn /= W.FirstColumn THEN
Text_IO.Put (Ch);
W.CurrentColumn := W.CurrentColumn - 1;
END IF;
ELSE
Text_IO.Put (Ch);
W.CurrentColumn := W.CurrentColumn + 1;
END IF;
CursorCol := W.CurrentColumn;
END Put;
PROCEDURE new_line (W : IN OUT Window) IS
col : Width;
-- If not after line, blank rest of line.
-- Move to First character of next line
BEGIN
IF W.CurrentColumn = 0 THEN
EraseToEndOfLine (W);
END IF;
IF W.CurrentRow = W.LastRow THEN
W.CurrentRow := W.FirstRow;
ELSE
W.CurrentRow := W.CurrentRow + 1;
END IF;
W.CurrentColumn := W.FirstColumn;
END new_line;
PROCEDURE Put_String (W : IN OUT Window;
S : String) IS
BEGIN
FOR I IN S'FIRST .. S'LAST LOOP
Put (W, S (i));
END LOOP;
END Put_String;
BEGIN -- Windows
ClearScreen;
MoveCursor (1, 1);
END Windows;
--::::::::::
--roomwind.adb
--::::::::::
WITH Windows;
WITH Chop;
WITH Phil;
WITH Calendar;
PRAGMA Elaborate(Phil);
PACKAGE BODY Room IS
Phils: ARRAY(Table_Type) OF Phil.Philosopher;
Phil_Windows: ARRAY(Table_Type) OF Windows.Window;
TYPE Phil_Names IS (Dijkstra, Texel, Booch, Ichbiah, Stroustrup);
TASK BODY Head_Waiter IS
T : Integer;
Start_Time: Calendar.Time;
BEGIN
ACCEPT Open_The_Room;
Start_Time := Calendar.Clock;
Windows.Open(Phil_Windows(1),1,23,7,30);
Windows.Borders(Phil_Windows(1),'+','|','-');
Windows.Title(Phil_Windows(1), "Eddy Dijkstra",'-');
Phils(1).Come_To_Life(1,1,2);
Windows.Open(Phil_Windows(3),9,50,7,30);
Windows.Borders(Phil_Windows(3),'+','|','-');
Windows.Title(Phil_Windows(3), "Grady Booch",'-');
Phils(3).Come_To_Life(3,3,4);
Windows.Open(Phil_Windows(2),9,2,7,30);
Windows.Borders(Phil_Windows(2),'+','|','-');
Windows.Title(Phil_Windows(2), "Putnam Texel",'-');
Phils(2).Come_To_Life(2,2,3);
Windows.Open(Phil_Windows(5),17,41,7,30);
Windows.Borders(Phil_Windows(5),'+','|','-');
Windows.Title(Phil_Windows(5), "Bjarne Stroustrup",'-');
Phils(5).Come_To_Life(5,1,5);
Windows.Open(Phil_Windows(4),17,8,7,30);
Windows.Borders(Phil_Windows(4),'+','|','-');
Windows.Title(Phil_Windows(4), "Jean Ichbiah",'-');
Phils(4).Come_To_Life(4,4,5);
LOOP
SELECT
ACCEPT Report_State(Which_Phil: Table_Type;
State: Phil.States;
How_Long: Natural := 0) DO
T := Integer(Calendar."-"(Calendar.Clock,Start_Time));
Windows.Put_String(Phil_Windows(Which_Phil),
"T=" & Integer'Image(T) & " ");
CASE State IS
WHEN Phil.Breathing =>
Windows.Put_String(Phil_Windows(Which_Phil), "Breathing...");
Windows.New_Line(Phil_Windows(Which_Phil));
WHEN Phil.Thinking =>
Windows.Put_String(Phil_Windows(Which_Phil),
"Thinking"
& Integer'Image(How_Long)
& " seconds.");
Windows.New_Line(Phil_Windows(Which_Phil));
WHEN Phil.Eating =>
Windows.Put_String(Phil_Windows(Which_Phil),
"Eating"
& Integer'Image(How_Long)
& " seconds.");
Windows.New_Line(Phil_Windows(Which_Phil));
WHEN Phil.Done_Eating =>
Windows.Put_String(Phil_Windows(Which_Phil), "Yum-yum (burp)");
Windows.New_Line(Phil_Windows(Which_Phil));
WHEN Phil.Got_One_Stick =>
Windows.Put_String(Phil_Windows(Which_Phil),
"First chopstick"
& Integer'Image(How_Long));
Windows.New_Line(Phil_Windows(Which_Phil));
WHEN Phil.Got_Other_Stick =>
Windows.Put_String(Phil_Windows(Which_Phil),
"Second chopstick"
& Integer'Image(How_Long));
Windows.New_Line(Phil_Windows(Which_Phil));
END CASE;
END Report_State;
OR
TERMINATE;
END SELECT;
END LOOP;
END Head_Waiter;
END Room;
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2016 onox <denkpadje@gmail.com>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Unchecked_Conversion;
with GL.API;
package body GL.Barriers is
procedure Texture_Barrier is
begin
API.Texture_Barrier.Ref.all;
end Texture_Barrier;
procedure Memory_Barrier (Bits : Memory_Barrier_Bits) is
use type Low_Level.Bitfield;
function Convert is new Ada.Unchecked_Conversion
(Source => Memory_Barrier_Bits, Target => Low_Level.Bitfield);
Raw_Bits : constant Low_Level.Bitfield :=
Convert (Bits) and 2#1111011111101110#;
begin
API.Memory_Barrier.Ref (Raw_Bits);
end Memory_Barrier;
procedure Memory_Barrier_By_Region (Bits : Memory_Barrier_Bits) is
use type Low_Level.Bitfield;
function Convert is new Ada.Unchecked_Conversion
(Source => Memory_Barrier_Bits, Target => Low_Level.Bitfield);
Raw_Bits : constant Low_Level.Bitfield :=
Convert (Bits) and 2#0011010000101100#;
begin
API.Memory_Barrier_By_Region.Ref (Raw_Bits);
end Memory_Barrier_By_Region;
end GL.Barriers;
|
-- This file is generated by SWIG. Please do *not* modify by hand.
--
with Interfaces.C.Pointers;
with Interfaces.C.Strings;
with System;
package clib.Pointers is
-- time_t_Pointer
--
type time_t_Pointer is access all clib.time_t;
-- time_t_Pointers
--
type time_t_Pointers is
array
(Interfaces.C.size_t range <>) of aliased clib.Pointers.time_t_Pointer;
-- FILE_Pointer
--
type FILE_Pointer is access all clib.FILE;
-- FILE_Pointers
--
type FILE_Pointers is
array
(Interfaces.C.size_t range <>) of aliased clib.Pointers.FILE_Pointer;
end clib.Pointers;
|
with
Interfaces.C,
System,
FLTK.Text_Buffers;
use type
Interfaces.C.int,
System.Address;
package body FLTK.Widgets.Groups.Text_Displays is
procedure text_display_set_draw_hook
(W, D : in System.Address);
pragma Import (C, text_display_set_draw_hook, "text_display_set_draw_hook");
pragma Inline (text_display_set_draw_hook);
procedure text_display_set_handle_hook
(W, H : in System.Address);
pragma Import (C, text_display_set_handle_hook, "text_display_set_handle_hook");
pragma Inline (text_display_set_handle_hook);
function new_fl_text_display
(X, Y, W, H : in Interfaces.C.int;
Label : in Interfaces.C.char_array)
return System.Address;
pragma Import (C, new_fl_text_display, "new_fl_text_display");
pragma Inline (new_fl_text_display);
procedure free_fl_text_display
(TD : in System.Address);
pragma Import (C, free_fl_text_display, "free_fl_text_display");
pragma Inline (free_fl_text_display);
function fl_text_display_get_buffer
(TD : in System.Address)
return System.Address;
pragma Import (C, fl_text_display_get_buffer, "fl_text_display_get_buffer");
pragma Inline (fl_text_display_get_buffer);
procedure fl_text_display_set_buffer
(TD, TB : in System.Address);
pragma Import (C, fl_text_display_set_buffer, "fl_text_display_set_buffer");
pragma Inline (fl_text_display_set_buffer);
procedure fl_text_display_highlight_data
(TD, TB, ST : in System.Address;
L : in Interfaces.C.int);
pragma Import (C, fl_text_display_highlight_data, "fl_text_display_highlight_data");
pragma Inline (fl_text_display_highlight_data);
procedure fl_text_display_highlight_data2
(TD, TB, ST : in System.Address;
L : in Interfaces.C.int;
C : in Interfaces.C.unsigned;
B, A : in System.Address);
pragma Import (C, fl_text_display_highlight_data2, "fl_text_display_highlight_data2");
pragma Inline (fl_text_display_highlight_data2);
function fl_text_display_col_to_x
(TD : in System.Address;
C : in Interfaces.C.double)
return Interfaces.C.double;
pragma Import (C, fl_text_display_col_to_x, "fl_text_display_col_to_x");
pragma Inline (fl_text_display_col_to_x);
function fl_text_display_x_to_col
(TD : in System.Address;
X : in Interfaces.C.double)
return Interfaces.C.double;
pragma Import (C, fl_text_display_x_to_col, "fl_text_display_x_to_col");
pragma Inline (fl_text_display_x_to_col);
function fl_text_display_in_selection
(TD : in System.Address;
X, Y : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_text_display_in_selection, "fl_text_display_in_selection");
pragma Inline (fl_text_display_in_selection);
function fl_text_display_position_to_xy
(TD : in System.Address;
P : in Interfaces.C.int;
X, Y : out Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_text_display_position_to_xy, "fl_text_display_position_to_xy");
pragma Inline (fl_text_display_position_to_xy);
function fl_text_display_get_cursor_color
(TD : in System.Address)
return Interfaces.C.unsigned;
pragma Import (C, fl_text_display_get_cursor_color, "fl_text_display_get_cursor_color");
pragma Inline (fl_text_display_get_cursor_color);
procedure fl_text_display_set_cursor_color
(TD : in System.Address;
C : in Interfaces.C.unsigned);
pragma Import (C, fl_text_display_set_cursor_color, "fl_text_display_set_cursor_color");
pragma Inline (fl_text_display_set_cursor_color);
procedure fl_text_display_set_cursor_style
(TD : in System.Address;
S : in Interfaces.C.int);
pragma Import (C, fl_text_display_set_cursor_style, "fl_text_display_set_cursor_style");
pragma Inline (fl_text_display_set_cursor_style);
procedure fl_text_display_hide_cursor
(TD : in System.Address);
pragma Import (C, fl_text_display_hide_cursor, "fl_text_display_hide_cursor");
pragma Inline (fl_text_display_hide_cursor);
procedure fl_text_display_show_cursor
(TD : in System.Address);
pragma Import (C, fl_text_display_show_cursor, "fl_text_display_show_cursor");
pragma Inline (fl_text_display_show_cursor);
function fl_text_display_get_text_color
(TD : in System.Address)
return Interfaces.C.unsigned;
pragma Import (C, fl_text_display_get_text_color, "fl_text_display_get_text_color");
pragma Inline (fl_text_display_get_text_color);
procedure fl_text_display_set_text_color
(TD : in System.Address;
C : in Interfaces.C.unsigned);
pragma Import (C, fl_text_display_set_text_color, "fl_text_display_set_text_color");
pragma Inline (fl_text_display_set_text_color);
function fl_text_display_get_text_font
(TD : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_text_display_get_text_font, "fl_text_display_get_text_font");
pragma Inline (fl_text_display_get_text_font);
procedure fl_text_display_set_text_font
(TD : in System.Address;
F : in Interfaces.C.int);
pragma Import (C, fl_text_display_set_text_font, "fl_text_display_set_text_font");
pragma Inline (fl_text_display_set_text_font);
function fl_text_display_get_text_size
(TD : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_text_display_get_text_size, "fl_text_display_get_text_size");
pragma Inline (fl_text_display_get_text_size);
procedure fl_text_display_set_text_size
(TD : in System.Address;
S : in Interfaces.C.int);
pragma Import (C, fl_text_display_set_text_size, "fl_text_display_set_text_size");
pragma Inline (fl_text_display_set_text_size);
procedure fl_text_display_insert
(TD : in System.Address;
I : in Interfaces.C.char_array);
pragma Import (C, fl_text_display_insert, "fl_text_display_insert");
pragma Inline (fl_text_display_insert);
procedure fl_text_display_overstrike
(TD : in System.Address;
T : in Interfaces.C.char_array);
pragma Import (C, fl_text_display_overstrike, "fl_text_display_overstrike");
pragma Inline (fl_text_display_overstrike);
function fl_text_display_get_insert_pos
(TD : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_text_display_get_insert_pos, "fl_text_display_get_insert_pos");
pragma Inline (fl_text_display_get_insert_pos);
procedure fl_text_display_set_insert_pos
(TD : in System.Address;
P : in Interfaces.C.int);
pragma Import (C, fl_text_display_set_insert_pos, "fl_text_display_set_insert_pos");
pragma Inline (fl_text_display_set_insert_pos);
procedure fl_text_display_show_insert_pos
(TD : in System.Address);
pragma Import (C, fl_text_display_show_insert_pos, "fl_text_display_show_insert_pos");
pragma Inline (fl_text_display_show_insert_pos);
function fl_text_display_word_start
(TD : in System.Address;
P : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_text_display_word_start, "fl_text_display_word_start");
pragma Inline (fl_text_display_word_start);
function fl_text_display_word_end
(TD : in System.Address;
P : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_text_display_word_end, "fl_text_display_word_end");
pragma Inline (fl_text_display_word_end);
procedure fl_text_display_next_word
(TD : in System.Address);
pragma Import (C, fl_text_display_next_word, "fl_text_display_next_word");
pragma Inline (fl_text_display_next_word);
procedure fl_text_display_previous_word
(TD : in System.Address);
pragma Import (C, fl_text_display_previous_word, "fl_text_display_previous_word");
pragma Inline (fl_text_display_previous_word);
procedure fl_text_display_wrap_mode
(TD : in System.Address;
W, M : in Interfaces.C.int);
pragma Import (C, fl_text_display_wrap_mode, "fl_text_display_wrap_mode");
pragma Inline (fl_text_display_wrap_mode);
function fl_text_display_line_start
(TD : in System.Address;
S : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_text_display_line_start, "fl_text_display_line_start");
pragma Inline (fl_text_display_line_start);
function fl_text_display_line_end
(TD : in System.Address;
S, P : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_text_display_line_end, "fl_text_display_line_end");
pragma Inline (fl_text_display_line_end);
function fl_text_display_count_lines
(TD : in System.Address;
S, F, P : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_text_display_count_lines, "fl_text_display_count_lines");
pragma Inline (fl_text_display_count_lines);
function fl_text_display_skip_lines
(TD : in System.Address;
S, L, P : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_text_display_skip_lines, "fl_text_display_skip_lines");
pragma Inline (fl_text_display_skip_lines);
function fl_text_display_rewind_lines
(TD : in System.Address;
S, L : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_text_display_rewind_lines, "fl_text_display_rewind_lines");
pragma Inline (fl_text_display_rewind_lines);
function fl_text_display_get_linenumber_align
(TD : in System.Address)
return Interfaces.C.unsigned;
pragma Import (C, fl_text_display_get_linenumber_align,
"fl_text_display_get_linenumber_align");
pragma Inline (fl_text_display_get_linenumber_align);
procedure fl_text_display_set_linenumber_align
(TD : in System.Address;
A : in Interfaces.C.unsigned);
pragma Import (C, fl_text_display_set_linenumber_align,
"fl_text_display_set_linenumber_align");
pragma Inline (fl_text_display_set_linenumber_align);
function fl_text_display_get_linenumber_bgcolor
(TD : in System.Address)
return Interfaces.C.unsigned;
pragma Import (C, fl_text_display_get_linenumber_bgcolor,
"fl_text_display_get_linenumber_bgcolor");
pragma Inline (fl_text_display_get_linenumber_bgcolor);
procedure fl_text_display_set_linenumber_bgcolor
(TD : in System.Address;
C : in Interfaces.C.unsigned);
pragma Import (C, fl_text_display_set_linenumber_bgcolor,
"fl_text_display_set_linenumber_bgcolor");
pragma Inline (fl_text_display_set_linenumber_bgcolor);
function fl_text_display_get_linenumber_fgcolor
(TD : in System.Address)
return Interfaces.C.unsigned;
pragma Import (C, fl_text_display_get_linenumber_fgcolor,
"fl_text_display_get_linenumber_fgcolor");
pragma Inline (fl_text_display_get_linenumber_fgcolor);
procedure fl_text_display_set_linenumber_fgcolor
(TD : in System.Address;
C : in Interfaces.C.unsigned);
pragma Import (C, fl_text_display_set_linenumber_fgcolor,
"fl_text_display_set_linenumber_fgcolor");
pragma Inline (fl_text_display_set_linenumber_fgcolor);
function fl_text_display_get_linenumber_font
(TD : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_text_display_get_linenumber_font,
"fl_text_display_get_linenumber_font");
pragma Inline (fl_text_display_get_linenumber_font);
procedure fl_text_display_set_linenumber_font
(TD : in System.Address;
F : in Interfaces.C.int);
pragma Import (C, fl_text_display_set_linenumber_font,
"fl_text_display_set_linenumber_font");
pragma Inline (fl_text_display_set_linenumber_font);
function fl_text_display_get_linenumber_size
(TD : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_text_display_get_linenumber_size,
"fl_text_display_get_linenumber_size");
pragma Inline (fl_text_display_get_linenumber_size);
procedure fl_text_display_set_linenumber_size
(TD : in System.Address;
S : in Interfaces.C.int);
pragma Import (C, fl_text_display_set_linenumber_size,
"fl_text_display_set_linenumber_size");
pragma Inline (fl_text_display_set_linenumber_size);
function fl_text_display_get_linenumber_width
(TD : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_text_display_get_linenumber_width,
"fl_text_display_get_linenumber_width");
pragma Inline (fl_text_display_get_linenumber_width);
procedure fl_text_display_set_linenumber_width
(TD : in System.Address;
W : in Interfaces.C.int);
pragma Import (C, fl_text_display_set_linenumber_width,
"fl_text_display_set_linenumber_width");
pragma Inline (fl_text_display_set_linenumber_width);
function fl_text_display_move_down
(TD : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_text_display_move_down, "fl_text_display_move_down");
pragma Inline (fl_text_display_move_down);
function fl_text_display_move_left
(TD : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_text_display_move_left, "fl_text_display_move_left");
pragma Inline (fl_text_display_move_left);
function fl_text_display_move_right
(TD : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_text_display_move_right, "fl_text_display_move_right");
pragma Inline (fl_text_display_move_right);
function fl_text_display_move_up
(TD : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_text_display_move_up, "fl_text_display_move_up");
pragma Inline (fl_text_display_move_up);
procedure fl_text_display_scroll
(TD : in System.Address;
L : in Interfaces.C.int);
pragma Import (C, fl_text_display_scroll, "fl_text_display_scroll");
pragma Inline (fl_text_display_scroll);
function fl_text_display_get_scrollbar_align
(TD : in System.Address)
return Interfaces.C.unsigned;
pragma Import (C, fl_text_display_get_scrollbar_align, "fl_text_display_get_scrollbar_align");
pragma Inline (fl_text_display_get_scrollbar_align);
procedure fl_text_display_set_scrollbar_align
(TD : in System.Address;
A : in Interfaces.C.unsigned);
pragma Import (C, fl_text_display_set_scrollbar_align, "fl_text_display_set_scrollbar_align");
pragma Inline (fl_text_display_set_scrollbar_align);
function fl_text_display_get_scrollbar_width
(TD : in System.Address)
return Interfaces.C.int;
pragma Import (C, fl_text_display_get_scrollbar_width, "fl_text_display_get_scrollbar_width");
pragma Inline (fl_text_display_get_scrollbar_width);
procedure fl_text_display_set_scrollbar_width
(TD : in System.Address;
W : in Interfaces.C.int);
pragma Import (C, fl_text_display_set_scrollbar_width, "fl_text_display_set_scrollbar_width");
pragma Inline (fl_text_display_set_scrollbar_width);
procedure fl_text_display_redisplay_range
(TD : in System.Address;
S, F : in Interfaces.C.int);
pragma Import (C, fl_text_display_redisplay_range, "fl_text_display_redisplay_range");
pragma Inline (fl_text_display_redisplay_range);
procedure fl_text_display_draw
(W : in System.Address);
pragma Import (C, fl_text_display_draw, "fl_text_display_draw");
pragma Inline (fl_text_display_draw);
function fl_text_display_handle
(W : in System.Address;
E : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_text_display_handle, "fl_text_display_handle");
pragma Inline (fl_text_display_handle);
procedure Style_Hook
(C : in Interfaces.C.int;
D : in System.Address)
is
use Styles; -- for maximum stylin'
Ada_Widget : access Text_Display'Class :=
Text_Display_Convert.To_Pointer (D);
begin
if Ada_Widget.Style_Callback /= null then
Ada_Widget.Style_Callback (Character'Val (C), Text_Display (Ada_Widget.all));
end if;
end Style_Hook;
procedure Finalize
(This : in out Text_Display) is
begin
if This.Void_Ptr /= System.Null_Address and then
This in Text_Display'Class
then
This.Clear;
free_fl_text_display (This.Void_Ptr);
This.Void_Ptr := System.Null_Address;
end if;
Finalize (Group (This));
end Finalize;
package body Forge is
function Create
(X, Y, W, H : in Integer;
Text : in String)
return Text_Display is
begin
return This : Text_Display do
This.Void_Ptr := new_fl_text_display
(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));
text_display_set_draw_hook (This.Void_Ptr, Draw_Hook'Address);
text_display_set_handle_hook (This.Void_Ptr, Handle_Hook'Address);
end return;
end Create;
end Forge;
package body Styles is
function Item
(Tint : in Color;
Font : in Font_Kind;
Size : in Font_Size)
return Style_Entry is
begin
return This : Style_Entry do
This.Attr := 0;
This.Col := Interfaces.C.unsigned (Tint);
This.Font := Font_Kind'Pos (Font);
This.Size := Interfaces.C.int (Size);
end return;
end Item;
pragma Inline (Item);
end Styles;
function Get_Buffer
(This : in Text_Display)
return FLTK.Text_Buffers.Text_Buffer_Reference is
begin
return Ref : FLTK.Text_Buffers.Text_Buffer_Reference (This.Buffer);
end Get_Buffer;
procedure Set_Buffer
(This : in out Text_Display;
Buff : in out FLTK.Text_Buffers.Text_Buffer) is
begin
This.Buffer := Buff'Unchecked_Access;
fl_text_display_set_buffer (This.Void_Ptr, Wrapper (Buff).Void_Ptr);
end Set_Buffer;
procedure Highlight_Data
(This : in out Text_Display;
Buff : in out FLTK.Text_Buffers.Text_Buffer;
Table : in Styles.Style_Array) is
begin
fl_text_display_highlight_data
(This.Void_Ptr,
Wrapper (Buff).Void_Ptr,
Table'Address,
Table'Length);
end Highlight_Data;
procedure Highlight_Data
(This : in out Text_Display;
Buff : in out FLTK.Text_Buffers.Text_Buffer;
Table : in Styles.Style_Array;
Unfinished : in Styles.Style_Index;
Callback : in Styles.Unfinished_Style_Callback) is
begin
This.Style_Callback := Callback;
fl_text_display_highlight_data2
(This.Void_Ptr,
Wrapper (Buff).Void_Ptr,
Table'Address,
Table'Length,
Character'Pos (Character (Unfinished)),
Style_Hook'Address,
This'Address);
end Highlight_Data;
function Col_To_X
(This : in Text_Display;
Col_Num : in Integer)
return Integer is
begin
return Integer (Interfaces.C.double'Rounding
(fl_text_display_col_to_x (This.Void_Ptr, Interfaces.C.double (Col_Num))));
end Col_To_X;
function X_To_Col
(This : in Text_Display;
X_Pos : in Integer)
return Integer is
begin
return Integer (Interfaces.C.double'Rounding
(fl_text_display_x_to_col (This.Void_Ptr, Interfaces.C.double (X_Pos))));
end X_To_Col;
function In_Selection
(This : in Text_Display;
X, Y : in Integer)
return Boolean is
begin
return fl_text_display_in_selection
(This.Void_Ptr, Interfaces.C.int (X), Interfaces.C.int (Y)) /= 0;
end In_Selection;
procedure Position_To_XY
(This : in Text_Display;
Pos : in Integer;
X, Y : out Integer;
Vert_Out : out Boolean) is
begin
Vert_Out := fl_text_display_position_to_xy
(This.Void_Ptr,
Interfaces.C.int (Pos),
Interfaces.C.int (X),
Interfaces.C.int (Y)) /= 0;
end Position_To_XY;
function Get_Cursor_Color
(This : in Text_Display)
return Color is
begin
return Color (fl_text_display_get_cursor_color (This.Void_Ptr));
end Get_Cursor_Color;
procedure Set_Cursor_Color
(This : in out Text_Display;
Col : in Color) is
begin
fl_text_display_set_cursor_color (This.Void_Ptr, Interfaces.C.unsigned (Col));
end Set_Cursor_Color;
procedure Set_Cursor_Style
(This : in out Text_Display;
Style : in Cursor_Style) is
begin
fl_text_display_set_cursor_style (This.Void_Ptr, Cursor_Style'Pos (Style));
end Set_Cursor_Style;
procedure Hide_Cursor
(This : in out Text_Display) is
begin
fl_text_display_hide_cursor (This.Void_Ptr);
end Hide_Cursor;
procedure Show_Cursor
(This : in out Text_Display) is
begin
fl_text_display_show_cursor (This.Void_Ptr);
end Show_Cursor;
function Get_Text_Color
(This : in Text_Display)
return Color is
begin
return Color (fl_text_display_get_text_color (This.Void_Ptr));
end Get_Text_Color;
procedure Set_Text_Color
(This : in out Text_Display;
Col : in Color) is
begin
fl_text_display_set_text_color (This.Void_Ptr, Interfaces.C.unsigned (Col));
end Set_Text_Color;
function Get_Text_Font
(This : in Text_Display)
return Font_Kind is
begin
return Font_Kind'Val (fl_text_display_get_text_font (This.Void_Ptr));
end Get_Text_Font;
procedure Set_Text_Font
(This : in out Text_Display;
Font : in Font_Kind) is
begin
fl_text_display_set_text_font (This.Void_Ptr, Font_Kind'Pos (Font));
end Set_Text_Font;
function Get_Text_Size
(This : in Text_Display)
return Font_Size is
begin
return Font_Size (fl_text_display_get_text_size (This.Void_Ptr));
end Get_Text_Size;
procedure Set_Text_Size
(This : in out Text_Display;
Size : in Font_Size) is
begin
fl_text_display_set_text_size (This.Void_Ptr, Interfaces.C.int (Size));
end Set_Text_Size;
procedure Insert_Text
(This : in out Text_Display;
Item : in String) is
begin
fl_text_display_insert (This.Void_Ptr, Interfaces.C.To_C (Item));
end Insert_Text;
procedure Overstrike
(This : in out Text_Display;
Text : in String) is
begin
fl_text_display_overstrike (This.Void_Ptr, Interfaces.C.To_C (Text));
end Overstrike;
function Get_Insert_Position
(This : in Text_Display)
return Natural is
begin
return Natural (fl_text_display_get_insert_pos (This.Void_Ptr));
end Get_Insert_Position;
procedure Set_Insert_Position
(This : in out Text_Display;
Pos : in Natural) is
begin
fl_text_display_set_insert_pos (This.Void_Ptr, Interfaces.C.int (Pos));
end Set_Insert_Position;
procedure Show_Insert_Position
(This : in out Text_Display) is
begin
fl_text_display_show_insert_pos (This.Void_Ptr);
end Show_Insert_Position;
function Word_Start
(This : in out Text_Display;
Pos : in Natural)
return Natural is
begin
return Natural (fl_text_display_word_start
(This.Void_Ptr,
Interfaces.C.int (Pos)));
end Word_Start;
function Word_End
(This : in out Text_Display;
Pos : in Natural)
return Natural is
begin
return Natural (fl_text_display_word_end
(This.Void_Ptr,
Interfaces.C.int (Pos)));
end Word_End;
procedure Next_Word
(This : in out Text_Display) is
begin
fl_text_display_next_word (This.Void_Ptr);
end Next_Word;
procedure Previous_Word
(This : in out Text_Display) is
begin
fl_text_display_previous_word (This.Void_Ptr);
end Previous_Word;
procedure Set_Wrap_Mode
(This : in out Text_Display;
Mode : in Wrap_Mode;
Margin : in Natural := 0) is
begin
fl_text_display_wrap_mode
(This.Void_Ptr,
Wrap_Mode'Pos (Mode),
Interfaces.C.int (Margin));
end Set_Wrap_Mode;
function Line_Start
(This : in Text_Display;
Pos : in Natural)
return Natural is
begin
return Natural (fl_text_display_line_start
(This.Void_Ptr,
Interfaces.C.int (Pos)));
end Line_Start;
function Line_End
(This : in Text_Display;
Pos : in Natural;
Start_Pos_Is_Line_Start : in Boolean := False)
return Natural is
begin
return Natural (fl_text_display_line_end
(This.Void_Ptr,
Interfaces.C.int (Pos),
Boolean'Pos (Start_Pos_Is_Line_Start)));
end Line_End;
function Count_Lines
(This : in Text_Display;
Start, Finish : in Natural;
Start_Pos_Is_Line_Start : in Boolean := False)
return Natural is
begin
return Natural (fl_text_display_count_lines
(This.Void_Ptr,
Interfaces.C.int (Start),
Interfaces.C.int (Finish),
Boolean'Pos (Start_Pos_Is_Line_Start)));
end Count_Lines;
function Skip_Lines
(This : in Text_Display;
Start, Lines : in Natural;
Start_Pos_Is_Line_Start : in Boolean := False)
return Natural is
begin
return Natural (fl_text_display_skip_lines
(This.Void_Ptr,
Interfaces.C.int (Start),
Interfaces.C.int (Lines),
Boolean'Pos (Start_Pos_Is_Line_Start)));
end Skip_Lines;
function Rewind_Lines
(This : in Text_Display;
Start, Lines : in Natural)
return Natural is
begin
return Natural (fl_text_display_rewind_lines
(This.Void_Ptr,
Interfaces.C.int (Start),
Interfaces.C.int (Lines)));
end Rewind_Lines;
function Get_Linenumber_Alignment
(This : in Text_Display)
return Alignment is
begin
return Alignment (fl_text_display_get_linenumber_align (This.Void_Ptr));
end Get_Linenumber_Alignment;
procedure Set_Linenumber_Alignment
(This : in out Text_Display;
To : in Alignment) is
begin
fl_text_display_set_linenumber_align
(This.Void_Ptr,
Interfaces.C.unsigned (To));
end Set_Linenumber_Alignment;
function Get_Linenumber_Back_Color
(This : in Text_Display)
return Color is
begin
return Color (fl_text_display_get_linenumber_bgcolor (This.Void_Ptr));
end Get_Linenumber_Back_Color;
procedure Set_Linenumber_Back_Color
(This : in out Text_Display;
To : in Color) is
begin
fl_text_display_set_linenumber_bgcolor
(This.Void_Ptr,
Interfaces.C.unsigned (To));
end Set_Linenumber_Back_Color;
function Get_Linenumber_Fore_Color
(This : in Text_Display)
return Color is
begin
return Color (fl_text_display_get_linenumber_fgcolor (This.Void_Ptr));
end Get_Linenumber_Fore_Color;
procedure Set_Linenumber_Fore_Color
(This : in out Text_Display;
To : in Color) is
begin
fl_text_display_set_linenumber_fgcolor
(This.Void_Ptr,
Interfaces.C.unsigned (To));
end Set_Linenumber_Fore_Color;
function Get_Linenumber_Font
(This : in Text_Display)
return Font_Kind is
begin
return Font_Kind'Val (fl_text_display_get_linenumber_font (This.Void_Ptr));
end Get_Linenumber_Font;
procedure Set_Linenumber_Font
(This : in out Text_Display;
To : in Font_Kind) is
begin
fl_text_display_set_linenumber_font
(This.Void_Ptr,
Font_Kind'Pos (To));
end Set_Linenumber_Font;
function Get_Linenumber_Size
(This : in Text_Display)
return Font_Size is
begin
return Font_Size (fl_text_display_get_linenumber_size (This.Void_Ptr));
end Get_Linenumber_Size;
procedure Set_Linenumber_Size
(This : in out Text_Display;
To : in Font_Size) is
begin
fl_text_display_set_linenumber_size
(This.Void_Ptr,
Interfaces.C.int (To));
end Set_Linenumber_Size;
function Get_Linenumber_Width
(This : in Text_Display)
return Natural is
begin
return Natural (fl_text_display_get_linenumber_width (This.Void_Ptr));
end Get_Linenumber_Width;
procedure Set_Linenumber_Width
(This : in out Text_Display;
Width : in Natural) is
begin
fl_text_display_set_linenumber_width
(This.Void_Ptr,
Interfaces.C.int (Width));
end Set_Linenumber_Width;
procedure Move_Down
(This : in out Text_Display) is
begin
if fl_text_display_move_down (This.Void_Ptr) = 0 then
raise Bounds_Error;
end if;
end Move_Down;
procedure Move_Left
(This : in out Text_Display) is
begin
if fl_text_display_move_left (This.Void_Ptr) = 0 then
raise Bounds_Error;
end if;
end Move_Left;
procedure Move_Right
(This : in out Text_Display) is
begin
if fl_text_display_move_right (This.Void_Ptr) = 0 then
raise Bounds_Error;
end if;
end Move_Right;
procedure Move_Up
(This : in out Text_Display) is
begin
if fl_text_display_move_up (This.Void_Ptr) = 0 then
raise Bounds_Error;
end if;
end Move_Up;
procedure Scroll_To
(This : in out Text_Display;
Line : in Natural) is
begin
fl_text_display_scroll (This.Void_Ptr, Interfaces.C.int (Line));
end Scroll_To;
function Get_Scrollbar_Alignment
(This : in Text_Display)
return Alignment is
begin
return Alignment (fl_text_display_get_scrollbar_align (This.Void_Ptr));
end Get_Scrollbar_Alignment;
procedure Set_Scrollbar_Alignment
(This : in out Text_Display;
Align : in Alignment) is
begin
fl_text_display_set_scrollbar_align
(This.Void_Ptr,
Interfaces.C.unsigned (Align));
end Set_Scrollbar_Alignment;
function Get_Scrollbar_Width
(This : in Text_Display)
return Natural is
begin
return Natural (fl_text_display_get_scrollbar_width (This.Void_Ptr));
end Get_Scrollbar_Width;
procedure Set_Scrollbar_Width
(This : in out Text_Display;
Width : in Natural) is
begin
fl_text_display_set_scrollbar_width
(This.Void_Ptr,
Interfaces.C.int (Width));
end Set_Scrollbar_Width;
procedure Redisplay_Range
(This : in out Text_Display;
Start, Finish : in Natural) is
begin
fl_text_display_redisplay_range
(This.Void_Ptr,
Interfaces.C.int (Start),
Interfaces.C.int (Finish));
end Redisplay_Range;
procedure Draw
(This : in out Text_Display) is
begin
fl_text_display_draw (This.Void_Ptr);
end Draw;
function Handle
(This : in out Text_Display;
Event : in Event_Kind)
return Event_Outcome is
begin
return Event_Outcome'Val
(fl_text_display_handle (This.Void_Ptr, Event_Kind'Pos (Event)));
end Handle;
end FLTK.Widgets.Groups.Text_Displays;
|
-----------------------------------------------------------------------
-- Util.Concurrent -- Concurrent Counters
-- Copyright (C) 2009, 2010 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
-- This implementation of atomic counters works only for Intel x86 based
-- platforms. It uses the <b>lock</b> instruction followed by an <b>incl</b>
-- or a <b>decl</b> instruction to implement the atomic operations.
-- (See GNU/Linux atomic.h headers).
with System.Machine_Code;
package body Util.Concurrent.Counters is
use System.Machine_Code;
use Interfaces;
-- ------------------------------
-- Increment the counter atomically.
-- ------------------------------
procedure Increment (C : in out Counter) is
begin
Asm (Template => "lock incl %0",
Volatile => True,
Outputs => Unsigned_32'Asm_Output ("+m", C.Value),
Clobber => "memory");
end Increment;
-- ------------------------------
-- Increment the counter atomically and return the value before increment.
-- ------------------------------
procedure Increment (C : in out Counter;
Value : out Integer) is
Val : Unsigned_32 := 1;
begin
Asm (Template => "lock xaddl %1,%0",
Volatile => True,
Outputs => (Unsigned_32'Asm_Output ("+m", C.Value),
Unsigned_32'Asm_Output ("=r", Val)),
Inputs => Unsigned_32'Asm_Input ("1", Val),
Clobber => "memory");
Value := Integer (Val);
end Increment;
-- ------------------------------
-- Decrement the counter atomically.
-- ------------------------------
procedure Decrement (C : in out Counter) is
begin
Asm (Template => "lock decl %0",
Volatile => True,
Outputs => Unsigned_32'Asm_Output ("+m", C.Value),
Clobber => "memory");
end Decrement;
-- ------------------------------
-- Decrement the counter atomically and return a status.
-- ------------------------------
procedure Decrement (C : in out Counter;
Is_Zero : out Boolean) is
Result : Unsigned_8;
begin
Asm ("lock decl %0; sete %1",
Volatile => True,
Outputs => (Unsigned_32'Asm_Output ("+m", C.Value),
Unsigned_8'Asm_Output ("=qm", Result)));
Is_Zero := Result /= 0;
end Decrement;
-- ------------------------------
-- Get the counter value
-- ------------------------------
function Value (C : in Counter) return Integer is
begin
-- On x86, reading the counter is atomic.
return Integer (C.Value);
end Value;
end Util.Concurrent.Counters;
|
with STM32GD.GPIO; use STM32GD.GPIO;
with STM32GD.GPIO.Pin;
package STM32GD.Board is
package GPIO renames STM32GD.GPIO;
package BUTTON is new GPIO.Pin (Pin => GPIO.Pin_0, Port => GPIO.Port_A);
package LED is new GPIO.Pin (Pin => GPIO.Pin_6, Port => GPIO.Port_F, Mode => GPIO.Mode_Out);
procedure Init;
end STM32GD.Board;
|
package body iconv.Streams is
procedure Adjust_Buffer (
Buffer : in out Buffer_Type;
First : in out Ada.Streams.Stream_Element_Offset;
Last : in out Ada.Streams.Stream_Element_Offset);
procedure Adjust_Buffer (
Buffer : in out Buffer_Type;
First : in out Ada.Streams.Stream_Element_Offset;
Last : in out Ada.Streams.Stream_Element_Offset) is
begin
if First >= Buffer_Type'First + Half_Buffer_Length then
-- shift
declare
New_Last : constant Ada.Streams.Stream_Element_Offset :=
Buffer_Type'First + Last - First;
begin
Buffer (Buffer_Type'First .. New_Last) := Buffer (First .. Last);
First := Buffer_Type'First;
Last := New_Last;
end;
end if;
end Adjust_Buffer;
procedure Initialize (Context : in out Reading_Context_Type);
procedure Initialize (Context : in out Reading_Context_Type) is
begin
Context.First := Buffer_Type'First;
Context.Last := Buffer_Type'First - 1;
Context.Converted_First := Buffer_Type'First;
Context.Converted_Last := Buffer_Type'First - 1;
Context.Status := Continuing;
end Initialize;
procedure Set_Substitute_To_Reading_Converter (
Object : in out Converter;
Substitute : in Ada.Streams.Stream_Element_Array)
renames Set_Substitute; -- iconv.Set_Substitute
procedure Read (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Object : in Converter;
Context : in out Reading_Context_Type);
procedure Read (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset;
Object : in Converter;
Context : in out Reading_Context_Type)
is
Read_Zero : Boolean := False;
begin
Last := Item'First - 1;
while Last < Item'Last loop
-- filling
if Context.Status = Continuing then
Adjust_Buffer (Context.Buffer, Context.First, Context.Last);
if Context.Last /= Buffer_Type'Last then
declare
Old_Context_Last : constant Ada.Streams.Stream_Element_Offset := Context.Last;
begin
Ada.Streams.Read (
Stream.all,
Context.Buffer (Context.Last + 1 .. Buffer_Type'Last),
Context.Last);
Read_Zero := Old_Context_Last = Context.Last;
exception
when End_Error =>
Context.Status := Finishing;
end;
end if;
end if;
-- converting
if Context.Status <= Finishing then
Adjust_Buffer (
Context.Converted_Buffer,
Context.Converted_First,
Context.Converted_Last);
-- try to convert subsequence
declare
Taken : Ada.Streams.Stream_Element_Offset;
Status : Subsequence_Status_Type;
begin
Convert (
Object,
Context.Buffer (Context.First .. Context.Last),
Taken,
Context.Converted_Buffer (Context.Converted_Last + 1 .. Buffer_Type'Last),
Context.Converted_Last,
Finish => Context.Status > Continuing,
Status => Status);
case Status is
when Finished =>
Context.Status := Ended;
when Success =>
null;
when Overflow =>
if Context.Converted_Last < Context.Converted_First then
raise Constraint_Error;
-- Converted_Buffer is too smaller
end if;
when Truncated =>
pragma Assert (Context.Status = Continuing);
if Context.Converted_Last < Context.Converted_First then
exit; -- wait tail-bytes
end if;
when Illegal_Sequence =>
declare
Is_Overflow : Boolean;
begin
Put_Substitute (
Object,
Context.Converted_Buffer (Context.Converted_Last + 1 .. Buffer_Type'Last),
Context.Converted_Last,
Is_Overflow);
if Is_Overflow then
exit; -- wait a next try
end if;
end;
-- skip one element
Taken :=
Ada.Streams.Stream_Element_Offset'Min (
Context.Last,
Context.First + Min_Size_In_From_Stream_Elements (Object) - 1);
end case;
-- drop converted subsequence
Context.First := Taken + 1;
end;
end if;
-- copy converted elements
declare
Move_Length : constant Ada.Streams.Stream_Element_Offset :=
Ada.Streams.Stream_Element_Offset'Min (
Item'Last - Last,
Context.Converted_Last - Context.Converted_First + 1);
New_Last : constant Ada.Streams.Stream_Element_Offset := Last + Move_Length;
New_Context_Converted_First : constant Ada.Streams.Stream_Element_Offset :=
Context.Converted_First + Move_Length;
begin
Item (Last + 1 .. New_Last) :=
Context.Converted_Buffer (
Context.Converted_First ..
New_Context_Converted_First - 1);
Last := New_Last;
Context.Converted_First := New_Context_Converted_First;
end;
exit when (Context.Status = Ended or else Read_Zero)
and then Context.Converted_Last < Context.Converted_First;
end loop;
if Last = Item'First - 1 -- do not use "<" since underflow
and then Context.Status = Ended
and then Context.Converted_Last < Context.Converted_First
then
raise End_Error;
end if;
end Read;
procedure Initialize (Context : in out Writing_Context_Type);
procedure Initialize (Context : in out Writing_Context_Type) is
begin
Context.First := Buffer_Type'First;
Context.Last := Buffer_Type'First - 1;
end Initialize;
procedure Set_Substitute_To_Writing_Converter (
Object : in out Converter;
Substitute : in Ada.Streams.Stream_Element_Array);
procedure Set_Substitute_To_Writing_Converter (
Object : in out Converter;
Substitute : in Ada.Streams.Stream_Element_Array)
is
Substitute_Last : Ada.Streams.Stream_Element_Offset := Substitute'First - 1;
S2 : Ada.Streams.Stream_Element_Array (1 .. Max_Substitute_Length);
S2_Last : Ada.Streams.Stream_Element_Offset := S2'First - 1;
begin
-- convert substitute from internal to external
loop
declare
Status : Substituting_Status_Type;
begin
Convert (
Object,
Substitute (Substitute_Last + 1 .. Substitute'Last),
Substitute_Last,
S2 (S2_Last + 1 .. S2'Last),
S2_Last,
Finish => True,
Status => Status);
case Status is
when Finished =>
exit;
when Success =>
null;
when Overflow =>
raise Constraint_Error;
end case;
end;
end loop;
Set_Substitute (Object, S2 (1 .. S2_Last));
end Set_Substitute_To_Writing_Converter;
procedure Write (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : in Ada.Streams.Stream_Element_Array;
Object : in Converter;
Context : in out Writing_Context_Type);
procedure Write (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Item : in Ada.Streams.Stream_Element_Array;
Object : in Converter;
Context : in out Writing_Context_Type)
is
Item_Last : Ada.Streams.Stream_Element_Offset := Item'First - 1;
begin
loop
-- filling
if Item_Last /= Item'Last then
Adjust_Buffer (Context.Buffer, Context.First, Context.Last);
if Context.Last /= Buffer_Type'Last then
declare
Rest : constant Ada.Streams.Stream_Element_Offset :=
Ada.Streams.Stream_Element_Offset'Min (
Item'Last - Item_Last,
Buffer_Type'Last - Context.Last);
New_Context_Last : constant Ada.Streams.Stream_Element_Offset :=
Context.Last + Rest;
New_Item_Last : constant Ada.Streams.Stream_Element_Offset := Item_Last + Rest;
begin
Context.Buffer (Context.Last + 1 .. New_Context_Last) :=
Item (Item_Last + 1 .. New_Item_Last);
Context.Last := New_Context_Last;
Item_Last := New_Item_Last;
end;
end if;
else
exit when Context.Last < Context.First;
end if;
-- try to convert subsequence
declare
Taken : Ada.Streams.Stream_Element_Offset;
Out_Buffer : Ada.Streams.Stream_Element_Array (0 .. 63);
Out_Last : Ada.Streams.Stream_Element_Offset;
Status : Continuing_Status_Type;
begin
Convert (
Object,
Context.Buffer (Context.First .. Context.Last),
Taken,
Out_Buffer,
Out_Last,
Status => Status);
case Status is
when Success =>
null;
when Overflow =>
if Out_Last < Out_Buffer'First then
raise Constraint_Error; -- Out_Buffer is too smaller
end if;
when Truncated =>
if Out_Last < Out_Buffer'First then
exit; -- wait tail-bytes
end if;
when Illegal_Sequence =>
declare
Is_Overflow : Boolean;
begin
Put_Substitute (Object, Out_Buffer, Out_Last, Is_Overflow);
if Is_Overflow then
exit; -- wait a next try
end if;
end;
-- skip one element
Taken :=
Ada.Streams.Stream_Element_Offset'Min (
Context.Last,
Context.First + Min_Size_In_From_Stream_Elements (Object) - 1);
end case;
-- write converted subsequence
Ada.Streams.Write (Stream.all, Out_Buffer (Out_Buffer'First .. Out_Last));
-- drop converted subsequence
Context.First := Taken + 1;
end;
end loop;
end Write;
procedure Finish (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Object : in Converter;
Context : in out Writing_Context_Type);
procedure Finish (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Object : in Converter;
Context : in out Writing_Context_Type)
is
Out_Buffer : Ada.Streams.Stream_Element_Array (0 .. 63);
Out_Last : Ada.Streams.Stream_Element_Offset := -1;
Status : Finishing_Status_Type;
begin
if Context.First <= Context.Last then
-- put substitute instead of incomplete sequence in the buffer
declare
Is_Overflow : Boolean; -- ignore
begin
Put_Substitute (
Object,
Out_Buffer (Out_Last + 1 .. Out_Buffer'Last),
Out_Last,
Is_Overflow);
end;
Initialize (Context); -- reset indexes
end if;
-- finish
loop
Convert (
Object,
Out_Buffer (Out_Last + 1 .. Out_Buffer'Last),
Out_Last,
Finish => True,
Status => Status);
Ada.Streams.Write (Stream.all, Out_Buffer (Out_Buffer'First .. Out_Last));
case Status is
when Finished =>
exit;
when Success =>
null;
when Overflow =>
if Out_Last < Out_Buffer'First then
raise Constraint_Error; -- Out_Buffer is too smaller
end if;
end case;
end loop;
end Finish;
-- implementation of only reading
function Open (
Decoder : in out Converter;
Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return In_Type
is
pragma Suppress (Accessibility_Check);
begin
return Result : In_Type do
Result.Stream := Stream;
Result.Reading_Converter := Variable_View (Decoder);
Initialize (Result.Reading_Context);
end return;
end Open;
function Is_Open (Object : In_Type) return Boolean is
begin
return Object.Stream /= null;
end Is_Open;
function Stream (
Object : aliased in out In_Type)
return not null access Ada.Streams.Root_Stream_Type'Class
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (Object) or else raise Status_Error);
begin
return Object'Unchecked_Access;
end Stream;
overriding procedure Read (
Object : in out In_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset) is
begin
Read (
Object.Stream,
Item,
Last,
Object.Reading_Converter.all,
Object.Reading_Context);
end Read;
overriding procedure Write (
Object : in out In_Type;
Item : in Ada.Streams.Stream_Element_Array)
is
pragma Check (Dynamic_Predicate, Check => Boolean'(raise Mode_Error));
begin
raise Program_Error;
end Write;
-- implementation of only writing
function Open (
Encoder : in out Converter;
Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Out_Type
is
pragma Suppress (Accessibility_Check);
begin
return Result : Out_Type do
Result.Stream := Stream;
Result.Writing_Converter := Variable_View (Encoder);
Initialize (Result.Writing_Context);
end return;
end Open;
function Is_Open (Object : Out_Type) return Boolean is
begin
return Object.Stream /= null;
end Is_Open;
function Stream (
Object : aliased in out Out_Type)
return not null access Ada.Streams.Root_Stream_Type'Class
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (Object) or else raise Status_Error);
begin
return Object'Unchecked_Access;
end Stream;
procedure Finish (Object : in out Out_Type) is
pragma Check (Dynamic_Predicate,
Check => Is_Open (Object) or else raise Status_Error);
begin
Finish (Object.Stream, Object.Writing_Converter.all, Object.Writing_Context);
end Finish;
overriding procedure Read (
Object : in out Out_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset)
is
pragma Check (Dynamic_Predicate, Check => Boolean'(raise Mode_Error));
begin
raise Program_Error;
end Read;
overriding procedure Write (
Object : in out Out_Type;
Item : in Ada.Streams.Stream_Element_Array) is
begin
Write (
Object.Stream,
Item,
Object.Writing_Converter.all,
Object.Writing_Context);
end Write;
-- implementation of bidirectional
function Open (
Internal : not null access constant String;
External : not null access constant String;
Stream : not null access Ada.Streams.Root_Stream_Type'Class)
return Inout_Type
is
pragma Suppress (Accessibility_Check);
begin
return Result : Inout_Type do
Result.Internal := Internal;
Result.External := External;
Result.Stream := Stream;
Result.Substitute_Length := 0; -- default is empty
Initialize (Result.Reading_Context);
Initialize (Result.Writing_Context);
end return;
end Open;
function Is_Open (Object : Inout_Type) return Boolean is
begin
return Object.Stream /= null;
end Is_Open;
function Substitute (
Object : Inout_Type)
return Ada.Streams.Stream_Element_Array
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (Object) or else raise Status_Error);
begin
return Object.Substitute (1 .. Object.Substitute_Length);
end Substitute;
procedure Set_Substitute (
Object : in out Inout_Type;
Substitute : in Ada.Streams.Stream_Element_Array)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (Object) or else raise Status_Error);
begin
if Substitute'Length > Object.Substitute'Length then
raise Constraint_Error;
end if;
Object.Substitute_Length := Substitute'Length;
Object.Substitute (1 .. Object.Substitute_Length) := Substitute;
-- set to converters
if Is_Open (Object.Reading_Converter) then
Set_Substitute_To_Reading_Converter (
Object.Reading_Converter,
Object.Substitute (1 .. Object.Substitute_Length));
end if;
if Is_Open (Object.Writing_Converter) then
Set_Substitute_To_Writing_Converter (
Object.Writing_Converter,
Object.Substitute (1 .. Object.Substitute_Length));
end if;
end Set_Substitute;
function Stream (
Object : aliased in out Inout_Type)
return not null access Ada.Streams.Root_Stream_Type'Class
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (Object) or else raise Status_Error);
begin
return Object'Unchecked_Access;
end Stream;
procedure Finish (
Object : in out Inout_Type)
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (Object) or else raise Status_Error);
begin
if Is_Open (Object.Writing_Converter) then
Finish (Object.Stream, Object.Writing_Converter, Object.Writing_Context);
end if;
end Finish;
overriding procedure Read (
Object : in out Inout_Type;
Item : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset) is
begin
if not Is_Open (Object.Reading_Converter) then
Open (
Object.Reading_Converter,
To => Object.Internal.all,
From => Object.External.all);
if Object.Substitute_Length >= 0 then
Set_Substitute_To_Reading_Converter (
Object.Reading_Converter,
Object.Substitute (1 .. Object.Substitute_Length));
end if;
end if;
Read (
Object.Stream,
Item,
Last,
Object.Reading_Converter,
Object.Reading_Context);
end Read;
overriding procedure Write (
Object : in out Inout_Type;
Item : in Ada.Streams.Stream_Element_Array) is
begin
if not Is_Open (Object.Writing_Converter) then
Open (
Object.Writing_Converter,
To => Object.External.all,
From => Object.Internal.all);
if Object.Substitute_Length >= 0 then
Set_Substitute_To_Writing_Converter (
Object.Writing_Converter,
Object.Substitute (1 .. Object.Substitute_Length));
end if;
end if;
Write (
Object.Stream,
Item,
Object.Writing_Converter,
Object.Writing_Context);
end Write;
end iconv.Streams;
|
-- Copyright 2019 Simon Symeonidis (psyomn)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
package HTTP_Status is
type Code is new Positive;
type Code_Range is range 100 .. 599;
Bad_Code_Error : exception;
-- Info
CONTINUE : constant Code := 100;
SWITCHING_PROTOCOLS : constant Code := 101;
-- Success
OK : constant Code := 200;
CREATED : constant Code := 201;
ACCEPTED : constant Code := 202;
NON_AUTHORITATIVE_INFORMATION : constant Code := 203;
NO_CONTENT : constant Code := 204;
RESET_CONTENT : constant Code := 205;
PARTIAL_CONTENT : constant Code := 206;
-- Redirections
MULTIPLE_CHOICES : constant Code := 300;
MOVED_PERMANENTLY : constant Code := 301;
FOUND : constant Code := 302;
SEE_OTHER : constant Code := 303;
NOT_MODIFIED : constant Code := 304;
USE_PROXY : constant Code := 305;
UNUSED : constant Code := 306;
TEMPORARY_REDIRECT : constant Code := 307;
-- PEBKAC
BAD_REQUEST : constant Code := 400;
UNAUTHORIZED : constant Code := 401;
PAYMENT_REQUIRED : constant Code := 402;
FORBIDDEN : constant Code := 403;
NOT_FOUND : constant Code := 404;
METHOD_NOT_ALLOWED : constant Code := 405;
NOT_ACCEPTABLE : constant Code := 406;
PROXY_AUTH_REQUIRED : constant Code := 407;
REQUEST_TIMEOUT : constant Code := 408;
CONFLICT : constant Code := 409;
GONE : constant Code := 410;
LENGTH_REQUIRED : constant Code := 411;
PRECONDITION_FAILED : constant Code := 412;
REQUEST_ENTITY_TOO_LARGE : constant Code := 413;
REQUEST_URI_TOO_LONG : constant Code := 414;
UNSUPPORTED_MEDIA_TYPE : constant Code := 415;
REQUESTED_RANGE_NOT_SATISFIABLE : constant Code := 416;
EXPECTATION_FAILED : constant Code := 417;
-- BOOM
INTERNAL_ERROR : constant Code := 500;
NOT_IMPLEMENTED : constant Code := 501;
BAD_GATEWAY : constant Code := 502;
SERVICE_UNAVAILABLE : constant Code := 503;
GATEWAY_TIMEOUT : constant Code := 504;
HTTP_VERSION_NOT_SUPPORTED : constant Code := 505;
function Message_Of_Code (C : Code) return String;
end HTTP_Status;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . W C H _ C O N --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2019, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- As a special exception under Section 7 of GPL version 3, you are granted --
-- additional permissions described in the GCC Runtime Library Exception, --
-- version 3.1, as published by the Free Software Foundation. --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package defines the codes used to identify the encoding method for
-- wide characters in string and character constants. This is needed both
-- at compile time and at runtime (for the wide character runtime routines)
-- This unit may be used directly from an application program by providing
-- an appropriate WITH, and the interface can be expected to remain stable.
pragma Compiler_Unit_Warning;
package System.WCh_Con is
pragma Pure;
-------------------------------------
-- Wide_Character Encoding Methods --
-------------------------------------
-- A wide character encoding method is a method for uniquely representing
-- a Wide_Character or Wide_Wide_Character value using a one or more
-- Character values. Three types of encoding method are supported by GNAT:
-- An escape encoding method uses ESC as the first character of the
-- sequence, and subsequent characters determine the wide character
-- value that is represented. Any character other than ESC stands
-- for itself as a single byte (i.e. any character in Latin-1, other
-- than ESC itself, is represented as a single character: itself).
-- An upper half encoding method uses a character in the upper half
-- range (i.e. in the range 16#80# .. 16#FF#) as the first byte of
-- a wide character encoding sequence. Subsequent characters are
-- used to determine the wide character value that is represented.
-- Any character in the lower half (16#00# .. 16#7F#) represents
-- itself as a single character.
-- The brackets notation, where a wide character is represented by the
-- sequence ["xx"] or ["xxxx"] or ["xxxxxx"] where xx are hexadecimal
-- characters. Note that currently this is the only encoding that
-- supports the full UTF-32 range.
-- Note that GNAT does not currently support escape-in, escape-out
-- encoding methods, where an escape sequence is used to set a mode
-- used to recognize subsequent characters. All encoding methods use
-- individual character-by-character encodings, so that a sequence of
-- wide characters is represented by a sequence of encodings.
-- To add new encoding methods, the following steps are required:
-- 1. Define a code for a new value of type WC_Encoding_Method
-- 2. Adjust the definition of WC_Encoding_Method accordingly
-- 3. Provide appropriate conversion routines in System.WCh_Cnv
-- 4. Adjust definition of WC_Longest_Sequence if necessary
-- 5. Add an entry in WC_Encoding_Letters for the new method
-- 6. Add proper code to s-wchstw.adb, s-wchwts.adb, s-widwch.adb
-- 7. Update documentation (remember section on form strings)
-- Note that the WC_Encoding_Method values must be kept ordered so that
-- the definitions of the subtypes WC_Upper_Half_Encoding_Method and
-- WC_ESC_Encoding_Method are still correct.
---------------------------------
-- Encoding Method Definitions --
---------------------------------
type WC_Encoding_Method is range 1 .. 6;
-- Type covering the range of values used to represent wide character
-- encoding methods. An enumeration type might be a little neater, but
-- more trouble than it's worth, given the need to pass these values
-- from the compiler to the backend, and to record them in the ALI file.
WCEM_Hex : constant WC_Encoding_Method := 1;
-- The wide character with code 16#abcd# is represented by the escape
-- sequence ESC a b c d (five characters, where abcd are ASCII hex
-- characters, using upper case for letters). This method is easy
-- to deal with in external environments that do not support wide
-- characters, and covers the whole 16-bit BMP. Codes larger than
-- 16#FFFF# are not representable using this encoding method.
WCEM_Upper : constant WC_Encoding_Method := 2;
-- The wide character with encoding 16#abcd#, where the upper bit is on
-- (i.e. a is in the range 8-F) is represented as two bytes 16#ab# and
-- 16#cd#. The second byte may never be a format control character, but
-- is not required to be in the upper half. This method can be also used
-- for shift-JIS or EUC where the internal coding matches the external
-- coding. Codes larger than 16#FFFF# are not representable using this
-- encoding method.
WCEM_Shift_JIS : constant WC_Encoding_Method := 3;
-- A wide character is represented by a two character sequence 16#ab#
-- and 16#cd#, with the restrictions described for upper half encoding
-- as described above. The internal character code is the corresponding
-- JIS character according to the standard algorithm for Shift-JIS
-- conversion. See the body of package System.JIS_Conversions for
-- further details. Codes larger than 16#FFFF are not representable
-- using this encoding method.
WCEM_EUC : constant WC_Encoding_Method := 4;
-- A wide character is represented by a two character sequence 16#ab# and
-- 16#cd#, with both characters being in the upper half set. The internal
-- character code is the corresponding JIS character according to the EUC
-- encoding algorithm. See the body of package System.JIS_Conversions for
-- further details. Codes larger than 16#FFFF# are not representable using
-- this encoding method.
WCEM_UTF8 : constant WC_Encoding_Method := 5;
-- An ISO 10646-1 BMP/Unicode wide character is represented in UCS
-- Transformation Format 8 (UTF-8), as defined in Annex R of ISO
-- 10646-1/Am.2. Depending on the character value, a Unicode character
-- is represented as the one to six byte sequence.
--
-- 16#0000_0000#-16#0000_007f#: 2#0xxxxxxx#
-- 16#0000_0080#-16#0000_07ff#: 2#110xxxxx# 2#10xxxxxx#
-- 16#0000_0800#-16#0000_ffff#: 2#1110xxxx# 2#10xxxxxx# 2#10xxxxxx#
-- 16#0001_0000#-16#001F_FFFF#: 2#11110xxx# 2#10xxxxxx# 2#10xxxxxx#
-- 2#10xxxxxx#
-- 16#0020_0000#-16#03FF_FFFF#: 2#111110xx# 2#10xxxxxx# 2#10xxxxxx#
-- 2#10xxxxxx# 2#10xxxxxx#
-- 16#0400_0000#-16#7FFF_FFFF#: 2#1111110x# 2#10xxxxxx# 2#10xxxxxx#
-- 2#10xxxxxx# 2#10xxxxxx# 2#10xxxxxx#
--
-- where the xxx bits correspond to the left-padded bits of the
-- 16-bit character value. Note that all lower half ASCII characters
-- are represented as ASCII bytes and all upper half characters and
-- other wide characters are represented as sequences of upper-half. This
-- encoding method can represent the entire range of Wide_Wide_Character.
WCEM_Brackets : constant WC_Encoding_Method := 6;
-- A wide character is represented using one of the following sequences:
--
-- ["xx"]
-- ["xxxx"]
-- ["xxxxxx"]
-- ["xxxxxxxx"]
--
-- where xx are hexadecimal digits representing the character code. This
-- encoding method can represent the entire range of Wide_Wide_Character
-- but in the general case results in ambiguous representations (there is
-- no ambiguity in Ada sources, since the above sequences are illegal Ada).
WC_Encoding_Letters : constant array (WC_Encoding_Method) of Character :=
(WCEM_Hex => 'h',
WCEM_Upper => 'u',
WCEM_Shift_JIS => 's',
WCEM_EUC => 'e',
WCEM_UTF8 => '8',
WCEM_Brackets => 'b');
-- Letters used for selection of wide character encoding method in the
-- compiler options (-gnatW? switch) and for Wide_Text_IO (WCEM parameter
-- in the form string).
subtype WC_ESC_Encoding_Method is
WC_Encoding_Method range WCEM_Hex .. WCEM_Hex;
-- Encoding methods using an ESC character at the start of the sequence
subtype WC_Upper_Half_Encoding_Method is
WC_Encoding_Method range WCEM_Upper .. WCEM_UTF8;
-- Encoding methods using an upper half character (16#80#..16#FF) at
-- the start of the sequence.
WC_Longest_Sequence : constant := 12;
-- The longest number of characters that can be used for a wide character
-- or wide wide character sequence for any of the active encoding methods.
WC_Longest_Sequences : constant array (WC_Encoding_Method) of Natural :=
(WCEM_Hex => 5,
WCEM_Upper => 2,
WCEM_Shift_JIS => 2,
WCEM_EUC => 2,
WCEM_UTF8 => 6,
WCEM_Brackets => 12);
-- The longest number of characters that can be used for a wide character
-- or wide wide character sequence using the given encoding method.
function Get_WC_Encoding_Method (C : Character) return WC_Encoding_Method;
-- Given a character C, returns corresponding encoding method (see array
-- WC_Encoding_Letters above). Raises Constraint_Error if not in list.
function Get_WC_Encoding_Method (S : String) return WC_Encoding_Method;
-- Given a lower case string that is one of hex, upper, shift_jis, euc,
-- utf8, brackets, return the corresponding encoding method. Raises
-- Constraint_Error if not in list.
function Is_Start_Of_Encoding
(C : Character;
EM : WC_Encoding_Method) return Boolean;
pragma Inline (Is_Start_Of_Encoding);
-- Returns True if the Character C is the start of a multi-character
-- encoding sequence for the given encoding method EM. If EM is set to
-- WCEM_Brackets, this function always returns False.
end System.WCh_Con;
|
-- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
-- Autogenerated by Generate, do not edit
package GL.API.Doubles is
pragma Preelaborate;
Vertex_Attrib1 : T1;
Vertex_Attrib2 : T2;
Vertex_Attrib2v : T3;
Vertex_Attrib3 : T4;
Vertex_Attrib3v : T5;
Vertex_Attrib4 : T6;
Vertex_Attrib4v : T7;
end GL.API.Doubles;
|
with Interfaces.C;
with System; use System;
package body dl_loader is
function Load_Wrapper(path: Interfaces.C.char_array) return System.Address
with Import => True,
Convention => C,
External_Name => "dp_load";
procedure Close_Wrapper(ptr: System.Address)
with Import => True,
Convention => C,
External_Name => "dp_close";
function Symbol_Wrapper(ptr: System.Address; name: Interfaces.C.char_array) return System.Address
with Import => True,
Convention => C,
External_Name => "dp_symbol";
function Open(path: in String; h: in out Handle) return Boolean is
begin
if Is_Valid(h) then
Close(h);
end if;
h.h := Load_Wrapper(Interfaces.C.To_C(path));
return Is_Valid(h);
end Open;
function Is_Valid(h: in Handle) return Boolean is
begin
return h.h /= System.Null_Address;
end Is_Valid;
function Get_Symbol(h: in Handle; name: String) return System.Address is
begin
return Symbol_Wrapper(h.h, Interfaces.C.To_C(name));
end Get_Symbol;
procedure Close(h: in out Handle) is
begin
if h.h /= System.Null_Address then
Close_Wrapper(h.h);
h.h := System.Null_Address;
end if;
end Close;
end dl_loader;
|
--------------------------------------------------------------------------------
-- --
-- Copyright (C) 2004, RISC OS Ada Library (RASCAL) developers. --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU Lesser General Public --
-- License as published by the Free Software Foundation; either --
-- version 2.1 of the License, or (at your option) any later version. --
-- --
-- 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 --
-- Lesser General Public License for more details. --
-- --
-- You should have received a copy of the GNU Lesser 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 --
-- --
--------------------------------------------------------------------------------
-- $Author$
-- $Date$
-- $Revision$
with Kernel; use Kernel;
with Interfaces.C; use Interfaces.C;
with Ada.Strings.Unbounded;
with Reporter;
with RASCAL.Memory; use RASCAL.Memory;
with RASCAL.Utility; use RASCAL.Utility;
with RASCAL.ToolboxWindow; use RASCAL.ToolboxWindow;
with RASCAL.OS;
package body RASCAL.ToolboxWritableField is
Toolbox_ObjectMiscOp : constant Interfaces.C.unsigned :=16#44EC6#;
--
function Get_Value (Window : in Object_ID;
Component : in Component_ID;
Flags : in System.Unsigned_Types.unsigned := 0) return String is
Register : aliased Kernel.swi_regs;
Error : oserror_access;
Buffer_Size : integer := 0;
begin
Register.R(0) := int(Unsigned_to_Int(Flags));
Register.R(1) := int(Window);
Register.R(2) := 513;
Register.R(3) := int(Component);
Register.R(4) := 0;
Register.R(5) := 0;
Error := Kernel.swi(Toolbox_ObjectMiscOp,Register'Access,Register'Access);
if Error /= null then
pragma Debug(Reporter.Report("ToolboxWritableField.Get_Value: " & To_Ada(Error.ErrMess)));
OS.Raise_Error(Error);
return "";
end if;
Buffer_Size := integer(Register.R(5));
declare
Buffer : String(1..Buffer_Size + 1);
begin
Register.R(0) := int(Unsigned_to_Int(Flags));
Register.R(1) := int(Window);
Register.R(2) := 513;
Register.R(3) := int(Component);
Register.R(4) := Adr_To_Int(Buffer'Address);
Register.R(5) := int(Buffer_Size + 1);
Error := Kernel.swi(Toolbox_ObjectMiscOp,Register'Access,Register'Access);
if Error /= null then
pragma Debug(Reporter.Report("ToolboxWritableField.Get_Value: " & To_Ada(Error.ErrMess)));
OS.Raise_Error(Error);
end if;
return MemoryToString(Buffer'Address);
end;
end Get_Value;
--
procedure Set_Allowable (Window : in Object_ID;
Component : in Component_ID;
Allowable : in string;
Flags : in System.Unsigned_Types.Unsigned := 0) is
Register : aliased Kernel.swi_regs;
Error : oserror_access;
Allowable_0 : string := Allowable & ASCII.NUL;
begin
Register.R(0) := int(Unsigned_to_Int(Flags));
Register.R(1) := int(Window);
Register.R(2) := 514;
Register.R(3) := int(Component);
Register.R(4) := Adr_To_Int(Allowable_0'Address);
Error := Kernel.swi(Toolbox_ObjectMiscOp,Register'Access,Register'Access);
if Error /= null then
pragma Debug(Reporter.Report("ToolboxWritableField.Set_Allowable: " & To_Ada(Error.ErrMess)));
OS.Raise_Error(Error);
end if;
end Set_Allowable;
--
procedure Set_Font (Window : in Object_ID;
Component : in Component_ID;
Font : in String;
Font_Width : in integer := 12;
Font_Height : in integer := 12;
Flags : in System.Unsigned_Types.Unsigned := 0) is
Register : aliased Kernel.swi_regs;
Error : oserror_access;
Font_0 : String := Font & ASCII.NUL;
begin
Register.R(0) := int(Unsigned_to_Int(Flags));
Register.R(1) := int(Window);
Register.R(2) := 516;
Register.R(3) := int(Component);
Register.R(4) := Adr_To_Int(Font_0'Address);
Register.R(5) := int(Font_Width);
Register.R(6) := int(Font_Height);
Error := Kernel.swi(Toolbox_ObjectMiscOp,Register'Access,Register'Access);
if Error /= null then
pragma Debug(Reporter.Report("ToolboxWritableField.Set_Font: " & To_Ada(Error.ErrMess)));
OS.Raise_Error(Error);
end if;
end Set_Font;
--
procedure Set_Value (Window : in Object_ID;
Component : in Component_ID;
New_Value : in string;
Flags : in System.Unsigned_Types.Unsigned := 0) is
Register : aliased Kernel.swi_regs;
Error : oserror_access;
Value_0 : UString := U(New_Value & ASCII.NUL);
Buffer_Size : Integer := (Gadget_Get_BufferSize(Window,Component))-1;
begin
if Buffer_Size > -1 then
if New_Value'Length > Buffer_Size then
Value_0 := Ada.Strings.Unbounded.Head(Value_0,Buffer_Size);
Ada.Strings.Unbounded.Append(Value_0,ASCII.NUL);
end if;
Register.R(0) := int(Unsigned_to_Int(Flags));
Register.R(1) := int(Window);
Register.R(2) := 512;
Register.R(3) := int(Component);
Register.R(4) := Adr_To_Int(S(Value_0)'Address);
Error := Kernel.swi(Toolbox_ObjectMiscOp,Register'Access,Register'Access);
if Error /= null then
pragma Debug(Reporter.Report("ToolboxWritableField.Set_Value: " & To_Ada(Error.ErrMess)));
OS.Raise_Error(Error);
end if;
end if;
end Set_Value;
--
end RASCAL.ToolboxWritableField;
|
package xample1 is
procedure SayWelcome(x : in Integer);
end xample1;
|
with External; use External;
with Node; use Node;
with Ada.Containers.Doubly_Linked_Lists;
with Logger;
with RandInt;
procedure Main is
package LST is new Ada.Containers.Doubly_Linked_Lists(Element_Type => pNodeObj);
n: Natural;
d: Natural;
k: Natural;
maxSleep: Natural;
begin
if CMD.Argument_Count /= 4 then
PrintBounded("four arguments necessary");
return;
end if;
n := Natural'Value(CMD.Argument(1));
d := Natural'Value(CMD.Argument(2));
k := Natural'Value(CMD.Argument(3));
maxSleep := Natural'Value(CMD.Argument(4));
declare
subtype RangeN is Natural range 1..n;
nodes: pArray_pNodeObj;
-- holder of `d` additional edges
subtype RangeD is Natural range 1..d;
-- RangeD (extended): `0` means there is no shortcut
subtype RangeDE is Natural range 0..d;
package RAD renames RandInt;
type AdditionalEdges is array (RangeD, 1..2) of Natural;
type pAdditionalEdges is access AdditionalEdges;
shortcuts: pAdditionalEdges;
type AdditionalEdgesArrayLengths is array (RangeN) of Natural;
type pAdditionalEdgesArrayLengths is access AdditionalEdgesArrayLengths;
shortcutsLengths: pAdditionalEdgesArrayLengths;
subtype RangeK is Natural range 1..k;
package LOG renames Logger;
loggerReceiver: LOG.pLoggerReceiver;
tmp: Natural := 0;
tmp2: Natural := 0;
tmp3: Natural := 0;
tmpExit: Boolean := False;
tmpNodeObj: pNodeObj;
tmpNodeObj2: pNodeObj;
tmpMessage: pMessage;
task type SenderTask(firstNode: pNodeObj);
task body SenderTask is
begin
for I in RangeK'Range loop
tmpMessage := new Message'(content => I);
firstNode.all.nodeTask.all.SendMessage(tmpMessage);
end loop;
end SenderTask;
type pSenderTask is access SenderTask;
sender: pSenderTask;
begin
-- instantiate the logger task
loggerReceiver := new LOG.LoggerReceiver(n, d, k);
-- create all nodes
nodes := new Array_pNodeObj(RangeN);
for I in RangeN'Range loop
nodes.all(I) := new NodeObj;
nodes.all(I).all.id := I-1;
end loop;
-- generate shortcuts
shortcuts := new AdditionalEdges;
for I in RangeD'Range loop
tmp := RAD.Next(n);
tmp2 := RAD.Next(n);
if tmp > tmp2 then
tmp3 := tmp;
tmp := tmp2;
tmp2 := tmp3;
end if;
if tmp /= tmp2 then
-- shortcut successfully created
shortcuts(I, 1) := tmp;
shortcuts(I, 2) := tmp2;
loggerReceiver.Log("shortcut" & Natural'Image(tmp-1) & " →" & Natural'Image(tmp2-1));
else
shortcuts(I, 1) := 0;
shortcuts(I, 2) := 0;
end if;
end loop;
loggerReceiver.Log("---");
-- we need to precalculate the neighbours’ array size
shortcutsLengths := new AdditionalEdgesArrayLengths;
-- initialize with `1`, because each node has at least one neighbour
for I in RangeN'Range loop
shortcutsLengths.all(I) := 1;
end loop;
shortcutsLengths.all(RangeN'Last) := 0;
-- count all the additional edges
for I in RangeD'Range loop
-- get the beginning node
tmp := shortcuts(I, 1);
if tmp > 0 and tmp <= n then
shortcutsLengths.all(tmp) := shortcutsLengths.all(tmp) + 1;
end if;
end loop;
-- special case for the last node
-- now we can initialize our nodes
for I in RangeN'Range loop
tmpNodeObj := nodes.all(I);
tmpNodeObj.all.neighbours := new Array_pNodeObj(1..shortcutsLengths.all(I));
if I < n then
tmpNodeObj.all.nodeTask := new NodeTask(tmpNodeObj, maxSleep, loggerReceiver, False);
else
tmpNodeObj.all.nodeTask := new NodeTask(tmpNodeObj, maxSleep, loggerReceiver, True);
end if;
end loop;
-- and add pointers to neighbours
for I in RangeD'Range loop
-- get the beginning node of the edge
tmp := shortcuts.all(I, 1);
if tmp /= 0 then
tmpNodeObj := nodes.all(tmp);
-- get the ending node of the edge
tmp2 := shortcuts.all(I, 2);
tmpNodeObj2 := nodes.all(tmp2);
-- add the neighbour (we’re using the lengths array as our pointer)
tmpNodeObj.all.neighbours(shortcutsLengths.all(tmp)) := tmpNodeObj2;
-- decrease the array pointer
shortcutsLengths.all(tmp) := shortcutsLengths.all(tmp) - 1;
end if;
end loop;
-- also add the edges for adjacent nodes
for I in RangeN'Range loop
-- current node
tmpNodeObj := nodes(I);
if I < n then
-- next node
tmpNodeObj2 := nodes(I+1);
-- add as neighbour
tmpNodeObj.all.neighbours(1) := tmpNodeObj2;
else
-- special case for the last node
null;
end if;
end loop;
-- send the messages
tmpNodeObj2 := nodes(RangeN'First);
sender := new SenderTask(tmpNodeObj2);
-- receive the messages
tmpNodeObj := nodes(RangeN'Last);
for I in RangeK'Range loop
tmpMessage := new Message;
if tmpMessage /= null then
tmpNodeObj.all.nodeTask.all.ReceiveMessage(tmpMessage);
loggerReceiver.Log("→→→message" & Natural'Image(tmpMessage.all.content) & " received");
end if;
end loop;
for I in RangeN'Range loop
nodes(I).all.nodeTask.Stop;
end loop;
loggerReceiver.Stop;
end;
end Main;
|
with Ada.Numerics;
with Ada.Text_IO; use Ada.Text_IO;
with Blade;
with Blade_Types;
with E3GA;
with GA_Utilities;
package body E3GA_Utilities is
-- -------------------------------------------------------------------------
function exp (BV : Multivectors.Bivector) return Multivectors.Rotor is
V : constant Multivectors.M_Vector :=
Inner_Product (BV, BV, Blade.Left_Contraction);
X2 : float := E3GA.e1_e2 (V);
Half_Angle : float;
Cos_HA : float;
Sin_HA : float;
Result : Rotor;
begin
if X2 > 0.0 then
X2 := 0.0;
end if;
Half_Angle := GA_Maths.Float_Functions.Sqrt (-X2);
if Half_Angle = 0.0 then
Update_Scalar_Part (Result, 1.0);
else
Cos_HA := GA_Maths.Float_Functions.Cos (Half_Angle);
Sin_HA := GA_Maths.Float_Functions.Sin (Half_Angle) / Half_Angle;
Result := New_Rotor (0.0, Cos_HA + Sin_HA * BV);
end if;
return Result;
end exp;
-- ----------------------------------------------------------------------------
-- special log() for 3D rotors
function log (R : Multivectors.Rotor) return Multivectors.Bivector is
use E3GA;
R2 : float;
R1 : float;
BV : Bivector;
Result : Bivector;
begin
-- get the bivector 2-blade part of R
BV := New_Bivector (e1_e2 (R), e2_e3 (R), e3_e1 (R));
-- compute the 'reverse norm' of the bivector part of R
R2 := Norm_E (BV);
-- R2 := Norm_R (BV);
if R2 > 0.0 then
-- return _bivector(B * ((float)atan2(R2, _Float(R)) / R2));
R1 := GA_Maths.Float_Functions.Arctan (R2, Scalar_Part (R)) / R2;
Result := R1 * BV;
-- otherwise, avoid divide-by-zero (and below zero due to FP roundoff)
elsif Scalar_Part (R) < 0.0 then
-- Return a 360 degree rotation in an arbitrary plane
Result := Ada.Numerics.Pi * Outer_Product (e1, e2);
else
BV := New_Bivector (0.0, 0.0, 0.0);
end if;
return Result;
end log;
-- ------------------------------------------------------------------------
procedure Print_Rotor (Name : String; R : Multivectors.Rotor) is
begin
GA_Utilities.Print_Multivector (Name, R);
end Print_Rotor;
-- ------------------------------------------------------------------------
procedure Rotor_To_Matrix (R : Multivectors.Rotor;
M : out GA_Maths.GA_Matrix3) is
Rot : constant GA_Maths.Float_4D := E3GA.Get_Coords (R);
begin
M (1, 1) := 1.0 - 2.0 * (Rot (3) * Rot (3) + Rot (4) * Rot (4));
M (2, 1) := 2.0 * (Rot (2) * Rot (3) + Rot (4) * Rot (1));
M (3, 1) := 2.0 * (Rot (2) * Rot (4) - Rot (3) * Rot (1));
M (1, 2) := 2.0 * (Rot (2) * Rot (3) - Rot (4) * Rot (1));
M (2, 2) := 1.0 - 2.0 * (Rot (2) * Rot (2) + Rot (4) * Rot (4));
M (3, 2) := 2.0 * (Rot (3) * Rot (4) + Rot (2) * Rot (1));
M (1, 3) := 2.0 * (Rot (2) * Rot (4) + Rot (3) * Rot (1));
M (2, 3) := 2.0 * (Rot (3) * Rot (4) - Rot (2) * Rot (1));
M (3, 3) := 1.0 - 2.0 * (Rot (2) * Rot (2) + Rot (3) * Rot (3));
end Rotor_To_Matrix;
-- ------------------------------------------------------------------------
-- Based on e3ga.util.rotorFromVectorToVector
function Rotor_Vector_To_Vector (From_V1, To_V2 : Multivectors.M_Vector)
return Multivectors.Rotor is
use GA_Maths.Float_Functions;
S : float;
w0 : M_Vector;
w1 : M_Vector;
w2 : M_Vector;
Nsq : Float;
R : Rotor;
Result : Rotor;
begin
if Scalar_Product (From_V1, To_V2) < -0.9 then
-- "near" 180 degree rotation :
-- v1 factor in returning blade regardless of any loss of precision
-- v1 << (v1^v2) means c3ga::lcont(v1, (v1^v2)),
-- lcont Left_Contraction
w0 := Left_Contraction (From_V1, Outer_Product (From_V1, To_V2));
Nsq := Norm_Esq (w0);
if Nsq = 0.0 then
w1 := Left_Contraction
(From_V1, Outer_Product (From_V1, Basis_Vector (Blade_Types.E3_e1)));
w2 := Left_Contraction
(From_V1, Outer_Product (From_V1, Basis_Vector (Blade_Types.E3_e2)));
if Norm_Esq (w1) > Norm_Esq (w2) then
Result := Outer_Product (From_V1, Unit_e (w1));
else
Result := Outer_Product (From_V1, Unit_e (w2));
end if;
else -- Nsq /= 0.0
-- Replace V1 with -V1 and an additional 180 degree rotation.
S := Sqrt (2.0 * (1.0 - Scalar_Part (Left_Contraction (To_V2, From_V1))));
R := (1.0 - Geometric_Product (To_V2, From_V1)) / S;
Result := Geometric_Product (R, Outer_Product (From_V1, Unit_e (w0)));
end if;
else -- normal case, not "near" 180 degree rotation.
-- (1 + ba)(1 + ab) = 1 + ab + ba + baab
-- = 1 + a.b + a^b + b.a + b^a + 1
-- = 2 + 2a.b + a^b - a^b
-- = 2(1 + a.b)
-- Geometric Algebra for Computer Science, Equation (10.13)
-- S := Sqrt (2.0 * (1.0 + Scalar_Part (Dot (To_V2, From_V1))));
S := Sqrt (2.0 * (1.0 + Scalar_Part (Left_Contraction (To_V2, From_V1))));
Result := To_Rotor ((1.0 + Geometric_Product (To_V2, From_V1)) / S);
end if;
Simplify (Result);
return Result;
exception
when others =>
Put_Line ("An exception occurred in E3GA_Utilities.Rotor_Vector_To_Vector.");
raise;
end Rotor_Vector_To_Vector;
-- ----------------------------------------------------------------------------
end E3GA_Utilities;
|
-- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
private with Ada.Containers.Hashed_Maps;
private with Ada.Containers.Vectors;
private with HelperText;
package INI_File_Manager is
ini_file_nonexistent : exception;
file_operation_failed : exception;
bad_ini_format : exception;
-- Create new INI File or overwrite existing one.
-- Throws exception if writing failed
-- It will attempt to create the directory (and throw exception if that fails)
-- Sections are sorted before writing
procedure scribe_file (directory, filename, first_comment : String);
-- If section exists, remove from internal storage.
-- Typical use: read INI File, remove section, Scribe_File
procedure delete_section (section : String);
-- If the section doesn't exist, create it in memory.
-- If the nvpair already exists overwrite value, otherwise insert it.
procedure insert_or_update (section, name, value : String);
-- If the section exists and the field within the section exists, remove it from memory
procedure delete_nv_pair (section, name : String);
-- Scans an existing INI file.
-- Throws exception if file does not exist, or if reading file fails
-- Throws bad_ini_format exception if parser hits something it doesn't like
procedure scan_file (directory, filename : String);
-- Returns number of sections present
function section_count return Natural;
-- Return name of section given its index
function section_name (index : Positive) return String;
-- Return number of nvpairs in a given section
function field_count (section : String) return Natural;
-- Call before iterating through section
procedure section_list_reset (section : String);
-- returns the name part of NV pair of current cursor
function show_name (section : String) return String;
-- returns the value part of the NV pair of current cursor
function show_value (section : String) return String;
-- Attempt to advance cursor of section list. If it's in the last position, return False.
function advance_section_list (section : String) return Boolean;
-- Return value of field identified by "name" within given section
function show_value (section, name : String) return String;
-- Return True if section exists
function section_exists (section : String) return Boolean;
-- Ensure no previous data lingers
procedure clear_section_data;
private
package HT renames HelperText;
package CON renames Ada.Containers;
package nvpair_crate is new CON.Hashed_Maps
(Key_Type => HT.Text,
Element_Type => HT.Text,
Hash => HT.hash,
Equivalent_Keys => HT.equivalent,
"=" => HT.SU."=");
type group_list is
record
section : HT.Text;
list : nvpair_crate.Map;
index : Natural;
cursor : nvpair_crate.Cursor;
end record;
package list_crate is new CON.Hashed_Maps
(Key_Type => HT.Text,
Element_Type => group_list,
Hash => HT.hash,
Equivalent_Keys => HT.equivalent);
package string_crate is new CON.Vectors
(Element_Type => HT.Text,
Index_Type => Positive,
"=" => HT.SU."=");
INI_sections : list_crate.Map;
end INI_File_Manager;
|
------------------------------------------------------------------------------
-- --
-- OPEN RAVENSCAR VALIDATION TEST SUITE --
-- --
-- --
-- Copyright (C) 1999-2000, C.A.S.A. - Space Division --
-- Copyright (C) 2004, DIT-UPM --
-- Copyright (C) 2004, The European Space Agency --
-- Copyright (C) 2004-2010, AdaCore --
-- --
-- The Open Ravenscar Validation Test Suite 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. The test suite is --
-- distributed in the hope that it will be useful, but WITHOUT ANY --
-- WARRANTY; without even the implied warranty of MERCHANTABILITY or --
-- FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for --
-- more details. You should have received a copy of the GNU General Public --
-- License distributed with this test suite; see file COPYING. If not, --
-- write to the Free Software Foundation, 59 Temple Place - Suite 30, --
-- Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- The original Validation Test Suite was developed by the Space Division --
-- of Construcciones Aeronauticas S.A. (CASA). --
-- --
-- The Open Ravenscar Validation Test Suite was then evolved and maintained --
-- by DIT-UPM and AdaCore. --
-- --
-- The current version of the Open Ravenscar Validation Test Suite is being --
-- developed and maintained by AdaCore. --
-- --
------------------------------------------------------------------------------
with System;
with Ada.Real_Time; use Ada.Real_Time;
package Tasking is
procedure Last_Chance_Handler (Msg : System.Address; Line : Integer);
pragma Export (C, Last_Chance_Handler, "__gnat_last_chance_handler");
procedure Wait_Forever;
type Task_Control_Container;
protected type Task_Ctrl is
entry Wait;
procedure Start;
private
Barrier : Boolean := False;
end Task_Ctrl;
task type Task_Type (Wrapper : not null access Task_Control_Container);
type Task_Control_Container is limited
record
Controller : Task_Ctrl;
T : Task_Type (Task_Control_Container'Access);
end record;
-- Associate a task to a protected object
task Test_Driver is
pragma Priority (System.Priority'Last);
end Test_Driver;
end Tasking;
|
private
with
ada.Calendar;
package openGL.frame_Counter
--
-- A utility which reports frames per second.
--
is
type Item is tagged private;
procedure increment (Self : in out Item);
private
type Item is tagged
record
frame_Count : Natural := 0;
next_FPS_Time : ada.Calendar.Time := ada.Calendar.Clock;
end record;
end openGL.frame_Counter;
|
package body Logic is
-- type Ternary is (True, Unknown, False);
function Image(Value: Ternary) return Character is
begin
case Value is
when True => return 'T';
when False => return 'F';
when Unknown => return '?';
end case;
end Image;
function "and"(Left, Right: Ternary) return Ternary is
begin
return Ternary'max(Left, Right);
end "and";
function "or"(Left, Right: Ternary) return Ternary is
begin
return Ternary'min(Left, Right);
end "or";
function "not"(T: Ternary) return Ternary is
begin
case T is
when False => return True;
when Unknown => return Unknown;
when True => return False;
end case;
end "not";
function To_Bool(X: Ternary) return Boolean is
begin
case X is
when True => return True;
when False => return False;
when Unknown => raise Constraint_Error;
end case;
end To_Bool;
function To_Ternary(B: Boolean) return Ternary is
begin
if B then
return True;
else
return False;
end if;
end To_Ternary;
function Equivalent(Left, Right: Ternary) return Ternary is
begin
return To_Ternary(To_Bool(Left) = To_Bool(Right));
exception
when Constraint_Error => return Unknown;
end Equivalent;
function Implies(Condition, Conclusion: Ternary) return Ternary is
begin
return (not Condition) or Conclusion;
end Implies;
end Logic;
|
with Utils.Command_Lines; use Utils.Command_Lines;
with Utils.Drivers;
with JSON_Gen.Actions;
with JSON_Gen.Command_Lines;
procedure JSON_Gen.Main is
-- Main procedure for lalstub
-- procedure Callback (Phase : Parse_Phase; Swit : Dynamically_Typed_Switch);
procedure Callback (Phase : Parse_Phase; Swit : Dynamically_Typed_Switch) is
null;
Tool : Actions.Json_Gen_Tool;
Cmd : Command_Line (JSON_Gen.Command_Lines.Descriptor'Access);
begin
Utils.Drivers.Driver
(Cmd => Cmd,
Tool => Tool,
Tool_Package_Name => "jsongen",
Needs_Per_File_Output => True,
Callback => Callback'Unrestricted_Access);
end JSON_Gen.Main;
|
-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Compilation_Unit_Vectors;
package Program.Contexts is
pragma Pure;
type Context is limited interface;
-- The Context is a view of a particular implementation of an Ada
-- environment. We require an application to identify that view of the
-- Ada environment. An Context identifies an Ada environment as defined
-- by ISO/IEC 8652:1995. The Ada environment is well defined for Ada
-- implementations. ISO/IEC 8652:1995 provides for an implementation-
-- defined method to enter compilation units into the Ada environment.
--
-- Defined by the implementation, an context is a way to identify a set of
-- Compilation Units to be processed by an application. This may include
-- things such as the pathname, search rules, etc., which are attributes
-- of the Ada environment and consequently becomes part of the Context
-- only because it is a "view" of the Ada environment.
type Context_Access is access all Context'Class
with Storage_Size => 0;
not overriding function Library_Unit_Declarations (Self : Context)
return Program.Compilation_Unit_Vectors.Compilation_Unit_Vector_Access
is abstract
-- with Post'Class =>
-- (Library_Unit_Declarations'Result.Is_Empty
-- or else (for all X in Library_Unit_Declarations'Result.Each_Unit
-- => X.Unit.Is_Library_Unit_Declaration))
;
-- Returns a list of all library_unit_declaration and
-- library_unit_renaming_declaration elements contained in Context.
-- Individual units will appear only once in an order that is not defined.
not overriding function Compilation_Unit_Bodies (Self : Context)
return Program.Compilation_Unit_Vectors.Compilation_Unit_Vector_Access
is abstract
-- with Post'Class =>
-- (Compilation_Unit_Bodies'Result.Is_Empty
-- or else (for all X in Compilation_Unit_Bodies'Result.Each_Unit
-- => X.Unit.Is_Library_Unit_Body or X.Unit.Is_Subunit))
;
-- Returns a list of all library_unit_body and subunit elements contained in
-- Context. Individual units will appear only once in an order that is not
-- defined.
end Program.Contexts;
|
with Ada.Calendar;
with Ada.Text_IO.Text_Streams;
with Ada.Unchecked_Conversion;
with Interfaces.C;
with SDL;
with SDL.Log;
with SDL.Video.Palettes;
with SDL.Video.Pixel_Formats;
with SDL.Video.Pixels;
with SDL.Video.Renderers.Makers;
with SDL.Video.Textures.Makers;
with SDL.Video.Windows.Makers;
with System;
procedure Stream is
use type SDL.Dimension;
use type SDL.Positive_Sizes;
type Moose_Frames is mod 10;
type Moose_Colour_Index is range 1 .. 84;
type Moose_Palette_Array is array (Moose_Colour_Index'Range) of SDL.Video.Palettes.RGB_Colour;
W : SDL.Video.Windows.Window;
Moose_Size : constant SDL.Positive_Sizes := (64, 88);
Moose_Frame_Size : constant SDL.Dimension := (Moose_Size.Width * Moose_Size.Height) - 1;
Moose_Frame : Moose_Frames := Moose_Frames'First;
Moose_Palette : constant Moose_Palette_Array :=
((49, 49, 49), (66, 24, 0), (66, 33, 0), (66, 66, 66),
(66, 115, 49), (74, 33, 0), (74, 41, 16), (82, 33, 8),
(82, 41, 8), (82, 49, 16), (82, 82, 82), (90, 41, 8),
(90, 41, 16), (90, 57, 24), (99, 49, 16), (99, 66, 24),
(99, 66, 33), (99, 74, 33), (107, 57, 24), (107, 82, 41),
(115, 57, 33), (115, 66, 33), (115, 66, 41), (115, 74, 0),
(115, 90, 49), (115, 115, 115), (123, 82, 0), (123, 99, 57),
(132, 66, 41), (132, 74, 41), (132, 90, 8), (132, 99, 33),
(132, 99, 66), (132, 107, 66), (140, 74, 49), (140, 99, 16),
(140, 107, 74), (140, 115, 74), (148, 107, 24), (148, 115, 82),
(148, 123, 74), (148, 123, 90), (156, 115, 33), (156, 115, 90),
(156, 123, 82), (156, 132, 82), (156, 132, 99), (156, 156, 156),
(165, 123, 49), (165, 123, 90), (165, 132, 82), (165, 132, 90),
(165, 132, 99), (165, 140, 90), (173, 132, 57), (173, 132, 99),
(173, 140, 107), (173, 140, 115), (173, 148, 99), (173, 173, 173),
(181, 140, 74), (181, 148, 115), (181, 148, 123), (181, 156, 107),
(189, 148, 123), (189, 156, 82), (189, 156, 123), (189, 156, 132),
(189, 189, 189), (198, 156, 123), (198, 165, 132), (206, 165, 99),
(206, 165, 132), (206, 173, 140), (206, 206, 206), (214, 173, 115),
(214, 173, 140), (222, 181, 148), (222, 189, 132), (222, 189, 156),
(222, 222, 222), (231, 198, 165), (231, 231, 231), (239, 206, 173));
type Moose_Frame_Data_Array is array (Moose_Frames'Range, 0 .. Moose_Frame_Size) of Moose_Colour_Index;
Moose_Frame_Data : Moose_Frame_Data_Array;
procedure Load_Moose_Data (Data : out Moose_Frame_Data_Array) is
Actual_Name : constant String := "../../test/moose.dat";
Data_File : Ada.Text_IO.File_Type;
Stream : Ada.Text_IO.Text_Streams.Stream_Access := null;
use type Ada.Text_IO.File_Mode;
begin
Ada.Text_IO.Open (File => Data_File, Mode => Ada.Text_IO.In_File, Name => Actual_Name);
Stream := Ada.Text_IO.Text_Streams.Stream (File => Data_File);
Moose_Frame_Data_Array'Read (Stream, Data);
Ada.Text_IO.Close (File => Data_File);
exception
when others =>
SDL.Log.Put_Error ("Error, reading source file, " & Actual_Name);
raise;
end Load_Moose_Data;
Renderer : SDL.Video.Renderers.Renderer;
Texture : SDL.Video.Textures.Texture;
Pixels : SDL.Video.Pixels.ARGB_8888_Access.Pointer;
procedure Lock is new SDL.Video.Textures.Lock (Pixel_Pointer_Type => SDL.Video.Pixels.ARGB_8888_Access.Pointer);
use type SDL.Video.Pixels.ARGB_8888_Access.Pointer;
use type Ada.Calendar.Time;
-- This uses the same algorithm as the original teststream.c. It copies 1 pixel at a time, indexing into the moose
-- palette using the data from moose.dat.
procedure Update_Texture_1 (Pointer : in SDL.Video.Pixels.ARGB_8888_Access.Pointer) is
Start_Time : Ada.Calendar.Time;
End_Time : Ada.Calendar.Time;
Colour : SDL.Video.Palettes.RGB_Colour;
begin
Start_Time := Ada.Calendar.Clock;
for Y in 1 .. Moose_Size.Height loop
declare
Dest : SDL.Video.Pixels.ARGB_8888_Access.Pointer :=
Pointer + Interfaces.C.ptrdiff_t ((Y - 1) * Moose_Size.Width);
begin
for X in 1 .. Moose_Size.Width loop
Colour := Moose_Palette (Moose_Frame_Data (Moose_Frame, ((Y - 1) * Moose_Size.Width) + (X - 1)));
Dest.all := SDL.Video.Pixels.ARGB_8888'(Red => Colour.Red,
Green => Colour.Green,
Blue => Colour.Blue,
Alpha => SDL.Video.Palettes.Colour_Component'Last);
SDL.Video.Pixels.ARGB_8888_Access.Increment (Dest);
end loop;
end;
end loop;
End_Time := Ada.Calendar.Clock;
SDL.Log.Put_Debug ("Update_Texture_1 took " & Duration'Image (End_Time - Start_Time) & " seconds.");
end Update_Texture_1;
type Texture_2D_Array is array (SDL.Dimension range <>, SDL.Dimension range <>) of
aliased SDL.Video.Pixels.ARGB_8888;
package Texture_2D is new SDL.Video.Pixels.Texture_Data
(Index => SDL.Dimension,
Element => SDL.Video.Pixels.ARGB_8888,
Element_Array_1D => SDL.Video.Pixels.ARGB_8888_Array,
Element_Array_2D => Texture_2D_Array,
Default_Terminator => SDL.Video.Pixels.ARGB_8888'(others => SDL.Video.Palettes.Colour_Component'First));
procedure Update_Texture_2 (Pointer : in Texture_2D.Pointer) is
pragma Unreferenced (Pointer); -- TODO: Fix me!
function To_Address is new Ada.Unchecked_Conversion (Source => SDL.Video.Pixels.ARGB_8888_Access.Pointer,
Target => System.Address);
Start_Time : Ada.Calendar.Time;
End_Time : Ada.Calendar.Time;
Colour : SDL.Video.Palettes.RGB_Colour;
Actual_Pixels : Texture_2D_Array (1 .. Moose_Size.Height, 1 .. Moose_Size.Width) with
Address => To_Address (Pixels);
begin
Start_Time := Ada.Calendar.Clock;
for Y in 1 .. Moose_Size.Height loop
for X in 1 .. Moose_Size.Width loop
Colour := Moose_Palette (Moose_Frame_Data (Moose_Frame, ((Y - 1) * Moose_Size.Width) + (X - 1)));
Actual_Pixels (Y, X) := SDL.Video.Pixels.ARGB_8888'(Red => Colour.Red,
Green => Colour.Green,
Blue => Colour.Blue,
Alpha => SDL.Video.Palettes.Colour_Component'Last);
end loop;
end loop;
End_Time := Ada.Calendar.Clock;
SDL.Log.Put_Debug ("Update_Texture_2 took " & Duration'Image (End_Time - Start_Time) & " seconds.");
end Update_Texture_2;
type Cached_Moose_Frame_Array is array (Moose_Frames) of
Texture_2D_Array (1 .. Moose_Size.Height, 1 .. Moose_Size.Width);
procedure Cache_Moose (Cache : in out Cached_Moose_Frame_Array;
Indices : in Moose_Frame_Data_Array;
Palette : in Moose_Palette_Array) is
Colour : SDL.Video.Palettes.RGB_Colour;
begin
for Frame in Moose_Frames loop
for Y in 1 .. Moose_Size.Height loop
for X in 1 .. Moose_Size.Width loop
Colour := Palette (Indices (Frame, ((Y - 1) * Moose_Size.Width) + (X - 1)));
Cache (Frame) (Y, X) := SDL.Video.Pixels.ARGB_8888'(Red => Colour.Red,
Green => Colour.Green,
Blue => Colour.Blue,
Alpha => SDL.Video.Palettes.Colour_Component'Last);
end loop;
end loop;
end loop;
end Cache_Moose;
Cache : Cached_Moose_Frame_Array;
begin
SDL.Log.Set (Category => SDL.Log.Application, Priority => SDL.Log.Debug);
Load_Moose_Data (Data => Moose_Frame_Data);
Cache_Moose (Cache, Moose_Frame_Data, Moose_Palette);
if SDL.Initialise = True then
SDL.Video.Windows.Makers.Create (Win => W,
Title => "Stream (Moose animation)",
Position => SDL.Natural_Coordinates'(X => 100, Y => 100),
Size => Moose_Size * 4,
Flags => SDL.Video.Windows.Resizable);
SDL.Video.Renderers.Makers.Create (Renderer, W);
SDL.Video.Textures.Makers.Create (Tex => Texture,
Renderer => Renderer,
Format => SDL.Video.Pixel_Formats.Pixel_Format_ARGB_8888,
Kind => SDL.Video.Textures.Streaming,
Size => Moose_Size);
-- W.Set_Mode (SDL.Video.Windows.Full_Screen);
-- First test.
for Index in 1 .. 10 loop
Lock (Texture, Pixels);
-- The block makes things a bit clearer.
begin
Update_Texture_1 (Pixels);
end;
Texture.Unlock;
Renderer.Clear;
Renderer.Copy (Texture);
Renderer.Present;
Moose_Frame := Moose_Frame + 1;
-- if Moose_Frame = Moose_Frame'Last then
-- Pixel := Data.Element_Array (0)'Access;
-- end if;
delay 0.05;
end loop;
Renderer.Clear;
Renderer.Present;
delay 0.7;
SDL.Log.Put_Debug ("");
-- Second test.
for Index in 1 .. 10 loop
Lock (Texture, Pixels);
-- The block makes things a bit clearer.
begin
Update_Texture_2 (Texture_2D.Pointer (Pixels));
end;
Texture.Unlock;
Renderer.Clear;
Renderer.Copy (Texture);
Renderer.Present;
Moose_Frame := Moose_Frame + 1;
-- if Moose_Frame = Moose_Frame'Last then
-- Pixel := Data.Element_Array (0)'Access;
-- end if;
delay 0.05;
end loop;
Renderer.Clear;
Renderer.Present;
delay 0.7;
SDL.Log.Put_Debug ("");
-- Third test.
for Index in 1 .. 100 loop
Lock (Texture, Pixels);
-- The block makes things a bit clearer.
Update_Texture_3 : declare
function To_Address is new Ada.Unchecked_Conversion (Source => SDL.Video.Pixels.ARGB_8888_Access.Pointer,
Target => System.Address);
Start_Time : Ada.Calendar.Time;
End_Time : Ada.Calendar.Time;
Actual_Pixels : Texture_2D_Array (1 .. Moose_Size.Height, 1 .. Moose_Size.Width) with
Address => To_Address (Pixels);
begin
Start_Time := Ada.Calendar.Clock;
Actual_Pixels := Cache (Moose_Frame);
End_Time := Ada.Calendar.Clock;
SDL.Log.Put_Debug ("Update_Texture_3 took " & Duration'Image (End_Time - Start_Time) & " seconds.");
end Update_Texture_3;
Texture.Unlock;
Renderer.Clear;
Renderer.Copy (Texture);
Renderer.Present;
Moose_Frame := Moose_Frame + 1;
-- if Moose_Frame = Moose_Frame'Last then
-- Pixel := Data.Element_Array (0)'Access;
-- end if;
delay 0.05;
end loop;
W.Finalize;
SDL.Finalise;
end if;
end Stream;
|
-- generated parser support file.
-- command line: wisitoken-bnf-generate.exe --generate LALR Ada re2c wisitoken_grammar.wy
--
-- Copyright (C) 2017 - 2019 Free Software Foundation, Inc.
--
-- Author: Stephen Leake <stephe-leake@stephe-leake.org>
--
-- This file is part of GNU Emacs.
--
-- GNU Emacs 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.
--
-- GNU Emacs 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 GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
with Wisitoken_Grammar_Actions; use Wisitoken_Grammar_Actions;
with WisiToken.Lexer.re2c;
with wisitoken_grammar_re2c_c;
package body Wisitoken_Grammar_Main is
package Lexer is new WisiToken.Lexer.re2c
(wisitoken_grammar_re2c_c.New_Lexer,
wisitoken_grammar_re2c_c.Free_Lexer,
wisitoken_grammar_re2c_c.Reset_Lexer,
wisitoken_grammar_re2c_c.Next_Token);
procedure Create_Parser
(Parser : out WisiToken.Parse.LR.Parser_No_Recover.Parser;
Trace : not null access WisiToken.Trace'Class;
User_Data : in WisiToken.Syntax_Trees.User_Data_Access)
is
use WisiToken.Parse.LR;
Table : constant Parse_Table_Ptr := new Parse_Table
(State_First => 0,
State_Last => 102,
First_Terminal => 3,
Last_Terminal => 36,
First_Nonterminal => 37,
Last_Nonterminal => 56);
begin
declare
procedure Subr_1
is begin
Add_Action (Table.States (0), 23, 1);
Add_Action (Table.States (0), 33, 2);
Add_Error (Table.States (0));
Add_Goto (Table.States (0), 38, 3);
Add_Goto (Table.States (0), 43, 4);
Add_Goto (Table.States (0), 55, 5);
Add_Goto (Table.States (0), 56, 6);
Add_Action (Table.States (1), 3, 7);
Add_Action (Table.States (1), 4, 8);
Add_Action (Table.States (1), 5, 9);
Add_Action (Table.States (1), 6, 10);
Add_Action (Table.States (1), 7, 11);
Add_Action (Table.States (1), 8, 12);
Add_Action (Table.States (1), 33, 13);
Add_Error (Table.States (1));
Add_Goto (Table.States (1), 39, 14);
Add_Action (Table.States (2), 13, 15);
Add_Action (Table.States (2), 14, 16);
Add_Error (Table.States (2));
Add_Action (Table.States (3), (23, 33, 36), (55, 0), 1, null, null);
Add_Action (Table.States (4), (23, 33, 36), (55, 1), 1, null, null);
Add_Action (Table.States (5), (23, 33, 36), (56, 0), 1, null, null);
Add_Action (Table.States (6), 23, 1);
Add_Action (Table.States (6), 33, 2);
Add_Action (Table.States (6), 36, Accept_It, (37, 0), 1, null, null);
Add_Error (Table.States (6));
Add_Goto (Table.States (6), 38, 3);
Add_Goto (Table.States (6), 43, 4);
Add_Goto (Table.States (6), 55, 17);
Add_Action (Table.States (7), 33, 18);
Add_Error (Table.States (7));
Add_Goto (Table.States (7), 40, 19);
Add_Action (Table.States (8), 5, 20);
Add_Error (Table.States (8));
Add_Action (Table.States (9), 33, 21);
Add_Error (Table.States (9));
Add_Action (Table.States (10), (1 => 33), (39, 0), 1, null, null);
Add_Action (Table.States (11), 21, 22);
Add_Error (Table.States (11));
Add_Action (Table.States (12), 21, 23);
Add_Error (Table.States (12));
Add_Action (Table.States (13), 8, 24);
Add_Action (Table.States (13), 10, 25);
Add_Action (Table.States (13), 15, 26);
Add_Action (Table.States (13), 16, 27);
Add_Action (Table.States (13), 20, 28);
Add_Action (Table.States (13), 23, Reduce, (38, 3), 2, declaration_3'Access, null);
Add_Action (Table.States (13), 28, 29);
Add_Action (Table.States (13), 30, 30);
Add_Action (Table.States (13), 32, 31);
Add_Action (Table.States (13), 33, 32);
Add_Conflict (Table.States (13), 33, (38, 3), 2, declaration_3'Access, null);
Add_Action (Table.States (13), 34, 33);
Add_Action (Table.States (13), 35, 34);
Add_Action (Table.States (13), 36, Reduce, (38, 3), 2, declaration_3'Access, null);
Add_Error (Table.States (13));
Add_Goto (Table.States (13), 41, 35);
Add_Goto (Table.States (13), 42, 36);
Add_Action (Table.States (14), 33, 37);
Add_Error (Table.States (14));
Add_Action (Table.States (15), 12, Reduce, (46, 0), 0, null, null);
Add_Action (Table.States (15), 18, 38);
Add_Action (Table.States (15), 19, 39);
Add_Action (Table.States (15), 20, 40);
Add_Action (Table.States (15), 21, 41);
Add_Action (Table.States (15), 23, Reduce, (46, 0), 0, null, null);
Add_Action (Table.States (15), 29, Reduce, (46, 0), 0, null, null);
Add_Action (Table.States (15), 33, 42);
Add_Conflict (Table.States (15), 33, (46, 0), 0, null, null);
Add_Action (Table.States (15), 35, 43);
Add_Action (Table.States (15), 36, Reduce, (46, 0), 0, null, null);
Add_Error (Table.States (15));
Add_Goto (Table.States (15), 45, 44);
Add_Goto (Table.States (15), 46, 45);
Add_Goto (Table.States (15), 47, 46);
Add_Goto (Table.States (15), 48, 47);
Add_Goto (Table.States (15), 49, 48);
Add_Goto (Table.States (15), 50, 49);
Add_Goto (Table.States (15), 51, 50);
Add_Goto (Table.States (15), 52, 51);
Add_Goto (Table.States (15), 53, 52);
Add_Action (Table.States (16), 12, Reduce, (46, 0), 0, null, null);
Add_Action (Table.States (16), 18, 38);
Add_Action (Table.States (16), 19, 39);
Add_Action (Table.States (16), 20, 40);
Add_Action (Table.States (16), 21, 41);
Add_Action (Table.States (16), 23, Reduce, (46, 0), 0, null, null);
Add_Action (Table.States (16), 29, Reduce, (46, 0), 0, null, null);
Add_Action (Table.States (16), 33, 42);
Add_Conflict (Table.States (16), 33, (46, 0), 0, null, null);
Add_Action (Table.States (16), 35, 43);
Add_Action (Table.States (16), 36, Reduce, (46, 0), 0, null, null);
Add_Error (Table.States (16));
Add_Goto (Table.States (16), 45, 53);
Add_Goto (Table.States (16), 46, 45);
Add_Goto (Table.States (16), 47, 46);
Add_Goto (Table.States (16), 48, 47);
Add_Goto (Table.States (16), 49, 48);
Add_Goto (Table.States (16), 50, 49);
Add_Goto (Table.States (16), 51, 50);
Add_Goto (Table.States (16), 52, 51);
Add_Goto (Table.States (16), 53, 52);
Add_Action (Table.States (17), (23, 33, 36), (56, 1), 2, null, null);
Add_Action (Table.States (18), (9, 33), (40, 0), 1, null, null);
Add_Action (Table.States (19), 9, 54);
Add_Action (Table.States (19), 33, 55);
Add_Error (Table.States (19));
Add_Action (Table.States (20), (23, 33, 36), (38, 5), 3, declaration_5'Access, null);
Add_Action (Table.States (21), 16, 56);
Add_Error (Table.States (21));
Add_Action (Table.States (22), 33, 57);
Add_Error (Table.States (22));
Add_Action (Table.States (23), 33, 58);
Add_Error (Table.States (23));
Add_Action (Table.States (24), (8, 10, 15, 16, 20, 23, 28, 30, 32, 33, 34, 35, 36), (42, 10), 1, null,
null);
Add_Action (Table.States (25), (8, 10, 15, 16, 20, 23, 28, 30, 32, 33, 34, 35, 36), (42, 5), 1, null,
null);
Add_Action (Table.States (26), (8, 10, 15, 16, 20, 23, 28, 30, 32, 33, 34, 35, 36), (42, 0), 1, null,
null);
Add_Action (Table.States (27), (8, 10, 15, 16, 20, 23, 28, 30, 32, 33, 34, 35, 36), (42, 2), 1, null,
null);
Add_Action (Table.States (28), (8, 10, 15, 16, 20, 23, 28, 30, 32, 33, 34, 35, 36), (42, 3), 1, null,
null);
Add_Action (Table.States (29), (8, 10, 15, 16, 20, 23, 28, 30, 32, 33, 34, 35, 36), (42, 6), 1, null,
null);
Add_Action (Table.States (30), (8, 10, 15, 16, 20, 23, 28, 30, 32, 33, 34, 35, 36), (42, 7), 1, null,
null);
Add_Action (Table.States (31), (8, 10, 15, 16, 20, 23, 28, 30, 32, 33, 34, 35, 36), (42, 4), 1, null,
null);
Add_Action (Table.States (32), (8, 10, 15, 16, 20, 23, 28, 30, 32, 33, 34, 35, 36), (42, 1), 1, null,
null);
Add_Action (Table.States (33), (8, 10, 15, 16, 20, 23, 28, 30, 32, 33, 34, 35, 36), (42, 8), 1, null,
null);
Add_Action (Table.States (34), (8, 10, 15, 16, 20, 23, 28, 30, 32, 33, 34, 35, 36), (42, 9), 1, null,
null);
Add_Action (Table.States (35), 8, 24);
Add_Action (Table.States (35), 10, 25);
Add_Action (Table.States (35), 15, 26);
Add_Action (Table.States (35), 16, 27);
Add_Action (Table.States (35), 20, 28);
Add_Action (Table.States (35), 23, Reduce, (38, 2), 3, declaration_2'Access, null);
Add_Action (Table.States (35), 28, 29);
Add_Action (Table.States (35), 30, 30);
Add_Action (Table.States (35), 32, 31);
Add_Action (Table.States (35), 33, 32);
Add_Conflict (Table.States (35), 33, (38, 2), 3, declaration_2'Access, null);
Add_Action (Table.States (35), 34, 33);
Add_Action (Table.States (35), 35, 34);
Add_Action (Table.States (35), 36, Reduce, (38, 2), 3, declaration_2'Access, null);
Add_Error (Table.States (35));
Add_Goto (Table.States (35), 42, 59);
Add_Action (Table.States (36), (8, 10, 15, 16, 20, 23, 28, 30, 32, 33, 34, 35, 36), (41, 0), 1, null,
null);
Add_Action (Table.States (37), 8, 24);
Add_Action (Table.States (37), 10, 25);
Add_Action (Table.States (37), 15, 26);
Add_Action (Table.States (37), 16, 27);
Add_Action (Table.States (37), 20, 28);
Add_Action (Table.States (37), 28, 29);
Add_Action (Table.States (37), 30, 30);
Add_Action (Table.States (37), 32, 31);
Add_Action (Table.States (37), 33, 32);
Add_Action (Table.States (37), 34, 33);
Add_Action (Table.States (37), 35, 34);
Add_Error (Table.States (37));
Add_Goto (Table.States (37), 41, 60);
Add_Goto (Table.States (37), 42, 36);
Add_Action (Table.States (38), 18, 38);
Add_Action (Table.States (38), 19, 39);
Add_Action (Table.States (38), 20, 40);
Add_Action (Table.States (38), 21, 41);
Add_Action (Table.States (38), 33, 42);
Add_Action (Table.States (38), 35, 43);
Add_Error (Table.States (38));
Add_Goto (Table.States (38), 47, 46);
Add_Goto (Table.States (38), 48, 47);
Add_Goto (Table.States (38), 49, 61);
Add_Goto (Table.States (38), 50, 49);
Add_Goto (Table.States (38), 51, 50);
Add_Goto (Table.States (38), 52, 51);
Add_Goto (Table.States (38), 53, 52);
Add_Goto (Table.States (38), 54, 62);
Add_Action (Table.States (39), 18, 38);
Add_Action (Table.States (39), 19, 39);
Add_Action (Table.States (39), 20, 40);
Add_Action (Table.States (39), 21, 41);
Add_Action (Table.States (39), 33, 42);
Add_Action (Table.States (39), 35, 43);
Add_Error (Table.States (39));
Add_Goto (Table.States (39), 47, 46);
Add_Goto (Table.States (39), 48, 47);
Add_Goto (Table.States (39), 49, 61);
Add_Goto (Table.States (39), 50, 49);
Add_Goto (Table.States (39), 51, 50);
Add_Goto (Table.States (39), 52, 51);
Add_Goto (Table.States (39), 53, 52);
Add_Goto (Table.States (39), 54, 63);
Add_Action (Table.States (40), 18, 38);
Add_Action (Table.States (40), 19, 39);
Add_Action (Table.States (40), 20, 40);
Add_Action (Table.States (40), 21, 41);
Add_Action (Table.States (40), 33, 42);
Add_Action (Table.States (40), 35, 43);
Add_Error (Table.States (40));
Add_Goto (Table.States (40), 47, 46);
Add_Goto (Table.States (40), 48, 47);
Add_Goto (Table.States (40), 49, 61);
Add_Goto (Table.States (40), 50, 49);
Add_Goto (Table.States (40), 51, 50);
Add_Goto (Table.States (40), 52, 51);
Add_Goto (Table.States (40), 53, 52);
Add_Goto (Table.States (40), 54, 64);
Add_Action (Table.States (41), 33, 65);
Add_Error (Table.States (41));
Add_Action (Table.States (42), 11, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (42), 12, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (42), 16, 66);
Add_Action (Table.States (42), 18, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (42), 19, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (42), 20, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (42), 21, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (42), 23, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (42), 24, 67);
Add_Action (Table.States (42), 25, 68);
Add_Action (Table.States (42), 26, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (42), 27, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (42), 28, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (42), 29, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (42), 31, 69);
Add_Action (Table.States (42), 33, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (42), 35, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (42), 36, Reduce, (50, 0), 1, null, null);
Add_Error (Table.States (42));
Add_Action (Table.States (43), 11, Reduce, (50, 1), 1, rhs_item_1'Access, null);
Add_Action (Table.States (43), 12, Reduce, (50, 1), 1, rhs_item_1'Access, null);
Add_Action (Table.States (43), 18, Reduce, (50, 1), 1, rhs_item_1'Access, null);
Add_Action (Table.States (43), 19, Reduce, (50, 1), 1, rhs_item_1'Access, null);
Add_Action (Table.States (43), 20, Reduce, (50, 1), 1, rhs_item_1'Access, null);
Add_Action (Table.States (43), 21, Reduce, (50, 1), 1, rhs_item_1'Access, null);
Add_Action (Table.States (43), 23, Reduce, (50, 1), 1, rhs_item_1'Access, null);
Add_Action (Table.States (43), 25, 70);
Add_Action (Table.States (43), 26, Reduce, (50, 1), 1, rhs_item_1'Access, null);
Add_Action (Table.States (43), 27, Reduce, (50, 1), 1, rhs_item_1'Access, null);
Add_Action (Table.States (43), 28, Reduce, (50, 1), 1, rhs_item_1'Access, null);
Add_Action (Table.States (43), 29, Reduce, (50, 1), 1, rhs_item_1'Access, null);
Add_Action (Table.States (43), 33, Reduce, (50, 1), 1, rhs_item_1'Access, null);
Add_Action (Table.States (43), 35, Reduce, (50, 1), 1, rhs_item_1'Access, null);
Add_Action (Table.States (43), 36, Reduce, (50, 1), 1, rhs_item_1'Access, null);
Add_Error (Table.States (43));
Add_Action (Table.States (44), 12, 71);
Add_Action (Table.States (44), 23, 72);
Add_Conflict (Table.States (44), 23, (44, 1), 0, null, null);
Add_Action (Table.States (44), 29, 73);
Add_Action (Table.States (44), 33, Reduce, (44, 1), 0, null, null);
Add_Action (Table.States (44), 36, Reduce, (44, 1), 0, null, null);
Add_Error (Table.States (44));
Add_Goto (Table.States (44), 44, 74);
Add_Action (Table.States (45), (12, 23, 29, 33, 36), (45, 0), 1, null, null);
Add_Action (Table.States (46), (11, 12, 18, 19, 20, 21, 23, 26, 27, 28, 29, 33, 35, 36), (50, 2), 1,
rhs_item_2'Access, null);
Add_Action (Table.States (47), (11, 12, 18, 19, 20, 21, 23, 26, 27, 28, 29, 33, 35, 36), (49, 0), 1, null,
null);
Add_Action (Table.States (48), 11, 75);
Add_Action (Table.States (48), 12, Reduce, (46, 1), 1, null, null);
Add_Action (Table.States (48), 18, 38);
Add_Action (Table.States (48), 19, 39);
Add_Action (Table.States (48), 20, 40);
Add_Action (Table.States (48), 21, 41);
Add_Action (Table.States (48), 23, Reduce, (46, 1), 1, null, null);
Add_Action (Table.States (48), 29, Reduce, (46, 1), 1, null, null);
Add_Action (Table.States (48), 33, 42);
Add_Conflict (Table.States (48), 33, (46, 1), 1, null, null);
Add_Action (Table.States (48), 35, 43);
Add_Action (Table.States (48), 36, Reduce, (46, 1), 1, null, null);
Add_Error (Table.States (48));
Add_Goto (Table.States (48), 47, 46);
Add_Goto (Table.States (48), 48, 76);
Add_Goto (Table.States (48), 50, 49);
Add_Goto (Table.States (48), 51, 50);
Add_Goto (Table.States (48), 52, 51);
Add_Goto (Table.States (48), 53, 52);
Add_Action (Table.States (49), (11, 12, 18, 19, 20, 21, 23, 26, 27, 28, 29, 33, 35, 36), (48, 0), 1, null,
null);
Add_Action (Table.States (50), (11, 12, 18, 19, 20, 21, 23, 26, 27, 28, 29, 33, 35, 36), (50, 5), 1,
rhs_item_5'Access, null);
Add_Action (Table.States (51), (11, 12, 18, 19, 20, 21, 23, 26, 27, 28, 29, 33, 35, 36), (50, 3), 1,
rhs_item_3'Access, null);
Add_Action (Table.States (52), (11, 12, 18, 19, 20, 21, 23, 26, 27, 28, 29, 33, 35, 36), (50, 4), 1,
rhs_item_4'Access, null);
Add_Action (Table.States (53), 12, 71);
Add_Action (Table.States (53), 23, 72);
Add_Conflict (Table.States (53), 23, (44, 1), 0, null, null);
Add_Action (Table.States (53), 29, 73);
Add_Action (Table.States (53), 33, Reduce, (44, 1), 0, null, null);
Add_Action (Table.States (53), 36, Reduce, (44, 1), 0, null, null);
Add_Error (Table.States (53));
Add_Goto (Table.States (53), 44, 77);
Add_Action (Table.States (54), (23, 33, 36), (38, 1), 4, declaration_1'Access, null);
Add_Action (Table.States (55), (9, 33), (40, 1), 2, null, null);
Add_Action (Table.States (56), 33, 78);
Add_Error (Table.States (56));
Add_Action (Table.States (57), 17, 79);
Add_Error (Table.States (57));
Add_Action (Table.States (58), 17, 80);
Add_Error (Table.States (58));
Add_Action (Table.States (59), (8, 10, 15, 16, 20, 23, 28, 30, 32, 33, 34, 35, 36), (41, 1), 2, null,
null);
Add_Action (Table.States (60), 8, 24);
Add_Action (Table.States (60), 10, 25);
Add_Action (Table.States (60), 15, 26);
Add_Action (Table.States (60), 16, 27);
Add_Action (Table.States (60), 20, 28);
Add_Action (Table.States (60), 23, Reduce, (38, 0), 4, declaration_0'Access, null);
Add_Action (Table.States (60), 28, 29);
Add_Action (Table.States (60), 30, 30);
Add_Action (Table.States (60), 32, 31);
Add_Action (Table.States (60), 33, 32);
Add_Conflict (Table.States (60), 33, (38, 0), 4, declaration_0'Access, null);
Add_Action (Table.States (60), 34, 33);
Add_Action (Table.States (60), 35, 34);
Add_Action (Table.States (60), 36, Reduce, (38, 0), 4, declaration_0'Access, null);
Add_Error (Table.States (60));
Add_Goto (Table.States (60), 42, 59);
Add_Action (Table.States (61), 12, Reduce, (54, 0), 1, null, null);
Add_Action (Table.States (61), 18, 38);
Add_Action (Table.States (61), 19, 39);
Add_Action (Table.States (61), 20, 40);
Add_Action (Table.States (61), 21, 41);
Add_Action (Table.States (61), 26, Reduce, (54, 0), 1, null, null);
Add_Action (Table.States (61), 27, Reduce, (54, 0), 1, null, null);
Add_Action (Table.States (61), 28, Reduce, (54, 0), 1, null, null);
Add_Action (Table.States (61), 33, 42);
Add_Action (Table.States (61), 35, 43);
Add_Error (Table.States (61));
Add_Goto (Table.States (61), 47, 46);
Add_Goto (Table.States (61), 48, 76);
Add_Goto (Table.States (61), 50, 49);
Add_Goto (Table.States (61), 51, 50);
Add_Goto (Table.States (61), 52, 51);
Add_Goto (Table.States (61), 53, 52);
Add_Action (Table.States (62), 12, 81);
Add_Action (Table.States (62), 26, 82);
Add_Error (Table.States (62));
Add_Action (Table.States (63), 12, 81);
Add_Action (Table.States (63), 27, 83);
Add_Error (Table.States (63));
Add_Action (Table.States (64), 12, 81);
Add_Action (Table.States (64), 28, 84);
Add_Error (Table.States (64));
Add_Action (Table.States (65), 16, 85);
Add_Error (Table.States (65));
Add_Action (Table.States (66), 18, 38);
Add_Action (Table.States (66), 19, 39);
Add_Action (Table.States (66), 20, 40);
Add_Action (Table.States (66), 21, 41);
Add_Action (Table.States (66), 33, 86);
Add_Action (Table.States (66), 35, 43);
Add_Error (Table.States (66));
Add_Goto (Table.States (66), 47, 46);
Add_Goto (Table.States (66), 50, 87);
Add_Goto (Table.States (66), 51, 50);
Add_Goto (Table.States (66), 52, 51);
Add_Goto (Table.States (66), 53, 52);
Add_Action (Table.States (67), (11, 12, 18, 19, 20, 21, 23, 26, 27, 28, 29, 33, 35, 36), (53, 4), 2, null,
null);
Add_Action (Table.States (68), (11, 12, 18, 19, 20, 21, 23, 26, 27, 28, 29, 33, 35, 36), (52, 2), 2, null,
null);
Add_Action (Table.States (69), (11, 12, 18, 19, 20, 21, 23, 26, 27, 28, 29, 33, 35, 36), (53, 5), 2, null,
null);
Add_Action (Table.States (70), (11, 12, 18, 19, 20, 21, 23, 26, 27, 28, 29, 33, 35, 36), (52, 3), 2,
rhs_optional_item_3'Access, null);
Add_Action (Table.States (71), 12, Reduce, (46, 0), 0, null, null);
Add_Action (Table.States (71), 18, 38);
Add_Action (Table.States (71), 19, 39);
Add_Action (Table.States (71), 20, 40);
Add_Action (Table.States (71), 21, 41);
Add_Action (Table.States (71), 23, Reduce, (46, 0), 0, null, null);
Add_Action (Table.States (71), 29, Reduce, (46, 0), 0, null, null);
Add_Action (Table.States (71), 33, 42);
Add_Conflict (Table.States (71), 33, (46, 0), 0, null, null);
Add_Action (Table.States (71), 35, 43);
Add_Action (Table.States (71), 36, Reduce, (46, 0), 0, null, null);
Add_Error (Table.States (71));
Add_Goto (Table.States (71), 46, 88);
Add_Goto (Table.States (71), 47, 46);
Add_Goto (Table.States (71), 48, 47);
Add_Goto (Table.States (71), 49, 48);
Add_Goto (Table.States (71), 50, 49);
Add_Goto (Table.States (71), 51, 50);
Add_Goto (Table.States (71), 52, 51);
Add_Goto (Table.States (71), 53, 52);
Add_Action (Table.States (72), 4, 89);
Add_Action (Table.States (72), 5, 90);
Add_Error (Table.States (72));
Add_Action (Table.States (73), (23, 33, 36), (44, 0), 1, null, null);
Add_Action (Table.States (74), (23, 33, 36), (43, 0), 4, nonterminal_0'Access, null);
Add_Action (Table.States (75), 11, 91);
Add_Action (Table.States (75), 12, Reduce, (46, 2), 2, null, null);
Add_Action (Table.States (75), 23, Reduce, (46, 2), 2, null, null);
Add_Action (Table.States (75), 29, Reduce, (46, 2), 2, null, null);
Add_Action (Table.States (75), 33, Reduce, (46, 2), 2, null, null);
Add_Action (Table.States (75), 36, Reduce, (46, 2), 2, null, null);
Add_Error (Table.States (75));
Add_Action (Table.States (76), (11, 12, 18, 19, 20, 21, 23, 26, 27, 28, 29, 33, 35, 36), (49, 1), 2, null,
null);
Add_Action (Table.States (77), (23, 33, 36), (43, 1), 4, nonterminal_1'Access, null);
Add_Action (Table.States (78), (23, 33, 36), (38, 4), 5, declaration_4'Access, null);
Add_Action (Table.States (79), (1 => 33), (39, 1), 4, null, null);
Add_Action (Table.States (80), (1 => 33), (39, 2), 4, null, null);
Add_Action (Table.States (81), 18, 38);
Add_Action (Table.States (81), 19, 39);
Add_Action (Table.States (81), 20, 40);
Add_Action (Table.States (81), 21, 41);
Add_Action (Table.States (81), 33, 42);
Add_Action (Table.States (81), 35, 43);
Add_Error (Table.States (81));
Add_Goto (Table.States (81), 47, 46);
Add_Goto (Table.States (81), 48, 47);
Add_Goto (Table.States (81), 49, 92);
Add_Goto (Table.States (81), 50, 49);
Add_Goto (Table.States (81), 51, 50);
Add_Goto (Table.States (81), 52, 51);
Add_Goto (Table.States (81), 53, 52);
Add_Action (Table.States (82), 11, Reduce, (53, 0), 3, null, null);
Add_Action (Table.States (82), 12, Reduce, (53, 0), 3, null, null);
Add_Action (Table.States (82), 18, Reduce, (53, 0), 3, null, null);
Add_Action (Table.States (82), 19, Reduce, (53, 0), 3, null, null);
Add_Action (Table.States (82), 20, Reduce, (53, 0), 3, null, null);
Add_Action (Table.States (82), 21, Reduce, (53, 0), 3, null, null);
Add_Action (Table.States (82), 22, 93);
Add_Action (Table.States (82), 23, Reduce, (53, 0), 3, null, null);
Add_Action (Table.States (82), 26, Reduce, (53, 0), 3, null, null);
Add_Action (Table.States (82), 27, Reduce, (53, 0), 3, null, null);
Add_Action (Table.States (82), 28, Reduce, (53, 0), 3, null, null);
Add_Action (Table.States (82), 29, Reduce, (53, 0), 3, null, null);
Add_Action (Table.States (82), 33, Reduce, (53, 0), 3, null, null);
Add_Action (Table.States (82), 35, Reduce, (53, 0), 3, null, null);
Add_Action (Table.States (82), 36, Reduce, (53, 0), 3, null, null);
Add_Error (Table.States (82));
Add_Action (Table.States (83), (11, 12, 18, 19, 20, 21, 23, 26, 27, 28, 29, 33, 35, 36), (52, 0), 3, null,
null);
Add_Action (Table.States (84), 11, Reduce, (51, 0), 3, null, null);
Add_Action (Table.States (84), 12, Reduce, (51, 0), 3, null, null);
Add_Action (Table.States (84), 18, Reduce, (51, 0), 3, null, null);
Add_Action (Table.States (84), 19, Reduce, (51, 0), 3, null, null);
Add_Action (Table.States (84), 20, Reduce, (51, 0), 3, null, null);
Add_Action (Table.States (84), 21, Reduce, (51, 0), 3, null, null);
Add_Action (Table.States (84), 23, Reduce, (51, 0), 3, null, null);
Add_Action (Table.States (84), 24, 94);
Add_Action (Table.States (84), 25, 95);
Add_Action (Table.States (84), 26, Reduce, (51, 0), 3, null, null);
Add_Action (Table.States (84), 27, Reduce, (51, 0), 3, null, null);
Add_Action (Table.States (84), 28, Reduce, (51, 0), 3, null, null);
Add_Action (Table.States (84), 29, Reduce, (51, 0), 3, null, null);
Add_Action (Table.States (84), 31, 96);
Add_Action (Table.States (84), 33, Reduce, (51, 0), 3, null, null);
Add_Action (Table.States (84), 35, Reduce, (51, 0), 3, null, null);
Add_Action (Table.States (84), 36, Reduce, (51, 0), 3, null, null);
Add_Error (Table.States (84));
Add_Action (Table.States (85), 33, 97);
Add_Error (Table.States (85));
Add_Action (Table.States (86), 11, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (86), 12, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (86), 18, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (86), 19, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (86), 20, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (86), 21, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (86), 23, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (86), 24, 67);
Add_Action (Table.States (86), 25, 68);
Add_Action (Table.States (86), 26, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (86), 27, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (86), 28, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (86), 29, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (86), 31, 69);
Add_Action (Table.States (86), 33, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (86), 35, Reduce, (50, 0), 1, null, null);
Add_Action (Table.States (86), 36, Reduce, (50, 0), 1, null, null);
Add_Error (Table.States (86));
Add_Action (Table.States (87), (11, 12, 18, 19, 20, 21, 23, 26, 27, 28, 29, 33, 35, 36), (48, 1), 3, null,
null);
Add_Action (Table.States (88), (12, 23, 29, 33, 36), (45, 1), 3, null, null);
Add_Action (Table.States (89), 5, 98);
Add_Error (Table.States (89));
Add_Action (Table.States (90), 33, 99);
Add_Error (Table.States (90));
Add_Action (Table.States (91), (12, 23, 29, 33, 36), (46, 3), 3, null, null);
Add_Action (Table.States (92), 12, Reduce, (54, 1), 3, null, null);
Add_Action (Table.States (92), 18, 38);
Add_Action (Table.States (92), 19, 39);
Add_Action (Table.States (92), 20, 40);
Add_Action (Table.States (92), 21, 41);
Add_Action (Table.States (92), 26, Reduce, (54, 1), 3, null, null);
Add_Action (Table.States (92), 27, Reduce, (54, 1), 3, null, null);
Add_Action (Table.States (92), 28, Reduce, (54, 1), 3, null, null);
Add_Action (Table.States (92), 33, 42);
Add_Action (Table.States (92), 35, 43);
Add_Error (Table.States (92));
Add_Goto (Table.States (92), 47, 46);
Add_Goto (Table.States (92), 48, 76);
Add_Goto (Table.States (92), 50, 49);
Add_Goto (Table.States (92), 51, 50);
Add_Goto (Table.States (92), 52, 51);
Add_Goto (Table.States (92), 53, 52);
Add_Action (Table.States (93), (11, 12, 18, 19, 20, 21, 23, 26, 27, 28, 29, 33, 35, 36), (53, 1), 4, null,
null);
Add_Action (Table.States (94), (11, 12, 18, 19, 20, 21, 23, 26, 27, 28, 29, 33, 35, 36), (53, 2), 4, null,
null);
Add_Action (Table.States (95), (11, 12, 18, 19, 20, 21, 23, 26, 27, 28, 29, 33, 35, 36), (52, 1), 4, null,
null);
Add_Action (Table.States (96), (11, 12, 18, 19, 20, 21, 23, 26, 27, 28, 29, 33, 35, 36), (53, 3), 4, null,
null);
Add_Action (Table.States (97), 17, 100);
Add_Error (Table.States (97));
Add_Action (Table.States (98), (12, 23, 29, 33, 36), (45, 3), 4, null, null);
Add_Action (Table.States (99), 16, 101);
Add_Error (Table.States (99));
Add_Action (Table.States (100), (11, 12, 18, 19, 20, 21, 23, 26, 27, 28, 29, 33, 35, 36), (47, 0), 5, null,
null);
Add_Action (Table.States (101), 33, 102);
Add_Error (Table.States (101));
Add_Action (Table.States (102), (12, 23, 29, 33, 36), (45, 2), 6, null, null);
end Subr_1;
begin
Subr_1;
end;
WisiToken.Parse.LR.Parser_No_Recover.New_Parser
(Parser,
Trace,
Lexer.New_Lexer (Trace.Descriptor),
Table,
User_Data,
Max_Parallel => 15,
Terminate_Same_State => True);
end Create_Parser;
end Wisitoken_Grammar_Main;
|
package body ulog is
procedure Init is null;
procedure Serialize_Ulog (msg : in Message; len : out Natural; bytes : out HIL.Byte_Array) is null;
procedure Format (msg : in Message; bytes : out HIL.Byte_Array) is null;
procedure Get_Header_Ulog (bytes : in out HIL.Byte_Array;
len : out Natural; valid : out Boolean) is null;
procedure Describe (msg : in Message; namestring : out String) is null;
function Describe_Func (msg : in Message) return String is ("hallo");
function Size (msg : in Message)
return Interfaces.Unsigned_16 is (0);
function Self (msg : in Message) return ULog.Message is (msg);
procedure Get_Serialization (msg : in Message; bytes : out HIL.Byte_Array) is null;
function Get_Size (msg : in Message) return Interfaces.Unsigned_16 is (0);
procedure Get_Format
(msg : in Message;
bytes : out HIL.Byte_Array) is null;
end ulog;
|
with Ada.Text_IO;
package body Approximation is
package RIO is new Ada.Text_IO.Float_IO(Real);
-- create an approximation
function Approx(Value: Real; Sigma: Real) return Number is
begin
return (Value, Sigma);
end Approx;
-- unary operations and conversion Real to Number
function "+"(X: Real) return Number is
begin
return Approx(X, 0.0);
end "+";
function "-"(X: Real) return Number is
begin
return Approx(-X, 0.0);
end "-";
function "+"(X: Number) return Number is
begin
return X;
end "+";
function "-"(X: Number) return Number is
begin
return Approx(-X.Value, X.Sigma);
end "-";
-- addition / subtraction
function "+"(X: Number; Y: Number) return Number is
Z: Number;
begin
Z.Value := X.Value + Y.Value;
Z.Sigma := Sqrt(X.Sigma*X.Sigma + Y.Sigma*Y.Sigma);
return Z;
end "+";
function "-"(X: Number; Y: Number) return Number is
begin
return X + (-Y);
end "-";
-- multiplication / division
function "*"(X: Number; Y: Number) return Number is
Z: Number;
begin
Z.Value := X.Value * Y.Value;
Z.Sigma := Z.Value * Sqrt((X.Sigma/X.Value)**2 + (Y.Sigma/Y.Value)**2);
return Z;
end "*";
function "/"(X: Number; Y: Number) return Number is
Z: Number;
begin
Z.Value := X.Value / Y.Value;
Z.Sigma := Z.Value * Sqrt((X.Sigma/X.Value)**2 + (Y.Sigma/Y.Value)**2);
return Z;
end "/";
-- exponentiation
function "**"(X: Number; Y: Positive) return Number is
Z: Number;
begin
Z.Value := X.Value ** Y ;
Z.Sigma := Z.Value * Real(Y) * (X.Sigma/X.Value);
if Z.Sigma < 0.0 then
Z.Sigma := - Z.Sigma;
end if;
return Z;
end "**";
function "**"(X: Number; Y: Real) return Number is
Z: Number;
begin
Z.Value := X.Value ** Y ;
Z.Sigma := Z.Value * Y * (X.Sigma/X.Value);
if Z.Sigma < 0.0 then
Z.Sigma := - Z.Sigma;
end if;
return Z;
end "**";
-- Output to Standard IO (wrapper for Ada.Text_IO.Float_IO)
procedure Put_Line(Message: String;
Item: Number;
Value_Fore: Natural := 7;
Sigma_Fore: Natural := 4;
Aft: Natural := 2;
Exp: Natural := 0) is
begin
Ada.Text_IO.Put(Message);
Put(Item, Value_Fore, Sigma_Fore, Aft, Exp);
Ada.Text_IO.New_Line;
end Put_Line;
procedure Put(Item: Number;
Value_Fore: Natural := 7;
Sigma_Fore: Natural := 3;
Aft: Natural := 2;
Exp: Natural := 0) is
begin
RIO.Put(Item.Value, Value_Fore, Aft, Exp);
Ada.Text_IO.Put(" (+-");
RIO.Put(Item.Sigma, Sigma_Fore, Aft, Exp);
Ada.Text_IO.Put(")");
end Put;
end Approximation;
|
-- ___ _ ___ _ _ --
-- / __| |/ (_) | | Common SKilL implementation --
-- \__ \ ' <| | | |__ memory manager for ada ported from c++ skill --
-- |___/_|\_\_|_|____| by: Timm Felden --
-- --
pragma Ada_2012;
with Skill.Containers.Vectors;
generic
type T is private;
type T_Access is access all T;
package Skill.Books is
package Vec is new Skill.Containers.Vectors (Natural, T_Access);
type P is array (Natural range <>) of aliased T;
type Page is access P;
package Pages_P is new Skill.Containers.Vectors (Natural, Page);
Default_Page_Size : constant := 128;
-- @see c++ for documentation
type Book is tagged record
Freelist : Vec.Vector := Vec.Empty_Vector;
--! @invariant: if not current page then, T is used or T is in freeList
Pages : Pages_P.Vector := Pages_P.Empty_Vector;
Current_Page : Page := null;
Current_Remaining : Natural := 0;
end record;
-- create a new page of expected size
-- @pre current_remaining == 0
-- @post current_remaining == 0
-- @return current_page
-- @note the caller has to use the whole page, as it is marked as used
function Make_Page (This : access Book'Class; Expected_Size : Natural)
return Page;
-- note won't free the book, but only the pages
procedure Free (This : access Book'Class);
-- can only be called directly after creation of the book
function First_Page
(This : access Book'Class) return Page is
(This.Current_Page);
-- return the next free instance
--
-- @note must never be called, while using the first page
function Next (This : access Book'Class) return T_Access;
-- recycle the argument instance
procedure free (This : access Book'Class; Target : T_Access);
end Skill.Books;
|
with Ada.Integer_Text_IO, Generic_Perm;
procedure Topswaps is
function Topswaps(Size: Positive) return Natural is
package Perms is new Generic_Perm(Size);
P: Perms.Permutation;
Done: Boolean;
Max: Natural;
function Swapper_Calls(P: Perms.Permutation) return Natural is
Q: Perms.Permutation := P;
I: Perms.Element := P(1);
begin
if I = 1 then
return 0;
else
for Idx in 1 .. I loop
Q(Idx) := P(I-Idx+1);
end loop;
return 1 + Swapper_Calls(Q);
end if;
end Swapper_Calls;
begin
Perms.Set_To_First(P, Done);
Max:= Swapper_Calls(P);
while not Done loop
Perms.Go_To_Next(P, Done);
Max := natural'Max(Max, Swapper_Calls(P));
end loop;
return Max;
end Topswaps;
begin
for I in 1 .. 10 loop
Ada.Integer_Text_IO.Put(Item => Topswaps(I), Width => 3);
end loop;
end Topswaps;
|
with String_Sets; use String_Sets;
with String_Vectors; use String_Vectors;
package String_Sets_Utils is
function From_Vector (V : Vector) return Set;
function To_String (S : Set) return String;
end String_Sets_Utils;
|
pragma Style_Checks (Off);
-- This spec has been automatically generated from ATSAMD51G19A.svd
pragma Restrictions (No_Elaboration_Code);
with HAL;
with System;
package SAM_SVD.TPI is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype TPI_ACPR_PRESCALER_Field is HAL.UInt13;
-- Asynchronous Clock Prescaler Register
type TPI_ACPR_Register is record
PRESCALER : TPI_ACPR_PRESCALER_Field := 16#0#;
-- unspecified
Reserved_13_31 : HAL.UInt19 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TPI_ACPR_Register use record
PRESCALER at 0 range 0 .. 12;
Reserved_13_31 at 0 range 13 .. 31;
end record;
subtype TPI_SPPR_TXMODE_Field is HAL.UInt2;
-- Selected Pin Protocol Register
type TPI_SPPR_Register is record
TXMODE : TPI_SPPR_TXMODE_Field := 16#0#;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TPI_SPPR_Register use record
TXMODE at 0 range 0 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-- Formatter and Flush Status Register
type TPI_FFSR_Register is record
-- Read-only.
FlInProg : Boolean;
-- Read-only.
FtStopped : Boolean;
-- Read-only.
TCPresent : Boolean;
-- Read-only.
FtNonStop : Boolean;
-- unspecified
Reserved_4_31 : HAL.UInt28;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TPI_FFSR_Register use record
FlInProg at 0 range 0 .. 0;
FtStopped at 0 range 1 .. 1;
TCPresent at 0 range 2 .. 2;
FtNonStop at 0 range 3 .. 3;
Reserved_4_31 at 0 range 4 .. 31;
end record;
-- Formatter and Flush Control Register
type TPI_FFCR_Register is record
-- unspecified
Reserved_0_0 : HAL.Bit := 16#0#;
EnFCont : Boolean := False;
-- unspecified
Reserved_2_7 : HAL.UInt6 := 16#0#;
TrigIn : Boolean := False;
-- unspecified
Reserved_9_31 : HAL.UInt23 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TPI_FFCR_Register use record
Reserved_0_0 at 0 range 0 .. 0;
EnFCont at 0 range 1 .. 1;
Reserved_2_7 at 0 range 2 .. 7;
TrigIn at 0 range 8 .. 8;
Reserved_9_31 at 0 range 9 .. 31;
end record;
-- TRIGGER
type TPI_TRIGGER_Register is record
-- Read-only.
TRIGGER : Boolean;
-- unspecified
Reserved_1_31 : HAL.UInt31;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TPI_TRIGGER_Register use record
TRIGGER at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-- TPI_FIFO0_ETM array element
subtype TPI_FIFO0_ETM_Element is HAL.UInt8;
-- TPI_FIFO0_ETM array
type TPI_FIFO0_ETM_Field_Array is array (0 .. 2) of TPI_FIFO0_ETM_Element
with Component_Size => 8, Size => 24;
-- Type definition for TPI_FIFO0_ETM
type TPI_FIFO0_ETM_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- ETM as a value
Val : HAL.UInt24;
when True =>
-- ETM as an array
Arr : TPI_FIFO0_ETM_Field_Array;
end case;
end record
with Unchecked_Union, Size => 24;
for TPI_FIFO0_ETM_Field use record
Val at 0 range 0 .. 23;
Arr at 0 range 0 .. 23;
end record;
subtype TPI_FIFO0_ETM_bytecount_Field is HAL.UInt2;
subtype TPI_FIFO0_ITM_bytecount_Field is HAL.UInt2;
-- Integration ETM Data
type TPI_FIFO0_Register is record
-- Read-only.
ETM : TPI_FIFO0_ETM_Field;
-- Read-only.
ETM_bytecount : TPI_FIFO0_ETM_bytecount_Field;
-- Read-only.
ETM_ATVALID : Boolean;
-- Read-only.
ITM_bytecount : TPI_FIFO0_ITM_bytecount_Field;
-- Read-only.
ITM_ATVALID : Boolean;
-- unspecified
Reserved_30_31 : HAL.UInt2;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TPI_FIFO0_Register use record
ETM at 0 range 0 .. 23;
ETM_bytecount at 0 range 24 .. 25;
ETM_ATVALID at 0 range 26 .. 26;
ITM_bytecount at 0 range 27 .. 28;
ITM_ATVALID at 0 range 29 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
-- ITATBCTR2
type ITATBCTR_Register is record
-- Read-only.
ATREADY : Boolean;
-- unspecified
Reserved_1_31 : HAL.UInt31;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ITATBCTR_Register use record
ATREADY at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
-- TPI_FIFO1_ITM array element
subtype TPI_FIFO1_ITM_Element is HAL.UInt8;
-- TPI_FIFO1_ITM array
type TPI_FIFO1_ITM_Field_Array is array (0 .. 2) of TPI_FIFO1_ITM_Element
with Component_Size => 8, Size => 24;
-- Type definition for TPI_FIFO1_ITM
type TPI_FIFO1_ITM_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- ITM as a value
Val : HAL.UInt24;
when True =>
-- ITM as an array
Arr : TPI_FIFO1_ITM_Field_Array;
end case;
end record
with Unchecked_Union, Size => 24;
for TPI_FIFO1_ITM_Field use record
Val at 0 range 0 .. 23;
Arr at 0 range 0 .. 23;
end record;
subtype TPI_FIFO1_ETM_bytecount_Field is HAL.UInt2;
subtype TPI_FIFO1_ITM_bytecount_Field is HAL.UInt2;
-- Integration ITM Data
type TPI_FIFO1_Register is record
-- Read-only.
ITM : TPI_FIFO1_ITM_Field;
-- Read-only.
ETM_bytecount : TPI_FIFO1_ETM_bytecount_Field;
-- Read-only.
ETM_ATVALID : Boolean;
-- Read-only.
ITM_bytecount : TPI_FIFO1_ITM_bytecount_Field;
-- Read-only.
ITM_ATVALID : Boolean;
-- unspecified
Reserved_30_31 : HAL.UInt2;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TPI_FIFO1_Register use record
ITM at 0 range 0 .. 23;
ETM_bytecount at 0 range 24 .. 25;
ETM_ATVALID at 0 range 26 .. 26;
ITM_bytecount at 0 range 27 .. 28;
ITM_ATVALID at 0 range 29 .. 29;
Reserved_30_31 at 0 range 30 .. 31;
end record;
-- Integration Mode Control
type TPI_ITCTRL_Register is record
Mode : Boolean := False;
-- unspecified
Reserved_1_31 : HAL.UInt31 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TPI_ITCTRL_Register use record
Mode at 0 range 0 .. 0;
Reserved_1_31 at 0 range 1 .. 31;
end record;
subtype TPI_DEVID_MinBufSz_Field is HAL.UInt3;
-- TPIU_DEVID
type TPI_DEVID_Register is record
-- Read-only.
NrTraceInput : Boolean;
-- unspecified
Reserved_1_4 : HAL.UInt4;
-- Read-only.
AsynClkIn : Boolean;
-- Read-only.
MinBufSz : TPI_DEVID_MinBufSz_Field;
-- Read-only.
PTINVALID : Boolean;
-- Read-only.
MANCVALID : Boolean;
-- Read-only.
NRZVALID : Boolean;
-- unspecified
Reserved_12_31 : HAL.UInt20;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TPI_DEVID_Register use record
NrTraceInput at 0 range 0 .. 0;
Reserved_1_4 at 0 range 1 .. 4;
AsynClkIn at 0 range 5 .. 5;
MinBufSz at 0 range 6 .. 8;
PTINVALID at 0 range 9 .. 9;
MANCVALID at 0 range 10 .. 10;
NRZVALID at 0 range 11 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype TPI_DEVTYPE_SubType_Field is HAL.UInt4;
subtype TPI_DEVTYPE_MajorType_Field is HAL.UInt4;
-- TPIU_DEVTYPE
type TPI_DEVTYPE_Register is record
-- Read-only.
SubType_k : TPI_DEVTYPE_SubType_Field;
-- Read-only.
MajorType : TPI_DEVTYPE_MajorType_Field;
-- unspecified
Reserved_8_31 : HAL.UInt24;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for TPI_DEVTYPE_Register use record
SubType_k at 0 range 0 .. 3;
MajorType at 0 range 4 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Trace Port Interface Register
type TPI_Peripheral is record
-- Supported Parallel Port Size Register
SSPSR : aliased HAL.UInt32;
-- Current Parallel Port Size Register
CSPSR : aliased HAL.UInt32;
-- Asynchronous Clock Prescaler Register
ACPR : aliased TPI_ACPR_Register;
-- Selected Pin Protocol Register
SPPR : aliased TPI_SPPR_Register;
-- Formatter and Flush Status Register
FFSR : aliased TPI_FFSR_Register;
-- Formatter and Flush Control Register
FFCR : aliased TPI_FFCR_Register;
-- Formatter Synchronization Counter Register
FSCR : aliased HAL.UInt32;
-- TRIGGER
TRIGGER : aliased TPI_TRIGGER_Register;
-- Integration ETM Data
FIFO0 : aliased TPI_FIFO0_Register;
-- ITATBCTR2
ITATBCTR2 : aliased ITATBCTR_Register;
-- ITATBCTR0
ITATBCTR0 : aliased ITATBCTR_Register;
-- Integration ITM Data
FIFO1 : aliased TPI_FIFO1_Register;
-- Integration Mode Control
ITCTRL : aliased TPI_ITCTRL_Register;
-- Claim tag set
CLAIMSET : aliased HAL.UInt32;
-- Claim tag clear
CLAIMCLR : aliased HAL.UInt32;
-- TPIU_DEVID
DEVID : aliased TPI_DEVID_Register;
-- TPIU_DEVTYPE
DEVTYPE : aliased TPI_DEVTYPE_Register;
end record
with Volatile;
for TPI_Peripheral use record
SSPSR at 16#0# range 0 .. 31;
CSPSR at 16#4# range 0 .. 31;
ACPR at 16#10# range 0 .. 31;
SPPR at 16#F0# range 0 .. 31;
FFSR at 16#300# range 0 .. 31;
FFCR at 16#304# range 0 .. 31;
FSCR at 16#308# range 0 .. 31;
TRIGGER at 16#EE8# range 0 .. 31;
FIFO0 at 16#EEC# range 0 .. 31;
ITATBCTR2 at 16#EF0# range 0 .. 31;
ITATBCTR0 at 16#EF8# range 0 .. 31;
FIFO1 at 16#EFC# range 0 .. 31;
ITCTRL at 16#F00# range 0 .. 31;
CLAIMSET at 16#FA0# range 0 .. 31;
CLAIMCLR at 16#FA4# range 0 .. 31;
DEVID at 16#FC8# range 0 .. 31;
DEVTYPE at 16#FCC# range 0 .. 31;
end record;
-- Trace Port Interface Register
TPI_Periph : aliased TPI_Peripheral
with Import, Address => TPI_Base;
end SAM_SVD.TPI;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- E X P A N D E R --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2006, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Atree; use Atree;
with Debug_A; use Debug_A;
with Errout; use Errout;
with Exp_Aggr; use Exp_Aggr;
with Exp_Attr; use Exp_Attr;
with Exp_Ch2; use Exp_Ch2;
with Exp_Ch3; use Exp_Ch3;
with Exp_Ch4; use Exp_Ch4;
with Exp_Ch5; use Exp_Ch5;
with Exp_Ch6; use Exp_Ch6;
with Exp_Ch7; use Exp_Ch7;
with Exp_Ch8; use Exp_Ch8;
with Exp_Ch9; use Exp_Ch9;
with Exp_Ch11; use Exp_Ch11;
with Exp_Ch12; use Exp_Ch12;
with Exp_Ch13; use Exp_Ch13;
with Exp_Prag; use Exp_Prag;
with Opt; use Opt;
with Rtsfind; use Rtsfind;
with Sem; use Sem;
with Sem_Ch8; use Sem_Ch8;
with Sem_Util; use Sem_Util;
with Sinfo; use Sinfo;
with Table;
package body Expander is
----------------
-- Local Data --
----------------
-- The following table is used to save values of the Expander_Active
-- flag when they are saved by Expander_Mode_Save_And_Set. We use an
-- extendible table (which is a bit of overkill) because it is easier
-- than figuring out a maximum value or bothering with range checks!
package Expander_Flags is new Table.Table (
Table_Component_Type => Boolean,
Table_Index_Type => Int,
Table_Low_Bound => 0,
Table_Initial => 32,
Table_Increment => 200,
Table_Name => "Expander_Flags");
------------
-- Expand --
------------
procedure Expand (N : Node_Id) is
begin
-- If we were analyzing a default expression the Full_Analysis flag
-- must be off. If we are in expansion mode then we must be
-- performing a full analysis. If we are analyzing a generic then
-- Expansion must be off.
pragma Assert
(not (Full_Analysis and then In_Default_Expression)
and then (Full_Analysis or else not Expander_Active)
and then not (Inside_A_Generic and then Expander_Active));
-- There are three reasons for the Expander_Active flag to be false.
--
-- The first is when are not generating code. In this mode the
-- Full_Analysis flag indicates whether we are performing a complete
-- analysis, in which case Full_Analysis = True or a pre-analysis in
-- which case Full_Analysis = False. See the spec of Sem for more
-- info on this.
--
-- The second reason for the Expander_Active flag to be False is that
-- we are performing a pre-analysis. During pre-analysis all
-- expansion activity is turned off to make sure nodes are
-- semantically decorated but no extra nodes are generated. This is
-- for instance needed for the first pass of aggregate semantic
-- processing. Note that in this case the Full_Analysis flag is set
-- to False because the node will subsequently be re-analyzed with
-- expansion on (see the spec of sem).
-- Finally, expansion is turned off in a regular compilation if there
-- are serious errors. In that case there will be no further expansion,
-- but one cleanup action may be required: if a transient scope was
-- created (e.g. for a function that returns an unconstrained type)
-- the scope may still be on the stack, and must be removed explicitly,
-- given that the expansion actions that would normally process it will
-- not take place. This prevents cascaded errors due to stack mismatch.
if not Expander_Active then
Set_Analyzed (N, Full_Analysis);
if Serious_Errors_Detected > 0
and then Scope_Is_Transient
then
Scope_Stack.Table
(Scope_Stack.Last).Actions_To_Be_Wrapped_Before := No_List;
Scope_Stack.Table
(Scope_Stack.Last).Actions_To_Be_Wrapped_After := No_List;
Pop_Scope;
end if;
return;
else
Debug_A_Entry ("expanding ", N);
-- Processing depends on node kind. For full details on the expansion
-- activity required in each case, see bodies of corresponding
-- expand routines
begin
case Nkind (N) is
when N_Abort_Statement =>
Expand_N_Abort_Statement (N);
when N_Accept_Statement =>
Expand_N_Accept_Statement (N);
when N_Aggregate =>
Expand_N_Aggregate (N);
when N_Allocator =>
Expand_N_Allocator (N);
when N_And_Then =>
Expand_N_And_Then (N);
when N_Assignment_Statement =>
Expand_N_Assignment_Statement (N);
when N_Asynchronous_Select =>
Expand_N_Asynchronous_Select (N);
when N_Attribute_Definition_Clause =>
Expand_N_Attribute_Definition_Clause (N);
when N_Attribute_Reference =>
Expand_N_Attribute_Reference (N);
when N_Block_Statement =>
Expand_N_Block_Statement (N);
when N_Case_Statement =>
Expand_N_Case_Statement (N);
when N_Conditional_Entry_Call =>
Expand_N_Conditional_Entry_Call (N);
when N_Conditional_Expression =>
Expand_N_Conditional_Expression (N);
when N_Delay_Relative_Statement =>
Expand_N_Delay_Relative_Statement (N);
when N_Delay_Until_Statement =>
Expand_N_Delay_Until_Statement (N);
when N_Entry_Body =>
Expand_N_Entry_Body (N);
when N_Entry_Call_Statement =>
Expand_N_Entry_Call_Statement (N);
when N_Entry_Declaration =>
Expand_N_Entry_Declaration (N);
when N_Exception_Declaration =>
Expand_N_Exception_Declaration (N);
when N_Exception_Renaming_Declaration =>
Expand_N_Exception_Renaming_Declaration (N);
when N_Exit_Statement =>
Expand_N_Exit_Statement (N);
when N_Expanded_Name =>
Expand_N_Expanded_Name (N);
when N_Explicit_Dereference =>
Expand_N_Explicit_Dereference (N);
when N_Extension_Aggregate =>
Expand_N_Extension_Aggregate (N);
when N_Freeze_Entity =>
Expand_N_Freeze_Entity (N);
when N_Full_Type_Declaration =>
Expand_N_Full_Type_Declaration (N);
when N_Function_Call =>
Expand_N_Function_Call (N);
when N_Generic_Instantiation =>
Expand_N_Generic_Instantiation (N);
when N_Goto_Statement =>
Expand_N_Goto_Statement (N);
when N_Handled_Sequence_Of_Statements =>
Expand_N_Handled_Sequence_Of_Statements (N);
when N_Identifier =>
Expand_N_Identifier (N);
when N_Indexed_Component =>
Expand_N_Indexed_Component (N);
when N_If_Statement =>
Expand_N_If_Statement (N);
when N_In =>
Expand_N_In (N);
when N_Loop_Statement =>
Expand_N_Loop_Statement (N);
when N_Not_In =>
Expand_N_Not_In (N);
when N_Null =>
Expand_N_Null (N);
when N_Object_Declaration =>
Expand_N_Object_Declaration (N);
when N_Object_Renaming_Declaration =>
Expand_N_Object_Renaming_Declaration (N);
when N_Op_Add =>
Expand_N_Op_Add (N);
when N_Op_Abs =>
Expand_N_Op_Abs (N);
when N_Op_And =>
Expand_N_Op_And (N);
when N_Op_Concat =>
Expand_N_Op_Concat (N);
when N_Op_Divide =>
Expand_N_Op_Divide (N);
when N_Op_Eq =>
Expand_N_Op_Eq (N);
when N_Op_Expon =>
Expand_N_Op_Expon (N);
when N_Op_Ge =>
Expand_N_Op_Ge (N);
when N_Op_Gt =>
Expand_N_Op_Gt (N);
when N_Op_Le =>
Expand_N_Op_Le (N);
when N_Op_Lt =>
Expand_N_Op_Lt (N);
when N_Op_Minus =>
Expand_N_Op_Minus (N);
when N_Op_Mod =>
Expand_N_Op_Mod (N);
when N_Op_Multiply =>
Expand_N_Op_Multiply (N);
when N_Op_Ne =>
Expand_N_Op_Ne (N);
when N_Op_Not =>
Expand_N_Op_Not (N);
when N_Op_Or =>
Expand_N_Op_Or (N);
when N_Op_Plus =>
Expand_N_Op_Plus (N);
when N_Op_Rem =>
Expand_N_Op_Rem (N);
when N_Op_Rotate_Left =>
Expand_N_Op_Rotate_Left (N);
when N_Op_Rotate_Right =>
Expand_N_Op_Rotate_Right (N);
when N_Op_Shift_Left =>
Expand_N_Op_Shift_Left (N);
when N_Op_Shift_Right =>
Expand_N_Op_Shift_Right (N);
when N_Op_Shift_Right_Arithmetic =>
Expand_N_Op_Shift_Right_Arithmetic (N);
when N_Op_Subtract =>
Expand_N_Op_Subtract (N);
when N_Op_Xor =>
Expand_N_Op_Xor (N);
when N_Or_Else =>
Expand_N_Or_Else (N);
when N_Package_Body =>
Expand_N_Package_Body (N);
when N_Package_Declaration =>
Expand_N_Package_Declaration (N);
when N_Package_Renaming_Declaration =>
Expand_N_Package_Renaming_Declaration (N);
when N_Pragma =>
Expand_N_Pragma (N);
when N_Procedure_Call_Statement =>
Expand_N_Procedure_Call_Statement (N);
when N_Protected_Type_Declaration =>
Expand_N_Protected_Type_Declaration (N);
when N_Protected_Body =>
Expand_N_Protected_Body (N);
when N_Qualified_Expression =>
Expand_N_Qualified_Expression (N);
when N_Raise_Statement =>
Expand_N_Raise_Statement (N);
when N_Raise_Constraint_Error =>
Expand_N_Raise_Constraint_Error (N);
when N_Raise_Program_Error =>
Expand_N_Raise_Program_Error (N);
when N_Raise_Storage_Error =>
Expand_N_Raise_Storage_Error (N);
when N_Real_Literal =>
Expand_N_Real_Literal (N);
when N_Record_Representation_Clause =>
Expand_N_Record_Representation_Clause (N);
when N_Requeue_Statement =>
Expand_N_Requeue_Statement (N);
when N_Return_Statement =>
Expand_N_Return_Statement (N);
when N_Selected_Component =>
Expand_N_Selected_Component (N);
when N_Selective_Accept =>
Expand_N_Selective_Accept (N);
when N_Single_Task_Declaration =>
Expand_N_Single_Task_Declaration (N);
when N_Slice =>
Expand_N_Slice (N);
when N_Subtype_Indication =>
Expand_N_Subtype_Indication (N);
when N_Subprogram_Body =>
Expand_N_Subprogram_Body (N);
when N_Subprogram_Body_Stub =>
Expand_N_Subprogram_Body_Stub (N);
when N_Subprogram_Declaration =>
Expand_N_Subprogram_Declaration (N);
when N_Subprogram_Info =>
Expand_N_Subprogram_Info (N);
when N_Task_Body =>
Expand_N_Task_Body (N);
when N_Task_Type_Declaration =>
Expand_N_Task_Type_Declaration (N);
when N_Timed_Entry_Call =>
Expand_N_Timed_Entry_Call (N);
when N_Type_Conversion =>
Expand_N_Type_Conversion (N);
when N_Unchecked_Expression =>
Expand_N_Unchecked_Expression (N);
when N_Unchecked_Type_Conversion =>
Expand_N_Unchecked_Type_Conversion (N);
when N_Variant_Part =>
Expand_N_Variant_Part (N);
-- For all other node kinds, no expansion activity is required
when others => null;
end case;
exception
when RE_Not_Available =>
return;
end;
-- Set result as analyzed and then do a possible transient wrap. The
-- transient wrap must be done after the Analyzed flag is set on, so
-- that we do not get a recursive attempt to expand the node N.
Set_Analyzed (N);
-- Deal with transient scopes
if Scope_Is_Transient and then N = Node_To_Be_Wrapped then
case Nkind (N) is
when N_Statement_Other_Than_Procedure_Call |
N_Procedure_Call_Statement =>
Wrap_Transient_Statement (N);
when N_Object_Declaration |
N_Object_Renaming_Declaration |
N_Subtype_Declaration =>
Wrap_Transient_Declaration (N);
when others => Wrap_Transient_Expression (N);
end case;
end if;
Debug_A_Exit ("expanding ", N, " (done)");
end if;
end Expand;
---------------------------
-- Expander_Mode_Restore --
---------------------------
procedure Expander_Mode_Restore is
begin
-- Not active (has no effect) in ASIS mode (see comments in spec of
-- Expander_Mode_Save_And_Set).
if ASIS_Mode then
return;
end if;
-- Otherwise restore the flag
Expander_Active := Expander_Flags.Table (Expander_Flags.Last);
Expander_Flags.Decrement_Last;
-- Keep expander off if serious errors detected. In this case we do
-- not need expansion, and continued expansion may cause cascaded
-- errors or compiler bombs.
if Serious_Errors_Detected /= 0 then
Expander_Active := False;
end if;
end Expander_Mode_Restore;
--------------------------------
-- Expander_Mode_Save_And_Set --
--------------------------------
procedure Expander_Mode_Save_And_Set (Status : Boolean) is
begin
-- Not active (has no effect) in ASIS mode (see comments in spec of
-- Expander_Mode_Save_And_Set).
if ASIS_Mode then
return;
end if;
-- Otherwise save and set the flag
Expander_Flags.Increment_Last;
Expander_Flags.Table (Expander_Flags.Last) := Expander_Active;
Expander_Active := Status;
end Expander_Mode_Save_And_Set;
end Expander;
|
with trafficlightswitcher;
with HWIF; use HWIF;
with HWIF_Types; use HWIF_Types;
procedure EmergencyVehicleOverride (dir : in Direction) is
begin
for DirectionElement in Direction'Range loop --Itterate through Directions
if Traffic_Light(DirectionElement) /= Traffic_Light(dir) and
Traffic_Light(DirectionElement) = 4
then --amber guarding needed?
TrafficLightSwitcher(dir);
end if;
end loop;
delay 1.0; -- Change this delay
end;
|
with Ada.Text_IO;
with System.Storage_Elements;
with GC.Pools;
procedure try_gc is
type Integer_Access is access Integer;
for Integer_Access'Storage_Pool use GC.Pools.Pool;
begin
loop
for I in 1 .. 1000 loop
declare
Gomi : constant Integer_Access := new Integer'(100);
begin
Gomi.all := 200;
end;
end loop;
Ada.Text_IO.Put_Line (
System.Storage_Elements.Storage_Count'Image (GC.Heap_Size));
end loop;
end try_gc;
|
with Arduino_Nano_33_Ble_Sense.IOs;
with Ada.Real_Time; use Ada.Real_Time;
procedure Main is
Time_Now : Ada.Real_Time.Time := Ada.Real_Time.Clock;
Rotate_Time : Ada.Real_Time.Time := Ada.Real_Time.Clock;
Pin_Id_PWM : Arduino_Nano_33_Ble_Sense.IOs.Pin_Id := 30;
High_Time : Integer := 2_000;
begin
loop
if Ada.Real_Time.Clock > Rotate_Time + Ada.Real_Time.Milliseconds(150) then
--Changes between 1000 and 2000 in 100 increments
High_Time := (High_Time + 100) mod 2000;
if High_Time < 1000 then
High_Time := High_Time + 1000;
end if;
Rotate_Time := Ada.Real_Time.Clock;
end if;
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(Pin_Id_PWM,True);
Time_Now := Ada.Real_Time.Clock;
delay until Time_Now + Ada.Real_Time.Microseconds(High_Time);
Arduino_Nano_33_Ble_Sense.IOs.DigitalWrite(Pin_Id_PWM,False);
Time_Now := Ada.Real_Time.Clock;
delay until Time_Now + Ada.Real_Time.Microseconds(20_000 - High_Time);
end loop;
end Main;
|
with Utilities.Hybrid_Files;
with Utilities.Option_Lists;
use Utilities;
use Utilities.Option_Lists;
--****P* Data_Streams/Text
-- DESCRIPTION
-- This package provides a concrete implementation of interfaces
-- Data_Source and Data_Destination that do I/O in text format. Although
-- not very efficient on the space occupation side, it is convenient
-- for backup etc.
--
-- OPTIONS
-- It accepts option "fmt" that if equal to "float" force I/O in
-- floating point format, otherwise signed 16 bit integers are used.
--
-- For example,
--
-- |html <center><code>-::fmt=float</code></center>
--
-- do I/O with floating point numbers to standard input/standard output
--***
package Fakedsp.Data_Streams.Text is
type Text_Source is limited new Data_Source with private;
type Text_Source_Access is access Text_Source;
Standard_IO_Name : constant String;
function Open_Source (Filename : String := Standard_IO_Name;
Options : Option_List := Empty_List)
return Text_Source_Access;
procedure Read (Src : in out Text_Source;
Sample : out Sample_Type;
End_Of_Stream : out Boolean;
Channel : Channel_Index := Channel_Index'First);
procedure Read (Src : in out Text_Source;
Sample : out Float;
End_Of_Stream : out Boolean;
Channel : Channel_Index := Channel_Index'First);
function Sampling_Frequency (Src : Text_Source)
return Frequency_Hz;
function Max_Channel (Src : Text_Source)
return Channel_Index;
procedure Close (Src : in out Text_Source);
function Standard_Input (Options : Option_List := Empty_List)
return Text_Source_Access;
type Text_Destination is limited new Data_Destination with private;
type Text_Destination_Access is access Text_Destination;
function Open_Destination (Filename : String := Standard_IO_Name;
Sampling : Frequency_Hz := 8000.0;
Last_Channel : Channel_Index := 1;
Options : Option_List := Empty_List)
return Text_Destination_Access;
function Standard_Output (Options : Option_List := Empty_List)
return Text_Destination_Access;
procedure Write (Dst : Text_Destination;
Sample : Sample_Type;
Channel : Channel_Index := Channel_Index'First);
procedure Write (Dst : Text_Destination;
Sample : Float;
Channel : Channel_Index := Channel_Index'First);
procedure Close (Dst : in out Text_Destination);
function Max_Channel (Src : Text_Destination) return Channel_Index;
Bad_Format : exception;
Unimplemented_Format : exception;
private
use Utilities.Hybrid_Files;
Standard_IO_Name : constant String (1 .. 1) := (1 => ASCII.NUL);
type Data_Format is (Float_Format, Sample_Format);
type Text_Source is limited new Data_Source
with
record
File : Hybrid_File;
Top_Channel : Channel_Index;
Frequency : Frequency_Hz;
Current_Sample : Float;
Empty : Boolean;
Format : Data_Format;
end record;
function Sampling_Frequency (Src : Text_Source) return Frequency_Hz
is (Src.Frequency);
function Max_Channel (Src : Text_Source) return Channel_Index
is (Src.Top_Channel);
function Standard_Input (Options : Option_List := Empty_List)
return Text_Source_Access
is (Open_Source (Standard_IO_Name, Options));
type Text_Destination is limited new Data_Destination with
record
File : Hybrid_File;
Top_Channel : Channel_Index;
Frequency : Frequency_Hz;
Format : Data_Format;
end record;
function Max_Channel (Src : Text_Destination) return Channel_Index
is (Src.Top_Channel);
function Standard_Output (Options : Option_List := Empty_List)
return Text_Destination_Access
is (Open_Destination (Filename => Standard_IO_Name,
Sampling => 8000.0,
Last_Channel => 1,
Options => Options));
end Fakedsp.Data_Streams.Text;
|
with Ada.Finalization;
use Ada;
--
-- This package provides functions that implement "discrete time finite
-- memory filters" in a general setup.
--
-- According to the model used in this package, the filter processes
-- samples of type Sample_Type and it is parameterized by coefficients
-- of type Coefficient_Type. The only operations required are the
-- product between a coefficient and a sample and the sum/difference of
-- two samples.
--
-- (For the more mathematically oriented, one can think samples as the
-- element of an Abelian group and the coefficients as elements of a group
-- acting on the samples)
--
-- Usually coefficients and sample will have the same type (e.g., complex or
-- real), but this solution is more flexible and has no special drawbacks.
--
generic
type Sample_Type is private; -- Type of samples
type Coefficient_Type is private; -- Type of coefficients
One : Sample_Type;
Zero : Sample_Type;
Zero_Coeff : Coefficient_Type;
with function "+" (X, Y : Sample_Type) return Sample_Type is <>;
with function "-" (X, Y : Sample_Type) return Sample_Type is <>;
with function "*" (X : Coefficient_Type; Y : Sample_Type) return Sample_Type is <>;
package Dsp.Ring_Filters is
type Coefficient_Array is array (Natural range<>) of Coefficient_Type;
type Sample_Array is array (Integer range<>) of Sample_Type;
type Signal is access function (N : Integer) return Sample_Type;
-- A signal is a function mapping Integers into samples
function Delta_Signal (K : Integer) return Sample_Type
is ((if K = 0 then One else Zero));
-- Special function very commonly used in DSP...
function Apply (F : Signal; From, To : Integer) return Sample_Array
with
Pre => To >= From,
Post => Apply'Result'First = From and Apply'Result'Last = To;
-- Return an array containing the values F(n) with From <= n <= To
type Ring_Filter_Interface is limited interface;
-- It is convenient to introduce an interface that specifies what the
-- generic filter can do. In this way we can write procedures that
-- expect generic filters.
type Filter_Status is (Unready, Ready, Running);
-- A filter can be in three different states:
--
-- * Unready: if the filter is not ready yet to process data.
-- a typical case is when the filter has been created, but the
-- impulse response has not been specified yet.
-- * Ready: The filter is in its initial state and it can start
-- processing data.
-- * Running: The filter has already processed at least one sample
function Status (Item : Ring_Filter_Interface)
return Filter_Status
is abstract ;
-- Return the current filter status
procedure Reset (Item : in out Ring_Filter_Interface)
is abstract
with Pre'Class => Item.Status /= Unready,
Post'Class => Item.Status = Ready;
-- Clean the internal state of the filter and bring it back to Ready
function Filter (Item : in out Ring_Filter_Interface;
Input : Sample_Type)
return Sample_Type
is abstract
with Pre'Class => Item.Status /= Unready,
Post'Class => Item.Status = Running;
-- Process a single sample
function Filter (Item : in out Ring_Filter_Interface'Class;
Input : Sample_Array;
Keep_Status : Boolean := False)
return Sample_Array
with
Pre =>
Item.Status /= Unready,
Post =>
Filter'Result'First = Input'First
and Filter'Result'Last = Input'Last;
-- Process an array of samples. If keep_status is False, Reset is called
-- before the processing.
type Ring_FIR is
new Finalization.Limited_Controlled
and Ring_Filter_Interface
with private;
-- type representing a FIR filter
overriding procedure Reset (Item : in out Ring_FIR);
overriding function Status (Item : Ring_Fir) return Filter_Status;
overriding function Filter (Item : in out Ring_FIR;
Input : Sample_Type)
return Sample_Type;
procedure Set (Filter : in out Ring_FIR;
Impulse_Response : Coefficient_Array)
with
Pre => Filter.Status = Unready,
Post => Filter.Status = Ready;
-- Specify the impulse response of the filter.
type Ring_IIR is
new Ada.Finalization.Limited_Controlled
and Ring_Filter_Interface
with private;
-- Specialization of Ring_Filter_Interface representing an IIR filter
overriding function Status (Item : Ring_IIR) return Filter_Status;
overriding procedure Reset (Item : in out Ring_IIR);
overriding function Filter (Item : in out Ring_IIR;
Input : Sample_Type)
return Sample_Type;
type Ring_IIR_Spec (Num_Deg, Den_Deg : Natural) is
record
Numerator : Coefficient_Array (0 .. Num_Deg);
Denominator : Coefficient_Array (1 .. Den_Deg);
end record;
-- Parametrization of an IIR filter.
--
-- *PLEASE NOTE*: we use the Matlab convention, that is, we give
-- the coefficients of numerator and denominator of the transfer function
-- This means that the values in denominator are the coefficients of
-- the autoregressive equations *with changed sign*. The
-- coefficient of z^0 at the denominator is not specified
-- since it is supposed to be 1).
procedure Set (Filter : in out Ring_IIR;
Specs : Ring_IIR_Spec)
with
Pre => Filter.Status = Unready,
Post => Filter.Status = Ready;
-- Set the transfer function of the IIR filter
procedure Set (Filter : in out Ring_IIR;
Numerator : Coefficient_Array;
Denominator : Coefficient_Array)
with
Pre =>
Filter.Status = Unready
and Numerator'First >= 0
and Denominator'First >= 0,
Post =>
Filter.Status = Ready;
-- Set the transfer function of the IIR filter
private
type Coefficient_Array_Access is access Coefficient_Array;
type Sample_Array_Access is access Sample_Array;
type Ring_FIR is
new Ada.Finalization.Limited_Controlled
and Ring_Filter_Interface
with
record
Current_Status : Filter_Status := Unready;
Spec : Coefficient_Array_Access := null;
Buffer : Sample_Array_Access := null;
end record
with Type_Invariant =>
((Spec = null) = (Buffer = null))
and then
(Spec = null
or else
(Spec.all'First = 0
and Buffer.all'First = 1
and Buffer.all'Last = Spec.all'Last));
overriding procedure Finalize (Object : in out Ring_FIR);
function Status (Item : Ring_Fir) return Filter_Status
is (Item.Current_Status);
type Ring_IIR is
new Ada.Finalization.Limited_Controlled
and Ring_Filter_Interface
with
record
Current_Status : Filter_Status := Unready;
Num : Coefficient_Array_Access := null;
Den : Coefficient_Array_Access := null;
Buffer : Sample_Array_Access := null;
end record
with Type_Invariant =>
((Num = null) = (Den = null) and (Num = null) = (Buffer = null))
and then
(Num = null
or else
(Num.all'First = 0
and Den.all'First = 1
and Buffer.all'First = 1
and Buffer.all'Last = Num.all'Last
and Buffer.all'Last = Den.all'Last));
overriding procedure Finalize (Object : in out Ring_IIR);
function Status (Item : Ring_IIR) return Filter_Status
is (Item.Current_Status);
end Dsp.Ring_Filters;
|
pragma Warnings (Off);
pragma Style_Checks (Off);
package body GLOBE_3D.Culler is
procedure Viewer_is (Self : in out Culler'Class; Now : p_Window)
is
begin
self.Viewer := Now.all'Access;
end;
function Viewer (Self : in Culler'Class) return p_Window
is
begin
return self.Viewer;
end;
end globe_3d.Culler;
|
with Ada.Finalization; use Ada.Finalization;
package Controlled5_Pkg is
type Root is tagged private;
type Inner is new Ada.Finalization.Controlled with null record;
type T_Root_Class is access all Root'Class;
function Dummy (I : Integer) return Root'Class;
private
type Root is tagged record
F2 : Inner;
end record;
end Controlled5_Pkg;
|
with Ada.Containers.Vectors;
with Ada.Numerics.Discrete_Random;
with Ada.Text_IO;
with Ada.Integer_Text_IO;
use Ada.Text_IO;
use Ada.Integer_Text_IO;
procedure Insertion_Sort is
------------------------------
-- Constant, types, package --
------------------------------
ARRAY_SIZE : constant Natural := 10;
RANGE_MIN : constant Integer := 1;
RANGE_MAX : constant Integer := 100;
package P_Vectors is new Ada.Containers.Vectors (Positive, Integer);
use P_Vectors;
-----------------------
-- Method prototype --
-----------------------
-- Initializing an array with default values
function Init_Vector return Vector;
procedure Put (Tab : Vector);
procedure Swap (a : in out Integer; b : in out Integer);
function Sort (T : Vector) return Vector;
-----------------------------
-- Declaration of methods --
-----------------------------
function Init_Vector return Vector
is
subtype T_Interval is Integer range RANGE_MIN .. RANGE_MAX;
package P_Random is new Ada.numerics.discrete_random (T_Interval);
use P_Random;
seed : Generator;
T : Vector;
begin
Reset (seed);
for i in 1 .. ARRAY_SIZE loop
Append (T, Random (seed));
end loop;
return T;
end Init_Vector;
procedure Put (Tab : Vector)
is
begin
for e of Tab loop
Put (e, Width => 0);
Put (";");
end loop;
end Put;
procedure Swap (a : in out Integer; b : in out Integer)
is
c : constant Integer := a;
begin
a := b;
b := c;
end Swap;
function Sort (T : Vector) return Vector is
Tab : Vector := T;
begin
for i in First_Index (T) + 1 .. Last_Index (T) loop
for j in reverse First_Index (T) + 1 .. i loop
exit when Tab (j - 1) <= Tab (j);
Swap (Tab (j - 1), Tab (j));
end loop;
end loop;
return Tab;
end Sort;
---------------
-- Variables --
---------------
T : Vector := Init_Vector;
begin
Put ("Array : ");
Put (T);
New_Line;
T := Sort (T);
Put ("Sorted array : ");
Put (T);
end Insertion_Sort;
|
-----------------------------------------------------------------------
-- util-beans-objects-time -- Helper conversion for Ada Calendar Time
-- Copyright (C) 2010, 2019 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Calendar;
with Util.Nullables;
package Util.Beans.Objects.Time is
-- Create an object from the given value.
function To_Object (Value : in Ada.Calendar.Time) return Object;
function To_Object (Value : in Nullables.Nullable_Time) return Object;
-- Convert the object into a time.
-- Raises Constraint_Error if the object cannot be converter to the target type.
function To_Time (Value : in Object) return Ada.Calendar.Time;
function To_Time (Value : in Object) return Nullables.Nullable_Time;
-- Force the object to be a time.
function Cast_Time (Value : Object) return Object;
end Util.Beans.Objects.Time;
|
float:
euclidean:
adb-async:
docker-tag: ann-benchmarks-adb-async
module: ann_benchmarks.algorithms.adb
constructor: AnalyticDBAsync
base-args: ["@dataset"]
run-groups:
base:
args: [["gp-bp19e1yl22d85gqgxo-master.gpdbmaster.rds.aliyuncs.com"], [1, 2, 3]]
query-args: [[1, 2, 3]]
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T A S K I N G . R E S T R I C T E D . S T A G E S --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
-- --
-- GNARL is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNARL; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
--
--
--
--
--
--
--
-- GNARL was developed by the GNARL team at Florida State University. --
-- Extensive contributions were provided by Ada Core Technologies, Inc. --
-- --
------------------------------------------------------------------------------
-- This is a simplified version of the System.Tasking.Stages package,
-- intended to be used in a restricted run time.
-- This package represents the high level tasking interface used by the
-- compiler to expand Ada 95 tasking constructs into simpler run time calls
-- (aka GNARLI, GNU Ada Run-time Library Interface)
-- Note: the compiler generates direct calls to this interface, via Rtsfind.
-- Any changes to this interface may require corresponding compiler changes
-- in exp_ch9.adb and possibly exp_ch7.adb
-- The restricted GNARLI is also composed of System.Protected_Objects and
-- System.Protected_Objects.Single_Entry
with System.Task_Info;
-- used for Task_Info_Type
with System.Parameters;
-- used for Size_Type
package System.Tasking.Restricted.Stages is
pragma Elaborate_Body;
---------------------------------
-- Compiler Interface (GNARLI) --
---------------------------------
-- The compiler will expand in the GNAT tree the following construct:
-- task type T (Discr : Integer);
-- task body T is
-- ...declarations, possibly some controlled...
-- begin
-- ...B...;
-- end T;
-- T1 : T (1);
-- as follows:
-- task type t (discr : integer);
-- tE : aliased boolean := false;
-- tZ : size_type := unspecified_size;
-- type tV (discr : integer) is limited record
-- _task_id : task_id;
-- _atcb : aliased system__tasking__ada_task_control_block (0);
-- end record;
-- procedure tB (_task : access tV);
-- freeze tV [
-- procedure tVIP (_init : in out tV; _master : master_id;
-- _chain : in out activation_chain; _task_name : in string;
-- discr : integer) is
-- begin
-- _init.discr := discr;
-- _init._task_id := null;
-- system__tasking__ada_task_control_blockIP (_init._atcb, 0);
-- _init._task_id := _init._atcb'unchecked_access;
-- create_restricted_task (unspecified_priority, tZ,
-- unspecified_task_info, task_procedure_access!(tB'address),
-- _init'address, tE'unchecked_access, _chain, _task_name, _init.
-- _task_id);
-- return;
-- end tVIP;
-- _chain : aliased activation_chain;
-- activation_chainIP (_chain);
-- procedure tB (_task : access tV) is
-- discr : integer renames _task.discr;
-- procedure _clean is
-- begin
-- complete_restricted_task;
-- finalize_list (F14b);
-- return;
-- end _clean;
-- begin
-- ...declarations...
-- complete_restricted_activation;
-- ...B...;
-- return;
-- at end
-- _clean;
-- end tB;
-- tE := true;
-- t1 : t (1);
-- t1S : constant String := "t1";
-- tIP (t1, 3, _chain, t1S, 1);
-- activate_restricted_tasks (_chain'unchecked_access);
procedure Create_Restricted_Task
(Priority : Integer;
Stack_Address : System.Address;
Size : System.Parameters.Size_Type;
Task_Info : System.Task_Info.Task_Info_Type;
State : Task_Procedure_Access;
Discriminants : System.Address;
Elaborated : Access_Boolean;
Chain : in out Activation_Chain;
Task_Image : String;
Created_Task : Task_Id);
-- Compiler interface only. Do not call from within the RTS.
-- This must be called to create a new task.
--
-- Priority is the task's priority (assumed to be in the
-- System.Any_Priority'Range)
--
-- Stack_Address is the start address of the stack associated to the
-- task, in case it has been preallocated by the compiler; it is equal
-- to Null_Address when the stack needs to be allocated by the
-- underlying operating system.
--
-- Size is the stack size of the task to create
--
-- Task_Info is the task info associated with the created task, or
-- Unspecified_Task_Info if none.
--
-- State is the compiler generated task's procedure body
--
-- Discriminants is a pointer to a limited record whose discriminants
-- are those of the task to create. This parameter should be passed as
-- the single argument to State.
--
-- Elaborated is a pointer to a Boolean that must be set to true on exit
-- if the task could be sucessfully elaborated.
--
-- Chain is a linked list of task that needs to be created. On exit,
-- Created_Task.Activation_Link will be Chain.T_ID, and Chain.T_ID
-- will be Created_Task (e.g the created task will be linked at the front
-- of Chain).
--
-- Task_Image is a string created by the compiler that the
-- run time can store to ease the debugging and the
-- Ada.Task_Identification facility.
--
-- Created_Task is the resulting task.
--
-- This procedure can raise Storage_Error if the task creation fails
procedure Activate_Restricted_Tasks
(Chain_Access : Activation_Chain_Access);
-- Compiler interface only. Do not call from within the RTS.
-- This must be called by the creator of a chain of one or more new tasks,
-- to activate them. The chain is a linked list that up to this point is
-- only known to the task that created them, though the individual tasks
-- are already in the All_Tasks_List.
--
-- The compiler builds the chain in LIFO order (as a stack). Another
-- version of this procedure had code to reverse the chain, so as to
-- activate the tasks in the order of declaration. This might be nice, but
-- it is not needed if priority-based scheduling is supported, since all
-- the activated tasks synchronize on the activators lock before they
-- start activating and so they should start activating in priority order.
procedure Complete_Restricted_Activation;
-- Compiler interface only. Do not call from within the RTS.
-- This should be called from the task body at the end of
-- the elaboration code for its declarative part.
-- Decrement the count of tasks to be activated by the activator and
-- wake it up so it can check to see if all tasks have been activated.
-- Except for the environment task, which should never call this procedure,
-- T.Activator should only be null iff T has completed activation.
procedure Complete_Restricted_Task;
-- Compiler interface only. Do not call from within the RTS.
-- This should be called from an implicit at-end handler
-- associated with the task body, when it completes.
-- From this point, the current task will become not callable.
-- If the current task have not completed activation, this should be done
-- now in order to wake up the activator (the environment task).
function Restricted_Terminated (T : Task_Id) return Boolean;
-- Compiler interface only. Do not call from within the RTS.
-- This is called by the compiler to implement the 'Terminated attribute.
--
-- source code:
-- T1'Terminated
--
-- code expansion:
-- restricted_terminated (t1._task_id)
procedure Finalize_Global_Tasks;
-- This is needed to support the compiler interface; it will only be called
-- by the Environment task in the binder generated file (by adafinal).
-- Instead, it will cause the Environment to block forever, since none of
-- the dependent tasks are expected to terminate
end System.Tasking.Restricted.Stages;
|
-----------------------------------------------------------------------
-- awa-jobs -- AWA Jobs
-- Copyright (C) 2012, 2015, 2018, 2020 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
-- = Jobs Module =
-- The `jobs` module defines a batch job framework for modules to perform
-- and execute long running and deferred actions. The `jobs` module is
-- intended to help web application designers in implementing end to end
-- asynchronous operation. A client schedules a job and does not block
-- nor wait for the immediate completion. Instead, the client asks
-- periodically or uses other mechanisms to check for the job completion.
--
-- @include awa-jobs-modules.ads
--
-- == Writing a job ==
-- A new job type is created by implementing the `Execute` operation
-- of the abstract `Job_Type` tagged record.
--
-- type Resize_Job is new AWA.Jobs.Job_Type with ...;
--
-- The `Execute` procedure must be implemented. It should use the
-- `Get_Parameter` functions to retrieve the job parameters and perform
-- the work. While the job is being executed, it can save result by using
-- the `Set_Result` operations, save messages by using the `Set_Message`
-- operations and report the progress by using `Set_Progress`.
-- It may report the job status by using `Set_Status`.
--
-- procedure Execute (Job : in out Resize_Job) is
-- begin
-- Job.Set_Result ("done", "ok");
-- end Execute;
--
-- == Registering a job ==
-- The `jobs` module must be able to create the job instance when
-- it is going to be executed. For this, a registration package must
-- be instantiated:
--
-- package Resize_Def is new AWA.Jobs.Definition (Resize_Job);
--
-- and the job definition must be added:
--
-- AWA.Jobs.Modules.Register (Resize_Def.Create'Access);
--
-- == Scheduling a job ==
-- To schedule a job, declare an instance of the job to execute and set
-- the job specific parameters. The job parameters will be saved in the
-- database. As soon as parameters are defined, call the `Schedule`
-- procedure to schedule the job in the job queue and obtain a job identifier.
--
-- Resize : Resize_Job;
-- ...
-- Resize.Set_Parameter ("file", "image.png");
-- Resize.Set_Parameter ("width", "32");
-- Resize.Set_Parameter ("height, "32");
-- Resize.Schedule;
--
-- == Checking for job completion ==
-- After a job is scheduled, a unique identifier is allocated that allows
-- to identify it. It is possible to query the status of the job by using
-- the `Get_Job_Status` function:
--
-- Status : AWA.Jobs.Models.Job_Status_Type
-- := AWA.Jobs.Services.Get_Job_Status (Resize.Get_Identifier);
--
-- @include awa-jobs-services.ads
--
-- == Ada Beans ==
--
-- @include-bean jobs.xml
--
-- == Data Model ==
-- [images/awa_jobs_model.png]
--
package AWA.Jobs is
pragma Pure;
end AWA.Jobs;
|
package body Termbox is
function Init return Return_Value is
termbox_rv: Interfaces.C.int;
begin
termbox_rv := tb_init;
return Return_Value(termbox_rv);
end Init;
procedure Shutdown is
begin
tb_shutdown;
end Shutdown;
function Width return Integer is
begin
return Integer(tb_width);
end Width;
function Height return Integer is
begin
return Integer(tb_height);
end Height;
procedure Clear is
begin
tb_clear;
end Clear;
procedure Set_Clear_Attributes(fg: Integer; bg:Integer) is
begin
tb_set_clear_attributes(Interfaces.C.unsigned_short(fg), Interfaces.C.unsigned_short(bg));
end Set_Clear_Attributes;
procedure Present is
begin
tb_present;
end Present;
procedure Set_Cursor(cx: Integer; cy: Integer) is
begin
tb_set_cursor(Interfaces.C.int(cx), Interfaces.C.int(cy));
end Set_Cursor;
procedure Put_Cell(x: Integer; y: Integer; pcell: access Cell) is
cell2: access tb_cell := new tb_cell;
begin
cell2.ch := Interfaces.C.unsigned(Character'Pos(pcell.ch));
cell2.fg := Interfaces.C.unsigned_short(pcell.fg);
cell2.bg := Interfaces.C.unsigned_short(pcell.bg);
tb_put_cell(Interfaces.C.int(x), Interfaces.C.int(y), cell2);
end Put_Cell;
procedure Change_Cell(x: Integer; y: Integer; ch: Character; fg: Integer; bg: Integer) is
x2: Interfaces.C.int := Interfaces.C.int(x);
y2: Interfaces.C.int := Interfaces.C.int(y);
ch2: Interfaces.C.unsigned := Interfaces.C.unsigned(Character'Pos(ch));
fg2: Interfaces.C.unsigned_short := Interfaces.C.unsigned_short(fg);
bg2: Interfaces.C.unsigned_short := Interfaces.C.unsigned_short(bg);
begin
tb_change_cell(x2, y2, ch2, fg2, bg2);
end Change_Cell;
function Select_Input_Mode(mode: Integer) return Return_Value is
rv: Interfaces.C.int;
begin
rv := tb_select_input_mode(Interfaces.C.int(mode));
return Return_Value(rv);
end Select_Input_Mode;
function Select_Output_Mode(mode: Integer) return Return_Value is
rv: Interfaces.C.int;
begin
rv := tb_select_output_mode(Interfaces.C.int(mode));
return Return_Value(rv);
end Select_Output_Mode;
function Peek_Event(Evt: access Event; timeout: Interfaces.C.int) return Return_Value is
termbox_event : access tb_event := new tb_event;
termbox_rv : Interfaces.C.int;
begin
termbox_rv := tb_peek_event(termbox_event, timeout);
Evt.c_type := Integer(termbox_event.c_type);
Evt.c_mod := Integer(termbox_event.c_mod);
Evt.key := Integer(termbox_event.key);
Evt.ch := Integer(termbox_event.ch);
Evt.w := Integer(termbox_event.w);
Evt.h := Integer(termbox_event.h);
Evt.x := Integer(termbox_event.x);
Evt.y := Integer(termbox_event.y);
return Return_Value(termbox_rv);
end Peek_Event;
function Poll_Event(Evt: access Event) return Return_Value is
termbox_event : access tb_event := new tb_event;
termbox_rv : Interfaces.C.int;
begin
termbox_rv := tb_poll_event(termbox_event);
Evt.c_type := Integer(termbox_event.c_type);
Evt.c_mod := Integer(termbox_event.c_mod);
Evt.key := Integer(termbox_event.key);
Evt.ch := Integer(termbox_event.ch);
Evt.w := Integer(termbox_event.w);
Evt.h := Integer(termbox_event.h);
Evt.x := Integer(termbox_event.x);
Evt.y := Integer(termbox_event.y);
return Return_Value(termbox_rv);
end Poll_Event;
end Termbox;
|
-- Copyright (c) 2017 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
------------------------------------------------------------------------------
-- WebDriver is a remote control interface that enables introspection and
-- control of user agents.
--
-- See more details on https://www.w3.org/TR/webdriver/
package WebDriver is
pragma Pure;
type Location_Strategy is
(CSS_Selector,
Link_Text,
Partial_Link_Text,
Tag_Name,
XPath);
-- An element location strategy is an enumerated attribute deciding what
-- technique should be used to search for elements in the current browsing
-- context.
end WebDriver;
|
with Ada.Unchecked_Deallocation;
package body pilas is
type Component is record
Cim : Tipus_Element;
Resta : Pila;
end record;
procedure Allibera_Memoria is
new Ada.Unchecked_Deallocation
(Object => Component,
Name => Pila);
procedure Pila_Buida
(P : out Pila) is
begin
P := null;
end Pila_Buida;
function Es_Buida
(P : Pila) return Boolean is
begin
return P = null;
end Es_Buida;
procedure Cim
(P : in Pila;
Element : out Tipus_Element) is
begin
pragma Assert
(P /= null, "Intent d'accedir a cim de pila buida");
Element := P.all.Cim;
end Cim;
procedure Empilar
(P : in out Pila;
Element : in Tipus_Element) is
begin
P := new Component'(Cim => Element, Resta => P);
exception
when Storage_Error => raise Memoria_Agotada;
end Empilar;
procedure Desempilar
(P : in out Pila) is
Antic : Pila;
begin
pragma Assert
(P /= null, "Intent de desempilar una pila buida");
Antic := P;
P := P.all.Resta;
Allibera_Memoria(Antic);
end Desempilar;
procedure Destruir
(P : in out Pila) is
Antic : Pila;
begin
while P /= null loop
Antic := P;
P := P.all.Resta;
Allibera_Memoria(Antic);
end loop;
end Destruir;
end pilas;
|
with GMP.Root_F;
generic
Precision : in GMP.Precision := Default_Precision;
package GMP.Generic_F is
pragma Preelaborate;
type MP_Float is new Root_F.MP_Float (Precision);
-- conversions
function To_MP_Float (X : Long_Float) return MP_Float;
-- function To_Long_Float (X : MP_Float) return Long_Float;
-- this function is inherited
pragma Inline (To_MP_Float);
-- formatting
-- function Image (Value : MP_Float; Base : Number_Base := 10) return String;
-- this function is inherited
function Value (Image : String; Base : Number_Base := 10) return MP_Float;
pragma Inline (Value);
-- relational operators are inherited
-- unary adding operators
function "+" (Right : MP_Float) return MP_Float;
function "-" (Right : MP_Float) return MP_Float;
pragma Inline ("+");
pragma Inline ("-");
-- binary adding operators
function "+" (Left, Right : MP_Float) return MP_Float;
function "-" (Left, Right : MP_Float) return MP_Float;
pragma Inline ("+");
pragma Inline ("-");
-- multiplying operators
function "*" (Left, Right : MP_Float) return MP_Float;
function "/" (Left, Right : MP_Float) return MP_Float;
pragma Inline ("*");
pragma Inline ("/");
-- highest precedence operators
function "**" (Left : MP_Float; Right : Integer) return MP_Float;
pragma Inline ("**");
end GMP.Generic_F;
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Strings.Maps.Constants;
-- NIGET TOM PEIP2-B2
-- IMPORTANT !
-- Si vous utilisez GNAT ou une vieille version d'Ada pas aux normes,
-- décommentez la ligne ci-dessous et commentez celle juste après
--with Ada.Strings.Unbounded_Text_IO; use Ada.Strings.Unbounded_Text_IO;
with Ada.Text_IO.Unbounded_IO; use Ada.Text_IO.Unbounded_IO;
procedure tp3_niget is
type T_Couleur_Vin is (Rouge, Blanc, Rose);
-- pour l'affichage
Couleur_Vin_Aff : array (T_Couleur_Vin) of Unbounded_String :=
(
To_Unbounded_String("rouge"),
To_Unbounded_String("blanc"),
To_Unbounded_String("rosé")
);
type T_Région is
(
Alsace, Beaujolais, Bordeaux, Bourgogne, Chablis, Champagne,
Corse, Jura, Languedoc_Roussillon, Loire, Provence, Rhone,
Savoie, Sud_Ouest
);
-- pour l'affichage
Région_Aff : array (T_Région) of Unbounded_String :=
(
To_Unbounded_String("Alsace"), To_Unbounded_String("Beaujolais"),
To_Unbounded_String("Bordeaux"), To_Unbounded_String("Bourgogne"),
To_Unbounded_String("Chablis"), To_Unbounded_String("Champagne"),
To_Unbounded_String("Corse"), To_Unbounded_String("Jura"),
To_Unbounded_String("Languedoc-Roussillon"), To_Unbounded_String("Loire"),
To_Unbounded_String("Provence"), To_Unbounded_String("Rhône"),
To_Unbounded_String("Savoie"), To_Unbounded_String("Sud-Ouest")
);
type T_Vin is
record
Nom : Unbounded_String;
Région : T_Région;
Couleur : T_Couleur_Vin;
Millésime : Integer;
Quantité : Natural;
end record;
TAILLE_CAVE : constant Positive := 40;
Cave : array (1..TAILLE_CAVE) of T_Vin;
subtype Pos_Vin is Integer range Cave'Range;
-- nombre de cases occupées de Cave
Cave_NB : Natural range 0..TAILLE_CAVE := 0;
-- pose une question fermée
function Choix(Msg : Unbounded_String) return Boolean is
Rep : Character;
begin
Put(Msg & " [O/N] ");
Get(Rep);
return Rep = 'O' or Rep = 'o';
end Choix;
-- a < b : -1
-- a = b : 0
-- a > b : 1
subtype Comparaison is Integer range -1..1;
-- compare deux chaînes sans se préoccuper de la casse
function Compare_Chaines(A, B : Unbounded_String) return Comparaison is
X : Unbounded_String := A;
Y : Unbounded_String := B;
begin
-- passage en minuscule pour mettre X et Y sur un pied d'égalité
-- pour éviter les 'z' > 'A' et autres loufoqueries des comparateurs d'Ada
Ada.Strings.Unbounded.Translate(X, Ada.Strings.Maps.Constants.Lower_Case_Map);
Ada.Strings.Unbounded.Translate(Y, Ada.Strings.Maps.Constants.Lower_Case_Map);
if X > Y then
return 1;
elsif X < Y then
return -1;
else
return 0;
end if;
end Compare_Chaines;
-- détermine l'emplacement où insérer un nouveau vin
-- par recherche dichotomique
function Indice_Correct(Q : Unbounded_String) return Pos_Vin is
-- bornes
A : Pos_Vin := 1;
B : Pos_Vin;
-- milieu de l'intervalle
Mid : Pos_Vin;
-- valeur à comparer
Val : Unbounded_String;
-- résultat de comparaison
Comp : Comparaison;
begin
-- si la cave est vide, on insère au début
if Cave_NB = 0 then
return 1;
else
B := Cave_NB;
end if;
while A < B loop
Mid := (A + B) / 2;
Val := Cave(Mid).Nom;
Comp := Compare_Chaines(Q, Val);
if Comp = 0 then
return Mid + 1; -- +1 pour ajouter à la fin d'une suite d'éléments équivalents et non au début
elsif Comp = -1 then
B := Mid;
elsif Comp = 1 then
if A = Mid then
return B + 1;
end if;
A := Mid;
end if;
end loop;
return B;
end Indice_Correct;
-- vérifie si la cave est vide, affiche une erreur le cas échéant
function Verif_Vide return Boolean is
begin
if Cave_NB = 0 then
Put_Line("*** La cave est vide ! ***");
return True;
end if;
return False;
end Verif_Vide;
-- affiche les caractéristiques d'un vin
procedure Aff_Vin(Vin : T_Vin) is
begin
Put_Line(Vin.Nom
& " - vin " & Couleur_Vin_Aff(Vin.Couleur)
& " d'origine " & Région_Aff(Vin.Région)
& ", millésime" & Integer'Image(Vin.Millésime)
& ", stock :" & Integer'Image(Vin.Quantité));
end Aff_Vin;
-- liste les vins
procedure A_Liste_Vins is
begin
if Verif_Vide then return; end if;
Put_Line("Il y a" & Integer'Image(Cave_NB) & " vins :");
for i in 1..Cave_NB loop
Put(Integer'Image(i) & "- ");
Aff_Vin(Cave(i));
end loop;
end A_Liste_Vins;
-- demande à l'utilisateur de choisir un vin
function Choisir_Vin return Pos_Vin is
N_Vin : Integer;
begin
A_Liste_Vins;
loop
Put_Line("Veuillez saisir le numéro du vin.");
Put("> ");
Get(N_Vin);
exit when N_Vin in 1..Cave_NB;
Put_Line("*** Numéro de vin incorrect ! ***");
end loop;
return N_Vin;
end Choisir_Vin;
-- insère un vin à la position spécifiée
-- pour cela, décale vers la droite celles qui sont dans le chemin
procedure Insérer_Vin(Vin : T_Vin; Pos : Pos_Vin) is
begin
for i in reverse Pos..Cave_NB loop
Cave(i + 1) := Cave(i);
end loop;
Cave(Pos) := Vin;
Cave_NB := Cave_NB + 1;
end Insérer_Vin;
-- supprime le vin à la position spécifiée
procedure A_Suppr_Vin(N : Integer := -1) is
N_Vin : Pos_Vin;
begin
if N not in Pos_Vin'Range then
N_Vin := Choisir_Vin;
else
N_Vin := N;
end if;
if not Choix(To_Unbounded_String("*** Cette action est irréversible ! Êtes-vous sûr(e) ? ***")) then
return;
end if;
Put_Line("*** Suppression de " & Cave(N_Vin).Nom & " ***");
for i in N_Vin..Cave_NB loop
Cave(i) := Cave(i + 1);
end loop;
Cave_NB := Cave_NB - 1;
end A_Suppr_Vin;
procedure A_Ajout_Bouteille(N : Integer := -1) is
N_Vin : Pos_Vin;
Quant : Positive;
begin
if Verif_Vide then return; end if;
if N not in Pos_Vin'Range then
N_Vin := Choisir_Vin;
else
N_Vin := N;
end if;
Put("Nombre de bouteilles à ajouter au stock : ");
Get(Quant);
Cave(N_Vin).Quantité := Cave(N_Vin).Quantité + Quant;
end A_Ajout_Bouteille;
-- lit et ajoute un ou plusieurs vins
procedure A_Ajout_Vin is
Vin : T_Vin;
Ent : Integer;
Existe : Boolean := False;
begin
loop
if Cave_NB = TAILLE_CAVE then
Put_Line("*** La cave est pleine ! ***");
exit;
end if;
-- efface le buffer d'entrée pour éviter de
-- relire le retour chariot précédemment entré
-- lors du choix de l'opération
Skip_Line;
Put_Line("Veuillez saisir les informations du vin.");
Put("Nom : ");
Vin.Nom := Get_Line;
Existe := False;
for i in Cave'Range loop
if Compare_Chaines(Cave(i).Nom, Vin.Nom) = 0 then
Put_Line("*** Le vin est déjà présent dans la base, entrée en mode ajout de bouteille ***");
A_Ajout_Bouteille(i);
Existe := True;
end if;
end loop;
if not Existe then
for r in T_Région'Range loop
Put_Line(Integer'Image(T_Région'Pos(r) + 1) & "- " & Région_Aff(r));
end loop;
loop
Put("Région : ");
Get(Ent);
exit when Ent in 1..(T_Région'Pos(T_Région'Last) + 1);
Put_Line("*** Numéro de région incorrect ! ***");
end loop;
Vin.Région := T_Région'Val(Ent - 1);
for r in T_Couleur_Vin'Range loop
Put_Line(Integer'Image(T_Couleur_Vin'Pos(r) + 1) & "- " & Couleur_Vin_Aff(r));
end loop;
loop
Put("Couleur : ");
Get(Ent);
exit when Ent in 1..(T_Couleur_Vin'Pos(T_Couleur_Vin'Last) + 1);
Put_Line("*** Numéro de couleur incorrect ! ***");
end loop;
Vin.Couleur := T_Couleur_Vin'Val(Ent - 1);
Put("Millésime : ");
Get(Vin.Millésime);
Put("Quantité : ");
Get(Vin.Quantité);
Insérer_Vin(Vin, Indice_Correct(Vin.Nom));
end if;
exit when not Choix(To_Unbounded_String("Voulez-vous ajouter un autre vin ?"));
end loop;
end A_Ajout_Vin;
-- lit et sort une ou plusieures bouteilles
procedure A_Sortir_Bouteille is
N_Vin : Integer;
N_Quant : Integer;
begin
loop
if Verif_Vide then return; end if;
N_Vin := Choisir_Vin;
loop
Put_Line("Combien de bouteilles voulez-vous sortir ?");
Put("> ");
Get(N_Quant);
exit when N_Quant in 1..Cave(N_Vin).Quantité;
Put_Line("*** La quantité doit être entre 1 et " & Integer'Image(Cave(N_Vin).Quantité) & " ! ***");
end loop;
Cave(N_Vin).Quantité := Cave(N_Vin).Quantité - N_Quant;
if Cave(N_Vin).Quantité = 0 then
Put_Line("*** Le vin est en rupture de stock ***");
if Choix(To_Unbounded_String("*** Voulez-vous le supprimer de la base ? ***")) then
A_Suppr_Vin(N_Vin);
end if;
end if;
A_Liste_Vins;
exit when not Choix(To_Unbounded_String("Voulez-vous sortir une autre bouteille ?"));
end loop;
end A_Sortir_Bouteille;
Action : Character;
begin
-- mettre à True pour charger des données d'exemple
-- pour ne pas avoir à tout saisir à la main
if True then
Cave
:= (
(To_Unbounded_String("Beaujolais AOC"),Beaujolais,Rouge,2000,7),
(To_Unbounded_String("Chablis AOC"),Bourgogne,Blanc,2017,11),
(To_Unbounded_String("Côtes de Provence"),Provence,Rose,1999,11),
(To_Unbounded_String("Saint-Emilion"),Bordeaux,Rouge,2003,3),
others => <>
);
Cave_NB := 4;
end if;
loop
-- affichage du menu
Put_Line("Choisissez une opération à effectuer :");
Put_Line(" 1- Ajouter un vin");
Put_Line(" 2- Supprimer un vin");
Put_Line(" 3- Ajouter une bouteille");
Put_Line(" 4- Sortir une bouteille");
Put_Line(" 5- Afficher la liste des vins");
Put_Line(" 6- Quitter");
Put("> ");
Get(Action);
New_Line;
case Action is
when '1' => A_Ajout_Vin;
when '2' => A_Suppr_Vin;
when '3' => A_Ajout_Bouteille;
when '4' => A_Sortir_Bouteille;
when '5' => A_Liste_Vins;
when '6' => exit;
when others => Put_Line("*** Numéro d'opération incorrect ! ***");
end case;
New_Line;
end loop;
end tp3_niget;
|
with AUnit.Test_Fixtures;
with AUnit.Test_Suites;
package HMAC_SHA1_Streams_Tests is
function Suite return AUnit.Test_Suites.Access_Test_Suite;
private
type Fixture is new AUnit.Test_Fixtures.Test_Fixture with null record;
procedure HMAC_SHA1_RFC2202_Test (Object : in out Fixture);
end HMAC_SHA1_Streams_Tests;
|
with Interfaces.C;
with GDNative.Thin;
with GDNative.Context;
package body GDNative.Console is
package IC renames Interfaces.C;
---------
-- Put --
---------
procedure Put (Item : in Wide_String) is
C_Item : IC.wchar_array := IC.To_C (Item);
Godot_Item : aliased Thin.godot_string;
begin
pragma Assert (Context.Core_Initialized, "Please run GDNative_Initialize");
Context.Core_Api.godot_string_new_with_wide_string (Godot_Item'access, C_Item (0)'access, C_Item'Length);
Context.Core_Api.godot_print (Godot_Item'access);
Context.Core_Api.godot_string_destroy (Godot_Item'access);
end;
end; |
-----------------------------------------------------------------------
-- ado-connections-postgresql -- Postgresql Database connections
-- Copyright (C) 2018, 2019 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
private with PQ;
private with Ada.Strings.Unbounded;
package ADO.Connections.Postgresql is
type Postgresql_Driver is limited private;
-- Initialize the Postgresql driver.
procedure Initialize;
private
use Ada.Strings.Unbounded;
-- Create a new Postgresql connection using the configuration parameters.
procedure Create_Connection (D : in out Postgresql_Driver;
Config : in Configuration'Class;
Result : in out Ref.Ref'Class);
type Postgresql_Driver is new ADO.Connections.Driver with record
Id : Natural := 0;
end record;
-- Create the database and initialize it with the schema SQL file.
-- The `Admin` parameter describes the database connection with administrator access.
-- The `Config` parameter describes the target database connection.
overriding
procedure Create_Database (D : in out Postgresql_Driver;
Admin : in Configs.Configuration'Class;
Config : in Configs.Configuration'Class;
Schema_Path : in String;
Messages : out Util.Strings.Vectors.Vector);
-- Deletes the Postgresql driver.
overriding
procedure Finalize (D : in out Postgresql_Driver);
-- Database connection implementation
type Database_Connection is new ADO.Connections.Database_Connection with record
Name : Unbounded_String;
Server_Name : Unbounded_String;
Login_Name : Unbounded_String;
Password : Unbounded_String;
Server : PQ.PGconn_Access := PQ.Null_PGconn;
Connected : Boolean := False;
end record;
type Database_Connection_Access is access all Database_Connection'Class;
-- Get the database driver which manages this connection.
overriding
function Get_Driver (Database : in Database_Connection)
return Driver_Access;
overriding
function Create_Statement (Database : in Database_Connection;
Table : in ADO.Schemas.Class_Mapping_Access)
return Query_Statement_Access;
overriding
function Create_Statement (Database : in Database_Connection;
Query : in String)
return Query_Statement_Access;
-- Create a delete statement.
overriding
function Create_Statement (Database : in Database_Connection;
Table : in ADO.Schemas.Class_Mapping_Access)
return Delete_Statement_Access;
-- Create an insert statement.
overriding
function Create_Statement (Database : in Database_Connection;
Table : in ADO.Schemas.Class_Mapping_Access)
return Insert_Statement_Access;
-- Create an update statement.
overriding
function Create_Statement (Database : in Database_Connection;
Table : in ADO.Schemas.Class_Mapping_Access)
return Update_Statement_Access;
-- Start a transaction.
overriding
procedure Begin_Transaction (Database : in out Database_Connection);
-- Commit the current transaction.
overriding
procedure Commit (Database : in out Database_Connection);
-- Rollback the current transaction.
overriding
procedure Rollback (Database : in out Database_Connection);
procedure Execute (Database : in out Database_Connection;
SQL : in Query_String);
-- Closes the database connection
overriding
procedure Close (Database : in out Database_Connection);
overriding
procedure Finalize (Database : in out Database_Connection);
-- Load the database schema definition for the current database.
overriding
procedure Load_Schema (Database : in Database_Connection;
Schema : out ADO.Schemas.Schema_Definition);
end ADO.Connections.Postgresql;
|
with AUnit.Assertions; use AUnit.Assertions;
with Ada.Text_IO;
with Ada.Containers; use Ada.Containers;
with Ada.Numerics.Float_Random;
with NeuralNet;
with MathUtils;
use MathUtils.Float_Vec;
package body NeuralNetTests is
procedure Register_Tests (T: in out TestCase) is
use AUnit.Test_Cases.Registration;
begin
Register_Routine (T, testBasicNet'Access, "basic net");
Register_Routine (T, testForwardPropagation'Access, "forward propagate");
Register_Routine (T, testTrain'Access, "train basic nn");
Register_Routine (T, testTrainComplex'Access, "train complex nn");
end Register_Tests;
function Name(T: TestCase) return Test_String is
begin
return Format("Neural Net Tests");
end Name;
procedure testBasicNet(T : in out Test_Cases.Test_Case'Class) is
config: NeuralNet.Config(3);
net: NeuralNet.Net(config.size);
begin
config.act := NeuralNet.RELU;
config.lr := 0.05;
config.inputSize := 4;
config.sizes := (2, 3, 2);
net := NeuralNet.create(conf => config);
Assert(net.layers.Length = 3, "net should have 3 layers");
Assert(net.layers(1).Length = 2, "2 neurons in layer 1");
Assert(net.layers(2).Length = 3, "3 neurons in layer 2");
Assert(net.layers(3).Length = 2, "2 neurons in layer 3");
-- assertions for weights in layer 1
Assert(net.layers(1)(1).w'Length = config.inputSize, "expected weights in layer 1 n 1");
Assert(net.layers(1)(2).w'Length = config.inputSize, "expected weights in layer 1 n 2");
-- assertions for weights in layer 2
Assert(net.layers(2)(1).w'Length = 2, "expected weights in layer 2 n 1");
Assert(net.layers(2)(2).w'Length = 2, "expected weights in layer 2 n 2");
Assert(net.layers(2)(3).w'Length = 2, "expected weights in layer 2 n 3");
-- assertions for weights in layer 3
Assert(net.layers(3)(1).w'Length = 3, "expected weights in layer 3 n 1");
Assert(net.layers(3)(2).w'Length = 3, "expected weights in layer 3 n 2");
end testBasicNet;
procedure testForwardPropagation(T : in out Test_Cases.Test_Case'Class) is
config: NeuralNet.Config(2);
net: NeuralNet.Net(config.size);
value: Float := 0.0;
input: MathUtils.Vector;
result: MathUtils.Vector;
begin
config.inputSize := 1;
config.act := NeuralNet.RELU;
config.sizes := (2, 1);
net := NeuralNet.create(config);
Assert(net.layers.Length = 2, "layer count");
Assert(net.layers(1).Length = 2, "neurons in layer 1");
Assert(net.layers(2).Length = 1, "neurons in output layer");
-- hardcode biases and weights
net.layers(1)(1).bias := 0.3;
net.layers(1)(1).w := (1 => 0.5);
net.layers(1)(2).bias := 0.7;
net.layers(1)(2).w := (1 => 0.1);
net.layers(2)(1).bias := 0.1;
net.layers(2)(1).w := (0.4, 0.6);
input.Append(2.0);
value := NeuralNet.forward(net.layers(1)(1), input);
Assert(value = 0.3 + 0.5 * 2.0, "forward 1: " & value'Image);
value := NeuralNet.forward(net.layers(1)(2), input);
Assert(value = 0.7 + 0.1 * 2.0, "forward 2: " & value'Image);
input.Clear;
input.Append(1.0);
input.Append(2.0);
value := NeuralNet.forward(net.layers(2)(1), input);
Assert(value = 1.0 * 0.4 + 2.0 * 0.6 + 0.1, "forward 3: " & value'Image);
input.Clear;
input.Append(2.0);
result := net.forward(input);
Assert(result.Length = 1, "Final net output size: " & result.Length'Image);
value := (0.3 + 0.5 * 2.0) * 0.4 + (0.7 + 0.1 * 2.0) * 0.6 + 0.1;
Assert(abs(result(1) - value) < Float'Epsilon, "Final net result: " & value'Image);
end testForwardPropagation;
procedure testTrain(T : in out Test_Cases.Test_Case'Class) is
config: NeuralNet.Config(1);
net: NeuralNet.Net(config.size);
previousLoss, currentLoss: Float := 0.0;
steps: constant Positive := 10;
input: MathUtils.Vector;
result: MathUtils.Vector;
begin
config.act := NeuralNet.RELU;
config.lr := 0.07;
config.inputSize := 1;
config.sizes := (1 => 1);
net := NeuralNet.create(config);
net.layers(1)(1).bias := 0.5;
net.layers(1)(1).w := (1 => 0.1);
input.Append(0.1);
result.Append(0.99);
net.train(input, result);
previousLoss := MathUtils.mse(result, net.forward(input));
for i in 1 .. steps loop
net.train(input, result);
currentLoss := MathUtils.mse(result, net.forward(input));
Assert(currentLoss < previousLoss, "Learning failed: " & currentLoss'Image & " > " & previousLoss'Image);
previousLoss := currentLoss;
end loop;
end testTrain;
procedure testTrainComplex(T : in out Test_Cases.Test_Case'Class) is
config: NeuralNet.Config(2);
net: NeuralNet.Net(config.size);
input: MathUtils.Vector;
target: MathUtils.Vector;
steps: constant Positive := 1000;
begin
config.act := NeuralNet.LOGISTIC;
config.lr := 0.1;
config.inputSize := 3;
config.sizes := (40, 3);
net := NeuralNet.create(config);
for i in 0 .. steps loop
input := 0.01 & 0.03 & (0.5 + MathUtils.rand01);
target := 1.0 & 0.0 & 0.0;
net.train(input, target);
input := (0.5 + MathUtils.rand01) & 0.03 & 0.07;
target := 0.0 & 1.0 & 0.0;
net.train(input, target);
input := 0.01 & (0.5 + MathUtils.rand01) & 0.0;
target := 0.0 & 0.0 & 1.0;
net.train(input, target);
end loop;
input := 0.0 & 0.0 & 0.5;
target := net.forward(input);
Assert(target(1) > target(2), "");
Assert(target(1) > target(3), "");
input := 0.5 & 0.0 & 0.0;
target := net.forward(input);
Assert(target(2) > target(1), "");
Assert(target(2) > target(3), "");
input := 0.0 & 0.5 & 0.0;
target := net.forward(input);
Assert(target(3) > target(1), "");
Assert(target(3) > target(2), "");
end testTrainComplex;
end NeuralNetTests;
|
-- This package contains the records of messages received from the
-- server in a convenient format.
with Ada.Strings.Unbounded;
package Irc.Message is
package SU renames Ada.Strings.Unbounded;
use type SU.Unbounded_String;
-- Available automatically from Irc.Message.Message when received
-- message is a PRIVMSG
type Privmsg_Message is tagged record
Target : SU.Unbounded_String; -- nick/chan message was sent to
Content : SU.Unbounded_String; -- content of the privmsg
end record;
-- Base message record, returned from Parse_Line, and passed
-- around to handle commands, reply, etc.
type Message is tagged record
Sender : SU.Unbounded_String; -- When a command is sent from the
-- server (PING, etc.) this will be
-- an empty string.
Command : SU.Unbounded_String;
Args : SU.Unbounded_String;
Privmsg : Privmsg_Message; -- Only exists when a PRIVMSG is sent
end record;
-- Given a line received from the server, parses and returns a
-- Message record. Will raise Parse_Error if the message is in an
-- unknown format.
function Parse_Line (Line : in SU.Unbounded_String) return Message;
-- Prints the message out to stdout in a readable format.
-- Currently it is: Sender & "» " & Command & " " & Args
procedure Print (This : Message);
-- Raised by Parse_Line on bad lines.
Parse_Error : exception;
private
procedure Parse_Privmsg (Msg : in out Message);
end Irc.Message;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Localization, Internationalization, Globalization for Ada --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-2017, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Matreshka.Internals.Unicode.Ucd;
package body Matreshka.CLDR.Collation_Compiler is
type Collation_Element_Sequence_Access is
access all Matreshka.Internals.Unicode.Ucd.Collation_Element_Sequence;
type Collation_Second_Stage_Access is
access Matreshka.Internals.Unicode.Ucd.Collation_Second_Stage;
type Collation_First_Stage is
array (Matreshka.Internals.Unicode.Ucd.First_Stage_Index)
of Collation_Second_Stage_Access;
type Contractor_Array_Access is
access all Matreshka.Internals.Unicode.Ucd.Contractor_Array;
procedure Free is
new Ada.Unchecked_Deallocation
(Matreshka.Internals.Unicode.Ucd.Collation_Second_Stage,
Collation_Second_Stage_Access);
procedure Free is
new Ada.Unchecked_Deallocation
(Matreshka.Internals.Unicode.Ucd.Collation_Element_Sequence,
Collation_Element_Sequence_Access);
procedure Free is
new Ada.Unchecked_Deallocation
(Matreshka.Internals.Unicode.Ucd.Contractor_Array,
Contractor_Array_Access);
-------------------------------------
-- Construct_Collation_Information --
-------------------------------------
procedure Construct_Collation_Information
(Data : Matreshka.CLDR.Collation_Data.Collation_Information;
Locale : not null access Matreshka.Internals.Locales.Locale_Data)
is
use type Matreshka.CLDR.Collation_Data.Collation_Record_Access;
use type Matreshka.Internals.Unicode.Code_Point;
use type Matreshka.Internals.Unicode.Ucd.Sequence_Index;
Expansion : Collation_Element_Sequence_Access;
Expansion_Last : Matreshka.Internals.Unicode.Ucd.Sequence_Index;
Contraction : Contractor_Array_Access;
Contraction_Last : Matreshka.Internals.Unicode.Ucd.Sequence_Index;
Mapping : Collation_First_Stage := (others => null);
Last_Variable : Matreshka.Internals.Unicode.Ucd.Collation_Weight := 0;
procedure Append_Expansion
(Sequence : Matreshka.CLDR.Collation_Data.Collation_Element_Array;
First : out Matreshka.Internals.Unicode.Ucd.Sequence_Index;
Last : out Matreshka.Internals.Unicode.Ucd.Sequence_Index);
-- Appends specified expansion sequence to collectd set of expansion
-- sequences.
procedure Process_Contractors
(Start : Matreshka.CLDR.Collation_Data.Collation_Record_Access;
Prefix : Matreshka.CLDR.Collation_Data.Code_Point_Array;
First : out Matreshka.Internals.Unicode.Ucd.Sequence_Count;
Last : out Matreshka.Internals.Unicode.Ucd.Sequence_Count);
-- Process contractors recursively.
----------------------
-- Append_Expansion --
----------------------
procedure Append_Expansion
(Sequence : Matreshka.CLDR.Collation_Data.Collation_Element_Array;
First : out Matreshka.Internals.Unicode.Ucd.Sequence_Index;
Last : out Matreshka.Internals.Unicode.Ucd.Sequence_Index)
is
Internal :
Matreshka.Internals.Unicode.Ucd.Collation_Element_Sequence
(1 .. Sequence'Length);
Internal_Last : Matreshka.Internals.Unicode.Ucd.Sequence_Index
:= Internal'First;
Expansion_First : Matreshka.Internals.Unicode.Ucd.Sequence_Index;
begin
-- Convert sequence of collation elements into format used by
-- internal database and update greatest weight of variable
-- character.
for Element of Sequence loop
Internal (Internal_Last) :=
(Primary => Element.Primary,
Secondary => Element.Secondary,
Trinary => Element.Trinary);
Internal_Last := Internal_Last + 1;
if Element.Is_Variable then
Last_Variable :=
Matreshka.Internals.Unicode.Ucd.Collation_Weight'Max
(Last_Variable, Element.Primary);
end if;
end loop;
if Expansion = null then
Expansion :=
new Matreshka.Internals.Unicode.Ucd.Collation_Element_Sequence
(Matreshka.Internals.Unicode.Ucd.Sequence_Index'Range);
Expansion_First := Expansion'First;
Expansion_Last := Expansion'First + Internal'Length - 1;
Expansion (Expansion'First .. Expansion_Last) := Internal;
else
-- Lookup to reuse of existent sequences in the table is not time
-- efficient, thus it is not used here.
Expansion_First := Expansion_Last + 1;
Expansion_Last := Expansion_Last + Internal'Length;
Expansion (Expansion_First .. Expansion_Last) := Internal;
end if;
First := Expansion_First;
Last := Expansion_Last;
end Append_Expansion;
------------------------------
-- Process_Code_Point_Chain --
------------------------------
procedure Process_Code_Point_Chain
(Starter : Matreshka.Internals.Unicode.Code_Point)
is
First : constant Matreshka.Internals.Unicode.Ucd.First_Stage_Index
:= Matreshka.Internals.Unicode.Ucd.First_Stage_Index
(Starter / Internals.Unicode.Ucd.Second_Stage_Index'Modulus);
Second : constant Matreshka.Internals.Unicode.Ucd.Second_Stage_Index
:= Matreshka.Internals.Unicode.Ucd.Second_Stage_Index
(Starter mod Internals.Unicode.Ucd.Second_Stage_Index'Modulus);
Current_Record : Matreshka.CLDR.Collation_Data.Collation_Record_Access
:= Data.Collations (Starter);
begin
-- Allocate block when it wasn't allocated.
if Mapping (First) = null then
Mapping (First) :=
new Matreshka.Internals.Unicode.Ucd.Collation_Second_Stage'
(others => (0, 0, 0, 0));
end if;
-- Lookup for collation record of code point itself (without
-- contractors) and process it.
while Current_Record /= null loop
-- XXX Loop can be removed if collations chain will be sorted in
-- contractors order (single character will be first element).
if Current_Record.Contractors'Length = 1 then
Append_Expansion
(Current_Record.Collations.all,
Mapping (First) (Second).Expansion_First,
Mapping (First) (Second).Expansion_Last);
exit;
end if;
Current_Record := Current_Record.Next;
end loop;
Process_Contractors
(Data.Collations (Starter),
(1 => Starter),
Mapping (First) (Second).Contractor_First,
Mapping (First) (Second).Contractor_Last);
end Process_Code_Point_Chain;
-------------------------
-- Process_Contractors --
-------------------------
procedure Process_Contractors
(Start : Matreshka.CLDR.Collation_Data.Collation_Record_Access;
Prefix : Matreshka.CLDR.Collation_Data.Code_Point_Array;
First : out Matreshka.Internals.Unicode.Ucd.Sequence_Count;
Last : out Matreshka.Internals.Unicode.Ucd.Sequence_Count)
is
use type Matreshka.CLDR.Collation_Data.Code_Point_Array;
Current_Record : Matreshka.CLDR.Collation_Data.Collation_Record_Access
:= Start;
begin
First := 0;
Last := 0;
-- Process all contractors with currently processed length and
-- started from given prefix.
while Current_Record /= null loop
if Current_Record.Contractors'Length = Prefix'Length + 1
and Current_Record.Contractors
(Current_Record.Contractors'First
.. Current_Record.Contractors'Last - 1) = Prefix
then
if Contraction = null then
Contraction :=
new Matreshka.Internals.Unicode.Ucd.Contractor_Array
(Matreshka.Internals.Unicode.Ucd.Sequence_Index);
Contraction_Last := Contraction'First;
else
Contraction_Last := Contraction_Last + 1;
end if;
if First = 0 then
First := Contraction_Last;
end if;
Last := Contraction_Last;
Contraction (Contraction_Last).Code :=
Current_Record.Contractors (Current_Record.Contractors'Last);
Append_Expansion
(Current_Record.Collations.all,
Contraction (Contraction_Last).Expansion_First,
Contraction (Contraction_Last).Expansion_Last);
end if;
Current_Record := Current_Record.Next;
end loop;
if First /= 0 then
for C in First .. Last loop
Process_Contractors
(Start,
Prefix & Contraction (C).Code,
Contraction (C).Contractor_First,
Contraction (C).Contractor_Last);
end loop;
end if;
end Process_Contractors;
use type Matreshka.Internals.Unicode.Ucd.First_Stage_Index;
use type Matreshka.Internals.Unicode.Ucd.Collation_Second_Stage;
Replaced :
array (Matreshka.Internals.Unicode.Ucd.First_Stage_Index) of Boolean
:= (others => False);
begin
-- Collect expansion and constraction information.
for Starting_Code in Data.Collations'Range loop
Process_Code_Point_Chain (Starting_Code);
end loop;
-- Remove duplicate tables and share one copy each time it duplicates.
for J in Mapping'Range loop
if not Replaced (J) then
for K in J + 1 .. Mapping'Last loop
if Mapping (J).all = Mapping (K).all then
Free (Mapping (K));
Mapping (K) := Mapping (J);
Replaced (K) := True;
end if;
end loop;
end if;
end loop;
-- Construct collation information for locale finally.
Locale.Collation.Expansion :=
new Matreshka.Internals.Unicode.Ucd.Collation_Element_Sequence'
(Expansion (Expansion'First .. Expansion_Last));
Locale.Collation.Contraction :=
new Matreshka.Internals.Unicode.Ucd.Contractor_Array'
(Contraction (Contraction'First .. Contraction_Last));
declare
Aux : Matreshka.Internals.Unicode.Ucd.Collation_First_Stage
:= (others =>
Matreshka.Internals.Unicode.Ucd.Collation_Second_Stage_Access
(Mapping (1)));
begin
for J in Mapping'Range loop
Aux (J) :=
Matreshka.Internals.Unicode.Ucd.Collation_Second_Stage_Access
(Mapping (J));
end loop;
Locale.Collation.Mapping :=
new Matreshka.Internals.Unicode.Ucd.Collation_First_Stage'(Aux);
end;
Locale.Collation.Last_Variable := Last_Variable;
Locale.Collation.Backwards := False;
-- XXX 'backward' must be taken from collation data.
-- Release auxiliary data.
Free (Expansion);
Free (Contraction);
end Construct_Collation_Information;
end Matreshka.CLDR.Collation_Compiler;
|
-- ----------------------------------------------------------------- --
-- AdaSDL_image --
-- Binding to SDL image lib --
-- Copyright (C) 2001 A.M.F.Vargas --
-- Antonio M. F. Vargas --
-- Ponta Delgada - Azores - Portugal --
-- E-mail: avargas@adapower.net --
-- ----------------------------------------------------------------- --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU General Public --
-- License as published by the Free Software Foundation; either --
-- version 2 of the License, or (at your option) any later version. --
-- --
-- This library is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. --
-- --
-- You should have received a copy of the GNU General Public --
-- License along with this library; if not, write to the --
-- Free Software Foundation, Inc., 59 Temple Place - Suite 330, --
-- Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from --
-- this unit, or you link this unit with other files to produce an --
-- executable, this unit does not by itself cause the resulting --
-- executable to be covered by the GNU General Public License. This --
-- exception does not however invalidate any other reasons why the --
-- executable file might be covered by the GNU Public License. --
-- ----------------------------------------------------------------- --
-- **************************************************************** --
-- This is an Ada binding to SDL_image lib from Sam Lantinga at --
-- www.libsld.org --
-- **************************************************************** --
-- In order to help the Ada programmer, the comments in this file --
-- are, in great extent, a direct copy of the original text in the --
-- SDL mixer header files. --
-- **************************************************************** --
-- A simple library to load images of various formats as SDL surfaces
with Interfaces.C.Strings;
with SDL.RWops; use SDL.RWops;
with SDL.Video; use SDL.Video;
with SDL.Error;
package SDL_Image is
package V renames SDL.Video;
package RW renames SDL.RWops;
package C renames Interfaces.C;
package CS renames Interfaces.C.Strings;
-- Load an image from an SDL data source.
-- The 'type' may be one of: "BMP", "GIF", "PNG", etc.
-- If the image format supports a transparent pixel, SDL will set the
-- colorkey for the surface. You can enable RLE acceleration on the
-- surface afterwards by calling:
-- SetColorKey (image, SDL_RLEACCEL, image.format.colorkey);
function LoadTyped_RW (src : RW.RWops_ptr;
freesrc : C.int;
the_type : CS.chars_ptr)
return V.Surface_ptr;
pragma Import (C, LoadTyped_RW, "IMG_LoadTyped_RW");
function LoadTyped_RW (src : RW.RWops_ptr;
freesrc : C.int;
the_type : String)
return V.Surface_ptr;
pragma Inline (LoadTyped_RW);
-- Convenience functions
function Load (file : CS.chars_ptr) return V.Surface_ptr;
pragma Import (C, Load, "IMG_Load");
function Load (file : String) return V.Surface_ptr;
pragma Inline (Load);
function Load_RW (src : RW.RWops_ptr; freesrc : C.int) return V.Surface_ptr;
pragma Import (C, Load_RW, "IMG_Load_RW");
-- Invert the alpha of a surface for use with OpenGL
-- This function is now a no-op, and only provided for backwards compatibility.
function InvertAlpha (on : C.int) return C.int;
pragma Import (C, InvertAlpha, "IMG_InvertAlpha");
-- Functions to detect a file type, given a seekable source */
function isBMP (src : RW.RWops_ptr) return C.int;
pragma Import (C, isBMP, "IMG_isBMP");
function isPPM (src : RW.RWops_ptr) return C.int;
pragma Import (C, isPPM, "IMG_isPPM");
function isPCX (src : RW.RWops_ptr) return C.int;
pragma Import (C, isPCX, "IMG_isPCX");
function isGIF (src : RW.RWops_ptr) return C.int;
pragma Import (C, isGIF, "IMG_isGIF");
function isJPG (src : RW.RWops_ptr) return C.int;
pragma Import (C, isJPG, "IMG_isJPG");
function isTIF (src : RW.RWops_ptr) return C.int;
pragma Import (C, isTIF, "IMG_isTIF");
function isPNG (src : RW.RWops_ptr) return C.int;
pragma Import (C, isPNG, "IMG_isPNG");
-- Individual loading functions
function LoadBMP_RW (src : RW.RWops) return V.Surface_ptr;
pragma Import (C, LoadBMP_RW, "IMG_LoadBMP_RW");
function LoadPPM_RW (src : RW.RWops) return V.Surface_ptr;
pragma Import (C, LoadPPM_RW, "IMG_LoadPPM_RW");
function LoadPCX_RW (src : RW.RWops) return V.Surface_ptr;
pragma Import (C, LoadPCX_RW, "IMG_LoadPCX_RW");
function LoadGIF_RW (src : RW.RWops) return V.Surface_ptr;
pragma Import (C, LoadGIF_RW, "IMG_LoadGIF_RW");
function LoadJPG_RW (src : RW.RWops) return V.Surface_ptr;
pragma Import (C, LoadJPG_RW, "IMG_LoadJPG_RW");
function LoadTIF_RW (src : RW.RWops) return V.Surface_ptr;
pragma Import (C, LoadTIF_RW, "IMG_LoadTIF_RW");
function LoadPNG_RW (src : RW.RWops) return V.Surface_ptr;
pragma Import (C, LoadPNG_RW, "IMG_LoadPNG_RW");
function LoadTGA_RW (src : RW.RWops) return V.Surface_ptr;
pragma Import (C, LoadTGA_RW, "IMG_LoadTGA_RW");
-- We'll use SDL for reporting errors
procedure SetError (fmt : CS.chars_ptr)
renames SDL.Error.SetError;
procedure Set_Error (fmt : String)
renames SDL.Error.Set_Error;
function GetError return CS.chars_ptr
renames SDL.Error.GetError;
function Get_Error return String
renames SDL.Error.Get_Error;
end SDL_Image;
|
with Ada.Streams.Stream_IO; use Ada.Streams.Stream_IO;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Parser; use Parser;
package body X86Writer is
-- The main X86 assembly function
procedure assemble(instr_list : Instr_Vector.Vector; writer : Stream_Access) is
-- Our types
type Byte is mod 2 ** 8;
-- Utility functions
-- TODO: This is also in the X86Parser, we should move this elsewhere
function Is_Number(Input : String) return Boolean is
Number : Integer;
begin
Number := Integer'Value(Input);
return true;
exception
when others =>
return false;
end Is_Number;
-- Checks if a string is a register
function Is_Register(input : String) return Boolean is
begin
-- The 8-bit registers
if input = "al" or input = "cl" or input = "dl" or input = "bl"
or input = "ah" or input = "ch" or input = "dh" or input = "bh" then
return true;
-- The 16-bit registers
elsif input = "ax" or input = "cx" or input = "dx" or input = "bx"
or input = "sp" or input = "bp" or input = "si" or input = "di" then
return true;
-- The 32-bit registers
elsif input = "eax" or input = "ecx" or input = "edx" or input = "ebx"
or input = "esp" or input = "ebp" or input = "esi" or input = "edi" then
return true;
end if;
return false;
end Is_Register;
-- The encode function for the mov instruction
-- This can get rather complicated...
procedure encode_mov(op1, op2 : String) is
imm : Integer := 0;
begin
if Is_Register(op1) and Is_Number(op2) then
if op1 = "eax" then
Byte'Write(writer, 16#B8#);
elsif op1 = "ecx" then
Byte'Write(writer, 16#B9#);
elsif op1 = "edx" then
Byte'Write(writer, 16#BA#);
elsif op1 = "ebx" then
Byte'Write(writer, 16#BB#);
elsif op1 = "esp" then
Byte'Write(writer, 16#BC#);
elsif op1 = "ebp" then
Byte'Write(writer, 16#BD#);
elsif op1 = "esi" then
Byte'Write(writer, 16#BE#);
elsif op1 = "edi" then
Byte'Write(writer, 16#BF#);
end if;
imm := Integer'Value(op2);
Integer'Write(writer, imm);
end if;
end encode_mov;
-- The main encode function
procedure encode(ln : Parts) is
token1 : String := To_String(ln(0));
token2 : String := To_String(ln(1));
token3 : String := To_String(ln(2));
begin
-- Syscall
if token1 = "syscall" then
Byte'Write(writer, 16#0F#);
Byte'Write(writer, 16#05#);
-- Mov
elsif token1 = "mov" then
encode_mov(token2, token3);
end if;
end encode;
begin
for Ln of instr_list loop
encode(Ln.line);
end loop;
end assemble;
end X86Writer;
|
pragma License (Unrestricted);
-- Ada 2012
with Ada.Characters.Conversions;
with Ada.Strings.Generic_Hash_Case_Insensitive;
function Ada.Strings.Wide_Hash_Case_Insensitive is
new Generic_Hash_Case_Insensitive (
Wide_Character,
Wide_String,
Characters.Conversions.Get);
-- pragma Pure (Ada.Strings.Wide_Hash_Case_Insensitive);
pragma Preelaborate (Ada.Strings.Wide_Hash_Case_Insensitive); -- use maps
|
package body Input_0 is
function My_Function return Boolean is
begin
return True;
end My_Function;
procedure My_Procedure is
begin
null;
end My_Procedure;
task body My_Task is
begin
accept GET (X: in My_T) do
null;
end GET;
end My_Task;
end Input_0;
|
pragma Warnings (Off);
pragma Style_Checks (Off);
with GLOBE_3D;
package Planet is
procedure Create (
object : in out GLOBE_3D.p_Object_3D;
scale : GLOBE_3D.Real;
centre : GLOBE_3D.Point_3D;
mercator : GLOBE_3D.Image_id;
parts : Positive := 30
);
end Planet;
|
-- Change log:
-- GdM : 26-Jul-2011 : using System.Address_To_Access_Conversions
-- GdM : 28-Nov-2005 : replaced Unrestricted_Access with Address
-- since Unrestricted_Access is GNAT-Specific
-- GdM : 27-Jan-2004 : Added Material_Float_vector and Material ( .. .) for it
-- GdM : 11-Apr-2002 : * "gl .. ." and other useless C prefixes removed
-- * removing of pointers and
-- " .. .4f" -style suffixes in progress
with Interfaces.C.Strings;
with GL.Extended;
package body GL is
procedure Light
(Light_id : LightIDEnm;
pname : LightParameterVEnm;
params : Light_Float_vector)
is
params_copy : aliased Light_Float_vector := params;
begin
Lightfv (Light_id, pname, params_copy (0)'Unchecked_Access);
end Light;
procedure Material (face : FaceEnm;
pname : MaterialParameterVEnm;
params : Material_Float_vector) is
params_copy : aliased Material_Float_vector := params;
begin
Materialfv (face, pname, params_copy (0)'Unchecked_Access);
end Material;
procedure Vertex (v : Double_Vector_3D) is
begin
Vertex3dv (A2A_double.To_Pointer (v (0)'Address));
-- This method is functionally identical
-- to using GNAT's 'Unrestricted_Access
end Vertex;
procedure Normal (v : Double_Vector_3D) is
begin
Normal3dv (A2A_double.To_Pointer (v (0)'Address));
end Normal;
procedure Translate (v : Double_Vector_3D) is
begin
Translate (v (0), v (1), v (2));
end Translate;
procedure Color (v : RGB_Color) is
begin
Color3dv (A2A_double.To_Pointer (v.Red'Address));
end Color;
procedure Color (v : RGBA_Color) is
begin
Color4dv (A2A_double.To_Pointer (v.red'Address));
end Color;
function GetString (name : StringEnm) return String is
function Cvt is new Ada.Unchecked_Conversion (ubytePtr, Interfaces.C.Strings.chars_ptr);
ps : constant Interfaces.C.Strings.chars_ptr := Cvt (GL.GetString (name));
use Interfaces.C.Strings;
begin
-- OpenGL doc : If an error is generated, glGetString returns 0.
if ps = Null_Ptr then
-- We still return a string, but an empty one (this is abnormal)
return "";
else
return Interfaces.C.Strings.Value (ps);
end if;
end GetString;
-----------------------------
-- Wrappers of GL.Extended --
-----------------------------
procedure Gen_Buffers (n : GL.Sizei;
buffers : GL.uintPtr)
renames GL.Extended.GenBuffers;
procedure Delete_Buffers (n : GL.Sizei;
buffers : GL.uintPtr)
renames GL.Extended.DeleteBuffers;
procedure BindBuffer (target : VBO_Target;
buffer : GL.Uint)
renames GL.Extended.BindBuffer;
procedure Buffer_Data (target : GL.VBO_Target;
size : GL.sizeiPtr;
data : GL.pointer;
usage : GL.VBO_Usage)
renames GL.Extended.BufferData;
procedure BufferSubData (target : GL.VBO_Target;
offset : GL.intPtr;
size : GL.sizeiPtr;
data : GL.pointer)
renames GL.Extended.BufferSubData;
function MapBuffer (target : GL.VBO_Target;
Policy : GL.Access_Policy) return GL.pointer
renames GL.Extended.MapBuffer;
function UnmapBuffer (target : GL.VBO_Target) return GL_Boolean
renames GL.Extended.UnmapBuffer;
procedure GetBufferParameter (target : GL.VBO_Target;
value : Buffer_Parameter;
data : intPointer)
renames GL.Extended.GetBufferParameter;
end GL;
|
--
-- 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.
--
---------------------------------------------------------------------------
--
-- This module implements routines use to construct the yy_action[] table.
--
-- The state of the yy_action table under construction is an instance of
-- the following structure.
--
-- The yy_action table maps the pair (state_number, lookahead) into an
-- action_number. The table is an array of integers pairs. The state_number
-- determines an initial offset into the yy_action array. The lookahead
-- value is then added to this initial offset to get an index X into the
-- yy_action array. If the aAction[X].lookahead equals the value of the
-- of the lookahead input, then the value of the action_number output is
-- aAction[X].action. If the lookaheads do not match then the
-- default action for the state_number is returned.
--
-- All actions associated with a single state_number are first entered
-- into aLookahead[] using multiple calls to acttab_action(). Then the
-- actions for that single state_number are placed into the aAction[]
-- array with a single call to acttab_insert(). The acttab_insert() call
-- also resets the aLookahead[] array in preparation for the next
-- state number.
--
limited with States;
with Rules;
with Symbols;
package Actions is
type Action_Kind is
(Shift,
C_Accept,
Reduce,
Error,
SS_Conflict, -- A shift/shift conflict
SR_Conflict, -- Was a reduce, but part of a conflict
RR_Conflict, -- Was a reduce, but part of a conflict
SH_Resolved, -- Was a shift. Precedence resolved conflict
RD_Resolved, -- Was reduce. Precedence resolved conflict
Not_Used, -- Deleted by compression
Shift_Reduce -- Shift first, then reduce
);
type Action_Record;
type Action_Access is access all Action_Record;
type State_Rule_Kind is (Is_State, Is_Rule);
type X_Union (Typ : State_Rule_Kind := Is_State) is record
case Typ is
when Is_State =>
State : access States.State_Record; -- The look-ahead symbol
when Is_Rule =>
Rule : access Rules.Rule_Record; -- The new state, if a shift
end case;
end record;
pragma Unchecked_Union (X_Union);
-- Every shift or reduce operation is stored as one of the following
type Action_Record is record
Symbol : access Symbols.Symbol_Record;
Kind : Action_Kind;
X : X_Union;
-- The rule, if a reduce
Symbol_Link : access Symbols.Symbol_Record;
-- Shift_Reduce optimization to this symbol
-- Next : access Action_Record;
-- Next action for this state
Collide : access Action_Record;
-- Next action with the same hash
end record;
function Action_Cmp (Left, Right : in Action_Record)
return Boolean;
-- Compare two actions for sorting purposes. Return negative, zero, or
-- positive if the first action is less than, equal to, or greater than
-- the first
-- Return True when Left is 'less than' Right.
-- function Action_Sort (Action : in Action_Access) return Action_Access;
-- -- Sort parser actions
-- -- function Action_New return Action_Access;
-- -- Allocate a new parser action
-- procedure Action_Add (Action : in out Action_Access;
-- Kind : in Action_Kind;
-- Symbol : in Symbols.Symbol_Access;
-- State : in States.State_Access;
-- Rule : in Rules.Rule_Access);
-- See Action_lists.Append
function Resolve_Conflict (Left : in out Action_Record;
Right : in out Action_Record) return Integer;
-- Resolve a conflict between the two given actions. If the
-- conflict can't be resolved, return non-zero.
--
-- NO LONGER TRUE:
-- To resolve a conflict, first look to see if either action
-- is on an error rule. In that case, take the action which
-- is not associated with the error rule. If neither or both
-- actions are associated with an error rule, then try to
-- use precedence to resolve the conflict.
--
-- If either action is a SHIFT, then it must be apx. This
-- function won't work if apx->type==REDUCE and apy->type==SHIFT.
end Actions;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- T R E E P R --
-- --
-- S p e c --
-- --
-- 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. 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 Types; use Types;
package Treepr is
-- This package provides printing routines for the abstract syntax tree
-- These routines are intended only for debugging use.
procedure Tree_Dump;
-- This routine is called from the GNAT main program to dump trees as
-- requested by debug options (including tree of Standard if requested).
procedure Print_Tree_Node (N : Node_Id; Label : String := "");
-- Prints a single tree node, without printing descendants. The Label
-- string is used to preface each line of the printed output.
procedure Print_Node_Briefly (N : Node_Id);
-- Terse version of Print_Tree_Node
procedure Print_Tree_List (L : List_Id);
-- Prints a single node list, without printing the descendants of any
-- of the nodes in the list
procedure Print_Tree_Elist (E : Elist_Id);
-- Prints a single node list, without printing the descendants of any
-- of the nodes in the list
procedure Print_Node_Subtree (N : Node_Id);
-- Prints the subtree rooted at a specified tree node, including all
-- referenced descendants.
procedure Print_List_Subtree (L : List_Id);
-- Prints the subtree consisting of the given node list and all its
-- referenced descendants.
procedure Print_Elist_Subtree (E : Elist_Id);
-- Prints the subtree consisting of the given element list and all its
-- referenced descendants.
-- The following debugging procedures are intended to be called from gdb.
-- Note that in several cases there are synonyms which represent historical
-- development, and we keep them because some people are used to them!
function p (N : Union_Id) return Node_Or_Entity_Id;
function par (N : Union_Id) return Node_Or_Entity_Id;
pragma Export (Ada, p);
pragma Export (Ada, par);
-- Return parent of a list or node (depending on the value of N). If N
-- is neither a list nor a node id, then prints a message to that effect
-- and returns Empty.
procedure pn (N : Union_Id);
procedure pp (N : Union_Id);
procedure pe (N : Union_Id);
pragma Export (Ada, pn);
pragma Export (Ada, pp);
pragma Export (Ada, pe);
-- Print a node, node list, uint, or anything else that falls under
-- the definition of Union_Id. Historically this was only for printing
-- nodes, hence the name.
procedure ppar (N : Union_Id);
pragma Export (Ada, ppar);
-- Print the node, its parent, its parent's parent, and so on
procedure pt (N : Union_Id);
procedure ppp (N : Union_Id);
pragma Export (Ada, pt);
pragma Export (Ada, ppp);
-- Same as pn/pp, except prints subtrees. For Nodes, it is exactly the same
-- as Print_Node_Subtree. For Elists it is the same as Print_Elist_Subtree.
-- For Lists, it is the same as Print_Tree_List. If given anything other
-- than a Node, List, or Elist, same effect as pn.
procedure pl (L : Int);
pragma Export (Ada, pl);
-- Same as Print_Tree_List, except that you can use e.g. 66 instead of
-- -99999966. In other words for the positive case we fill out to 8 digits
-- on the left and add a minus sign. This just saves some typing in the
-- debugger.
end Treepr;
|
-- -----------------------------------------------------------------------------
-- Copyright (C) 2003-2019 Stichting Mapcode Foundation (http://www.mapcode.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-- -----------------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
package body Mapcode_Utils.As_U is
-- Each time a re-allocation is needed, increment Length by
-- Nb_To_Add + Growth_Offset + Curr_Length / Growth_Factor
-- so that some further growths will not lead to re-alloc
Growth_Factor : constant Natural := 64;
Growth_Offset : constant Natural := 32;
procedure Free (X : in out String_Access) is
procedure Deallocate is
new Ada.Unchecked_Deallocation (String, String_Access);
begin
-- Do not try to free statically allocated null array
if X /= Asu_Null.Ref then
Deallocate (X);
end if;
end Free;
procedure Check_Indexes (Low : in Positive;
High : in Natural;
Last : in Natural;
Check_High : in Boolean) is
begin
if Low > Last + 1 or else (Check_High and then High > Last) then
raise Index_Error;
end if;
end Check_Indexes;
procedure Check_Index (Index : in Positive;
Last : in Natural;
Allow_Append : in Boolean) is
begin
if Index <= Last then
-- Index within range
return;
end if;
if Allow_Append and then Index = Last + 1 then
-- Append = insert before last + 1
return;
end if;
raise Index_Error;
end Check_Index;
-- Size computed to Add to Length
function New_Size (Length : Natural; Add : Positive) return Positive is
(Length + Add + Growth_Offset + Length / Growth_Factor);
-- Store Item in Unbounded array, re-alloc if necessary
procedure Store (Within : in out Asu_Us;
Item : in String) is
Incr : Integer;
Acc : String_Access;
begin
Incr := Item'Length - Within.Ref'Length;
if Incr <= 0 then
if Item'Length = 0 then
-- Item to store is empty
Free (Within.Ref);
Within.Ref := Null_Access;
else
-- Item to store fits in Reference, no need to re-alloc
Within.Ref.all(1 .. Item'Length) := Item;
end if;
else
-- Re-alloc reference to new size
Acc := new String(1 .. New_Size (Within.Ref'Length, Incr));
Acc(1 .. Item'Length) := Item;
Free (Within.Ref);
Within.Ref := Acc;
end if;
Within.Last := Item'Length;
end Store;
procedure Init (Target : in out Asu_Us; Length : Natural) is
begin
Free (Target.Ref);
if Length = 0 then
Target := Asu_Null;
else
Target.Ref := new String(1 .. Length);
Target.Ref.all := (others => ' ');
Target.Last := Length;
end if;
end Init;
-- Move the slice Last .. Source.Last at Before
procedure Move (Source : in out Asu_Us; Before, Last : in Positive) is
Tmp : constant String := Source.Ref (Last .. Source.Last);
begin
-- Shift head from Before to Last - 1 at the tail
Source.Ref(Source.Last - Last + Before + 1 .. Source.Last) :=
Source.Ref(Before .. Last - 1);
-- Copy Tmp at Before
Source.Ref(Before .. Before + Tmp'Length - 1) := Tmp;
end Move;
-----------------------
-- PUBLIC operations --
-----------------------
procedure Set_Null (Target : in out Asu_Us) is
begin
-- Optim: avoid copying Asu_Null
Free (Target.Ref);
Target.Ref := Null_Access;
Target.Last := 0;
end Set_Null;
function Is_Null (Source : Asu_Us) return Boolean is (Source = Asu_Null);
function Length (Source : Asu_Us) return Natural is (Source.Last);
function Tus (Str : String) return Asu_Us is
Res : Asu_Us;
begin
if Str'Length = 0 then
Res := Asu_Null;
else
Res.Ref := new String(1 .. Str'Length);
Res.Ref.all := Str;
Res.Last := Str'Length;
end if;
return Res;
end Tus;
function Tus (Char : Character) return Asu_Us is
Res : Asu_Us;
begin
Res.Ref := new String(1 .. 1);
Res.Ref(1) := Char;
Res.Last := 1;
return Res;
end Tus;
function Image (Str : Asu_Us) return String is (Str.Ref (1 .. Str.Last));
procedure Set (Target : out Asu_Us; Val : in Asu_Us) is
begin
if Val.Last = 0 then
Target := Asu_Null;
else
Target.Ref := new String(1 .. Val.Last);
Target.Ref.all := Val.Ref(1 .. Val.Last);
Target.Last := Val.Last;
end if;
end Set;
procedure Set (Target : out Asu_Us; Val : in String) is
begin
if Val'Length = 0 then
Target := Asu_Null;
else
Target.Ref := new String(1 .. Val'Length);
Target.Ref.all := Val;
Target.Last := Val'Length;
end if;
end Set;
procedure Set (Target : out Asu_Us; Val : in Character) is
begin
Target.Ref := new String(1 .. 1);
Target.Ref(1) := Val;
Target.Last := 1;
end Set;
function Uslice (Source : Asu_Us;
Low : Positive; High : Natural) return Asu_Us is
begin
Check_Indexes (Low, High, Source.Last, True);
return Tus (Source.Ref.all(Low .. High));
end Uslice;
procedure Uslice (Source : in Asu_Us; Target : out Asu_Us;
Low : in Positive; High : in Natural) is
begin
Check_Indexes (Low, High, Source.Last, True);
Set (Target, Source.Ref.all(Low .. High));
end Uslice;
function Slice (Source : Asu_Us;
Low : Positive; High : Natural) return String is
begin
Check_Indexes (Low, High, Source.Last, True);
return Source.Ref.all(Low .. High);
end Slice;
procedure Prepend (Source : in out Asu_Us; New_Item : in Asu_Us) is
begin
Store (Source, New_Item.Ref.all & Source.Ref(1 .. Source.Last));
end Prepend;
procedure Prepend (Source : in out Asu_Us; New_Item : in String) is
begin
Store (Source, New_Item & Source.Ref(1 .. Source.Last));
end Prepend;
procedure Prepend (Source : in out Asu_Us; New_Item : in Character) is
begin
Store (Source, New_Item & Source.Ref(1 .. Source.Last));
end Prepend;
procedure Append (Source : in out Asu_Us; New_Item : in Asu_Us) is
begin
if New_Item.Last <= Source.Ref'Length - Source.Last then
-- Optim: no copy if New_Item fits
Source.Ref(Source.Last + 1 .. Source.Last + New_Item.Last) :=
New_Item.Ref(1 .. New_Item.Last);
Source.Last := Source.Last + New_Item.Last;
else
Store (Source, Source.Ref(1 .. Source.Last)
& New_Item.Ref(1 .. New_Item.Last));
end if;
end Append;
procedure Append (Source : in out Asu_Us; New_Item : in String) is
begin
if New_Item'Length <= Source.Ref'Length - Source.Last then
-- Optim: no copy if New_Item fits
Source.Ref(Source.Last + 1 .. Source.Last + New_Item'Length) := New_Item;
Source.Last := Source.Last + New_Item'Length;
else
Store (Source, Source.Ref(1 .. Source.Last) & New_Item);
end if;
end Append;
procedure Append (Source : in out Asu_Us; New_Item : in Character) is
begin
if 1 <= Source.Ref'Length - Source.Last then
-- Optim: no copy if New_Item fits
Source.Ref(Source.Last + 1) := New_Item;
Source.Last := Source.Last + 1;
else
Store (Source, Source.Ref.all & New_Item);
end if;
end Append;
function "&" (Left, Right : Asu_Us) return Asu_Us is
Res : Asu_Us := Left;
begin
Append (Res, Right);
return Res;
end "&";
function "&" (Left : Asu_Us; Right : String) return Asu_Us is
Res : Asu_Us := Left;
begin
Append (Res, Right);
return Res;
end "&";
function "&" (Left : String; Right : Asu_Us) return Asu_Us is
Res : Asu_Us := Tus (Left);
begin
Append (Res, Right);
return Res;
end "&";
function "&" (Left : Asu_Us; Right : Character) return Asu_Us is
Res : Asu_Us := Left;
begin
Append (Res, Right);
return Res;
end "&";
function "&" (Left : Character; Right : Asu_Us) return Asu_Us is
Res : Asu_Us := Tus (Left);
begin
Append (Res, Right);
return Res;
end "&";
function Element (Source : Asu_Us; Index : Positive) return Character is
begin
Check_Index (Index, Source.Last, False);
return Source.Ref.all(Index);
end Element;
procedure Replace_Element (Source : in out Asu_Us;
Index : in Positive;
By : in Character) is
begin
Check_Index (Index, Source.Last, False);
Source.Ref.all(Index) := By;
end Replace_Element;
overriding function "=" (Left, Right : Asu_Us) return Boolean is
(Left.Ref.all(1 .. Left.Last) = Right.Ref.all(1 .. Right.Last));
function "=" (Left : Asu_Us; Right : String) return Boolean is
(Left.Ref.all(1 .. Left.Last) = Right);
function "=" (Left : String; Right : Asu_Us) return Boolean is
(Left = Right.Ref.all(1 .. Right.Last));
function "<" (Left, Right : Asu_Us) return Boolean is
(Left.Ref.all(1 .. Left.Last) < Right.Ref.all(1 .. Right.Last));
function "<" (Left : Asu_Us; Right : String) return Boolean is
(Left.Ref.all(1 .. Left.Last) < Right);
function "<" (Left : String; Right : Asu_Us) return Boolean is
(Left < Right.Ref.all(1 .. Right.Last));
function "<=" (Left, Right : Asu_Us) return Boolean is
(Left.Ref.all(1 .. Left.Last) <= Right.Ref.all(1 .. Right.Last));
function "<=" (Left : Asu_Us; Right : String) return Boolean is
(Left.Ref.all(1 .. Left.Last) <= Right);
function "<=" (Left : String; Right : Asu_Us) return Boolean is
(Left <= Right.Ref.all(1 .. Right.Last));
function ">" (Left, Right : Asu_Us) return Boolean is
(Left.Ref.all(1 .. Left.Last) > Right.Ref.all(1 .. Right.Last));
function ">" (Left : Asu_Us; Right : String) return Boolean is
(Left.Ref.all(1 .. Left.Last) > Right);
function ">" (Left : String; Right : Asu_Us) return Boolean is
(Left > Right.Ref.all(1 .. Right.Last));
function ">=" (Left, Right : Asu_Us) return Boolean is
(Left.Ref.all(1 .. Left.Last) >= Right.Ref.all(1 .. Right.Last));
function ">=" (Left : Asu_Us; Right : String) return Boolean is
(Left.Ref.all(1 .. Left.Last) >= Right);
function ">=" (Left : String; Right : Asu_Us) return Boolean is
(Left >= Right.Ref.all(1 .. Right.Last));
function Locate (Within : Asu_Us;
Fragment : String;
From_Index : Natural := 0;
Forward : Boolean := True;
Occurence : Positive := 1) return Natural is
Index : Natural;
Found_Occurence : Natural := 0;
begin
-- Fix Index
Index := (if From_Index = 0 then
(if Forward then 1 else Within.Last)
else From_Index);
-- Handle limit or incorrect values
if Within.Last = 0
or else Fragment'Length = 0
or else Index > Within.Last then
return 0;
end if;
if Forward then
for I in Index .. Within.Last - Fragment'Length + 1 loop
if Within.Ref(I .. I + Fragment'Length - 1) = Fragment then
Found_Occurence := Found_Occurence + 1;
if Found_Occurence = Occurence then
return I;
end if;
end if;
end loop;
else
for I in reverse 1 .. Index - Fragment'Length + 1 loop
if Within.Ref(I .. I + Fragment'Length - 1) = Fragment then
Found_Occurence := Found_Occurence + 1;
if Found_Occurence = Occurence then
return I;
end if;
end if;
end loop;
end if;
return 0;
exception
when Constraint_Error =>
return 0;
end Locate;
function Count (Source : Asu_Us;
Pattern : String) return Natural is
Result : Natural := 0;
begin
for I in 1 .. Source.Last - Pattern'Length + 1 loop
if Source.Ref(I .. I + Pattern'Length - 1) = Pattern then
Result := Result + 1;
end if;
end loop;
return Result;
end Count;
procedure Overwrite (Source : in out Asu_Us;
Position : in Positive;
New_Item : in Asu_Us) is
-- Index in New_Item of last overwritting char (others are appended)
Lo : Natural;
begin
Check_Index (Position, Source.Last, True);
Lo := (if Position + New_Item.Last - 1 > Source.Last then
Source.Last - Position + 1
else New_Item.Last);
-- Overwrite by Lo chars from Position
Source.Ref(Position .. Position + Lo - 1) := New_Item.Ref(1 .. Lo);
-- Append others
Append (Source, New_Item.Ref(Lo + 1 .. New_Item.Last));
end Overwrite;
procedure Overwrite (Source : in out Asu_Us;
Position : in Positive;
New_Item : in String) is
-- Index in New_Item of last overwritting char (others are appended)
Lo : Natural;
begin
Check_Index (Position, Source.Last, True);
Lo := (if Position + New_Item'Length - 1 > Source.Last then
New_Item'First + Source.Last - Position
else New_Item'Last);
-- Overwrite by Lo chars from Position
Source.Ref(Position .. Position + Lo - New_Item'First) :=
New_Item(New_Item'First .. Lo);
-- Append others
Append (Source, New_Item(Lo + 1 .. New_Item'Last));
end Overwrite;
procedure Replace (Source : in out Asu_Us;
Low : in Positive;
High : in Natural;
By : in Asu_Us) is
Start_Tail : Positive;
begin
Check_Indexes (Low, High, Source.Last, False);
-- Replace or insert
Start_Tail := (if Low <= High then High + 1 else Low);
Store (Source, Source.Ref(1 .. Low - 1)
& By.Ref(1 .. By.Last)
& Source.Ref(Start_Tail .. Source.Last));
end Replace;
procedure Replace (Source : in out Asu_Us;
Low : in Positive;
High : in Natural;
By : in String) is
Start_Tail : Positive;
begin
Check_Indexes (Low, High, Source.Last, False);
-- Replace or insert
Start_Tail := (if Low <= High then High + 1 else Low);
Store (Source, Source.Ref(1 .. Low - 1)
& By
& Source.Ref(Start_Tail .. Source.Last));
end Replace;
procedure Insert (Source : in out Asu_Us;
Before : in Positive;
New_Item : in Asu_Us) is
Last : constant Natural := Source.Last;
begin
if Before > Source.Last + 1 then
raise Index_Error;
end if;
Append (Source, New_Item);
Move (Source, Before, Last + 1);
end Insert;
procedure Insert (Source : in out Asu_Us;
Before : in Positive;
New_Item : in String) is
Last : constant Natural := Source.Last;
begin
if Before > Source.Last + 1 then
raise Index_Error;
end if;
Append (Source, New_Item);
Move (Source, Before, Last + 1);
end Insert;
procedure Insert (Source : in out Asu_Us;
Before : in Positive;
New_Item : in Character) is
Last : constant Natural := Source.Last;
begin
if Before > Source.Last + 1 then
raise Index_Error;
end if;
Append (Source, New_Item);
Move (Source, Before, Last + 1);
end Insert;
procedure Delete (Source : in out Asu_Us;
From : in Positive;
Through : in Natural) is
New_Len : Natural;
begin
if Through < From then
return;
end if;
if Through > Source.Last then
raise Index_Error;
end if;
New_Len := Source.Last - (Through - From + 1);
if New_Len = 0 then
Free(Source.Ref);
Source := Asu_Null;
else
Source.Ref(1 .. New_Len) :=
Source.Ref(1 .. From - 1)
& Source.Ref(Through + 1 .. Source.Last);
Source.Last := New_Len;
end if;
end Delete;
procedure Delete_Nb (Source : in out Asu_Us;
From : in Positive;
Number : in Natural) is
begin
if From + Number - 1 <= Source.Last then
-- We can delete Number characters
Delete (Source, From, From + Number - 1);
else
-- We delete from From to Last
Delete (Source, From, Source.Last);
end if;
end Delete_Nb;
procedure Trail (Source : in out Asu_Us;
Number : in Natural) is
begin
if Number >= Source.Last then
Free(Source.Ref);
Source := Asu_Null;
else
Source.Last := Source.Last - Number;
end if;
end Trail;
function Head (Source : Asu_Us; Count : Natural; Pad : Character := Space)
return Asu_Us is
Result : Asu_Us;
begin
Init (Result, Count);
if Count <= Source.Last then
Result.Ref.all := Source.Ref(1 .. Count);
else
Result.Ref(1 .. Source.Last) := Source.Ref(1 .. Source.Last);
for I in Source.Last + 1 .. Count loop
Result.Ref(I) := Pad;
end loop;
end if;
return Result;
end Head;
function Tail (Source : Asu_Us; Count : Natural; Pad : Character := Space)
return Asu_Us is
Result : Asu_Us;
begin
Init (Result, Count);
if Count <= Source.Last then
Result.Ref.all := Source.Ref(Source.Last - Count + 1 .. Source.Last);
else
for I in 1 .. Count - Source.Last loop
Result.Ref(I) := Pad;
end loop;
Result.Ref(Count - Source.Last + 1 .. Count) := Source.Ref.all;
end if;
return Result;
end Tail;
function "*" (Left : Natural; Right : Character) return Asu_Us is
Result : Asu_Us;
begin
Init (Result, Left);
for I in 1 .. Left loop
Result.Ref(I) := Right;
end loop;
return Result;
end "*";
function "*" (Left : Natural; Right : String) return Asu_Us is
Result : Asu_Us;
Ptr : Integer := 1;
begin
Init (Result, Left * Right'Length);
for I in 1 .. Left loop
Result.Ref(Ptr .. Ptr + Right'Length - 1) := Right;
Ptr := Ptr + Right'Length;
end loop;
return Result;
end "*";
function "*" (Left : Natural; Right : Asu_Us) return Asu_Us is
Result : Asu_Us;
Ptr : Integer := 1;
begin
Init (Result, Left * Right.Last);
for I in 1 .. Left loop
Result.Ref(Ptr .. Ptr + Right.Last - 1) := Right.Ref(1 .. Right.Last);
Ptr := Ptr + Right.Last;
end loop;
return Result;
end "*";
-- Life cycle
overriding procedure Initialize (Object : in out Asu_Us) is
begin
Object.Ref := Null_Access;
Object.Last := 0;
end Initialize;
overriding procedure Adjust (Object : in out Asu_Us) is
begin
if Object.Ref /= Null_Access then
-- Real copy
Object.Ref := new String'(Object.Ref(1 .. Object.Last));
end if;
end Adjust;
overriding procedure Finalize (Object : in out Asu_Us) is
begin
Free (Object.Ref);
Object.Ref := Null_Access;
Object.Last := 0;
end Finalize;
end Mapcode_Utils.As_U;
|
-- Module : string_scanner_.ada
-- Component of : common_library
-- Version : 1.2
-- Date : 11/21/86 16:37:08
-- SCCS File : disk21~/rschm/hasee/sccs/common_library/sccs/sxstring_scanner_.ada
with String_Pkg; use String_Pkg;
package String_Scanner is
--| Functions for scanning tokens from strings.
pragma Page;
--| Overview
--| This package provides a set of functions used to scan tokens from
--| strings. After the function make_Scanner is called to convert a string
--| into a string Scanner, the following functions may be called to scan
--| various tokens from the string:
--|-
--| Make_Scanner Given a string returns a Scanner
--| Destroy_Scanner Free storage used by Scanner
--| More Return TRUE iff unscanned characters remain
--| Forward Bump the Scanner
--| Backward Bump back the Scanner
--| Get Return character
--| Next Return character and bump the Scanner
--| Get_String Return String_Type in Scanner
--| Get_Remainder Return String_Type in Scanner from current Index
--| Mark Mark the current Index for Restore
--| Restore Restore the previously marked Index
--| Position Return the current position of the Scanner
--| Is_Word Return TRUE iff Scanner is at a non-blank character
--| Scan_Word Return sequence of non blank characters
--| Is_Number Return TRUE iff Scanner is at a digit
--| Scan_Number (2) Return sequence of decimal digits
--| Is_Signed_Number Return TRUE iff Scanner is at a digit or sign
--| Scan_Signed_Number (2)
--| sequence of decimal digits with optional sign (+/-)
--| Is_Space Return TRUE iff Scanner is at a space or tab
--| Scan_Space Return sequence of spaces or tabs
--| Skip_Space Advance Scanner past white space
--| Is_Ada_Id Return TRUE iff Scanner is at first character of ada id
--| Scan_Ada_Id Scan an Ada identifier
--| Is_Quoted Return TRUE iff Scanner is at a double quote
--| Scan_Quoted Scan quoted string, embedded quotes doubled
--| Is_Enclosed Return TRUE iff Scanner is at an enclosing character
--| Scan_Enclosed Scan enclosed string, embedded enclosing character doubled
--| Is_Sequence Return TRUE iff Scanner is at some character in sequence
--| Scan_Sequence Scan user specified sequence of chars
--| Is_Not_Sequence Return TRUE iff Scanner is not at the characters in sequence
--| Scan_Not_Sequence Scan string up to but not including a given sequence of chars
--| Is_Literal Return TRUE iff Scanner is at literal
--| Scan_Literal Scan user specified literal
--| Is_Not_Literal Return TRUE iff Scanner is not a given literal
--| Scan_Not_Literal Scan string up to but not including a given literal
--|+
----------------------------------------------------------------
Out_Of_Bounds : exception; --| Raised when a operation is attempted on a
--| Scanner that has passed the end
Scanner_Already_Marked : exception;
--| Raised when a Mark is attemped on a Scanner
--| that has already been marked
----------------------------------------------------------------
type Scanner is private; --| Scanner type
----------------------------------------------------------------
pragma Page;
function Make_Scanner( --| Construct a Scanner from S.
S : in String_Type --| String to be scanned.
) return Scanner;
--| Effects: Construct a Scanner from S.
--| N/A: Raises, Modifies, Errors
----------------------------------------------------------------
procedure Destroy_Scanner( --| Free Scanner storage
T : in out Scanner --| Scanner to be freed
);
--| Effects: Free space occupied by the Scanner.
--| N/A: Raises, Modifies, Errors
----------------------------------------------------------------
function More( --| Check if Scanner is exhausted
T : in Scanner --| Scanner to check
) return boolean;
--| Effects: Return TRUE iff additional characters remain to be scanned.
--| N/A: Raises, Modifies, Errors
----------------------------------------------------------------
procedure Forward( --| Bump scanner
T : in Scanner --| Scanner
);
--| Effects: Update the scanner position.
--| N/A: Raises, Modifies, Errors
----------------------------------------------------------------
procedure Backward( --| Bump back scanner
T : in Scanner --| Scanner
);
--| Effects: Update the scanner position.
--| N/A: Raises, Modifies, Errors
----------------------------------------------------------------
function Get( --| Return character
T : in Scanner --| Scanner to check
) return character;
--| Raises: Out_Of_Bounds
--| Effects: Return character at the current Scanner position.
--| The scanner position remains unchanged.
--| N/A: Modifies, Errors
----------------------------------------------------------------
procedure Next( --| Return character and bump scanner
T : in Scanner; --| Scanner to check
C : out character --| Character to be returned
);
--| Raises: Out_Of_Bounds
--| Effects: Return character at the current Scanner position and update
--| the position.
--| N/A: Modifies, Errors
----------------------------------------------------------------
function Position( --| Return current Scanner position
T : in Scanner --| Scanner to check
) return positive;
--| Raises: Out_Of_Bounds
--| Effects: Return a positive integer indicating the current Scanner position,
--| N/A: Modifies, Errors
----------------------------------------------------------------
function Get_String( --| Return contents of Scanner
T : in Scanner --| Scanner
) return String_Type;
--| Effects: Return a String_Type corresponding to the contents of the Scanner
--| N/A: Raises, Modifies, Errors
----------------------------------------------------------------
function Get_Remainder( --| Return contents of Scanner from index
T : in Scanner
) return String_Type;
--| Effects: Return a String_Type starting at the current index of the Scanner
--| N/A: Raises, Modifies, Errors
----------------------------------------------------------------
procedure Mark(
T : in Scanner
);
--| Raises: Scanner_Already_Marked
--| Effects: Mark the current index for possible future use
--| N/A: Modifies, Errors
----------------------------------------------------------------
procedure Restore(
T : in Scanner
);
--| Effects: Restore the index to the previously marked value
--| N/A: Raises, Modifies, Errors
----------------------------------------------------------------
pragma Page;
function Is_Word( --| Check if Scanner is at the start of a word.
T : in Scanner --| Scanner to check
) return boolean;
--| Effects: Return TRUE iff Scanner is at the start of a word.
--| N/A: Raises, Modifies, Errors
----------------------------------------------------------------
procedure Scan_word( --| Scan sequence of non blank characters
T : in Scanner; --| String to be scanned
Found : out boolean; --| TRUE iff a word found
Result : out String_Type;--| Word scanned from string
Skip : in boolean := false
--| Skip white spaces before scan
);
--| Effects: Scan T for a sequence of non blank
--| characters. If at least one is found, return Found => TRUE,
--| Result => <the characters>.
--| Otherwise return Found => FALSE and Result is unpredictable.
--| N/A: Raises, Modifies, Errors
pragma Page;
function Is_Number( --| Return TRUE iff Scanner is at a decimal digit
T : in Scanner --| The string being scanned
) return boolean;
--| Effects: Return TRUE iff Scan_Number would return a non-null string.
--| N/A: Raises, Modifies, Errors
----------------------------------------------------------------
procedure Scan_Number( --| Scan sequence of digits
T : in Scanner; --| String to be scanned
Found : out boolean; --| TRUE iff one or more digits found
Result : out String_Type;--| Number scanned from string
Skip : in boolean := false
--| Skip white spaces before scan
);
--| Effects: Scan T for a sequence of digits.
--| If at least one is found, return Found => TRUE, Result => <the digits>.
--| Otherwise return Found => FALSE and Result is unpredictable.
--| Modifies: Raises, Modifies, Errors
----------------------------------------------------------------
procedure Scan_Number( --| Scan sequence of digits
T : in Scanner; --| String to be scanned
Found : out boolean; --| TRUE iff one or more digits found
Result : out integer; --| Number scanned from string
Skip : in boolean := false
--| Skip white spaces before scan
);
--| Effects: Scan T for a sequence of digits.
--| If at least one is found, return Found => TRUE, Result => <the digits>.
--| Otherwise return Found => FALSE and Result is unpredictable.
--| Modifies: Raises, Modifies, Errors
pragma Page;
function Is_Signed_Number( --| Check if Scanner is at a decimal digit or
--| sign (+/-)
T : in Scanner --| The string being scanned
) return boolean;
--| Effects: Return TRUE iff Scan_Signed_Number would return a non-null
--| string.
--| N/A: Raises, Modifies, Errors
----------------------------------------------------------------
procedure Scan_Signed_Number( --| Scan signed sequence of digits
T : in Scanner; --| String to be scanned
Found : out boolean; --| TRUE iff one or more digits found
Result : out String_Type;--| Number scanned from string
Skip : in boolean := false
--| Skip white spaces before scan
);
--| Effects: Scan T for a sequence of digits preceeded with optional sign.
--| If at least one digit is found, return Found => TRUE,
--| Result => <the digits>.
--| Otherwise return Found => FALSE and Result is unpredictable.
--| Modifies: Raises, Modifies, Errors
----------------------------------------------------------------
procedure Scan_Signed_Number( --| Scan signed sequence of digits
T : in Scanner; --| String to be scanned
Found : out boolean; --| TRUE iff one or more digits found
Result : out integer; --| Number scanned from string
Skip : in boolean := false
--| Skip white spaces before scan
);
--| Effects: Scan T for a sequence of digits preceeded with optional sign.
--| If at least one digit is found, return Found => TRUE,
--| Result => <the digits>.
--| Otherwise return Found => FALSE and Result is unpredictable.
--| Modifies: Raises, Modifies, Errors
pragma Page;
function Is_Space( --| Check if T is at a space or tab
T : in Scanner --| The string being scanned
) return boolean;
--| Effects: Return TRUE iff Scan_Space would return a non-null string.
--| Modifies: Raises, Modifies, Errors
----------------------------------------------------------------
procedure Scan_Space( --| Scan sequence of white space characters
T : in Scanner; --| String to be scanned
Found : out boolean; --| TRUE iff space found
Result : out String_Type --| Spaces scanned from string
);
--| Effects: Scan T past all white space (spaces
--| and tabs. If at least one is found, return Found => TRUE,
--| Result => <the characters>.
--| Otherwise return Found => FALSE and Result is unpredictable.
--| Modifies: Raises, Modifies, Errors
----------------------------------------------------------------
procedure Skip_Space( --| Skip white space
T : in Scanner --| String to be scanned
);
--| Effects: Scan T past all white space (spaces and tabs).
--| Modifies: Raises, Modifies, Errors
pragma Page;
function Is_Ada_Id( --| Check if T is at an Ada identifier
T : in Scanner --| The string being scanned
) return boolean;
--| Effects: Return TRUE iff Scan_Ada_Id would return a non-null string.
--| Modifies: Raises, Modifies, Errors
----------------------------------------------------------------
procedure Scan_Ada_Id( --| Scan Ada identifier
T : in Scanner; --| String to be scanned
Found : out boolean; --| TRUE iff an Ada identifier found
Result : out String_Type;--| Identifier scanned from string
Skip : in boolean := false
--| Skip white spaces before scan
);
--| Effects: Scan T for a valid Ada identifier.
--| If one is found, return Found => TRUE, Result => <the characters>.
--| Otherwise return Found => FALSE and Result is unpredictable.
--| Modifies: Raises, Modifies, Errors
pragma Page;
function Is_Quoted( --| Check if T is at a double quote
T : in Scanner --| The string being scanned
) return boolean;
--| Effects: Return TRUE iff T is at a quoted string (eg. ... "Hello" ...).
--| Modifies: Raises, Modifies, Errors
----------------------------------------------------------------
procedure Scan_Quoted( --| Scan a quoted string
T : in Scanner; --| String to be scanned
Found : out boolean; --| TRUE iff a quoted string found
Result : out String_Type;--| Quoted string scanned from string
Skip : in boolean := false
--| Skip white spaces before scan
);
--| Effects: Scan at T for an opening quote
--| followed by a sequence of characters and ending with a closing
--| quote. If successful, return Found => TRUE, Result => <the characters>.
--| Otherwise return Found => FALSE and Result is unpredictable.
--| A pair of quotes within the quoted string is converted to a single quote.
--| The outer quotes are stripped.
--| Modifies: Raises, Modifies, Errors
pragma Page;
function Is_Enclosed( --| Check if T is at an enclosing character
B : in character; --| Enclosing open character
E : in character; --| Enclosing close character
T : in Scanner --| The string being scanned
) return boolean;
--| Effects: Return TRUE iff T as encosed by B and E (eg. ... [ABC] ...).
--| Modifies: Raises, Modifies, Errors
----------------------------------------------------------------
procedure Scan_Enclosed( --| Scan an enclosed string
B : in character; --| Enclosing open character
E : in character; --| Enclosing close character
T : in Scanner; --| String to be scanned
Found : out boolean; --| TRUE iff a quoted string found
Result : out String_Type;--| Quoted string scanned from string
Skip : in boolean := false
--| Skip white spaces before scan
);
--| Effects: Scan at T for an enclosing character
--| followed by a sequence of characters and ending with an enclosing character.
--| If successful, return Found => TRUE, Result => <the characters>.
--| Otherwise return Found => FALSE and Result is unpredictable.
--| The enclosing characters are stripped.
--| Modifies: Raises, Modifies, Errors
pragma Page;
function Is_Sequence( --| Check if T is at some sequence characters
Chars : in String_Type; --| Characters to be scanned
T : in Scanner --| The string being scanned
) return boolean;
--| Effects: Return TRUE iff T is at some character of Chars.
--| Modifies: Raises, Modifies, Errors
----------------------------------------------------------------
function Is_Sequence( --| Check if T is at some sequence characters
Chars : in string; --| Characters to be scanned
T : in Scanner --| The string being scanned
) return boolean;
--| Effects: Return TRUE iff T is at some character of Chars.
--| Modifies: Raises, Modifies, Errors
----------------------------------------------------------------
procedure Scan_Sequence( --| Scan arbitrary sequence of characters
Chars : in String_Type;--| Characters that should be scanned
T : in Scanner; --| String to be scanned
Found : out boolean; --| TRUE iff a sequence found
Result : out String_Type;--| Sequence scanned from string
Skip : in boolean := false
--| Skip white spaces before scan
);
--| Effects: Scan T for a sequence of characters C such that C appears in
--| Char. If at least one is found, return Found => TRUE,
--| Result => <the characters>.
--| Otherwise return Found => FALSE and Result is unpredictable.
--| Modifies: Raises, Modifies, Errors
--| Notes:
--| Scan_Sequence("0123456789", S, Index, Found, Result)
--| is equivalent to Scan_Number(S, Index, Found, Result)
--| but is less efficient.
----------------------------------------------------------------
procedure Scan_Sequence( --| Scan arbitrary sequence of characters
Chars : in string; --| Characters that should be scanned
T : in Scanner; --| String to be scanned
Found : out boolean; --| TRUE iff a sequence found
Result : out String_Type;--| Sequence scanned from string
Skip : in boolean := false
--| Skip white spaces before scan
);
--| Effects: Scan T for a sequence of characters C such that C appears in
--| Char. If at least one is found, return Found => TRUE,
--| Result => <the characters>.
--| Otherwise return Found => FALSE and Result is unpredictable.
--| Modifies: Raises, Modifies, Errors
--| Notes:
--| Scan_Sequence("0123456789", S, Index, Found, Result)
--| is equivalent to Scan_Number(S, Index, Found, Result)
--| but is less efficient.
pragma Page;
function Is_Not_Sequence( --| Check if T is not at some seuqnce of character
Chars : in String_Type; --| Characters to be scanned
T : in Scanner --| The string being scanned
) return boolean;
--| Effects: Return TRUE iff T is not at some character of Chars.
--| Modifies: Raises, Modifies, Errors
----------------------------------------------------------------
function Is_Not_Sequence( --| Check if T is at some sequence of characters
Chars : in string; --| Characters to be scanned
T : in Scanner --| The string being scanned
) return boolean;
--| Effects: Return TRUE iff T is not at some character of Chars.
--| Modifies: Raises, Modifies, Errors
----------------------------------------------------------------
procedure Scan_Not_Sequence( --| Scan arbitrary sequence of characters
Chars : in String_Type;--| Characters that should be scanned
T : in Scanner; --| String to be scanned
Found : out boolean; --| TRUE iff a sequence found
Result : out String_Type;--| Sequence scanned from string
Skip : in boolean := false
--| Skip white spaces before scan
);
--| Effects: Scan T for a sequence of characters C such that C does not appear
--| in Chars. If at least one such C is found, return Found => TRUE,
--| Result => <the characters>.
--| Otherwise return Found => FALSE and Result is unpredictable.
--| Modifies: Raises, Modifies, Errors
----------------------------------------------------------------
procedure Scan_Not_Sequence( --| Scan arbitrary sequence of characters
Chars : in string; --| Characters that should be scanned
T : in Scanner; --| String to be scanned
Found : out boolean; --| TRUE iff a sequence found
Result : out String_Type;--| Sequence scanned from string
Skip : in boolean := false
--| Skip white spaces before scan
);
--| Effects: Scan T for a sequence of characters C such that C does not appear
--| in Chars. If at least one such C is found, return Found => TRUE,
--| Result => <the characters>.
--| Otherwise return Found => FALSE and Result is unpredictable.
--| Modifies: Raises, Modifies, Errors
pragma Page;
function Is_Literal( --| Check if T is at literal Chars
Chars : in String_Type; --| Characters to be scanned
T : in Scanner --| The string being scanned
) return boolean;
--| Effects: Return TRUE iff T is at literal Chars.
--| Modifies: Raises, Modifies, Errors
----------------------------------------------------------------
function Is_Literal( --| Check if T is at literal Chars
Chars : in string; --| Characters to be scanned
T : in Scanner --| The string being scanned
) return boolean;
--| Effects: Return TRUE iff T is at literal Chars.
--| Modifies: Raises, Modifies, Errors
----------------------------------------------------------------
procedure Scan_Literal( --| Scan arbitrary literal
Chars : in String_Type;--| Literal that should be scanned
T : in Scanner; --| String to be scanned
Found : out boolean; --| TRUE iff a sequence found
Skip : in boolean := false
--| Skip white spaces before scan
);
--| Effects: Scan T for a litral Chars such that Char matches the sequence
--| of characters in T. If found, return Found => TRUE,
--| Otherwise return Found => FALSE
--| Modifies: Raises, Modifies, Errors
----------------------------------------------------------------
procedure Scan_Literal( --| Scan arbitrary literal
Chars : in string; --| Literal that should be scanned
T : in Scanner; --| String to be scanned
Found : out boolean; --| TRUE iff a sequence found
Skip : in boolean := false
--| Skip white spaces before scan
);
--| Effects: Scan T for a litral Chars such that Char matches the sequence
--| of characters in T. If found, return Found => TRUE,
--| Otherwise return Found => FALSE
--| Modifies: Raises, Modifies, Errors
pragma Page;
function Is_Not_Literal( --| Check if T is not at literal Chars
Chars : in string; --| Characters to be scanned
T : in Scanner --| The string being scanned
) return boolean;
--| Effects: Return TRUE iff T is not at literal Chars
--| Modifies: Raises, Modifies, Errors
----------------------------------------------------------------
function Is_Not_Literal( --| Check if T is not at literal Chars
Chars : in String_Type; --| Characters to be scanned
T : in Scanner --| The string being scanned
) return boolean;
--| Effects: Return TRUE iff T is not at literal Chars
--| Modifies: Raises, Modifies, Errors
----------------------------------------------------------------
procedure Scan_Not_Literal( --| Scan arbitrary literal
Chars : in string; --| Literal that should be scanned
T : in Scanner; --| String to be scanned
Found : out boolean; --| TRUE iff a sequence found
Result : out String_Type;--| String up to literal
Skip : in boolean := false
--| Skip white spaces before scan
);
--| Effects: Scan T for a litral Chars such that Char does not match the
--| sequence of characters in T. If found, return Found => TRUE,
--| Otherwise return Found => FALSE
--| Modifies: Raises, Modifies, Errors
----------------------------------------------------------------
procedure Scan_Not_Literal( --| Scan arbitrary literal
Chars : in String_Type;--| Literal that should be scanned
T : in Scanner; --| String to be scanned
Found : out boolean; --| TRUE iff a sequence found
Result : out String_Type;--| String up to literal
Skip : in boolean := false
--| Skip white spaces before scan
);
--| Effects: Scan T for a litral Chars such that Char does not match the
--| sequence of characters in T. If found, return Found => TRUE,
--| Otherwise return Found => FALSE
--| Modifies: Raises, Modifies, Errors
pragma Page;
private
pragma List(off);
type Scan_Record is
record
text : String_Type; --| Copy of string being scanned
index : positive := 1; --| Current position of Scanner
mark : natural := 0; --| Mark
end record;
type Scanner is access Scan_Record;
pragma List(on);
end String_Scanner;
pragma Page;
|
-- C46054A.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT CONSTRAINT_ERROR IS RAISED FOR CONVERSION TO AN
-- ACCESS SUBTYPE IF THE OPERAND VALUE IS NOT NULL AND THE
-- DISCRIMINANTS OR INDEX BOUNDS OF THE DESIGNATED OBJECT DO NOT
-- MATCH THOSE OF THE TARGET TYPE.
-- R.WILLIAMS 9/9/86
WITH REPORT; USE REPORT;
PROCEDURE C46054A IS
BEGIN
TEST ( "C46054A", "CHECK THAT CONSTRAINT_ERROR IS RAISED FOR " &
"CONVERSION TO AN ACCESS SUBTYPE IF THE " &
"OPERAND VALUE IS NOT NULL AND THE " &
"DISCRIMINANTS OR INDEX BOUNDS OF THE " &
"DESIGNATED OBJECT DO NOT MATCH THOSE OF " &
"THE TARGET TYPE" );
DECLARE
TYPE REC (D : INTEGER) IS
RECORD
NULL;
END RECORD;
TYPE ACREC IS ACCESS REC;
A : ACREC (IDENT_INT (0)) := NEW REC (IDENT_INT (0));
SUBTYPE ACREC3 IS ACREC (IDENT_INT (3));
PROCEDURE PROC (A : ACREC) IS
I : INTEGER;
BEGIN
I := IDENT_INT (A.D);
END PROC;
BEGIN
PROC (ACREC3 (A));
FAILED ( "NO EXCEPTION RAISED FOR 'ACREC3 (A)'" );
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ( "WRONG EXCEPTION RAISED FOR 'ACREC3 (A)'" );
END;
DECLARE
TYPE REC (D1, D2 : INTEGER) IS
RECORD
NULL;
END RECORD;
TYPE ACREC IS ACCESS REC;
A : ACREC (IDENT_INT (3), IDENT_INT (1)) :=
NEW REC (IDENT_INT (3), IDENT_INT (1));
SUBTYPE ACREC13 IS ACREC (IDENT_INT (1), IDENT_INT (3));
PROCEDURE PROC (A : ACREC) IS
I : INTEGER;
BEGIN
I := IDENT_INT (A.D1);
END PROC;
BEGIN
PROC (ACREC13 (A));
FAILED ( "NO EXCEPTION RAISED FOR 'ACREC13 (A)'" );
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ( "WRONG EXCEPTION RAISED FOR 'ACREC13 (A)'" );
END;
DECLARE
TYPE ARR IS ARRAY (INTEGER RANGE <>) OF INTEGER;
TYPE ACARR IS ACCESS ARR;
A : ACARR (IDENT_INT (0) .. IDENT_INT (1)) :=
NEW ARR'(IDENT_INT (0) .. IDENT_INT (1) => 0);
SUBTYPE ACARR02 IS ACARR (IDENT_INT (0) .. IDENT_INT (2));
PROCEDURE PROC (A : ACARR) IS
I : INTEGER;
BEGIN
I := IDENT_INT (A'LAST);
END PROC;
BEGIN
PROC (ACARR02 (A));
FAILED ( "NO EXCEPTION RAISED FOR 'ACARR02 (A)'" );
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ( "WRONG EXCEPTION RAISED FOR 'ACARR02 (A)'" );
END;
DECLARE
TYPE ARR IS ARRAY (INTEGER RANGE <>, INTEGER RANGE <>) OF
INTEGER;
TYPE ACARR IS ACCESS ARR;
A : ACARR (IDENT_INT (1) .. IDENT_INT (0),
IDENT_INT (4) .. IDENT_INT (5)) :=
NEW ARR'(IDENT_INT (1) .. IDENT_INT (0) =>
(IDENT_INT (4) .. IDENT_INT (5) => 0));
SUBTYPE NACARR IS ACARR (IDENT_INT (0) .. IDENT_INT (1),
IDENT_INT (5) .. IDENT_INT (4));
PROCEDURE PROC (A : NACARR) IS
I : INTEGER;
BEGIN
I := IDENT_INT (A'LAST (1));
END PROC;
BEGIN
PROC (NACARR (A));
FAILED ( "NO EXCEPTION RAISED FOR 'NACARR (A)'" );
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ( "WRONG EXCEPTION RAISED FOR 'NACARR (A)'" );
END;
DECLARE
PACKAGE PKG1 IS
TYPE PRIV (D : INTEGER) IS PRIVATE;
TYPE ACPRV IS ACCESS PRIV;
SUBTYPE ACPRV3 IS ACPRV (IDENT_INT (3));
PRIVATE
TYPE PRIV (D : INTEGER) IS
RECORD
NULL;
END RECORD;
END PKG1;
USE PKG1;
PACKAGE PKG2 IS
A : ACPRV (IDENT_INT (0)) := NEW PRIV (IDENT_INT (0));
END PKG2;
USE PKG2;
PROCEDURE PROC (A : ACPRV) IS
I : INTEGER;
BEGIN
I := IDENT_INT (A.D);
END PROC;
BEGIN
PROC (ACPRV3 (A));
FAILED ( "NO EXCEPTION RAISED FOR 'ACPRV3 (A)'" );
EXCEPTION
WHEN CONSTRAINT_ERROR =>
NULL;
WHEN OTHERS =>
FAILED ( "WRONG EXCEPTION RAISED FOR 'ACPRV3 (A)'" );
END;
RESULT;
END C46054A;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- P R J . P R O C --
-- --
-- B o d y --
-- --
-- Copyright (C) 2001-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. 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 Atree; use Atree;
with Err_Vars; use Err_Vars;
with Opt; use Opt;
with Osint; use Osint;
with Output; use Output;
with Prj.Attr; use Prj.Attr;
with Prj.Env;
with Prj.Err; use Prj.Err;
with Prj.Ext; use Prj.Ext;
with Prj.Nmsc; use Prj.Nmsc;
with Prj.Part;
with Prj.Util;
with Snames;
with Ada.Containers.Vectors;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with GNAT.Case_Util; use GNAT.Case_Util;
with GNAT.HTable;
package body Prj.Proc is
package Processed_Projects is new GNAT.HTable.Simple_HTable
(Header_Num => Header_Num,
Element => Project_Id,
No_Element => No_Project,
Key => Name_Id,
Hash => Hash,
Equal => "=");
-- This hash table contains all processed projects
package Unit_Htable is new GNAT.HTable.Simple_HTable
(Header_Num => Header_Num,
Element => Source_Id,
No_Element => No_Source,
Key => Name_Id,
Hash => Hash,
Equal => "=");
-- This hash table contains all processed projects
package Runtime_Defaults is new GNAT.HTable.Simple_HTable
(Header_Num => Prj.Header_Num,
Element => Name_Id,
No_Element => No_Name,
Key => Name_Id,
Hash => Prj.Hash,
Equal => "=");
-- Stores the default values of 'Runtime names for the various languages
package Name_Ids is new Ada.Containers.Vectors (Positive, Name_Id);
procedure Add (To_Exp : in out Name_Id; Str : Name_Id);
-- Concatenate two strings and returns another string if both
-- arguments are not null string.
-- In the following procedures, we are expected to guess the meaning of
-- the parameters from their names, this is never a good idea, comments
-- should be added precisely defining every formal ???
procedure Add_Attributes
(Project : Project_Id;
Project_Name : Name_Id;
Project_Dir : Name_Id;
Shared : Shared_Project_Tree_Data_Access;
Decl : in out Declarations;
First : Attribute_Node_Id;
Project_Level : Boolean);
-- Add all attributes, starting with First, with their default values to
-- the package or project with declarations Decl.
procedure Check
(In_Tree : Project_Tree_Ref;
Project : Project_Id;
Node_Tree : Prj.Tree.Project_Node_Tree_Ref;
Flags : Processing_Flags);
-- Set all projects to not checked, then call Recursive_Check for the
-- main project Project. Project is set to No_Project if errors occurred.
-- Current_Dir is for optimization purposes, avoiding extra system calls.
-- If Allow_Duplicate_Basenames, then files with the same base names are
-- authorized within a project for source-based languages (never for unit
-- based languages)
procedure Copy_Package_Declarations
(From : Declarations;
To : in out Declarations;
New_Loc : Source_Ptr;
Restricted : Boolean;
Shared : Shared_Project_Tree_Data_Access);
-- Copy a package declaration From to To for a renamed package. Change the
-- locations of all the attributes to New_Loc. When Restricted is
-- True, do not copy attributes Body, Spec, Implementation, Specification
-- and Linker_Options.
function Expression
(Project : Project_Id;
Shared : Shared_Project_Tree_Data_Access;
From_Project_Node : Project_Node_Id;
From_Project_Node_Tree : Project_Node_Tree_Ref;
Env : Prj.Tree.Environment;
Pkg : Package_Id;
First_Term : Project_Node_Id;
Kind : Variable_Kind) return Variable_Value;
-- From N_Expression project node From_Project_Node, compute the value
-- of an expression and return it as a Variable_Value.
function Imported_Or_Extended_Project_From
(Project : Project_Id;
With_Name : Name_Id;
No_Extending : Boolean := False) return Project_Id;
-- Find an imported or extended project of Project whose name is With_Name.
-- When No_Extending is True, do not look for extending projects, returns
-- the exact project whose name is With_Name.
function Package_From
(Project : Project_Id;
Shared : Shared_Project_Tree_Data_Access;
With_Name : Name_Id) return Package_Id;
-- Find the package of Project whose name is With_Name
procedure Process_Declarative_Items
(Project : Project_Id;
In_Tree : Project_Tree_Ref;
From_Project_Node : Project_Node_Id;
Node_Tree : Project_Node_Tree_Ref;
Env : Prj.Tree.Environment;
Pkg : Package_Id;
Item : Project_Node_Id;
Child_Env : in out Prj.Tree.Environment);
-- Process declarative items starting with From_Project_Node, and put them
-- in declarations Decl. This is a recursive procedure; it calls itself for
-- a package declaration or a case construction.
--
-- Child_Env is the modified environment after seeing declarations like
-- "for External(...) use" or "for Project_Path use" in aggregate projects.
-- It should have been initialized first.
procedure Recursive_Process
(In_Tree : Project_Tree_Ref;
Project : out Project_Id;
Packages_To_Check : String_List_Access;
From_Project_Node : Project_Node_Id;
From_Project_Node_Tree : Project_Node_Tree_Ref;
Env : in out Prj.Tree.Environment;
Extended_By : Project_Id;
From_Encapsulated_Lib : Boolean;
On_New_Tree_Loaded : Tree_Loaded_Callback := null);
-- Process project with node From_Project_Node in the tree. Do nothing if
-- From_Project_Node is Empty_Node. If project has already been processed,
-- simply return its project id. Otherwise create a new project id, mark it
-- as processed, call itself recursively for all imported projects and a
-- extended project, if any. Then process the declarative items of the
-- project.
--
-- Is_Root_Project should be true only for the project that the user
-- explicitly loaded. In the context of aggregate projects, only that
-- project is allowed to modify the environment that will be used to load
-- projects (Child_Env).
--
-- From_Encapsulated_Lib is true if we are parsing a project from
-- encapsulated library dependencies.
--
-- If specified, On_New_Tree_Loaded is called after each aggregated project
-- has been processed succesfully.
function Get_Attribute_Index
(Tree : Project_Node_Tree_Ref;
Attr : Project_Node_Id;
Index : Name_Id) return Name_Id;
-- Copy the index of the attribute into Name_Buffer, converting to lower
-- case if the attribute is case-insensitive.
---------
-- Add --
---------
procedure Add (To_Exp : in out Name_Id; Str : Name_Id) is
begin
if To_Exp = No_Name or else To_Exp = Empty_String then
-- To_Exp is nil or empty. The result is Str
To_Exp := Str;
-- If Str is nil, then do not change To_Ext
elsif Str /= No_Name and then Str /= Empty_String then
declare
S : constant String := Get_Name_String (Str);
begin
Get_Name_String (To_Exp);
Add_Str_To_Name_Buffer (S);
To_Exp := Name_Find;
end;
end if;
end Add;
--------------------
-- Add_Attributes --
--------------------
procedure Add_Attributes
(Project : Project_Id;
Project_Name : Name_Id;
Project_Dir : Name_Id;
Shared : Shared_Project_Tree_Data_Access;
Decl : in out Declarations;
First : Attribute_Node_Id;
Project_Level : Boolean)
is
The_Attribute : Attribute_Node_Id := First;
begin
while The_Attribute /= Empty_Attribute loop
if Attribute_Kind_Of (The_Attribute) = Single then
declare
New_Attribute : Variable_Value;
begin
case Variable_Kind_Of (The_Attribute) is
-- Undefined should not happen
when Undefined =>
pragma Assert
(False, "attribute with an undefined kind");
raise Program_Error;
-- Single attributes have a default value of empty string
when Single =>
New_Attribute :=
(Project => Project,
Kind => Single,
Location => No_Location,
Default => True,
Value => Empty_String,
Index => 0);
-- Special cases of <project>'Name and
-- <project>'Project_Dir.
if Project_Level then
if Attribute_Name_Of (The_Attribute) =
Snames.Name_Name
then
New_Attribute.Value := Project_Name;
elsif Attribute_Name_Of (The_Attribute) =
Snames.Name_Project_Dir
then
New_Attribute.Value := Project_Dir;
end if;
end if;
-- List attributes have a default value of nil list
when List =>
New_Attribute :=
(Project => Project,
Kind => List,
Location => No_Location,
Default => True,
Values => Nil_String);
end case;
Variable_Element_Table.Increment_Last
(Shared.Variable_Elements);
Shared.Variable_Elements.Table
(Variable_Element_Table.Last (Shared.Variable_Elements)) :=
(Next => Decl.Attributes,
Name => Attribute_Name_Of (The_Attribute),
Value => New_Attribute);
Decl.Attributes :=
Variable_Element_Table.Last
(Shared.Variable_Elements);
end;
end if;
The_Attribute := Next_Attribute (After => The_Attribute);
end loop;
end Add_Attributes;
-----------
-- Check --
-----------
procedure Check
(In_Tree : Project_Tree_Ref;
Project : Project_Id;
Node_Tree : Prj.Tree.Project_Node_Tree_Ref;
Flags : Processing_Flags)
is
begin
Process_Naming_Scheme (In_Tree, Project, Node_Tree, Flags);
-- Set the Other_Part field for the units
declare
Source1 : Source_Id;
Name : Name_Id;
Source2 : Source_Id;
Iter : Source_Iterator;
begin
Unit_Htable.Reset;
Iter := For_Each_Source (In_Tree);
loop
Source1 := Prj.Element (Iter);
exit when Source1 = No_Source;
if Source1.Unit /= No_Unit_Index then
Name := Source1.Unit.Name;
Source2 := Unit_Htable.Get (Name);
if Source2 = No_Source then
Unit_Htable.Set (K => Name, E => Source1);
else
Unit_Htable.Remove (Name);
end if;
end if;
Next (Iter);
end loop;
end;
end Check;
-------------------------------
-- Copy_Package_Declarations --
-------------------------------
procedure Copy_Package_Declarations
(From : Declarations;
To : in out Declarations;
New_Loc : Source_Ptr;
Restricted : Boolean;
Shared : Shared_Project_Tree_Data_Access)
is
V1 : Variable_Id;
V2 : Variable_Id := No_Variable;
Var : Variable;
A1 : Array_Id;
A2 : Array_Id := No_Array;
Arr : Array_Data;
E1 : Array_Element_Id;
E2 : Array_Element_Id := No_Array_Element;
Elm : Array_Element;
begin
-- To avoid references in error messages to attribute declarations in
-- an original package that has been renamed, copy all the attribute
-- declarations of the package and change all locations to New_Loc,
-- the location of the renamed package.
-- First single attributes
V1 := From.Attributes;
while V1 /= No_Variable loop
-- Copy the attribute
Var := Shared.Variable_Elements.Table (V1);
V1 := Var.Next;
-- Do not copy the value of attribute Linker_Options if Restricted
if Restricted and then Var.Name = Snames.Name_Linker_Options then
Var.Value.Values := Nil_String;
end if;
-- Remove the Next component
Var.Next := No_Variable;
-- Change the location to New_Loc
Var.Value.Location := New_Loc;
Variable_Element_Table.Increment_Last (Shared.Variable_Elements);
-- Put in new declaration
if To.Attributes = No_Variable then
To.Attributes :=
Variable_Element_Table.Last (Shared.Variable_Elements);
else
Shared.Variable_Elements.Table (V2).Next :=
Variable_Element_Table.Last (Shared.Variable_Elements);
end if;
V2 := Variable_Element_Table.Last (Shared.Variable_Elements);
Shared.Variable_Elements.Table (V2) := Var;
end loop;
-- Then the associated array attributes
A1 := From.Arrays;
while A1 /= No_Array loop
Arr := Shared.Arrays.Table (A1);
A1 := Arr.Next;
-- Remove the Next component
Arr.Next := No_Array;
Array_Table.Increment_Last (Shared.Arrays);
-- Create new Array declaration
if To.Arrays = No_Array then
To.Arrays := Array_Table.Last (Shared.Arrays);
else
Shared.Arrays.Table (A2).Next :=
Array_Table.Last (Shared.Arrays);
end if;
A2 := Array_Table.Last (Shared.Arrays);
-- Don't store the array as its first element has not been set yet
-- Copy the array elements of the array
E1 := Arr.Value;
Arr.Value := No_Array_Element;
while E1 /= No_Array_Element loop
-- Copy the array element
Elm := Shared.Array_Elements.Table (E1);
E1 := Elm.Next;
-- Remove the Next component
Elm.Next := No_Array_Element;
Elm.Restricted := Restricted;
-- Change the location
Elm.Value.Location := New_Loc;
Array_Element_Table.Increment_Last (Shared.Array_Elements);
-- Create new array element
if Arr.Value = No_Array_Element then
Arr.Value := Array_Element_Table.Last (Shared.Array_Elements);
else
Shared.Array_Elements.Table (E2).Next :=
Array_Element_Table.Last (Shared.Array_Elements);
end if;
E2 := Array_Element_Table.Last (Shared.Array_Elements);
Shared.Array_Elements.Table (E2) := Elm;
end loop;
-- Finally, store the new array
Shared.Arrays.Table (A2) := Arr;
end loop;
end Copy_Package_Declarations;
-------------------------
-- Get_Attribute_Index --
-------------------------
function Get_Attribute_Index
(Tree : Project_Node_Tree_Ref;
Attr : Project_Node_Id;
Index : Name_Id) return Name_Id
is
begin
if Index = All_Other_Names
or else not Case_Insensitive (Attr, Tree)
then
return Index;
end if;
Get_Name_String (Index);
To_Lower (Name_Buffer (1 .. Name_Len));
return Name_Find;
end Get_Attribute_Index;
----------------
-- Expression --
----------------
function Expression
(Project : Project_Id;
Shared : Shared_Project_Tree_Data_Access;
From_Project_Node : Project_Node_Id;
From_Project_Node_Tree : Project_Node_Tree_Ref;
Env : Prj.Tree.Environment;
Pkg : Package_Id;
First_Term : Project_Node_Id;
Kind : Variable_Kind) return Variable_Value
is
The_Term : Project_Node_Id;
-- The term in the expression list
The_Current_Term : Project_Node_Id := Empty_Node;
-- The current term node id
Result : Variable_Value (Kind => Kind);
-- The returned result
Last : String_List_Id := Nil_String;
-- Reference to the last string elements in Result, when Kind is List
Current_Term_Kind : Project_Node_Kind;
begin
Result.Project := Project;
Result.Location := Location_Of (First_Term, From_Project_Node_Tree);
-- Process each term of the expression, starting with First_Term
The_Term := First_Term;
while Present (The_Term) loop
The_Current_Term := Current_Term (The_Term, From_Project_Node_Tree);
if The_Current_Term /= Empty_Node then
Current_Term_Kind :=
Kind_Of (The_Current_Term, From_Project_Node_Tree);
case Current_Term_Kind is
when N_Literal_String =>
case Kind is
when Undefined =>
-- Should never happen
pragma Assert (False, "Undefined expression kind");
raise Program_Error;
when Single =>
Add (Result.Value,
String_Value_Of
(The_Current_Term, From_Project_Node_Tree));
Result.Index :=
Source_Index_Of
(The_Current_Term, From_Project_Node_Tree);
when List =>
String_Element_Table.Increment_Last
(Shared.String_Elements);
if Last = Nil_String then
-- This can happen in an expression like () & "toto"
Result.Values := String_Element_Table.Last
(Shared.String_Elements);
else
Shared.String_Elements.Table
(Last).Next := String_Element_Table.Last
(Shared.String_Elements);
end if;
Last := String_Element_Table.Last
(Shared.String_Elements);
Shared.String_Elements.Table (Last) :=
(Value => String_Value_Of
(The_Current_Term,
From_Project_Node_Tree),
Index => Source_Index_Of
(The_Current_Term,
From_Project_Node_Tree),
Display_Value => No_Name,
Location => Location_Of
(The_Current_Term,
From_Project_Node_Tree),
Flag => False,
Next => Nil_String);
end case;
when N_Literal_String_List =>
declare
String_Node : Project_Node_Id :=
First_Expression_In_List
(The_Current_Term,
From_Project_Node_Tree);
Value : Variable_Value;
begin
if Present (String_Node) then
-- If String_Node is nil, it is an empty list, there is
-- nothing to do.
Value := Expression
(Project => Project,
Shared => Shared,
From_Project_Node => From_Project_Node,
From_Project_Node_Tree => From_Project_Node_Tree,
Env => Env,
Pkg => Pkg,
First_Term =>
Tree.First_Term
(String_Node, From_Project_Node_Tree),
Kind => Single);
String_Element_Table.Increment_Last
(Shared.String_Elements);
if Result.Values = Nil_String then
-- This literal string list is the first term in a
-- string list expression
Result.Values :=
String_Element_Table.Last
(Shared.String_Elements);
else
Shared.String_Elements.Table (Last).Next :=
String_Element_Table.Last (Shared.String_Elements);
end if;
Last :=
String_Element_Table.Last (Shared.String_Elements);
Shared.String_Elements.Table (Last) :=
(Value => Value.Value,
Display_Value => No_Name,
Location => Value.Location,
Flag => False,
Next => Nil_String,
Index => Value.Index);
loop
-- Add the other element of the literal string list
-- one after the other.
String_Node :=
Next_Expression_In_List
(String_Node, From_Project_Node_Tree);
exit when No (String_Node);
Value :=
Expression
(Project => Project,
Shared => Shared,
From_Project_Node => From_Project_Node,
From_Project_Node_Tree => From_Project_Node_Tree,
Env => Env,
Pkg => Pkg,
First_Term =>
Tree.First_Term
(String_Node, From_Project_Node_Tree),
Kind => Single);
String_Element_Table.Increment_Last
(Shared.String_Elements);
Shared.String_Elements.Table (Last).Next :=
String_Element_Table.Last (Shared.String_Elements);
Last := String_Element_Table.Last
(Shared.String_Elements);
Shared.String_Elements.Table (Last) :=
(Value => Value.Value,
Display_Value => No_Name,
Location => Value.Location,
Flag => False,
Next => Nil_String,
Index => Value.Index);
end loop;
end if;
end;
when N_Attribute_Reference
| N_Variable_Reference
=>
declare
The_Project : Project_Id := Project;
The_Package : Package_Id := Pkg;
The_Name : Name_Id := No_Name;
The_Variable_Id : Variable_Id := No_Variable;
The_Variable : Variable_Value;
Term_Project : constant Project_Node_Id :=
Project_Node_Of
(The_Current_Term,
From_Project_Node_Tree);
Term_Package : constant Project_Node_Id :=
Package_Node_Of
(The_Current_Term,
From_Project_Node_Tree);
Index : Name_Id := No_Name;
begin
<<Object_Dir_Restart>>
The_Project := Project;
The_Package := Pkg;
The_Name := No_Name;
The_Variable_Id := No_Variable;
Index := No_Name;
if Present (Term_Project)
and then Term_Project /= From_Project_Node
then
-- This variable or attribute comes from another project
The_Name :=
Name_Of (Term_Project, From_Project_Node_Tree);
The_Project := Imported_Or_Extended_Project_From
(Project => Project,
With_Name => The_Name,
No_Extending => True);
end if;
if Present (Term_Package) then
-- This is an attribute of a package
The_Name :=
Name_Of (Term_Package, From_Project_Node_Tree);
The_Package := The_Project.Decl.Packages;
while The_Package /= No_Package
and then Shared.Packages.Table (The_Package).Name /=
The_Name
loop
The_Package :=
Shared.Packages.Table (The_Package).Next;
end loop;
pragma Assert
(The_Package /= No_Package, "package not found.");
elsif Kind_Of (The_Current_Term, From_Project_Node_Tree) =
N_Attribute_Reference
then
The_Package := No_Package;
end if;
The_Name :=
Name_Of (The_Current_Term, From_Project_Node_Tree);
if Current_Term_Kind = N_Attribute_Reference then
Index :=
Associative_Array_Index_Of
(The_Current_Term, From_Project_Node_Tree);
end if;
-- If it is not an associative array attribute
if Index = No_Name then
-- It is not an associative array attribute
if The_Package /= No_Package then
-- First, if there is a package, look into the package
if Current_Term_Kind = N_Variable_Reference then
The_Variable_Id :=
Shared.Packages.Table
(The_Package).Decl.Variables;
else
The_Variable_Id :=
Shared.Packages.Table
(The_Package).Decl.Attributes;
end if;
while The_Variable_Id /= No_Variable
and then Shared.Variable_Elements.Table
(The_Variable_Id).Name /= The_Name
loop
The_Variable_Id :=
Shared.Variable_Elements.Table
(The_Variable_Id).Next;
end loop;
end if;
if The_Variable_Id = No_Variable then
-- If we have not found it, look into the project
if Current_Term_Kind = N_Variable_Reference then
The_Variable_Id := The_Project.Decl.Variables;
else
The_Variable_Id := The_Project.Decl.Attributes;
end if;
while The_Variable_Id /= No_Variable
and then Shared.Variable_Elements.Table
(The_Variable_Id).Name /= The_Name
loop
The_Variable_Id :=
Shared.Variable_Elements.Table
(The_Variable_Id).Next;
end loop;
end if;
if From_Project_Node_Tree.Incomplete_With then
if The_Variable_Id = No_Variable then
The_Variable := Nil_Variable_Value;
else
The_Variable :=
Shared.Variable_Elements.Table
(The_Variable_Id).Value;
end if;
else
pragma Assert (The_Variable_Id /= No_Variable,
"variable or attribute not found");
The_Variable :=
Shared.Variable_Elements.Table
(The_Variable_Id).Value;
end if;
else
-- It is an associative array attribute
declare
The_Array : Array_Id := No_Array;
The_Element : Array_Element_Id := No_Array_Element;
Array_Index : Name_Id := No_Name;
begin
if The_Package /= No_Package then
The_Array :=
Shared.Packages.Table (The_Package).Decl.Arrays;
else
The_Array := The_Project.Decl.Arrays;
end if;
while The_Array /= No_Array
and then Shared.Arrays.Table (The_Array).Name /=
The_Name
loop
The_Array := Shared.Arrays.Table (The_Array).Next;
end loop;
if The_Array /= No_Array then
The_Element :=
Shared.Arrays.Table (The_Array).Value;
Array_Index :=
Get_Attribute_Index
(From_Project_Node_Tree,
The_Current_Term,
Index);
while The_Element /= No_Array_Element
and then Shared.Array_Elements.Table
(The_Element).Index /= Array_Index
loop
The_Element :=
Shared.Array_Elements.Table (The_Element).Next;
end loop;
end if;
if The_Element /= No_Array_Element then
The_Variable :=
Shared.Array_Elements.Table (The_Element).Value;
else
if Expression_Kind_Of
(The_Current_Term, From_Project_Node_Tree) =
List
then
The_Variable :=
(Project => Project,
Kind => List,
Location => No_Location,
Default => True,
Values => Nil_String);
else
The_Variable :=
(Project => Project,
Kind => Single,
Location => No_Location,
Default => True,
Value => Empty_String,
Index => 0);
end if;
end if;
end;
end if;
-- Check the defaults
if Current_Term_Kind = N_Attribute_Reference then
declare
The_Default : constant Attribute_Default_Value :=
Default_Of
(The_Current_Term, From_Project_Node_Tree);
begin
-- Check the special value for 'Target when specified
if The_Default = Target_Value
and then Opt.Target_Origin = Specified
then
Name_Len := 0;
Add_Str_To_Name_Buffer (Opt.Target_Value.all);
The_Variable.Value := Name_Find;
-- Check the defaults
elsif The_Variable.Default then
case The_Variable.Kind is
when Undefined =>
null;
when Single =>
case The_Default is
when Read_Only_Value =>
null;
when Empty_Value =>
The_Variable.Value := Empty_String;
when Dot_Value =>
The_Variable.Value := Dot_String;
when Object_Dir_Value =>
From_Project_Node_Tree.Project_Nodes.Table
(The_Current_Term).Name :=
Snames.Name_Object_Dir;
From_Project_Node_Tree.Project_Nodes.Table
(The_Current_Term).Default :=
Dot_Value;
goto Object_Dir_Restart;
when Target_Value =>
if Opt.Target_Value = null then
The_Variable.Value := Empty_String;
else
Name_Len := 0;
Add_Str_To_Name_Buffer
(Opt.Target_Value.all);
The_Variable.Value := Name_Find;
end if;
when Runtime_Value =>
Get_Name_String (Index);
To_Lower (Name_Buffer (1 .. Name_Len));
The_Variable.Value :=
Runtime_Defaults.Get (Name_Find);
if The_Variable.Value = No_Name then
The_Variable.Value := Empty_String;
end if;
end case;
when List =>
case The_Default is
when Read_Only_Value =>
null;
when Empty_Value =>
The_Variable.Values := Nil_String;
when Dot_Value =>
The_Variable.Values :=
Shared.Dot_String_List;
when Object_Dir_Value
| Runtime_Value
| Target_Value
=>
null;
end case;
end case;
end if;
end;
end if;
case Kind is
when Undefined =>
-- Should never happen
pragma Assert (False, "undefined expression kind");
null;
when Single =>
case The_Variable.Kind is
when Undefined =>
null;
when Single =>
Add (Result.Value, The_Variable.Value);
when List =>
-- Should never happen
pragma Assert
(False,
"list cannot appear in single " &
"string expression");
null;
end case;
when List =>
case The_Variable.Kind is
when Undefined =>
null;
when Single =>
String_Element_Table.Increment_Last
(Shared.String_Elements);
if Last = Nil_String then
-- This can happen in an expression such as
-- () & Var
Result.Values :=
String_Element_Table.Last
(Shared.String_Elements);
else
Shared.String_Elements.Table (Last).Next :=
String_Element_Table.Last
(Shared.String_Elements);
end if;
Last :=
String_Element_Table.Last
(Shared.String_Elements);
Shared.String_Elements.Table (Last) :=
(Value => The_Variable.Value,
Display_Value => No_Name,
Location => Location_Of
(The_Current_Term,
From_Project_Node_Tree),
Flag => False,
Next => Nil_String,
Index => 0);
when List =>
declare
The_List : String_List_Id :=
The_Variable.Values;
begin
while The_List /= Nil_String loop
String_Element_Table.Increment_Last
(Shared.String_Elements);
if Last = Nil_String then
Result.Values :=
String_Element_Table.Last
(Shared.String_Elements);
else
Shared.
String_Elements.Table (Last).Next :=
String_Element_Table.Last
(Shared.String_Elements);
end if;
Last :=
String_Element_Table.Last
(Shared.String_Elements);
Shared.String_Elements.Table
(Last) :=
(Value =>
Shared.String_Elements.Table
(The_List).Value,
Display_Value => No_Name,
Location =>
Location_Of
(The_Current_Term,
From_Project_Node_Tree),
Flag => False,
Next => Nil_String,
Index => 0);
The_List := Shared.String_Elements.Table
(The_List).Next;
end loop;
end;
end case;
end case;
end;
when N_External_Value =>
Get_Name_String
(String_Value_Of
(External_Reference_Of
(The_Current_Term, From_Project_Node_Tree),
From_Project_Node_Tree));
declare
Name : constant Name_Id := Name_Find;
Default : Name_Id := No_Name;
Value : Name_Id := No_Name;
Ext_List : Boolean := False;
Str_List : String_List_Access := null;
Def_Var : Variable_Value;
Default_Node : constant Project_Node_Id :=
External_Default_Of
(The_Current_Term,
From_Project_Node_Tree);
begin
-- If there is a default value for the external reference,
-- get its value.
if Present (Default_Node) then
Def_Var := Expression
(Project => Project,
Shared => Shared,
From_Project_Node => From_Project_Node,
From_Project_Node_Tree => From_Project_Node_Tree,
Env => Env,
Pkg => Pkg,
First_Term =>
Tree.First_Term
(Default_Node, From_Project_Node_Tree),
Kind => Single);
if Def_Var /= Nil_Variable_Value then
Default := Def_Var.Value;
end if;
end if;
Ext_List := Expression_Kind_Of
(The_Current_Term,
From_Project_Node_Tree) = List;
if Ext_List then
Value := Prj.Ext.Value_Of (Env.External, Name, No_Name);
if Value /= No_Name then
declare
Sep : constant String :=
Get_Name_String (Default);
First : Positive := 1;
Lst : Natural;
Done : Boolean := False;
Nmb : Natural;
begin
Get_Name_String (Value);
if Name_Len = 0
or else Sep'Length = 0
or else Name_Buffer (1 .. Name_Len) = Sep
then
Done := True;
end if;
if not Done and then Name_Len < Sep'Length then
Str_List :=
new String_List'
(1 => new String'
(Name_Buffer (1 .. Name_Len)));
Done := True;
end if;
if not Done then
if Name_Buffer (1 .. Sep'Length) = Sep then
First := Sep'Length + 1;
end if;
if Name_Len - First + 1 >= Sep'Length
and then
Name_Buffer (Name_Len - Sep'Length + 1 ..
Name_Len) = Sep
then
Name_Len := Name_Len - Sep'Length;
end if;
if Name_Len = 0 then
Str_List :=
new String_List'(1 => new String'(""));
Done := True;
end if;
end if;
if not Done then
-- Count the number of strings
declare
Saved : constant Positive := First;
begin
Nmb := 1;
loop
Lst :=
Index
(Source =>
Name_Buffer (First .. Name_Len),
Pattern => Sep);
exit when Lst = 0;
Nmb := Nmb + 1;
First := Lst + Sep'Length;
end loop;
First := Saved;
end;
Str_List := new String_List (1 .. Nmb);
-- Populate the string list
Nmb := 1;
loop
Lst :=
Index
(Source =>
Name_Buffer (First .. Name_Len),
Pattern => Sep);
if Lst = 0 then
Str_List (Nmb) :=
new String'
(Name_Buffer (First .. Name_Len));
exit;
else
Str_List (Nmb) :=
new String'
(Name_Buffer (First .. Lst - 1));
Nmb := Nmb + 1;
First := Lst + Sep'Length;
end if;
end loop;
end if;
end;
end if;
else
-- Get the value
Value := Prj.Ext.Value_Of (Env.External, Name, Default);
if Value = No_Name then
if not Quiet_Output then
Error_Msg
(Env.Flags, "?undefined external reference",
Location_Of
(The_Current_Term, From_Project_Node_Tree),
Project);
end if;
Value := Empty_String;
end if;
end if;
case Kind is
when Undefined =>
null;
when Single =>
if Ext_List then
null; -- error
else
Add (Result.Value, Value);
end if;
when List =>
if not Ext_List or else Str_List /= null then
String_Element_Table.Increment_Last
(Shared.String_Elements);
if Last = Nil_String then
Result.Values :=
String_Element_Table.Last
(Shared.String_Elements);
else
Shared.String_Elements.Table (Last).Next
:= String_Element_Table.Last
(Shared.String_Elements);
end if;
Last := String_Element_Table.Last
(Shared.String_Elements);
if Ext_List then
for Ind in Str_List'Range loop
Name_Len := 0;
Add_Str_To_Name_Buffer (Str_List (Ind).all);
Value := Name_Find;
Shared.String_Elements.Table (Last) :=
(Value => Value,
Display_Value => No_Name,
Location =>
Location_Of
(The_Current_Term,
From_Project_Node_Tree),
Flag => False,
Next => Nil_String,
Index => 0);
if Ind /= Str_List'Last then
String_Element_Table.Increment_Last
(Shared.String_Elements);
Shared.String_Elements.Table (Last).Next :=
String_Element_Table.Last
(Shared.String_Elements);
Last := String_Element_Table.Last
(Shared.String_Elements);
end if;
end loop;
else
Shared.String_Elements.Table (Last) :=
(Value => Value,
Display_Value => No_Name,
Location =>
Location_Of
(The_Current_Term,
From_Project_Node_Tree),
Flag => False,
Next => Nil_String,
Index => 0);
end if;
end if;
end case;
end;
when others =>
-- Should never happen
pragma Assert
(False,
"illegal node kind in an expression");
raise Program_Error;
end case;
end if;
The_Term := Next_Term (The_Term, From_Project_Node_Tree);
end loop;
return Result;
end Expression;
---------------------------------------
-- Imported_Or_Extended_Project_From --
---------------------------------------
function Imported_Or_Extended_Project_From
(Project : Project_Id;
With_Name : Name_Id;
No_Extending : Boolean := False) return Project_Id
is
List : Project_List;
Result : Project_Id;
Temp_Result : Project_Id;
begin
-- First check if it is the name of an extended project
Result := Project.Extends;
while Result /= No_Project loop
if Result.Name = With_Name then
return Result;
else
Result := Result.Extends;
end if;
end loop;
-- Then check the name of each imported project
Temp_Result := No_Project;
List := Project.Imported_Projects;
while List /= null loop
Result := List.Project;
-- If the project is directly imported, then returns its ID
if Result.Name = With_Name then
return Result;
end if;
-- If a project extending the project is imported, then keep this
-- extending project as a possibility. It will be the returned ID
-- if the project is not imported directly.
declare
Proj : Project_Id;
begin
Proj := Result.Extends;
while Proj /= No_Project loop
if Proj.Name = With_Name then
if No_Extending then
Temp_Result := Proj;
else
Temp_Result := Result;
end if;
exit;
end if;
Proj := Proj.Extends;
end loop;
end;
List := List.Next;
end loop;
pragma Assert (Temp_Result /= No_Project, "project not found");
return Temp_Result;
end Imported_Or_Extended_Project_From;
------------------
-- Package_From --
------------------
function Package_From
(Project : Project_Id;
Shared : Shared_Project_Tree_Data_Access;
With_Name : Name_Id) return Package_Id
is
Result : Package_Id := Project.Decl.Packages;
begin
-- Check the name of each existing package of Project
while Result /= No_Package
and then Shared.Packages.Table (Result).Name /= With_Name
loop
Result := Shared.Packages.Table (Result).Next;
end loop;
if Result = No_Package then
-- Should never happen
Write_Line
("package """ & Get_Name_String (With_Name) & """ not found");
raise Program_Error;
else
return Result;
end if;
end Package_From;
-------------
-- Process --
-------------
procedure Process
(In_Tree : Project_Tree_Ref;
Project : out Project_Id;
Packages_To_Check : String_List_Access;
Success : out Boolean;
From_Project_Node : Project_Node_Id;
From_Project_Node_Tree : Project_Node_Tree_Ref;
Env : in out Prj.Tree.Environment;
Reset_Tree : Boolean := True;
On_New_Tree_Loaded : Tree_Loaded_Callback := null)
is
begin
Process_Project_Tree_Phase_1
(In_Tree => In_Tree,
Project => Project,
Success => Success,
From_Project_Node => From_Project_Node,
From_Project_Node_Tree => From_Project_Node_Tree,
Env => Env,
Packages_To_Check => Packages_To_Check,
Reset_Tree => Reset_Tree,
On_New_Tree_Loaded => On_New_Tree_Loaded);
if Project_Qualifier_Of
(From_Project_Node, From_Project_Node_Tree) /= Configuration
then
Process_Project_Tree_Phase_2
(In_Tree => In_Tree,
Project => Project,
Success => Success,
From_Project_Node => From_Project_Node,
From_Project_Node_Tree => From_Project_Node_Tree,
Env => Env);
end if;
end Process;
-------------------------------
-- Process_Declarative_Items --
-------------------------------
procedure Process_Declarative_Items
(Project : Project_Id;
In_Tree : Project_Tree_Ref;
From_Project_Node : Project_Node_Id;
Node_Tree : Project_Node_Tree_Ref;
Env : Prj.Tree.Environment;
Pkg : Package_Id;
Item : Project_Node_Id;
Child_Env : in out Prj.Tree.Environment)
is
Shared : constant Shared_Project_Tree_Data_Access := In_Tree.Shared;
procedure Check_Or_Set_Typed_Variable
(Value : in out Variable_Value;
Declaration : Project_Node_Id);
-- Check whether Value is valid for this typed variable declaration. If
-- it is an error, the behavior depends on the flags: either an error is
-- reported, or a warning, or nothing. In the last two cases, the value
-- of the variable is set to a valid value, replacing Value.
procedure Process_Package_Declaration
(Current_Item : Project_Node_Id);
procedure Process_Attribute_Declaration
(Current : Project_Node_Id);
procedure Process_Case_Construction
(Current_Item : Project_Node_Id);
procedure Process_Associative_Array
(Current_Item : Project_Node_Id);
procedure Process_Expression
(Current : Project_Node_Id);
procedure Process_Expression_For_Associative_Array
(Current : Project_Node_Id;
New_Value : Variable_Value);
procedure Process_Expression_Variable_Decl
(Current_Item : Project_Node_Id;
New_Value : Variable_Value);
-- Process the various declarative items
---------------------------------
-- Check_Or_Set_Typed_Variable --
---------------------------------
procedure Check_Or_Set_Typed_Variable
(Value : in out Variable_Value;
Declaration : Project_Node_Id)
is
Loc : constant Source_Ptr := Location_Of (Declaration, Node_Tree);
Reset_Value : Boolean := False;
Current_String : Project_Node_Id;
begin
-- Report an error for an empty string
if Value.Value = Empty_String then
Error_Msg_Name_1 := Name_Of (Declaration, Node_Tree);
case Env.Flags.Allow_Invalid_External is
when Error =>
Error_Msg
(Env.Flags, "no value defined for %%", Loc, Project);
when Warning =>
Reset_Value := True;
Error_Msg
(Env.Flags, "?no value defined for %%", Loc, Project);
when Silent =>
Reset_Value := True;
end case;
else
-- Loop through all the valid strings for the
-- string type and compare to the string value.
Current_String :=
First_Literal_String
(String_Type_Of (Declaration, Node_Tree), Node_Tree);
while Present (Current_String)
and then
String_Value_Of (Current_String, Node_Tree) /= Value.Value
loop
Current_String :=
Next_Literal_String (Current_String, Node_Tree);
end loop;
-- Report error if string value is not one for the string type
if No (Current_String) then
Error_Msg_Name_1 := Value.Value;
Error_Msg_Name_2 := Name_Of (Declaration, Node_Tree);
case Env.Flags.Allow_Invalid_External is
when Error =>
Error_Msg
(Env.Flags, "value %% is illegal for typed string %%",
Loc, Project);
when Warning =>
Error_Msg
(Env.Flags, "?value %% is illegal for typed string %%",
Loc, Project);
Reset_Value := True;
when Silent =>
Reset_Value := True;
end case;
end if;
end if;
if Reset_Value then
Current_String :=
First_Literal_String
(String_Type_Of (Declaration, Node_Tree), Node_Tree);
Value.Value := String_Value_Of (Current_String, Node_Tree);
end if;
end Check_Or_Set_Typed_Variable;
---------------------------------
-- Process_Package_Declaration --
---------------------------------
procedure Process_Package_Declaration
(Current_Item : Project_Node_Id)
is
begin
-- Do not process a package declaration that should be ignored
if Expression_Kind_Of (Current_Item, Node_Tree) /= Ignored then
-- Create the new package
Package_Table.Increment_Last (Shared.Packages);
declare
New_Pkg : constant Package_Id :=
Package_Table.Last (Shared.Packages);
The_New_Package : Package_Element;
Project_Of_Renamed_Package : constant Project_Node_Id :=
Project_Of_Renamed_Package_Of
(Current_Item, Node_Tree);
begin
-- Set the name of the new package
The_New_Package.Name := Name_Of (Current_Item, Node_Tree);
-- Insert the new package in the appropriate list
if Pkg /= No_Package then
The_New_Package.Next :=
Shared.Packages.Table (Pkg).Decl.Packages;
Shared.Packages.Table (Pkg).Decl.Packages := New_Pkg;
else
The_New_Package.Next := Project.Decl.Packages;
Project.Decl.Packages := New_Pkg;
end if;
Shared.Packages.Table (New_Pkg) := The_New_Package;
if Present (Project_Of_Renamed_Package) then
-- Renamed or extending package
declare
Project_Name : constant Name_Id :=
Name_Of (Project_Of_Renamed_Package,
Node_Tree);
Renamed_Project : constant Project_Id :=
Imported_Or_Extended_Project_From
(Project, Project_Name);
Renamed_Package : constant Package_Id :=
Package_From
(Renamed_Project, Shared,
Name_Of (Current_Item, Node_Tree));
begin
-- For a renamed package, copy the declarations of the
-- renamed package, but set all the locations to the
-- location of the package name in the renaming
-- declaration.
Copy_Package_Declarations
(From => Shared.Packages.Table
(Renamed_Package).Decl,
To => Shared.Packages.Table (New_Pkg).Decl,
New_Loc => Location_Of (Current_Item, Node_Tree),
Restricted => False,
Shared => Shared);
end;
else
-- Set the default values of the attributes
Add_Attributes
(Project,
Project.Name,
Name_Id (Project.Directory.Display_Name),
Shared,
Shared.Packages.Table (New_Pkg).Decl,
First_Attribute_Of
(Package_Id_Of (Current_Item, Node_Tree)),
Project_Level => False);
end if;
-- Process declarative items (nothing to do when the package is
-- renaming, as the first declarative item is null).
Process_Declarative_Items
(Project => Project,
In_Tree => In_Tree,
From_Project_Node => From_Project_Node,
Node_Tree => Node_Tree,
Env => Env,
Pkg => New_Pkg,
Item =>
First_Declarative_Item_Of (Current_Item, Node_Tree),
Child_Env => Child_Env);
end;
end if;
end Process_Package_Declaration;
-------------------------------
-- Process_Associative_Array --
-------------------------------
procedure Process_Associative_Array
(Current_Item : Project_Node_Id)
is
Current_Item_Name : constant Name_Id :=
Name_Of (Current_Item, Node_Tree);
-- The name of the attribute
Current_Location : constant Source_Ptr :=
Location_Of (Current_Item, Node_Tree);
New_Array : Array_Id;
-- The new associative array created
Orig_Array : Array_Id;
-- The associative array value
Orig_Project_Name : Name_Id := No_Name;
-- The name of the project where the associative array
-- value is.
Orig_Project : Project_Id := No_Project;
-- The id of the project where the associative array
-- value is.
Orig_Package_Name : Name_Id := No_Name;
-- The name of the package, if any, where the associative array value
-- is located.
Orig_Package : Package_Id := No_Package;
-- The id of the package, if any, where the associative array value
-- is located.
New_Element : Array_Element_Id := No_Array_Element;
-- Id of a new array element created
Prev_Element : Array_Element_Id := No_Array_Element;
-- Last new element id created
Orig_Element : Array_Element_Id := No_Array_Element;
-- Current array element in original associative array
Next_Element : Array_Element_Id := No_Array_Element;
-- Id of the array element that follows the new element. This is not
-- always nil, because values for the associative array attribute may
-- already have been declared, and the array elements declared are
-- reused.
Prj : Project_List;
begin
-- First find if the associative array attribute already has elements
-- declared.
if Pkg /= No_Package then
New_Array := Shared.Packages.Table (Pkg).Decl.Arrays;
else
New_Array := Project.Decl.Arrays;
end if;
while New_Array /= No_Array
and then Shared.Arrays.Table (New_Array).Name /= Current_Item_Name
loop
New_Array := Shared.Arrays.Table (New_Array).Next;
end loop;
-- If the attribute has never been declared add new entry in the
-- arrays of the project/package and link it.
if New_Array = No_Array then
Array_Table.Increment_Last (Shared.Arrays);
New_Array := Array_Table.Last (Shared.Arrays);
if Pkg /= No_Package then
Shared.Arrays.Table (New_Array) :=
(Name => Current_Item_Name,
Location => Current_Location,
Value => No_Array_Element,
Next => Shared.Packages.Table (Pkg).Decl.Arrays);
Shared.Packages.Table (Pkg).Decl.Arrays := New_Array;
else
Shared.Arrays.Table (New_Array) :=
(Name => Current_Item_Name,
Location => Current_Location,
Value => No_Array_Element,
Next => Project.Decl.Arrays);
Project.Decl.Arrays := New_Array;
end if;
end if;
-- Find the project where the value is declared
Orig_Project_Name :=
Name_Of
(Associative_Project_Of (Current_Item, Node_Tree), Node_Tree);
Prj := In_Tree.Projects;
while Prj /= null loop
if Prj.Project.Name = Orig_Project_Name then
Orig_Project := Prj.Project;
exit;
end if;
Prj := Prj.Next;
end loop;
pragma Assert (Orig_Project /= No_Project,
"original project not found");
if No (Associative_Package_Of (Current_Item, Node_Tree)) then
Orig_Array := Orig_Project.Decl.Arrays;
else
-- If in a package, find the package where the value is declared
Orig_Package_Name :=
Name_Of
(Associative_Package_Of (Current_Item, Node_Tree), Node_Tree);
Orig_Package := Orig_Project.Decl.Packages;
pragma Assert (Orig_Package /= No_Package,
"original package not found");
while Shared.Packages.Table
(Orig_Package).Name /= Orig_Package_Name
loop
Orig_Package := Shared.Packages.Table (Orig_Package).Next;
pragma Assert (Orig_Package /= No_Package,
"original package not found");
end loop;
Orig_Array := Shared.Packages.Table (Orig_Package).Decl.Arrays;
end if;
-- Now look for the array
while Orig_Array /= No_Array
and then Shared.Arrays.Table (Orig_Array).Name /= Current_Item_Name
loop
Orig_Array := Shared.Arrays.Table (Orig_Array).Next;
end loop;
if Orig_Array = No_Array then
Error_Msg
(Env.Flags,
"associative array value not found",
Location_Of (Current_Item, Node_Tree),
Project);
else
Orig_Element := Shared.Arrays.Table (Orig_Array).Value;
-- Copy each array element
while Orig_Element /= No_Array_Element loop
-- Case of first element
if Prev_Element = No_Array_Element then
-- And there is no array element declared yet, create a new
-- first array element.
if Shared.Arrays.Table (New_Array).Value =
No_Array_Element
then
Array_Element_Table.Increment_Last
(Shared.Array_Elements);
New_Element := Array_Element_Table.Last
(Shared.Array_Elements);
Shared.Arrays.Table (New_Array).Value := New_Element;
Next_Element := No_Array_Element;
-- Otherwise, the new element is the first
else
New_Element := Shared.Arrays.Table (New_Array).Value;
Next_Element :=
Shared.Array_Elements.Table (New_Element).Next;
end if;
-- Otherwise, reuse an existing element, or create
-- one if necessary.
else
Next_Element :=
Shared.Array_Elements.Table (Prev_Element).Next;
if Next_Element = No_Array_Element then
Array_Element_Table.Increment_Last
(Shared.Array_Elements);
New_Element := Array_Element_Table.Last
(Shared.Array_Elements);
Shared.Array_Elements.Table (Prev_Element).Next :=
New_Element;
else
New_Element := Next_Element;
Next_Element :=
Shared.Array_Elements.Table (New_Element).Next;
end if;
end if;
-- Copy the value of the element
Shared.Array_Elements.Table (New_Element) :=
Shared.Array_Elements.Table (Orig_Element);
Shared.Array_Elements.Table (New_Element).Value.Project
:= Project;
-- Adjust the Next link
Shared.Array_Elements.Table (New_Element).Next := Next_Element;
-- Adjust the previous id for the next element
Prev_Element := New_Element;
-- Go to the next element in the original array
Orig_Element := Shared.Array_Elements.Table (Orig_Element).Next;
end loop;
-- Make sure that the array ends here, in case there previously a
-- greater number of elements.
Shared.Array_Elements.Table (New_Element).Next := No_Array_Element;
end if;
end Process_Associative_Array;
----------------------------------------------
-- Process_Expression_For_Associative_Array --
----------------------------------------------
procedure Process_Expression_For_Associative_Array
(Current : Project_Node_Id;
New_Value : Variable_Value)
is
Name : constant Name_Id := Name_Of (Current, Node_Tree);
Current_Location : constant Source_Ptr :=
Location_Of (Current, Node_Tree);
Index_Name : Name_Id :=
Associative_Array_Index_Of (Current, Node_Tree);
Source_Index : constant Int :=
Source_Index_Of (Current, Node_Tree);
The_Array : Array_Id;
Elem : Array_Element_Id := No_Array_Element;
begin
if Index_Name /= All_Other_Names then
Index_Name := Get_Attribute_Index (Node_Tree, Current, Index_Name);
end if;
-- Look for the array in the appropriate list
if Pkg /= No_Package then
The_Array := Shared.Packages.Table (Pkg).Decl.Arrays;
else
The_Array := Project.Decl.Arrays;
end if;
while The_Array /= No_Array
and then Shared.Arrays.Table (The_Array).Name /= Name
loop
The_Array := Shared.Arrays.Table (The_Array).Next;
end loop;
-- If the array cannot be found, create a new entry in the list.
-- As The_Array_Element is initialized to No_Array_Element, a new
-- element will be created automatically later
if The_Array = No_Array then
Array_Table.Increment_Last (Shared.Arrays);
The_Array := Array_Table.Last (Shared.Arrays);
if Pkg /= No_Package then
Shared.Arrays.Table (The_Array) :=
(Name => Name,
Location => Current_Location,
Value => No_Array_Element,
Next => Shared.Packages.Table (Pkg).Decl.Arrays);
Shared.Packages.Table (Pkg).Decl.Arrays := The_Array;
else
Shared.Arrays.Table (The_Array) :=
(Name => Name,
Location => Current_Location,
Value => No_Array_Element,
Next => Project.Decl.Arrays);
Project.Decl.Arrays := The_Array;
end if;
else
Elem := Shared.Arrays.Table (The_Array).Value;
end if;
-- Look in the list, if any, to find an element with the same index
-- and same source index.
while Elem /= No_Array_Element
and then
(Shared.Array_Elements.Table (Elem).Index /= Index_Name
or else
Shared.Array_Elements.Table (Elem).Src_Index /= Source_Index)
loop
Elem := Shared.Array_Elements.Table (Elem).Next;
end loop;
-- If no such element were found, create a new one
-- and insert it in the element list, with the
-- proper value.
if Elem = No_Array_Element then
Array_Element_Table.Increment_Last (Shared.Array_Elements);
Elem := Array_Element_Table.Last (Shared.Array_Elements);
Shared.Array_Elements.Table
(Elem) :=
(Index => Index_Name,
Restricted => False,
Src_Index => Source_Index,
Index_Case_Sensitive =>
not Case_Insensitive (Current, Node_Tree),
Value => New_Value,
Next => Shared.Arrays.Table (The_Array).Value);
Shared.Arrays.Table (The_Array).Value := Elem;
else
-- An element with the same index already exists, just replace its
-- value with the new one.
Shared.Array_Elements.Table (Elem).Value := New_Value;
end if;
if Name = Snames.Name_External then
if In_Tree.Is_Root_Tree then
Add (Child_Env.External,
External_Name => Get_Name_String (Index_Name),
Value => Get_Name_String (New_Value.Value),
Source => From_External_Attribute);
Add (Env.External,
External_Name => Get_Name_String (Index_Name),
Value => Get_Name_String (New_Value.Value),
Source => From_External_Attribute,
Silent => True);
else
if Current_Verbosity = High then
Debug_Output
("'for External' has no effect except in root aggregate ("
& Get_Name_String (Index_Name) & ")", New_Value.Value);
end if;
end if;
end if;
end Process_Expression_For_Associative_Array;
--------------------------------------
-- Process_Expression_Variable_Decl --
--------------------------------------
procedure Process_Expression_Variable_Decl
(Current_Item : Project_Node_Id;
New_Value : Variable_Value)
is
Name : constant Name_Id := Name_Of (Current_Item, Node_Tree);
Is_Attribute : constant Boolean :=
Kind_Of (Current_Item, Node_Tree) =
N_Attribute_Declaration;
Var : Variable_Id := No_Variable;
begin
-- First, find the list where to find the variable or attribute
if Is_Attribute then
if Pkg /= No_Package then
Var := Shared.Packages.Table (Pkg).Decl.Attributes;
else
Var := Project.Decl.Attributes;
end if;
else
if Pkg /= No_Package then
Var := Shared.Packages.Table (Pkg).Decl.Variables;
else
Var := Project.Decl.Variables;
end if;
end if;
-- Loop through the list, to find if it has already been declared
while Var /= No_Variable
and then Shared.Variable_Elements.Table (Var).Name /= Name
loop
Var := Shared.Variable_Elements.Table (Var).Next;
end loop;
-- If it has not been declared, create a new entry in the list
if Var = No_Variable then
-- All single string attribute should already have been declared
-- with a default empty string value.
pragma Assert
(not Is_Attribute,
"illegal attribute declaration for " & Get_Name_String (Name));
Variable_Element_Table.Increment_Last (Shared.Variable_Elements);
Var := Variable_Element_Table.Last (Shared.Variable_Elements);
-- Put the new variable in the appropriate list
if Pkg /= No_Package then
Shared.Variable_Elements.Table (Var) :=
(Next => Shared.Packages.Table (Pkg).Decl.Variables,
Name => Name,
Value => New_Value);
Shared.Packages.Table (Pkg).Decl.Variables := Var;
else
Shared.Variable_Elements.Table (Var) :=
(Next => Project.Decl.Variables,
Name => Name,
Value => New_Value);
Project.Decl.Variables := Var;
end if;
-- If the variable/attribute has already been declared, just
-- change the value.
else
Shared.Variable_Elements.Table (Var).Value := New_Value;
end if;
if Is_Attribute and then Name = Snames.Name_Project_Path then
if In_Tree.Is_Root_Tree then
declare
Val : String_List_Id := New_Value.Values;
List : Name_Ids.Vector;
begin
-- Get all values
while Val /= Nil_String loop
List.Prepend
(Shared.String_Elements.Table (Val).Value);
Val := Shared.String_Elements.Table (Val).Next;
end loop;
-- Prepend them in the order found in the attribute
for K in Positive range 1 .. Positive (List.Length) loop
Prj.Env.Add_Directories
(Child_Env.Project_Path,
Normalize_Pathname
(Name => Get_Name_String
(List.Element (K)),
Directory => Get_Name_String
(Project.Directory.Display_Name)),
Prepend => True);
end loop;
end;
else
if Current_Verbosity = High then
Debug_Output
("'for Project_Path' has no effect except in"
& " root aggregate");
end if;
end if;
end if;
end Process_Expression_Variable_Decl;
------------------------
-- Process_Expression --
------------------------
procedure Process_Expression (Current : Project_Node_Id) is
New_Value : Variable_Value :=
Expression
(Project => Project,
Shared => Shared,
From_Project_Node => From_Project_Node,
From_Project_Node_Tree => Node_Tree,
Env => Env,
Pkg => Pkg,
First_Term =>
Tree.First_Term
(Expression_Of (Current, Node_Tree), Node_Tree),
Kind =>
Expression_Kind_Of (Current, Node_Tree));
begin
-- Process a typed variable declaration
if Kind_Of (Current, Node_Tree) = N_Typed_Variable_Declaration then
Check_Or_Set_Typed_Variable (New_Value, Current);
end if;
if Kind_Of (Current, Node_Tree) /= N_Attribute_Declaration
or else Associative_Array_Index_Of (Current, Node_Tree) = No_Name
then
Process_Expression_Variable_Decl (Current, New_Value);
else
Process_Expression_For_Associative_Array (Current, New_Value);
end if;
end Process_Expression;
-----------------------------------
-- Process_Attribute_Declaration --
-----------------------------------
procedure Process_Attribute_Declaration (Current : Project_Node_Id) is
begin
if Expression_Of (Current, Node_Tree) = Empty_Node then
Process_Associative_Array (Current);
else
Process_Expression (Current);
end if;
end Process_Attribute_Declaration;
-------------------------------
-- Process_Case_Construction --
-------------------------------
procedure Process_Case_Construction
(Current_Item : Project_Node_Id)
is
The_Project : Project_Id := Project;
-- The id of the project of the case variable
The_Package : Package_Id := Pkg;
-- The id of the package, if any, of the case variable
The_Variable : Variable_Value := Nil_Variable_Value;
-- The case variable
Case_Value : Name_Id := No_Name;
-- The case variable value
Case_Item : Project_Node_Id := Empty_Node;
Choice_String : Project_Node_Id := Empty_Node;
Decl_Item : Project_Node_Id := Empty_Node;
begin
declare
Variable_Node : constant Project_Node_Id :=
Case_Variable_Reference_Of
(Current_Item,
Node_Tree);
Var_Id : Variable_Id := No_Variable;
Name : Name_Id := No_Name;
begin
-- If a project was specified for the case variable, get its id
if Present (Project_Node_Of (Variable_Node, Node_Tree)) then
Name :=
Name_Of
(Project_Node_Of (Variable_Node, Node_Tree), Node_Tree);
The_Project :=
Imported_Or_Extended_Project_From
(Project, Name, No_Extending => True);
The_Package := No_Package;
end if;
-- If a package was specified for the case variable, get its id
if Present (Package_Node_Of (Variable_Node, Node_Tree)) then
Name :=
Name_Of
(Package_Node_Of (Variable_Node, Node_Tree), Node_Tree);
The_Package := Package_From (The_Project, Shared, Name);
end if;
Name := Name_Of (Variable_Node, Node_Tree);
-- First, look for the case variable into the package, if any
if The_Package /= No_Package then
Name := Name_Of (Variable_Node, Node_Tree);
Var_Id := Shared.Packages.Table (The_Package).Decl.Variables;
while Var_Id /= No_Variable
and then Shared.Variable_Elements.Table (Var_Id).Name /= Name
loop
Var_Id := Shared.Variable_Elements.Table (Var_Id).Next;
end loop;
end if;
-- If not found in the package, or if there is no package, look at
-- the project level.
if Var_Id = No_Variable
and then No (Package_Node_Of (Variable_Node, Node_Tree))
then
Var_Id := The_Project.Decl.Variables;
while Var_Id /= No_Variable
and then Shared.Variable_Elements.Table (Var_Id).Name /= Name
loop
Var_Id := Shared.Variable_Elements.Table (Var_Id).Next;
end loop;
end if;
if Var_Id = No_Variable then
if Node_Tree.Incomplete_With then
return;
-- Should never happen, because this has already been checked
-- during parsing.
else
Write_Line
("variable """ & Get_Name_String (Name) & """ not found");
raise Program_Error;
end if;
end if;
-- Get the case variable
The_Variable := Shared.Variable_Elements. Table (Var_Id).Value;
if The_Variable.Kind /= Single then
-- Should never happen, because this has already been checked
-- during parsing.
Write_Line ("variable""" & Get_Name_String (Name) &
""" is not a single string variable");
raise Program_Error;
end if;
-- Get the case variable value
Case_Value := The_Variable.Value;
end;
-- Now look into all the case items of the case construction
Case_Item := First_Case_Item_Of (Current_Item, Node_Tree);
Case_Item_Loop :
while Present (Case_Item) loop
Choice_String := First_Choice_Of (Case_Item, Node_Tree);
-- When Choice_String is nil, it means that it is the
-- "when others =>" alternative.
if No (Choice_String) then
Decl_Item := First_Declarative_Item_Of (Case_Item, Node_Tree);
exit Case_Item_Loop;
end if;
-- Look into all the alternative of this case item
Choice_Loop :
while Present (Choice_String) loop
if Case_Value = String_Value_Of (Choice_String, Node_Tree) then
Decl_Item :=
First_Declarative_Item_Of (Case_Item, Node_Tree);
exit Case_Item_Loop;
end if;
Choice_String := Next_Literal_String (Choice_String, Node_Tree);
end loop Choice_Loop;
Case_Item := Next_Case_Item (Case_Item, Node_Tree);
end loop Case_Item_Loop;
-- If there is an alternative, then we process it
if Present (Decl_Item) then
Process_Declarative_Items
(Project => Project,
In_Tree => In_Tree,
From_Project_Node => From_Project_Node,
Node_Tree => Node_Tree,
Env => Env,
Pkg => Pkg,
Item => Decl_Item,
Child_Env => Child_Env);
end if;
end Process_Case_Construction;
-- Local variables
Current, Decl : Project_Node_Id;
Kind : Project_Node_Kind;
-- Start of processing for Process_Declarative_Items
begin
Decl := Item;
while Present (Decl) loop
Current := Current_Item_Node (Decl, Node_Tree);
Decl := Next_Declarative_Item (Decl, Node_Tree);
Kind := Kind_Of (Current, Node_Tree);
case Kind is
when N_Package_Declaration =>
Process_Package_Declaration (Current);
-- Nothing to process for string type declaration
when N_String_Type_Declaration =>
null;
when N_Attribute_Declaration
| N_Typed_Variable_Declaration
| N_Variable_Declaration
=>
Process_Attribute_Declaration (Current);
when N_Case_Construction =>
Process_Case_Construction (Current);
when others =>
Write_Line ("Illegal declarative item: " & Kind'Img);
raise Program_Error;
end case;
end loop;
end Process_Declarative_Items;
----------------------------------
-- Process_Project_Tree_Phase_1 --
----------------------------------
procedure Process_Project_Tree_Phase_1
(In_Tree : Project_Tree_Ref;
Project : out Project_Id;
Packages_To_Check : String_List_Access;
Success : out Boolean;
From_Project_Node : Project_Node_Id;
From_Project_Node_Tree : Project_Node_Tree_Ref;
Env : in out Prj.Tree.Environment;
Reset_Tree : Boolean := True;
On_New_Tree_Loaded : Tree_Loaded_Callback := null)
is
begin
if Reset_Tree then
-- Make sure there are no projects in the data structure
Free_List (In_Tree.Projects, Free_Project => True);
end if;
Processed_Projects.Reset;
-- And process the main project and all of the projects it depends on,
-- recursively.
Debug_Increase_Indent ("Process tree, phase 1");
Recursive_Process
(Project => Project,
In_Tree => In_Tree,
Packages_To_Check => Packages_To_Check,
From_Project_Node => From_Project_Node,
From_Project_Node_Tree => From_Project_Node_Tree,
Env => Env,
Extended_By => No_Project,
From_Encapsulated_Lib => False,
On_New_Tree_Loaded => On_New_Tree_Loaded);
Success :=
Total_Errors_Detected = 0
and then
(Warning_Mode /= Treat_As_Error or else Warnings_Detected = 0);
if Current_Verbosity = High then
Debug_Decrease_Indent
("Done Process tree, phase 1, Success=" & Success'Img);
end if;
end Process_Project_Tree_Phase_1;
----------------------------------
-- Process_Project_Tree_Phase_2 --
----------------------------------
procedure Process_Project_Tree_Phase_2
(In_Tree : Project_Tree_Ref;
Project : Project_Id;
Success : out Boolean;
From_Project_Node : Project_Node_Id;
From_Project_Node_Tree : Project_Node_Tree_Ref;
Env : Environment)
is
Obj_Dir : Path_Name_Type;
Extending : Project_Id;
Extending2 : Project_Id;
Prj : Project_List;
-- Start of processing for Process_Project_Tree_Phase_2
begin
Success := True;
Debug_Increase_Indent ("Process tree, phase 2", Project.Name);
if Project /= No_Project then
Check (In_Tree, Project, From_Project_Node_Tree, Env.Flags);
end if;
-- If main project is an extending all project, set object directory of
-- all virtual extending projects to object directory of main project.
if Project /= No_Project
and then Is_Extending_All (From_Project_Node, From_Project_Node_Tree)
then
declare
Object_Dir : constant Path_Information := Project.Object_Directory;
begin
Prj := In_Tree.Projects;
while Prj /= null loop
if Prj.Project.Virtual then
Prj.Project.Object_Directory := Object_Dir;
end if;
Prj := Prj.Next;
end loop;
end;
end if;
-- Check that no extending project shares its object directory with
-- the project(s) it extends.
if Project /= No_Project then
Prj := In_Tree.Projects;
while Prj /= null loop
Extending := Prj.Project.Extended_By;
if Extending /= No_Project then
Obj_Dir := Prj.Project.Object_Directory.Name;
-- Check that a project being extended does not share its
-- object directory with any project that extends it, directly
-- or indirectly, including a virtual extending project.
-- Start with the project directly extending it
Extending2 := Extending;
while Extending2 /= No_Project loop
if Has_Ada_Sources (Extending2)
and then Extending2.Object_Directory.Name = Obj_Dir
then
if Extending2.Virtual then
Error_Msg_Name_1 := Prj.Project.Display_Name;
Error_Msg
(Env.Flags,
"project %% cannot be extended by a virtual" &
" project with the same object directory",
Prj.Project.Location, Project);
else
Error_Msg_Name_1 := Extending2.Display_Name;
Error_Msg_Name_2 := Prj.Project.Display_Name;
Error_Msg
(Env.Flags,
"project %% cannot extend project %%",
Extending2.Location, Project);
Error_Msg
(Env.Flags,
"\they share the same object directory",
Extending2.Location, Project);
end if;
end if;
-- Continue with the next extending project, if any
Extending2 := Extending2.Extended_By;
end loop;
end if;
Prj := Prj.Next;
end loop;
end if;
Debug_Decrease_Indent ("Done Process tree, phase 2");
Success := Total_Errors_Detected = 0
and then
(Warning_Mode /= Treat_As_Error or else Warnings_Detected = 0);
end Process_Project_Tree_Phase_2;
-----------------------
-- Recursive_Process --
-----------------------
procedure Recursive_Process
(In_Tree : Project_Tree_Ref;
Project : out Project_Id;
Packages_To_Check : String_List_Access;
From_Project_Node : Project_Node_Id;
From_Project_Node_Tree : Project_Node_Tree_Ref;
Env : in out Prj.Tree.Environment;
Extended_By : Project_Id;
From_Encapsulated_Lib : Boolean;
On_New_Tree_Loaded : Tree_Loaded_Callback := null)
is
Shared : constant Shared_Project_Tree_Data_Access := In_Tree.Shared;
Child_Env : Prj.Tree.Environment;
-- Only used for the root aggregate project (if any). This is left
-- uninitialized otherwise.
procedure Process_Imported_Projects
(Imported : in out Project_List;
Limited_With : Boolean);
-- Process imported projects. If Limited_With is True, then only
-- projects processed through a "limited with" are processed, otherwise
-- only projects imported through a standard "with" are processed.
-- Imported is the id of the last imported project.
procedure Process_Aggregated_Projects;
-- Process all the projects aggregated in List. This does nothing if the
-- project is not an aggregate project.
procedure Process_Extended_Project;
-- Process the extended project: inherit all packages from the extended
-- project that are not explicitly defined or renamed. Also inherit the
-- languages, if attribute Languages is not explicitly defined.
-------------------------------
-- Process_Imported_Projects --
-------------------------------
procedure Process_Imported_Projects
(Imported : in out Project_List;
Limited_With : Boolean)
is
With_Clause : Project_Node_Id;
New_Project : Project_Id;
Proj_Node : Project_Node_Id;
begin
With_Clause :=
First_With_Clause_Of
(From_Project_Node, From_Project_Node_Tree);
while Present (With_Clause) loop
Proj_Node :=
Non_Limited_Project_Node_Of
(With_Clause, From_Project_Node_Tree);
New_Project := No_Project;
if (Limited_With and then No (Proj_Node))
or else (not Limited_With and then Present (Proj_Node))
then
Recursive_Process
(In_Tree => In_Tree,
Project => New_Project,
Packages_To_Check => Packages_To_Check,
From_Project_Node =>
Project_Node_Of (With_Clause, From_Project_Node_Tree),
From_Project_Node_Tree => From_Project_Node_Tree,
Env => Env,
Extended_By => No_Project,
From_Encapsulated_Lib => From_Encapsulated_Lib,
On_New_Tree_Loaded => On_New_Tree_Loaded);
if Imported = null then
Project.Imported_Projects := new Project_List_Element'
(Project => New_Project,
From_Encapsulated_Lib => False,
Next => null);
Imported := Project.Imported_Projects;
else
Imported.Next := new Project_List_Element'
(Project => New_Project,
From_Encapsulated_Lib => False,
Next => null);
Imported := Imported.Next;
end if;
end if;
With_Clause :=
Next_With_Clause_Of (With_Clause, From_Project_Node_Tree);
end loop;
end Process_Imported_Projects;
---------------------------------
-- Process_Aggregated_Projects --
---------------------------------
procedure Process_Aggregated_Projects is
List : Aggregated_Project_List;
Loaded_Project : Prj.Tree.Project_Node_Id;
Success : Boolean := True;
Tree : Project_Tree_Ref;
Node_Tree : Project_Node_Tree_Ref;
begin
if Project.Qualifier not in Aggregate_Project then
return;
end if;
Debug_Increase_Indent ("Process_Aggregated_Projects", Project.Name);
Prj.Nmsc.Process_Aggregated_Projects
(Tree => In_Tree,
Project => Project,
Node_Tree => From_Project_Node_Tree,
Flags => Env.Flags);
List := Project.Aggregated_Projects;
while Success and then List /= null loop
Node_Tree := new Project_Node_Tree_Data;
Initialize (Node_Tree);
Prj.Part.Parse
(In_Tree => Node_Tree,
Project => Loaded_Project,
Packages_To_Check => Packages_To_Check,
Project_File_Name => Get_Name_String (List.Path),
Errout_Handling => Prj.Part.Never_Finalize,
Current_Directory => Get_Name_String (Project.Directory.Name),
Is_Config_File => False,
Env => Child_Env);
Success := not Prj.Tree.No (Loaded_Project);
if Success then
if Node_Tree.Incomplete_With then
From_Project_Node_Tree.Incomplete_With := True;
end if;
List.Tree := new Project_Tree_Data (Is_Root_Tree => False);
Prj.Initialize (List.Tree);
List.Tree.Shared := In_Tree.Shared;
-- In aggregate library, aggregated projects are parsed using
-- the aggregate library tree.
if Project.Qualifier = Aggregate_Library then
Tree := In_Tree;
else
Tree := List.Tree;
end if;
-- We can only do the phase 1 of the processing, since we do
-- not have access to the configuration file yet (this is
-- called when doing phase 1 of the processing for the root
-- aggregate project).
if In_Tree.Is_Root_Tree then
Process_Project_Tree_Phase_1
(In_Tree => Tree,
Project => List.Project,
Packages_To_Check => Packages_To_Check,
Success => Success,
From_Project_Node => Loaded_Project,
From_Project_Node_Tree => Node_Tree,
Env => Child_Env,
Reset_Tree => False,
On_New_Tree_Loaded => On_New_Tree_Loaded);
else
-- use the same environment as the rest of the aggregated
-- projects, ie the one that was setup by the root aggregate
Process_Project_Tree_Phase_1
(In_Tree => Tree,
Project => List.Project,
Packages_To_Check => Packages_To_Check,
Success => Success,
From_Project_Node => Loaded_Project,
From_Project_Node_Tree => Node_Tree,
Env => Env,
Reset_Tree => False,
On_New_Tree_Loaded => On_New_Tree_Loaded);
end if;
if On_New_Tree_Loaded /= null then
On_New_Tree_Loaded
(Node_Tree, Tree, Loaded_Project, List.Project);
end if;
else
Debug_Output ("Failed to parse", Name_Id (List.Path));
end if;
List := List.Next;
end loop;
Debug_Decrease_Indent ("Done Process_Aggregated_Projects");
end Process_Aggregated_Projects;
------------------------------
-- Process_Extended_Project --
------------------------------
procedure Process_Extended_Project is
Extended_Pkg : Package_Id;
Current_Pkg : Package_Id;
Element : Package_Element;
First : constant Package_Id := Project.Decl.Packages;
Attribute1 : Variable_Id;
Attribute2 : Variable_Id;
Attr_Value1 : Variable;
Attr_Value2 : Variable;
begin
Extended_Pkg := Project.Extends.Decl.Packages;
while Extended_Pkg /= No_Package loop
Element := Shared.Packages.Table (Extended_Pkg);
Current_Pkg := First;
while Current_Pkg /= No_Package
and then
Shared.Packages.Table (Current_Pkg).Name /= Element.Name
loop
Current_Pkg := Shared.Packages.Table (Current_Pkg).Next;
end loop;
if Current_Pkg = No_Package then
Package_Table.Increment_Last (Shared.Packages);
Current_Pkg := Package_Table.Last (Shared.Packages);
Shared.Packages.Table (Current_Pkg) :=
(Name => Element.Name,
Decl => No_Declarations,
Parent => No_Package,
Next => Project.Decl.Packages);
Project.Decl.Packages := Current_Pkg;
Copy_Package_Declarations
(From => Element.Decl,
To => Shared.Packages.Table (Current_Pkg).Decl,
New_Loc => No_Location,
Restricted => True,
Shared => Shared);
end if;
Extended_Pkg := Element.Next;
end loop;
-- Check if attribute Languages is declared in the extending project
Attribute1 := Project.Decl.Attributes;
while Attribute1 /= No_Variable loop
Attr_Value1 := Shared.Variable_Elements. Table (Attribute1);
exit when Attr_Value1.Name = Snames.Name_Languages;
Attribute1 := Attr_Value1.Next;
end loop;
if Attribute1 = No_Variable or else Attr_Value1.Value.Default then
-- Attribute Languages is not declared in the extending project.
-- Check if it is declared in the project being extended.
Attribute2 := Project.Extends.Decl.Attributes;
while Attribute2 /= No_Variable loop
Attr_Value2 := Shared.Variable_Elements.Table (Attribute2);
exit when Attr_Value2.Name = Snames.Name_Languages;
Attribute2 := Attr_Value2.Next;
end loop;
if Attribute2 /= No_Variable
and then not Attr_Value2.Value.Default
then
-- As attribute Languages is declared in the project being
-- extended, copy its value for the extending project.
if Attribute1 = No_Variable then
Variable_Element_Table.Increment_Last
(Shared.Variable_Elements);
Attribute1 := Variable_Element_Table.Last
(Shared.Variable_Elements);
Attr_Value1.Next := Project.Decl.Attributes;
Project.Decl.Attributes := Attribute1;
end if;
Attr_Value1.Name := Snames.Name_Languages;
Attr_Value1.Value := Attr_Value2.Value;
Shared.Variable_Elements.Table (Attribute1) := Attr_Value1;
end if;
end if;
end Process_Extended_Project;
-- Start of processing for Recursive_Process
begin
if No (From_Project_Node) then
Project := No_Project;
else
declare
Imported, Mark : Project_List;
Declaration_Node : Project_Node_Id := Empty_Node;
Name : constant Name_Id :=
Name_Of (From_Project_Node, From_Project_Node_Tree);
Display_Name : constant Name_Id :=
Display_Name_Of
(From_Project_Node, From_Project_Node_Tree);
begin
Project := Processed_Projects.Get (Name);
if Project /= No_Project then
-- Make sure that, when a project is extended, the project id
-- of the project extending it is recorded in its data, even
-- when it has already been processed as an imported project.
-- This is for virtually extended projects.
if Extended_By /= No_Project then
Project.Extended_By := Extended_By;
end if;
return;
end if;
-- Check if the project is already in the tree
Project := No_Project;
declare
List : Project_List := In_Tree.Projects;
Path : constant Path_Name_Type :=
Path_Name_Of (From_Project_Node,
From_Project_Node_Tree);
begin
while List /= null loop
if List.Project.Path.Display_Name = Path then
Project := List.Project;
exit;
end if;
List := List.Next;
end loop;
end;
if Project = No_Project then
Project :=
new Project_Data'
(Empty_Project
(Project_Qualifier_Of
(From_Project_Node, From_Project_Node_Tree)));
-- Note that at this point we do not know yet if the project
-- has been withed from an encapsulated library or not.
In_Tree.Projects :=
new Project_List_Element'
(Project => Project,
From_Encapsulated_Lib => False,
Next => In_Tree.Projects);
end if;
-- Keep track of this point
Mark := In_Tree.Projects;
Processed_Projects.Set (Name, Project);
Project.Name := Name;
Project.Display_Name := Display_Name;
Get_Name_String (Name);
-- If name starts with the virtual prefix, flag the project as
-- being a virtual extending project.
if Name_Len > Virtual_Prefix'Length
and then
Name_Buffer (1 .. Virtual_Prefix'Length) = Virtual_Prefix
then
Project.Virtual := True;
end if;
Project.Path.Display_Name :=
Path_Name_Of (From_Project_Node, From_Project_Node_Tree);
Get_Name_String (Project.Path.Display_Name);
Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
Project.Path.Name := Name_Find;
Project.Location :=
Location_Of (From_Project_Node, From_Project_Node_Tree);
Project.Directory.Display_Name :=
Directory_Of (From_Project_Node, From_Project_Node_Tree);
Get_Name_String (Project.Directory.Display_Name);
Canonical_Case_File_Name (Name_Buffer (1 .. Name_Len));
Project.Directory.Name := Name_Find;
Project.Extended_By := Extended_By;
Add_Attributes
(Project,
Name,
Name_Id (Project.Directory.Display_Name),
In_Tree.Shared,
Project.Decl,
Prj.Attr.Attribute_First,
Project_Level => True);
Process_Imported_Projects (Imported, Limited_With => False);
if Project.Qualifier = Aggregate then
Initialize_And_Copy (Child_Env, Copy_From => Env);
elsif Project.Qualifier = Aggregate_Library then
-- The child environment is the same as the current one
Child_Env := Env;
else
-- No need to initialize Child_Env, since it will not be
-- used anyway by Process_Declarative_Items (only the root
-- aggregate can modify it, and it is never read anyway).
null;
end if;
Declaration_Node :=
Project_Declaration_Of
(From_Project_Node, From_Project_Node_Tree);
Recursive_Process
(In_Tree => In_Tree,
Project => Project.Extends,
Packages_To_Check => Packages_To_Check,
From_Project_Node =>
Extended_Project_Of
(Declaration_Node, From_Project_Node_Tree),
From_Project_Node_Tree => From_Project_Node_Tree,
Env => Env,
Extended_By => Project,
From_Encapsulated_Lib => From_Encapsulated_Lib,
On_New_Tree_Loaded => On_New_Tree_Loaded);
Process_Declarative_Items
(Project => Project,
In_Tree => In_Tree,
From_Project_Node => From_Project_Node,
Node_Tree => From_Project_Node_Tree,
Env => Env,
Pkg => No_Package,
Item => First_Declarative_Item_Of
(Declaration_Node, From_Project_Node_Tree),
Child_Env => Child_Env);
if Project.Extends /= No_Project then
Process_Extended_Project;
end if;
Process_Imported_Projects (Imported, Limited_With => True);
if Total_Errors_Detected = 0 then
Process_Aggregated_Projects;
end if;
-- At this point (after Process_Declarative_Items) we have the
-- attribute values set, we can backtrace In_Tree.Project and
-- set the From_Encapsulated_Library status.
declare
Lib_Standalone : constant Prj.Variable_Value :=
Prj.Util.Value_Of
(Snames.Name_Library_Standalone,
Project.Decl.Attributes,
Shared);
List : Project_List := In_Tree.Projects;
Is_Encapsulated : Boolean;
begin
Get_Name_String (Lib_Standalone.Value);
To_Lower (Name_Buffer (1 .. Name_Len));
Is_Encapsulated := Name_Buffer (1 .. Name_Len) = "encapsulated";
if Is_Encapsulated then
while List /= null and then List /= Mark loop
List.From_Encapsulated_Lib := Is_Encapsulated;
List := List.Next;
end loop;
end if;
if Total_Errors_Detected = 0 then
-- For an aggregate library we add the aggregated projects
-- as imported ones. This is necessary to give visibility
-- to all sources from the aggregates from the aggregated
-- library projects.
if Project.Qualifier = Aggregate_Library then
declare
L : Aggregated_Project_List;
begin
L := Project.Aggregated_Projects;
while L /= null loop
Project.Imported_Projects :=
new Project_List_Element'
(Project => L.Project,
From_Encapsulated_Lib => Is_Encapsulated,
Next =>
Project.Imported_Projects);
L := L.Next;
end loop;
end;
end if;
end if;
end;
if Project.Qualifier = Aggregate and then In_Tree.Is_Root_Tree then
Free (Child_Env);
end if;
end;
end if;
end Recursive_Process;
-----------------------------
-- Set_Default_Runtime_For --
-----------------------------
procedure Set_Default_Runtime_For (Language : Name_Id; Value : String) is
begin
Name_Len := Value'Length;
Name_Buffer (1 .. Name_Len) := Value;
Runtime_Defaults.Set (Language, Name_Find);
end Set_Default_Runtime_For;
end Prj.Proc;
|
-----------------------------------------------------------------------
-- openapi-server-applications -- REST application
-- Copyright (C) 2017, 2019, 2022 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Util.Properties.Basic;
with OpenAPI.Servers.Config;
package body OpenAPI.Servers.Applications is
-- ------------------------------
-- Configures the REST application so that it is ready to handler REST
-- operations as well as give access to the OpenAPI UI that describes them.
-- ------------------------------
not overriding
procedure Configure (App : in out Application_Type;
Config : in Util.Properties.Manager'Class) is
use Util.Properties.Basic;
Cfg : Util.Properties.Manager;
Dir : constant String := Config.Get ("swagger.dir");
UI_Enable : constant Boolean := Boolean_Property.Get (Config, "swagger.ui.enable", True);
Web_Enable : constant Boolean := Boolean_Property.Get (Config, "swagger.web.enable", True);
Key : constant String := Config.Get ("swagger.key");
begin
Cfg.Copy (Config);
Cfg.Set ("view.dir", Dir & ";" & OpenAPI.Servers.Config.WEB_DIR);
App.Set_Init_Parameters (Cfg);
App.Realm.Load (Config, Config.Get ("swagger.users", "users"));
App.Apps.Load (Config, Config.Get ("swagger.apps", "apps"));
App.Filter.Set_Auth_Manager (App.Auth'Unchecked_Access);
-- Configure the authorization manager.
App.Auth.Set_Application_Manager (App.Apps'Unchecked_Access);
App.Auth.Set_Realm_Manager (App.Realm'Unchecked_Access);
App.OAuth.Set_Auth_Manager (App.Auth'Unchecked_Access);
App.Auth.Set_Private_Key (Key);
-- Register the servlets and filters
App.Add_Filter (Name => "oauth", Filter => App.Filter'Unchecked_Access);
App.Add_Servlet (Name => "api", Server => App.Api'Unchecked_Access);
App.Add_Servlet (Name => "files", Server => App.Files'Unchecked_Access);
App.Add_Servlet (Name => "oauth", Server => App.OAuth'Unchecked_Access);
-- Define servlet mappings
App.Add_Mapping (Name => "api", Pattern => "/*");
App.Add_Mapping (Name => "files", Pattern => "/swagger/*.json");
App.Add_Mapping (Name => "oauth", Pattern => "/oauth/token");
App.Add_Filter_Mapping (Name => "oauth", Pattern => "/*");
if UI_Enable then
App.Add_Mapping (Name => "files", Pattern => "/ui/*.html");
App.Add_Mapping (Name => "files", Pattern => "/ui/*.js");
App.Add_Mapping (Name => "files", Pattern => "/ui/*.png");
App.Add_Mapping (Name => "files", Pattern => "/ui/*.css");
App.Add_Mapping (Name => "files", Pattern => "/ui/*.map");
end if;
if Web_Enable then
App.Add_Mapping (Name => "files", Pattern => "*.html");
App.Add_Mapping (Name => "files", Pattern => "*.js");
App.Add_Mapping (Name => "files", Pattern => "*.png");
App.Add_Mapping (Name => "files", Pattern => "*.css");
App.Add_Mapping (Name => "files", Pattern => "*.map");
App.Add_Mapping (Name => "files", Pattern => "*.jpg");
end if;
end Configure;
end OpenAPI.Servers.Applications;
|
with Ada.Finalization;
with Ada.Streams;
with Google.Protobuf.Any;
with Google.Protobuf.Duration;
with Google.Protobuf.Field_Mask;
with Google.Protobuf.Struct;
with Google.Protobuf.Timestamp;
with Google.Protobuf.Wrappers;
with Interfaces;
with League.Stream_Element_Vectors;
with League.String_Vectors;
with League.Strings;
with PB_Support.Boolean_Vectors;
with PB_Support.IEEE_Float_32_Vectors;
with PB_Support.IEEE_Float_64_Vectors;
with PB_Support.Integer_32_Vectors;
with PB_Support.Integer_64_Vectors;
with PB_Support.Stream_Element_Vector_Vectors;
with PB_Support.Unsigned_32_Vectors;
with PB_Support.Unsigned_64_Vectors;
with PB_Support.Vectors;
package Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3 is
type Foreign_Enum is (FOREIGN_FOO, FOREIGN_BAR, FOREIGN_BAZ);
for Foreign_Enum use (FOREIGN_FOO => 0, FOREIGN_BAR => 1, FOREIGN_BAZ => 2);
package Foreign_Enum_Vectors is new PB_Support.Vectors (Foreign_Enum);
type Nested_Enum is (NEG, FOO, BAR, BAZ);
for Nested_Enum use (NEG => - 1, FOO => 0, BAR => 1, BAZ => 2);
package Nested_Enum_Vectors is new PB_Support.Vectors (Nested_Enum);
type Aliased_Enum is (ALIAS_FOO, ALIAS_BAR, ALIAS_BAZ);
for Aliased_Enum use (ALIAS_FOO => 0, ALIAS_BAR => 1, ALIAS_BAZ => 2);
function QUX return Aliased_Enum is (ALIAS_BAZ);
function bAz return Aliased_Enum is (QUX);
package Aliased_Enum_Vectors is new PB_Support.Vectors (Aliased_Enum);
type Test_All_Types_Proto_3_Vector is tagged private
with Variable_Indexing => Get_Test_All_Types_Proto_3_Variable_Reference,
Constant_Indexing => Get_Test_All_Types_Proto_3_Constant_Reference;
type Nested_Message_Vector is tagged private
with Variable_Indexing => Get_Nested_Message_Variable_Reference,
Constant_Indexing => Get_Nested_Message_Constant_Reference;
type Map_Int_32Int_32Entry_Vector is tagged private
with Variable_Indexing => Get_Map_Int_32Int_32Entry_Variable_Reference,
Constant_Indexing => Get_Map_Int_32Int_32Entry_Constant_Reference;
type Map_Int_64Int_64Entry_Vector is tagged private
with Variable_Indexing => Get_Map_Int_64Int_64Entry_Variable_Reference,
Constant_Indexing => Get_Map_Int_64Int_64Entry_Constant_Reference;
type Map_Uint_32Uint_32Entry_Vector is tagged private
with Variable_Indexing => Get_Map_Uint_32Uint_32Entry_Variable_Reference,
Constant_Indexing => Get_Map_Uint_32Uint_32Entry_Constant_Reference;
type Map_Uint_64Uint_64Entry_Vector is tagged private
with Variable_Indexing => Get_Map_Uint_64Uint_64Entry_Variable_Reference,
Constant_Indexing => Get_Map_Uint_64Uint_64Entry_Constant_Reference;
type Map_Sint_32Sint_32Entry_Vector is tagged private
with Variable_Indexing => Get_Map_Sint_32Sint_32Entry_Variable_Reference,
Constant_Indexing => Get_Map_Sint_32Sint_32Entry_Constant_Reference;
type Map_Sint_64Sint_64Entry_Vector is tagged private
with Variable_Indexing => Get_Map_Sint_64Sint_64Entry_Variable_Reference,
Constant_Indexing => Get_Map_Sint_64Sint_64Entry_Constant_Reference;
type Map_Fixed_32Fixed_32Entry_Vector is tagged private
with Variable_Indexing =>
Get_Map_Fixed_32Fixed_32Entry_Variable_Reference,
Constant_Indexing => Get_Map_Fixed_32Fixed_32Entry_Constant_Reference;
type Map_Fixed_64Fixed_64Entry_Vector is tagged private
with Variable_Indexing =>
Get_Map_Fixed_64Fixed_64Entry_Variable_Reference,
Constant_Indexing => Get_Map_Fixed_64Fixed_64Entry_Constant_Reference;
type Map_Sfixed_32Sfixed_32Entry_Vector is tagged private
with Variable_Indexing =>
Get_Map_Sfixed_32Sfixed_32Entry_Variable_Reference,
Constant_Indexing => Get_Map_Sfixed_32Sfixed_32Entry_Constant_Reference;
type Map_Sfixed_64Sfixed_64Entry_Vector is tagged private
with Variable_Indexing =>
Get_Map_Sfixed_64Sfixed_64Entry_Variable_Reference,
Constant_Indexing => Get_Map_Sfixed_64Sfixed_64Entry_Constant_Reference;
type Map_Int_32Float_Entry_Vector is tagged private
with Variable_Indexing => Get_Map_Int_32Float_Entry_Variable_Reference,
Constant_Indexing => Get_Map_Int_32Float_Entry_Constant_Reference;
type Map_Int_32Double_Entry_Vector is tagged private
with Variable_Indexing => Get_Map_Int_32Double_Entry_Variable_Reference,
Constant_Indexing => Get_Map_Int_32Double_Entry_Constant_Reference;
type Map_Bool_Bool_Entry_Vector is tagged private
with Variable_Indexing => Get_Map_Bool_Bool_Entry_Variable_Reference,
Constant_Indexing => Get_Map_Bool_Bool_Entry_Constant_Reference;
type Map_String_String_Entry_Vector is tagged private
with Variable_Indexing => Get_Map_String_String_Entry_Variable_Reference,
Constant_Indexing => Get_Map_String_String_Entry_Constant_Reference;
type Map_String_Bytes_Entry_Vector is tagged private
with Variable_Indexing => Get_Map_String_Bytes_Entry_Variable_Reference,
Constant_Indexing => Get_Map_String_Bytes_Entry_Constant_Reference;
type Map_String_Nested_Message_Entry_Vector is tagged private
with Variable_Indexing =>
Get_Map_String_Nested_Message_Entry_Variable_Reference,
Constant_Indexing =>
Get_Map_String_Nested_Message_Entry_Constant_Reference;
type Map_String_Foreign_Message_Entry_Vector is tagged private
with Variable_Indexing =>
Get_Map_String_Foreign_Message_Entry_Variable_Reference,
Constant_Indexing =>
Get_Map_String_Foreign_Message_Entry_Constant_Reference;
type Map_String_Nested_Enum_Entry_Vector is tagged private
with Variable_Indexing =>
Get_Map_String_Nested_Enum_Entry_Variable_Reference,
Constant_Indexing => Get_Map_String_Nested_Enum_Entry_Constant_Reference;
type Map_String_Foreign_Enum_Entry_Vector is tagged private
with Variable_Indexing =>
Get_Map_String_Foreign_Enum_Entry_Variable_Reference,
Constant_Indexing => Get_Map_String_Foreign_Enum_Entry_Constant_Reference;
type Foreign_Message_Vector is tagged private
with Variable_Indexing => Get_Foreign_Message_Variable_Reference,
Constant_Indexing => Get_Foreign_Message_Constant_Reference;
type Map_Int_32Int_32Entry is
record
Key : Interfaces.Integer_32 := 0;
Value : Interfaces.Integer_32 := 0;
end record;
type Optional_Map_Int_32Int_32Entry (Is_Set : Boolean := False) is
record
case Is_Set is
when True =>
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Map_Int_32Int_32Entry;
when False =>
null;
end case;
end record;
function Length (Self : Map_Int_32Int_32Entry_Vector) return Natural;
procedure Clear (Self : in out Map_Int_32Int_32Entry_Vector);
procedure Append
(Self : in out Map_Int_32Int_32Entry_Vector;
V : Map_Int_32Int_32Entry);
type Map_Int_32Int_32Entry_Variable_Reference
(Element : not null access Map_Int_32Int_32Entry) is null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Int_32Int_32Entry_Variable_Reference
(Self : aliased in out Map_Int_32Int_32Entry_Vector;
Index : Positive)
return Map_Int_32Int_32Entry_Variable_Reference
with Inline;
type Map_Int_32Int_32Entry_Constant_Reference
(Element : not null access constant Map_Int_32Int_32Entry) is null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Int_32Int_32Entry_Constant_Reference
(Self : aliased Map_Int_32Int_32Entry_Vector;
Index : Positive)
return Map_Int_32Int_32Entry_Constant_Reference
with Inline;
type Map_Int_64Int_64Entry is
record
Key : Interfaces.Integer_64 := 0;
Value : Interfaces.Integer_64 := 0;
end record;
type Optional_Map_Int_64Int_64Entry (Is_Set : Boolean := False) is
record
case Is_Set is
when True =>
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Map_Int_64Int_64Entry;
when False =>
null;
end case;
end record;
function Length (Self : Map_Int_64Int_64Entry_Vector) return Natural;
procedure Clear (Self : in out Map_Int_64Int_64Entry_Vector);
procedure Append
(Self : in out Map_Int_64Int_64Entry_Vector;
V : Map_Int_64Int_64Entry);
type Map_Int_64Int_64Entry_Variable_Reference
(Element : not null access Map_Int_64Int_64Entry) is null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Int_64Int_64Entry_Variable_Reference
(Self : aliased in out Map_Int_64Int_64Entry_Vector;
Index : Positive)
return Map_Int_64Int_64Entry_Variable_Reference
with Inline;
type Map_Int_64Int_64Entry_Constant_Reference
(Element : not null access constant Map_Int_64Int_64Entry) is null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Int_64Int_64Entry_Constant_Reference
(Self : aliased Map_Int_64Int_64Entry_Vector;
Index : Positive)
return Map_Int_64Int_64Entry_Constant_Reference
with Inline;
type Map_Uint_32Uint_32Entry is
record
Key : Interfaces.Unsigned_32 := 0;
Value : Interfaces.Unsigned_32 := 0;
end record;
type Optional_Map_Uint_32Uint_32Entry (Is_Set : Boolean := False) is
record
case Is_Set is
when True =>
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Map_Uint_32Uint_32Entry;
when False =>
null;
end case;
end record;
function Length (Self : Map_Uint_32Uint_32Entry_Vector) return Natural;
procedure Clear (Self : in out Map_Uint_32Uint_32Entry_Vector);
procedure Append
(Self : in out Map_Uint_32Uint_32Entry_Vector;
V : Map_Uint_32Uint_32Entry);
type Map_Uint_32Uint_32Entry_Variable_Reference
(Element : not null access Map_Uint_32Uint_32Entry) is null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Uint_32Uint_32Entry_Variable_Reference
(Self : aliased in out Map_Uint_32Uint_32Entry_Vector;
Index : Positive)
return Map_Uint_32Uint_32Entry_Variable_Reference
with Inline;
type Map_Uint_32Uint_32Entry_Constant_Reference
(Element : not null access constant Map_Uint_32Uint_32Entry) is
null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Uint_32Uint_32Entry_Constant_Reference
(Self : aliased Map_Uint_32Uint_32Entry_Vector;
Index : Positive)
return Map_Uint_32Uint_32Entry_Constant_Reference
with Inline;
type Map_Uint_64Uint_64Entry is
record
Key : Interfaces.Unsigned_64 := 0;
Value : Interfaces.Unsigned_64 := 0;
end record;
type Optional_Map_Uint_64Uint_64Entry (Is_Set : Boolean := False) is
record
case Is_Set is
when True =>
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Map_Uint_64Uint_64Entry;
when False =>
null;
end case;
end record;
function Length (Self : Map_Uint_64Uint_64Entry_Vector) return Natural;
procedure Clear (Self : in out Map_Uint_64Uint_64Entry_Vector);
procedure Append
(Self : in out Map_Uint_64Uint_64Entry_Vector;
V : Map_Uint_64Uint_64Entry);
type Map_Uint_64Uint_64Entry_Variable_Reference
(Element : not null access Map_Uint_64Uint_64Entry) is null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Uint_64Uint_64Entry_Variable_Reference
(Self : aliased in out Map_Uint_64Uint_64Entry_Vector;
Index : Positive)
return Map_Uint_64Uint_64Entry_Variable_Reference
with Inline;
type Map_Uint_64Uint_64Entry_Constant_Reference
(Element : not null access constant Map_Uint_64Uint_64Entry) is
null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Uint_64Uint_64Entry_Constant_Reference
(Self : aliased Map_Uint_64Uint_64Entry_Vector;
Index : Positive)
return Map_Uint_64Uint_64Entry_Constant_Reference
with Inline;
type Map_Sint_32Sint_32Entry is
record
Key : Interfaces.Integer_32 := 0;
Value : Interfaces.Integer_32 := 0;
end record;
type Optional_Map_Sint_32Sint_32Entry (Is_Set : Boolean := False) is
record
case Is_Set is
when True =>
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Map_Sint_32Sint_32Entry;
when False =>
null;
end case;
end record;
function Length (Self : Map_Sint_32Sint_32Entry_Vector) return Natural;
procedure Clear (Self : in out Map_Sint_32Sint_32Entry_Vector);
procedure Append
(Self : in out Map_Sint_32Sint_32Entry_Vector;
V : Map_Sint_32Sint_32Entry);
type Map_Sint_32Sint_32Entry_Variable_Reference
(Element : not null access Map_Sint_32Sint_32Entry) is null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Sint_32Sint_32Entry_Variable_Reference
(Self : aliased in out Map_Sint_32Sint_32Entry_Vector;
Index : Positive)
return Map_Sint_32Sint_32Entry_Variable_Reference
with Inline;
type Map_Sint_32Sint_32Entry_Constant_Reference
(Element : not null access constant Map_Sint_32Sint_32Entry) is
null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Sint_32Sint_32Entry_Constant_Reference
(Self : aliased Map_Sint_32Sint_32Entry_Vector;
Index : Positive)
return Map_Sint_32Sint_32Entry_Constant_Reference
with Inline;
type Map_Sint_64Sint_64Entry is
record
Key : Interfaces.Integer_64 := 0;
Value : Interfaces.Integer_64 := 0;
end record;
type Optional_Map_Sint_64Sint_64Entry (Is_Set : Boolean := False) is
record
case Is_Set is
when True =>
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Map_Sint_64Sint_64Entry;
when False =>
null;
end case;
end record;
function Length (Self : Map_Sint_64Sint_64Entry_Vector) return Natural;
procedure Clear (Self : in out Map_Sint_64Sint_64Entry_Vector);
procedure Append
(Self : in out Map_Sint_64Sint_64Entry_Vector;
V : Map_Sint_64Sint_64Entry);
type Map_Sint_64Sint_64Entry_Variable_Reference
(Element : not null access Map_Sint_64Sint_64Entry) is null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Sint_64Sint_64Entry_Variable_Reference
(Self : aliased in out Map_Sint_64Sint_64Entry_Vector;
Index : Positive)
return Map_Sint_64Sint_64Entry_Variable_Reference
with Inline;
type Map_Sint_64Sint_64Entry_Constant_Reference
(Element : not null access constant Map_Sint_64Sint_64Entry) is
null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Sint_64Sint_64Entry_Constant_Reference
(Self : aliased Map_Sint_64Sint_64Entry_Vector;
Index : Positive)
return Map_Sint_64Sint_64Entry_Constant_Reference
with Inline;
type Map_Fixed_32Fixed_32Entry is
record
Key : Interfaces.Unsigned_32 := 0;
Value : Interfaces.Unsigned_32 := 0;
end record;
type Optional_Map_Fixed_32Fixed_32Entry (Is_Set : Boolean := False) is
record
case Is_Set is
when True =>
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Map_Fixed_32Fixed_32Entry;
when False =>
null;
end case;
end record;
function Length (Self : Map_Fixed_32Fixed_32Entry_Vector) return Natural;
procedure Clear (Self : in out Map_Fixed_32Fixed_32Entry_Vector);
procedure Append
(Self : in out Map_Fixed_32Fixed_32Entry_Vector;
V : Map_Fixed_32Fixed_32Entry);
type Map_Fixed_32Fixed_32Entry_Variable_Reference
(Element : not null access Map_Fixed_32Fixed_32Entry) is null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Fixed_32Fixed_32Entry_Variable_Reference
(Self : aliased in out Map_Fixed_32Fixed_32Entry_Vector;
Index : Positive)
return Map_Fixed_32Fixed_32Entry_Variable_Reference
with Inline;
type Map_Fixed_32Fixed_32Entry_Constant_Reference
(Element : not null access constant Map_Fixed_32Fixed_32Entry) is
null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Fixed_32Fixed_32Entry_Constant_Reference
(Self : aliased Map_Fixed_32Fixed_32Entry_Vector;
Index : Positive)
return Map_Fixed_32Fixed_32Entry_Constant_Reference
with Inline;
type Map_Fixed_64Fixed_64Entry is
record
Key : Interfaces.Unsigned_64 := 0;
Value : Interfaces.Unsigned_64 := 0;
end record;
type Optional_Map_Fixed_64Fixed_64Entry (Is_Set : Boolean := False) is
record
case Is_Set is
when True =>
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Map_Fixed_64Fixed_64Entry;
when False =>
null;
end case;
end record;
function Length (Self : Map_Fixed_64Fixed_64Entry_Vector) return Natural;
procedure Clear (Self : in out Map_Fixed_64Fixed_64Entry_Vector);
procedure Append
(Self : in out Map_Fixed_64Fixed_64Entry_Vector;
V : Map_Fixed_64Fixed_64Entry);
type Map_Fixed_64Fixed_64Entry_Variable_Reference
(Element : not null access Map_Fixed_64Fixed_64Entry) is null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Fixed_64Fixed_64Entry_Variable_Reference
(Self : aliased in out Map_Fixed_64Fixed_64Entry_Vector;
Index : Positive)
return Map_Fixed_64Fixed_64Entry_Variable_Reference
with Inline;
type Map_Fixed_64Fixed_64Entry_Constant_Reference
(Element : not null access constant Map_Fixed_64Fixed_64Entry) is
null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Fixed_64Fixed_64Entry_Constant_Reference
(Self : aliased Map_Fixed_64Fixed_64Entry_Vector;
Index : Positive)
return Map_Fixed_64Fixed_64Entry_Constant_Reference
with Inline;
type Map_Sfixed_32Sfixed_32Entry is
record
Key : Interfaces.Integer_32 := 0;
Value : Interfaces.Integer_32 := 0;
end record;
type Optional_Map_Sfixed_32Sfixed_32Entry (Is_Set : Boolean := False) is
record
case Is_Set is
when True =>
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Map_Sfixed_32Sfixed_32Entry;
when False =>
null;
end case;
end record;
function Length (Self : Map_Sfixed_32Sfixed_32Entry_Vector) return Natural;
procedure Clear (Self : in out Map_Sfixed_32Sfixed_32Entry_Vector);
procedure Append
(Self : in out Map_Sfixed_32Sfixed_32Entry_Vector;
V : Map_Sfixed_32Sfixed_32Entry);
type Map_Sfixed_32Sfixed_32Entry_Variable_Reference
(Element : not null access Map_Sfixed_32Sfixed_32Entry) is null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Sfixed_32Sfixed_32Entry_Variable_Reference
(Self : aliased in out Map_Sfixed_32Sfixed_32Entry_Vector;
Index : Positive)
return Map_Sfixed_32Sfixed_32Entry_Variable_Reference
with Inline;
type Map_Sfixed_32Sfixed_32Entry_Constant_Reference
(Element : not null access constant Map_Sfixed_32Sfixed_32Entry) is
null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Sfixed_32Sfixed_32Entry_Constant_Reference
(Self : aliased Map_Sfixed_32Sfixed_32Entry_Vector;
Index : Positive)
return Map_Sfixed_32Sfixed_32Entry_Constant_Reference
with Inline;
type Map_Sfixed_64Sfixed_64Entry is
record
Key : Interfaces.Integer_64 := 0;
Value : Interfaces.Integer_64 := 0;
end record;
type Optional_Map_Sfixed_64Sfixed_64Entry (Is_Set : Boolean := False) is
record
case Is_Set is
when True =>
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Map_Sfixed_64Sfixed_64Entry;
when False =>
null;
end case;
end record;
function Length (Self : Map_Sfixed_64Sfixed_64Entry_Vector) return Natural;
procedure Clear (Self : in out Map_Sfixed_64Sfixed_64Entry_Vector);
procedure Append
(Self : in out Map_Sfixed_64Sfixed_64Entry_Vector;
V : Map_Sfixed_64Sfixed_64Entry);
type Map_Sfixed_64Sfixed_64Entry_Variable_Reference
(Element : not null access Map_Sfixed_64Sfixed_64Entry) is null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Sfixed_64Sfixed_64Entry_Variable_Reference
(Self : aliased in out Map_Sfixed_64Sfixed_64Entry_Vector;
Index : Positive)
return Map_Sfixed_64Sfixed_64Entry_Variable_Reference
with Inline;
type Map_Sfixed_64Sfixed_64Entry_Constant_Reference
(Element : not null access constant Map_Sfixed_64Sfixed_64Entry) is
null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Sfixed_64Sfixed_64Entry_Constant_Reference
(Self : aliased Map_Sfixed_64Sfixed_64Entry_Vector;
Index : Positive)
return Map_Sfixed_64Sfixed_64Entry_Constant_Reference
with Inline;
type Map_Int_32Float_Entry is
record
Key : Interfaces.Integer_32 := 0;
Value : Interfaces.IEEE_Float_32 := 0.0;
end record;
type Optional_Map_Int_32Float_Entry (Is_Set : Boolean := False) is
record
case Is_Set is
when True =>
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Map_Int_32Float_Entry;
when False =>
null;
end case;
end record;
function Length (Self : Map_Int_32Float_Entry_Vector) return Natural;
procedure Clear (Self : in out Map_Int_32Float_Entry_Vector);
procedure Append
(Self : in out Map_Int_32Float_Entry_Vector;
V : Map_Int_32Float_Entry);
type Map_Int_32Float_Entry_Variable_Reference
(Element : not null access Map_Int_32Float_Entry) is null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Int_32Float_Entry_Variable_Reference
(Self : aliased in out Map_Int_32Float_Entry_Vector;
Index : Positive)
return Map_Int_32Float_Entry_Variable_Reference
with Inline;
type Map_Int_32Float_Entry_Constant_Reference
(Element : not null access constant Map_Int_32Float_Entry) is null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Int_32Float_Entry_Constant_Reference
(Self : aliased Map_Int_32Float_Entry_Vector;
Index : Positive)
return Map_Int_32Float_Entry_Constant_Reference
with Inline;
type Map_Int_32Double_Entry is
record
Key : Interfaces.Integer_32 := 0;
Value : Interfaces.IEEE_Float_64 := 0.0;
end record;
type Optional_Map_Int_32Double_Entry (Is_Set : Boolean := False) is
record
case Is_Set is
when True =>
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Map_Int_32Double_Entry;
when False =>
null;
end case;
end record;
function Length (Self : Map_Int_32Double_Entry_Vector) return Natural;
procedure Clear (Self : in out Map_Int_32Double_Entry_Vector);
procedure Append
(Self : in out Map_Int_32Double_Entry_Vector;
V : Map_Int_32Double_Entry);
type Map_Int_32Double_Entry_Variable_Reference
(Element : not null access Map_Int_32Double_Entry) is null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Int_32Double_Entry_Variable_Reference
(Self : aliased in out Map_Int_32Double_Entry_Vector;
Index : Positive)
return Map_Int_32Double_Entry_Variable_Reference
with Inline;
type Map_Int_32Double_Entry_Constant_Reference
(Element : not null access constant Map_Int_32Double_Entry) is null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Int_32Double_Entry_Constant_Reference
(Self : aliased Map_Int_32Double_Entry_Vector;
Index : Positive)
return Map_Int_32Double_Entry_Constant_Reference
with Inline;
type Map_Bool_Bool_Entry is
record
Key : Boolean := False;
Value : Boolean := False;
end record;
type Optional_Map_Bool_Bool_Entry (Is_Set : Boolean := False) is
record
case Is_Set is
when True =>
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Map_Bool_Bool_Entry;
when False =>
null;
end case;
end record;
function Length (Self : Map_Bool_Bool_Entry_Vector) return Natural;
procedure Clear (Self : in out Map_Bool_Bool_Entry_Vector);
procedure Append
(Self : in out Map_Bool_Bool_Entry_Vector;
V : Map_Bool_Bool_Entry);
type Map_Bool_Bool_Entry_Variable_Reference
(Element : not null access Map_Bool_Bool_Entry) is null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Bool_Bool_Entry_Variable_Reference
(Self : aliased in out Map_Bool_Bool_Entry_Vector;
Index : Positive)
return Map_Bool_Bool_Entry_Variable_Reference
with Inline;
type Map_Bool_Bool_Entry_Constant_Reference
(Element : not null access constant Map_Bool_Bool_Entry) is null record
with Implicit_Dereference => Element;
not overriding function Get_Map_Bool_Bool_Entry_Constant_Reference
(Self : aliased Map_Bool_Bool_Entry_Vector;
Index : Positive)
return Map_Bool_Bool_Entry_Constant_Reference
with Inline;
type Map_String_String_Entry is
record
Key : League.Strings.Universal_String;
Value : League.Strings.Universal_String;
end record;
type Optional_Map_String_String_Entry (Is_Set : Boolean := False) is
record
case Is_Set is
when True =>
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Map_String_String_Entry;
when False =>
null;
end case;
end record;
function Length (Self : Map_String_String_Entry_Vector) return Natural;
procedure Clear (Self : in out Map_String_String_Entry_Vector);
procedure Append
(Self : in out Map_String_String_Entry_Vector;
V : Map_String_String_Entry);
type Map_String_String_Entry_Variable_Reference
(Element : not null access Map_String_String_Entry) is null record
with Implicit_Dereference => Element;
not overriding function Get_Map_String_String_Entry_Variable_Reference
(Self : aliased in out Map_String_String_Entry_Vector;
Index : Positive)
return Map_String_String_Entry_Variable_Reference
with Inline;
type Map_String_String_Entry_Constant_Reference
(Element : not null access constant Map_String_String_Entry) is
null record
with Implicit_Dereference => Element;
not overriding function Get_Map_String_String_Entry_Constant_Reference
(Self : aliased Map_String_String_Entry_Vector;
Index : Positive)
return Map_String_String_Entry_Constant_Reference
with Inline;
type Map_String_Bytes_Entry is
record
Key : League.Strings.Universal_String;
Value : League.Stream_Element_Vectors.Stream_Element_Vector;
end record;
type Optional_Map_String_Bytes_Entry (Is_Set : Boolean := False) is
record
case Is_Set is
when True =>
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Map_String_Bytes_Entry;
when False =>
null;
end case;
end record;
function Length (Self : Map_String_Bytes_Entry_Vector) return Natural;
procedure Clear (Self : in out Map_String_Bytes_Entry_Vector);
procedure Append
(Self : in out Map_String_Bytes_Entry_Vector;
V : Map_String_Bytes_Entry);
type Map_String_Bytes_Entry_Variable_Reference
(Element : not null access Map_String_Bytes_Entry) is null record
with Implicit_Dereference => Element;
not overriding function Get_Map_String_Bytes_Entry_Variable_Reference
(Self : aliased in out Map_String_Bytes_Entry_Vector;
Index : Positive)
return Map_String_Bytes_Entry_Variable_Reference
with Inline;
type Map_String_Bytes_Entry_Constant_Reference
(Element : not null access constant Map_String_Bytes_Entry) is null record
with Implicit_Dereference => Element;
not overriding function Get_Map_String_Bytes_Entry_Constant_Reference
(Self : aliased Map_String_Bytes_Entry_Vector;
Index : Positive)
return Map_String_Bytes_Entry_Constant_Reference
with Inline;
type Map_String_Nested_Enum_Entry is
record
Key : League.Strings.Universal_String;
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Nested_Enum :=
Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3.FOO;
end record;
type Optional_Map_String_Nested_Enum_Entry (Is_Set : Boolean := False) is
record
case Is_Set is
when True =>
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Map_String_Nested_Enum_Entry;
when False =>
null;
end case;
end record;
function Length (Self : Map_String_Nested_Enum_Entry_Vector) return Natural;
procedure Clear (Self : in out Map_String_Nested_Enum_Entry_Vector);
procedure Append
(Self : in out Map_String_Nested_Enum_Entry_Vector;
V : Map_String_Nested_Enum_Entry);
type Map_String_Nested_Enum_Entry_Variable_Reference
(Element : not null access Map_String_Nested_Enum_Entry) is null record
with Implicit_Dereference => Element;
not overriding function Get_Map_String_Nested_Enum_Entry_Variable_Reference
(Self : aliased in out Map_String_Nested_Enum_Entry_Vector;
Index : Positive)
return Map_String_Nested_Enum_Entry_Variable_Reference
with Inline;
type Map_String_Nested_Enum_Entry_Constant_Reference
(Element : not null access constant Map_String_Nested_Enum_Entry) is
null record
with Implicit_Dereference => Element;
not overriding function Get_Map_String_Nested_Enum_Entry_Constant_Reference
(Self : aliased Map_String_Nested_Enum_Entry_Vector;
Index : Positive)
return Map_String_Nested_Enum_Entry_Constant_Reference
with Inline;
type Map_String_Foreign_Enum_Entry is
record
Key : League.Strings.Universal_String;
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Foreign_Enum :=
Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3.FOREIGN_FOO;
end record;
type Optional_Map_String_Foreign_Enum_Entry (Is_Set : Boolean := False) is
record
case Is_Set is
when True =>
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Map_String_Foreign_Enum_Entry;
when False =>
null;
end case;
end record;
function Length
(Self : Map_String_Foreign_Enum_Entry_Vector)
return Natural;
procedure Clear (Self : in out Map_String_Foreign_Enum_Entry_Vector);
procedure Append
(Self : in out Map_String_Foreign_Enum_Entry_Vector;
V : Map_String_Foreign_Enum_Entry);
type Map_String_Foreign_Enum_Entry_Variable_Reference
(Element : not null access Map_String_Foreign_Enum_Entry) is null record
with Implicit_Dereference => Element;
not overriding function Get_Map_String_Foreign_Enum_Entry_Variable_Reference
(Self : aliased in out Map_String_Foreign_Enum_Entry_Vector;
Index : Positive)
return Map_String_Foreign_Enum_Entry_Variable_Reference
with Inline;
type Map_String_Foreign_Enum_Entry_Constant_Reference
(Element : not null access constant Map_String_Foreign_Enum_Entry) is
null record
with Implicit_Dereference => Element;
not overriding function Get_Map_String_Foreign_Enum_Entry_Constant_Reference
(Self : aliased Map_String_Foreign_Enum_Entry_Vector;
Index : Positive)
return Map_String_Foreign_Enum_Entry_Constant_Reference
with Inline;
type Foreign_Message is record C : Interfaces.Integer_32 := 0; end record;
type Optional_Foreign_Message (Is_Set : Boolean := False) is
record
case Is_Set is
when True =>
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Foreign_Message;
when False =>
null;
end case;
end record;
function Length (Self : Foreign_Message_Vector) return Natural;
procedure Clear (Self : in out Foreign_Message_Vector);
procedure Append
(Self : in out Foreign_Message_Vector;
V : Foreign_Message);
type Foreign_Message_Variable_Reference
(Element : not null access Foreign_Message) is null record
with Implicit_Dereference => Element;
not overriding function Get_Foreign_Message_Variable_Reference
(Self : aliased in out Foreign_Message_Vector;
Index : Positive)
return Foreign_Message_Variable_Reference
with Inline;
type Foreign_Message_Constant_Reference
(Element : not null access constant Foreign_Message) is null record
with Implicit_Dereference => Element;
not overriding function Get_Foreign_Message_Constant_Reference
(Self : aliased Foreign_Message_Vector;
Index : Positive)
return Foreign_Message_Constant_Reference
with Inline;
type Map_String_Foreign_Message_Entry is
record
Key : League.Strings.Universal_String;
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Optional_Foreign_Message;
end record;
type Optional_Map_String_Foreign_Message_Entry
(Is_Set : Boolean := False) is
record
case Is_Set is
when True =>
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Map_String_Foreign_Message_Entry;
when False =>
null;
end case;
end record;
function Length
(Self : Map_String_Foreign_Message_Entry_Vector)
return Natural;
procedure Clear (Self : in out Map_String_Foreign_Message_Entry_Vector);
procedure Append
(Self : in out Map_String_Foreign_Message_Entry_Vector;
V : Map_String_Foreign_Message_Entry);
type Map_String_Foreign_Message_Entry_Variable_Reference
(Element : not null access Map_String_Foreign_Message_Entry) is
null record
with Implicit_Dereference => Element;
not overriding function Get_Map_String_Foreign_Message_Entry_Variable_Reference
(Self : aliased in out Map_String_Foreign_Message_Entry_Vector;
Index : Positive)
return Map_String_Foreign_Message_Entry_Variable_Reference
with Inline;
type Map_String_Foreign_Message_Entry_Constant_Reference
(Element : not null access constant Map_String_Foreign_Message_Entry) is
null record
with Implicit_Dereference => Element;
not overriding function Get_Map_String_Foreign_Message_Entry_Constant_Reference
(Self : aliased Map_String_Foreign_Message_Entry_Vector;
Index : Positive)
return Map_String_Foreign_Message_Entry_Constant_Reference
with Inline;
type Nested_Message is
record
A : Interfaces.Integer_32 := 0;
Corecursive : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Test_All_Types_Proto_3_Vector;
end record;
type Optional_Nested_Message (Is_Set : Boolean := False) is
record
case Is_Set is
when True =>
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Nested_Message;
when False =>
null;
end case;
end record;
function Length (Self : Nested_Message_Vector) return Natural;
procedure Clear (Self : in out Nested_Message_Vector);
procedure Append
(Self : in out Nested_Message_Vector;
V : Nested_Message);
type Nested_Message_Variable_Reference
(Element : not null access Nested_Message) is null record
with Implicit_Dereference => Element;
not overriding function Get_Nested_Message_Variable_Reference
(Self : aliased in out Nested_Message_Vector;
Index : Positive)
return Nested_Message_Variable_Reference
with Inline;
type Nested_Message_Constant_Reference
(Element : not null access constant Nested_Message) is null record
with Implicit_Dereference => Element;
not overriding function Get_Nested_Message_Constant_Reference
(Self : aliased Nested_Message_Vector;
Index : Positive)
return Nested_Message_Constant_Reference
with Inline;
type Map_String_Nested_Message_Entry is
record
Key : League.Strings.Universal_String;
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Optional_Nested_Message;
end record;
type Optional_Map_String_Nested_Message_Entry
(Is_Set : Boolean := False) is
record
case Is_Set is
when True =>
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Map_String_Nested_Message_Entry;
when False =>
null;
end case;
end record;
function Length
(Self : Map_String_Nested_Message_Entry_Vector)
return Natural;
procedure Clear (Self : in out Map_String_Nested_Message_Entry_Vector);
procedure Append
(Self : in out Map_String_Nested_Message_Entry_Vector;
V : Map_String_Nested_Message_Entry);
type Map_String_Nested_Message_Entry_Variable_Reference
(Element : not null access Map_String_Nested_Message_Entry) is null record
with Implicit_Dereference => Element;
not overriding function Get_Map_String_Nested_Message_Entry_Variable_Reference
(Self : aliased in out Map_String_Nested_Message_Entry_Vector;
Index : Positive)
return Map_String_Nested_Message_Entry_Variable_Reference
with Inline;
type Map_String_Nested_Message_Entry_Constant_Reference
(Element : not null access constant Map_String_Nested_Message_Entry) is
null record
with Implicit_Dereference => Element;
not overriding function Get_Map_String_Nested_Message_Entry_Constant_Reference
(Self : aliased Map_String_Nested_Message_Entry_Vector;
Index : Positive)
return Map_String_Nested_Message_Entry_Constant_Reference
with Inline;
type Test_All_Types_Proto_3_Variant_Kind is
(Oneof_Field_Not_Set,
Oneof_Uint_32_Kind ,
Oneof_Nested_Message_Kind,
Oneof_String_Kind ,
Oneof_Bytes_Kind ,
Oneof_Bool_Kind ,
Oneof_Uint_64_Kind ,
Oneof_Float_Kind ,
Oneof_Double_Kind ,
Oneof_Enum_Kind );
type Test_All_Types_Proto_3_Variant
(Oneof_Field : Test_All_Types_Proto_3_Variant_Kind := Oneof_Field_Not_Set) is
record
case Oneof_Field is
when Oneof_Field_Not_Set =>
null;
when Oneof_Uint_32_Kind =>
Oneof_Uint_32 : Interfaces.Unsigned_32 := 0;
when Oneof_Nested_Message_Kind =>
Oneof_Nested_Message : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Nested_Message;
when Oneof_String_Kind =>
Oneof_String : League.Strings.Universal_String;
when Oneof_Bytes_Kind =>
Oneof_Bytes : League.Stream_Element_Vectors
.Stream_Element_Vector;
when Oneof_Bool_Kind =>
Oneof_Bool : Boolean := False;
when Oneof_Uint_64_Kind =>
Oneof_Uint_64 : Interfaces.Unsigned_64 := 0;
when Oneof_Float_Kind =>
Oneof_Float : Interfaces.IEEE_Float_32 := 0.0;
when Oneof_Double_Kind =>
Oneof_Double : Interfaces.IEEE_Float_64 := 0.0;
when Oneof_Enum_Kind =>
Oneof_Enum : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Nested_Enum :=
Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3.FOO;
end case;
end record;
type Test_All_Types_Proto_3 is
record
Optional_Int_32 : Interfaces.Integer_32 := 0;
Optional_Int_64 : Interfaces.Integer_64 := 0;
Optional_Uint_32 : Interfaces.Unsigned_32 := 0;
Optional_Uint_64 : Interfaces.Unsigned_64 := 0;
Optional_Sint_32 : Interfaces.Integer_32 := 0;
Optional_Sint_64 : Interfaces.Integer_64 := 0;
Optional_Fixed_32 : Interfaces.Unsigned_32 := 0;
Optional_Fixed_64 : Interfaces.Unsigned_64 := 0;
Optional_Sfixed_32 : Interfaces.Integer_32 := 0;
Optional_Sfixed_64 : Interfaces.Integer_64 := 0;
Optional_Float : Interfaces.IEEE_Float_32 := 0.0;
Optional_Double : Interfaces.IEEE_Float_64 := 0.0;
Optional_Bool : Boolean := False;
Optional_String : League.Strings.Universal_String;
Optional_Bytes : League.Stream_Element_Vectors
.Stream_Element_Vector;
Optional_Nested_Message : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Optional_Nested_Message;
Optional_Foreign_Message : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Optional_Foreign_Message;
Optional_Nested_Enum : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Nested_Enum :=
Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3.FOO;
Optional_Foreign_Enum : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Foreign_Enum :=
Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3.FOREIGN_FOO;
Optional_Aliased_Enum : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Aliased_Enum :=
Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3.ALIAS_FOO;
Optional_String_Piece : League.Strings.Universal_String;
Optional_Cord : League.Strings.Universal_String;
Recursive_Message : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Test_All_Types_Proto_3_Vector;
Repeated_Int_32 : PB_Support.Integer_32_Vectors.Vector;
Repeated_Int_64 : PB_Support.Integer_64_Vectors.Vector;
Repeated_Uint_32 : PB_Support.Unsigned_32_Vectors.Vector;
Repeated_Uint_64 : PB_Support.Unsigned_64_Vectors.Vector;
Repeated_Sint_32 : PB_Support.Integer_32_Vectors.Vector;
Repeated_Sint_64 : PB_Support.Integer_64_Vectors.Vector;
Repeated_Fixed_32 : PB_Support.Unsigned_32_Vectors.Vector;
Repeated_Fixed_64 : PB_Support.Unsigned_64_Vectors.Vector;
Repeated_Sfixed_32 : PB_Support.Integer_32_Vectors.Vector;
Repeated_Sfixed_64 : PB_Support.Integer_64_Vectors.Vector;
Repeated_Float : PB_Support.IEEE_Float_32_Vectors.Vector;
Repeated_Double : PB_Support.IEEE_Float_64_Vectors.Vector;
Repeated_Bool : PB_Support.Boolean_Vectors.Vector;
Repeated_String : League.String_Vectors
.Universal_String_Vector;
Repeated_Bytes : PB_Support.Stream_Element_Vector_Vectors
.Vector;
Repeated_Nested_Message : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Nested_Message_Vector;
Repeated_Foreign_Message : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Foreign_Message_Vector;
Repeated_Nested_Enum : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Nested_Enum_Vectors.Vector;
Repeated_Foreign_Enum : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Foreign_Enum_Vectors.Vector;
Repeated_String_Piece : League.String_Vectors
.Universal_String_Vector;
Repeated_Cord : League.String_Vectors
.Universal_String_Vector;
Packed_Int_32 : PB_Support.Integer_32_Vectors.Vector;
Packed_Int_64 : PB_Support.Integer_64_Vectors.Vector;
Packed_Uint_32 : PB_Support.Unsigned_32_Vectors.Vector;
Packed_Uint_64 : PB_Support.Unsigned_64_Vectors.Vector;
Packed_Sint_32 : PB_Support.Integer_32_Vectors.Vector;
Packed_Sint_64 : PB_Support.Integer_64_Vectors.Vector;
Packed_Fixed_32 : PB_Support.Unsigned_32_Vectors.Vector;
Packed_Fixed_64 : PB_Support.Unsigned_64_Vectors.Vector;
Packed_Sfixed_32 : PB_Support.Integer_32_Vectors.Vector;
Packed_Sfixed_64 : PB_Support.Integer_64_Vectors.Vector;
Packed_Float : PB_Support.IEEE_Float_32_Vectors.Vector;
Packed_Double : PB_Support.IEEE_Float_64_Vectors.Vector;
Packed_Bool : PB_Support.Boolean_Vectors.Vector;
Packed_Nested_Enum : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Nested_Enum_Vectors.Vector;
Unpacked_Int_32 : PB_Support.Integer_32_Vectors.Vector;
Unpacked_Int_64 : PB_Support.Integer_64_Vectors.Vector;
Unpacked_Uint_32 : PB_Support.Unsigned_32_Vectors.Vector;
Unpacked_Uint_64 : PB_Support.Unsigned_64_Vectors.Vector;
Unpacked_Sint_32 : PB_Support.Integer_32_Vectors.Vector;
Unpacked_Sint_64 : PB_Support.Integer_64_Vectors.Vector;
Unpacked_Fixed_32 : PB_Support.Unsigned_32_Vectors.Vector;
Unpacked_Fixed_64 : PB_Support.Unsigned_64_Vectors.Vector;
Unpacked_Sfixed_32 : PB_Support.Integer_32_Vectors.Vector;
Unpacked_Sfixed_64 : PB_Support.Integer_64_Vectors.Vector;
Unpacked_Float : PB_Support.IEEE_Float_32_Vectors.Vector;
Unpacked_Double : PB_Support.IEEE_Float_64_Vectors.Vector;
Unpacked_Bool : PB_Support.Boolean_Vectors.Vector;
Unpacked_Nested_Enum : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Nested_Enum_Vectors.Vector;
Map_Int_32_Int_32 : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Map_Int_32Int_32Entry_Vector;
Map_Int_64_Int_64 : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Map_Int_64Int_64Entry_Vector;
Map_Uint_32_Uint_32 : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Map_Uint_32Uint_32Entry_Vector;
Map_Uint_64_Uint_64 : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Map_Uint_64Uint_64Entry_Vector;
Map_Sint_32_Sint_32 : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Map_Sint_32Sint_32Entry_Vector;
Map_Sint_64_Sint_64 : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Map_Sint_64Sint_64Entry_Vector;
Map_Fixed_32_Fixed_32 : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Map_Fixed_32Fixed_32Entry_Vector;
Map_Fixed_64_Fixed_64 : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Map_Fixed_64Fixed_64Entry_Vector;
Map_Sfixed_32_Sfixed_32 : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Map_Sfixed_32Sfixed_32Entry_Vector;
Map_Sfixed_64_Sfixed_64 : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Map_Sfixed_64Sfixed_64Entry_Vector;
Map_Int_32_Float : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Map_Int_32Float_Entry_Vector;
Map_Int_32_Double : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Map_Int_32Double_Entry_Vector;
Map_Bool_Bool : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Map_Bool_Bool_Entry_Vector;
Map_String_String : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Map_String_String_Entry_Vector;
Map_String_Bytes : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Map_String_Bytes_Entry_Vector;
Map_String_Nested_Message : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Map_String_Nested_Message_Entry_Vector;
Map_String_Foreign_Message : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Map_String_Foreign_Message_Entry_Vector;
Map_String_Nested_Enum : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Map_String_Nested_Enum_Entry_Vector;
Map_String_Foreign_Enum : Protobuf_Test_Messages.Proto_3
.Test_Messages_Proto_3.Map_String_Foreign_Enum_Entry_Vector;
Optional_Bool_Wrapper : Google.Protobuf.Wrappers
.Optional_Bool_Value;
Optional_Int_32_Wrapper : Google.Protobuf.Wrappers
.Optional_Int_32Value;
Optional_Int_64_Wrapper : Google.Protobuf.Wrappers
.Optional_Int_64Value;
Optional_Uint_32_Wrapper : Google.Protobuf.Wrappers
.Optional_UInt_32Value;
Optional_Uint_64_Wrapper : Google.Protobuf.Wrappers
.Optional_UInt_64Value;
Optional_Float_Wrapper : Google.Protobuf.Wrappers
.Optional_Float_Value;
Optional_Double_Wrapper : Google.Protobuf.Wrappers
.Optional_Double_Value;
Optional_String_Wrapper : Google.Protobuf.Wrappers
.Optional_String_Value;
Optional_Bytes_Wrapper : Google.Protobuf.Wrappers
.Optional_Bytes_Value;
Repeated_Bool_Wrapper : Google.Protobuf.Wrappers
.Bool_Value_Vector;
Repeated_Int_32_Wrapper : Google.Protobuf.Wrappers
.Int_32Value_Vector;
Repeated_Int_64_Wrapper : Google.Protobuf.Wrappers
.Int_64Value_Vector;
Repeated_Uint_32_Wrapper : Google.Protobuf.Wrappers
.UInt_32Value_Vector;
Repeated_Uint_64_Wrapper : Google.Protobuf.Wrappers
.UInt_64Value_Vector;
Repeated_Float_Wrapper : Google.Protobuf.Wrappers
.Float_Value_Vector;
Repeated_Double_Wrapper : Google.Protobuf.Wrappers
.Double_Value_Vector;
Repeated_String_Wrapper : Google.Protobuf.Wrappers
.String_Value_Vector;
Repeated_Bytes_Wrapper : Google.Protobuf.Wrappers
.Bytes_Value_Vector;
Optional_Duration : Google.Protobuf.Duration
.Optional_Duration;
Optional_Timestamp : Google.Protobuf.Timestamp
.Optional_Timestamp;
Optional_Field_Mask : Google.Protobuf.Field_Mask
.Optional_Field_Mask;
Optional_Struct : Google.Protobuf.Struct.Optional_Struct;
Optional_Any : Google.Protobuf.Any.Optional_Any;
Optional_Value : Google.Protobuf.Struct.Optional_Value;
Repeated_Duration : Google.Protobuf.Duration.Duration_Vector;
Repeated_Timestamp : Google.Protobuf.Timestamp
.Timestamp_Vector;
Repeated_Fieldmask : Google.Protobuf.Field_Mask
.Field_Mask_Vector;
Repeated_Struct : Google.Protobuf.Struct.Struct_Vector;
Repeated_Any : Google.Protobuf.Any.Any_Vector;
Repeated_Value : Google.Protobuf.Struct.Value_Vector;
Repeated_List_Value : Google.Protobuf.Struct.List_Value_Vector;
Fieldname_1 : Interfaces.Integer_32 := 0;
Field_Name_2 : Interfaces.Integer_32 := 0;
Field_Name_3 : Interfaces.Integer_32 := 0;
Field_Name_4 : Interfaces.Integer_32 := 0;
Field_0name_5 : Interfaces.Integer_32 := 0;
Field_0_Name_6 : Interfaces.Integer_32 := 0;
Field_Name_7 : Interfaces.Integer_32 := 0;
Field_Name_8 : Interfaces.Integer_32 := 0;
Field_Name_9 : Interfaces.Integer_32 := 0;
Field_Name_10 : Interfaces.Integer_32 := 0;
FIELD_NAME11 : Interfaces.Integer_32 := 0;
FIELD_Name_12 : Interfaces.Integer_32 := 0;
Field_Name_13 : Interfaces.Integer_32 := 0;
Field_Name_14 : Interfaces.Integer_32 := 0;
Field_Name_15 : Interfaces.Integer_32 := 0;
Field_Name_16 : Interfaces.Integer_32 := 0;
Field_Name_17 : Interfaces.Integer_32 := 0;
Field_Name_18 : Interfaces.Integer_32 := 0;
Variant : Test_All_Types_Proto_3_Variant;
end record;
type Optional_Test_All_Types_Proto_3 (Is_Set : Boolean := False) is
record
case Is_Set is
when True =>
Value : Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3
.Test_All_Types_Proto_3;
when False =>
null;
end case;
end record;
function Length (Self : Test_All_Types_Proto_3_Vector) return Natural;
procedure Clear (Self : in out Test_All_Types_Proto_3_Vector);
procedure Append
(Self : in out Test_All_Types_Proto_3_Vector;
V : Test_All_Types_Proto_3);
type Test_All_Types_Proto_3_Variable_Reference
(Element : not null access Test_All_Types_Proto_3) is null record
with Implicit_Dereference => Element;
not overriding function Get_Test_All_Types_Proto_3_Variable_Reference
(Self : aliased in out Test_All_Types_Proto_3_Vector;
Index : Positive)
return Test_All_Types_Proto_3_Variable_Reference
with Inline;
type Test_All_Types_Proto_3_Constant_Reference
(Element : not null access constant Test_All_Types_Proto_3) is null record
with Implicit_Dereference => Element;
not overriding function Get_Test_All_Types_Proto_3_Constant_Reference
(Self : aliased Test_All_Types_Proto_3_Vector;
Index : Positive)
return Test_All_Types_Proto_3_Constant_Reference
with Inline;
private
procedure Read_Nested_Message
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : out Nested_Message);
procedure Write_Nested_Message
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : Nested_Message);
for Nested_Message'Read use Read_Nested_Message;
for Nested_Message'Write use Write_Nested_Message;
type Nested_Message_Array is
array (Positive range <>) of aliased Nested_Message;
type Nested_Message_Array_Access is access Nested_Message_Array;
type Nested_Message_Vector is
new Ada.Finalization.Controlled
with record
Data : Nested_Message_Array_Access;
Length : Natural := 0;
end record;
overriding procedure Adjust (Self : in out Nested_Message_Vector);
overriding procedure Finalize (Self : in out Nested_Message_Vector);
procedure Read_Map_Int_32Int_32Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : out Map_Int_32Int_32Entry);
procedure Write_Map_Int_32Int_32Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : Map_Int_32Int_32Entry);
for Map_Int_32Int_32Entry'Read use Read_Map_Int_32Int_32Entry;
for Map_Int_32Int_32Entry'Write use Write_Map_Int_32Int_32Entry;
type Map_Int_32Int_32Entry_Array is
array (Positive range <>) of aliased Map_Int_32Int_32Entry;
type Map_Int_32Int_32Entry_Array_Access is
access Map_Int_32Int_32Entry_Array;
type Map_Int_32Int_32Entry_Vector is
new Ada.Finalization.Controlled
with record
Data : Map_Int_32Int_32Entry_Array_Access;
Length : Natural := 0;
end record;
overriding procedure Adjust (Self : in out Map_Int_32Int_32Entry_Vector);
overriding procedure Finalize (Self : in out Map_Int_32Int_32Entry_Vector);
procedure Read_Map_Int_64Int_64Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : out Map_Int_64Int_64Entry);
procedure Write_Map_Int_64Int_64Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : Map_Int_64Int_64Entry);
for Map_Int_64Int_64Entry'Read use Read_Map_Int_64Int_64Entry;
for Map_Int_64Int_64Entry'Write use Write_Map_Int_64Int_64Entry;
type Map_Int_64Int_64Entry_Array is
array (Positive range <>) of aliased Map_Int_64Int_64Entry;
type Map_Int_64Int_64Entry_Array_Access is
access Map_Int_64Int_64Entry_Array;
type Map_Int_64Int_64Entry_Vector is
new Ada.Finalization.Controlled
with record
Data : Map_Int_64Int_64Entry_Array_Access;
Length : Natural := 0;
end record;
overriding procedure Adjust (Self : in out Map_Int_64Int_64Entry_Vector);
overriding procedure Finalize (Self : in out Map_Int_64Int_64Entry_Vector);
procedure Read_Map_Uint_32Uint_32Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : out Map_Uint_32Uint_32Entry);
procedure Write_Map_Uint_32Uint_32Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : Map_Uint_32Uint_32Entry);
for Map_Uint_32Uint_32Entry'Read use Read_Map_Uint_32Uint_32Entry;
for Map_Uint_32Uint_32Entry'Write use Write_Map_Uint_32Uint_32Entry;
type Map_Uint_32Uint_32Entry_Array is
array (Positive range <>) of aliased Map_Uint_32Uint_32Entry;
type Map_Uint_32Uint_32Entry_Array_Access is
access Map_Uint_32Uint_32Entry_Array;
type Map_Uint_32Uint_32Entry_Vector is
new Ada.Finalization.Controlled
with record
Data : Map_Uint_32Uint_32Entry_Array_Access;
Length : Natural := 0;
end record;
overriding procedure Adjust (Self : in out Map_Uint_32Uint_32Entry_Vector);
overriding procedure Finalize
(Self : in out Map_Uint_32Uint_32Entry_Vector);
procedure Read_Map_Uint_64Uint_64Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : out Map_Uint_64Uint_64Entry);
procedure Write_Map_Uint_64Uint_64Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : Map_Uint_64Uint_64Entry);
for Map_Uint_64Uint_64Entry'Read use Read_Map_Uint_64Uint_64Entry;
for Map_Uint_64Uint_64Entry'Write use Write_Map_Uint_64Uint_64Entry;
type Map_Uint_64Uint_64Entry_Array is
array (Positive range <>) of aliased Map_Uint_64Uint_64Entry;
type Map_Uint_64Uint_64Entry_Array_Access is
access Map_Uint_64Uint_64Entry_Array;
type Map_Uint_64Uint_64Entry_Vector is
new Ada.Finalization.Controlled
with record
Data : Map_Uint_64Uint_64Entry_Array_Access;
Length : Natural := 0;
end record;
overriding procedure Adjust (Self : in out Map_Uint_64Uint_64Entry_Vector);
overriding procedure Finalize
(Self : in out Map_Uint_64Uint_64Entry_Vector);
procedure Read_Map_Sint_32Sint_32Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : out Map_Sint_32Sint_32Entry);
procedure Write_Map_Sint_32Sint_32Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : Map_Sint_32Sint_32Entry);
for Map_Sint_32Sint_32Entry'Read use Read_Map_Sint_32Sint_32Entry;
for Map_Sint_32Sint_32Entry'Write use Write_Map_Sint_32Sint_32Entry;
type Map_Sint_32Sint_32Entry_Array is
array (Positive range <>) of aliased Map_Sint_32Sint_32Entry;
type Map_Sint_32Sint_32Entry_Array_Access is
access Map_Sint_32Sint_32Entry_Array;
type Map_Sint_32Sint_32Entry_Vector is
new Ada.Finalization.Controlled
with record
Data : Map_Sint_32Sint_32Entry_Array_Access;
Length : Natural := 0;
end record;
overriding procedure Adjust (Self : in out Map_Sint_32Sint_32Entry_Vector);
overriding procedure Finalize
(Self : in out Map_Sint_32Sint_32Entry_Vector);
procedure Read_Map_Sint_64Sint_64Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : out Map_Sint_64Sint_64Entry);
procedure Write_Map_Sint_64Sint_64Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : Map_Sint_64Sint_64Entry);
for Map_Sint_64Sint_64Entry'Read use Read_Map_Sint_64Sint_64Entry;
for Map_Sint_64Sint_64Entry'Write use Write_Map_Sint_64Sint_64Entry;
type Map_Sint_64Sint_64Entry_Array is
array (Positive range <>) of aliased Map_Sint_64Sint_64Entry;
type Map_Sint_64Sint_64Entry_Array_Access is
access Map_Sint_64Sint_64Entry_Array;
type Map_Sint_64Sint_64Entry_Vector is
new Ada.Finalization.Controlled
with record
Data : Map_Sint_64Sint_64Entry_Array_Access;
Length : Natural := 0;
end record;
overriding procedure Adjust (Self : in out Map_Sint_64Sint_64Entry_Vector);
overriding procedure Finalize
(Self : in out Map_Sint_64Sint_64Entry_Vector);
procedure Read_Map_Fixed_32Fixed_32Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : out Map_Fixed_32Fixed_32Entry);
procedure Write_Map_Fixed_32Fixed_32Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : Map_Fixed_32Fixed_32Entry);
for Map_Fixed_32Fixed_32Entry'Read use Read_Map_Fixed_32Fixed_32Entry;
for Map_Fixed_32Fixed_32Entry'Write use Write_Map_Fixed_32Fixed_32Entry;
type Map_Fixed_32Fixed_32Entry_Array is
array (Positive range <>) of aliased Map_Fixed_32Fixed_32Entry;
type Map_Fixed_32Fixed_32Entry_Array_Access is
access Map_Fixed_32Fixed_32Entry_Array;
type Map_Fixed_32Fixed_32Entry_Vector is
new Ada.Finalization.Controlled
with record
Data : Map_Fixed_32Fixed_32Entry_Array_Access;
Length : Natural := 0;
end record;
overriding procedure Adjust
(Self : in out Map_Fixed_32Fixed_32Entry_Vector);
overriding procedure Finalize
(Self : in out Map_Fixed_32Fixed_32Entry_Vector);
procedure Read_Map_Fixed_64Fixed_64Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : out Map_Fixed_64Fixed_64Entry);
procedure Write_Map_Fixed_64Fixed_64Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : Map_Fixed_64Fixed_64Entry);
for Map_Fixed_64Fixed_64Entry'Read use Read_Map_Fixed_64Fixed_64Entry;
for Map_Fixed_64Fixed_64Entry'Write use Write_Map_Fixed_64Fixed_64Entry;
type Map_Fixed_64Fixed_64Entry_Array is
array (Positive range <>) of aliased Map_Fixed_64Fixed_64Entry;
type Map_Fixed_64Fixed_64Entry_Array_Access is
access Map_Fixed_64Fixed_64Entry_Array;
type Map_Fixed_64Fixed_64Entry_Vector is
new Ada.Finalization.Controlled
with record
Data : Map_Fixed_64Fixed_64Entry_Array_Access;
Length : Natural := 0;
end record;
overriding procedure Adjust
(Self : in out Map_Fixed_64Fixed_64Entry_Vector);
overriding procedure Finalize
(Self : in out Map_Fixed_64Fixed_64Entry_Vector);
procedure Read_Map_Sfixed_32Sfixed_32Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : out Map_Sfixed_32Sfixed_32Entry);
procedure Write_Map_Sfixed_32Sfixed_32Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : Map_Sfixed_32Sfixed_32Entry);
for Map_Sfixed_32Sfixed_32Entry'Read use Read_Map_Sfixed_32Sfixed_32Entry;
for Map_Sfixed_32Sfixed_32Entry'Write use Write_Map_Sfixed_32Sfixed_32Entry;
type Map_Sfixed_32Sfixed_32Entry_Array is
array (Positive range <>) of aliased Map_Sfixed_32Sfixed_32Entry;
type Map_Sfixed_32Sfixed_32Entry_Array_Access is
access Map_Sfixed_32Sfixed_32Entry_Array;
type Map_Sfixed_32Sfixed_32Entry_Vector is
new Ada.Finalization.Controlled
with record
Data : Map_Sfixed_32Sfixed_32Entry_Array_Access;
Length : Natural := 0;
end record;
overriding procedure Adjust
(Self : in out Map_Sfixed_32Sfixed_32Entry_Vector);
overriding procedure Finalize
(Self : in out Map_Sfixed_32Sfixed_32Entry_Vector);
procedure Read_Map_Sfixed_64Sfixed_64Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : out Map_Sfixed_64Sfixed_64Entry);
procedure Write_Map_Sfixed_64Sfixed_64Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : Map_Sfixed_64Sfixed_64Entry);
for Map_Sfixed_64Sfixed_64Entry'Read use Read_Map_Sfixed_64Sfixed_64Entry;
for Map_Sfixed_64Sfixed_64Entry'Write use Write_Map_Sfixed_64Sfixed_64Entry;
type Map_Sfixed_64Sfixed_64Entry_Array is
array (Positive range <>) of aliased Map_Sfixed_64Sfixed_64Entry;
type Map_Sfixed_64Sfixed_64Entry_Array_Access is
access Map_Sfixed_64Sfixed_64Entry_Array;
type Map_Sfixed_64Sfixed_64Entry_Vector is
new Ada.Finalization.Controlled
with record
Data : Map_Sfixed_64Sfixed_64Entry_Array_Access;
Length : Natural := 0;
end record;
overriding procedure Adjust
(Self : in out Map_Sfixed_64Sfixed_64Entry_Vector);
overriding procedure Finalize
(Self : in out Map_Sfixed_64Sfixed_64Entry_Vector);
procedure Read_Map_Int_32Float_Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : out Map_Int_32Float_Entry);
procedure Write_Map_Int_32Float_Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : Map_Int_32Float_Entry);
for Map_Int_32Float_Entry'Read use Read_Map_Int_32Float_Entry;
for Map_Int_32Float_Entry'Write use Write_Map_Int_32Float_Entry;
type Map_Int_32Float_Entry_Array is
array (Positive range <>) of aliased Map_Int_32Float_Entry;
type Map_Int_32Float_Entry_Array_Access is
access Map_Int_32Float_Entry_Array;
type Map_Int_32Float_Entry_Vector is
new Ada.Finalization.Controlled
with record
Data : Map_Int_32Float_Entry_Array_Access;
Length : Natural := 0;
end record;
overriding procedure Adjust (Self : in out Map_Int_32Float_Entry_Vector);
overriding procedure Finalize (Self : in out Map_Int_32Float_Entry_Vector);
procedure Read_Map_Int_32Double_Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : out Map_Int_32Double_Entry);
procedure Write_Map_Int_32Double_Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : Map_Int_32Double_Entry);
for Map_Int_32Double_Entry'Read use Read_Map_Int_32Double_Entry;
for Map_Int_32Double_Entry'Write use Write_Map_Int_32Double_Entry;
type Map_Int_32Double_Entry_Array is
array (Positive range <>) of aliased Map_Int_32Double_Entry;
type Map_Int_32Double_Entry_Array_Access is
access Map_Int_32Double_Entry_Array;
type Map_Int_32Double_Entry_Vector is
new Ada.Finalization.Controlled
with record
Data : Map_Int_32Double_Entry_Array_Access;
Length : Natural := 0;
end record;
overriding procedure Adjust (Self : in out Map_Int_32Double_Entry_Vector);
overriding procedure Finalize (Self : in out Map_Int_32Double_Entry_Vector);
procedure Read_Map_Bool_Bool_Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : out Map_Bool_Bool_Entry);
procedure Write_Map_Bool_Bool_Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : Map_Bool_Bool_Entry);
for Map_Bool_Bool_Entry'Read use Read_Map_Bool_Bool_Entry;
for Map_Bool_Bool_Entry'Write use Write_Map_Bool_Bool_Entry;
type Map_Bool_Bool_Entry_Array is
array (Positive range <>) of aliased Map_Bool_Bool_Entry;
type Map_Bool_Bool_Entry_Array_Access is access Map_Bool_Bool_Entry_Array;
type Map_Bool_Bool_Entry_Vector is
new Ada.Finalization.Controlled
with record
Data : Map_Bool_Bool_Entry_Array_Access;
Length : Natural := 0;
end record;
overriding procedure Adjust (Self : in out Map_Bool_Bool_Entry_Vector);
overriding procedure Finalize (Self : in out Map_Bool_Bool_Entry_Vector);
procedure Read_Map_String_String_Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : out Map_String_String_Entry);
procedure Write_Map_String_String_Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : Map_String_String_Entry);
for Map_String_String_Entry'Read use Read_Map_String_String_Entry;
for Map_String_String_Entry'Write use Write_Map_String_String_Entry;
type Map_String_String_Entry_Array is
array (Positive range <>) of aliased Map_String_String_Entry;
type Map_String_String_Entry_Array_Access is
access Map_String_String_Entry_Array;
type Map_String_String_Entry_Vector is
new Ada.Finalization.Controlled
with record
Data : Map_String_String_Entry_Array_Access;
Length : Natural := 0;
end record;
overriding procedure Adjust (Self : in out Map_String_String_Entry_Vector);
overriding procedure Finalize
(Self : in out Map_String_String_Entry_Vector);
procedure Read_Map_String_Bytes_Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : out Map_String_Bytes_Entry);
procedure Write_Map_String_Bytes_Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : Map_String_Bytes_Entry);
for Map_String_Bytes_Entry'Read use Read_Map_String_Bytes_Entry;
for Map_String_Bytes_Entry'Write use Write_Map_String_Bytes_Entry;
type Map_String_Bytes_Entry_Array is
array (Positive range <>) of aliased Map_String_Bytes_Entry;
type Map_String_Bytes_Entry_Array_Access is
access Map_String_Bytes_Entry_Array;
type Map_String_Bytes_Entry_Vector is
new Ada.Finalization.Controlled
with record
Data : Map_String_Bytes_Entry_Array_Access;
Length : Natural := 0;
end record;
overriding procedure Adjust (Self : in out Map_String_Bytes_Entry_Vector);
overriding procedure Finalize (Self : in out Map_String_Bytes_Entry_Vector);
procedure Read_Map_String_Nested_Message_Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : out Map_String_Nested_Message_Entry);
procedure Write_Map_String_Nested_Message_Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : Map_String_Nested_Message_Entry);
for Map_String_Nested_Message_Entry'Read use Read_Map_String_Nested_Message_Entry;
for Map_String_Nested_Message_Entry'Write use Write_Map_String_Nested_Message_Entry;
type Map_String_Nested_Message_Entry_Array is
array (Positive range <>) of aliased Map_String_Nested_Message_Entry;
type Map_String_Nested_Message_Entry_Array_Access is
access Map_String_Nested_Message_Entry_Array;
type Map_String_Nested_Message_Entry_Vector is
new Ada.Finalization.Controlled
with record
Data : Map_String_Nested_Message_Entry_Array_Access;
Length : Natural := 0;
end record;
overriding procedure Adjust
(Self : in out Map_String_Nested_Message_Entry_Vector);
overriding procedure Finalize
(Self : in out Map_String_Nested_Message_Entry_Vector);
procedure Read_Map_String_Foreign_Message_Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : out Map_String_Foreign_Message_Entry);
procedure Write_Map_String_Foreign_Message_Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : Map_String_Foreign_Message_Entry);
for Map_String_Foreign_Message_Entry'Read use Read_Map_String_Foreign_Message_Entry;
for Map_String_Foreign_Message_Entry'Write use Write_Map_String_Foreign_Message_Entry;
type Map_String_Foreign_Message_Entry_Array is
array (Positive range <>) of aliased Map_String_Foreign_Message_Entry;
type Map_String_Foreign_Message_Entry_Array_Access is
access Map_String_Foreign_Message_Entry_Array;
type Map_String_Foreign_Message_Entry_Vector is
new Ada.Finalization.Controlled
with record
Data : Map_String_Foreign_Message_Entry_Array_Access;
Length : Natural := 0;
end record;
overriding procedure Adjust
(Self : in out Map_String_Foreign_Message_Entry_Vector);
overriding procedure Finalize
(Self : in out Map_String_Foreign_Message_Entry_Vector);
procedure Read_Map_String_Nested_Enum_Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : out Map_String_Nested_Enum_Entry);
procedure Write_Map_String_Nested_Enum_Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : Map_String_Nested_Enum_Entry);
for Map_String_Nested_Enum_Entry'Read use Read_Map_String_Nested_Enum_Entry;
for Map_String_Nested_Enum_Entry'Write use Write_Map_String_Nested_Enum_Entry;
type Map_String_Nested_Enum_Entry_Array is
array (Positive range <>) of aliased Map_String_Nested_Enum_Entry;
type Map_String_Nested_Enum_Entry_Array_Access is
access Map_String_Nested_Enum_Entry_Array;
type Map_String_Nested_Enum_Entry_Vector is
new Ada.Finalization.Controlled
with record
Data : Map_String_Nested_Enum_Entry_Array_Access;
Length : Natural := 0;
end record;
overriding procedure Adjust
(Self : in out Map_String_Nested_Enum_Entry_Vector);
overriding procedure Finalize
(Self : in out Map_String_Nested_Enum_Entry_Vector);
procedure Read_Map_String_Foreign_Enum_Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : out Map_String_Foreign_Enum_Entry);
procedure Write_Map_String_Foreign_Enum_Entry
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : Map_String_Foreign_Enum_Entry);
for Map_String_Foreign_Enum_Entry'Read use Read_Map_String_Foreign_Enum_Entry;
for Map_String_Foreign_Enum_Entry'Write use Write_Map_String_Foreign_Enum_Entry;
type Map_String_Foreign_Enum_Entry_Array is
array (Positive range <>) of aliased Map_String_Foreign_Enum_Entry;
type Map_String_Foreign_Enum_Entry_Array_Access is
access Map_String_Foreign_Enum_Entry_Array;
type Map_String_Foreign_Enum_Entry_Vector is
new Ada.Finalization.Controlled
with record
Data : Map_String_Foreign_Enum_Entry_Array_Access;
Length : Natural := 0;
end record;
overriding procedure Adjust
(Self : in out Map_String_Foreign_Enum_Entry_Vector);
overriding procedure Finalize
(Self : in out Map_String_Foreign_Enum_Entry_Vector);
procedure Read_Test_All_Types_Proto_3
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : out Test_All_Types_Proto_3);
procedure Write_Test_All_Types_Proto_3
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : Test_All_Types_Proto_3);
for Test_All_Types_Proto_3'Read use Read_Test_All_Types_Proto_3;
for Test_All_Types_Proto_3'Write use Write_Test_All_Types_Proto_3;
type Test_All_Types_Proto_3_Array is
array (Positive range <>) of aliased Test_All_Types_Proto_3;
type Test_All_Types_Proto_3_Array_Access is
access Test_All_Types_Proto_3_Array;
type Test_All_Types_Proto_3_Vector is
new Ada.Finalization.Controlled
with record
Data : Test_All_Types_Proto_3_Array_Access;
Length : Natural := 0;
end record;
overriding procedure Adjust (Self : in out Test_All_Types_Proto_3_Vector);
overriding procedure Finalize (Self : in out Test_All_Types_Proto_3_Vector);
procedure Read_Foreign_Message
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : out Foreign_Message);
procedure Write_Foreign_Message
(Stream : access Ada.Streams.Root_Stream_Type'Class;
V : Foreign_Message);
for Foreign_Message'Read use Read_Foreign_Message;
for Foreign_Message'Write use Write_Foreign_Message;
type Foreign_Message_Array is
array (Positive range <>) of aliased Foreign_Message;
type Foreign_Message_Array_Access is access Foreign_Message_Array;
type Foreign_Message_Vector is
new Ada.Finalization.Controlled
with record
Data : Foreign_Message_Array_Access;
Length : Natural := 0;
end record;
overriding procedure Adjust (Self : in out Foreign_Message_Vector);
overriding procedure Finalize (Self : in out Foreign_Message_Vector);
end Protobuf_Test_Messages.Proto_3.Test_Messages_Proto_3; |
------------------------------------------------------------------------------
-- Copyright (c) 2014, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
------------------------------------------------------------------------------
-- Generate_Static_Hash_Map is a command-line interface to the static hash --
-- map package generator, using a description from S-expression files. --
-- It also provides bootstrap for the S-expression description interpreter. --
------------------------------------------------------------------------------
with Ada.Command_Line;
with Ada.Directories;
with Ada.Text_IO;
with Natools.Static_Hash_Maps.S_Expressions;
with Natools.S_Expressions.File_Readers;
with Natools.S_Expressions.Lockable;
procedure Generate_Static_Hash_Map is
Dir_Arg : Natural := 0;
First_Arg : Positive := 1;
Prev_Dir : constant String := Ada.Directories.Current_Directory;
begin
if Ada.Command_Line.Argument_Count >= 2
and then Ada.Command_Line.Argument (1) = "-C"
then
Dir_Arg := 2;
First_Arg := 3;
end if;
if Ada.Command_Line.Argument_Count < First_Arg then
Ada.Text_IO.Put_Line
(Ada.Text_IO.Current_Error,
"Usage: " & Ada.Command_Line.Command_Name
& " [-C target_directory]"
& " input.sx [other-input.sx ...]");
Ada.Text_IO.Put_Line
(Ada.Text_IO.Current_Error,
" special argument ""--"" instead of input file bootstraps the");
Ada.Text_IO.Put_Line
(Ada.Text_IO.Current_Error,
" descriptor interpreter hash map.");
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
return;
end if;
for I in First_Arg .. Ada.Command_Line.Argument_Count loop
if Ada.Command_Line.Argument (I) = "--" then
declare
use Natools.Static_Hash_Maps;
begin
if Dir_Arg > 0 then
Ada.Directories.Set_Directory
(Ada.Command_Line.Argument (Dir_Arg));
end if;
Generate_Package
("Natools.Static_Hash_Maps.S_Expressions.Command_Maps",
(Map
(Element_Type => "Package_Command",
Hash_Package_Name =>
"Natools.Static_Hash_Maps.S_Expressions.Command_Pkg",
Function_Name => "To_Package_Command",
Nodes =>
(Node ("private", "Private_Child"),
Node ("public", "Public_Child"))),
Map
(Element_Type => "Map_Command",
Hash_Package_Name =>
"Natools.Static_Hash_Maps.S_Expressions.Command_Map",
Function_Name => "To_Map_Command",
Nodes =>
(Node ("hash-package", "Hash_Package"),
Node ("nodes", "Nodes"),
Node ("function", "Function_Name"),
Node ("not-found", "Not_Found")))),
Private_Child => True);
if Dir_Arg > 0 then
Ada.Directories.Set_Directory (Prev_Dir);
end if;
end;
else
declare
Prev_Dir : constant String := Ada.Directories.Current_Directory;
Input : Natools.S_Expressions.Lockable.Descriptor'Class
:= Natools.S_Expressions.File_Readers.Reader
(Ada.Command_Line.Argument (I));
begin
if Dir_Arg > 0 then
Ada.Directories.Set_Directory
(Ada.Command_Line.Argument (Dir_Arg));
end if;
Natools.Static_Hash_Maps.S_Expressions.Generate_Packages
(Input,
"from " & Ada.Command_Line.Argument (I));
if Dir_Arg > 0 then
Ada.Directories.Set_Directory (Prev_Dir);
end if;
end;
end if;
end loop;
end Generate_Static_Hash_Map;
|
with AUnit;
with AUnit.Simple_Test_Cases;
with kv.avm.Symbol_Tables;
package kv.avm.Vole_Tests is
type Base_Test_Case is abstract new AUnit.Simple_Test_Cases.Test_Case with
record
Symbols : aliased kv.avm.Symbol_Tables.Symbol_Table;
end record;
procedure Set_Up (T : in out Base_Test_Case);
procedure Tear_Down (T : in out Base_Test_Case);
type Test_01 is new Base_Test_Case with null record;
function Name (T : Test_01) return AUnit.Message_String;
procedure Run_Test (T : in out Test_01);
type Test_02 is new Base_Test_Case with null record;
function Name (T : Test_02) return AUnit.Message_String;
procedure Run_Test (T : in out Test_02);
type Test_03 is new Base_Test_Case with null record;
function Name (T : Test_03) return AUnit.Message_String;
procedure Run_Test (T : in out Test_03);
type Test_04 is new Base_Test_Case with null record;
function Name (T : Test_04) return AUnit.Message_String;
procedure Run_Test (T : in out Test_04);
type Test_05 is new Base_Test_Case with null record;
function Name (T : Test_05) return AUnit.Message_String;
procedure Run_Test (T : in out Test_05);
type Test_06 is new Base_Test_Case with null record;
function Name (T : Test_06) return AUnit.Message_String;
procedure Run_Test (T : in out Test_06);
type Test_07 is new Base_Test_Case with null record;
function Name (T : Test_07) return AUnit.Message_String;
procedure Run_Test (T : in out Test_07);
type Test_08 is new Base_Test_Case with null record;
function Name (T : Test_08) return AUnit.Message_String;
procedure Run_Test (T : in out Test_08);
end kv.avm.Vole_Tests;
|
with Ada.Text_IO;
-- List of objects used
with Root_Object.MicrowaveOven.MO_O;
with Root_Object;
-- package body MicrowaveOven_defineoven_service is
procedure MicrowaveOven_defineoven is
a : Integer;
begin
-- a := Root_Object.MicrowaveOven.MO_O.remaining_cooking_time;
a := 1;
Ada.Text_IO.Put_Line("Defining oven...");
end MicrowaveOven_defineoven;
-- end MicrowaveOven_defineoven_service;
|
-----------------------------------------------------------------------
-- asf-events -- ASF Events
-- Copyright (C) 2010 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
package body ASF.Events.Faces is
-- ------------------------------
-- Get the lifecycle phase where the event must be processed.
-- ------------------------------
function Get_Phase (Event : in Faces_Event) return ASF.Lifecycles.Phase_Type is
begin
return Event.Phase;
end Get_Phase;
-- ------------------------------
-- Set the lifecycle phase when this event must be processed.
-- ------------------------------
procedure Set_Phase (Event : in out Faces_Event;
Phase : in ASF.Lifecycles.Phase_Type) is
begin
Event.Phase := Phase;
end Set_Phase;
-- ------------------------------
-- Get the component onto which the event was posted.
-- ------------------------------
function Get_Component (Event : in Faces_Event) return Components.Base.UIComponent_Access is
begin
return Event.Component;
end Get_Component;
end ASF.Events.Faces;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Test is null: integer; begin Put('a'); end;
|
-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with System.Storage_Pools.Subpools;
with Program.Compilation_Units;
with Program.Compilations;
with Program.Contexts;
with Program.Lexical_Elements;
with Program.Parsers;
with Program.Plain_Lexical_Elements;
private with Ada.Containers.Vectors;
private with Ada.Strings.Wide_Wide_Unbounded;
private with Program.Source_Buffers;
private with Program.Plain_Source_Buffers;
private with Program.Plain_Contexts;
package Program.Plain_Compilations is
pragma Preelaborate;
type Compilation
(Subpool : not null System.Storage_Pools.Subpools.Subpool_Handle)
is limited new Program.Compilations.Compilation
and Program.Plain_Lexical_Elements.Line_Buffer with private;
procedure Initialize
(Self : in out Compilation'Class;
Context : not null Program.Contexts.Context_Access);
overriding function Context (Self : Compilation)
return not null Program.Contexts.Context_Access;
-- Return corresponding context
overriding function Text_Name (Self : Compilation) return Program.Text;
overriding function Object_Name (Self : Compilation) return Program.Text;
overriding function Line_Count (Self : Compilation) return Natural;
overriding function Line
(Self : Compilation;
Index : Positive) return Program.Text;
overriding function Lexical_Element_Count (Self : Compilation)
return Natural;
overriding function Lexical_Element
(Self : Compilation;
Index : Positive) return Program.Lexical_Elements.Lexical_Element_Access;
not overriding procedure Parse_File
(Self : aliased in out Compilation;
Text_Name : Program.Text;
Units : out Program.Parsers.Unit_Vectors.Vector;
Pragmas : out Program.Parsers.Element_Vectors.Vector;
Standard : Boolean := False);
private
package Span_Vectors is new Ada.Containers.Vectors
(Index_Type => Positive,
Element_Type => Program.Source_Buffers.Span,
"=" => Program.Source_Buffers."=");
type Plain_Context_Access is access all Program.Plain_Contexts.Context;
type Compilation
(Subpool : not null System.Storage_Pools.Subpools.Subpool_Handle)
is limited new Compilations.Compilation
and Plain_Lexical_Elements.Line_Buffer with
record
Context : Plain_Context_Access;
Text_Name : Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String;
Object_Name : Ada.Strings.Wide_Wide_Unbounded.Unbounded_Wide_Wide_String;
Buffer : aliased Program.Plain_Source_Buffers.Source_Buffer;
Tokens : aliased Plain_Lexical_Elements.Lexical_Element_Vector
(Compilation'Unchecked_Access);
Line_Spans : Span_Vectors.Vector;
end record;
overriding function Text
(Self : Compilation;
Span : Program.Source_Buffers.Span) return Program.Text;
overriding procedure Get_Span
(Self : Compilation;
Span : Program.Source_Buffers.Span;
From_Line : out Positive;
To_Line : out Positive;
From_Column : out Positive;
To_Column : out Positive);
end Program.Plain_Compilations;
|
package body problem_19 is
function Solution_1 return Integer is
Start_Year : constant Integer := 1901;
End_Year : constant Integer := 2000;
Sundays : Integer := 0;
Offset : constant array (Natural range 0 .. 11) of Natural := (
0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4
);
begin
for Year in Start_Year .. End_Year loop
for Month in 0 .. 11 loop
declare
Y : Integer := Year;
Dow : Integer;
begin
if Month < 3 then
Y := Y - 1;
end if;
DOW := (1 + Y + (Y/4) - (Y/100) + (Y/400) + Offset(Month)) mod 7;
if DOW = 0 then
Sundays := Sundays + 1;
end if;
end;
end loop;
end loop;
return Sundays;
end Solution_1;
procedure Test_Solution_1 is
Solution : constant Integer := 171;
begin
Assert( Solution_1 = Solution );
end Test_Solution_1;
function Get_Solutions return Solution_Case is
Ret : Solution_Case;
begin
Set_Name( Ret, "Problem 19" );
Add_Test( Ret, Test_Solution_1'Access );
return Ret;
end Get_Solutions;
end problem_19;
|
with Ada.Text_IO;
procedure Hello_World is
begin
Ada.Text_IO.Put_Line ("Hello ADA");
Ada.Text_IO.Put_Line("This is the worlds safest hello world program");
end Hello_World;
|
-------------------------------------------------------------------------------
-- Copyright (c) 2019, Daniel King
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
-- * Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * The name of the copyright holder may not be used to endorse or promote
-- Products derived from this software without specific prior written
-- permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with Keccak.Generic_MonkeyDuplex;
with Keccak.Generic_MonkeyWrap;
with Keccak.Generic_KeccakF.Byte_Lanes.Twisted;
with Keccak.Keccak_200;
with Keccak.Keccak_200.Rounds_12;
with Keccak.Keccak_400;
with Keccak.Keccak_400.Rounds_12;
with Keccak.Keccak_800;
with Keccak.Keccak_800.Rounds_12;
with Keccak.Keccak_1600;
with Keccak.Keccak_1600.Rounds_12;
with Keccak.Padding;
pragma Elaborate_All (Keccak.Generic_MonkeyDuplex);
pragma Elaborate_All (Keccak.Generic_MonkeyWrap);
pragma Elaborate_All (Keccak.Generic_KeccakF.Byte_Lanes.Twisted);
package Ketje
with SPARK_Mode => On
is
-- @private
package Implementation is
use Keccak;
----------------
-- Ketje Jr --
----------------
procedure Permute_Jr_Step is new Keccak_200.KeccakF_200_Permutation.Permute
(Num_Rounds => 1);
procedure Permute_Jr_Stride is new Keccak_200.KeccakF_200_Permutation.Permute
(Num_Rounds => 6);
package Twisted_Lanes_200 is new Keccak_200.KeccakF_200_Lanes.Twisted;
procedure XOR_Padding_Into_State is new Keccak.Padding.XOR_Pad101_Into_State
(State_Size_Bits => 200,
State_Type => Keccak_200.State,
XOR_Byte_Into_State => Twisted_Lanes_200.XOR_Byte_Into_State_Twisted);
package MonkeyDuplex_Jr is new Keccak.Generic_MonkeyDuplex
(State_Size_Bits => 200,
State_Type => Keccak_200.State,
Init_State => Keccak_200.KeccakF_200.Init,
Permute_Start => Keccak_200.Rounds_12.Permute,
Permute_Step => Permute_Jr_Step,
Permute_Stride => Permute_Jr_Stride,
XOR_Bits_Into_State => Twisted_Lanes_200.XOR_Bits_Into_State_Twisted,
XOR_Byte_Into_State => Twisted_Lanes_200.XOR_Byte_Into_State_Twisted,
Extract_Bits => Twisted_Lanes_200.Extract_Bits_Twisted,
XOR_Padding_Into_State => XOR_Padding_Into_State,
Min_Padding_Bits => Keccak.Padding.Pad101_Min_Bits);
----------------
-- Ketje Sr --
----------------
procedure Permute_Sr_Step is new Keccak_400.KeccakF_400_Permutation.Permute
(Num_Rounds => 1);
procedure Permute_Sr_Stride is new Keccak_400.KeccakF_400_Permutation.Permute
(Num_Rounds => 6);
package Twisted_Lanes_400 is new Keccak_400.KeccakF_400_Lanes.Twisted;
procedure XOR_Padding_Into_State is new Keccak.Padding.XOR_Pad101_Into_State
(State_Size_Bits => 400,
State_Type => Keccak_400.State,
XOR_Byte_Into_State => Twisted_Lanes_400.XOR_Byte_Into_State_Twisted);
package MonkeyDuplex_Sr is new Keccak.Generic_MonkeyDuplex
(State_Size_Bits => 400,
State_Type => Keccak_400.State,
Init_State => Keccak_400.KeccakF_400.Init,
Permute_Start => Keccak_400.Rounds_12.Permute,
Permute_Step => Permute_Sr_Step,
Permute_Stride => Permute_Sr_Stride,
XOR_Bits_Into_State => Twisted_Lanes_400.XOR_Bits_Into_State_Twisted,
XOR_Byte_Into_State => Twisted_Lanes_400.XOR_Byte_Into_State_Twisted,
Extract_Bits => Twisted_Lanes_400.Extract_Bits_Twisted,
XOR_Padding_Into_State => XOR_Padding_Into_State,
Min_Padding_Bits => Keccak.Padding.Pad101_Min_Bits);
-------------------
-- Ketje Minor --
-------------------
procedure Permute_Minor_Step is new Keccak_800.KeccakF_800_Permutation.Permute
(Num_Rounds => 1);
procedure Permute_Minor_Stride is new Keccak_800.KeccakF_800_Permutation.Permute
(Num_Rounds => 6);
package Twisted_Lanes_800 is new Keccak_800.KeccakF_800_Lanes.Twisted;
procedure XOR_Padding_Into_State is new Keccak.Padding.XOR_Pad101_Into_State
(State_Size_Bits => 800,
State_Type => Keccak_800.State,
XOR_Byte_Into_State => Twisted_Lanes_800.XOR_Byte_Into_State_Twisted);
package MonkeyDuplex_Minor is new Keccak.Generic_MonkeyDuplex
(State_Size_Bits => 800,
State_Type => Keccak_800.State,
Init_State => Keccak_800.KeccakF_800.Init,
Permute_Start => Keccak_800.Rounds_12.Permute,
Permute_Step => Permute_Minor_Step,
Permute_Stride => Permute_Minor_Stride,
XOR_Bits_Into_State => Twisted_Lanes_800.XOR_Bits_Into_State_Twisted,
XOR_Byte_Into_State => Twisted_Lanes_800.XOR_Byte_Into_State_Twisted,
Extract_Bits => Twisted_Lanes_800.Extract_Bits_Twisted,
XOR_Padding_Into_State => XOR_Padding_Into_State,
Min_Padding_Bits => Keccak.Padding.Pad101_Min_Bits);
-------------------
-- Ketje Major --
-------------------
procedure Permute_Major_Step is new Keccak_1600.KeccakF_1600_Permutation.Permute
(Num_Rounds => 1);
procedure Permute_Major_Stride is new Keccak_1600.KeccakF_1600_Permutation.Permute
(Num_Rounds => 6);
package Twisted_Lanes_1600 is new Keccak_1600.KeccakF_1600_Lanes.Twisted;
procedure XOR_Padding_Into_State is new Keccak.Padding.XOR_Pad101_Into_State
(State_Size_Bits => 1600,
State_Type => Keccak_1600.State,
XOR_Byte_Into_State => Twisted_Lanes_1600.XOR_Byte_Into_State_Twisted);
package MonkeyDuplex_Major is new Keccak.Generic_MonkeyDuplex
(State_Size_Bits => 1600,
State_Type => Keccak_1600.State,
Init_State => Keccak_1600.KeccakF_1600.Init,
Permute_Start => Keccak_1600.Rounds_12.Permute,
Permute_Step => Permute_Major_Step,
Permute_Stride => Permute_Major_Stride,
XOR_Bits_Into_State => Twisted_Lanes_1600.XOR_Bits_Into_State_Twisted,
XOR_Byte_Into_State => Twisted_Lanes_1600.XOR_Byte_Into_State_Twisted,
Extract_Bits => Twisted_Lanes_1600.Extract_Bits_Twisted,
XOR_Padding_Into_State => XOR_Padding_Into_State,
Min_Padding_Bits => Keccak.Padding.Pad101_Min_Bits);
end Implementation;
-----------------------
-- Ketje Instances --
-----------------------
package Jr is new Keccak.Generic_MonkeyWrap
(Block_Size_Bytes => 16 / 8,
MonkeyDuplex => Implementation.MonkeyDuplex_Jr);
package Sr is new Keccak.Generic_MonkeyWrap
(Block_Size_Bytes => 32 / 8,
MonkeyDuplex => Implementation.MonkeyDuplex_Sr);
package Minor is new Keccak.Generic_MonkeyWrap
(Block_Size_Bytes => 128 / 8,
MonkeyDuplex => Implementation.MonkeyDuplex_Minor);
package Major is new Keccak.Generic_MonkeyWrap
(Block_Size_Bytes => 256 / 8,
MonkeyDuplex => Implementation.MonkeyDuplex_Major);
end Ketje;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- ADA.NUMERICS.GENERIC_COMPLEX_ARRAYS --
-- --
-- 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_Real_Arrays, Ada.Numerics.Generic_Complex_Types;
generic
with package Real_Arrays is new Ada.Numerics.Generic_Real_Arrays (<>);
use Real_Arrays;
with package Complex_Types is new Ada.Numerics.Generic_Complex_Types (Real);
use Complex_Types;
package Ada.Numerics.Generic_Complex_Arrays is
pragma Pure (Generic_Complex_Arrays);
-- Types
type Complex_Vector is array (Integer range <>) of Complex;
type Complex_Matrix is
array (Integer range <>, Integer range <>) of Complex;
-- Subprograms for Complex_Vector types
-- Complex_Vector selection, conversion and composition operations
function Re (X : Complex_Vector) return Real_Vector;
function Im (X : Complex_Vector) return Real_Vector;
procedure Set_Re (X : in out Complex_Vector; Re : Real_Vector);
procedure Set_Im (X : in out Complex_Vector; Im : Real_Vector);
function Compose_From_Cartesian
(Re : Real_Vector) return Complex_Vector;
function Compose_From_Cartesian
(Re, Im : Real_Vector) return Complex_Vector;
function Modulus (X : Complex_Vector) return Real_Vector;
function "abs" (Right : Complex_Vector) return Real_Vector renames Modulus;
function Argument (X : Complex_Vector) return Real_Vector;
function Argument
(X : Complex_Vector;
Cycle : Real'Base) return Real_Vector;
function Compose_From_Polar
(Modulus, Argument : Real_Vector) return Complex_Vector;
function Compose_From_Polar
(Modulus, Argument : Real_Vector;
Cycle : Real'Base) return Complex_Vector;
-- Complex_Vector arithmetic operations
function "+" (Right : Complex_Vector) return Complex_Vector;
function "-" (Right : Complex_Vector) return Complex_Vector;
function Conjugate (X : Complex_Vector) return Complex_Vector;
function "+" (Left, Right : Complex_Vector) return Complex_Vector;
function "-" (Left, Right : Complex_Vector) return Complex_Vector;
function "*" (Left, Right : Complex_Vector) return Complex;
function "abs" (Right : Complex_Vector) return Real'Base;
-- Mixed Real_Vector and Complex_Vector arithmetic operations
function "+"
(Left : Real_Vector;
Right : Complex_Vector) return Complex_Vector;
function "+"
(Left : Complex_Vector;
Right : Real_Vector) return Complex_Vector;
function "-"
(Left : Real_Vector;
Right : Complex_Vector) return Complex_Vector;
function "-"
(Left : Complex_Vector;
Right : Real_Vector) return Complex_Vector;
function "*" (Left : Real_Vector; Right : Complex_Vector) return Complex;
function "*" (Left : Complex_Vector; Right : Real_Vector) return Complex;
-- Complex_Vector scaling operations
function "*"
(Left : Complex;
Right : Complex_Vector) return Complex_Vector;
function "*"
(Left : Complex_Vector;
Right : Complex) return Complex_Vector;
function "/"
(Left : Complex_Vector;
Right : Complex) return Complex_Vector;
function "*"
(Left : Real'Base;
Right : Complex_Vector) return Complex_Vector;
function "*"
(Left : Complex_Vector;
Right : Real'Base) return Complex_Vector;
function "/"
(Left : Complex_Vector;
Right : Real'Base) return Complex_Vector;
-- Other Complex_Vector operations
function Unit_Vector
(Index : Integer;
Order : Positive;
First : Integer := 1) return Complex_Vector;
-- Subprograms for Complex_Matrix types
-- Complex_Matrix selection, conversion and composition operations
function Re (X : Complex_Matrix) return Real_Matrix;
function Im (X : Complex_Matrix) return Real_Matrix;
procedure Set_Re (X : in out Complex_Matrix; Re : Real_Matrix);
procedure Set_Im (X : in out Complex_Matrix; Im : Real_Matrix);
function Compose_From_Cartesian (Re : Real_Matrix) return Complex_Matrix;
function Compose_From_Cartesian
(Re, Im : Real_Matrix) return Complex_Matrix;
function Modulus (X : Complex_Matrix) return Real_Matrix;
function "abs" (Right : Complex_Matrix) return Real_Matrix renames Modulus;
function Argument (X : Complex_Matrix) return Real_Matrix;
function Argument
(X : Complex_Matrix;
Cycle : Real'Base) return Real_Matrix;
function Compose_From_Polar
(Modulus, Argument : Real_Matrix) return Complex_Matrix;
function Compose_From_Polar
(Modulus : Real_Matrix;
Argument : Real_Matrix;
Cycle : Real'Base) return Complex_Matrix;
-- Complex_Matrix arithmetic operations
function "+" (Right : Complex_Matrix) return Complex_Matrix;
function "-" (Right : Complex_Matrix) return Complex_Matrix;
function Conjugate (X : Complex_Matrix) return Complex_Matrix;
function Transpose (X : Complex_Matrix) return Complex_Matrix;
function "+" (Left, Right : Complex_Matrix) return Complex_Matrix;
function "-" (Left, Right : Complex_Matrix) return Complex_Matrix;
function "*" (Left, Right : Complex_Matrix) return Complex_Matrix;
function "*" (Left, Right : Complex_Vector) return Complex_Matrix;
function "*"
(Left : Complex_Vector;
Right : Complex_Matrix) return Complex_Vector;
function "*"
(Left : Complex_Matrix;
Right : Complex_Vector) return Complex_Vector;
-- Mixed Real_Matrix and Complex_Matrix arithmetic operations
function "+"
(Left : Real_Matrix;
Right : Complex_Matrix) return Complex_Matrix;
function "+"
(Left : Complex_Matrix;
Right : Real_Matrix) return Complex_Matrix;
function "-"
(Left : Real_Matrix;
Right : Complex_Matrix) return Complex_Matrix;
function "-"
(Left : Complex_Matrix;
Right : Real_Matrix) return Complex_Matrix;
function "*"
(Left : Real_Matrix;
Right : Complex_Matrix) return Complex_Matrix;
function "*"
(Left : Complex_Matrix;
Right : Real_Matrix) return Complex_Matrix;
function "*"
(Left : Real_Vector;
Right : Complex_Vector) return Complex_Matrix;
function "*"
(Left : Complex_Vector;
Right : Real_Vector) return Complex_Matrix;
function "*"
(Left : Real_Vector;
Right : Complex_Matrix) return Complex_Vector;
function "*"
(Left : Complex_Vector;
Right : Real_Matrix) return Complex_Vector;
function "*"
(Left : Real_Matrix;
Right : Complex_Vector) return Complex_Vector;
function "*"
(Left : Complex_Matrix;
Right : Real_Vector) return Complex_Vector;
-- Complex_Matrix scaling operations
function "*"
(Left : Complex;
Right : Complex_Matrix) return Complex_Matrix;
function "*"
(Left : Complex_Matrix;
Right : Complex) return Complex_Matrix;
function "/"
(Left : Complex_Matrix;
Right : Complex) return Complex_Matrix;
function "*"
(Left : Real'Base;
Right : Complex_Matrix) return Complex_Matrix;
function "*"
(Left : Complex_Matrix;
Right : Real'Base) return Complex_Matrix;
function "/"
(Left : Complex_Matrix;
Right : Real'Base) return Complex_Matrix;
-- Complex_Matrix inversion and related operations
function Solve
(A : Complex_Matrix;
X : Complex_Vector) return Complex_Vector;
function Solve (A, X : Complex_Matrix) return Complex_Matrix;
function Inverse (A : Complex_Matrix) return Complex_Matrix;
function Determinant (A : Complex_Matrix) return Complex;
-- Eigenvalues and vectors of a Hermitian matrix
function Eigenvalues (A : Complex_Matrix) return Real_Vector;
procedure Eigensystem
(A : Complex_Matrix;
Values : out Real_Vector;
Vectors : out Complex_Matrix);
-- Other Complex_Matrix operations
function Unit_Matrix
(Order : Positive;
First_1, First_2 : Integer := 1) return Complex_Matrix;
end Ada.Numerics.Generic_Complex_Arrays;
|
package body GotoTest is
procedure P(x,y:Integer) is
begin
if x = y then
goto TheEnd;
end if;
<<TheEnd>> null;
end P;
end GotoTest;
|
-- Copyright (c) 2017 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
with League.Strings;
with League.String_Vectors;
package WebDriver.Elements is
type Element is limited interface;
type Element_Access is access all Element'Class
with Storage_Size => 0;
not overriding function Is_Selected
(Self : access Element) return Boolean is abstract;
-- Determines if the referenced element is selected or not.
not overriding function Is_Enabled
(Self : access Element) return Boolean is abstract;
-- Determines if the referenced element is enabled or not.
not overriding function Get_Attribute
(Self : access Element;
Name : League.Strings.Universal_String)
return League.Strings.Universal_String is abstract;
-- Returns the attribute of a web element.
not overriding function Get_Property
(Self : access Element;
Name : League.Strings.Universal_String)
return League.Strings.Universal_String is abstract;
-- Returns the result of getting a property of an element.
not overriding function Get_CSS_Value
(Self : access Element;
Name : League.Strings.Universal_String)
return League.Strings.Universal_String is abstract;
-- Retrieves the computed value of the given CSS property of the given
-- web element.
not overriding function Get_Text
(Self : access Element)
return League.Strings.Universal_String is abstract;
-- Returns an element’s text "as rendered".
not overriding function Get_Tag_Name
(Self : access Element)
return League.Strings.Universal_String is abstract;
-- Returns the qualified element name of the given web element.
not overriding procedure Click (Self : access Element) is abstract;
-- Scrolls into view the element if it is not already pointer-interactable,
-- and clicks its in-view center point.
not overriding procedure Clear (Self : access Element) is abstract;
-- Scrolls into view an editable or resettable element and then attempts
-- to clear its selected files or text content.
not overriding procedure Send_Keys
(Self : access Element;
Text : League.String_Vectors.Universal_String_Vector) is abstract;
-- Scrolls into view the form control element and then sends the provided
-- keys to the element.
procedure Send_Keys
(Self : access Element'Class;
Text : League.Strings.Universal_String);
end WebDriver.Elements;
|
-- The Village of Vampire by YT, このソースコードはNYSLです
with Serialization;
package Tabula.Calendar.Time_IO is
procedure IO (
Serializer : not null access Serialization.Serializer;
Name : in String;
Value : in out Ada.Calendar.Time);
procedure IO (
Serializer : not null access Serialization.Serializer;
Name : in String;
Value : in out Duration);
end Tabula.Calendar.Time_IO;
|
package body BBqueue.Buffers
with SPARK_Mode
is
function Get_Addr (This : Buffer;
Offset : Buffer_Offset)
return System.Address
with Pre => Offset in 0 .. This.Buf'Last - 1;
--------------
-- Get_Addr --
--------------
function Get_Addr (This : Buffer;
Offset : Buffer_Offset)
return System.Address
is
pragma SPARK_Mode (Off);
begin
return This.Buf (This.Buf'First + Offset)'Address;
end Get_Addr;
-----------
-- Grant --
-----------
procedure Grant (This : in out Buffer;
G : in out Write_Grant;
Size : Count)
is
begin
BBqueue.Grant (This.Offsets, G.Offsets_Grant, Size);
if G.Offsets_Grant.Result = Valid then
G.Slice.Length := G.Offsets_Grant.Slice.Length;
G.Slice.Addr := Get_Addr (This, G.Offsets_Grant.Slice.From);
end if;
end Grant;
------------
-- Commit --
------------
procedure Commit
(This : in out Buffer; G : in out Write_Grant; Size : Count := Count'Last)
is
begin
BBqueue.Commit (This.Offsets, G.Offsets_Grant, Size);
end Commit;
--------------
-- Write_CB --
--------------
procedure Write_CB (This : in out Buffer;
Size : Count;
Result : out Result_Kind)
is
G : Write_Grant := Empty;
begin
Grant (This, G, Size);
Result := State (G);
if Result = Valid then
declare
S : constant BBqueue.Slice_Rec := BBqueue.Slice (G.Offsets_Grant);
B : Storage_Array renames This.Buf;
To_Commit : Count;
begin
Process_Write (B (B'First + S.From .. B'First + S.To),
To_Commit);
Commit (This, G, To_Commit);
pragma Assert (State (G) = Empty);
end;
end if;
end Write_CB;
----------
-- Read --
----------
procedure Read (This : in out Buffer;
G : in out Read_Grant;
Max : Count := Count'Last)
is
begin
BBqueue.Read (This.Offsets, G.Offsets_Grant, Max);
if G.Offsets_Grant.Result = Valid then
G.Slice.Length := G.Offsets_Grant.Slice.Length;
G.Slice.Addr := Get_Addr (This, G.Offsets_Grant.Slice.From);
end if;
end Read;
-------------
-- Release --
-------------
procedure Release
(This : in out Buffer; G : in out Read_Grant; Size : Count := Count'Last)
is
begin
BBqueue.Release (This.Offsets, G.Offsets_Grant, Size);
end Release;
-------------
-- Read_CB --
-------------
procedure Read_CB (This : in out Buffer;
Result : out Result_Kind)
is
pragma SPARK_Mode (Off);
G : Read_Grant := Empty;
begin
Read (This, G);
Result := State (G);
if Result = Valid then
declare
S : constant BBqueue.Slice_Rec := BBqueue.Slice (G.Offsets_Grant);
B : Storage_Array renames This.Buf;
To_Release : Count;
begin
Process_Read (B (B'First + S.From .. B'First + S.To),
To_Release);
Release (This, G, To_Release);
pragma Assert (State (G) = Empty);
end;
end if;
end Read_CB;
end BBqueue.Buffers;
|
------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- S Y S T E M . C R C 3 2 --
-- --
-- B o d y --
-- --
-- Copyright (C) 2001-2021, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
pragma Compiler_Unit_Warning;
package body System.CRC32 is
Init : constant CRC32 := 16#FFFF_FFFF#; -- Initial value
XorOut : constant CRC32 := 16#FFFF_FFFF#; -- To compute final result.
-- The following table contains precomputed values for contributions
-- from various possible byte values. Doing a table lookup is quicker
-- than processing the byte bit by bit.
Table : constant array (CRC32 range 0 .. 255) of CRC32 :=
(16#0000_0000#, 16#7707_3096#, 16#EE0E_612C#, 16#9909_51BA#,
16#076D_C419#, 16#706A_F48F#, 16#E963_A535#, 16#9E64_95A3#,
16#0EDB_8832#, 16#79DC_B8A4#, 16#E0D5_E91E#, 16#97D2_D988#,
16#09B6_4C2B#, 16#7EB1_7CBD#, 16#E7B8_2D07#, 16#90BF_1D91#,
16#1DB7_1064#, 16#6AB0_20F2#, 16#F3B9_7148#, 16#84BE_41DE#,
16#1ADA_D47D#, 16#6DDD_E4EB#, 16#F4D4_B551#, 16#83D3_85C7#,
16#136C_9856#, 16#646B_A8C0#, 16#FD62_F97A#, 16#8A65_C9EC#,
16#1401_5C4F#, 16#6306_6CD9#, 16#FA0F_3D63#, 16#8D08_0DF5#,
16#3B6E_20C8#, 16#4C69_105E#, 16#D560_41E4#, 16#A267_7172#,
16#3C03_E4D1#, 16#4B04_D447#, 16#D20D_85FD#, 16#A50A_B56B#,
16#35B5_A8FA#, 16#42B2_986C#, 16#DBBB_C9D6#, 16#ACBC_F940#,
16#32D8_6CE3#, 16#45DF_5C75#, 16#DCD6_0DCF#, 16#ABD1_3D59#,
16#26D9_30AC#, 16#51DE_003A#, 16#C8D7_5180#, 16#BFD0_6116#,
16#21B4_F4B5#, 16#56B3_C423#, 16#CFBA_9599#, 16#B8BD_A50F#,
16#2802_B89E#, 16#5F05_8808#, 16#C60C_D9B2#, 16#B10B_E924#,
16#2F6F_7C87#, 16#5868_4C11#, 16#C161_1DAB#, 16#B666_2D3D#,
16#76DC_4190#, 16#01DB_7106#, 16#98D2_20BC#, 16#EFD5_102A#,
16#71B1_8589#, 16#06B6_B51F#, 16#9FBF_E4A5#, 16#E8B8_D433#,
16#7807_C9A2#, 16#0F00_F934#, 16#9609_A88E#, 16#E10E_9818#,
16#7F6A_0DBB#, 16#086D_3D2D#, 16#9164_6C97#, 16#E663_5C01#,
16#6B6B_51F4#, 16#1C6C_6162#, 16#8565_30D8#, 16#F262_004E#,
16#6C06_95ED#, 16#1B01_A57B#, 16#8208_F4C1#, 16#F50F_C457#,
16#65B0_D9C6#, 16#12B7_E950#, 16#8BBE_B8EA#, 16#FCB9_887C#,
16#62DD_1DDF#, 16#15DA_2D49#, 16#8CD3_7CF3#, 16#FBD4_4C65#,
16#4DB2_6158#, 16#3AB5_51CE#, 16#A3BC_0074#, 16#D4BB_30E2#,
16#4ADF_A541#, 16#3DD8_95D7#, 16#A4D1_C46D#, 16#D3D6_F4FB#,
16#4369_E96A#, 16#346E_D9FC#, 16#AD67_8846#, 16#DA60_B8D0#,
16#4404_2D73#, 16#3303_1DE5#, 16#AA0A_4C5F#, 16#DD0D_7CC9#,
16#5005_713C#, 16#2702_41AA#, 16#BE0B_1010#, 16#C90C_2086#,
16#5768_B525#, 16#206F_85B3#, 16#B966_D409#, 16#CE61_E49F#,
16#5EDE_F90E#, 16#29D9_C998#, 16#B0D0_9822#, 16#C7D7_A8B4#,
16#59B3_3D17#, 16#2EB4_0D81#, 16#B7BD_5C3B#, 16#C0BA_6CAD#,
16#EDB8_8320#, 16#9ABF_B3B6#, 16#03B6_E20C#, 16#74B1_D29A#,
16#EAD5_4739#, 16#9DD2_77AF#, 16#04DB_2615#, 16#73DC_1683#,
16#E363_0B12#, 16#9464_3B84#, 16#0D6D_6A3E#, 16#7A6A_5AA8#,
16#E40E_CF0B#, 16#9309_FF9D#, 16#0A00_AE27#, 16#7D07_9EB1#,
16#F00F_9344#, 16#8708_A3D2#, 16#1E01_F268#, 16#6906_C2FE#,
16#F762_575D#, 16#8065_67CB#, 16#196C_3671#, 16#6E6B_06E7#,
16#FED4_1B76#, 16#89D3_2BE0#, 16#10DA_7A5A#, 16#67DD_4ACC#,
16#F9B9_DF6F#, 16#8EBE_EFF9#, 16#17B7_BE43#, 16#60B0_8ED5#,
16#D6D6_A3E8#, 16#A1D1_937E#, 16#38D8_C2C4#, 16#4FDF_F252#,
16#D1BB_67F1#, 16#A6BC_5767#, 16#3FB5_06DD#, 16#48B2_364B#,
16#D80D_2BDA#, 16#AF0A_1B4C#, 16#3603_4AF6#, 16#4104_7A60#,
16#DF60_EFC3#, 16#A867_DF55#, 16#316E_8EEF#, 16#4669_BE79#,
16#CB61_B38C#, 16#BC66_831A#, 16#256F_D2A0#, 16#5268_E236#,
16#CC0C_7795#, 16#BB0B_4703#, 16#2202_16B9#, 16#5505_262F#,
16#C5BA_3BBE#, 16#B2BD_0B28#, 16#2BB4_5A92#, 16#5CB3_6A04#,
16#C2D7_FFA7#, 16#B5D0_CF31#, 16#2CD9_9E8B#, 16#5BDE_AE1D#,
16#9B64_C2B0#, 16#EC63_F226#, 16#756A_A39C#, 16#026D_930A#,
16#9C09_06A9#, 16#EB0E_363F#, 16#7207_6785#, 16#0500_5713#,
16#95BF_4A82#, 16#E2B8_7A14#, 16#7BB1_2BAE#, 16#0CB6_1B38#,
16#92D2_8E9B#, 16#E5D5_BE0D#, 16#7CDC_EFB7#, 16#0BDB_DF21#,
16#86D3_D2D4#, 16#F1D4_E242#, 16#68DD_B3F8#, 16#1FDA_836E#,
16#81BE_16CD#, 16#F6B9_265B#, 16#6FB0_77E1#, 16#18B7_4777#,
16#8808_5AE6#, 16#FF0F_6A70#, 16#6606_3BCA#, 16#1101_0B5C#,
16#8F65_9EFF#, 16#F862_AE69#, 16#616B_FFD3#, 16#166C_CF45#,
16#A00A_E278#, 16#D70D_D2EE#, 16#4E04_8354#, 16#3903_B3C2#,
16#A767_2661#, 16#D060_16F7#, 16#4969_474D#, 16#3E6E_77DB#,
16#AED1_6A4A#, 16#D9D6_5ADC#, 16#40DF_0B66#, 16#37D8_3BF0#,
16#A9BC_AE53#, 16#DEBB_9EC5#, 16#47B2_CF7F#, 16#30B5_FFE9#,
16#BDBD_F21C#, 16#CABA_C28A#, 16#53B3_9330#, 16#24B4_A3A6#,
16#BAD0_3605#, 16#CDD7_0693#, 16#54DE_5729#, 16#23D9_67BF#,
16#B366_7A2E#, 16#C461_4AB8#, 16#5D68_1B02#, 16#2A6F_2B94#,
16#B40B_BE37#, 16#C30C_8EA1#, 16#5A05_DF1B#, 16#2D02_EF8D#);
---------------
-- Get_Value --
---------------
function Get_Value (C : CRC32) return Interfaces.Unsigned_32 is
begin
return Interfaces.Unsigned_32 (C xor XorOut);
end Get_Value;
----------------
-- Initialize --
----------------
procedure Initialize (C : out CRC32) is
begin
C := Init;
end Initialize;
------------
-- Update --
------------
procedure Update (C : in out CRC32; Value : Character) is
V : constant CRC32 := CRC32 (Character'Pos (Value));
begin
C := Shift_Right (C, 8) xor Table (V xor (C and 16#0000_00FF#));
end Update;
end System.CRC32;
|
-----------------------------------------------------------------------
-- babel-base -- Database for files
-- Copyright (C) 2014 Stephane.Carrez
-- Written by Stephane.Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Streams;
with Ada.Calendar;
with Ada.Exceptions;
with Util.Dates.ISO8601;
with Util.Files;
with Util.Strings;
with Util.Encoders.Base16;
with Util.Encoders.SHA1;
with Util.Log.Loggers;
with Babel.Files.Sets;
with Babel.Files.Maps;
with Babel.Files.Lifecycles;
with Ada.Text_IO;
package body Babel.Base.Text is
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Babel.Base.Text");
-- ------------------------------
-- Insert the file in the database.
-- ------------------------------
overriding
procedure Insert (Into : in out Text_Database;
File : in Babel.Files.File_Type) is
begin
Into.Files.Insert (File);
end Insert;
overriding
procedure Iterate (From : in Text_Database;
Process : not null access procedure (File : in Babel.Files.File_Type)) is
procedure Process_One (Pos : in Babel.Files.Sets.File_Cursor) is
begin
Process (Babel.Files.Sets.File_Sets.Element (Pos));
end Process_One;
begin
From.Files.Iterate (Process_One'Access);
end Iterate;
-- ------------------------------
-- Save the database file description in the file.
-- ------------------------------
procedure Save (Database : in Text_Database;
Path : in String) is
Checksum : Ada.Text_IO.File_Type;
procedure Write_Checksum (Position : in Babel.Files.Sets.File_Cursor) is
File : constant Babel.Files.File_Type := Babel.Files.Sets.File_Sets.Element (Position);
SHA1 : constant String := Babel.Files.Get_SHA1 (File);
Path : constant String := Babel.Files.Get_Path (File);
begin
Ada.Text_IO.Put (Checksum, SHA1);
Ada.Text_IO.Put (Checksum, Babel.Uid_Type'Image (Babel.Files.Get_User (File)));
Ada.Text_IO.Put (Checksum, Babel.Gid_Type'Image (Babel.Files.Get_Group (File)));
Ada.Text_IO.Put (Checksum, " ");
Ada.Text_IO.Put (Checksum, Util.Dates.ISO8601.Image (Babel.Files.Get_Date (File)));
Ada.Text_IO.Put (Checksum, Babel.Files.File_Size'Image (Babel.Files.Get_Size (File)));
Ada.Text_IO.Put (Checksum, " ");
Ada.Text_IO.Put (Checksum, Path);
Ada.Text_IO.New_Line (Checksum);
end Write_Checksum;
begin
Log.Info ("Save text database {0}", Path);
Ada.Text_IO.Create (File => Checksum, Name => Path);
Database.Files.Iterate (Write_Checksum'Access);
Ada.Text_IO.Close (File => Checksum);
end Save;
-- ------------------------------
-- Load the database file description from the file.
-- ------------------------------
procedure Load (Database : in out Text_Database;
Path : in String) is
Checksum : Ada.Text_IO.File_Type;
Dirs : Babel.Files.Maps.Directory_Map;
Files : Babel.Files.Maps.File_Map;
Hex_Decoder : Util.Encoders.Base16.Decoder;
Line_Number : Natural := 0;
procedure Read_Line (Line : in String) is
File : Babel.Files.File_Type;
Pos : Natural;
First : Natural;
Sign : Util.Encoders.SHA1.Hash_Array;
Sign_Size : Ada.Streams.Stream_Element_Offset;
User : Uid_Type;
Group : Gid_Type;
Date : Ada.Calendar.Time;
Size : Babel.Files.File_Size;
begin
Line_Number := Line_Number + 1;
Pos := Util.Strings.Index (Line, ' ');
if Pos = 0 then
return;
end if;
Hex_Decoder.Transform (Line (Line'First .. Pos - 1), Sign, Sign_Size);
-- Extract the user ID.
First := Pos + 1;
Pos := Util.Strings.Index (Line, ' ', First);
if Pos = 0 then
return;
end if;
User := Uid_Type'Value (Line (First .. Pos - 1));
-- Extract the group ID.
First := Pos + 1;
Pos := Util.Strings.Index (Line, ' ', First);
if Pos = 0 then
return;
end if;
Group := Uid_Type'Value (Line (First .. Pos - 1));
-- Extract the file date.
First := Pos + 1;
Pos := Util.Strings.Index (Line, ' ', First);
if Pos = 0 then
return;
end if;
Date := Util.Dates.ISO8601.Value (Line (First .. Pos - 1));
-- Extract the file size.
First := Pos + 1;
Pos := Util.Strings.Index (Line, ' ', First);
if Pos = 0 then
return;
end if;
Size := Babel.Files.File_Size'Value (Line (First .. Pos - 1));
Babel.Files.Maps.Add_File (Dirs, Files, Line (Pos + 1 .. Line'Last), File);
Babel.Files.Set_Owner (File, User, Group);
Babel.Files.Set_Size (File, Size);
Babel.Files.Set_Signature (File, Sign);
Babel.Files.Set_Date (File, Date);
Database.Insert (File);
exception
when E : others =>
Log.Error ("{0}:{1}: Error: {2}: {3}: " & Line, Path, Natural'Image (Line_Number),
Ada.Exceptions.Exception_Message (E));
end Read_Line;
begin
Log.Info ("Load text database {0}", Path);
Util.Files.Read_File (Path, Read_Line'Access);
end Load;
end Babel.Base.Text;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- R E S T R I C T --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package deals with the implementation of the Restrictions pragma
with Rident; use Rident;
with Table;
with Types; use Types;
with Uintp; use Uintp;
package Restrict is
Restrictions : Restrictions_Info;
-- This variable records restrictions found in any units in the main
-- extended unit, and in the case of restrictions checked for partition
-- consistency, restrictions found in any with'ed units, parent specs
-- etc, since we may as well check as much as we can at compile time.
-- These variables should not be referenced directly by clients. Instead
-- use Check_Restrictions to record a violation of a restriction, and
-- Restriction_Active to test if a given restriction is active.
Restrictions_Loc : array (All_Restrictions) of Source_Ptr :=
(others => No_Location);
-- Locations of Restrictions pragmas for error message purposes.
-- Valid only if corresponding entry in Restrictions is set. A value
-- of No_Location is used for implicit restrictions set by another
-- pragma, and a value of System_Location is used for restrictions
-- set from package Standard by the processing in Targparm.
Main_Restrictions : Restrictions_Info;
-- This variable records only restrictions found in any units of the
-- main extended unit. These are the variables used for ali file output,
-- since we want the binder to be able to accurately diagnose inter-unit
-- restriction violations.
Restriction_Warnings : Rident.Restriction_Flags;
-- If one of these flags is set, then it means that violation of the
-- corresponding restriction results only in a warning message, not
-- in an error message, and the restriction is not otherwise enforced.
-- Note that the flags in Restrictions are set to indicate that the
-- restriction is set in this case, but Main_Restrictions is never
-- set if Restriction_Warnings is set, so this does not look like a
-- restriction to the binder.
type Save_Cunit_Boolean_Restrictions is private;
-- Type used for saving and restoring compilation unit restrictions.
-- See Cunit_Boolean_Restrictions_[Save|Restore] subprograms.
-- The following declarations establish a mapping between restriction
-- identifiers, and the names of corresponding restriction library units.
type Unit_Entry is record
Res_Id : Restriction_Id;
Filenm : String (1 .. 8);
end record;
Unit_Array : constant array (Positive range <>) of Unit_Entry := (
(No_Asynchronous_Control, "a-astaco"),
(No_Calendar, "a-calend"),
(No_Calendar, "calendar"),
(No_Delay, "a-calend"),
(No_Delay, "calendar"),
(No_Dynamic_Priorities, "a-dynpri"),
(No_Finalization, "a-finali"),
(No_IO, "a-direio"),
(No_IO, "directio"),
(No_IO, "a-sequio"),
(No_IO, "sequenio"),
(No_IO, "a-ststio"),
(No_IO, "a-textio"),
(No_IO, "text_io "),
(No_IO, "a-witeio"),
(No_Task_Attributes_Package, "a-tasatt"),
(No_Unchecked_Conversion, "a-unccon"),
(No_Unchecked_Conversion, "unchconv"),
(No_Unchecked_Deallocation, "a-uncdea"),
(No_Unchecked_Deallocation, "unchdeal"));
-- The following map has True for all GNAT pragmas. It is used to
-- implement pragma Restrictions (No_Implementation_Restrictions)
-- (which is why this restriction itself is excluded from the list).
Implementation_Restriction : array (All_Restrictions) of Boolean :=
(Simple_Barriers => True,
No_Calendar => True,
No_Dispatching_Calls => True,
No_Dynamic_Attachment => True,
No_Enumeration_Maps => True,
No_Entry_Calls_In_Elaboration_Code => True,
No_Entry_Queue => True,
No_Exception_Handlers => True,
No_Exception_Registration => True,
No_Implicit_Conditionals => True,
No_Implicit_Dynamic_Code => True,
No_Implicit_Loops => True,
No_Local_Protected_Objects => True,
No_Protected_Type_Allocators => True,
No_Relative_Delay => True,
No_Requeue_Statements => True,
No_Secondary_Stack => True,
No_Select_Statements => True,
No_Standard_Storage_Pools => True,
No_Streams => True,
No_Task_Attributes_Package => True,
No_Task_Termination => True,
No_Wide_Characters => True,
Static_Priorities => True,
Static_Storage_Size => True,
No_Implementation_Attributes => True,
No_Implementation_Pragmas => True,
No_Elaboration_Code => True,
others => False);
-- The following table records entries made by Restrictions pragmas
-- that specify a parameter for No_Dependence. Each such pragma makes
-- an entry in this table.
-- Note: we have chosen to implement this restriction in the "syntactic"
-- form, where we do not check that the named package is a language defined
-- package, but instead we allow arbitrary package names. The discussion of
-- this issue is not complete in the ARG, but the sense seems to be leaning
-- in this direction, which makes more sense to us, since it is much more
-- useful, and much easier to implement.
type ND_Entry is record
Unit : Node_Id;
-- The unit parameter from the No_Dependence pragma
Warn : Boolean;
-- True if from Restriction_Warnings, False if from Restrictions
end record;
package No_Dependence is new Table.Table (
Table_Component_Type => ND_Entry,
Table_Index_Type => Int,
Table_Low_Bound => 0,
Table_Initial => 200,
Table_Increment => 200,
Table_Name => "Name_No_Dependence");
-----------------
-- Subprograms --
-----------------
function Abort_Allowed return Boolean;
pragma Inline (Abort_Allowed);
-- Tests to see if abort is allowed by the current restrictions settings.
-- For abort to be allowed, either No_Abort_Statements must be False,
-- or Max_Asynchronous_Select_Nesting must be non-zero.
procedure Check_Restricted_Unit (U : Unit_Name_Type; N : Node_Id);
-- Checks if loading of unit U is prohibited by the setting of some
-- restriction (e.g. No_IO restricts the loading of unit Ada.Text_IO).
-- If a restriction exists post error message at the given node.
procedure Check_Restriction
(R : Restriction_Id;
N : Node_Id;
V : Uint := Uint_Minus_1);
-- Checks that the given restriction is not set, and if it is set, an
-- appropriate message is posted on the given node. Also records the
-- violation in the appropriate internal arrays. Note that it is
-- mandatory to always use this routine to check if a restriction
-- is violated. Such checks must never be done directly by the caller,
-- since otherwise violations in the absence of restrictions are not
-- properly recorded. The value of V is relevant only for parameter
-- restrictions, and in this case indicates the exact count for the
-- violation. If the exact count is not known, V is left at its
-- default value of -1 which indicates an unknown count.
procedure Check_Restriction_No_Dependence (U : Node_Id; Err : Node_Id);
-- Called when a dependence on a unit is created (either implicitly, or by
-- an explicit WITH clause). U is a node for the unit involved, and Err
-- is the node to which an error will be attached if necessary.
procedure Check_Elaboration_Code_Allowed (N : Node_Id);
-- Tests to see if elaboration code is allowed by the current restrictions
-- settings. This function is called by Gigi when it needs to define
-- an elaboration routine. If elaboration code is not allowed, an error
-- message is posted on the node given as argument.
procedure Check_No_Implicit_Heap_Alloc (N : Node_Id);
-- Equivalent to Check_Restriction (No_Implicit_Heap_Allocations, N).
-- Provided for easy use by back end, which has to check this restriction.
function Cunit_Boolean_Restrictions_Save
return Save_Cunit_Boolean_Restrictions;
-- This function saves the compilation unit restriction settings, and
-- resets them to False. This is used e.g. when compiling a with'ed
-- unit to avoid incorrectly propagating restrictions. Note that it
-- would not be wrong to also save and reset the partition restrictions,
-- since the binder would catch inconsistencies, but actually it is a
-- good thing to acquire restrictions from with'ed units if they are
-- required to be partition wide, because it allows the restriction
-- violation message to be given at compile time instead of link time.
procedure Cunit_Boolean_Restrictions_Restore
(R : Save_Cunit_Boolean_Restrictions);
-- This is the corresponding restore procedure to restore restrictions
-- previously saved by Cunit_Boolean_Restrictions_Save.
function Get_Restriction_Id
(N : Name_Id) return Restriction_Id;
-- Given an identifier name, determines if it is a valid restriction
-- identifier, and if so returns the corresponding Restriction_Id
-- value, otherwise returns Not_A_Restriction_Id.
function No_Exception_Handlers_Set return Boolean;
-- Test to see if current restrictions settings specify that no exception
-- handlers are present. This function is called by Gigi when it needs to
-- expand an AT END clean up identifier with no exception handler.
function Process_Restriction_Synonyms (N : Node_Id) return Name_Id;
-- Id is a node whose Chars field contains the name of a restriction.
-- If it is one of synonyms that we allow for historical purposes (for
-- list see System.Rident), then the proper official name is returned.
-- Otherwise the Chars field of the argument is returned unchanged.
function Restriction_Active (R : All_Restrictions) return Boolean;
pragma Inline (Restriction_Active);
-- Determines if a given restriction is active. This call should only be
-- used where the compiled code depends on whether the restriction is
-- active. Always use Check_Restriction to record a violation.
function Restricted_Profile return Boolean;
-- Tests if set of restrictions corresponding to Profile (Restricted) is
-- currently in effect (set by pragma Profile, or by an appropriate set
-- of individual Restrictions pragms). Returns True only if all the
-- required restrictions are set.
procedure Set_Profile_Restrictions
(P : Profile_Name;
N : Node_Id;
Warn : Boolean);
-- Sets the set of restrictions associated with the given profile
-- name. N is the node of the construct to which error messages
-- are to be attached as required. Warn is set True for the case
-- of Profile_Warnings where the restrictions are set as warnings
-- rather than legality requirements.
procedure Set_Restriction
(R : All_Boolean_Restrictions;
N : Node_Id);
-- N is a node (typically a pragma node) that has the effect of setting
-- Boolean restriction R. The restriction is set in Restrictions, and
-- also in Main_Restrictions if this is the main unit.
procedure Set_Restriction
(R : All_Parameter_Restrictions;
N : Node_Id;
V : Integer);
-- Similar to the above, except that this is used for the case of a
-- parameter restriction, and the corresponding value V is given.
procedure Set_Restriction_No_Dependence
(Unit : Node_Id;
Warn : Boolean);
-- Sets given No_Dependence restriction in table if not there already.
-- Warn is True if from Restriction_Warnings, False if from Restrictions.
function Tasking_Allowed return Boolean;
pragma Inline (Tasking_Allowed);
-- Tests to see if tasking operations are allowed by the current
-- restrictions settings. For tasking to be allowed Max_Tasks must
-- be non-zero.
private
type Save_Cunit_Boolean_Restrictions is
array (Cunit_Boolean_Restrictions) of Boolean;
-- Type used for saving and restoring compilation unit restrictions.
-- See Compilation_Unit_Restrictions_[Save|Restore] subprograms.
end Restrict;
|
--|---------------------------------------------------------------------------
--|
--| Unit Name: Workload
--|
--| Unit Type: Package Body
--|
--| Description:
--| See the description in the package specification and the description
--| of the Small_Whetstone procedure below.
--|
--| The Small_Whetstone procedure requires an implementation-dependent
--| mathematical library. Refer to the explanatory comments in the
--| procedure for details.
--|
--|---------------------------------------------------------------------------
-- IMPLEMENTATION-DEPENDENT library name; see examples below
-- with Float_Math_Lib;
-- use Float_Math_Lib;
-- with Ada.Numerics.Generic_Elementary_Functions;
with Ada.Numerics.Elementary_Functions;
use Ada.Numerics.Elementary_Functions;
package body Workload is
-- IMPLEMENTATION-DEPENDENT subtype definition; see comments below
subtype Whet_Float is Float;
-- package Math is new Ada.Numerics.Generic_Elementary_Functions(Whet_Float);
-- use Math;
-- IMPLEMENTATION-DEPENDENT library & function names; see examples in
-- comments below
-- function Log(X : in Whet_Float) return Whet_Float
-- renames Float_Math_Lib.Log;
--|-------------------------------------------------------------------------
--|
--| Unit Name: Small_Whetstone
--|
--| Unit Type: Procedure Body
--|
--| This version of the Whetstone benchmark is designed to have an inner
--| loop which executes only 1000 Whetstone instructions. This is so that
--| smaller units of CPU time can be requested for benchmarks, especially
--| real-time benchmarks. The parameter "Kilo_Whets" determines the number
--| of loop iterations; a value of 1 means the loop will execute 1000
--| Whetstone Instructions. A Whetstone Instruction corresponds to about
--| 1.3 machine instructions on a conventional machine with floating point.
--|
--| Small_Whetstone was developed by Brian Wichmann of the UK National
--| Physical Laboratory (NPL). The Ada version was translated at the
--| Carnegie Mellon University Software Engineering Institute from the
--| original standard Pascal language version (see references below).
--| This Hartstone version has been adapted from the Ada standard
--| version by making the Kilo_Whets variable a passed parameter, and
--| by raising an exception, rather than printing an error message, if
--| the benchmark's internal consistency check fails.
--|
--| Small_Whetstone uses the following mathematical functions, which are
--| listed here using the ISO/WG9 Numerics Rapporteur Group proposed
--| standard names for functions of a Generic_Elementary_Functions library
--| (Float_Type is a generic type definition):
--|
--| function Cos (X : Float_Type) return Float_Type;
--| function Exp (X : Float_Type) return Float_Type;
--| function Log (X : Float_Type) return Float_Type; -- Natural logs
--| function Sin (X : Float_Type) return Float_Type;
--| function Sqrt (X : Float_Type) return Float_Type;
--|
--| The name of the actual mathematical library and the functions it
--| provides are implementation-dependent. For Small_Whetstone, the
--| function name to be careful of is the natural logarithm function;
--| some vendors call it "Log" while others call it "Ln". A renaming
--| declaration has been provided to rename the function according to
--| the ISO/WG9 name.
--| Another implementation-dependent area is the accuracy of floating-
--| point types. One vendor's Float is another's Long_Float, or even
--| Short_Float. The subtype Whet_Float is provided so that the change
--| can be made in a single place; users should modify it as necessary
--| to ensure comparability of their test runs.
--|
--| Examples of some vendor mathematical library and log function names,
--| and the values of the 'Digits attribute for the floating-point types
--| are provided in the comments below. The ONLY changes a user should
--| make to run Small_Whetstone are (a) the library name, (b) the log
--| function name, if necessary, and (c) the definition of the subtype
--| Whet_Float, if necessary. Any changes should be documented along
--| with reported results.
--|
--| References:
--| The first two apply only to the full version of Whetstone. The
--| first includes a listing of the original Algol version. The second
--| includes an Ada listing. The third reference also deals mostly with
--| the full Whetstone benchmark but in addition contains a brief
--| rationale for the Small_Whetstone benchmark and a listing of its
--| standard Pascal version.
--|
--| Curnow, H.J., and Wichmann, B.A.
--| A Synthetic Benchmark
--| The Computer Journal, Vol. 19, No. 1, February 1976, pp. 43-49.
--|
--| Harbaugh, S., and Forakis, J.A.
--| Timing Studies Using a Synthetic Whetstone Benchmark
--| Ada Letters, Vol. 4, No. 2, 1984, pp. 23-34.
--|
--| Wichmann, B.A.,
--| Validation Code for the Whetstone Benchmark
--| NPL report DITC 107/88, March 1988.
--| National Physical Laboratory,
--| Teddington, Middlesex TW11 OLW, UK.
--|
--|-------------------------------------------------------------------------
----------------------------------------------------------------------------
-- Math library for TeleSoft TeleGen2 VAX/VMS -> MC68020:
--
-- with Math_Library;
--
-- package Math is new Math_Library(Whet_Float);
-- use Math;
--
-- Natural logs (base e) = Ln(x); base 10 logs = Log(x).
-- There is also a pre-instantiated library called Float_Math_Library.
--
-- Float'Digits = 6; Long_Float'Digits = 15
----------------------------------------------------------------------------
-- Math library for Verdix VADS VAX/VMS -> MC68020:
--
-- with Generic_Elementary_Functions;
--
-- package Math is new Generic_Elementary_Functions(Whet_Float);
-- use Math;
--
-- Natural logs (base e) = Log(x); base 10 logs = Log(x, Base => 10).
--
-- Short_Float'Digits = 6; Float'Digits = 15
---------------------------------------------------------------------------
-- Math library for DEC VAX Ada:
--
-- with Float_Math_Lib;
-- use Float_Math_Lib;
--
-- Natural logs (base e) = Log(x); base 10 logs = Log10(x).
--
-- Float'Digits = 6; Long_Float'Digits = 15; Long_Long_Float'Digits = 33
----------------------------------------------------------------------------
-- Math library for Alsys Ada VAX/VMS -> MC68020:
--
-- with Math_Lib;
--
-- package Math is new Math_Lib(Whet_Float);
-- use Math;
--
-- Natural logs (base e) = Log(x); base 10 logs = Log10(x).
--
-- If using the 68881 Floating-Point Co-Processor, the Math_Lib_M68881
-- package can be used.
--
-- Float'Digits = 6; Long_Float'Digits = 15
----------------------------------------------------------------------------
-- Math library for DDC-I Ada (DACS-80386PM) VAX/VMS -> i80386:
--
-- with Math_Pack;
-- use Math_Pack;
--
-- Natural logs (base e) = Ln(x); base 10 logs = Log(x, 10.0).
--
-- Float'Digits = 6; Long_Float'Digits = 15
----------------------------------------------------------------------------
-- Math library for Systems Designers XD Ada VAX/VMS -> MC68020:
--
-- with Float_Math_Lib;
-- use Float_Math_Lib;
--
-- Natural logs (base e) = Log(x); base 10 logs = Log10(x).
--
-- Float'Digits = 6; Long_Float'Digits = 15; Long_Long_Float'Digits = 18
----------------------------------------------------------------------------
procedure Small_Whetstone(Kilo_Whets : in Positive) is
T : constant := 0.499975; -- Values from the original Algol
T1 : constant := 0.50025; -- Whetstone program and the
T2 : constant := 2.0; -- Pascal SmallWhetstone program
N8 : constant := 10; -- Loop iteration count for module 8
N9 : constant := 7; -- Loop iteration count for module 9
Value : constant := 0.941377; -- Value calculated in main loop
Tolerance : constant := 0.00001; -- Determined by interval arithmetic
I : Integer;
IJ : Integer := 1;
IK : Integer := 2;
IL : Integer := 3;
Y : Whet_Float := 1.0; -- Constant within loop
Z : Whet_Float;
Sum : Whet_Float := 0.0; -- Accumulates value of Z
subtype Index is Integer range 1..N9; -- Was a type in the Pascal version
E1 : array (Index) of Whet_Float;
procedure Clear_Array is
begin
for Loop_Var in E1'Range loop
E1(Loop_Var) := 0.0;
end loop;
end Clear_Array;
procedure P0 is
begin
E1(IJ) := E1(IK);
E1(IK) := E1(IL);
E1(I) := E1(IJ);
end P0;
procedure P3(X : in Whet_Float;
Y : in Whet_Float;
Z : in out Whet_Float) is
Xtemp: Whet_Float := T * (Z + X);
Ytemp: Whet_Float := T * (Xtemp + Y);
begin
Z := (Xtemp + Ytemp) / T2;
end P3;
begin -- Small_Whetstone
for Outer_Loop_Var in 1..Kilo_Whets loop
Clear_Array;
-- Module 6: Integer arithmetic
IJ := (IK - IJ) * (IL - IK);
IK := IL - (IK - IJ);
IL := (IL - IK) * (IK + IL);
E1(IL - 1) := Whet_Float(IJ + IK + IL);
E1(IK - 1) := Sin( Whet_Float(IL) );
-- Module 8: Procedure calls
Z := E1(4);
for Inner_Loop_Var in 1..N8 loop
P3( Y * Whet_Float(Inner_Loop_Var), Y + Z, Z );
end loop;
-- Second version of Module 6:
IJ := IL - (IL - 3) * IK;
IL := (IL - IK) * (IK - IJ);
IK := (IL - IK) * IK;
E1(IL - 1) := Whet_Float(IJ + IK + IL);
E1(IK + 1) := Abs( Cos(Z) );
-- Module 9: Array references
-- Note: In the Pascal version, the global variable I is used as both
-- the control variable of the for loop and an array index
-- within procedure P0. Because the for-loop control variable
-- of Ada is strictly local, this translation uses a while loop.
I := 1;
while I <= N9 loop
P0;
I := I + 1;
end loop;
-- Module 11: Standard mathematical functions
-- Note: The actual name of the natural logarithm function used here
-- is implementation-dependent. See the comments above.
Z := Sqrt( Exp( Log(E1(N9)) / T1 ) );
Sum := Sum + Z;
-- Check the current value of the loop computation
if Abs(Z - Value) > Tolerance then
Sum := 2.0 * Sum; -- Forces error at end
IJ := IJ + 1; -- Prevents optimization
end if;
end loop;
-- Self-validation check
if Abs( Sum / Whet_Float(Kilo_Whets) - Value ) >
Tolerance * Whet_Float(Kilo_Whets) then
raise Workload_Failure;
end if;
end Small_Whetstone;
end Workload;
|
--
-- Copyright (C) 2006-2013, AdaCore
--
with Ada.Unchecked_Conversion;
package body Memory_Copy is
subtype mem is char_array (size_t);
type memptr is access all mem;
function to_memptr is new Ada.Unchecked_Conversion (Address, memptr);
------------
-- memcpy --
------------
procedure memcpy (Dest : Address; Src : Address; N : size_t) is
dest_p : constant memptr := to_memptr (Dest);
src_p : constant memptr := to_memptr (Src);
begin
if N > 0 then
for J in 0 .. N - 1 loop
dest_p (J) := src_p (J);
end loop;
end if;
end memcpy;
end Memory_Copy;
|
with
GL_Types,
Interfaces.C;
package GL
--
-- Provides types and constants common to all openGL profiles.
--
is
pragma Pure;
use Interfaces;
---------
-- Types
--
-- GLvoid
--
subtype GLvoid is GL_Types.GLvoid;
type GLvoid_array is array (C.size_t range <>) of aliased GLvoid;
-- GLenum
--
subtype GLenum is GL_Types.GLenum;
type GLenum_array is array (C.size_t range <>) of aliased GLenum;
-- GLboolean
--
subtype GLboolean is GL_Types.GLboolean;
type GLboolean_array is array (C.size_t range <>) of aliased GLboolean;
-- GLbitfield
--
subtype GLbitfield is GL_Types.GLbitfield;
type GLbitfield_array is array (C.size_t range <>) of aliased GLbitfield;
-- GLshort
--
subtype GLshort is GL_Types.GLshort;
type GLshort_array is array (C.size_t range <>) of aliased GLshort;
-- GLint
--
subtype GLint is GL_Types.GLint;
type GLint_array is array (C.size_t range <>) of aliased GLint;
-- GLsizei
--
subtype GLsizei is GL_Types.GLsizei;
type GLsizei_array is array (C.size_t range <>) of aliased GLsizei;
-- GLushort
--
subtype GLushort is GL_Types.GLushort;
type GLushort_array is array (C.size_t range <>) of aliased GLushort;
-- GLuint
--
subtype GLuint is GL_Types.GLuint;
type GLuint_array is array (C.size_t range <>) of aliased GLuint;
-- GLbyte
--
subtype GLbyte is GL_Types.GLbyte;
type GLbyte_array is array (C.size_t range <>) of aliased GLbyte;
-- GLubyte
--
subtype GLubyte is GL_Types.GLubyte;
type GLubyte_array is array (C.size_t range <>) of aliased GLubyte;
-- GLfloat
--
subtype GLfloat is GL_Types.GLfloat;
type GLfloat_array is array (C.size_t range <>) of aliased GLfloat;
-- GLclampf
--
subtype GLclampf is GL_Types.GLclampf;
type GLclampf_array is array (C.size_t range <>) of aliased GLclampf;
-------------
-- Constants
--
-- ClearBufferMask
GL_DEPTH_BUFFER_BIT : constant := 16#100#;
GL_STENCIL_BUFFER_BIT : constant := 16#400#;
GL_COLOR_BUFFER_BIT : constant := 16#4000#;
-- Boolean
GL_FALSE : constant := 0;
GL_TRUE : constant := 1;
-- BeginMode
GL_POINTS : constant := 16#0#;
GL_LINES : constant := 16#1#;
GL_LINE_LOOP : constant := 16#2#;
GL_LINE_STRIP : constant := 16#3#;
GL_TRIANGLES : constant := 16#4#;
GL_TRIANGLE_STRIP : constant := 16#5#;
GL_TRIANGLE_FAN : constant := 16#6#;
-- BlendingFactorDest
GL_ZERO : constant := 0;
GL_ONE : constant := 1;
GL_ONE_MINUS_SRC_ALPHA : constant := 16#303#;
-- BlendingFactorSrc
GL_SRC_ALPHA : constant := 16#302#;
GL_SRC_ALPHA_SATURATE : constant := 16#308#;
-- CullFaceMode
GL_FRONT : constant := 16#404#;
GL_BACK : constant := 16#405#;
GL_FRONT_AND_BACK : constant := 16#408#;
-- EnableCap
GL_TEXTURE_2D : constant := 16#de1#;
GL_CULL_FACE : constant := 16#b44#;
GL_BLEND : constant := 16#be2#;
GL_STENCIL_TEST : constant := 16#b90#;
GL_DEPTH_TEST : constant := 16#b71#;
GL_SCISSOR_TEST : constant := 16#c11#;
GL_POLYGON_OFFSET_FILL : constant := 16#8037#;
-- ErrorCode
GL_NO_ERROR : constant := 0;
GL_INVALID_ENUM : constant := 16#500#;
GL_INVALID_VALUE : constant := 16#501#;
GL_INVALID_OPERATION : constant := 16#502#;
GL_OUT_OF_MEMORY : constant := 16#505#;
-- FrontFaceDirection
GL_CW : constant := 16#900#;
GL_CCW : constant := 16#901#;
-- TODO: As above, categorise and add category comment for the following ...
--
GL_LINE_WIDTH : constant := 16#b21#;
GL_ALIASED_POINT_SIZE_RANGE : constant := 16#846d#;
GL_ALIASED_LINE_WIDTH_RANGE : constant := 16#846e#;
GL_CULL_FACE_MODE : constant := 16#b45#;
GL_FRONT_FACE : constant := 16#b46#;
GL_DEPTH_RANGE : constant := 16#b70#;
GL_DEPTH_WRITEMASK : constant := 16#b72#;
GL_DEPTH_CLEAR_VALUE : constant := 16#b73#;
GL_DEPTH_FUNC : constant := 16#b74#;
GL_STENCIL_CLEAR_VALUE : constant := 16#b91#;
GL_STENCIL_FUNC : constant := 16#b92#;
GL_STENCIL_FAIL : constant := 16#b94#;
GL_STENCIL_PASS_DEPTH_FAIL : constant := 16#b95#;
GL_STENCIL_PASS_DEPTH_PASS : constant := 16#b96#;
GL_STENCIL_REF : constant := 16#b97#;
GL_STENCIL_VALUE_MASK : constant := 16#b93#;
GL_STENCIL_WRITEMASK : constant := 16#b98#;
GL_VIEWPORT : constant := 16#ba2#;
GL_SCISSOR_BOX : constant := 16#c10#;
GL_COLOR_CLEAR_VALUE : constant := 16#c22#;
GL_COLOR_WRITEMASK : constant := 16#c23#;
GL_UNPACK_ALIGNMENT : constant := 16#cf5#;
GL_PACK_ALIGNMENT : constant := 16#d05#;
GL_MAX_TEXTURE_SIZE : constant := 16#d33#;
GL_MAX_VIEWPORT_DIMS : constant := 16#d3a#;
GL_SUBPIXEL_BITS : constant := 16#d50#;
GL_RED_BITS : constant := 16#d52#;
GL_GREEN_BITS : constant := 16#d53#;
GL_BLUE_BITS : constant := 16#d54#;
GL_ALPHA_BITS : constant := 16#d55#;
GL_DEPTH_BITS : constant := 16#d56#;
GL_STENCIL_BITS : constant := 16#d57#;
GL_POLYGON_OFFSET_UNITS : constant := 16#2a00#;
GL_POLYGON_OFFSET_FACTOR : constant := 16#8038#;
GL_TEXTURE_BINDING_2D : constant := 16#8069#;
GL_DONT_CARE : constant := 16#1100#;
GL_FASTEST : constant := 16#1101#;
GL_NICEST : constant := 16#1102#;
GL_BYTE : constant := 16#1400#;
GL_UNSIGNED_BYTE : constant := 16#1401#;
GL_INT : constant := 16#1404#;
GL_UNSIGNED_INT : constant := 16#1405#;
GL_FLOAT : constant := 16#1406#;
GL_ALPHA : constant := 16#1906#;
GL_RGB : constant := 16#1907#;
GL_RGBA : constant := 16#1908#;
GL_LUMINANCE : constant := 16#1909#;
GL_LUMINANCE_ALPHA : constant := 16#190a#;
GL_NEVER : constant := 16#200#;
GL_LESS : constant := 16#201#;
GL_EQUAL : constant := 16#202#;
GL_LEQUAL : constant := 16#203#;
GL_GREATER : constant := 16#204#;
GL_NOTEQUAL : constant := 16#205#;
GL_GEQUAL : constant := 16#206#;
GL_ALWAYS : constant := 16#207#;
GL_KEEP : constant := 16#1e00#;
GL_REPLACE : constant := 16#1e01#;
GL_INCR : constant := 16#1e02#;
GL_DECR : constant := 16#1e03#;
GL_INVERT : constant := 16#150a#;
GL_VENDOR : constant := 16#1f00#;
GL_RENDERER : constant := 16#1f01#;
GL_VERSION : constant := 16#1f02#;
GL_EXTENSIONS : constant := 16#1f03#;
GL_MAJOR_VERSION : constant := 16#821B#;
GL_MINOR_VERSION : constant := 16#821C#;
GL_NEAREST : constant := 16#2600#;
GL_LINEAR : constant := 16#2601#;
GL_NEAREST_MIPMAP_NEAREST : constant := 16#2700#;
GL_LINEAR_MIPMAP_NEAREST : constant := 16#2701#;
GL_NEAREST_MIPMAP_LINEAR : constant := 16#2702#;
GL_LINEAR_MIPMAP_LINEAR : constant := 16#2703#;
GL_TEXTURE_MAG_FILTER : constant := 16#2800#;
GL_TEXTURE_MIN_FILTER : constant := 16#2801#;
GL_TEXTURE_WRAP_S : constant := 16#2802#;
GL_TEXTURE_WRAP_T : constant := 16#2803#;
GL_TEXTURE0 : constant := 16#84c0#;
GL_TEXTURE1 : constant := 16#84c1#;
GL_TEXTURE2 : constant := 16#84c2#;
GL_TEXTURE3 : constant := 16#84c3#;
GL_TEXTURE4 : constant := 16#84c4#;
GL_TEXTURE5 : constant := 16#84c5#;
GL_TEXTURE6 : constant := 16#84c6#;
GL_TEXTURE7 : constant := 16#84c7#;
GL_TEXTURE8 : constant := 16#84c8#;
GL_TEXTURE9 : constant := 16#84c9#;
GL_TEXTURE10 : constant := 16#84ca#;
GL_TEXTURE11 : constant := 16#84cb#;
GL_TEXTURE12 : constant := 16#84cc#;
GL_TEXTURE13 : constant := 16#84cd#;
GL_TEXTURE14 : constant := 16#84ce#;
GL_TEXTURE15 : constant := 16#84cf#;
GL_TEXTURE16 : constant := 16#84d0#;
GL_TEXTURE17 : constant := 16#84d1#;
GL_TEXTURE18 : constant := 16#84d2#;
GL_TEXTURE19 : constant := 16#84d3#;
GL_TEXTURE20 : constant := 16#84d4#;
GL_TEXTURE21 : constant := 16#84d5#;
GL_TEXTURE22 : constant := 16#84d6#;
GL_TEXTURE23 : constant := 16#84d7#;
GL_TEXTURE24 : constant := 16#84d8#;
GL_TEXTURE25 : constant := 16#84d9#;
GL_TEXTURE26 : constant := 16#84da#;
GL_TEXTURE27 : constant := 16#84db#;
GL_TEXTURE28 : constant := 16#84dc#;
GL_TEXTURE29 : constant := 16#84dd#;
GL_TEXTURE30 : constant := 16#84de#;
GL_TEXTURE31 : constant := 16#84df#;
GL_ACTIVE_TEXTURE : constant := 16#84e0#;
GL_REPEAT : constant := 16#2901#;
GL_CLAMP_TO_EDGE : constant := 16#812f#;
end GL;
|
-----------------------------------------------------------------------
-- security-oauth-file_registry -- File Based Application and Realm
-- Copyright (C) 2017, 2018 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Ada.Strings.Hash;
with Ada.Containers.Indefinite_Hashed_Maps;
with Util.Strings;
with Util.Properties;
with Security.OAuth.Servers;
with Security.Permissions;
private with Util.Strings.Maps;
private with Security.Random;
package Security.OAuth.File_Registry is
type File_Principal is new Servers.Principal with private;
type File_Principal_Access is access all File_Principal'Class;
-- Get the principal name.
overriding
function Get_Name (From : in File_Principal) return String;
-- Check if the permission was granted.
overriding
function Has_Permission (Auth : in File_Principal;
Permission : in Security.Permissions.Permission_Index)
return Boolean;
type File_Application_Manager is new Servers.Application_Manager with private;
-- Find the application that correspond to the given client id.
-- The <tt>Invalid_Application</tt> exception should be raised if there is no such application.
overriding
function Find_Application (Realm : in File_Application_Manager;
Client_Id : in String) return Servers.Application'Class;
-- Add the application to the application repository.
procedure Add_Application (Realm : in out File_Application_Manager;
App : in Servers.Application);
-- Load from the properties the definition of applications. The list of applications
-- is controled by the property <prefix>.list which contains a comma separated list of
-- application names or ids. The application definition are represented by properties
-- of the form:
-- <prefix>.<app>.client_id
-- <prefix>.<app>.client_secret
-- <prefix>.<app>.callback_url
procedure Load (Realm : in out File_Application_Manager;
Props : in Util.Properties.Manager'Class;
Prefix : in String);
procedure Load (Realm : in out File_Application_Manager;
Path : in String;
Prefix : in String);
type File_Realm_Manager is limited new Servers.Realm_Manager with private;
-- Authenticate the token and find the associated authentication principal.
-- The access token has been verified and the token represents the identifier
-- of the Tuple (client_id, user, session) that describes the authentication.
-- The <tt>Authenticate</tt> procedure should look in its database (internal
-- or external) to find the authentication principal that was granted for
-- the token Tuple. When the token was not found (because it was revoked),
-- the procedure should return a null principal. If the authentication
-- principal can be cached, the <tt>Cacheable</tt> value should be set.
-- In that case, the access token and authentication principal are inserted
-- in a cache.
overriding
procedure Authenticate (Realm : in out File_Realm_Manager;
Token : in String;
Auth : out Servers.Principal_Access;
Cacheable : out Boolean);
-- Create an auth token string that identifies the given principal. The returned
-- token will be used by <tt>Authenticate</tt> to retrieve back the principal. The
-- returned token does not need to be signed. It will be inserted in the public part
-- of the returned access token.
overriding
function Authorize (Realm : in File_Realm_Manager;
App : in Servers.Application'Class;
Scope : in String;
Auth : in Servers.Principal_Access) return String;
overriding
procedure Verify (Realm : in out File_Realm_Manager;
Username : in String;
Password : in String;
Auth : out Servers.Principal_Access);
overriding
procedure Verify (Realm : in out File_Realm_Manager;
Token : in String;
Auth : out Servers.Principal_Access);
overriding
procedure Revoke (Realm : in out File_Realm_Manager;
Auth : in Servers.Principal_Access);
-- Crypt the password using the given salt and return the string composed with
-- the salt in clear text and the crypted password.
function Crypt_Password (Realm : in File_Realm_Manager;
Salt : in String;
Password : in String) return String;
-- Load from the properties the definition of users. The list of users
-- is controled by the property <prefix>.list which contains a comma separated list of
-- users names or ids. The user definition are represented by properties
-- of the form:
-- <prefix>.<user>.username
-- <prefix>.<user>.password
-- <prefix>.<user>.salt
-- When a 'salt' property is defined, it is assumed that the password is encrypted using
-- the salt and SHA1 and base64url. Otherwise, the password is in clear text.
procedure Load (Realm : in out File_Realm_Manager;
Props : in Util.Properties.Manager'Class;
Prefix : in String);
procedure Load (Realm : in out File_Realm_Manager;
Path : in String;
Prefix : in String);
-- Add a username with the associated password.
procedure Add_User (Realm : in out File_Realm_Manager;
Username : in String;
Password : in String);
private
use Ada.Strings.Unbounded;
package Application_Maps is
new Ada.Containers.Indefinite_Hashed_Maps (Key_Type => String,
Element_Type => Servers.Application,
Hash => Ada.Strings.Hash,
Equivalent_Keys => "=",
"=" => Servers."=");
package Token_Maps is
new Ada.Containers.Indefinite_Hashed_Maps (Key_Type => String,
Element_Type => File_Principal_Access,
Hash => Ada.Strings.Hash,
Equivalent_Keys => "=",
"=" => "=");
package User_Maps renames Util.Strings.Maps;
type File_Principal is new Servers.Principal with record
Token : Ada.Strings.Unbounded.Unbounded_String;
Name : Ada.Strings.Unbounded.Unbounded_String;
Perms : Security.Permissions.Permission_Index_Set := Security.Permissions.EMPTY_SET;
end record;
type File_Application_Manager is new Servers.Application_Manager with record
Applications : Application_Maps.Map;
end record;
type File_Realm_Manager is limited new Servers.Realm_Manager with record
Users : User_Maps.Map;
Tokens : Token_Maps.Map;
Random : Security.Random.Generator;
Token_Bits : Positive := 256;
end record;
end Security.OAuth.File_Registry;
|
--===========================================================================
--
-- This package is the interface to the SH1107 transfomer
-- The transformer transforms the logical coordinates in the given
-- orientation the corresponding indices and bits.
--
--===========================================================================
--
-- Copyright 2022 (C) Holger Rodriguez
--
-- SPDX-License-Identifier: BSD-3-Clause
--
private package SH1107.Transformer is
--------------------------------------------------------------------------
-- Calculates the byte index into the memory area,
-- which corresponds to the logical
-- Orientation and X, Y coordinates
function Get_Byte_Index (O : SH1107_Orientation;
X, Y : Natural) return Natural;
--------------------------------------------------------------------------
-- Calculates the bit mask to use
-- which corresponds to the logical
-- Orientation and X, Y coordinates
function Get_Bit_Mask (O : SH1107_Orientation;
X, Y : Natural) return HAL.UInt8;
end SH1107.Transformer;
|
with tracker.presentation;
procedure tracker.exec is
app : tracker.presentation.instance;
begin
app.Run;
end tracker.exec;
|
-- Suppose an arithmetic expression is given as a binary tree. Each leaf is an integer and each internal node is
-- one of '+', '−', '∗', or '/'.
--
-- Given the root to such a tree, write a function to evaluate it.
--
-- For example, given the following tree:
--
-- *
-- / \
-- + +
-- / \ / \
-- 3 2 4 5
--
-- You should return 45, as it is (3 + 2) * (4 + 5).
package Parser is
type Node_Types is (Empty, Literal, Plus, Minus, Multiply, Divide);
type Node (Node_Type : Node_Types) is private;
type Node_Ptr is access Node;
Null_Node : constant Node;
-- Root is the root of the current sub-tree.
function Evaluate (Root : in Node_Ptr) return Integer;
private
type Node (Node_Type : Node_Types) is record
case Node_Type is
when Empty =>
null;
when Literal => -- Leaf of the tree.
Value : Integer;
when others =>
Left : Node_Ptr;
Right : Node_Ptr;
end case;
end record;
Null_Node : constant Node := (Node_Type => Empty, others => null);
end Parser;
|
-----------------------------------------------------------------------
-- package body e_Jacobi_Eigen, extended precision Jacobi eigen-decomposition
-- Copyright (C) 2008-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 e_Jacobi_Eigen is
Reciprocal_Epsilon : constant Real := One / e_Real_Model_Epsilon;
---------------------------------
-- Get_Jacobi_Rotation_Factors --
---------------------------------
-- all underflows are OK here.
-- no overflows are OK here.
-- so we test for Q / P overflows by calculating P / Q
procedure Get_Jacobi_Rotation_Factors
(P, Q : in Real;
s : out Real;
tau : out Real;
Delta_D : out Real)
is
t, Gamma : Real;
-- function "/" (x, y : Real) return Real renames Divide;
-- faster than stnd "/", but scarcely matters.
begin
s := Zero;
tau := Zero;
Delta_D := Zero;
if Abs (Q) > e_Real_Safe_Min and then
Abs (P) > e_Real_Safe_Min and then
Abs (Q) < e_Real_Safe_Max and then
Abs (P) < e_Real_Safe_Max then
-- Following Gamma is usually the more accurate.
Gamma := P / (Abs (Q) + Sqrt (P*P + Q*Q));
if Q < Zero then Gamma := -Gamma; end if;
-- usual case overwhelmingly. If you scale matrix to unit Norm,
-- then no overflows because Matrix norm is preserved, preventing
-- large P, Q if they are not large to begin with. (So the above
-- tests for < e_Real_Safe_Max would be unnecessary.)
-- (Requires scaling of matrix prior to decomposition to be
-- absolutely sure.)
-- Should be able to do the following w/o any tests of p,q if don't care
-- about quality of answer in P < e_Safe_Small, Q < e_Safe_Small limit.
--
--Gamma := P / (Abs(Q) + Sqrt (P*P + Q*Q) + e_Safe_Small);
--if Q < Zero then Gamma := -Gamma; end if;
elsif Abs (Q) > Abs (P) then
-- Abs (P) > 0 was a tested before arrival, which implies Abs (Q) > 0.
t := P / Q;
Gamma := t / (One + Sqrt (One + t*t));
-- Underflow OK; overflow not allowed.
elsif Abs (P) >= Abs (Q) then
t := Q / P;
Gamma := One / (Abs (t) + Sqrt (One + t*t));
-- Underflow OK; overflow not allowed.
if t < Zero then Gamma := -Gamma; end if;
else
return; -- must have hit some inf's. Use stnd rotation init'd above.
end if;
declare
c : Real;
begin
c := Reciprocal_Sqrt (One + Gamma*Gamma); -- Cosine (ok)
--c := Sqrt (One / (One + Gamma*Gamma)); -- Cosine
s := c * Gamma; -- Sine
tau := s / (One + c); -- -cos_minus_1_over_sin
Delta_D := P * Gamma;
end;
end Get_Jacobi_Rotation_Factors;
---------------------
-- Eigen_Decompose --
---------------------
procedure Eigen_Decompose
(A : in out Matrix;
Q_tr : out Matrix;
Eigenvals : out Col_Vector;
No_of_Sweeps_Performed : out Natural;
Total_No_of_Rotations : out Natural;
Start_Col : in Index := Index'First;
Final_Col : in Index := Index'Last;
Eigenvectors_Desired : in Boolean := False)
is
D : Col_Vector renames Eigenvals;
Z, B : Col_Vector;
Max_Allowed_No_of_Sweeps : constant Positive := 256; -- badly scaled need lots
No_of_Preliminary_Sweeps : constant Positive := 14;
--Reciprocal_Epsilon : constant Real := One / e_Real_Model_Epsilon;
-- Good stnd setting for the effective eps is: Real'Epsilon * Two**(-2).
-- Usually, Real'Epsilon := 2.0**(-50) for 15 digit Reals.
Matrix_Size : constant Real_8 := Real_8(Final_Col) - Real_8(Start_Col) + 1.0;
No_of_Off_Diag_Elements : constant Real_8 := 0.5*Matrix_Size*(Matrix_Size-1.0);
Mean_Off_Diagonal_Element_Size : Real;
s, g, h, tau : Real; -- Rutishauser variable names.
Q, Delta_D : Real;
Sum, Pivot, Threshold : Real;
begin
-- Initialize all out parameters. D renames Eigenvals.
-- Q_tr starts as Identity; is rotated into set of Eigenvectors of A.
Q_tr := (others => (others => Zero));
for j in Index loop
Q_tr(j,j) := One;
end loop;
Z := (others => Zero);
B := (others => Zero);
D := (others => Zero);
for j in Start_Col .. Final_Col loop -- assume A not all init
D(j) := A(j,j);
B(j) := A(j,j);
end loop;
No_of_Sweeps_Performed := 0;
Total_No_of_Rotations := 0;
if Matrix_Size <= 1.0 then return; end if; -- right answer for Size=1.
Sweep: for Sweep_id in 1 .. Max_Allowed_No_of_Sweeps loop
Sum := Zero;
for N in Start_Col .. Final_Col-1 loop --sum off-diagonal elements
for I in N+1 .. Final_Col loop
Sum := Sum + Abs (A(N,I));
end loop;
end loop;
Mean_Off_Diagonal_Element_Size := Sum / (+No_of_Off_Diag_Elements);
exit Sweep when Mean_Off_Diagonal_Element_Size < Min_Allowed_Real;
if Sweep_id > No_of_Preliminary_Sweeps then
Threshold := Zero;
else
Threshold := One * Mean_Off_Diagonal_Element_Size;
end if;
for N in Start_Col .. Final_Col-1 loop
for I in N+1 .. Final_Col loop
Pivot := A(N,I);
-- Have to zero out sufficiently small A(I,N) to get convergence,
-- ie, to get Off_Diag_Sum -> 0.0.
-- After 4 sweeps all A(I,N) are small so that
-- A(I,N) / Epsilon will never overflow. The test is
-- A(I,N) / Epsilon <= Abs D(I) and A(I,N) / Epsilon <= Abs D(N).
if
(Sweep_id > No_of_Preliminary_Sweeps) and then
(Reciprocal_Epsilon * Abs (Pivot) <= Abs D(N)) and then
(Reciprocal_Epsilon * Abs (Pivot) <= Abs D(I))
then
A(N,I) := Zero;
elsif Abs (Pivot) > Threshold then
Q := Half * (D(I) - D(N));
Get_Jacobi_Rotation_Factors (Pivot, Q, s, tau, Delta_D);
-- Pivot=A(N,I)
D(N) := D(N) - Delta_D; -- Locally D is only used for threshold test.
D(I) := D(I) + Delta_D;
Z(N) := Z(N) - Delta_D; -- Z is reinitialized to 0 each sweep, so Z
Z(I) := Z(I) + Delta_D; -- sums the small d's 1st. Helps a tad.
A(N,I) := Zero;
for j in Start_Col .. N-1 loop
g := A(j,N);
h := A(j,I);
A(j,N) := g-s*(h+g*tau);
A(j,I) := h+s*(g-h*tau);
end loop;
for j in N+1 .. I-1 loop
g := A(N,j);
h := A(j,I);
A(N,j) := g-s*(h+g*tau);
A(j,I) := h+s*(g-h*tau);
end loop;
for j in I+1 .. Final_Col loop
g := A(N,j);
h := A(I,j);
A(N,j) := g-s*(h+g*tau);
A(I,j) := h+s*(g-h*tau);
end loop;
if Eigenvectors_Desired then
for j in Start_Col .. Final_Col loop
g := Q_tr(N,j);
h := Q_tr(I,j);
Q_tr(N,j) := g-s*(h+g*tau);
Q_tr(I,j) := h+s*(g-h*tau);
end loop;
end if;
Total_No_of_Rotations := Total_No_of_Rotations + 1;
end if; -- if (Sweep_id > No_of_Preliminary_Sweeps)
end loop; --I loop (Col)
end loop; --N loop (Row)
for j in Start_Col .. Final_Col loop -- assume A not all initialized
B(j) := B(j) + Z(j);
D(j) := B(j);
Z(j) := Zero;
end loop;
end loop Sweep; --Sweep_id loop
end Eigen_Decompose;
---------------
-- Sort_Eigs --
---------------
procedure Sort_Eigs
(Eigenvals : in out Col_Vector;
Q_tr : in out Matrix; -- rows are the eigvectors
Start_Col : in Index := Index'First;
Final_Col : in Index := Index'Last;
Sort_Eigvecs_Also : in Boolean := False)
is
Max_Eig, tmp : Real;
Max_id : Index;
begin
if Start_Col < Final_Col then
for i in Start_Col .. Final_Col-1 loop
Max_Eig := Eigenvals(i); Max_id := i;
for j in i+1 .. Final_Col loop
if Eigenvals(j) > Max_Eig then
Max_Eig := Eigenvals(j); Max_id := j;
end if;
end loop;
tmp := Eigenvals(i);
Eigenvals(i) := Max_Eig;
Eigenvals(Max_id) := tmp;
-- swap rows of Q_tr:
if Sort_Eigvecs_Also then
for k in Start_Col .. Final_Col loop
tmp := Q_tr(i,k);
Q_tr(i,k) := Q_tr(Max_id,k);
Q_tr(Max_id,k) := tmp;
end loop;
end if;
end loop;
end if;
end Sort_Eigs;
end e_Jacobi_Eigen;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.