content
stringlengths 23
1.05M
|
|---|
with Ada.Text_IO; use Ada.Text_IO;
with Sf.System.Thread; use Sf, Sf.System, Sf.System.Thread;
with Sf.System.Sleep; use Sf.System.Sleep;
with Thread_Func;
procedure Main is
Thread : sfThread_Ptr;
TFunc : sfThreadFunc_Ptr := Thread_Func'Access;
UData : String := "Hello";
begin
Thread := Create (TFunc, UData'Address);
Launch (Thread);
for I in 1 .. 10 loop
Put_Line ("I'm main thread");
sfDelay (0.001);
end loop;
Destroy (Thread);
end Main;
|
pragma Ada_2012;
package body Line_Arrays.Regexp_Classifiers is
---------
-- Add --
---------
procedure Add (To : in out Classifier_Type;
Regexp : String;
Callback : Callback_Type)
is
Matcher : constant Gnat.Regpat.Pattern_Matcher := Gnat.Regpat.Compile (Regexp);
begin
To.Exprs.Append (New_Item => Regexp_Descriptor'(Size => Matcher.Size,
Matcher => Matcher,
Callback => Callback));
end Add;
-----------------
-- Add_Default --
-----------------
procedure Add_Default
(To : in out Classifier_Type; Callback : Callback_Type)
is
begin
if To.Default /= null then
raise Double_Default;
end if;
To.Default := Callback;
end Add_Default;
------------
-- Create --
------------
function Create (Regexps : Regexp_Array) return Classifier_Type
is
Result : Classifier_Type;
begin
for R of Regexps loop
if Is_Default (R) then
Result.Add_Default (R.Callback);
else
Result.Add (Regexp => To_String (R.Regexp),
Callback => R.Callback);
end if;
end loop;
return Result;
end Create;
--------------
-- Classify --
--------------
function Classify
(Classifier : Classifier_Type; Line : String) return Classified_Line
is
use Gnat.Regpat;
begin
for Regexp of Classifier.Exprs loop
declare
Matched : Match_Array (0 .. Paren_Count (Regexp.Matcher));
begin
Gnat.Regpat.Match (Self => Regexp.Matcher,
Data => Line,
Matches => Matched);
if Matched (0) /= No_Match then
return Regexp.Callback (Line, Matched);
end if;
end;
end loop;
if Classifier.Default = null then
raise Constraint_Error;
else
declare
Matched : constant Match_Array (0 .. 0) :=
(0 => Match_Location'(First => Line'First,
Last => Line'Last));
begin
return Classifier.Default (Line, Matched);
end;
end if;
end Classify;
end Line_Arrays.Regexp_Classifiers;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- P A R . C H 8 --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2013, 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. --
-- --
------------------------------------------------------------------------------
pragma Style_Checks (All_Checks);
-- Turn off subprogram body ordering check. Subprograms are in order
-- by RM section rather than alphabetical
separate (Par)
package body Ch8 is
-----------------------
-- Local Subprograms --
-----------------------
function P_Use_Package_Clause return Node_Id;
function P_Use_Type_Clause return Node_Id;
---------------------
-- 8.4 Use Clause --
---------------------
-- USE_CLAUSE ::= USE_PACKAGE_CLAUSE | USE_TYPE_CLAUSE
-- The caller has checked that the initial token is USE
-- Error recovery: cannot raise Error_Resync
function P_Use_Clause return Node_Id is
begin
Scan; -- past USE
if Token = Tok_Type or else Token = Tok_All then
return P_Use_Type_Clause;
else
return P_Use_Package_Clause;
end if;
end P_Use_Clause;
-----------------------------
-- 8.4 Use Package Clause --
-----------------------------
-- USE_PACKAGE_CLAUSE ::= use package_NAME {, package_NAME};
-- The caller has scanned out the USE keyword
-- Error recovery: cannot raise Error_Resync
function P_Use_Package_Clause return Node_Id is
Use_Node : Node_Id;
begin
Use_Node := New_Node (N_Use_Package_Clause, Prev_Token_Ptr);
Set_Names (Use_Node, New_List);
if Token = Tok_Package then
Error_Msg_SC ("PACKAGE should not appear here");
Scan; -- past PACKAGE
end if;
loop
Append (P_Qualified_Simple_Name, Names (Use_Node));
exit when Token /= Tok_Comma;
Scan; -- past comma
end loop;
TF_Semicolon;
return Use_Node;
end P_Use_Package_Clause;
--------------------------
-- 8.4 Use Type Clause --
--------------------------
-- USE_TYPE_CLAUSE ::= use [ALL] type SUBTYPE_MARK {, SUBTYPE_MARK};
-- The caller has checked that the initial token is USE, scanned it out
-- and that the current token is either ALL or TYPE.
-- Note: Use of ALL is an Ada 2012 feature
-- Error recovery: cannot raise Error_Resync
function P_Use_Type_Clause return Node_Id is
Use_Node : Node_Id;
All_Present : Boolean;
Use_Sloc : constant Source_Ptr := Prev_Token_Ptr;
begin
if Token = Tok_All then
Error_Msg_Ada_2012_Feature ("|`USE ALL TYPE`", Token_Ptr);
All_Present := True;
Scan; -- past ALL
if Token /= Tok_Type then
Error_Msg_SC ("TYPE expected");
end if;
else pragma Assert (Token = Tok_Type);
All_Present := False;
end if;
Use_Node := New_Node (N_Use_Type_Clause, Use_Sloc);
Set_All_Present (Use_Node, All_Present);
Set_Subtype_Marks (Use_Node, New_List);
Set_Used_Operations (Use_Node, No_Elist);
if Ada_Version = Ada_83 then
Error_Msg_SC ("(Ada 83) use type not allowed!");
end if;
Scan; -- past TYPE
loop
Append (P_Subtype_Mark, Subtype_Marks (Use_Node));
No_Constraint;
exit when Token /= Tok_Comma;
Scan; -- past comma
end loop;
TF_Semicolon;
return Use_Node;
end P_Use_Type_Clause;
-------------------------------
-- 8.5 Renaming Declaration --
-------------------------------
-- Object renaming declarations and exception renaming declarations
-- are parsed by P_Identifier_Declaration (3.3.1)
-- Subprogram renaming declarations are parsed by P_Subprogram (6.1)
-- Package renaming declarations are parsed by P_Package (7.1)
-- Generic renaming declarations are parsed by P_Generic (12.1)
----------------------------------------
-- 8.5.1 Object Renaming Declaration --
----------------------------------------
-- Parsed by P_Identifier_Declarations (3.3.1)
----------------------------------------
-- 8.5.2 Exception Renaming Declaration --
----------------------------------------
-- Parsed by P_Identifier_Declarations (3.3.1)
-----------------------------------------
-- 8.5.3 Package Renaming Declaration --
-----------------------------------------
-- Parsed by P_Package (7.1)
--------------------------------------------
-- 8.5.4 Subprogram Renaming Declaration --
--------------------------------------------
-- Parsed by P_Subprogram (6.1)
-----------------------------------------
-- 8.5.2 Generic Renaming Declaration --
-----------------------------------------
-- Parsed by P_Generic (12.1)
end Ch8;
|
with Ada.Text_IO; use Ada.Text_IO;
with AVTAS.LMCP.Types; use AVTAS.LMCP.Types;
with AVTAS.LMCP.ByteBuffers; use AVTAS.LMCP.ByteBuffers;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
procedure Test_ByteBuffers is
Byte_Input : constant Byte := 42;
String_Input : constant String := "Hello World!";
UInt32_Input : constant UInt32 := 42;
Real32_Input : constant Real32 := 42.42;
Boolean_Input : constant Boolean := True;
UInt64_Input : constant UInt64 := 84;
Buffer : ByteBuffer (Capacity => 1024);
begin
-- NB: the order of the following must match the order of the calls to Get_*
Put_Line ("Putting Byte");
Buffer.Put_Byte (Byte_Input);
Put_Line ("Putting String");
Buffer.Put_String (String_Input);
Put_Line ("Putting UInt32");
Buffer.Put_UInt32 (UInt32_Input);
Put_Line ("Putting Unbounded_String");
Buffer.Put_Unbounded_String (To_Unbounded_String (String_Input));
Put_Line ("Putting Real32");
Buffer.Put_Real32 (Real32_Input);
Put_Line ("Putting Boolean");
Buffer.Put_Boolean (Boolean_Input);
Put_Line ("Putting UInt64");
Buffer.Put_UInt64 (UInt64_Input);
New_Line;
-- now we read back what was written
Buffer.Rewind;
-- NB: the order of the following must match the order of the calls to Put_*
Put_Line ("Getting Byte");
declare
Output : Byte;
begin
Buffer.Get_Byte (Output);
pragma Assert (Output = Byte_Input);
end;
Put_Line ("Getting String");
declare
Output : String (String_Input'Range);
Last : Natural;
begin
Buffer.Get_String (Output, Last);
pragma Assert (Last = String_Input'Length);
pragma Assert (Output (1 .. Last) = String_Input);
end;
Put_Line ("Getting UInt32");
declare
Output : UInt32;
begin
Buffer.Get_UInt32 (Output);
pragma Assert (Output = UInt32_Input);
end;
Put_Line ("Getting Unbounded_String");
declare
Output : Unbounded_String;
begin
Buffer.Get_Unbounded_String (Output);
pragma Assert (To_String (Output) = String_Input);
end;
Put_Line ("Getting Real32");
declare
Output : Real32;
begin
Buffer.Get_Real32 (Output);
pragma Assert (Output = Real32_Input);
end;
Put_Line ("Getting Boolean");
declare
Output : Boolean;
begin
Buffer.Get_Boolean (Output);
pragma Assert (Output = Boolean_Input);
end;
Put_Line ("Getting UInt64");
declare
Output : UInt64;
begin
Buffer.Get_UInt64 (Output);
pragma Assert (Output = UInt64_Input);
end;
New_Line;
Put_Line ("Testing completed");
end Test_ByteBuffers;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2022, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
--
-- From the Hitachi HD44780U data sheet:
--
-- The HD44780U has two 8-bit registers, an instruction register (IR)
-- and a data register (DR).
--
-- The IR stores instruction codes, such as display clear and cursor
-- shift, and address information for display data RAM (DDRAM) and
-- character generator RAM (CGRAM). The IR can only be written from
-- the MPU.
--
-- The DR temporarily stores data to be written into DDRAM or CGRAM
-- and temporarily stores data to be read from DDRAM or CGRAM. Data
-- written into the DR from the MPU is automatically written into
-- DDRAM or CGRAM by an internal operation. The DR is also used for
-- data storage when reading data from DDRAM or CGRAM. When address
-- information is written into the IR, data is read and then stored
-- into the DR from DDRAM or CGRAM by an internal operation. Data
-- transfer between the MPU is then completed when the MPU reads the
-- DR. After the read, data in DDRAM or CGRAM at the next address is
-- sent to the DR for the next read from the MPU. By the register
-- selector (RS) signal, these two registers can be selected
package body LCD_HD44780 is
----------------
-- Initialize --
----------------
procedure Initialize (This : in out LCD_Module) is
Dispatch : constant Any_LCD_Module := This'Unchecked_Access;
begin
Dispatch.Init_4bit_Mode;
-- now we can use the standard Command routine for set up
Dispatch.Command (Commands.Display_On); -- implies blink off and cursor off
This.Clear_Screen;
Dispatch.Command (Commands.Entry_Inc);
end Initialize;
---------
-- Put --
---------
-- output at the current cursor location
procedure Put (This : in out LCD_Module; C : Character) is
Dispatch : constant Any_LCD_Module := This'Unchecked_Access;
begin
Dispatch.Output (Character'Pos (C), Is_Data => True);
end Put;
-- output at the current cursor location
procedure Put (This : in out LCD_Module; Text : String) is
begin
for C of Text loop
This.Put (C);
end loop;
end Put;
-- output at the specified cursor location
procedure Put (This : in out LCD_Module;
X : Char_Position;
Y : Line_Position;
Text : String)
is
begin
This.Goto_XY (X, Y);
This.Put (Text);
end Put;
-------------
-- Command --
-------------
-- output the command code Cmd to the display
procedure Command (This : in out LCD_Module; Cmd : Command_Type) is
Dispatch : constant Any_LCD_Module := This'Unchecked_Access;
begin
Dispatch.Output (UInt8 (Cmd), Is_Data => False);
end Command;
------------------
-- Clear_Screen --
------------------
-- clear display and move cursor to home position
procedure Clear_Screen (This : in out LCD_Module) is
begin
This.Command (Commands.Clear);
This.Time.Delay_Microseconds (1_500);
end Clear_Screen;
----------
-- Home --
----------
-- move cursor to home position
procedure Home (This : in out LCD_Module) is
begin
This.Command (16#02#);
end Home;
-------------
-- Goto_XY --
-------------
-- move cursor into line Y and before character position X. Lines
-- are numbered 1 to 2 (or 1 to 4 on big displays). The left most
-- character position is Y = 1. The right most position is
-- defined by Lcd.Display.Width;
procedure Goto_XY (This : in out LCD_Module;
X : Char_Position;
Y : Line_Position)
is
begin
if X > This.Display_Width then return; end if;
if Y > This.Display_Height then return; end if;
case Y is
when 1 => Command (This, 16#80# + Command_Type (X) - 1);
when 2 => Command (This, 16#C0# + Command_Type (X) - 1);
when 3 => Command (This, 16#80# + Command_Type (X + This.Display_Width) - 1);
when 4 => Command (This, 16#C0# + Command_Type (X + This.Display_Width) - 1);
end case;
end Goto_XY;
-----------------------------
-- Create_Custom_Character --
-----------------------------
procedure Create_Custom_Character (This : in out LCD_Module;
Position : Custom_Character_Index;
Definition : Custom_Character_Definition)
is
Start_Address : constant := 16#40#;
Dispatch : constant Any_LCD_Module := This'Unchecked_Access;
begin
Dispatch.Output (UInt8 (Start_Address + 8 * Position), Is_Data => False);
for Line of Definition loop
Dispatch.Output (UInt8 (Line), Is_Data => True);
end loop;
end Create_Custom_Character;
-----------------
-- Custom_Char --
-----------------
function Custom_Char (From_Index : Custom_Character_Index) return Character
is
begin
return Character'Val (From_Index);
end Custom_Char;
end LCD_HD44780;
|
--------------------------------------------------------------------------------------------------------------------
-- Copyright (c) 2013-2020, Luke A. Guest
--
-- This software is provided 'as-is', without any express or implied
-- warranty. In no event will the authors be held liable for any damages
-- arising from the use of this software.
--
-- Permission is granted to anyone to use this software for any purpose,
-- including commercial applications, and to alter it and redistribute it
-- freely, subject to the following restrictions:
--
-- 1. The origin of this software must not be misrepresented; you must not
-- claim that you wrote the original software. If you use this software
-- in a product, an acknowledgment in the product documentation would be
-- appreciated but is not required.
--
-- 2. Altered source versions must be plainly marked as such, and must not be
-- misrepresented as being the original software.
--
-- 3. This notice may not be removed or altered from any source
-- distribution.
--------------------------------------------------------------------------------------------------------------------
with Ada.Text_IO; use Ada.Text_IO;
package body Utils is
procedure Comment_Dash (Total : in Positive; Indent : in Natural := 0; New_Line : Boolean := True) is
begin
if Indent > 0 then
for Index in 1 .. Indent loop
Put (' ');
end loop;
end if;
for Index in 1 .. Total loop
Put ('-');
end loop;
if New_Line then
Ada.Text_IO.New_Line;
end if;
end Comment_Dash;
procedure Comment (Indent : in Natural; Text : in String; New_Line : in Boolean := True) is
begin
if Indent > 0 then
for Index in 1 .. Indent loop
Put (' ');
end loop;
end if;
if Text = "" then
Put ("--");
else
Put ("-- " & Text);
end if;
if New_Line then
Ada.Text_IO.New_Line;
end if;
end Comment;
procedure Output_Field (Text : in String;
Width : in Integer;
Indent : in Natural;
Separator : in String := " ";
Truncate : in Boolean := False) is
Field_Index : Positive_Count := Col;
begin
if Indent > 0 then
for Index in 1 .. Indent loop
Put (' ');
end loop;
end if;
if Text'Length + Indent > Width and Truncate then
Put (Text (Text'First .. Width) & Separator);
else
Put (Text & Separator);
end if;
Set_Col (Field_Index + Positive_Count (Width + Indent));
end Output_Field;
end Utils;
|
------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- ncurses --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 2000-2011,2018 Free Software Foundation, Inc. --
-- --
-- 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, distribute with modifications, 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 ABOVE 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. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
-- Version Control
-- $Revision: 1.10 $
-- $Date: 2018/07/07 23:30:32 $
-- Binding Version 01.00
------------------------------------------------------------------------------
with ncurses2.util; use ncurses2.util;
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
with Ada.Strings.Unbounded;
with Interfaces.C;
with Terminal_Interface.Curses.Aux;
procedure ncurses2.slk_test is
procedure myGet (Win : Window := Standard_Window;
Str : out Ada.Strings.Unbounded.Unbounded_String;
Len : Integer := -1);
procedure myGet (Win : Window := Standard_Window;
Str : out Ada.Strings.Unbounded.Unbounded_String;
Len : Integer := -1)
is
use Ada.Strings.Unbounded;
use Interfaces.C;
use Terminal_Interface.Curses.Aux;
function Wgetnstr (Win : Window;
Str : char_array;
Len : int) return int;
pragma Import (C, Wgetnstr, "wgetnstr");
-- FIXME: how to construct "(Len > 0) ? Len : 80"?
Ask : constant Interfaces.C.size_t := Interfaces.C.size_t'Val (Len + 80);
Txt : char_array (0 .. Ask);
begin
Txt (0) := Interfaces.C.char'First;
if Wgetnstr (Win, Txt, Txt'Length) = Curses_Err then
raise Curses_Exception;
end if;
Str := To_Unbounded_String (To_Ada (Txt, True));
end myGet;
use Ada.Strings.Unbounded;
c : Key_Code;
buf : Unbounded_String;
c2 : Character;
fmt : Label_Justification := Centered;
tmp : Integer;
begin
c := CTRL ('l');
loop
Move_Cursor (Line => 0, Column => 0);
c2 := Code_To_Char (c);
case c2 is
when Character'Val (Character'Pos ('l') mod 16#20#) => -- CTRL('l')
Erase;
Switch_Character_Attribute (Attr => (Bold_Character => True,
others => False));
Add (Line => 0, Column => 20,
Str => "Soft Key Exerciser");
Switch_Character_Attribute (On => False,
Attr => (Bold_Character => True,
others => False));
Move_Cursor (Line => 2, Column => 0);
P ("Available commands are:");
P ("");
P ("^L -- refresh screen");
P ("a -- activate or restore soft keys");
P ("d -- disable soft keys");
P ("c -- set centered format for labels");
P ("l -- set left-justified format for labels");
P ("r -- set right-justified format for labels");
P ("[12345678] -- set label; labels are numbered 1 through 8");
P ("e -- erase stdscr (should not erase labels)");
P ("s -- test scrolling of shortened screen");
P ("x, q -- return to main menu");
P ("");
P ("Note: if activating the soft keys causes your terminal to");
P ("scroll up one line, your terminal auto-scrolls when anything");
P ("is written to the last screen position. The ncurses code");
P ("does not yet handle this gracefully.");
Refresh;
Restore_Soft_Label_Keys;
when 'a' =>
Restore_Soft_Label_Keys;
when 'e' =>
Clear;
when 's' =>
Add (Line => 20, Column => 0,
Str => "Press Q to stop the scrolling-test: ");
loop
c := Getchar;
c2 := Code_To_Char (c);
exit when c2 = 'Q';
-- c = ERR?
-- TODO when c is not a character (arrow key)
-- the behavior is different from the C version.
Add (Ch => c2);
end loop;
when 'd' =>
Clear_Soft_Label_Keys;
when 'l' =>
fmt := Left;
when 'c' =>
fmt := Centered;
when 'r' =>
fmt := Right;
when '1' | '2' | '3' | '4' | '5' | '6' | '7' | '8' =>
Add (Line => 20, Column => 0,
Str => "Please enter the label value: ");
Set_Echo_Mode (SwitchOn => True);
myGet (Str => buf);
Set_Echo_Mode (SwitchOn => False);
tmp := ctoi (c2);
Set_Soft_Label_Key (Label_Number (tmp), To_String (buf), fmt);
Refresh_Soft_Label_Keys;
Move_Cursor (Line => 20, Column => 0);
Clear_To_End_Of_Line;
when 'x' | 'q' =>
exit;
-- the C version needed a goto, ha ha
-- breaks exit the case not the loop because fall-through
-- happens in C!
when others =>
Beep;
end case;
c := Getchar;
-- TODO exit when c = EOF
end loop;
Erase;
End_Windows;
end ncurses2.slk_test;
|
<Diagramm>
<AdditionalSQLCode>
<SQLCode>
<AdditionalSQLCodePostChanging></AdditionalSQLCodePostChanging>
<AdditionalSQLCodePostReducing></AdditionalSQLCodePostReducing>
<AdditionalSQLCodePreChanging></AdditionalSQLCodePreChanging>
<AdditionalSQLCodePreExtending></AdditionalSQLCodePreExtending>
</SQLCode>
</AdditionalSQLCode>
<Colors>
<Anzahl>23</Anzahl>
<Color0>
<B>255</B>
<G>0</G>
<Name>blau</Name>
<R>0</R>
</Color0>
<Color1>
<B>221</B>
<G>212</G>
<Name>blaugrau</Name>
<R>175</R>
</Color1>
<Color10>
<B>192</B>
<G>192</G>
<Name>hellgrau</Name>
<R>192</R>
</Color10>
<Color11>
<B>255</B>
<G>0</G>
<Name>kamesinrot</Name>
<R>255</R>
</Color11>
<Color12>
<B>0</B>
<G>200</G>
<Name>orange</Name>
<R>255</R>
</Color12>
<Color13>
<B>255</B>
<G>247</G>
<Name>pastell-blau</Name>
<R>211</R>
</Color13>
<Color14>
<B>186</B>
<G>245</G>
<Name>pastell-gelb</Name>
<R>255</R>
</Color14>
<Color15>
<B>234</B>
<G>255</G>
<Name>pastell-gr&uuml;n</Name>
<R>211</R>
</Color15>
<Color16>
<B>255</B>
<G>211</G>
<Name>pastell-lila</Name>
<R>244</R>
</Color16>
<Color17>
<B>191</B>
<G>165</G>
<Name>pastell-rot</Name>
<R>244</R>
</Color17>
<Color18>
<B>175</B>
<G>175</G>
<Name>pink</Name>
<R>255</R>
</Color18>
<Color19>
<B>0</B>
<G>0</G>
<Name>rot</Name>
<R>255</R>
</Color19>
<Color2>
<B>61</B>
<G>125</G>
<Name>braun</Name>
<R>170</R>
</Color2>
<Color20>
<B>0</B>
<G>0</G>
<Name>schwarz</Name>
<R>0</R>
</Color20>
<Color21>
<B>255</B>
<G>255</G>
<Name>t&uuml;rkis</Name>
<R>0</R>
</Color21>
<Color22>
<B>255</B>
<G>255</G>
<Name>wei&szlig;</Name>
<R>255</R>
</Color22>
<Color3>
<B>64</B>
<G>64</G>
<Name>dunkelgrau</Name>
<R>64</R>
</Color3>
<Color4>
<B>84</B>
<G>132</G>
<Name>dunkelgr&uuml;n</Name>
<R>94</R>
</Color4>
<Color5>
<B>0</B>
<G>255</G>
<Name>gelb</Name>
<R>255</R>
</Color5>
<Color6>
<B>0</B>
<G>225</G>
<Name>goldgelb</Name>
<R>255</R>
</Color6>
<Color7>
<B>128</B>
<G>128</G>
<Name>grau</Name>
<R>128</R>
</Color7>
<Color8>
<B>0</B>
<G>255</G>
<Name>gr&uuml;n</Name>
<R>0</R>
</Color8>
<Color9>
<B>255</B>
<G>212</G>
<Name>hellblau</Name>
<R>191</R>
</Color9>
</Colors>
<ComplexIndices>
<IndexCount>0</IndexCount>
</ComplexIndices>
<DataSource>
<Import>
<DBName></DBName>
<Description></Description>
<Domains>false</Domains>
<Driver></Driver>
<Name></Name>
<Referenzen>false</Referenzen>
<User></User>
</Import>
</DataSource>
<DatabaseConnections>
<Count>2</Count>
<DatabaseConnection0>
<DBExecMode>POSTGRESQL</DBExecMode>
<Driver>org.postgresql.Driver</Driver>
<Name>Test-DB (Postgre)</Name>
<Quote>"</Quote>
<SetDomains>false</SetDomains>
<SetNotNull>true</SetNotNull>
<SetReferences>true</SetReferences>
<URL>jdbc:postgresql://mykene/TEST_OLI_ISIS_2</URL>
<UserName>op1</UserName>
</DatabaseConnection0>
<DatabaseConnection1>
<DBExecMode>HSQL</DBExecMode>
<Driver>org.hsqldb.jdbcDriver</Driver>
<Name>Test-DB (HSQL)</Name>
<Quote>"</Quote>
<SetDomains>false</SetDomains>
<SetNotNull>true</SetNotNull>
<SetReferences>true</SetReferences>
<URL>jdbc:hsqldb:unittests/db/tst</URL>
<UserName>sa</UserName>
</DatabaseConnection1>
</DatabaseConnections>
<DefaultComment>
<Anzahl>0</Anzahl>
</DefaultComment>
<Domains>
<Anzahl>4</Anzahl>
<Domain0>
<Datatype>-5</Datatype>
<History></History>
<Initialwert>NULL</Initialwert>
<Kommentar></Kommentar>
<Length>0</Length>
<NKS>0</NKS>
<Name>Ident</Name>
<Parameters></Parameters>
</Domain0>
<Domain1>
<Datatype>12</Datatype>
<History></History>
<Initialwert>NULL</Initialwert>
<Kommentar></Kommentar>
<Length>500</Length>
<NKS>0</NKS>
<Name>LongName</Name>
<Parameters></Parameters>
</Domain1>
<Domain2>
<Datatype>12</Datatype>
<History></History>
<Initialwert>NULL</Initialwert>
<Kommentar></Kommentar>
<Length>200</Length>
<NKS>0</NKS>
<Name>Name</Name>
<Parameters></Parameters>
</Domain2>
<Domain3>
<Datatype>2</Datatype>
<History></History>
<Initialwert>NULL</Initialwert>
<Kommentar></Kommentar>
<Length>8</Length>
<NKS>2</NKS>
<Name>Price</Name>
<Parameters></Parameters>
</Domain3>
</Domains>
<Factories>
<Object>archimedes.legacy.scheme.DefaultObjectFactory</Object>
</Factories>
<Pages>
<PerColumn>5</PerColumn>
<PerRow>10</PerRow>
</Pages>
<Parameter>
<AdditionalSQLScriptListener></AdditionalSQLScriptListener>
<Applicationname></Applicationname>
<AufgehobeneAusblenden>false</AufgehobeneAusblenden>
<Autor>&lt;null&gt;</Autor>
<Basepackagename></Basepackagename>
<CodeFactoryClassName></CodeFactoryClassName>
<Codebasispfad>.\</Codebasispfad>
<DBVersionDBVersionColumn></DBVersionDBVersionColumn>
<DBVersionDescriptionColumn></DBVersionDescriptionColumn>
<DBVersionTablename></DBVersionTablename>
<History></History>
<Kommentar>&lt;null&gt;</Kommentar>
<Name>TST</Name>
<Optionen>
<Anzahl>0</Anzahl>
</Optionen>
<PflichtfelderMarkieren>false</PflichtfelderMarkieren>
<ReferenzierteSpaltenAnzeigen>true</ReferenzierteSpaltenAnzeigen>
<RelationColorExternalTables>hellgrau</RelationColorExternalTables>
<RelationColorRegular>schwarz</RelationColorRegular>
<SchemaName>TST</SchemaName>
<Schriftgroessen>
<Tabelleninhalte>12</Tabelleninhalte>
<Ueberschriften>24</Ueberschriften>
<Untertitel>12</Untertitel>
</Schriftgroessen>
<Scripte>
<AfterWrite>&lt;null&gt;</AfterWrite>
</Scripte>
<TechnischeFelderAusgrauen>false</TechnischeFelderAusgrauen>
<TransienteFelderAusgrauen>false</TransienteFelderAusgrauen>
<UdschebtiBaseClassName></UdschebtiBaseClassName>
<Version>1</Version>
<Versionsdatum>08.12.2015</Versionsdatum>
<Versionskommentar>&lt;null&gt;</Versionskommentar>
</Parameter>
<Sequences>
<Count>0</Count>
</Sequences>
<Stereotype>
<Anzahl>0</Anzahl>
</Stereotype>
<Tabellen>
<Anzahl>2</Anzahl>
<Tabelle0>
<Aufgehoben>false</Aufgehoben>
<Codegenerator>
<AuswahlMembers>
<Anzahl>0</Anzahl>
</AuswahlMembers>
<CompareMembers>
<Anzahl>0</Anzahl>
</CompareMembers>
<Equalsmembers>
<Anzahl>0</Anzahl>
</Equalsmembers>
<HashCodeMembers>
<Anzahl>0</Anzahl>
</HashCodeMembers>
<NReferenzen>
<Anzahl>0</Anzahl>
</NReferenzen>
<OrderMembers>
<Anzahl>0</Anzahl>
</OrderMembers>
<ToComboStringMembers>
<Anzahl>0</Anzahl>
</ToComboStringMembers>
<ToStringMembers>
<Anzahl>0</Anzahl>
</ToStringMembers>
</Codegenerator>
<ExternalTable>false</ExternalTable>
<Farben>
<Hintergrund>wei&szlig;</Hintergrund>
<Schrift>schwarz</Schrift>
</Farben>
<FirstGenerationDone>false</FirstGenerationDone>
<History>@changed OLI - Added.$BR$@changed OLI - Added column: Id.</History>
<InDevelopment>false</InDevelopment>
<Kommentar></Kommentar>
<NMRelation>false</NMRelation>
<Name>Author</Name>
<Options>
<Count>0</Count>
</Options>
<Panels>
<Anzahl>1</Anzahl>
<Panel0>
<PanelClass></PanelClass>
<PanelNumber>0</PanelNumber>
<TabMnemonic>1</TabMnemonic>
<TabTitle>1.Daten</TabTitle>
<TabToolTipText>Hier können Sie die Daten des Objekt warten</TabToolTipText>
</Panel0>
</Panels>
<Spalten>
<Anzahl>4</Anzahl>
<Codegenerator>
<ActiveInApplication>false</ActiveInApplication>
<AdditionalCreateConstraints></AdditionalCreateConstraints>
<Codegeneratoroptionen></Codegeneratoroptionen>
<Codeverzeichnis>.</Codeverzeichnis>
<Codieren>true</Codieren>
<DynamicCode>true</DynamicCode>
<Inherited>false</Inherited>
<Kontextname></Kontextname>
<UniqueFormula></UniqueFormula>
</Codegenerator>
<Spalte0>
<AlterInBatch>false</AlterInBatch>
<Aufgehoben>false</Aufgehoben>
<CanBeReferenced>true</CanBeReferenced>
<Disabled>false</Disabled>
<Domain>Ident</Domain>
<Editordescriptor>
<Editormember>false</Editormember>
<LabelText></LabelText>
<MaxCharacters>0</MaxCharacters>
<Mnemonic></Mnemonic>
<Position>0</Position>
<ReferenceWeight>keine</ReferenceWeight>
<RessourceIdentifier></RessourceIdentifier>
<ToolTipText></ToolTipText>
</Editordescriptor>
<ForeignKey>false</ForeignKey>
<Global>false</Global>
<GlobalId>false</GlobalId>
<HideReference>false</HideReference>
<History>@changed OLI - Added.</History>
<IndexSearchMember>false</IndexSearchMember>
<Indexed>false</Indexed>
<IndividualDefaultValue></IndividualDefaultValue>
<Kodiert>false</Kodiert>
<Kommentar></Kommentar>
<Konsistenz>
<Writeablemember>false</Writeablemember>
</Konsistenz>
<LastModificationField>false</LastModificationField>
<ListItemField>false</ListItemField>
<Name>Author</Name>
<NotNull>false</NotNull>
<PanelNumber>0</PanelNumber>
<Parameter></Parameter>
<PrimaryKey>true</PrimaryKey>
<RemovedStateField>false</RemovedStateField>
<SequenceForKeyGeneration></SequenceForKeyGeneration>
<SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints>
<TechnicalField>false</TechnicalField>
<Transient>false</Transient>
<Unique>false</Unique>
</Spalte0>
<Spalte1>
<AlterInBatch>false</AlterInBatch>
<Aufgehoben>false</Aufgehoben>
<CanBeReferenced>false</CanBeReferenced>
<Disabled>false</Disabled>
<Domain>Name</Domain>
<Editordescriptor>
<Editormember>false</Editormember>
<LabelText></LabelText>
<MaxCharacters>0</MaxCharacters>
<Mnemonic></Mnemonic>
<Position>0</Position>
<ReferenceWeight>keine</ReferenceWeight>
<RessourceIdentifier></RessourceIdentifier>
<ToolTipText></ToolTipText>
</Editordescriptor>
<ForeignKey>false</ForeignKey>
<Global>false</Global>
<GlobalId>false</GlobalId>
<HideReference>false</HideReference>
<History>@changed OLI - Added.</History>
<IndexSearchMember>false</IndexSearchMember>
<Indexed>false</Indexed>
<IndividualDefaultValue>'n/a'</IndividualDefaultValue>
<Kodiert>false</Kodiert>
<Kommentar></Kommentar>
<Konsistenz>
<Writeablemember>false</Writeablemember>
</Konsistenz>
<LastModificationField>false</LastModificationField>
<ListItemField>false</ListItemField>
<Name>Address</Name>
<NotNull>true</NotNull>
<PanelNumber>0</PanelNumber>
<Parameter></Parameter>
<PrimaryKey>false</PrimaryKey>
<RemovedStateField>false</RemovedStateField>
<SequenceForKeyGeneration></SequenceForKeyGeneration>
<SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints>
<TechnicalField>false</TechnicalField>
<Transient>false</Transient>
<Unique>false</Unique>
</Spalte1>
<Spalte2>
<AlterInBatch>false</AlterInBatch>
<Aufgehoben>false</Aufgehoben>
<CanBeReferenced>false</CanBeReferenced>
<Disabled>false</Disabled>
<Domain>Ident</Domain>
<Editordescriptor>
<Editormember>false</Editormember>
<LabelText></LabelText>
<MaxCharacters>0</MaxCharacters>
<Mnemonic></Mnemonic>
<Position>0</Position>
<ReferenceWeight>keine</ReferenceWeight>
<RessourceIdentifier></RessourceIdentifier>
<ToolTipText></ToolTipText>
</Editordescriptor>
<ForeignKey>false</ForeignKey>
<Global>false</Global>
<GlobalId>false</GlobalId>
<HideReference>false</HideReference>
<History>@changed OLI - Added.</History>
<IndexSearchMember>false</IndexSearchMember>
<Indexed>false</Indexed>
<IndividualDefaultValue></IndividualDefaultValue>
<Kodiert>false</Kodiert>
<Kommentar></Kommentar>
<Konsistenz>
<Writeablemember>false</Writeablemember>
</Konsistenz>
<LastModificationField>false</LastModificationField>
<ListItemField>false</ListItemField>
<Name>AuthorId</Name>
<NotNull>false</NotNull>
<PanelNumber>0</PanelNumber>
<Parameter></Parameter>
<PrimaryKey>false</PrimaryKey>
<RemovedStateField>false</RemovedStateField>
<SequenceForKeyGeneration></SequenceForKeyGeneration>
<SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints>
<TechnicalField>false</TechnicalField>
<Transient>false</Transient>
<Unique>true</Unique>
</Spalte2>
<Spalte3>
<AlterInBatch>false</AlterInBatch>
<Aufgehoben>false</Aufgehoben>
<CanBeReferenced>false</CanBeReferenced>
<Disabled>false</Disabled>
<Domain>Name</Domain>
<Editordescriptor>
<Editormember>false</Editormember>
<LabelText></LabelText>
<MaxCharacters>0</MaxCharacters>
<Mnemonic></Mnemonic>
<Position>0</Position>
<ReferenceWeight>keine</ReferenceWeight>
<RessourceIdentifier></RessourceIdentifier>
<ToolTipText></ToolTipText>
</Editordescriptor>
<ForeignKey>false</ForeignKey>
<Global>false</Global>
<GlobalId>false</GlobalId>
<HideReference>false</HideReference>
<History>@changed OLI - Added.</History>
<IndexSearchMember>false</IndexSearchMember>
<Indexed>false</Indexed>
<IndividualDefaultValue></IndividualDefaultValue>
<Kodiert>false</Kodiert>
<Kommentar></Kommentar>
<Konsistenz>
<Writeablemember>false</Writeablemember>
</Konsistenz>
<LastModificationField>false</LastModificationField>
<ListItemField>false</ListItemField>
<Name>Name</Name>
<NotNull>true</NotNull>
<PanelNumber>0</PanelNumber>
<Parameter></Parameter>
<PrimaryKey>false</PrimaryKey>
<RemovedStateField>false</RemovedStateField>
<SequenceForKeyGeneration></SequenceForKeyGeneration>
<SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints>
<TechnicalField>false</TechnicalField>
<Transient>false</Transient>
<Unique>false</Unique>
</Spalte3>
</Spalten>
<Stereotype>
<Anzahl>0</Anzahl>
</Stereotype>
<Views>
<Anzahl>1</Anzahl>
<View0>
<Name>Main</Name>
<X>150</X>
<Y>150</Y>
</View0>
</Views>
</Tabelle0>
<Tabelle1>
<Aufgehoben>false</Aufgehoben>
<Codegenerator>
<AuswahlMembers>
<Anzahl>0</Anzahl>
</AuswahlMembers>
<CompareMembers>
<Anzahl>0</Anzahl>
</CompareMembers>
<Equalsmembers>
<Anzahl>0</Anzahl>
</Equalsmembers>
<HashCodeMembers>
<Anzahl>0</Anzahl>
</HashCodeMembers>
<NReferenzen>
<Anzahl>0</Anzahl>
</NReferenzen>
<OrderMembers>
<Anzahl>0</Anzahl>
</OrderMembers>
<ToComboStringMembers>
<Anzahl>0</Anzahl>
</ToComboStringMembers>
<ToStringMembers>
<Anzahl>0</Anzahl>
</ToStringMembers>
</Codegenerator>
<ExternalTable>false</ExternalTable>
<Farben>
<Hintergrund>wei&szlig;</Hintergrund>
<Schrift>schwarz</Schrift>
</Farben>
<FirstGenerationDone>false</FirstGenerationDone>
<History>@changed OLI - Added.</History>
<InDevelopment>false</InDevelopment>
<Kommentar></Kommentar>
<NMRelation>false</NMRelation>
<Name>Book</Name>
<Options>
<Count>0</Count>
</Options>
<Panels>
<Anzahl>1</Anzahl>
<Panel0>
<PanelClass></PanelClass>
<PanelNumber>0</PanelNumber>
<TabMnemonic>1</TabMnemonic>
<TabTitle>1.Daten</TabTitle>
<TabToolTipText>Hier können Sie die Daten des Objekt warten</TabToolTipText>
</Panel0>
</Panels>
<Spalten>
<Anzahl>3</Anzahl>
<Codegenerator>
<ActiveInApplication>false</ActiveInApplication>
<AdditionalCreateConstraints></AdditionalCreateConstraints>
<Codegeneratoroptionen></Codegeneratoroptionen>
<Codeverzeichnis>.</Codeverzeichnis>
<Codieren>true</Codieren>
<DynamicCode>true</DynamicCode>
<Inherited>false</Inherited>
<Kontextname></Kontextname>
<UniqueFormula></UniqueFormula>
</Codegenerator>
<Spalte0>
<AlterInBatch>false</AlterInBatch>
<Aufgehoben>false</Aufgehoben>
<CanBeReferenced>true</CanBeReferenced>
<Disabled>false</Disabled>
<Domain>Ident</Domain>
<Editordescriptor>
<Editormember>false</Editormember>
<LabelText></LabelText>
<MaxCharacters>0</MaxCharacters>
<Mnemonic></Mnemonic>
<Position>0</Position>
<ReferenceWeight>keine</ReferenceWeight>
<RessourceIdentifier></RessourceIdentifier>
<ToolTipText></ToolTipText>
</Editordescriptor>
<ForeignKey>false</ForeignKey>
<Global>false</Global>
<GlobalId>false</GlobalId>
<HideReference>false</HideReference>
<History>@changed OLI - Added.</History>
<IndexSearchMember>false</IndexSearchMember>
<Indexed>false</Indexed>
<IndividualDefaultValue></IndividualDefaultValue>
<Kodiert>false</Kodiert>
<Kommentar></Kommentar>
<Konsistenz>
<Writeablemember>false</Writeablemember>
</Konsistenz>
<LastModificationField>false</LastModificationField>
<ListItemField>false</ListItemField>
<Name>Book</Name>
<NotNull>false</NotNull>
<PanelNumber>0</PanelNumber>
<Parameter></Parameter>
<PrimaryKey>true</PrimaryKey>
<RemovedStateField>false</RemovedStateField>
<SequenceForKeyGeneration></SequenceForKeyGeneration>
<SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints>
<TechnicalField>false</TechnicalField>
<Transient>false</Transient>
<Unique>false</Unique>
</Spalte0>
<Spalte1>
<AlterInBatch>false</AlterInBatch>
<Aufgehoben>false</Aufgehoben>
<CanBeReferenced>false</CanBeReferenced>
<Disabled>false</Disabled>
<Domain>Ident</Domain>
<Editordescriptor>
<Editormember>false</Editormember>
<LabelText></LabelText>
<MaxCharacters>0</MaxCharacters>
<Mnemonic></Mnemonic>
<Position>0</Position>
<ReferenceWeight>keine</ReferenceWeight>
<RessourceIdentifier></RessourceIdentifier>
<ToolTipText></ToolTipText>
</Editordescriptor>
<ForeignKey>true</ForeignKey>
<Global>false</Global>
<GlobalId>false</GlobalId>
<HideReference>false</HideReference>
<History>@changed OLI - Added.</History>
<IndexSearchMember>false</IndexSearchMember>
<Indexed>false</Indexed>
<IndividualDefaultValue></IndividualDefaultValue>
<Kodiert>false</Kodiert>
<Kommentar></Kommentar>
<Konsistenz>
<Writeablemember>false</Writeablemember>
</Konsistenz>
<LastModificationField>false</LastModificationField>
<ListItemField>false</ListItemField>
<Name>Author</Name>
<NotNull>true</NotNull>
<PanelNumber>0</PanelNumber>
<Parameter></Parameter>
<PrimaryKey>false</PrimaryKey>
<Referenz>
<Direction0>UP</Direction0>
<Direction1>DOWN</Direction1>
<Offset0>50</Offset0>
<Offset1>50</Offset1>
<Spalte>Author</Spalte>
<Tabelle>Author</Tabelle>
<Views>
<Anzahl>1</Anzahl>
<View0>
<Direction0>UP</Direction0>
<Direction1>DOWN</Direction1>
<Name>Main</Name>
<Offset0>50</Offset0>
<Offset1>50</Offset1>
<Points>
<Anzahl>0</Anzahl>
</Points>
</View0>
</Views>
</Referenz>
<RemovedStateField>false</RemovedStateField>
<SequenceForKeyGeneration></SequenceForKeyGeneration>
<SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints>
<TechnicalField>false</TechnicalField>
<Transient>false</Transient>
<Unique>false</Unique>
</Spalte1>
<Spalte2>
<AlterInBatch>false</AlterInBatch>
<Aufgehoben>false</Aufgehoben>
<CanBeReferenced>false</CanBeReferenced>
<Disabled>false</Disabled>
<Domain>LongName</Domain>
<Editordescriptor>
<Editormember>false</Editormember>
<LabelText></LabelText>
<MaxCharacters>0</MaxCharacters>
<Mnemonic></Mnemonic>
<Position>0</Position>
<ReferenceWeight>keine</ReferenceWeight>
<RessourceIdentifier></RessourceIdentifier>
<ToolTipText></ToolTipText>
</Editordescriptor>
<ForeignKey>false</ForeignKey>
<Global>false</Global>
<GlobalId>false</GlobalId>
<HideReference>false</HideReference>
<History>@changed OLI - Added.</History>
<IndexSearchMember>false</IndexSearchMember>
<Indexed>false</Indexed>
<IndividualDefaultValue></IndividualDefaultValue>
<Kodiert>false</Kodiert>
<Kommentar></Kommentar>
<Konsistenz>
<Writeablemember>false</Writeablemember>
</Konsistenz>
<LastModificationField>false</LastModificationField>
<ListItemField>false</ListItemField>
<Name>Title</Name>
<NotNull>false</NotNull>
<PanelNumber>0</PanelNumber>
<Parameter></Parameter>
<PrimaryKey>false</PrimaryKey>
<RemovedStateField>false</RemovedStateField>
<SequenceForKeyGeneration></SequenceForKeyGeneration>
<SuppressForeignKeyConstraints>false</SuppressForeignKeyConstraints>
<TechnicalField>false</TechnicalField>
<Transient>false</Transient>
<Unique>false</Unique>
</Spalte2>
</Spalten>
<Stereotype>
<Anzahl>0</Anzahl>
</Stereotype>
<Views>
<Anzahl>1</Anzahl>
<View0>
<Name>Main</Name>
<X>150</X>
<Y>375</Y>
</View0>
</Views>
</Tabelle1>
</Tabellen>
<Views>
<Anzahl>1</Anzahl>
<View0>
<Beschreibung>Diese Sicht beinhaltet alle Tabellen des Schemas</Beschreibung>
<Name>Main</Name>
<ReferenzierteSpaltenAnzeigen>true</ReferenzierteSpaltenAnzeigen>
<Tabelle0>Author</Tabelle0>
<Tabellenanzahl>1</Tabellenanzahl>
<TechnischeSpaltenVerstecken>false</TechnischeSpaltenVerstecken>
</View0>
</Views>
</Diagramm>
|
-- This spec has been automatically generated from cm7.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
-- Data Watchpoint Trace
package Cortex_M_SVD.DWT is
pragma Preelaborate;
---------------
-- Registers --
---------------
subtype CTRL_POSTPRESET_Field is HAL.UInt4;
subtype CTRL_POSTINIT_Field is HAL.UInt4;
subtype CTRL_SYNCTAP_Field is HAL.UInt2;
subtype CTRL_Reserved_13_15_Field is HAL.UInt3;
subtype CTRL_NUMCOMP_Field is HAL.UInt4;
-- Control Register
type CTRL_Register is record
-- enable cycle counter
CYCCNTENA : Boolean := False;
-- ???
POSTPRESET : CTRL_POSTPRESET_Field := 16#0#;
-- ???
POSTINIT : CTRL_POSTINIT_Field := 16#0#;
-- ???
CYCTAP : Boolean := False;
-- ???
SYNCTAP : CTRL_SYNCTAP_Field := 16#0#;
-- enable POSTCNT as timer for PC sample packets
PCSAMPLENA : Boolean := False;
-- Reserved bits 13..15
Reserved_13_15 : CTRL_Reserved_13_15_Field := 16#0#;
-- enable interrupt event tracing
EXCTRCENA : Boolean := False;
-- enable CPI count event
CPIEVTENA : Boolean := False;
-- enable interrupt overhead event
EXCEVTENA : Boolean := False;
-- enable Sleep count event
SLEEPEVTENA : Boolean := False;
-- enable Load Store Unit (LSU) count event
LSUEVTENA : Boolean := False;
-- enable Folded instruction count event
FOLDEVTENA : Boolean := False;
-- enable Cycle count event
CYCEVTENA : Boolean := False;
-- Read-only. Reserved bit 23
Reserved_23 : Boolean := False;
-- No profiling counters
NOPRFCNT : Boolean := False;
-- No cycle counter
NOCYCCNT : Boolean := False;
-- No external match signals
NOEXTTRIG : Boolean := False;
-- No trace sampling and exception tracing
NOTRCPKT : Boolean := False;
-- Number of comparators
NUMCOMP : CTRL_NUMCOMP_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CTRL_Register use record
CYCCNTENA at 0 range 0 .. 0;
POSTPRESET at 0 range 1 .. 4;
POSTINIT at 0 range 5 .. 8;
CYCTAP at 0 range 9 .. 9;
SYNCTAP at 0 range 10 .. 11;
PCSAMPLENA at 0 range 12 .. 12;
Reserved_13_15 at 0 range 13 .. 15;
EXCTRCENA at 0 range 16 .. 16;
CPIEVTENA at 0 range 17 .. 17;
EXCEVTENA at 0 range 18 .. 18;
SLEEPEVTENA at 0 range 19 .. 19;
LSUEVTENA at 0 range 20 .. 20;
FOLDEVTENA at 0 range 21 .. 21;
CYCEVTENA at 0 range 22 .. 22;
Reserved_23 at 0 range 23 .. 23;
NOPRFCNT at 0 range 24 .. 24;
NOCYCCNT at 0 range 25 .. 25;
NOEXTTRIG at 0 range 26 .. 26;
NOTRCPKT at 0 range 27 .. 27;
NUMCOMP at 0 range 28 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Data Watchpoint Trace
type DWT_Peripheral is record
-- Control Register
CTRL : aliased CTRL_Register;
-- Cycle Count Register
CYCCNT : aliased HAL.UInt32;
-- CPI Count Register
CPICNT : aliased HAL.UInt32;
-- Exception Overhead Count Register
EXCCNT : aliased HAL.UInt32;
-- Sleep Count Register
SLEEPCNT : aliased HAL.UInt32;
-- LSU Count Register
LSUCNT : aliased HAL.UInt32;
-- Folded-instruction Count Register
FOLDCNT : aliased HAL.UInt32;
-- Program Counter Sample Register
PCSR : aliased HAL.UInt32;
-- Comparator Register 0
COMP0 : aliased HAL.UInt32;
-- Mask Register 0
MASK0 : aliased HAL.UInt32;
-- Function Register 0
FUNCTION0 : aliased HAL.UInt32;
-- Reserved 0
RESERVED0 : aliased HAL.UInt32;
-- Comparator Register 1
COMP1 : aliased HAL.UInt32;
-- Mask Register 1
MASK1 : aliased HAL.UInt32;
-- Function Register 1
FUNCTION1 : aliased HAL.UInt32;
-- Reserved 1
RESERVED1 : aliased HAL.UInt32;
-- Comparator Register 2
COMP2 : aliased HAL.UInt32;
-- Mask Register 2
MASK2 : aliased HAL.UInt32;
-- Function Register 2
FUNCTION2 : aliased HAL.UInt32;
-- Reserved 2
RESERVED2 : aliased HAL.UInt32;
-- Comparator Register 3
COMP3 : aliased HAL.UInt32;
-- Mask Register 3
MASK3 : aliased HAL.UInt32;
-- Function Register 3
FUNCTION3 : aliased HAL.UInt32;
-- Lock Access Register
LAR : aliased HAL.UInt32;
-- Lock Status Register
LSR : aliased HAL.UInt32;
end record
with Volatile;
for DWT_Peripheral use record
CTRL at 16#0# range 0 .. 31;
CYCCNT at 16#4# range 0 .. 31;
CPICNT at 16#8# range 0 .. 31;
EXCCNT at 16#C# range 0 .. 31;
SLEEPCNT at 16#10# range 0 .. 31;
LSUCNT at 16#14# range 0 .. 31;
FOLDCNT at 16#18# range 0 .. 31;
PCSR at 16#1C# range 0 .. 31;
COMP0 at 16#20# range 0 .. 31;
MASK0 at 16#24# range 0 .. 31;
FUNCTION0 at 16#28# range 0 .. 31;
RESERVED0 at 16#2C# range 0 .. 31;
COMP1 at 16#30# range 0 .. 31;
MASK1 at 16#34# range 0 .. 31;
FUNCTION1 at 16#38# range 0 .. 31;
RESERVED1 at 16#3C# range 0 .. 31;
COMP2 at 16#40# range 0 .. 31;
MASK2 at 16#44# range 0 .. 31;
FUNCTION2 at 16#48# range 0 .. 31;
RESERVED2 at 16#4C# range 0 .. 31;
COMP3 at 16#50# range 0 .. 31;
MASK3 at 16#54# range 0 .. 31;
FUNCTION3 at 16#58# range 0 .. 31;
LAR at 16#FB0# range 0 .. 31;
LSR at 16#FB4# range 0 .. 31;
end record;
-- Data Watchpoint Trace
DWT_Periph : aliased DWT_Peripheral
with Import, Address => DWT_Base;
end Cortex_M_SVD.DWT;
|
-- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../../License.txt
with CommonText;
with AdaBase.Connection.Base;
with AdaBase.Interfaces.Statement;
with AdaBase.Logger.Facility;
with AdaBase.Results.Sets;
with AdaBase.Results.Field;
with AdaBase.Results.Converters;
with AdaBase.Results.Generic_Converters;
with Ada.Calendar.Formatting;
with Ada.Characters.Handling;
with Ada.Containers.Indefinite_Hashed_Maps;
with Ada.Containers.Vectors;
with Ada.Strings.Hash;
with Ada.Strings.Wide_Unbounded;
with Ada.Strings.Wide_Wide_Unbounded;
with Ada.Characters.Conversions;
with Ada.Unchecked_Deallocation;
with Spatial_Data.Well_Known_Binary;
package AdaBase.Statement.Base is
package CT renames CommonText;
package SUW renames Ada.Strings.Wide_Unbounded;
package SWW renames Ada.Strings.Wide_Wide_Unbounded;
package CAL renames Ada.Calendar;
package CFM renames Ada.Calendar.Formatting;
package ACC renames Ada.Characters.Conversions;
package AR renames AdaBase.Results;
package ACB renames AdaBase.Connection.Base;
package AIS renames AdaBase.Interfaces.Statement;
package ALF renames AdaBase.Logger.Facility;
package ARC renames AdaBase.Results.Converters;
package RGC renames AdaBase.Results.Generic_Converters;
package ARF renames AdaBase.Results.Field;
package ARS renames AdaBase.Results.Sets;
package ACH renames Ada.Characters.Handling;
package GEO renames Spatial_Data;
package WKB renames Spatial_Data.Well_Known_Binary;
type SQL_Access is access all String;
type Base_Statement is
abstract new Base_Pure and AIS.iStatement with private;
type Basic_Statement is access all Base_Statement'Class;
type Stmt_Type is (direct_statement, prepared_statement);
ILLEGAL_BIND_SQL : exception;
INVALID_FOR_DIRECT_QUERY : exception;
INVALID_FOR_RESULT_SET : exception;
INVALID_COLUMN_INDEX : exception;
PRIOR_EXECUTION_FAILED : exception;
BINDING_COLUMN_NOT_FOUND : exception;
BINDING_TYPE_MISMATCH : exception;
BINDING_SIZE_MISMATCH : exception;
STMT_PREPARATION : exception;
STMT_EXECUTION : exception;
MARKER_NOT_FOUND : exception;
overriding
function rows_affected (Stmt : Base_Statement) return Affected_Rows;
overriding
function successful (Stmt : Base_Statement) return Boolean;
overriding
function data_discarded (Stmt : Base_Statement) return Boolean;
overriding
procedure iterate (Stmt : out Base_Statement;
process : not null access procedure);
overriding
procedure iterate (Stmt : out Base_Statement;
process : not null access procedure (row : ARS.Datarow));
-------------------------------------------
-- 23 bind using integer index --
-------------------------------------------
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte0_Access);
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte1_Access);
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte2_Access);
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte3_Access);
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte4_Access);
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte8_Access);
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte1_Access);
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte2_Access);
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte3_Access);
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte4_Access);
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte8_Access);
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Real9_Access);
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Real18_Access);
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Str1_Access);
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Str2_Access);
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Str4_Access);
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Time_Access);
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Chain_Access);
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Enum_Access);
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Settype_Access);
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Bits_Access);
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.S_UTF8_Access);
procedure bind (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Geometry_Access);
-------------------------------------------
-- 23 bind using header for index --
-------------------------------------------
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.NByte0_Access);
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.NByte1_Access);
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.NByte2_Access);
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.NByte3_Access);
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.NByte4_Access);
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.NByte8_Access);
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Byte1_Access);
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Byte2_Access);
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Byte3_Access);
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Byte4_Access);
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Byte8_Access);
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Real9_Access);
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Real18_Access);
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Str1_Access);
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Str2_Access);
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Str4_Access);
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Time_Access);
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Chain_Access);
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Enum_Access);
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Settype_Access);
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Bits_Access);
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.S_UTF8_Access);
procedure bind (Stmt : out Base_Statement;
heading : String;
vaxx : AR.Geometry_Access);
--------------------------------------------
-- 23 assign/access using integer index --
--------------------------------------------
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte0_Access);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte1_Access);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte2_Access);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte3_Access);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte4_Access);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte8_Access);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte1_Access);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte2_Access);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte3_Access);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte4_Access);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte8_Access);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Real9_Access);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Real18_Access);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Str1_Access);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Str2_Access);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Str4_Access);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Time_Access);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Chain_Access);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Enum_Access);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Settype_Access);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Bits_Access);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.S_UTF8_Access);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Geometry_Access);
------------------------------------------------
-- 23 assign/access using moniker for index --
------------------------------------------------
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.NByte0_Access);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.NByte1_Access);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.NByte2_Access);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.NByte3_Access);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.NByte4_Access);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.NByte8_Access);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Byte1_Access);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Byte2_Access);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Byte3_Access);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Byte4_Access);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Byte8_Access);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Real9_Access);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Real18_Access);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Str1_Access);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Str2_Access);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Str4_Access);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Time_Access);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Chain_Access);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Enum_Access);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Settype_Access);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Bits_Access);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.S_UTF8_Access);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Geometry_Access);
-------------------------------------------
-- 22 assign/value using integer index --
-------------------------------------------
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte0);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte1);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte2);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte3);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte4);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.NByte8);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte1);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte2);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte3);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte4);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Byte8);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Real9);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Real18);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Textual);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Textwide);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Textsuper);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : CAL.Time);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Chain);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Enumtype);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Settype);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Bits);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : AR.Text_UTF8);
procedure assign (Stmt : out Base_Statement;
index : Positive;
vaxx : Spatial_Data.Geometry);
-----------------------------------------------
-- 23 assign/value using moniker for index --
-----------------------------------------------
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.NByte0);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.NByte1);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.NByte2);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.NByte3);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.NByte4);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.NByte8);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Byte1);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Byte2);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Byte3);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Byte4);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Byte8);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Real9);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Real18);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Textual);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Textwide);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Textsuper);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : CAL.Time);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Chain);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Enumtype);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Settype);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Bits);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : AR.Text_UTF8);
procedure assign (Stmt : out Base_Statement;
moniker : String;
vaxx : Spatial_Data.Geometry);
private
logger_access : ALF.LogFacility_access;
function Same_Strings (S, T : String) return Boolean;
function transform_sql (Stmt : out Base_Statement; sql : String)
return String;
procedure log_nominal (statement : Base_Statement;
category : Log_Category;
message : String);
procedure free_datarow is new Ada.Unchecked_Deallocation
(AR.Sets.Datarow, AR.Sets.Datarow_Access);
procedure free_sql is new Ada.Unchecked_Deallocation
(String, SQL_Access);
procedure check_bound_column_access (absent : Boolean);
package Markers is new Ada.Containers.Indefinite_Hashed_Maps
(Key_Type => String,
Element_Type => Positive,
Equivalent_Keys => Same_Strings,
Hash => Ada.Strings.Hash);
function convert is new RGC.convert4str (IntType => AR.NByte1);
function convert is new RGC.convert4str (IntType => AR.NByte2);
function convert is new RGC.convert4str (IntType => AR.NByte3);
function convert is new RGC.convert4str (IntType => AR.NByte4);
function convert is new RGC.convert4str (IntType => AR.NByte8);
function convert is new RGC.convert4str (IntType => AR.Byte1);
function convert is new RGC.convert4str (IntType => AR.Byte2);
function convert is new RGC.convert4str (IntType => AR.Byte3);
function convert is new RGC.convert4str (IntType => AR.Byte4);
function convert is new RGC.convert4str (IntType => AR.Byte8);
function convert is new RGC.convert4st2 (RealType => AR.Real9);
function convert is new RGC.convert4st2 (RealType => AR.Real18);
function convert (nv : String) return AR.Textwide;
function convert (nv : String) return AR.Textsuper;
type bindrec (output_type : field_types := ft_nbyte0)
is record
bound : Boolean := False;
null_data : Boolean := False;
case output_type is
when ft_nbyte0 => a00 : AR.NByte0_Access;
v00 : AR.NByte0;
when ft_nbyte1 => a01 : AR.NByte1_Access;
v01 : AR.NByte1;
when ft_nbyte2 => a02 : AR.NByte2_Access;
v02 : AR.NByte2;
when ft_nbyte3 => a03 : AR.NByte3_Access;
v03 : AR.NByte3;
when ft_nbyte4 => a04 : AR.NByte4_Access;
v04 : AR.NByte4;
when ft_nbyte8 => a05 : AR.NByte8_Access;
v05 : AR.NByte8;
when ft_byte1 => a06 : AR.Byte1_Access;
v06 : AR.Byte1;
when ft_byte2 => a07 : AR.Byte2_Access;
v07 : AR.Byte2;
when ft_byte3 => a08 : AR.Byte3_Access;
v08 : AR.Byte3;
when ft_byte4 => a09 : AR.Byte4_Access;
v09 : AR.Byte4;
when ft_byte8 => a10 : AR.Byte8_Access;
v10 : AR.Byte8;
when ft_real9 => a11 : AR.Real9_Access;
v11 : AR.Real9;
when ft_real18 => a12 : AR.Real18_Access;
v12 : AR.Real18;
when ft_textual => a13 : AR.Str1_Access;
v13 : AR.Textual;
when ft_widetext => a14 : AR.Str2_Access;
v14 : AR.Textwide;
when ft_supertext => a15 : AR.Str4_Access;
v15 : AR.Textsuper;
when ft_timestamp => a16 : AR.Time_Access;
v16 : CAL.Time;
when ft_chain => a17 : AR.Chain_Access;
v17 : AR.Textual;
when ft_enumtype => a18 : AR.Enum_Access;
v18 : AR.Enumtype;
when ft_settype => a19 : AR.Settype_Access;
v19 : AR.Textual;
when ft_bits => a20 : AR.Bits_Access;
v20 : AR.Textual;
when ft_utf8 => a21 : AR.S_UTF8_Access;
v21 : AR.Textual;
when ft_geometry => a22 : AR.Geometry_Access;
v22 : AR.Textual;
end case;
end record;
procedure set_as_null (param : bindrec);
-- For fetch_bound
function bind_proceed (Stmt : Base_Statement; index : Positive)
return Boolean;
function bind_index (Stmt : Base_Statement; heading : String)
return Positive;
function assign_index (Stmt : Base_Statement; moniker : String)
return Positive;
procedure auto_assign (Stmt : out Base_Statement; index : Positive;
value : String);
package bind_crate is new Ada.Containers.Vectors
(Index_Type => Positive,
Element_Type => bindrec);
type Base_Statement is
abstract new Base_Pure and AIS.iStatement with record
successful_execution : Boolean := False;
result_present : Boolean := False;
rows_leftover : Boolean := False;
dialect : Driver_Type := foundation;
impacted : Affected_Rows := 0;
connection : ACB.Base_Connection_Access;
alpha_markers : Markers.Map;
headings_map : Markers.Map;
crate : bind_crate.Vector;
realmccoy : bind_crate.Vector;
end record;
end AdaBase.Statement.Base;
|
-----------------------------------------------------------------------
-- awa-users-filters -- Specific filters for authentication and key verification
-- Copyright (C) 2011, 2012, 2015, 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.Strings.Unbounded;
with Servlet.Requests;
with Servlet.Responses;
with Servlet.Filters;
with Servlet.Core;
with AWA.Applications;
package AWA.Sysadmin.Filters is
ADMIN_AUTH_BEAN : constant String := "sysadminAuth";
-- ------------------------------
-- Authentication verification filter
-- ------------------------------
-- The <b>Auth_Filter</b> verifies that the user has the permission to access
-- a given page. If the user is not logged, it tries to login automatically
-- by using some persistent cookie. When this fails, it redirects the
-- user to a login page (configured by AUTH_FILTER_REDIRECT_PARAM property).
type Auth_Filter is new Servlet.Filters.Filter with private;
-- Initialize the filter and configure the redirection URIs.
overriding
procedure Initialize (Filter : in out Auth_Filter;
Config : in Servlet.Core.Filter_Config);
-- Display or redirects the user to the login page. This procedure is called when
-- the user is not authenticated.
procedure Do_Login (Filter : in Auth_Filter;
Request : in out Servlet.Requests.Request'Class;
Response : in out Servlet.Responses.Response'Class);
-- Filter a request which contains an access key and verify that the
-- key is valid and identifies a user. Once the user is known, create
-- a session and setup the user principal.
--
-- If the access key is missing or invalid, redirect to the
-- <b>Invalid_Key_URI</b> associated with the filter.
overriding
procedure Do_Filter (Filter : in Auth_Filter;
Request : in out Servlet.Requests.Request'Class;
Response : in out Servlet.Responses.Response'Class;
Chain : in out Servlet.Core.Filter_Chain);
private
use Ada.Strings.Unbounded;
type Auth_Filter is new Servlet.Filters.Filter with record
Login_URI : Unbounded_String;
Application : AWA.Applications.Application_Access;
end record;
end AWA.Sysadmin.Filters;
|
with Ada.Calendar.Formatting;
with System.Long_Long_Integer_Types;
package body Ada.Calendar.Arithmetic is
use type System.Long_Long_Integer_Types.Long_Long_Unsigned;
subtype Long_Long_Unsigned is
System.Long_Long_Integer_Types.Long_Long_Unsigned;
procedure Addition (Left : Time; Right : Day_Count; Result : out Time);
procedure Addition (Left : Time; Right : Day_Count; Result : out Time) is
Left_Seconds : Day_Duration;
Left_Leap_Second : Boolean;
begin
Result := Left + Duration'(Duration (Right) * (24 * 60 * 60.0));
declare -- split Left
Year : Year_Number;
Month : Month_Number;
Day : Day_Number;
begin
Formatting.Split (Left,
Year => Year,
Month => Month,
Day => Day,
Seconds => Left_Seconds,
Leap_Second => Left_Leap_Second,
Time_Zone => 0);
end;
declare -- split Result
Year : Year_Number;
Month : Month_Number;
Day : Day_Number;
Seconds : Duration; -- may include a leap second
Leap_Second : Boolean;
begin
Formatting.Split (Result,
Year => Year,
Month => Month,
Day => Day,
Seconds => Seconds,
Leap_Second => Leap_Second,
Time_Zone => 0);
if Leap_Second then
Seconds := Seconds + 1.0;
end if;
if Left_Seconds - Seconds >= 12 * 60 * 60.0 then
Result := Result - Seconds - Duration'(1.0);
Formatting.Split (Result,
Year => Year,
Month => Month,
Day => Day,
Seconds => Seconds,
Leap_Second => Leap_Second,
Time_Zone => 0);
pragma Assert (Seconds = Duration'(24 * 60 * 60.0) - 1.0);
if Leap_Second then
Seconds := Seconds + 1.0;
end if;
elsif Seconds - Left_Seconds >= 12 * 60 * 60.0 then
Result := Result + (Duration'(24 * 60 * 60.0 + 1.0) - Seconds);
Formatting.Split (Result,
Year => Year,
Month => Month,
Day => Day,
Seconds => Seconds,
Leap_Second => Leap_Second,
Time_Zone => 0);
pragma Assert (Seconds = 0.0);
pragma Assert (not Leap_Second);
end if;
Result := Result + (Left_Seconds - Seconds);
end;
if Left_Leap_Second then
declare -- set if a leap second is existing in the result day
New_Result : constant Time := Result + Duration'(1.0);
Year : Year_Number;
Month : Month_Number;
Day : Day_Number;
Seconds : Day_Duration;
Leap_Second : Boolean;
begin
Formatting.Split (New_Result,
Year => Year,
Month => Month,
Day => Day,
Seconds => Seconds,
Leap_Second => Leap_Second,
Time_Zone => 0);
if Leap_Second then
pragma Assert (Seconds = Left_Seconds);
Result := New_Result;
end if;
end;
end if;
end Addition;
-- implementation
procedure Difference (
Left, Right : Time;
Days : out Day_Count;
Seconds : out Duration;
Leap_Seconds : out Leap_Seconds_Count)
is
Minus : Boolean;
L, H : Time;
L_Seconds : Duration; -- may include a leap second
H_Seconds : Duration; -- may over 24H
Truncated_L, Truncated_H : Time;
begin
if Left < Right then
Minus := True;
L := Left;
H := Right;
else
Minus := False;
L := Right;
H := Left;
end if;
declare -- split L
Year : Year_Number;
Month : Month_Number;
Day : Day_Number;
Leap_Second : Boolean;
begin
Formatting.Split (L,
Year => Year,
Month => Month,
Day => Day,
Seconds => L_Seconds,
Leap_Second => Leap_Second,
Time_Zone => 0);
Truncated_L :=
Formatting.Time_Of (
Year => Year,
Month => Month,
Day => Day,
Seconds => 0.0,
Leap_Second => False,
Time_Zone => 0);
if Leap_Second then
L_Seconds := L_Seconds + 1.0;
end if;
end;
declare -- split H
Year : Year_Number;
Month : Month_Number;
Day : Day_Number;
Seconds : Day_Duration;
Leap_Second : Boolean;
T : Time;
begin
Formatting.Split (H,
Year => Year,
Month => Month,
Day => Day,
Seconds => H_Seconds,
Leap_Second => Leap_Second,
Time_Zone => 0);
Truncated_H :=
Formatting.Time_Of (
Year => Year,
Month => Month,
Day => Day,
Seconds => 0.0,
Leap_Second => False,
Time_Zone => 0);
if Leap_Second then
H_Seconds := H_Seconds + 1.0;
end if;
if H_Seconds < L_Seconds then
T := Truncated_H;
Formatting.Split (T - Duration'(1.0),
Year => Year,
Month => Month,
Day => Day,
Seconds => Seconds,
Leap_Second => Leap_Second, -- ignored
Time_Zone => 0);
Truncated_H :=
Formatting.Time_Of (
Year => Year,
Month => Month,
Day => Day,
Seconds => 0.0,
Leap_Second => False,
Time_Zone => 0);
H_Seconds := H_Seconds + (T - Truncated_H);
end if;
end;
declare
Truncated_D : constant Duration := Truncated_H - Truncated_L;
Quotient, Remainder : Long_Long_Unsigned;
begin
System.Long_Long_Integer_Types.Divide (
Long_Long_Unsigned'Integer_Value (Truncated_D),
Long_Long_Unsigned'Integer_Value (Duration'(24 * 60 * 60.0)),
Quotient => Quotient,
Remainder => Remainder);
Days := Day_Count (Quotient);
Seconds := H_Seconds - L_Seconds;
Leap_Seconds := Integer (Remainder / 1_000_000_000);
pragma Assert (Remainder rem 1_000_000_000 = 0);
end;
if Minus then
Days := -Days;
Seconds := -Seconds;
Leap_Seconds := -Leap_Seconds;
end if;
end Difference;
function "+" (Left : Time; Right : Day_Count) return Time is
Result : Time;
begin
Addition (Left, Right, Result => Result);
return Result;
end "+";
function "+" (Left : Day_Count; Right : Time) return Time is
begin
return Right + Left;
end "+";
function "-" (Left : Time; Right : Day_Count) return Time is
begin
return Left + (-Right);
end "-";
function "-" (Left, Right : Time) return Day_Count is
Days : Day_Count;
Seconds : Duration;
Leap_Seconds : Leap_Seconds_Count;
begin
Difference (Left, Right,
Days => Days, Seconds => Seconds, Leap_Seconds => Leap_Seconds);
return Days;
end "-";
end Ada.Calendar.Arithmetic;
|
package Volatile11_Pkg is
procedure Bit_Test(Input : in Integer;
Output1 : out Boolean; Output2 : out Boolean;
Output3 : out Boolean; Output4 : out Boolean;
Output5 : out Boolean; Output6 : out Boolean;
Output7 : out Boolean; Output8 : out Boolean);
type Ptr is access all Boolean;
B : aliased Boolean := False;
function F return Ptr;
end Volatile11_Pkg;
|
package body Square_Root with SPARK_Mode is
function Sqrt (X: Float; Tolerance: Float) return Float is
A: Float := X;
begin
while abs(X - A ** 2) > X * Tolerance loop
A := (X/A + A) / 2.0;
pragma Loop_Invariant ((if X < 1.0 then (A >= X and A < 1.0)));
pragma Loop_Invariant ((if X > 1.0 then (A >= 1.0 and A < X)));
end loop;
return A;
end Sqrt;
end Square_Root;
|
package body Scheme_Test is
function Hello_Ada(Num : Int) return Int is
Len : Int;
begin
Len := Num;
Len := Len + 1;
Put_Line ("Hello Scheme, from Ada.");
Put_Line ("The number passed is: " & Num'Image);
-- Can we call Scheme directly here?
Len := Hello_Scheme("How is the weather in your interpreter?");
Put_Line("String length sent to Scheme, as computed by Scheme is: " & Len'Image);
return(Len);
end Hello_Ada;
end Scheme_Test;
|
-------------------------------------------------------------------------------
-- Copyright (c) 2016, 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 System.Machine_Code; use System.Machine_Code;
package body Timing
is
Measurement_Overhead : Cycles_Count;
function RDTSC return Cycles_Count
is
L, H : Unsigned_32;
begin
Asm ("rdtsc",
Outputs => (Unsigned_32'Asm_Output("=a", L),
Unsigned_32'Asm_Output("=d", H)),
Volatile => True);
return Shift_Left (Unsigned_64 (H), 32) or Unsigned_64 (L);
end RDTSC;
procedure Calibrate
is
T : Time;
Diff : Cycles_Count;
Min : Cycles_Count;
begin
Measurement_Overhead := 0;
Start_Measurement (T);
Min := End_Measurement (T);
for N in 1 .. 100 loop
Start_Measurement (T);
Diff := End_Measurement (T);
-- Keep the minimum
if Diff < Min then
Min := Diff;
end if;
end loop;
Measurement_Overhead := Min;
end Calibrate;
procedure Start_Measurement (T : out Time)
is
begin
T := Time (RDTSC);
end Start_Measurement;
function End_Measurement (T : in Time) return Cycles_Count
is
End_Time : Cycles_Count;
begin
End_Time := RDTSC;
return (End_Time - Cycles_Count (T)) - Measurement_Overhead;
end End_Measurement;
begin
Calibrate;
end Timing;
|
with Ada.Calendar;
package Fmt.Time_Argument is
function To_Argument (X : Ada.Calendar.Time) return Argument_Type'Class
with Inline;
function "&" (Args : Arguments; X : Ada.Calendar.Time) return Arguments
with Inline;
private
type Time_Argument_Type is new Placeholder_Argument_Type with record
Value : Ada.Calendar.Time;
end record;
overriding
function Get_Placeholder_Width (
Self : in out Time_Argument_Type;
Name : Character)
return Natural;
overriding
function Is_Valid_Placeholder (
Self : Time_Argument_Type;
Name : Character)
return Boolean;
overriding
procedure Put_Placeholder (
Self : in out Time_Argument_Type;
Name : Character;
To : in out String);
end Fmt.Time_Argument;
|
with Ada.Streams.Stream_IO.Naked;
with System.Form_Parameters;
package body Ada.Storage_Mapped_IO is
use type Streams.Stream_Element_Offset;
use type Streams.Stream_IO.File_Mode;
use type System.Address;
use type System.Native_IO.File_Mode;
function Pack_For_Map (Form : String) return Boolean;
function Pack_For_Map (Form : String) return Boolean is
Keyword_First : Positive;
Keyword_Last : Natural;
Item_First : Positive;
Item_Last : Natural;
Last : Natural;
Private_Copy : Boolean := False; -- default
begin
Last := Form'First - 1;
while Last < Form'Last loop
System.Form_Parameters.Get (
Form (Last + 1 .. Form'Last),
Keyword_First,
Keyword_Last,
Item_First,
Item_Last,
Last);
declare
Keyword : String
renames Form (Keyword_First .. Keyword_Last);
Item : String
renames Form (Item_First .. Item_Last);
begin
if Keyword = "private" then
if Item'Length > 0 and then Item (Item'First) = 'f' then
Private_Copy := False; -- false
elsif Item'Length > 0 and then Item (Item'First) = 't' then
Private_Copy := True; -- true
end if;
end if;
end;
end loop;
return Private_Copy;
end Pack_For_Map;
procedure Map (
Object : in out Non_Controlled_Mapping;
File : Streams.Naked_Stream_IO.Non_Controlled_File_Type;
Private_Copy : Boolean;
Offset : Streams.Stream_IO.Positive_Count;
Size : Streams.Stream_IO.Count);
procedure Map (
Object : in out Non_Controlled_Mapping;
File : Streams.Naked_Stream_IO.Non_Controlled_File_Type;
Private_Copy : Boolean;
Offset : Streams.Stream_IO.Positive_Count;
Size : Streams.Stream_IO.Count)
is
Mapped_Size : Streams.Stream_IO.Count;
begin
if Size = 0 then
Mapped_Size := Streams.Naked_Stream_IO.Size (File) - (Offset - 1);
else
Mapped_Size := Size;
end if;
System.Native_IO.Map (
Object.Mapping,
Streams.Naked_Stream_IO.Handle (File),
Streams.Naked_Stream_IO.Mode (File)
and System.Native_IO.Read_Write_Mask,
Private_Copy => Private_Copy,
Offset => Offset,
Size => Mapped_Size);
end Map;
procedure Map (
Object : aliased in out Non_Controlled_Mapping;
Mode : File_Mode;
Name : String;
Form : System.Native_IO.Packed_Form;
Private_Copy : Boolean;
Offset : Streams.Stream_IO.Positive_Count;
Size : Streams.Stream_IO.Count);
procedure Map (
Object : aliased in out Non_Controlled_Mapping;
Mode : File_Mode;
Name : String;
Form : System.Native_IO.Packed_Form;
Private_Copy : Boolean;
Offset : Streams.Stream_IO.Positive_Count;
Size : Streams.Stream_IO.Count) is
begin
-- open file
-- this file will be closed in Finalize even if any exception is raised
Streams.Naked_Stream_IO.Open (
Object.File,
IO_Modes.Inout_File_Mode (Mode),
Name => Name,
Form => Form);
-- map
Map (
Object,
Object.File,
Private_Copy => Private_Copy,
Offset => Offset,
Size => Size);
end Map;
procedure Unmap (
Object : in out Non_Controlled_Mapping;
Raise_On_Error : Boolean);
procedure Unmap (
Object : in out Non_Controlled_Mapping;
Raise_On_Error : Boolean) is
begin
-- unmap
System.Native_IO.Unmap (
Object.Mapping,
Raise_On_Error => Raise_On_Error);
-- close file
if Streams.Naked_Stream_IO.Is_Open (Object.File) then
Streams.Naked_Stream_IO.Close (
Object.File,
Raise_On_Error => Raise_On_Error);
end if;
end Unmap;
-- implementation
function Is_Mapped (Object : Storage_Type) return Boolean is
NC_Object : Non_Controlled_Mapping
renames Controlled.Reference (Object).all;
begin
return NC_Object.Mapping.Storage_Address /= System.Null_Address;
end Is_Mapped;
procedure Map (
Object : in out Storage_Type;
File : Streams.Stream_IO.File_Type;
Form : String; -- removed default
Offset : Streams.Stream_IO.Positive_Count := 1;
Size : Streams.Stream_IO.Count := 0)
is
pragma Check (Pre,
Check => not Is_Mapped (Object) or else raise Status_Error);
NC_Object : Non_Controlled_Mapping
renames Controlled.Reference (Object).all;
begin
Map (
NC_Object,
Streams.Stream_IO.Naked.Non_Controlled (File).all,
Private_Copy => Pack_For_Map (Form),
Offset => Offset,
Size => Size);
end Map;
procedure Map (
Object : in out Storage_Type;
File : Streams.Stream_IO.File_Type;
Private_Copy : Boolean := False;
Offset : Streams.Stream_IO.Positive_Count := 1;
Size : Streams.Stream_IO.Count := 0)
is
pragma Check (Pre,
Check => not Is_Mapped (Object) or else raise Status_Error);
NC_Object : Non_Controlled_Mapping
renames Controlled.Reference (Object).all;
begin
Map (
NC_Object,
Streams.Stream_IO.Naked.Non_Controlled (File).all,
Private_Copy => Private_Copy,
Offset => Offset,
Size => Size);
end Map;
function Map (
File : Streams.Stream_IO.File_Type;
Private_Copy : Boolean := False;
Offset : Streams.Stream_IO.Positive_Count := 1;
Size : Streams.Stream_IO.Count := 0)
return Storage_Type is
begin
return Result : Storage_Type do
Map (
Result,
File,
Private_Copy => Private_Copy,
Offset => Offset,
Size => Size);
end return;
end Map;
procedure Map (
Object : in out Storage_Type;
Mode : File_Mode := In_File;
Name : String;
Form : String;
Offset : Streams.Stream_IO.Positive_Count := 1;
Size : Streams.Stream_IO.Count := 0)
is
pragma Check (Pre,
Check => not Is_Mapped (Object) or else raise Status_Error);
NC_Object : Non_Controlled_Mapping
renames Controlled.Reference (Object).all;
begin
Map (
NC_Object,
Mode,
Name => Name,
Form => Streams.Naked_Stream_IO.Pack (Form),
Private_Copy => Pack_For_Map (Form),
Offset => Offset,
Size => Size);
end Map;
procedure Map (
Object : in out Storage_Type;
Mode : File_Mode := In_File;
Name : String;
Shared : IO_Modes.File_Shared_Spec := IO_Modes.By_Mode;
Wait : Boolean := False;
Overwrite : Boolean := True;
Private_Copy : Boolean := False;
Offset : Streams.Stream_IO.Positive_Count := 1;
Size : Streams.Stream_IO.Count := 0)
is
pragma Check (Pre,
Check => not Is_Mapped (Object) or else raise Status_Error);
NC_Object : Non_Controlled_Mapping
renames Controlled.Reference (Object).all;
begin
Map (
NC_Object,
Mode,
Name => Name,
Form => (Shared, Wait, Overwrite),
Private_Copy => Private_Copy,
Offset => Offset,
Size => Size);
end Map;
function Map (
Mode : File_Mode := In_File;
Name : String;
Shared : IO_Modes.File_Shared_Spec := IO_Modes.By_Mode;
Wait : Boolean := False;
Overwrite : Boolean := True;
Private_Copy : Boolean := False;
Offset : Streams.Stream_IO.Positive_Count := 1;
Size : Streams.Stream_IO.Count := 0)
return Storage_Type is
begin
return Result : Storage_Type do
Map (
Result,
Mode,
Name => Name,
Shared => Shared,
Wait => Wait,
Overwrite => Overwrite,
Private_Copy => Private_Copy,
Offset => Offset,
Size => Size);
end return;
end Map;
procedure Unmap (Object : in out Storage_Type) is
pragma Check (Pre,
Check => Is_Mapped (Object) or else raise Status_Error);
NC_Object : Non_Controlled_Mapping
renames Controlled.Reference (Object).all;
begin
Unmap (NC_Object, Raise_On_Error => True);
end Unmap;
function Storage_Address (
Object : Storage_Type)
return System.Address
is
pragma Check (Dynamic_Predicate,
Check => Is_Mapped (Object) or else raise Status_Error);
NC_Object : Non_Controlled_Mapping
renames Controlled.Reference (Object).all;
begin
return NC_Object.Mapping.Storage_Address;
end Storage_Address;
function Storage_Size (
Object : Storage_Type)
return System.Storage_Elements.Storage_Count
is
pragma Check (Dynamic_Predicate,
Check => Is_Mapped (Object) or else raise Status_Error);
NC_Object : Non_Controlled_Mapping
renames Controlled.Reference (Object).all;
begin
return NC_Object.Mapping.Storage_Size;
end Storage_Size;
package body Controlled is
function Reference (Object : Storage_Mapped_IO.Storage_Type)
return not null access Non_Controlled_Mapping is
begin
return Storage_Type (Object).Data'Unrestricted_Access;
end Reference;
overriding procedure Finalize (Object : in out Storage_Type) is
begin
if Object.Data.Mapping.Storage_Address /= System.Null_Address then
Unmap (Object.Data, Raise_On_Error => False);
end if;
end Finalize;
end Controlled;
end Ada.Storage_Mapped_IO;
|
package body External is
procedure SleepForSomeTime (maxSleep: Natural) is
gen: RAF.Generator;
fraction: Float;
begin
RAF.Reset(gen);
fraction := 1.0 / Float(maxSleep);
delay Duration(fraction * RAF.Random(gen));
end SleepForSomeTime;
end External;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Line_By_Line is
File : File_Type;
begin
Open (File => File,
Mode => In_File,
Name => "line_by_line.adb");
While not End_Of_File (File) Loop
Put_Line (Get_Line (File));
end loop;
Close (File);
end Line_By_Line;
|
-- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
package body Zstandard.Functions.Streaming_Decompression is
------------------
-- Initialize --
------------------
procedure Initialize
(mechanism : out Decompressor;
input_stream : not null access STR.Root_Stream_Type'Class)
is
use type Thin.ZSTD_DStream_ptr;
initResult : Thin.IC.size_t;
begin
mechanism.source_stream := input_stream;
mechanism.zstd_stream := Thin.ZSTD_createDStream;
if mechanism.zstd_stream = Thin.Null_DStream_pointer then
raise streaming_decompression_initialization with "ZSTD_createDStream failure";
end if;
initResult := Thin.ZSTD_initDStream (zds => mechanism.zstd_stream);
if Natural (Thin.ZSTD_isError (code => initResult)) /= 0 then
raise streaming_decompression_initialization with "ZSTD_initDStream failure";
end if;
end Initialize;
-----------------------
-- Decompress_Data --
-----------------------
procedure Decompress_Data
(mechanism : Decompressor;
complete : out Boolean;
output_data : out Output_Data_Container;
last_element : out Natural)
is
use type Thin.ZSTD_DStream_ptr;
sin_last : STR.Stream_Element_Offset := STR.Stream_Element_Offset (Recommended_Chunk_Size);
Last : STR.Stream_Element_Offset;
data_in : aliased Thin.IC.char_array := (1 .. Recommended_Chunk_Size => Thin.IC.nul);
data_out : aliased Thin.IC.char_array := (1 .. Output_container_size => Thin.IC.nul);
data_sin : STR.Stream_Element_Array (1 .. sin_last);
index : Thin.IC.size_t := data_in'First;
size_hint : Thin.IC.size_t;
inbuffer : aliased Thin.ZSTD_inBuffer_s :=
(src => Thin.ICS.To_Chars_Ptr (data_in'Unchecked_Access),
size => Recommended_Chunk_Size,
pos => 0);
outbuffer : aliased Thin.ZSTD_outBuffer_s :=
(dst => Thin.ICS.To_Chars_Ptr (data_out'Unchecked_Access),
size => Output_container_size,
pos => 0);
begin
if mechanism.zstd_stream = Thin.Null_DStream_pointer then
raise streaming_decompression_error with "Run initialize procedure first";
end if;
mechanism.source_stream.Read (Item => data_sin, Last => Last);
if Natural (Last) = 0 then
last_element := 0;
complete := True;
return;
end if;
data_in := convert_to_char_array (data_sin (1 .. Last), Recommended_Chunk_Size);
complete := (Natural (Last) /= Natural (Recommended_Chunk_Size));
size_hint := Thin.ZSTD_decompressStream (zds => mechanism.zstd_stream,
output => outbuffer'Unchecked_Access,
input => inbuffer'Unchecked_Access);
last_element := Natural (outbuffer.pos);
output_data (1 .. STR.Stream_Element_Offset (last_element)) :=
convert_to_stream_array (data_out, outbuffer.pos);
end Decompress_Data;
-------------------------------
-- convert_to_stream_array --
-------------------------------
function convert_to_stream_array
(char_data : Thin.IC.char_array;
number_characters : Thin.IC.size_t) return STR.Stream_Element_Array
is
product : STR.Stream_Element_Array (1 .. STR.Stream_Element_Offset (number_characters));
dondx : Thin.IC.size_t;
begin
for z in product'Range loop
dondx := Thin.IC.size_t (z);
product (z) := STR.Stream_Element (Character'Pos (Thin.IC.To_Ada (char_data (dondx))));
end loop;
return product;
end convert_to_stream_array;
-----------------------------
-- convert_to_char_array --
-----------------------------
function convert_to_char_array
(stream_data : STR.Stream_Element_Array;
output_array_size : Thin.IC.size_t) return Thin.IC.char_array
is
use type Thin.IC.size_t;
product : Thin.IC.char_array := (1 .. output_array_size => Thin.IC.nul);
dondx : Thin.IC.size_t := 1;
begin
for z in stream_data'Range loop
product (dondx) := Thin.IC.To_C (Character'Val (stream_data (z)));
dondx := dondx + 1;
end loop;
return product;
end convert_to_char_array;
end Zstandard.Functions.Streaming_Decompression;
|
with Interfaces.C;
with termbox_h; use termbox_h;
package Termbox is
subtype Termbox_Constant is Integer;
subtype Return_Value is Integer;
type Cell is record
ch: aliased Character;
fg: aliased Integer;
bg: aliased Integer;
end record;
type Event is record
c_type : aliased Integer;
c_mod : aliased Integer;
key : aliased Integer;
ch : aliased Integer;
w : aliased Integer;
h : aliased Integer;
x : aliased Integer;
y : aliased Integer;
end record;
BLACK : Termbox_Constant := Integer(TB_BLACK);
RED : Termbox_Constant := Integer(TB_RED);
GREEN : Termbox_Constant := Integer(TB_GREEN);
YELLOW : Termbox_Constant := Integer(TB_YELLOW);
BLUE : Termbox_Constant := Integer(TB_BLUE);
MAGENTA : Termbox_Constant := Integer(TB_MAGENTA);
CYAN : Termbox_Constant := Integer(TB_CYAN);
WHITE : Termbox_Constant := Integer(TB_WHITE);
KEY_ESC: Termbox_Constant := Integer(TB_KEY_ESC);
INPUT_CURRENT: Termbox_Constant := Integer(TB_INPUT_CURRENT);
INPUT_ESC: Termbox_Constant := Integer(TB_INPUT_ESC);
INPUT_ALT: Termbox_Constant := Integer(TB_INPUT_ALT);
INPUT_MOUSE: Termbox_Constant := Integer(TB_INPUT_MOUSE);
OUTPUT_CURRENT: Termbox_Constant := Integer(TB_OUTPUT_CURRENT);
OUTPUT_NORMAL: Termbox_Constant := Integer(TB_OUTPUT_NORMAL);
OUTPUT_256: Termbox_Constant := Integer(TB_OUTPUT_256);
OUTPUT_216: Termbox_Constant := Integer(TB_OUTPUT_216);
OUTPUT_GRAYSCALE: Termbox_Constant := Integer(TB_OUTPUT_GRAYSCALE);
function Init return Return_Value;
procedure Shutdown;
function Width return Integer;
function Height return Integer;
procedure Clear;
procedure Set_Clear_Attributes(fg: Integer; bg:Integer);
procedure Present;
procedure Set_Cursor(cx: Integer; cy: Integer);
procedure Put_Cell(x: Integer; y: Integer; pcell: access Cell);
procedure Change_Cell(x: Integer; y: Integer; ch: Character; fg: Integer; bg: Integer);
function Select_Input_Mode(mode: Integer) return Return_Value;
function Select_Output_Mode(mode: Integer) return Return_Value;
function Peek_Event(Evt: access Event; timeout: Interfaces.C.int) return Return_Value;
function Poll_Event(Evt: access Event) return Return_Value;
end Termbox;
|
-- Auto_Counters_Suite.Unique_Ptrs_Tests
-- Unit tests for Auto_Counters Unique_Ptrs package
-- Copyright (c) 2016, James Humphry - see LICENSE file for details
with AUnit.Assertions;
with Unique_Ptrs;
package body Auto_Counters_Suite.Unique_Ptrs_Tests is
use AUnit.Assertions;
Resources_Released : Natural := 0;
procedure Deletion_Recorder (X : in out String) is
pragma Unreferenced (X);
begin
Resources_Released := Resources_Released + 1;
end Deletion_Recorder;
package String_Unique_Ptrs is new Unique_Ptrs(T => String,
Delete => Deletion_Recorder);
use String_Unique_Ptrs;
--------------------
-- Register_Tests --
--------------------
procedure Register_Tests (T: in out Unique_Ptrs_Test) is
use AUnit.Test_Cases.Registration;
begin
Register_Routine (T, Check_Unique_Ptrs'Access,
"Check Unique_Ptr");
Register_Routine (T, Check_Unique_Const_Ptrs'Access,
"Check Unique_Const_Ptr");
end Register_Tests;
----------
-- Name --
----------
function Name (T : Unique_Ptrs_Test) return Test_String is
pragma Unreferenced (T);
begin
return Format ("Tests of Unique_Ptrs");
end Name;
------------
-- Set_Up --
------------
procedure Set_Up (T : in out Unique_Ptrs_Test) is
begin
null;
end Set_Up;
-----------------------
-- Check_Unique_Ptrs --
-----------------------
procedure Check_Unique_Ptrs (T : in out Test_Cases.Test_Case'Class) is
pragma Unreferenced(T);
UP1 : Unique_Ptr := Make_Unique_Ptr(new String'("Hello, World!"));
procedure Make_UP_from_Local is
S : aliased String := "Test";
UP2 : Unique_Ptr(Element => S'Access);
pragma Unreferenced (UP2);
begin
null;
end Make_UP_from_Local;
Caught_Make_UP_from_Local : Boolean := False;
begin
Assert (UP1 = "Hello, World!",
"Initialized Unique_Ptr not working");
UP1(6):= ':';
Assert (UP1 = "Hello: World!",
"Writing via a Unique_Ptr is not working");
UP1.Get(6):= ',';
Assert (UP1 = "Hello, World!",
"Writing via Unique_Ptr.Get is not working");
Resources_Released := 0;
declare
UP3 : Unique_Ptr := Make_Unique_Ptr(new String'("Goodbye, World!"));
pragma Unreferenced (UP3);
begin
null;
end;
Assert (Resources_Released = 1,
"Unique_Ptr did not delete contents when destroyed");
begin
Make_UP_from_Local;
exception
when Unique_Ptr_Error =>
Caught_Make_UP_from_Local := True;
end;
Assert(Caught_Make_UP_from_Local,
"Failed to identify Unique_Ptr being set to a local");
end Check_Unique_Ptrs;
-----------------------------
-- Check_Unique_Const_Ptrs --
-----------------------------
procedure Check_Unique_Const_Ptrs (T : in out Test_Cases.Test_Case'Class) is
pragma Unreferenced(T);
UCP1 : Unique_Const_Ptr
:= Make_Unique_Const_Ptr(new String'("Hello, World!"));
procedure Make_UCP_from_Local is
S : aliased String := "Test";
UP2 : Unique_Const_Ptr(Element => S'Access);
pragma Unreferenced (UP2);
begin
null;
end Make_UCP_from_Local;
Caught_Make_UCP_from_Local : Boolean := False;
begin
Assert (UCP1 = "Hello, World!",
"Initialized Unique_Const_Ptr not working");
Assert (UCP1.Get.all = "Hello, World!",
"Access via Unique_Const_Ptr.Get not working");
Resources_Released := 0;
declare
UCP3 : Unique_Const_Ptr
:= Make_Unique_Const_Ptr(new String'("Goodbye, World!"));
pragma Unreferenced (UCP3);
begin
null;
end;
Assert (Resources_Released = 1,
"Unique_Const_Ptr did not delete contents when destroyed");
begin
Make_UCP_from_Local;
exception
when Unique_Ptr_Error =>
Caught_Make_UCP_from_Local := True;
end;
Assert(Caught_Make_UCP_from_Local,
"Failed to identify Unique_Const_Ptr being set to a local");
end Check_Unique_Const_Ptrs;
end Auto_Counters_Suite.Unique_Ptrs_Tests;
|
-----------------------------------------------------------------------
-- ado-sql -- Basic SQL Generation
-- Copyright (C) 2010, 2011, 2012, 2015, 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.
-----------------------------------------------------------------------
-- Utilities for creating SQL queries and statements.
package body ADO.SQL is
-- --------------------
-- Buffer
-- --------------------
-- --------------------
-- Clear the SQL buffer.
-- --------------------
procedure Clear (Target : in out Buffer) is
begin
Target.Buf := To_Unbounded_String ("");
end Clear;
-- --------------------
-- Append an SQL extract into the buffer.
-- --------------------
procedure Append (Target : in out Buffer;
SQL : in String) is
begin
Append (Target.Buf, SQL);
end Append;
-- --------------------
-- Append a name in the buffer and escape that
-- name if this is a reserved keyword.
-- --------------------
procedure Append_Name (Target : in out Buffer;
Name : in String) is
use type ADO.Dialects.Dialect_Access;
Dialect : constant ADO.Dialects.Dialect_Access := Target.Get_Dialect;
begin
if Dialect /= null and then Dialect.Is_Reserved (Name) then
declare
Quote : constant Character := Dialect.Get_Identifier_Quote;
begin
Append (Target.Buf, Quote);
Append (Target.Buf, Name);
Append (Target.Buf, Quote);
end;
else
Append (Target.Buf, Name);
end if;
end Append_Name;
-- --------------------
-- Append a string value in the buffer and
-- escape any special character if necessary.
-- --------------------
procedure Append_Value (Target : in out Buffer;
Value : in String) is
begin
Append (Target.Buf, Value);
end Append_Value;
-- --------------------
-- Append a string value in the buffer and
-- escape any special character if necessary.
-- --------------------
procedure Append_Value (Target : in out Buffer;
Value : in Unbounded_String) is
begin
Append (Target.Buf, Value);
end Append_Value;
-- --------------------
-- Append the integer value in the buffer.
-- --------------------
procedure Append_Value (Target : in out Buffer;
Value : in Long_Integer) is
S : constant String := Long_Integer'Image (Value);
begin
Append (Target.Buf, S (S'First + 1 .. S'Last));
end Append_Value;
-- --------------------
-- Append the integer value in the buffer.
-- --------------------
procedure Append_Value (Target : in out Buffer;
Value : in Integer) is
S : constant String := Integer'Image (Value);
begin
Append (Target.Buf, S (S'First + 1 .. S'Last));
end Append_Value;
-- --------------------
-- Append the identifier value in the buffer.
-- --------------------
procedure Append_Value (Target : in out Buffer;
Value : in Identifier) is
S : constant String := Identifier'Image (Value);
begin
Append (Target.Buf, S (S'First + 1 .. S'Last));
end Append_Value;
-- --------------------
-- Get the SQL string that was accumulated in the buffer.
-- --------------------
function To_String (From : in Buffer) return String is
begin
return To_String (From.Buf);
end To_String;
-- --------------------
-- Clear the query object.
-- --------------------
overriding
procedure Clear (Target : in out Query) is
begin
ADO.Parameters.List (Target).Clear;
Target.Join.Clear;
Target.Filter.Clear;
Target.SQL.Clear;
end Clear;
-- --------------------
-- Set the SQL dialect description object.
-- --------------------
procedure Set_Dialect (Target : in out Query;
D : in ADO.Dialects.Dialect_Access) is
begin
ADO.Parameters.Abstract_List (Target).Set_Dialect (D);
Set_Dialect (Target.SQL, D);
Set_Dialect (Target.Filter, D);
Set_Dialect (Target.Join, D);
end Set_Dialect;
procedure Set_Filter (Target : in out Query;
Filter : in String) is
begin
Target.Filter.Buf := To_Unbounded_String (Filter);
end Set_Filter;
function Get_Filter (Source : in Query) return String is
begin
if Source.Filter.Buf = Null_Unbounded_String then
return "";
else
return To_String (Source.Filter.Buf);
end if;
end Get_Filter;
function Has_Filter (Source : in Query) return Boolean is
begin
return Source.Filter.Buf /= Null_Unbounded_String
and Length (Source.Filter.Buf) > 0;
end Has_Filter;
-- --------------------
-- Set the join condition.
-- --------------------
procedure Set_Join (Target : in out Query;
Join : in String) is
begin
Target.Join.Buf := To_Unbounded_String (Join);
end Set_Join;
-- --------------------
-- Returns true if there is a join condition
-- --------------------
function Has_Join (Source : in Query) return Boolean is
begin
return Source.Join.Buf /= Null_Unbounded_String
and Length (Source.Join.Buf) > 0;
end Has_Join;
-- --------------------
-- Get the join condition
-- --------------------
function Get_Join (Source : in Query) return String is
begin
if Source.Join.Buf = Null_Unbounded_String then
return "";
else
return To_String (Source.Join.Buf);
end if;
end Get_Join;
-- --------------------
-- Set the parameters from another parameter list.
-- If the parameter list is a query object, also copy the filter part.
-- --------------------
procedure Set_Parameters (Params : in out Query;
From : in ADO.Parameters.Abstract_List'Class) is
begin
ADO.Parameters.List (Params).Set_Parameters (From);
if From in Query'Class then
declare
L : constant Query'Class := Query'Class (From);
begin
Params.Filter := L.Filter;
Params.Join := L.Join;
end;
end if;
end Set_Parameters;
-- --------------------
-- Expand the parameters into the query and return the expanded SQL query.
-- --------------------
function Expand (Source : in Query) return String is
begin
return ADO.Parameters.Abstract_List (Source).Expand (To_String (Source.SQL.Buf));
end Expand;
procedure Add_Field (Update : in out Update_Query'Class;
Name : in String) is
begin
Update.Pos := Update.Pos + 1;
if Update.Pos > 1 then
Append (Target => Update.Set_Fields, SQL => ",");
Append (Target => Update.Fields, SQL => ",");
end if;
Append_Name (Target => Update.Set_Fields, Name => Name);
if Update.Is_Update_Stmt then
Append (Target => Update.Set_Fields, SQL => " = ?");
end if;
Append (Target => Update.Fields, SQL => "?");
end Add_Field;
-- ------------------------------
-- Set the SQL dialect description object.
-- ------------------------------
procedure Set_Dialect (Target : in out Update_Query;
D : in ADO.Dialects.Dialect_Access) is
begin
Target.Set_Fields.Set_Dialect (D);
Target.Fields.Set_Dialect (D);
Query (Target).Set_Dialect (D);
end Set_Dialect;
-- ------------------------------
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
-- ------------------------------
procedure Save_Field (Update : in out Update_Query;
Name : in String;
Value : in Boolean) is
begin
Update.Add_Field (Name => Name);
Update_Query'Class (Update).Bind_Param (Position => Update.Pos, Value => Value);
end Save_Field;
-- --------------------
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
-- --------------------
procedure Save_Field (Update : in out Update_Query;
Name : in String;
Value : in Integer) is
begin
Update.Add_Field (Name => Name);
Update_Query'Class (Update).Bind_Param (Position => Update.Pos, Value => Value);
end Save_Field;
-- --------------------
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
-- --------------------
procedure Save_Field (Update : in out Update_Query;
Name : in String;
Value : in Long_Long_Integer) is
begin
Update.Add_Field (Name => Name);
Update_Query'Class (Update).Bind_Param (Position => Update.Pos, Value => Value);
end Save_Field;
-- --------------------
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
-- --------------------
procedure Save_Field (Update : in out Update_Query;
Name : in String;
Value : in Long_Float) is
begin
Update.Add_Field (Name => Name);
Update_Query'Class (Update).Bind_Param (Position => Update.Pos, Value => Value);
end Save_Field;
-- --------------------
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
-- --------------------
procedure Save_Field (Update : in out Update_Query;
Name : in String;
Value : in Identifier) is
begin
Update.Add_Field (Name => Name);
Update_Query'Class (Update).Add_Param (Value => Value);
end Save_Field;
-- --------------------
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
-- --------------------
procedure Save_Field (Update : in out Update_Query;
Name : in String;
Value : in Entity_Type) is
begin
Update.Add_Field (Name => Name);
Update_Query'Class (Update).Add_Param (Value => Integer (Value));
end Save_Field;
-- --------------------
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
-- --------------------
procedure Save_Field (Update : in out Update_Query;
Name : in String;
Value : in Ada.Calendar.Time) is
begin
Update.Add_Field (Name => Name);
Update_Query'Class (Update).Add_Param (Value => Value);
end Save_Field;
-- --------------------
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
-- --------------------
procedure Save_Field (Update : in out Update_Query;
Name : in String;
Value : in String) is
begin
Update.Add_Field (Name => Name);
Update_Query'Class (Update).Bind_Param (Position => Update.Pos, Value => Value);
end Save_Field;
-- --------------------
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
-- --------------------
procedure Save_Field (Update : in out Update_Query;
Name : in String;
Value : in Unbounded_String) is
begin
Update.Add_Field (Name => Name);
Update_Query'Class (Update).Bind_Param (Position => Update.Pos, Value => Value);
end Save_Field;
-- ------------------------------
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to the <b>Value</b>.
-- ------------------------------
procedure Save_Field (Update : in out Update_Query;
Name : in String;
Value : in ADO.Blob_Ref) is
begin
Update.Add_Field (Name => Name);
Update_Query'Class (Update).Bind_Param (Position => Update.Pos, Value => Value);
end Save_Field;
-- ------------------------------
-- Prepare the update/insert query to save the table field
-- identified by <b>Name</b> and set it to NULL.
-- ------------------------------
procedure Save_Null_Field (Update : in out Update_Query;
Name : in String) is
begin
Update.Add_Field (Name => Name);
Update_Query'Class (Update).Bind_Null_Param (Position => Update.Pos);
end Save_Null_Field;
-- --------------------
-- Check if the update/insert query has some fields to update.
-- --------------------
function Has_Save_Fields (Update : in Update_Query) return Boolean is
begin
return Update.Pos > 0;
end Has_Save_Fields;
procedure Set_Insert_Mode (Update : in out Update_Query) is
begin
Update.Is_Update_Stmt := False;
end Set_Insert_Mode;
procedure Append_Fields (Update : in out Update_Query;
Mode : in Boolean := False) is
begin
if Mode then
Append (Target => Update.SQL, SQL => To_String (Update.Fields.Buf));
else
Append (Target => Update.SQL, SQL => To_String (Update.Set_Fields.Buf));
end if;
end Append_Fields;
end ADO.SQL;
|
with Lv.Color;
with Lv.Style;
package Lv.Objx.Gauge is
subtype Instance is Obj_T;
-- Create a gauge objects
-- @param par pointer to an object, it will be the parent of the new gauge
-- @param copy pointer to a gauge object, if not NULL then the new object will be copied from it
-- @return pointer to the created gauge
function Create (Parent : Obj_T; Copy : Instance) return Instance;
----------------------
-- Setter functions --
----------------------
-- Set the number of needles
-- @param self pointer to gauge object
-- @param needle_cnt new count of needles
-- @param colors an array of colors for needles (with 'num' elements)
procedure Set_Needle_Count
(Self : Instance;
Needle_Cnt : Uint8_T;
Colors : access constant Lv.Color.Color_T);
-- Set the value of a needle
-- @param self pointer to a gauge
-- @param needle_id the id of the needle
-- @param value the new value
procedure Set_Value (Self : Instance; Needle_Id : Uint8_T; Value : Int16_T);
-- Set minimum and the maximum values of a gauge
-- @param self pointer to he gauge object
-- @param min minimum value
-- @param max maximum value
procedure Set_Range (Self : Instance; Min : Int16_T; Max : Int16_T);
-- Set a critical value on the scale. After this value 'line.color' scale lines will be drawn
-- @param self pointer to a gauge object
-- @param value the critical value
procedure Set_Critical_Value (Self : Instance; Value : Int16_T);
-- Set the scale settings of a gauge
-- @param self pointer to a gauge object
-- @param angle angle of the scale (0..360)
-- @param line_cnt count of scale lines.
-- The get a given "subdivision" lines between label, `line_cnt` = (sub_div + 1) -- (label_cnt - 1) + 1
-- @param label_cnt count of scale labels.
procedure Set_Scale
(Self : Instance;
Angle : Uint16_T;
Line_Cnt : Uint8_T;
Label_Cnt : Uint8_T);
-- Set the styles of a gauge
-- @param self pointer to a gauge object
-- @param bg set the style of the gauge
procedure Set_Style (Self : Instance; Bg : access Lv.Style.Style);
----------------------
-- Getter functions --
----------------------
-- Get the value of a needle
-- @param self pointer to gauge object
-- @param needle the id of the needle
-- @return the value of the needle [min,max]
function Value (Self : Instance; Needle : Uint8_T) return Int16_T;
-- Get the count of needles on a gauge
-- @param self pointer to gauge
-- @return count of needles
function Needle_Count (Self : Instance) return Uint8_T;
-- Get the minimum value of a gauge
-- @param self pointer to a gauge object
-- @return the minimum value of the gauge
function Min_Value (Self : Instance) return Int16_T;
-- Get the maximum value of a gauge
-- @param self pointer to a gauge object
-- @return the maximum value of the gauge
function Max_Value (Self : Instance) return Int16_T;
-- Get a critical value on the scale.
-- @param self pointer to a gauge object
-- @return the critical value
function Critical_Value (Self : Instance) return Int16_T;
-- Set the number of labels (and the thicker lines too)
-- @param self pointer to a gauge object
-- @return count of labels
function Label_Count (Self : Instance) return Uint8_T;
-- Get the scale number of a gauge
-- @param self pointer to a gauge object
-- @return number of the scale units
function Line_Count (Self : Instance) return Uint8_T;
-- Get the scale angle of a gauge
-- @param self pointer to a gauge object
-- @return angle of the scale
function Scale_Angle (Self : Instance) return Uint16_T;
-- Get the style of a gauge
-- @param self pointer to a gauge object
-- @return pointer to the gauge's style
function Style (Self : Instance) return access Lv.Style.Style;
-------------
-- Imports --
-------------
pragma Import (C, Create, "lv_gauge_create");
pragma Import (C, Set_Needle_Count, "lv_gauge_set_needle_count");
pragma Import (C, Set_Value, "lv_gauge_set_value");
pragma Import (C, Set_Range, "lv_gauge_set_range_inline");
pragma Import (C, Set_Critical_Value, "lv_gauge_set_critical_value_inline");
pragma Import (C, Set_Scale, "lv_gauge_set_scale");
pragma Import (C, Set_Style, "lv_gauge_set_style_inline");
pragma Import (C, Value, "lv_gauge_get_value");
pragma Import (C, Needle_Count, "lv_gauge_get_needle_count");
pragma Import (C, Min_Value, "lv_gauge_get_min_value_inline");
pragma Import (C, Max_Value, "lv_gauge_get_max_value_inline");
pragma Import (C, Critical_Value, "lv_gauge_get_critical_value_inline");
pragma Import (C, Label_Count, "lv_gauge_get_label_count");
pragma Import (C, Line_Count, "lv_gauge_get_line_count_inline");
pragma Import (C, Scale_Angle, "lv_gauge_get_scale_angle_inline");
pragma Import (C, Style, "lv_gauge_get_style_inline");
end Lv.Objx.Gauge;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Adventofcode.Day_16.Main is
begin
Put_Line ("Day-16");
end Adventofcode.Day_16.Main;
|
--------------------------------------------------------------------------------
-- Copyright (C) 2020 by Heisenbug Ltd. (gh+owm@heisenbug.eu)
--
-- This work is free. You can redistribute it and/or modify it under the
-- terms of the Do What The Fuck You Want To Public License, Version 2,
-- as published by Sam Hocevar. See the LICENSE file for more details.
--------------------------------------------------------------------------------
pragma License (Unrestricted);
package Types with
Pure => True,
Remote_Types => True
is
type Scalar is delta 1.0 / 2 ** 32 range -2.0 ** 15 .. 2.0 ** 15
with Small => 1.0 / 2 ** 32;
--% Fixed point type all other types are derived from.
type Degree is new Scalar range -180.0 .. 180.0;
--% Type representing degrees.
--% unit: °
subtype Latitude is Types.Degree range -90.0 .. 90.0;
--% Type representing a latitude.
--% 90°S .. 90°N
subtype Longitude is Types.Degree range -180.0 .. 180.0;
--% Type representing a longitude.
--% 180°W .. 180°E
type Humidity is new Scalar range 0.0 .. 100.0;
--% Type representing humidity.
--% unit: %
type Pressure is new Scalar range 0.0 .. 2048.0;
--% Type representing (atmospheric) pressure.
--% unit: hPa
--
-- Temperature requires a bit of attention due to the different scales used.
--
Zero_Celsius : constant Scalar :=
273.149_999_999_906_867_742_538_452_148_437_500;
--% Physical constant denoting the different scales of Kelvin and Celsius.
-- (Fixed point value closest to 273.15).
-- Supported range of temperature measurement, based on their respective
-- lowest points.
-- The temperature can be used in different contexts, so we need a rather
-- large range. For weather data we should at least support the
-- temperature range found on Earth, this is roughly -90.0 °C to 56.0 °C for
-- the air temperature, but ground temperatures of 94 °C have been recorded.
-- Hence, to be on the safe side, let's support -150.0 to +150.0 °C.
Celsius_First : constant Scalar := -150.0;
--% Minimum temperature measurement supported (in degree Celsius).
Celsius_Last : constant Scalar := 150.0;
--% Maximum temperature measurement supported (in degree Celsius).
type Celsius is new Scalar range Celsius_First .. Celsius_Last;
--% Supported temperature measurement range in degree Celsius (-150 °C to
--% 150 °C).
Kelvin_First : constant Scalar := Zero_Celsius + Celsius_First;
--% Minimum temperature measurement supported (in Kelvin).
Kelvin_Last : constant Scalar := Zero_Celsius + Celsius_Last;
--% Maximum temperature measurement supported (in Kelvin).
type Kelvin is new Scalar range Kelvin_First .. Kelvin_Last;
--% Supported temperature measurement range in Kelvin.
--% Same scale as Celsius, but in Kelvin, i.e. 123.15 .. 423.15.
-----------------------------------------------------------------------------
-- To_Celsius
-----------------------------------------------------------------------------
function To_Celsius (K : in Kelvin) return Celsius with
Inline => True;
--% Converts a temperature from Kelvin to degree Celsius.
--
--% @param K
--% The value to be converted from Kelvin to degree Celsius.
-----------------------------------------------------------------------------
-- To_Kelvin
-----------------------------------------------------------------------------
function To_Kelvin (C : in Celsius) return Kelvin with
Inline => True;
--% Converts a temperature from degree Celsius to Kelvin.
--
--% @param C
--% The value to be converted from degree Celsius to Kelvin.
private
-----------------------------------------------------------------------------
-- To_Celsius
-----------------------------------------------------------------------------
function To_Celsius (K : in Kelvin) return Celsius is
(Celsius (Scalar (K) - Zero_Celsius));
-----------------------------------------------------------------------------
-- To_Kelvin
-----------------------------------------------------------------------------
function To_Kelvin (C : in Celsius) return Kelvin is
(Kelvin (Scalar (C) + Zero_Celsius));
end Types;
|
-- This file is generated by SWIG. Please do *not* modify by hand.
--
with Interfaces.C;
package bullet_c.Pointers is
-- Shape_Pointer
--
type Shape_Pointer is access all bullet_c.Shape;
-- Shape_Pointers
--
type Shape_Pointers is
array
(Interfaces.C
.size_t range <>) of aliased bullet_c.Pointers.Shape_Pointer;
-- Object_Pointer
--
type Object_Pointer is access all bullet_c.Object;
-- Object_Pointers
--
type Object_Pointers is
array
(Interfaces.C
.size_t range <>) of aliased bullet_c.Pointers.Object_Pointer;
-- Joint_Pointer
--
type Joint_Pointer is access all bullet_c.Joint;
-- Joint_Pointers
--
type Joint_Pointers is
array
(Interfaces.C
.size_t range <>) of aliased bullet_c.Pointers.Joint_Pointer;
-- Space_Pointer
--
type Space_Pointer is access all bullet_c.Space;
-- Space_Pointers
--
type Space_Pointers is
array
(Interfaces.C
.size_t range <>) of aliased bullet_c.Pointers.Space_Pointer;
end bullet_c.Pointers;
|
package Pack5 is
type Small is range -32 .. 31;
type Arr is array (Integer range <>) of Small;
pragma Pack (Arr);
type Rec is record
Y: Arr (1 .. 10);
end record;
pragma Pack (Rec);
end Pack5;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- A D A . W I D E _ C H A R A C T E R S . H A N D L I N G --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
package Ada.Wide_Characters.Handling is
pragma Pure;
function Character_Set_Version return String;
pragma Inline (Character_Set_Version);
-- Returns an implementation-defined identifier that identifies the version
-- of the character set standard that is used for categorizing characters
-- by the implementation. For GNAT this is "Unicode v.v".
function Is_Control (Item : Wide_Character) return Boolean;
pragma Inline (Is_Control);
-- Returns True if the Wide_Character designated by Item is categorized as
-- other_control, otherwise returns False.
function Is_Letter (Item : Wide_Character) return Boolean;
pragma Inline (Is_Letter);
-- Returns True if the Wide_Character designated by Item is categorized as
-- letter_uppercase, letter_lowercase, letter_titlecase, letter_modifier,
-- letter_other, or number_letter. Otherwise returns False.
function Is_Lower (Item : Wide_Character) return Boolean;
pragma Inline (Is_Lower);
-- Returns True if the Wide_Character designated by Item is categorized as
-- letter_lowercase, otherwise returns False.
function Is_Upper (Item : Wide_Character) return Boolean;
pragma Inline (Is_Upper);
-- Returns True if the Wide_Character designated by Item is categorized as
-- letter_uppercase, otherwise returns False.
function Is_Basic (Item : Wide_Character) return Boolean;
pragma Inline (Is_Basic);
-- Returns True if the Wide_Character designated by Item has no
-- Decomposition Mapping in the code charts of ISO/IEC 10646:2017,
-- otherwise returns False.
function Is_Digit (Item : Wide_Character) return Boolean;
pragma Inline (Is_Digit);
-- Returns True if the Wide_Character designated by Item is categorized as
-- number_decimal, otherwise returns False.
function Is_Decimal_Digit (Item : Wide_Character) return Boolean
renames Is_Digit;
function Is_Hexadecimal_Digit (Item : Wide_Character) return Boolean;
-- Returns True if the Wide_Character designated by Item is categorized as
-- number_decimal, or is in the range 'A' .. 'F' or 'a' .. 'f', otherwise
-- returns False.
function Is_Alphanumeric (Item : Wide_Character) return Boolean;
pragma Inline (Is_Alphanumeric);
-- Returns True if the Wide_Character designated by Item is categorized as
-- letter_uppercase, letter_lowercase, letter_titlecase, letter_modifier,
-- letter_other, number_letter, or number_decimal; otherwise returns False.
function Is_Special (Item : Wide_Character) return Boolean;
pragma Inline (Is_Special);
-- Returns True if the Wide_Character designated by Item is categorized
-- as graphic_character, but not categorized as letter_uppercase,
-- letter_lowercase, letter_titlecase, letter_modifier, letter_other,
-- number_letter, or number_decimal. Otherwise returns False.
function Is_Line_Terminator (Item : Wide_Character) return Boolean;
pragma Inline (Is_Line_Terminator);
-- Returns True if the Wide_Character designated by Item is categorized as
-- separator_line or separator_paragraph, or if Item is a conventional line
-- terminator character (CR, LF, VT, or FF). Otherwise returns False.
function Is_Mark (Item : Wide_Character) return Boolean;
pragma Inline (Is_Mark);
-- Returns True if the Wide_Character designated by Item is categorized as
-- mark_non_spacing or mark_spacing_combining, otherwise returns False.
function Is_Other_Format (Item : Wide_Character) return Boolean;
pragma Inline (Is_Other_Format);
-- Returns True if the Wide_Character designated by Item is categorized as
-- other_format, otherwise returns False.
function Is_Punctuation_Connector (Item : Wide_Character) return Boolean;
pragma Inline (Is_Punctuation_Connector);
-- Returns True if the Wide_Character designated by Item is categorized as
-- punctuation_connector, otherwise returns False.
function Is_Space (Item : Wide_Character) return Boolean;
pragma Inline (Is_Space);
-- Returns True if the Wide_Character designated by Item is categorized as
-- separator_space, otherwise returns False.
function Is_NFKC (Item : Wide_Character) return Boolean;
pragma Inline (Is_NFKC);
-- Returns True if the Wide_Character designated by Item could be present
-- in a string normalized to Normalization Form KC (as defined by Clause
-- 21 of ISO/IEC 10646:2017), otherwise returns False.
function Is_Graphic (Item : Wide_Character) return Boolean;
pragma Inline (Is_Graphic);
-- Returns True if the Wide_Character designated by Item is categorized as
-- graphic_character, otherwise returns False.
function To_Lower (Item : Wide_Character) return Wide_Character;
pragma Inline (To_Lower);
-- Returns the Simple Lowercase Mapping of the Wide_Character designated by
-- Item. If the Simple Lowercase Mapping does not exist for the
-- Wide_Character designated by Item, then the value of Item is returned.
function To_Lower (Item : Wide_String) return Wide_String;
-- Returns the result of applying the To_Lower Wide_Character to
-- Wide_Character conversion to each element of the Wide_String designated
-- by Item. The result is the null Wide_String if the value of the formal
-- parameter is the null Wide_String.
function To_Upper (Item : Wide_Character) return Wide_Character;
pragma Inline (To_Upper);
-- Returns the Simple Uppercase Mapping of the Wide_Character designated by
-- Item. If the Simple Uppercase Mapping does not exist for the
-- Wide_Character designated by Item, then the value of Item is returned.
function To_Upper (Item : Wide_String) return Wide_String;
-- Returns the result of applying the To_Upper Wide_Character to
-- Wide_Character conversion to each element of the Wide_String designated
-- by Item. The result is the null Wide_String if the value of the formal
-- parameter is the null Wide_String.
function To_Basic (Item : Wide_Character) return Wide_Character;
pragma Inline (To_Basic);
-- Returns the Wide_Character whose code point is given by the first value
-- of its Decomposition Mapping in the code charts of ISO/IEC 10646:2017 if
-- any, returns Item otherwise.
function To_Basic (Item : Wide_String) return Wide_String;
-- Returns the result of applying the To_Basic conversion to each
-- Wide_Character element of the Wide_String designated by Item. The result
-- is the null Wide_String if the value of the formal parameter is the null
-- Wide_String. The lower bound of the result Wide_String is 1.
end Ada.Wide_Characters.Handling;
|
-- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
with Ada.Containers.Indefinite_Hashed_Maps;
with Ada.Unchecked_Conversion;
with System;
with GL.API;
with GL.Enums;
package body GL.Objects.Buffers is
use type Low_Level.Enums.Buffer_Kind;
function Hash (Key : Low_Level.Enums.Buffer_Kind)
return Ada.Containers.Hash_Type is
function Value is new Ada.Unchecked_Conversion
(Source => Low_Level.Enums.Buffer_Kind, Target => Low_Level.Enum);
begin
return Ada.Containers.Hash_Type (Value (Key));
end Hash;
package Buffer_Maps is new Ada.Containers.Indefinite_Hashed_Maps
(Key_Type => Low_Level.Enums.Buffer_Kind,
Element_Type => Buffer'Class,
Hash => Hash,
Equivalent_Keys => Low_Level.Enums."=");
use type Buffer_Maps.Cursor;
Current_Buffers : Buffer_Maps.Map;
procedure Bind (Target : Buffer_Target; Object : Buffer'Class) is
Cursor : constant Buffer_Maps.Cursor
:= Current_Buffers.Find (Target.Kind);
begin
if Cursor = Buffer_Maps.No_Element or else
Buffer_Maps.Element (Cursor).Reference.GL_Id /= Object.Reference.GL_Id
then
API.Bind_Buffer (Target.Kind, Object.Reference.GL_Id);
Raise_Exception_On_OpenGL_Error;
if Cursor = Buffer_Maps.No_Element then
Current_Buffers.Insert (Target.Kind, Object);
else
Current_Buffers.Replace_Element (Cursor, Object);
end if;
end if;
end Bind;
function Current_Object (Target : Buffer_Target) return Buffer'Class is
Cursor : constant Buffer_Maps.Cursor
:= Current_Buffers.Find (Target.Kind);
begin
if Cursor /= Buffer_Maps.No_Element then
return Buffer_Maps.Element (Cursor);
else
raise No_Object_Bound_Exception with Target.Kind'Img;
end if;
end Current_Object;
procedure Load_To_Buffer (Target : Buffer_Target;
Data : Pointers.Element_Array;
Usage : Buffer_Usage) is
use type C.long;
begin
API.Buffer_Data (Target.Kind,
Pointers.Element'Size * Data'Length / System.Storage_Unit,
Data (Data'First)'Address, Usage);
Raise_Exception_On_OpenGL_Error;
end Load_To_Buffer;
procedure Allocate (Target : Buffer_Target; Number_Of_Bytes : Long;
Usage : Buffer_Usage) is
begin
API.Buffer_Data (Target.Kind, Low_Level.SizeIPtr (Number_Of_Bytes),
System.Null_Address, Usage);
Raise_Exception_On_OpenGL_Error;
end Allocate;
procedure Draw_Elements (Mode : Connection_Mode; Count : Types.Size;
Index_Type : Unsigned_Numeric_Type;
Element_Offset : Natural := 0) is
Element_Bytes : Natural;
begin
case Index_Type is
when UByte_Type => Element_Bytes := 1;
when UShort_Type => Element_Bytes := 2;
when UInt_Type => Element_Bytes := 4;
end case;
API.Draw_Elements (Mode, Count, Index_Type,
Low_Level.IntPtr (Element_Bytes * Element_Offset));
Raise_Exception_On_OpenGL_Error;
end Draw_Elements;
procedure Map (Target : in out Buffer_Target; Access_Type : Access_Kind;
Pointer : out Pointers.Pointer) is
function To_Pointer is new Ada.Unchecked_Conversion
(System.Address, Pointers.Pointer);
begin
Pointer := To_Pointer (API.Map_Buffer (Target.Kind, Access_Type));
Raise_Exception_On_OpenGL_Error;
end Map;
procedure Unmap (Target : in out Buffer_Target) is
begin
API.Unmap_Buffer (Target.Kind);
Raise_Exception_On_OpenGL_Error;
end Unmap;
function Pointer (Target : Buffer_Target) return Pointers.Pointer is
function To_Pointer is new Ada.Unchecked_Conversion
(System.Address, Pointers.Pointer);
Ret : System.Address := System.Null_Address;
begin
API.Buffer_Pointer (Target.Kind, Enums.Buffer_Map_Pointer, Ret);
Raise_Exception_On_OpenGL_Error;
return To_Pointer (Ret);
end Pointer;
procedure Set_Sub_Data (Target : Buffer_Target;
Offset : Types.Size;
Data : Pointers.Element_Array) is
begin
API.Buffer_Sub_Data (Target.Kind, Low_Level.IntPtr (Offset),
Low_Level.SizeIPtr (Data'Length),
Data (Data'First)'Address);
Raise_Exception_On_OpenGL_Error;
end Set_Sub_Data;
function Access_Type (Target : Buffer_Target) return Access_Kind is
Ret : Access_Kind := Access_Kind'First;
begin
API.Get_Buffer_Parameter_Access_Kind (Target.Kind, Enums.Buffer_Access,
Ret);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Access_Type;
function Mapped (Target : Buffer_Target) return Boolean is
Ret : Low_Level.Bool := Low_Level.Bool (False);
begin
API.Get_Buffer_Parameter_Bool (Target.Kind, Enums.Buffer_Mapped, Ret);
Raise_Exception_On_OpenGL_Error;
return Boolean (Ret);
end Mapped;
function Size (Target : Buffer_Target) return Types.Size is
Ret : Types.Size := 0;
begin
API.Get_Buffer_Parameter_Size (Target.Kind, Enums.Buffer_Size, Ret);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Size;
function Usage (Target : Buffer_Target) return Buffer_Usage is
Ret : Buffer_Usage := Buffer_Usage'First;
begin
API.Get_Buffer_Parameter_Usage (Target.Kind, Enums.Buffer_Usage, Ret);
Raise_Exception_On_OpenGL_Error;
return Ret;
end Usage;
procedure Destructor (Reference : not null GL_Object_Reference_Access) is
begin
API.Delete_Buffers (1, (1 => Reference.GL_Id));
Raise_Exception_On_OpenGL_Error;
Reference.Initialized := Uninitialized;
end Destructor;
overriding procedure Initialize_Id (Object : in out Buffer) is
New_Id : UInt := 0;
begin
API.Gen_Buffers (1, New_Id);
Raise_Exception_On_OpenGL_Error;
Object.Reference.GL_Id := New_Id;
Object.Reference.Initialized := Allocated;
Object.Reference.Destructor := Destructor'Access;
end Initialize_Id;
procedure Invalidate_Data (Object : in out Buffer) is
begin
API.Invalidate_Buffer_Data (Object.Reference.GL_Id);
Raise_Exception_On_OpenGL_Error;
end Invalidate_Data;
procedure Invalidate_Sub_Data (Object : in out Buffer;
Offset, Length : Long_Size) is
begin
API.Invalidate_Buffer_Sub_Data (Object.Reference.GL_Id,
Low_Level.IntPtr (Offset),
Low_Level.SizeIPtr (Length));
Raise_Exception_On_OpenGL_Error;
end Invalidate_Sub_Data;
end GL.Objects.Buffers;
|
with Asis.Compilation_Units;
with Asis.Elements;
with Asis.Iterator;
with Ada.Directories;
with Ada.Characters.Handling;
-- GNAT-specific:
with Asis.Set_Get;
with A4G.A_Types;
with Asis_Adapter.Element;
with Dot;
package body Asis_Adapter.Unit is
package ACU renames Asis.Compilation_Units;
-----------------------------------------------------------------------------
-- Unit_ID support
function Get_Unit_ID
(Unit : in Asis.Compilation_Unit)
return A4G.A_Types.Unit_Id is
begin
return Asis.Set_Get.Get_Unit_Id (Unit);
end Get_Unit_ID;
function To_Unit_ID
(ID : in A4G.A_Types.Unit_Id)
return a_nodes_h.Unit_ID
is
(a_nodes_h.Unit_ID (ID));
function Get_Unit_ID
(Unit : in Asis.Compilation_Unit)
return a_nodes_h.Unit_ID is
begin
return a_nodes_h.Unit_ID (Asis.Set_Get.Get_Unit_Id (Unit));
end Get_Unit_ID;
function To_String
(ID : in a_nodes_h.Unit_ID)
return String
is
(To_String (ID, Unit_ID_Kind));
-- END Unit_ID support
-----------------------------------------------------------------------------
-- String
-- Add <Name> = <Value> to the label, and print it if trace is on.
procedure Add_To_Dot_Label
(This : in out Class;
Name : in String;
Value : in String) is
begin
Add_To_Dot_Label (Dot_Label => This.Dot_Label,
Outputs => This.Outputs,
Name => Name,
Value => Value);
end;
-- Wide_String
-- Add <Name> = <Value> to the label, and print it if trace is on.
procedure Add_To_Dot_Label
(This : in out Class;
Name : in String;
Value : in Wide_String) is
begin
Add_To_Dot_Label (Dot_Label => This.Dot_Label,
Outputs => This.Outputs,
Name => Name,
Value => To_String (Value));
end;
-- Unit_ID
-- Add <Name> = <Value> to the label, and print it if trace is on.
procedure Add_To_Dot_Label
(This : in out Class;
Name : in String;
Value : in a_nodes_h.Unit_ID) is
begin
This.Add_To_Dot_Label (Name, To_String (Value));
end;
-- Unit_ID
-- Add <Name> = <Value> to the label, and print it if trace is on.
procedure Add_To_Dot_Label
(This : in out Class;
Name : in String;
Value : in Boolean) is
begin
Add_To_Dot_Label (Dot_Label => This.Dot_Label,
Outputs => This.Outputs,
Name => Name,
Value => Value);
end;
-- Add <Value> to the label in one wide cell, and print it if trace is on.
procedure Add_To_Dot_Label
(This : in out Class;
Value : in String) is
begin
Add_To_Dot_Label
(Dot_Label => This.Dot_Label,
Outputs => This.Outputs,
Value => Value);
end;
-- Add an edge for a child element:
procedure Add_Dot_Edge
(This : in out Class;
From : in a_nodes_h.Unit_ID;
To : in a_nodes_h.Element_ID;
Label : in String)
is
begin
Add_Dot_Edge (Outputs => This.Outputs,
From => From,
From_Kind => Unit_ID_Kind,
To => To,
To_Kind => Element_ID_Kind,
Label => Label);
end Add_Dot_Edge;
-- Add an edge and a dot label for a child element:
procedure Add_To_Dot_Label_And_Edge
(This : in out Class;
Label : in String;
To : in a_nodes_h.Element_ID) is
begin
-- Element, not Unit:
This.Add_To_Dot_Label (Label, To_String (To, Element_ID_Kind));
This.Add_Dot_Edge
(From => This.Unit_ID,
To => To,
Label => Label);
end Add_To_Dot_Label_And_Edge;
procedure Add_Unit_List
(This : in out class;
Units_In : in Asis.Compilation_Unit_List;
Dot_Label_Name : in String;
List_Out : out a_nodes_h.Unit_List)
is
Count : constant Natural := Units_In'Length;
IDs : anhS.Unit_ID_Array_Access := new
anhS.Unit_ID_Array (1 .. Count);
IDs_Index : Positive := IDs'First;
begin
for Unit of Units_In loop
declare
ID : constant a_nodes_h.Unit_ID := Get_Unit_Id (Unit);
Label : constant String :=
Dot_Label_Name & " (" & IDs_Index'Image & ")";
begin
IDs (IDs_Index) := Interfaces.C.int (ID);
Add_To_Dot_Label (This, Label, ID);
IDs_Index := IDs_Index + 1;
end;
end loop;
List_Out :=
(length => Interfaces.C.int(Count),
IDs => anhS.To_Unit_ID_Ptr (IDs));
end Add_Unit_List;
procedure Add_Element_List
(This : in out class;
Elements_In : in Asis.Element_List;
Dot_Label_Name : in String;
List_Out : out a_nodes_h.Element_ID_List)
is
-- For "-"
use type IC.int;
begin
List_Out := Element.To_Element_ID_List
(Dot_Label => This.Dot_Label,
Outputs => This.Outputs,
This_Element_ID => This.Unit_ID,
Elements_In => Elements_In,
Dot_Label_Name => Dot_Label_Name,
Add_Edges => True,
This_Is_Unit => True);
end Add_Element_List;
-----------
-- PRIVATE:
-----------
procedure Process_Element_Tree
(This : in out Class;
Asis_Element : in Asis.Element)
is
Tool_Element : Element.Class; -- Initialized
begin
Tool_Element.Process_Element_Tree
(Element => Asis_Element,
Outputs => This.Outputs);
end;
procedure Process_Context_Clauses
(This : in out Class;
Asis_Unit : in Asis.Compilation_Unit;
Include_Pragmas : in Boolean := True)
is
Context_Clauses : constant Asis.Element_List :=
Asis.Elements.Context_Clause_Elements
(Compilation_Unit => Asis_Unit,
Include_Pragmas => Include_Pragmas);
begin
for Context_Clause of Context_Clauses loop
This.Process_Element_Tree (Context_Clause);
end loop;
end Process_Context_Clauses;
procedure Process_Compilation_Pragmas
(This : in out Class;
Asis_Unit : in Asis.Compilation_Unit)
is
Compilation_Pragmas : constant Asis.Element_List :=
Asis.Elements.Compilation_Pragmas (Asis_Unit);
begin
for Compilation_Pragma of Compilation_Pragmas loop
This.Process_Element_Tree (Compilation_Pragma);
end loop;
end Process_Compilation_Pragmas;
-- Process all the elements in the compilation unit:
procedure Process_Element_Trees
(This : in out Class;
Asis_Unit : in Asis.Compilation_Unit;
Do_Context_Clauses : in Boolean := True;
Include_Pragmas : in Boolean := True)
is
Top_Element_Asis : Asis.Element := Asis.Elements.Unit_Declaration (Asis_Unit);
begin
if Do_Context_Clauses then
Process_Context_Clauses (This, Asis_Unit, Include_Pragmas);
end if;
Process_Element_Tree (This, Top_Element_Asis);
-- TODO: later
-- Process_Compilation_Pragmas (This, Asis_Unit);
end Process_Element_Trees;
function To_Wide_String (this : in Asis.Unit_Classes) return Wide_String is
begin
case this is
when Asis.A_Public_Declaration |
Asis.A_Private_Declaration =>
return "spec";
when Asis.A_Public_Body |
Asis.A_Public_Declaration_And_Body |
Asis.A_Private_Body =>
return "body";
when Asis.A_Separate_Body =>
return "subunit";
when others =>
return Asis.Unit_Classes'Wide_Image(this);
end case;
end To_Wide_String;
-- Create a Dot node for this unit, add all the attributes, and append it to the
-- graph.
procedure Process_Unit
(This : in out Class;
Unit : in Asis.Compilation_Unit)
is
Parent_Name : constant String := Module_Name;
Module_Name : constant String := Parent_Name & ".Process_Unit";
package Logging is new Generic_Logging (Module_Name); use Logging;
Unit_Class : constant Asis.Unit_Classes := ACU.Unit_Class (Unit);
Unit_Full_Name : constant Wide_String := Acu.Unit_Full_Name (Unit);
Unit_Kind : constant Asis.Unit_Kinds := ACU.Unit_Kind (Unit);
-- These are in alphabetical order:
procedure Add_Can_Be_Main_Program is
Value : Boolean := ACU.Exists (Unit);
begin
This.Add_To_Dot_Label ("Can_Be_Main_Program", Value);
This.A_Unit.Can_Be_Main_Program := a_nodes_h.Support.To_bool (Value);
end;
procedure Add_Compilation_Command_Line_Options is
WS : constant Wide_String :=
Acu.Compilation_Command_Line_Options (Unit);
begin
This.Add_To_Dot_Label ("Compilation_Command_Line_Options", WS);
This.A_Unit.Compilation_Command_Line_Options := To_Chars_Ptr (WS);
end;
procedure Add_Compilation_Pragmas is
begin
Add_Element_List
(This => This,
Elements_In => Asis.Elements.Compilation_Pragmas (Unit),
Dot_Label_Name => "Compilation_Pragmas",
List_Out => This.A_Unit.Compilation_Pragmas);
end;
procedure Add_Context_Clause_Elements is
begin
Add_Element_List
(This => This,
Elements_In => Asis.Elements.Context_Clause_Elements (Unit),
Dot_Label_Name => "Context_Clause_Elements",
List_Out => This.A_Unit.Context_Clause_Elements);
end;
procedure Add_Corresponding_Body is
ID : constant a_nodes_h.Unit_ID := Get_Unit_Id
(ACU.Corresponding_Body (Unit));
begin
This.Add_To_Dot_Label ("Corresponding_Body", ID);
This.A_Unit.Corresponding_Body := ID;
end;
procedure Add_Corresponding_Children is
begin
Add_Unit_List
(This => This,
Units_In => ACU.Corresponding_Children (Unit),
Dot_Label_Name => "Corresponding_Children",
List_Out => This.A_Unit.Corresponding_Children);
end;
procedure Add_Corresponding_Declaration is
ID : constant a_nodes_h.Unit_ID := Get_Unit_Id
(ACU.Corresponding_Declaration (Unit));
begin
This.Add_To_Dot_Label ("Corresponding_Declaration", ID);
This.A_Unit.Corresponding_Declaration := ID;
end;
procedure Add_Corresponding_Parent_Declaration is
ID : constant a_nodes_h.Unit_ID := Get_Unit_Id
(ACU.Corresponding_Parent_Declaration (Unit));
begin
This.Add_To_Dot_Label ("Corresponding_Parent_Declaration", ID);
This.A_Unit.Corresponding_Parent_Declaration := ID;
end;
procedure Add_Corresponding_Subunit_Parent_Body is
ID : constant a_nodes_h.Unit_ID := Get_Unit_Id
(ACU.Corresponding_Subunit_Parent_Body (Unit));
begin
This.Add_To_Dot_Label ("Corresponding_Subunit_Parent_Body", ID);
This.A_Unit.Corresponding_Subunit_Parent_Body := ID;
end;
procedure Add_Debug_Image is
WS : constant Wide_String := ACU.Debug_Image (Unit);
begin
This.A_Unit.Debug_Image := To_Chars_Ptr (WS);
end;
procedure Add_Enclosing_Container is
-- Container : constant Asis.Ada_Environments.Containers.Container :=
-- ACU.Enclosing_Container (Unit);
begin
null; -- TODO: Finish if needed:
-- This.A_Unit.Enclosing_Container := Container;
end;
procedure Add_Enclosing_Context is
Context : constant Asis.Context := ACU.Enclosing_Context (Unit);
begin
null; -- TODO: Finish if needed:
-- This.A_Unit.Enclosing_Context := Context;
end;
procedure Add_Exists is
Value : Boolean := ACU.Exists (Unit);
begin
This.Add_To_Dot_Label ("Exists", Value);
This.A_Unit.Exists := a_nodes_h.Support.To_bool (Value);
end;
procedure Add_Is_Body_Required is
Value : Boolean := ACU.Exists (Unit);
begin
This.Add_To_Dot_Label ("Is_Body_Required", Value);
This.A_Unit.Is_Body_Required := a_nodes_h.Support.To_bool (Value);
end;
procedure Add_Is_Standard is
Value : Boolean := Asis.Set_Get.Is_Standard (Unit);
begin
This.Add_To_Dot_Label ("Is_Standard", Value);
This.A_Unit.Is_Standard := a_nodes_h.Support.To_bool (Value);
end;
procedure Add_Object_Form is
WS : constant Wide_String := ACU.Object_Form (Unit);
begin
-- Empty:
This.Add_To_Dot_Label ("Object_Form", WS);
This.A_Unit.Object_Form := To_Chars_Ptr (WS);
end;
procedure Add_Object_Name is
WS : constant Wide_String := ACU.Object_Name (Unit);
begin
-- Empty:
This.Add_To_Dot_Label ("Object_Name", WS);
This.A_Unit.Object_Name := To_Chars_Ptr (WS);
end;
procedure Add_Subunits is
begin
Add_Unit_List
(This => This,
Units_In => ACU.Subunits (Unit),
Dot_Label_Name => "Subunits",
List_Out => This.A_Unit.Subunits);
end;
procedure Add_Text_Form is
WS : constant Wide_String := ACU.Text_Form (Unit);
begin
-- Empty:
This.Add_To_Dot_Label ("Text_Form", WS);
This.A_Unit.Text_Form := To_Chars_Ptr (WS);
end;
procedure Add_Text_Name is
package AD renames Ada.Directories;
WS : constant Wide_String := ACU.Text_Name (Unit);
-- Package Standard has an empty file name, which AD.Simple_Name
-- doesn't like. Handle that here:
function To_Simple_File_Name
(Name_String : in String)
return String is
begin
if Name_String = "" then
return "";
else
return AD.Simple_Name (Name_String);
end if;
end To_Simple_File_Name;
Simple_File_Name : aliased String := To_Simple_File_Name (To_String(WS));
begin
This.Add_To_Dot_Label ("Text_Name", Simple_File_Name);
This.A_Unit.Text_Name := To_Chars_Ptr (WS);
end;
procedure Add_Unique_Name is
WS : constant Wide_String := ACU.Unique_Name (Unit);
begin
This.Add_To_Dot_Label ("Unique_Name", WS);
This.A_Unit.Unique_Name := To_Chars_Ptr (WS);
end;
procedure Add_Unit_Class is
begin
This.Add_To_Dot_Label ("Unit_Class", Unit_Class'Image);
This.A_Unit.Unit_Class := anhS.To_Unit_Classes (Unit_Class);
end;
procedure Add_Unit_Declaration is
Asis_Element : constant Asis.Element :=
Asis.Elements.Unit_Declaration (Unit);
anhS_Element_ID : constant a_nodes_h.Element_ID :=
Element.Get_Element_ID (Asis_Element);
begin
This.Add_To_Dot_Label_And_Edge
(Label => "Unit_Declaration",
To => anhS_Element_ID);
This.A_Unit.Unit_Declaration := anhS_Element_ID;
end;
procedure Add_Unit_Full_Name is
WS : constant Wide_String := ACU.Unit_Full_Name (Unit);
begin
This.Add_To_Dot_Label ("Unit_Full_Name", WS);
This.A_Unit.Unit_Full_Name := To_Chars_Ptr (WS);
end;
procedure Add_Unit_Id is
begin
-- ID is in the Dot node twice (once in the Label and once in
-- Node_ID), but not in the a_node twice.
This.Add_To_Dot_Label (To_String (This.Unit_ID));
This.A_Unit.id := This.Unit_ID;
end;
procedure Add_Unit_Kind is
begin
This.Add_To_Dot_Label ("Unit_Kind", Unit_Kind'Image);
This.A_Unit.Unit_Kind := anhS.To_Unit_Kinds (Unit_Kind);
end;
procedure Add_Unit_Origin is
Unit_Origin : constant Asis.Unit_Origins := ACU.Unit_Origin (Unit);
begin
This.Add_To_Dot_Label ("Unit_Origin", Unit_Origin'Image);
This.A_Unit.Unit_Origin := anhS.To_Unit_Origins (Unit_Origin);
end;
procedure Start_Output is
Default_Node : Dot.Node_Stmt.Class; -- Initialized
Default_Label : Dot.HTML_Like_Labels.Class; -- Initialized
begin
Log ("Processing " & To_String (Unit_Full_Name) & " " &
To_String (To_Wide_String (Unit_Class)));
-- Set defaults:
This.A_Unit := a_nodes_h.Support.Default_Unit_Struct;
This.Outputs.Text.End_Line;
-- Unit ID comes out on next line via Add_Unit_ID:
This.Outputs.Text.Put_Indented_Line (String'("BEGIN "));
This.Outputs.Text.Indent;
This.Dot_Node := Default_Node;
This.Dot_Label := Default_Label;
-- Get ID:
This.Unit_ID := Get_Unit_ID (Unit);
This.Dot_Node.Node_ID.ID :=
To_Dot_ID_Type (This.Unit_ID, Unit_ID_Kind);
-- Want these at the top:
Add_Unit_Id;
Add_Unit_Kind;
-- Common items, in Asis order:
Add_Unit_Class;
Add_Unit_Origin;
if not Asis.Compilation_Units.Is_Nil (Unit) then
Add_Enclosing_Context;
Add_Enclosing_Container;
end if;
Add_Unit_Full_Name;
Add_Unique_Name;
Add_Exists;
Add_Can_Be_Main_Program;
Add_Is_Body_Required;
Add_Text_Name;
Add_Text_Form;
Add_Object_Name;
Add_Object_Form;
Add_Compilation_Command_Line_Options;
Add_Debug_Image;
Add_Unit_Declaration;
Add_Context_Clause_Elements;
-- TODO: later
-- Add_Compilation_Pragmas;
Add_Is_Standard;
end;
procedure Finish_Output is
begin
This.Dot_Node.Add_Label (This.Dot_Label);
This.Outputs.Graph.Append_Stmt
(new Dot.Node_Stmt.Class'(This.Dot_Node));
This.Outputs.A_Nodes.Push (This.A_Unit);
This.Outputs.Text.End_Line;
This.Outputs.Text.Dedent;
This.Outputs.Text.Put_Indented_Line
(String'("END " & To_String (This.Unit_ID)));
end;
use all type Asis.Unit_Kinds;
begin -- Process_Unit
If Unit_Kind /= Not_A_Unit then
Start_Output;
end if;
-- Not common items, in Asis order:
case Unit_Kind is
when Not_A_Unit =>
raise Program_Error with
Module_Name & " called with: " & Unit_Kind'Image;
when A_Procedure |
A_Function |
A_Generic_Procedure |
A_Generic_Function =>
Add_Corresponding_Parent_Declaration;
Add_Corresponding_Body;
when A_Package |
A_Generic_Package =>
Add_Corresponding_Children;
Add_Corresponding_Parent_Declaration;
Add_Corresponding_Body;
when A_Procedure_Instance |
A_Function_Instance |
A_Procedure_Renaming |
A_Function_Renaming |
A_Package_Renaming |
A_Generic_Procedure_Renaming |
A_Generic_Function_Renaming |
A_Generic_Package_Renaming =>
Add_Corresponding_Parent_Declaration;
when A_Package_Instance =>
Add_Corresponding_Children;
Add_Corresponding_Parent_Declaration;
when A_Procedure_Body |
A_Function_Body |
A_Package_Body =>
Add_Corresponding_Declaration;
Add_Corresponding_Parent_Declaration;
Add_Subunits;
when A_Procedure_Body_Subunit |
A_Function_Body_Subunit |
A_Package_Body_Subunit |
A_Task_Body_Subunit |
A_Protected_Body_Subunit =>
Add_Subunits;
Add_Corresponding_Subunit_Parent_Body;
when A_Nonexistent_Declaration |
A_Nonexistent_Body |
A_Configuration_Compilation =>
null; -- No more info
when An_Unknown_Unit=>
Add_Corresponding_Declaration;
Add_Corresponding_Body;
end case;
Finish_Output;
Process_Element_Trees (This, Unit);
Log ("Not_Implemented count: " &
This.Outputs.A_Nodes.Get_Not_Implemented'Image);
Log ("DONE Processing " & To_String (Unit_Full_Name) & " " &
To_String (To_Wide_String (Unit_Class)));
end Process_Unit;
------------
-- EXPORTED:
------------
procedure Process
(This : in out Class;
Unit : in Asis.Compilation_Unit;
Options : in Options_Record;
Outputs : in Outputs_Record)
is
Parent_Name : constant String := Module_Name;
Module_Name : constant String := Parent_Name & ".Process";
package Logging is new Generic_Logging (Module_Name); use Logging;
function To_Description (This : in Asis.Unit_Origins)
return Wide_String is
begin
case This is
when Asis.Not_An_Origin =>
return "(unit origin is nil or nonexistent)";
when Asis.A_Predefined_Unit =>
return "(Ada predefined language environment unit)";
when Asis.An_Implementation_Unit =>
return "(Implementation specific library unit)";
when Asis.An_Application_Unit =>
return "(Application unit)";
end case;
end To_Description;
Unit_Full_Name : constant String :=
To_String (Acu.Unit_Full_Name (Unit));
Unit_Origin : constant Asis.Unit_Origins := Acu.Unit_Origin (Unit);
begin
-- I would like to just pass Outputs through and not store it in the
-- object, since it is all pointers and we doesn't need to store their
-- values between calls to Process_Element_Tree. Outputs has to go into
-- Add_To_Dot_Label, though, so we'll put it in the object and pass
-- that:
This.Outputs := Outputs;
if Options.Process_If_Origin_Is (Unit_Origin) and then
-- Processing package Standard causes a constraint error:
-- +===========================ASIS BUG DETECTED==============================+
-- | ASIS 2.0.R for GNAT Community 2019 (20190517) CONSTRAINT_ERROR a4g-a_sinput.adb:210 index check failed|
-- | when processing Asis.Declarations.Is_Name_Repeated |
-- ...
-- So skip it for now:
Unit_Full_Name /= "Standard" then
Process_Unit (This, Unit);
else
Log ("Skipped " & Unit_Full_Name &
" (" & To_String (To_Description(Unit_Origin) & ")"));
end if;
exception
when X : others =>
Log ("EXCEPTION " & Aex.Exception_Name (X) & " when processing " &
Unit_Full_Name);
Log ("Reraising.");
raise;
end Process;
end Asis_Adapter.Unit;
|
with System.Formatting;
with System.Img_WChar;
with System.Long_Long_Integer_Types;
with System.Val_Char;
with System.Val_Enum;
with System.Value_Errors;
with System.UTF_Conversions;
package body System.Val_WChar is
use type Long_Long_Integer_Types.Word_Unsigned;
use type UTF_Conversions.From_Status_Type;
use type UTF_Conversions.To_Status_Type;
subtype Word_Unsigned is Long_Long_Integer_Types.Word_Unsigned;
procedure Get_Named (
S : String;
Value : out Wide_Character;
Error : out Boolean);
procedure Get_Named (
S : String;
Value : out Wide_Character;
Error : out Boolean) is
begin
if S = Img_WChar.Image_ad then
Value := Wide_Character'Val (16#ad#);
Error := False;
else
declare
C : Character;
begin
Val_Char.Get_Named (S, C, Error);
Value := Wide_Character'Val (Character'Pos (C));
end;
end if;
end Get_Named;
-- implementation
function Value_Wide_Character (Str : String; EM : WC_Encoding_Method)
return Wide_Character
is
pragma Unreferenced (EM);
First : Positive;
Last : Natural;
begin
Val_Enum.Trim (Str, First, Last);
if First + 2 <= Last
and then Str (First) = '''
and then Str (Last) = '''
then
declare
Used_Last : Natural;
Code : UTF_Conversions.UCS_4;
From_Status : UTF_Conversions.From_Status_Type;
To_Status : UTF_Conversions.To_Status_Type;
Result : Wide_String (1 .. 2);
begin
UTF_Conversions.From_UTF_8 (
Str (First + 1 .. Last),
Used_Last,
Code,
From_Status);
if From_Status = UTF_Conversions.Success
and then Used_Last + 1 = Last
then
UTF_Conversions.To_UTF_16 (
Code,
Result,
Used_Last,
To_Status);
if To_Status = UTF_Conversions.Success
and then Used_Last = 1
then
return Result (1);
end if;
end if;
end;
else
declare
S : String := Str (First .. Last);
L : constant Natural := First + (Val_Char.HEX_Prefix'Length - 1);
begin
Val_Enum.To_Upper (S);
if L <= Last and then S (First .. L) = Val_Char.HEX_Prefix then
declare
Used_Last : Natural;
Result : Word_Unsigned;
Error : Boolean;
begin
Formatting.Value (
S (First + Val_Char.HEX_Prefix'Length .. Last),
Used_Last,
Result,
Base => 16,
Error => Error);
if not Error
and then Used_Last = Last
and then Result <=
Wide_Character'Pos (Wide_Character'Last)
then
return Wide_Character'Val (Result);
end if;
end;
else
declare
Result : Wide_Character;
Error : Boolean;
begin
Get_Named (S, Result, Error);
if not Error then
return Result;
end if;
end;
end if;
end;
end if;
Value_Errors.Raise_Discrete_Value_Failure ("Wide_Character", Str);
declare
Uninitialized : Wide_Character;
pragma Unmodified (Uninitialized);
begin
return Uninitialized;
end;
end Value_Wide_Character;
function Value_Wide_Wide_Character (Str : String; EM : WC_Encoding_Method)
return Wide_Wide_Character
is
pragma Unreferenced (EM);
First : Positive;
Last : Natural;
begin
Val_Enum.Trim (Str, First, Last);
if First + 2 <= Last
and then Str (First) = '''
and then Str (Last) = '''
then
declare
Used_Last : Natural;
Code : UTF_Conversions.UCS_4;
From_Status : UTF_Conversions.From_Status_Type;
begin
UTF_Conversions.From_UTF_8 (
Str (First + 1 .. Last),
Used_Last,
Code,
From_Status);
if From_Status = UTF_Conversions.Success
and then Used_Last + 1 = Last
then
return Wide_Wide_Character'Val (Code);
end if;
end;
else
declare
S : String := Str (First .. Last);
L : constant Natural := First + (Val_Char.HEX_Prefix'Length - 1);
begin
Val_Enum.To_Upper (S);
if L <= Last and then S (First .. L) = Val_Char.HEX_Prefix then
declare
Used_Last : Natural;
Result : Word_Unsigned;
Error : Boolean;
begin
Formatting.Value (
S (First + Val_Char.HEX_Prefix'Length .. Last),
Used_Last,
Result,
Base => 16,
Error => Error);
if not Error
and then Used_Last = Last
and then Result <=
Wide_Wide_Character'Pos (Wide_Wide_Character'Last)
then
return Wide_Wide_Character'Val (Result);
end if;
end;
else
declare
Result : Wide_Character;
Error : Boolean;
begin
Get_Named (S, Result, Error);
if not Error then
return Wide_Wide_Character'Val (
Wide_Character'Pos (Result));
end if;
end;
end if;
end;
end if;
Value_Errors.Raise_Discrete_Value_Failure ("Wide_Wide_Character", Str);
declare
Uninitialized : Wide_Wide_Character;
pragma Unmodified (Uninitialized);
begin
return Uninitialized;
end;
end Value_Wide_Wide_Character;
end System.Val_WChar;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Test_If_2 is
type Two_Bool is range 0 .. 3;
function If_2(Cond_1, Cond_2: Boolean) return Two_Bool is
(Two_Bool(2*Boolean'Pos(Cond_1)) + Two_Bool(Boolean'Pos(Cond_2)));
begin
for N in 10 .. 20 loop
Put(Integer'Image(N) & " is ");
case If_2(N mod 2 = 0, N mod 3 = 0) is
when 2#11# => Put_Line("divisible by both two and three.");
when 2#10# => Put_Line("divisible by two, but not by three.");
when 2#01# => Put_Line("divisible by three, but not by two.");
when 2#00# => Put_Line("neither divisible by two, nor by three.");
end case;
end loop;
end Test_If_2;
|
with
Interfaces.C;
use type
Interfaces.C.int;
package body FLTK.Screen is
function fl_screen_x
return Interfaces.C.int;
pragma Import (C, fl_screen_x, "fl_screen_x");
pragma Inline (fl_screen_x);
function fl_screen_y
return Interfaces.C.int;
pragma Import (C, fl_screen_y, "fl_screen_y");
pragma Inline (fl_screen_y);
function fl_screen_w
return Interfaces.C.int;
pragma Import (C, fl_screen_w, "fl_screen_w");
pragma Inline (fl_screen_w);
function fl_screen_h
return Interfaces.C.int;
pragma Import (C, fl_screen_h, "fl_screen_h");
pragma Inline (fl_screen_h);
function fl_screen_count
return Interfaces.C.int;
pragma Import (C, fl_screen_count, "fl_screen_count");
pragma Inline (fl_screen_count);
procedure fl_screen_dpi
(H, V : out Interfaces.C.C_float;
N : in Interfaces.C.int);
pragma Import (C, fl_screen_dpi, "fl_screen_dpi");
pragma Inline (fl_screen_dpi);
function fl_screen_num
(X, Y : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_screen_num, "fl_screen_num");
pragma Inline (fl_screen_num);
function fl_screen_num2
(X, Y, W, H : in Interfaces.C.int)
return Interfaces.C.int;
pragma Import (C, fl_screen_num2, "fl_screen_num2");
pragma Inline (fl_screen_num2);
procedure fl_screen_work_area
(X, Y, W, H : out Interfaces.C.int;
PX, PY : in Interfaces.C.int);
pragma Import (C, fl_screen_work_area, "fl_screen_work_area");
pragma Inline (fl_screen_work_area);
procedure fl_screen_work_area2
(X, Y, W, H : out Interfaces.C.int;
N : in Interfaces.C.int);
pragma Import (C, fl_screen_work_area2, "fl_screen_work_area2");
pragma Inline (fl_screen_work_area2);
procedure fl_screen_work_area3
(X, Y, W, H : out Interfaces.C.int);
pragma Import (C, fl_screen_work_area3, "fl_screen_work_area3");
pragma Inline (fl_screen_work_area3);
procedure fl_screen_xywh
(X, Y, W, H : out Interfaces.C.int;
PX, PY : in Interfaces.C.int);
pragma Import (C, fl_screen_xywh, "fl_screen_xywh");
pragma Inline (fl_screen_xywh);
procedure fl_screen_xywh2
(X, Y, W, H : out Interfaces.C.int;
N : in Interfaces.C.int);
pragma Import (C, fl_screen_xywh2, "fl_screen_xywh2");
pragma Inline (fl_screen_xywh2);
procedure fl_screen_xywh3
(X, Y, W, H : out Interfaces.C.int);
pragma Import (C, fl_screen_xywh3, "fl_screen_xywh3");
pragma Inline (fl_screen_xywh3);
procedure fl_screen_xywh4
(X, Y, W, H : out Interfaces.C.int;
PX, PY, PW, PH : in Interfaces.C.int);
pragma Import (C, fl_screen_xywh4, "fl_screen_xywh4");
pragma Inline (fl_screen_xywh4);
function Get_X return Integer is
begin
return Integer (fl_screen_x);
end Get_X;
function Get_Y return Integer is
begin
return Integer (fl_screen_y);
end Get_Y;
function Get_W return Integer is
begin
return Integer (fl_screen_w);
end Get_W;
function Get_H return Integer is
begin
return Integer (fl_screen_h);
end Get_H;
function Count return Integer is
begin
return Integer (fl_screen_count);
end Count;
-- Screen numbers in the range 1 .. Get_Count
procedure DPI
(Horizontal, Vertical : out Float;
Screen_Number : in Integer := 1) is
begin
fl_screen_dpi
(Interfaces.C.C_float (Horizontal),
Interfaces.C.C_float (Vertical),
Interfaces.C.int (Screen_Number) - 1);
end DPI;
function Containing
(X, Y : in Integer)
return Integer is
begin
return Integer (fl_screen_num
(Interfaces.C.int (X),
Interfaces.C.int (Y)));
end Containing;
function Containing
(X, Y, W, H : in Integer)
return Integer is
begin
return Integer (fl_screen_num2
(Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H)));
end Containing;
procedure Work_Area
(X, Y, W, H : out Integer;
Pos_X, Pos_Y : in Integer) is
begin
fl_screen_work_area
(Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H),
Interfaces.C.int (Pos_X),
Interfaces.C.int (Pos_Y));
end Work_Area;
procedure Work_Area
(X, Y, W, H : out Integer;
Screen_Num : in Integer) is
begin
fl_screen_work_area2
(Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H),
Interfaces.C.int (Screen_Num));
end Work_Area;
procedure Work_Area
(X, Y, W, H : out Integer) is
begin
fl_screen_work_area3
(Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H));
end Work_Area;
procedure Bounding_Rect
(X, Y, W, H : out Integer;
Pos_X, Pos_Y : in Integer) is
begin
fl_screen_xywh
(Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H),
Interfaces.C.int (Pos_X),
Interfaces.C.int (Pos_Y));
end Bounding_Rect;
procedure Bounding_Rect
(X, Y, W, H : out Integer;
Screen_Num : in Integer) is
begin
fl_screen_xywh2
(Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H),
Interfaces.C.int (Screen_Num));
end Bounding_Rect;
procedure Bounding_Rect
(X, Y, W, H : out Integer) is
begin
fl_screen_xywh3
(Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H));
end Bounding_Rect;
procedure Bounding_Rect
(X, Y, W, H : out Integer;
PX, PY, PW, PH : in Integer) is
begin
fl_screen_xywh4
(Interfaces.C.int (X),
Interfaces.C.int (Y),
Interfaces.C.int (W),
Interfaces.C.int (H),
Interfaces.C.int (PX),
Interfaces.C.int (PY),
Interfaces.C.int (PW),
Interfaces.C.int (PH));
end Bounding_Rect;
end FLTK.Screen;
|
------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A 4 G . Q U E R I E S --
-- --
-- B o d y --
-- --
-- Copyright (C) 1995-2012, Free Software Foundation, Inc. --
-- --
-- ASIS-for-GNAT is free software; you can redistribute it and/or modify it --
-- under terms of the GNU General Public License as published by the Free --
-- Software Foundation; either version 2, or (at your option) any later --
-- version. ASIS-for-GNAT is distributed in the hope that it will be use- --
-- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- --
-- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General --
-- Public License for more details. You should have received a copy of the --
-- GNU General Public License distributed with ASIS-for-GNAT; see file --
-- COPYING. If not, write to the Free Software Foundation, 51 Franklin --
-- Street, Fifth Floor, Boston, MA 02110-1301, USA. --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- --
-- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the --
-- Software Engineering Laboratory of the Swiss Federal Institute of --
-- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the --
-- Scientific Research Computer Center of Moscow State University (SRCC --
-- MSU), Russia, with funding partially provided by grants from the Swiss --
-- National Science Foundation and the Swiss Academy of Engineering --
-- Sciences. ASIS-for-GNAT is now maintained by AdaCore --
-- (http://www.adacore.com). --
-- --
-- The original version of this component has been developed by --
-- Jean-Charles Marteau (Jean-Charles.Marteau@ensimag.imag.fr) and Serge --
-- Reboul (Serge.Reboul@ensimag.imag.fr), ENSIMAG High School Graduates --
-- (Computer sciences) Grenoble, France in Sema Group Grenoble, France. Now --
-- this component is maintained by the ASIS team at AdaCore --
-- --
------------------------------------------------------------------------------
--------------------------------------------------
-- The structure of this package is very basic, --
-- it consists in massive imbricated cases --
-- determining what element we're considering --
-- and returning an array containing its --
-- corresponding queries. --
--------------------------------------------------
with Asis.Clauses;
with Asis.Declarations;
with Asis.Definitions;
with Asis.Elements;
with Asis.Expressions;
with Asis.Extensions;
with Asis.Statements;
with A4G.A_Types; use A4G.A_Types;
package body A4G.Queries is
-----------------------
-- Local subprograms --
-----------------------
function Subprogram_Call_Needs_Reordering
(El : Asis.Element)
return Boolean;
-- Checks if for a subprogram call element the sequence of its components
-- obtained as
--
-- 'Name_Of_Called_Subprogram' -> 'Parameter_Associations'
--
-- should be reordered because of one of the following reasons:
--
-- 1. For 'A + B' the right order of traversing is
--
-- 'A' -> '+' -> 'B'
--
-- 2. For Obj.Operation (Par1, Par2) where Obj is the dispatching
-- operand for subprogram Operation the right order of traversing is
--
-- 'Obj' -> 'Fun' -> 'Par1' ->'Par2'
function First_Parameter_Association
(Call : Asis.Element)
return Asis.Element;
-- Returns the first parameter association from the Call that is supposed
-- to be either A_Function_Call or A_Procedure_Call_Statement Element, and
-- the corresponding call has at least one parameter association.
function All_But_First_Associations
(Call : Asis.Element)
return Asis.Element_List;
-- Returns the parameter association list from the Call that contains all
-- but first associations. The Call that is supposed to be either
-- A_Function_Call or A_Procedure_Call_Statement Element, and the
-- corresponding call has at least one parameter association. If Call
-- contains exactly one parameter association, the result is
-- Nil_Element_List
-- Subprograms declared below implement first-depth-level parsing of
-- Elements of specific kinds - they return a list of queries needed to
-- get all the first-depth-level components of their argument in
-- from-left-to-right order
function PARSE_Defining_Name
(Ada_Defining_Name : Asis.Element)
return Query_Array;
function PARSE_Association
(Ada_Association : Asis.Element)
return Query_Array;
function PARSE_Clause
(Ada_Clause : Asis.Element)
return Query_Array;
function PARSE_Expression
(Ada_Expression : Asis.Element)
return Query_Array;
function PARSE_Path (Ada_Path : Asis.Element) return Query_Array;
function PARSE_Definition
(Ada_Definition : Asis.Element)
return Query_Array;
function PARSE_Declaration
(Ada_Declaration : Asis.Element)
return Query_Array;
function PARSE_Statement
(Ada_Statement : Asis.Element)
return Query_Array;
--------------------------------
-- All_But_First_Associations --
--------------------------------
function All_But_First_Associations
(Call : Asis.Element)
return Asis.Element_List
is
Result : constant Asis.Element_List :=
Asis.Extensions.Get_Call_Parameters (Call);
begin
return Result (Result'First + 1 .. Result'Last);
end All_But_First_Associations;
-------------------------
-- Appropriate_Queries --
-------------------------
function Appropriate_Queries (Element : Asis.Element) return Query_Array is
begin
case Asis.Elements.Element_Kind (Element) is
when Not_An_Element =>
return No_Query;
when A_Pragma =>
return Query_Array'
(1 => (Element_List_Query,
Asis.Elements.Pragma_Argument_Associations'Access));
when A_Defining_Name =>
return PARSE_Defining_Name (Element);
when A_Declaration =>
return PARSE_Declaration (Element);
when A_Definition =>
return PARSE_Definition (Element);
when An_Expression =>
return PARSE_Expression (Element);
when An_Association =>
return PARSE_Association (Element);
when A_Statement =>
return PARSE_Statement (Element);
when A_Path =>
return PARSE_Path (Element);
when A_Clause =>
return PARSE_Clause (Element);
when An_Exception_Handler =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Statements.Choice_Parameter_Specification'Access),
2 => (Element_List_Query,
Asis.Statements.Exception_Choices'Access),
3 => (Element_List_Query_With_Boolean,
Asis.Statements.Handler_Statements'Access, True));
end case;
end Appropriate_Queries;
---------------------------------
-- First_Parameter_Association --
---------------------------------
function First_Parameter_Association
(Call : Asis.Element)
return Asis.Element
is
Result : constant Asis.Element_List :=
Asis.Extensions.Get_Call_Parameters (Call);
begin
return Result (Result'First);
end First_Parameter_Association;
-----------------------
-- PARSE_Association --
-----------------------
function PARSE_Association
(Ada_Association : Asis.Element)
return Query_Array
is
begin
case Asis.Elements.Association_Kind (Ada_Association) is
when Not_An_Association =>
raise Internal_Implementation_Error;
when A_Discriminant_Association =>
return Query_Array'
(1 => (Element_List_Query,
Asis.Expressions.Discriminant_Selector_Names'Access),
2 => (Single_Element_Query,
Asis.Expressions.Discriminant_Expression'Access));
when A_Record_Component_Association =>
return Query_Array'
(1 => (Element_List_Query,
Asis.Expressions.Record_Component_Choices'Access),
2 => (Single_Element_Query,
Asis.Expressions.Component_Expression'Access));
when An_Array_Component_Association =>
return Query_Array'
(1 => (Element_List_Query,
Asis.Expressions.Array_Component_Choices'Access),
2 => (Single_Element_Query,
Asis.Expressions.Component_Expression'Access));
when A_Parameter_Association |
A_Pragma_Argument_Association |
A_Generic_Association =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Expressions.Formal_Parameter'Access),
2 => (Single_Element_Query,
Asis.Expressions.Actual_Parameter'Access));
end case;
end PARSE_Association;
------------------
-- PARSE_Clause --
------------------
function PARSE_Clause
(Ada_Clause : Asis.Element)
return Query_Array
is
begin
case Asis.Elements.Clause_Kind (Ada_Clause) is
when Not_A_Clause =>
raise Internal_Implementation_Error;
when A_Use_Package_Clause |
A_Use_Type_Clause |
A_Use_All_Type_Clause | -- Ada 2012
A_With_Clause =>
return Query_Array'
(1 => (Element_List_Query, Asis.Clauses.Clause_Names'Access));
when A_Representation_Clause =>
case Asis.Elements.Representation_Clause_Kind (Ada_Clause) is
when Not_A_Representation_Clause =>
raise Internal_Implementation_Error;
when An_Attribute_Definition_Clause |
An_Enumeration_Representation_Clause |
An_At_Clause =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Clauses.Representation_Clause_Name'Access),
2 => (Single_Element_Query,
Asis.Clauses.Representation_Clause_Expression'Access));
when A_Record_Representation_Clause =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Clauses.Representation_Clause_Name'Access),
2 => (Single_Element_Query,
Asis.Clauses.Mod_Clause_Expression'Access),
3 => (Element_List_Query_With_Boolean,
Asis.Clauses.Component_Clauses'Access, True));
end case;
when A_Component_Clause =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Clauses.Representation_Clause_Name'Access),
2 => (Single_Element_Query,
Asis.Clauses.Component_Clause_Position'Access),
3 => (Single_Element_Query,
Asis.Clauses.Component_Clause_Range'Access));
end case;
end PARSE_Clause;
-----------------------
-- PARSE_Declaration --
-----------------------
----------------------------------------------------------------------------
-- function PARSE_Declaration
--
-- This function parse every declarations
-- The Declaration_Kinds are :
--
-- Declaration_Kind LRM P.
----------------------------------------------------------
--
-- An_Ordinary_Type_Declaration, -- 3.2.1
-- A_Task_Type_Declaration, -- 3.2.1
-- A_Protected_Type_Declaration, -- 3.2.1
-- An_Incomplete_Type_Declaration, -- 3.2.1
-- A_Private_Type_Declaration, -- 3.2.1
-- A_Private_Extension_Declaration, -- 3.2.1
--
-- A_Subtype_Declaration, -- 3.2.2
--
-- A_Variable_Declaration, -- 3.3.1
-- A_Constant_Declaration, -- 3.3.1
-- A_Deferred_Constant_Declaration, -- 3.3.1
-- A_Single_Task_Declaration, -- 3.3.1
-- A_Single_Protected_Declaration, -- 3.3.1
--
-- An_Integer_Number_Declaration, -- 3.3.2
-- A_Real_Number_Declaration, -- 3.3.2
--
-- An_Enumeration_Literal_Specification, -- 3.5.1
--
-- A_Discriminant_Specification, -- 3.7
--
-- A_Component_Declaration, -- 3.8
--
-- A_Loop_Parameter_Specification, -- 5.5
-- A_Generalized_Iterator_Specification, -- 5.5.2
-- An_Element_Iterator_Specification, -- 5.5.2
--
-- A_Procedure_Declaration, -- 6.1
-- A_Function_Declaration, -- 6.1
--
-- A_Parameter_Specification, -- 6.1
--
-- A_Procedure_Body_Declaration, -- 6.3
-- A_Function_Body_Declaration, -- 6.3
--
-- A_Package_Declaration, -- 7.1
-- A_Package_Body_Declaration, -- 7.2
--
-- An_Object_Renaming_Declaration, -- 8.5.1
-- An_Exception_Renaming_Declaration, -- 8.5.2
-- A_Package_Renaming_Declaration, -- 8.5.3
-- A_Procedure_Renaming_Declaration, -- 8.5.4
-- A_Function_Renaming_Declaration, -- 8.5.4
-- A_Generic_Package_Renaming_Declaration, -- 8.5.5
-- A_Generic_Procedure_Renaming_Declaration, -- 8.5.5
-- A_Generic_Function_Renaming_Declaration, -- 8.5.5
--
-- A_Task_Body_Declaration, -- 9.1
-- A_Protected_Body_Declaration, -- 9.4
--
-- An_Entry_Declaration, -- 9.5.2
-- An_Entry_Body_Declaration, -- 9.5.2
-- An_Entry_Index_Specification, -- 9.5.2
--
-- A_Procedure_Body_Stub, -- 10.1.3
-- A_Function_Body_Stub, -- 10.1.3
-- A_Package_Body_Stub, -- 10.1.3
-- A_Task_Body_Stub, -- 10.1.3
-- A_Protected_Body_Stub, -- 10.1.3
--
-- An_Exception_Declaration, -- 11.1
-- A_Choice_Parameter_Specification, -- 11.2
--
-- A_Generic_Procedure_Declaration, -- 12.1
-- A_Generic_Function_Declaration, -- 12.1
-- A_Generic_Package_Declaration, -- 12.1
--
-- A_Package_Instantiation, -- 12.3
-- A_Procedure_Instantiation, -- 12.3
-- A_Function_Instantiation, -- 12.3
--
-- A_Formal_Object_Declaration, -- 12.4
-- A_Formal_Type_Declaration, -- 12.5
-- A_Formal_Procedure_Declaration, -- 12.6
-- A_Formal_Function_Declaration, -- 12.6
-- A_Formal_Package_Declaration, -- 12.7
-- A_Formal_Package_Declaration_With_Box, -- 12.7
--
-- Not_A_Declaration. -- An unexpected element
----------------------------------------------------------------------------
function PARSE_Declaration
(Ada_Declaration : Asis.Element)
return Query_Array
is
begin
case Asis.Elements.Declaration_Kind (Ada_Declaration) is
-- An_Ordinary_Type_Declaration, -- 3.2.1
-- A_Protected_Type_Declaration, -- 3.2.1
-- A_Formal_Type_Declaration, -- 12.5
when An_Ordinary_Type_Declaration |
A_Formal_Type_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Single_Element_Query,
Asis.Declarations.Discriminant_Part'Access),
3 => (Single_Element_Query,
Asis.Declarations.Type_Declaration_View'Access));
-- A_Task_Type_Declaration, -- 3.2.1
-- A_Private_Type_Declaration, -- 3.2.1
-- A_Private_Extension_Declaration, -- 3.2.1
when A_Private_Type_Declaration |
A_Private_Extension_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Single_Element_Query,
Asis.Declarations.Discriminant_Part'Access),
3 => (Single_Element_Query,
Asis.Declarations.Type_Declaration_View'Access));
-- |A2005 start
when A_Task_Type_Declaration |
A_Protected_Type_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Single_Element_Query,
Asis.Declarations.Discriminant_Part'Access),
3 => (Element_List_Query,
Asis.Declarations.Declaration_Interface_List'Access),
4 => (Single_Element_Query,
Asis.Declarations.Type_Declaration_View'Access));
-- |A2005 end
-- An_Incomplete_Type_Declaration, -- 3.2.1
-- |A2005 start
-- A_Tagged_Incomplete_Type_Declaration, -- 3.10.1(2)
-- |A2005 end
when An_Incomplete_Type_Declaration |
-- |A2005 start
A_Tagged_Incomplete_Type_Declaration |
-- |A2005 end
-- |A2012 start
A_Formal_Incomplete_Type_Declaration =>
-- |A2012 end
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Single_Element_Query,
Asis.Declarations.Discriminant_Part'Access));
-- A_Variable_Declaration, -- 3.3.1
-- A_Constant_Declaration, -- 3.3.1
when A_Variable_Declaration |
A_Constant_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Single_Element_Query,
Asis.Declarations.Object_Declaration_View'Access),
3 => (Single_Element_Query,
Asis.Declarations.Initialization_Expression'Access));
-- A_Deferred_Constant_Declaration, -- 3.3.1
-- A_Single_Task_Declaration, -- 3.3.1
-- A_Single_Protected_Declaration. -- 3.3.1
when A_Deferred_Constant_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Single_Element_Query,
Asis.Declarations.Object_Declaration_View'Access));
-- |A2005 start
when A_Single_Task_Declaration |
A_Single_Protected_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Element_List_Query,
Asis.Declarations.Declaration_Interface_List'Access),
3 => (Single_Element_Query,
Asis.Declarations.Object_Declaration_View'Access));
-- |A2005 end
-- An_Integer_Number_Declaration, -- 3.3.2
-- A_Real_Number_Declaration, -- 3.3.2
when An_Integer_Number_Declaration |
A_Real_Number_Declaration =>
return Query_Array'
(1 => (Element_List_Query,
Asis.Declarations.Names'Access),
2 => (Single_Element_Query,
Asis.Declarations.Initialization_Expression'Access));
-- A_Procedure_Declaration, -- 6.1
-- A_Null_Procedure_Declaration, -- 6.7
when A_Procedure_Declaration |
-- |A2005 start
A_Null_Procedure_Declaration =>
-- |A2005 end
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Element_List_Query,
Asis.Declarations.Parameter_Profile'Access),
3 => (Element_List_Query,
Asis.Declarations.Aspect_Specifications'Access));
-- A_Procedure_Body_Stub, -- 10.1.3
when A_Procedure_Body_Stub =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Element_List_Query,
Asis.Declarations.Parameter_Profile'Access));
-- A_Function_Declaration, -- 6.1
-- |A2005 start
when A_Function_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Element_List_Query,
Asis.Declarations.Parameter_Profile'Access),
3 => (Single_Element_Query,
Asis.Declarations.Result_Profile'Access),
4 => (Element_List_Query,
Asis.Declarations.Aspect_Specifications'Access));
-- |A2005 end
-- A_Function_Body_Stub, -- 10.1.3
when A_Function_Body_Stub =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Element_List_Query,
Asis.Declarations.Parameter_Profile'Access),
3 => (Single_Element_Query,
Asis.Declarations.Result_Profile'Access));
-- |A2005 start
-- A_Return_Variable_Specification, -- 6.5
-- A_Return_Constant_Specification, -- 6.5
when A_Return_Variable_Specification |
A_Return_Constant_Specification =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Single_Element_Query,
Asis.Declarations.Object_Declaration_View'Access),
3 => (Single_Element_Query,
Asis.Declarations.Initialization_Expression'Access));
-- |A2005 end
-- A_Package_Declaration, -- 7.1
-- |A2012 start
when An_Expression_Function_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Element_List_Query,
Asis.Declarations.Parameter_Profile'Access),
3 => (Single_Element_Query,
Asis.Declarations.Result_Profile'Access),
4 => (Single_Element_Query,
Asis.Declarations.Result_Expression'Access),
5 => (Element_List_Query,
Asis.Declarations.Aspect_Specifications'Access));
-- |A2012 end
when A_Package_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Element_List_Query_With_Boolean,
Asis.Declarations.Visible_Part_Declarative_Items'Access, True),
3 => (Element_List_Query_With_Boolean,
Asis.Declarations.Private_Part_Declarative_Items'Access, True));
-- An_Entry_Declaration, -- 9.5.2
when An_Entry_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Single_Element_Query,
Asis.Declarations.Entry_Family_Definition'Access),
3 => (Element_List_Query,
Asis.Declarations.Parameter_Profile'Access));
-- A_Package_Body_Stub, -- 10.1.3
-- A_Task_Body_Stub, -- 10.1.3
-- A_Protected_Body_Stub, -- 10.1.3
-- An_Exception_Declaration, -- 11.1
when A_Package_Body_Stub |
A_Task_Body_Stub |
A_Protected_Body_Stub |
An_Exception_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access));
-- A_Generic_Procedure_Declaration, -- 12.1
when A_Generic_Procedure_Declaration =>
return Query_Array'
(1 => (Element_List_Query_With_Boolean,
Asis.Declarations.Generic_Formal_Part'Access, True),
2 => (Element_List_Query, Asis.Declarations.Names'Access),
3 => (Element_List_Query,
Asis.Declarations.Parameter_Profile'Access));
-- A_Generic_Function_Declaration, -- 12.1
when A_Generic_Function_Declaration =>
return Query_Array'
(1 => (Element_List_Query_With_Boolean,
Asis.Declarations.Generic_Formal_Part'Access, True),
2 => (Element_List_Query,
Asis.Declarations.Names'Access),
3 => (Element_List_Query,
Asis.Declarations.Parameter_Profile'Access),
4 => (Single_Element_Query,
Asis.Declarations.Result_Profile'Access));
-- A_Generic_Package_Declaration. -- 12.1
when A_Generic_Package_Declaration =>
return Query_Array'
(1 => (Element_List_Query_With_Boolean,
Asis.Declarations.Generic_Formal_Part'Access, True),
2 => (Element_List_Query,
Asis.Declarations.Names'Access),
3 => (Element_List_Query_With_Boolean,
Asis.Declarations.Visible_Part_Declarative_Items'Access,
True),
4 => (Element_List_Query_With_Boolean,
Asis.Declarations.Private_Part_Declarative_Items'Access,
True));
-- A_Procedure_Body_Declaration, -- 6.3
when A_Procedure_Body_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Element_List_Query,
Asis.Declarations.Parameter_Profile'Access),
3 => (Element_List_Query_With_Boolean,
Asis.Declarations.Body_Declarative_Items'Access,
True),
4 => (Element_List_Query_With_Boolean,
Asis.Declarations.Body_Statements'Access,
True),
5 => (Element_List_Query_With_Boolean,
Asis.Declarations.Body_Exception_Handlers'Access,
True));
-- A_Function_Body_Declaration, -- 6.3
when A_Function_Body_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Element_List_Query,
Asis.Declarations.Parameter_Profile'Access),
3 => (Single_Element_Query,
Asis.Declarations.Result_Profile'Access),
4 => (Element_List_Query_With_Boolean,
Asis.Declarations.Body_Declarative_Items'Access,
True),
5 => (Element_List_Query_With_Boolean,
Asis.Declarations.Body_Statements'Access,
True),
6 => (Element_List_Query_With_Boolean,
Asis.Declarations.Body_Exception_Handlers'Access,
True));
-- A_Package_Body_Declaration, -- 7.2
when A_Package_Body_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Element_List_Query_With_Boolean,
Asis.Declarations.Body_Declarative_Items'Access,
True),
3 => (Element_List_Query_With_Boolean,
Asis.Declarations.Body_Statements'Access,
True),
4 => (Element_List_Query_With_Boolean,
Asis.Declarations.Body_Exception_Handlers'Access,
True));
-- A_Task_Body_Declaration, -- 9.1
when A_Task_Body_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Element_List_Query_With_Boolean,
Asis.Declarations.Body_Declarative_Items'Access,
True),
3 => (Element_List_Query_With_Boolean,
Asis.Declarations.Body_Statements'Access, True),
4 => (Element_List_Query_With_Boolean,
Asis.Declarations.Body_Exception_Handlers'Access,
True));
-- An_Entry_Body_Declaration, -- 9.5.2
when An_Entry_Body_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Single_Element_Query,
Asis.Declarations.Entry_Index_Specification'Access),
3 => (Element_List_Query,
Asis.Declarations.Parameter_Profile'Access),
4 => (Single_Element_Query,
Asis.Declarations.Entry_Barrier'Access),
5 => (Element_List_Query_With_Boolean,
Asis.Declarations.Body_Declarative_Items'Access,
True),
6 => (Element_List_Query_With_Boolean,
Asis.Declarations.Body_Statements'Access,
True),
7 => (Element_List_Query_With_Boolean,
Asis.Declarations.Body_Exception_Handlers'Access,
True));
-- A_Protected_Body_Declaration, -- 9.4
when A_Protected_Body_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Element_List_Query_With_Boolean,
Asis.Declarations.Protected_Operation_Items'Access,
True));
-- An_Object_Renaming_Declaration, -- 8.5.1
when An_Object_Renaming_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Single_Element_Query,
Asis.Declarations.Object_Declaration_View'Access),
3 => (Single_Element_Query,
Asis.Declarations.Renamed_Entity'Access));
-- An_Exception_Renaming_Declaration, -- 8.5.2
-- A_Package_Renaming_Declaration, -- 8.5.3
-- A_Generic_Package_Renaming_Declaration, -- 8.5.5
-- A_Generic_Procedure_Renaming_Declaration, -- 8.5.5
-- A_Generic_Function_Renaming_Declaration. -- 8.5.5
when An_Exception_Renaming_Declaration |
A_Package_Renaming_Declaration |
A_Generic_Package_Renaming_Declaration |
A_Generic_Procedure_Renaming_Declaration |
A_Generic_Function_Renaming_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Single_Element_Query,
Asis.Declarations.Renamed_Entity'Access));
-- A_Procedure_Renaming_Declaration, -- 8.5.4
when A_Procedure_Renaming_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Element_List_Query,
Asis.Declarations.Parameter_Profile'Access),
3 => (Single_Element_Query,
Asis.Declarations.Renamed_Entity'Access));
-- A_Function_Renaming_Declaration, -- 8.5.4
when A_Function_Renaming_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Element_List_Query,
Asis.Declarations.Parameter_Profile'Access),
3 => (Single_Element_Query,
Asis.Declarations.Result_Profile'Access),
4 => (Single_Element_Query,
Asis.Declarations.Renamed_Entity'Access));
-- A_Package_Instantiation, -- 12.3
-- A_Procedure_Instantiation, -- 12.3
-- A_Function_Instantiation, -- 12.3
-- A_Formal_Package_Declaration. -- 12.3
when A_Package_Instantiation |
A_Procedure_Instantiation |
A_Function_Instantiation |
A_Formal_Package_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Single_Element_Query,
Asis.Declarations.Generic_Unit_Name'Access),
3 => (Element_List_Query_With_Boolean,
Asis.Declarations.Generic_Actual_Part'Access,
False)
-- Will Parse the Actual_Part in the UN-Normalized Form.
-- (as noticed in the Traverse_Element specification
-- (see asisi_elements.ads))
);
-- A_Subtype_Declaration, -- 3.2.2
when A_Subtype_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Single_Element_Query,
Asis.Declarations.Type_Declaration_View'Access));
-- An_Enumeration_Literal_Specification, -- 3.5.1
when An_Enumeration_Literal_Specification =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access));
-- A_Discriminant_Specification, -- 3.7 -> Trait_Kinds
-- A_Parameter_Specification, -- 6.1 -> Trait_Kinds
when A_Discriminant_Specification |
A_Parameter_Specification =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Single_Element_Query,
Asis.Declarations.Object_Declaration_View'Access),
3 => (Single_Element_Query,
Asis.Declarations.Initialization_Expression'Access));
-- A_Component_Declaration, -- 3.8
when A_Component_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Single_Element_Query,
Asis.Declarations.Object_Declaration_View'Access),
3 => (Single_Element_Query,
Asis.Declarations.Initialization_Expression'Access));
-- A_Loop_Parameter_Specification, -- 5.5 -> Trait_Kinds
-- An_Entry_Index_Specification, -- 9.5.2
when A_Loop_Parameter_Specification |
An_Entry_Index_Specification =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Single_Element_Query,
Asis.Declarations.Specification_Subtype_Definition'Access));
when A_Generalized_Iterator_Specification =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Single_Element_Query,
Asis.Declarations.Iteration_Scheme_Name'Access));
when An_Element_Iterator_Specification =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Single_Element_Query,
Asis.Declarations.Subtype_Indication'Access),
3 => (Single_Element_Query,
Asis.Declarations.Iteration_Scheme_Name'Access));
-- A_Choice_Parameter_Specification, -- 11.2
when A_Choice_Parameter_Specification =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access));
-- A_Formal_Object_Declaration, -- 12.4 -> Mode_Kinds
-- |A2005 start
when A_Formal_Object_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Single_Element_Query,
Asis.Declarations.Object_Declaration_View'Access),
3 => (Single_Element_Query,
Asis.Declarations.Initialization_Expression'Access));
-- |A2005 end
-- A_Formal_Procedure_Declaration, -- 12.6 -> Default_Kinds
when A_Formal_Procedure_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Element_List_Query,
Asis.Declarations.Parameter_Profile'Access),
3 => (Single_Element_Query,
Asis.Extensions.Formal_Subprogram_Default'Access)
-- Asis.Declarations.Formal_Subprogram_Default
-- cannot be used here!
);
-- A_Formal_Function_Declaration, -- 12.6 -> Default_Kinds
when A_Formal_Function_Declaration =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Element_List_Query,
Asis.Declarations.Parameter_Profile'Access),
3 => (Single_Element_Query,
Asis.Declarations.Result_Profile'Access),
4 => (Single_Element_Query,
Asis.Extensions.Formal_Subprogram_Default'Access)
-- Asis.Declarations.Formal_Subprogram_Default
-- cannot be used here!
);
-- A_Formal_Package_Declaration_With_Box -- 12.7
when A_Formal_Package_Declaration_With_Box =>
return Query_Array'
(1 => (Element_List_Query, Asis.Declarations.Names'Access),
2 => (Single_Element_Query,
Asis.Declarations.Generic_Unit_Name'Access));
-- Not_A_Declaration, -- An unexpected element
when Not_A_Declaration =>
raise Internal_Implementation_Error;
end case;
end PARSE_Declaration;
-------------------------
-- PARSE_Defining_Name --
-------------------------
function PARSE_Defining_Name
(Ada_Defining_Name : Asis.Element)
return Query_Array
is
begin
-- PARSE_Defining_Name deals with every Defining_Name 's Element_Kinds.
-- That is to say, it deals with Defining_Name_Kinds :
-- Not_A_Defining_Name, -- An unexpected element
-- A_Defining_Identifier, -- 3.1
-- A_Defining_Character_Literal, -- 3.5.1
-- A_Defining_Enumeration_Literal, -- 3.5.1
-- A_Defining_Operator_Symbol, -- 6.1
-- A_Defining_Expanded_Name.
-- 6.1 program_unit_name.defining_identifier
case Asis.Elements.Defining_Name_Kind (Ada_Defining_Name) is
-- Terminal Elements : DO NOTHING !!!!
when A_Defining_Identifier |
A_Defining_Character_Literal |
A_Defining_Enumeration_Literal |
A_Defining_Operator_Symbol =>
-- Terminal Elements : DO NOTHING !!!!
return No_Query;
when A_Defining_Expanded_Name =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Declarations.Defining_Prefix'Access),
2 => (Single_Element_Query,
Asis.Declarations.Defining_Selector'Access));
when Not_A_Defining_Name =>
raise Internal_Implementation_Error;
end case;
end PARSE_Defining_Name;
----------------------
-- PARSE_Definition --
----------------------
-----------------------------------------------------------------------
-- function PARSE_Definition
--
-- This function parse every definitions
-- The Definition_Kinds are :
--
-- Definition_Kinds LRM P.
-- SubType_Kind
-----------------------------------------------------------------------
-- Not_A_Definition, -- An unexpected element
--
-- A_Type_Definition, -- 3.2.1
-- Not_A_Type_Definition, -- An unexpected element
-- A_Derived_Type_Definition, -- 3.4
-- A_Derived_Record_Extension_Definition, -- 3.4
-- An_Enumeration_Type_Definition, -- 3.5.1
-- A_Signed_Integer_Type_Definition, -- 3.5.4
-- A_Modular_Type_Definition, -- 3.5.4
-- A_Root_Type_Definition, -- 3.5.4(10), 3.5.6(4)
-- A_Floating_Point_Definition, -- 3.5.7
-- An_Ordinary_Fixed_Point_Definition, -- 3.5.9
-- A_Decimal_Fixed_Point_Definition, -- 3.5.9
-- An_Unconstrained_Array_Definition, -- 3.6
-- A_Constrained_Array_Definition, -- 3.6
-- A_Record_Type_Definition, -- 3.8
-- A_Tagged_Record_Type_Definition, -- 3.8
-- An_Access_Type_Definition. -- 3.10
-- Not_An_Access_Type_Definition, -- An unexpected element
-- A_Pool_Specific_Access_To_Variable, -- access subtype_indication
-- An_Access_To_Variable, -- access all subtype_indication
-- An_Access_To_Constant, -- access constant subtype_indication
-- An_Access_To_Procedure, -- access procedure
-- An_Access_To_Protected_Procedure, -- access protected procedure
-- An_Access_To_Function, -- access function
-- An_Access_To_Protected_Function. -- access protected function
--
-- A_Subtype_Indication, -- 3.2.2
--
-- A_Constraint, -- 3.2.2
-- Not_A_Constraint, -- An unexpected element
-- A_Range_Attribute_Reference, -- 3.2.2, 3.5
-- A_Simple_Expression_Range, -- 3.2.2, 3.5
-- A_Digits_Constraint, -- 3.2.2, 3.5.9
-- A_Delta_Constraint, -- 3.2.2, J.3
-- An_Index_Constraint, -- 3.2.2, 3.6.1
-- A_Discriminant_Constraint. -- 3.2.2
--
-- A_Component_Definition, -- 3.6
--
-- A_Discrete_Subtype_Definition, -- 3.6
-- A_Discrete_Range, -- 3.6.1
-- Not_A_Discrete_Range, -- An unexpected element
-- A_Discrete_Subtype_Indication, -- 3.6.1, 3.2.2
-- A_Discrete_Range_Attribute_Reference, -- 3.6.1, 3.5
-- A_Discrete_Simple_Expression_Range. -- 3.6.1, 3.5
--
--
-- An_Unknown_Discriminant_Part, -- 3.7
-- A_Known_Discriminant_Part, -- 3.7
--
-- A_Record_Definition, -- 3.8
-- A_Null_Record_Definition, -- 3.8
--
-- A_Null_Component, -- 3.8
-- A_Variant_Part, -- 3.8
-- A_Variant, -- 3.8
--
-- An_Others_Choice, -- 3.8.1, 4.3.1, 4.3.3, 11.2
--
-- A_Private_Type_Definition, -- 7.3
-- A_Tagged_Private_Type_Definition, -- 7.3
-- A_Private_Extension_Definition, -- 7.3
--
-- A_Task_Definition, -- 9.1
-- A_Protected_Definition, -- 9.4
--
-- A_Formal_Type_Definition. -- 12.5
-- Not_A_Formal_Type_Definition, -- An unexpected element
-- A_Formal_Private_Type_Definition, -- 12.5.1
-- A_Formal_Tagged_Private_Type_Definition, -- 12.5.1
-- A_Formal_Derived_Type_Definition, -- 12.5.1
-- A_Formal_Discrete_Type_Definition, -- 12.5.2
-- A_Formal_Signed_Integer_Type_Definition, -- 12.5.2
-- A_Formal_Modular_Type_Definition, -- 12.5.2
-- A_Formal_Floating_Point_Definition, -- 12.5.2
-- A_Formal_Ordinary_Fixed_Point_Definition, -- 12.5.2
-- A_Formal_Decimal_Fixed_Point_Definition, -- 12.5.2
-- A_Formal_Unconstrained_Array_Definition, -- 12.5.3
-- A_Formal_Constrained_Array_Definition, -- 12.5.3
-- A_Formal_Access_Type_Definition. -- 12.5.4
--
-----------------------------------------------------------------------
function PARSE_Definition
(Ada_Definition : Asis.Element)
return Query_Array
is
begin
case Asis.Elements.Definition_Kind (Ada_Definition) is
when Not_A_Definition =>
raise Internal_Implementation_Error;
-- A_Type_Definition. -- 3.2.1
when A_Type_Definition =>
case Asis.Elements.Type_Kind (Ada_Definition) is
-- Not_A_Type_Definition, -- An unexpected element
when Not_A_Type_Definition =>
raise Internal_Implementation_Error;
-- A_Derived_Type_Definition, -- 3.4
when A_Derived_Type_Definition =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Definitions.Parent_Subtype_Indication'Access));
-- A_Derived_Record_Extension_Definition, -- 3.4
when A_Derived_Record_Extension_Definition =>
-- |A2005 start
return Query_Array'
(1 => (Single_Element_Query,
Asis.Definitions.
Parent_Subtype_Indication'Access),
2 => (Element_List_Query,
Asis.Definitions.
Definition_Interface_List'Access),
3 => (Single_Element_Query,
Asis.Definitions.Record_Definition'Access));
-- |A2005 end
-- An_Enumeration_Type_Definition, -- 3.5.1
when An_Enumeration_Type_Definition =>
return Query_Array'
(1 => (Element_List_Query,
Asis.Definitions.Enumeration_Literal_Declarations'Access));
-- A_Signed_Integer_Type_Definition, -- 3.5.4
when A_Signed_Integer_Type_Definition =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Definitions.Integer_Constraint'Access));
-- A_Modular_Type_Definition, -- 3.5.4
when A_Modular_Type_Definition =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Definitions.Mod_Static_Expression'Access));
-- A_Root_Type_Definition, -- 3.5.4(10), 3.5.6(4)
when A_Root_Type_Definition =>
return No_Query;
-- A_Floating_Point_Definition, -- 3.5.7
when A_Floating_Point_Definition =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Definitions.Digits_Expression'Access),
2 => (Single_Element_Query,
Asis.Definitions.Real_Range_Constraint'Access));
-- An_Ordinary_Fixed_Point_Definition, -- 3.5.9
when An_Ordinary_Fixed_Point_Definition =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Definitions.Delta_Expression'Access),
2 => (Single_Element_Query,
Asis.Definitions.Real_Range_Constraint'Access));
-- A_Decimal_Fixed_Point_Definition, -- 3.5.9
when A_Decimal_Fixed_Point_Definition =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Definitions.Delta_Expression'Access),
2 => (Single_Element_Query,
Asis.Definitions.Digits_Expression'Access),
3 => (Single_Element_Query,
Asis.Definitions.Real_Range_Constraint'Access));
-- An_Unconstrained_Array_Definition, -- 3.6
when An_Unconstrained_Array_Definition =>
return Query_Array'
(1 => (Element_List_Query,
Asis.Definitions.Index_Subtype_Definitions'Access),
2 => (Single_Element_Query,
Asis.Definitions.Array_Component_Definition'Access));
-- A_Constrained_Array_Definition, -- 3.6
when A_Constrained_Array_Definition =>
return Query_Array'
(1 => (Element_List_Query,
Asis.Definitions.Discrete_Subtype_Definitions'Access),
2 => (Single_Element_Query,
Asis.Definitions.Array_Component_Definition'Access));
-- A_Record_Type_Definition, -- 3.8
-- A_Tagged_Record_Type_Definition, -- 3.8
when A_Record_Type_Definition |
A_Tagged_Record_Type_Definition =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Definitions.Record_Definition'Access));
-- |A2005 start
-- An_Interface_Type_Definition, -- 3.9.4
when An_Interface_Type_Definition =>
return Query_Array'
(1 => (Element_List_Query,
Asis.Definitions.Definition_Interface_List'Access));
-- |A2005 end
-- An_Access_Type_Definition. -- 3.10
when An_Access_Type_Definition =>
case Asis.Elements.Access_Type_Kind (Ada_Definition) is
-- Not_An_Access_Type_Definition,
when Not_An_Access_Type_Definition =>
raise Internal_Implementation_Error;
-- A_Pool_Specific_Access_To_Variable,
-- An_Access_To_Variable,
-- An_Access_To_Constant,
when A_Pool_Specific_Access_To_Variable |
An_Access_To_Variable |
An_Access_To_Constant =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Definitions.Access_To_Object_Definition'Access));
-- An_Access_To_Procedure,
-- An_Access_To_Protected_Procedure,
when An_Access_To_Procedure |
An_Access_To_Protected_Procedure =>
return Query_Array'
(1 => (Element_List_Query,
Asis.Definitions.Access_To_Subprogram_Parameter_Profile'Access));
-- An_Access_To_Function,
-- An_Access_To_Protected_Function
when An_Access_To_Function |
An_Access_To_Protected_Function =>
return Query_Array'
(1 => (Element_List_Query,
Asis.Definitions.Access_To_Subprogram_Parameter_Profile'Access),
2 => (Single_Element_Query,
Asis.Definitions.Access_To_Function_Result_Profile'Access));
end case;
end case;
-- A_Subtype_Indication, -- 3.2.2
when A_Subtype_Indication =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Definitions.Subtype_Mark'Access),
2 => (Single_Element_Query,
Asis.Definitions.Subtype_Constraint'Access));
-- A_Constraint, -- 3.2.2
when A_Constraint =>
case Asis.Elements.Constraint_Kind (Ada_Definition) is
-- Not_A_Constraint, -- An unexpected element
when Not_A_Constraint =>
raise Internal_Implementation_Error;
-- A_Range_Attribute_Reference, -- 3.2.2, 3.5
when A_Range_Attribute_Reference =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Definitions.Range_Attribute'Access));
-- A_Simple_Expression_Range, -- 3.2.2, 3.5
when A_Simple_Expression_Range =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Definitions.Lower_Bound'Access),
2 => (Single_Element_Query,
Asis.Definitions.Upper_Bound'Access));
-- A_Digits_Constraint, -- 3.2.2, 3.5.9
when A_Digits_Constraint =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Definitions.Digits_Expression'Access),
2 => (Single_Element_Query,
Asis.Definitions.Real_Range_Constraint'Access));
-- A_Delta_Constraint, -- 3.2.2, J.3
when A_Delta_Constraint =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Definitions.Delta_Expression'Access),
2 => (Single_Element_Query,
Asis.Definitions.Real_Range_Constraint'Access));
-- An_Index_Constraint, -- 3.2.2, 3.6.1
when An_Index_Constraint =>
return Query_Array'
(1 => (Element_List_Query,
Asis.Definitions.Discrete_Ranges'Access));
-- A_Discriminant_Constraint. -- 3.2.2
when A_Discriminant_Constraint =>
return Query_Array'
(1 => (Element_List_Query_With_Boolean,
Asis.Definitions.Discriminant_Associations'Access, False));
end case;
-- A_Component_Definition, -- 3.6
when A_Component_Definition =>
-- |A2005 start
return Query_Array'
(1 => (Single_Element_Query,
Asis.Definitions.Component_Definition_View'Access));
-- |A2005 end
-- A_Discrete_Subtype_Definition, -- 3.6
-- A_Discrete_Range, -- 3.6.1
when A_Discrete_Subtype_Definition |
A_Discrete_Range =>
case Asis.Elements.Discrete_Range_Kind (Ada_Definition) is
-- Not_A_Discrete_Range, -- An unexpected element
when Not_A_Discrete_Range =>
raise Internal_Implementation_Error;
-- A_Discrete_Subtype_Indication, -- 3.6.1, 3.2.2
when A_Discrete_Subtype_Indication =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Definitions.Subtype_Mark'Access),
2 => (Single_Element_Query,
Asis.Definitions.Subtype_Constraint'Access));
-- A_Discrete_Range_Attribute_Reference, -- 3.6.1, 3.5
when A_Discrete_Range_Attribute_Reference =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Definitions.Range_Attribute'Access));
-- A_Discrete_Simple_Expression_Range. -- 3.6.1, 3.5
when A_Discrete_Simple_Expression_Range =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Definitions.Lower_Bound'Access),
2 => (Single_Element_Query,
Asis.Definitions.Upper_Bound'Access));
end case;
-- An_Unknown_Discriminant_Part, -- 3.7
when An_Unknown_Discriminant_Part =>
return No_Query;
-- A_Known_Discriminant_Part, -- 3.7
when A_Known_Discriminant_Part =>
return Query_Array'
(1 => (Element_List_Query,
Asis.Definitions.Discriminants'Access));
-- A_Record_Definition, -- 3.8
when A_Record_Definition =>
return Query_Array'
(1 => (Element_List_Query_With_Boolean,
Asis.Definitions.Record_Components'Access, True));
-- A_Null_Record_Definition, -- 3.8
-- A_Null_Component, -- 3.8
when A_Null_Record_Definition |
A_Null_Component =>
return No_Query;
-- A_Variant_Part, -- 3.8
when A_Variant_Part =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Definitions.Discriminant_Direct_Name'Access),
2 => (Element_List_Query_With_Boolean,
Asis.Definitions.Variants'Access, True));
-- A_Variant, -- 3.8
when A_Variant =>
return Query_Array'
(1 => (Element_List_Query,
Asis.Definitions.Variant_Choices'Access),
2 => (Element_List_Query_With_Boolean,
Asis.Definitions.Record_Components'Access, True));
-- An_Others_Choice, -- 3.8.1, 4.3.1, 4.3.3, 11.2
when An_Others_Choice =>
return No_Query;
-- |A2005 start
-- An_Access_Definition, -- 3.10(6/2) -> Access_Definition_Kinds
when An_Access_Definition =>
case Asis.Elements.Access_Definition_Kind (Ada_Definition) is
when Not_An_Access_Definition =>
raise Internal_Implementation_Error;
when An_Anonymous_Access_To_Variable |
An_Anonymous_Access_To_Constant =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Definitions.
Anonymous_Access_To_Object_Subtype_Mark'
Access));
when An_Anonymous_Access_To_Procedure |
An_Anonymous_Access_To_Protected_Procedure =>
return Query_Array'
(1 => (Element_List_Query,
Asis.Definitions.
Access_To_Subprogram_Parameter_Profile'
Access));
when An_Anonymous_Access_To_Function |
An_Anonymous_Access_To_Protected_Function =>
return Query_Array'
(1 => (Element_List_Query,
Asis.Definitions.
Access_To_Subprogram_Parameter_Profile'Access),
2 => (Single_Element_Query,
Asis.Definitions.
Access_To_Function_Result_Profile'Access));
end case;
-- |A2005 end
-- A_Private_Type_Definition, -- 7.3
-- A_Tagged_Private_Type_Definition, -- 7.3
when A_Private_Type_Definition |
A_Tagged_Private_Type_Definition =>
return No_Query;
-- A_Private_Extension_Definition, -- 7.3
when A_Private_Extension_Definition =>
-- |A2005 start
return Query_Array'
(1 => (Single_Element_Query,
Asis.Definitions.Ancestor_Subtype_Indication'Access),
2 => (Element_List_Query,
Asis.Definitions.Definition_Interface_List'Access));
-- |A2005 end
-- A_Task_Definition, -- 9.1
-- A_Protected_Definition, -- 9.4
when A_Task_Definition |
A_Protected_Definition =>
return Query_Array'
(1 => (Element_List_Query_With_Boolean,
Asis.Definitions.Visible_Part_Items'Access, True),
2 => (Element_List_Query_With_Boolean,
Asis.Definitions.Private_Part_Items'Access, True));
-- A_Formal_Type_Definition. -- 12.5
when A_Formal_Type_Definition =>
case Asis.Elements.Formal_Type_Kind (Ada_Definition) is
-- Not_A_Formal_Type_Definition, -- An unexpected element
when Not_A_Formal_Type_Definition =>
raise Internal_Implementation_Error;
-- A_Formal_Private_Type_Definition, -- 12.5.1
-- A_Formal_Tagged_Private_Type_Definition, -- 12.5.1
-- A_Formal_Discrete_Type_Definition, -- 12.5.2
-- A_Formal_Signed_Integer_Type_Definition, -- 12.5.2
-- A_Formal_Modular_Type_Definition, -- 12.5.2
-- A_Formal_Floating_Point_Definition, -- 12.5.2
-- A_Formal_Ordinary_Fixed_Point_Definition, -- 12.5.2
-- A_Formal_Decimal_Fixed_Point_Definition, -- 12.5.2
when A_Formal_Private_Type_Definition |
A_Formal_Tagged_Private_Type_Definition |
A_Formal_Discrete_Type_Definition |
A_Formal_Signed_Integer_Type_Definition |
A_Formal_Modular_Type_Definition |
A_Formal_Floating_Point_Definition |
A_Formal_Ordinary_Fixed_Point_Definition |
A_Formal_Decimal_Fixed_Point_Definition =>
return No_Query;
-- A_Formal_Derived_Type_Definition, -- 12.5.1
when A_Formal_Derived_Type_Definition =>
-- |A2005 start
return Query_Array'
(1 => (Single_Element_Query,
Asis.Definitions.Subtype_Mark'Access),
2 => (Element_List_Query,
Asis.Definitions.
Definition_Interface_List'Access));
-- |A2005 end
-- |A2005 start
-- A_Formal_Interface_Type_Definition, -- 12.5.5(2)
when A_Formal_Interface_Type_Definition =>
return Query_Array'
(1 => (Element_List_Query,
Asis.Definitions.Definition_Interface_List'Access));
-- |A2005 end
-- A_Formal_Unconstrained_Array_Definition, -- 12.5.3
when A_Formal_Unconstrained_Array_Definition =>
return Query_Array'
(1 => (Element_List_Query,
Asis.Definitions.Index_Subtype_Definitions'Access),
2 => (Single_Element_Query,
Asis.Definitions.Array_Component_Definition'Access));
-- A_Formal_Constrained_Array_Definition, -- 12.5.3
when A_Formal_Constrained_Array_Definition =>
return Query_Array'
(1 => (Element_List_Query,
Asis.Definitions.Discrete_Subtype_Definitions'Access),
2 => (Single_Element_Query,
Asis.Definitions.Array_Component_Definition'Access));
-- A_Formal_Access_Type_Definition. -- 12.5.4
when A_Formal_Access_Type_Definition =>
case Asis.Elements.Access_Type_Kind (Ada_Definition) is
-- Not_An_Access_Type_Definition,
when Not_An_Access_Type_Definition =>
raise Internal_Implementation_Error;
-- A_Pool_Specific_Access_To_Variable,
-- An_Access_To_Variable,
-- An_Access_To_Constant,
when A_Pool_Specific_Access_To_Variable |
An_Access_To_Variable |
An_Access_To_Constant =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Definitions.Access_To_Object_Definition'Access));
-- An_Access_To_Procedure,
-- An_Access_To_Protected_Procedure,
when An_Access_To_Procedure |
An_Access_To_Protected_Procedure =>
return Query_Array'
(1 => (Element_List_Query,
Asis.Definitions.Access_To_Subprogram_Parameter_Profile'Access));
-- An_Access_To_Function,
-- An_Access_To_Protected_Function
when An_Access_To_Function |
An_Access_To_Protected_Function =>
return Query_Array'
(1 => (Element_List_Query,
Asis.Definitions.Access_To_Subprogram_Parameter_Profile'Access),
2 => (Single_Element_Query,
Asis.Definitions.Access_To_Function_Result_Profile'Access));
end case;
end case;
-- |A2012 start
when An_Aspect_Specification =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Definitions.Aspect_Mark'Access),
2 => (Single_Element_Query,
Asis.Definitions.Aspect_Definition'Access));
-- |A2012 end
end case;
end PARSE_Definition;
----------------------
-- PARSE_Expression --
----------------------
----------------------------------------------------------------------------
-- function PARSE_Expression
--
-- This function parse every expressions
-- The Expression_Kind are :
--
-- An_Integer_Literal, -- 2.4
-- A_Real_Literal, -- 2.4.1
-- A_String_Literal, -- 2.6
--
-- An_Identifier, -- 4.1
-- An_Operator_Symbol, -- 4.1
-- A_Character_Literal, -- 4.1
-- An_Enumeration_Literal, -- 4.1
-- An_Explicit_Dereference, -- 4.1
-- A_Function_Call, -- 4.1
--
-- An_Indexed_Component, -- 4.1.1
-- A_Slice, -- 4.1.2
-- A_Selected_Component, -- 4.1.3
-- An_Attribute_Reference, -- 4.1.4
--
-- A_Record_Aggregate, -- 4.3
-- An_Extension_Aggregate, -- 4.3
-- A_Positional_Array_Aggregate, -- 4.3
-- A_Named_Array_Aggregate, -- 4.3
--
-- An_And_Then_Short_Circuit, -- 4.4
-- An_Or_Else_Short_Circuit, -- 4.4
--
-- An_In_Membership_Test, -- 4.4 Ada 2012
-- A_Not_In_Membership_Test, -- 4.4 Ada 2012
--
-- A_Null_Literal, -- 4.4
-- A_Parenthesized_Expression, -- 4.4
--
-- A_Type_Conversion, -- 4.6
-- A_Qualified_Expression, -- 4.7
--
-- An_Allocation_From_Subtype, -- 4.8
-- An_Allocation_From_Qualified_Expression, -- 4.8
--
-- Not_An_Expression. -- An unexpected element
--
function PARSE_Expression
(Ada_Expression : Asis.Element)
return Query_Array
is
begin
-- maybe there could be a factorization of all Prefix processing here
case Asis.Elements.Expression_Kind (Ada_Expression) is
when Not_An_Expression =>
raise Internal_Implementation_Error;
when An_Integer_Literal |
A_Real_Literal |
A_String_Literal |
An_Identifier |
An_Operator_Symbol |
A_Character_Literal |
An_Enumeration_Literal |
A_Null_Literal =>
return No_Query;
when An_Explicit_Dereference =>
-- P.ALL
return Query_Array'
(1 => (Single_Element_Query, Asis.Expressions.Prefix'Access));
when A_Function_Call =>
-- Abc(...) or Integer'Image(...)
if Subprogram_Call_Needs_Reordering (Ada_Expression) then
return Query_Array'
(1 => (Single_Element_Query,
First_Parameter_Association'Access),
2 => (Single_Element_Query, Asis.Expressions.Prefix'Access),
3 => (Element_List_Query,
All_But_First_Associations'Access));
else
return Query_Array'
(1 => (Single_Element_Query, Asis.Expressions.Prefix'Access),
2 => (Element_List_Query_With_Boolean,
Asis.Expressions.Function_Call_Parameters'Access,
False));
end if;
when An_Indexed_Component =>
-- An_Array(3)
return Query_Array'
(1 => (Single_Element_Query, Asis.Expressions.Prefix'Access),
2 => (Element_List_Query,
Asis.Expressions.Index_Expressions'Access));
when A_Slice => -- An_Array(3 .. 5)
return Query_Array'
(1 => (Single_Element_Query, Asis.Expressions.Prefix'Access),
2 => (Single_Element_Query, Asis.Expressions.Slice_Range'Access));
when A_Selected_Component => -- A.B.C
return Query_Array'
(1 => (Single_Element_Query, Asis.Expressions.Prefix'Access),
2 => (Single_Element_Query, Asis.Expressions.Selector'Access));
when An_Attribute_Reference => -- Priv'Base'First
-- Attribute_Designator_Expressions
case Asis.Elements.Attribute_Kind (Ada_Expression) is
when Not_An_Attribute =>
raise Internal_Implementation_Error;
when A_First_Attribute |
A_Last_Attribute |
A_Length_Attribute |
A_Range_Attribute |
An_Implementation_Defined_Attribute |
An_Unknown_Attribute =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Expressions.Prefix'Access),
2 => (Single_Element_Query,
Asis.Expressions.Attribute_Designator_Identifier'Access),
3 => (Element_List_Query,
Asis.Expressions.Attribute_Designator_Expressions'Access));
when others =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Expressions.Prefix'Access),
2 => (Single_Element_Query,
Asis.Expressions.Attribute_Designator_Identifier'Access));
end case;
when A_Record_Aggregate =>
-- (Field1 => value1, Field2 => value2)
return Query_Array'
(1 => (Element_List_Query_With_Boolean,
Asis.Expressions.Record_Component_Associations'Access, False));
when An_Extension_Aggregate =>
-- (Ewpr with Field1 => value1, Field2 => value2)
return Query_Array'
(1 => (Single_Element_Query,
Asis.Expressions.Extension_Aggregate_Expression'Access),
2 => (Element_List_Query_With_Boolean,
Asis.Expressions.Record_Component_Associations'Access, False));
when A_Positional_Array_Aggregate |
A_Named_Array_Aggregate =>
return Query_Array'
(1 => (Element_List_Query,
Asis.Expressions.Array_Component_Associations'Access));
when An_And_Then_Short_Circuit |
An_Or_Else_Short_Circuit =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Expressions.Short_Circuit_Operation_Left_Expression'Access),
2 => (Single_Element_Query,
Asis.Expressions.Short_Circuit_Operation_Right_Expression'Access));
when An_In_Membership_Test |
A_Not_In_Membership_Test =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Expressions.Membership_Test_Expression'Access),
2 => (Element_List_Query,
Asis.Expressions.Membership_Test_Choices'Access));
when A_Parenthesized_Expression =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Expressions.Expression_Parenthesized'Access));
when A_Type_Conversion |
A_Qualified_Expression =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Expressions.Converted_Or_Qualified_Subtype_Mark'Access),
2 => (Single_Element_Query,
Asis.Expressions.Converted_Or_Qualified_Expression'Access));
when An_Allocation_From_Subtype =>
return Query_Array'
(1 => (Single_Element_Query, -- Ada 2012
Asis.Expressions.Subpool_Name'Access),
2 => (Single_Element_Query,
Asis.Expressions.Allocator_Subtype_Indication'Access));
when An_Allocation_From_Qualified_Expression =>
return Query_Array'
(1 => (Single_Element_Query, -- Ada 2012
Asis.Expressions.Subpool_Name'Access),
2 => (Single_Element_Query,
Asis.Expressions.Allocator_Qualified_Expression'Access));
when A_Case_Expression => -- Ada 2012
return Query_Array'
(1 => (Single_Element_Query,
Asis.Statements.Case_Expression'Access),
2 => (Element_List_Query,
Asis.Expressions.Expression_Paths'Access));
when An_If_Expression => -- Ada 2012
return Query_Array'
(1 => (Element_List_Query,
Asis.Expressions.Expression_Paths'Access));
when A_For_All_Quantified_Expression | -- Ada 2012
A_For_Some_Quantified_Expression => -- Ada 2012
return Query_Array'
(1 => (Single_Element_Query,
Asis.Expressions.Iterator_Specification'Access),
2 => (Single_Element_Query,
Asis.Expressions.Predicate'Access));
end case;
end PARSE_Expression;
----------------
-- PARSE_Path --
----------------
-- PARSE_Path deals with every Path 's Element_Kind.
-- That is to say, it deals with Path_Kinds :
-- Not_A_Path, -- An unexpected element
-- An_If_Path, -- 5.3:
-- -- if condition then
-- -- sequence_of_statements
-- An_Elsif_Path, -- 5.3:
-- -- elsif condition then
-- -- sequence_of_statements
-- An_Else_Path, -- 5.3, 9.7.1, 9.7.3:
-- -- else sequence_of_statements
-- A_Case_Path, -- 5.4:
-- -- when discrete_choice_list =>
-- -- sequence_of_statements
-- A_Select_Path, -- 9.7.1:
-- -- select [guard] select_alternative
-- -- 9.7.2, 9.7.3:
-- -- select entry_call_alternative
-- -- 9.7.4:
-- -- select triggering_alternative
-- An_Or_Path, -- 9.7.1:
-- -- or [guard] select_alternative
-- -- 9.7.2:
-- -- or delay_alternative
-- A_Then_Abort_Path. -- 9.7.4
-- -- then abort sequence_of_statements
--
-- (See asis_element_kind.ads for more details)
--
function PARSE_Path (Ada_Path : Asis.Element) return Query_Array is
begin
case Asis.Elements.Path_Kind (Ada_Path) is
when An_If_Path |
An_Elsif_Path =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Statements.Condition_Expression'Access),
2 => (Element_List_Query_With_Boolean,
Asis.Statements.Sequence_Of_Statements'Access, True));
when An_Else_Path |
A_Then_Abort_Path =>
return Query_Array'
(1 => (Element_List_Query_With_Boolean,
Asis.Statements.Sequence_Of_Statements'Access, True));
when A_Case_Path =>
return Query_Array'
(1 => (Element_List_Query,
Asis.Statements.Case_Statement_Alternative_Choices'Access),
2 => (Element_List_Query_With_Boolean,
Asis.Statements.Sequence_Of_Statements'Access, True));
when A_Select_Path |
An_Or_Path =>
return Query_Array'
(1 => (Single_Element_Query, Asis.Statements.Guard'Access),
2 => (Element_List_Query_With_Boolean,
Asis.Statements.Sequence_Of_Statements'Access, True));
-- |A2012 start
when A_Case_Expression_Path =>
return Query_Array'
(1 => (Element_List_Query,
Asis.Statements.Case_Statement_Alternative_Choices'Access),
2 => (Single_Element_Query,
Asis.Expressions.Dependent_Expression'Access));
when An_If_Expression_Path |
An_Elsif_Expression_Path =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Statements.Condition_Expression'Access),
2 => (Single_Element_Query,
Asis.Expressions.Dependent_Expression'Access));
when An_Else_Expression_Path =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Expressions.Dependent_Expression'Access));
when Not_A_Path =>
raise Internal_Implementation_Error;
end case;
end PARSE_Path;
---------------------
-- PARSE_Statement --
---------------------
function PARSE_Statement
(Ada_Statement : Asis.Element)
return Query_Array
is
begin
-- all statements can have one or several Labels
case Asis.Elements.Statement_Kind (Ada_Statement) is
when Not_A_Statement =>
raise Internal_Implementation_Error;
when A_Null_Statement =>
return Query_Array'
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access));
when An_Assignment_Statement =>
return Query_Array'
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
2 => (Single_Element_Query,
Asis.Statements.Assignment_Variable_Name'Access),
3 => (Single_Element_Query,
Asis.Statements.Assignment_Expression'Access));
when An_If_Statement |
A_Selective_Accept_Statement |
A_Timed_Entry_Call_Statement |
A_Conditional_Entry_Call_Statement |
An_Asynchronous_Select_Statement =>
return Query_Array'
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
2 => (Element_List_Query_With_Boolean,
Asis.Statements.Statement_Paths'Access,
True));
when A_Case_Statement =>
return Query_Array'
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
2 => (Single_Element_Query,
Asis.Statements.Case_Expression'Access),
3 => (Element_List_Query_With_Boolean,
Asis.Statements.Statement_Paths'Access,
True));
when A_Loop_Statement =>
return Query_Array'
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
2 => (Single_Element_Query,
Asis.Statements.Statement_Identifier'Access),
3 => (Element_List_Query_With_Boolean,
Asis.Statements.Loop_Statements'Access,
True));
when A_While_Loop_Statement =>
return Query_Array'
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
2 => (Single_Element_Query,
Asis.Statements.Statement_Identifier'Access),
3 => (Single_Element_Query,
Asis.Statements.While_Condition'Access),
4 => (Element_List_Query_With_Boolean,
Asis.Statements.Loop_Statements'Access,
True));
when A_For_Loop_Statement =>
return Query_Array'
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
2 => (Single_Element_Query,
Asis.Statements.Statement_Identifier'Access),
3 => (Single_Element_Query,
Asis.Statements.For_Loop_Parameter_Specification'Access),
4 => (Element_List_Query_With_Boolean,
Asis.Statements.Loop_Statements'Access,
True));
when A_Block_Statement =>
return Query_Array'
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
2 => (Single_Element_Query,
Asis.Statements.Statement_Identifier'Access),
3 => (Element_List_Query_With_Boolean,
Asis.Statements.Block_Declarative_Items'Access,
True),
4 => (Element_List_Query_With_Boolean,
Asis.Statements.Block_Statements'Access,
True),
5 => (Element_List_Query_With_Boolean,
Asis.Statements.Block_Exception_Handlers'Access,
True));
when An_Exit_Statement =>
return Query_Array'
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
2 => (Single_Element_Query,
Asis.Statements.Exit_Loop_Name'Access),
3 => (Single_Element_Query,
Asis.Statements.Exit_Condition'Access));
when A_Goto_Statement =>
return Query_Array'
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
2 => (Single_Element_Query, Asis.Statements.Goto_Label'Access));
when A_Procedure_Call_Statement |
An_Entry_Call_Statement =>
if Subprogram_Call_Needs_Reordering (Ada_Statement) then
return Query_Array'
(1 => (Element_List_Query,
Asis.Statements.Label_Names'Access),
2 => (Single_Element_Query,
First_Parameter_Association'Access),
3 => (Single_Element_Query,
Asis.Statements.Called_Name'Access),
4 => (Element_List_Query,
All_But_First_Associations'Access));
else
return Query_Array'
(1 => (Element_List_Query,
Asis.Statements.Label_Names'Access),
2 => (Single_Element_Query,
Asis.Statements.Called_Name'Access),
3 => (Element_List_Query_With_Boolean,
Asis.Statements.Call_Statement_Parameters'Access,
False));
end if;
when A_Return_Statement =>
return Query_Array'
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
2 => (Single_Element_Query,
Asis.Statements.Return_Expression'Access));
-- |A2005 start
-- An_Extended_Return_Statement, -- 6.5
when An_Extended_Return_Statement =>
return Query_Array'
(1 => (Single_Element_Query,
Asis.Statements.Return_Object_Declaration'Access),
2 => (Element_List_Query_With_Boolean,
Asis.Statements.Extended_Return_Statements'Access,
True),
3 => (Element_List_Query_With_Boolean,
Asis.Statements.Extended_Return_Exception_Handlers'Access,
True));
-- |A2005 end
when An_Accept_Statement =>
return Query_Array'
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
2 => (Single_Element_Query,
Asis.Statements.Accept_Entry_Direct_Name'Access),
3 => (Single_Element_Query,
Asis.Statements.Accept_Entry_Index'Access),
4 => (Element_List_Query,
Asis.Statements.Accept_Parameters'Access),
5 => (Element_List_Query_With_Boolean,
Asis.Statements.Accept_Body_Statements'Access, True),
6 => (Element_List_Query_With_Boolean,
Asis.Statements.Accept_Body_Exception_Handlers'Access,
True));
when A_Requeue_Statement |
A_Requeue_Statement_With_Abort =>
return Query_Array'
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
2 => (Single_Element_Query,
Asis.Statements.Requeue_Entry_Name'Access));
when A_Delay_Until_Statement |
A_Delay_Relative_Statement =>
return Query_Array'
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
2 => (Single_Element_Query,
Asis.Statements.Delay_Expression'Access));
when A_Terminate_Alternative_Statement =>
return No_Query;
when An_Abort_Statement =>
return Query_Array'
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
2 => (Element_List_Query,
Asis.Statements.Aborted_Tasks'Access));
when A_Raise_Statement =>
-- |A2005 start
return Query_Array'
(1 => (Element_List_Query,
Asis.Statements.Label_Names'Access),
2 => (Single_Element_Query,
Asis.Statements.Raised_Exception'Access),
3 => (Single_Element_Query,
Asis.Statements.Associated_Message'Access));
-- |A2005 end
when A_Code_Statement =>
return Query_Array'
(1 => (Element_List_Query, Asis.Statements.Label_Names'Access),
2 => (Single_Element_Query,
Asis.Statements.Qualified_Expression'Access));
end case;
end PARSE_Statement;
-- We've separated the functions to make the program clearer,
-- but it is better to expand them inline ...
pragma Inline (PARSE_Defining_Name);
pragma Inline (PARSE_Declaration);
pragma Inline (PARSE_Definition);
pragma Inline (PARSE_Expression);
pragma Inline (PARSE_Association);
pragma Inline (PARSE_Statement);
pragma Inline (PARSE_Path);
pragma Inline (PARSE_Clause);
--------------------------------------
-- Subprogram_Call_Needs_Reordering --
--------------------------------------
function Subprogram_Call_Needs_Reordering
(El : Asis.Element)
return Boolean
is
Result : Boolean := False;
begin
if Asis.Elements.Is_Prefix_Notation (El)
or else
(Asis.Elements.Expression_Kind (El) = A_Function_Call
and then
not Asis.Expressions.Is_Prefix_Call (El)
and then
Asis.Expressions.Function_Call_Parameters (El)'Length = 2)
then
Result := True;
end if;
return Result;
end Subprogram_Call_Needs_Reordering;
end A4G.Queries;
|
--
-- Copyright 2018 The wookey project team <wookey@ssi.gouv.fr>
-- - Ryad Benadjila
-- - Arnauld Michelizza
-- - Mathieu Renard
-- - Philippe Thierry
-- - Philippe Trebuchet
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
--
--
with ada.unchecked_conversion;
with soc.devmap; use soc.devmap;
with soc.pwr;
with soc.flash;
with soc.rcc.default;
package body soc.rcc
with spark_mode => off
is
procedure reset
is
function to_rcc_cfgr is new ada.unchecked_conversion
(unsigned_32, t_RCC_CFGR);
function to_rcc_pllcfgr is new ada.unchecked_conversion
(unsigned_32, t_RCC_PLLCFGR);
begin
RCC.CR.HSION := true;
RCC.CFGR := to_rcc_cfgr (0);
RCC.CR.HSEON := false;
RCC.CR.CSSON := false;
RCC.CR.PLLON := false;
-- Magic number. Cf. STM32F4 datasheet
RCC.PLLCFGR := to_rcc_pllcfgr (16#2400_3010#);
RCC.CR.HSEBYP := false;
RCC.CIR := 0; -- Reset all interrupts
end reset;
procedure init
is
begin
-- Power interface clock enable
RCC.APB1ENR.PWREN := true;
-- Regulator voltage scaling output selection
-- This bit controls the main internal voltage regulator output voltage
-- to achieve a trade-off between performance and power consumption when
-- the device does not operate at the maximum frequency.
soc.pwr.PWR.CR.VOS := soc.pwr.VOS_SCALE1;
if default.enable_hse then
RCC.CR.HSEON := true;
loop
exit when RCC.CR.HSERDY;
end loop;
else -- Enable HSI
RCC.CR.HSION := true;
loop
exit when RCC.CR.HSIRDY;
end loop;
end if;
if default.enable_pll then
RCC.CR.PLLON := false;
RCC.PLLCFGR :=
(PLLM => default.PLL_M, -- Division factor for the main PLL
PLLN => default.PLL_N, -- Main PLL multiplication factor for VCO
PLLP => default.PLL_P, -- Main PLL division factor for main system clock
PLLSRC => (if default.enable_hse then 1 else 0),
-- HSE or HSI oscillator clock selected as PLL
PLLQ => default.PLL_Q);
-- Main PLL division factor for USB OTG FS, SDIO and random
-- number generator
-- Enable the main PLL
RCC.CR.PLLON := true;
loop
exit when RCC.CR.PLLRDY;
end loop;
end if;
-- Configuring flash (prefetch, instruction cache, data cache, wait state)
soc.flash.FLASH.ACR.ICEN := true; -- Instruction cache enable
soc.flash.FLASH.ACR.DCEN := true; -- Data cache is enabled
soc.flash.FLASH.ACR.PRFTEN := false; -- Prefetch is disabled to avoid
-- SPA or DPA side channel attacks
soc.flash.FLASH.ACR.LATENCY := 5; -- Latency = 5 wait states
-- Set clock dividers
RCC.CFGR.HPRE := default.AHB_DIV; -- AHB prescaler
RCC.CFGR.PPRE1 := default.APB1_DIV; -- APB1 low speed prescaler
RCC.CFGR.PPRE2 := default.APB2_DIV; -- APB2 high speed prescaler
if default.enable_pll then
RCC.CFGR.SW := 2#10#; -- PLL selected as system clock
loop
exit when RCC.CFGR.SWS = 2#10#;
end loop;
end if;
end init;
procedure enable_clock (periph : in soc.devmap.t_periph_id)
is
begin
case periph is
when NO_PERIPH => return;
when DMA1_INFO .. DMA1_STR7 => soc.rcc.RCC.AHB1ENR.DMA1EN := true;
when DMA2_INFO .. DMA2_STR7 => soc.rcc.RCC.AHB1ENR.DMA2EN := true;
when CRYP_CFG .. CRYP => soc.rcc.RCC.AHB2ENR.CRYPEN := true;
when HASH => soc.rcc.RCC.AHB2ENR.HASHEN := true;
when RNG => soc.rcc.RCC.AHB2ENR.RNGEN := true;
when USB_OTG_FS => soc.rcc.RCC.AHB2ENR.OTGFSEN := true;
when USB_OTG_HS =>
soc.rcc.RCC.AHB1ENR.OTGHSEN := true;
soc.rcc.RCC.AHB1ENR.OTGHSULPIEN := true;
when SDIO => soc.rcc.RCC.APB2ENR.SDIOEN := true;
when ETH_MAC => soc.rcc.RCC.AHB1ENR.ETHMACEN := true;
when CRC => soc.rcc.RCC.AHB1ENR.CRCEN := true;
when SPI1 => soc.rcc.RCC.APB2ENR.SPI1EN := true;
when SPI2 => soc.rcc.RCC.APB1ENR.SPI2EN := true;
when SPI3 => soc.rcc.RCC.APB1ENR.SPI3EN := true;
when I2C1 => soc.rcc.RCC.APB1ENR.I2C1EN := true;
when I2C2 => soc.rcc.RCC.APB1ENR.I2C2EN := true;
when I2C3 => soc.rcc.RCC.APB1ENR.I2C3EN := true;
when CAN1 => soc.rcc.RCC.APB1ENR.CAN1EN := true;
when CAN2 => soc.rcc.RCC.APB1ENR.CAN2EN := true;
when USART1 => soc.rcc.RCC.APB2ENR.USART1EN := true;
when USART6 => soc.rcc.RCC.APB2ENR.USART6EN := true;
when USART2 => soc.rcc.RCC.APB1ENR.USART2EN := true;
when USART3 => soc.rcc.RCC.APB1ENR.USART3EN := true;
when UART4 => soc.rcc.RCC.APB1ENR.UART4EN := true;
when UART5 => soc.rcc.RCC.APB1ENR.UART5EN := true;
when TIM1 => soc.rcc.RCC.APB2ENR.TIM1EN := true;
when TIM8 => soc.rcc.RCC.APB2ENR.TIM8EN := true;
when TIM9 => soc.rcc.RCC.APB2ENR.TIM9EN := true;
when TIM10 => soc.rcc.RCC.APB2ENR.TIM10EN := true;
when TIM11 => soc.rcc.RCC.APB2ENR.TIM11EN := true;
when TIM2 => soc.rcc.RCC.APB1ENR.TIM2EN := true;
when TIM3 => soc.rcc.RCC.APB1ENR.TIM3EN := true;
when TIM4 => soc.rcc.RCC.APB1ENR.TIM4EN := true;
when TIM5 => soc.rcc.RCC.APB1ENR.TIM5EN := true;
when TIM6 => soc.rcc.RCC.APB1ENR.TIM6EN := true;
when TIM7 => soc.rcc.RCC.APB1ENR.TIM7EN := true;
when TIM12 => soc.rcc.RCC.APB1ENR.TIM12EN := true;
when TIM13 => soc.rcc.RCC.APB1ENR.TIM13EN := true;
when TIM14 => soc.rcc.RCC.APB1ENR.TIM14EN := true;
when FLASH_CTRL .. FLASH_FLOP => null;
end case;
end enable_clock;
end soc.rcc;
|
-------------------------------------------------------------------------------
-- Copyright 2021, The Septum Developers (see AUTHORS file)
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
-- http://www.apache.org/licenses/LICENSE-2.0
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-------------------------------------------------------------------------------
with Ada.Containers.Ordered_Sets;
with Ada.Containers.Vectors;
with Ada.Strings.Unbounded;
with SP.Strings;
package SP.Contexts
with Preelaborate
is
package Line_Matches is new Ada.Containers.Ordered_Sets (Element_Type => Positive);
type Context_Match is record
File_Name : Ada.Strings.Unbounded.Unbounded_String;
Internal_Matches : Line_Matches.Set;
Minimum : Positive;
Maximum : Positive;
end record;
function From
(File_Name : String; Line : Natural; Num_Lines : Natural; Context_Width : Natural) return Context_Match with
Pre => Line <= Num_Lines,
Post => Is_Valid (From'Result);
function Real_Min (C : Context_Match) return Positive with
Pre => Is_Valid (C),
Post => C.Minimum <= Real_Min'Result and then Real_Min'Result <= C.Maximum;
function Real_Max (C : Context_Match) return Positive with
Pre => Is_Valid (C),
Post => C.Minimum <= Real_Max'Result and then Real_Max'Result <= C.Maximum;
function Is_Valid (C : Context_Match) return Boolean;
function Overlap (A, B : Context_Match) return Boolean with
Pre => Is_Valid (A) and then Is_Valid (B);
function Contains (A : Context_Match; Line_Num : Positive) return Boolean with
Pre => Is_Valid (A);
function Contains (A, B : Context_Match) return Boolean with
Pre => Is_Valid (A) and then Is_Valid (B);
function Merge (A, B : Context_Match) return Context_Match with
Pre => Is_Valid (A) and then Is_Valid (B),
Post => Is_Valid (Merge'Result);
function Image (A : Context_Match) return String with
Pre => Is_Valid (A);
overriding
function "="(A, B : Context_Match) return Boolean with
Pre => Is_Valid (A) and then Is_Valid (B);
package Context_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Context_Match);
function Files_In (V : Context_Vectors.Vector) return SP.Strings.String_Sets.Set;
end SP.Contexts;
|
-------------------------------------------------------------------------------
--
-- WAVEFILES GTK APPLICATION
--
-- Main Application
--
-- The MIT License (MIT)
--
-- Copyright (c) 2017 Gustavo A. Hoffmann
--
-- 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 Gtk.Main;
with Gtk.Enums;
with Gtk.Widget;
with WaveFiles_Gtk.Menu;
with WaveFiles_Gtk.Wavefile_List;
with Gtk.Label;
package body WaveFiles_Gtk is
procedure On_Destroy
(W : access Gtk.Widget.Gtk_Widget_Record'Class);
procedure Create_Window;
Main_Win : Gtk.Window.Gtk_Window;
Vbox : Gtk.Box.Gtk_Vbox;
Wavefile_Info : Gtk.Label.Gtk_Label;
----------------
-- On_Destroy --
----------------
procedure On_Destroy
(W : access Gtk.Widget.Gtk_Widget_Record'Class)
is
pragma Unreferenced (W);
begin
Destroy_Window;
end On_Destroy;
-------------------
-- Create_Window --
-------------------
procedure Create_Window is
begin
-- Create the main window
Gtk.Window.Gtk_New
(Window => Main_Win,
The_Type => Gtk.Enums.Window_Toplevel);
-- From Gtk.Widget:
Main_Win.Set_Title (Title => "Wavefiles Gtk App");
Main_Win.Resize (Width => 800, Height => 640);
-- The global box
Gtk.Box.Gtk_New_Vbox (Vbox, Homogeneous => False, Spacing => 0);
Main_Win.Add (Vbox);
-- Create menu
WaveFiles_Gtk.Menu.Create;
-- Add tree
WaveFiles_Gtk.Wavefile_List.Create (Vbox);
-- Add info view
Gtk.Label.Gtk_New (Wavefile_Info);
Wavefile_Info.Set_Valign (Gtk.Widget.Align_Start);
Wavefile_Info.Set_Halign (Gtk.Widget.Align_Start);
Vbox.Pack_Start (Wavefile_Info, True, True, 0);
-- Construct the window and connect various callbacks
Main_Win.On_Destroy (On_Destroy'Access);
Vbox.Show_All;
Main_Win.Show_All;
end Create_Window;
-----------------------
-- Set_Wavefile_Info --
-----------------------
procedure Set_Wavefile_Info (Info : String) is
begin
Wavefile_Info.Set_Label (Info);
end Set_Wavefile_Info;
--------------------
-- Destroy_Window --
--------------------
procedure Destroy_Window is
begin
Gtk.Main.Main_Quit;
end Destroy_Window;
------------
-- Create --
------------
procedure Create is
begin
-- Initializes GtkAda
Gtk.Main.Init;
Create_Window;
-- Signal handling loop
Gtk.Main.Main;
end Create;
----------------
-- Get_Window --
----------------
function Get_Window
return not null access Gtk.Window.Gtk_Window_Record'Class is
begin
return Main_Win;
end Get_Window;
--------------
-- Get_VBox --
--------------
function Get_VBox
return not null access Gtk.Box.Gtk_Vbox_Record'Class is
begin
return Vbox;
end Get_VBox;
end WaveFiles_Gtk;
|
-----------------------------------------------------------------------
-- el-variables-default -- Default Variable Mapper
-- Copyright (C) 2009, 2010, 2011, 2012, 2021 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with EL.Expressions;
package body EL.Variables.Default is
overriding
procedure Bind (Mapper : in out Default_Variable_Mapper;
Name : in String;
Value : in EL.Objects.Object) is
Expr : constant EL.Expressions.Value_Expression
:= EL.Expressions.Create_ValueExpression (Value);
begin
Mapper.Map.Include (Key => To_Unbounded_String (Name),
New_Item => EL.Expressions.Expression (Expr));
end Bind;
overriding
function Get_Variable (Mapper : Default_Variable_Mapper;
Name : Unbounded_String)
return EL.Expressions.Expression is
C : constant Variable_Maps.Cursor := Mapper.Map.Find (Name);
begin
if not Variable_Maps.Has_Element (C) then
if Mapper.Next_Mapper /= null then
return Mapper.Next_Mapper.all.Get_Variable (Name);
end if;
-- Avoid raising an exception if we can't resolve a variable.
-- Instead, return a null expression. This speeds up the resolution and
-- creation of Ada bean in ASF framework (cost of exception is high compared to this).
return E : EL.Expressions.Expression;
end if;
return Variable_Maps.Element (C);
end Get_Variable;
overriding
procedure Set_Variable (Mapper : in out Default_Variable_Mapper;
Name : in Unbounded_String;
Value : in EL.Expressions.Expression) is
begin
Mapper.Map.Include (Key => Name,
New_Item => Value);
end Set_Variable;
-- ------------------------------
-- Set the next variable mapper that will be used to resolve a variable if
-- the current variable mapper does not find a variable.
-- ------------------------------
procedure Set_Next_Variable_Mapper (Mapper : in out Default_Variable_Mapper;
Next_Mapper : in Variable_Mapper_Access) is
begin
Mapper.Next_Mapper := Next_Mapper;
end Set_Next_Variable_Mapper;
end EL.Variables.Default;
|
-----------------------------------------------------------------------
-- wiki-render-text -- Wiki Text renderer
-- Copyright (C) 2011, 2012, 2013, 2015, 2016, 2019, 2020 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Wiki.Attributes;
with Wiki.Streams;
with Wiki.Strings;
-- === Text Renderer ===
-- The `Text_Renderer` allows to render a wiki document into a text content.
-- The formatting rules are ignored except for the paragraphs and sections.
package Wiki.Render.Text is
-- ------------------------------
-- Wiki to Text renderer
-- ------------------------------
type Text_Renderer is new Wiki.Render.Renderer with private;
-- Set the output stream.
procedure Set_Output_Stream (Engine : in out Text_Renderer;
Stream : in Streams.Output_Stream_Access);
-- Set the no-newline mode to produce a single line text (disabled by default).
procedure Set_No_Newline (Engine : in out Text_Renderer;
Enable : in Boolean);
-- Render the node instance from the document.
overriding
procedure Render (Engine : in out Text_Renderer;
Doc : in Wiki.Documents.Document;
Node : in Wiki.Nodes.Node_Type);
-- Add a line break (<br>).
procedure Add_Line_Break (Document : in out Text_Renderer);
-- Render a blockquote (<blockquote>). The level indicates the blockquote nested level.
-- The blockquote must be closed at the next header.
procedure Render_Blockquote (Engine : in out Text_Renderer;
Level : in Natural);
-- Render a list item (<li>). Close the previous paragraph and list item if any.
-- The list item will be closed at the next list item, next paragraph or next header.
procedure Render_List_Item (Engine : in out Text_Renderer;
Level : in Positive;
Ordered : in Boolean);
-- Render a link.
procedure Render_Link (Engine : in out Text_Renderer;
Title : in Wiki.Strings.WString;
Attr : in Wiki.Attributes.Attribute_List);
-- Render an image.
procedure Render_Image (Engine : in out Text_Renderer;
Title : in Wiki.Strings.WString;
Attr : in Wiki.Attributes.Attribute_List);
-- Render a text block that is pre-formatted.
procedure Render_Preformatted (Engine : in out Text_Renderer;
Text : in Wiki.Strings.WString;
Format : in Wiki.Strings.WString);
-- Finish the document after complete wiki text has been parsed.
overriding
procedure Finish (Engine : in out Text_Renderer;
Doc : in Wiki.Documents.Document);
private
-- Emit a new line.
procedure New_Line (Document : in out Text_Renderer);
procedure Close_Paragraph (Document : in out Text_Renderer);
procedure Open_Paragraph (Document : in out Text_Renderer);
type Text_Renderer is new Wiki.Render.Renderer with record
Output : Streams.Output_Stream_Access := null;
Format : Wiki.Format_Map := (others => False);
Has_Paragraph : Boolean := False;
Need_Paragraph : Boolean := False;
Empty_Line : Boolean := True;
No_Newline : Boolean := False;
Indent_Level : Natural := 0;
end record;
end Wiki.Render.Text;
|
------------------------------------------------------------------------------
-- --
-- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
-- --
-- S Y S T E M . T A S K _ P R I M I T I V E S --
-- --
-- S p e c --
-- --
-- $Revision$
-- --
-- Copyright (C) 1991-1999 Florida State University --
-- --
-- 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, 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. --
-- --
-- GNARL was developed by the GNARL team at Florida State University. It is --
-- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
-- State University (http://www.gnat.com). --
-- --
------------------------------------------------------------------------------
-- This is an OS/2 version of this package.
-- This package provides low-level support for most tasking features.
pragma Polling (Off);
-- Turn off polling, we do not want ATC polling to take place during
-- tasking operations. It causes infinite loops and other problems.
with Interfaces.OS2Lib.Threads;
with Interfaces.OS2Lib.Synchronization;
package System.Task_Primitives is
pragma Preelaborate;
-- type Lock is limited private;
-- Should be used for implementation of protected objects.
-- type RTS_Lock is limited private;
-- Should be used inside the runtime system.
-- The difference between Lock and the RTS_Lock is that the later
-- one serves only as a semaphore so that do not check for
-- ceiling violations.
type Task_Body_Access is access procedure;
-- Pointer to the task body's entry point (or possibly a wrapper
-- declared local to the GNARL).
-- type Private_Data is limited private;
-- Any information that the GNULLI needs maintained on a per-task
-- basis. A component of this type is guaranteed to be included
-- in the Ada_Task_Control_Block.
-- private
type Lock is
record
Mutex : aliased Interfaces.OS2Lib.Synchronization.HMTX;
Priority : Integer;
Owner_Priority : Integer;
Owner_ID : Address;
end record;
type RTS_Lock is new Lock;
type Private_Data is record
Thread : aliased Interfaces.OS2Lib.Threads.TID;
pragma Atomic (Thread);
-- Thread field may be updated by two different threads of control.
-- (See, Enter_Task and Create_Task in s-taprop.adb).
-- They put the same value (thr_self value). We do not want to
-- use lock on those operations and the only thing we have to
-- make sure is that they are updated in atomic fashion.
CV : aliased Interfaces.OS2Lib.Synchronization.HEV;
L : aliased RTS_Lock;
-- Protection for all components is lock L
Current_Priority : Integer := -1;
-- The Current_Priority is the actual priority of a thread.
-- This field is needed because it is only possible to set a
-- delta priority in OS/2. The only places where this field should
-- be set are Set_Priority, Create_Task and Initialize (Environment).
Wrapper : Interfaces.OS2Lib.Threads.PFNTHREAD;
-- This is the original wrapper passed by Operations.Create_Task.
-- When installing an exception handler in a thread, the thread
-- starts executing the Exception_Wrapper which calls Wrapper
-- when the handler has been installed. The handler is removed when
-- wrapper returns.
end record;
end System.Task_Primitives;
|
-- SPDX-FileCopyrightText: 2021 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Elements.Case_Paths;
package body Program.Complete_Contexts.Case_Statements is
--------------------
-- Case_Statement --
--------------------
procedure Case_Statement
(Sets : not null Program.Interpretations.Context_Access;
Setter : not null Program.Cross_Reference_Updaters
.Cross_Reference_Updater_Access;
Element : Program.Elements.Case_Statements.Case_Statement_Access)
is
View : Program.Visibility.View;
begin
Resolve_To_Discrete_Type
(Element => Element.Selecting_Expression,
Sets => Sets,
Setter => Setter,
Result => View);
for J in Element.Paths.Each_Element loop
declare
Path : constant Program.Elements.Case_Paths.Case_Path_Access :=
J.Element.To_Case_Path;
begin
for K in Path.Choices.Each_Element loop
Resolve_To_Expected_Type
(Element => K.Element,
Sets => Sets,
Setter => Setter,
Expect => View);
end loop;
for K in Path.Statements.Each_Element loop
null;
end loop;
end;
end loop;
end Case_Statement;
end Program.Complete_Contexts.Case_Statements;
|
------------------------------------------------------------------------------
-- Copyright (c) 2015-2017, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Ada.Calendar;
with Ada.Command_Line;
with Ada.Text_IO;
with Natools.Time_IO.RFC_3339;
with Natools.Time_Keys;
procedure Timekey is
procedure Process (Line : in String);
-- Guess the type of Line and convert it to or from type.
procedure Process_Input;
-- Read lines from current input and process them.
Input_Processed : Boolean := False;
Empty : Boolean := True;
Verbose : Boolean := False;
Subsecond_Digits : Natural := Duration'Aft;
procedure Process (Line : in String) is
begin
if Verbose then
Ada.Text_IO.Put (Line);
end if;
if Natools.Time_Keys.Is_Valid (Line) then
if Verbose then
Ada.Text_IO.Put (" => ");
end if;
Ada.Text_IO.Put_Line
(Natools.Time_IO.RFC_3339.Image
(Natools.Time_Keys.To_Time (Line), Subsecond_Digits, False));
elsif Natools.Time_IO.RFC_3339.Is_Valid (Line) then
if Verbose then
Ada.Text_IO.Put (" => ");
end if;
Ada.Text_IO.Put_Line
(Natools.Time_Keys.To_Key (Natools.Time_IO.RFC_3339.Value (Line)));
end if;
end Process;
procedure Process_Input is
begin
if Input_Processed then
return;
else
Input_Processed := True;
end if;
begin
loop
Process (Ada.Text_IO.Get_Line);
end loop;
exception
when Ada.Text_IO.End_Error => null;
end;
end Process_Input;
begin
for I in 1 .. Ada.Command_Line.Argument_Count loop
declare
Arg : constant String := Ada.Command_Line.Argument (I);
begin
if Arg = "-" then
Empty := False;
Process_Input;
elsif Arg = "-v" then
Verbose := True;
elsif Arg'Length = 2
and then Arg (Arg'First) = '-'
and then Arg (Arg'Last) in '0' .. '9'
then
Subsecond_Digits := Character'Pos (Arg (Arg'Last))
- Character'Pos ('0');
else
Empty := False;
Process (Arg);
end if;
end;
end loop;
if Empty then
declare
Now : constant Ada.Calendar.Time := Ada.Calendar.Clock;
begin
if Verbose then
Ada.Text_IO.Put
(Natools.Time_IO.RFC_3339.Image (Now, Subsecond_Digits, False)
& " => ");
end if;
Ada.Text_IO.Put_Line (Natools.Time_Keys.To_Key (Now));
end;
end if;
end Timekey;
|
with
lace.Text.all_Tokens,
ada.Characters.latin_1;
package body lace.Text.all_Lines
is
use lace.Text.all_Tokens,
ada.Characters.latin_1;
function Lines (Self : in Item) return Text.items_2
is
begin
return Tokens (Self, LF);
end Lines;
function Lines (Self : in Item) return Text.items_4
is
begin
return Tokens (Self, LF);
end Lines;
function Lines (Self : in Item) return Text.items_8
is
begin
return Tokens (Self, LF);
end Lines;
function Lines (Self : in Item) return Text.items_16
is
begin
return Tokens (Self, LF);
end Lines;
function Lines (Self : in Item) return Text.items_32
is
begin
return Tokens (Self, LF);
end Lines;
function Lines (Self : in Item) return Text.items_64
is
begin
return Tokens (Self, LF);
end Lines;
function Lines (Self : in Item) return Text.items_128
is
begin
return Tokens (Self, LF);
end Lines;
function Lines (Self : in Item) return Text.items_256
is
begin
return Tokens (Self, LF);
end Lines;
function Lines (Self : in Item) return Text.items_512
is
begin
return Tokens (Self, LF);
end Lines;
function Lines (Self : in Item) return Text.items_1k
is
begin
return Tokens (Self, LF);
end Lines;
function Lines (Self : in Item) return Text.items_2k
is
begin
return Tokens (Self, LF);
end Lines;
function Lines (Self : in Item) return Text.items_4k
is
begin
return Tokens (Self, LF);
end Lines;
function Lines (Self : in Item) return Text.items_8k
is
begin
return Tokens (Self, LF);
end Lines;
function Lines (Self : in Item) return Text.items_16k
is
begin
return Tokens (Self, LF);
end Lines;
function Lines (Self : in Item) return Text.items_32k
is
begin
return Tokens (Self, LF);
end Lines;
function Lines (Self : in Item) return Text.items_64k
is
begin
return Tokens (Self, LF);
end Lines;
function Lines (Self : in Item) return Text.items_128k
is
begin
return Tokens (Self, LF);
end Lines;
function Lines (Self : in Item) return Text.items_256k
is
begin
return Tokens (Self, LF);
end Lines;
function Lines (Self : in Item) return Text.items_512k
is
begin
return Tokens (Self, LF);
end Lines;
end lace.Text.all_Lines;
|
with Ada.Text_IO;
with Ada.Containers.Vectors;
with Ada.Numerics.Long_Elementary_Functions;
with PrimeInstances;
package body Problem_46 is
package IO renames Ada.Text_IO;
package Math renames Ada.Numerics.Long_Elementary_Functions;
package Positive_Primes renames PrimeInstances.Positive_Primes;
package Positive_Vector is new Ada.Containers.Vectors(Index_Type => Positive,
Element_Type => Positive);
procedure Solve is
gen : Positive_Primes.Prime_Generator := Positive_Primes.Make_Generator;
primes : Positive_Vector.Vector := Positive_Vector.Empty_Vector;
prime, composite : Positive;
function goldbach_composite(composite : Positive) return Boolean is
use Positive_Vector;
prime_cursor : Cursor := primes.First;
begin
while prime_cursor /= No_Element loop
declare
root : constant Long_Float := Math.Sqrt(Long_Float(composite - Element(prime_cursor))/2.0);
begin
if root = Long_Float'floor(root) then
return True;
end if;
end;
Positive_Vector.Next(prime_cursor);
end loop;
return False;
end;
begin
-- initialize virtual lists
Positive_Primes.Next_Prime(gen, prime); -- skip 2. It's an ugly prime for this problem
Positive_Primes.Next_Prime(gen, prime);
composite := 3;
main_loop:
loop
while composite < prime loop
exit main_loop when not goldbach_composite(composite);
composite := composite + 2;
end loop;
if composite = prime then
composite := composite + 2;
end if;
primes.Append(prime);
Positive_Primes.Next_Prime(gen, prime);
end loop main_loop;
IO.Put_Line(Positive'Image(composite));
end Solve;
end Problem_46;
|
pragma License (Unrestricted); -- BSD 3-Clause
-- translated unit from SFMT (SFMT-sse2.h)
private generic
package Ada.Numerics.SFMT.Generating is
-- SSE2 version
pragma Preelaborate;
procedure gen_rand_all (
sfmt : in out w128_t_Array_N);
pragma Inline (gen_rand_all);
procedure gen_rand_array (
sfmt : in out w128_t_Array_N;
Item : in out w128_t_Array_1; -- w128_t_Array (0 .. size - 1)
size : Integer);
pragma Inline (gen_rand_array);
end Ada.Numerics.SFMT.Generating;
|
-- Ascon_Demo
-- Copyright (c) 2016-2018, James Humphry - see LICENSE file for details
with Ada.Text_IO;
use Ada.Text_IO;
with System.Storage_Elements;
use System.Storage_Elements;
with Ascon.Utils;
with Ascon128v12;
use Ascon128v12;
procedure Ascon128_Demo is
package Ascon128v12_Utils is new Ascon128v12.Utils;
use Ascon128v12_Utils;
K : Key_Type;
N : Nonce_Type;
A, M, C, M2 : Storage_Array(0..127);
T : Tag_Type;
Valid : Boolean;
begin
Put_Line("Ascon-128 v1.2 Example");
Put_Line("Encrypting and decrypting a message using the high-level API");
New_Line;
-- Setting up example input data
for I in K'Range loop
K(I) := Storage_Element(I);
end loop;
for I in N'Range loop
N(I) := (15 - Storage_Element(I)) * 16;
end loop;
for I in A'Range loop
A(I) := Storage_Element(I);
M(I) := Storage_Element(I);
end loop;
-- Displaying example input data
Put_Line("Key:"); Put_Storage_Array(K);
Put_Line("Nonce:"); Put_Storage_Array(N);
Put_Line("Header and Message (both the same):");
Put_Storage_Array(M);
New_Line;
-- Performing the encryption
Put_Line("Calling AEADEnc");
AEADEnc(K, N, A, M, C, T);
New_Line;
-- Displayng the result of the encryption
Put_Line("Ciphertext:"); Put_Storage_Array(C);
Put_Line("Tag:"); Put_Storage_Array(T);
New_Line;
-- Performing the decryption
Put_Line("Calling AEADDec");
AEADDec(K, N, A, C, T, M2, Valid);
if Valid then
Put_Line("Result of decryption is valid as expected");
else
Put_Line("ERROR - Result of decryption is invalid");
end if;
New_Line;
-- Displaying the result of the decryption
Put_Line("Decrypted message:"); Put_Storage_Array(M2);
New_Line;
-- Corrupting the tag
Put_Line("Now corrupting one bit of the tag");
T(7) := T(7) xor 8;
-- Now checking that decryption with the corrupt tag fails
Put_Line("Calling AEADDec again with the corrupted tag");
AEADDec(K, N, A, C, T, M2, Valid);
if Valid then
Put_Line("ERROR Result of decryption is valid despite the corrupt tag");
else
Put_Line("Result of decryption with corrupt tag is invalid, as expected");
end if;
New_Line;
end Ascon128_Demo;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, Vadim Godunko <vgodunko@gmail.com> --
-- All rights reserved. --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions --
-- are met: --
-- --
-- * Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- --
-- * Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in the --
-- documentation and/or other materials provided with the distribution. --
-- --
-- * Neither the name of the Vadim Godunko, IE nor the names of its --
-- contributors may be used to endorse or promote products derived from --
-- this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED --
-- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR --
-- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF --
-- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING --
-- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS --
-- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- $Revision$ $Date$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.CMOF.Associations;
with AMF.CMOF.Classes;
with AMF.CMOF.Data_Types;
with AMF.Factories.UML_Factories;
with AMF.Links;
with AMF.UML.Abstractions;
with AMF.UML.Accept_Call_Actions;
with AMF.UML.Accept_Event_Actions;
with AMF.UML.Action_Execution_Specifications;
with AMF.UML.Action_Input_Pins;
with AMF.UML.Activities;
with AMF.UML.Activity_Final_Nodes;
with AMF.UML.Activity_Parameter_Nodes;
with AMF.UML.Activity_Partitions;
with AMF.UML.Actors;
with AMF.UML.Add_Structural_Feature_Value_Actions;
with AMF.UML.Add_Variable_Value_Actions;
with AMF.UML.Any_Receive_Events;
with AMF.UML.Artifacts;
with AMF.UML.Association_Classes;
with AMF.UML.Associations;
with AMF.UML.Behavior_Execution_Specifications;
with AMF.UML.Broadcast_Signal_Actions;
with AMF.UML.Call_Behavior_Actions;
with AMF.UML.Call_Events;
with AMF.UML.Call_Operation_Actions;
with AMF.UML.Central_Buffer_Nodes;
with AMF.UML.Change_Events;
with AMF.UML.Classes;
with AMF.UML.Classifier_Template_Parameters;
with AMF.UML.Clauses;
with AMF.UML.Clear_Association_Actions;
with AMF.UML.Clear_Structural_Feature_Actions;
with AMF.UML.Clear_Variable_Actions;
with AMF.UML.Collaboration_Uses;
with AMF.UML.Collaborations;
with AMF.UML.Combined_Fragments;
with AMF.UML.Comments;
with AMF.UML.Communication_Paths;
with AMF.UML.Component_Realizations;
with AMF.UML.Components;
with AMF.UML.Conditional_Nodes;
with AMF.UML.Connectable_Element_Template_Parameters;
with AMF.UML.Connection_Point_References;
with AMF.UML.Connector_Ends;
with AMF.UML.Connectors;
with AMF.UML.Consider_Ignore_Fragments;
with AMF.UML.Constraints;
with AMF.UML.Continuations;
with AMF.UML.Control_Flows;
with AMF.UML.Create_Link_Actions;
with AMF.UML.Create_Link_Object_Actions;
with AMF.UML.Create_Object_Actions;
with AMF.UML.Data_Store_Nodes;
with AMF.UML.Data_Types;
with AMF.UML.Decision_Nodes;
with AMF.UML.Dependencies;
with AMF.UML.Deployment_Specifications;
with AMF.UML.Deployments;
with AMF.UML.Destroy_Link_Actions;
with AMF.UML.Destroy_Object_Actions;
with AMF.UML.Destruction_Occurrence_Specifications;
with AMF.UML.Devices;
with AMF.UML.Duration_Constraints;
with AMF.UML.Duration_Intervals;
with AMF.UML.Duration_Observations;
with AMF.UML.Durations;
with AMF.UML.Element_Imports;
with AMF.UML.Enumeration_Literals;
with AMF.UML.Enumerations;
with AMF.UML.Exception_Handlers;
with AMF.UML.Execution_Environments;
with AMF.UML.Execution_Occurrence_Specifications;
with AMF.UML.Expansion_Nodes;
with AMF.UML.Expansion_Regions;
with AMF.UML.Expressions;
with AMF.UML.Extends;
with AMF.UML.Extension_Ends;
with AMF.UML.Extension_Points;
with AMF.UML.Extensions;
with AMF.UML.Final_States;
with AMF.UML.Flow_Final_Nodes;
with AMF.UML.Fork_Nodes;
with AMF.UML.Function_Behaviors;
with AMF.UML.Gates;
with AMF.UML.General_Orderings;
with AMF.UML.Generalization_Sets;
with AMF.UML.Generalizations;
with AMF.UML.Images;
with AMF.UML.Includes;
with AMF.UML.Information_Flows;
with AMF.UML.Information_Items;
with AMF.UML.Initial_Nodes;
with AMF.UML.Input_Pins;
with AMF.UML.Instance_Specifications;
with AMF.UML.Instance_Values;
with AMF.UML.Interaction_Constraints;
with AMF.UML.Interaction_Operands;
with AMF.UML.Interaction_Uses;
with AMF.UML.Interactions;
with AMF.UML.Interface_Realizations;
with AMF.UML.Interfaces;
with AMF.UML.Interruptible_Activity_Regions;
with AMF.UML.Interval_Constraints;
with AMF.UML.Intervals;
with AMF.UML.Join_Nodes;
with AMF.UML.Lifelines;
with AMF.UML.Link_End_Creation_Datas;
with AMF.UML.Link_End_Datas;
with AMF.UML.Link_End_Destruction_Datas;
with AMF.UML.Literal_Booleans;
with AMF.UML.Literal_Integers;
with AMF.UML.Literal_Nulls;
with AMF.UML.Literal_Reals;
with AMF.UML.Literal_Strings;
with AMF.UML.Literal_Unlimited_Naturals;
with AMF.UML.Loop_Nodes;
with AMF.UML.Manifestations;
with AMF.UML.Merge_Nodes;
with AMF.UML.Message_Occurrence_Specifications;
with AMF.UML.Messages;
with AMF.UML.Models;
with AMF.UML.Nodes;
with AMF.UML.Object_Flows;
with AMF.UML.Occurrence_Specifications;
with AMF.UML.Opaque_Actions;
with AMF.UML.Opaque_Behaviors;
with AMF.UML.Opaque_Expressions;
with AMF.UML.Operation_Template_Parameters;
with AMF.UML.Operations;
with AMF.UML.Output_Pins;
with AMF.UML.Package_Imports;
with AMF.UML.Package_Merges;
with AMF.UML.Packages;
with AMF.UML.Parameter_Sets;
with AMF.UML.Parameters;
with AMF.UML.Part_Decompositions;
with AMF.UML.Ports;
with AMF.UML.Primitive_Types;
with AMF.UML.Profile_Applications;
with AMF.UML.Profiles;
with AMF.UML.Properties;
with AMF.UML.Protocol_Conformances;
with AMF.UML.Protocol_State_Machines;
with AMF.UML.Protocol_Transitions;
with AMF.UML.Pseudostates;
with AMF.UML.Qualifier_Values;
with AMF.UML.Raise_Exception_Actions;
with AMF.UML.Read_Extent_Actions;
with AMF.UML.Read_Is_Classified_Object_Actions;
with AMF.UML.Read_Link_Actions;
with AMF.UML.Read_Link_Object_End_Actions;
with AMF.UML.Read_Link_Object_End_Qualifier_Actions;
with AMF.UML.Read_Self_Actions;
with AMF.UML.Read_Structural_Feature_Actions;
with AMF.UML.Read_Variable_Actions;
with AMF.UML.Realizations;
with AMF.UML.Receptions;
with AMF.UML.Reclassify_Object_Actions;
with AMF.UML.Redefinable_Template_Signatures;
with AMF.UML.Reduce_Actions;
with AMF.UML.Regions;
with AMF.UML.Remove_Structural_Feature_Value_Actions;
with AMF.UML.Remove_Variable_Value_Actions;
with AMF.UML.Reply_Actions;
with AMF.UML.Send_Object_Actions;
with AMF.UML.Send_Signal_Actions;
with AMF.UML.Sequence_Nodes;
with AMF.UML.Signal_Events;
with AMF.UML.Signals;
with AMF.UML.Slots;
with AMF.UML.Start_Classifier_Behavior_Actions;
with AMF.UML.Start_Object_Behavior_Actions;
with AMF.UML.State_Invariants;
with AMF.UML.State_Machines;
with AMF.UML.States;
with AMF.UML.Stereotypes;
with AMF.UML.String_Expressions;
with AMF.UML.Structured_Activity_Nodes;
with AMF.UML.Substitutions;
with AMF.UML.Template_Bindings;
with AMF.UML.Template_Parameter_Substitutions;
with AMF.UML.Template_Parameters;
with AMF.UML.Template_Signatures;
with AMF.UML.Test_Identity_Actions;
with AMF.UML.Time_Constraints;
with AMF.UML.Time_Events;
with AMF.UML.Time_Expressions;
with AMF.UML.Time_Intervals;
with AMF.UML.Time_Observations;
with AMF.UML.Transitions;
with AMF.UML.Triggers;
with AMF.UML.Unmarshall_Actions;
with AMF.UML.Usages;
with AMF.UML.Use_Cases;
with AMF.UML.Value_Pins;
with AMF.UML.Value_Specification_Actions;
with AMF.UML.Variables;
with League.Holders;
package AMF.Internals.Factories.UML_Factories is
type UML_Factory is
limited new AMF.Internals.Factories.Metamodel_Factory_Base
and AMF.Factories.UML_Factories.UML_Factory with null record;
overriding function Convert_To_String
(Self : not null access UML_Factory;
Data_Type : not null access AMF.CMOF.Data_Types.CMOF_Data_Type'Class;
Value : League.Holders.Holder) return League.Strings.Universal_String;
overriding function Create
(Self : not null access UML_Factory;
Meta_Class : not null access AMF.CMOF.Classes.CMOF_Class'Class)
return not null AMF.Elements.Element_Access;
overriding function Create_From_String
(Self : not null access UML_Factory;
Data_Type : not null access AMF.CMOF.Data_Types.CMOF_Data_Type'Class;
Image : League.Strings.Universal_String) return League.Holders.Holder;
overriding function Create_Link
(Self : not null access UML_Factory;
Association :
not null access AMF.CMOF.Associations.CMOF_Association'Class;
First_Element : not null AMF.Elements.Element_Access;
Second_Element : not null AMF.Elements.Element_Access)
return not null AMF.Links.Link_Access;
overriding function Get_Package
(Self : not null access constant UML_Factory)
return AMF.CMOF.Packages.Collections.Set_Of_CMOF_Package;
function Constructor
(Extent : AMF.Internals.AMF_Extent)
return not null AMF.Factories.Factory_Access;
function Get_Package return not null AMF.CMOF.Packages.CMOF_Package_Access;
function Create_Abstraction
(Self : not null access UML_Factory)
return AMF.UML.Abstractions.UML_Abstraction_Access;
function Create_Accept_Call_Action
(Self : not null access UML_Factory)
return AMF.UML.Accept_Call_Actions.UML_Accept_Call_Action_Access;
function Create_Accept_Event_Action
(Self : not null access UML_Factory)
return AMF.UML.Accept_Event_Actions.UML_Accept_Event_Action_Access;
function Create_Action_Execution_Specification
(Self : not null access UML_Factory)
return AMF.UML.Action_Execution_Specifications.UML_Action_Execution_Specification_Access;
function Create_Action_Input_Pin
(Self : not null access UML_Factory)
return AMF.UML.Action_Input_Pins.UML_Action_Input_Pin_Access;
function Create_Activity
(Self : not null access UML_Factory)
return AMF.UML.Activities.UML_Activity_Access;
function Create_Activity_Final_Node
(Self : not null access UML_Factory)
return AMF.UML.Activity_Final_Nodes.UML_Activity_Final_Node_Access;
function Create_Activity_Parameter_Node
(Self : not null access UML_Factory)
return AMF.UML.Activity_Parameter_Nodes.UML_Activity_Parameter_Node_Access;
function Create_Activity_Partition
(Self : not null access UML_Factory)
return AMF.UML.Activity_Partitions.UML_Activity_Partition_Access;
function Create_Actor
(Self : not null access UML_Factory)
return AMF.UML.Actors.UML_Actor_Access;
function Create_Add_Structural_Feature_Value_Action
(Self : not null access UML_Factory)
return AMF.UML.Add_Structural_Feature_Value_Actions.UML_Add_Structural_Feature_Value_Action_Access;
function Create_Add_Variable_Value_Action
(Self : not null access UML_Factory)
return AMF.UML.Add_Variable_Value_Actions.UML_Add_Variable_Value_Action_Access;
function Create_Any_Receive_Event
(Self : not null access UML_Factory)
return AMF.UML.Any_Receive_Events.UML_Any_Receive_Event_Access;
function Create_Artifact
(Self : not null access UML_Factory)
return AMF.UML.Artifacts.UML_Artifact_Access;
function Create_Association
(Self : not null access UML_Factory)
return AMF.UML.Associations.UML_Association_Access;
function Create_Association_Class
(Self : not null access UML_Factory)
return AMF.UML.Association_Classes.UML_Association_Class_Access;
function Create_Behavior_Execution_Specification
(Self : not null access UML_Factory)
return AMF.UML.Behavior_Execution_Specifications.UML_Behavior_Execution_Specification_Access;
function Create_Broadcast_Signal_Action
(Self : not null access UML_Factory)
return AMF.UML.Broadcast_Signal_Actions.UML_Broadcast_Signal_Action_Access;
function Create_Call_Behavior_Action
(Self : not null access UML_Factory)
return AMF.UML.Call_Behavior_Actions.UML_Call_Behavior_Action_Access;
function Create_Call_Event
(Self : not null access UML_Factory)
return AMF.UML.Call_Events.UML_Call_Event_Access;
function Create_Call_Operation_Action
(Self : not null access UML_Factory)
return AMF.UML.Call_Operation_Actions.UML_Call_Operation_Action_Access;
function Create_Central_Buffer_Node
(Self : not null access UML_Factory)
return AMF.UML.Central_Buffer_Nodes.UML_Central_Buffer_Node_Access;
function Create_Change_Event
(Self : not null access UML_Factory)
return AMF.UML.Change_Events.UML_Change_Event_Access;
function Create_Class
(Self : not null access UML_Factory)
return AMF.UML.Classes.UML_Class_Access;
function Create_Classifier_Template_Parameter
(Self : not null access UML_Factory)
return AMF.UML.Classifier_Template_Parameters.UML_Classifier_Template_Parameter_Access;
function Create_Clause
(Self : not null access UML_Factory)
return AMF.UML.Clauses.UML_Clause_Access;
function Create_Clear_Association_Action
(Self : not null access UML_Factory)
return AMF.UML.Clear_Association_Actions.UML_Clear_Association_Action_Access;
function Create_Clear_Structural_Feature_Action
(Self : not null access UML_Factory)
return AMF.UML.Clear_Structural_Feature_Actions.UML_Clear_Structural_Feature_Action_Access;
function Create_Clear_Variable_Action
(Self : not null access UML_Factory)
return AMF.UML.Clear_Variable_Actions.UML_Clear_Variable_Action_Access;
function Create_Collaboration
(Self : not null access UML_Factory)
return AMF.UML.Collaborations.UML_Collaboration_Access;
function Create_Collaboration_Use
(Self : not null access UML_Factory)
return AMF.UML.Collaboration_Uses.UML_Collaboration_Use_Access;
function Create_Combined_Fragment
(Self : not null access UML_Factory)
return AMF.UML.Combined_Fragments.UML_Combined_Fragment_Access;
function Create_Comment
(Self : not null access UML_Factory)
return AMF.UML.Comments.UML_Comment_Access;
function Create_Communication_Path
(Self : not null access UML_Factory)
return AMF.UML.Communication_Paths.UML_Communication_Path_Access;
function Create_Component
(Self : not null access UML_Factory)
return AMF.UML.Components.UML_Component_Access;
function Create_Component_Realization
(Self : not null access UML_Factory)
return AMF.UML.Component_Realizations.UML_Component_Realization_Access;
function Create_Conditional_Node
(Self : not null access UML_Factory)
return AMF.UML.Conditional_Nodes.UML_Conditional_Node_Access;
function Create_Connectable_Element_Template_Parameter
(Self : not null access UML_Factory)
return AMF.UML.Connectable_Element_Template_Parameters.UML_Connectable_Element_Template_Parameter_Access;
function Create_Connection_Point_Reference
(Self : not null access UML_Factory)
return AMF.UML.Connection_Point_References.UML_Connection_Point_Reference_Access;
function Create_Connector
(Self : not null access UML_Factory)
return AMF.UML.Connectors.UML_Connector_Access;
function Create_Connector_End
(Self : not null access UML_Factory)
return AMF.UML.Connector_Ends.UML_Connector_End_Access;
function Create_Consider_Ignore_Fragment
(Self : not null access UML_Factory)
return AMF.UML.Consider_Ignore_Fragments.UML_Consider_Ignore_Fragment_Access;
function Create_Constraint
(Self : not null access UML_Factory)
return AMF.UML.Constraints.UML_Constraint_Access;
function Create_Continuation
(Self : not null access UML_Factory)
return AMF.UML.Continuations.UML_Continuation_Access;
function Create_Control_Flow
(Self : not null access UML_Factory)
return AMF.UML.Control_Flows.UML_Control_Flow_Access;
function Create_Create_Link_Action
(Self : not null access UML_Factory)
return AMF.UML.Create_Link_Actions.UML_Create_Link_Action_Access;
function Create_Create_Link_Object_Action
(Self : not null access UML_Factory)
return AMF.UML.Create_Link_Object_Actions.UML_Create_Link_Object_Action_Access;
function Create_Create_Object_Action
(Self : not null access UML_Factory)
return AMF.UML.Create_Object_Actions.UML_Create_Object_Action_Access;
function Create_Data_Store_Node
(Self : not null access UML_Factory)
return AMF.UML.Data_Store_Nodes.UML_Data_Store_Node_Access;
function Create_Data_Type
(Self : not null access UML_Factory)
return AMF.UML.Data_Types.UML_Data_Type_Access;
function Create_Decision_Node
(Self : not null access UML_Factory)
return AMF.UML.Decision_Nodes.UML_Decision_Node_Access;
function Create_Dependency
(Self : not null access UML_Factory)
return AMF.UML.Dependencies.UML_Dependency_Access;
function Create_Deployment
(Self : not null access UML_Factory)
return AMF.UML.Deployments.UML_Deployment_Access;
function Create_Deployment_Specification
(Self : not null access UML_Factory)
return AMF.UML.Deployment_Specifications.UML_Deployment_Specification_Access;
function Create_Destroy_Link_Action
(Self : not null access UML_Factory)
return AMF.UML.Destroy_Link_Actions.UML_Destroy_Link_Action_Access;
function Create_Destroy_Object_Action
(Self : not null access UML_Factory)
return AMF.UML.Destroy_Object_Actions.UML_Destroy_Object_Action_Access;
function Create_Destruction_Occurrence_Specification
(Self : not null access UML_Factory)
return AMF.UML.Destruction_Occurrence_Specifications.UML_Destruction_Occurrence_Specification_Access;
function Create_Device
(Self : not null access UML_Factory)
return AMF.UML.Devices.UML_Device_Access;
function Create_Duration
(Self : not null access UML_Factory)
return AMF.UML.Durations.UML_Duration_Access;
function Create_Duration_Constraint
(Self : not null access UML_Factory)
return AMF.UML.Duration_Constraints.UML_Duration_Constraint_Access;
function Create_Duration_Interval
(Self : not null access UML_Factory)
return AMF.UML.Duration_Intervals.UML_Duration_Interval_Access;
function Create_Duration_Observation
(Self : not null access UML_Factory)
return AMF.UML.Duration_Observations.UML_Duration_Observation_Access;
function Create_Element_Import
(Self : not null access UML_Factory)
return AMF.UML.Element_Imports.UML_Element_Import_Access;
function Create_Enumeration
(Self : not null access UML_Factory)
return AMF.UML.Enumerations.UML_Enumeration_Access;
function Create_Enumeration_Literal
(Self : not null access UML_Factory)
return AMF.UML.Enumeration_Literals.UML_Enumeration_Literal_Access;
function Create_Exception_Handler
(Self : not null access UML_Factory)
return AMF.UML.Exception_Handlers.UML_Exception_Handler_Access;
function Create_Execution_Environment
(Self : not null access UML_Factory)
return AMF.UML.Execution_Environments.UML_Execution_Environment_Access;
function Create_Execution_Occurrence_Specification
(Self : not null access UML_Factory)
return AMF.UML.Execution_Occurrence_Specifications.UML_Execution_Occurrence_Specification_Access;
function Create_Expansion_Node
(Self : not null access UML_Factory)
return AMF.UML.Expansion_Nodes.UML_Expansion_Node_Access;
function Create_Expansion_Region
(Self : not null access UML_Factory)
return AMF.UML.Expansion_Regions.UML_Expansion_Region_Access;
function Create_Expression
(Self : not null access UML_Factory)
return AMF.UML.Expressions.UML_Expression_Access;
function Create_Extend
(Self : not null access UML_Factory)
return AMF.UML.Extends.UML_Extend_Access;
function Create_Extension
(Self : not null access UML_Factory)
return AMF.UML.Extensions.UML_Extension_Access;
function Create_Extension_End
(Self : not null access UML_Factory)
return AMF.UML.Extension_Ends.UML_Extension_End_Access;
function Create_Extension_Point
(Self : not null access UML_Factory)
return AMF.UML.Extension_Points.UML_Extension_Point_Access;
function Create_Final_State
(Self : not null access UML_Factory)
return AMF.UML.Final_States.UML_Final_State_Access;
function Create_Flow_Final_Node
(Self : not null access UML_Factory)
return AMF.UML.Flow_Final_Nodes.UML_Flow_Final_Node_Access;
function Create_Fork_Node
(Self : not null access UML_Factory)
return AMF.UML.Fork_Nodes.UML_Fork_Node_Access;
function Create_Function_Behavior
(Self : not null access UML_Factory)
return AMF.UML.Function_Behaviors.UML_Function_Behavior_Access;
function Create_Gate
(Self : not null access UML_Factory)
return AMF.UML.Gates.UML_Gate_Access;
function Create_General_Ordering
(Self : not null access UML_Factory)
return AMF.UML.General_Orderings.UML_General_Ordering_Access;
function Create_Generalization
(Self : not null access UML_Factory)
return AMF.UML.Generalizations.UML_Generalization_Access;
function Create_Generalization_Set
(Self : not null access UML_Factory)
return AMF.UML.Generalization_Sets.UML_Generalization_Set_Access;
function Create_Image
(Self : not null access UML_Factory)
return AMF.UML.Images.UML_Image_Access;
function Create_Include
(Self : not null access UML_Factory)
return AMF.UML.Includes.UML_Include_Access;
function Create_Information_Flow
(Self : not null access UML_Factory)
return AMF.UML.Information_Flows.UML_Information_Flow_Access;
function Create_Information_Item
(Self : not null access UML_Factory)
return AMF.UML.Information_Items.UML_Information_Item_Access;
function Create_Initial_Node
(Self : not null access UML_Factory)
return AMF.UML.Initial_Nodes.UML_Initial_Node_Access;
function Create_Input_Pin
(Self : not null access UML_Factory)
return AMF.UML.Input_Pins.UML_Input_Pin_Access;
function Create_Instance_Specification
(Self : not null access UML_Factory)
return AMF.UML.Instance_Specifications.UML_Instance_Specification_Access;
function Create_Instance_Value
(Self : not null access UML_Factory)
return AMF.UML.Instance_Values.UML_Instance_Value_Access;
function Create_Interaction
(Self : not null access UML_Factory)
return AMF.UML.Interactions.UML_Interaction_Access;
function Create_Interaction_Constraint
(Self : not null access UML_Factory)
return AMF.UML.Interaction_Constraints.UML_Interaction_Constraint_Access;
function Create_Interaction_Operand
(Self : not null access UML_Factory)
return AMF.UML.Interaction_Operands.UML_Interaction_Operand_Access;
function Create_Interaction_Use
(Self : not null access UML_Factory)
return AMF.UML.Interaction_Uses.UML_Interaction_Use_Access;
function Create_Interface
(Self : not null access UML_Factory)
return AMF.UML.Interfaces.UML_Interface_Access;
function Create_Interface_Realization
(Self : not null access UML_Factory)
return AMF.UML.Interface_Realizations.UML_Interface_Realization_Access;
function Create_Interruptible_Activity_Region
(Self : not null access UML_Factory)
return AMF.UML.Interruptible_Activity_Regions.UML_Interruptible_Activity_Region_Access;
function Create_Interval
(Self : not null access UML_Factory)
return AMF.UML.Intervals.UML_Interval_Access;
function Create_Interval_Constraint
(Self : not null access UML_Factory)
return AMF.UML.Interval_Constraints.UML_Interval_Constraint_Access;
function Create_Join_Node
(Self : not null access UML_Factory)
return AMF.UML.Join_Nodes.UML_Join_Node_Access;
function Create_Lifeline
(Self : not null access UML_Factory)
return AMF.UML.Lifelines.UML_Lifeline_Access;
function Create_Link_End_Creation_Data
(Self : not null access UML_Factory)
return AMF.UML.Link_End_Creation_Datas.UML_Link_End_Creation_Data_Access;
function Create_Link_End_Data
(Self : not null access UML_Factory)
return AMF.UML.Link_End_Datas.UML_Link_End_Data_Access;
function Create_Link_End_Destruction_Data
(Self : not null access UML_Factory)
return AMF.UML.Link_End_Destruction_Datas.UML_Link_End_Destruction_Data_Access;
function Create_Literal_Boolean
(Self : not null access UML_Factory)
return AMF.UML.Literal_Booleans.UML_Literal_Boolean_Access;
function Create_Literal_Integer
(Self : not null access UML_Factory)
return AMF.UML.Literal_Integers.UML_Literal_Integer_Access;
function Create_Literal_Null
(Self : not null access UML_Factory)
return AMF.UML.Literal_Nulls.UML_Literal_Null_Access;
function Create_Literal_Real
(Self : not null access UML_Factory)
return AMF.UML.Literal_Reals.UML_Literal_Real_Access;
function Create_Literal_String
(Self : not null access UML_Factory)
return AMF.UML.Literal_Strings.UML_Literal_String_Access;
function Create_Literal_Unlimited_Natural
(Self : not null access UML_Factory)
return AMF.UML.Literal_Unlimited_Naturals.UML_Literal_Unlimited_Natural_Access;
function Create_Loop_Node
(Self : not null access UML_Factory)
return AMF.UML.Loop_Nodes.UML_Loop_Node_Access;
function Create_Manifestation
(Self : not null access UML_Factory)
return AMF.UML.Manifestations.UML_Manifestation_Access;
function Create_Merge_Node
(Self : not null access UML_Factory)
return AMF.UML.Merge_Nodes.UML_Merge_Node_Access;
function Create_Message
(Self : not null access UML_Factory)
return AMF.UML.Messages.UML_Message_Access;
function Create_Message_Occurrence_Specification
(Self : not null access UML_Factory)
return AMF.UML.Message_Occurrence_Specifications.UML_Message_Occurrence_Specification_Access;
function Create_Model
(Self : not null access UML_Factory)
return AMF.UML.Models.UML_Model_Access;
function Create_Node
(Self : not null access UML_Factory)
return AMF.UML.Nodes.UML_Node_Access;
function Create_Object_Flow
(Self : not null access UML_Factory)
return AMF.UML.Object_Flows.UML_Object_Flow_Access;
function Create_Occurrence_Specification
(Self : not null access UML_Factory)
return AMF.UML.Occurrence_Specifications.UML_Occurrence_Specification_Access;
function Create_Opaque_Action
(Self : not null access UML_Factory)
return AMF.UML.Opaque_Actions.UML_Opaque_Action_Access;
function Create_Opaque_Behavior
(Self : not null access UML_Factory)
return AMF.UML.Opaque_Behaviors.UML_Opaque_Behavior_Access;
function Create_Opaque_Expression
(Self : not null access UML_Factory)
return AMF.UML.Opaque_Expressions.UML_Opaque_Expression_Access;
function Create_Operation
(Self : not null access UML_Factory)
return AMF.UML.Operations.UML_Operation_Access;
function Create_Operation_Template_Parameter
(Self : not null access UML_Factory)
return AMF.UML.Operation_Template_Parameters.UML_Operation_Template_Parameter_Access;
function Create_Output_Pin
(Self : not null access UML_Factory)
return AMF.UML.Output_Pins.UML_Output_Pin_Access;
function Create_Package
(Self : not null access UML_Factory)
return AMF.UML.Packages.UML_Package_Access;
function Create_Package_Import
(Self : not null access UML_Factory)
return AMF.UML.Package_Imports.UML_Package_Import_Access;
function Create_Package_Merge
(Self : not null access UML_Factory)
return AMF.UML.Package_Merges.UML_Package_Merge_Access;
function Create_Parameter
(Self : not null access UML_Factory)
return AMF.UML.Parameters.UML_Parameter_Access;
function Create_Parameter_Set
(Self : not null access UML_Factory)
return AMF.UML.Parameter_Sets.UML_Parameter_Set_Access;
function Create_Part_Decomposition
(Self : not null access UML_Factory)
return AMF.UML.Part_Decompositions.UML_Part_Decomposition_Access;
function Create_Port
(Self : not null access UML_Factory)
return AMF.UML.Ports.UML_Port_Access;
function Create_Primitive_Type
(Self : not null access UML_Factory)
return AMF.UML.Primitive_Types.UML_Primitive_Type_Access;
function Create_Profile
(Self : not null access UML_Factory)
return AMF.UML.Profiles.UML_Profile_Access;
function Create_Profile_Application
(Self : not null access UML_Factory)
return AMF.UML.Profile_Applications.UML_Profile_Application_Access;
function Create_Property
(Self : not null access UML_Factory)
return AMF.UML.Properties.UML_Property_Access;
function Create_Protocol_Conformance
(Self : not null access UML_Factory)
return AMF.UML.Protocol_Conformances.UML_Protocol_Conformance_Access;
function Create_Protocol_State_Machine
(Self : not null access UML_Factory)
return AMF.UML.Protocol_State_Machines.UML_Protocol_State_Machine_Access;
function Create_Protocol_Transition
(Self : not null access UML_Factory)
return AMF.UML.Protocol_Transitions.UML_Protocol_Transition_Access;
function Create_Pseudostate
(Self : not null access UML_Factory)
return AMF.UML.Pseudostates.UML_Pseudostate_Access;
function Create_Qualifier_Value
(Self : not null access UML_Factory)
return AMF.UML.Qualifier_Values.UML_Qualifier_Value_Access;
function Create_Raise_Exception_Action
(Self : not null access UML_Factory)
return AMF.UML.Raise_Exception_Actions.UML_Raise_Exception_Action_Access;
function Create_Read_Extent_Action
(Self : not null access UML_Factory)
return AMF.UML.Read_Extent_Actions.UML_Read_Extent_Action_Access;
function Create_Read_Is_Classified_Object_Action
(Self : not null access UML_Factory)
return AMF.UML.Read_Is_Classified_Object_Actions.UML_Read_Is_Classified_Object_Action_Access;
function Create_Read_Link_Action
(Self : not null access UML_Factory)
return AMF.UML.Read_Link_Actions.UML_Read_Link_Action_Access;
function Create_Read_Link_Object_End_Action
(Self : not null access UML_Factory)
return AMF.UML.Read_Link_Object_End_Actions.UML_Read_Link_Object_End_Action_Access;
function Create_Read_Link_Object_End_Qualifier_Action
(Self : not null access UML_Factory)
return AMF.UML.Read_Link_Object_End_Qualifier_Actions.UML_Read_Link_Object_End_Qualifier_Action_Access;
function Create_Read_Self_Action
(Self : not null access UML_Factory)
return AMF.UML.Read_Self_Actions.UML_Read_Self_Action_Access;
function Create_Read_Structural_Feature_Action
(Self : not null access UML_Factory)
return AMF.UML.Read_Structural_Feature_Actions.UML_Read_Structural_Feature_Action_Access;
function Create_Read_Variable_Action
(Self : not null access UML_Factory)
return AMF.UML.Read_Variable_Actions.UML_Read_Variable_Action_Access;
function Create_Realization
(Self : not null access UML_Factory)
return AMF.UML.Realizations.UML_Realization_Access;
function Create_Reception
(Self : not null access UML_Factory)
return AMF.UML.Receptions.UML_Reception_Access;
function Create_Reclassify_Object_Action
(Self : not null access UML_Factory)
return AMF.UML.Reclassify_Object_Actions.UML_Reclassify_Object_Action_Access;
function Create_Redefinable_Template_Signature
(Self : not null access UML_Factory)
return AMF.UML.Redefinable_Template_Signatures.UML_Redefinable_Template_Signature_Access;
function Create_Reduce_Action
(Self : not null access UML_Factory)
return AMF.UML.Reduce_Actions.UML_Reduce_Action_Access;
function Create_Region
(Self : not null access UML_Factory)
return AMF.UML.Regions.UML_Region_Access;
function Create_Remove_Structural_Feature_Value_Action
(Self : not null access UML_Factory)
return AMF.UML.Remove_Structural_Feature_Value_Actions.UML_Remove_Structural_Feature_Value_Action_Access;
function Create_Remove_Variable_Value_Action
(Self : not null access UML_Factory)
return AMF.UML.Remove_Variable_Value_Actions.UML_Remove_Variable_Value_Action_Access;
function Create_Reply_Action
(Self : not null access UML_Factory)
return AMF.UML.Reply_Actions.UML_Reply_Action_Access;
function Create_Send_Object_Action
(Self : not null access UML_Factory)
return AMF.UML.Send_Object_Actions.UML_Send_Object_Action_Access;
function Create_Send_Signal_Action
(Self : not null access UML_Factory)
return AMF.UML.Send_Signal_Actions.UML_Send_Signal_Action_Access;
function Create_Sequence_Node
(Self : not null access UML_Factory)
return AMF.UML.Sequence_Nodes.UML_Sequence_Node_Access;
function Create_Signal
(Self : not null access UML_Factory)
return AMF.UML.Signals.UML_Signal_Access;
function Create_Signal_Event
(Self : not null access UML_Factory)
return AMF.UML.Signal_Events.UML_Signal_Event_Access;
function Create_Slot
(Self : not null access UML_Factory)
return AMF.UML.Slots.UML_Slot_Access;
function Create_Start_Classifier_Behavior_Action
(Self : not null access UML_Factory)
return AMF.UML.Start_Classifier_Behavior_Actions.UML_Start_Classifier_Behavior_Action_Access;
function Create_Start_Object_Behavior_Action
(Self : not null access UML_Factory)
return AMF.UML.Start_Object_Behavior_Actions.UML_Start_Object_Behavior_Action_Access;
function Create_State
(Self : not null access UML_Factory)
return AMF.UML.States.UML_State_Access;
function Create_State_Invariant
(Self : not null access UML_Factory)
return AMF.UML.State_Invariants.UML_State_Invariant_Access;
function Create_State_Machine
(Self : not null access UML_Factory)
return AMF.UML.State_Machines.UML_State_Machine_Access;
function Create_Stereotype
(Self : not null access UML_Factory)
return AMF.UML.Stereotypes.UML_Stereotype_Access;
function Create_String_Expression
(Self : not null access UML_Factory)
return AMF.UML.String_Expressions.UML_String_Expression_Access;
function Create_Structured_Activity_Node
(Self : not null access UML_Factory)
return AMF.UML.Structured_Activity_Nodes.UML_Structured_Activity_Node_Access;
function Create_Substitution
(Self : not null access UML_Factory)
return AMF.UML.Substitutions.UML_Substitution_Access;
function Create_Template_Binding
(Self : not null access UML_Factory)
return AMF.UML.Template_Bindings.UML_Template_Binding_Access;
function Create_Template_Parameter
(Self : not null access UML_Factory)
return AMF.UML.Template_Parameters.UML_Template_Parameter_Access;
function Create_Template_Parameter_Substitution
(Self : not null access UML_Factory)
return AMF.UML.Template_Parameter_Substitutions.UML_Template_Parameter_Substitution_Access;
function Create_Template_Signature
(Self : not null access UML_Factory)
return AMF.UML.Template_Signatures.UML_Template_Signature_Access;
function Create_Test_Identity_Action
(Self : not null access UML_Factory)
return AMF.UML.Test_Identity_Actions.UML_Test_Identity_Action_Access;
function Create_Time_Constraint
(Self : not null access UML_Factory)
return AMF.UML.Time_Constraints.UML_Time_Constraint_Access;
function Create_Time_Event
(Self : not null access UML_Factory)
return AMF.UML.Time_Events.UML_Time_Event_Access;
function Create_Time_Expression
(Self : not null access UML_Factory)
return AMF.UML.Time_Expressions.UML_Time_Expression_Access;
function Create_Time_Interval
(Self : not null access UML_Factory)
return AMF.UML.Time_Intervals.UML_Time_Interval_Access;
function Create_Time_Observation
(Self : not null access UML_Factory)
return AMF.UML.Time_Observations.UML_Time_Observation_Access;
function Create_Transition
(Self : not null access UML_Factory)
return AMF.UML.Transitions.UML_Transition_Access;
function Create_Trigger
(Self : not null access UML_Factory)
return AMF.UML.Triggers.UML_Trigger_Access;
function Create_Unmarshall_Action
(Self : not null access UML_Factory)
return AMF.UML.Unmarshall_Actions.UML_Unmarshall_Action_Access;
function Create_Usage
(Self : not null access UML_Factory)
return AMF.UML.Usages.UML_Usage_Access;
function Create_Use_Case
(Self : not null access UML_Factory)
return AMF.UML.Use_Cases.UML_Use_Case_Access;
function Create_Value_Pin
(Self : not null access UML_Factory)
return AMF.UML.Value_Pins.UML_Value_Pin_Access;
function Create_Value_Specification_Action
(Self : not null access UML_Factory)
return AMF.UML.Value_Specification_Actions.UML_Value_Specification_Action_Access;
function Create_Variable
(Self : not null access UML_Factory)
return AMF.UML.Variables.UML_Variable_Access;
end AMF.Internals.Factories.UML_Factories;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Test is
procedure R is begin R; end;
begin
R;
end;
|
--
-- Copyright (C) 2015-2016 secunet Security Networks AG
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
with HW.GFX.GMA.Registers;
use type HW.Int32;
private package HW.GFX.GMA.Pipe_Setup
is
procedure On
(Pipe : Pipe_Index;
Port_Cfg : Port_Config;
Framebuffer : Framebuffer_Type;
Cursor : Cursor_Type)
with
Pre =>
Rotated_Width (Framebuffer) <= Port_Cfg.Mode.H_Visible and
Rotated_Height (Framebuffer) <= Port_Cfg.Mode.V_Visible and
(Framebuffer.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or
Framebuffer.Height + Framebuffer.Start_Y <= Framebuffer.V_Stride);
procedure Off (Pipe : Pipe_Index);
procedure Legacy_VGA_Off;
procedure All_Off;
procedure Setup_FB
(Pipe : Pipe_Index;
Mode : Mode_Type;
Framebuffer : Framebuffer_Type)
with
Pre =>
Rotated_Width (Framebuffer) <= Mode.H_Visible and
Rotated_Height (Framebuffer) <= Mode.V_Visible and
(Framebuffer.Offset = VGA_PLANE_FRAMEBUFFER_OFFSET or
Framebuffer.Height + Framebuffer.Start_Y <= Framebuffer.V_Stride);
procedure Update_Cursor
(Pipe : Pipe_Index;
FB : Framebuffer_Type;
Cursor : Cursor_Type);
procedure Place_Cursor
(Pipe : Pipe_Index;
FB : Framebuffer_Type;
Cursor : Cursor_Type);
procedure Scaler_Available (Available : out Boolean; Pipe : Pipe_Index);
private
subtype WM_Levels is Natural range 0 .. 7;
type PLANE_WM_Type is array (WM_Levels) of Registers.Registers_Index;
type Controller_Type is
record
Pipe : Pipe_Index;
PIPESRC : Registers.Registers_Index;
PIPEMISC : Registers.Registers_Index;
PF_CTRL : Registers.Registers_Index;
PF_WIN_POS : Registers.Registers_Index;
PF_WIN_SZ : Registers.Registers_Index;
DSPCNTR : Registers.Registers_Index;
DSPLINOFF : Registers.Registers_Index;
DSPSTRIDE : Registers.Registers_Index;
DSPSURF : Registers.Registers_Index;
DSPTILEOFF : Registers.Registers_Index;
SPCNTR : Registers.Registers_Index;
CUR_CTL : Registers.Registers_Index;
CUR_BASE : Registers.Registers_Index;
CUR_POS : Registers.Registers_Index;
CUR_FBC_CTL : Registers.Registers_Index;
-- Skylake registers (partially aliased)
PLANE_CTL : Registers.Registers_Index;
PLANE_OFFSET : Registers.Registers_Index;
PLANE_POS : Registers.Registers_Index;
PLANE_SIZE : Registers.Registers_Index;
PLANE_STRIDE : Registers.Registers_Index;
PLANE_SURF : Registers.Registers_Index;
PS_CTRL_1 : Registers.Registers_Index;
PS_WIN_POS_1 : Registers.Registers_Index;
PS_WIN_SZ_1 : Registers.Registers_Index;
PS_CTRL_2 : Registers.Registers_Invalid_Index;
PS_WIN_SZ_2 : Registers.Registers_Invalid_Index;
WM_LINETIME : Registers.Registers_Index;
PLANE_BUF_CFG : Registers.Registers_Index;
PLANE_WM : PLANE_WM_Type;
CUR_BUF_CFG : Registers.Registers_Index;
CUR_WM : PLANE_WM_Type;
end record;
type Controller_Array is array (Pipe_Index) of Controller_Type;
Controllers : constant Controller_Array :=
(Primary => Controller_Type'
(Pipe => Primary,
PIPESRC => Registers.PIPEASRC,
PIPEMISC => Registers.PIPEAMISC,
PF_CTRL => Registers.PFA_CTL_1,
PF_WIN_POS => Registers.PFA_WIN_POS,
PF_WIN_SZ => Registers.PFA_WIN_SZ,
DSPCNTR => Registers.DSPACNTR,
DSPLINOFF => Registers.DSPALINOFF,
DSPSTRIDE => Registers.DSPASTRIDE,
DSPSURF => Registers.DSPASURF,
DSPTILEOFF => Registers.DSPATILEOFF,
SPCNTR => Registers.SPACNTR,
CUR_CTL => Registers.CUR_CTL_A,
CUR_BASE => Registers.CUR_BASE_A,
CUR_POS => Registers.CUR_POS_A,
CUR_FBC_CTL => Registers.CUR_FBC_CTL_A,
PLANE_CTL => Registers.DSPACNTR,
PLANE_OFFSET => Registers.DSPATILEOFF,
PLANE_POS => Registers.PLANE_POS_1_A,
PLANE_SIZE => Registers.PLANE_SIZE_1_A,
PLANE_STRIDE => Registers.DSPASTRIDE,
PLANE_SURF => Registers.DSPASURF,
PS_CTRL_1 => Registers.PS_CTRL_1_A,
PS_WIN_POS_1 => Registers.PS_WIN_POS_1_A,
PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_A,
PS_CTRL_2 => Registers.PS_CTRL_2_A,
PS_WIN_SZ_2 => Registers.PS_WIN_SZ_2_A,
WM_LINETIME => Registers.WM_LINETIME_A,
PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_A,
PLANE_WM => PLANE_WM_Type'(
Registers.PLANE_WM_1_A_0,
Registers.PLANE_WM_1_A_1,
Registers.PLANE_WM_1_A_2,
Registers.PLANE_WM_1_A_3,
Registers.PLANE_WM_1_A_4,
Registers.PLANE_WM_1_A_5,
Registers.PLANE_WM_1_A_6,
Registers.PLANE_WM_1_A_7),
CUR_BUF_CFG => Registers.CUR_BUF_CFG_A,
CUR_WM => PLANE_WM_Type'(
Registers.CUR_WM_A_0,
Registers.CUR_WM_A_1,
Registers.CUR_WM_A_2,
Registers.CUR_WM_A_3,
Registers.CUR_WM_A_4,
Registers.CUR_WM_A_5,
Registers.CUR_WM_A_6,
Registers.CUR_WM_A_7)),
Secondary => Controller_Type'
(Pipe => Secondary,
PIPESRC => Registers.PIPEBSRC,
PIPEMISC => Registers.PIPEBMISC,
PF_CTRL => Registers.PFB_CTL_1,
PF_WIN_POS => Registers.PFB_WIN_POS,
PF_WIN_SZ => Registers.PFB_WIN_SZ,
DSPCNTR => Registers.DSPBCNTR,
DSPLINOFF => Registers.DSPBLINOFF,
DSPSTRIDE => Registers.DSPBSTRIDE,
DSPSURF => Registers.DSPBSURF,
DSPTILEOFF => Registers.DSPBTILEOFF,
SPCNTR => Registers.SPBCNTR,
CUR_CTL => Registers.CUR_CTL_B,
CUR_BASE => Registers.CUR_BASE_B,
CUR_POS => Registers.CUR_POS_B,
CUR_FBC_CTL => Registers.CUR_FBC_CTL_B,
PLANE_CTL => Registers.DSPBCNTR,
PLANE_OFFSET => Registers.DSPBTILEOFF,
PLANE_POS => Registers.PLANE_POS_1_B,
PLANE_SIZE => Registers.PLANE_SIZE_1_B,
PLANE_STRIDE => Registers.DSPBSTRIDE,
PLANE_SURF => Registers.DSPBSURF,
PS_CTRL_1 => Registers.PS_CTRL_1_B,
PS_WIN_POS_1 => Registers.PS_WIN_POS_1_B,
PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_B,
PS_CTRL_2 => Registers.PS_CTRL_2_B,
PS_WIN_SZ_2 => Registers.PS_WIN_SZ_2_B,
WM_LINETIME => Registers.WM_LINETIME_B,
PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_B,
PLANE_WM => PLANE_WM_Type'(
Registers.PLANE_WM_1_B_0,
Registers.PLANE_WM_1_B_1,
Registers.PLANE_WM_1_B_2,
Registers.PLANE_WM_1_B_3,
Registers.PLANE_WM_1_B_4,
Registers.PLANE_WM_1_B_5,
Registers.PLANE_WM_1_B_6,
Registers.PLANE_WM_1_B_7),
CUR_BUF_CFG => Registers.CUR_BUF_CFG_B,
CUR_WM => PLANE_WM_Type'(
Registers.CUR_WM_B_0,
Registers.CUR_WM_B_1,
Registers.CUR_WM_B_2,
Registers.CUR_WM_B_3,
Registers.CUR_WM_B_4,
Registers.CUR_WM_B_5,
Registers.CUR_WM_B_6,
Registers.CUR_WM_B_7)),
Tertiary => Controller_Type'
(Pipe => Tertiary,
PIPESRC => Registers.PIPECSRC,
PIPEMISC => Registers.PIPECMISC,
PF_CTRL => Registers.PFC_CTL_1,
PF_WIN_POS => Registers.PFC_WIN_POS,
PF_WIN_SZ => Registers.PFC_WIN_SZ,
DSPCNTR => Registers.DSPCCNTR,
DSPLINOFF => Registers.DSPCLINOFF,
DSPSTRIDE => Registers.DSPCSTRIDE,
DSPSURF => Registers.DSPCSURF,
DSPTILEOFF => Registers.DSPCTILEOFF,
SPCNTR => Registers.SPCCNTR,
CUR_CTL => Registers.CUR_CTL_C,
CUR_BASE => Registers.CUR_BASE_C,
CUR_POS => Registers.CUR_POS_C,
CUR_FBC_CTL => Registers.CUR_FBC_CTL_C,
PLANE_CTL => Registers.DSPCCNTR,
PLANE_OFFSET => Registers.DSPCTILEOFF,
PLANE_POS => Registers.PLANE_POS_1_C,
PLANE_SIZE => Registers.PLANE_SIZE_1_C,
PLANE_STRIDE => Registers.DSPCSTRIDE,
PLANE_SURF => Registers.DSPCSURF,
PS_CTRL_1 => Registers.PS_CTRL_1_C,
PS_WIN_POS_1 => Registers.PS_WIN_POS_1_C,
PS_WIN_SZ_1 => Registers.PS_WIN_SZ_1_C,
PS_CTRL_2 => Registers.Invalid_Register,
PS_WIN_SZ_2 => Registers.Invalid_Register,
WM_LINETIME => Registers.WM_LINETIME_C,
PLANE_BUF_CFG => Registers.PLANE_BUF_CFG_1_C,
PLANE_WM => PLANE_WM_Type'(
Registers.PLANE_WM_1_C_0,
Registers.PLANE_WM_1_C_1,
Registers.PLANE_WM_1_C_2,
Registers.PLANE_WM_1_C_3,
Registers.PLANE_WM_1_C_4,
Registers.PLANE_WM_1_C_5,
Registers.PLANE_WM_1_C_6,
Registers.PLANE_WM_1_C_7),
CUR_BUF_CFG => Registers.CUR_BUF_CFG_C,
CUR_WM => PLANE_WM_Type'(
Registers.CUR_WM_C_0,
Registers.CUR_WM_C_1,
Registers.CUR_WM_C_2,
Registers.CUR_WM_C_3,
Registers.CUR_WM_C_4,
Registers.CUR_WM_C_5,
Registers.CUR_WM_C_6,
Registers.CUR_WM_C_7)));
end HW.GFX.GMA.Pipe_Setup;
|
-- Abstract :
--
-- See spec
--
-- Copyright (C) 2012, 2013, 2015, 2017 - 2019 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or
-- modify it under terms of the GNU General Public License as
-- published by the Free Software Foundation; either version 3, or (at
-- your option) any later version. This program is distributed in the
-- hope that it will be useful, but WITHOUT ANY WARRANTY; without even
-- the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
-- PURPOSE. See the GNU General Public License for more details. You
-- should have received a copy of the GNU General Public License
-- distributed with this program; see file COPYING. If not, write to
-- the Free Software Foundation, 51 Franklin Street, Suite 500, Boston,
-- MA 02110-1335, USA.
pragma License (GPL);
with Ada.Text_IO;
with WisiToken.Generate;
package body WisiToken.BNF.Output_Elisp_Common is
function Find_Elisp_ID (List : in String_Lists.List; Elisp_Name : in String) return Integer
is
I : Integer := 0; -- match elisp array
begin
for Name of List loop
if Name = Elisp_Name then
return I;
end if;
I := I + 1;
end loop;
raise Not_Found with "unknown elisp name: '" & Elisp_Name & "'";
end Find_Elisp_ID;
function Elisp_Name_To_Ada
(Elisp_Name : in String;
Append_ID : in Boolean;
Trim : in Integer)
return String
is
Result : String := Elisp_Name (Elisp_Name'First + Trim .. Elisp_Name'Last);
begin
Result (Result'First) := To_Upper (Result (Result'First));
for I in Result'Range loop
if Result (I) = '-' then
Result (I) := '_';
Result (I + 1) := To_Upper (Result (I + 1));
elsif Result (I) = '_' then
Result (I + 1) := To_Upper (Result (I + 1));
end if;
end loop;
if Append_ID then
return Result & "_ID"; -- Some elisp names may be Ada reserved words;
else
return Result;
end if;
end Elisp_Name_To_Ada;
procedure Indent_Keyword_Table
(Output_File_Root : in String;
Label : in String;
Keywords : in String_Pair_Lists.List;
Image : access function (Name : in Ada.Strings.Unbounded.Unbounded_String) return String)
is
use Ada.Text_IO;
use WisiToken.Generate;
begin
Indent_Line ("(defconst " & Output_File_Root & "-" & Label & "-keyword-table-raw");
Indent_Line (" '(");
Indent := Indent + 3;
for Pair of Keywords loop
Indent_Line ("(" & (-Pair.Value) & " . " & Image (Pair.Name) & ")");
end loop;
Indent_Line ("))");
Indent := Indent - 3;
end Indent_Keyword_Table;
procedure Indent_Token_Table
(Output_File_Root : in String;
Label : in String;
Tokens : in Token_Lists.List;
Image : access function (Name : in Ada.Strings.Unbounded.Unbounded_String) return String)
is
use Ada.Strings.Unbounded;
use Ada.Text_IO;
use WisiToken.Generate;
function To_Double_Quotes (Item : in String) return String
is
Result : String := Item;
begin
if Result (Result'First) = ''' then
Result (Result'First) := '"';
end if;
if Result (Result'Last) = ''' then
Result (Result'Last) := '"';
end if;
return Result;
end To_Double_Quotes;
begin
Indent_Line ("(defconst " & Output_File_Root & "-" & Label & "-token-table-raw");
Indent_Line (" '(");
Indent := Indent + 3;
for Kind of Tokens loop
if not (-Kind.Kind = "line_comment" or -Kind.Kind = "whitespace") then
Indent_Line ("(""" & (-Kind.Kind) & """");
Indent := Indent + 1;
for Token of Kind.Tokens loop
if 0 = Length (Token.Value) then
Indent_Line ("(" & Image (Token.Name) & ")");
else
if -Kind.Kind = "number" then
-- allow for (<token> <number-p> <require>)
Indent_Line ("(" & Image (Token.Name) & " " & (-Token.Value) & ")");
elsif -Kind.Kind = "symbol" or
-Kind.Kind = "string-double" or
-Kind.Kind = "string-single"
then
-- value not used by elisp
Indent_Line ("(" & Image (Token.Name) & " . """")");
else
Indent_Line ("(" & Image (Token.Name) & " . " & To_Double_Quotes (-Token.Value) & ")");
end if;
end if;
end loop;
Indent_Line (")");
Indent := Indent - 1;
end if;
end loop;
Indent_Line ("))");
Indent := Indent - 3;
end Indent_Token_Table;
procedure Indent_Name_Table
(Output_File_Root : in String;
Label : in String;
Names : in String_Lists.List)
is
use Ada.Text_IO;
use WisiToken.Generate;
begin
Indent_Line ("(defconst " & Output_File_Root & "-" & Label);
Indent_Line (" [");
Indent := Indent + 3;
for Name of Names loop
Indent_Line (Name);
end loop;
Indent_Line ("])");
Indent := Indent - 3;
end Indent_Name_Table;
procedure Indent_Repair_Image
(Output_File_Root : in String;
Label : in String;
Tokens : in WisiToken.BNF.Tokens)
is
use all type Ada.Text_IO.Count;
use Ada.Strings.Unbounded;
use WisiToken.Generate;
function re2c_To_Elisp (Item : in String) return String
is
Result : String (1 .. Item'Length * 2);
Last : Integer := Result'First - 1;
begin
-- Convert re2c case-insensitive string '...' to elisp string "...",
-- with '"' escaped.
if Item (Item'First) /= ''' then
return Item;
end if;
for C of Item loop
if C = ''' then
Result (Last + 1) := '"';
Last := Last + 1;
elsif C = '"' then
Result (Last + 1) := '\';
Result (Last + 2) := '"';
Last := Last + 2;
else
Result (Last + 1) := C;
Last := Last + 1;
end if;
end loop;
return Result (1 .. Last);
end re2c_To_Elisp;
begin
Indent_Line ("(defconst " & Output_File_Root & "-" & Label & "-repair-image");
Indent_Line (" '(");
Indent := Indent + 3;
for Pair of Tokens.Keywords loop
Indent_Line ("(" & (-Pair.Name) & " . " & (-Pair.Value) & ")");
end loop;
for Kind of Tokens.Tokens loop
for Token of Kind.Tokens loop
if Length (Token.Repair_Image) > 0 then
Indent_Line ("(" & (-Token.Name) & " . " & re2c_To_Elisp (-Token.Repair_Image) & ")");
else
Indent_Line ("(" & (-Token.Name) & " . " & (-Token.Value) & ")");
end if;
end loop;
end loop;
Indent_Line ("))");
Indent := Indent - 3;
end Indent_Repair_Image;
end WisiToken.BNF.Output_Elisp_Common;
|
-- Module : string_scanner.ada
-- Component of : common_library
-- Version : 1.2
-- Date : 11/21/86 16:36:26
-- SCCS File : disk21~/rschm/hasee/sccs/common_library/sccs/sxstring_scanner.ada
with String_Pkg; use String_Pkg;
with Unchecked_Deallocation;
package body String_Scanner is
SCCS_ID : constant String := "@(#) string_scanner.ada, Version 1.2";
White_Space : constant string := " " & ASCII.HT;
Number_1 : constant string := "0123456789";
Number : constant string := Number_1 & "_";
Quote : constant string := """";
Ada_Id_1 : constant string := "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
Ada_Id : constant string := Ada_Id_1 & Number;
procedure Free_Scanner is
new Unchecked_Deallocation(Scan_Record, Scanner);
pragma Page;
function Is_Valid(
T : in Scanner
) return boolean is
begin
return T /= null;
end Is_Valid;
function Make_Scanner(
S : in String_Type
) return Scanner is
T : Scanner := new Scan_Record;
begin
T.text := String_Pkg.Make_Persistent(S);
return T;
end Make_Scanner;
----------------------------------------------------------------
procedure Destroy_Scanner(
T : in out Scanner
) is
begin
if Is_Valid(T) then
String_Pkg.Flush(T.text);
Free_Scanner(T);
end if;
end Destroy_Scanner;
----------------------------------------------------------------
function More(
T : in Scanner
) return boolean is
begin
if Is_Valid(T) then
if T.index > String_Pkg.Length(T.text) then
return false;
else
return true;
end if;
else
return false;
end if;
end More;
----------------------------------------------------------------
function Get(
T : in Scanner
) return character is
begin
if not More(T) then
raise Out_Of_Bounds;
end if;
return String_Pkg.Fetch(T.text, T.index);
end Get;
----------------------------------------------------------------
procedure Forward(
T : in Scanner
) is
begin
if Is_Valid(T) then
if String_Pkg.Length(T.text) >= T.index then
T.index := T.index + 1;
end if;
end if;
end Forward;
----------------------------------------------------------------
procedure Backward(
T : in Scanner
) is
begin
if Is_Valid(T) then
if T.index > 1 then
T.index := T.index - 1;
end if;
end if;
end Backward;
----------------------------------------------------------------
procedure Next(
T : in Scanner;
C : out character
) is
begin
C := Get(T);
Forward(T);
end Next;
----------------------------------------------------------------
function Position(
T : in Scanner
) return positive is
begin
if not More(T) then
raise Out_Of_Bounds;
end if;
return T.index;
end Position;
----------------------------------------------------------------
function Get_String(
T : in Scanner
) return String_Type is
begin
if Is_Valid(T) then
return String_Pkg.Make_Persistent(T.text);
else
return String_Pkg.Make_Persistent("");
end if;
end Get_String;
----------------------------------------------------------------
function Get_Remainder(
T : in Scanner
) return String_Type is
S_Str : String_Type;
begin
if More(T) then
String_Pkg.Mark;
S_Str := String_Pkg.Make_Persistent(
String_Pkg.Substr(T.text,
T.index,
String_Pkg.Length(T.text) - T.index + 1));
String_Pkg.Release;
else
S_Str := String_Pkg.Make_Persistent("");
end if;
return S_Str;
end Get_Remainder;
----------------------------------------------------------------
procedure Mark(
T : in Scanner
) is
begin
if Is_Valid(T) then
if T.mark /= 0 then
raise Scanner_Already_Marked;
else
T.mark := T.index;
end if;
end if;
end Mark;
----------------------------------------------------------------
procedure Restore(
T : in Scanner
) is
begin
if Is_Valid(T) then
if T.mark /= 0 then
T.index := T.mark;
T.mark := 0;
end if;
end if;
end Restore;
pragma Page;
function Is_Any(
T : in Scanner;
Q : in string
) return boolean is
N : natural;
begin
if not More(T) then
return false;
end if;
String_Pkg.Mark;
N := String_Pkg.Match_Any(T.text, Q, T.index);
if N /= T.index then
N := 0;
end if;
String_Pkg.Release;
return N /= 0;
end Is_Any;
pragma Page;
procedure Scan_Any(
T : in Scanner;
Q : in string;
Found : out boolean;
Result : in out String_Type
) is
S_Str : String_Type;
N : natural;
begin
if Is_Any(T, Q) then
N := String_Pkg.Match_None(T.text, Q, T.index);
if N = 0 then
N := String_Pkg.Length(T.text) + 1;
end if;
Result := Result & String_Pkg.Substr(T.text, T.index, N - T.index);
T.index := N;
Found := true;
else
Found := false;
end if;
end Scan_Any;
pragma Page;
function Quoted_String(
T : in Scanner
) return integer is
Count : integer := 0;
I : positive;
N : natural;
begin
if not Is_Valid(T) then
return Count;
end if;
I := T.index;
while Is_Any(T, """") loop
T.index := T.index + 1;
if not More(T) then
T.index := I;
return 0;
end if;
String_Pkg.Mark;
N := String_Pkg.Match_Any(T.text, """", T.index);
String_Pkg.Release;
if N = 0 then
T.index := I;
return 0;
end if;
T.index := N + 1;
end loop;
Count := T.index - I;
T.index := I;
return Count;
end Quoted_String;
pragma Page;
function Enclosed_String(
B : in character;
E : in character;
T : in Scanner
) return natural is
Count : natural := 1;
I : positive;
Inx_B : natural;
Inx_E : natural;
Depth : natural := 1;
begin
if not Is_Any(T, B & "") then
return 0;
end if;
I := T.index;
Forward(T);
while Depth /= 0 loop
if not More(T) then
T.index := I;
return 0;
end if;
String_Pkg.Mark;
Inx_B := String_Pkg.Match_Any(T.text, B & "", T.index);
Inx_E := String_Pkg.Match_Any(T.text, E & "", T.index);
String_Pkg.Release;
if Inx_E = 0 then
T.index := I;
return 0;
end if;
if Inx_B /= 0 and then Inx_B < Inx_E then
Depth := Depth + 1;
else
Inx_B := Inx_E;
Depth := Depth - 1;
end if;
T.index := Inx_B + 1;
end loop;
Count := T.index - I;
T.index := I;
return Count;
end Enclosed_String;
pragma Page;
function Is_Word(
T : in Scanner
) return boolean is
begin
if not More(T) then
return false;
else
return not Is_Any(T, White_Space);
end if;
end Is_Word;
----------------------------------------------------------------
procedure Scan_Word(
T : in Scanner;
Found : out boolean;
Result : out String_Type;
Skip : in boolean := false
) is
S_Str : String_Type;
N : natural;
begin
if Skip then
Skip_Space(T);
end if;
if Is_Word(T) then
String_Pkg.Mark;
N := String_Pkg.Match_Any(T.text, White_Space, T.index);
if N = 0 then
N := String_Pkg.Length(T.text) + 1;
end if;
Result := String_Pkg.Make_Persistent
(String_Pkg.Substr(T.text, T.index, N - T.index));
T.index := N;
Found := true;
String_Pkg.Release;
else
Found := false;
end if;
return;
end Scan_Word;
pragma Page;
function Is_Number(
T : in Scanner
) return boolean is
begin
return Is_Any(T, Number_1);
end Is_Number;
----------------------------------------------------------------
procedure Scan_Number(
T : in Scanner;
Found : out boolean;
Result : out String_Type;
Skip : in boolean := false
) is
C : character;
S_Str : String_Type;
begin
if Skip then
Skip_Space(T);
end if;
if not Is_Number(T) then
Found := false;
return;
end if;
String_Pkg.Mark;
while Is_Number(T) loop
Scan_Any(T, Number_1, Found, S_Str);
if More(T) then
C := Get(T);
if C = '_' then
Forward(T);
if Is_Number(T) then
S_Str := S_Str & "_";
else
Backward(T);
end if;
end if;
end if;
end loop;
Result := String_Pkg.Make_Persistent(S_Str);
String_Pkg.Release;
end Scan_Number;
----------------------------------------------------------------
procedure Scan_Number(
T : in Scanner;
Found : out boolean;
Result : out integer;
Skip : in boolean := false
) is
F : boolean;
S_Str : String_Type;
begin
Scan_Number(T, F, S_Str, Skip);
if F then
Result := integer'value(String_Pkg.Value(S_Str));
end if;
Found := F;
end Scan_Number;
pragma Page;
function Is_Signed_Number(
T : in Scanner
) return boolean is
I : positive;
C : character;
F : boolean;
begin
if More(T) then
I := T.index;
C := Get(T);
if C = '+' or C = '-' then
T.index := T.index + 1;
end if;
F := Is_Any(T, Number_1);
T.index := I;
return F;
else
return false;
end if;
end Is_Signed_Number;
----------------------------------------------------------------
procedure Scan_Signed_Number(
T : in Scanner;
Found : out boolean;
Result : out String_Type;
Skip : in boolean := false
) is
C : character;
S_Str : String_Type;
begin
if Skip then
Skip_Space(T);
end if;
if Is_Signed_Number(T) then
C := Get(T);
if C = '+' or C = '-' then
Forward(T);
end if;
Scan_Number(T, Found, S_Str);
String_Pkg.Mark;
if C = '+' or C = '-' then
Result := String_Pkg.Make_Persistent(("" & C) & S_Str);
else
Result := String_Pkg.Make_Persistent(S_Str);
end if;
String_Pkg.Release;
String_Pkg.Flush(S_Str);
else
Found := false;
end if;
end Scan_Signed_Number;
----------------------------------------------------------------
procedure Scan_Signed_Number(
T : in Scanner;
Found : out boolean;
Result : out integer;
Skip : in boolean := false
) is
F : boolean;
S_Str : String_Type;
begin
Scan_Signed_Number(T, F, S_Str, Skip);
if F then
Result := integer'value(String_Pkg.Value(S_Str));
end if;
Found := F;
end Scan_Signed_Number;
pragma Page;
function Is_Space(
T : in Scanner
) return boolean is
begin
return Is_Any(T, White_Space);
end Is_Space;
----------------------------------------------------------------
procedure Scan_Space(
T : in Scanner;
Found : out boolean;
Result : out String_Type
) is
S_Str : String_Type;
begin
String_Pkg.Mark;
Scan_Any(T, White_Space, Found, S_Str);
Result := String_Pkg.Make_Persistent(S_Str);
String_Pkg.Release;
end Scan_Space;
----------------------------------------------------------------
procedure Skip_Space(
T : in Scanner
) is
S_Str : String_Type;
Found : boolean;
begin
String_Pkg.Mark;
Scan_Any(T, White_Space, Found, S_Str);
String_Pkg.Release;
end Skip_Space;
pragma Page;
function Is_Ada_Id(
T : in Scanner
) return boolean is
begin
return Is_Any(T, Ada_Id_1);
end Is_Ada_Id;
----------------------------------------------------------------
procedure Scan_Ada_Id(
T : in Scanner;
Found : out boolean;
Result : out String_Type;
Skip : in boolean := false
) is
C : character;
F : boolean;
S_Str : String_Type;
begin
if Skip then
Skip_Space(T);
end if;
if Is_Ada_Id(T) then
String_Pkg.Mark;
Next(T, C);
Scan_Any(T, Ada_Id, F, S_Str);
Result := String_Pkg.Make_Persistent(("" & C) & S_Str);
Found := true;
String_Pkg.Release;
else
Found := false;
end if;
end Scan_Ada_Id;
pragma Page;
function Is_Quoted(
T : in Scanner
) return boolean is
begin
if Quoted_String(T) = 0 then
return false;
else
return true;
end if;
end Is_Quoted;
----------------------------------------------------------------
procedure Scan_Quoted(
T : in Scanner;
Found : out boolean;
Result : out String_Type;
Skip : in boolean := false
) is
Count : integer;
begin
if Skip then
Skip_Space(T);
end if;
Count := Quoted_String(T);
if Count /= 0 then
Count := Count - 2;
T.index := T.index + 1;
if Count /= 0 then
String_Pkg.Mark;
Result := String_Pkg.Make_Persistent
(String_Pkg.Substr(T.text, T.index, positive(Count)));
String_Pkg.Release;
else
Result := String_Pkg.Make_Persistent("");
end if;
T.index := T.index + Count + 1;
Found := true;
else
Found := false;
end if;
end Scan_Quoted;
pragma Page;
function Is_Enclosed(
B : in character;
E : in character;
T : in Scanner
) return boolean is
begin
if Enclosed_String(B, E, T) = 0 then
return false;
else
return true;
end if;
end Is_Enclosed;
----------------------------------------------------------------
procedure Scan_Enclosed(
B : in character;
E : in character;
T : in Scanner;
Found : out boolean;
Result : out String_Type;
Skip : in boolean := false
) is
Count : natural;
begin
if Skip then
Skip_Space(T);
end if;
Count := Enclosed_String(B, E, T);
if Count /= 0 then
Count := Count - 2;
T.index := T.index + 1;
if Count /= 0 then
String_Pkg.Mark;
Result := String_Pkg.Make_Persistent(String_Pkg.Substr(T.text, T.index, positive(Count)));
String_Pkg.Release;
else
Result := String_Pkg.Make_Persistent("");
end if;
T.index := T.index + Count + 1;
Found := true;
else
Found := false;
end if;
end Scan_Enclosed;
pragma Page;
function Is_Sequence(
Chars : in String_Type;
T : in Scanner
) return boolean is
begin
return Is_Any(T, String_Pkg.Value(Chars));
end Is_Sequence;
----------------------------------------------------------------
function Is_Sequence(
Chars : in string;
T : in Scanner
) return boolean is
begin
return Is_Any(T, Chars);
end Is_Sequence;
----------------------------------------------------------------
procedure Scan_Sequence(
Chars : in String_Type;
T : in Scanner;
Found : out boolean;
Result : out String_Type;
Skip : in boolean := false
) is
I : positive;
Count : integer := 0;
begin
if Skip then
Skip_Space(T);
end if;
if not Is_Valid(T) then
Found := false;
return;
end if;
I := T.index;
while Is_Any(T, Value(Chars)) loop
Forward(T);
Count := Count + 1;
end loop;
if Count /= 0 then
String_Pkg.Mark;
Result := String_Pkg.Make_Persistent
(String_Pkg.Substr(T.text, I, positive(Count)));
Found := true;
String_Pkg.Release;
else
Found := false;
end if;
end Scan_Sequence;
----------------------------------------------------------------
procedure Scan_Sequence(
Chars : in string;
T : in Scanner;
Found : out boolean;
Result : out String_Type;
Skip : in boolean := false
) is
begin
String_Pkg.Mark;
Scan_Sequence(String_Pkg.Create(Chars), T, Found, Result, Skip);
String_Pkg.Release;
end Scan_Sequence;
pragma Page;
function Is_Not_Sequence(
Chars : in String_Type;
T : in Scanner
) return boolean is
N : natural;
begin
if not Is_Valid(T) then
return false;
end if;
String_Pkg.Mark;
N := String_Pkg.Match_Any(T.text, Chars, T.index);
if N = T.index then
N := 0;
end if;
String_Pkg.Release;
return N /= 0;
end Is_Not_Sequence;
----------------------------------------------------------------
function Is_Not_Sequence(
Chars : in string;
T : in Scanner
) return boolean is
begin
return Is_Not_Sequence(String_Pkg.Create(Chars), T);
end Is_Not_Sequence;
----------------------------------------------------------------
procedure Scan_Not_Sequence(
Chars : in string;
T : in Scanner;
Found : out boolean;
Result : out String_Type;
Skip : in boolean := false
) is
N : natural;
begin
if Skip then
Skip_Space(T);
end if;
if Is_Not_Sequence(Chars, T) then
String_Pkg.Mark;
N := String_Pkg.Match_Any(T.text, Chars, T.index);
Result := String_Pkg.Make_Persistent
(String_Pkg.Substr(T.text, T.index, N - T.index));
T.index := N;
Found := true;
String_Pkg.Release;
else
Found := false;
end if;
end Scan_Not_Sequence;
----------------------------------------------------------------
procedure Scan_Not_Sequence(
Chars : in String_Type;
T : in Scanner;
Found : out boolean;
Result : out String_Type;
Skip : in boolean := false
) is
begin
Scan_Not_Sequence(String_Pkg.Value(Chars), T, Found, Result, Skip);
end Scan_Not_Sequence;
pragma Page;
function Is_Literal(
Chars : in String_Type;
T : in Scanner
) return boolean is
N : natural;
begin
if not Is_Valid(T) then
return false;
end if;
String_Pkg.Mark;
N := String_Pkg.Match_S(T.text, Chars, T.index);
if N /= T.index then
N := 0;
end if;
String_Pkg.Release;
return N /= 0;
end Is_Literal;
----------------------------------------------------------------
function Is_Literal(
Chars : in string;
T : in Scanner
) return boolean is
Found : boolean;
begin
String_Pkg.Mark;
Found := Is_Literal(String_Pkg.Create(Chars), T);
String_Pkg.Release;
return Found;
end Is_Literal;
----------------------------------------------------------------
procedure Scan_Literal(
Chars : in String_Type;
T : in Scanner;
Found : out boolean;
Skip : in boolean := false
) is
begin
if Skip then
Skip_Space(T);
end if;
if Is_Literal(Chars, T) then
T.index := T.index + String_Pkg.Length(Chars);
Found := true;
else
Found := false;
end if;
end Scan_Literal;
----------------------------------------------------------------
procedure Scan_Literal(
Chars : in string;
T : in Scanner;
Found : out boolean;
Skip : in boolean := false
) is
begin
String_Pkg.Mark;
Scan_Literal(String_Pkg.Create(Chars), T, Found, Skip);
String_Pkg.Release;
end Scan_Literal;
pragma Page;
function Is_Not_Literal(
Chars : in string;
T : in Scanner
) return boolean is
N : natural;
begin
if not Is_Valid(T) then
return false;
end if;
String_Pkg.Mark;
N := String_Pkg.Match_S(T.text, Chars, T.index);
if N = T.index then
N := 0;
end if;
String_Pkg.Release;
return N /= 0;
end Is_Not_Literal;
----------------------------------------------------------------
function Is_Not_Literal(
Chars : in String_Type;
T : in Scanner
) return boolean is
begin
if not More(T) then
return false;
end if;
return Is_Not_Literal(String_Pkg.Value(Chars), T);
end Is_Not_Literal;
----------------------------------------------------------------
procedure Scan_Not_Literal(
Chars : in string;
T : in Scanner;
Found : out boolean;
Result : out String_Type;
Skip : in boolean := false
) is
N : natural;
begin
if Skip then
Skip_Space(T);
end if;
if Is_Not_Literal(Chars, T) then
String_Pkg.Mark;
N := String_Pkg.Match_S(T.text, Chars, T.index);
Result := String_Pkg.Make_Persistent(String_Pkg.Substr(T.text, T.index, N - T.index));
T.index := N;
Found := true;
String_Pkg.Release;
else
Found := false;
return;
end if;
end Scan_Not_Literal;
----------------------------------------------------------------
procedure Scan_Not_Literal(
Chars : in String_Type;
T : in Scanner;
Found : out boolean;
Result : out String_Type;
Skip : in boolean := false
) is
begin
Scan_Not_Literal(String_Pkg.Value(Chars), T, Found, Result, Skip);
end Scan_Not_Literal;
end String_Scanner;
pragma Page;
|
------------------------------------------------------------------------------
-- Copyright (c) 2015, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Natools.S_Expressions.Interpreter_Loop;
function Natools.S_Expressions.Conditionals.Generic_Evaluate
(Context : in Context_Type;
Expression : in out Lockable.Descriptor'Class)
return Boolean
is
type State_Type is record
Result : Boolean;
Conjunction : Boolean;
end record;
procedure Evaluate_Element
(State : in out State_Type;
Context : in Context_Type;
Name : in Atom);
-- Evaluate a name as part of an "and" or "or" operation
procedure Evaluate_Element
(State : in out State_Type;
Context : in Context_Type;
Name : in Atom;
Arguments : in out Lockable.Descriptor'Class);
-- Evaluate a name as part of an "and" or "or" operation
function Internal_Evaluate
(Context : in Context_Type;
Name : in Atom)
return Boolean;
-- Evaluate a boolean name or a context name
function Internal_Evaluate
(Context : in Context_Type;
Name : in Atom;
Arguments : in out Lockable.Descriptor'Class)
return Boolean;
-- Evaluate a boolean function or a context function
procedure Run is new Natools.S_Expressions.Interpreter_Loop
(State_Type, Context_Type, Evaluate_Element, Evaluate_Element);
------------------------------
-- Local Helper Subprograms --
------------------------------
procedure Evaluate_Element
(State : in out State_Type;
Context : in Context_Type;
Name : in Atom) is
begin
if State.Result = State.Conjunction then
State.Result := Internal_Evaluate (Context, Name);
end if;
end Evaluate_Element;
procedure Evaluate_Element
(State : in out State_Type;
Context : in Context_Type;
Name : in Atom;
Arguments : in out Lockable.Descriptor'Class) is
begin
if State.Result = State.Conjunction then
State.Result := Internal_Evaluate (Context, Name, Arguments);
end if;
end Evaluate_Element;
function Internal_Evaluate
(Context : in Context_Type;
Name : in Atom)
return Boolean
is
S_Name : constant String := To_String (Name);
begin
if S_Name = "true" then
return True;
elsif S_Name = "false" then
return False;
else
return Simple_Evaluate (Context, Name);
end if;
end Internal_Evaluate;
function Internal_Evaluate
(Context : in Context_Type;
Name : in Atom;
Arguments : in out Lockable.Descriptor'Class)
return Boolean
is
State : State_Type;
S_Name : constant String := To_String (Name);
begin
if S_Name = "and" then
State := (True, True);
Run (Arguments, State, Context);
return State.Result;
elsif S_Name = "or" then
State := (False, False);
Run (Arguments, State, Context);
return State.Result;
elsif S_Name = "not" then
return not Generic_Evaluate (Context, Arguments);
else
return Parametric_Evaluate (Context, Name, Arguments);
end if;
end Internal_Evaluate;
-------------------
-- Function Body --
-------------------
Event : Events.Event;
Lock : Lockable.Lock_State;
Result : Boolean;
begin
case Expression.Current_Event is
when Events.Add_Atom =>
Result := Internal_Evaluate (Context, Expression.Current_Atom);
when Events.Open_List =>
Expression.Lock (Lock);
begin
Expression.Next (Event);
if Event = Events.Add_Atom then
declare
Name : constant Atom := Expression.Current_Atom;
begin
Expression.Next (Event);
Result := Internal_Evaluate (Context, Name, Expression);
end;
end if;
exception
when others =>
Expression.Unlock (Lock, False);
raise;
end;
Expression.Unlock (Lock);
when Events.Close_List | Events.Error | Events.End_Of_Input =>
raise Constraint_Error with "Conditional on empty expression";
end case;
return Result;
end Natools.S_Expressions.Conditionals.Generic_Evaluate;
|
with
lace.Event,
lace.Observer;
limited
with
lace.Event.Logger;
package lace.Subject
--
-- Provides an interface for an event subject.
--
is
pragma remote_Types;
type Item is limited interface;
type View is access all Item'Class;
type Views is array (Positive range <>) of View;
type fast_View is access all Item'Class with Asynchronous;
type fast_Views is array (Positive range <>) of fast_View;
-------------
-- Containers
--
type Observer_views is array (Positive range <>) of Observer.view;
-------------
-- Attributes
--
function Name (Self : in Item) return Event.subject_Name is abstract;
------------
-- Observers
--
procedure register (Self : access Item; the_Observer : in Observer.view;
of_Kind : in Event.Kind) is abstract;
procedure deregister (Self : in out Item; the_Observer : in Observer.view;
of_Kind : in Event.Kind) is abstract;
function Observers (Self : in Item; of_Kind : in Event.Kind) return Observer_views is abstract;
function observer_Count (Self : in Item) return Natural is abstract;
-------------
-- Operations
--
procedure emit (Self : access Item; the_Event : in Event.item'Class := Event.null_Event) is abstract;
--
-- Communication errors are ignored.
function emit (Self : access Item; the_Event : in Event.item'Class := Event.null_Event)
return Observer_views is abstract;
--
-- Observers who cannot be communicated with are returned.
----------
-- Logging
--
procedure Logger_is (Now : in Event.Logger.view);
function Logger return Event.Logger.view;
end lace.Subject;
|
-- { dg-do run }
-- { dg-options "-gnatws" }
with System; use System;
procedure Trampoline2 is
A : Integer;
type FuncPtr is access function (I : Integer) return Integer;
function F (I : Integer) return Integer is
begin
return A + I;
end F;
P : FuncPtr := F'Access;
CA : System.Address := F'Code_Address;
I : Integer;
begin
if CA = System.Null_Address then
raise Program_Error;
end if;
I := P(0);
end;
|
package Constants is
Max_Entries : constant Integer := 400; -- constant
Avogadros_Number : constant := 6.022137 * 10**23; -- named number
Bytes_Per_Page : constant := 512;
Pages_Per_Buffer : constant := 10;
Buffer_Size : constant := Pages_Per_Buffer * Bytes_Per_Page;
Buffer_Size10 : constant := 5_120;
New_Character : constant Character :='$';
--~ Author : constant := "George Dantzig";
end Constants;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S P R I N T --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 1992-2001, 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, 59 Temple Place - Suite 330, Boston, --
-- MA 02111-1307, 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 Casing; use Casing;
with Debug; use Debug;
with Einfo; use Einfo;
with Lib; use Lib;
with Namet; use Namet;
with Nlists; use Nlists;
with Opt; use Opt;
with Output; use Output;
with Rtsfind; use Rtsfind;
with Sinfo; use Sinfo;
with Sinput; use Sinput;
with Sinput.L; use Sinput.L;
with Snames; use Snames;
with Stand; use Stand;
with Stringt; use Stringt;
with Uintp; use Uintp;
with Uname; use Uname;
with Urealp; use Urealp;
package body Sprint is
Debug_Node : Node_Id := Empty;
-- If we are in Debug_Generated_Code mode, then this location is set
-- to the current node requiring Sloc fixup, until Set_Debug_Sloc is
-- called to set the proper value. The call clears it back to Empty.
Debug_Sloc : Source_Ptr;
-- Sloc of first byte of line currently being written if we are
-- generating a source debug file.
Dump_Original_Only : Boolean;
-- Set True if the -gnatdo (dump original tree) flag is set
Dump_Generated_Only : Boolean;
-- Set True if the -gnatG (dump generated tree) debug flag is set
-- or for Print_Generated_Code (-gnatG) or Dump_Gnerated_Code (-gnatD).
Dump_Freeze_Null : Boolean;
-- Set True if freeze nodes and non-source null statements output
Indent : Int := 0;
-- Number of columns for current line output indentation
Indent_Annull_Flag : Boolean := False;
-- Set True if subsequent Write_Indent call to be ignored, gets reset
-- by this call, so it is only active to suppress a single indent call.
Line_Limit : constant := 72;
-- Limit value for chopping long lines
Freeze_Indent : Int := 0;
-- Keep track of freeze indent level (controls blank lines before
-- procedures within expression freeze actions)
-----------------------
-- Local Subprograms --
-----------------------
procedure Col_Check (N : Nat);
-- Check that at least N characters remain on current line, and if not,
-- then start an extra line with two characters extra indentation for
-- continuing text on the next line.
procedure Indent_Annull;
-- Causes following call to Write_Indent to be ignored. This is used when
-- a higher level node wants to stop a lower level node from starting a
-- new line, when it would otherwise be inclined to do so (e.g. the case
-- of an accept statement called from an accept alternative with a guard)
procedure Indent_Begin;
-- Increase indentation level
procedure Indent_End;
-- Decrease indentation level
procedure Print_Eol;
-- Terminate current line in line buffer
procedure Process_TFAI_RR_Flags (Nod : Node_Id);
-- Given a divide, multiplication or division node, check the flags
-- Treat_Fixed_As_Integer and Rounded_Flags, and if set, output the
-- appropriate special syntax characters (# and @).
procedure Set_Debug_Sloc;
-- If Debug_Node is non-empty, this routine sets the appropriate value
-- in its Sloc field, from the current location in the debug source file
-- that is currently being written. Note that Debug_Node is always empty
-- if a debug source file is not being written.
procedure Sprint_Bar_List (List : List_Id);
-- Print the given list with items separated by vertical bars
procedure Sprint_Node_Actual (Node : Node_Id);
-- This routine prints its node argument. It is a lower level routine than
-- Sprint_Node, in that it does not bother about rewritten trees.
procedure Sprint_Node_Sloc (Node : Node_Id);
-- Like Sprint_Node, but in addition, in Debug_Generated_Code mode,
-- sets the Sloc of the current debug node to be a copy of the Sloc
-- of the sprinted node Node. Note that this is done after printing
-- Node, so that the Sloc is the proper updated value for the debug file.
procedure Write_Char_Sloc (C : Character);
-- Like Write_Char, except that if C is non-blank, Set_Debug_Sloc is
-- called to ensure that the current node has a proper Sloc set.
procedure Write_Discr_Specs (N : Node_Id);
-- Output discriminant specification for node, which is any of the type
-- declarations that can have discriminants.
procedure Write_Ekind (E : Entity_Id);
-- Write the String corresponding to the Ekind without "E_".
procedure Write_Id (N : Node_Id);
-- N is a node with a Chars field. This procedure writes the name that
-- will be used in the generated code associated with the name. For a
-- node with no associated entity, this is simply the Chars field. For
-- the case where there is an entity associated with the node, we print
-- the name associated with the entity (since it may have been encoded).
-- One other special case is that an entity has an active external name
-- (i.e. an external name present with no address clause), then this
-- external name is output.
function Write_Identifiers (Node : Node_Id) return Boolean;
-- Handle node where the grammar has a list of defining identifiers, but
-- the tree has a separate declaration for each identifier. Handles the
-- printing of the defining identifier, and returns True if the type and
-- initialization information is to be printed, False if it is to be
-- skipped (the latter case happens when printing defining identifiers
-- other than the first in the original tree output case).
procedure Write_Implicit_Def (E : Entity_Id);
pragma Warnings (Off, Write_Implicit_Def);
-- Write the definition of the implicit type E according to its Ekind
-- For now a debugging procedure, but might be used in the future.
procedure Write_Indent;
-- Start a new line and write indentation spacing
function Write_Indent_Identifiers (Node : Node_Id) return Boolean;
-- Like Write_Identifiers except that each new printed declaration
-- is at the start of a new line.
function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean;
-- Like Write_Indent_Identifiers except that in Debug_Generated_Code
-- mode, the Sloc of the current debug node is set to point ot the
-- first output identifier.
procedure Write_Indent_Str (S : String);
-- Start a new line and write indent spacing followed by given string
procedure Write_Indent_Str_Sloc (S : String);
-- Like Write_Indent_Str, but in addition, in Debug_Generated_Code mode,
-- the Sloc of the current node is set to the first non-blank character
-- in the string S.
procedure Write_Name_With_Col_Check (N : Name_Id);
-- Write name (using Write_Name) with initial column check, and possible
-- initial Write_Indent (to get new line) if current line is too full.
procedure Write_Name_With_Col_Check_Sloc (N : Name_Id);
-- Like Write_Name_With_Col_Check but in addition, in Debug_Generated_Code
-- mode, sets Sloc of current debug node to first character of name.
procedure Write_Operator (N : Node_Id; S : String);
-- Like Write_Str_Sloc, used for operators, encloses the string in
-- characters {} if the Do_Overflow flag is set on the node N.
procedure Write_Param_Specs (N : Node_Id);
-- Output parameter specifications for node (which is either a function
-- or procedure specification with a Parameter_Specifications field)
procedure Write_Rewrite_Str (S : String);
-- Writes out a string (typically containing <<< or >>>}) for a node
-- created by rewriting the tree. Suppressed if we are outputting the
-- generated code only, since in this case we don't specially mark nodes
-- created by rewriting).
procedure Write_Str_Sloc (S : String);
-- Like Write_Str, but sets debug Sloc of current debug node to first
-- non-blank character if a current debug node is active.
procedure Write_Str_With_Col_Check (S : String);
-- Write string (using Write_Str) with initial column check, and possible
-- initial Write_Indent (to get new line) if current line is too full.
procedure Write_Str_With_Col_Check_Sloc (S : String);
-- Like Write_Str_WIth_Col_Check, but sets debug Sloc of current debug
-- node to first non-blank character if a current debug node is active.
procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format);
-- Write Uint (using UI_Write) with initial column check, and possible
-- initial Write_Indent (to get new line) if current line is too full.
-- The format parameter determines the output format (see UI_Write).
-- In addition, in Debug_Generated_Code mode, sets the current node
-- Sloc to the first character of the output value.
procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal);
-- Write Ureal (using same output format as UR_Write) with column checks
-- and a possible initial Write_Indent (to get new line) if current line
-- is too full. In addition, in Debug_Generated_Code mode, sets the
-- current node Sloc to the first character of the output value.
---------------
-- Col_Check --
---------------
procedure Col_Check (N : Nat) is
begin
if N + Column > Line_Limit then
Write_Indent_Str (" ");
end if;
end Col_Check;
-------------------
-- Indent_Annull --
-------------------
procedure Indent_Annull is
begin
Indent_Annull_Flag := True;
end Indent_Annull;
------------------
-- Indent_Begin --
------------------
procedure Indent_Begin is
begin
Indent := Indent + 3;
end Indent_Begin;
----------------
-- Indent_End --
----------------
procedure Indent_End is
begin
Indent := Indent - 3;
end Indent_End;
--------
-- PG --
--------
procedure PG (Node : Node_Id) is
begin
Dump_Generated_Only := True;
Dump_Original_Only := False;
Sprint_Node (Node);
Print_Eol;
end PG;
--------
-- PO --
--------
procedure PO (Node : Node_Id) is
begin
Dump_Generated_Only := False;
Dump_Original_Only := True;
Sprint_Node (Node);
Print_Eol;
end PO;
---------------
-- Print_Eol --
---------------
procedure Print_Eol is
begin
-- If we are writing a debug source file, then grab it from the
-- Output buffer, and reset the column counter (the routines in
-- Output never actually write any output for us in this mode,
-- they just build line images in Buffer).
if Debug_Generated_Code then
Write_Debug_Line (Buffer (1 .. Natural (Column) - 1), Debug_Sloc);
Column := 1;
-- In normal mode, we call Write_Eol to write the line normally
else
Write_Eol;
end if;
end Print_Eol;
---------------------------
-- Process_TFAI_RR_Flags --
---------------------------
procedure Process_TFAI_RR_Flags (Nod : Node_Id) is
begin
if Treat_Fixed_As_Integer (Nod) then
Write_Char ('#');
end if;
if Rounded_Result (Nod) then
Write_Char ('@');
end if;
end Process_TFAI_RR_Flags;
--------
-- PS --
--------
procedure PS (Node : Node_Id) is
begin
Dump_Generated_Only := False;
Dump_Original_Only := False;
Sprint_Node (Node);
Print_Eol;
end PS;
--------------------
-- Set_Debug_Sloc --
--------------------
procedure Set_Debug_Sloc is
begin
if Present (Debug_Node) then
Set_Sloc (Debug_Node, Debug_Sloc + Source_Ptr (Column - 1));
Debug_Node := Empty;
end if;
end Set_Debug_Sloc;
-----------------
-- Source_Dump --
-----------------
procedure Source_Dump is
procedure Underline;
-- Put underline under string we just printed
procedure Underline is
Col : constant Int := Column;
begin
Print_Eol;
while Col > Column loop
Write_Char ('-');
end loop;
Print_Eol;
end Underline;
-- Start of processing for Tree_Dump.
begin
Dump_Generated_Only := Debug_Flag_G or
Print_Generated_Code or
Debug_Generated_Code;
Dump_Original_Only := Debug_Flag_O;
Dump_Freeze_Null := Debug_Flag_S or Debug_Flag_G;
-- Note that we turn off the tree dump flags immediately, before
-- starting the dump. This avoids generating two copies of the dump
-- if an abort occurs after printing the dump, and more importantly,
-- avoids an infinite loop if an abort occurs during the dump.
if Debug_Flag_Z then
Debug_Flag_Z := False;
Print_Eol;
Print_Eol;
Write_Str ("Source recreated from tree of Standard (spec)");
Underline;
Sprint_Node (Standard_Package_Node);
Print_Eol;
Print_Eol;
end if;
if Debug_Flag_S or Dump_Generated_Only or Dump_Original_Only then
Debug_Flag_G := False;
Debug_Flag_O := False;
Debug_Flag_S := False;
-- Dump requested units
for U in Main_Unit .. Last_Unit loop
-- Dump all units if -gnatdf set, otherwise we dump only
-- the source files that are in the extended main source.
if Debug_Flag_F
or else In_Extended_Main_Source_Unit (Cunit_Entity (U))
then
-- If we are generating debug files, setup to write them
if Debug_Generated_Code then
Create_Debug_Source (Source_Index (U), Debug_Sloc);
Sprint_Node (Cunit (U));
Print_Eol;
Close_Debug_Source;
-- Normal output to standard output file
else
Write_Str ("Source recreated from tree for ");
Write_Unit_Name (Unit_Name (U));
Underline;
Sprint_Node (Cunit (U));
Write_Eol;
Write_Eol;
end if;
end if;
end loop;
end if;
end Source_Dump;
---------------------
-- Sprint_Bar_List --
---------------------
procedure Sprint_Bar_List (List : List_Id) is
Node : Node_Id;
begin
if Is_Non_Empty_List (List) then
Node := First (List);
loop
Sprint_Node (Node);
Next (Node);
exit when Node = Empty;
Write_Str (" | ");
end loop;
end if;
end Sprint_Bar_List;
-----------------------
-- Sprint_Comma_List --
-----------------------
procedure Sprint_Comma_List (List : List_Id) is
Node : Node_Id;
begin
if Is_Non_Empty_List (List) then
Node := First (List);
loop
Sprint_Node (Node);
Next (Node);
exit when Node = Empty;
if not Is_Rewrite_Insertion (Node)
or else not Dump_Original_Only
then
Write_Str (", ");
end if;
end loop;
end if;
end Sprint_Comma_List;
--------------------------
-- Sprint_Indented_List --
--------------------------
procedure Sprint_Indented_List (List : List_Id) is
begin
Indent_Begin;
Sprint_Node_List (List);
Indent_End;
end Sprint_Indented_List;
-----------------
-- Sprint_Node --
-----------------
procedure Sprint_Node (Node : Node_Id) is
begin
if Is_Rewrite_Insertion (Node) then
if not Dump_Original_Only then
-- For special cases of nodes that always output <<< >>>
-- do not duplicate the output at this point.
if Nkind (Node) = N_Freeze_Entity
or else Nkind (Node) = N_Implicit_Label_Declaration
then
Sprint_Node_Actual (Node);
-- Normal case where <<< >>> may be required
else
Write_Rewrite_Str ("<<<");
Sprint_Node_Actual (Node);
Write_Rewrite_Str (">>>");
end if;
end if;
elsif Is_Rewrite_Substitution (Node) then
-- Case of dump generated only
if Dump_Generated_Only then
Sprint_Node_Actual (Node);
-- Case of dump original only
elsif Dump_Original_Only then
Sprint_Node_Actual (Original_Node (Node));
-- Case of both being dumped
else
Sprint_Node_Actual (Original_Node (Node));
Write_Rewrite_Str ("<<<");
Sprint_Node_Actual (Node);
Write_Rewrite_Str (">>>");
end if;
else
Sprint_Node_Actual (Node);
end if;
end Sprint_Node;
------------------------
-- Sprint_Node_Actual --
------------------------
procedure Sprint_Node_Actual (Node : Node_Id) is
Save_Debug_Node : constant Node_Id := Debug_Node;
begin
if Node = Empty then
return;
end if;
for J in 1 .. Paren_Count (Node) loop
Write_Str_With_Col_Check ("(");
end loop;
-- Setup node for Sloc fixup if writing a debug source file. Note
-- that we take care of any previous node not yet properly set.
if Debug_Generated_Code then
Debug_Node := Node;
end if;
if Nkind (Node) in N_Subexpr
and then Do_Range_Check (Node)
then
Write_Str_With_Col_Check ("{");
end if;
-- Select print circuit based on node kind
case Nkind (Node) is
when N_Abort_Statement =>
Write_Indent_Str_Sloc ("abort ");
Sprint_Comma_List (Names (Node));
Write_Char (';');
when N_Abortable_Part =>
Set_Debug_Sloc;
Write_Str_Sloc ("abort ");
Sprint_Indented_List (Statements (Node));
when N_Abstract_Subprogram_Declaration =>
Write_Indent;
Sprint_Node (Specification (Node));
Write_Str_With_Col_Check (" is ");
Write_Str_Sloc ("abstract;");
when N_Accept_Alternative =>
Sprint_Node_List (Pragmas_Before (Node));
if Present (Condition (Node)) then
Write_Indent_Str ("when ");
Sprint_Node (Condition (Node));
Write_Str (" => ");
Indent_Annull;
end if;
Sprint_Node_Sloc (Accept_Statement (Node));
Sprint_Node_List (Statements (Node));
when N_Accept_Statement =>
Write_Indent_Str_Sloc ("accept ");
Write_Id (Entry_Direct_Name (Node));
if Present (Entry_Index (Node)) then
Write_Str_With_Col_Check (" (");
Sprint_Node (Entry_Index (Node));
Write_Char (')');
end if;
Write_Param_Specs (Node);
if Present (Handled_Statement_Sequence (Node)) then
Write_Str_With_Col_Check (" do");
Sprint_Node (Handled_Statement_Sequence (Node));
Write_Indent_Str ("end ");
Write_Id (Entry_Direct_Name (Node));
end if;
Write_Char (';');
when N_Access_Definition =>
Write_Str_With_Col_Check_Sloc ("access ");
Sprint_Node (Subtype_Mark (Node));
when N_Access_Function_Definition =>
Write_Str_With_Col_Check_Sloc ("access ");
if Protected_Present (Node) then
Write_Str_With_Col_Check ("protected ");
end if;
Write_Str_With_Col_Check ("function");
Write_Param_Specs (Node);
Write_Str_With_Col_Check (" return ");
Sprint_Node (Subtype_Mark (Node));
when N_Access_Procedure_Definition =>
Write_Str_With_Col_Check_Sloc ("access ");
if Protected_Present (Node) then
Write_Str_With_Col_Check ("protected ");
end if;
Write_Str_With_Col_Check ("procedure");
Write_Param_Specs (Node);
when N_Access_To_Object_Definition =>
Write_Str_With_Col_Check_Sloc ("access ");
if All_Present (Node) then
Write_Str_With_Col_Check ("all ");
elsif Constant_Present (Node) then
Write_Str_With_Col_Check ("constant ");
end if;
Sprint_Node (Subtype_Indication (Node));
when N_Aggregate =>
if Null_Record_Present (Node) then
Write_Str_With_Col_Check_Sloc ("(null record)");
else
Write_Str_With_Col_Check_Sloc ("(");
if Present (Expressions (Node)) then
Sprint_Comma_List (Expressions (Node));
if Present (Component_Associations (Node)) then
Write_Str (", ");
end if;
end if;
if Present (Component_Associations (Node)) then
Indent_Begin;
declare
Nd : Node_Id;
begin
Nd := First (Component_Associations (Node));
loop
Write_Indent;
Sprint_Node (Nd);
Next (Nd);
exit when No (Nd);
if not Is_Rewrite_Insertion (Nd)
or else not Dump_Original_Only
then
Write_Str (", ");
end if;
end loop;
end;
Indent_End;
end if;
Write_Char (')');
end if;
when N_Allocator =>
Write_Str_With_Col_Check_Sloc ("new ");
Sprint_Node (Expression (Node));
if Present (Storage_Pool (Node)) then
Write_Str_With_Col_Check ("[storage_pool = ");
Sprint_Node (Storage_Pool (Node));
Write_Char (']');
end if;
when N_And_Then =>
Sprint_Node (Left_Opnd (Node));
Write_Str_Sloc (" and then ");
Sprint_Node (Right_Opnd (Node));
when N_At_Clause =>
Write_Indent_Str_Sloc ("for ");
Write_Id (Identifier (Node));
Write_Str_With_Col_Check (" use at ");
Sprint_Node (Expression (Node));
Write_Char (';');
when N_Assignment_Statement =>
Write_Indent;
Sprint_Node (Name (Node));
Write_Str_Sloc (" := ");
Sprint_Node (Expression (Node));
Write_Char (';');
when N_Asynchronous_Select =>
Write_Indent_Str_Sloc ("select");
Indent_Begin;
Sprint_Node (Triggering_Alternative (Node));
Indent_End;
-- Note: let the printing of Abortable_Part handle outputting
-- the ABORT keyword, so that the Slco can be set correctly.
Write_Indent_Str ("then ");
Sprint_Node (Abortable_Part (Node));
Write_Indent_Str ("end select;");
when N_Attribute_Definition_Clause =>
Write_Indent_Str_Sloc ("for ");
Sprint_Node (Name (Node));
Write_Char (''');
Write_Name_With_Col_Check (Chars (Node));
Write_Str_With_Col_Check (" use ");
Sprint_Node (Expression (Node));
Write_Char (';');
when N_Attribute_Reference =>
if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
Write_Indent;
end if;
Sprint_Node (Prefix (Node));
Write_Char_Sloc (''');
Write_Name_With_Col_Check (Attribute_Name (Node));
Sprint_Paren_Comma_List (Expressions (Node));
if Is_Procedure_Attribute_Name (Attribute_Name (Node)) then
Write_Char (';');
end if;
when N_Block_Statement =>
Write_Indent;
if Present (Identifier (Node))
and then (not Has_Created_Identifier (Node)
or else not Dump_Original_Only)
then
Write_Rewrite_Str ("<<<");
Write_Id (Identifier (Node));
Write_Str (" : ");
Write_Rewrite_Str (">>>");
end if;
if Present (Declarations (Node)) then
Write_Str_With_Col_Check_Sloc ("declare");
Sprint_Indented_List (Declarations (Node));
Write_Indent;
end if;
Write_Str_With_Col_Check_Sloc ("begin");
Sprint_Node (Handled_Statement_Sequence (Node));
Write_Indent_Str ("end");
if Present (Identifier (Node))
and then (not Has_Created_Identifier (Node)
or else not Dump_Original_Only)
then
Write_Rewrite_Str ("<<<");
Write_Char (' ');
Write_Id (Identifier (Node));
Write_Rewrite_Str (">>>");
end if;
Write_Char (';');
when N_Case_Statement =>
Write_Indent_Str_Sloc ("case ");
Sprint_Node (Expression (Node));
Write_Str (" is");
Sprint_Indented_List (Alternatives (Node));
Write_Indent_Str ("end case;");
when N_Case_Statement_Alternative =>
Write_Indent_Str_Sloc ("when ");
Sprint_Bar_List (Discrete_Choices (Node));
Write_Str (" => ");
Sprint_Indented_List (Statements (Node));
when N_Character_Literal =>
if Column > 70 then
Write_Indent_Str (" ");
end if;
Write_Char_Sloc (''');
Write_Char_Code (Char_Literal_Value (Node));
Write_Char (''');
when N_Code_Statement =>
Write_Indent;
Set_Debug_Sloc;
Sprint_Node (Expression (Node));
Write_Char (';');
when N_Compilation_Unit =>
Sprint_Node_List (Context_Items (Node));
Sprint_Opt_Node_List (Declarations (Aux_Decls_Node (Node)));
if Private_Present (Node) then
Write_Indent_Str ("private ");
Indent_Annull;
end if;
Sprint_Node_Sloc (Unit (Node));
if Present (Actions (Aux_Decls_Node (Node)))
or else
Present (Pragmas_After (Aux_Decls_Node (Node)))
then
Write_Indent;
end if;
Sprint_Opt_Node_List (Actions (Aux_Decls_Node (Node)));
Sprint_Opt_Node_List (Pragmas_After (Aux_Decls_Node (Node)));
when N_Compilation_Unit_Aux =>
null; -- nothing to do, never used, see above
when N_Component_Association =>
Set_Debug_Sloc;
Sprint_Bar_List (Choices (Node));
Write_Str (" => ");
Sprint_Node (Expression (Node));
when N_Component_Clause =>
Write_Indent;
Sprint_Node (Component_Name (Node));
Write_Str_Sloc (" at ");
Sprint_Node (Position (Node));
Write_Char (' ');
Write_Str_With_Col_Check ("range ");
Sprint_Node (First_Bit (Node));
Write_Str (" .. ");
Sprint_Node (Last_Bit (Node));
Write_Char (';');
when N_Component_Declaration =>
if Write_Indent_Identifiers_Sloc (Node) then
Write_Str (" : ");
if Aliased_Present (Node) then
Write_Str_With_Col_Check ("aliased ");
end if;
Sprint_Node (Subtype_Indication (Node));
if Present (Expression (Node)) then
Write_Str (" := ");
Sprint_Node (Expression (Node));
end if;
Write_Char (';');
end if;
when N_Component_List =>
if Null_Present (Node) then
Indent_Begin;
Write_Indent_Str_Sloc ("null");
Write_Char (';');
Indent_End;
else
Set_Debug_Sloc;
Sprint_Indented_List (Component_Items (Node));
Sprint_Node (Variant_Part (Node));
end if;
when N_Conditional_Entry_Call =>
Write_Indent_Str_Sloc ("select");
Indent_Begin;
Sprint_Node (Entry_Call_Alternative (Node));
Indent_End;
Write_Indent_Str ("else");
Sprint_Indented_List (Else_Statements (Node));
Write_Indent_Str ("end select;");
when N_Conditional_Expression =>
declare
Condition : constant Node_Id := First (Expressions (Node));
Then_Expr : constant Node_Id := Next (Condition);
Else_Expr : constant Node_Id := Next (Then_Expr);
begin
Write_Str_With_Col_Check_Sloc ("(if ");
Sprint_Node (Condition);
Write_Str_With_Col_Check (" then ");
Sprint_Node (Then_Expr);
Write_Str_With_Col_Check (" else ");
Sprint_Node (Else_Expr);
Write_Char (')');
end;
when N_Constrained_Array_Definition =>
Write_Str_With_Col_Check_Sloc ("array ");
Sprint_Paren_Comma_List (Discrete_Subtype_Definitions (Node));
Write_Str (" of ");
if Aliased_Present (Node) then
Write_Str_With_Col_Check ("aliased ");
end if;
Sprint_Node (Subtype_Indication (Node));
when N_Decimal_Fixed_Point_Definition =>
Write_Str_With_Col_Check_Sloc (" delta ");
Sprint_Node (Delta_Expression (Node));
Write_Str_With_Col_Check ("digits ");
Sprint_Node (Digits_Expression (Node));
Sprint_Opt_Node (Real_Range_Specification (Node));
when N_Defining_Character_Literal =>
Write_Name_With_Col_Check_Sloc (Chars (Node));
when N_Defining_Identifier =>
Set_Debug_Sloc;
Write_Id (Node);
when N_Defining_Operator_Symbol =>
Write_Name_With_Col_Check_Sloc (Chars (Node));
when N_Defining_Program_Unit_Name =>
Set_Debug_Sloc;
Sprint_Node (Name (Node));
Write_Char ('.');
Write_Id (Defining_Identifier (Node));
when N_Delay_Alternative =>
Sprint_Node_List (Pragmas_Before (Node));
if Present (Condition (Node)) then
Write_Indent;
Write_Str_With_Col_Check ("when ");
Sprint_Node (Condition (Node));
Write_Str (" => ");
Indent_Annull;
end if;
Sprint_Node_Sloc (Delay_Statement (Node));
Sprint_Node_List (Statements (Node));
when N_Delay_Relative_Statement =>
Write_Indent_Str_Sloc ("delay ");
Sprint_Node (Expression (Node));
Write_Char (';');
when N_Delay_Until_Statement =>
Write_Indent_Str_Sloc ("delay until ");
Sprint_Node (Expression (Node));
Write_Char (';');
when N_Delta_Constraint =>
Write_Str_With_Col_Check_Sloc ("delta ");
Sprint_Node (Delta_Expression (Node));
Sprint_Opt_Node (Range_Constraint (Node));
when N_Derived_Type_Definition =>
if Abstract_Present (Node) then
Write_Str_With_Col_Check ("abstract ");
end if;
Write_Str_With_Col_Check_Sloc ("new ");
Sprint_Node (Subtype_Indication (Node));
if Present (Record_Extension_Part (Node)) then
Write_Str_With_Col_Check (" with ");
Sprint_Node (Record_Extension_Part (Node));
end if;
when N_Designator =>
Sprint_Node (Name (Node));
Write_Char_Sloc ('.');
Write_Id (Identifier (Node));
when N_Digits_Constraint =>
Write_Str_With_Col_Check_Sloc ("digits ");
Sprint_Node (Digits_Expression (Node));
Sprint_Opt_Node (Range_Constraint (Node));
when N_Discriminant_Association =>
Set_Debug_Sloc;
if Present (Selector_Names (Node)) then
Sprint_Bar_List (Selector_Names (Node));
Write_Str (" => ");
end if;
Set_Debug_Sloc;
Sprint_Node (Expression (Node));
when N_Discriminant_Specification =>
Set_Debug_Sloc;
if Write_Identifiers (Node) then
Write_Str (" : ");
Sprint_Node (Discriminant_Type (Node));
if Present (Expression (Node)) then
Write_Str (" := ");
Sprint_Node (Expression (Node));
end if;
else
Write_Str (", ");
end if;
when N_Elsif_Part =>
Write_Indent_Str_Sloc ("elsif ");
Sprint_Node (Condition (Node));
Write_Str_With_Col_Check (" then");
Sprint_Indented_List (Then_Statements (Node));
when N_Empty =>
null;
when N_Entry_Body =>
Write_Indent_Str_Sloc ("entry ");
Write_Id (Defining_Identifier (Node));
Sprint_Node (Entry_Body_Formal_Part (Node));
Write_Str_With_Col_Check (" is");
Sprint_Indented_List (Declarations (Node));
Write_Indent_Str ("begin");
Sprint_Node (Handled_Statement_Sequence (Node));
Write_Indent_Str ("end ");
Write_Id (Defining_Identifier (Node));
Write_Char (';');
when N_Entry_Body_Formal_Part =>
if Present (Entry_Index_Specification (Node)) then
Write_Str_With_Col_Check_Sloc (" (");
Sprint_Node (Entry_Index_Specification (Node));
Write_Char (')');
end if;
Write_Param_Specs (Node);
Write_Str_With_Col_Check_Sloc (" when ");
Sprint_Node (Condition (Node));
when N_Entry_Call_Alternative =>
Sprint_Node_List (Pragmas_Before (Node));
Sprint_Node_Sloc (Entry_Call_Statement (Node));
Sprint_Node_List (Statements (Node));
when N_Entry_Call_Statement =>
Write_Indent;
Sprint_Node_Sloc (Name (Node));
Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
Write_Char (';');
when N_Entry_Declaration =>
Write_Indent_Str_Sloc ("entry ");
Write_Id (Defining_Identifier (Node));
if Present (Discrete_Subtype_Definition (Node)) then
Write_Str_With_Col_Check (" (");
Sprint_Node (Discrete_Subtype_Definition (Node));
Write_Char (')');
end if;
Write_Param_Specs (Node);
Write_Char (';');
when N_Entry_Index_Specification =>
Write_Str_With_Col_Check_Sloc ("for ");
Write_Id (Defining_Identifier (Node));
Write_Str_With_Col_Check (" in ");
Sprint_Node (Discrete_Subtype_Definition (Node));
when N_Enumeration_Representation_Clause =>
Write_Indent_Str_Sloc ("for ");
Write_Id (Identifier (Node));
Write_Str_With_Col_Check (" use ");
Sprint_Node (Array_Aggregate (Node));
Write_Char (';');
when N_Enumeration_Type_Definition =>
Set_Debug_Sloc;
-- Skip attempt to print Literals field if it's not there and
-- we are in package Standard (case of Character, which is
-- handled specially (without an explicit literals list).
if Sloc (Node) > Standard_Location
or else Present (Literals (Node))
then
Sprint_Paren_Comma_List (Literals (Node));
end if;
when N_Error =>
Write_Str_With_Col_Check_Sloc ("<error>");
when N_Exception_Declaration =>
if Write_Indent_Identifiers (Node) then
Write_Str_With_Col_Check (" : ");
Write_Str_Sloc ("exception;");
end if;
when N_Exception_Handler =>
Write_Indent_Str_Sloc ("when ");
if Present (Choice_Parameter (Node)) then
Sprint_Node (Choice_Parameter (Node));
Write_Str (" : ");
end if;
Sprint_Bar_List (Exception_Choices (Node));
Write_Str (" => ");
Sprint_Indented_List (Statements (Node));
when N_Exception_Renaming_Declaration =>
Write_Indent;
Set_Debug_Sloc;
Sprint_Node (Defining_Identifier (Node));
Write_Str_With_Col_Check (" : exception renames ");
Sprint_Node (Name (Node));
Write_Char (';');
when N_Exit_Statement =>
Write_Indent_Str_Sloc ("exit");
Sprint_Opt_Node (Name (Node));
if Present (Condition (Node)) then
Write_Str_With_Col_Check (" when ");
Sprint_Node (Condition (Node));
end if;
Write_Char (';');
when N_Explicit_Dereference =>
Sprint_Node (Prefix (Node));
Write_Char ('.');
Write_Str_Sloc ("all");
when N_Extension_Aggregate =>
Write_Str_With_Col_Check_Sloc ("(");
Sprint_Node (Ancestor_Part (Node));
Write_Str_With_Col_Check (" with ");
if Null_Record_Present (Node) then
Write_Str_With_Col_Check ("null record");
else
if Present (Expressions (Node)) then
Sprint_Comma_List (Expressions (Node));
if Present (Component_Associations (Node)) then
Write_Str (", ");
end if;
end if;
if Present (Component_Associations (Node)) then
Sprint_Comma_List (Component_Associations (Node));
end if;
end if;
Write_Char (')');
when N_Floating_Point_Definition =>
Write_Str_With_Col_Check_Sloc ("digits ");
Sprint_Node (Digits_Expression (Node));
Sprint_Opt_Node (Real_Range_Specification (Node));
when N_Formal_Decimal_Fixed_Point_Definition =>
Write_Str_With_Col_Check_Sloc ("delta <> digits <>");
when N_Formal_Derived_Type_Definition =>
Write_Str_With_Col_Check_Sloc ("new ");
Sprint_Node (Subtype_Mark (Node));
if Private_Present (Node) then
Write_Str_With_Col_Check (" with private");
end if;
when N_Formal_Discrete_Type_Definition =>
Write_Str_With_Col_Check_Sloc ("<>");
when N_Formal_Floating_Point_Definition =>
Write_Str_With_Col_Check_Sloc ("digits <>");
when N_Formal_Modular_Type_Definition =>
Write_Str_With_Col_Check_Sloc ("mod <>");
when N_Formal_Object_Declaration =>
Set_Debug_Sloc;
if Write_Indent_Identifiers (Node) then
Write_Str (" : ");
if In_Present (Node) then
Write_Str_With_Col_Check ("in ");
end if;
if Out_Present (Node) then
Write_Str_With_Col_Check ("out ");
end if;
Sprint_Node (Subtype_Mark (Node));
if Present (Expression (Node)) then
Write_Str (" := ");
Sprint_Node (Expression (Node));
end if;
Write_Char (';');
end if;
when N_Formal_Ordinary_Fixed_Point_Definition =>
Write_Str_With_Col_Check_Sloc ("delta <>");
when N_Formal_Package_Declaration =>
Write_Indent_Str_Sloc ("with package ");
Write_Id (Defining_Identifier (Node));
Write_Str_With_Col_Check (" is new ");
Sprint_Node (Name (Node));
Write_Str_With_Col_Check (" (<>);");
when N_Formal_Private_Type_Definition =>
if Abstract_Present (Node) then
Write_Str_With_Col_Check ("abstract ");
end if;
if Tagged_Present (Node) then
Write_Str_With_Col_Check ("tagged ");
end if;
if Limited_Present (Node) then
Write_Str_With_Col_Check ("limited ");
end if;
Write_Str_With_Col_Check_Sloc ("private");
when N_Formal_Signed_Integer_Type_Definition =>
Write_Str_With_Col_Check_Sloc ("range <>");
when N_Formal_Subprogram_Declaration =>
Write_Indent_Str_Sloc ("with ");
Sprint_Node (Specification (Node));
if Box_Present (Node) then
Write_Str_With_Col_Check (" is <>");
elsif Present (Default_Name (Node)) then
Write_Str_With_Col_Check (" is ");
Sprint_Node (Default_Name (Node));
end if;
Write_Char (';');
when N_Formal_Type_Declaration =>
Write_Indent_Str_Sloc ("type ");
Write_Id (Defining_Identifier (Node));
if Present (Discriminant_Specifications (Node)) then
Write_Discr_Specs (Node);
elsif Unknown_Discriminants_Present (Node) then
Write_Str_With_Col_Check ("(<>)");
end if;
Write_Str_With_Col_Check (" is ");
Sprint_Node (Formal_Type_Definition (Node));
Write_Char (';');
when N_Free_Statement =>
Write_Indent_Str_Sloc ("free ");
Sprint_Node (Expression (Node));
Write_Char (';');
when N_Freeze_Entity =>
if Dump_Original_Only then
null;
elsif Present (Actions (Node)) or else Dump_Freeze_Null then
Write_Indent;
Write_Rewrite_Str ("<<<");
Write_Str_With_Col_Check_Sloc ("freeze ");
Write_Id (Entity (Node));
Write_Str (" [");
if No (Actions (Node)) then
Write_Char (']');
else
Freeze_Indent := Freeze_Indent + 1;
Sprint_Indented_List (Actions (Node));
Freeze_Indent := Freeze_Indent - 1;
Write_Indent_Str ("]");
end if;
Write_Rewrite_Str (">>>");
end if;
when N_Full_Type_Declaration =>
Write_Indent_Str_Sloc ("type ");
Write_Id (Defining_Identifier (Node));
Write_Discr_Specs (Node);
Write_Str_With_Col_Check (" is ");
Sprint_Node (Type_Definition (Node));
Write_Char (';');
when N_Function_Call =>
Set_Debug_Sloc;
Sprint_Node (Name (Node));
Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
when N_Function_Instantiation =>
Write_Indent_Str_Sloc ("function ");
Sprint_Node (Defining_Unit_Name (Node));
Write_Str_With_Col_Check (" is new ");
Sprint_Node (Name (Node));
Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
Write_Char (';');
when N_Function_Specification =>
Write_Str_With_Col_Check_Sloc ("function ");
Sprint_Node (Defining_Unit_Name (Node));
Write_Param_Specs (Node);
Write_Str_With_Col_Check (" return ");
Sprint_Node (Subtype_Mark (Node));
when N_Generic_Association =>
Set_Debug_Sloc;
if Present (Selector_Name (Node)) then
Sprint_Node (Selector_Name (Node));
Write_Str (" => ");
end if;
Sprint_Node (Explicit_Generic_Actual_Parameter (Node));
when N_Generic_Function_Renaming_Declaration =>
Write_Indent_Str_Sloc ("generic function ");
Sprint_Node (Defining_Unit_Name (Node));
Write_Str_With_Col_Check (" renames ");
Sprint_Node (Name (Node));
Write_Char (';');
when N_Generic_Package_Declaration =>
Write_Indent;
Write_Indent_Str_Sloc ("generic ");
Sprint_Indented_List (Generic_Formal_Declarations (Node));
Write_Indent;
Sprint_Node (Specification (Node));
Write_Char (';');
when N_Generic_Package_Renaming_Declaration =>
Write_Indent_Str_Sloc ("generic package ");
Sprint_Node (Defining_Unit_Name (Node));
Write_Str_With_Col_Check (" renames ");
Sprint_Node (Name (Node));
Write_Char (';');
when N_Generic_Procedure_Renaming_Declaration =>
Write_Indent_Str_Sloc ("generic procedure ");
Sprint_Node (Defining_Unit_Name (Node));
Write_Str_With_Col_Check (" renames ");
Sprint_Node (Name (Node));
Write_Char (';');
when N_Generic_Subprogram_Declaration =>
Write_Indent;
Write_Indent_Str_Sloc ("generic ");
Sprint_Indented_List (Generic_Formal_Declarations (Node));
Write_Indent;
Sprint_Node (Specification (Node));
Write_Char (';');
when N_Goto_Statement =>
Write_Indent_Str_Sloc ("goto ");
Sprint_Node (Name (Node));
Write_Char (';');
if Nkind (Next (Node)) = N_Label then
Write_Indent;
end if;
when N_Handled_Sequence_Of_Statements =>
Set_Debug_Sloc;
Sprint_Indented_List (Statements (Node));
if Present (Exception_Handlers (Node)) then
Write_Indent_Str ("exception");
Indent_Begin;
Sprint_Node_List (Exception_Handlers (Node));
Indent_End;
end if;
if Present (At_End_Proc (Node)) then
Write_Indent_Str ("at end");
Indent_Begin;
Write_Indent;
Sprint_Node (At_End_Proc (Node));
Write_Char (';');
Indent_End;
end if;
when N_Identifier =>
Set_Debug_Sloc;
Write_Id (Node);
when N_If_Statement =>
Write_Indent_Str_Sloc ("if ");
Sprint_Node (Condition (Node));
Write_Str_With_Col_Check (" then");
Sprint_Indented_List (Then_Statements (Node));
Sprint_Opt_Node_List (Elsif_Parts (Node));
if Present (Else_Statements (Node)) then
Write_Indent_Str ("else");
Sprint_Indented_List (Else_Statements (Node));
end if;
Write_Indent_Str ("end if;");
when N_Implicit_Label_Declaration =>
if not Dump_Original_Only then
Write_Indent;
Write_Rewrite_Str ("<<<");
Set_Debug_Sloc;
Write_Id (Defining_Identifier (Node));
Write_Str (" : ");
Write_Str_With_Col_Check ("label");
Write_Rewrite_Str (">>>");
end if;
when N_In =>
Sprint_Node (Left_Opnd (Node));
Write_Str_Sloc (" in ");
Sprint_Node (Right_Opnd (Node));
when N_Incomplete_Type_Declaration =>
Write_Indent_Str_Sloc ("type ");
Write_Id (Defining_Identifier (Node));
if Present (Discriminant_Specifications (Node)) then
Write_Discr_Specs (Node);
elsif Unknown_Discriminants_Present (Node) then
Write_Str_With_Col_Check ("(<>)");
end if;
Write_Char (';');
when N_Index_Or_Discriminant_Constraint =>
Set_Debug_Sloc;
Sprint_Paren_Comma_List (Constraints (Node));
when N_Indexed_Component =>
Sprint_Node_Sloc (Prefix (Node));
Sprint_Opt_Paren_Comma_List (Expressions (Node));
when N_Integer_Literal =>
if Print_In_Hex (Node) then
Write_Uint_With_Col_Check_Sloc (Intval (Node), Hex);
else
Write_Uint_With_Col_Check_Sloc (Intval (Node), Auto);
end if;
when N_Iteration_Scheme =>
if Present (Condition (Node)) then
Write_Str_With_Col_Check_Sloc ("while ");
Sprint_Node (Condition (Node));
else
Write_Str_With_Col_Check_Sloc ("for ");
Sprint_Node (Loop_Parameter_Specification (Node));
end if;
Write_Char (' ');
when N_Itype_Reference =>
Write_Indent_Str_Sloc ("reference ");
Write_Id (Itype (Node));
when N_Label =>
Write_Indent_Str_Sloc ("<<");
Write_Id (Identifier (Node));
Write_Str (">>");
when N_Loop_Parameter_Specification =>
Set_Debug_Sloc;
Write_Id (Defining_Identifier (Node));
Write_Str_With_Col_Check (" in ");
if Reverse_Present (Node) then
Write_Str_With_Col_Check ("reverse ");
end if;
Sprint_Node (Discrete_Subtype_Definition (Node));
when N_Loop_Statement =>
Write_Indent;
if Present (Identifier (Node))
and then (not Has_Created_Identifier (Node)
or else not Dump_Original_Only)
then
Write_Rewrite_Str ("<<<");
Write_Id (Identifier (Node));
Write_Str (" : ");
Write_Rewrite_Str (">>>");
Sprint_Node (Iteration_Scheme (Node));
Write_Str_With_Col_Check_Sloc ("loop");
Sprint_Indented_List (Statements (Node));
Write_Indent_Str ("end loop ");
Write_Rewrite_Str ("<<<");
Write_Id (Identifier (Node));
Write_Rewrite_Str (">>>");
Write_Char (';');
else
Sprint_Node (Iteration_Scheme (Node));
Write_Str_With_Col_Check_Sloc ("loop");
Sprint_Indented_List (Statements (Node));
Write_Indent_Str ("end loop;");
end if;
when N_Mod_Clause =>
Sprint_Node_List (Pragmas_Before (Node));
Write_Str_With_Col_Check_Sloc ("at mod ");
Sprint_Node (Expression (Node));
when N_Modular_Type_Definition =>
Write_Str_With_Col_Check_Sloc ("mod ");
Sprint_Node (Expression (Node));
when N_Not_In =>
Sprint_Node (Left_Opnd (Node));
Write_Str_Sloc (" not in ");
Sprint_Node (Right_Opnd (Node));
when N_Null =>
Write_Str_With_Col_Check_Sloc ("null");
when N_Null_Statement =>
if Comes_From_Source (Node)
or else Dump_Freeze_Null
or else not Is_List_Member (Node)
or else (No (Prev (Node)) and then No (Next (Node)))
then
Write_Indent_Str_Sloc ("null;");
end if;
when N_Number_Declaration =>
Set_Debug_Sloc;
if Write_Indent_Identifiers (Node) then
Write_Str_With_Col_Check (" : constant ");
Write_Str (" := ");
Sprint_Node (Expression (Node));
Write_Char (';');
end if;
when N_Object_Declaration =>
-- Put extra blank line before and after if this is a handler
-- record or a subprogram descriptor.
declare
Typ : constant Entity_Id := Etype (Defining_Identifier (Node));
Exc : constant Boolean :=
Is_RTE (Typ, RE_Handler_Record)
or else
Is_RTE (Typ, RE_Subprogram_Descriptor);
begin
if Exc then
Write_Indent;
end if;
Set_Debug_Sloc;
if Write_Indent_Identifiers (Node) then
Write_Str (" : ");
if Aliased_Present (Node) then
Write_Str_With_Col_Check ("aliased ");
end if;
if Constant_Present (Node) then
Write_Str_With_Col_Check ("constant ");
end if;
Sprint_Node (Object_Definition (Node));
if Present (Expression (Node)) then
Write_Str (" := ");
Sprint_Node (Expression (Node));
end if;
Write_Char (';');
end if;
if Exc then
Write_Indent;
end if;
end;
when N_Object_Renaming_Declaration =>
Write_Indent;
Set_Debug_Sloc;
Sprint_Node (Defining_Identifier (Node));
Write_Str (" : ");
Sprint_Node (Subtype_Mark (Node));
Write_Str_With_Col_Check (" renames ");
Sprint_Node (Name (Node));
Write_Char (';');
when N_Op_Abs =>
Write_Operator (Node, "abs ");
Sprint_Node (Right_Opnd (Node));
when N_Op_Add =>
Sprint_Node (Left_Opnd (Node));
Write_Operator (Node, " + ");
Sprint_Node (Right_Opnd (Node));
when N_Op_And =>
Sprint_Node (Left_Opnd (Node));
Write_Operator (Node, " and ");
Sprint_Node (Right_Opnd (Node));
when N_Op_Concat =>
Sprint_Node (Left_Opnd (Node));
Write_Operator (Node, " & ");
Sprint_Node (Right_Opnd (Node));
when N_Op_Divide =>
Sprint_Node (Left_Opnd (Node));
Write_Char (' ');
Process_TFAI_RR_Flags (Node);
Write_Operator (Node, "/ ");
Sprint_Node (Right_Opnd (Node));
when N_Op_Eq =>
Sprint_Node (Left_Opnd (Node));
Write_Operator (Node, " = ");
Sprint_Node (Right_Opnd (Node));
when N_Op_Expon =>
Sprint_Node (Left_Opnd (Node));
Write_Operator (Node, " ** ");
Sprint_Node (Right_Opnd (Node));
when N_Op_Ge =>
Sprint_Node (Left_Opnd (Node));
Write_Operator (Node, " >= ");
Sprint_Node (Right_Opnd (Node));
when N_Op_Gt =>
Sprint_Node (Left_Opnd (Node));
Write_Operator (Node, " > ");
Sprint_Node (Right_Opnd (Node));
when N_Op_Le =>
Sprint_Node (Left_Opnd (Node));
Write_Operator (Node, " <= ");
Sprint_Node (Right_Opnd (Node));
when N_Op_Lt =>
Sprint_Node (Left_Opnd (Node));
Write_Operator (Node, " < ");
Sprint_Node (Right_Opnd (Node));
when N_Op_Minus =>
Write_Operator (Node, "-");
Sprint_Node (Right_Opnd (Node));
when N_Op_Mod =>
Sprint_Node (Left_Opnd (Node));
if Treat_Fixed_As_Integer (Node) then
Write_Str (" #");
end if;
Write_Operator (Node, " mod ");
Sprint_Node (Right_Opnd (Node));
when N_Op_Multiply =>
Sprint_Node (Left_Opnd (Node));
Write_Char (' ');
Process_TFAI_RR_Flags (Node);
Write_Operator (Node, "* ");
Sprint_Node (Right_Opnd (Node));
when N_Op_Ne =>
Sprint_Node (Left_Opnd (Node));
Write_Operator (Node, " /= ");
Sprint_Node (Right_Opnd (Node));
when N_Op_Not =>
Write_Operator (Node, "not ");
Sprint_Node (Right_Opnd (Node));
when N_Op_Or =>
Sprint_Node (Left_Opnd (Node));
Write_Operator (Node, " or ");
Sprint_Node (Right_Opnd (Node));
when N_Op_Plus =>
Write_Operator (Node, "+");
Sprint_Node (Right_Opnd (Node));
when N_Op_Rem =>
Sprint_Node (Left_Opnd (Node));
if Treat_Fixed_As_Integer (Node) then
Write_Str (" #");
end if;
Write_Operator (Node, " rem ");
Sprint_Node (Right_Opnd (Node));
when N_Op_Shift =>
Set_Debug_Sloc;
Write_Id (Node);
Write_Char ('!');
Write_Str_With_Col_Check ("(");
Sprint_Node (Left_Opnd (Node));
Write_Str (", ");
Sprint_Node (Right_Opnd (Node));
Write_Char (')');
when N_Op_Subtract =>
Sprint_Node (Left_Opnd (Node));
Write_Operator (Node, " - ");
Sprint_Node (Right_Opnd (Node));
when N_Op_Xor =>
Sprint_Node (Left_Opnd (Node));
Write_Operator (Node, " xor ");
Sprint_Node (Right_Opnd (Node));
when N_Operator_Symbol =>
Write_Name_With_Col_Check_Sloc (Chars (Node));
when N_Ordinary_Fixed_Point_Definition =>
Write_Str_With_Col_Check_Sloc ("delta ");
Sprint_Node (Delta_Expression (Node));
Sprint_Opt_Node (Real_Range_Specification (Node));
when N_Or_Else =>
Sprint_Node (Left_Opnd (Node));
Write_Str_Sloc (" or else ");
Sprint_Node (Right_Opnd (Node));
when N_Others_Choice =>
if All_Others (Node) then
Write_Str_With_Col_Check ("all ");
end if;
Write_Str_With_Col_Check_Sloc ("others");
when N_Package_Body =>
Write_Indent;
Write_Indent_Str_Sloc ("package body ");
Sprint_Node (Defining_Unit_Name (Node));
Write_Str (" is");
Sprint_Indented_List (Declarations (Node));
if Present (Handled_Statement_Sequence (Node)) then
Write_Indent_Str ("begin");
Sprint_Node (Handled_Statement_Sequence (Node));
end if;
Write_Indent_Str ("end ");
Sprint_Node (Defining_Unit_Name (Node));
Write_Char (';');
when N_Package_Body_Stub =>
Write_Indent_Str_Sloc ("package body ");
Sprint_Node (Defining_Identifier (Node));
Write_Str_With_Col_Check (" is separate;");
when N_Package_Declaration =>
Write_Indent;
Write_Indent;
Sprint_Node_Sloc (Specification (Node));
Write_Char (';');
when N_Package_Instantiation =>
Write_Indent;
Write_Indent_Str_Sloc ("package ");
Sprint_Node (Defining_Unit_Name (Node));
Write_Str (" is new ");
Sprint_Node (Name (Node));
Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
Write_Char (';');
when N_Package_Renaming_Declaration =>
Write_Indent_Str_Sloc ("package ");
Sprint_Node (Defining_Unit_Name (Node));
Write_Str_With_Col_Check (" renames ");
Sprint_Node (Name (Node));
Write_Char (';');
when N_Package_Specification =>
Write_Str_With_Col_Check_Sloc ("package ");
Sprint_Node (Defining_Unit_Name (Node));
Write_Str (" is");
Sprint_Indented_List (Visible_Declarations (Node));
if Present (Private_Declarations (Node)) then
Write_Indent_Str ("private");
Sprint_Indented_List (Private_Declarations (Node));
end if;
Write_Indent_Str ("end ");
Sprint_Node (Defining_Unit_Name (Node));
when N_Parameter_Association =>
Sprint_Node_Sloc (Selector_Name (Node));
Write_Str (" => ");
Sprint_Node (Explicit_Actual_Parameter (Node));
when N_Parameter_Specification =>
Set_Debug_Sloc;
if Write_Identifiers (Node) then
Write_Str (" : ");
if In_Present (Node) then
Write_Str_With_Col_Check ("in ");
end if;
if Out_Present (Node) then
Write_Str_With_Col_Check ("out ");
end if;
Sprint_Node (Parameter_Type (Node));
if Present (Expression (Node)) then
Write_Str (" := ");
Sprint_Node (Expression (Node));
end if;
else
Write_Str (", ");
end if;
when N_Pragma =>
Write_Indent_Str_Sloc ("pragma ");
Write_Name_With_Col_Check (Chars (Node));
if Present (Pragma_Argument_Associations (Node)) then
Sprint_Opt_Paren_Comma_List
(Pragma_Argument_Associations (Node));
end if;
Write_Char (';');
when N_Pragma_Argument_Association =>
Set_Debug_Sloc;
if Chars (Node) /= No_Name then
Write_Name_With_Col_Check (Chars (Node));
Write_Str (" => ");
end if;
Sprint_Node (Expression (Node));
when N_Private_Type_Declaration =>
Write_Indent_Str_Sloc ("type ");
Write_Id (Defining_Identifier (Node));
if Present (Discriminant_Specifications (Node)) then
Write_Discr_Specs (Node);
elsif Unknown_Discriminants_Present (Node) then
Write_Str_With_Col_Check ("(<>)");
end if;
Write_Str (" is ");
if Tagged_Present (Node) then
Write_Str_With_Col_Check ("tagged ");
end if;
if Limited_Present (Node) then
Write_Str_With_Col_Check ("limited ");
end if;
Write_Str_With_Col_Check ("private;");
when N_Private_Extension_Declaration =>
Write_Indent_Str_Sloc ("type ");
Write_Id (Defining_Identifier (Node));
if Present (Discriminant_Specifications (Node)) then
Write_Discr_Specs (Node);
elsif Unknown_Discriminants_Present (Node) then
Write_Str_With_Col_Check ("(<>)");
end if;
Write_Str_With_Col_Check (" is new ");
Sprint_Node (Subtype_Indication (Node));
Write_Str_With_Col_Check (" with private;");
when N_Procedure_Call_Statement =>
Write_Indent;
Set_Debug_Sloc;
Sprint_Node (Name (Node));
Sprint_Opt_Paren_Comma_List (Parameter_Associations (Node));
Write_Char (';');
when N_Procedure_Instantiation =>
Write_Indent_Str_Sloc ("procedure ");
Sprint_Node (Defining_Unit_Name (Node));
Write_Str_With_Col_Check (" is new ");
Sprint_Node (Name (Node));
Sprint_Opt_Paren_Comma_List (Generic_Associations (Node));
Write_Char (';');
when N_Procedure_Specification =>
Write_Str_With_Col_Check_Sloc ("procedure ");
Sprint_Node (Defining_Unit_Name (Node));
Write_Param_Specs (Node);
when N_Protected_Body =>
Write_Indent_Str_Sloc ("protected body ");
Write_Id (Defining_Identifier (Node));
Write_Str (" is");
Sprint_Indented_List (Declarations (Node));
Write_Indent_Str ("end ");
Write_Id (Defining_Identifier (Node));
Write_Char (';');
when N_Protected_Body_Stub =>
Write_Indent_Str_Sloc ("protected body ");
Write_Id (Defining_Identifier (Node));
Write_Str_With_Col_Check (" is separate;");
when N_Protected_Definition =>
Set_Debug_Sloc;
Sprint_Indented_List (Visible_Declarations (Node));
if Present (Private_Declarations (Node)) then
Write_Indent_Str ("private");
Sprint_Indented_List (Private_Declarations (Node));
end if;
Write_Indent_Str ("end ");
when N_Protected_Type_Declaration =>
Write_Indent_Str_Sloc ("protected type ");
Write_Id (Defining_Identifier (Node));
Write_Discr_Specs (Node);
Write_Str (" is");
Sprint_Node (Protected_Definition (Node));
Write_Id (Defining_Identifier (Node));
Write_Char (';');
when N_Qualified_Expression =>
Sprint_Node (Subtype_Mark (Node));
Write_Char_Sloc (''');
Sprint_Node (Expression (Node));
when N_Raise_Constraint_Error =>
-- This node can be used either as a subexpression or as a
-- statement form. The following test is a reasonably reliable
-- way to distinguish the two cases.
if Is_List_Member (Node)
and then Nkind (Parent (Node)) not in N_Subexpr
then
Write_Indent;
end if;
Write_Str_With_Col_Check_Sloc ("[constraint_error");
if Present (Condition (Node)) then
Write_Str_With_Col_Check (" when ");
Sprint_Node (Condition (Node));
end if;
Write_Char (']');
when N_Raise_Program_Error =>
Write_Indent;
Write_Str_With_Col_Check_Sloc ("[program_error");
if Present (Condition (Node)) then
Write_Str_With_Col_Check (" when ");
Sprint_Node (Condition (Node));
end if;
Write_Char (']');
when N_Raise_Storage_Error =>
Write_Indent;
Write_Str_With_Col_Check_Sloc ("[storage_error");
if Present (Condition (Node)) then
Write_Str_With_Col_Check (" when ");
Sprint_Node (Condition (Node));
end if;
Write_Char (']');
when N_Raise_Statement =>
Write_Indent_Str_Sloc ("raise ");
Sprint_Node (Name (Node));
Write_Char (';');
when N_Range =>
Sprint_Node (Low_Bound (Node));
Write_Str_Sloc (" .. ");
Sprint_Node (High_Bound (Node));
when N_Range_Constraint =>
Write_Str_With_Col_Check_Sloc ("range ");
Sprint_Node (Range_Expression (Node));
when N_Real_Literal =>
Write_Ureal_With_Col_Check_Sloc (Realval (Node));
when N_Real_Range_Specification =>
Write_Str_With_Col_Check_Sloc ("range ");
Sprint_Node (Low_Bound (Node));
Write_Str (" .. ");
Sprint_Node (High_Bound (Node));
when N_Record_Definition =>
if Abstract_Present (Node) then
Write_Str_With_Col_Check ("abstract ");
end if;
if Tagged_Present (Node) then
Write_Str_With_Col_Check ("tagged ");
end if;
if Limited_Present (Node) then
Write_Str_With_Col_Check ("limited ");
end if;
if Null_Present (Node) then
Write_Str_With_Col_Check_Sloc ("null record");
else
Write_Str_With_Col_Check_Sloc ("record");
Sprint_Node (Component_List (Node));
Write_Indent_Str ("end record");
end if;
when N_Record_Representation_Clause =>
Write_Indent_Str_Sloc ("for ");
Sprint_Node (Identifier (Node));
Write_Str_With_Col_Check (" use record ");
if Present (Mod_Clause (Node)) then
Sprint_Node (Mod_Clause (Node));
end if;
Sprint_Indented_List (Component_Clauses (Node));
Write_Indent_Str ("end record;");
when N_Reference =>
Sprint_Node (Prefix (Node));
Write_Str_With_Col_Check_Sloc ("'reference");
when N_Requeue_Statement =>
Write_Indent_Str_Sloc ("requeue ");
Sprint_Node (Name (Node));
if Abort_Present (Node) then
Write_Str_With_Col_Check (" with abort");
end if;
Write_Char (';');
when N_Return_Statement =>
if Present (Expression (Node)) then
Write_Indent_Str_Sloc ("return ");
Sprint_Node (Expression (Node));
Write_Char (';');
else
Write_Indent_Str_Sloc ("return;");
end if;
when N_Selective_Accept =>
Write_Indent_Str_Sloc ("select");
declare
Alt_Node : Node_Id;
begin
Alt_Node := First (Select_Alternatives (Node));
loop
Indent_Begin;
Sprint_Node (Alt_Node);
Indent_End;
Next (Alt_Node);
exit when No (Alt_Node);
Write_Indent_Str ("or");
end loop;
end;
if Present (Else_Statements (Node)) then
Write_Indent_Str ("else");
Sprint_Indented_List (Else_Statements (Node));
end if;
Write_Indent_Str ("end select;");
when N_Signed_Integer_Type_Definition =>
Write_Str_With_Col_Check_Sloc ("range ");
Sprint_Node (Low_Bound (Node));
Write_Str (" .. ");
Sprint_Node (High_Bound (Node));
when N_Single_Protected_Declaration =>
Write_Indent_Str_Sloc ("protected ");
Write_Id (Defining_Identifier (Node));
Write_Str (" is");
Sprint_Node (Protected_Definition (Node));
Write_Id (Defining_Identifier (Node));
Write_Char (';');
when N_Single_Task_Declaration =>
Write_Indent_Str_Sloc ("task ");
Write_Id (Defining_Identifier (Node));
if Present (Task_Definition (Node)) then
Write_Str (" is");
Sprint_Node (Task_Definition (Node));
Write_Id (Defining_Identifier (Node));
end if;
Write_Char (';');
when N_Selected_Component | N_Expanded_Name =>
Sprint_Node (Prefix (Node));
Write_Char_Sloc ('.');
Sprint_Node (Selector_Name (Node));
when N_Slice =>
Set_Debug_Sloc;
Sprint_Node (Prefix (Node));
Write_Str_With_Col_Check (" (");
Sprint_Node (Discrete_Range (Node));
Write_Char (')');
when N_String_Literal =>
if String_Length (Strval (Node)) + Column > 75 then
Write_Indent_Str (" ");
end if;
Set_Debug_Sloc;
Write_String_Table_Entry (Strval (Node));
when N_Subprogram_Body =>
if Freeze_Indent = 0 then
Write_Indent;
end if;
Write_Indent;
Sprint_Node_Sloc (Specification (Node));
Write_Str (" is");
Sprint_Indented_List (Declarations (Node));
Write_Indent_Str ("begin");
Sprint_Node (Handled_Statement_Sequence (Node));
Write_Indent_Str ("end ");
Sprint_Node (Defining_Unit_Name (Specification (Node)));
Write_Char (';');
if Is_List_Member (Node)
and then Present (Next (Node))
and then Nkind (Next (Node)) /= N_Subprogram_Body
then
Write_Indent;
end if;
when N_Subprogram_Body_Stub =>
Write_Indent;
Sprint_Node_Sloc (Specification (Node));
Write_Str_With_Col_Check (" is separate;");
when N_Subprogram_Declaration =>
Write_Indent;
Sprint_Node_Sloc (Specification (Node));
Write_Char (';');
when N_Subprogram_Info =>
Sprint_Node (Identifier (Node));
Write_Str_With_Col_Check_Sloc ("'subprogram_info");
when N_Subprogram_Renaming_Declaration =>
Write_Indent;
Sprint_Node (Specification (Node));
Write_Str_With_Col_Check_Sloc (" renames ");
Sprint_Node (Name (Node));
Write_Char (';');
when N_Subtype_Declaration =>
Write_Indent_Str_Sloc ("subtype ");
Write_Id (Defining_Identifier (Node));
Write_Str (" is ");
Sprint_Node (Subtype_Indication (Node));
Write_Char (';');
when N_Subtype_Indication =>
Sprint_Node_Sloc (Subtype_Mark (Node));
Write_Char (' ');
Sprint_Node (Constraint (Node));
when N_Subunit =>
Write_Indent_Str_Sloc ("separate (");
Sprint_Node (Name (Node));
Write_Char (')');
Print_Eol;
Sprint_Node (Proper_Body (Node));
when N_Task_Body =>
Write_Indent_Str_Sloc ("task body ");
Write_Id (Defining_Identifier (Node));
Write_Str (" is");
Sprint_Indented_List (Declarations (Node));
Write_Indent_Str ("begin");
Sprint_Node (Handled_Statement_Sequence (Node));
Write_Indent_Str ("end ");
Write_Id (Defining_Identifier (Node));
Write_Char (';');
when N_Task_Body_Stub =>
Write_Indent_Str_Sloc ("task body ");
Write_Id (Defining_Identifier (Node));
Write_Str_With_Col_Check (" is separate;");
when N_Task_Definition =>
Set_Debug_Sloc;
Sprint_Indented_List (Visible_Declarations (Node));
if Present (Private_Declarations (Node)) then
Write_Indent_Str ("private");
Sprint_Indented_List (Private_Declarations (Node));
end if;
Write_Indent_Str ("end ");
when N_Task_Type_Declaration =>
Write_Indent_Str_Sloc ("task type ");
Write_Id (Defining_Identifier (Node));
Write_Discr_Specs (Node);
if Present (Task_Definition (Node)) then
Write_Str (" is");
Sprint_Node (Task_Definition (Node));
Write_Id (Defining_Identifier (Node));
end if;
Write_Char (';');
when N_Terminate_Alternative =>
Sprint_Node_List (Pragmas_Before (Node));
Write_Indent;
if Present (Condition (Node)) then
Write_Str_With_Col_Check ("when ");
Sprint_Node (Condition (Node));
Write_Str (" => ");
end if;
Write_Str_With_Col_Check_Sloc ("terminate;");
Sprint_Node_List (Pragmas_After (Node));
when N_Timed_Entry_Call =>
Write_Indent_Str_Sloc ("select");
Indent_Begin;
Sprint_Node (Entry_Call_Alternative (Node));
Indent_End;
Write_Indent_Str ("or");
Indent_Begin;
Sprint_Node (Delay_Alternative (Node));
Indent_End;
Write_Indent_Str ("end select;");
when N_Triggering_Alternative =>
Sprint_Node_List (Pragmas_Before (Node));
Sprint_Node_Sloc (Triggering_Statement (Node));
Sprint_Node_List (Statements (Node));
when N_Type_Conversion =>
Set_Debug_Sloc;
Sprint_Node (Subtype_Mark (Node));
Col_Check (4);
if Conversion_OK (Node) then
Write_Char ('?');
end if;
if Float_Truncate (Node) then
Write_Char ('^');
end if;
if Rounded_Result (Node) then
Write_Char ('@');
end if;
Write_Char ('(');
Sprint_Node (Expression (Node));
Write_Char (')');
when N_Unchecked_Expression =>
Col_Check (10);
Write_Str ("`(");
Sprint_Node_Sloc (Expression (Node));
Write_Char (')');
when N_Unchecked_Type_Conversion =>
Sprint_Node (Subtype_Mark (Node));
Write_Char ('!');
Write_Str_With_Col_Check ("(");
Sprint_Node_Sloc (Expression (Node));
Write_Char (')');
when N_Unconstrained_Array_Definition =>
Write_Str_With_Col_Check_Sloc ("array (");
declare
Node1 : Node_Id;
begin
Node1 := First (Subtype_Marks (Node));
loop
Sprint_Node (Node1);
Write_Str_With_Col_Check (" range <>");
Next (Node1);
exit when Node1 = Empty;
Write_Str (", ");
end loop;
end;
Write_Str (") of ");
if Aliased_Present (Node) then
Write_Str_With_Col_Check ("aliased ");
end if;
Sprint_Node (Subtype_Indication (Node));
when N_Unused_At_Start | N_Unused_At_End =>
Write_Indent_Str ("***** Error, unused node encountered *****");
Print_Eol;
when N_Use_Package_Clause =>
Write_Indent_Str_Sloc ("use ");
Sprint_Comma_List (Names (Node));
Write_Char (';');
when N_Use_Type_Clause =>
Write_Indent_Str_Sloc ("use type ");
Sprint_Comma_List (Subtype_Marks (Node));
Write_Char (';');
when N_Validate_Unchecked_Conversion =>
Write_Indent_Str_Sloc ("validate unchecked_conversion (");
Sprint_Node (Source_Type (Node));
Write_Str (", ");
Sprint_Node (Target_Type (Node));
Write_Str (");");
when N_Variant =>
Write_Indent_Str_Sloc ("when ");
Sprint_Bar_List (Discrete_Choices (Node));
Write_Str (" => ");
Sprint_Node (Component_List (Node));
when N_Variant_Part =>
Indent_Begin;
Write_Indent_Str_Sloc ("case ");
Sprint_Node (Name (Node));
Write_Str (" is ");
Sprint_Indented_List (Variants (Node));
Write_Indent_Str ("end case");
Indent_End;
when N_With_Clause =>
-- Special test, if we are dumping the original tree only,
-- then we want to eliminate the bogus with clauses that
-- correspond to the non-existent children of Text_IO.
if Dump_Original_Only
and then Is_Text_IO_Kludge_Unit (Name (Node))
then
null;
-- Normal case, output the with clause
else
if First_Name (Node) or else not Dump_Original_Only then
Write_Indent_Str ("with ");
else
Write_Str (", ");
end if;
Sprint_Node_Sloc (Name (Node));
if Last_Name (Node) or else not Dump_Original_Only then
Write_Char (';');
end if;
end if;
when N_With_Type_Clause =>
Write_Indent_Str ("with type ");
Sprint_Node_Sloc (Name (Node));
if Tagged_Present (Node) then
Write_Str (" is tagged;");
else
Write_Str (" is access;");
end if;
end case;
if Nkind (Node) in N_Subexpr
and then Do_Range_Check (Node)
then
Write_Str ("}");
end if;
for J in 1 .. Paren_Count (Node) loop
Write_Char (')');
end loop;
pragma Assert (No (Debug_Node));
Debug_Node := Save_Debug_Node;
end Sprint_Node_Actual;
----------------------
-- Sprint_Node_List --
----------------------
procedure Sprint_Node_List (List : List_Id) is
Node : Node_Id;
begin
if Is_Non_Empty_List (List) then
Node := First (List);
loop
Sprint_Node (Node);
Next (Node);
exit when Node = Empty;
end loop;
end if;
end Sprint_Node_List;
----------------------
-- Sprint_Node_Sloc --
----------------------
procedure Sprint_Node_Sloc (Node : Node_Id) is
begin
Sprint_Node (Node);
if Present (Debug_Node) then
Set_Sloc (Debug_Node, Sloc (Node));
Debug_Node := Empty;
end if;
end Sprint_Node_Sloc;
---------------------
-- Sprint_Opt_Node --
---------------------
procedure Sprint_Opt_Node (Node : Node_Id) is
begin
if Present (Node) then
Write_Char (' ');
Sprint_Node (Node);
end if;
end Sprint_Opt_Node;
--------------------------
-- Sprint_Opt_Node_List --
--------------------------
procedure Sprint_Opt_Node_List (List : List_Id) is
begin
if Present (List) then
Sprint_Node_List (List);
end if;
end Sprint_Opt_Node_List;
---------------------------------
-- Sprint_Opt_Paren_Comma_List --
---------------------------------
procedure Sprint_Opt_Paren_Comma_List (List : List_Id) is
begin
if Is_Non_Empty_List (List) then
Write_Char (' ');
Sprint_Paren_Comma_List (List);
end if;
end Sprint_Opt_Paren_Comma_List;
-----------------------------
-- Sprint_Paren_Comma_List --
-----------------------------
procedure Sprint_Paren_Comma_List (List : List_Id) is
N : Node_Id;
Node_Exists : Boolean := False;
begin
if Is_Non_Empty_List (List) then
if Dump_Original_Only then
N := First (List);
while Present (N) loop
if not Is_Rewrite_Insertion (N) then
Node_Exists := True;
exit;
end if;
Next (N);
end loop;
if not Node_Exists then
return;
end if;
end if;
Write_Str_With_Col_Check ("(");
Sprint_Comma_List (List);
Write_Char (')');
end if;
end Sprint_Paren_Comma_List;
---------------------
-- Write_Char_Sloc --
---------------------
procedure Write_Char_Sloc (C : Character) is
begin
if Debug_Generated_Code and then C /= ' ' then
Set_Debug_Sloc;
end if;
Write_Char (C);
end Write_Char_Sloc;
------------------------
-- Write_Discr_Specs --
------------------------
procedure Write_Discr_Specs (N : Node_Id) is
Specs : List_Id;
Spec : Node_Id;
begin
Specs := Discriminant_Specifications (N);
if Present (Specs) then
Write_Str_With_Col_Check (" (");
Spec := First (Specs);
loop
Sprint_Node (Spec);
Next (Spec);
exit when Spec = Empty;
-- Add semicolon, unless we are printing original tree and the
-- next specification is part of a list (but not the first
-- element of that list)
if not Dump_Original_Only or else not Prev_Ids (Spec) then
Write_Str ("; ");
end if;
end loop;
Write_Char (')');
end if;
end Write_Discr_Specs;
-----------------
-- Write_Ekind --
-----------------
procedure Write_Ekind (E : Entity_Id) is
S : constant String := Entity_Kind'Image (Ekind (E));
begin
Name_Len := S'Length;
Name_Buffer (1 .. Name_Len) := S;
Set_Casing (Mixed_Case);
Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
end Write_Ekind;
--------------
-- Write_Id --
--------------
procedure Write_Id (N : Node_Id) is
begin
-- Case of a defining identifier
if Nkind (N) = N_Defining_Identifier then
-- If defining identifier has an interface name (and no
-- address clause), then we output the interface name.
if (Is_Imported (N) or else Is_Exported (N))
and then Present (Interface_Name (N))
and then No (Address_Clause (N))
then
String_To_Name_Buffer (Strval (Interface_Name (N)));
Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
-- If no interface name (or inactive because there was
-- an address clause), then just output the Chars name.
else
Write_Name_With_Col_Check (Chars (N));
end if;
-- Case of selector of an expanded name where the expanded name
-- has an associated entity, output this entity.
elsif Nkind (Parent (N)) = N_Expanded_Name
and then Selector_Name (Parent (N)) = N
and then Present (Entity (Parent (N)))
then
Write_Id (Entity (Parent (N)));
-- For any other kind of node with an associated entity, output it.
elsif Nkind (N) in N_Has_Entity
and then Present (Entity (N))
then
Write_Id (Entity (N));
-- All other cases, we just print the Chars field
else
Write_Name_With_Col_Check (Chars (N));
end if;
end Write_Id;
-----------------------
-- Write_Identifiers --
-----------------------
function Write_Identifiers (Node : Node_Id) return Boolean is
begin
Sprint_Node (Defining_Identifier (Node));
-- The remainder of the declaration must be printed unless we are
-- printing the original tree and this is not the last identifier
return
not Dump_Original_Only or else not More_Ids (Node);
end Write_Identifiers;
------------------------
-- Write_Implicit_Def --
------------------------
procedure Write_Implicit_Def (E : Entity_Id) is
Ind : Node_Id;
begin
case Ekind (E) is
when E_Array_Subtype =>
Write_Str_With_Col_Check ("subtype ");
Write_Id (E);
Write_Str_With_Col_Check (" is ");
Write_Id (Base_Type (E));
Write_Str_With_Col_Check (" (");
Ind := First_Index (E);
while Present (Ind) loop
Sprint_Node (Ind);
Next_Index (Ind);
if Present (Ind) then
Write_Str (", ");
end if;
end loop;
Write_Str (");");
when E_Signed_Integer_Subtype | E_Enumeration_Subtype =>
Write_Str_With_Col_Check ("subtype ");
Write_Id (E);
Write_Str (" is ");
Write_Id (Etype (E));
Write_Str_With_Col_Check (" range ");
Sprint_Node (Scalar_Range (E));
Write_Str (";");
when others =>
Write_Str_With_Col_Check ("type ");
Write_Id (E);
Write_Str_With_Col_Check (" is <");
Write_Ekind (E);
Write_Str (">;");
end case;
end Write_Implicit_Def;
------------------
-- Write_Indent --
------------------
procedure Write_Indent is
begin
if Indent_Annull_Flag then
Indent_Annull_Flag := False;
else
Print_Eol;
for J in 1 .. Indent loop
Write_Char (' ');
end loop;
end if;
end Write_Indent;
------------------------------
-- Write_Indent_Identifiers --
------------------------------
function Write_Indent_Identifiers (Node : Node_Id) return Boolean is
begin
-- We need to start a new line for every node, except in the case
-- where we are printing the original tree and this is not the first
-- defining identifier in the list.
if not Dump_Original_Only or else not Prev_Ids (Node) then
Write_Indent;
-- If printing original tree and this is not the first defining
-- identifier in the list, then the previous call to this procedure
-- printed only the name, and we add a comma to separate the names.
else
Write_Str (", ");
end if;
Sprint_Node (Defining_Identifier (Node));
-- The remainder of the declaration must be printed unless we are
-- printing the original tree and this is not the last identifier
return
not Dump_Original_Only or else not More_Ids (Node);
end Write_Indent_Identifiers;
-----------------------------------
-- Write_Indent_Identifiers_Sloc --
-----------------------------------
function Write_Indent_Identifiers_Sloc (Node : Node_Id) return Boolean is
begin
-- We need to start a new line for every node, except in the case
-- where we are printing the original tree and this is not the first
-- defining identifier in the list.
if not Dump_Original_Only or else not Prev_Ids (Node) then
Write_Indent;
-- If printing original tree and this is not the first defining
-- identifier in the list, then the previous call to this procedure
-- printed only the name, and we add a comma to separate the names.
else
Write_Str (", ");
end if;
Set_Debug_Sloc;
Sprint_Node (Defining_Identifier (Node));
-- The remainder of the declaration must be printed unless we are
-- printing the original tree and this is not the last identifier
return
not Dump_Original_Only or else not More_Ids (Node);
end Write_Indent_Identifiers_Sloc;
----------------------
-- Write_Indent_Str --
----------------------
procedure Write_Indent_Str (S : String) is
begin
Write_Indent;
Write_Str (S);
end Write_Indent_Str;
---------------------------
-- Write_Indent_Str_Sloc --
---------------------------
procedure Write_Indent_Str_Sloc (S : String) is
begin
Write_Indent;
Write_Str_Sloc (S);
end Write_Indent_Str_Sloc;
-------------------------------
-- Write_Name_With_Col_Check --
-------------------------------
procedure Write_Name_With_Col_Check (N : Name_Id) is
J : Natural;
begin
Get_Name_String (N);
-- Deal with -gnatI which replaces digits in an internal
-- name by three dots (e.g. R7b becomes R...b).
if Debug_Flag_II and then Name_Buffer (1) in 'A' .. 'Z' then
J := 2;
while J < Name_Len loop
exit when Name_Buffer (J) not in 'A' .. 'Z';
J := J + 1;
end loop;
if Name_Buffer (J) in '0' .. '9' then
Write_Str_With_Col_Check (Name_Buffer (1 .. J - 1));
Write_Str ("...");
while J <= Name_Len loop
if Name_Buffer (J) not in '0' .. '9' then
Write_Str (Name_Buffer (J .. Name_Len));
exit;
else
J := J + 1;
end if;
end loop;
return;
end if;
end if;
-- Fall through for normal case
Write_Str_With_Col_Check (Name_Buffer (1 .. Name_Len));
end Write_Name_With_Col_Check;
------------------------------------
-- Write_Name_With_Col_Check_Sloc --
------------------------------------
procedure Write_Name_With_Col_Check_Sloc (N : Name_Id) is
begin
Get_Name_String (N);
Write_Str_With_Col_Check_Sloc (Name_Buffer (1 .. Name_Len));
end Write_Name_With_Col_Check_Sloc;
--------------------
-- Write_Operator --
--------------------
procedure Write_Operator (N : Node_Id; S : String) is
F : Natural := S'First;
T : Natural := S'Last;
begin
if S (F) = ' ' then
Write_Char (' ');
F := F + 1;
end if;
if S (T) = ' ' then
T := T - 1;
end if;
if Do_Overflow_Check (N) then
Write_Char ('{');
Write_Str_Sloc (S (F .. T));
Write_Char ('}');
else
Write_Str_Sloc (S);
end if;
if S (S'Last) = ' ' then
Write_Char (' ');
end if;
end Write_Operator;
-----------------------
-- Write_Param_Specs --
-----------------------
procedure Write_Param_Specs (N : Node_Id) is
Specs : List_Id;
Spec : Node_Id;
Formal : Node_Id;
begin
Specs := Parameter_Specifications (N);
if Is_Non_Empty_List (Specs) then
Write_Str_With_Col_Check (" (");
Spec := First (Specs);
loop
Sprint_Node (Spec);
Formal := Defining_Identifier (Spec);
Next (Spec);
exit when Spec = Empty;
-- Add semicolon, unless we are printing original tree and the
-- next specification is part of a list (but not the first
-- element of that list)
if not Dump_Original_Only or else not Prev_Ids (Spec) then
Write_Str ("; ");
end if;
end loop;
-- Write out any extra formals
while Present (Extra_Formal (Formal)) loop
Formal := Extra_Formal (Formal);
Write_Str ("; ");
Write_Name_With_Col_Check (Chars (Formal));
Write_Str (" : ");
Write_Name_With_Col_Check (Chars (Etype (Formal)));
end loop;
Write_Char (')');
end if;
end Write_Param_Specs;
--------------------------
-- Write_Rewrite_Str --
--------------------------
procedure Write_Rewrite_Str (S : String) is
begin
if not Dump_Generated_Only then
if S'Length = 3 and then S = ">>>" then
Write_Str (">>>");
else
Write_Str_With_Col_Check (S);
end if;
end if;
end Write_Rewrite_Str;
--------------------
-- Write_Str_Sloc --
--------------------
procedure Write_Str_Sloc (S : String) is
begin
for J in S'Range loop
Write_Char_Sloc (S (J));
end loop;
end Write_Str_Sloc;
------------------------------
-- Write_Str_With_Col_Check --
------------------------------
procedure Write_Str_With_Col_Check (S : String) is
begin
if Int (S'Last) + Column > Line_Limit then
Write_Indent_Str (" ");
if S (1) = ' ' then
Write_Str (S (2 .. S'Length));
else
Write_Str (S);
end if;
else
Write_Str (S);
end if;
end Write_Str_With_Col_Check;
-----------------------------------
-- Write_Str_With_Col_Check_Sloc --
-----------------------------------
procedure Write_Str_With_Col_Check_Sloc (S : String) is
begin
if Int (S'Last) + Column > Line_Limit then
Write_Indent_Str (" ");
if S (1) = ' ' then
Write_Str_Sloc (S (2 .. S'Length));
else
Write_Str_Sloc (S);
end if;
else
Write_Str_Sloc (S);
end if;
end Write_Str_With_Col_Check_Sloc;
------------------------------------
-- Write_Uint_With_Col_Check_Sloc --
------------------------------------
procedure Write_Uint_With_Col_Check_Sloc (U : Uint; Format : UI_Format) is
begin
Col_Check (UI_Decimal_Digits_Hi (U));
Set_Debug_Sloc;
UI_Write (U, Format);
end Write_Uint_With_Col_Check_Sloc;
-------------------------------------
-- Write_Ureal_With_Col_Check_Sloc --
-------------------------------------
procedure Write_Ureal_With_Col_Check_Sloc (U : Ureal) is
D : constant Uint := Denominator (U);
N : constant Uint := Numerator (U);
begin
Col_Check
(UI_Decimal_Digits_Hi (D) + UI_Decimal_Digits_Hi (N) + 4);
Set_Debug_Sloc;
UR_Write (U);
end Write_Ureal_With_Col_Check_Sloc;
end Sprint;
|
-- Based on libgasandbox.draw.h and draw.cpp
with Ada.Numerics;
with Ada.Numerics.Elementary_Functions;
with Ada.Text_IO; use Ada.Text_IO;
with GL;
with GL.Attributes;
with GL.Culling;
with GL.Objects.Buffers;
with GL.Objects.Vertex_Arrays;
with GL.Rasterization;
with GL.Toggles;
with GL.Types; use GL.Types;
with GL_Util;
with Maths;
with Utilities;
with Blade_Types;
with E3GA;
with E3GA_Utilities;
with GA_Maths;
-- with GA_Utilities;
with Geosphere;
with Multivectors;
with Shader_Manager;
package body GA_Draw is
Count : Integer := 0;
procedure Draw_Circle (Palet_Type : Palet.Colour_Palet;
Method : GA_Draw.Method_Type);
-- ------------------------------------------------------------------------
procedure Draw_Base (Render_Program : GL.Objects.Programs.Program;
Scale : Float) is
use GL.Objects.Buffers;
use GA_Maths.Float_Functions;
Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object;
Vertex_Buffer : GL.Objects.Buffers.Buffer;
S_Scale : constant Single := Single (5.0 / Scale);
Z : float := 0.0;
Num_Steps : constant int := 32;
Rotor_Step : constant float :=
2.0 * Ada.Numerics.Pi / float (Num_Steps);
Fan : Singles.Vector3_Array (1 .. Num_Steps + 1);
begin
Vertex_Array.Initialize_Id;
Vertex_Array.Bind;
Vertex_Buffer.Initialize_Id;
Array_Buffer.Bind (Vertex_Buffer);
Fan (1) := (S_Scale, 0.0, -0.25);
for Count in 2 .. Num_Steps + 1 loop
Fan (Count) := (S_Scale * Single (Cos (Z)), S_Scale * Single (Sin (Z)), -0.25);
Z := Z + Rotor_Step;
end loop;
Utilities.Load_Vertex_Buffer (Array_Buffer, Fan, Static_Draw);
GL.Objects.Programs.Use_Program (Render_Program);
GL.Attributes.Enable_Vertex_Attrib_Array (0);
GL.Objects.Buffers.Array_Buffer.Bind (Vertex_Buffer);
GL.Attributes.Set_Vertex_Attrib_Pointer (0, 3, Single_Type, 0, 0);
GL.Objects.Vertex_Arrays.Draw_Arrays (Mode => Triangle_Fan,
First => 0,
Count => Num_Steps);
GL.Attributes.Disable_Vertex_Attrib_Array (0);
exception
when others =>
Put_Line ("An exception occurred in GA_Draw.Draw_Base.");
raise;
end Draw_Base;
-- ------------------------------------------------------------------------
-- Draw_Bivector corresponds to draw.draw_Bivector of draw.cpp
-- The parameter names correspond of those in draw.h!
procedure Draw_Bivector (Render_Program : GL.Objects.Programs.Program;
Base, Normal, Ortho_1, Ortho_2 : C3GA.Vector_E3;
Palet_Type : Palet.Colour_Palet;
Scale : float := 1.0;
Method : Method_Type :=
Draw_Bivector_Circle) is
use GA_Maths;
use Float_Functions;
use GL.Types.Singles;
-- Rotor_Step : float := 2.0 * Ada.Numerics.Pi / 64.0;
-- Cords : Float_3D := (0.0, 0.0, 0.0);
-- Translate : Vector3 := (0.0, 0.0, 0.0);
-- O2 : Multivectors.M_Vector := Ortho_2;
Model_Matrix : GL.Types.Singles.Matrix4 := Identity4;
Position_Norm : Float := C3GA.Norm_E2 (Base);
Normal_Norm : constant Float := C3GA.Norm_E2 (Normal);
Base_Coords : constant GA_Maths.Float_3D :=
C3GA.Get_Coords (Base);
Normal_Coords : constant GA_Maths.Float_3D :=
C3GA.Get_Coords (Normal);
Ortho_1_Coords : constant GA_Maths.Float_3D :=
C3GA.Get_Coords (Ortho_1);
Ortho_2_Coords : constant GA_Maths.Float_3D :=
C3GA.Get_Coords (Ortho_2);
Translation_Vector : Vector3 := (0.0, 0.0, 0.0);
MV_Normal : constant Multivectors.M_Vector
:= Multivectors.New_Vector
(Normal_Coords (1), Normal_Coords (2), Normal_Coords (3));
MV_Ortho_1 : constant Multivectors.M_Vector
:= Multivectors.New_Vector
(Ortho_1_Coords (1), Ortho_1_Coords (2), Ortho_1_Coords (3));
MV_Ortho_2 : constant Multivectors.M_Vector
:= Multivectors.New_Vector
(Ortho_2_Coords (1), Ortho_2_Coords (2), Ortho_2_Coords (3));
Rotation_Matrix : Matrix4 := Identity4;
Scaling_Matrix : Matrix4;
Translation_Matrix : Matrix4 := Identity4;
BV_Scale : Single := Single (Scale);
RT : Multivectors.Rotor;
begin
GL.Objects.Programs.Use_Program (Render_Program);
-- Set position
if Position_Norm > 0.0 then
Translation_Vector :=
(Single (Base_Coords (1)), Single (Base_Coords (2)),
Single (Base_Coords (3)));
Translation_Matrix := Maths.Translation_Matrix (Translation_Vector);
end if;
Shader_Manager.Set_Translation_Matrix (Translation_Matrix);
if Method /= Draw_Bivector_Parallelogram and then
Method /= Draw_Bivector_Parallelogram_No_Vectors then
-- Rotate e3 to normal direction
if Normal_Norm > 0.0 then
Rotation_Matrix := GA_Maths.Vector_Rotation_Matrix ((0.0, 0.0, 1.0), Normal);
end if;
RT := E3GA_Utilities.Rotor_Vector_To_Vector
(Multivectors.Basis_Vector (Blade_Types.E3_e3), MV_Normal);
GL_Util.Rotor_GL_Multiply (RT, Rotation_Matrix);
else -- Draw_Bivector_Parallelogram
Position_Norm :=
C3GA.Norm_E2 (C3GA.To_VectorE3GA
((Multivectors.Outer_Product (MV_Ortho_1,
MV_Ortho_2))));
BV_Scale := Single (Sqrt (Pi / Position_Norm)) * BV_Scale;
end if;
Shader_Manager.Set_Rotation_Matrix (Rotation_Matrix);
Scaling_Matrix := Maths.Scaling_Matrix ((BV_Scale, BV_Scale, BV_Scale));
Model_Matrix := Scaling_Matrix * Model_Matrix;
Shader_Manager.Set_Model_Matrix (Model_Matrix);
case Method is
when Draw_Bivector_Circle |
Draw_Bivector_Circle_Outline =>
Draw_Circle (Palet_Type, Method);
when others => null;
end case;
exception
when others =>
Put_Line ("An exception occurred in GA_Draw.Draw_Bivector.");
raise;
end Draw_Bivector;
-- ----------------------------------------------------------------------
-- procedure Draw_Bivector (Render_Program : GL.Objects.Programs.Program;
-- Base, Ortho_1, Ortho_2 : Multivectors.M_Vector;
-- Palet_Type : Palet.Colour_Palet;
-- Scale : float := 1.0;
-- Method : Method_Type := Draw_Bivector_Circle) is
-- use GA_Maths;
-- use GL.Types.Singles;
--
-- Vertex_Array_Object : GL.Objects.Vertex_Arrays.Vertex_Array_Object;
-- -- Rotor_Step : float := 2.0 * Ada.Numerics.Pi / 64.0;
-- Scale_S : constant GL.Types.Single := GL.Types.Single (Scale);
-- Translate : Vector3 := (0.0, 0.0, 0.0);
-- -- O2 : Multivectors.M_Vector := Ortho_2;
-- -- Model_Matrix : GL.Types.Singles.Matrix4 := GL.Types.Singles.Identity4;
-- MVP_Matrix : Matrix4 := Singles.Identity4;
-- Scaled : GL.Types.Single;
-- E2_Norm : Float;
-- begin
-- GL.Objects.Programs.Use_Program (Render_Program);
-- Vertex_Array_Object.Initialize_Id;
-- Vertex_Array_Object.Bind;
--
-- Shader_Manager.Set_Ambient_Colour ((1.0, 1.0, 1.0, 1.0));
--
-- -- MVP_Matrix := Model_Matrix;
-- Translate := (Single (C3GA.e1 (Base)),
-- Single (C3GA.e2 (Base)),
-- Single (C3GA.e3 (Base)));
-- E2_Norm := Multivectors.Norm_E2 (Base);
-- if E2_Norm /= 0.0 then
-- MVP_Matrix := Maths.Translation_Matrix (Translate) * MVP_Matrix;
-- end if;
--
-- if Method = Draw_Bivector_Parallelogram and then
-- Method = Draw_Bivector_Parallelogram_No_Vectors then
-- MVP_Matrix := Maths.Scaling_Matrix ((Scale_S, Scale_S, Scale_S)) * MVP_Matrix;
-- else
-- E2_Norm := Multivectors.Norm_E2 (Multivectors.Outer_Product (Ortho_1, Ortho_2));
-- Scaled := GL.Types.Single (Scale * Float_Functions.Sqrt (pi / E2_Norm));
-- MVP_Matrix := Maths.Scaling_Matrix ((Scaled, Scaled, Scaled))
-- * MVP_Matrix;
-- end if;
--
-- Case Method is
-- when Draw_Bivector_Circle |
-- Draw_Bivector_Circle_Outline =>
-- Draw_Circle (Render_Program, MVP_Matrix, Palet_Type, Method);
-- when others => null;
-- end case;
-- exception
-- when others =>
-- Put_Line ("An exception occurred in Draw_Object.Draw_Bivector.");
-- raise;
-- end Draw_Bivector;
-- ----------------------------------------------------------------------
-- procedure Draw_Multivector (Render_Program : GL.Objects.Programs.Program;
-- Model_Matrix : GL.Types.Singles.Matrix4;
-- MV : E2GA.Multivector;
-- Colour : GL.Types.Colors.Color := (1.0, 1.0, 1.0, 1.0);
-- Scale : GL.Types.Single) is
-- -- L : boolean;
-- Rotor_Step : float := 2.0 * Ada.Numerics.Pi / 64.0;
-- -- X : float;
-- -- Y : float;
-- MVP_Matrix : Singles.Matrix4 := Singles.Identity4;
-- Rotor : E2GA.Rotor;
--
-- begin
--
-- GL.Objects.Programs.Use_Program (Render_Program);
-- Vertex_Array_Object.Initialize_Id;
-- Vertex_Array_Object.Bind;
-- -- if E3GA.Norm_E2 (MV).M_C1 = 0.0 then
-- -- Maths.Translation_Matrix (Get_Coord_1 (Base),
-- -- Get_Coord_2 (Base), Get_Coord_3 (Base)) * MVP_Matrix;
-- -- end if;
-- exception
-- when others =>
-- Put_Line ("An exception occurred in Draw_Object.Draw_Multivector.");
-- raise;
-- end Draw_Multivector;
-- ----------------------------------------------------------------------
procedure Draw_Circle (Palet_Type : Palet.Colour_Palet;
Method : GA_Draw.Method_Type) is
use GA_Maths;
use GA_Maths.Float_Functions;
use GL.Objects.Buffers;
use Singles;
use Palet;
type Circle_Part is (Back_Part, Front_Part, Outline_Part);
Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object;
procedure Draw_Part (Part : Circle_Part) is
Vertex_Buffer : GL.Objects.Buffers.Buffer;
Normals_Buffer : GL.Objects.Buffers.Buffer;
Num_Steps : constant int := 256;
VB_Size : Int := Num_Steps;
Angle : float := 0.0;
Rotor_Step : constant float :=
2.0 * Ada.Numerics.Pi / float (Num_Steps);
Norm_Z : Single;
Draw_Hooks : constant Boolean :=
Part = Outline_Part and Get_Draw_Mode.Orientation;
begin
Vertex_Array.Initialize_Id;
Vertex_Array.Bind;
Vertex_Buffer.Initialize_Id;
Normals_Buffer.Initialize_Id;
case Part is
when Back_Part | Outline_Part =>
Norm_Z := 1.0;
when Front_Part =>
Norm_Z := -1.0;
end case;
if Draw_Hooks then
VB_Size := Num_Steps + 12;
end if;
declare
Fan : Vector3_Array (1 .. VB_Size);
Normal : Vector3_Array (1 .. VB_Size) :=
(others => (0.0, 0.0, 1.0));
Hooks : Vector3_Array (1 .. 2) := ((1.0, 0.0, 0.0),
(1.0, -0.5, 0.0));
Hook_Rotation : constant Matrix3 := Rotation_Matrix
(Maths.Radian (Ada.Numerics.Pi / 3.0), (0.0, 0.0, 1.0));
Hook_Index : Int := 1;
begin
for Count in 1 .. Num_Steps loop
case Part is
when Back_Part | Outline_Part =>
Fan (Count) := (Single (Cos (Angle)), Single (Sin (Angle)), 0.0);
when Front_Part =>
Fan (Count) := (-Single (Cos (Angle)), Single (Sin (Angle)), 0.0);
end case;
Normal (Count) := (0.0, 0.0, Norm_Z);
Angle := Angle + Rotor_Step;
end loop;
if Draw_Hooks then
-- draw six 'hooks' along the edge of the circle
while Hook_Index < 12 loop
Fan (Num_Steps + Hook_Index) := Hooks (1);
Fan (Num_Steps + Hook_Index + 1) := Hooks (2);
Normal (Num_Steps + Hook_Index) := (0.0, 0.0, Norm_Z);
Normal (Num_Steps + Hook_Index + 1) := (0.0, 0.0, Norm_Z);
Hooks (1) := Hook_Rotation * Hooks (1);
Hooks (2) := Hook_Rotation * Hooks (2);
Hook_Index := Hook_Index + 2;
end loop;
end if;
Vertex_Array.Bind;
Array_Buffer.Bind (Vertex_Buffer);
Utilities.Load_Vertex_Buffer (Array_Buffer, Fan, Static_Draw);
Array_Buffer.Bind (Normals_Buffer);
Utilities.Load_Vertex_Buffer (Array_Buffer, Normal, Static_Draw);
GL.Attributes.Enable_Vertex_Attrib_Array (0);
Array_Buffer.Bind (Vertex_Buffer);
GL.Attributes.Set_Vertex_Attrib_Pointer (0, 3, Single_Type, 0, 0);
GL.Attributes.Enable_Vertex_Attrib_Array (1);
Array_Buffer.Bind (Normals_Buffer);
GL.Attributes.Set_Vertex_Attrib_Pointer (1, 3, Single_Type, 0, 0);
if Part = Back_Part or Part = Front_Part then
if Part = Back_Part and then Get_Draw_Mode.Orientation then
GL.Rasterization.Set_Polygon_Mode (GL.Rasterization.Line);
end if;
GL.Objects.Vertex_Arrays.Draw_Arrays (Mode => Triangle_Fan,
First => 0,
Count => VB_Size);
else -- Outline part
GL.Objects.Vertex_Arrays.Draw_Arrays (Mode => Line_Loop,
First => 0,
Count => Num_Steps);
if Draw_Hooks then
GL.Objects.Vertex_Arrays.Draw_Arrays (Mode => Lines,
First => Num_Steps,
Count => 12);
end if;
end if;
GL.Attributes.Disable_Vertex_Attrib_Array (0);
GL.Attributes.Disable_Vertex_Attrib_Array (1);
end; -- declare block
end Draw_Part;
begin
Shader_Manager.Set_Model_Matrix (Identity4);
if (Method = Draw_Bivector_Circle) and then
(Palet_Type = Is_Null or
Palet.Foreground_Alpha (Palet_Type) > 0.0000001) then
Draw_Part (Back_Part);
Draw_Part (Front_Part);
end if;
if Palet_Type /= Is_Null then
Set_Outline_Colour (Palet_Type);
end if;
Draw_Part (Outline_Part);
exception
when others =>
Put_Line ("An exception occurred in GA_Draw.Draw_Circle.");
raise;
end Draw_Circle;
-- ------------------------------------------------------------------------
procedure Draw_Cone (Render_Program : GL.Objects.Programs.Program;
Scale : Float) is
use GL.Objects.Buffers;
use GA_Maths.Float_Functions;
Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object;
Vertex_Buffer : GL.Objects.Buffers.Buffer;
S_Scale : constant Single := Single (5.0 / Scale);
Z : float := 0.0;
Num_Steps : constant int := 256;
Rotor_Step : constant float :=
2.0 * Ada.Numerics.Pi / float (Num_Steps);
Fan : Singles.Vector3_Array (1 .. Num_Steps);
begin
Vertex_Array.Initialize_Id;
Vertex_Array.Bind;
Vertex_Buffer.Initialize_Id;
Fan (1) := (0.0, 0.0, 0.0);
for Count in 2 .. Num_Steps loop
Fan (Count) := (S_Scale * Single (Cos (Z)), S_Scale * Single (Sin (Z)), -0.25);
Z := Z + Rotor_Step;
end loop;
Array_Buffer.Bind (Vertex_Buffer);
Utilities.Load_Vertex_Buffer (Array_Buffer, Fan, Static_Draw);
GL.Objects.Programs.Use_Program (Render_Program);
-- Shader_Manager.Set_Model_Matrix (Model_Matrix);
GL.Attributes.Enable_Vertex_Attrib_Array (0);
GL.Attributes.Set_Vertex_Attrib_Pointer (0, 3, Single_Type, 0, 0);
GL.Objects.Vertex_Arrays.Draw_Arrays (Mode => Triangle_Fan,
First => 0,
Count => Num_Steps);
GL.Attributes.Disable_Vertex_Attrib_Array (0);
exception
when others =>
Put_Line ("An exception occurred in GA_Draw.Draw_Cone.");
raise;
end Draw_Cone;
-- ------------------------------------------------------------------------
procedure Draw_Line (Render_Program : GL.Objects.Programs.Program;
Direction : C3GA.Vector_E3;
Weight : Float := 1.0) is
use GL.Objects.Buffers;
use GL.Types.Singles;
use Shader_Manager;
Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object;
Vertex_Buffer : GL.Objects.Buffers.Buffer;
-- Scale_Constant and Step_Size are used for building Line_Strip
Scale_Constant : constant Single := Single (Palet.Line_Length); -- 6.0
Step_Size : constant Single := 0.1;
Step_Length : constant Single := Scale_Constant * Step_Size;
Num_Steps : constant Int := Int (2.0 / Step_Size + 0.5) + 1;
Num_Vertices : constant Int := Num_Steps + 1;
Length_Vertices : Singles.Vector3_Array (1 .. Num_Steps);
C_Steps : constant Int := Int (1.0 / Step_Size + 0.5) + 1;
C_Rotation_Matrix : Matrix4 := Identity4;
Rotation_Matrix : Matrix4 := Identity4;
Translation_Matrix : Matrix4 := Identity4;
Scale_Matrix : Matrix4 :=
Maths.Scaling_Matrix (Single (Weight));
Model_Matrix : Matrix4 := Identity4;
Z : Single := -Scale_Constant;
C : Single := 0.0;
Num_C_Vertices : constant Int := 3 * C_Steps + 1;
C_Vertices : Singles.Vector3_Array (1 .. Num_C_Vertices);
C_Index : Int := 0;
C_Vertex1 : constant Singles.Vector3 := (-0.25, 0.0, -1.0);
C_Vertex2 : constant Singles.Vector3 := (0.0, 0.0, 0.0);
C_Vertex3 : constant Singles.Vector3 := (0.25, 0.0, -1.0);
begin
-- aPoint and Direction are model coordinates
GL.Objects.Programs.Use_Program (Render_Program);
-- Utilities.Print_Vector ("GA_Draw.Draw_Line aPoint", aPoint);
-- Utilities.Print_Vector ("GA_Draw.Draw_Line Direction", Direction);
for index in 1 .. Num_Steps loop
Length_Vertices (index) := (0.0, 0.0, Z);
Z := Z + Step_Length;
end loop;
Vertex_Array.Initialize_Id;
Vertex_Array.Bind;
Vertex_Buffer.Initialize_Id;
Array_Buffer.Bind (Vertex_Buffer);
Utilities.Load_Vertex_Buffer (Array_Buffer, Length_Vertices, Static_Draw);
-- rotate e3 to line direction
Rotation_Matrix :=
GA_Maths.Vector_Rotation_Matrix ((0.0, 0.0, 1.0), Direction);
Set_Rotation_Matrix (Rotation_Matrix);
Set_Translation_Matrix (Translation_Matrix);
Model_Matrix := Scale_Matrix * Model_Matrix;
-- translate to point on line
-- Translation_Matrix :=
-- Maths.Translation_Matrix ((aPoint (GL.X), aPoint (GL.Y), aPoint (GL.Z)));
-- Model_Matrix := Translation_Matrix * Model_Matrix;
Set_Model_Matrix (Model_Matrix);
GL.Attributes.Enable_Vertex_Attrib_Array (0);
Array_Buffer.Bind (Vertex_Buffer);
GL.Attributes.Set_Vertex_Attrib_Pointer (0, 3, Single_Type, 0, 0);
GL.Objects.Vertex_Arrays.Draw_Arrays (Mode => Line_Strip,
First => 0, Count => Num_Vertices);
GL.Attributes.Disable_Vertex_Attrib_Array (0);
if Palet.Get_Draw_Mode.Orientation then
if Palet.Get_Draw_Mode.Magnitude then
Scale_Matrix :=
Maths.Scaling_Matrix (Single (0.5 * Abs (Weight)));
else
Scale_Matrix := Maths.Scaling_Matrix (0.5);
end if;
Set_Model_Matrix (Scale_Matrix);
Translation_Matrix :=
Maths.Translation_Matrix ((0.0, 0.0, -Scale_Constant));
while C < 1.0 loop
C_Index := C_Index + 1;
C_Vertices (C_Index) := C_Vertex1;
C_Index := C_Index + 1;
C_Vertices (C_Index) := C_Vertex2;
C_Index := C_Index + 1;
C_Vertices (C_Index) := C_Vertex3;
C := C + Step_Size;
Utilities.Load_Vertex_Buffer (Array_Buffer, C_Vertices, Static_Draw);
Set_Rotation_Matrix (C_Rotation_Matrix);
Set_Translation_Matrix (Translation_Matrix);
GL.Attributes.Set_Vertex_Attrib_Pointer (0, 3, Single_Type, 0, 0);
GL.Attributes.Enable_Vertex_Attrib_Array (0);
GL.Objects.Vertex_Arrays.Draw_Arrays
(Mode => Line_Strip, First => 0, Count => Num_C_Vertices);
GL.Attributes.Disable_Vertex_Attrib_Array (0);
C_Rotation_Matrix :=
Maths.Rotation_Matrix (Maths.Degree (90.0), (0.0, 0.0, 1.0));
Translation_Matrix :=
Maths.Translation_Matrix ((0.0, 0.0, 2.0 * Step_Length));
end loop;
end if;
exception
when others =>
Put_Line ("An exception occurred in GA_Draw.Draw_Line.");
raise;
end Draw_Line;
-- ------------------------------------------------------------------------
procedure Draw_Parallelepiped (Render_Program : GL.Objects.Programs.Program;
Model_Matrix : GL.Types.Singles.Matrix4;
MVC : Multivector_Analyze.E3_Vector_Array;
Scale : Float;
Method : Method_Type) is
use GL.Objects.Buffers;
use Singles;
Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object;
Vertex_Buffer : GL.Objects.Buffers.Buffer;
Normals_Buffer : GL.Objects.Buffers.Buffer;
Scale_Matrix : Matrix4;
Scale_Sign : GL.Types.Single;
Polygon : constant Ints.Vector4_Array (1 .. 6) :=
((0, 1, 5, 4),
(0, 4, 7, 3),
(4, 5, 6, 7),
(1, 2, 6, 5),
(6, 2, 3, 7),
(0, 3, 2, 1));
Vertex : Vector3_Array (1 .. 8) :=
(others => (others => 0.0));
GL_Vertices : Vector3_Array (1 .. 4) :=
(others => (others => 0.0));
aVertex : Vector3;
Vertex_Vectors : constant Ints.Vector3_Array (1 .. 8) :=
((-1, -1, -1), -- -
(0, -1, -1), -- 0
(0, 1, -1), -- 0 + 1
(1, -1, -1), -- 1
(2, -1, -1), -- 2
(0, 2, -1), -- 0 + 2
(0, 1, 2), -- 0 + 1 + 2
(1, 2, -1)); -- 1 + 2
Vertex_Index : Int := 0;
GL_Normals : Vector3_Array (1 .. 6) :=
(others => (others => 0.0));
V1 : E3GA.E3_Vector;
V2 : E3GA.E3_Vector;
V3 : E3GA.E3_Vector;
Stride : constant Int := 0;
begin
Vertex_Array.Initialize_Id;
Vertex_Array.Bind;
-- for index in 1 .. MVC'Length loop
-- VC (Int (index)) := E3GA.Get_Coords (MVC (index));
-- end loop;
if Scale >= 0.0 then
Scale_Sign := 1.0;
else
Scale_Sign := -1.0;
end if;
if Palet.Get_Draw_Mode.Orientation then
Scale_Matrix := Maths.Scaling_Matrix (Scale_Sign);
end if;
for Row in Int range 1 .. 8 loop
aVertex := (0.0, 0.0, 0.0);
for Col in GL.Index_Homogeneous range GL.X .. GL.Z loop
Vertex_Index := Vertex_Vectors (Row) (Col);
if Vertex_Index >= 0 then
aVertex := aVertex + MVC (Integer (Vertex_Index));
Vertex (Row) := aVertex;
end if;
end loop;
end loop;
for Index in GL_Normals'Range loop
V1 := Vertex (Polygon (Index) (GL.X));
V2 := Vertex (Polygon (Index) (GL.Y));
V3 := Vertex (Polygon (Index) (GL.W));
GL_Normals (Index) :=
(Scale_Sign * E3GA.Outer_Product ((V2 - V1), (V3 - V1)));
if Scale >= 0.0 then
for GL_Index in Int range 1 .. 3 loop
GL_Vertices (GL_Index) :=
Vertex (Polygon (Index)
(GL.Index_Homogeneous'Enum_Val (GL_Index)));
end loop;
else
for GL_Index in reverse Int range 3 .. 1 loop
GL_Vertices (GL_Index) :=
Vertex (Polygon (Index)
(GL.Index_Homogeneous'Enum_Val (GL_Index)));
end loop;
end if;
end loop;
Vertex_Buffer.Initialize_Id;
Array_Buffer.Bind (Vertex_Buffer);
Utilities.Load_Vertex_Buffer (Array_Buffer, GL_Vertices, Static_Draw);
Normals_Buffer.Initialize_Id;
Array_Buffer.Bind (Normals_Buffer);
Utilities.Load_Vertex_Buffer (Array_Buffer, GL_Normals, Static_Draw);
if Method = Draw_TV_Parellelepiped then
Draw_Parallelepiped
(Render_Program, Model_Matrix, MVC, Scale, Method);
end if;
GL.Objects.Programs.Use_Program (Render_Program);
Shader_Manager.Set_Ambient_Colour ((1.0, 1.0, 1.0, 1.0));
Shader_Manager.Set_Model_Matrix (Scale_Matrix * Model_Matrix);
GL.Attributes.Set_Vertex_Attrib_Pointer (0, 3, Single_Type, 0, 0);
GL.Attributes.Enable_Vertex_Attrib_Array (0);
GL.Attributes.Set_Vertex_Attrib_Pointer (1, 3, Single_Type, Stride, 0);
GL.Objects.Vertex_Arrays.Draw_Arrays (Mode => Lines,
First => 0,
Count => 1 * 3);
GL.Attributes.Disable_Vertex_Attrib_Array (0);
GL.Attributes.Disable_Vertex_Attrib_Array (1);
exception
when others =>
Put_Line ("An exception occurred in GA_Draw.Draw_Parallelepiped.");
raise;
end Draw_Parallelepiped;
-- ------------------------------------------------------------------------
-- Based on draw.cpp DrawState::drawSphere(e3ga::mv::Float normal)
procedure Draw_Sphere (Render_Program : GL.Objects.Programs.Program;
Normal : GL.Types.Single) is
use Geosphere;
Sphere : constant Geosphere.Geosphere := Palet.Current_Sphere;
begin
Count := Count + 1;
Geosphere.New_Sphere_List (Sphere);
-- gsDraw(m_sphere, 0.0f);
Put_Line ("GA_Draw.Draw_Sphere calling GS_Draw Count : " &
Integer'Image (Count));
Geosphere.GS_Draw (Render_Program, Sphere);
if Normal = 0.0 then
Draw_Sphere_List (Render_Program);
else
Geosphere.GS_Draw (Render_Program, Sphere, Normal);
end if;
exception
when others =>
Put_Line ("An exception occurred in GA_Draw.Draw_Sphere.");
raise;
end Draw_Sphere;
-- ------------------------------------------------------------------------
-- procedure Draw_Sphere (Render_Program : GL.Objects.Programs.Program;
-- Translation_Matrix, Projection_Matrix : GL.Types.Singles.Matrix4;
-- Normal : E3GA.Vector; Scale : float := 1.0;
-- Colour : GL.Types.Colors.Color) is
-- begin
-- if G_Draw_State.Max_Vertices = 0 then
-- Geosphere.GS_Compute (G_Draw_State.M_Sphere, 4);
-- end if;
-- exception
-- when others =>
-- Put_Line ("An exception occurred in GA_Draw.Draw_Line.");
-- raise;
-- end Draw_Sphere;
-- ------------------------------------------------------------------------
-- Based on draw.cpp drawTriVector
procedure Draw_Trivector (Render_Program : GL.Objects.Programs.Program;
Base : C3GA.Vector_E3;
Scale : float := 1.0;
Palet_Type : Palet.Colour_Palet;
Method : Method_Type := Draw_TV_Sphere) is
-- use GL.Types.Singles;
-- use Ada.Numerics.Elementary_Functions; -- needed for fractional powers
-- use GA_Maths;
-- Vector_Base : constant Singles.Vector3 := (0.0, 0.0, 0.0);
-- Scale_Sign : Float;
-- P_Scale : Float;
Normal : Single;
-- Base_Coords : constant GA_Maths.Float_3D := C3GA.Get_Coords (Base);
-- Translation : Singles.Vector3;
-- MV_Matrix : Matrix4 := Identity4;
begin
-- if Scale >= 0.0 then
-- Scale_Sign := 1.0;
-- else
-- Scale_Sign := -1.0;
-- end if;
if Method = Draw_TV_Parellelepiped or
Method = Draw_TV_Parellelepiped_No_Vectors then
Put_Line ("GA_Draw.Draw_Trivector, Draw_TV_Parellelepiped or Draw_TV_Parellelepiped_No_Vectors");
Draw_Trivector (Render_Program, Base, Scale,
Palet_Type, Draw_TV_Sphere) ;
-- P_Scale := Scale_Sign * ((Scale_Sign * Scale) ** 1.0 / 3.0);
-- else
-- P_Scale := Scale_Sign * ((Scale_Sign * Scale / (4.0 / 3.0 * GA_Maths.PI)) ** 1.0 / 3.0);
end if;
-- if C3GA.Norm_e2 (Base) /= 0.0 then
-- Translation := (Single (Base_Coords (1)), Single (Base_Coords (2)), Single (Base_Coords (3)));
-- MV_Matrix := Maths.Translation_Matrix (Translation) * MV_Matrix;
-- end if;
--
-- MV_Matrix := Maths.Scaling_Matrix (Single (P_Scale)) * MV_Matrix;
case Method is
when Draw_TV_Sphere =>
Put_Line ("GA_Draw.Draw_Trivector Draw_TV_Sphere.");
if Palet.Get_Draw_Mode.Orientation then
Normal := 0.1;
else
Normal := 0.0;
end if;
-- g_drawState.drawSphere (s)
Draw_Sphere (Render_Program, Normal);
when Draw_TV_Cross =>
Put_Line ("GA_Draw.Draw_Trivector Draw_TV_Cross.");
null;
when Draw_TV_Curly_Tail =>
Put_Line ("GA_Draw.Draw_Trivector Draw_TV_Curly_Tail.");
null;
when Draw_TV_Parellelepiped =>
Put_Line ("GA_Draw.Draw_Trivector Draw_TV_Parellelepiped.");
-- Draw_Vector (Render_Program => Render_Program,
-- Model_Matrix => MV_Matrix,
-- Tail => Vector_Base,
-- Direction => ,
-- Scale => );
when Draw_TV_Parellelepiped_No_Vectors =>
Put_Line ("GA_Draw.Draw_Trivector Draw_TV_Parellelepiped_No_Vectors.");
-- Draw_Parallelepiped (Render_Program, MV_Matrix, V, Scale,
-- Draw_TV_Parellelepiped_No_Vectors);
when others => null;
Put_Line ("GA_Draw.Draw_Trivector others.");
end case;
exception
when others =>
Put_Line ("An exception occurred in GA_Draw.Draw_Trivector.");
raise;
end Draw_Trivector;
-- ------------------------------------------------------------------------
procedure Draw_Trivector (Render_Program : GL.Objects.Programs.Program;
Base : C3GA.Vector_E3; Scale : float := 1.0;
V : Multivector_Analyze.E3_Vector_Array;
-- Palet_Type : Palet.Colour_Palet;
Method : Method_Type := Draw_TV_Sphere) is
use GL.Types.Singles;
use Ada.Numerics.Elementary_Functions; -- needed for fractional powers
use GA_Maths;
Scale_Sign : Float;
P_Scale : Float;
Normal : Single;
Base_Coords : constant GA_Maths.Float_3D := C3GA.Get_Coords (Base);
Translation : Singles.Vector3;
MV_Matrix : Matrix4 := Identity4;
begin
if Scale >= 0.0 then
Scale_Sign := 1.0;
else
Scale_Sign := -1.0;
end if;
if Method = Draw_TV_Parellelepiped or
Method = Draw_TV_Parellelepiped_No_Vectors then
Put_Line ("GA_Draw.Draw_Trivector, Draw_TV_Parellelepiped or Draw_TV_Parellelepiped_No_Vectors");
P_Scale := Scale_Sign * ((Scale_Sign * Scale) ** 1.0 / 3.0);
else
P_Scale := Scale_Sign * ((Scale_Sign * Scale / (4.0 / 3.0 * GA_Maths.PI)) ** 1.0 / 3.0);
end if;
if C3GA.Norm_e2 (Base) /= 0.0 then
Translation := (Single (Base_Coords (1)), Single (Base_Coords (2)), Single (Base_Coords (3)));
MV_Matrix := Maths.Translation_Matrix (Translation) * MV_Matrix;
end if;
MV_Matrix := Maths.Scaling_Matrix (Single (P_Scale)) * MV_Matrix;
case Method is
when Draw_TV_Sphere =>
Put_Line ("GA_Draw.Draw_Trivector Draw_TV_Sphere.");
if Palet.Get_Draw_Mode.Orientation then
Normal := 0.1;
else
Normal := 0.0;
end if;
-- g_drawState.drawSphere (s)
Draw_Sphere (Render_Program, Normal);
when Draw_TV_Cross =>
Put_Line ("GA_Draw.Draw_Trivector Draw_TV_Cross.");
null;
when Draw_TV_Curly_Tail =>
Put_Line ("GA_Draw.Draw_Trivector Draw_TV_Curly_Tail.");
null;
when Draw_TV_Parellelepiped =>
Put_Line ("GA_Draw.Draw_Trivector Draw_TV_Parellelepiped.");
Draw_Parallelepiped (Render_Program, MV_Matrix, V, Scale,
Draw_TV_Parellelepiped);
when Draw_TV_Parellelepiped_No_Vectors =>
Put_Line ("GA_Draw.Draw_Trivector Draw_TV_Parellelepiped_No_Vectors.");
-- Draw_Parallelepiped (Render_Program, MV_Matrix, V, Scale,
-- Draw_TV_Parellelepiped_No_Vectors);
when others => null;
Put_Line ("GA_Draw.Draw_Trivector others.");
end case;
exception
when others =>
Put_Line ("An exception occurred in GA_Draw.Draw_Trivector.");
raise;
end Draw_Trivector;
-- ------------------------------------------------------------------------
procedure Draw_Vector (Render_Program : GL.Objects.Programs.Program;
Tail, Direction : C3GA.Vector_E3;
Scale : float := 1.0) is
use GL.Culling;
use GL.Toggles;
use GL.Types.Singles;
use Multivectors;
use Maths.Single_Math_Functions;
Vertex_Array_Object : GL.Objects.Vertex_Arrays.Vertex_Array_Object;
MV_Matrix : Matrix4 := Identity4;
Dir_Coords : constant GA_Maths.Float_3D :=
C3GA.Get_Coords (Direction);
-- GL_Tail : constant Vector3 := GL_Util.To_GL (Tail);
-- GL_Dir : constant Vector3 := GL_Util.To_GL (Direction);
MV_Dir : constant Multivectors.M_Vector :=
New_Vector (Dir_Coords (1), Dir_Coords (2), Dir_Coords (3));
aRotor : Rotor;
Saved_Cull_Face : constant Face_Selector := Cull_Face;
Saved_Front_Face : constant GL.Types.Orientation := GL.Culling.Front_Face;
begin
if Scale /= 0.0 then
Vertex_Array_Object.Initialize_Id;
Vertex_Array_Object.Bind;
GL.Objects.Programs.Use_Program (Render_Program);
if C3GA.Norm_e2 (Tail) /= 0.0 then
MV_Matrix := Maths.Translation_Matrix (Tail) * MV_Matrix;
end if;
MV_Matrix := Maths.Scaling_Matrix (Single (Scale)) * MV_Matrix;
-- Draw the stick of the vector
Draw_Line (Render_Program, (0.98 * Direction (GL.X),
0.98 * Direction (GL.Y), 0.98 * Direction (GL.Z)), Scale);
-- Setup translation matrix for arrow head
-- rotate e3 to vector direction
MV_Matrix := Maths.Translation_Matrix (Direction) * MV_Matrix;
aRotor := E3GA_Utilities.Rotor_Vector_To_Vector
(Basis_Vector (Blade_Types.E3_e3), MV_Dir);
if Scale > 1.2 then
MV_Matrix := Maths.Scaling_Matrix (Single (1.2 / Scale)) * MV_Matrix;
MV_Matrix := Maths.Scaling_Matrix (1.1 / Sqrt (Single (Scale))) * MV_Matrix;
end if;
GL_Util.Rotor_GL_Multiply (aRotor, MV_Matrix);
if C3GA.Norm_e2 (Tail) /= 0.0 then
MV_Matrix := Maths.Translation_Matrix (Tail) * MV_Matrix;
end if;
-- Translate to head of vector
MV_Matrix := Maths.Translation_Matrix
(Single (Scale) * Direction) * MV_Matrix;
Shader_Manager.Set_Model_Matrix (MV_Matrix);
Enable (Cull_Face);
Set_Front_Face (GL.Types.Clockwise);
Set_Cull_Face (Front);
Draw_Cone (Render_Program, Scale);
Draw_Base (Render_Program, Scale);
Set_Front_Face (Saved_Front_Face);
Set_Cull_Face (Saved_Cull_Face);
end if;
exception
when others =>
Put_Line ("An exception occurred in GA_Draw.Draw_Vector.");
raise;
end Draw_Vector;
-- -----------------------------------------------------------------------
end GA_Draw;
|
pragma Style_Checks (Off);
-- This spec has been automatically generated from ATSAMD51G19A.svd
pragma Restrictions (No_Elaboration_Code);
with System;
-- Microchip ATSAMD51G19A Microcontroller
package SAM_SVD is
pragma Preelaborate;
--------------------
-- Base addresses --
--------------------
AC_Base : constant System.Address := System'To_Address (16#42002000#);
ADC0_Base : constant System.Address := System'To_Address (16#43001C00#);
ADC1_Base : constant System.Address := System'To_Address (16#43002000#);
AES_Base : constant System.Address := System'To_Address (16#42002400#);
CCL_Base : constant System.Address := System'To_Address (16#42003800#);
CMCC_Base : constant System.Address := System'To_Address (16#41006000#);
DAC_Base : constant System.Address := System'To_Address (16#43002400#);
DMAC_Base : constant System.Address := System'To_Address (16#4100A000#);
DSU_Base : constant System.Address := System'To_Address (16#41002000#);
EIC_Base : constant System.Address := System'To_Address (16#40002800#);
EVSYS_Base : constant System.Address := System'To_Address (16#4100E000#);
FREQM_Base : constant System.Address := System'To_Address (16#40002C00#);
GCLK_Base : constant System.Address := System'To_Address (16#40001C00#);
HMATRIX_Base : constant System.Address := System'To_Address (16#4100C000#);
ICM_Base : constant System.Address := System'To_Address (16#42002C00#);
MCLK_Base : constant System.Address := System'To_Address (16#40000800#);
NVMCTRL_Base : constant System.Address := System'To_Address (16#41004000#);
OSCCTRL_Base : constant System.Address := System'To_Address (16#40001000#);
OSC32KCTRL_Base : constant System.Address := System'To_Address (16#40001400#);
PAC_Base : constant System.Address := System'To_Address (16#40000000#);
PCC_Base : constant System.Address := System'To_Address (16#43002C00#);
PDEC_Base : constant System.Address := System'To_Address (16#42001C00#);
PM_Base : constant System.Address := System'To_Address (16#40000400#);
PORT_Base : constant System.Address := System'To_Address (16#41008000#);
QSPI_Base : constant System.Address := System'To_Address (16#42003400#);
RAMECC_Base : constant System.Address := System'To_Address (16#41020000#);
RSTC_Base : constant System.Address := System'To_Address (16#40000C00#);
RTC_Base : constant System.Address := System'To_Address (16#40002400#);
SDHC0_Base : constant System.Address := System'To_Address (16#45000000#);
SERCOM0_Base : constant System.Address := System'To_Address (16#40003000#);
SERCOM1_Base : constant System.Address := System'To_Address (16#40003400#);
SERCOM2_Base : constant System.Address := System'To_Address (16#41012000#);
SERCOM3_Base : constant System.Address := System'To_Address (16#41014000#);
SERCOM4_Base : constant System.Address := System'To_Address (16#43000000#);
SERCOM5_Base : constant System.Address := System'To_Address (16#43000400#);
SUPC_Base : constant System.Address := System'To_Address (16#40001800#);
TC0_Base : constant System.Address := System'To_Address (16#40003800#);
TC1_Base : constant System.Address := System'To_Address (16#40003C00#);
TC2_Base : constant System.Address := System'To_Address (16#4101A000#);
TC3_Base : constant System.Address := System'To_Address (16#4101C000#);
TCC0_Base : constant System.Address := System'To_Address (16#41016000#);
TCC1_Base : constant System.Address := System'To_Address (16#41018000#);
TCC2_Base : constant System.Address := System'To_Address (16#42000C00#);
TRNG_Base : constant System.Address := System'To_Address (16#42002800#);
USB_Base : constant System.Address := System'To_Address (16#41000000#);
WDT_Base : constant System.Address := System'To_Address (16#40002000#);
CoreDebug_Base : constant System.Address := System'To_Address (16#E000EDF0#);
DWT_Base : constant System.Address := System'To_Address (16#E0001000#);
ETM_Base : constant System.Address := System'To_Address (16#E0041000#);
FPU_Base : constant System.Address := System'To_Address (16#E000EF30#);
ITM_Base : constant System.Address := System'To_Address (16#E0000000#);
MPU_Base : constant System.Address := System'To_Address (16#E000ED90#);
NVIC_Base : constant System.Address := System'To_Address (16#E000E100#);
SysTick_Base : constant System.Address := System'To_Address (16#E000E010#);
SystemControl_Base : constant System.Address := System'To_Address (16#E000E000#);
TPI_Base : constant System.Address := System'To_Address (16#E0040000#);
end SAM_SVD;
|
with Ada.Exception_Identification.From_Here;
package body Ada.Sequential_IO is
use Exception_Identification.From_Here;
use type Streams.Stream_Element_Offset;
procedure Create (
File : in out File_Type;
Mode : File_Mode := Out_File;
Name : String := "";
Form : String := "") is
begin
Streams.Stream_IO.Create (
Streams.Stream_IO.File_Type (File),
Streams.Stream_IO.File_Mode (Mode),
Name,
Form);
end Create;
procedure Open (
File : in out File_Type;
Mode : File_Mode;
Name : String;
Form : String := "") is
begin
Streams.Stream_IO.Open (
Streams.Stream_IO.File_Type (File),
Streams.Stream_IO.File_Mode (Mode),
Name,
Form);
end Open;
procedure Close (File : in out File_Type) is
begin
Streams.Stream_IO.Close (Streams.Stream_IO.File_Type (File));
end Close;
procedure Delete (File : in out File_Type) is
begin
Streams.Stream_IO.Delete (Streams.Stream_IO.File_Type (File));
end Delete;
procedure Reset (File : in out File_Type; Mode : File_Mode) is
begin
Streams.Stream_IO.Reset (
Streams.Stream_IO.File_Type (File),
Streams.Stream_IO.File_Mode (Mode));
end Reset;
procedure Reset (File : in out File_Type) is
begin
Streams.Stream_IO.Reset (Streams.Stream_IO.File_Type (File));
end Reset;
function Mode (
File : File_Type)
return File_Mode is
begin
return File_Mode (
Streams.Stream_IO.Mode (
Streams.Stream_IO.File_Type (File))); -- checking the predicate
end Mode;
function Name (
File : File_Type)
return String is
begin
return Streams.Stream_IO.Name (
Streams.Stream_IO.File_Type (File)); -- checking the predicate
end Name;
function Form (
File : File_Type)
return String is
begin
return Streams.Stream_IO.Form (
Streams.Stream_IO.File_Type (File)); -- checking the predicate
end Form;
function Is_Open (File : File_Type) return Boolean is
begin
return Streams.Stream_IO.Is_Open (Streams.Stream_IO.File_Type (File));
end Is_Open;
procedure Flush (
File : File_Type) is
begin
Streams.Stream_IO.Flush (
Streams.Stream_IO.File_Type (File)); -- checking the predicate
end Flush;
procedure Read (
File : File_Type;
Item : out Element_Type)
is
Unit : constant := Streams.Stream_Element'Size;
Size : constant Streams.Stream_Element_Count :=
(Item'Size + Unit - 1) / Unit;
begin
if not Element_Type'Definite or else Element_Type'Has_Discriminants then
-- indefinite (or unconstrained) types
declare
Read_Size : Streams.Stream_Element_Offset;
begin
Streams.Stream_Element_Offset'Read (
Stream (File), -- checking the predicate
Read_Size);
declare
Item_As_SEA : Streams.Stream_Element_Array (1 .. Read_Size);
for Item_As_SEA'Address use Item'Address;
Last : Streams.Stream_Element_Offset;
begin
Streams.Stream_IO.Read (
Streams.Stream_IO.File_Type (File),
Item_As_SEA,
Last);
if Last < Item_As_SEA'Last then
Raise_Exception (Data_Error'Identity);
end if;
end;
end;
else
declare
Item_As_SEA : Streams.Stream_Element_Array (1 .. Size);
for Item_As_SEA'Address use Item'Address;
Last : Streams.Stream_Element_Offset;
begin
Streams.Stream_IO.Read (
Streams.Stream_IO.File_Type (File), -- checking the predicate
Item_As_SEA,
Last);
if Last < Item_As_SEA'Last then
Raise_Exception (End_Error'Identity);
end if;
end;
end if;
end Read;
procedure Write (
File : File_Type;
Item : Element_Type)
is
Unit : constant := Streams.Stream_Element'Size;
Size : constant Streams.Stream_Element_Count :=
(Item'Size + Unit - 1) / Unit;
begin
if not Element_Type'Definite or else Element_Type'Has_Discriminants then
-- indefinite (or unconstrained) types
Streams.Stream_Element_Offset'Write (
Stream (File), -- checking the predicate, or below
Size);
end if;
declare
Item_As_SEA : Streams.Stream_Element_Array (1 .. Size);
for Item_As_SEA'Address use Item'Address;
begin
Streams.Stream_IO.Write (
Streams.Stream_IO.File_Type (File), -- checking the predicate
Item_As_SEA);
end;
end Write;
function End_Of_File (
File : File_Type)
return Boolean
is
pragma Check (Dynamic_Predicate,
Check => Is_Open (File) or else raise Status_Error);
pragma Check (Dynamic_Predicate,
Check => Mode (File) = In_File or else raise Mode_Error);
begin
return Streams.Stream_IO.End_Of_File (
Streams.Stream_IO.File_Type (File));
end End_Of_File;
end Ada.Sequential_IO;
|
-- $Id: Idents.mi,v 1.8 1992/06/22 14:23:18 grosch rel $
-- $Log: Idents.mi,v $
-- Ich, Doktor Josef Grosch, Informatiker, Sept. 1994
with DynArray;
package body Idents is
cNoIdent : constant Integer := 0;
InitialTableSize: constant Integer := 512;
HashTableSize : constant Integer := 256;
type IdentTableEntry is record
StringRef : tStringRef;
Length : Integer;
Collision : tIdent;
end record;
subtype HashIndex is Integer range 0 .. HashTableSize;
package Int_Io is new Integer_IO (Integer); use Int_Io;
package Ident_DA is new DynArray (IdentTableEntry); use Ident_DA;
TablePtr : FlexArray;
IdentTableSize : Integer;
IdentCount : tIdent;
HashTable : array (HashIndex) of tIdent;
function MakeIdent (s: tString) return tIdent is
HashTableIndex : HashIndex;
CurIdent : tIdent;
l : constant Integer := Length (s);
begin
if l = 0 then -- hash
HashTableIndex := 0;
else
HashTableIndex := (Character'Pos (Element (s, 1)) +
Character'Pos (Element (s, l)) * 11 + l * 26) mod HashTableSize;
end if;
CurIdent := HashTable (HashTableIndex); -- search
while CurIdent /= cNoIdent loop
if (TablePtr (CurIdent).Length = l) and IsEqual (TablePtr (CurIdent).StringRef, s) then
return CurIdent; -- found
end if;
CurIdent := TablePtr(CurIdent).Collision;
end loop;
IdentCount := IdentCount + 1; -- not found: enter
if IdentCount = IdentTableSize then
ExtendArray (TablePtr, IdentTableSize);
end if;
TablePtr (IdentCount) := (
StringRef => PutString (s),
Length => l,
Collision => HashTable (HashTableIndex)
);
HashTable (HashTableIndex) := IdentCount;
return IdentCount;
end MakeIdent;
procedure GetString (i: tIdent; s: in out tString) is
begin
s := StringM.GetString (TablePtr (i).StringRef);
end GetString;
function GetStringRef (i: tIdent) return tStringRef is
begin
return TablePtr (i).StringRef;
end GetStringRef;
function MaxIdent return tIdent is
begin
return IdentCount;
end MaxIdent;
procedure WriteIdent (f: File_Type; i: tIdent) is
s : tString;
begin
GetString (i, s);
WriteS (f, s);
end WriteIdent;
procedure WriteIdents is
begin
for i in 1 .. IdentCount loop
Put (Standard_Output, i, 5);
Put (Standard_Output, ' ');
WriteIdent (Standard_Output, i);
New_Line (Standard_Output);
end loop;
end WriteIdents;
procedure WriteHashTable is
CurIdent : tIdent;
Count : Integer;
begin
for i in 0 .. HashTableSize loop
Put (Standard_Output, i, 5);
Count := 0;
CurIdent := HashTable (i);
while CurIdent /= cNoIdent loop
Count := Count;
CurIdent := TablePtr (CurIdent).Collision;
end loop;
Put (Standard_Output, Count, 5);
CurIdent := HashTable (i);
while CurIdent /= cNoIdent loop
Put (Standard_Output, ' ');
WriteIdent (Standard_Output, CurIdent);
CurIdent := TablePtr (CurIdent).Collision;
end loop;
New_Line (Standard_Output);
end loop;
New_Line (Standard_Output);
Put (Standard_Output, "Idents =");
Put (Standard_Output, IdentCount, 5);
New_Line (Standard_Output);
end WriteHashTable;
procedure InitIdents is
begin
HashTable := (0 .. HashTableSize => cNoIdent);
IdentCount := 0;
NoIdent := MakeIdent (NoString);
end InitIdents;
begin
IdentTableSize := InitialTableSize;
MakeArray (TablePtr, IdentTableSize);
InitIdents;
end Idents;
|
------------------------------------------------------------------------------
-- AGAR CORE LIBRARY --
-- A G A R . O B J E C T --
-- B o d y --
-- --
-- Copyright (c) 2018-2019, Julien Nadeau Carriere (vedge@csoft.net) --
-- Copyright (c) 2010, coreland (mark@coreland.ath.cx) --
-- --
-- Permission to use, copy, modify, and/or distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Agar.Error;
package body Agar.Object is
use Interfaces.C;
use Agar.Event;
function New_Object
(Parent : in Object_Access;
Name : in String;
Class : in Class_Not_Null_Access) return Object_Access
is
Ch_Name : aliased C.char_array := C.To_C(Name);
begin
return AG_ObjectNew
(Parent => Parent.all'Address,
Name => CS.To_Chars_Ptr(Ch_Name'Unchecked_Access),
Class => Class);
end;
function New_Object
(Parent : in Object_Access;
Class : in Class_Not_Null_Access) return Object_Access is
begin
return AG_ObjectNew
(Parent => Parent.all'Address,
Name => CS.Null_Ptr,
Class => Class);
end;
function New_Object
(Class : in Class_Not_Null_Access) return Object_Access is
begin
return AG_ObjectNew
(Parent => System.Null_Address,
Name => CS.Null_Ptr,
Class => Class);
end;
procedure Init_Object
(Object : in Object_Not_Null_Access;
Class : in Class_Not_Null_Access;
Static : in Boolean := False;
Name_On_Attach : in Boolean := False)
is
C_Flags : C.unsigned := 0;
begin
AG_ObjectInit (Object, Class);
C_Flags := Object.Flags;
if Static then
C_Flags := C_Flags or OBJECT_STATIC;
end if;
if Name_On_Attach then
C_Flags := C_Flags or OBJECT_NAME_ON_ATTACH;
end if;
Object.Flags := C_Flags;
end;
procedure Attach
(Parent : in Object_Access;
Child : in Object_not_null_Access)
is
begin
AG_ObjectAttach
(Parent => Parent,
Child => Child);
end;
function Find
(Root : in Object_Not_Null_Access;
Path : in String) return Object_Access
is
Ch_Path : aliased C.char_array := C.To_C(Path);
begin
return AG_ObjectFindS
(Root => Root,
Path => CS.To_Chars_Ptr(Ch_Path'Unchecked_Access));
end;
function Find_Parent
(Object : in Object_Not_Null_Access;
Name : in String;
Class : in String) return Object_Access
is
Ch_Name : aliased C.char_array := C.To_C(Name);
Ch_Class : aliased C.char_array := C.To_C(Class);
begin
return AG_ObjectFindParent
(Object => Object,
Name => CS.To_Chars_Ptr(Ch_Name'Unchecked_Access),
Class => CS.To_Chars_Ptr(Ch_Class'Unchecked_Access));
end;
function Find_Child
(Parent : in Object_Not_Null_Access;
Name : in String) return Object_Access
is
Ch_Name : aliased C.char_array := C.To_C(Name);
begin
return AG_ObjectFindChild
(Parent => Parent,
Name => CS.To_Chars_Ptr(Ch_Name'Unchecked_Access));
end;
function Get_Name (Object : in Object_Not_Null_Access) return String
is
Ch_Name : aliased C.char_array (0 .. C.size_t(HIERARCHY_MAX));
Result : C.int;
begin
Result := AG_ObjectCopyName
(Object => Object,
Buffer => Ch_Name'Address,
Size => Ch_Name'Length);
if Integer(Result) /= 0 then
raise Program_Error with Agar.Error.Get_Error;
end if;
return C.To_Ada(Ch_Name);
end;
procedure Set_Name
(Object : in Object_Not_Null_Access;
Name : in String)
is
Ch_Name : aliased C.char_array := C.To_C(Name);
begin
AG_ObjectSetNameS
(Object => Object,
Name => CS.To_Chars_Ptr(Ch_Name'Unchecked_Access));
end;
function Generate_Name
(Object : in Object_Not_Null_Access;
Class : in Class_Not_Null_Access) return String
is
Ch_Name : aliased C.char_array (0 .. C.size_t(NAME_MAX));
begin
AG_ObjectGenName
(Object => Object,
Class => Class,
Buffer => Ch_Name'Address,
Size => Ch_Name'Length);
return C.To_Ada(Ch_Name);
end;
function Generate_Name
(Object : in Object_Not_Null_Access;
Prefix : in String) return String
is
Ch_Name : aliased C.char_array (0 .. C.size_t(NAME_MAX));
Ch_Prefix : aliased C.char_array := C.To_C(Prefix);
begin
AG_ObjectGenNamePfx
(Object => Object,
Prefix => CS.To_Chars_Ptr(Ch_Prefix'Unchecked_Access),
Buffer => Ch_Name'Address,
Size => Ch_Name'Length);
return C.To_Ada(Ch_Name);
end;
procedure Register_Namespace
(Name : in String;
Prefix : in String;
URL : in String)
is
Ch_Name : aliased C.char_array := C.To_C(Name);
Ch_Prefix : aliased C.char_array := C.To_C(Prefix);
Ch_URL : aliased C.char_array := C.To_C(URL);
begin
AG_RegisterNamespace
(Name => CS.To_Chars_Ptr(Ch_Name'Unchecked_Access),
Prefix => CS.To_Chars_Ptr(Ch_Prefix'Unchecked_Access),
URL => CS.To_Chars_Ptr(Ch_URL'Unchecked_Access));
end;
procedure Unregister_Namespace
(Name : in String)
is
Ch_Name : aliased C.char_array := C.To_C(Name);
begin
AG_UnregisterNamespace(CS.To_Chars_Ptr(Ch_Name'Unchecked_Access));
end;
function Create_Class
(Hierarchy : in String;
Object_Size : in Natural;
Class_Size : in Natural;
Major : in Natural := 1;
Minor : in Natural := 0;
Init_Func : in Init_Func_Access := null;
Reset_Func : in Reset_Func_Access := null;
Destroy_Func : in Destroy_Func_Access := null;
Load_Func : in Load_Func_Access := null;
Save_Func : in Save_Func_Access := null;
Edit_Func : in Edit_Func_Access := null) return Class_Not_Null_Access
is
Ch_Hierarchy : aliased C.char_array := C.To_C(Hierarchy);
Class : Class_Access;
begin
Class := AG_CreateClass
(Hierarchy => CS.To_Chars_Ptr(Ch_Hierarchy'Unchecked_Access),
Object_Size => AG_Size(Object_Size / System.Storage_Unit),
Class_Size => AG_Size(Class_Size / System.Storage_Unit),
Major => C.unsigned(Major),
Minor => C.unsigned(Minor));
if Class = null then
raise Program_Error with Agar.Error.Get_Error;
end if;
if Init_Func /= null then AG_ClassSetInit (Class, Init_Func); end if;
if Reset_Func /= null then AG_ClassSetReset (Class, Reset_Func); end if;
if Destroy_Func /= null then AG_ClassSetDestroy (Class, Destroy_Func); end if;
if Load_Func /= null then AG_ClassSetLoad (Class, Load_Func); end if;
if Save_Func /= null then AG_ClassSetSave (Class, Save_Func); end if;
if Edit_Func /= null then AG_ClassSetEdit (Class, Edit_Func); end if;
return Class;
end Create_Class;
procedure Class_Set_Init
(Class : in Class_Not_Null_Access;
Init_Func : in Init_Func_Access) is
begin
AG_ClassSetInit(Class, Init_Func);
end;
function Class_Set_Init
(Class : in Class_Not_Null_Access;
Init_Func : in Init_Func_Access) return Init_Func_Access is
begin
return AG_ClassSetInit(Class, Init_Func);
end;
procedure Class_Set_Reset
(Class : in Class_Not_Null_Access;
Reset_Func : in Reset_Func_Access) is
begin
AG_ClassSetReset(Class, Reset_Func);
end;
function Class_Set_Reset
(Class : in Class_Not_Null_Access;
Reset_Func : in Reset_Func_Access) return Reset_Func_Access is
begin
return AG_ClassSetReset(Class, Reset_Func);
end;
procedure Class_Set_Destroy
(Class : in Class_Not_Null_Access;
Destroy_Func : in Destroy_Func_Access) is
begin
AG_ClassSetDestroy(Class, Destroy_Func);
end;
function Class_Set_Destroy
(Class : in Class_Not_Null_Access;
Destroy_Func : in Destroy_Func_Access) return Destroy_Func_Access is
begin
return AG_ClassSetDestroy(Class, Destroy_Func);
end;
procedure Class_Set_Load
(Class : in Class_Not_Null_Access;
Load_Func : in Load_Func_Access) is
begin
AG_ClassSetLoad(Class, Load_Func);
end;
function Class_Set_Load
(Class : in Class_Not_Null_Access;
Load_Func : in Load_Func_Access) return Load_Func_Access is
begin
return AG_ClassSetLoad(Class, Load_Func);
end;
procedure Class_Set_Save
(Class : in Class_Not_Null_Access;
Save_Func : in Save_Func_Access) is
begin
AG_ClassSetSave(Class, Save_Func);
end;
function Class_Set_Save
(Class : in Class_Not_Null_Access;
Save_Func : in Save_Func_Access) return Save_Func_Access is
begin
return AG_ClassSetSave(Class, Save_Func);
end;
procedure Class_Set_Edit
(Class : in Class_Not_Null_Access;
Edit_Func : in Edit_Func_Access) is
begin
AG_ClassSetEdit(Class, Edit_Func);
end;
function Class_Set_Edit
(Class : in Class_Not_Null_Access;
Edit_Func : in Edit_Func_Access) return Edit_Func_Access is
begin
return AG_ClassSetEdit(Class, Edit_Func);
end;
function Lookup_Class
(Class : in String) return Class_Access
is
Ch_Class : aliased C.char_array := C.To_C(Class);
begin
return AG_LookupClass
(Class => CS.To_Chars_Ptr(Ch_Class'Unchecked_Access));
end;
function Load_Class
(Class : in String) return Class_Access
is
Ch_Class : aliased C.char_array := C.To_C(Class);
begin
return AG_LoadClass
(Class => CS.To_Chars_Ptr(Ch_Class'Unchecked_Access));
end;
procedure Register_Module_Directory
(Path : in String)
is
Ch_Path : aliased C.char_array := C.To_C(Path);
begin
AG_RegisterModuleDirectory
(Path => CS.To_Chars_Ptr(Ch_Path'Unchecked_Access));
end;
procedure Unregister_Module_Directory
(Path : in String)
is
Ch_Path : aliased C.char_array := C.To_C(Path);
begin
AG_UnregisterModuleDirectory
(Path => CS.To_Chars_Ptr(Ch_Path'Unchecked_Access));
end;
function Is_Of_Class
(Object : in Object_Not_Null_Access;
Pattern : in String) return Boolean
is
Ch_Pattern : aliased C.char_array := C.To_C(Pattern);
begin
return AG_OfClass
(Object => Object,
Pattern => CS.To_Chars_Ptr(Ch_Pattern'Unchecked_Access)) = 1;
end;
function Is_A
(Object : in Object_Not_Null_Access;
Pattern : in String) return Boolean
is
Ch_Pattern : aliased C.char_array := C.To_C(Pattern);
begin
return AG_OfClass
(Object => Object,
Pattern => CS.To_Chars_Ptr(Ch_Pattern'Unchecked_Access)) = 1;
end;
function In_Use (Object : in Object_Not_Null_Access) return Boolean is
begin
return AG_ObjectInUse(Object) = 1;
end;
-------------------
-- Serialization --
-------------------
function Load (Object : in Object_Not_Null_Access) return Boolean is
begin
return AG_ObjectLoad(Object) = 0;
end;
function Load
(Object : in Object_Not_Null_Access;
File : in String) return Boolean
is
Ch_File : aliased C.char_array := C.To_C(File);
begin
return AG_ObjectLoadFromFile
(Object => Object,
File => CS.To_Chars_Ptr(Ch_File'Unchecked_Access)) = 0;
end;
function Load_Data (Object : in Object_Not_Null_Access) return Boolean is
begin
return AG_ObjectLoadData(Object) = 0;
end;
function Load_Data
(Object : in Object_Not_Null_Access;
File : in String) return Boolean
is
Ch_File : aliased C.char_array := C.To_C(File);
begin
return AG_ObjectLoadDataFromFile
(Object => Object,
File => CS.To_Chars_Ptr(Ch_File'Unchecked_Access)) = 0;
end;
function Load_Generic (Object : in Object_Not_Null_Access) return Boolean is
begin
return AG_ObjectLoadGeneric(Object) = 0;
end;
function Load_Generic
(Object : in Object_Not_Null_Access;
File : in String) return Boolean
is
Ch_File : aliased C.char_array := C.To_C(File);
begin
return AG_ObjectLoadGenericFromFile
(Object => Object,
File => CS.To_Chars_Ptr(Ch_File'Unchecked_Access)) = 0;
end;
function Save (Object : in Object_Not_Null_Access) return Boolean is
begin
return AG_ObjectSave(Object) = 0;
end;
function Save
(Object : in Object_Not_Null_Access;
File : in String) return Boolean
is
Ch_File : aliased C.char_array := C.To_C(File);
begin
return AG_ObjectSaveToFile
(Object => Object,
File => CS.To_Chars_Ptr(Ch_File'Unchecked_Access)) = 0;
end;
function Save_All (Object : in Object_Not_Null_Access) return Boolean is
begin
return AG_ObjectSaveAll(Object) = 0;
end;
function Serialize
(Object : in Object_Not_Null_Access;
Source : in DS.Data_Source_Not_Null_Access) return Boolean is
begin
return AG_ObjectSerialize(Object, Source) = 0;
end;
function Unserialize
(Object : in Object_Not_Null_Access;
Source : in DS.Data_Source_Not_Null_Access) return Boolean is
begin
return AG_ObjectUnserialize(Object, Source) = 0;
end;
function Read_Header
(Source : in DS.Data_Source_Not_Null_Access;
Header : in Header_Access) return Boolean is
begin
return AG_ObjectReadHeader (Source, Header) = 0;
end;
function Page_In
(Object : in Object_Not_Null_Access) return Boolean is
begin
return AG_ObjectPageIn (Object) = 0;
end;
function Page_Out
(Object : in Object_Not_Null_Access) return Boolean is
begin
return AG_ObjectPageOut (Object) = 0;
end;
------------
-- Events --
------------
function Set_Event
(Object : in Object_Not_Null_Access;
Event : in String;
Func : in Event_Func_Access;
Async : in Boolean := False;
Propagate : in Boolean := False) return Event_Not_Null_Access
is
Ch_Event : aliased C.char_array := C.To_C(Event);
Result : constant Event_Not_Null_Access := AG_SetEvent
(Object => Object,
Event => CS.To_Chars_Ptr(Ch_Event'Unchecked_Access),
Func => Func,
Format => CS.Null_Ptr);
begin
-- TODO Async, Propagate
return (Result);
end;
procedure Set_Event
(Object : in Object_Not_Null_Access;
Event : in String;
Func : in Event_Func_Access;
Async : in Boolean := False;
Propagate : in Boolean := False)
is
Ch_Event : aliased C.char_array := C.To_C(Event);
begin
AG_SetEvent
(Object => Object,
Event => CS.To_Chars_Ptr(Ch_Event'Unchecked_Access),
Func => Func,
Format => CS.Null_Ptr);
end;
function Add_Event
(Object : in Object_Not_Null_Access;
Event : in String;
Func : in Event_Func_Access;
Async : in Boolean := False;
Propagate : in Boolean := False) return Event_Not_Null_Access
is
Ch_Event : aliased C.char_array := C.To_C(Event);
Result : constant Event_Not_Null_Access := AG_AddEvent
(Object => Object,
Event => CS.To_Chars_Ptr(Ch_Event'Unchecked_Access),
Func => Func,
Format => CS.Null_Ptr);
begin
return (Result);
end;
procedure Add_Event
(Object : in Object_Not_Null_Access;
Event : in String;
Func : in Event_Func_Access;
Async : in Boolean := False;
Propagate : in Boolean := False)
is
Ch_Event : aliased C.char_array := C.To_C(Event);
begin
AG_AddEvent
(Object => Object,
Event => CS.To_Chars_Ptr(Ch_Event'Unchecked_Access),
Func => Func,
Format => CS.Null_Ptr);
end;
procedure Post_Event
(Object : in Object_Not_Null_Access;
Event : in String)
is
Ch_Event : aliased C.char_array := C.To_C(Event);
begin
AG_PostEvent
(Object => Object,
Event => CS.To_Chars_Ptr(Ch_Event'Unchecked_Access),
Format => CS.Null_Ptr);
end;
procedure Post_Event
(Object : in Object_Not_Null_Access;
Event : in Event_Not_Null_Access) is
begin
AG_PostEventByPtr
(Object => Object,
Event => Event,
Format => CS.Null_Ptr);
end;
procedure Debug
(Object : in Object_Access;
Message : in String)
is
Ch_Format : aliased C.char_array := C.To_C("%s");
Ch_Message : aliased C.char_array := C.To_C(Message);
begin
AG_Debug
(Object => Object,
Format => CS.To_Chars_Ptr(Ch_Format'Unchecked_Access),
Message => CS.To_Chars_Ptr(Ch_Message'Unchecked_Access));
end;
------------
-- Timers --
------------
function Add_Timer
(Object : in Object_Access;
Timer : in TMR.Timer_not_null_Access;
Interval : in Interfaces.Unsigned_32;
Func : in TMR.Timer_Callback) return Boolean
is
begin
return 0 = AG_AddTimer
(Object => Object,
Timer => Timer,
Interval => Interval,
Func => Func,
Flags => 0,
Format => CS.Null_Ptr);
end;
function Add_Timer
(Object : in Object_Access;
Interval : in Interfaces.Unsigned_32;
Func : in TMR.Timer_Callback) return TMR.Timer_Access
is
begin
return AG_AddTimerAuto
(Object => Object,
Interval => Interval,
Func => Func,
Format => CS.Null_Ptr);
end;
---------------
-- Variables --
---------------
function Defined
(Object : in Object_not_null_Access;
Variable : in String) return Boolean
is
Ch_Name : aliased C.char_array := C.To_C(Variable);
Result : C.int;
begin
Lock(Object);
Result := AG_Defined
(Object => Object,
Name => CS.To_Chars_Ptr(Ch_Name'Unchecked_Access));
Unlock(Object);
return Result = 1;
end;
--
-- Compare two variables with no dereference. Discrete types are compared
-- by value. Strings are compared case-sensitively. Reference types are
-- compared by their pointer value.
--
function "=" (Left, Right : in Variable_not_null_Access) return Boolean is
begin
return 0 = AG_CompareVariables (Left, Right);
end;
end Agar.Object;
|
with Ada.Integer_Text_IO, tools, Garden_Pkg;
use Ada.Integer_Text_IO, tools;
procedure main is
numberOfFields : Positive;
begin
Output.Puts("Number of fields: ", 0);
Get(numberOfFields);
declare
subtype Position is Positive range 1 .. numberOfFields;
package Garden is new Garden_Pkg(Position);
begin
Garden.Start;
end;
end main;
|
with display,Ada.Containers.Hashed_Maps ;
with Ada.Strings.Hash;
with Ada.text_io; use Ada.text_io;
package body snake_types is
function Hash_Func(Key : character) return Ada.Containers.Hash_Type is
begin
return Ada.Strings.Hash(Key'Image);
end Hash_Func;
end snake_types ;
|
package constants with SPARK_Mode is
BUFLEN : constant := 200;
type Arr_T is array (Natural range <>) of Integer;
subtype Data_Type is Arr_T;
subtype UBX_Data is Data_Type (0 .. 91);
UBX_SYNC1 : constant := 16#B5#;
UBX_SYNC2 : constant := 16#62#;
procedure Do_Something;
end constants;
|
pragma License (Unrestricted);
-- Ada 2012
with Ada.Characters.Conversions;
with Ada.Strings.Generic_Equal_Case_Insensitive;
function Ada.Strings.Equal_Case_Insensitive is
new Generic_Equal_Case_Insensitive (
Character,
String,
Characters.Conversions.Get);
-- pragma Pure (Ada.Strings.Equal_Case_Insensitive);
pragma Preelaborate (Ada.Strings.Equal_Case_Insensitive); -- use maps
|
-- 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 GL.API;
with GL.Helpers;
with GL.Low_Level;
with GL.Enums.Textures;
package body GL.Objects.Samplers is
procedure Bind (Object : Sampler; Unit : Textures.Texture_Unit) is
begin
API.Bind_Sampler.Ref (UInt (Unit), Object.Reference.GL_Id);
end Bind;
procedure Bind (Objects : Sampler_Array; First_Unit : Textures.Texture_Unit) is
Sampler_Ids : Low_Level.UInt_Array (Objects'Range);
begin
for Index in Objects'Range loop
Sampler_Ids (Index) := Objects (Index).Reference.GL_Id;
end loop;
API.Bind_Samplers.Ref (UInt (First_Unit), Sampler_Ids'Length, Sampler_Ids);
end Bind;
overriding
procedure Initialize_Id (Object : in out Sampler) is
New_Id : UInt := 0;
begin
API.Create_Samplers.Ref (1, New_Id);
Object.Reference.GL_Id := New_Id;
end Initialize_Id;
overriding
procedure Delete_Id (Object : in out Sampler) is
begin
API.Delete_Samplers.Ref (1, (1 => Object.Reference.GL_Id));
Object.Reference.GL_Id := 0;
end Delete_Id;
-----------------------------------------------------------------------------
-- Sampler Parameters --
-----------------------------------------------------------------------------
procedure Set_Minifying_Filter (Object : Sampler;
Filter : Minifying_Function) is
begin
API.Sampler_Parameter_Minifying_Function.Ref
(Object.Reference.GL_Id, Enums.Textures.Min_Filter, Filter);
end Set_Minifying_Filter;
function Minifying_Filter (Object : Sampler) return Minifying_Function is
Ret : Minifying_Function := Minifying_Function'First;
begin
API.Get_Sampler_Parameter_Minifying_Function.Ref
(Object.Reference.GL_Id, Enums.Textures.Min_Filter, Ret);
return Ret;
end Minifying_Filter;
procedure Set_Magnifying_Filter (Object : Sampler;
Filter : Magnifying_Function) is
begin
API.Sampler_Parameter_Magnifying_Function.Ref
(Object.Reference.GL_Id, Enums.Textures.Mag_Filter, Filter);
end Set_Magnifying_Filter;
function Magnifying_Filter (Object : Sampler) return Magnifying_Function is
Ret : Magnifying_Function := Magnifying_Function'First;
begin
API.Get_Sampler_Parameter_Magnifying_Function.Ref
(Object.Reference.GL_Id, Enums.Textures.Mag_Filter, Ret);
return Ret;
end Magnifying_Filter;
procedure Set_Minimum_LoD (Object : Sampler; Level : Double) is
begin
API.Sampler_Parameter_Float.Ref
(Object.Reference.GL_Id, Enums.Textures.Min_LoD, Single (Level));
end Set_Minimum_LoD;
function Minimum_LoD (Object : Sampler) return Double is
Ret : Low_Level.Single_Array (1 .. 1);
begin
API.Get_Sampler_Parameter_Floats.Ref
(Object.Reference.GL_Id, Enums.Textures.Min_LoD, Ret);
return Double (Ret (1));
end Minimum_LoD;
procedure Set_Maximum_LoD (Object : Sampler; Level : Double) is
begin
API.Sampler_Parameter_Float.Ref
(Object.Reference.GL_Id, Enums.Textures.Max_LoD, Single (Level));
end Set_Maximum_LoD;
function Maximum_LoD (Object : Sampler) return Double is
Ret : Low_Level.Single_Array (1 .. 1);
begin
API.Get_Sampler_Parameter_Floats.Ref
(Object.Reference.GL_Id, Enums.Textures.Max_LoD, Ret);
return Double (Ret (1));
end Maximum_LoD;
procedure Set_LoD_Bias (Object : Sampler; Level : Double) is
begin
API.Sampler_Parameter_Float.Ref
(Object.Reference.GL_Id, Enums.Textures.LoD_Bias, Single (Level));
end Set_LoD_Bias;
function LoD_Bias (Object : Sampler) return Double is
Ret : Low_Level.Single_Array (1 .. 1);
begin
API.Get_Sampler_Parameter_Floats.Ref
(Object.Reference.GL_Id, Enums.Textures.LoD_Bias, Ret);
return Double (Ret (1));
end LoD_Bias;
procedure Set_Seamless_Filtering (Object : Sampler; Enable : Boolean) is
begin
API.Sampler_Parameter_Bool.Ref
(Object.Reference.GL_Id, Enums.Textures.Cube_Map_Seamless,
Low_Level.Bool (Enable));
end Set_Seamless_Filtering;
function Seamless_Filtering (Object : Sampler) return Boolean is
Result : Low_Level.Bool := Low_Level.Bool'First;
begin
API.Get_Sampler_Parameter_Bool.Ref
(Object.Reference.GL_Id, Enums.Textures.Cube_Map_Seamless, Result);
return Boolean (Result);
end Seamless_Filtering;
procedure Set_Max_Anisotropy (Object : Sampler; Degree : Double) is
begin
API.Sampler_Parameter_Float.Ref
(Object.Reference.GL_Id, Enums.Textures.Max_Anisotropy, Single (Degree));
end Set_Max_Anisotropy;
function Max_Anisotropy (Object : Sampler) return Double is
Ret : Low_Level.Single_Array (1 .. 1);
begin
API.Get_Sampler_Parameter_Floats.Ref
(Object.Reference.GL_Id, Enums.Textures.Max_Anisotropy, Ret);
return Double (Ret (1));
end Max_Anisotropy;
procedure Set_X_Wrapping (Object : Sampler; Mode : Wrapping_Mode) is
begin
API.Sampler_Parameter_Wrapping_Mode.Ref
(Object.Reference.GL_Id, Enums.Textures.Wrap_S, Mode);
end Set_X_Wrapping;
function X_Wrapping (Object : Sampler) return Wrapping_Mode is
Ret : Wrapping_Mode := Wrapping_Mode'First;
begin
API.Get_Sampler_Parameter_Wrapping_Mode.Ref
(Object.Reference.GL_Id, Enums.Textures.Wrap_S, Ret);
return Ret;
end X_Wrapping;
procedure Set_Y_Wrapping (Object : Sampler; Mode : Wrapping_Mode) is
begin
API.Sampler_Parameter_Wrapping_Mode.Ref
(Object.Reference.GL_Id, Enums.Textures.Wrap_T, Mode);
end Set_Y_Wrapping;
function Y_Wrapping (Object : Sampler) return Wrapping_Mode is
Ret : Wrapping_Mode := Wrapping_Mode'First;
begin
API.Get_Sampler_Parameter_Wrapping_Mode.Ref
(Object.Reference.GL_Id, Enums.Textures.Wrap_T, Ret);
return Ret;
end Y_Wrapping;
procedure Set_Z_Wrapping (Object : Sampler; Mode : Wrapping_Mode) is
begin
API.Sampler_Parameter_Wrapping_Mode.Ref
(Object.Reference.GL_Id, Enums.Textures.Wrap_R, Mode);
end Set_Z_Wrapping;
function Z_Wrapping (Object : Sampler) return Wrapping_Mode is
Ret : Wrapping_Mode := Wrapping_Mode'First;
begin
API.Get_Sampler_Parameter_Wrapping_Mode.Ref
(Object.Reference.GL_Id, Enums.Textures.Wrap_R, Ret);
return Ret;
end Z_Wrapping;
procedure Set_Border_Color (Object : Sampler; Color : Colors.Border_Color) is
Raw : constant Low_Level.Single_Array
:= Helpers.Float_Array (Colors.Vulkan_To_OpenGL (Color));
begin
API.Sampler_Parameter_Floats.Ref
(Object.Reference.GL_Id, Enums.Textures.Border_Color, Raw);
end Set_Border_Color;
function Border_Color (Object : Sampler) return Colors.Border_Color is
Raw : Low_Level.Single_Array (1 .. 4);
begin
API.Get_Sampler_Parameter_Floats.Ref
(Object.Reference.GL_Id, Enums.Textures.Border_Color, Raw);
return Colors.OpenGL_To_Vulkan (Helpers.Color (Raw));
end Border_Color;
procedure Set_Compare_X_To_Texture (Object : Sampler; Enabled : Boolean) is
Value : Enums.Textures.Compare_Kind;
begin
if Enabled then
Value := Enums.Textures.Compare_R_To_Texture;
else
Value := Enums.Textures.None;
end if;
API.Sampler_Parameter_Compare_Kind.Ref
(Object.Reference.GL_Id, Enums.Textures.Compare_Mode, Value);
end Set_Compare_X_To_Texture;
function Compare_X_To_Texture_Enabled (Object : Sampler) return Boolean is
use type Enums.Textures.Compare_Kind;
Value : Enums.Textures.Compare_Kind := Enums.Textures.Compare_Kind'First;
begin
API.Get_Sampler_Parameter_Compare_Kind.Ref
(Object.Reference.GL_Id, Enums.Textures.Compare_Mode, Value);
return Value = Enums.Textures.Compare_R_To_Texture;
end Compare_X_To_Texture_Enabled;
procedure Set_Compare_Function (Object : Sampler; Func : Compare_Function) is
begin
API.Sampler_Parameter_Compare_Function.Ref
(Object.Reference.GL_Id, Enums.Textures.Compare_Func, Func);
end Set_Compare_Function;
function Current_Compare_Function (Object : Sampler) return Compare_Function is
Value : Compare_Function := Compare_Function'First;
begin
API.Get_Sampler_Parameter_Compare_Function.Ref
(Object.Reference.GL_Id, Enums.Textures.Compare_Func, Value);
return Value;
end Current_Compare_Function;
end GL.Objects.Samplers;
|
package body System.Formatting.Decimal is
pragma Suppress (All_Checks);
use type Long_Long_Integer_Types.Long_Long_Unsigned;
subtype Word_Unsigned is Long_Long_Integer_Types.Word_Unsigned;
subtype Long_Long_Unsigned is Long_Long_Integer_Types.Long_Long_Unsigned;
-- implementation
procedure Image (
Value : Long_Long_Integer;
Item : out String;
Fore_Last, Last : out Natural;
Scale : Integer;
Signs : Sign_Marks := ('-', ' ', ' ');
Fore_Digits_Width : Positive := 1;
Fore_Digits_Fill : Character := '0';
Aft_Width : Natural)
is
Abs_Value : Long_Long_Unsigned;
Error : Boolean;
begin
Last := Item'First - 1;
declare
Sign : Character;
begin
if Value < 0 then
Abs_Value := -Long_Long_Unsigned'Mod (Value);
Sign := Signs.Minus;
else
Abs_Value := Long_Long_Unsigned (Value);
if Value > 0 then
Sign := Signs.Plus;
else
Sign := Signs.Zero;
end if;
end if;
if Sign /= No_Sign then
Last := Last + 1;
pragma Assert (Last <= Item'Last);
Item (Last) := Sign;
end if;
end;
if Scale > 0 then
declare
Rounded_Item : Long_Long_Unsigned := Abs_Value;
Sp : constant Long_Long_Unsigned := 10 ** Scale;
Q : Long_Long_Unsigned;
Aft : Long_Long_Unsigned;
Error : Boolean;
begin
if Aft_Width < Scale then
Rounded_Item := Rounded_Item + (10 ** (Scale - Aft_Width)) / 2;
end if;
Long_Long_Integer_Types.Divide (Rounded_Item, Sp, Q, Aft);
if Long_Long_Integer'Size <= Word_Unsigned'Size then
Formatting.Image (
Word_Unsigned (Q),
Item (Last + 1 .. Item'Last),
Last,
Width => Fore_Digits_Width,
Fill => Fore_Digits_Fill,
Error => Error);
else
Formatting.Image (
Q,
Item (Last + 1 .. Item'Last),
Last,
Width => Fore_Digits_Width,
Fill => Fore_Digits_Fill,
Error => Error);
end if;
pragma Assert (not Error);
Fore_Last := Last;
if Aft_Width > 0 then
Last := Last + 1;
pragma Assert (Last <= Item'Last);
Item (Last) := '.';
if Aft_Width > Scale then
Aft := Aft * 10 ** (Aft_Width - Scale);
elsif Aft_Width < Scale then
Aft := Aft / 10 ** (Scale - Aft_Width);
end if;
if Long_Long_Integer'Size <= Word_Unsigned'Size then
Formatting.Image (
Word_Unsigned (Aft),
Item (Last + 1 .. Item'Last),
Last,
Width => Aft_Width,
Error => Error);
else
Formatting.Image (
Aft,
Item (Last + 1 .. Item'Last),
Last,
Width => Aft_Width,
Error => Error);
end if;
pragma Assert (not Error);
end if;
end;
else
if Abs_Value /= 0 then
if Long_Long_Integer'Size <= Standard'Word_Size then
Formatting.Image (
Word_Unsigned (Abs_Value),
Item (Last + 1 .. Item'Last),
Last,
Width => Fore_Digits_Width,
Fill => Fore_Digits_Fill,
Error => Error);
else
Formatting.Image (
Abs_Value,
Item (Last + 1 .. Item'Last),
Last,
Width => Fore_Digits_Width,
Fill => Fore_Digits_Fill,
Error => Error);
end if;
pragma Assert (not Error);
pragma Assert (Last - Scale <= Item'Last);
Fill_Padding (Item (Last + 1 .. Last - Scale), '0');
Last := Last - Scale;
else
pragma Assert (Last + Fore_Digits_Width <= Item'Last);
Fill_Padding (
Item (Last + 1 .. Last + Fore_Digits_Width - 1),
Fore_Digits_Fill);
Last := Last + Fore_Digits_Width; -- including '0'
Item (Last) := '0';
end if;
Fore_Last := Last;
if Aft_Width > 0 then
Last := Last + 1;
pragma Assert (Last <= Item'Last);
Item (Last) := '.';
pragma Assert (Last + Aft_Width <= Item'Last);
Fill_Padding (Item (Last + 1 .. Last + Aft_Width), '0');
Last := Last + Aft_Width;
end if;
end if;
end Image;
end System.Formatting.Decimal;
|
with base_iface; use base_iface;
generic
type Base is tagged limited private;
package generic_mixin is
type Derived is new Base and The_Interface with null record;
overriding procedure simple (Self : Derived);
overriding procedure compound (Self : Derived);
overriding procedure redispatching(Self : Derived);
end generic_mixin;
|
package body Turing is
function List_To_String(L: List; Map: Symbol_Map) return String is
LL: List := L;
use type List;
begin
if L = Symbol_Lists.Empty_List then
return "";
else
LL.Delete_First;
return Map(L.First_Element) & List_To_String(LL, Map);
end if;
end List_To_String;
function To_String(Tape: Tape_Type; Map: Symbol_Map) return String is
begin
return List_To_String(Tape.Left, Map) & Map(Tape.Here) &
List_To_String(Tape.Right, Map);
end To_String;
function Position_To_String(Tape: Tape_Type; Marker: Character := '^')
return String is
Blank_Map: Symbol_Map := (others => ' ');
begin
return List_To_String(Tape.Left, Blank_Map) & Marker &
List_To_String(Tape.Right, Blank_Map);
end Position_To_String;
function To_Tape(Str: String; Map: Symbol_Map) return Tape_Type is
Char_Map: array(Character) of Symbol := (others => Blank);
Tape: Tape_Type;
begin
if Str = "" then
Tape.Here := Blank;
else
for S in Symbol loop
Char_Map(Map(S)) := S;
end loop;
Tape.Here := Char_Map(Str(Str'First));
for I in Str'First+1 .. Str'Last loop
Tape.Right.Append(Char_Map(Str(I)));
end loop;
end if;
return Tape;
end To_Tape;
procedure Single_Step(Current: in out State;
Tape: in out Tape_Type;
Rules: Rules_Type) is
Act: Action := Rules(Current, Tape.Here);
use type List; -- needed to compare Tape.Left/Right to the Empty_List
begin
Current := Act.New_State; -- 1. update State
Tape.Here := Act.New_Symbol; -- 2. write Symbol to Tape
case Act.Move_To is -- 3. move Tape to the Left/Right or Stay
when Left =>
Tape.Right.Prepend(Tape.Here);
if Tape.Left /= Symbol_Lists.Empty_List then
Tape.Here := Tape.Left.Last_Element;
Tape.Left.Delete_Last;
else
Tape.Here := Blank;
end if;
when Stay =>
null; -- Stay where you are!
when Right =>
Tape.Left.Append(Tape.Here);
if Tape.Right /= Symbol_Lists.Empty_List then
Tape.Here := Tape.Right.First_Element;
Tape.Right.Delete_First;
else
Tape.Here := Blank;
end if;
end case;
end Single_Step;
procedure Run(The_Tape: in out Tape_Type;
Rules: Rules_Type;
Max_Steps: Natural := Natural'Last;
Print: access procedure (Tape: Tape_Type; Current: State)) is
The_State: State := Start;
Steps: Natural := 0;
begin
Steps := 0;
while (Steps <= Max_Steps) and (The_State /= Halt) loop
if Print /= null then
Print(The_Tape, The_State);
end if;
Steps := Steps + 1;
Single_Step(The_State, The_Tape, Rules);
end loop;
if The_State /= Halt then
raise Constraint_Error;
end if;
end Run;
end Turing;
|
-- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
with Ada.Containers;
with Text.Pool;
with Yaml.Tags;
limited with Yaml.Dom.Node;
package Yaml.Dom is
type Document_Reference is tagged private;
type Node_Kind is (Scalar, Sequence, Mapping);
type Node_Reference is tagged private;
type Optional_Node_Reference is tagged private;
type Accessor (Data : not null access Node.Instance) is limited private
with Implicit_Dereference => Data;
subtype Count_Type is Ada.Containers.Count_Type;
No_Document : constant Document_Reference;
No_Node : constant Optional_Node_Reference;
-----------------------------------------------------------------------------
-- constructors and comparators --
-----------------------------------------------------------------------------
-- uses the given pool for all text content
function New_Document (Pool : Text.Pool.Reference :=
Text.Pool.With_Capacity (Text.Pool.Default_Size);
Implicit_Start, Implicit_End : Boolean := True)
return Document_Reference;
function New_Scalar (Parent : Document_Reference'Class;
Content : String := "";
Tag : Text.Reference := Yaml.Tags.Question_Mark;
Style : Scalar_Style_Type := Any) return Node_Reference;
function New_Scalar (Parent : Document_Reference'Class;
Content : Text.Reference;
Tag : Text.Reference := Yaml.Tags.Question_Mark;
Style : Scalar_Style_Type := Any) return Node_Reference;
function New_Sequence (Parent : Document_Reference'Class;
Tag : Text.Reference := Yaml.Tags.Question_Mark;
Style : Collection_Style_Type := Any)
return Node_Reference;
function New_Mapping (Parent : Document_Reference'Class;
Tag : Text.Reference := Yaml.Tags.Question_Mark;
Style : Collection_Style_Type := Any)
return Node_Reference;
function "=" (Left, Right : Document_Reference) return Boolean;
-- checks whether the content of two nodes is identical
function "=" (Left, Right : Node_Reference) return Boolean;
-- checks whether the two references reference the same node
function Same_Node (Left, Right : Node_Reference) return Boolean;
-----------------------------------------------------------------------------
-- data access --
-----------------------------------------------------------------------------
function Is_Empty (Object : Document_Reference) return Boolean;
function Root (Object : Document_Reference'Class) return Node_Reference
with Pre => not Is_Empty (Object);
procedure Set_Root (Object : Document_Reference;
Value : Node_Reference'Class);
procedure Set_Root (Object : Document_Reference;
Value : Optional_Node_Reference'Class);
function Starts_Implicitly (Object : Document_Reference) return Boolean;
function Ends_Implicitly (Object : Document_Reference) return Boolean;
procedure Set_Representation_Hints (Object : Document_Reference;
Implicit_Start, Implicit_End : Boolean);
function Value (Object : Node_Reference) return Accessor;
function Value (Object : Optional_Node_Reference) return Accessor;
function Required (Object : Optional_Node_Reference'Class) return Node_Reference;
function Optional (Object : Node_Reference'Class) return Optional_Node_Reference;
private
type Node_Pointer is not null access all Node.Instance;
function Nodes_Equal (Left, Right : access Node.Instance) return Boolean;
type Document_Instance is new Refcount_Base with record
Root_Node : access Node.Instance;
Pool : Text.Pool.Reference;
Implicit_Start, Implicit_End : Boolean;
end record;
type Document_Reference is new Ada.Finalization.Controlled with record
Data : not null access Document_Instance;
end record;
overriding procedure Adjust (Object : in out Document_Reference);
overriding procedure Finalize (Object : in out Document_Reference);
type Node_Reference is new Ada.Finalization.Controlled with record
Data : Node_Pointer;
Document : not null access Document_Instance;
end record;
overriding procedure Adjust (Object : in out Node_Reference);
overriding procedure Finalize (Object : in out Node_Reference);
type Optional_Node_Reference is new Ada.Finalization.Controlled with record
Data : access Node.Instance;
Document : access Document_Instance;
end record;
overriding procedure Adjust (Object : in out Optional_Node_Reference);
overriding procedure Finalize (Object : in out Optional_Node_Reference);
type Accessor (Data : not null access Node.Instance) is limited null record;
No_Document : constant Document_Reference :=
(Ada.Finalization.Controlled with Data =>
new Document_Instance'(Refcount_Base with
Root_Node => null, Pool => <>, Implicit_Start => True,
Implicit_End => True));
No_Node : constant Optional_Node_Reference :=
(Ada.Finalization.Controlled with Data => null, Document => null);
end Yaml.Dom;
|
--
-- This package provides few handlers for common types: strings,
-- integers and float. A separate package provides a generic
-- handler for enumerative types.
--
package Line_Parsers.Receivers is
type String_Receiver is new Abstract_Parameter_Handler with private;
overriding
function Is_Set(Handler: String_Receiver) return Boolean;
overriding
procedure Receive (Handler : in out String_Receiver;
Name : String;
Value : String;
Position : Natural);
overriding
function Reusable(Handler: String_Receiver) return Boolean;
function Value (Handler : String_Receiver) return String
with Pre => Handler.Is_Set;
type Integer_Receiver is new Abstract_Parameter_Handler with private;
overriding
function Is_Set (Handler : integer_Receiver) return Boolean;
overriding
procedure Receive (Handler : in out Integer_Receiver;
Name : String;
Value : String;
Position : Natural);
overriding
function Reusable (Handler : Integer_Receiver) return Boolean;
function Get (Handler : Integer_Receiver) return Integer
with Pre => Handler.Is_Set;
type Float_Receiver is new Abstract_Parameter_Handler with private;
overriding
function Is_Set (Handler : Float_Receiver) return Boolean;
procedure Receive (Handler : in out Float_Receiver;
Name : String;
Value : String;
Position : Natural);
function Get (Handler : Float_Receiver) return Float
with Pre => Handler.Is_Set;
overriding
function Reusable(Handler: Float_Receiver) return Boolean;
private
type String_Receiver is new Abstract_Parameter_Handler with
record
Set : Boolean := False;
Value : Unbounded_String;
end record;
function Is_Set (Handler : String_Receiver) return Boolean
is (Handler.Set);
function Value (Handler : String_Receiver) return String
is (To_String (Handler.Value));
function Reusable(Handler: String_Receiver) return Boolean
is (False);
type Integer_Receiver is new Abstract_Parameter_Handler with
record
Set : Boolean := False;
Value : Integer;
end record;
function Is_Set (Handler : Integer_Receiver) return Boolean
is (Handler.Set);
function Get (Handler : Integer_Receiver) return Integer
is (Handler.Value);
function Reusable(Handler: Integer_Receiver) return Boolean
is (False);
type Float_Receiver is new Abstract_Parameter_Handler with
record
Set : Boolean := False;
Value : Float;
end record;
function Is_Set (Handler : Float_Receiver) return Boolean
is (Handler.Set);
function Get (Handler : Float_Receiver) return Float
is (Handler.Value);
function Reusable(Handler: Float_Receiver) return Boolean
is (False);
end Line_Parsers.Receivers;
|
-----------------------------------------------------------------------
-- jason -- jason applications
-- Copyright (C) 2016, 2018, 2021 Stephane.Carrez
-- Written by Stephane.Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.IO_Exceptions;
with Util.Log.Loggers;
with Util.Properties;
with ASF.Applications;
with AWA.Applications.Factory;
package body Jason.Applications is
use AWA.Applications;
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Jason");
-- ------------------------------
-- Create the Jason application instance.
-- ------------------------------
function Create return Application_Access is
App : constant Application_Access := new Application;
begin
App.Self := App;
return App;
end Create;
-- ------------------------------
-- Initialize the application:
-- <ul>
-- <li>Register the servlets and filters.
-- <li>Register the application modules.
-- <li>Define the servlet and filter mappings.
-- </ul>
-- ------------------------------
procedure Initialize (App : in Application_Access) is
Fact : AWA.Applications.Factory.Application_Factory;
C : ASF.Applications.Config;
begin
App.Self := App;
begin
C.Load_Properties ("jason.properties");
Util.Log.Loggers.Initialize (Util.Properties.Manager (C));
exception
when Ada.IO_Exceptions.Name_Error =>
Log.Error ("Cannot read application configuration file {0}", CONFIG_PATH);
end;
App.Initialize (C, Fact);
App.Set_Global ("contextPath", CONTEXT_PATH);
end Initialize;
-- ------------------------------
-- Initialize the servlets provided by the application.
-- This procedure is called by <b>Initialize</b>.
-- It should register the application servlets.
-- ------------------------------
overriding
procedure Initialize_Servlets (App : in out Application) is
begin
Log.Info ("Initializing application servlets...");
AWA.Applications.Application (App).Initialize_Servlets;
App.Add_Servlet (Name => "faces", Server => App.Self.Faces'Access);
App.Add_Servlet (Name => "files", Server => App.Self.Files'Access);
App.Add_Servlet (Name => "ajax", Server => App.Self.Ajax'Access);
App.Add_Servlet (Name => "measures", Server => App.Self.Measures'Access);
App.Add_Servlet (Name => "auth", Server => App.Self.Auth'Access);
App.Add_Servlet (Name => "verify-auth", Server => App.Self.Verify_Auth'Access);
end Initialize_Servlets;
-- ------------------------------
-- Initialize the filters provided by the application.
-- This procedure is called by <b>Initialize</b>.
-- It should register the application filters.
-- ------------------------------
overriding
procedure Initialize_Filters (App : in out Application) is
begin
Log.Info ("Initializing application filters...");
AWA.Applications.Application (App).Initialize_Filters;
App.Add_Filter (Name => "dump", Filter => App.Self.Dump'Access);
App.Add_Filter (Name => "measures", Filter => App.Self.Measures'Access);
App.Add_Filter (Name => "service", Filter => App.Self.Service_Filter'Access);
end Initialize_Filters;
-- ------------------------------
-- Initialize the AWA modules provided by the application.
-- This procedure is called by <b>Initialize</b>.
-- It should register the modules used by the application.
-- ------------------------------
overriding
procedure Initialize_Modules (App : in out Application) is
begin
Log.Info ("Initializing application modules...");
Register (App => App.Self.all'Access,
Name => AWA.Users.Modules.NAME,
URI => "user",
Module => App.User_Module'Access);
Register (App => App.Self.all'Access,
Name => AWA.Workspaces.Modules.NAME,
URI => "workspaces",
Module => App.Workspace_Module'Access);
Register (App => App.Self.all'Access,
Name => AWA.Mail.Modules.NAME,
URI => "mail",
Module => App.Mail_Module'Access);
Register (App => App.Self.all'Access,
Name => AWA.Comments.Modules.NAME,
URI => "comments",
Module => App.Comment_Module'Access);
Register (App => App.Self.all'Access,
Name => AWA.Tags.Modules.NAME,
URI => "tags",
Module => App.Tag_Module'Access);
Register (App => App.Self.all'Access,
Name => AWA.Storages.Modules.NAME,
URI => "storages",
Module => App.Storage_Module'Access);
Register (App => App.Self.all'Access,
Name => Jason.Projects.Modules.NAME,
URI => "projects",
Module => App.Project_Module'Access);
Register (App => App.Self.all'Access,
Name => Jason.Tickets.Modules.NAME,
URI => "tickets",
Module => App.Ticket_Module'Access);
end Initialize_Modules;
end Jason.Applications;
|
-- { dg-do compile }
-- { dg-options "-gnatws" }
package body Aggr15 is
function CREATE return DATA_T is
D : DATA_T;
begin
return D;
end;
function ALL_CREATE return ALL_DATA_T is
C : constant ALL_DATA_T := (others => (others => Create));
begin
return C;
end;
end Aggr15;
|
------------------------------------------------------------------------------
-- --
-- Ada User Repository Annex (AURA) --
-- ANNEXI-STRAYLINE Reference Implementation --
-- --
-- Command Line Interface --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. --
-- All rights reserved. --
-- --
-- Original Contributors: --
-- * Richard Wai (ANNEXI-STRAYLINE) --
-- --
-- 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 copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A --
-- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
separate (Specification_Scanner)
procedure Scan_Subprogram
(Buffer : in out Ada_Lexical_Parser.Source_Buffer;
Unit_Tree : in out Declaration_Trees.Tree;
Subprogram_Node: in Declaration_Trees.Cursor)
is
use Ada_Lexical_Parser;
use Declaration_Trees;
package Toolkit is new Parse_Toolkit (Buffer); use Toolkit;
use type WWU.Unbounded_Wide_Wide_String;
This_Ent: Declared_Entity renames Unit_Tree(Subprogram_Node);
procedure Add_Parameter is
Parameter_Ent: Declared_Entity;
begin
Parameter_Ent.Kind := Object_Declaration;
Parameter_Ent.Name := Current_Element.Content;
Next_Element;
Assert_Syntax (Category = Delimiter and then Content = ":");
Next_Element;
while Category = Reserved_Word loop
Assert_Syntax (Content in
"in" | "out"
| "not" | "null" | "access"
| "aliased");
Next_Element;
end loop;
Assert_Syntax (Category = Identifier);
Load_Identifier (This_Ent.Subtype_Mark);
end Add_Parameter;
begin
This_Ent.Kind := Subprogram_Declaration;
Load_Identifier (This_Ent.Name);
Assert_Syntax (Category in Delimiter | Reserved_Word
and then Content in
";" | "(" | "return"
| "is" | "with" | "renames");
if Category = Delimiter and then Content = "(" then
-- Process parameters
loop
Add_Parameter;
Assert_Syntax (Category = Delimiter);
exit when Content = ")";
Assert_Syntax (Content = ";");
end loop;
Next_Element;
end if;
if Category = Delimiter and then Content = ";" then
return;
end if;
Assert_Syntax (Category in Reserved_Word
and then Content in "return" | "is" | "with" | "renames");
if Content = "return" then
-- Record the subtype mark
Next_Element;
Assert_Syntax (Category = Identifier);
Load_Identifier (This_Ent.Subtype_Mark);
end if;
if Category = Identifier and then Content = ";" then
return;
end if;
Assert_Syntax (Category = Reserved_Word
and then Content in "is" | "with" | "renames");
if Content = "is" then
-- Either a function expression or a null procedure. We allow either
-- without checking if it really is a function or a procedure because
-- this is just a scanner. We care about an "is" only because we want
-- to extract the expression
Next_Element;
Assert_Syntax
((Category = Delimiter and then Content = "(")
or else (Category = Reserved_Word and then Content = "null"));
if Content = "(" then
-- For ease of parsing, we will pull in the expression including
-- the surrouding parenthesis. This allivates us from needing to
-- track depth. We simply go until we hit "with" or ";".
This_Ent.Expression := Current_Element.Content;
loop
Next_Element;
exit when Category = Delimiter and then Content = ";";
exit when Category = Reserved_Word and then Content = "with";
This_Ent.Expression
:= This_Ent.Expression & Current_Element.Content;
end loop;
elsif Content = "null" then
Next_Element;
Assert_Syntax (Category = Delimiter and then Content = ";");
return;
end if;
end if;
if Category = Identifier and then Content = ";" then
return;
end if;
Assert_Syntax (Category = Reserved_Word
and then Content in "with" | "renames");
-- For renames, rename must come before "with"
-- Also, expression functions obviously cannot also be a rename
if Content = "renames" then
Assert_Syntax (WWU.Length (This_Ent.Expression) = 0);
This_Ent.Is_Renaming := True;
Next_Element;
Assert_Syntax (Category = Identifier);
Load_Identifier (This_Ent.Renamed_Entity_Name);
end if;
Assert_Syntax (Category = Reserved_Word and then Content = "with");
-- We're not interested in the aspect_specification part
Skip_To_Semicolon;
end Scan_Subprogram;
|
--
-- 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.
--
with Ada.Strings.Unbounded;
with Auxiliary;
package body Report_Parsers is
use Ada.Strings.Unbounded;
type Context_Record is
record
ARG : Unbounded_String;
CTX : Unbounded_String;
end record;
Global_Parser_Context : aliased Context_Record := (ARG => Null_Unbounded_String,
CTX => Null_Unbounded_String);
--
function Get_Context return Context_Access
is
begin
return Global_Parser_Context'Access;
end Get_Context;
function Get_ARG (Parser : in Context_Access) return String
is
begin
return To_String (Parser.ARG);
end Get_ARG;
function Get_CTX (Parser : in Context_Access) return String
is
begin
return To_String (Parser.CTX);
end Get_CTX;
procedure Trim_Right_Symbol (Item : in String;
Pos : out Natural)
is
S : String renames Item;
begin
Pos := S'Last;
-- Skip spaces
while Pos >= 1 and S (Pos - 1) = ' ' loop
Pos := Pos - 1;
end loop;
while Pos >= 1 and (Auxiliary.Is_Alnum (S (Pos - 1)) or S (Pos - 1) = '_') loop
Pos := Pos - 1;
end loop;
end Trim_Right_Symbol;
end Report_Parsers;
|
package body Ast_Printers is
function Print (The_Expr : Expr'Class) return String is
V : Ast_Printer;
begin
Accept_Visitor (The_Expr, V);
return Print (V);
end Print;
function Print (V : Ast_Printer) return String is
begin
return To_String (V.Image);
end Print;
function Print (The_Expr : Binary) return String is
begin
return "(" & To_String (The_Expr.Get_operator.Lexeme) & " "
& Print (Retrieve (The_Expr.Get_left)) & " "
& Print (Retrieve (The_Expr.Get_right)) & ")";
end Print;
function Print (The_Expr : Grouping) return String is
begin
return "(group " & Print (Retrieve (The_Expr.Get_expression)) & ")";
end Print;
function Print (The_Expr : Float_Literal) return String is
begin
return Float'Image (The_Expr.Get_value);
end Print;
function Print (The_Expr : Num_Literal) return String is
begin
return Integer'Image (The_Expr.Get_value);
end Print;
function Print (The_Expr : Str_Literal) return String is
begin
return L_Strings.To_String (The_Expr.Get_value);
end Print;
function Print (The_Expr : Unary) return String is
begin
return "(" & To_String (The_Expr.Get_operator.Lexeme) & " " & Print (Retrieve (The_Expr.Get_right)) & ")";
end Print;
generic
type Expr_Type (<>) is abstract new Expr with private;
with function Print (The_Expr : Expr_Type) return String is <>;
procedure Visit_Expr (V : in out Ast_Printer; The_Expr : Expr_Type);
procedure Visit_Expr (V : in out Ast_Printer; The_Expr : Expr_Type) is
function Local_Print (E : Expr_Type) return String
renames Print; -- resolve ambiguity
Image : constant String := Local_Print (The_Expr);
begin
V.Image := To_Bounded_String (Image);
end Visit_Expr;
procedure Do_Visit_Binary_Expr is new Visit_Expr (Binary);
overriding
procedure visit_Binary_Expr (Self : in out Ast_Printer; The_Expr : Binary)
renames Do_Visit_Binary_Expr;
procedure Do_Visit_Grouping_Expr is new Visit_Expr (Grouping);
overriding
procedure visit_Grouping_Expr (Self : in out Ast_Printer; The_Expr : Grouping)
renames Do_Visit_Grouping_Expr;
procedure Do_Visit_Float_Literal_Expr is new Visit_Expr (Float_Literal);
overriding
procedure visit_Float_Literal_Expr (Self : in out Ast_Printer; The_Expr : Float_Literal)
renames Do_Visit_Float_Literal_Expr;
procedure Do_Visit_Num_Literal_Expr is new Visit_Expr (Num_Literal);
overriding
procedure visit_Num_Literal_Expr (Self : in out Ast_Printer; The_Expr : Num_Literal)
renames Do_Visit_Num_Literal_Expr;
procedure Do_Visit_str_literal_Expr is new Visit_Expr (Str_Literal);
overriding
procedure visit_Str_Literal_Expr (Self : in out Ast_Printer; The_Expr : Str_Literal)
renames Do_Visit_str_literal_Expr;
procedure Do_Visit_unary_Expr is new Visit_Expr (Unary);
overriding
procedure visit_Unary_Expr (Self : in out Ast_Printer; The_Expr : Unary)
renames Do_Visit_unary_Expr;
end Ast_Printers;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- E X P _ P U T _ I M A G E --
-- --
-- B o d y --
-- --
-- Copyright (C) 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 Atree; use Atree;
with Einfo; use Einfo;
with Exp_Tss; use Exp_Tss;
with Exp_Util;
with Debug; use Debug;
with Lib; use Lib;
with Namet; use Namet;
with Nlists; use Nlists;
with Nmake; use Nmake;
with Opt; use Opt;
with Rtsfind; use Rtsfind;
with Sem_Aux; use Sem_Aux;
with Sem_Util; use Sem_Util;
with Sinfo; use Sinfo;
with Snames; use Snames;
with Stand;
with Tbuild; use Tbuild;
with Ttypes; use Ttypes;
with Uintp; use Uintp;
package body Exp_Put_Image is
Tagged_Put_Image_Enabled : Boolean renames Debug_Flag_Underscore_Z;
-- ???Set True to enable Put_Image for at least some tagged types
-----------------------
-- Local Subprograms --
-----------------------
procedure Build_Put_Image_Proc
(Loc : Source_Ptr;
Typ : Entity_Id;
Decl : out Node_Id;
Pnam : Entity_Id;
Stms : List_Id);
-- Build an array or record Put_Image procedure. Stms is the list of
-- statements for the body and Pnam is the name of the constructed
-- procedure. (The declaration list is always null.)
function Make_Put_Image_Name
(Loc : Source_Ptr; Typ : Entity_Id) return Entity_Id;
-- Return the entity that identifies the Put_Image subprogram for Typ. This
-- procedure deals with the difference between tagged types (where a single
-- subprogram associated with the type is generated) and all other cases
-- (where a subprogram is generated at the point of the attribute
-- reference). The Loc parameter is used as the Sloc of the created entity.
function Put_Image_Base_Type (E : Entity_Id) return Entity_Id;
-- Returns the base type, except for an array type whose whose first
-- subtype is constrained, in which case it returns the first subtype.
-------------------------------------
-- Build_Array_Put_Image_Procedure --
-------------------------------------
procedure Build_Array_Put_Image_Procedure
(Nod : Node_Id;
Typ : Entity_Id;
Decl : out Node_Id;
Pnam : out Entity_Id)
is
Loc : constant Source_Ptr := Sloc (Nod);
function Wrap_In_Loop
(Stms : List_Id;
Dim : Pos;
Index_Subtype : Entity_Id;
Between_Proc : RE_Id) return Node_Id;
-- Wrap Stms in a loop and if statement of the form:
--
-- if V'First (Dim) <= V'Last (Dim) then -- nonempty range?
-- declare
-- LDim : Index_Type_For_Dim := V'First (Dim);
-- begin
-- loop
-- Stms;
-- exit when LDim = V'Last (Dim);
-- Between_Proc (S);
-- LDim := Index_Type_For_Dim'Succ (LDim);
-- end loop;
-- end;
-- end if;
--
-- This is called once per dimension, from inner to outer.
function Wrap_In_Loop
(Stms : List_Id;
Dim : Pos;
Index_Subtype : Entity_Id;
Between_Proc : RE_Id) return Node_Id
is
Index : constant Entity_Id :=
Make_Defining_Identifier
(Loc, Chars => New_External_Name ('L', Dim));
Decl : constant Node_Id :=
Make_Object_Declaration (Loc,
Defining_Identifier => Index,
Object_Definition =>
New_Occurrence_Of (Index_Subtype, Loc),
Expression =>
Make_Attribute_Reference (Loc,
Prefix => Make_Identifier (Loc, Name_V),
Attribute_Name => Name_First,
Expressions => New_List (
Make_Integer_Literal (Loc, Dim))));
Loop_Stm : constant Node_Id :=
Make_Implicit_Loop_Statement (Nod, Statements => Stms);
Exit_Stm : constant Node_Id :=
Make_Exit_Statement (Loc,
Condition =>
Make_Op_Eq (Loc,
Left_Opnd => New_Occurrence_Of (Index, Loc),
Right_Opnd =>
Make_Attribute_Reference (Loc,
Prefix =>
Make_Identifier (Loc, Name_V),
Attribute_Name => Name_Last,
Expressions => New_List (
Make_Integer_Literal (Loc, Dim)))));
Increment : constant Node_Id :=
Make_Increment (Loc, Index, Index_Subtype);
Between : constant Node_Id :=
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of (RTE (Between_Proc), Loc),
Parameter_Associations => New_List
(Make_Identifier (Loc, Name_S)));
Block : constant Node_Id :=
Make_Block_Statement (Loc,
Declarations => New_List (Decl),
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc,
Statements => New_List (Loop_Stm)));
begin
Append_To (Stms, Exit_Stm);
Append_To (Stms, Between);
Append_To (Stms, Increment);
-- Note that we're appending to the Stms list passed in
return
Make_If_Statement (Loc,
Condition =>
Make_Op_Le (Loc,
Left_Opnd =>
Make_Attribute_Reference (Loc,
Prefix => Make_Identifier (Loc, Name_V),
Attribute_Name => Name_First,
Expressions => New_List (
Make_Integer_Literal (Loc, Dim))),
Right_Opnd =>
Make_Attribute_Reference (Loc,
Prefix => Make_Identifier (Loc, Name_V),
Attribute_Name => Name_Last,
Expressions => New_List (
Make_Integer_Literal (Loc, Dim)))),
Then_Statements => New_List (Block));
end Wrap_In_Loop;
Ndim : constant Pos := Number_Dimensions (Typ);
Ctyp : constant Entity_Id := Component_Type (Typ);
Stm : Node_Id;
Exl : constant List_Id := New_List;
PI_Entity : Entity_Id;
Indices : array (1 .. Ndim) of Entity_Id;
-- Start of processing for Build_Array_Put_Image_Procedure
begin
Pnam :=
Make_Defining_Identifier (Loc,
Chars => Make_TSS_Name_Local (Typ, TSS_Put_Image));
-- Get the Indices
declare
Index_Subtype : Node_Id := First_Index (Typ);
begin
for Dim in 1 .. Ndim loop
Indices (Dim) := Etype (Index_Subtype);
Next_Index (Index_Subtype);
end loop;
pragma Assert (No (Index_Subtype));
end;
-- Build the inner attribute call
for Dim in 1 .. Ndim loop
Append_To (Exl, Make_Identifier (Loc, New_External_Name ('L', Dim)));
end loop;
Stm :=
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Put_Image_Base_Type (Ctyp), Loc),
Attribute_Name => Name_Put_Image,
Expressions => New_List (
Make_Identifier (Loc, Name_S),
Make_Indexed_Component (Loc,
Prefix => Make_Identifier (Loc, Name_V),
Expressions => Exl)));
-- The corresponding attribute for the component type of the array might
-- be user-defined, and frozen after the array type. In that case,
-- freeze the Put_Image attribute of the component type, whose
-- declaration could not generate any additional freezing actions in any
-- case.
PI_Entity := TSS (Base_Type (Ctyp), TSS_Put_Image);
if Present (PI_Entity) and then not Is_Frozen (PI_Entity) then
Set_Is_Frozen (PI_Entity);
end if;
-- Loop through the dimensions, innermost first, generating a loop for
-- each dimension.
declare
Stms : List_Id := New_List (Stm);
begin
for Dim in reverse 1 .. Ndim loop
declare
New_Stms : constant List_Id := New_List;
Between_Proc : RE_Id;
begin
-- For a one-dimensional array of elementary type, use
-- RE_Simple_Array_Between. The same applies to the last
-- dimension of a multidimensional array.
if Is_Elementary_Type (Ctyp) and then Dim = Ndim then
Between_Proc := RE_Simple_Array_Between;
else
Between_Proc := RE_Array_Between;
end if;
Append_To (New_Stms,
Make_Procedure_Call_Statement (Loc,
Name => New_Occurrence_Of (RTE (RE_Array_Before), Loc),
Parameter_Associations => New_List
(Make_Identifier (Loc, Name_S))));
Append_To
(New_Stms,
Wrap_In_Loop (Stms, Dim, Indices (Dim), Between_Proc));
Append_To (New_Stms,
Make_Procedure_Call_Statement (Loc,
Name => New_Occurrence_Of (RTE (RE_Array_After), Loc),
Parameter_Associations => New_List
(Make_Identifier (Loc, Name_S))));
Stms := New_Stms;
end;
end loop;
Build_Put_Image_Proc (Loc, Typ, Decl, Pnam, Stms);
end;
end Build_Array_Put_Image_Procedure;
-------------------------------------
-- Build_Elementary_Put_Image_Call --
-------------------------------------
function Build_Elementary_Put_Image_Call (N : Node_Id) return Node_Id is
Loc : constant Source_Ptr := Sloc (N);
P_Type : constant Entity_Id := Entity (Prefix (N));
U_Type : constant Entity_Id := Underlying_Type (P_Type);
FST : constant Entity_Id := First_Subtype (U_Type);
Sink : constant Node_Id := First (Expressions (N));
Item : constant Node_Id := Next (Sink);
P_Size : constant Uint := Esize (FST);
Lib_RE : RE_Id;
begin
if Is_Signed_Integer_Type (U_Type) then
if P_Size <= Standard_Integer_Size then
Lib_RE := RE_Put_Image_Integer;
else
pragma Assert (P_Size <= Standard_Long_Long_Integer_Size);
Lib_RE := RE_Put_Image_Long_Long_Integer;
end if;
elsif Is_Modular_Integer_Type (U_Type) then
if P_Size <= Standard_Integer_Size then -- Yes, Integer
Lib_RE := RE_Put_Image_Unsigned;
else
pragma Assert (P_Size <= Standard_Long_Long_Integer_Size);
Lib_RE := RE_Put_Image_Long_Long_Unsigned;
end if;
elsif Is_Access_Type (U_Type) then
if Is_Access_Protected_Subprogram_Type (Base_Type (U_Type)) then
Lib_RE := RE_Put_Image_Access_Prot_Subp;
elsif Is_Access_Subprogram_Type (Base_Type (U_Type)) then
Lib_RE := RE_Put_Image_Access_Subp;
elsif P_Size = System_Address_Size then
Lib_RE := RE_Put_Image_Thin_Pointer;
else
pragma Assert (P_Size = 2 * System_Address_Size);
Lib_RE := RE_Put_Image_Fat_Pointer;
end if;
else
pragma Assert
(Is_Enumeration_Type (U_Type) or else Is_Real_Type (U_Type));
-- For other elementary types, generate:
--
-- Put_Wide_Wide_String (Sink, U_Type'Wide_Wide_Image (Item));
--
-- It would be more elegant to do it the other way around (define
-- '[[Wide_]Wide_]Image in terms of 'Put_Image). But this is easier
-- to implement, because we already have support for
-- 'Wide_Wide_Image. Furthermore, we don't want to remove the
-- existing support for '[[Wide_]Wide_]Image, because we don't
-- currently plan to support 'Put_Image on restricted runtimes.
-- We can't do this:
--
-- Put_UTF_8 (Sink, U_Type'Image (Item));
--
-- because we need to generate UTF-8, but 'Image for enumeration
-- types uses the character encoding of the source file.
--
-- Note that this is putting a leading space for reals.
declare
Image : constant Node_Id :=
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (U_Type, Loc),
Attribute_Name => Name_Wide_Wide_Image,
Expressions => New_List (Relocate_Node (Item)));
Put_Call : constant Node_Id :=
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of (RTE (RE_Put_Wide_Wide_String), Loc),
Parameter_Associations => New_List
(Relocate_Node (Sink), Image));
begin
return Put_Call;
end;
end if;
-- Unchecked-convert parameter to the required type (i.e. the type of
-- the corresponding parameter), and call the appropriate routine.
-- We could use a normal type conversion for scalars, but the
-- "unchecked" is needed for access and private types.
declare
Libent : constant Entity_Id := RTE (Lib_RE);
begin
return
Make_Procedure_Call_Statement (Loc,
Name => New_Occurrence_Of (Libent, Loc),
Parameter_Associations => New_List (
Relocate_Node (Sink),
Unchecked_Convert_To
(Etype (Next_Formal (First_Formal (Libent))),
Relocate_Node (Item))));
end;
end Build_Elementary_Put_Image_Call;
-------------------------------------
-- Build_String_Put_Image_Call --
-------------------------------------
function Build_String_Put_Image_Call (N : Node_Id) return Node_Id is
Loc : constant Source_Ptr := Sloc (N);
P_Type : constant Entity_Id := Entity (Prefix (N));
U_Type : constant Entity_Id := Underlying_Type (P_Type);
R : constant Entity_Id := Root_Type (U_Type);
Sink : constant Node_Id := First (Expressions (N));
Item : constant Node_Id := Next (Sink);
Lib_RE : RE_Id;
use Stand;
begin
if R = Standard_String then
Lib_RE := RE_Put_Image_String;
elsif R = Standard_Wide_String then
Lib_RE := RE_Put_Image_Wide_String;
elsif R = Standard_Wide_Wide_String then
Lib_RE := RE_Put_Image_Wide_Wide_String;
else
raise Program_Error;
end if;
-- Convert parameter to the required type (i.e. the type of the
-- corresponding parameter), and call the appropriate routine.
-- We set the Conversion_OK flag in case the type is private.
declare
Libent : constant Entity_Id := RTE (Lib_RE);
Conv : constant Node_Id :=
OK_Convert_To
(Etype (Next_Formal (First_Formal (Libent))),
Relocate_Node (Item));
begin
return
Make_Procedure_Call_Statement (Loc,
Name => New_Occurrence_Of (Libent, Loc),
Parameter_Associations => New_List (
Relocate_Node (Sink),
Conv));
end;
end Build_String_Put_Image_Call;
------------------------------------
-- Build_Protected_Put_Image_Call --
------------------------------------
-- For "Protected_Type'Put_Image (S, Protected_Object)", build:
--
-- Put_Image_Protected (S);
--
-- The protected object is not passed.
function Build_Protected_Put_Image_Call (N : Node_Id) return Node_Id is
Loc : constant Source_Ptr := Sloc (N);
Sink : constant Node_Id := First (Expressions (N));
Lib_RE : constant RE_Id := RE_Put_Image_Protected;
Libent : constant Entity_Id := RTE (Lib_RE);
begin
return
Make_Procedure_Call_Statement (Loc,
Name => New_Occurrence_Of (Libent, Loc),
Parameter_Associations => New_List (
Relocate_Node (Sink)));
end Build_Protected_Put_Image_Call;
------------------------------------
-- Build_Task_Put_Image_Call --
------------------------------------
-- For "Task_Type'Put_Image (S, Task_Object)", build:
--
-- Put_Image_Task (S, Task_Object'Identity);
--
-- The task object is not passed; its Task_Id is.
function Build_Task_Put_Image_Call (N : Node_Id) return Node_Id is
Loc : constant Source_Ptr := Sloc (N);
Sink : constant Node_Id := First (Expressions (N));
Item : constant Node_Id := Next (Sink);
Lib_RE : constant RE_Id := RE_Put_Image_Task;
Libent : constant Entity_Id := RTE (Lib_RE);
Task_Id : constant Node_Id :=
Make_Attribute_Reference (Loc,
Prefix => Relocate_Node (Item),
Attribute_Name => Name_Identity,
Expressions => No_List);
begin
return
Make_Procedure_Call_Statement (Loc,
Name => New_Occurrence_Of (Libent, Loc),
Parameter_Associations => New_List (
Relocate_Node (Sink),
Task_Id));
end Build_Task_Put_Image_Call;
--------------------------------------
-- Build_Record_Put_Image_Procedure --
--------------------------------------
-- The form of the record Put_Image procedure is as shown by the
-- following example:
-- procedure Put_Image (S : in out Sink'Class; V : Typ) is
-- begin
-- Component_Type'Put_Image (S, V.component);
-- Component_Type'Put_Image (S, V.component);
-- ...
-- Component_Type'Put_Image (S, V.component);
--
-- case V.discriminant is
-- when choices =>
-- Component_Type'Put_Image (S, V.component);
-- Component_Type'Put_Image (S, V.component);
-- ...
-- Component_Type'Put_Image (S, V.component);
--
-- when choices =>
-- Component_Type'Put_Image (S, V.component);
-- Component_Type'Put_Image (S, V.component);
-- ...
-- Component_Type'Put_Image (S, V.component);
-- ...
-- end case;
-- end Put_Image;
procedure Build_Record_Put_Image_Procedure
(Loc : Source_Ptr;
Typ : Entity_Id;
Decl : out Node_Id;
Pnam : out Entity_Id)
is
Btyp : constant Entity_Id := Base_Type (Typ);
pragma Assert (not Is_Unchecked_Union (Btyp));
First_Time : Boolean := True;
function Make_Component_List_Attributes (CL : Node_Id) return List_Id;
-- Returns a sequence of Component_Type'Put_Image attribute_references
-- to process the components that are referenced in the given component
-- list. Called for the main component list, and then recursively for
-- variants.
function Make_Component_Attributes (Clist : List_Id) return List_Id;
-- Given Clist, a component items list, construct series of
-- Component_Type'Put_Image attribute_references for componentwise
-- processing of the corresponding components. Called for the
-- discriminants, and then from Make_Component_List_Attributes for each
-- list (including in variants).
procedure Append_Component_Attr (Clist : List_Id; C : Entity_Id);
-- Given C, the entity for a discriminant or component, build a call to
-- Component_Type'Put_Image for the corresponding component value, and
-- append it onto Clist. Called from Make_Component_Attributes.
function Make_Component_Name (C : Entity_Id) return Node_Id;
-- Create a call that prints "Comp_Name => "
------------------------------------
-- Make_Component_List_Attributes --
------------------------------------
function Make_Component_List_Attributes (CL : Node_Id) return List_Id is
CI : constant List_Id := Component_Items (CL);
VP : constant Node_Id := Variant_Part (CL);
Result : List_Id;
Alts : List_Id;
V : Node_Id;
DC : Node_Id;
DCH : List_Id;
D_Ref : Node_Id;
begin
Result := Make_Component_Attributes (CI);
if Present (VP) then
Alts := New_List;
V := First_Non_Pragma (Variants (VP));
while Present (V) loop
DCH := New_List;
DC := First (Discrete_Choices (V));
while Present (DC) loop
Append_To (DCH, New_Copy_Tree (DC));
Next (DC);
end loop;
Append_To (Alts,
Make_Case_Statement_Alternative (Loc,
Discrete_Choices => DCH,
Statements =>
Make_Component_List_Attributes (Component_List (V))));
Next_Non_Pragma (V);
end loop;
-- Note: in the following, we use New_Occurrence_Of for the
-- selector, since there are cases in which we make a reference
-- to a hidden discriminant that is not visible.
D_Ref :=
Make_Selected_Component (Loc,
Prefix => Make_Identifier (Loc, Name_V),
Selector_Name =>
New_Occurrence_Of (Entity (Name (VP)), Loc));
Append_To (Result,
Make_Case_Statement (Loc,
Expression => D_Ref,
Alternatives => Alts));
end if;
return Result;
end Make_Component_List_Attributes;
--------------------------------
-- Append_Component_Attr --
--------------------------------
procedure Append_Component_Attr (Clist : List_Id; C : Entity_Id) is
Component_Typ : constant Entity_Id := Put_Image_Base_Type (Etype (C));
begin
if Ekind (C) /= E_Void then
Append_To (Clist,
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Component_Typ, Loc),
Attribute_Name => Name_Put_Image,
Expressions => New_List (
Make_Identifier (Loc, Name_S),
Make_Selected_Component (Loc,
Prefix => Make_Identifier (Loc, Name_V),
Selector_Name => New_Occurrence_Of (C, Loc)))));
end if;
end Append_Component_Attr;
-------------------------------
-- Make_Component_Attributes --
-------------------------------
function Make_Component_Attributes (Clist : List_Id) return List_Id is
Item : Node_Id;
Result : List_Id;
begin
Result := New_List;
if Present (Clist) then
Item := First (Clist);
-- Loop through components, skipping all internal components,
-- which are not part of the value (e.g. _Tag), except that we
-- don't skip the _Parent, since we do want to process that
-- recursively. If _Parent is an interface type, being abstract
-- with no components there is no need to handle it.
while Present (Item) loop
if Nkind (Item) in
N_Component_Declaration | N_Discriminant_Specification
and then
((Chars (Defining_Identifier (Item)) = Name_uParent
and then not Is_Interface
(Etype (Defining_Identifier (Item))))
or else
not Is_Internal_Name (Chars (Defining_Identifier (Item))))
then
if First_Time then
First_Time := False;
else
Append_To (Result,
Make_Procedure_Call_Statement (Loc,
Name =>
New_Occurrence_Of (RTE (RE_Record_Between), Loc),
Parameter_Associations => New_List
(Make_Identifier (Loc, Name_S))));
end if;
Append_To (Result, Make_Component_Name (Item));
Append_Component_Attr (Result, Defining_Identifier (Item));
end if;
Next (Item);
end loop;
end if;
return Result;
end Make_Component_Attributes;
-------------------------
-- Make_Component_Name --
-------------------------
function Make_Component_Name (C : Entity_Id) return Node_Id is
Name : constant Name_Id := Chars (Defining_Identifier (C));
begin
return
Make_Procedure_Call_Statement (Loc,
Name => New_Occurrence_Of (RTE (RE_Put_UTF_8), Loc),
Parameter_Associations => New_List
(Make_Identifier (Loc, Name_S),
Make_String_Literal (Loc, Get_Name_String (Name) & " => ")));
end Make_Component_Name;
Stms : constant List_Id := New_List;
Rdef : Node_Id;
Type_Decl : constant Node_Id :=
Declaration_Node (Base_Type (Underlying_Type (Btyp)));
-- Start of processing for Build_Record_Put_Image_Procedure
begin
Append_To (Stms,
Make_Procedure_Call_Statement (Loc,
Name => New_Occurrence_Of (RTE (RE_Record_Before), Loc),
Parameter_Associations => New_List
(Make_Identifier (Loc, Name_S))));
-- Generate Put_Images for the discriminants of the type
Append_List_To (Stms,
Make_Component_Attributes (Discriminant_Specifications (Type_Decl)));
Rdef := Type_Definition (Type_Decl);
-- In the record extension case, the components we want, including the
-- _Parent component representing the parent type, are to be found in
-- the extension. We will process the _Parent component using the type
-- of the parent.
if Nkind (Rdef) = N_Derived_Type_Definition then
Rdef := Record_Extension_Part (Rdef);
end if;
if Present (Component_List (Rdef)) then
Append_List_To (Stms,
Make_Component_List_Attributes (Component_List (Rdef)));
end if;
Append_To (Stms,
Make_Procedure_Call_Statement (Loc,
Name => New_Occurrence_Of (RTE (RE_Record_After), Loc),
Parameter_Associations => New_List
(Make_Identifier (Loc, Name_S))));
Pnam := Make_Put_Image_Name (Loc, Btyp);
Build_Put_Image_Proc (Loc, Btyp, Decl, Pnam, Stms);
end Build_Record_Put_Image_Procedure;
-------------------------------
-- Build_Put_Image_Profile --
-------------------------------
function Build_Put_Image_Profile
(Loc : Source_Ptr; Typ : Entity_Id) return List_Id
is
begin
return New_List (
Make_Parameter_Specification (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_S),
In_Present => True,
Out_Present => True,
Parameter_Type =>
New_Occurrence_Of (Class_Wide_Type (RTE (RE_Sink)), Loc)),
Make_Parameter_Specification (Loc,
Defining_Identifier => Make_Defining_Identifier (Loc, Name_V),
Parameter_Type => New_Occurrence_Of (Typ, Loc)));
end Build_Put_Image_Profile;
--------------------------
-- Build_Put_Image_Proc --
--------------------------
procedure Build_Put_Image_Proc
(Loc : Source_Ptr;
Typ : Entity_Id;
Decl : out Node_Id;
Pnam : Entity_Id;
Stms : List_Id)
is
Spec : constant Node_Id :=
Make_Procedure_Specification (Loc,
Defining_Unit_Name => Pnam,
Parameter_Specifications => Build_Put_Image_Profile (Loc, Typ));
begin
Decl :=
Make_Subprogram_Body (Loc,
Specification => Spec,
Declarations => Empty_List,
Handled_Statement_Sequence =>
Make_Handled_Sequence_Of_Statements (Loc,
Statements => Stms));
end Build_Put_Image_Proc;
------------------------------------
-- Build_Unknown_Put_Image_Call --
------------------------------------
function Build_Unknown_Put_Image_Call (N : Node_Id) return Node_Id is
Loc : constant Source_Ptr := Sloc (N);
Sink : constant Node_Id := First (Expressions (N));
Lib_RE : constant RE_Id := RE_Put_Image_Unknown;
Libent : constant Entity_Id := RTE (Lib_RE);
begin
return
Make_Procedure_Call_Statement (Loc,
Name => New_Occurrence_Of (Libent, Loc),
Parameter_Associations => New_List (
Relocate_Node (Sink),
Make_String_Literal (Loc,
Exp_Util.Fully_Qualified_Name_String (
Entity (Prefix (N)), Append_NUL => False))));
end Build_Unknown_Put_Image_Call;
----------------------
-- Enable_Put_Image --
----------------------
function Enable_Put_Image (Typ : Entity_Id) return Boolean is
begin
-- There's a bit of a chicken&egg problem. The compiler is likely to
-- have trouble if we refer to the Put_Image of Sink itself, because
-- Sink is part of the parameter profile:
--
-- function Sink'Put_Image (S : in out Sink'Class; V : T);
--
-- Likewise, the Ada.Strings.Text_Output package, where Sink is
-- declared, depends on various other packages, so if we refer to
-- Put_Image of types declared in those other packages, we could create
-- cyclic dependencies. Therefore, we disable Put_Image for some
-- types. It's not clear exactly what types should be disabled. Scalar
-- types are OK, even if predefined, because calls to Put_Image of
-- scalar types are expanded inline. We certainly want to be able to use
-- Integer'Put_Image, for example.
-- ???Temporarily disable to work around bugs:
--
-- Put_Image does not work for Remote_Types. We check the containing
-- package, rather than the type itself, because we want to include
-- types in the private part of a Remote_Types package.
--
-- Put_Image on tagged types triggers some bugs.
if Is_Remote_Types (Scope (Typ))
or else (Is_Tagged_Type (Typ) and then In_Predefined_Unit (Typ))
or else (Is_Tagged_Type (Typ) and then not Tagged_Put_Image_Enabled)
then
return False;
end if;
-- End of workarounds.
-- No sense in generating code for Put_Image if there are errors. This
-- avoids certain cascade errors.
if Total_Errors_Detected > 0 then
return False;
end if;
-- If type Sink is unavailable in this runtime, disable Put_Image
-- altogether.
if No_Run_Time_Mode or else not RTE_Available (RE_Sink) then
return False;
end if;
-- ???Disable Put_Image on type Sink declared in
-- Ada.Strings.Text_Output. Note that we can't call Is_RTU on
-- Ada_Strings_Text_Output, because it's not known yet (we might be
-- compiling it). But this is insufficient to allow support for tagged
-- predefined types.
declare
Parent_Scope : constant Entity_Id := Scope (Scope (Typ));
begin
if Present (Parent_Scope)
and then Is_RTU (Parent_Scope, Ada_Strings)
and then Chars (Scope (Typ)) = Name_Find ("text_output")
then
return False;
end if;
end;
-- Disable for CPP types, because the components are unavailable on the
-- Ada side.
if Is_Tagged_Type (Typ)
and then Convention (Typ) = Convention_CPP
and then Is_CPP_Class (Root_Type (Typ))
then
return False;
end if;
-- Disable for unchecked unions, because there is no way to know the
-- discriminant value, and therefore no way to know which components
-- should be printed.
if Is_Unchecked_Union (Typ) then
return False;
end if;
return True;
end Enable_Put_Image;
---------------------------------
-- Make_Put_Image_Name --
---------------------------------
function Make_Put_Image_Name
(Loc : Source_Ptr; Typ : Entity_Id) return Entity_Id
is
Sname : Name_Id;
begin
-- For tagged types, we are dealing with a TSS associated with the
-- declaration, so we use the standard primitive function name. For
-- other types, generate a local TSS name since we are generating
-- the subprogram at the point of use.
if Is_Tagged_Type (Typ) then
Sname := Make_TSS_Name (Typ, TSS_Put_Image);
else
Sname := Make_TSS_Name_Local (Typ, TSS_Put_Image);
end if;
return Make_Defining_Identifier (Loc, Sname);
end Make_Put_Image_Name;
function Image_Should_Call_Put_Image (N : Node_Id) return Boolean is
begin
if Ada_Version < Ada_2020 then
return False;
end if;
-- In Ada 2020, T'Image calls T'Put_Image if there is an explicit
-- aspect_specification for Put_Image, or if U_Type'Image is illegal
-- in pre-2020 versions of Ada.
declare
U_Type : constant Entity_Id := Underlying_Type (Entity (Prefix (N)));
begin
if Present (TSS (U_Type, TSS_Put_Image)) then
return True;
end if;
return not Is_Scalar_Type (U_Type);
end;
end Image_Should_Call_Put_Image;
function Build_Image_Call (N : Node_Id) return Node_Id is
-- For T'Image (X) Generate an Expression_With_Actions node:
--
-- do
-- S : Buffer := New_Buffer;
-- U_Type'Put_Image (S, X);
-- Result : constant String := Get (S);
-- Destroy (S);
-- in Result end
--
-- where U_Type is the underlying type, as needed to bypass privacy.
Loc : constant Source_Ptr := Sloc (N);
U_Type : constant Entity_Id := Underlying_Type (Entity (Prefix (N)));
Sink_Entity : constant Entity_Id :=
Make_Defining_Identifier (Loc, Chars => New_Internal_Name ('S'));
Sink_Decl : constant Node_Id :=
Make_Object_Declaration (Loc,
Defining_Identifier => Sink_Entity,
Object_Definition =>
New_Occurrence_Of (RTE (RE_Buffer), Loc),
Expression =>
Make_Function_Call (Loc,
Name => New_Occurrence_Of (RTE (RE_New_Buffer), Loc),
Parameter_Associations => Empty_List));
Put_Im : constant Node_Id :=
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (U_Type, Loc),
Attribute_Name => Name_Put_Image,
Expressions => New_List (
New_Occurrence_Of (Sink_Entity, Loc),
New_Copy_Tree (First (Expressions (N)))));
Result_Entity : constant Entity_Id :=
Make_Defining_Identifier (Loc, Chars => New_Internal_Name ('R'));
Result_Decl : constant Node_Id :=
Make_Object_Declaration (Loc,
Defining_Identifier => Result_Entity,
Object_Definition =>
New_Occurrence_Of (Stand.Standard_String, Loc),
Expression =>
Make_Function_Call (Loc,
Name => New_Occurrence_Of (RTE (RE_Get), Loc),
Parameter_Associations => New_List (
New_Occurrence_Of (Sink_Entity, Loc))));
Image : constant Node_Id :=
Make_Expression_With_Actions (Loc,
Actions => New_List (Sink_Decl, Put_Im, Result_Decl),
Expression => New_Occurrence_Of (Result_Entity, Loc));
begin
return Image;
end Build_Image_Call;
------------------
-- Preload_Sink --
------------------
procedure Preload_Sink (Compilation_Unit : Node_Id) is
begin
-- We can't call RTE (RE_Sink) for at least some predefined units,
-- because it would introduce cyclic dependences. The package where Sink
-- is declared, for example, and things it depends on.
--
-- It's only needed for tagged types, so don't do it unless Put_Image is
-- enabled for tagged types, and we've seen a tagged type. Note that
-- Tagged_Seen is set True by the parser if the "tagged" reserved word
-- is seen; this flag tells us whether we have any tagged types.
-- It's unfortunate to have this Tagged_Seen processing so scattered
-- about, but we need to know if there are tagged types where this is
-- called in Analyze_Compilation_Unit, before we have analyzed any type
-- declarations. This mechanism also prevents doing RTE (RE_Sink) when
-- compiling the compiler itself. Packages Ada.Strings.Text_Output and
-- friends are not included in the compiler.
--
-- Don't do it if type Sink is unavailable in the runtime.
if not In_Predefined_Unit (Compilation_Unit)
and then Tagged_Put_Image_Enabled
and then Tagged_Seen
and then not No_Run_Time_Mode
and then RTE_Available (RE_Sink)
then
declare
Ignore : constant Entity_Id := RTE (RE_Sink);
begin
null;
end;
end if;
end Preload_Sink;
-------------------------
-- Put_Image_Base_Type --
-------------------------
function Put_Image_Base_Type (E : Entity_Id) return Entity_Id is
begin
if Is_Array_Type (E) and then Is_First_Subtype (E) then
return E;
else
return Base_Type (E);
end if;
end Put_Image_Base_Type;
end Exp_Put_Image;
|
package Loop_Optimization11_Pkg is
function Img (X : Integer) return String;
procedure Put_Line (Data : String);
type Prot is (Execute, Execute_Read, Execute_Read_Write);
type Mem is (Mem_Image, Mem_Mapped, Mem_Private, Unknown);
end Loop_Optimization11_Pkg;
|
with Ada.Text_IO.Float_IO;
with Ada.Text_IO.Formatting;
package body Ada.Text_IO.Complex_IO is
package Real_IO is new Float_IO (Complex_Types.Real);
procedure Get_From_Field (
From : String;
Item : out Complex_Types.Complex;
Last : out Positive);
procedure Get_From_Field (
From : String;
Item : out Complex_Types.Complex;
Last : out Positive)
is
Paren : Boolean;
begin
Formatting.Get_Tail (From, Last);
Paren := From (Last) = '(';
if Paren then
Last := Last + 1;
end if;
Real_IO.Get (From (Last .. From'Last), Item.Re, Last);
Formatting.Get_Tail (From (Last + 1 .. From'Last), Last);
if From (Last) = ',' then
Last := Last + 1;
end if;
Real_IO.Get (From (Last .. From'Last), Item.Im, Last);
if Paren then
Formatting.Get_Tail (From (Last + 1 .. From'Last), Last);
if From (Last) /= ')' then
raise Data_Error;
end if;
end if;
end Get_From_Field;
-- implementation
procedure Get (
File : File_Type;
Item : out Complex_Types.Complex;
Width : Field := 0) is
begin
if Width /= 0 then
declare
S : String (1 .. Width);
Last_1 : Natural;
Last_2 : Natural;
begin
Formatting.Get_Field (File, S, Last_1); -- checking the predicate
Get_From_Field (S (1 .. Last_1), Item, Last_2);
if Last_2 /= Last_1 then
raise Data_Error;
end if;
end;
else
declare
S : constant String :=
Formatting.Get_Complex_Literal (File); -- checking the predicate
Last : Natural;
begin
Get_From_Field (S, Item, Last);
if Last /= S'Last then
raise Data_Error;
end if;
end;
end if;
end Get;
procedure Get (
Item : out Complex_Types.Complex;
Width : Field := 0) is
begin
Get (Current_Input.all, Item, Width);
end Get;
procedure Put (
File : File_Type;
Item : Complex_Types.Complex;
Fore : Field := Default_Fore;
Aft : Field := Default_Aft;
Exp : Field := Default_Exp) is
begin
Put (File, '('); -- checking the predicate
Real_IO.Put (File, Item.Re, Fore, Aft, Exp);
Put (File, ',');
Real_IO.Put (File, Item.Im, Fore, Aft, Exp);
Put (File, ')');
end Put;
procedure Put (
Item : Complex_Types.Complex;
Fore : Field := Default_Fore;
Aft : Field := Default_Aft;
Exp : Field := Default_Exp) is
begin
Put (Current_Output.all, Item, Fore, Aft, Exp);
end Put;
procedure Overloaded_Get (
From : String;
Item : out Complex_Types.Complex;
Last : out Positive)
renames Get_From_Field;
procedure Overloaded_Get (
From : Wide_String;
Item : out Complex_Types.Complex;
Last : out Positive)
is
String_From : String (From'Range);
begin
for I in From'Range loop
if Wide_Character'Pos (From (I)) < 16#80# then
String_From (I) := Character'Val (Wide_Character'Pos (From (I)));
else
String_From (I) := Character'Val (16#1A#); -- substitute
end if;
end loop;
Overloaded_Get (String_From, Item, Last);
end Overloaded_Get;
procedure Overloaded_Get (
From : Wide_Wide_String;
Item : out Complex_Types.Complex;
Last : out Positive)
is
String_From : String (From'Range);
begin
for I in From'Range loop
if Wide_Wide_Character'Pos (From (I)) < 16#80# then
String_From (I) :=
Character'Val (Wide_Wide_Character'Pos (From (I)));
else
String_From (I) := Character'Val (16#1A#); -- substitute
end if;
end loop;
Overloaded_Get (String_From, Item, Last);
end Overloaded_Get;
procedure Overloaded_Put (
To : out String;
Item : Complex_Types.Complex;
Aft : Field := Default_Aft;
Exp : Field := Default_Exp)
is
Index : Natural;
begin
if To'Length < (Aft + Exp) * 2 + 7 then -- "(0.,0.)"
raise Layout_Error;
end if;
To (To'First) := '(';
Real_IO.Put (To (To'First + 1 .. To'Last), Index, Item.Re, Aft, Exp);
Index := Index + 1;
if Index > To'Last then
raise Layout_Error;
end if;
To (Index) := ',';
Real_IO.Put (To (Index + 1 .. To'Last - 1), Item.Im, Aft, Exp);
To (To'Last) := ')';
end Overloaded_Put;
procedure Overloaded_Put (
To : out Wide_String;
Item : Complex_Types.Complex;
Aft : Field := Default_Aft;
Exp : Field := Default_Exp)
is
String_To : String (To'Range);
begin
Overloaded_Put (String_To, Item, Aft, Exp);
for I in To'Range loop
To (I) := Wide_Character'Val (Character'Pos (String_To (I)));
end loop;
end Overloaded_Put;
procedure Overloaded_Put (
To : out Wide_Wide_String;
Item : Complex_Types.Complex;
Aft : Field := Default_Aft;
Exp : Field := Default_Exp)
is
String_To : String (To'Range);
begin
Overloaded_Put (String_To, Item, Aft, Exp);
for I in To'Range loop
To (I) := Wide_Wide_Character'Val (Character'Pos (String_To (I)));
end loop;
end Overloaded_Put;
end Ada.Text_IO.Complex_IO;
|
with Ada.Containers.Indefinite_Ordered_Sets;
with Ada.Containers.Ordered_Sets;
package Partitions is
-- Argument type for Create_Partitions: Array of Numbers
type Arguments is array (Positive range <>) of Natural;
package Number_Sets is new Ada.Containers.Ordered_Sets
(Natural);
type Partition is array (Positive range <>) of Number_Sets.Set;
function "<" (Left, Right : Partition) return Boolean;
package Partition_Sets is new Ada.Containers.Indefinite_Ordered_Sets
(Partition);
function Create_Partitions (Args : Arguments) return Partition_Sets.Set;
end Partitions;
|
package openGL.Model.polygon
--
-- Provides an abstract class for polygon models.
--
is
type Item is abstract new Model.item with null record;
end openGL.Model.polygon;
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Containers.Ordered_Sets;
procedure Truncatable_Primes is
package Natural_Set is new Ada.Containers.Ordered_Sets (Natural);
use Natural_Set;
Primes : Set;
function Is_Prime (N : Natural) return Boolean is
Position : Cursor := First (Primes);
begin
while Has_Element (Position) loop
if N mod Element (Position) = 0 then
return False;
end if;
Position := Next (Position);
end loop;
return True;
end Is_Prime;
function Is_Left_Trucatable_Prime (N : Positive) return Boolean is
M : Natural := 1;
begin
while Contains (Primes, N mod (M * 10)) and (N / M) mod 10 > 0 loop
M := M * 10;
if N <= M then
return True;
end if;
end loop;
return False;
end Is_Left_Trucatable_Prime;
function Is_Right_Trucatable_Prime (N : Positive) return Boolean is
M : Natural := N;
begin
while Contains (Primes, M) and M mod 10 > 0 loop
M := M / 10;
if M <= 1 then
return True;
end if;
end loop;
return False;
end Is_Right_Trucatable_Prime;
Position : Cursor;
begin
for N in 2..1_000_000 loop
if Is_Prime (N) then
Insert (Primes, N);
end if;
end loop;
Position := Last (Primes);
while Has_Element (Position) loop
if Is_Left_Trucatable_Prime (Element (Position)) then
Put_Line ("Largest LTP from 1..1000000:" & Integer'Image (Element (Position)));
exit;
end if;
Previous (Position);
end loop;
Position := Last (Primes);
while Has_Element (Position) loop
if Is_Right_Trucatable_Prime (Element (Position)) then
Put_Line ("Largest RTP from 1..1000000:" & Integer'Image (Element (Position)));
exit;
end if;
Previous (Position);
end loop;
end Truncatable_Primes;
|
-- Copyright 2021 Jeff Foley. All rights reserved.
-- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file.
local json = require("json")
name = "Crtsh"
type = "cert"
function start()
setratelimit(2)
end
function vertical(ctx, domain)
local resp, err = request(ctx, {
['url']=buildurl(domain),
headers={['Content-Type']="application/json"},
})
if (err ~= nil and err ~= "") then
return
end
dec = json.decode(resp)
if (dec == nil or #dec == 0) then
return
end
for i, r in pairs(dec) do
local parts = split(r.name_value, "\n")
if #parts == 0 then
table.insert(parts, r.name_value)
end
for j, name in pairs(parts) do
newname(ctx, name)
end
end
end
function buildurl(domain)
return "https://crt.sh/?q=%25." .. domain .. "&output=json"
end
function split(str, delim)
local result = {}
local pattern = "[^%" .. delim .. "]+"
local matches = find(str, pattern)
if (matches == nil or #matches == 0) then
return result
end
for i, match in pairs(matches) do
table.insert(result, match)
end
return result
end
|
procedure Type_Conversion is
X : Integer;
Y : Positive;
begin
X := 1;
Y := Positive (X);
end Type_Conversion;
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 onox <denkpadje@gmail.com>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
package body Orka.glTF.Scenes is
function Create_Nodes (Nodes : Types.JSON_Value) return Natural_Vectors.Vector is
Result : Natural_Vectors.Vector;
begin
for Node of Nodes loop
Result.Append (Natural (Long_Integer'(Node.Value)));
end loop;
return Result;
end Create_Nodes;
function Get_Matrix (Matrix : Types.JSON_Value) return Transforms.Matrix4
with Pre => Matrix.Length = 16;
function Get_Matrix (Matrix : Types.JSON_Value) return Transforms.Matrix4 is
Result : Transforms.Matrix4;
begin
for I in Index_Homogeneous loop
for J in Index_Homogeneous loop
declare
Column : constant Natural := Index_Homogeneous'Pos (I) * 4;
Row : constant Natural := Index_Homogeneous'Pos (J);
begin
Result (I) (J) := Matrix.Get (Column + Row + 1).Value;
end;
end loop;
end loop;
return Result;
end Get_Matrix;
function Get_Vector3 (Vector : Types.JSON_Value) return Transforms.Vector4
with Pre => Vector.Length = 3;
function Get_Vector4 (Vector : Types.JSON_Value) return Transforms.Vector4
with Pre => Vector.Length = 4;
function Get_Vector3 (Vector : Types.JSON_Value) return Transforms.Vector4 is
((Vector.Get (1).Value, Vector.Get (2).Value, Vector.Get (3).Value, 0.0));
function Get_Vector4 (Vector : Types.JSON_Value) return Transforms.Vector4 is
((Vector.Get (1).Value, Vector.Get (2).Value, Vector.Get (3).Value, Vector.Get (4).Value));
function Create_Node (Object : Types.JSON_Value) return Node is
Transform : constant Transform_Kind
:= (if Object.Contains ("matrix") then Matrix else TRS);
begin
return Result : Node (Transform) do
Result.Name := Name_Strings.To_Bounded_String (Object.Get ("name").Value);
Result.Children.Append (Create_Nodes (Object.Get_Array_Or_Empty ("children")));
Result.Mesh := Natural_Optional (Long_Integer'(Object.Get ("mesh", Undefined).Value));
case Transform is
when Matrix =>
Result.Matrix := Get_Matrix (Object.Get ("matrix"));
when TRS =>
if Object.Contains ("translation") then
Result.Translation := Get_Vector3 (Object.Get ("translation"));
end if;
if Object.Contains ("rotation") then
Result.Rotation := Get_Vector4 (Object.Get ("rotation"));
pragma Assert (for all E of Result.Rotation => E in -1.0 .. 1.0);
end if;
if Object.Contains ("scale") then
Result.Scale := Get_Vector3 (Object.Get ("scale"));
end if;
end case;
end return;
end Create_Node;
function Get_Nodes
(Nodes : Types.JSON_Value) return Node_Vectors.Vector
is
Result : Node_Vectors.Vector (Capacity => Nodes.Length);
begin
for Node of Nodes loop
Result.Append (Create_Node (Node));
end loop;
return Result;
end Get_Nodes;
function Create_Scene
(Object : Types.JSON_Value) return Scene is
begin
return Result : Scene do
Result.Name := Name_Strings.To_Bounded_String (Object.Get ("name").Value);
Result.Nodes.Append (Create_Nodes (Object.Get ("nodes")));
end return;
end Create_Scene;
function Get_Scenes
(Scenes : Types.JSON_Value) return Scene_Vectors.Vector
is
Result : Scene_Vectors.Vector (Capacity => Scenes.Length);
begin
for Scene of Scenes loop
Result.Append (Create_Scene (Scene));
end loop;
return Result;
end Get_Scenes;
end Orka.glTF.Scenes;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- U R E A L P --
-- --
-- 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. --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
-- Support for universal real arithmetic
-- WARNING: There is a C version of this package. Any changes to this
-- source file must be properly reflected in the C header file urealp.h
with Types; use Types;
with Uintp; use Uintp;
package Urealp is
---------------------------------------
-- Representation of Universal Reals --
---------------------------------------
-- A universal real value is represented by a single value (which is
-- an index into an internal table). These values are not hashed, so
-- the equality operator should not be used on Ureal values (instead
-- use the UR_Eq function).
-- A Ureal value represents an arbitrary precision universal real value,
-- stored internally using four components:
-- the numerator (Uint, always non-negative)
-- the denominator (Uint, always non-zero, always positive if base = 0)
-- a real base (Nat, either zero, or in the range 2 .. 16)
-- a sign flag (Boolean), set if negative
-- Negative numbers are represented by the sign flag being True.
-- If the base is zero, then the absolute value of the Ureal is simply
-- numerator/denominator, where denominator is positive. If the base is
-- non-zero, then the absolute value is numerator / (base ** denominator).
-- In that case, since base is positive, (base ** denominator) is also
-- positive, even when denominator is negative or null.
-- A normalized Ureal value has base = 0, and numerator/denominator
-- reduced to lowest terms, with zero itself being represented as 0/1.
-- This is a canonical format, so that for normalized Ureal values it
-- is the case that two equal values always have the same denominator
-- and numerator values.
-- Note: a value of minus zero is legitimate, and the operations in
-- Urealp preserve the handling of signed zeroes in accordance with
-- the rules of IEEE P754 ("IEEE floating point").
------------------------------
-- Types for Urealp Package --
------------------------------
type Ureal is private;
-- Type used for representation of universal reals
No_Ureal : constant Ureal;
-- Constant used to indicate missing or unset Ureal value
---------------------
-- Ureal Constants --
---------------------
function Ureal_0 return Ureal;
-- Returns value 0.0
function Ureal_M_0 return Ureal;
-- Returns value -0.0
function Ureal_Tenth return Ureal;
-- Returns value 0.1
function Ureal_Half return Ureal;
-- Returns value 0.5
function Ureal_1 return Ureal;
-- Returns value 1.0
function Ureal_2 return Ureal;
-- Returns value 2.0
function Ureal_10 return Ureal;
-- Returns value 10.0
function Ureal_100 return Ureal;
-- Returns value 100.0
function Ureal_2_80 return Ureal;
-- Returns value 2.0 ** 80
function Ureal_2_M_80 return Ureal;
-- Returns value 2.0 ** (-80)
function Ureal_2_128 return Ureal;
-- Returns value 2.0 ** 128
function Ureal_2_M_128 return Ureal;
-- Returns value 2.0 ** (-128)
function Ureal_10_36 return Ureal;
-- Returns value 10.0 ** 36
function Ureal_M_10_36 return Ureal;
-- Returns value -10.0 ** 36
-----------------
-- Subprograms --
-----------------
procedure Initialize;
-- Initialize Ureal tables. Note that there is no Lock routine in this
-- unit. These tables are among the few tables that can be expanded
-- during Gigi processing.
function Rbase (Real : Ureal) return Nat;
-- Return the base of the universal real
function Denominator (Real : Ureal) return Uint;
-- Return the denominator of the universal real
function Numerator (Real : Ureal) return Uint;
-- Return the numerator of the universal real
function Norm_Den (Real : Ureal) return Uint;
-- Return the denominator of the universal real after a normalization
function Norm_Num (Real : Ureal) return Uint;
-- Return the numerator of the universal real after a normalization
function UR_From_Uint (UI : Uint) return Ureal;
-- Returns real corresponding to universal integer value
function UR_To_Uint (Real : Ureal) return Uint;
-- Return integer value obtained by accurate rounding of real value.
-- The rounding of values half way between two integers is away from
-- zero, as required by normal Ada 95 rounding semantics.
function UR_Trunc (Real : Ureal) return Uint;
-- Return integer value obtained by a truncation of real towards zero
function UR_Ceiling (Real : Ureal) return Uint;
-- Return value of smallest integer not less than the given value
function UR_Floor (Real : Ureal) return Uint;
-- Return value of smallest integer not greater than the given value
-- Conversion table for above four functions
-- Input To_Uint Trunc Ceiling Floor
-- 1.0 1 1 1 1
-- 1.2 1 1 2 1
-- 1.5 2 1 2 1
-- 1.7 2 1 2 1
-- 2.0 2 2 2 2
-- -1.0 -1 -1 -1 -1
-- -1.2 -1 -1 -1 -2
-- -1.5 -2 -1 -1 -2
-- -1.7 -2 -1 -1 -2
-- -2.0 -2 -2 -2 -2
function UR_From_Components
(Num : Uint;
Den : Uint;
Rbase : Nat := 0;
Negative : Boolean := False)
return Ureal;
-- Builds real value from given numerator, denominator and base. The
-- value is negative if Negative is set to true, and otherwise is
-- non-negative.
function UR_Add (Left : Ureal; Right : Ureal) return Ureal;
function UR_Add (Left : Ureal; Right : Uint) return Ureal;
function UR_Add (Left : Uint; Right : Ureal) return Ureal;
-- Returns real sum of operands
function UR_Div (Left : Ureal; Right : Ureal) return Ureal;
function UR_Div (Left : Uint; Right : Ureal) return Ureal;
function UR_Div (Left : Ureal; Right : Uint) return Ureal;
-- Returns real quotient of operands. Fatal error if Right is zero
function UR_Mul (Left : Ureal; Right : Ureal) return Ureal;
function UR_Mul (Left : Uint; Right : Ureal) return Ureal;
function UR_Mul (Left : Ureal; Right : Uint) return Ureal;
-- Returns real product of operands
function UR_Sub (Left : Ureal; Right : Ureal) return Ureal;
function UR_Sub (Left : Uint; Right : Ureal) return Ureal;
function UR_Sub (Left : Ureal; Right : Uint) return Ureal;
-- Returns real difference of operands
function UR_Exponentiate (Real : Ureal; N : Uint) return Ureal;
-- Returns result of raising Ureal to Uint power.
-- Fatal error if Left is 0 and Right is negative.
function UR_Abs (Real : Ureal) return Ureal;
-- Returns abs function of real
function UR_Negate (Real : Ureal) return Ureal;
-- Returns negative of real
function UR_Eq (Left, Right : Ureal) return Boolean;
-- Compares reals for equality
function UR_Max (Left, Right : Ureal) return Ureal;
-- Returns the maximum of two reals
function UR_Min (Left, Right : Ureal) return Ureal;
-- Returns the minimum of two reals
function UR_Ne (Left, Right : Ureal) return Boolean;
-- Compares reals for inequality
function UR_Lt (Left, Right : Ureal) return Boolean;
-- Compares reals for less than
function UR_Le (Left, Right : Ureal) return Boolean;
-- Compares reals for less than or equal
function UR_Gt (Left, Right : Ureal) return Boolean;
-- Compares reals for greater than
function UR_Ge (Left, Right : Ureal) return Boolean;
-- Compares reals for greater than or equal
function UR_Is_Zero (Real : Ureal) return Boolean;
-- Tests if real value is zero
function UR_Is_Negative (Real : Ureal) return Boolean;
-- Tests if real value is negative, note that negative zero gives true
function UR_Is_Positive (Real : Ureal) return Boolean;
-- Test if real value is greater than zero
procedure UR_Write (Real : Ureal; Brackets : Boolean := False);
-- Writes value of Real to standard output. Used for debugging and
-- tree/source output, and also for -gnatR representation output. If the
-- result is easily representable as a standard Ada literal, it will be
-- given that way, but as a result of evaluation of static expressions, it
-- is possible to generate constants (e.g. 1/13) which have no such
-- representation. In such cases (and in cases where it is too much work to
-- figure out the Ada literal), the string that is output is of the form
-- of some expression such as integer/integer, or integer*integer**integer.
-- In the case where an expression is output, if Brackets is set to True,
-- the expression is surrounded by square brackets.
procedure pr (Real : Ureal);
pragma Export (Ada, pr);
-- Writes value of Real to standard output with a terminating line return,
-- using UR_Write as described above. This is for use from the debugger.
------------------------
-- Operator Renamings --
------------------------
function "+" (Left : Ureal; Right : Ureal) return Ureal renames UR_Add;
function "+" (Left : Uint; Right : Ureal) return Ureal renames UR_Add;
function "+" (Left : Ureal; Right : Uint) return Ureal renames UR_Add;
function "/" (Left : Ureal; Right : Ureal) return Ureal renames UR_Div;
function "/" (Left : Uint; Right : Ureal) return Ureal renames UR_Div;
function "/" (Left : Ureal; Right : Uint) return Ureal renames UR_Div;
function "*" (Left : Ureal; Right : Ureal) return Ureal renames UR_Mul;
function "*" (Left : Uint; Right : Ureal) return Ureal renames UR_Mul;
function "*" (Left : Ureal; Right : Uint) return Ureal renames UR_Mul;
function "-" (Left : Ureal; Right : Ureal) return Ureal renames UR_Sub;
function "-" (Left : Uint; Right : Ureal) return Ureal renames UR_Sub;
function "-" (Left : Ureal; Right : Uint) return Ureal renames UR_Sub;
function "**" (Real : Ureal; N : Uint) return Ureal
renames UR_Exponentiate;
function "abs" (Real : Ureal) return Ureal renames UR_Abs;
function "-" (Real : Ureal) return Ureal renames UR_Negate;
function "=" (Left, Right : Ureal) return Boolean renames UR_Eq;
function "<" (Left, Right : Ureal) return Boolean renames UR_Lt;
function "<=" (Left, Right : Ureal) return Boolean renames UR_Le;
function ">=" (Left, Right : Ureal) return Boolean renames UR_Ge;
function ">" (Left, Right : Ureal) return Boolean renames UR_Gt;
-----------------------------
-- Mark/Release Processing --
-----------------------------
-- The space used by Ureal data is not automatically reclaimed. However,
-- a mark-release regime is implemented which allows storage to be
-- released back to a previously noted mark. This is used for example
-- when doing comparisons, where only intermediate results get stored
-- that do not need to be saved for future use.
type Save_Mark is private;
function Mark return Save_Mark;
-- Note mark point for future release
procedure Release (M : Save_Mark);
-- Release storage allocated since mark was noted
------------------------------------
-- Representation of Ureal Values --
------------------------------------
private
type Ureal is new Int range Ureal_Low_Bound .. Ureal_High_Bound;
for Ureal'Size use 32;
No_Ureal : constant Ureal := Ureal'First;
type Save_Mark is new Int;
pragma Inline (Denominator);
pragma Inline (Mark);
pragma Inline (Norm_Num);
pragma Inline (Norm_Den);
pragma Inline (Numerator);
pragma Inline (Rbase);
pragma Inline (Release);
pragma Inline (Ureal_0);
pragma Inline (Ureal_M_0);
pragma Inline (Ureal_Tenth);
pragma Inline (Ureal_Half);
pragma Inline (Ureal_1);
pragma Inline (Ureal_2);
pragma Inline (Ureal_10);
pragma Inline (UR_From_Components);
end Urealp;
|
------------------------------------------------------------------------------
-- Copyright (c) 2016-2017, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Natools.Smaz_Implementations.Base_64_Tools;
package body Natools.Smaz_Implementations.Base_4096 is
package Tools renames Natools.Smaz_Implementations.Base_64_Tools;
use type Ada.Streams.Stream_Element_Offset;
procedure Read_Code
(Input : in Ada.Streams.Stream_Element_Array;
Offset : in out Ada.Streams.Stream_Element_Offset;
Code : out Base_4096_Digit);
procedure Read_Code_Or_End
(Input : in Ada.Streams.Stream_Element_Array;
Offset : in out Ada.Streams.Stream_Element_Offset;
Code : out Base_4096_Digit;
Finished : out Boolean);
-- Read two base-64 symbols and assemble them into a base-4096 number
------------------------------
-- Local Helper Subprograms --
------------------------------
procedure Read_Code
(Input : in Ada.Streams.Stream_Element_Array;
Offset : in out Ada.Streams.Stream_Element_Offset;
Code : out Base_4096_Digit)
is
Low, High : Tools.Base_64_Digit;
begin
Tools.Next_Digit (Input, Offset, Low);
Tools.Next_Digit (Input, Offset, High);
Code := Base_4096_Digit (Low) + Base_4096_Digit (High) * 64;
end Read_Code;
procedure Read_Code_Or_End
(Input : in Ada.Streams.Stream_Element_Array;
Offset : in out Ada.Streams.Stream_Element_Offset;
Code : out Base_4096_Digit;
Finished : out Boolean)
is
Low, High : Tools.Base_64_Digit;
begin
Tools.Next_Digit_Or_End (Input, Offset, Low, Finished);
if Finished then
return;
end if;
Tools.Next_Digit (Input, Offset, High);
Code := Base_4096_Digit (Low) + Base_4096_Digit (High) * 64;
end Read_Code_Or_End;
----------------------
-- Public Interface --
----------------------
procedure Read_Code
(Input : in Ada.Streams.Stream_Element_Array;
Offset : in out Ada.Streams.Stream_Element_Offset;
Code : out Base_4096_Digit;
Verbatim_Length : out Natural;
Last_Code : in Base_4096_Digit;
Variable_Length_Verbatim : in Boolean)
is
Finished : Boolean;
begin
Read_Code_Or_End (Input, Offset, Code, Finished);
if Finished then
Code := Base_4096_Digit'Last;
Verbatim_Length := 0;
return;
end if;
if Code <= Last_Code then
Verbatim_Length := 0;
elsif not Variable_Length_Verbatim then
Verbatim_Length := Positive (Base_4096_Digit'Last - Code + 1);
Code := 0;
elsif Code < Base_4096_Digit'Last then
Verbatim_Length := Positive (Base_4096_Digit'Last - Code);
Code := 0;
else
Read_Code (Input, Offset, Code);
Verbatim_Length
:= Natural (Code) + Natural (Base_4096_Digit'Last - Last_Code);
Code := 0;
end if;
end Read_Code;
procedure Read_Verbatim
(Input : in Ada.Streams.Stream_Element_Array;
Offset : in out Ada.Streams.Stream_Element_Offset;
Output : out String) is
begin
Tools.Decode (Input, Offset, Output);
end Read_Verbatim;
procedure Skip_Verbatim
(Input : in Ada.Streams.Stream_Element_Array;
Offset : in out Ada.Streams.Stream_Element_Offset;
Verbatim_Length : in Positive)
is
Code : Tools.Base_64_Digit;
begin
for I in 1 .. Tools.Image_Length (Verbatim_Length) loop
Tools.Next_Digit (Input, Offset, Code);
end loop;
end Skip_Verbatim;
function Verbatim_Size
(Input_Length : in Positive;
Last_Code : in Base_4096_Digit;
Variable_Length_Verbatim : in Boolean)
return Ada.Streams.Stream_Element_Count
is
Verbatim1_Max_Size : constant Natural
:= Natural (Base_4096_Digit'Last - Last_Code)
- Boolean'Pos (Variable_Length_Verbatim);
Verbatim2_Max_Size : constant Natural
:= Natural (Base_4096_Digit'Last) + Verbatim1_Max_Size + 1;
Input_Index : Natural := 0;
Remaining_Length, Block_Length : Positive;
Result : Ada.Streams.Stream_Element_Count := 0;
begin
while Input_Index < Input_Length loop
Remaining_Length := Input_Length - Input_Index;
if Variable_Length_Verbatim
and then Remaining_Length > Verbatim1_Max_Size
then
Block_Length := Positive'Min
(Remaining_Length, Verbatim2_Max_Size);
Result := Result + 4;
else
Block_Length := Positive'Min
(Remaining_Length, Verbatim1_Max_Size);
Result := Result + 2;
end if;
Result := Result + Tools.Image_Length (Block_Length);
Input_Index := Input_Index + Block_Length;
end loop;
return Result;
end Verbatim_Size;
procedure Write_Code
(Output : in out Ada.Streams.Stream_Element_Array;
Offset : in out Ada.Streams.Stream_Element_Offset;
Code : in Base_4096_Digit)
is
Low : constant Tools.Base_64_Digit := Tools.Base_64_Digit (Code mod 64);
High : constant Tools.Base_64_Digit := Tools.Base_64_Digit (Code / 64);
begin
Output (Offset + 0) := Tools.Image (Low);
Output (Offset + 1) := Tools.Image (High);
Offset := Offset + 2;
end Write_Code;
procedure Write_Verbatim
(Output : in out Ada.Streams.Stream_Element_Array;
Offset : in out Ada.Streams.Stream_Element_Offset;
Input : in String;
Last_Code : in Base_4096_Digit;
Variable_Length_Verbatim : in Boolean)
is
Verbatim1_Max_Size : constant Natural
:= Natural (Base_4096_Digit'Last - Last_Code)
- Boolean'Pos (Variable_Length_Verbatim);
Verbatim2_Max_Size : constant Natural
:= Natural (Base_4096_Digit'Last) + Verbatim1_Max_Size + 1;
Input_Index : Positive := Input'First;
Remaining_Length, Block_Length : Positive;
begin
while Input_Index in Input'Range loop
Remaining_Length := Input'Last - Input_Index + 1;
if Variable_Length_Verbatim
and then Remaining_Length > Verbatim1_Max_Size
then
Block_Length := Positive'Min
(Remaining_Length, Verbatim2_Max_Size);
Write_Code (Output, Offset, Base_4096_Digit'Last);
Write_Code (Output, Offset, Base_4096_Digit
(Block_Length - Verbatim1_Max_Size - 1));
else
Block_Length := Positive'Min
(Remaining_Length, Verbatim1_Max_Size);
Write_Code (Output, Offset, Base_4096_Digit
(Base_4096_Digit'Last - Base_4096_Digit (Block_Length)
+ 1 - Boolean'Pos (Variable_Length_Verbatim)));
end if;
Tools.Encode
(Input (Input_Index .. Input_Index + Block_Length - 1),
Output, Offset);
Input_Index := Input_Index + Block_Length;
end loop;
end Write_Verbatim;
end Natools.Smaz_Implementations.Base_4096;
|
package body Loop_Optimization3_Pkg is
function F (n : Integer) return Integer is
begin
return n;
end;
end Loop_Optimization3_Pkg;
|
-----------------------------------------------------------------------
-- ado-audits -- Auditing support
-- Copyright (C) 2018 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Util.Beans.Objects.Time;
with ADO.Utils;
package body ADO.Audits is
use Ada.Strings.Unbounded;
use type ADO.Schemas.Column_Index;
use type Ada.Calendar.Time;
package UBOT renames Util.Beans.Objects.Time;
procedure Free is
new Ada.Unchecked_Deallocation (Object => Audit_Array,
Name => Audit_Array_Access);
procedure Save (Object : in out Auditable_Object_Record'Class;
Session : in out ADO.Sessions.Master_Session'Class) is
Manager : constant access Audit_Manager'Class := Session.Get_Audit_Manager;
Audits : constant Audit_Array_Access := Object.Audits;
Last : Audit_Info_Index;
begin
if Manager /= null and Audits /= null then
Last := 1;
for Pos in Audits'Range loop
exit when Audits (Pos).Field = 0;
Last := Pos;
end loop;
Manager.Save (Session, Object, Audits (1 .. Last));
end if;
Free (Object.Audits);
end Save;
-- --------------------
-- Record an audit information for a field.
-- --------------------
procedure Audit_Field (Object : in out Auditable_Object_Record;
Field : in ADO.Schemas.Column_Index;
Old_Value : in UBO.Object;
New_Value : in UBO.Object) is
Audits : Audit_Array_Access := Object.Audits;
begin
if Audits = null then
Audits := new Audit_Array (1 .. Audit_Info_Index (Object.With_Audit.Count));
Object.Audits := Audits;
end if;
for Pos in Object.Audits'Range loop
if Audits (Pos).Field = Field then
Audits (Pos).New_Value := New_Value;
return;
end if;
if Audits (Pos).Field = 0 then
Audits (Pos).Field := Field;
Audits (Pos).Old_Value := Old_Value;
Audits (Pos).New_Value := New_Value;
return;
end if;
end loop;
end Audit_Field;
-- --------------------
-- Release the object.
-- --------------------
overriding
procedure Finalize (Object : in out Auditable_Object_Record) is
begin
Free (Object.Audits);
ADO.Objects.Finalize (ADO.Objects.Object_Record (Object));
end Finalize;
procedure Set_Field_Unbounded_String (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out Ada.Strings.Unbounded.Unbounded_String;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
begin
if Into /= Value then
Object.Audit_Field (Field, UBO.To_Object (Into), UBO.To_Object (Value));
Into := Value;
Object.Set_Field (Field);
end if;
end Set_Field_Unbounded_String;
procedure Set_Field_String (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out Ada.Strings.Unbounded.Unbounded_String;
Value : in String) is
begin
if Into /= Value then
Object.Audit_Field (Field, UBO.To_Object (Into), UBO.To_Object (Value));
Ada.Strings.Unbounded.Set_Unbounded_String (Into, Value);
Object.Set_Field (Field);
end if;
end Set_Field_String;
procedure Set_Field_String (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out ADO.Nullable_String;
Value : in String) is
begin
if Into.Is_Null or else Into.Value /= Value then
if Into.Is_Null then
Object.Audit_Field (Field, UBO.Null_Object, UBO.To_Object (Value));
else
Object.Audit_Field (Field, UBO.To_Object (Into.Value), UBO.To_Object (Value));
end if;
Into.Is_Null := False;
Ada.Strings.Unbounded.Set_Unbounded_String (Into.Value, Value);
Object.Set_Field (Field);
end if;
end Set_Field_String;
procedure Set_Field_String (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out ADO.Nullable_String;
Value : in ADO.Nullable_String) is
begin
if Into.Is_Null then
if not Value.Is_Null then
Object.Audit_Field (Field, UBO.Null_Object, UBO.To_Object (Value.Value));
Into := Value;
Object.Set_Field (Field);
end if;
elsif Value.Is_Null then
Object.Audit_Field (Field, UBO.To_Object (Into.Value), UBO.Null_Object);
Into := Value;
Object.Set_Field (Field);
elsif Into.Value /= Value.Value then
Object.Audit_Field (Field, UBO.To_Object (Into.Value), UBO.To_Object (Value.Value));
Into := Value;
Object.Set_Field (Field);
end if;
end Set_Field_String;
procedure Set_Field_Time (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out Ada.Calendar.Time;
Value : in Ada.Calendar.Time) is
begin
if Into /= Value then
Object.Audit_Field (Field, UBOT.To_Object (Into), UBOT.To_Object (Value));
Into := Value;
Object.Set_Field (Field);
end if;
end Set_Field_Time;
procedure Set_Field_Time (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out ADO.Nullable_Time;
Value : in ADO.Nullable_Time) is
begin
if Into.Is_Null then
if not Value.Is_Null then
Object.Audit_Field (Field, UBO.Null_Object, UBOT.To_Object (Value.Value));
Into := Value;
Object.Set_Field (Field);
end if;
elsif Value.Is_Null then
Object.Audit_Field (Field, UBOT.To_Object (Into.Value), UBO.Null_Object);
Into := Value;
Object.Set_Field (Field);
elsif Into.Value /= Value.Value then
Object.Audit_Field (Field, UBOT.To_Object (Into.Value), UBOT.To_Object (Value.Value));
Into := Value;
Object.Set_Field (Field);
end if;
end Set_Field_Time;
procedure Set_Field_Integer (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out Integer;
Value : in Integer) is
begin
if Into /= Value then
Object.Audit_Field (Field, UBO.To_Object (Into), UBO.To_Object (Value));
Into := Value;
Object.Set_Field (Field);
end if;
end Set_Field_Integer;
procedure Set_Field_Integer (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out ADO.Nullable_Integer;
Value : in ADO.Nullable_Integer) is
begin
if Into.Is_Null then
if not Value.Is_Null then
Object.Audit_Field (Field, UBO.Null_Object, UBO.To_Object (Value.Value));
Into := Value;
Object.Set_Field (Field);
end if;
elsif Value.Is_Null then
Object.Audit_Field (Field, UBO.To_Object (Into.Value), UBO.Null_Object);
Into := Value;
Object.Set_Field (Field);
elsif Into.Value /= Value.Value then
Object.Audit_Field (Field, UBO.To_Object (Into.Value), UBO.To_Object (Value.Value));
Into := Value;
Object.Set_Field (Field);
end if;
end Set_Field_Integer;
procedure Set_Field_Natural (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out Natural;
Value : in Natural) is
begin
if Into /= Value then
Object.Audit_Field (Field, UBO.To_Object (Into), UBO.To_Object (Value));
Into := Value;
Object.Set_Field (Field);
end if;
end Set_Field_Natural;
procedure Set_Field_Positive (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out Positive;
Value : in Positive) is
begin
if Into /= Value then
Object.Audit_Field (Field, UBO.To_Object (Into), UBO.To_Object (Value));
Into := Value;
Object.Set_Field (Field);
end if;
end Set_Field_Positive;
procedure Set_Field_Boolean (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out Boolean;
Value : in Boolean) is
begin
if Into /= Value then
Object.Audit_Field (Field, UBO.To_Object (Into), UBO.To_Object (Value));
Into := Value;
Object.Set_Field (Field);
end if;
end Set_Field_Boolean;
procedure Set_Field_Float (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out Float;
Value : in Float) is
begin
if Into /= Value then
Object.Audit_Field (Field, UBO.To_Object (Into), UBO.To_Object (Value));
Into := Value;
Object.Set_Field (Field);
end if;
end Set_Field_Float;
procedure Set_Field_Long_Float (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out Long_Float;
Value : in Long_Float) is
begin
if Into /= Value then
Object.Audit_Field (Field, UBO.To_Object (Into), UBO.To_Object (Value));
Into := Value;
Object.Set_Field (Field);
end if;
end Set_Field_Long_Float;
procedure Set_Field_Object (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out ADO.Objects.Object_Ref'Class;
Value : in ADO.Objects.Object_Ref'Class) is
use type ADO.Objects.Object_Ref;
begin
if Into /= Value then
Object.Audit_Field (Field, ADO.Objects.To_Object (Into.Get_Key),
ADO.Objects.To_Object (Value.Get_Key));
ADO.Objects.Set_Field_Object (Object, Field, Into, Value);
end if;
end Set_Field_Object;
procedure Set_Field_Identifier (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out ADO.Identifier;
Value : in ADO.Identifier) is
begin
if Into /= Value then
Object.Audit_Field (Field, Utils.To_Object (Into), Utils.To_Object (Value));
Into := Value;
Object.Set_Field (Field);
end if;
end Set_Field_Identifier;
procedure Set_Field_Entity_Type (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out ADO.Entity_Type;
Value : in ADO.Entity_Type) is
begin
if Into /= Value then
Object.Audit_Field (Field, UBO.To_Object (Natural (Into)),
UBO.To_Object (Natural (Value)));
Into := Value;
Object.Set_Field (Field);
end if;
end Set_Field_Entity_Type;
procedure Set_Field_Entity_Type (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out ADO.Nullable_Entity_Type;
Value : in ADO.Nullable_Entity_Type) is
begin
if Into.Is_Null then
if not Value.Is_Null then
Object.Audit_Field (Field, UBO.Null_Object, UBO.To_Object (Natural (Value.Value)));
Into := Value;
Object.Set_Field (Field);
end if;
elsif Value.Is_Null then
Object.Audit_Field (Field, UBO.To_Object (Natural (Into.Value)), UBO.Null_Object);
Into := Value;
Object.Set_Field (Field);
elsif Into.Value /= Value.Value then
Object.Audit_Field (Field, UBO.To_Object (Natural (Into.Value)),
UBO.To_Object (Natural (Value.Value)));
Into := Value;
Object.Set_Field (Field);
end if;
end Set_Field_Entity_Type;
procedure Set_Field_Key_Value (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Value : in ADO.Identifier) is
begin
if Object.Get_Key_Value /= Value then
Object.Audit_Field (Field, ADO.Objects.To_Object (Object.Get_Key),
Utils.To_Object (Value));
ADO.Objects.Set_Key_Value (Object, Value);
Object.Set_Field (Field);
end if;
end Set_Field_Key_Value;
procedure Set_Field_Key_Value (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Value : in String) is
begin
if Object.Get_Key_Value /= Value then
Object.Audit_Field (Field, ADO.Objects.To_Object (Object.Get_Key),
UBO.To_Object (Value));
ADO.Objects.Set_Key_Value (Object, Value);
Object.Set_Field (Field);
end if;
end Set_Field_Key_Value;
procedure Set_Field_Key_Value (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
begin
if Object.Get_Key_Value /= Value then
Object.Audit_Field (Field, ADO.Objects.To_Object (Object.Get_Key),
UBO.To_Object (Value));
ADO.Objects.Set_Key_Value (Object, Value);
Object.Set_Field (Field);
end if;
end Set_Field_Key_Value;
procedure Set_Field_Operation (Object : in out Auditable_Object_Record'Class;
Field : in Column_Index;
Into : in out T;
Value : in T) is
begin
if Into /= Value then
Object.Audit_Field (Field, To_Object (Into), To_Object (Value));
Into := Value;
Object.Set_Field (Field);
end if;
end Set_Field_Operation;
end ADO.Audits;
|
with Ada.Text_IO;
with Sax.Readers;
with Input_Sources.Strings;
with Unicode.CES.Utf8;
with DOM.Readers;
with DOM.Core.Documents;
with DOM.Core.Nodes;
with DOM.Core.Attrs;
procedure Extract_Students is
Sample_String : String :=
"<Students>" &
"<Student Name=""April"" Gender=""F"" DateOfBirth=""1989-01-02"" />" &
"<Student Name=""Bob"" Gender=""M"" DateOfBirth=""1990-03-04"" />" &
"<Student Name=""Chad"" Gender=""M"" DateOfBirth=""1991-05-06"" />" &
"<Student Name=""Dave"" Gender=""M"" DateOfBirth=""1992-07-08"">" &
"<Pet Type=""dog"" Name=""Rover"" />" &
"</Student>" &
"<Student DateOfBirth=""1993-09-10"" Gender=""F"" Name=""Émily"" />" &
"</Students>";
Input : Input_Sources.Strings.String_Input;
Reader : DOM.Readers.Tree_Reader;
Document : DOM.Core.Document;
List : DOM.Core.Node_List;
begin
Input_Sources.Strings.Open (Sample_String, Unicode.CES.Utf8.Utf8_Encoding, Input);
DOM.Readers.Parse (Reader, Input);
Input_Sources.Strings.Close (Input);
Document := DOM.Readers.Get_Tree (Reader);
List := DOM.Core.Documents.Get_Elements_By_Tag_Name (Document, "Student");
for I in 0 .. DOM.Core.Nodes.Length (List) - 1 loop
Ada.Text_IO.Put_Line
(DOM.Core.Attrs.Value
(DOM.Core.Nodes.Get_Named_Item
(DOM.Core.Nodes.Attributes
(DOM.Core.Nodes.Item (List, I)), "Name")
)
);
end loop;
DOM.Readers.Free (Reader);
end Extract_Students;
|
with Ada.Numerics.Elementary_Functions;
use Ada.Numerics.Elementary_Functions;
with Ada.Numerics;
use Ada.Numerics;
package body Geometry is
function distance(point1, point2 : Point) return Float is begin
return Sqrt(
(point2.x - point1.x)**2+
(point2.y - point1.y)**2+
(point2.z - point1.z)**2);
end distance;
function midpoint(point1, point2 : Point) return Point is
result : Point;
begin
result.x := (point1.x + point2.x)/2.0;
result.y := (point1.y + point2.y)/2.0;
result.z := (point1.z + point2.z)/2.0;
return result;
end midpoint;
-- Rectangle functions
function volume(s : Rectangle) return Float is begin
return s.width * s.length * s.height;
end volume;
function surface_area(s : Rectangle) return Float is begin
return 2.0*s.width*s.length + 2.0*s.length*s.height + 2.0*s.width*s.height;
end surface_area;
-- Circle functions
function surface_area(s : Circle) return Float is begin
return Pi * s.radius**2;
end surface_area;
function circumference(s : Circle) return Float is begin
return Pi * s.radius**2;
end circumference;
-- Ellipse functions
function surface_area(s : Ellipse) return Float is begin
return Pi * s.a * s.b;
end surface_area;
function circumference(s : Ellipse) return Float is begin
-- 2*\pi*\sqrt{\frac{a^2+b^2}{2}}
return 2.0 * Pi * Sqrt((s.a**2+s.b**2)/2.0);
end circumference;
-- Cylinder functions
function volume(s : Cylinder) return Float is begin
return Pi * s.radius**2 * s.height;
end volume;
function surface_area(s : Cylinder) return Float is begin
return 2.0 * Pi * s.radius**2 + 2.0 * Pi * s.radius * s.height;
end surface_area;
-- Sphere functions
function volume(s : Sphere) return Float is begin
return (4.0/3.0) * Pi * s.radius**3;
end volume;
function surface_area(s : Sphere) return Float is begin
return 4.0 * Pi * s.radius**2;
end surface_area;
end Geometry;
|
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-- License-Filename: LICENSE
-------------------------------------------------------------
package body Program.Element_Vectors is
procedure Skip_Elements
(Self : Iterator;
Pos : in out Element_Cursor;
Step : Integer);
-- Find a good Element starting from Pos.Index and set other fields of Pos
------------------
-- Each_Element --
------------------
function Each_Element
(Self : access Element_Vector'Class;
When_Element : Element_Checker := null) return Iterator is
begin
return (Vector => Self, Condition => When_Element);
end Each_Element;
-----------
-- First --
-----------
overriding function First
(Self : Iterator) return Program.Element_Vectors.Element_Cursor is
begin
return Result : Element_Cursor := (Index => 1, others => <>) do
Self.Skip_Elements (Result, Step => 1);
end return;
end First;
----------
-- Last --
----------
overriding function Last
(Self : Iterator) return Program.Element_Vectors.Element_Cursor is
begin
return Result : Element_Cursor :=
(Index => Self.Vector.Length, others => <>)
do
Self.Skip_Elements (Result, Step => -1);
end return;
end Last;
----------
-- Next --
----------
overriding function Next
(Self : Iterator;
Cursor : Program.Element_Vectors.Element_Cursor)
return Program.Element_Vectors.Element_Cursor is
begin
return Result : Element_Cursor := Cursor do
Result.Index := Result.Index + 1;
Self.Skip_Elements (Result, Step => 1);
end return;
end Next;
--------------
-- Previous --
--------------
overriding function Previous
(Self : Iterator;
Cursor : Program.Element_Vectors.Element_Cursor)
return Program.Element_Vectors.Element_Cursor is
begin
return Result : Element_Cursor := Cursor do
Result.Index := Result.Index - 1;
Self.Skip_Elements (Result, Step => -1);
end return;
end Previous;
-------------------
-- Skip_Elements --
-------------------
procedure Skip_Elements
(Self : Iterator;
Pos : in out Element_Cursor;
Step : Integer) is
begin
while Pos.Index in 1 .. Self.Vector.Length
and then Self.Condition /= null
and then not Self.Condition (Self.Vector.Element (Pos.Index).all)
loop
Pos.Index := Pos.Index + Step;
end loop;
if Pos.Index in 1 .. Self.Vector.Length then
Pos := (Self.Vector.Element (Pos.Index),
Self.Vector.Delimiter (Pos.Index),
Pos.Index,
Pos.Index = Self.Vector.Length);
else
Pos := (null, null, 0, False);
end if;
end Skip_Elements;
end Program.Element_Vectors;
|
-- SPDX-License-Identifier: Apache-2.0
--
-- Copyright (c) 2017 onox <denkpadje@gmail.com>
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
with Ada.Numerics.Generic_Elementary_Functions;
with AUnit.Assertions;
with AUnit.Test_Caller;
with Orka.Transforms.Singles.Vectors;
package body Test_Transforms_Singles_Vectors is
use Orka;
use Orka.Transforms.Singles.Vectors;
use type Vector4;
package EF is new Ada.Numerics.Generic_Elementary_Functions (Float_32);
function Is_Equivalent (Expected, Result : Float_32) return Boolean is
(abs (Result - Expected) <= Float_32'Model_Epsilon);
use AUnit.Assertions;
package Caller is new AUnit.Test_Caller (Test);
Test_Suite : aliased AUnit.Test_Suites.Test_Suite;
function Suite return AUnit.Test_Suites.Access_Test_Suite is
Name : constant String := "(Transforms - Singles - Vectors) ";
begin
Test_Suite.Add_Test (Caller.Create
(Name & "Test '+' operator", Test_Add'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test '-' operator", Test_Subtract'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test '*' operator", Test_Scale'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test 'abs' operator", Test_Absolute'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test Magnitude function", Test_Magnitude'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test Normalize function", Test_Normalize'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test Distance function", Test_Distance'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test Projection function", Test_Projection'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test Perpendicular function", Test_Perpendicular'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test Angle function", Test_Angle'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test Dot function", Test_Dot_Product'Access));
Test_Suite.Add_Test (Caller.Create
(Name & "Test Cross function", Test_Cross_Product'Access));
return Test_Suite'Access;
end Suite;
procedure Test_Add (Object : in out Test) is
Left : constant Vector4 := (2.0, 3.0, 4.0, 0.0);
Right : constant Vector4 := (-2.0, 3.0, 0.0, -1.0);
Expected : constant Vector4 := (0.0, 6.0, 4.0, -1.0);
Result : constant Vector4 := Left + Right;
begin
for I in Index_Homogeneous loop
Assert (Expected (I) = Result (I), "Unexpected Single at " & I'Image);
end loop;
end Test_Add;
procedure Test_Subtract (Object : in out Test) is
Left : constant Vector4 := (2.0, 3.0, 4.0, 0.0);
Right : constant Vector4 := (-2.0, 3.0, 0.0, -1.0);
Expected : constant Vector4 := (4.0, 0.0, 4.0, 1.0);
Result : constant Vector4 := Left - Right;
begin
for I in Index_Homogeneous loop
Assert (Expected (I) = Result (I), "Unexpected Single at " & I'Image);
end loop;
end Test_Subtract;
procedure Test_Scale (Object : in out Test) is
Elements : constant Vector4 := (2.0, 3.0, 1.0, 0.0);
Expected : constant Vector4 := (4.0, 6.0, 2.0, 0.0);
Result : constant Vector4 := 2.0 * Elements;
begin
for I in Index_Homogeneous loop
Assert (Expected (I) = Result (I), "Unexpected Single at " & I'Image);
end loop;
end Test_Scale;
procedure Test_Absolute (Object : in out Test) is
Elements : constant Vector4 := (-2.0, 0.0, 1.0, -1.0);
Expected : constant Vector4 := (2.0, 0.0, 1.0, 1.0);
Result : constant Vector4 := abs Elements;
begin
for I in Index_Homogeneous loop
Assert (Expected (I) = Result (I), "Unexpected Single at " & I'Image);
end loop;
end Test_Absolute;
procedure Test_Magnitude (Object : in out Test) is
Elements : constant Vector4 := (1.0, -2.0, 3.0, -4.0);
Expected : constant Float_32 := EF.Sqrt (1.0**2 + (-2.0)**2 + 3.0**2 + (-4.0)**2);
Result : constant Float_32 := Magnitude (Elements);
begin
Assert (Is_Equivalent (Expected, Result), "Unexpected Single " & Result'Image);
end Test_Magnitude;
procedure Test_Normalize (Object : in out Test) is
Elements : constant Vector4 := (1.0, -2.0, 3.0, -4.0);
Expected : constant Float_32 := 1.0;
Result : constant Float_32 := Magnitude (Normalize (Elements));
begin
Assert (Is_Equivalent (Expected, Result), "Unexpected Single " & Result'Image);
end Test_Normalize;
procedure Test_Distance (Object : in out Test) is
Left : constant Point := (2.0, 5.0, 0.0, 1.0);
Right : constant Point := (2.0, 2.0, 0.0, 1.0);
Expected : constant Float_32 := 3.0;
Result : constant Float_32 := Distance (Left, Right);
begin
Assert (Is_Equivalent (Expected, Result), "Unexpected Single " & Result'Image);
end Test_Distance;
procedure Test_Projection (Object : in out Test) is
Elements : constant Vector4 := (3.0, 4.0, 0.0, 0.0);
Direction : constant Vector4 := (0.0, 1.0, 0.0, 0.0);
Expected : constant Vector4 := (0.0, 4.0, 0.0, 0.0);
Result : constant Vector4 := Projection (Elements, Direction);
begin
for I in Index_Homogeneous loop
Assert (Expected (I) = Result (I), "Unexpected Single at " & I'Image);
end loop;
end Test_Projection;
procedure Test_Perpendicular (Object : in out Test) is
Elements : constant Vector4 := (3.0, 4.0, 0.0, 0.0);
Direction : constant Vector4 := (0.0, 1.0, 0.0, 0.0);
Expected : constant Vector4 := (3.0, 0.0, 0.0, 0.0);
Result : constant Vector4 := Perpendicular (Elements, Direction);
begin
for I in Index_Homogeneous loop
Assert (Expected (I) = Result (I), "Unexpected Single at " & I'Image);
end loop;
end Test_Perpendicular;
procedure Test_Angle (Object : in out Test) is
Left : constant Vector4 := (3.0, 0.0, 0.0, 0.0);
Right : constant Vector4 := (0.0, 4.0, 0.0, 0.0);
Expected : constant Float_32 := To_Radians (90.0);
Result : constant Float_32 := Angle (Left, Right);
begin
Assert (Is_Equivalent (Expected, Result), "Unexpected Single " & Result'Image);
end Test_Angle;
procedure Test_Dot_Product (Object : in out Test) is
Left : constant Vector4 := (1.0, 2.0, 3.0, 4.0);
Right : constant Vector4 := (2.0, 3.0, 4.0, 5.0);
Expected : constant Float_32 := 40.0;
Result : constant Float_32 := Dot (Left, Right);
begin
Assert (Is_Equivalent (Expected, Result), "Unexpected Single " & Result'Image);
end Test_Dot_Product;
procedure Test_Cross_Product (Object : in out Test) is
Left : constant Vector4 := (2.0, 4.0, 8.0, 0.0);
Right : constant Vector4 := (5.0, 6.0, 7.0, 0.0);
Expected : constant Vector4 := (-20.0, 26.0, -8.0, 0.0);
Result : constant Vector4 := Cross (Left, Right);
begin
for I in X .. Z loop
Assert (Expected (I) = Result (I), "Unexpected Single at " & I'Image);
end loop;
end Test_Cross_Product;
end Test_Transforms_Singles_Vectors;
|
with Ada.Text_IO;
package body Problem_48 is
package IO renames Ada.Text_IO;
procedure Solve is
type Unsigned is mod 2**32;
function modular_pow(base, exponent, modulus : Unsigned) return Unsigned is
result : Unsigned := 1;
base_mod : Unsigned := base;
exponent_mod : Unsigned := exponent;
begin
while exponent_mod > 0 loop
if (exponent_mod and 1) = 1 then
result := (result * base_mod) mod modulus;
end if;
exponent_mod := exponent_mod / 2;
base_mod := (base_mod**2) mod modulus;
end loop;
return result;
end modular_pow;
sum : Unsigned := 0;
begin
for num in 1 .. Unsigned(1_000) loop
sum := (sum + modular_pow(num, num, 1_000_000_000)) mod 1_000_000_000;
end loop;
IO.Put_Line(Unsigned'Image(sum));
end Solve;
end Problem_48;
|
with Ada.Integer_Text_IO, Ada.Text_IO;
use Ada.Integer_Text_IO, Ada.Text_IO;
with Listas;
with Es_Abundante;
with Crear_Sublista_4Primos;
with Crear_Sublista_Pares;
procedure Probar_Listas is
procedure Crear_Sublista_3Abundantes is new Listas.Crear_Sublista(Cuantos => 3, Filtro => Es_Abundante);
procedure Escribir_Contenido(L: in out Listas.Lista; Lista: String) is
N: Integer;
begin
-- Contenido de L1 con los 10 primeros enteros
Put_Line("El contenido de la Lista "&Lista&" es:");
Put("===> ");
while not Listas.Es_Vacia(L) loop
Listas.Obtener_Primero(L, N);
Put(N,2);
Put(" ");
Listas.Borrar_Primero(L);
end loop;
New_Line; New_Line;
end Escribir_Contenido;
procedure Escribir_Contenidos(L1: in out Listas.Lista; L1s: String; L2: in out Listas.Lista; L2s: String) is
N1, N2: Integer;
begin
Put_Line("===> El contenido de las Listas "&L1s&" y "&L2s&" es:");
while not Listas.Es_Vacia(L1) loop
Listas.Obtener_Primero(L1, N1);
Listas.Obtener_Primero(L2, N2);
Put(N1, 4);
Put(" -- ");
Put(N2, 4);
New_Line;
Listas.Borrar_Primero(L1);
Listas.Borrar_Primero(L2);
end loop;
end Escribir_Contenidos;
L1,
L1p,
L2,
L3,
L4,
L2p,
Lp1,
Lp2,
L3primos,
L4abudantes : Listas.Lista;
N,
N1,
N2 : Integer;
begin
-- Crear lista de enteros L1 con los 10 primeros enteros
Put("===> Creando L1 ...");
Listas.Crear_Vacia(L1);
for I in 1..10 loop
Listas.Colocar(L1, I);
if Listas.Esta(L1, I) then
Put(I, 0);
Put(" ");
else
Put("NO");
Put(I, 0);
Put(" ");
end if;
end loop;
Crear_Sublista_Pares(L1, L1p); -- Los pares de L1
New_Line; New_Line;
-- Crear lista de enteros L2 con los enteros desde el 11 al 23
Put("===> Creando L2 ...");
Listas.Crear_Vacia(L2);
for I in 11..23 loop
Listas.Colocar(L2, I);
if Listas.Esta(L2, I) then
Put(I, 0);
Put(" ");
else
Put("NO");
Put(I, 0);
Put(" ");
end if;
end loop;
Crear_Sublista_Pares(L2, L2p); -- Los pares de L2
New_Line; New_Line;
Put("===> Creando L3 ...");
Listas.Crear_Vacia(L3);
for I in 11..23 loop
Listas.Colocar(L3, I);
if Listas.Esta(L3, I) then
Put(I, 0);
Put(" ");
else
Put("NO");
Put(I, 0);
Put(" ");
end if;
end loop;
Crear_Sublista_4Primos(L3, L3primos); -- Los pares de L2
New_Line; New_Line;
Put("===> Creando L4 ...");
Listas.Crear_Vacia(L4);
for I in 11..23 loop
Listas.Colocar(L4, I);
if Listas.Esta(L4, I) then
Put(I, 0);
Put(" ");
else
Put("NO");
Put(I, 0);
Put(" ");
end if;
end loop;
Crear_Sublista_3Abundantes(L4, L4abudantes); -- Los pares de L2
New_Line; New_Line;
-- Contenido de L1 con los 10 primeros enteros
Put("===> ");
Escribir_Contenido(L1, "L1");
-- Contenido de L2 con los 10 primeros enteros
Put("===> ");
Escribir_Contenido(L2, "L2");
Put("===> ");
Escribir_Contenido(L3, "L3");
Put("===> ");
Escribir_Contenido(L3primos, "L3primos");
Put("===> ");
Escribir_Contenido(L4, "L4");
Put("===> ");
Escribir_Contenido(L4abudantes, "L4abudantes");
-- Crear lista de enteros pares Lp con los 5 primeros pares del 2 al 8
Listas.Crear_Vacia(Lp1);
N:= 2;
while N<=10 loop
Listas.Colocar(Lp1, N);
N:= N+2;
end loop;
-- Trataremos las listas de pares L1p y Lp1
if Listas.Igual(Lp1, L1p) then
Put_Line("La lista Lp1 y la obtenida como sublista de pares L1p son iguales");
Escribir_Contenidos(L1p, "L1p", Lp1, "Lp1");
else
Put_Line("La lista Lp1 y la obtenida como sublista de pares L1p NO son iguales");
-- Contenido de L1p
Put("===> ");
Escribir_Contenido(L1p, "L1p");
end if;
New_Line; New_Line;
-- Trataremos las listas de pares L2p y Lp2
Listas.Copiar(Lp2, L2p);
if Listas.Igual(Lp2, L2p) then
Put_Line("La lista Lp2 y la obtenida como copia L2p son iguales");
Escribir_Contenidos(L2p, "L2p", Lp2, "Lp2");
else
Put_Line("La lista Lp2 y la obtenida como copia L2p NO son iguales");
-- Contenido de L2p
Put("===> ");
Escribir_Contenido(L2p, "L2p");
end if;
end Probar_Listas;
|
-- Copyright 2016-2019 NXP
-- All rights reserved.SPDX-License-Identifier: BSD-3-Clause
-- This spec has been automatically generated from LPC55S6x.svd
pragma Restrictions (No_Elaboration_Code);
pragma Ada_2012;
pragma Style_Checks (Off);
with HAL;
with System;
package NXP_SVD.SCT is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- SCT operation
type CONFIG_UNIFY_Field is
(
-- The SCT operates as two 16-bit counters named COUNTER_L and
-- COUNTER_H.
Dual_Counter,
-- The SCT operates as a unified 32-bit counter.
Unified_Counter)
with Size => 1;
for CONFIG_UNIFY_Field use
(Dual_Counter => 0,
Unified_Counter => 1);
-- SCT clock mode
type CONFIG_CLKMODE_Field is
(
-- System Clock Mode. The system clock clocks the entire SCT module
-- including the counter(s) and counter prescalers.
System_Clock_Mode,
-- Sampled System Clock Mode. The system clock clocks the SCT module,
-- but the counter and prescalers are only enabled to count when the
-- designated edge is detected on the input selected by the CKSEL field.
-- The minimum pulse width on the selected clock-gate input is 1 bus
-- clock period. This mode is the high-performance, sampled-clock mode.
Sampled_System_Clock_Mode,
-- SCT Input Clock Mode. The input/edge selected by the CKSEL field
-- clocks the SCT module, including the counters and prescalers, after
-- first being synchronized to the system clock. The minimum pulse width
-- on the clock input is 1 bus clock period. This mode is the low-power,
-- sampled-clock mode.
Sct_Input_Clock_Mode,
-- Asynchronous Mode. The entire SCT module is clocked directly by the
-- input/edge selected by the CKSEL field. In this mode, the SCT outputs
-- are switched synchronously to the SCT input clock - not the system
-- clock. The input clock rate must be at least half the system clock
-- rate and can be the same or faster than the system clock.
Asynchronous_Mode)
with Size => 2;
for CONFIG_CLKMODE_Field use
(System_Clock_Mode => 0,
Sampled_System_Clock_Mode => 1,
Sct_Input_Clock_Mode => 2,
Asynchronous_Mode => 3);
-- SCT clock select. The specific functionality of the designated
-- input/edge is dependent on the CLKMODE bit selection in this register.
type CONFIG_CKSEL_Field is
(
-- Rising edges on input 0.
Input_0_Rising_Edges,
-- Falling edges on input 0.
Input_0_Falling_Edge,
-- Rising edges on input 1.
Input_1_Rising_Edges,
-- Falling edges on input 1.
Input_1_Falling_Edge,
-- Rising edges on input 2.
Input_2_Rising_Edges,
-- Falling edges on input 2.
Input_2_Falling_Edge,
-- Rising edges on input 3.
Input_3_Rising_Edges,
-- Falling edges on input 3.
Input_3_Falling_Edge,
-- Rising edges on input 4.
Input_4_Rising_Edges,
-- Falling edges on input 4.
Input_4_Falling_Edge,
-- Rising edges on input 5.
Input_5_Rising_Edges,
-- Falling edges on input 5.
Input_5_Falling_Edge,
-- Rising edges on input 6.
Input_6_Rising_Edges,
-- Falling edges on input 6.
Input_6_Falling_Edge,
-- Rising edges on input 7.
Input_7_Rising_Edges,
-- Falling edges on input 7.
Input_7_Falling_Edge)
with Size => 4;
for CONFIG_CKSEL_Field use
(Input_0_Rising_Edges => 0,
Input_0_Falling_Edge => 1,
Input_1_Rising_Edges => 2,
Input_1_Falling_Edge => 3,
Input_2_Rising_Edges => 4,
Input_2_Falling_Edge => 5,
Input_3_Rising_Edges => 6,
Input_3_Falling_Edge => 7,
Input_4_Rising_Edges => 8,
Input_4_Falling_Edge => 9,
Input_5_Rising_Edges => 10,
Input_5_Falling_Edge => 11,
Input_6_Rising_Edges => 12,
Input_6_Falling_Edge => 13,
Input_7_Rising_Edges => 14,
Input_7_Falling_Edge => 15);
subtype CONFIG_INSYNC_Field is HAL.UInt4;
-- SCT configuration register
type CONFIG_Register is record
-- SCT operation
UNIFY : CONFIG_UNIFY_Field := NXP_SVD.SCT.Dual_Counter;
-- SCT clock mode
CLKMODE : CONFIG_CLKMODE_Field := NXP_SVD.SCT.System_Clock_Mode;
-- SCT clock select. The specific functionality of the designated
-- input/edge is dependent on the CLKMODE bit selection in this
-- register.
CKSEL : CONFIG_CKSEL_Field := NXP_SVD.SCT.Input_0_Rising_Edges;
-- A 1 in this bit prevents the lower match registers from being
-- reloaded from their respective reload registers. Setting this bit
-- eliminates the need to write to the reload registers MATCHREL if the
-- match values are fixed. Software can write to set or clear this bit
-- at any time. This bit applies to both the higher and lower registers
-- when the UNIFY bit is set.
NORELOAD_L : Boolean := False;
-- A 1 in this bit prevents the higher match registers from being
-- reloaded from their respective reload registers. Setting this bit
-- eliminates the need to write to the reload registers MATCHREL if the
-- match values are fixed. Software can write to set or clear this bit
-- at any time. This bit is not used when the UNIFY bit is set.
NORELOAD_H : Boolean := False;
-- Synchronization for input N (bit 9 = input 0, bit 10 = input 1,, bit
-- 12 = input 3); all other bits are reserved. A 1 in one of these bits
-- subjects the corresponding input to synchronization to the SCT clock,
-- before it is used to create an event. If an input is known to already
-- be synchronous to the SCT clock, this bit may be set to 0 for faster
-- input response. (Note: The SCT clock is the system clock for CKMODEs
-- 0-2. It is the selected, asynchronous SCT input clock for CKMODE3).
-- Note that the INSYNC field only affects inputs used for event
-- generation. It does not apply to the clock input specified in the
-- CKSEL field.
INSYNC : CONFIG_INSYNC_Field := 16#F#;
-- unspecified
Reserved_13_16 : HAL.UInt4 := 16#0#;
-- A one in this bit causes a match on match register 0 to be treated as
-- a de-facto LIMIT condition without the need to define an associated
-- event. As with any LIMIT event, this automatic limit causes the
-- counter to be cleared to zero in unidirectional mode or to change the
-- direction of count in bi-directional mode. Software can write to set
-- or clear this bit at any time. This bit applies to both the higher
-- and lower registers when the UNIFY bit is set.
AUTOLIMIT_L : Boolean := False;
-- A one in this bit will cause a match on match register 0 to be
-- treated as a de-facto LIMIT condition without the need to define an
-- associated event. As with any LIMIT event, this automatic limit
-- causes the counter to be cleared to zero in unidirectional mode or to
-- change the direction of count in bi-directional mode. Software can
-- write to set or clear this bit at any time. This bit is not used when
-- the UNIFY bit is set.
AUTOLIMIT_H : Boolean := False;
-- unspecified
Reserved_19_31 : HAL.UInt13 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CONFIG_Register use record
UNIFY at 0 range 0 .. 0;
CLKMODE at 0 range 1 .. 2;
CKSEL at 0 range 3 .. 6;
NORELOAD_L at 0 range 7 .. 7;
NORELOAD_H at 0 range 8 .. 8;
INSYNC at 0 range 9 .. 12;
Reserved_13_16 at 0 range 13 .. 16;
AUTOLIMIT_L at 0 range 17 .. 17;
AUTOLIMIT_H at 0 range 18 .. 18;
Reserved_19_31 at 0 range 19 .. 31;
end record;
-- L or unified counter direction select
type CTRL_BIDIR_L_Field is
(
-- Up. The counter counts up to a limit condition, then is cleared to
-- zero.
Up,
-- Up-down. The counter counts up to a limit, then counts down to a
-- limit condition or to 0.
Up_Down)
with Size => 1;
for CTRL_BIDIR_L_Field use
(Up => 0,
Up_Down => 1);
subtype CTRL_PRE_L_Field is HAL.UInt8;
-- Direction select
type CTRL_BIDIR_H_Field is
(
-- The H counter counts up to its limit condition, then is cleared to
-- zero.
Up,
-- The H counter counts up to its limit, then counts down to a limit
-- condition or to 0.
Up_Down)
with Size => 1;
for CTRL_BIDIR_H_Field use
(Up => 0,
Up_Down => 1);
subtype CTRL_PRE_H_Field is HAL.UInt8;
-- SCT control register
type CTRL_Register is record
-- This bit is 1 when the L or unified counter is counting down.
-- Hardware sets this bit when the counter is counting up, counter limit
-- occurs, and BIDIR = 1.Hardware clears this bit when the counter is
-- counting down and a limit condition occurs or when the counter
-- reaches 0.
DOWN_L : Boolean := False;
-- When this bit is 1 and HALT is 0, the L or unified counter does not
-- run, but I/O events related to the counter can occur. If a designated
-- start event occurs, this bit is cleared and counting resumes.
STOP_L : Boolean := False;
-- When this bit is 1, the L or unified counter does not run and no
-- events can occur. A reset sets this bit. When the HALT_L bit is one,
-- the STOP_L bit is cleared. It is possible to remove the halt
-- condition while keeping the SCT in the stop condition (not running)
-- with a single write to this register to simultaneously clear the HALT
-- bit and set the STOP bit. Once set, only software can clear this bit
-- to restore counter operation. This bit is set on reset.
HALT_L : Boolean := True;
-- Writing a 1 to this bit clears the L or unified counter. This bit
-- always reads as 0.
CLRCTR_L : Boolean := False;
-- L or unified counter direction select
BIDIR_L : CTRL_BIDIR_L_Field := NXP_SVD.SCT.Up;
-- Specifies the factor by which the SCT clock is prescaled to produce
-- the L or unified counter clock. The counter clock is clocked at the
-- rate of the SCT clock divided by PRE_L+1. Clear the counter (by
-- writing a 1 to the CLRCTR bit) whenever changing the PRE value.
PRE_L : CTRL_PRE_L_Field := 16#0#;
-- unspecified
Reserved_13_15 : HAL.UInt3 := 16#0#;
-- This bit is 1 when the H counter is counting down. Hardware sets this
-- bit when the counter is counting, a counter limit condition occurs,
-- and BIDIR is 1. Hardware clears this bit when the counter is counting
-- down and a limit condition occurs or when the counter reaches 0.
DOWN_H : Boolean := False;
-- When this bit is 1 and HALT is 0, the H counter does not, run but I/O
-- events related to the counter can occur. If such an event matches the
-- mask in the Start register, this bit is cleared and counting resumes.
STOP_H : Boolean := False;
-- When this bit is 1, the H counter does not run and no events can
-- occur. A reset sets this bit. When the HALT_H bit is one, the STOP_H
-- bit is cleared. It is possible to remove the halt condition while
-- keeping the SCT in the stop condition (not running) with a single
-- write to this register to simultaneously clear the HALT bit and set
-- the STOP bit. Once set, this bit can only be cleared by software to
-- restore counter operation. This bit is set on reset.
HALT_H : Boolean := True;
-- Writing a 1 to this bit clears the H counter. This bit always reads
-- as 0.
CLRCTR_H : Boolean := False;
-- Direction select
BIDIR_H : CTRL_BIDIR_H_Field := NXP_SVD.SCT.Up;
-- Specifies the factor by which the SCT clock is prescaled to produce
-- the H counter clock. The counter clock is clocked at the rate of the
-- SCT clock divided by PRELH+1. Clear the counter (by writing a 1 to
-- the CLRCTR bit) whenever changing the PRE value.
PRE_H : CTRL_PRE_H_Field := 16#0#;
-- unspecified
Reserved_29_31 : HAL.UInt3 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CTRL_Register use record
DOWN_L at 0 range 0 .. 0;
STOP_L at 0 range 1 .. 1;
HALT_L at 0 range 2 .. 2;
CLRCTR_L at 0 range 3 .. 3;
BIDIR_L at 0 range 4 .. 4;
PRE_L at 0 range 5 .. 12;
Reserved_13_15 at 0 range 13 .. 15;
DOWN_H at 0 range 16 .. 16;
STOP_H at 0 range 17 .. 17;
HALT_H at 0 range 18 .. 18;
CLRCTR_H at 0 range 19 .. 19;
BIDIR_H at 0 range 20 .. 20;
PRE_H at 0 range 21 .. 28;
Reserved_29_31 at 0 range 29 .. 31;
end record;
subtype LIMIT_LIMMSK_L_Field is HAL.UInt16;
subtype LIMIT_LIMMSK_H_Field is HAL.UInt16;
-- SCT limit event select register
type LIMIT_Register is record
-- If bit n is one, event n is used as a counter limit for the L or
-- unified counter (event 0 = bit 0, event 1 = bit 1, etc.). The number
-- of bits = number of events in this SCT.
LIMMSK_L : LIMIT_LIMMSK_L_Field := 16#0#;
-- If bit n is one, event n is used as a counter limit for the H counter
-- (event 0 = bit 16, event 1 = bit 17, etc.). The number of bits =
-- number of events in this SCT.
LIMMSK_H : LIMIT_LIMMSK_H_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for LIMIT_Register use record
LIMMSK_L at 0 range 0 .. 15;
LIMMSK_H at 0 range 16 .. 31;
end record;
subtype HALT_HALTMSK_L_Field is HAL.UInt16;
subtype HALT_HALTMSK_H_Field is HAL.UInt16;
-- SCT halt event select register
type HALT_Register is record
-- If bit n is one, event n sets the HALT_L bit in the CTRL register
-- (event 0 = bit 0, event 1 = bit 1, etc.). The number of bits = number
-- of events in this SCT.
HALTMSK_L : HALT_HALTMSK_L_Field := 16#0#;
-- If bit n is one, event n sets the HALT_H bit in the CTRL register
-- (event 0 = bit 16, event 1 = bit 17, etc.). The number of bits =
-- number of events in this SCT.
HALTMSK_H : HALT_HALTMSK_H_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for HALT_Register use record
HALTMSK_L at 0 range 0 .. 15;
HALTMSK_H at 0 range 16 .. 31;
end record;
subtype STOP_STOPMSK_L_Field is HAL.UInt16;
subtype STOP_STOPMSK_H_Field is HAL.UInt16;
-- SCT stop event select register
type STOP_Register is record
-- If bit n is one, event n sets the STOP_L bit in the CTRL register
-- (event 0 = bit 0, event 1 = bit 1, etc.). The number of bits = number
-- of events in this SCT.
STOPMSK_L : STOP_STOPMSK_L_Field := 16#0#;
-- If bit n is one, event n sets the STOP_H bit in the CTRL register
-- (event 0 = bit 16, event 1 = bit 17, etc.). The number of bits =
-- number of events in this SCT.
STOPMSK_H : STOP_STOPMSK_H_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for STOP_Register use record
STOPMSK_L at 0 range 0 .. 15;
STOPMSK_H at 0 range 16 .. 31;
end record;
subtype START_STARTMSK_L_Field is HAL.UInt16;
subtype START_STARTMSK_H_Field is HAL.UInt16;
-- SCT start event select register
type START_Register is record
-- If bit n is one, event n clears the STOP_L bit in the CTRL register
-- (event 0 = bit 0, event 1 = bit 1, etc.). The number of bits = number
-- of events in this SCT.
STARTMSK_L : START_STARTMSK_L_Field := 16#0#;
-- If bit n is one, event n clears the STOP_H bit in the CTRL register
-- (event 0 = bit 16, event 1 = bit 17, etc.). The number of bits =
-- number of events in this SCT.
STARTMSK_H : START_STARTMSK_H_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for START_Register use record
STARTMSK_L at 0 range 0 .. 15;
STARTMSK_H at 0 range 16 .. 31;
end record;
subtype COUNT_CTR_L_Field is HAL.UInt16;
subtype COUNT_CTR_H_Field is HAL.UInt16;
-- SCT counter register
type COUNT_Register is record
-- When UNIFY = 0, read or write the 16-bit L counter value. When UNIFY
-- = 1, read or write the lower 16 bits of the 32-bit unified counter.
CTR_L : COUNT_CTR_L_Field := 16#0#;
-- When UNIFY = 0, read or write the 16-bit H counter value. When UNIFY
-- = 1, read or write the upper 16 bits of the 32-bit unified counter.
CTR_H : COUNT_CTR_H_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for COUNT_Register use record
CTR_L at 0 range 0 .. 15;
CTR_H at 0 range 16 .. 31;
end record;
subtype STATE_STATE_L_Field is HAL.UInt5;
subtype STATE_STATE_H_Field is HAL.UInt5;
-- SCT state register
type STATE_Register is record
-- State variable.
STATE_L : STATE_STATE_L_Field := 16#0#;
-- unspecified
Reserved_5_15 : HAL.UInt11 := 16#0#;
-- State variable.
STATE_H : STATE_STATE_H_Field := 16#0#;
-- unspecified
Reserved_21_31 : HAL.UInt11 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for STATE_Register use record
STATE_L at 0 range 0 .. 4;
Reserved_5_15 at 0 range 5 .. 15;
STATE_H at 0 range 16 .. 20;
Reserved_21_31 at 0 range 21 .. 31;
end record;
-- INPUT_AIN array
type INPUT_AIN_Field_Array is array (0 .. 15) of Boolean
with Component_Size => 1, Size => 16;
-- Type definition for INPUT_AIN
type INPUT_AIN_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- AIN as a value
Val : HAL.UInt16;
when True =>
-- AIN as an array
Arr : INPUT_AIN_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for INPUT_AIN_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- INPUT_SIN array
type INPUT_SIN_Field_Array is array (0 .. 15) of Boolean
with Component_Size => 1, Size => 16;
-- Type definition for INPUT_SIN
type INPUT_SIN_Field
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SIN as a value
Val : HAL.UInt16;
when True =>
-- SIN as an array
Arr : INPUT_SIN_Field_Array;
end case;
end record
with Unchecked_Union, Size => 16;
for INPUT_SIN_Field use record
Val at 0 range 0 .. 15;
Arr at 0 range 0 .. 15;
end record;
-- SCT input register
type INPUT_Register is record
-- Read-only. Input 0 state. Input 0 state on the last SCT clock edge.
AIN : INPUT_AIN_Field;
-- Read-only. Input 0 state. Input 0 state following the synchronization
-- specified by INSYNC.
SIN : INPUT_SIN_Field;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for INPUT_Register use record
AIN at 0 range 0 .. 15;
SIN at 0 range 16 .. 31;
end record;
subtype REGMODE_REGMOD_L_Field is HAL.UInt16;
subtype REGMODE_REGMOD_H_Field is HAL.UInt16;
-- SCT match/capture mode register
type REGMODE_Register is record
-- Each bit controls one match/capture register (register 0 = bit 0,
-- register 1 = bit 1, etc.). The number of bits = number of
-- match/captures in this SCT. 0 = register operates as match register.
-- 1 = register operates as capture register.
REGMOD_L : REGMODE_REGMOD_L_Field := 16#0#;
-- Each bit controls one match/capture register (register 0 = bit 16,
-- register 1 = bit 17, etc.). The number of bits = number of
-- match/captures in this SCT. 0 = register operates as match registers.
-- 1 = register operates as capture registers.
REGMOD_H : REGMODE_REGMOD_H_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for REGMODE_Register use record
REGMOD_L at 0 range 0 .. 15;
REGMOD_H at 0 range 16 .. 31;
end record;
subtype OUTPUT_OUT_Field is HAL.UInt16;
-- SCT output register
type OUTPUT_Register is record
-- Writing a 1 to bit n forces the corresponding output HIGH. Writing a
-- 0 forces the corresponding output LOW (output 0 = bit 0, output 1 =
-- bit 1, etc.). The number of bits = number of outputs in this SCT.
OUT_k : OUTPUT_OUT_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for OUTPUT_Register use record
OUT_k at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- Set/clear operation on output 0. Value 0x3 is reserved. Do not program
-- this value.
type OUTPUTDIRCTRL_SETCLR0_Field is
(
-- Set and clear do not depend on the direction of any counter.
Independent,
-- Set and clear are reversed when counter L or the unified counter is
-- counting down.
L_Reversed,
-- Set and clear are reversed when counter H is counting down. Do not
-- use if UNIFY = 1.
H_Reversed)
with Size => 2;
for OUTPUTDIRCTRL_SETCLR0_Field use
(Independent => 0,
L_Reversed => 1,
H_Reversed => 2);
-- OUTPUTDIRCTRL_SETCLR array
type OUTPUTDIRCTRL_SETCLR_Field_Array is array (0 .. 15)
of OUTPUTDIRCTRL_SETCLR0_Field
with Component_Size => 2, Size => 32;
-- SCT output counter direction control register
type OUTPUTDIRCTRL_Register
(As_Array : Boolean := False)
is record
case As_Array is
when False =>
-- SETCLR as a value
Val : HAL.UInt32;
when True =>
-- SETCLR as an array
Arr : OUTPUTDIRCTRL_SETCLR_Field_Array;
end case;
end record
with Unchecked_Union, Size => 32, Volatile_Full_Access,
Bit_Order => System.Low_Order_First;
for OUTPUTDIRCTRL_Register use record
Val at 0 range 0 .. 31;
Arr at 0 range 0 .. 31;
end record;
-- Effect of simultaneous set and clear on output 0.
type RES_O0RES_Field is
(
-- No change.
No_Change,
-- Set output (or clear based on the SETCLR0 field in the OUTPUTDIRCTRL
-- register).
Set,
-- Clear output (or set based on the SETCLR0 field).
Clear,
-- Toggle output.
Toggle_Output)
with Size => 2;
for RES_O0RES_Field use
(No_Change => 0,
Set => 1,
Clear => 2,
Toggle_Output => 3);
-- Effect of simultaneous set and clear on output 1.
type RES_O1RES_Field is
(
-- No change.
No_Change,
-- Set output (or clear based on the SETCLR1 field in the OUTPUTDIRCTRL
-- register).
Set,
-- Clear output (or set based on the SETCLR1 field).
Clear,
-- Toggle output.
Toggle_Output)
with Size => 2;
for RES_O1RES_Field use
(No_Change => 0,
Set => 1,
Clear => 2,
Toggle_Output => 3);
-- Effect of simultaneous set and clear on output 2.
type RES_O2RES_Field is
(
-- No change.
No_Change,
-- Set output (or clear based on the SETCLR2 field in the OUTPUTDIRCTRL
-- register).
Set,
-- Clear output n (or set based on the SETCLR2 field).
Clear,
-- Toggle output.
Toggle_Output)
with Size => 2;
for RES_O2RES_Field use
(No_Change => 0,
Set => 1,
Clear => 2,
Toggle_Output => 3);
-- Effect of simultaneous set and clear on output 3.
type RES_O3RES_Field is
(
-- No change.
No_Change,
-- Set output (or clear based on the SETCLR3 field in the OUTPUTDIRCTRL
-- register).
Set,
-- Clear output (or set based on the SETCLR3 field).
Clear,
-- Toggle output.
Toggle_Output)
with Size => 2;
for RES_O3RES_Field use
(No_Change => 0,
Set => 1,
Clear => 2,
Toggle_Output => 3);
-- Effect of simultaneous set and clear on output 4.
type RES_O4RES_Field is
(
-- No change.
No_Change,
-- Set output (or clear based on the SETCLR4 field in the OUTPUTDIRCTRL
-- register).
Set,
-- Clear output (or set based on the SETCLR4 field).
Clear,
-- Toggle output.
Toggle_Output)
with Size => 2;
for RES_O4RES_Field use
(No_Change => 0,
Set => 1,
Clear => 2,
Toggle_Output => 3);
-- Effect of simultaneous set and clear on output 5.
type RES_O5RES_Field is
(
-- No change.
No_Change,
-- Set output (or clear based on the SETCLR5 field in the OUTPUTDIRCTRL
-- register).
Set,
-- Clear output (or set based on the SETCLR5 field).
Clear,
-- Toggle output.
Toggle_Output)
with Size => 2;
for RES_O5RES_Field use
(No_Change => 0,
Set => 1,
Clear => 2,
Toggle_Output => 3);
-- Effect of simultaneous set and clear on output 6.
type RES_O6RES_Field is
(
-- No change.
No_Change,
-- Set output (or clear based on the SETCLR6 field in the OUTPUTDIRCTRL
-- register).
Set,
-- Clear output (or set based on the SETCLR6 field).
Clear,
-- Toggle output.
Toggle_Output)
with Size => 2;
for RES_O6RES_Field use
(No_Change => 0,
Set => 1,
Clear => 2,
Toggle_Output => 3);
-- Effect of simultaneous set and clear on output 7.
type RES_O7RES_Field is
(
-- No change.
No_Change,
-- Set output (or clear based on the SETCLR7 field in the OUTPUTDIRCTRL
-- register).
Set,
-- Clear output n (or set based on the SETCLR7 field).
Clear,
-- Toggle output.
Toggle_Output)
with Size => 2;
for RES_O7RES_Field use
(No_Change => 0,
Set => 1,
Clear => 2,
Toggle_Output => 3);
-- Effect of simultaneous set and clear on output 8.
type RES_O8RES_Field is
(
-- No change.
No_Change,
-- Set output (or clear based on the SETCLR8 field in the OUTPUTDIRCTRL
-- register).
Set,
-- Clear output (or set based on the SETCLR8 field).
Clear,
-- Toggle output.
Toggle_Output)
with Size => 2;
for RES_O8RES_Field use
(No_Change => 0,
Set => 1,
Clear => 2,
Toggle_Output => 3);
-- Effect of simultaneous set and clear on output 9.
type RES_O9RES_Field is
(
-- No change.
No_Change,
-- Set output (or clear based on the SETCLR9 field in the OUTPUTDIRCTRL
-- register).
Set,
-- Clear output (or set based on the SETCLR9 field).
Clear,
-- Toggle output.
Toggle_Output)
with Size => 2;
for RES_O9RES_Field use
(No_Change => 0,
Set => 1,
Clear => 2,
Toggle_Output => 3);
-- Effect of simultaneous set and clear on output 10.
type RES_O10RES_Field is
(
-- No change.
No_Change,
-- Set output (or clear based on the SETCLR10 field in the OUTPUTDIRCTRL
-- register).
Set,
-- Clear output (or set based on the SETCLR10 field).
Clear,
-- Toggle output.
Toggle_Output)
with Size => 2;
for RES_O10RES_Field use
(No_Change => 0,
Set => 1,
Clear => 2,
Toggle_Output => 3);
-- Effect of simultaneous set and clear on output 11.
type RES_O11RES_Field is
(
-- No change.
No_Change,
-- Set output (or clear based on the SETCLR11 field in the OUTPUTDIRCTRL
-- register).
Set,
-- Clear output (or set based on the SETCLR11 field).
Clear,
-- Toggle output.
Toggle_Output)
with Size => 2;
for RES_O11RES_Field use
(No_Change => 0,
Set => 1,
Clear => 2,
Toggle_Output => 3);
-- Effect of simultaneous set and clear on output 12.
type RES_O12RES_Field is
(
-- No change.
No_Change,
-- Set output (or clear based on the SETCLR12 field in the OUTPUTDIRCTRL
-- register).
Set,
-- Clear output (or set based on the SETCLR12 field).
Clear,
-- Toggle output.
Toggle_Output)
with Size => 2;
for RES_O12RES_Field use
(No_Change => 0,
Set => 1,
Clear => 2,
Toggle_Output => 3);
-- Effect of simultaneous set and clear on output 13.
type RES_O13RES_Field is
(
-- No change.
No_Change,
-- Set output (or clear based on the SETCLR13 field in the OUTPUTDIRCTRL
-- register).
Set,
-- Clear output (or set based on the SETCLR13 field).
Clear,
-- Toggle output.
Toggle_Output)
with Size => 2;
for RES_O13RES_Field use
(No_Change => 0,
Set => 1,
Clear => 2,
Toggle_Output => 3);
-- Effect of simultaneous set and clear on output 14.
type RES_O14RES_Field is
(
-- No change.
No_Change,
-- Set output (or clear based on the SETCLR14 field in the OUTPUTDIRCTRL
-- register).
Set,
-- Clear output (or set based on the SETCLR14 field).
Clear,
-- Toggle output.
Toggle_Output)
with Size => 2;
for RES_O14RES_Field use
(No_Change => 0,
Set => 1,
Clear => 2,
Toggle_Output => 3);
-- Effect of simultaneous set and clear on output 15.
type RES_O15RES_Field is
(
-- No change.
No_Change,
-- Set output (or clear based on the SETCLR15 field in the OUTPUTDIRCTRL
-- register).
Set,
-- Clear output (or set based on the SETCLR15 field).
Clear,
-- Toggle output.
Toggle_Output)
with Size => 2;
for RES_O15RES_Field use
(No_Change => 0,
Set => 1,
Clear => 2,
Toggle_Output => 3);
-- SCT conflict resolution register
type RES_Register is record
-- Effect of simultaneous set and clear on output 0.
O0RES : RES_O0RES_Field := NXP_SVD.SCT.No_Change;
-- Effect of simultaneous set and clear on output 1.
O1RES : RES_O1RES_Field := NXP_SVD.SCT.No_Change;
-- Effect of simultaneous set and clear on output 2.
O2RES : RES_O2RES_Field := NXP_SVD.SCT.No_Change;
-- Effect of simultaneous set and clear on output 3.
O3RES : RES_O3RES_Field := NXP_SVD.SCT.No_Change;
-- Effect of simultaneous set and clear on output 4.
O4RES : RES_O4RES_Field := NXP_SVD.SCT.No_Change;
-- Effect of simultaneous set and clear on output 5.
O5RES : RES_O5RES_Field := NXP_SVD.SCT.No_Change;
-- Effect of simultaneous set and clear on output 6.
O6RES : RES_O6RES_Field := NXP_SVD.SCT.No_Change;
-- Effect of simultaneous set and clear on output 7.
O7RES : RES_O7RES_Field := NXP_SVD.SCT.No_Change;
-- Effect of simultaneous set and clear on output 8.
O8RES : RES_O8RES_Field := NXP_SVD.SCT.No_Change;
-- Effect of simultaneous set and clear on output 9.
O9RES : RES_O9RES_Field := NXP_SVD.SCT.No_Change;
-- Effect of simultaneous set and clear on output 10.
O10RES : RES_O10RES_Field := NXP_SVD.SCT.No_Change;
-- Effect of simultaneous set and clear on output 11.
O11RES : RES_O11RES_Field := NXP_SVD.SCT.No_Change;
-- Effect of simultaneous set and clear on output 12.
O12RES : RES_O12RES_Field := NXP_SVD.SCT.No_Change;
-- Effect of simultaneous set and clear on output 13.
O13RES : RES_O13RES_Field := NXP_SVD.SCT.No_Change;
-- Effect of simultaneous set and clear on output 14.
O14RES : RES_O14RES_Field := NXP_SVD.SCT.No_Change;
-- Effect of simultaneous set and clear on output 15.
O15RES : RES_O15RES_Field := NXP_SVD.SCT.No_Change;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for RES_Register use record
O0RES at 0 range 0 .. 1;
O1RES at 0 range 2 .. 3;
O2RES at 0 range 4 .. 5;
O3RES at 0 range 6 .. 7;
O4RES at 0 range 8 .. 9;
O5RES at 0 range 10 .. 11;
O6RES at 0 range 12 .. 13;
O7RES at 0 range 14 .. 15;
O8RES at 0 range 16 .. 17;
O9RES at 0 range 18 .. 19;
O10RES at 0 range 20 .. 21;
O11RES at 0 range 22 .. 23;
O12RES at 0 range 24 .. 25;
O13RES at 0 range 26 .. 27;
O14RES at 0 range 28 .. 29;
O15RES at 0 range 30 .. 31;
end record;
subtype DMAREQ0_DEV_0_Field is HAL.UInt16;
-- SCT DMA request 0 register
type DMAREQ0_Register is record
-- If bit n is one, event n triggers DMA request 0 (event 0 = bit 0,
-- event 1 = bit 1, etc.). The number of bits = number of events in this
-- SCT.
DEV_0 : DMAREQ0_DEV_0_Field := 16#0#;
-- unspecified
Reserved_16_29 : HAL.UInt14 := 16#0#;
-- A 1 in this bit triggers DMA request 0 when it loads the
-- MATCH_L/Unified registers from the RELOAD_L/Unified registers.
DRL0 : Boolean := False;
-- This read-only bit indicates the state of DMA Request 0. Note that if
-- the related DMA channel is enabled and properly set up, it is
-- unlikely that software will see this flag, it will be cleared rapidly
-- by the DMA service. The flag remaining set could point to an issue
-- with DMA setup.
DRQ0 : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DMAREQ0_Register use record
DEV_0 at 0 range 0 .. 15;
Reserved_16_29 at 0 range 16 .. 29;
DRL0 at 0 range 30 .. 30;
DRQ0 at 0 range 31 .. 31;
end record;
subtype DMAREQ1_DEV_1_Field is HAL.UInt16;
-- SCT DMA request 1 register
type DMAREQ1_Register is record
-- If bit n is one, event n triggers DMA request 1 (event 0 = bit 0,
-- event 1 = bit 1, etc.). The number of bits = number of events in this
-- SCT.
DEV_1 : DMAREQ1_DEV_1_Field := 16#0#;
-- unspecified
Reserved_16_29 : HAL.UInt14 := 16#0#;
-- A 1 in this bit triggers DMA request 1 when it loads the Match
-- L/Unified registers from the Reload L/Unified registers.
DRL1 : Boolean := False;
-- This read-only bit indicates the state of DMA Request 1. Note that if
-- the related DMA channel is enabled and properly set up, it is
-- unlikely that software will see this flag, it will be cleared rapidly
-- by the DMA service. The flag remaining set could point to an issue
-- with DMA setup.
DRQ1 : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for DMAREQ1_Register use record
DEV_1 at 0 range 0 .. 15;
Reserved_16_29 at 0 range 16 .. 29;
DRL1 at 0 range 30 .. 30;
DRQ1 at 0 range 31 .. 31;
end record;
subtype EVEN_IEN_Field is HAL.UInt16;
-- SCT event interrupt enable register
type EVEN_Register is record
-- The SCT requests an interrupt when bit n of this register and the
-- event flag register are both one (event 0 = bit 0, event 1 = bit 1,
-- etc.). The number of bits = number of events in this SCT.
IEN : EVEN_IEN_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EVEN_Register use record
IEN at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype EVFLAG_FLAG_Field is HAL.UInt16;
-- SCT event flag register
type EVFLAG_Register is record
-- Bit n is one if event n has occurred since reset or a 1 was last
-- written to this bit (event 0 = bit 0, event 1 = bit 1, etc.). The
-- number of bits = number of events in this SCT.
FLAG : EVFLAG_FLAG_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EVFLAG_Register use record
FLAG at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype CONEN_NCEN_Field is HAL.UInt16;
-- SCT conflict interrupt enable register
type CONEN_Register is record
-- The SCT requests an interrupt when bit n of this register and the SCT
-- conflict flag register are both one (output 0 = bit 0, output 1 = bit
-- 1, etc.). The number of bits = number of outputs in this SCT.
NCEN : CONEN_NCEN_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CONEN_Register use record
NCEN at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype CONFLAG_NCFLAG_Field is HAL.UInt16;
-- SCT conflict flag register
type CONFLAG_Register is record
-- Bit n is one if a no-change conflict event occurred on output n since
-- reset or a 1 was last written to this bit (output 0 = bit 0, output 1
-- = bit 1, etc.). The number of bits = number of outputs in this SCT.
NCFLAG : CONFLAG_NCFLAG_Field := 16#0#;
-- unspecified
Reserved_16_29 : HAL.UInt14 := 16#0#;
-- The most recent bus error from this SCT involved writing CTR
-- L/Unified, STATE L/Unified, MATCH L/Unified, or the Output register
-- when the L/U counter was not halted. A word write to certain L and H
-- registers can be half successful and half unsuccessful.
BUSERRL : Boolean := False;
-- The most recent bus error from this SCT involved writing CTR H, STATE
-- H, MATCH H, or the Output register when the H counter was not halted.
BUSERRH : Boolean := False;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CONFLAG_Register use record
NCFLAG at 0 range 0 .. 15;
Reserved_16_29 at 0 range 16 .. 29;
BUSERRL at 0 range 30 .. 30;
BUSERRH at 0 range 31 .. 31;
end record;
subtype CAP_CAPn_L_Field is HAL.UInt16;
subtype CAP_CAPn_H_Field is HAL.UInt16;
-- SCT capture register of capture channel
type CAP_Register is record
-- When UNIFY = 0, read the 16-bit counter value at which this register
-- was last captured. When UNIFY = 1, read the lower 16 bits of the
-- 32-bit value at which this register was last captured.
CAPn_L : CAP_CAPn_L_Field := 16#0#;
-- When UNIFY = 0, read the 16-bit counter value at which this register
-- was last captured. When UNIFY = 1, read the upper 16 bits of the
-- 32-bit value at which this register was last captured.
CAPn_H : CAP_CAPn_H_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAP_Register use record
CAPn_L at 0 range 0 .. 15;
CAPn_H at 0 range 16 .. 31;
end record;
subtype MATCH_MATCHn_L_Field is HAL.UInt16;
subtype MATCH_MATCHn_H_Field is HAL.UInt16;
-- SCT match value register of match channels
type MATCH_Register is record
-- When UNIFY = 0, read or write the 16-bit value to be compared to the
-- L counter. When UNIFY = 1, read or write the lower 16 bits of the
-- 32-bit value to be compared to the unified counter.
MATCHn_L : MATCH_MATCHn_L_Field := 16#0#;
-- When UNIFY = 0, read or write the 16-bit value to be compared to the
-- H counter. When UNIFY = 1, read or write the upper 16 bits of the
-- 32-bit value to be compared to the unified counter.
MATCHn_H : MATCH_MATCHn_H_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MATCH_Register use record
MATCHn_L at 0 range 0 .. 15;
MATCHn_H at 0 range 16 .. 31;
end record;
subtype CAPCTRL_CAPCONn_L_Field is HAL.UInt16;
subtype CAPCTRL_CAPCONn_H_Field is HAL.UInt16;
-- SCT capture control register
type CAPCTRL_Register is record
-- If bit m is one, event m causes the CAPn_L (UNIFY = 0) or the CAPn
-- (UNIFY = 1) register to be loaded (event 0 = bit 0, event 1 = bit 1,
-- etc.). The number of bits = number of match/captures in this SCT.
CAPCONn_L : CAPCTRL_CAPCONn_L_Field := 16#0#;
-- If bit m is one, event m causes the CAPn_H (UNIFY = 0) register to be
-- loaded (event 0 = bit 16, event 1 = bit 17, etc.). The number of bits
-- = number of match/captures in this SCT.
CAPCONn_H : CAPCTRL_CAPCONn_H_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for CAPCTRL_Register use record
CAPCONn_L at 0 range 0 .. 15;
CAPCONn_H at 0 range 16 .. 31;
end record;
subtype MATCHREL_RELOADn_L_Field is HAL.UInt16;
subtype MATCHREL_RELOADn_H_Field is HAL.UInt16;
-- SCT match reload value register
type MATCHREL_Register is record
-- When UNIFY = 0, specifies the 16-bit value to be loaded into the
-- MATCHn_L register. When UNIFY = 1, specifies the lower 16 bits of the
-- 32-bit value to be loaded into the MATCHn register.
RELOADn_L : MATCHREL_RELOADn_L_Field := 16#0#;
-- When UNIFY = 0, specifies the 16-bit to be loaded into the MATCHn_H
-- register. When UNIFY = 1, specifies the upper 16 bits of the 32-bit
-- value to be loaded into the MATCHn register.
RELOADn_H : MATCHREL_RELOADn_H_Field := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for MATCHREL_Register use record
RELOADn_L at 0 range 0 .. 15;
RELOADn_H at 0 range 16 .. 31;
end record;
----------------------------
-- EV cluster's Registers --
----------------------------
subtype EV_STATE_EV_STATEMSKn_Field is HAL.UInt16;
-- SCT event state register 0
type EV_STATE_EV_Register is record
-- If bit m is one, event n happens in state m of the counter selected
-- by the HEVENT bit (n = event number, m = state number; state 0 = bit
-- 0, state 1= bit 1, etc.). The number of bits = number of states in
-- this SCT.
STATEMSKn : EV_STATE_EV_STATEMSKn_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EV_STATE_EV_Register use record
STATEMSKn at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype EV_CTRL_EV_MATCHSEL_Field is HAL.UInt4;
-- Select L/H counter. Do not set this bit if UNIFY = 1.
type EV_CTRL_HEVENT_Field is
(
-- Selects the L state and the L match register selected by MATCHSEL.
L_Counter,
-- Selects the H state and the H match register selected by MATCHSEL.
H_Counter)
with Size => 1;
for EV_CTRL_HEVENT_Field use
(L_Counter => 0,
H_Counter => 1);
-- Input/output select
type EV_CTRL_OUTSEL_Field is
(
-- Selects the inputs selected by IOSEL.
Input,
-- Selects the outputs selected by IOSEL.
Output)
with Size => 1;
for EV_CTRL_OUTSEL_Field use
(Input => 0,
Output => 1);
subtype EV_CTRL_EV_IOSEL_Field is HAL.UInt4;
-- Selects the I/O condition for event n. (The detection of edges on
-- outputs lag the conditions that switch the outputs by one SCT clock). In
-- order to guarantee proper edge/state detection, an input must have a
-- minimum pulse width of at least one SCT clock period .
type EV_CTRL_IOCOND_Field is
(
-- LOW
Low,
-- Rise
Rise,
-- Fall
Fall,
-- HIGH
High)
with Size => 2;
for EV_CTRL_IOCOND_Field use
(Low => 0,
Rise => 1,
Fall => 2,
High => 3);
-- Selects how the specified match and I/O condition are used and combined.
type EV_CTRL_COMBMODE_Field is
(
-- OR. The event occurs when either the specified match or I/O condition
-- occurs.
Or_k,
-- MATCH. Uses the specified match only.
Match,
-- IO. Uses the specified I/O condition only.
Io,
-- AND. The event occurs when the specified match and I/O condition
-- occur simultaneously.
And_k)
with Size => 2;
for EV_CTRL_COMBMODE_Field use
(Or_k => 0,
Match => 1,
Io => 2,
And_k => 3);
-- This bit controls how the STATEV value modifies the state selected by
-- HEVENT when this event is the highest-numbered event occurring for that
-- state.
type EV_CTRL_STATELD_Field is
(
-- STATEV value is added into STATE (the carry-out is ignored).
Add,
-- STATEV value is loaded into STATE.
Load)
with Size => 1;
for EV_CTRL_STATELD_Field use
(Add => 0,
Load => 1);
subtype EV_CTRL_EV_STATEV_Field is HAL.UInt5;
-- Direction qualifier for event generation. This field only applies when
-- the counters are operating in BIDIR mode. If BIDIR = 0, the SCT ignores
-- this field. Value 0x3 is reserved.
type EV_CTRL_DIRECTION_Field is
(
-- Direction independent. This event is triggered regardless of the
-- count direction.
Direction_Independent,
-- Counting up. This event is triggered only during up-counting when
-- BIDIR = 1.
Counting_Up,
-- Counting down. This event is triggered only during down-counting when
-- BIDIR = 1.
Counting_Down)
with Size => 2;
for EV_CTRL_DIRECTION_Field use
(Direction_Independent => 0,
Counting_Up => 1,
Counting_Down => 2);
-- SCT event control register 0
type EV_CTRL_EV_Register is record
-- Selects the Match register associated with this event (if any). A
-- match can occur only when the counter selected by the HEVENT bit is
-- running.
MATCHSEL : EV_CTRL_EV_MATCHSEL_Field := 16#0#;
-- Select L/H counter. Do not set this bit if UNIFY = 1.
HEVENT : EV_CTRL_HEVENT_Field := NXP_SVD.SCT.L_Counter;
-- Input/output select
OUTSEL : EV_CTRL_OUTSEL_Field := NXP_SVD.SCT.Input;
-- Selects the input or output signal number associated with this event
-- (if any). Do not select an input in this register if CKMODE is 1x. In
-- this case the clock input is an implicit ingredient of every event.
IOSEL : EV_CTRL_EV_IOSEL_Field := 16#0#;
-- Selects the I/O condition for event n. (The detection of edges on
-- outputs lag the conditions that switch the outputs by one SCT clock).
-- In order to guarantee proper edge/state detection, an input must have
-- a minimum pulse width of at least one SCT clock period .
IOCOND : EV_CTRL_IOCOND_Field := NXP_SVD.SCT.Low;
-- Selects how the specified match and I/O condition are used and
-- combined.
COMBMODE : EV_CTRL_COMBMODE_Field := NXP_SVD.SCT.Or_k;
-- This bit controls how the STATEV value modifies the state selected by
-- HEVENT when this event is the highest-numbered event occurring for
-- that state.
STATELD : EV_CTRL_STATELD_Field := NXP_SVD.SCT.Add;
-- This value is loaded into or added to the state selected by HEVENT,
-- depending on STATELD, when this event is the highest-numbered event
-- occurring for that state. If STATELD and STATEV are both zero, there
-- is no change to the STATE value.
STATEV : EV_CTRL_EV_STATEV_Field := 16#0#;
-- If this bit is one and the COMBMODE field specifies a match component
-- to the triggering of this event, then a match is considered to be
-- active whenever the counter value is GREATER THAN OR EQUAL TO the
-- value specified in the match register when counting up, LESS THEN OR
-- EQUAL TO the match value when counting down. If this bit is zero, a
-- match is only be active during the cycle when the counter is equal to
-- the match value.
MATCHMEM : Boolean := False;
-- Direction qualifier for event generation. This field only applies
-- when the counters are operating in BIDIR mode. If BIDIR = 0, the SCT
-- ignores this field. Value 0x3 is reserved.
DIRECTION : EV_CTRL_DIRECTION_Field :=
NXP_SVD.SCT.Direction_Independent;
-- unspecified
Reserved_23_31 : HAL.UInt9 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for EV_CTRL_EV_Register use record
MATCHSEL at 0 range 0 .. 3;
HEVENT at 0 range 4 .. 4;
OUTSEL at 0 range 5 .. 5;
IOSEL at 0 range 6 .. 9;
IOCOND at 0 range 10 .. 11;
COMBMODE at 0 range 12 .. 13;
STATELD at 0 range 14 .. 14;
STATEV at 0 range 15 .. 19;
MATCHMEM at 0 range 20 .. 20;
DIRECTION at 0 range 21 .. 22;
Reserved_23_31 at 0 range 23 .. 31;
end record;
-- no description available
type EV_Cluster is record
-- SCT event state register 0
EV_STATE : aliased EV_STATE_EV_Register;
-- SCT event control register 0
EV_CTRL : aliased EV_CTRL_EV_Register;
end record
with Volatile, Size => 64;
for EV_Cluster use record
EV_STATE at 16#0# range 0 .. 31;
EV_CTRL at 16#4# range 0 .. 31;
end record;
-- no description available
type EV_Clusters is array (0 .. 15) of EV_Cluster;
-----------------------------
-- OUT cluster's Registers --
-----------------------------
subtype OUT_SET_OUT_SET_Field is HAL.UInt16;
-- SCT output 0 set register
type OUT_SET_OUT_Register is record
-- A 1 in bit m selects event m to set output n (or clear it if SETCLRn
-- = 0x1 or 0x2) output 0 = bit 0, output 1 = bit 1, etc. The number of
-- bits = number of events in this SCT. When the counter is used in
-- bi-directional mode, it is possible to reverse the action specified
-- by the output set and clear registers when counting down, See the
-- OUTPUTCTRL register.
SET : OUT_SET_OUT_SET_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for OUT_SET_OUT_Register use record
SET at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
subtype OUT_CLR_OUT_CLR_Field is HAL.UInt16;
-- SCT output 0 clear register
type OUT_CLR_OUT_Register is record
-- A 1 in bit m selects event m to clear output n (or set it if SETCLRn
-- = 0x1 or 0x2) event 0 = bit 0, event 1 = bit 1, etc. The number of
-- bits = number of events in this SCT. When the counter is used in
-- bi-directional mode, it is possible to reverse the action specified
-- by the output set and clear registers when counting down, See the
-- OUTPUTCTRL register.
CLR : OUT_CLR_OUT_CLR_Field := 16#0#;
-- unspecified
Reserved_16_31 : HAL.UInt16 := 16#0#;
end record
with Volatile_Full_Access, Size => 32,
Bit_Order => System.Low_Order_First;
for OUT_CLR_OUT_Register use record
CLR at 0 range 0 .. 15;
Reserved_16_31 at 0 range 16 .. 31;
end record;
-- no description available
type OUT_Cluster is record
-- SCT output 0 set register
OUT_SET : aliased OUT_SET_OUT_Register;
-- SCT output 0 clear register
OUT_CLR : aliased OUT_CLR_OUT_Register;
end record
with Volatile, Size => 64;
for OUT_Cluster use record
OUT_SET at 16#0# range 0 .. 31;
OUT_CLR at 16#4# range 0 .. 31;
end record;
-- no description available
type OUT_Clusters is array (0 .. 9) of OUT_Cluster;
-----------------
-- Peripherals --
-----------------
type SCT0_Disc is
(
Mode_1,
Mode_2);
-- SCTimer/PWM (SCT)
type SCT0_Peripheral
(Discriminent : SCT0_Disc := Mode_1)
is record
-- SCT configuration register
CONFIG : aliased CONFIG_Register;
-- SCT control register
CTRL : aliased CTRL_Register;
-- SCT limit event select register
LIMIT : aliased LIMIT_Register;
-- SCT halt event select register
HALT : aliased HALT_Register;
-- SCT stop event select register
STOP : aliased STOP_Register;
-- SCT start event select register
START : aliased START_Register;
-- SCT counter register
COUNT : aliased COUNT_Register;
-- SCT state register
STATE : aliased STATE_Register;
-- SCT input register
INPUT : aliased INPUT_Register;
-- SCT match/capture mode register
REGMODE : aliased REGMODE_Register;
-- SCT output register
OUTPUT : aliased OUTPUT_Register;
-- SCT output counter direction control register
OUTPUTDIRCTRL : aliased OUTPUTDIRCTRL_Register;
-- SCT conflict resolution register
RES : aliased RES_Register;
-- SCT DMA request 0 register
DMAREQ0 : aliased DMAREQ0_Register;
-- SCT DMA request 1 register
DMAREQ1 : aliased DMAREQ1_Register;
-- SCT event interrupt enable register
EVEN : aliased EVEN_Register;
-- SCT event flag register
EVFLAG : aliased EVFLAG_Register;
-- SCT conflict interrupt enable register
CONEN : aliased CONEN_Register;
-- SCT conflict flag register
CONFLAG : aliased CONFLAG_Register;
-- no description available
EV : aliased EV_Clusters;
-- no description available
OUT_k : aliased OUT_Clusters;
case Discriminent is
when Mode_1 =>
-- SCT capture register of capture channel
CAP0 : aliased CAP_Register;
-- SCT capture register of capture channel
CAP1 : aliased CAP_Register;
-- SCT capture register of capture channel
CAP2 : aliased CAP_Register;
-- SCT capture register of capture channel
CAP3 : aliased CAP_Register;
-- SCT capture register of capture channel
CAP4 : aliased CAP_Register;
-- SCT capture register of capture channel
CAP5 : aliased CAP_Register;
-- SCT capture register of capture channel
CAP6 : aliased CAP_Register;
-- SCT capture register of capture channel
CAP7 : aliased CAP_Register;
-- SCT capture register of capture channel
CAP8 : aliased CAP_Register;
-- SCT capture register of capture channel
CAP9 : aliased CAP_Register;
-- SCT capture register of capture channel
CAP10 : aliased CAP_Register;
-- SCT capture register of capture channel
CAP11 : aliased CAP_Register;
-- SCT capture register of capture channel
CAP12 : aliased CAP_Register;
-- SCT capture register of capture channel
CAP13 : aliased CAP_Register;
-- SCT capture register of capture channel
CAP14 : aliased CAP_Register;
-- SCT capture register of capture channel
CAP15 : aliased CAP_Register;
-- SCT capture control register
CAPCTRL0 : aliased CAPCTRL_Register;
-- SCT capture control register
CAPCTRL1 : aliased CAPCTRL_Register;
-- SCT capture control register
CAPCTRL2 : aliased CAPCTRL_Register;
-- SCT capture control register
CAPCTRL3 : aliased CAPCTRL_Register;
-- SCT capture control register
CAPCTRL4 : aliased CAPCTRL_Register;
-- SCT capture control register
CAPCTRL5 : aliased CAPCTRL_Register;
-- SCT capture control register
CAPCTRL6 : aliased CAPCTRL_Register;
-- SCT capture control register
CAPCTRL7 : aliased CAPCTRL_Register;
-- SCT capture control register
CAPCTRL8 : aliased CAPCTRL_Register;
-- SCT capture control register
CAPCTRL9 : aliased CAPCTRL_Register;
-- SCT capture control register
CAPCTRL10 : aliased CAPCTRL_Register;
-- SCT capture control register
CAPCTRL11 : aliased CAPCTRL_Register;
-- SCT capture control register
CAPCTRL12 : aliased CAPCTRL_Register;
-- SCT capture control register
CAPCTRL13 : aliased CAPCTRL_Register;
-- SCT capture control register
CAPCTRL14 : aliased CAPCTRL_Register;
-- SCT capture control register
CAPCTRL15 : aliased CAPCTRL_Register;
when Mode_2 =>
-- SCT match value register of match channels
MATCH0 : aliased MATCH_Register;
-- SCT match value register of match channels
MATCH1 : aliased MATCH_Register;
-- SCT match value register of match channels
MATCH2 : aliased MATCH_Register;
-- SCT match value register of match channels
MATCH3 : aliased MATCH_Register;
-- SCT match value register of match channels
MATCH4 : aliased MATCH_Register;
-- SCT match value register of match channels
MATCH5 : aliased MATCH_Register;
-- SCT match value register of match channels
MATCH6 : aliased MATCH_Register;
-- SCT match value register of match channels
MATCH7 : aliased MATCH_Register;
-- SCT match value register of match channels
MATCH8 : aliased MATCH_Register;
-- SCT match value register of match channels
MATCH9 : aliased MATCH_Register;
-- SCT match value register of match channels
MATCH10 : aliased MATCH_Register;
-- SCT match value register of match channels
MATCH11 : aliased MATCH_Register;
-- SCT match value register of match channels
MATCH12 : aliased MATCH_Register;
-- SCT match value register of match channels
MATCH13 : aliased MATCH_Register;
-- SCT match value register of match channels
MATCH14 : aliased MATCH_Register;
-- SCT match value register of match channels
MATCH15 : aliased MATCH_Register;
-- SCT match reload value register
MATCHREL0 : aliased MATCHREL_Register;
-- SCT match reload value register
MATCHREL1 : aliased MATCHREL_Register;
-- SCT match reload value register
MATCHREL2 : aliased MATCHREL_Register;
-- SCT match reload value register
MATCHREL3 : aliased MATCHREL_Register;
-- SCT match reload value register
MATCHREL4 : aliased MATCHREL_Register;
-- SCT match reload value register
MATCHREL5 : aliased MATCHREL_Register;
-- SCT match reload value register
MATCHREL6 : aliased MATCHREL_Register;
-- SCT match reload value register
MATCHREL7 : aliased MATCHREL_Register;
-- SCT match reload value register
MATCHREL8 : aliased MATCHREL_Register;
-- SCT match reload value register
MATCHREL9 : aliased MATCHREL_Register;
-- SCT match reload value register
MATCHREL10 : aliased MATCHREL_Register;
-- SCT match reload value register
MATCHREL11 : aliased MATCHREL_Register;
-- SCT match reload value register
MATCHREL12 : aliased MATCHREL_Register;
-- SCT match reload value register
MATCHREL13 : aliased MATCHREL_Register;
-- SCT match reload value register
MATCHREL14 : aliased MATCHREL_Register;
-- SCT match reload value register
MATCHREL15 : aliased MATCHREL_Register;
end case;
end record
with Unchecked_Union, Volatile;
for SCT0_Peripheral use record
CONFIG at 16#0# range 0 .. 31;
CTRL at 16#4# range 0 .. 31;
LIMIT at 16#8# range 0 .. 31;
HALT at 16#C# range 0 .. 31;
STOP at 16#10# range 0 .. 31;
START at 16#14# range 0 .. 31;
COUNT at 16#40# range 0 .. 31;
STATE at 16#44# range 0 .. 31;
INPUT at 16#48# range 0 .. 31;
REGMODE at 16#4C# range 0 .. 31;
OUTPUT at 16#50# range 0 .. 31;
OUTPUTDIRCTRL at 16#54# range 0 .. 31;
RES at 16#58# range 0 .. 31;
DMAREQ0 at 16#5C# range 0 .. 31;
DMAREQ1 at 16#60# range 0 .. 31;
EVEN at 16#F0# range 0 .. 31;
EVFLAG at 16#F4# range 0 .. 31;
CONEN at 16#F8# range 0 .. 31;
CONFLAG at 16#FC# range 0 .. 31;
EV at 16#300# range 0 .. 1023;
OUT_k at 16#500# range 0 .. 639;
CAP0 at 16#100# range 0 .. 31;
CAP1 at 16#104# range 0 .. 31;
CAP2 at 16#108# range 0 .. 31;
CAP3 at 16#10C# range 0 .. 31;
CAP4 at 16#110# range 0 .. 31;
CAP5 at 16#114# range 0 .. 31;
CAP6 at 16#118# range 0 .. 31;
CAP7 at 16#11C# range 0 .. 31;
CAP8 at 16#120# range 0 .. 31;
CAP9 at 16#124# range 0 .. 31;
CAP10 at 16#128# range 0 .. 31;
CAP11 at 16#12C# range 0 .. 31;
CAP12 at 16#130# range 0 .. 31;
CAP13 at 16#134# range 0 .. 31;
CAP14 at 16#138# range 0 .. 31;
CAP15 at 16#13C# range 0 .. 31;
CAPCTRL0 at 16#200# range 0 .. 31;
CAPCTRL1 at 16#204# range 0 .. 31;
CAPCTRL2 at 16#208# range 0 .. 31;
CAPCTRL3 at 16#20C# range 0 .. 31;
CAPCTRL4 at 16#210# range 0 .. 31;
CAPCTRL5 at 16#214# range 0 .. 31;
CAPCTRL6 at 16#218# range 0 .. 31;
CAPCTRL7 at 16#21C# range 0 .. 31;
CAPCTRL8 at 16#220# range 0 .. 31;
CAPCTRL9 at 16#224# range 0 .. 31;
CAPCTRL10 at 16#228# range 0 .. 31;
CAPCTRL11 at 16#22C# range 0 .. 31;
CAPCTRL12 at 16#230# range 0 .. 31;
CAPCTRL13 at 16#234# range 0 .. 31;
CAPCTRL14 at 16#238# range 0 .. 31;
CAPCTRL15 at 16#23C# range 0 .. 31;
MATCH0 at 16#100# range 0 .. 31;
MATCH1 at 16#104# range 0 .. 31;
MATCH2 at 16#108# range 0 .. 31;
MATCH3 at 16#10C# range 0 .. 31;
MATCH4 at 16#110# range 0 .. 31;
MATCH5 at 16#114# range 0 .. 31;
MATCH6 at 16#118# range 0 .. 31;
MATCH7 at 16#11C# range 0 .. 31;
MATCH8 at 16#120# range 0 .. 31;
MATCH9 at 16#124# range 0 .. 31;
MATCH10 at 16#128# range 0 .. 31;
MATCH11 at 16#12C# range 0 .. 31;
MATCH12 at 16#130# range 0 .. 31;
MATCH13 at 16#134# range 0 .. 31;
MATCH14 at 16#138# range 0 .. 31;
MATCH15 at 16#13C# range 0 .. 31;
MATCHREL0 at 16#200# range 0 .. 31;
MATCHREL1 at 16#204# range 0 .. 31;
MATCHREL2 at 16#208# range 0 .. 31;
MATCHREL3 at 16#20C# range 0 .. 31;
MATCHREL4 at 16#210# range 0 .. 31;
MATCHREL5 at 16#214# range 0 .. 31;
MATCHREL6 at 16#218# range 0 .. 31;
MATCHREL7 at 16#21C# range 0 .. 31;
MATCHREL8 at 16#220# range 0 .. 31;
MATCHREL9 at 16#224# range 0 .. 31;
MATCHREL10 at 16#228# range 0 .. 31;
MATCHREL11 at 16#22C# range 0 .. 31;
MATCHREL12 at 16#230# range 0 .. 31;
MATCHREL13 at 16#234# range 0 .. 31;
MATCHREL14 at 16#238# range 0 .. 31;
MATCHREL15 at 16#23C# range 0 .. 31;
end record;
-- SCTimer/PWM (SCT)
SCT0_Periph : aliased SCT0_Peripheral
with Import, Address => System'To_Address (16#40085000#);
end NXP_SVD.SCT;
|
with Ada.Containers.Vectors;
with Ada.Containers.Indefinite_Hashed_Maps;
with Ada.Strings.Hash;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
package Generator.Match_Pattern_Specific is
use Ada.Containers;
package List_String is new Vectors (Positive, Unbounded_String);
function Equivalent_Key (Left, Right : String) return Boolean;
function Equivalent_Value (Left, Right : List_String.Vector) return Boolean;
package Mapping_Single_Map is new Indefinite_Hashed_Maps
(Key_Type => String, Element_Type => List_String.Vector,
Hash => Ada.Strings.Hash, Equivalent_Keys => Equivalent_Key,
"=" => Equivalent_Value);
procedure Append
(Map : in out Mapping_Single_Map.Map; Key : String; Value : String);
procedure Process_Node_Kinds;
procedure Process_Type_Decl;
procedure Process_Subp;
procedure Generate_Match_Specific;
procedure Main;
end Generator.Match_Pattern_Specific;
|
with EU_Projects.Nodes.Partners;
with EU_Projects.Times.Time_Expressions;
with EU_Projects.Event_Names;
with EU_Projects.Node_Tables;
with EU_Projects.Efforts;
--
-- An action node is a basic node that represent an activity, that is, a WP
-- or a task. An action has
--
-- * A leader
-- * An activity interval with begin and end dates
--
-- Actually, there is the necessity of two types of begin/end dates. At
-- the beginning the activity dates can be expressed in symbolic, e.g.,
-- the begin date of a task is the largest of the end dates of two
-- other tasks.
--
-- The constraints expressed in this way will be mapped to absolute
-- dates by solving the corrispondent system of equations. After that, the
-- symbolic dates need to be changed to their "absolute" counterpart. The
-- symbolic dates are set during creation time, while the absolute times need
-- to be fixed after all the project has been set.
--
-- Because of this, an Action_Node has two states: if the absolute
-- action times have been fixed or not. Absolute times can be fixed
-- only once.
--
package EU_Projects.Nodes.Action_Nodes is
type Action_Node is abstract new Node_Type with private;
type Instant_Raw is new String;
type Duration_Raw is new String;
type Action_Time is private;
function Create (Start_On : Instant_Raw;
End_On : Instant_Raw)
return Action_Time;
function Create (Depends_On : Node_Label_Lists.Vector;
End_On : Instant_Raw)
return Action_Time;
function Create (Start_On : Instant_Raw;
Duration : Duration_Raw)
return Action_Time;
function Create (Depends_On : Node_Label_Lists.Vector;
Duration : Duration_Raw)
return Action_Time;
function Starting_Time (Item : Action_Node) return Times.Instant
with Pre => Item.Is_Fixed (Event_Names.Begin_Name);
function Ending_Time (Item : Action_Node) return Times.Instant
with Pre => Item.Is_Fixed (Event_Names.End_Name);
function Timing (Item : Action_Node) return String;
function Leader (Item : Action_Node) return Partners.Partner_Label;
overriding function Variables (Item : Action_Node) return Variable_List;
overriding procedure Parse_Raw_Expressions
(Item : in out Action_Node;
Vars : Times.Time_Expressions.Parsing.Symbol_Table);
overriding function Is_Variable (Item : Action_Node;
Var : Simple_Identifier) return Boolean;
overriding function Is_A (Item : Action_Node;
Var : Simple_Identifier;
Class : Times.Time_Type)
return Boolean;
overriding function Is_Fixed (Item : Action_Node;
Var : Simple_Identifier)
return Boolean;
overriding procedure Fix_Instant
(Item : in out Action_Node;
Var : Simple_Identifier;
Value : Times.Instant);
overriding function Get_Symbolic_Instant
(Item : Action_Node;
Var : Simple_Identifier)
return Times.Time_Expressions.Symbolic_Instant;
overriding function Get_Symbolic_Duration
(Item : Action_Node;
Var : Simple_Identifier)
return Times.Time_Expressions.Symbolic_Duration;
procedure Add_Effort (Item : in out Action_Node;
Partner : in Nodes.Partners.Partner_Label;
PM : in Efforts.Person_Months);
function Effort_Of (Item : Action_Node;
Partner : Nodes.Partners.Partner_Label)
return Efforts.Person_Months;
type Effort_Entry is
record
Partner : Nodes.Partners.Partner_Label;
Effort : Efforts.Person_Months;
end record;
type Effort_List is array (Partners.Partner_Index range <>) of Effort_Entry;
function Efforts_Of (Item : Action_Node;
Names : Partners.Partner_Name_Array) return Effort_List;
Duplicated_Effort : exception;
Unknown_Partner : exception;
private
use type Times.Time_Expressions.Symbolic_Instant;
use type Times.Time_Expressions.Symbolic_Duration;
use type Times.Time_Type;
type Action_Time is
record
Start : Unbounded_String;
Stop : Unbounded_String;
Duration : Unbounded_String;
end record
with Type_Invariant => (if Stop = Null_Unbounded_String
then Duration /= Null_Unbounded_String
else Duration = Null_Unbounded_String);
function Var_Begin (Item : Action_Node) return Times.Time_Expressions.Symbolic_Instant;
function Var_End (Item : Action_Node) return Times.Time_Expressions.Symbolic_Instant;
function Var_Duration (Item : Action_Node) return Times.Time_Expressions.Symbolic_Duration;
procedure Initialize_Efforts (Item : in out Action_Node;
Node_Dir : Node_Tables.Node_Table);
type Action_Node is abstract
new Node_Type
with
record
Raw_Time : Action_Time;
Start_Symbolic : Times.Time_Expressions.Symbolic_Instant;
Stop_Symbolic : Times.Time_Expressions.Symbolic_Instant;
Duration_Symbolic : Times.Time_Expressions.Symbolic_Duration;
Start_At : Times.Instant;
Stop_At : Times.Instant;
Elapsed_Time : Times.Duration;
Start_Fixed : Boolean := False;
Stop_Fixed : Boolean := False;
Leader : Nodes.Partners.Partner_Label;
Partner_Effort : Efforts.Effort_Maps.Map;
end record;
function To_U (X : Instant_Raw) return Unbounded_String
is (To_Unbounded_String (String (X)));
function To_U (X : Duration_Raw) return Unbounded_String
is (To_Unbounded_String (String (X)));
function After (List : Node_Label_Lists.Vector)
return Instant_Raw;
function Create (Start_On : Instant_Raw;
End_On : Instant_Raw)
return Action_Time
is (Start => To_U (Start_On), Stop => To_U (End_On), Duration => Null_Unbounded_String);
function Create (Depends_On : Node_Label_Lists.Vector;
End_On : Instant_Raw)
return Action_Time
is (Create (After (Depends_On), End_On));
function Create (Start_On : Instant_Raw;
Duration : Duration_Raw)
return Action_Time
is (Start => To_U (Start_On), Stop => Null_Unbounded_String, Duration => To_U (Duration));
function Create (Depends_On : Node_Label_Lists.Vector;
Duration : Duration_Raw)
return Action_Time
is (Create (After (Depends_On), Duration));
function Leader (Item : Action_Node) return Partners.Partner_Label
is (Item.Leader);
function Starting_Time (Item : Action_Node) return Times.Instant
is (Item.Start_At);
function Ending_Time (Item : Action_Node) return Times.Instant
is (Item.Stop_At);
function Timing (Item : Action_Node) return String
is ("M" & Times.Image (Item.Starting_Time) & "-M" & Times.Image (Item.Ending_Time));
-- function Event_Var (Item : Action_Node;
-- Event : Event_Type) return Identifier
-- is (case Event is
-- when Start => Item.Starting_Time_Var,
-- when Stop => Item.Ending_Time_Var);
--
-- function Event_Time (Item : Action_Node;
-- Event : Event_Type) return Times.Instant
-- is (case Event is
-- when Start => Item.Starting_Time,
-- when Stop => Item.Ending_Time);
function Variables (Item : Action_Node) return Variable_List
is ((1 => Event_Names.Begin_Name,
2 => Event_Names.End_Name,
3 => Event_Names.Duration_Name));
function Is_Variable (Item : Action_Node;
Var : Simple_Identifier) return Boolean
is (Var = Event_Names.Begin_Name
or Var = Event_Names.End_Name
or Var = Event_Names.Duration_Name);
function Is_A (Item : Action_Node;
Var : Simple_Identifier;
Class : Times.Time_Type)
return Boolean
is (if Var = Event_Names.Begin_Name or Var = Event_Names.End_Name then
Class = Times.Instant_Value
elsif Var = Event_Names.Duration_Name then
Class = Times.Duration_Value
else
False);
function Is_Fixed (Item : Action_Node;
Var : Simple_Identifier)
return Boolean
is (if Var = Event_Names.Begin_Name then
Item.Start_Fixed
elsif Var = Event_Names.End_Name then
Item.Stop_Fixed
elsif Var = Event_Names.Duration_Name then
Item.Start_Fixed and Item.Stop_Fixed
else
raise Constraint_Error);
overriding function Get_Symbolic_Instant
(Item : Action_Node;
Var : Simple_Identifier)
return Times.Time_Expressions.Symbolic_Instant
is (if Var = Event_Names.Begin_Name then
Item.Start_Symbolic
elsif Var = Event_Names.End_Name then
Item.Stop_Symbolic
else
raise Unknown_Instant_Var);
overriding function Get_Symbolic_Duration
(Item : Action_Node;
Var : Simple_Identifier)
return Times.Time_Expressions.Symbolic_Duration
is (if Var = Event_Names.Duration_Name then
Item.Duration_Symbolic
else
raise Unknown_Duration_Var);
function Effort_Of (Item : Action_Node;
Partner : Nodes.Partners.Partner_Label)
return Efforts.Person_Months
is (if Item.Partner_Effort.Contains (Partner) then
Item.Partner_Effort (Partner)
else
raise Unknown_Partner);
end EU_Projects.Nodes.Action_Nodes;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.