content stringlengths 23 1.05M |
|---|
package body EU_Projects.Nodes.Timed_Nodes is
procedure Due_On (Item : in out Timed_Node;
Time : in String)
is
begin
Item.Expected_Raw := To_Unbounded_String (Time);
-- Times.Time_Expressions.Symbolic (Time);
end Due_On;
procedure Parse_Raw_Expressions (Item : in out Timed_Node;
Vars : Times.Time_Expressions.Parsing.Symbol_Table)
is
use Times.Time_Expressions.Parsing;
To_Parse : constant String :=
(if Item.Expected_Raw = Event_Names.Default_Time
then
After (Timed_Node'Class (Item).Dependency_List,
Timed_Node'Class (Item).Dependency_Ready_Var)
else
To_String (Item.Expected_Raw));
begin
Item.Expected_Symbolic := Parse (Input => To_Parse,
Symbols => Vars);
end Parse_Raw_Expressions;
overriding procedure Fix_Instant
(Item : in out Timed_Node;
Var : Simple_Identifier;
Value : Times.Instant)
is
begin
if Var = Event_Names.Event_Time_Name then
Item.Expected_On := Value;
else
raise Unknown_Instant_Var with To_String (Var);
end if;
Item.Fixed := True;
end Fix_Instant;
--------------
-- Is_Fixed --
--------------
overriding function Is_Fixed (Item : Timed_Node;
Var : Simple_Identifier)
return Boolean
is
begin
if Var = Event_Names.Event_Time_Name then
return Item.Fixed;
else
raise Unknown_Var with To_String (Var);
end if;
end Is_Fixed;
end EU_Projects.Nodes.Timed_Nodes;
|
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Strings.Bounded;
package EU_Projects.Identifiers is
type Identifier is private;
function "=" (X, Y : Identifier) return Boolean;
function "<" (X, Y : Identifier) return Boolean;
function Join (X, Y : Identifier) return Identifier;
-- A valid identifier:
-- * every character is a letter, a digit or an underscore
-- * the first character must be a letter
-- * the last character cannot be an underscore
-- * it cannot have two consecutive underscores
function Is_Valid_Identifier (X : String) return Boolean
is (
(X'Length > 0)
and then (Is_Letter (X (X'First))
and Is_Alphanumeric (X (X'Last)))
and then (for all I in X'Range =>
(Is_Alphanumeric (X (I))
or (X (I) = '_' and Is_Alphanumeric (X (I + 1)))))
);
function To_ID (X : String) return Identifier
with Pre => Is_Valid_Identifier (X);
function Image (X : Identifier) return String;
Bad_Identifier : exception;
private
package ID_Names is new
Ada.Strings.Bounded.Generic_Bounded_Length (16);
use type ID_Names.Bounded_String;
type Identifier is
record
ID : ID_Names.Bounded_String;
end record;
function Image (X : Identifier) return String
is (ID_Names.To_String (ID_Names.Bounded_String (X.ID)));
function "=" (X, Y : Identifier) return Boolean
is (ID_Names.Bounded_String (X.ID) = ID_Names.Bounded_String (Y.ID));
function "<" (X, Y : Identifier) return Boolean
is (ID_Names.Bounded_String (X.ID) > ID_Names.Bounded_String (Y.ID));
function Join (X, Y : Identifier) return Identifier
is (ID => X.ID & "." & Y.ID);
end EU_Projects.Identifiers;
|
--
-- PLAYMUS: Port to the Ada programming language of a test application for the
-- the SDL mixer library.
--
-- The original code was written in C by Sam Lantinga http://www.libsdl.org.
--
-- 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.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
--
-- Ada code written by:
-- Antonio M. F. Vargas --
-- Ponta Delgada - Azores - Portugal --
-- E-mail: avargas@adapower.net --
-- http://www.adapower.net/~avargas --
with System.OS_Interface;
with Interfaces.C;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Command_Line;
with Ada.Characters.Handling;
with Ada.Strings.Unbounded;
with GNAT.OS_Lib;
with Lib_C;
with SDL.Timer;
with SDL.Types; use SDL.Types;
with SDL.Audio;
with SDL.Quit;
with SDL_Mixer;
with PlayMus_Sprogs;
use PlayMus_Sprogs;
procedure PlayMus is
package C renames Interfaces.C;
use type C.int;
package CL renames Ada.Command_Line;
package US renames Ada.Strings.Unbounded;
package CH renames Ada.Characters.Handling;
package A renames SDL.Audio;
use type A.Format_Flag;
package T renames SDL.Timer;
package Mix renames SDL_Mixer;
use type Mix.Music_ptr;
argv0 : US.Unbounded_String;
-- ======================================
procedure Usage (argv0 : US.Unbounded_String) is
begin
Put_Line ("Usage: " & US.To_String (argv0)
& " [-i] [-l] [-8] [-r rate] [-b buffers] [-s] <musicfile>");
end Usage;
-- ======================================
procedure Menu is
buf : Character;
begin
Put_Line ("Available commands: (p)ause (r)esume (h)alt > ");
Get_Immediate (buf);
Put_Line ("buf is: " & buf);
case buf is
when 'p' | 'P' => Mix.PauseMusic;
when 'r' | 'R' => Mix.ResumeMusic;
when 'h' | 'H' => Mix.HaltMusic;
when others => null;
end case;
Put ("Music playing: ");
if Mix.PlayingMusic /= 0 then
Put ("yes");
else
Put ("no");
end if;
Put (" Paused: ");
if Mix.PausedMusic /= 0 then
Put_Line ("yes");
else
Put_Line ("no");
end if;
end Menu;
-- ======================================
audio_rate : C.int;
audio_format : A.Format_Flag;
audio_channels : C.int;
audio_buffers : C.int;
looping : C.int := 0;
interactive : Boolean := False;
i : Integer;
begin
-- Initialize variables
audio_rate := 22050;
audio_format := A.AUDIO_S16;
audio_channels := 2;
audio_buffers := 4096;
-- Check command line usage
i := 1;
while (i <= CL.Argument_Count)
and then (CL.Argument (i) (1) = '-') loop
if CL.Argument (i) = "-r"
and then CL.Argument_Count >= i + 1
and then CH.Is_Digit (CL.Argument (i + 1) (1)) then
i := i + 1;
declare
package int_IO is new Ada.Text_IO.Integer_IO (C.int);
use int_IO;
last : Positive;
begin
Get (CL.Argument (i), audio_rate, last);
end;
elsif CL.Argument (i) = "-b"
and then CL.Argument_Count >= i + 1
and then CH.Is_Digit (CL.Argument (i + 1) (1)) then
i := i + 1;
declare
package int_IO is new Ada.Text_IO.Integer_IO (C.int);
use int_IO;
last : Positive;
begin
Get (CL.Argument (i), audio_buffers, last);
end;
elsif CL.Argument (i) = "-m" then
audio_channels := 1;
elsif CL.Argument (i) = "-l" then
looping := -1;
elsif CL.Argument (i) = "-i" then
interactive := True;
elsif CL.Argument (i) = "-8" then
audio_format := A.AUDIO_U8;
else
Usage (US.To_Unbounded_String (CL.Command_Name));
GNAT.OS_Lib.OS_Exit (1);
end if;
i := i + 1;
end loop;
if CL.Argument_Count < i then
Usage (US.To_Unbounded_String (CL.Command_Name));
GNAT.OS_Lib.OS_Exit (1);
end if;
-- Initialize the SDL library
if SDL.Init (SDL.INIT_AUDIO) < 0 then
Put_Line ("Couldn't initialize SDL: " & Mix.Get_Error);
GNAT.OS_Lib.OS_Exit (255);
end if;
SDL.Quit.atexit (CleanUp'Access);
Lib_C.Set_Signal (System.OS_Interface.SIGINT, the_exit'Access);
Lib_C.Set_Signal (System.OS_Interface.SIGTERM, the_exit'Access);
-- Open the audio device
if Mix.OpenAudio (audio_rate, audio_format, audio_channels, audio_buffers) < 0 then
Put_Line ("Couldn't open audio: " & Mix.Get_Error);
GNAT.OS_Lib.OS_Exit (2);
else
Mix.Query_Spec (audio_rate, audio_format, audio_channels);
Put ("Opened audio at " & C.int'Image (audio_rate)
& " Hz " & A.Format_Flag'Image (audio_format and 16#FF#) & " bit ");
if audio_channels > 1 then
Put ("stereo, ");
else
Put ("mono, ");
end if;
Put_Line (C.int'Image (audio_buffers) & " bytes audio buffer");
end if;
audio_open := True;
-- Set the external music player, if any
Mix.Set_Music_CMD (GNAT.OS_Lib.Getenv ("MUSIC_CMD").all);
-- Load the requested music file
music := Mix.Load_MUS (CL.Argument (i));
if music = Mix.null_Music_ptr then
Put_Line ("Couldn't load " & CL.Argument (i) & ": " & Mix.Get_Error);
GNAT.OS_Lib.OS_Exit (2);
end if;
-- Play and then exit
Mix.FadeInMusic (music, looping, 4000);
while Mix.PlayingMusic /= 0 or Mix.PausedMusic /= 0 loop
if interactive then
Menu;
else
T.SDL_Delay (100);
end if;
end loop;
GNAT.OS_Lib.OS_Exit (0);
end PlayMus;
|
with Ada.Strings.Unbounded;
use Ada.Strings.Unbounded;
package body Gilded_Rose is
procedure Update_Quality(Self : in out Gilded_Rose) is
Cursor : Item_Vecs.Cursor := Item_Vecs.First(Self.Items);
begin
while Item_Vecs.Has_Element(Cursor) loop
if Self.Items(Cursor).Name /= To_Unbounded_String("Aged Brie")
and Self.Items(Cursor).Name /= To_Unbounded_String("Backstage passes to a TAFKAL80ETC concert") then
if Self.Items(Cursor).Quality > 0 then
if Self.Items(Cursor).Name /= To_Unbounded_String("Sulfuras, Hand of Ragnaros") then
Self.Items(Cursor).Quality := Self.Items(Cursor).Quality - 1;
end if;
end if;
else
if Self.Items(Cursor).Quality < 50 then
Self.Items(Cursor).Quality := Self.Items(Cursor).Quality + 1;
if Self.Items(Cursor).Name = To_Unbounded_String("Backstage passes to a TAFKAL80ETC concert") then
if Self.Items(Cursor).Sell_In < 11 then
if Self.Items(Cursor).Quality < 50 then
Self.Items(Cursor).Quality := Self.Items(Cursor).Quality + 1;
end if;
end if;
if Self.Items(Cursor).Sell_In < 6 then
if Self.Items(Cursor).Quality < 50 then
Self.Items(Cursor).Quality := Self.Items(Cursor).Quality + 1;
end if;
end if;
end if;
end if;
end if;
if Self.Items(Cursor).Name /= To_Unbounded_String("Sulfuras, Hand of Ragnaros") then
Self.Items(Cursor).Sell_In := Self.Items(Cursor).Sell_In - 1;
end if;
if Self.Items(Cursor).Sell_In < 0 then
if Self.Items(Cursor).Name /= To_Unbounded_String("Aged Brie") then
if Self.Items(Cursor).Name /= To_Unbounded_String("Backstage passes to a TAFKAL80ETC concert") then
if Self.Items(Cursor).Quality > 0 then
if Self.Items(Cursor).Name /= To_Unbounded_String("Sulfuras, Hand of Ragnaros") then
Self.Items(Cursor).Quality := Self.Items(Cursor).Quality - 1;
end if;
end if;
else
Self.Items(Cursor).Quality := Self.Items(Cursor).Quality - Self.Items(Cursor).Quality;
end if;
else
if Self.Items(Cursor).Quality < 50 then
Self.Items(Cursor).Quality := Self.Items(Cursor).Quality + 1;
end if;
end if;
end if;
Item_Vecs.Next(Cursor);
end loop;
end;
end Gilded_Rose;
|
-- AoC 2019, Day 1
with Ada.Text_IO;
with Ada.Containers.Vectors;
package body Day1 is
package TIO renames Ada.Text_IO;
package Module_Vectors is new Ada.Containers.Vectors
(Index_Type => Natural,
Element_Type => Mass);
modules : Module_Vectors.Vector;
procedure load_modules(filename : in String) is
file : TIO.File_Type;
begin
TIO.open(File => file, Mode => TIO.In_File, Name => filename);
while not TIO.end_of_file(file) loop
modules.append(Mass'Value(TIO.get_line(file)));
end loop;
TIO.close(file);
end load_modules;
function fuel_required(weight : in Mass) return Integer is
begin
return Integer(Float'Floor(Float(weight) / 3.0) - 2.0);
end fuel_required;
function fuel_for_modules return Mass is
total : Mass := 0;
begin
for m of modules loop
total := total + Mass(fuel_required(m));
end loop;
return total;
end fuel_for_modules;
function recursive_fuel_required(weight : in Mass) return Mass is
total : Mass := weight;
remaining : Integer := Integer(weight);
begin
while remaining > 0 loop
remaining := fuel_required(Mass(remaining));
if remaining > 0 then
total := total + Mass(remaining);
end if;
end loop;
return total;
end recursive_fuel_required;
function total_fuel return Mass is
module_fuel : Mass;
all_fuel : Mass;
total : Mass := 0;
begin
for m of modules loop
module_fuel := Mass(fuel_required(m));
all_fuel := recursive_fuel_required(module_fuel);
total := total + all_fuel;
end loop;
return total;
end total_fuel;
end day1;
|
package body Generic_Root is
procedure Compute_Root(N: Number;
Root, Persistence: out Number;
Base: Base_Type := 10) is
function Digit_Sum(N: Number) return Number is
begin
if N < Number(Base) then
return N;
else
return (N mod Number(Base)) & Digit_Sum(N / Number(Base));
end if;
end Digit_Sum;
begin
if N < Number(Base) then
Root := N;
Persistence := 0;
else
Compute_Root(Digit_Sum(N), Root, Persistence, Base);
Persistence := Persistence + 1;
end if;
end Compute_Root;
end Generic_Root;
|
-----------------------------------------------------------------------
-- wiki-plugins-template -- Template Plugin
-- Copyright (C) 2016, 2020 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
with Wiki.Strings;
-- === Template Plugins ===
-- The `Wiki.Plugins.Templates` package defines an abstract template plugin.
-- To use the template plugin, the `Get_Template` procedure must be implemented.
-- It is responsible for getting the template content according to the plugin parameters.
--
package Wiki.Plugins.Templates is
type Template_Plugin is abstract new Wiki_Plugin with null record;
-- Get the template content for the plugin evaluation.
procedure Get_Template (Plugin : in out Template_Plugin;
Params : in out Wiki.Attributes.Attribute_List;
Template : out Wiki.Strings.UString) is abstract;
-- Expand the template configured with the parameters for the document.
-- The <tt>Get_Template</tt> operation is called and the template content returned
-- by that operation is parsed in the current document. Template parameters are passed
-- in the <tt>Context</tt> instance and they can be evaluated within the template
-- while parsing the template content.
overriding
procedure Expand (Plugin : in out Template_Plugin;
Document : in out Wiki.Documents.Document;
Params : in out Wiki.Attributes.Attribute_List;
Context : in out Plugin_Context);
type File_Template_Plugin is new Wiki_Plugin and Plugin_Factory with private;
-- Find a plugin knowing its name.
overriding
function Find (Factory : in File_Template_Plugin;
Name : in String) return Wiki_Plugin_Access;
-- Set the directory path that contains template files.
procedure Set_Template_Path (Plugin : in out File_Template_Plugin;
Path : in String);
-- Expand the template configured with the parameters for the document.
-- Read the file whose basename correspond to the first parameter and parse that file
-- in the current document. Template parameters are passed
-- in the <tt>Context</tt> instance and they can be evaluated within the template
-- while parsing the template content.
overriding
procedure Expand (Plugin : in out File_Template_Plugin;
Document : in out Wiki.Documents.Document;
Params : in out Wiki.Attributes.Attribute_List;
Context : in out Plugin_Context);
private
type File_Template_Plugin is new Wiki_Plugin and Plugin_Factory with record
Path : Ada.Strings.Unbounded.Unbounded_String;
end record;
end Wiki.Plugins.Templates;
|
-- { dg-do run }
with Text_IO; use Text_IO;
with Ada.Finalization; use Ada.Finalization;
procedure Nested_Controlled_Alloc is
package Controlled_Alloc is
type Fin is new Limited_Controlled with null record;
procedure Finalize (X : in out Fin);
F : Fin;
type T is limited private;
type Ref is access all T;
private
type T is new Limited_Controlled with null record;
procedure Finalize (X : in out T);
end Controlled_Alloc;
package body Controlled_Alloc is
procedure Finalize (X : in out T) is
begin
Put_Line ("Finalize (T)");
end Finalize;
procedure Finalize (X : in out Fin) is
R : Ref;
begin
begin
R := new T;
raise Constraint_Error;
exception
when Program_Error =>
null; -- OK
end;
end Finalize;
end Controlled_Alloc;
begin
null;
end Nested_Controlled_Alloc;
|
with Interfaces; use Interfaces;
with Interfaces.C; use Interfaces.C;
with Bitmap_Graphics; use Bitmap_Graphics;
package OLED_SH1106 is
function Start_Driver return Boolean;
procedure Stop_Driver ;
procedure Init_Display;
procedure Show;
-- Graphics Routine.
procedure Clear
(Clr: Color:= Black);
procedure Dot
(P: Point; Size: Positive:= 1; Clr: Color:= White);
procedure Line
(P,Q: Point; Size: Positive:= 1; Clr: Color:= White);
procedure Rectangle
(P, Q: Point; Size: Positive:= 1; Clr: Color:= White);
procedure Fill_Rectangle
(P, Q: Point; Clr: Color := White);
procedure Circle
(Center: Point; R:Natural; Size: Positive := 1; Clr: Color:= White);
procedure Fill_Circle
(Center: Point; R: Natural; Clr: Color:= White);
procedure Put
(P : Point;
Ch : Character;
Size : Positive:= 12;
Fgnd : Color := White;
Bgnd : Color := Black);
procedure Put
(P : Point;
Text : String;
Size : Positive:= 12;
Fgnd : Color := White;
Bgnd : Color := Black);
procedure Put
(P : Point;
Num : Natural;
Size : Positive := 12;
Fgnd : Color:= White;
Bgnd : Color:= Black);
procedure Bitmap
(P: Point; Bytes : Byte_Array_Access; S: Size);
procedure Bitmap
(P: Point; Icon: Bitmap_Icon);
end OLED_SH1106;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2017, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
-- This package provides a user friendly interface to the file system. For
-- more info, see the file system chapter of the documentation.
with System;
with HAL.Block_Drivers;
with HAL.Filesystem;
package File_IO is
MAX_PATH_LENGTH : constant := 1024;
-- Maximum size of a path name length
type Status_Code is
(OK,
Non_Empty_Directory,
Disk_Error, -- A hardware error occurred in the low level disk I/O
Disk_Full,
Internal_Error,
Drive_Not_Ready,
No_Such_File,
No_Such_Path,
Not_Mounted, -- The mount point is invalid
Invalid_Name,
Access_Denied,
Already_Exists,
Invalid_Object_Entry,
Write_Protected,
Invalid_Drive,
No_Filesystem, -- The volume is not a FAT volume
Locked,
Too_Many_Open_Files, -- All available handles are used
Invalid_Parameter,
Input_Output_Error,
No_MBR_Found,
No_Partition_Found,
No_More_Entries,
Read_Only_File_System,
Operation_Not_Permitted);
type File_Mode is (Read_Only, Write_Only, Read_Write);
type Seek_Mode is
(
-- Seek from the beginning of the file, forward
From_Start,
-- Seek from the end of the file, backward
From_End,
-- Seek from the current position, forward
Forward,
-- Seek from the current position, backward
Backward);
type File_Size is new HAL.UInt64;
-- Modern fs all support 64-bit file size. Only old or limited ones support
-- max 32-bit (FAT in particular). So let's see big and not limit ourselves
-- in this API with 32-bit only.
type File_Descriptor is limited private;
function Open
(File : in out File_Descriptor;
Name : String;
Mode : File_Mode)
return Status_Code;
procedure Close (File : in out File_Descriptor);
function Is_Open (File : File_Descriptor)
return Boolean;
function Flush (File : File_Descriptor)
return Status_Code;
function Size (File : File_Descriptor)
return File_Size;
function Read (File : File_Descriptor;
Addr : System.Address;
Length : File_Size)
return File_Size;
function Write (File : File_Descriptor;
Addr : System.Address;
Length : File_Size)
return File_Size;
function Offset (File : File_Descriptor)
return File_Size;
function Seek
(File : in out File_Descriptor;
Origin : Seek_Mode;
Amount : in out File_Size) return Status_Code;
generic
type T is private;
function Generic_Write
(File : File_Descriptor;
Value : T) return Status_Code;
generic
type T is private;
function Generic_Read
(File : File_Descriptor;
Value : out T) return Status_Code;
type Directory_Descriptor is limited private;
function Open
(Dir : in out Directory_Descriptor;
Name : String)
return Status_Code;
procedure Close (Dir : in out Directory_Descriptor);
type Directory_Entry (Name_Length : Natural) is record
Name : String (1 .. Name_Length);
Subdirectory : Boolean;
Read_Only : Boolean;
Hidden : Boolean;
Symlink : Boolean;
Size : File_Size;
end record;
Invalid_Dir_Entry : constant Directory_Entry;
function Read (Dir : in out Directory_Descriptor)
return Directory_Entry;
procedure Reset (Dir : in out Directory_Descriptor);
function Create_File (Path : String) return Status_Code;
function Unlink (Path : String) return Status_Code;
function Remove_Directory (Path : String) return Status_Code;
function Copy_File (Source_Path, Destination_Path : String;
Buffer_Size : Positive := 512)
return Status_Code;
--------------
-- Mounting --
--------------
MAX_MOUNT_POINTS : constant := 2;
MAX_MOUNT_NAME_LENGTH : constant := 128;
subtype Mount_Path is String
with Dynamic_Predicate => Mount_Path'Length <= MAX_MOUNT_NAME_LENGTH;
function Mount_Volume
(Mount_Point : Mount_Path;
FS : HAL.Filesystem.Any_Filesystem_Driver) return Status_Code;
function Mount_Drive
(Mount_Point : Mount_Path;
Device : HAL.Block_Drivers.Any_Block_Driver) return Status_Code;
function Unmount (Mount_Point : Mount_Path) return Status_Code;
private
type File_Descriptor is limited record
Handle : HAL.Filesystem.Any_File_Handle := null;
end record;
type Directory_Descriptor is limited record
Handle : HAL.Filesystem.Any_Directory_Handle := null;
end record;
Invalid_Dir_Entry : constant Directory_Entry (Name_Length => 0) :=
(Name_Length => 0,
Name => "",
Subdirectory => False,
Read_Only => False,
Hidden => False,
Symlink => False,
Size => 0);
for Status_Code use
(OK => HAL.Filesystem.OK'Enum_Rep,
Non_Empty_Directory => HAL.Filesystem.Non_Empty_Directory'Enum_Rep,
Disk_Error => HAL.Filesystem.Disk_Error'Enum_Rep,
Disk_Full => HAL.Filesystem.Disk_Full'Enum_Rep,
Internal_Error => HAL.Filesystem.Internal_Error'Enum_Rep,
Drive_Not_Ready => HAL.Filesystem.Drive_Not_Ready'Enum_Rep,
No_Such_File => HAL.Filesystem.No_Such_File'Enum_Rep,
No_Such_Path => HAL.Filesystem.No_Such_Path'Enum_Rep,
Not_Mounted => HAL.Filesystem.Not_Mounted'Enum_Rep,
Invalid_Name => HAL.Filesystem.Invalid_Name'Enum_Rep,
Access_Denied => HAL.Filesystem.Access_Denied'Enum_Rep,
Already_Exists => HAL.Filesystem.Already_Exists'Enum_Rep,
Invalid_Object_Entry => HAL.Filesystem.Invalid_Object_Entry'Enum_Rep,
Write_Protected => HAL.Filesystem.Write_Protected'Enum_Rep,
Invalid_Drive => HAL.Filesystem.Invalid_Drive'Enum_Rep,
No_Filesystem => HAL.Filesystem.No_Filesystem'Enum_Rep,
Locked => HAL.Filesystem.Locked'Enum_Rep,
Too_Many_Open_Files => HAL.Filesystem.Too_Many_Open_Files'Enum_Rep,
Invalid_Parameter => HAL.Filesystem.Invalid_Parameter'Enum_Rep,
Input_Output_Error => HAL.Filesystem.Input_Output_Error'Enum_Rep,
No_MBR_Found => HAL.Filesystem.No_MBR_Found'Enum_Rep,
No_Partition_Found => HAL.Filesystem.No_Partition_Found'Enum_Rep,
No_More_Entries => HAL.Filesystem.No_More_Entries'Enum_Rep,
Read_Only_File_System => HAL.Filesystem.Read_Only_File_System'Enum_Rep,
Operation_Not_Permitted => HAL.Filesystem.Operation_Not_Permitted'Enum_Rep);
for File_Mode use
(Read_Only => HAL.Filesystem.Read_Only'Enum_Rep,
Write_Only => HAL.Filesystem.Write_Only'Enum_Rep,
Read_Write => HAL.Filesystem.Read_Write'Enum_Rep);
for Seek_Mode use
(From_Start => HAL.Filesystem.From_Start'Enum_Rep,
From_End => HAL.Filesystem.From_End'Enum_Rep,
Forward => HAL.Filesystem.Forward'Enum_Rep,
Backward => HAL.Filesystem.Backward'Enum_Rep);
end File_IO;
|
-- Abstract :
--
-- Subprograms common to Output_Elisp and Output_Ada_Emacs
--
-- Copyright (C) 2012, 2013, 2015, 2017, 2018, 2019 Free Software Foundation, Inc.
--
-- The WisiToken package is free software; you can redistribute it
-- and/or modify it under terms of the GNU General Public License as
-- published by the Free Software Foundation; either version 3, or
-- (at your option) any later version. This library is distributed in
-- the hope that it will be useful, but WITHOUT ANY WARRANTY; without
-- even the implied warranty of MERCHANTABILITY or FITNESS FOR A
-- PARTICULAR PURPOSE.
--
-- As a special exception under Section 7 of GPL version 3, you are granted
-- additional permissions described in the GCC Runtime Library Exception,
-- version 3.1, as published by the Free Software Foundation.
pragma License (Modified_GPL);
package WisiToken.BNF.Output_Elisp_Common is
function Find_Elisp_ID (List : in WisiToken.BNF.String_Lists.List; Elisp_Name : in String) return Integer;
function Elisp_Name_To_Ada
(Elisp_Name : in String;
Append_ID : in Boolean;
Trim : in Integer)
return String;
-- Drop Trim chars from beginning of Elisp_Name, capitalize.
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);
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);
procedure Indent_Name_Table
(Output_File_Root : in String;
Label : in String;
Names : in String_Lists.List);
procedure Indent_Repair_Image
(Output_File_Root : in String;
Label : in String;
Tokens : in WisiToken.BNF.Tokens);
end WisiToken.BNF.Output_Elisp_Common;
|
with Application_Types;
generic
type Element_Type is private;
package Generic_List is
type Node_Type;
type Node_Access_Type is access Node_Type;
type Node_Type is
record
Item : Element_Type;
Next : Node_Access_Type;
end record;
--
-- The node is the basic element of the list.
-- Component 'Item' is the 'useful' information and component 'Next' maintains the list
-- structure
--
--
-- The List_Header_Type is the entry element into the list. A number of the components are made
-- visible for diagnostic purposes and care should be taken when using them
--
type List_Header_Type is
record
Count : Application_Types.Base_Integer_Type := 0;
Max_Count : Application_Types.Base_Integer_Type := 0;
First_Entry : Node_Access_Type := null;
Stepping_Pointer : Node_Access_Type := null;
Free_List_Count : Application_Types.Base_Integer_Type := 0;
Free_List : Node_Access_Type := null;
end record;
type List_Header_Access_Type is access List_Header_Type;
--
-- The access type to the header is the most commonly-met item
--
---------------------------------------------------------------
--
function Initialise return List_Header_Access_Type;
--
-- Initialise must be done before any accesses are attempted on the list.
-- A sign that it has been missed is Constraint_Error/Access_Error
--
procedure Insert (New_Item : in Element_Type;
On_To : in List_Header_Access_Type );
procedure Delete (Item : in Node_Access_Type;
From : in out List_Header_Access_Type);
--
-- Insert and delete act on single items. Note that the 'item' parameter
-- is different in the two cases
--
-- PILOT_0000_0452 Add additional operation to remove entries without destroying list.
--
procedure Clear (From : in out List_Header_Access_Type);
--
-- Clear will remove all item entries from the list, but new items can be added as the list structure
-- will not be destroyed.
--
function Count_Of (Target_List : List_Header_Access_Type) return Application_Types.Base_Integer_Type;
--
-- Count_Of returns the number of items on the list.
--
function Max_Count_Of (Target_List : List_Header_Access_Type) return Application_Types.Base_Integer_Type;
--
-- Max_Count_Of returns the maximum number of items on the list jusqu'ici.
--
function First_Entry_Of (Target_List : List_Header_Access_Type) return Node_Access_Type;
function Next_Entry_Of (Target_List : List_Header_Access_Type) return Node_Access_Type;
--
-- These enable iteration over the list. First_Entry_Of always sets the pointer to the start,
-- and Next_Entry_Of always steps just one on. Note that these operations share a temporary
-- pointer with the Free list iterators below, and therefore should never be intermingled.
--
procedure Destroy_List (Target_List : in out List_Header_Access_Type);
--
-- This operation wipes out and deallocates the memory space of the items and the list
-- header. There is no way back after this one.
--
---------------------------------------------------------------------
function First_Entry_Of_Free_List (Target_List : List_Header_Access_Type) return Node_Access_Type;
function Next_Entry_Of_Free_List (Target_List : List_Header_Access_Type) return Node_Access_Type;
--
-- These enable iteration over the free list. They are the analogues of the list iterators above.
-- As noted, they must not be intermingled, but as these are essentially for diagnostic
-- purposes, this should not be a problem.
--
function Count_Of_Free_List (Target_List : List_Header_Access_Type) return Application_Types.Base_Integer_Type;
---------------------------------------------------------------------
--
List_Underflow_Error,
List_Storage_Error,
List_Access_Error: exception;
end Generic_List;
|
----------------------------------------
-- Copyright (C) 2019 Dmitriy Shadrin --
-- All rights reserved. --
----------------------------------------
package ConfigTree.SaxParser is
procedure Parse(root : in out ConfigTree.NodePtr);
end ConfigTree.SaxParser;
|
with Ada.Containers.Doubly_Linked_Lists;
with Ada.Text_IO; use Ada.Text_IO;
with Utilities;
with GL.Attributes;
with GL.Objects.Buffers;
with GL.Objects.Vertex_Arrays;
with E3GA;
with GA_Utilities;
with GL_Util;
with Shader_Manager;
package body Geosphere is
use GL.Types;
package Indices_List_Package is new Ada.Containers.Doubly_Linked_Lists
(Element_Type => GL.Types.UInt);
type Indices_DL_List is new Indices_List_Package.List with null record;
package Sphere_List_Package is new Ada.Containers.Doubly_Linked_Lists
(Element_Type => Geosphere);
type Sphere_DL_List is new Sphere_List_Package.List with null record;
type Indices_Array is array (Integer range <>) of Indices;
type Vertices_Array is array (Integer range <>) of Multivectors.M_Vector;
Sphere_List : Sphere_DL_List;
procedure Get_Vertices (Sphere : Geosphere;
Vertices : in out GL.Types.Singles.Vector3_Array);
procedure GL_Draw (Render_Program : GL.Objects.Programs.Program;
Model_Matrix : GL.Types.Singles.Matrix4;
Sphere : Geosphere; Normal : GL.Types.Single;
Vertex_Buffer : in out GL.Objects.Buffers.Buffer;
Indices_Buffer : GL.Objects.Buffers.Buffer;
Stride : GL.Types.Int; Num_Faces : GL.Types.Size);
procedure Print_MV_Vector (Name : String; MV : MV_Vector);
procedure Refine_Face (Sphere : in out Geosphere; Face_Index, Depth : Natural);
-- -------------------------------------------------------------------------
procedure Add_Face_Indices (Sphere : Geosphere; aFace : Geosphere_Face;
Indices : in out Indices_DL_List) is
use GA_Maths;
begin
if aFace.Indices /= (-1, -1, -1) then
for index in Int3_Range loop
Indices.Append (UInt (aFace.Indices (index)));
end loop;
end if;
if aFace.Child /= (-1, -1, -1, -1) then
for index in Int4_Range loop
if aFace.Child (index) /= -1 then
Add_Face_Indices (Sphere, Sphere.Faces.Element (aFace.Child (index)), Indices);
end if;
end loop;
end if;
exception
when others =>
Put_Line ("An exception occurred in Geosphere.Add_Face_Indices.");
raise;
end Add_Face_Indices;
-- -------------------------------------------------------------------------
procedure Add_To_Sphere_List (Sphere : Geosphere) is
begin
Sphere_List.Append (Sphere);
end Add_To_Sphere_List;
-- -------------------------------------------------------------------------
procedure Add_Vertex (Sphere : in out Geosphere; Pos : Multivectors.M_Vector;
V_Index : out Integer) is
Vertices : constant MV_Vector := Sphere.Vertices;
MV : Multivectors.M_Vector;
Index : Integer := 0;
Found : Boolean := False;
begin
-- first check if vertex already exists
while not Found and then Index <= Sphere.Vertices.Last_Index loop
MV := Pos - Vertices.Element (Index);
Found := Norm_Esq (MV) < 10.0 ** (-5);
if Found then
V_Index := Index;
end if;
Index := Index + 1;
end loop;
if not Found then
Sphere.Vertices.Append (Pos);
V_Index := Sphere.Vertices.Last_Index;
end if;
exception
when others =>
Put_Line ("An exception occurred in Geosphere.Add_Vertex.");
raise;
end Add_Vertex;
-- -------------------------------------------------------------------------
pragma Warnings (Off, "procedure ""Compute_Neighbours"" is not referenced");
procedure Compute_Neighbours (Sphere : in out Geosphere) is
procedure Find_Relation (Face_Cursor_F : Face_Vectors.Cursor) is
Index_FF : constant Integer := Face_Vectors.To_Index (Face_Cursor_F); -- f
Face_F : Geosphere_Face := Sphere.Faces.Element (Index_FF);
Num : Integer := 0;
Found : Boolean := False;
-- -------------------------------------------------------------------
-- Find_Neighbours finds the neighbour faces of vertex E of Face I
procedure Find_Neighbours (Index_FI, Index_FI_VE : Integer) is
Face_I : Geosphere_Face := Sphere.Faces.Element (Index_FI);
FE_Index : constant Integer := Face_F.Indices (Index_FI_VE);
-- e + 1 mod 3:
Index_VE1 : integer := Index_FI_VE + 1;
Next_FE_Index : Integer;
Vertex_J1 : Integer;
Vertex_J2 : Integer;
begin
if Index_VE1 > 3 then
Index_VE1 := 1;
end if;
Next_FE_Index := Face_F.Indices (Index_VE1);
-- For each vertex j of Face_I find edged common to face Face_I and
-- neighbour E of Face_F
for Vertex_J in 1 .. 3 loop -- j
if Face_I.Indices (Vertex_J) = FE_Index then
-- same vertices found
Vertex_J1 := Vertex_J + 1; -- i + 1 mod 3
if Vertex_J1 > 3 then
Vertex_J1 := 1;
end if;
Vertex_J2 := Vertex_J1 + 1; -- i + 2 mod 3
if Vertex_J2 > 3 then
Vertex_J2 := 1;
end if;
if Face_I.Indices (Vertex_J1) = Next_FE_Index then
-- next vertices also match
Face_F.Neighbour (Index_FI_VE) := Index_FI;
Face_I.Neighbour (Vertex_J) := Index_FF;
Found := True;
Num := Num + 1;
elsif Face_I.Indices (Vertex_J2) = Next_FE_Index then
-- next vertex of face[f] matches preceding vertex of face[i]
Face_F.Neighbour (Index_FI_VE) := Index_FI;
Face_I.Neighbour (Vertex_J2) := Index_FF;
Found := True;
Num := Num + 1;
end if;
end if;
if Found then
Sphere.Faces.Replace_Element (Index_FI, Face_I);
Found := False;
end if;
end loop;
exception
when others =>
Put_Line ("An exception occurred in Geosphere.Find_Neighbours.");
raise;
end Find_Neighbours;
-- -------------------------------------------------------------------
begin -- Find_Relation
for Vertex_FE in 1 .. 3 loop -- e
if Face_F.Neighbour (Vertex_FE) >= 0 then
Num := Num + 1;
else
for Index_FI in Index_FF + 1 .. Sphere.Faces.Last_Index loop
Find_Neighbours (Index_FI, Vertex_FE);
end loop;
end if;
end loop;
if Num /= 3 then
Put ("Geosphere.Compute_Neighbours found");
if Num < 3 then
Put (" only");
end if;
Put_Line (Integer'Image (Num) & " neighbours of face " &
Integer'Image (Index_FF));
raise Geosphere_Exception;
end if;
end Find_Relation;
-- ---------------------------------------------------------------------
-- procedure New_Sphere_List (Sphere : Geosphere) is
-- begin
-- Sphere_List.Clear;
-- Sphere_List.Append (Sphere);
-- end New_Sphere_List;
-- ---------------------------------------------------------------------
procedure Reset_Relation (C : Face_Vectors.Cursor) is
Face_Index : constant Integer := Face_Vectors.To_Index (C);
aFace : Geosphere_Face := Sphere.Faces.Element (Face_Index);
begin
aFace.Neighbour := (-1, -1, -1);
Sphere.Faces.Replace_Element (Face_Index, aFace);
end Reset_Relation;
-- ---------------------------------------------------------------------
begin
Iterate (Sphere.Faces, Reset_Relation'Access);
Iterate (Sphere.Faces, Find_Relation'Access);
exception
when others =>
Put_Line ("An exception occurred in Geosphere.Compute_Neighbours.");
raise;
end Compute_Neighbours;
-- -------------------------------------------------------------------------
procedure Draw_Sphere_List (Render_Program : GL.Objects.Programs.Program;
Normal : GL.Types.Single := 0.0) is
use Sphere_List_Package;
Curs : Cursor := Sphere_List.First;
begin
if Sphere_List.Is_Empty then
Put_Line ("Geosphere.Draw_Sphere_List, Sphere_List is empty.");
else
while Has_Element (Curs) loop
GS_Draw (Render_Program,Element (Curs), Normal);
Next (Curs);
end loop;
end if;
end Draw_Sphere_List;
-- -------------------------------------------------------------------------
function Get_Vertex (Sphere : Geosphere; Vertex_Index : Natural)
return GL.Types.Singles.Vector3 is
theVertex : Singles.Vector3;
GA_Vector : constant Multivectors.M_Vector :=
Sphere.Vertices.Element (Vertex_Index);
begin
theVertex (GL.X) := Single (E3GA.e1 (GA_Vector));
theVertex (GL.Y) := Single (E3GA.e2 (GA_Vector));
theVertex (GL.Z) := Single (E3GA.e3 (GA_Vector));
return theVertex;
exception
when others =>
Put_Line ("An exception occurred in Geosphere.Get_Vertex.");
raise;
end Get_Vertex;
-- -------------------------------------------------------------------------
function Get_Vertex (Sphere : Geosphere; Vertex_Index : Natural)
return Multivectors.M_Vector is
GA_Vector : constant Multivectors.M_Vector :=
Sphere.Vertices.Element (Vertex_Index);
begin
Put_Line ("Geosphere.Get_Vertex 2 Vertex_Index." & Natural'Image (Vertex_Index));
return GA_Vector;
exception
when others =>
Put_Line ("An exception occurred in Geosphere.Get_Vertex 2.");
raise;
end Get_Vertex;
-- -------------------------------------------------------------------------
function Get_Indices (Indices_List : Indices_DL_List) return GL.Types.UInt_Array is
use Indices_List_Package;
Curs : Cursor := Indices_List.First;
theIndices : GL.Types.UInt_Array (1 .. Int (Indices_List.Length));
Index : Int := 0;
begin
while Has_Element (Curs) loop
Index := Index + 1;
theIndices (Index) := Element (Curs);
Next (Curs);
end loop;
return theIndices;
exception
when others =>
Put_Line ("An exception occurred in Geosphere.Get_Indices.");
raise;
end Get_Indices;
-- -------------------------------------------------------------------------
procedure Get_Vertices (Sphere : Geosphere;
Vertices : in out GL.Types.Singles.Vector3_Array) is
Index : Int := 0;
procedure Add_Vertex (C : Vertex_Vectors.Cursor) is
Vertex_Index : constant Natural := Vertex_Vectors.To_Index (C);
thisVertex : constant Multivectors.M_Vector :=
Sphere.Vertices.Element (Vertex_Index);
begin
Index := Index + 1;
Vertices (Index) := GL_Util.To_GL (thisVertex);
exception
when others =>
Put_Line ("An exception occurred in Geosphere.Get_Vertices.Add_Vertex.");
raise;
end Add_Vertex;
begin
Iterate (Sphere.Vertices, Add_Vertex'Access);
exception
when others =>
Put_Line ("An exception occurred in Geosphere.Get_Vertices 1.");
raise;
end Get_Vertices;
-- -------------------------------------------------------------------------
procedure GL_Draw (Render_Program : GL.Objects.Programs.Program;
Model_Matrix : GL.Types.Singles.Matrix4;
Sphere : Geosphere; Normal : GL.Types.Single;
Vertex_Buffer : in out GL.Objects.Buffers.Buffer;
Indices_Buffer : GL.Objects.Buffers.Buffer;
Stride : GL.Types.Int; Num_Faces : GL.Types.Size) is
use GL.Objects.Buffers;
use GL.Types.Singles;
Lines : Singles.Vector3_Array (1 .. 6) := (others => (0.0, 0.0, 0.0));
V1 : Singles.Vector3 := (0.0, 0.0, 0.0);
V1_MV : Multivectors.M_Vector;
begin
GL.Objects.Programs.Use_Program (Render_Program);
Shader_Manager.Set_Model_Matrix (Model_Matrix);
GL.Objects.Buffers.Array_Buffer.Bind (Vertex_Buffer);
GL.Attributes.Set_Vertex_Attrib_Pointer (0, 3, GL.Types.Single_Type, Stride, 0);
GL.Attributes.Enable_Vertex_Attrib_Array (0);
GL.Attributes.Set_Vertex_Attrib_Pointer (1, 3, GL.Types.Single_Type, Stride, 0);
GL.Attributes.Enable_Vertex_Attrib_Array (1);
Element_Array_Buffer.Bind (Indices_Buffer);
-- Draw_Elements uses Count sequential elements from an enabled array
-- starting at Element_Offset to construct a sequence of Mode geometric primitives.
GL.Objects.Buffers.Draw_Elements (Mode => Triangles,
Count => Num_Faces,
Index_Type => UInt_Type,
Element_Offset => 0);
GL.Attributes.Disable_Vertex_Attrib_Array (0);
GL.Attributes.Disable_Vertex_Attrib_Array (1);
if Normal /= 0.0 then
Put_Line ("Geosphere.GL_Draw setting lines");
-- Draw three lines
for index in 1 .. 3 loop
V1_MV := Unit_E (Get_Vertex (Sphere, index));
V1 := GL_Util.To_GL (V1_MV);
Lines (2 * Int (index - 1) + 1) := Get_Vertex (Sphere, index);
Lines (2 * Int (index - 1) + 2) :=
Get_Vertex (Sphere, index) + V1 * Normal;
end loop;
Vertex_Buffer.Clear;
Utilities.Load_Vertex_Buffer (Array_Buffer, Lines, Static_Draw);
GL.Attributes.Set_Vertex_Attrib_Pointer (0, 3, GL.Types.Single_Type, 0, 0);
GL.Attributes.Enable_Vertex_Attrib_Array (0);
GL.Objects.Vertex_Arrays.Draw_Arrays (Mode => GL.Types.Lines,
First => 0,
Count => 3);
GL.Attributes.Disable_Vertex_Attrib_Array (0);
end if;
exception
when others =>
Put_Line ("An exception occurred in Geosphere.GL_Draw.");
raise;
end GL_Draw;
-- -------------------------------------------------------------------------
procedure GS_Compute (Sphere : in out Geosphere; Depth : Integer) is
Num_Faces : constant Positive := 8;
Num_Vertices : constant Positive := 6;
New_Face : Geosphere_Face;
Face_Indices : constant Indices_Array (1 .. Num_Faces)
:= ((5, 0, 2),
(3, 2, 0),
(5, 4, 0),
(4, 3, 0),
(1, 5, 2),
(1, 2, 3),
(1, 3, 4),
(1, 4, 5));
Vertices : Vertices_Array (1 .. Num_Vertices);
begin
Vertices (1) := Multivectors.New_Vector (0.0, -1.0, 0.0);
Vertices (2) := New_Vector (0.0, 1.0, 0.0);
Vertices (3) := New_Vector (0.707, 0.0, 0.707);
Vertices (4) := New_Vector (0.707, 0.0, -0.707);
Vertices (5) := New_Vector (-0.707, 0.0, -0.707);
Vertices (6) := New_Vector (-0.707, 0.0, 0.707);
-- set initial geometry
Sphere.Faces.Clear;
Put_Line ("Geosphere.GS_Compute loading New_Face.");
New_Line;
for face in 1 .. Num_Faces loop
New_Face.Indices := Indices_Vector (Face_Indices (face));
Sphere.Faces.Append (New_Face);
end loop;
Sphere.Vertices.Clear;
for vertex_index in 1 .. Num_Vertices loop
Sphere.Vertices.Append (Vertices (vertex_index));
end loop;
Print_MV_Vector ("Geosphere.GS_Compute Sphere Vertices", Sphere.Vertices);
for face_index in 1 .. Num_Faces loop
Put_Line ("Geosphere.GS_Compute Refine Face " & Integer'Image (face_index));
Refine_Face (Sphere, face_index, Depth);
end loop;
Sphere.Depth := Depth;
Put_Line ("Geosphere.GS_Compute done.");
exception
when others =>
Put_Line ("An exception occurred in Geosphere.GS_Compute.");
raise;
end GS_Compute;
-- -------------------------------------------------------------------------
-- Based on geosphere.cpp
-- gsDraw(geosphere * sphere, mv::Float normal /*= 0.0*/)
procedure GS_Draw (Render_Program : GL.Objects.Programs.Program;
Sphere : Geosphere;
Normal : GL.Types.Single := 0.0) is
use GL.Objects.Buffers;
use Face_Vectors;
Vertex_Array : GL.Objects.Vertex_Arrays.Vertex_Array_Object;
Vertex_Buffer : GL.Objects.Buffers.Buffer;
Indices_Buffer : GL.Objects.Buffers.Buffer;
Indices_List : Indices_DL_List;
Model_View_Matrix : constant GL.Types.Singles.Matrix4 :=
GL.Types.Singles.Identity4;
Vertices : Singles.Vector3_Array
(1 .. Int (Length (Sphere.Vertices)));
Vertex_Data_Bytes : constant Int := Vertices'Size / 8;
procedure Build_Indices_List (Face_Cursor : Cursor) is
Face_Index : constant Integer := Face_Vectors.To_Index (Face_Cursor);
thisFace : constant Geosphere_Face :=
Sphere.Faces.Element (Face_Index);
begin
Add_Face_Indices (Sphere, thisFace, Indices_List);
end Build_Indices_List;
begin
Vertex_Array.Initialize_Id;
Vertex_Array.Bind;
Vertex_Buffer.Initialize_Id;
Array_Buffer.Bind (Vertex_Buffer);
Get_Vertices (Sphere, Vertices);
Iterate (Sphere.Faces, Build_Indices_List'Access);
Get_Vertices (Sphere, Vertices);
Array_Buffer.Bind (Vertex_Buffer);
Allocate (Array_Buffer, 2 * Long (Vertex_Data_Bytes), Static_Draw);
Utilities.Load_Vertex_Sub_Buffer (Array_Buffer, 0, Vertices);
Utilities.Load_Vertex_Sub_Buffer (Array_Buffer, Vertex_Data_Bytes, Vertices);
Indices_Buffer.Initialize_Id;
Element_Array_Buffer.Bind (Indices_Buffer);
Utilities.Load_Element_Buffer (Element_Array_Buffer, Get_Indices (Indices_List), Static_Draw);
GL_Draw (Render_Program, Model_View_Matrix, Sphere, Normal, Vertex_Buffer,
Indices_Buffer, 0, GL.Types.Size (Indices_List.Length) / 3);
exception
when others =>
Put_Line ("An exception occurred in Geosphere.GS_Draw.");
raise;
end GS_Draw;
-- -------------------------------------------------------------------------
procedure New_Face (Sphere : in out Geosphere; V1, V2, V3, Depth : Integer) is
newFace : Geosphere_Face;
begin
newFace.Indices (1) := V1;
newFace.Indices (2) := V2;
newFace.Indices (3) := V3;
newFace.Depth := Depth + 1;
Sphere.Faces.Append (newFace);
exception
when others =>
Put_Line ("An exception occurred in Geosphere.New_Face.");
raise;
end New_Face;
-- -------------------------------------------------------------------------
procedure New_Sphere_List (Sphere : Geosphere) is
begin
Sphere_List.Clear;
Sphere_List.Append (Sphere);
end New_Sphere_List;
-- -------------------------------------------------------------------------
procedure Print_MV_Vector (Name : String; MV : MV_Vector) is
use Vertex_Vectors;
Vector_Cursor : Vertex_Vectors.Cursor := MV.First;
aVector : Multivectors.Multivector;
begin
New_Line;
Put_Line (Name);
while Has_Element (Vector_Cursor) loop
aVector := Element (Vector_Cursor);
GA_Utilities.Print_Multivector ("", aVector);
Next (Vector_Cursor);
end loop;
exception
when others =>
Put_Line ("An exception occurred in Geosphere.Print_MV_Vector.");
raise;
end Print_MV_Vector;
-- ------------------------------------------------------------------------
procedure Refine_Face (Sphere : in out Geosphere; Face_Index,
Depth : Natural) is
use Face_Vectors;
use E3GA;
Faces : constant F_Vector := Sphere.Faces;
Num_Faces : constant Positive := Positive (Faces.Length);
this_Face : Geosphere_Face := Faces.Element (Face_index);
Face_Cursor : constant Cursor := Sphere.Faces.To_Cursor (Face_index);
Vertex_Indicies : constant Indices_Vector := this_Face.Indices;
Vertices : constant MV_Vector := Sphere.Vertices;
New_Indices : Indices_Vector := (0, 0, 0); -- v[3]
Index_2 : Natural;
Vertex_1 : E3_Vector;
Vertex_2 : E3_Vector;
New_Vertex : E3_Vector; -- V1
begin
GA_Utilities.Print_Integer_Array ("Geosphere.Refine_Face Vertex_Indicies",
Vertex_Indicies);
-- Refine_Face is recursive
if Depth > 0 then
-- create 3 new vertices
for index in Int3_Range loop
Index_2 := index + 1;
if Index_2 > 3 then
Index_2 := 1;
end if;
Put_Line ("Geosphere.Refine_Face index and Index_2: " &
Integer'Image (index) & " " & Integer'Image (Index_2));
Vertex_1 := E3GA.Get_Coords (Vertices.Element (Vertex_Indicies (index)));
GA_Utilities.Print_E3_Vector
("Geosphere.Refine_Face Vertex_1", Vertex_1);
Vertex_2 := E3GA.Get_Coords (Vertices.Element (Vertex_Indicies (Index_2)));
GA_Utilities.Print_E3_Vector
("Geosphere.Refine_Face Vertex_2", Vertex_2);
New_Vertex := E3GA.Unit_E (Vertex_1 + Vertex_2);
GA_Utilities.Print_E3_Vector
("Geosphere.Refine_Face New_Vertex", New_Vertex);
Add_Vertex (Sphere,
New_Vector (Float (New_Vertex (GL.X)), Float (New_Vertex (GL.Y)),
Float (New_Vertex (GL.Z))), New_Indices (index));
end loop;
Put_Line ("Geosphere.Refine_Face allocating four new faces");
-- allocate four new faces
New_Face (Sphere, this_Face.Indices (1), New_Indices (1),
New_Indices (3), this_Face.Depth);
New_Face (Sphere, New_Indices (1), this_Face.Indices (2),
New_Indices (2), this_Face.Depth);
New_Face (Sphere, New_Indices (1), New_Indices (2), New_Indices (3),
this_Face.Depth);
New_Face (Sphere, New_Indices (2), this_Face.Indices (3),
New_Indices (3), this_Face.Depth);
for index in Integer range 1 .. 4 loop
this_Face.Child (index) := Num_Faces + index;
end loop;
Sphere.Faces.Replace_Element (Face_Cursor, this_Face);
for index in Integer range 1 .. 4 loop
Refine_Face (Sphere, Num_Faces + index, Depth - 1);
end loop;
end if;
exception
when others =>
Put_Line ("An exception occurred in Geosphere.Refine_Face.");
raise;
end Refine_Face;
-- -------------------------------------------------------------------------
end Geosphere;
|
-- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
with Interfaces.C;
with Interfaces.C_Streams;
with Interfaces.C.Strings;
with HelperText;
package Unix is
package HT renames HelperText;
package IC renames Interfaces.C;
package ICS renames Interfaces.C.Strings;
package CSM renames Interfaces.C_Streams;
type process_exit is (still_running, exited_normally, exited_with_error);
type Int32 is private;
subtype pid_t is Int32;
-- check if process identified by pid has exited or keeps going
function process_status (pid : pid_t) return process_exit;
-- Kill everything with the identified process group
procedure kill_process_tree (process_group : pid_t);
-- Allows other packages to call external commands (e.g. Pilot)
-- Returns "True" on success
function external_command (command : String) return Boolean;
-- wrapper for nonblocking spawn
function launch_process (command : String) return pid_t;
-- Returns True if pid is less than zero
function fork_failed (pid : pid_t) return Boolean;
-- Returns True if "variable" is defined in the environment. The
-- value of variable is irrelevant
function env_variable_defined (variable : String) return Boolean;
-- Return value of "variable" defined in environment. If it's not
-- defined than an empty string is returned;
function env_variable_value (variable : String) return String;
-- Execute popen and return stdout+stderr combined
-- Also the result status is returned as an "out" variable
function piped_command
(command : String;
status : out Integer) return HT.Text;
-- Run external command that is expected to have no output to standard
-- out, but catch stdout anyway. Don't return any output, but do return
-- True of the command returns status of zero.
function piped_mute_command
(command : String;
abnormal : out HT.Text) return Boolean;
-- When the cone of silence is deployed, the terminal does not echo
-- and Control-Q/S keystrokes are not captured (and vice-versa)
procedure cone_of_silence (deploy : Boolean);
-- Returns True if a TTY device is detected
function screen_attached return Boolean;
-- Equivalent of libc's realpath() function
-- It resolves symlinks and relative directories to get the true path
function true_path (provided_path : String) return String;
-- Ignore SIGTTOU signal (background process trying to write to terminal)
-- If that happens, synth will suspend and ultimately fail.
procedure ignore_background_tty;
-- Attempts to create a hardlink and returns True on success
function create_hardlink (actual_file : String; destination : String) return Boolean;
-- Attempts to create a symlink and returns True on success
function create_symlink (actual_file : String; destination : String) return Boolean;
private
type uInt8 is mod 2 ** 16;
type Int32 is range -(2 ** 31) .. +(2 ** 31) - 1;
popen_re : constant IC.char_array := IC.To_C ("re");
popen_r : constant IC.char_array := IC.To_C ("r");
function popen (Command, Mode : IC.char_array) return CSM.FILEs;
pragma Import (C, popen);
function pclose (FileStream : CSM.FILEs) return CSM.int;
pragma Import (C, pclose);
function ferror (FileStream : CSM.FILEs) return CSM.int;
pragma Import (C, ferror);
function realpath (pathname, resolved_path : IC.char_array)
return ICS.chars_ptr;
pragma Import (C, realpath, "realpath");
function nohang_waitpid (pid : pid_t) return uInt8;
pragma Import (C, nohang_waitpid, "__nohang_waitpid");
function silent_control return uInt8;
pragma Import (C, silent_control, "__silent_control");
function chatty_control return uInt8;
pragma Import (C, chatty_control, "__chatty_control");
function signal_runaway (pid : pid_t) return IC.int;
pragma Import (C, signal_runaway, "__shut_it_down");
function ignore_tty_write return uInt8;
pragma Import (C, ignore_tty_write, "__ignore_background_tty_writes");
function ignore_tty_read return uInt8;
pragma Import (C, ignore_tty_read, "__ignore_background_tty_reads");
function link (path1, path2 : IC.char_array) return IC.int;
pragma Import (C, link);
function symlink (path1, path2 : IC.char_array) return IC.int;
pragma Import (C, symlink);
-- internal pipe close command
function pipe_close (OpenFile : CSM.FILEs) return Integer;
-- internal pipe read command
function pipe_read (OpenFile : CSM.FILEs) return HT.Text;
-- Internal file error check
function good_stream (OpenFile : CSM.FILEs) return Boolean;
end Unix;
|
-----------------------------------------------------------------------
-- util-system-os -- Windows system operations
-- Copyright (C) 2011, 2012, 2015, 2018, 2019 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Characters.Conversions;
package body Util.Systems.Os is
use type Interfaces.Unsigned_32;
use type Interfaces.Unsigned_64;
use type Interfaces.C.size_t;
function To_WSTR (Value : in String) return Wchar_Ptr is
Result : constant Wchar_Ptr := new Interfaces.C.wchar_array (0 .. Value'Length + 1);
Pos : Interfaces.C.size_t := 0;
begin
for C of Value loop
Result (Pos)
:= Interfaces.C.To_C (Ada.Characters.Conversions.To_Wide_Character (C));
Pos := Pos + 1;
end loop;
Result (Pos) := Interfaces.C.wide_nul;
return Result;
end To_WSTR;
function Sys_SetFilePointerEx (Fs : in File_Type;
Offset : in Util.Systems.Types.off_t;
Result : access Util.Systems.Types.off_t;
Mode : in Util.Systems.Types.Seek_Mode) return BOOL
with Import => True, Convention => Stdcall, Link_Name => "SetFilePointerEx";
function Sys_Lseek (Fs : in File_Type;
Offset : in Util.Systems.Types.off_t;
Mode : in Util.Systems.Types.Seek_Mode)
return Util.Systems.Types.off_t is
Result : aliased Util.Systems.Types.off_t;
begin
if Sys_SetFilePointerEx (Fs, Offset, Result'Access, Mode) /= 0 then
return Result;
else
return -1;
end if;
end Sys_Lseek;
function Sys_GetFileSizeEx (Fs : in File_Type;
Result : access Util.Systems.Types.off_t) return BOOL
with Import => True, Convention => Stdcall, Link_Name => "GetFileSizeEx";
function Sys_GetFileTime (Fs : in File_Type;
Create : access FileTime;
AccessTime : access FileTime;
ModifyTime : access FileTime) return BOOL
with Import => True, Convention => Stdcall, Link_Name => "GetFileTime";
TICKS_PER_SECOND : constant := 10000000;
EPOCH_DIFFERENCE : constant := 11644473600;
function To_Time (Time : in FileTime) return Types.Time_Type is
Value : Interfaces.Unsigned_64;
begin
Value := Interfaces.Shift_Left (Interfaces.Unsigned_64 (Time.dwHighDateTime), 32);
Value := Value + Interfaces.Unsigned_64 (Time.dwLowDateTime);
Value := Value / TICKS_PER_SECOND;
Value := Value - EPOCH_DIFFERENCE;
return Types.Time_Type (Value);
end To_Time;
function Sys_Fstat (Fs : in File_Type;
Stat : access Util.Systems.Types.Stat_Type) return Integer is
Size : aliased Util.Systems.Types.off_t;
Creation_Time : aliased FileTime;
Access_Time : aliased FileTime;
Write_Time : aliased FileTime;
begin
Stat.st_dev := 0;
Stat.st_ino := 0;
Stat.st_mode := 0;
Stat.st_nlink := 0;
Stat.st_uid := 0;
Stat.st_gid := 0;
Stat.st_rdev := 0;
Stat.st_atime := 0;
Stat.st_mtime := 0;
Stat.st_ctime := 0;
if Sys_GetFileSizeEx (Fs, Size'Access) = 0 then
return -1;
end if;
if Sys_GetFileTime (Fs, Creation_Time'Access, Access_Time'Access, Write_Time'Access) = 0 then
return -1;
end if;
Stat.st_size := Size;
Stat.st_ctime := To_Time (Creation_Time);
Stat.st_mtime := To_Time (Write_Time);
Stat.st_atime := To_Time (Access_Time);
return 0;
end Sys_Fstat;
-- Open a file
function Sys_Open (Path : in Ptr;
Flags : in Interfaces.C.int;
Mode : in Util.Systems.Types.mode_t) return File_Type is
pragma Unreferenced (Mode);
function Has_Flag (M : in Interfaces.C.int;
F : in Interfaces.C.int) return Boolean
is ((Interfaces.Unsigned_32 (M) and Interfaces.Unsigned_32 (F)) /= 0);
Sec : aliased Security_Attributes;
Result : File_Type;
Desired_Access : DWORD;
Share_Mode : DWORD := FILE_SHARE_READ + FILE_SHARE_WRITE;
Creation : DWORD;
WPath : Wchar_Ptr;
begin
WPath := To_WSTR (Interfaces.C.Strings.Value (Path));
Sec.Length := Security_Attributes'Size / 8;
Sec.Security_Descriptor := System.Null_Address;
Sec.Inherit := (if Has_Flag (Flags, Util.Systems.Constants.O_CLOEXEC) then 0 else 1);
if Has_Flag (Flags, O_WRONLY) then
Desired_Access := GENERIC_WRITE;
elsif Has_Flag (Flags, O_RDWR) then
Desired_Access := GENERIC_READ + GENERIC_WRITE;
else
Desired_Access := GENERIC_READ;
end if;
if Has_Flag (Flags, O_CREAT) then
if Has_Flag (Flags, O_EXCL) then
Creation := CREATE_NEW;
else
Creation := CREATE_ALWAYS;
end if;
else
Creation := OPEN_EXISTING;
end if;
if Has_Flag (Flags, O_APPEND) then
Desired_Access := FILE_APPEND_DATA;
end if;
if Has_Flag (Flags, O_EXCL) then
Share_Mode := 0;
end if;
Result := Create_File (WPath.all'Address,
Desired_Access,
Share_Mode,
Sec'Unchecked_Access,
Creation,
FILE_ATTRIBUTE_NORMAL,
NO_FILE);
Free (WPath);
return (if Result = INVALID_HANDLE_VALUE then NO_FILE else Result);
end Sys_Open;
function Sys_SetEndOfFile (Fs : in File_Type) return BOOL
with Import => True, Convention => Stdcall, Link_Name => "SetEndOfFile";
function Sys_Ftruncate (Fs : in File_Type;
Length : in Util.Systems.Types.off_t) return Integer is
begin
if Sys_Lseek (Fs, Length, Util.Systems.Types.SEEK_SET) < 0 then
return -1;
end if;
if Sys_SetEndOfFile (Fs) = 0 then
return -1;
end if;
return 0;
end Sys_Ftruncate;
function Sys_Fchmod (Fd : in File_Type;
Mode : in Util.Systems.Types.mode_t) return Integer is
pragma Unreferenced (Fd, Mode);
begin
return 0;
end Sys_Fchmod;
-- Close a file
function Sys_Close (Fd : in File_Type) return Integer is
begin
if Close_Handle (Fd) = 0 then
return -1;
else
return 0;
end if;
end Sys_Close;
end Util.Systems.Os;
|
-- Copyright 2016 Steven Stewart-Gallus
--
-- 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 Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings;
with Libc.Stddef;
package Pulse.Util with
Spark_Mode => Off is
function pa_get_user_name
(s : Interfaces.C.Strings.chars_ptr;
l : Libc.Stddef.size_t)
return Interfaces.C.Strings.chars_ptr; -- /usr/include/pulse/util.h:37
pragma Import (C, pa_get_user_name, "pa_get_user_name");
function pa_get_host_name
(s : Interfaces.C.Strings.chars_ptr;
l : Libc.Stddef.size_t)
return Interfaces.C.Strings.chars_ptr; -- /usr/include/pulse/util.h:40
pragma Import (C, pa_get_host_name, "pa_get_host_name");
function pa_get_fqdn
(s : Interfaces.C.Strings.chars_ptr;
l : Libc.Stddef.size_t)
return Interfaces.C.Strings.chars_ptr; -- /usr/include/pulse/util.h:43
pragma Import (C, pa_get_fqdn, "pa_get_fqdn");
function pa_get_home_dir
(s : Interfaces.C.Strings.chars_ptr;
l : Libc.Stddef.size_t)
return Interfaces.C.Strings.chars_ptr; -- /usr/include/pulse/util.h:46
pragma Import (C, pa_get_home_dir, "pa_get_home_dir");
function pa_get_binary_name
(s : Interfaces.C.Strings.chars_ptr;
l : Libc.Stddef.size_t)
return Interfaces.C.Strings.chars_ptr; -- /usr/include/pulse/util.h:50
pragma Import (C, pa_get_binary_name, "pa_get_binary_name");
function pa_path_get_filename
(p : Interfaces.C.Strings.chars_ptr)
return Interfaces.C.Strings.chars_ptr; -- /usr/include/pulse/util.h:54
pragma Import (C, pa_path_get_filename, "pa_path_get_filename");
function pa_msleep
(t : unsigned_long) return int; -- /usr/include/pulse/util.h:57
pragma Import (C, pa_msleep, "pa_msleep");
end Pulse.Util;
|
-----------------------------------------------------------------------
-- secret-values -- Ada wrapper for Secret Service
-- Copyright (C) 2017 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.
-----------------------------------------------------------------------
-- === Secret Values ===
-- A secret value is represented by the <tt>Secret_Type</tt> type. The value is internally
-- held and managed by the libsecret in some secure memory region. The secret value is
-- associated with a content type that can be retrieved as well. The Ada library only creates
-- secret values with the "text/plain" content type.
--
-- A secret value is only copied by reference that is the secret value stored in the secure
-- memory region is shared among different <tt>Secret_Type</tt> instances. A secret value
-- cannot be modified once it is created.
--
-- To create a secret value, you can use the <tt>Create</tt> function as follows:
--
-- Value : Secret.Values.Secret_Type := Secret.Values.Create ("my-secret-password");
--
package Secret.Values is
-- Represents a value returned by the secret server.
type Secret_Type is new Object_Type with null record;
-- Create a value with the default content type text/plain.
function Create (Value : in String) return Secret_Type
with Post => not Create'Result.Is_Null;
-- Get the value content type.
function Get_Content_Type (Value : in Secret_Type) return String
with Pre => not Value.Is_Null;
-- Get the value as a string.
function Get_Value (Value : in Secret_Type) return String
with Pre => not Value.Is_Null;
private
overriding
procedure Adjust (Object : in out Secret_Type);
overriding
procedure Finalize (Object : in out Secret_Type);
end Secret.Values;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- M D L L . T O O L S --
-- --
-- B o d y --
-- --
-- $Revision$
-- --
-- Copyright (C) 1992-2000 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. --
-- --
------------------------------------------------------------------------------
-- Interface to externals tools used to build DLL and import libraries
with Ada.Text_IO;
with Ada.Exceptions;
with Ada.Unchecked_Deallocation;
with Sdefault;
package body MDLL.Tools is
use Ada;
use GNAT;
Dlltool_Name : constant String := "dlltool";
Dlltool_Exec : OS_Lib.String_Access;
Gcc_Name : constant String := "gcc";
Gcc_Exec : OS_Lib.String_Access;
Gnatbind_Name : constant String := "gnatbind";
Gnatbind_Exec : OS_Lib.String_Access;
Gnatlink_Name : constant String := "gnatlink";
Gnatlink_Exec : OS_Lib.String_Access;
procedure Free is
new Ada.Unchecked_Deallocation (OS_Lib.Argument_List,
OS_Lib.Argument_List_Access);
procedure Print_Command (Tool_Name : in String;
Arguments : in OS_Lib.Argument_List);
-- display the command runned when in Verbose mode
-------------------
-- Print_Command --
-------------------
procedure Print_Command (Tool_Name : in String;
Arguments : in OS_Lib.Argument_List) is
begin
if Verbose then
Text_IO.Put (Tool_Name);
for K in Arguments'Range loop
Text_IO.Put (" " & Arguments (K).all);
end loop;
Text_IO.New_Line;
end if;
end Print_Command;
-----------------
-- Delete_File --
-----------------
procedure Delete_File (Filename : in String) is
File : constant String := Filename & ASCII.Nul;
Success : Boolean;
begin
OS_Lib.Delete_File (File'Address, Success);
end Delete_File;
-------------
-- Dlltool --
-------------
procedure Dlltool (Def_Filename : in String;
DLL_Name : in String;
Library : in String;
Exp_Table : in String := "";
Base_File : in String := "";
Build_Import : in Boolean)
is
Arguments : OS_Lib.Argument_List (1 .. 11);
A : Positive;
Success : Boolean;
Def_Opt : aliased String := "--def";
Def_V : aliased String := Def_Filename;
Dll_Opt : aliased String := "--dllname";
Dll_V : aliased String := DLL_Name;
Lib_Opt : aliased String := "--output-lib";
Lib_V : aliased String := Library;
Exp_Opt : aliased String := "--output-exp";
Exp_V : aliased String := Exp_Table;
Bas_Opt : aliased String := "--base-file";
Bas_V : aliased String := Base_File;
No_Suf_Opt : aliased String := "-k";
begin
Arguments (1 .. 4) := (1 => Def_Opt'Unchecked_Access,
2 => Def_V'Unchecked_Access,
3 => Dll_Opt'Unchecked_Access,
4 => Dll_V'Unchecked_Access);
A := 4;
if Kill_Suffix then
A := A + 1;
Arguments (A) := No_Suf_Opt'Unchecked_Access;
end if;
if Library /= "" and then Build_Import then
A := A + 1;
Arguments (A) := Lib_Opt'Unchecked_Access;
A := A + 1;
Arguments (A) := Lib_V'Unchecked_Access;
end if;
if Exp_Table /= "" then
A := A + 1;
Arguments (A) := Exp_Opt'Unchecked_Access;
A := A + 1;
Arguments (A) := Exp_V'Unchecked_Access;
end if;
if Base_File /= "" then
A := A + 1;
Arguments (A) := Bas_Opt'Unchecked_Access;
A := A + 1;
Arguments (A) := Bas_V'Unchecked_Access;
end if;
Print_Command ("dlltool", Arguments (1 .. A));
OS_Lib.Spawn (Dlltool_Exec.all, Arguments (1 .. A), Success);
if not Success then
Exceptions.Raise_Exception (Tools_Error'Identity,
Dlltool_Name & " execution error.");
end if;
end Dlltool;
---------
-- Gcc --
---------
procedure Gcc (Output_File : in String;
Files : in Argument_List;
Options : in Argument_List;
Base_File : in String := "";
Build_Lib : in Boolean := False)
is
use Sdefault;
Arguments : OS_Lib.Argument_List
(1 .. 5 + Files'Length + Options'Length);
A : Natural := 0;
Success : Boolean;
C_Opt : aliased String := "-c";
Out_Opt : aliased String := "-o";
Out_V : aliased String := Output_File;
Bas_Opt : aliased String := "-Wl,--base-file," & Base_File;
Lib_Opt : aliased String := "-mdll";
Lib_Dir : aliased String := "-L" & Object_Dir_Default_Name.all;
begin
A := A + 1;
if Build_Lib then
Arguments (A) := Lib_Opt'Unchecked_Access;
else
Arguments (A) := C_Opt'Unchecked_Access;
end if;
A := A + 1;
Arguments (A .. A + 2) := (Out_Opt'Unchecked_Access,
Out_V'Unchecked_Access,
Lib_Dir'Unchecked_Access);
A := A + 2;
if Base_File /= "" then
A := A + 1;
Arguments (A) := Bas_Opt'Unchecked_Access;
end if;
A := A + 1;
Arguments (A .. A + Files'Length - 1) := Files;
A := A + Files'Length - 1;
if Build_Lib then
A := A + 1;
Arguments (A .. A + Options'Length - 1) := Options;
A := A + Options'Length - 1;
else
declare
Largs : Argument_List (Options'Range);
L : Natural := Largs'First - 1;
begin
for K in Options'Range loop
if Options (K) (1 .. 2) /= "-l" then
L := L + 1;
Largs (L) := Options (K);
end if;
end loop;
A := A + 1;
Arguments (A .. A + L - 1) := Largs (1 .. L);
A := A + L - 1;
end;
end if;
Print_Command ("gcc", Arguments (1 .. A));
OS_Lib.Spawn (Gcc_Exec.all, Arguments (1 .. A), Success);
if not Success then
Exceptions.Raise_Exception (Tools_Error'Identity,
Gcc_Name & " execution error.");
end if;
end Gcc;
--------------
-- Gnatbind --
--------------
procedure Gnatbind (Alis : in Argument_List;
Args : in Argument_List := Null_Argument_List)
is
Arguments : OS_Lib.Argument_List (1 .. 1 + Alis'Length + Args'Length);
Success : Boolean;
No_Main_Opt : aliased String := "-n";
begin
Arguments (1) := No_Main_Opt'Unchecked_Access;
Arguments (2 .. 1 + Alis'Length) := Alis;
Arguments (2 + Alis'Length .. Arguments'Last) := Args;
Print_Command ("gnatbind", Arguments);
OS_Lib.Spawn (Gnatbind_Exec.all, Arguments, Success);
if not Success then
Exceptions.Raise_Exception (Tools_Error'Identity,
Gnatbind_Name & " execution error.");
end if;
end Gnatbind;
--------------
-- Gnatlink --
--------------
procedure Gnatlink (Ali : in String;
Args : in Argument_List := Null_Argument_List)
is
Arguments : OS_Lib.Argument_List (1 .. 1 + Args'Length);
Success : Boolean;
Ali_Name : aliased String := Ali;
begin
Arguments (1) := Ali_Name'Unchecked_Access;
Arguments (2 .. Arguments'Last) := Args;
Print_Command ("gnatlink", Arguments);
OS_Lib.Spawn (Gnatlink_Exec.all, Arguments, Success);
if not Success then
Exceptions.Raise_Exception (Tools_Error'Identity,
Gnatlink_Name & " execution error.");
end if;
end Gnatlink;
------------
-- Locate --
------------
procedure Locate is
use type OS_Lib.String_Access;
begin
-- dlltool
Dlltool_Exec := OS_Lib.Locate_Exec_On_Path (Dlltool_Name);
if Dlltool_Exec = null then
Exceptions.Raise_Exception (Tools_Error'Identity,
Dlltool_Name & " not found in path");
elsif Verbose then
Text_IO.Put_Line ("using " & Dlltool_Exec.all);
end if;
-- gcc
Gcc_Exec := OS_Lib.Locate_Exec_On_Path (Gcc_Name);
if Gcc_Exec = null then
Exceptions.Raise_Exception (Tools_Error'Identity,
Gcc_Name & " not found in path");
elsif Verbose then
Text_IO.Put_Line ("using " & Gcc_Exec.all);
end if;
-- gnatbind
Gnatbind_Exec := OS_Lib.Locate_Exec_On_Path (Gnatbind_Name);
if Gnatbind_Exec = null then
Exceptions.Raise_Exception (Tools_Error'Identity,
Gnatbind_Name & " not found in path");
elsif Verbose then
Text_IO.Put_Line ("using " & Gnatbind_Exec.all);
end if;
-- gnatlink
Gnatlink_Exec := OS_Lib.Locate_Exec_On_Path (Gnatlink_Name);
if Gnatlink_Exec = null then
Exceptions.Raise_Exception (Tools_Error'Identity,
Gnatlink_Name & " not found in path");
elsif Verbose then
Text_IO.Put_Line ("using " & Gnatlink_Exec.all);
Text_IO.New_Line;
end if;
end Locate;
end MDLL.Tools;
|
------------------------------------------------------------------------------
-- Copyright (c) 2014, Natacha Porté --
-- --
-- Permission to use, copy, modify, and distribute this software for any --
-- purpose with or without fee is hereby granted, provided that the above --
-- copyright notice and this permission notice appear in all copies. --
-- --
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES --
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF --
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR --
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES --
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN --
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF --
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. --
------------------------------------------------------------------------------
with Ada.Calendar.Arithmetic;
with Ada.Calendar.Formatting;
with Ada.Calendar.Time_Zones;
with Natools.Time_IO.Human;
with Natools.Time_IO.RFC_3339;
package body Natools.Time_IO.Tests is
use type Ada.Calendar.Time;
use type Ada.Calendar.Time_Zones.Time_Offset;
type Extended_Time is record
Time : Ada.Calendar.Time;
Offset : Ada.Calendar.Time_Zones.Time_Offset;
end record;
------------------------------
-- Local Helper Subprograms --
------------------------------
function Explicit_Sign (Image : String) return String
is (if Image'Length > 0 and then Image (Image'First) = ' '
then '+' & Image (Image'First + 1 .. Image'Last)
else Image);
function Has_Leap_Second_Support return Boolean;
function Image (Time : Extended_Time) return String
is ('[' & Ada.Calendar.Formatting.Image (Time.Time) & "] "
& Explicit_Sign
(Ada.Calendar.Time_Zones.Time_Offset'Image (Time.Offset)));
function Quote (Original : String) return String
is ('"' & Original & '"');
procedure Check is new NT.Generic_Check (Extended_Time);
procedure Check is new NT.Generic_Check (String, "=", Quote);
function Has_Leap_Second_Support return Boolean is
Leap_Second_Time : Ada.Calendar.Time;
Year : Ada.Calendar.Year_Number;
Month : Ada.Calendar.Month_Number;
Day : Ada.Calendar.Day_Number;
Hour : Ada.Calendar.Formatting.Hour_Number;
Minute : Ada.Calendar.Formatting.Minute_Number;
Second : Ada.Calendar.Formatting.Second_Number;
Sub_Second : Ada.Calendar.Formatting.Second_Duration;
Is_Leap_Second : Boolean;
begin
begin
Leap_Second_Time := Ada.Calendar.Formatting.Time_Of
(1990, 12, 31, 23, 59, 59, 0.25, True, 0);
exception
when Ada.Calendar.Time_Error =>
-- Leap second are explicitly not supported
return False;
end;
Ada.Calendar.Formatting.Split
(Leap_Second_Time,
Year, Month, Day,
Hour, Minute, Second, Sub_Second,
Is_Leap_Second,
Time_Zone => 0);
-- Check that Time_Of/Split at least work on the normal part
pragma Assert (Year = 1990);
pragma Assert (Month = 12);
pragma Assert (Day = 31);
pragma Assert (Hour = 23);
pragma Assert (Minute = 59);
pragma Assert (Second = 59);
pragma Assert (Sub_Second = 0.25);
-- According to the standard, Is_Leap_Second should be True at this
-- point, because Time_Error should have been raised if leap second is
-- not supported.
-- However some implementations mistakenly drop silently Leap_Second,
-- so actual support is determined here by check Is_Leap_Second.
return Is_Leap_Second;
end Has_Leap_Second_Support;
-------------------------
-- Complete Test Suite --
-------------------------
procedure All_Tests (Report : in out NT.Reporter'Class) is
begin
Human_Duration (Report);
Human_Time_Difference (Report);
Read_From_RFC_3339 (Report);
Write_As_RFC_3339 (Report);
end All_Tests;
-----------------------
-- Inidividual Tests --
-----------------------
procedure Human_Duration (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Human-readable time intervals");
function Compose
(Second : Ada.Calendar.Formatting.Second_Number;
Minute : Ada.Calendar.Formatting.Minute_Number := 0;
Hour : Ada.Calendar.Formatting.Hour_Number := 0)
return Duration
is (Second * 1.0 + Minute * 60.0 + Hour * 3600.0);
begin
Check (Test, "-1d", Human.Image (-86400.0), "-1d");
Check (Test, "0s", Human.Image (0.0), "0");
Check (Test, "1d", Human.Image (86400.0), "1d");
Check (Test, "1d", Human.Image (Compose (1, 30, 23)), "23h 30m 1s");
Check (Test, "23h", Human.Image (Compose (59, 29, 23)), "23h 29m 59s");
Check (Test, "15h", Human.Image (Compose (0, 20, 15)), "15h 20m");
Check (Test, "10h", Human.Image (Compose (0, 0, 10)), "10h");
Check (Test, "10h", Human.Image (Compose (31, 59, 9)), "9h 59m 31s");
Check (Test, "9h 59m", Human.Image (Compose (29, 59, 9)), "9h 59m 29s");
Check (Test, "2h", Human.Image (Compose (45, 59, 1)), "1h 59m 45s");
Check (Test, "1h 2m", Human.Image (Compose (45, 1, 1)), "1h 1m 45s");
Check (Test, "1h", Human.Image (Compose (31, 59)), "59m 31s");
Check (Test, "59 min", Human.Image (Compose (28, 59)), "59m 28s");
Check (Test, "10 min", Human.Image (600.1), "10m 0.1s");
Check (Test, "10 min", Human.Image (599.7), "9m 59.7s");
Check (Test, "9 min 59s", Human.Image (599.4), "9m 59.4s");
Check (Test, "1 min", Human.Image (60.4), "1m 0.4s");
Check (Test, "1 min", Human.Image (59.6), "59.6s");
Check (Test, "59s", Human.Image (59.4), "59.4s");
Check (Test, "10s", Human.Image (10.3), "10.3s");
Check (Test, "6 s", Human.Image (6.0), "6s");
Check (Test, "5.400 s", Human.Image (5.4), "5.4s");
Check (Test, "1 s", Human.Image (1.0), "1s");
Check (Test, "980 ms", Human.Image (0.98), "980ms");
Check (Test, "40 ms", Human.Image (0.04), "40ms");
Check (Test, "20 ms", Human.Image (0.02), "20ms");
pragma Warnings (Off, "condition is always *");
if 89999.0 in Duration then
Check (Test, "1d 1h", Human.Image (89999.0), "1d 59m 59s");
end if;
-- The tests below require a smaller Duration'Small than what is
-- guaranteed by the standard. Further conditions should be added
-- to prevent a check from failing because of lack of Duration precision
Check (Test, "2 s", Human.Image (2.0002), "2.0002s");
Check (Test, "2 s", Human.Image (1.9997), "1.9997s");
Check (Test, "1.999 s", Human.Image (1.999), "1.999s");
Check (Test, "1 s", Human.Image (1.0), "1s");
Check (Test, "999 ms", Human.Image (0.999), "999 ms");
Check (Test, "2 s", Human.Image (2.000_4), "2.0004");
Check (Test, "10 ms", Human.Image (0.0104), "10.4 ms");
Check (Test, "9.990 ms", Human.Image (0.009_99), "9.990 ms");
Check (Test, "1.001 ms", Human.Image (0.001_001), "1.001 ms");
Check (Test, "1 ms", Human.Image (0.001), "1.000 ms");
Check (Test, "999 us", Human.Image (0.000_999), "999 us");
Check (Test, "10 us", Human.Image (0.000_01), "10 us");
Check (Test, "9.500 us", Human.Image (0.000_009_5), "9.5 us");
Check (Test, "1.100 us", Human.Image (0.000_001_1), "1.1 us");
Check (Test, "1 us", Human.Image (0.000_001), "1 us");
Check (Test, "900 ns", Human.Image (0.000_000_9), "900 ns");
pragma Warnings (On, "condition is always *");
exception
when Error : others => Test.Report_Exception (Error);
end Human_Duration;
procedure Human_Time_Difference (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Human-readable time differences");
Now : constant Ada.Calendar.Time := Ada.Calendar.Clock;
function Add
(Base : Ada.Calendar.Time;
Days : Ada.Calendar.Arithmetic.Day_Count;
Seconds : Duration)
return Ada.Calendar.Time
is (Ada.Calendar."+"
(Ada.Calendar.Arithmetic."+" (Base, Days), Seconds));
function Test_Image
(Days : Ada.Calendar.Arithmetic.Day_Count;
Seconds : Duration;
Use_Weeks : Boolean)
return String
is (Human.Difference_Image (Add (Now, Days, Seconds), Now, Use_Weeks));
begin
Check (Test, "-1d", Human.Difference_Image (Now, Add (Now, 1, 900.0)));
Check (Test, "71d", Test_Image (71, 36_000.0, False));
Check (Test, "10w", Test_Image (70, 3_600.0, True));
Check (Test, "5w 1d", Test_Image (35, 60_000.0, True));
Check (Test, "1w 2d", Test_Image (8, 54_000.0, True));
Check (Test, "8d 15h", Test_Image (8, 54_000.0, False));
Check (Test, "8d", Test_Image (7, 23 * 3600.0 + 35 * 60.0, False));
Check (Test, "5d", Test_Image (5, 900.0, True));
Check (Test, "10h", Test_Image (0, 36_598.0, True));
exception
when Error : others => Test.Report_Exception (Error);
end Human_Time_Difference;
procedure Read_From_RFC_3339 (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("RFC-3339 -> Ada.Calendar.Time");
Now : constant Extended_Time
:= (Ada.Calendar.Clock, Ada.Calendar.Time_Zones.UTC_Time_Offset);
function Value
(Img : String;
Expected_Leap : Boolean := False)
return Extended_Time;
function Value
(Img : String;
Expected_Leap : Boolean := False)
return Extended_Time
is
Result : Extended_Time;
Leap : Boolean;
begin
RFC_3339.Value (Img, Result.Time, Result.Offset, Leap);
if Leap /= Expected_Leap then
Test.Fail ("Unexpected leap second flag at "
& Boolean'Image (Leap)
& " for """ & Img & '"');
end if;
return Result;
end Value;
begin
Check (Test,
(Ada.Calendar.Formatting.Time_Of
(1985, 04, 12, 23, 20, 50, 0.52, False, 0), 0),
Value ("1985-04-12T23:20:50.52Z"),
"[1] UTC time with subseconds:");
Check (Test,
(Ada.Calendar.Formatting.Time_Of
(1996, 12, 19, 16, 39, 57, 0.0, False, -8 * 60), -8 * 60),
Value ("1996-12-19T16:39:57-08:00"),
"[2] Time with negative offset:");
if Has_Leap_Second_Support then
Check (Test,
(Ada.Calendar.Formatting.Time_Of
(1990, 12, 31, 23, 59, 59, 0.0, True, 0), 0),
Value ("1990-12-31T23:59:60Z"),
"[3] UTC leap second:");
Check (Test,
(Ada.Calendar.Formatting.Time_Of
(1990, 12, 31, 15, 59, 59, 0.0, True, -8 * 60), -8 * 60),
Value ("1990-12-31T15:59:60-08:00"),
"[4] Leap second with time offset:");
else
Check (Test,
(Ada.Calendar.Formatting.Time_Of
(1990, 12, 31, 23, 59, 59, 0.0, False, 0), 0),
Value ("1990-12-31T23:59:60Z", True),
"[3] UTC leap second:");
Check (Test,
(Ada.Calendar.Formatting.Time_Of
(1990, 12, 31, 15, 59, 59, 0.0, False, -8 * 60), -8 * 60),
Value ("1990-12-31T15:59:60-08:00", True),
"[4] Leap second with time offset:");
end if;
Check (Test,
(Ada.Calendar.Formatting.Time_Of
(1937, 01, 01, 12, 0, 27, 0.87, False, 20), 20),
Value ("1937-01-01T12:00:27.87+00:20"),
"[5] Noon in the Netherlands:");
Check (Test, Now,
Value (RFC_3339.Image (Now.Time, Subsecond_Digits => 9)),
"[6] Round trip with current time:");
declare
Time : Extended_Time;
begin
RFC_3339.Value ("1990-11-31T23:59:60Z", Time.Time, Time.Offset);
Test.Fail ("No exception on 1990-11-31, found " & Image (Time));
exception
when Ada.Calendar.Time_Error =>
null;
end;
exception
when Error : others => Test.Report_Exception (Error);
end Read_From_RFC_3339;
procedure Write_As_RFC_3339 (Report : in out NT.Reporter'Class) is
Test : NT.Test := Report.Item ("Ada.Calendar.Time -> RFC-3339");
begin
Check (Test,
"1985-04-12T23:20:50.52Z",
RFC_3339.Image
(Ada.Calendar.Formatting.Time_Of
(1985, 04, 12, 23, 20, 50, 0.52, False, 0),
0, 2),
"[1] UTC time with subseconds:");
Check (Test,
"1996-12-19T16:39:57-08:00",
RFC_3339.Image
(Ada.Calendar.Formatting.Time_Of
(1996, 12, 19, 16, 39, 57, 0.0, False, -8 * 60),
-8 * 60, 0),
"[2] Time with negative offset:");
if Has_Leap_Second_Support then
Check (Test,
"1990-12-31T23:59:60Z",
RFC_3339.Image
(Ada.Calendar.Formatting.Time_Of
(1990, 12, 31, 23, 59, 59, 0.0, True, 0),
0, 0),
"[3] UTC leap second:");
Check (Test,
"1990-12-31T15:59:60-08:00",
RFC_3339.Image
(Ada.Calendar.Formatting.Time_Of
(1990, 12, 31, 15, 59, 59, 0.0, True, -8 * 60),
-8 * 60, 0),
"[4] Leap second with time offset:");
end if;
Check (Test,
"1990-12-31T23:59:60Z",
RFC_3339.Image
(Ada.Calendar.Formatting.Time_Of
(1990, 12, 31, 23, 59, 59, 0.0, False, 0),
0, 0, True),
"[3b] UTC leap second with workaround:");
Check (Test,
"1990-12-31T15:59:60-08:00",
RFC_3339.Image
(Ada.Calendar.Formatting.Time_Of
(1990, 12, 31, 15, 59, 59, 0.0, False, -8 * 60),
-8 * 60, 0, True),
"[4b] Leap second with time offset and workaround:");
Check (Test,
"1937-01-01T12:00:27.87+00:20",
RFC_3339.Image
(Ada.Calendar.Formatting.Time_Of
(1937, 01, 01, 12, 0, 27, 0.87, False, 20),
20, 2),
"[5] Noon in the Netherlands:");
Check (Test,
"2014-12-25T23:00:00+01:00",
RFC_3339.Image
(RFC_3339.Value ("2014-12-25T23:00:00+01:00"),
60, 0),
"[6] Round trip");
exception
when Error : others => Test.Report_Exception (Error);
end Write_As_RFC_3339;
end Natools.Time_IO.Tests;
|
-- for MR_Pool
with System.Storage_Pools.Subpools;
with System.Storage_Elements;
with Ada.Unchecked_Deallocate_Subpool;
-- for dummy item type
with Ada.Finalization;
with System.Storage_Elements.Formatting;
procedure subpool is
-- RM 13-11-6
package MR_Pool is
use System.Storage_Pools;
-- For uses of Subpools.
use System.Storage_Elements;
-- For uses of Storage_Count and Storage_Array.]
-- Mark and Release work in a stack fashion, and allocations are not allowed
-- from a subpool other than the one at the top of the stack. This is also
-- the default pool.
subtype Subpool_Handle is Subpools.Subpool_Handle;
type Mark_Release_Pool_Type (Pool_Size : Storage_Count) is new
Subpools.Root_Storage_Pool_With_Subpools with private;
function Mark (Pool : in out Mark_Release_Pool_Type)
return not null Subpool_Handle;
procedure Release (Subpool : in out Subpool_Handle) renames
Ada.Unchecked_Deallocate_Subpool;
private
type MR_Subpool is new Subpools.Root_Subpool with record
Start : Storage_Count;
end record;
subtype Subpool_Indexes is Positive range 1 .. 10;
type Subpool_Array is array (Subpool_Indexes) of aliased MR_Subpool;
type Mark_Release_Pool_Type (Pool_Size : Storage_Count) is new
Subpools.Root_Storage_Pool_With_Subpools with record
Storage : Storage_Array (0 .. Pool_Size);
Next_Allocation : Storage_Count := 1;
Markers : Subpool_Array;
Current_Pool : Subpool_Indexes := 1;
end record;
overriding
function Create_Subpool (Pool : in out Mark_Release_Pool_Type)
return not null Subpool_Handle;
function Mark (Pool : in out Mark_Release_Pool_Type)
return not null Subpool_Handle renames Create_Subpool;
overriding
procedure Allocate_From_Subpool (
Pool : in out Mark_Release_Pool_Type;
Storage_Address : out System.Address;
Size_In_Storage_Elements : in Storage_Count;
Alignment : in Storage_Count;
Subpool : not null Subpool_Handle);
overriding
procedure Deallocate_Subpool (
Pool : in out Mark_Release_Pool_Type;
Subpool : in out Subpool_Handle);
overriding
function Default_Subpool_for_Pool (Pool : in out Mark_Release_Pool_Type)
return not null Subpool_Handle;
overriding
procedure Initialize (Pool : in out Mark_Release_Pool_Type);
-- We don't need Finalize.
end MR_Pool;
package body MR_Pool is
use type Subpool_Handle;
procedure Initialize (Pool : in out Mark_Release_Pool_Type) is
-- Initialize the first default subpool.
begin
Subpools.Initialize (Subpools.Root_Storage_Pool_With_Subpools (Pool)); -- drake
Pool.Markers(1).Start := 1;
Subpools.Set_Pool_of_Subpool
(Pool.Markers(1)'Unchecked_Access, Pool);
end Initialize;
function Create_Subpool (Pool : in out Mark_Release_Pool_Type)
return not null Subpool_Handle is
-- Mark the current allocation location.
begin
if Pool.Current_Pool = Subpool_Indexes'Last then
raise Storage_Error; -- No more subpools.
end if;
Pool.Current_Pool := Pool.Current_Pool + 1; -- Move to the next subpool
return Result : constant not null Subpool_Handle :=
Pool.Markers(Pool.Current_Pool)'Unchecked_Access
do
MR_Subpool (Result.all).Start := Pool.Next_Allocation;
Subpools.Set_Pool_of_Subpool (Result, Pool);
end return;
end Create_Subpool;
procedure Deallocate_Subpool (
Pool : in out Mark_Release_Pool_Type;
Subpool : in out Subpool_Handle) is
begin
if Subpool /= Pool.Markers(Pool.Current_Pool)'Unchecked_Access then
raise Program_Error; -- Only the last marked subpool can be released.
end if;
if Pool.Current_Pool /= 1 then
Pool.Next_Allocation := Pool.Markers(Pool.Current_Pool).Start;
Pool.Current_Pool := Pool.Current_Pool - 1; -- Move to the previous subpool
else -- Reinitialize the default subpool:
Pool.Next_Allocation := 1;
Subpools.Set_Pool_of_Subpool
(Pool.Markers(1)'Unchecked_Access, Pool);
end if;
end Deallocate_Subpool;
function Default_Subpool_for_Pool (Pool : in out Mark_Release_Pool_Type)
return not null Subpool_Handle is
begin
return Pool.Markers(Pool.Current_Pool)
'Unrestricted_Access; -- 'Unchecked_Access; / different gcc from Standard
end Default_Subpool_for_Pool;
procedure Allocate_From_Subpool (
Pool : in out Mark_Release_Pool_Type;
Storage_Address : out System.Address;
Size_In_Storage_Elements : in Storage_Count;
Alignment : in Storage_Count;
Subpool : not null Subpool_Handle) is
begin
if Subpool /= Pool.Markers(Pool.Current_Pool)'Unchecked_Access then
raise Program_Error; -- Only the last marked subpool can be used for allocations.
end if;
-- Correct the alignment if necessary:
Pool.Next_Allocation := Pool.Next_Allocation
+ ((-Pool.Next_Allocation) mod Alignment);
if Pool.Next_Allocation + Size_In_Storage_Elements >
Pool.Pool_Size then
raise Storage_Error; -- Out of space.
end if;
Storage_Address := Pool.Storage (Pool.Next_Allocation)'Address;
Pool.Next_Allocation :=
Pool.Next_Allocation + Size_In_Storage_Elements;
end Allocate_From_Subpool;
end MR_Pool;
use type System.Storage_Elements.Storage_Offset;
Pool : MR_Pool.Mark_Release_Pool_Type (Pool_Size => 1024 - 1);
package Dummy is
type Dummy is new Ada.Finalization.Controlled with null record;
overriding procedure Initialize (Object : in out Dummy);
overriding procedure Adjust (Object : in out Dummy);
overriding procedure Finalize (Object : in out Dummy);
end Dummy;
package body Dummy is
package SSEF renames System.Storage_Elements.Formatting;
overriding procedure Initialize (Object : in out Dummy) is
begin
Ada.Debug.Put ("at " & SSEF.Image (Object'Address));
end Initialize;
overriding procedure Adjust (Object : in out Dummy) is
begin
Ada.Debug.Put ("at " & SSEF.Image (Object'Address));
end Adjust;
overriding procedure Finalize (Object : in out Dummy) is
begin
Ada.Debug.Put ("at " & SSEF.Image (Object'Address));
end Finalize;
end Dummy;
type A is access Dummy.Dummy;
for A'Storage_Pool use Pool;
X : array (1 .. 3) of A;
Mark : MR_Pool.Subpool_Handle;
begin
Mark := MR_Pool.Mark (Pool);
for I in X'Range loop
X (I) := new Dummy.Dummy;
end loop;
MR_Pool.Release (Mark);
pragma Debug (Ada.Debug.Put ("OK"));
end subpool;
|
with Ada.Text_IO;
use Ada.Text_IO;
procedure procs2 is
procedure forLoop --
is --(vari :Natural) is
begin
for i in 1..10 loop
Put_Line ("Iteration: ");
--Put(i);
-- Ada.Text_IO.Put_Line;
end loop;
-- Put_Line(vari);
-- Vari := Vari +1;
end forLoop;
begin
forLoop;
Put_Line("second line");
end procs2;
|
with ada.characters.latin_1;
with box_parts;
use box_parts;
package svg is
-- exporte la boite au format svg
function get_svg(box : box_parts_t; input_border_color, input_fill_color, pattern : string) return string;
private
lf : constant character := ada.characters.latin_1.lf;
tab : constant character := ada.characters.latin_1.ht;
default_border_color : constant string := "red";
default_fill_color : constant string := "white";
svg_header : constant string :=
"<svg version=""1.1""" & lf &
" baseProfile=""full""" & lf &
" xmlns=""http://www.w3.org/2000/svg""" & lf &
" xmlns:xlink=""http://www.w3.org/1999/xlink"">" & lf;
svg_polygon_begin : constant string :=
tab & "<polygon style=""stroke-width:0.1;stroke:";
svg_polygon_fill_style : constant string :=
";fill:";
svg_polygon_end_style : constant string :=
""" points=""";
svg_polygon_end : constant string :=
"""/>" & lf;
svg_footer : constant string := "</svg>";
end svg;
|
-- Abstract :
--
-- See spec
--
-- Copyright (C) 2017, 2018 Free Software Foundation, Inc.
--
-- This library is free software; you can redistribute it and/or modify it
-- under terms of the GNU General Public License as published by the Free
-- Software Foundation; either version 3, or (at your option) any later
-- version. This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-- As a special exception under Section 7 of GPL version 3, you are granted
-- additional permissions described in the GCC Runtime Library Exception,
-- version 3.1, as published by the Free Software Foundation.
pragma License (GPL);
with Ada.Characters.Handling;
with WisiToken.Wisi_Ada;
package body WisiToken.Gen_Token_Enum is
function Token_Enum_Image return Token_ID_Array_String
is
use Ada.Characters.Handling;
Result : Token_ID_Array_String (Token_ID'First .. +Last_Nonterminal);
begin
for I in Token_Enum_ID loop
if I <= Last_Terminal then
Result (+I) := new String'(Token_Enum_ID'Image (I));
else
Result (+I) := new String'(To_Lower (Token_Enum_ID'Image (I)));
end if;
end loop;
return Result;
end Token_Enum_Image;
function To_Syntax (Item : in Enum_Syntax) return WisiToken.Lexer.Regexp.Syntax
is
Result : WisiToken.Lexer.Regexp.Syntax (Token_ID'First .. +Last_Terminal);
begin
for I in Result'Range loop
Result (I) := Item (-I);
end loop;
return Result;
end To_Syntax;
function "&" (Left, Right : in Token_Enum_ID) return Token_ID_Arrays.Vector
is begin
return Result : Token_ID_Arrays.Vector do
Result.Append (+Left);
Result.Append (+Right);
end return;
end "&";
function "&"
(Left : in Token_ID_Arrays.Vector;
Right : in Token_Enum_ID)
return Token_ID_Arrays.Vector
is begin
return Result : Token_ID_Arrays.Vector := Left do
Result.Append (+Right);
end return;
end "&";
function "+"
(Left : in Token_Enum_ID;
Right : in WisiToken.Syntax_Trees.Semantic_Action)
return WisiToken.Productions.Right_Hand_Side
is begin
return WisiToken.Wisi_Ada."+" (+Left, Right);
end "+";
function "<="
(Left : in Token_Enum_ID;
Right : in WisiToken.Productions.Right_Hand_Side)
return WisiToken.Productions.Instance
is begin
return WisiToken.Wisi_Ada."<=" (+Left, Productions.RHS_Arrays.To_Vector (Right, 1));
end "<=";
function To_Nonterminal_Array_Token_Set
(Item : in Nonterminal_Array_Token_Set)
return WisiToken.Token_Array_Token_Set
is
Result : Token_Array_Token_Set :=
(LR1_Descriptor.First_Nonterminal .. LR1_Descriptor.Last_Nonterminal =>
(LR1_Descriptor.First_Terminal .. LR1_Descriptor.Last_Nonterminal => False));
begin
for I in Item'Range (1) loop
for J in Item'Range (2) loop
Result (+I, +J) := Item (I, J);
end loop;
end loop;
return Result;
end To_Nonterminal_Array_Token_Set;
function To_Nonterminal_Array_Terminal_Set
(Item : in Nonterminal_Array_Terminal_Set)
return WisiToken.Token_Array_Token_Set
is
Result : Token_Array_Token_Set :=
(LR1_Descriptor.First_Nonterminal .. LR1_Descriptor.Last_Nonterminal =>
(LR1_Descriptor.First_Terminal .. LR1_Descriptor.Last_Terminal => False));
begin
for I in Item'Range (1) loop
for J in Item'Range (2) loop
Result (+I, +J) := Item (I, J);
end loop;
end loop;
return Result;
end To_Nonterminal_Array_Terminal_Set;
function "+" (Item : in Token_Array) return WisiToken.Token_ID_Set
is
Result : Token_ID_Set := (LR1_Descriptor.First_Terminal .. LR1_Descriptor.Last_Terminal => False);
begin
for I in Item'Range loop
Result (+Item (I)) := True;
end loop;
return Result;
end "+";
function "+" (Item : in Token_Enum_ID) return WisiToken.Token_ID_Set
is begin
return +Token_Array'(1 => Item);
end "+";
begin
LR1_Descriptor.Image := Token_Enum_Image;
LALR_Descriptor.Image := LR1_Descriptor.Image;
end WisiToken.Gen_Token_Enum;
|
with
Asis;
package AdaM.Assist.Query.find_All.unit_Processing
is
procedure Process_Unit (The_Unit : in Asis.Compilation_Unit);
end AdaM.Assist.Query.find_All.unit_Processing;
|
-- Copyright (c) 2020-2021 Bartek thindil Jasicki <thindil@laeran.pl>
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Ada.Characters.Handling; use Ada.Characters.Handling;
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1;
with Ada.Containers.Generic_Array_Sort;
with Ada.Strings; use Ada.Strings;
with Ada.Strings.Fixed; use Ada.Strings.Fixed;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Interfaces.C.Strings; use Interfaces.C.Strings;
with GNAT.String_Split; use GNAT.String_Split;
with Tcl.Ada; use Tcl.Ada;
with Tcl.Tk.Ada; use Tcl.Tk.Ada;
with Tcl.Tk.Ada.Grid;
with Tcl.Tk.Ada.Widgets; use Tcl.Tk.Ada.Widgets;
with Tcl.Tk.Ada.Widgets.Canvas; use Tcl.Tk.Ada.Widgets.Canvas;
with Tcl.Tk.Ada.Widgets.Menu; use Tcl.Tk.Ada.Widgets.Menu;
with Tcl.Tk.Ada.Widgets.Toplevel; use Tcl.Tk.Ada.Widgets.Toplevel;
with Tcl.Tk.Ada.Widgets.Toplevel.MainWindow;
use Tcl.Tk.Ada.Widgets.Toplevel.MainWindow;
with Tcl.Tk.Ada.Widgets.TtkEntry; use Tcl.Tk.Ada.Widgets.TtkEntry;
with Tcl.Tk.Ada.Widgets.TtkEntry.TtkComboBox;
use Tcl.Tk.Ada.Widgets.TtkEntry.TtkComboBox;
with Tcl.Tk.Ada.Widgets.TtkFrame; use Tcl.Tk.Ada.Widgets.TtkFrame;
with Tcl.Tk.Ada.Widgets.TtkLabel; use Tcl.Tk.Ada.Widgets.TtkLabel;
with Tcl.Tk.Ada.Widgets.TtkScrollbar; use Tcl.Tk.Ada.Widgets.TtkScrollbar;
with Tcl.Tk.Ada.Winfo; use Tcl.Tk.Ada.Winfo;
with Tcl.Tklib.Ada.Tooltip; use Tcl.Tklib.Ada.Tooltip;
with Bases; use Bases;
with BasesTypes; use BasesTypes;
with Config; use Config;
with CoreUI; use CoreUI;
with Dialogs; use Dialogs;
with Factions; use Factions;
with Game; use Game;
with Maps; use Maps;
with Messages; use Messages;
with Ships; use Ships;
with Table; use Table;
with Utils; use Utils;
with Utils.UI; use Utils.UI;
package body Knowledge.Bases is
-- ****iv* KBases/KBases.BasesTable
-- FUNCTION
-- Table with info about the know bases
-- SOURCE
BasesTable: Table_Widget (7);
-- ****
-- ****iv* KBases/KBases.Modules_Indexes
-- FUNCTION
-- Indexes of the player ship modules
-- SOURCE
Bases_Indexes: Positive_Container.Vector;
-- ****
-- ****if* KBases/KBases.Get_Reputation_Text
-- FUNCTION
-- Get the name of the reputation level in the selected base
-- PARAMETERS
-- Reputation_Level - The numerical level of reputation in a base
-- RESULT
-- The name of the reputation level in the selected base
-- SOURCE
function Get_Reputation_Text(Reputation_Level: Integer) return String is
-- ****
begin
case Reputation_Level is
when -100 .. -75 =>
return "Hated";
when -74 .. -50 =>
return "Outlaw";
when -49 .. -25 =>
return "Hostile";
when -24 .. -1 =>
return "Unfriendly";
when 0 =>
return "Unknown";
when 1 .. 25 =>
return "Visitor";
when 26 .. 50 =>
return "Trader";
when 51 .. 75 =>
return "Friend";
when 76 .. 100 =>
return "Well known";
when others =>
return "";
end case;
end Get_Reputation_Text;
procedure UpdateBasesList(BaseName: String := ""; Page: Positive := 1) is
BasesCanvas: constant Tk_Canvas :=
Get_Widget(Main_Paned & ".knowledgeframe.bases.canvas");
BasesFrame: constant Ttk_Frame := Get_Widget(BasesCanvas & ".frame");
SearchEntry: constant Ttk_Entry :=
Get_Widget(BasesFrame & ".options.search");
Tokens: Slice_Set;
Rows: Natural := 0;
ComboBox: Ttk_ComboBox := Get_Widget(BasesFrame & ".options.types");
BasesType, BasesOwner, BasesStatus: Unbounded_String;
Start_Row: constant Positive :=
((Page - 1) * Game_Settings.Lists_Limit) + 1;
Current_Row: Positive := 1;
begin
Create(Tokens, Tcl.Tk.Ada.Grid.Grid_Size(BasesFrame), " ");
Rows := Natural'Value(Slice(Tokens, 2));
if BasesTable.Row > 1 then
ClearTable(BasesTable);
end if;
Delete_Widgets(2, Rows - 1, BasesFrame);
BasesTable :=
CreateTable
(Widget_Image(BasesFrame),
(To_Unbounded_String("Name"), To_Unbounded_String("Distance"),
To_Unbounded_String("Population"), To_Unbounded_String("Size"),
To_Unbounded_String("Owner"), To_Unbounded_String("Type"),
To_Unbounded_String("Reputation")),
Get_Widget(".gameframe.paned.knowledgeframe.bases.scrolly"),
"SortKnownBases {" & BaseName & "}",
"Press mouse button to sort the bases.");
if Bases_Indexes.Is_Empty then
for I in Sky_Bases'Range loop
Bases_Indexes.Append(I);
end loop;
end if;
if BaseName'Length = 0 then
configure(SearchEntry, "-validatecommand {}");
Delete(SearchEntry, "0", "end");
configure(SearchEntry, "-validatecommand {ShowBases %P}");
end if;
BasesType := To_Unbounded_String(Get(ComboBox));
ComboBox.Name := New_String(BasesFrame & ".options.status");
BasesStatus := To_Unbounded_String(Get(ComboBox));
ComboBox.Name := New_String(BasesFrame & ".options.owner");
BasesOwner := To_Unbounded_String(Get(ComboBox));
Rows := 0;
Load_Bases_Loop :
for I of Bases_Indexes loop
if not Sky_Bases(I).Known then
goto End_Of_Loop;
end if;
if BaseName'Length > 0
and then
Index
(To_Lower(To_String(Sky_Bases(I).Name)), To_Lower(BaseName),
1) =
0 then
goto End_Of_Loop;
end if;
if BasesStatus = To_Unbounded_String("Only not visited") and
Sky_Bases(I).Visited.Year /= 0 then
goto End_Of_Loop;
end if;
if BasesStatus = To_Unbounded_String("Only visited") and
Sky_Bases(I).Visited.Year = 0 then
goto End_Of_Loop;
end if;
if Sky_Bases(I).Visited.Year = 0
and then
(BasesType /= To_Unbounded_String("Any") or
BasesOwner /= To_Unbounded_String("Any")) then
goto End_Of_Loop;
end if;
if Current_Row < Start_Row then
Current_Row := Current_Row + 1;
goto End_Of_Loop;
end if;
AddButton
(BasesTable, To_String(Sky_Bases(I).Name),
"Show available base's options",
"ShowBasesMenu" & Positive'Image(I), 1);
AddButton
(BasesTable,
Natural'Image
(CountDistance(Sky_Bases(I).Sky_X, Sky_Bases(I).Sky_Y)),
"The distance to the base", "ShowBasesMenu" & Positive'Image(I),
2);
if Sky_Bases(I).Visited.Year > 0 then
AddButton
(BasesTable,
(case Sky_Bases(I).Population is when 0 => "empty",
when 1 .. 150 => "small", when 151 .. 299 => "medium",
when others => "large"),
"The population size of the base",
"ShowBasesMenu" & Positive'Image(I), 3);
AddButton
(BasesTable, To_Lower(Bases_Size'Image(Sky_Bases(I).Size)),
"The size of the base", "ShowBasesMenu" & Positive'Image(I), 4);
AddButton
(BasesTable, To_String(Factions_List(Sky_Bases(I).Owner).Name),
"The faction which own the base",
"ShowBasesMenu" & Positive'Image(I), 5);
AddButton
(BasesTable,
To_String(Bases_Types_List(Sky_Bases(I).Base_Type).Name),
"The type of the base", "ShowBasesMenu" & Positive'Image(I), 6);
AddButton
(BasesTable, Get_Reputation_Text(Sky_Bases(I).Reputation(1)),
"Your reputation in the base",
"ShowBasesMenu" & Positive'Image(I), 7, True);
else
AddButton
(BasesTable, "not", "Show available base's options",
"ShowBasesMenu" & Positive'Image(I), 3);
AddButton
(BasesTable, "", "Show available base's options",
"ShowBasesMenu" & Positive'Image(I), 4);
AddButton
(BasesTable, "visited", "Show available base's options",
"ShowBasesMenu" & Positive'Image(I), 5);
AddButton
(BasesTable, "", "Show available base's options",
"ShowBasesMenu" & Positive'Image(I), 6);
AddButton
(BasesTable, "yet", "Show available base's options",
"ShowBasesMenu" & Positive'Image(I), 7, True);
end if;
Rows := Rows + 1;
exit Load_Bases_Loop when Rows = Game_Settings.Lists_Limit + 1 and
I < Sky_Bases'Last;
<<End_Of_Loop>>
end loop Load_Bases_Loop;
if Page > 1 then
AddPagination
(BasesTable,
"ShowBases {" & BaseName & "}" & Positive'Image(Page - 1),
(if BasesTable.Row < Game_Settings.Lists_Limit + 1 then ""
else "ShowBases {" & BaseName & "}" & Positive'Image(Page + 1)));
elsif BasesTable.Row = Game_Settings.Lists_Limit + 1 then
AddPagination
(BasesTable, "",
"ShowBases {" & BaseName & "}" & Positive'Image(Page + 1));
end if;
UpdateTable
(BasesTable, (if Focus = Widget_Image(SearchEntry) then False));
Xview_Move_To(BasesCanvas, "0.0");
Yview_Move_To(BasesCanvas, "0.0");
Tcl_Eval(Get_Context, "update");
configure
(BasesCanvas, "-scrollregion [list " & BBox(BasesCanvas, "all") & "]");
end UpdateBasesList;
-- ****o* KBases/KBases.Show_Bases_Command
-- FUNCTION
-- Show the list of known bases to a player
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command.
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- ShowBases ?basename? ?page?
-- Basename parameter is a string which will be looking for in the bases
-- names, page parameter is a index of page from which starts showing
-- bases.
-- SOURCE
function Show_Bases_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Show_Bases_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData);
begin
case Argc is
when 3 =>
UpdateBasesList
(CArgv.Arg(Argv, 1), Positive'Value(CArgv.Arg(Argv, 2)));
when 2 =>
UpdateBasesList(CArgv.Arg(Argv, 1));
when others =>
UpdateBasesList;
end case;
Tcl_SetResult(Interp, "1");
return TCL_OK;
end Show_Bases_Command;
-- ****if* KBases/KBases.Show_Bases_Menu_Command
-- FUNCTION
-- Show the menu with available the selected base options
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed.
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- ShowBaseMenu baseindex
-- BaseIndex is the index of the base's menu to show
-- SOURCE
function Show_Bases_Menu_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Show_Bases_Menu_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Argc);
BaseMenu: Tk_Menu := Get_Widget(".baseslistmenu", Interp);
BaseIndex: constant Positive := Positive'Value(CArgv.Arg(Argv, 1));
begin
if Winfo_Get(BaseMenu, "exists") = "0" then
BaseMenu := Create(".baseslistmenu", "-tearoff false");
end if;
Delete(BaseMenu, "0", "end");
Menu.Add
(BaseMenu, "command",
"-label {Show the base on map} -command {ShowOnMap" &
Map_X_Range'Image(Sky_Bases(BaseIndex).Sky_X) &
Map_Y_Range'Image(Sky_Bases(BaseIndex).Sky_Y) & "}");
Menu.Add
(BaseMenu, "command",
"-label {Set the base as destination for the ship} -command {SetDestination2 " &
Map_X_Range'Image(Sky_Bases(BaseIndex).Sky_X) &
Map_Y_Range'Image(Sky_Bases(BaseIndex).Sky_Y) & "}");
if Sky_Bases(BaseIndex).Visited.Year > 0 then
Menu.Add
(BaseMenu, "command",
"-label {Show more information about the base} -command {ShowBaseInfo " &
CArgv.Arg(Argv, 1) & "}");
end if;
Tk_Popup
(BaseMenu, Winfo_Get(Get_Main_Window(Interp), "pointerx"),
Winfo_Get(Get_Main_Window(Interp), "pointery"));
return TCL_OK;
end Show_Bases_Menu_Command;
-- ****o* KBases/KBases.Show_Base_Info_Command
-- FUNCTION
-- Show information about the selected base
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed. Unused
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- ShowBaseInfo baseindex
-- BaseIndex is the index of the base to show
-- SOURCE
function Show_Base_Info_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Show_Base_Info_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Interp, Argc);
BaseIndex: constant Positive := Positive'Value(CArgv.Arg(Argv, 1));
BaseDialog: constant Ttk_Frame :=
Create_Dialog
(Name => ".basedialog",
Title => To_String(Sky_Bases(BaseIndex).Name), Columns => 2);
BaseLabel: Ttk_Label;
BaseInfo: Unbounded_String;
procedure SetReputationText(ReputationText: String) is
ReputationBar: constant Ttk_Frame :=
Create
(BaseDialog & ".reputation",
"-width 204 -height 24 -style ProgressBar.TFrame");
ReputationLabel: constant Ttk_Label :=
Create(BaseDialog & ".reputationlabel");
ReputationProgress: constant Ttk_Frame :=
Create(ReputationBar & ".reputation", "-height 18");
begin
if Sky_Bases(BaseIndex).Reputation(1) = 0 then
configure(ReputationLabel, "-text {Reputation: Unknown}");
else
configure(ReputationLabel, "-text {Reputation:}");
Tcl.Tk.Ada.Grid.Grid(ReputationBar, "-row 2 -column 1 -padx 5");
Tcl.Tk.Ada.Grid.Grid_Propagate(ReputationBar, "off");
configure
(ReputationProgress,
"-width" &
Positive'Image(abs (Sky_Bases(BaseIndex).Reputation(1))));
if Sky_Bases(BaseIndex).Reputation(1) > 0 then
configure(ReputationProgress, "-style GreenProgressBar.TFrame");
Tcl.Tk.Ada.Grid.Grid
(ReputationProgress, "-padx {100 0} -pady 3");
else
configure(ReputationProgress, "-style RedProgressBar.TFrame");
Tcl.Tk.Ada.Grid.Grid
(ReputationProgress,
"-padx {" &
Trim
(Positive'Image(100 + Sky_Bases(BaseIndex).Reputation(1)),
Left) &
" 0} -pady 3");
end if;
Add(ReputationBar, ReputationText);
end if;
Tcl.Tk.Ada.Grid.Grid(ReputationLabel, "-row 2 -sticky w -padx {5 0}");
end SetReputationText;
begin
BaseInfo :=
To_Unbounded_String
("Coordinates X:" & Positive'Image(Sky_Bases(BaseIndex).Sky_X) &
" Y:" & Positive'Image(Sky_Bases(BaseIndex).Sky_Y));
Append
(BaseInfo,
LF & "Last visited: " & FormatedTime(Sky_Bases(BaseIndex).Visited));
declare
TimeDiff: Integer;
begin
if Sky_Bases(BaseIndex).Population > 0 and
Sky_Bases(BaseIndex).Reputation(1) > -25 then
TimeDiff :=
30 - Days_Difference(Sky_Bases(BaseIndex).Recruit_Date);
if TimeDiff > 0 then
Append
(BaseInfo,
LF & "New recruits available in" & Natural'Image(TimeDiff) &
" days.");
else
Append(BaseInfo, LF & "New recruits available now.");
end if;
else
Append
(BaseInfo, LF & "You can't recruit crew members at this base.");
end if;
if Sky_Bases(BaseIndex).Population > 0 and
Sky_Bases(BaseIndex).Reputation(1) > -25 then
TimeDiff := Days_Difference(Sky_Bases(BaseIndex).Asked_For_Events);
if TimeDiff < 7 then
Append
(BaseInfo,
LF & "You asked for events" & Natural'Image(TimeDiff) &
" days ago.");
else
Append(BaseInfo, LF & "You can ask for events again.");
end if;
else
Append(BaseInfo, LF & "You can't ask for events at this base.");
end if;
if Sky_Bases(BaseIndex).Population > 0 and
Sky_Bases(BaseIndex).Reputation(1) > -1 then
TimeDiff :=
7 - Days_Difference(Sky_Bases(BaseIndex).Missions_Date);
if TimeDiff > 0 then
Append
(BaseInfo,
LF & "New missions available in" & Natural'Image(TimeDiff) &
" days.");
else
Append(BaseInfo, LF & "New missions available now.");
end if;
else
Append(BaseInfo, LF & "You can't take missions at this base.");
end if;
end;
SetReputationText
(Get_Reputation_Text(Sky_Bases(BaseIndex).Reputation(1)));
if BaseIndex = Player_Ship.Home_Base then
Append(BaseInfo, LF & "It is your home base.");
end if;
BaseLabel :=
Create
(BaseDialog & ".info",
"-text {" & To_String(BaseInfo) & "} -wraplength 400");
Tcl.Tk.Ada.Grid.Grid
(BaseLabel, "-row 1 -columnspan 2 -padx 5 -pady {5 0} -sticky w");
Add_Close_Button
(BaseDialog & ".button", "Close", "CloseDialog " & BaseDialog, 2);
Show_Dialog(BaseDialog);
return TCL_OK;
end Show_Base_Info_Command;
-- ****it* KBases/KBases.Bases_Sort_Orders
-- FUNCTION
-- Sorting orders for the known bases list
-- OPTIONS
-- NAMEASC - Sort bases by name ascending
-- NAMEDESC - Sort bases by name descending
-- DISTANCEASC - Sort bases by distance ascending
-- DISTANCEDESC - Sort bases by distance descending
-- POPULATIONASC - Sort bases by population ascending
-- POPULATIONDESC - Sort bases by population descending
-- SIZEASC - Sort bases by size ascending
-- SIZEDESC - Sort bases by size descending
-- OWNERASC - Sort bases by owner ascending
-- OWNERDESC - Sort bases by owner descending
-- TYPEASC - Sort bases by type ascending
-- TYPEDESC - Sort bases by type descending
-- REPUTATIONASC - Sort bases by reputation ascending
-- REPUTATIONDESC - Sort bases by reputation descending
-- NONE - No sorting bases (default)
-- HISTORY
-- 6.4 - Added
-- SOURCE
type Bases_Sort_Orders is
(NAMEASC, NAMEDESC, DISTANCEASC, DISTANCEDESC, POPULATIONASC,
POPULATIONDESC, SIZEASC, SIZEDESC, OWNERASC, OWNERDESC, TYPEASC,
TYPEDESC, REPUTATIONASC, REPUTATIONDESC, NONE) with
Default_Value => NONE;
-- ****
-- ****id* KBases/KBases.Default_Bases_Sort_Order
-- FUNCTION
-- Default sorting order for the list of known bases
-- HISTORY
-- 6.4 - Added
-- SOURCE
Default_Bases_Sort_Order: constant Bases_Sort_Orders := NONE;
-- ****
-- ****iv* KBases/KBases.Bases_Sort_Order
-- FUNCTION
-- The current sorting order for known bases list
-- HISTORY
-- 6.4 - Added
-- SOURCE
Bases_Sort_Order: Bases_Sort_Orders := Default_Bases_Sort_Order;
-- ****
-- ****o* KBases/KBases.Sort_Bases_Command
-- FUNCTION
-- Sort the list of known bases
-- PARAMETERS
-- ClientData - Custom data send to the command. Unused
-- Interp - Tcl interpreter in which command was executed. Unused
-- Argc - Number of arguments passed to the command. Unused
-- Argv - Values of arguments passed to the command.
-- RESULT
-- This function always return TCL_OK
-- COMMANDS
-- SortKnownBases x
-- X is X axis coordinate where the player clicked the mouse button
-- SOURCE
function Sort_Bases_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int with
Convention => C;
-- ****
function Sort_Bases_Command
(ClientData: Integer; Interp: Tcl.Tcl_Interp; Argc: Interfaces.C.int;
Argv: CArgv.Chars_Ptr_Ptr) return Interfaces.C.int is
pragma Unreferenced(ClientData, Interp, Argc);
Column: constant Positive :=
Get_Column_Number(BasesTable, Natural'Value(CArgv.Arg(Argv, 2)));
type Local_Base_Data is record
Name: Unbounded_String;
Distance: Natural;
Population: Integer;
Size: Bases_Size;
Owner: Unbounded_String;
Base_Type: Unbounded_String;
Reputation: Integer;
Id: Positive;
end record;
type Bases_Array is array(Positive range <>) of Local_Base_Data;
Local_Bases: Bases_Array (Bases_Range);
function "<"(Left, Right: Local_Base_Data) return Boolean is
begin
if Bases_Sort_Order = NAMEASC and then Left.Name < Right.Name then
return True;
end if;
if Bases_Sort_Order = NAMEDESC and then Left.Name > Right.Name then
return True;
end if;
if Bases_Sort_Order = DISTANCEASC
and then Left.Distance < Right.Distance then
return True;
end if;
if Bases_Sort_Order = DISTANCEDESC
and then Left.Distance > Right.Distance then
return True;
end if;
if Bases_Sort_Order = POPULATIONASC
and then Left.Population < Right.Population then
return True;
end if;
if Bases_Sort_Order = POPULATIONDESC
and then Left.Population > Right.Population then
return True;
end if;
if Bases_Sort_Order = SIZEASC and then Left.Size < Right.Size then
return True;
end if;
if Bases_Sort_Order = SIZEDESC and then Left.Size > Right.Size then
return True;
end if;
if Bases_Sort_Order = OWNERASC and then Left.Owner < Right.Owner then
return True;
end if;
if Bases_Sort_Order = OWNERDESC and then Left.Owner > Right.Owner then
return True;
end if;
if Bases_Sort_Order = TYPEASC
and then Left.Base_Type < Right.Base_Type then
return True;
end if;
if Bases_Sort_Order = TYPEDESC
and then Left.Base_Type > Right.Base_Type then
return True;
end if;
if Bases_Sort_Order = REPUTATIONASC
and then Left.Reputation < Right.Reputation then
return True;
end if;
if Bases_Sort_Order = REPUTATIONDESC
and then Left.Reputation > Right.Reputation then
return True;
end if;
return False;
end "<";
procedure Sort_Bases is new Ada.Containers.Generic_Array_Sort
(Index_Type => Positive, Element_Type => Local_Base_Data,
Array_Type => Bases_Array);
begin
case Column is
when 1 =>
if Bases_Sort_Order = NAMEASC then
Bases_Sort_Order := NAMEDESC;
else
Bases_Sort_Order := NAMEASC;
end if;
when 2 =>
if Bases_Sort_Order = DISTANCEASC then
Bases_Sort_Order := DISTANCEDESC;
else
Bases_Sort_Order := DISTANCEASC;
end if;
when 3 =>
if Bases_Sort_Order = POPULATIONASC then
Bases_Sort_Order := POPULATIONDESC;
else
Bases_Sort_Order := POPULATIONASC;
end if;
when 4 =>
if Bases_Sort_Order = SIZEASC then
Bases_Sort_Order := SIZEDESC;
else
Bases_Sort_Order := SIZEASC;
end if;
when 5 =>
if Bases_Sort_Order = OWNERASC then
Bases_Sort_Order := OWNERDESC;
else
Bases_Sort_Order := OWNERASC;
end if;
when 6 =>
if Bases_Sort_Order = TYPEASC then
Bases_Sort_Order := TYPEDESC;
else
Bases_Sort_Order := TYPEASC;
end if;
when 7 =>
if Bases_Sort_Order = REPUTATIONASC then
Bases_Sort_Order := REPUTATIONDESC;
else
Bases_Sort_Order := REPUTATIONASC;
end if;
when others =>
null;
end case;
if Bases_Sort_Order = NONE then
return TCL_OK;
end if;
for I in Sky_Bases'Range loop
Local_Bases(I) :=
(Name => Sky_Bases(I).Name,
Distance => CountDistance(Sky_Bases(I).Sky_X, Sky_Bases(I).Sky_Y),
Population =>
(if Sky_Bases(I).Visited = (others => 0) then -1
else Sky_Bases(I).Population),
Size =>
(if Sky_Bases(I).Visited = (others => 0) then UNKNOWN
else Sky_Bases(I).Size),
Owner =>
(if Sky_Bases(I).Visited = (others => 0) then
Null_Unbounded_String
else Sky_Bases(I).Owner),
Base_Type =>
(if Sky_Bases(I).Visited = (others => 0) then
Null_Unbounded_String
else Sky_Bases(I).Base_Type),
Reputation =>
(if Sky_Bases(I).Visited = (others => 0) then 200
else Sky_Bases(I).Reputation(1)),
Id => I);
end loop;
Sort_Bases(Local_Bases);
Bases_Indexes.Clear;
for Base of Local_Bases loop
Bases_Indexes.Append(Base.Id);
end loop;
UpdateBasesList(CArgv.Arg(Argv, 1));
return TCL_OK;
end Sort_Bases_Command;
procedure AddCommands is
begin
Add_Command("ShowBases", Show_Bases_Command'Access);
Add_Command("ShowBasesMenu", Show_Bases_Menu_Command'Access);
Add_Command("ShowBaseInfo", Show_Base_Info_Command'Access);
Add_Command("SortKnownBases", Sort_Bases_Command'Access);
end AddCommands;
end Knowledge.Bases;
|
with System.Storage_Elements;
package GC is
pragma Preelaborate;
pragma Linker_Options ("-lgc");
function Version return String;
function Heap_Size return System.Storage_Elements.Storage_Count;
procedure Collect;
end GC;
|
--PRÁCTICA 3: CÉSAR BORAO MORATINOS (Chat_Procedures.ads)
with Maps_G;
with Ada.Text_IO;
with Ada.Calendar;
with Lower_Layer_UDP;
with Ada.Command_Line;
with Ada.Strings.Unbounded;
package Chat_Procedures is
package ATI renames Ada.Text_IO;
package LLU renames Lower_Layer_UDP;
package ACL renames Ada.Command_Line;
package ASU renames Ada.Strings.Unbounded;
use type ASU.Unbounded_String;
type Data is record
Client_EP: LLU.End_Point_Type;
Time: Ada.Calendar.Time;
end record;
function Max_Valid (Max_Clients: Natural) return Boolean;
package Active_Clients is new Maps_G (Key_Type => ASU.Unbounded_String,
Value_Type => Data,
Max_Clients => Natural'Value(ACL.Argument(2)),
"=" => ASU."=");
package Old_Clients is new Maps_G (Key_Type => ASU.Unbounded_String,
Value_Type => Ada.Calendar.Time,
Max_Clients => 150,
"=" => ASU."=");
Active_Map: Active_Clients.Map;
Old_Map: Old_Clients.Map;
procedure Print_Active_Map;
procedure Print_Old_Map;
procedure Case_Init (I_Buffer: access LLU.Buffer_Type;
O_Buffer: access LLU.Buffer_Type);
procedure Case_Writer (I_Buffer: access LLU.Buffer_Type;
O_Buffer: access LLU.Buffer_Type);
procedure Case_Logout (I_Buffer: access LLU.Buffer_Type;
O_Buffer: access LLU.Buffer_Type);
end Chat_Procedures;
|
--
-- Uwe R. Zimmer, Australia, 2013
--
with Vectors_3D; use Vectors_3D;
package body Swarm_Configurations is
function Default_Globes (Configuration : Configurations) return Energy_Globes is
begin
case Configuration is
when Single_Globe_In_Orbit =>
return (1 => (Position => Zero_Vector_3D, Velocity => Zero_Vector_3D));
when Dual_Globes_In_Orbit =>
return (1 => (Position => Zero_Vector_3D, Velocity => Zero_Vector_3D),
2 => (Position => Zero_Vector_3D, Velocity => Zero_Vector_3D));
when Dual_Globes_In_Orbit_Fast =>
return (1 => (Position => Zero_Vector_3D, Velocity => Zero_Vector_3D),
2 => (Position => Zero_Vector_3D, Velocity => Zero_Vector_3D));
when Globe_Grid_In_Centre =>
declare
Grid_Space : constant Real := 0.1;
begin
return (1 => (Position => (-Grid_Space, -Grid_Space, -Grid_Space), Velocity => Zero_Vector_3D),
2 => (Position => (-Grid_Space, -Grid_Space, +Grid_Space), Velocity => Zero_Vector_3D),
3 => (Position => (-Grid_Space, +Grid_Space, -Grid_Space), Velocity => Zero_Vector_3D),
4 => (Position => (-Grid_Space, +Grid_Space, +Grid_Space), Velocity => Zero_Vector_3D),
5 => (Position => (-Grid_Space, 0.0, -Grid_Space), Velocity => Zero_Vector_3D),
6 => (Position => (-Grid_Space, 0.0, +Grid_Space), Velocity => Zero_Vector_3D),
7 => (Position => (-Grid_Space, 0.0, 0.0), Velocity => Zero_Vector_3D),
8 => (Position => (-Grid_Space, -Grid_Space, 0.0), Velocity => Zero_Vector_3D),
9 => (Position => (-Grid_Space, +Grid_Space, 0.0), Velocity => Zero_Vector_3D),
10 => (Position => (0.0, -Grid_Space, -Grid_Space), Velocity => Zero_Vector_3D),
11 => (Position => (0.0, -Grid_Space, +Grid_Space), Velocity => Zero_Vector_3D),
12 => (Position => (0.0, +Grid_Space, -Grid_Space), Velocity => Zero_Vector_3D),
13 => (Position => (0.0, +Grid_Space, +Grid_Space), Velocity => Zero_Vector_3D),
14 => (Position => (0.0, 0.0, -Grid_Space), Velocity => Zero_Vector_3D),
15 => (Position => (0.0, 0.0, +Grid_Space), Velocity => Zero_Vector_3D),
16 => (Position => (0.0, 0.0, 0.0), Velocity => Zero_Vector_3D),
17 => (Position => (0.0, -Grid_Space, 0.0), Velocity => Zero_Vector_3D),
18 => (Position => (0.0, +Grid_Space, 0.0), Velocity => Zero_Vector_3D),
19 => (Position => (+Grid_Space, -Grid_Space, -Grid_Space), Velocity => Zero_Vector_3D),
20 => (Position => (+Grid_Space, -Grid_Space, +Grid_Space), Velocity => Zero_Vector_3D),
21 => (Position => (+Grid_Space, +Grid_Space, -Grid_Space), Velocity => Zero_Vector_3D),
22 => (Position => (+Grid_Space, +Grid_Space, +Grid_Space), Velocity => Zero_Vector_3D),
23 => (Position => (+Grid_Space, 0.0, -Grid_Space), Velocity => Zero_Vector_3D),
24 => (Position => (+Grid_Space, 0.0, +Grid_Space), Velocity => Zero_Vector_3D),
25 => (Position => (+Grid_Space, 0.0, 0.0), Velocity => Zero_Vector_3D),
26 => (Position => (+Grid_Space, -Grid_Space, 0.0), Velocity => Zero_Vector_3D),
27 => (Position => (+Grid_Space, +Grid_Space, 0.0), Velocity => Zero_Vector_3D));
end;
when Globe_Grid_Drifting =>
declare
Grid_Space : constant Real := 0.2;
begin
return (1 => (Position => (-Grid_Space, -Grid_Space, -Grid_Space), Velocity => Zero_Vector_3D),
2 => (Position => (-Grid_Space, -Grid_Space, +Grid_Space), Velocity => Zero_Vector_3D),
3 => (Position => (-Grid_Space, +Grid_Space, -Grid_Space), Velocity => Zero_Vector_3D),
4 => (Position => (-Grid_Space, +Grid_Space, +Grid_Space), Velocity => Zero_Vector_3D),
5 => (Position => (-Grid_Space, 0.0, -Grid_Space), Velocity => Zero_Vector_3D),
6 => (Position => (-Grid_Space, 0.0, +Grid_Space), Velocity => Zero_Vector_3D),
7 => (Position => (-Grid_Space, 0.0, 0.0), Velocity => Zero_Vector_3D),
8 => (Position => (-Grid_Space, -Grid_Space, 0.0), Velocity => Zero_Vector_3D),
9 => (Position => (-Grid_Space, +Grid_Space, 0.0), Velocity => Zero_Vector_3D),
10 => (Position => (0.0, -Grid_Space, -Grid_Space), Velocity => Zero_Vector_3D),
11 => (Position => (0.0, -Grid_Space, +Grid_Space), Velocity => Zero_Vector_3D),
12 => (Position => (0.0, +Grid_Space, -Grid_Space), Velocity => Zero_Vector_3D),
13 => (Position => (0.0, +Grid_Space, +Grid_Space), Velocity => Zero_Vector_3D),
14 => (Position => (0.0, 0.0, -Grid_Space), Velocity => Zero_Vector_3D),
15 => (Position => (0.0, 0.0, +Grid_Space), Velocity => Zero_Vector_3D),
16 => (Position => (0.0, 0.0, 0.0), Velocity => Zero_Vector_3D),
17 => (Position => (0.0, -Grid_Space, 0.0), Velocity => Zero_Vector_3D),
18 => (Position => (0.0, +Grid_Space, 0.0), Velocity => Zero_Vector_3D),
19 => (Position => (+Grid_Space, -Grid_Space, -Grid_Space), Velocity => Zero_Vector_3D),
20 => (Position => (+Grid_Space, -Grid_Space, +Grid_Space), Velocity => Zero_Vector_3D),
21 => (Position => (+Grid_Space, +Grid_Space, -Grid_Space), Velocity => Zero_Vector_3D),
22 => (Position => (+Grid_Space, +Grid_Space, +Grid_Space), Velocity => Zero_Vector_3D),
23 => (Position => (+Grid_Space, 0.0, -Grid_Space), Velocity => Zero_Vector_3D),
24 => (Position => (+Grid_Space, 0.0, +Grid_Space), Velocity => Zero_Vector_3D),
25 => (Position => (+Grid_Space, 0.0, 0.0), Velocity => Zero_Vector_3D),
26 => (Position => (+Grid_Space, -Grid_Space, 0.0), Velocity => Zero_Vector_3D),
27 => (Position => (+Grid_Space, +Grid_Space, 0.0), Velocity => Zero_Vector_3D));
end;
end case;
end Default_Globes;
function Default_Protected_Globes (Configuration : Configurations) return Energy_Globes_Protected is
Globes : constant Energy_Globes := Default_Globes (Configuration);
Globes_Protected : Energy_Globes_Protected (Globes'Range);
begin
for Each in Globes'Range loop
Globes_Protected (Each) := (Position => Protected_Point_3D.Allocate (Globes (Each).Position),
Velocity => Protected_Vector_3D.Allocate (Globes (Each).Velocity));
end loop;
return Globes_Protected;
end Default_Protected_Globes;
end Swarm_Configurations;
|
-- SPDX-FileCopyrightText: 2019 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Program.Elements.Statements;
with Program.Lexical_Elements;
with Program.Elements.Return_Object_Specifications;
with Program.Element_Vectors;
with Program.Elements.Exception_Handlers;
package Program.Elements.Extended_Return_Statements is
pragma Pure (Program.Elements.Extended_Return_Statements);
type Extended_Return_Statement is
limited interface and Program.Elements.Statements.Statement;
type Extended_Return_Statement_Access is
access all Extended_Return_Statement'Class with Storage_Size => 0;
not overriding function Return_Object
(Self : Extended_Return_Statement)
return not null Program.Elements.Return_Object_Specifications
.Return_Object_Specification_Access is abstract;
not overriding function Statements
(Self : Extended_Return_Statement)
return Program.Element_Vectors.Element_Vector_Access is abstract;
not overriding function Exception_Handlers
(Self : Extended_Return_Statement)
return Program.Elements.Exception_Handlers
.Exception_Handler_Vector_Access is abstract;
type Extended_Return_Statement_Text is limited interface;
type Extended_Return_Statement_Text_Access is
access all Extended_Return_Statement_Text'Class with Storage_Size => 0;
not overriding function To_Extended_Return_Statement_Text
(Self : in out Extended_Return_Statement)
return Extended_Return_Statement_Text_Access is abstract;
not overriding function Return_Token
(Self : Extended_Return_Statement_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
not overriding function Do_Token
(Self : Extended_Return_Statement_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Exception_Token
(Self : Extended_Return_Statement_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function End_Token
(Self : Extended_Return_Statement_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Return_Token_2
(Self : Extended_Return_Statement_Text)
return Program.Lexical_Elements.Lexical_Element_Access is abstract;
not overriding function Semicolon_Token
(Self : Extended_Return_Statement_Text)
return not null Program.Lexical_Elements.Lexical_Element_Access
is abstract;
end Program.Elements.Extended_Return_Statements;
|
-- --
-- package Copyright (c) Dmitry A. Kazakov --
-- GNAT.Sockets.Connection_State_Machine. Luebeck --
-- Big_Endian.Unsigneds Winter, 2012 --
-- Interface --
-- Last revision : 22:45 07 Apr 2016 --
-- --
-- This library is free software; you can redistribute it and/or --
-- modify it under the terms of the GNU General Public License as --
-- published by the Free Software Foundation; either version 2 of --
-- the License, or (at your option) any later version. This library --
-- is distributed in the hope that it will be useful, but WITHOUT --
-- ANY WARRANTY; without even the implied warranty of --
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- General Public License for more details. You should have --
-- received a copy of the GNU General Public License along with --
-- this library; if not, write to the Free Software Foundation, --
-- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. --
-- --
-- As a special exception, if other files instantiate generics from --
-- this unit, or you link this unit with other files to produce an --
-- executable, this unit does not by itself cause the resulting --
-- executable to be covered by the GNU General Public License. This --
-- exception does not however invalidate any other reasons why the --
-- executable file might be covered by the GNU Public License. --
--____________________________________________________________________--
package GNAT.Sockets.Connection_State_Machine.Big_Endian.Unsigneds is
use Interfaces;
--
-- Unsigned_{8|16|32|64}_Data_Item -- Big endian-encoded unsigned number
--
type Unsigned_8_Data_Item is new Data_Item with record
Value : Unsigned_8;
end record;
type Unsigned_16_Data_Item is new Data_Item with record
Value : Unsigned_16;
end record;
type Unsigned_32_Data_Item is new Data_Item with record
Value : Unsigned_32;
end record;
type Unsigned_64_Data_Item is new Data_Item with record
Value : Unsigned_64;
end record;
--
-- Feed -- Implementation of the feed operation
--
procedure Feed
( Item : in out Unsigned_8_Data_Item;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset;
Client : in out State_Machine'Class;
State : in out Stream_Element_Offset
);
procedure Feed
( Item : in out Unsigned_16_Data_Item;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset;
Client : in out State_Machine'Class;
State : in out Stream_Element_Offset
);
procedure Feed
( Item : in out Unsigned_32_Data_Item;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset;
Client : in out State_Machine'Class;
State : in out Stream_Element_Offset
);
procedure Feed
( Item : in out Unsigned_64_Data_Item;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset;
Client : in out State_Machine'Class;
State : in out Stream_Element_Offset
);
--
-- Get -- Number from stream element array
--
-- Data - The stream element array
-- Pointer - The first element to read
-- Value - The result
--
-- The parameter Pointer is advanced beyond the value obtained
--
-- Exceptions :
--
-- End_Error - Not enough data
-- Layout_Error - Pointer is outside bounds
--
procedure Get
( Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset;
Value : out Unsigned_8
);
procedure Get
( Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset;
Value : out Unsigned_16
);
procedure Get
( Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset;
Value : out Unsigned_32
);
procedure Get
( Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset;
Value : out Unsigned_64
);
--
-- Put -- Number into stream element array
--
-- Data - The stream element array
-- Pointer - The first element to write
-- Value - The value to encode
--
-- The parameter Pointer is advanced beyond the value output
--
-- Exceptions :
--
-- End_Error - No room for output
-- Layout_Error - Pointer is outside bounds
--
procedure Put
( Data : in out Stream_Element_Array;
Pointer : in out Stream_Element_Offset;
Value : Unsigned_8
);
procedure Put
( Data : in out Stream_Element_Array;
Pointer : in out Stream_Element_Offset;
Value : Unsigned_16
);
procedure Put
( Data : in out Stream_Element_Array;
Pointer : in out Stream_Element_Offset;
Value : Unsigned_32
);
procedure Put
( Data : in out Stream_Element_Array;
Pointer : in out Stream_Element_Offset;
Value : Unsigned_64
);
private
pragma Assert (Stream_Element'Size = 8);
end GNAT.Sockets.Connection_State_Machine.Big_Endian.Unsigneds;
|
with Envs;
with Types;
package Eval_Callback is
type Eval_Func is access
function (MH : Types.Lovelace_Handle; Env : Envs.Env_Handle) return Types.Lovelace_Handle;
Eval : Eval_Func;
end Eval_Callback;
|
package body 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) is
begin
Output8 := B;
Output7 := Input = 7;
Output6 := Input = 6;
Output5 := Input = 5;
Output4 := Input = 4;
Output3 := Input = 3;
Output2 := Input = 2;
Output1 := Input = 1;
end Bit_Test;
function F return Ptr is
begin
B := True;
return B'Access;
end;
end Volatile11_Pkg;
|
pragma Ada_2012;
with GNAT.Regpat;
package body Adventofcode.Day_2 is
use GNAT.Strings;
-----------
-- Valid --
-----------
function Valid (Self : Password_Entry) return Boolean is
Count : Natural := 0;
begin
for C of Self.Password.all loop
if C = Self.Key then
Count := Count + 1;
end if;
end loop;
return Self.Min <= Count and then Count <= Self.Max;
end Valid;
function Valid2 (Self : Password_Entry) return Boolean is
begin
return (Self.Password.all (Self.Password.all'First - 1 + Self.Min) = Self.Key) xor
(Self.Password.all (Self.Password.all'First - 1 + Self.Max) = Self.Key);
end Valid2;
-----------
-- Parse --
-----------
function Parse (Line : String) return Password_Entry is
Matcher : constant GNAT.Regpat.Pattern_Matcher := GNAT.Regpat.Compile ("(\d+)-(\d+)\s*(\w)\s*:\s*(\w+)");
Matches : GNAT.Regpat.Match_Array (1 .. GNAT.Regpat.Paren_Count (Matcher));
begin
GNAT.Regpat.Match (Matcher, Line, Matches);
return Password_Entry'(Ada.Finalization.Controlled with
Min => Natural'Value (Line (Matches (1).First .. Matches (1).Last)),
Max => Natural'Value (Line (Matches (2).First .. Matches (2).Last)),
Key => Line (Matches (3).First),
Password => new String'(Line (Matches (4).First .. Matches (4).Last)));
end Parse;
overriding procedure Finalize (Object : in out Password_Entry) is
begin
GNAT.Strings.Free (Object.Password);
end;
overriding procedure Adjust (Object : in out Password_Entry) is
begin
Object.Password := new String'(Object.Password.all);
end;
end Adventofcode.Day_2;
|
with Numerics, Ada.Text_IO, Chebyshev, Dense_AD, Dense_AD.Integrator;
use Numerics, Ada.Text_IO, Chebyshev;
procedure Henon_Heiles is
use Int_IO, Real_IO, Real_Functions;
N : constant Nat := 2;
K : constant Nat := 13;
package AD_Package is new Dense_AD (2 * N);
package Integrator is new AD_Package.Integrator (K);
use AD_Package, Integrator;
-----------------------------------------------
Control : Control_Type := New_Control_Type (Tol => 1.0e-7);
function KE (Q : in AD_Vector) return AD_Type is
begin
return 0.5 * (Q (3) ** 2 + Q (4) ** 2);
end KE;
function PE (Q : in AD_Vector) return AD_Type is
begin
return 0.5 * (Q (1) ** 2 + Q (2) ** 2)
+ Q (1) ** 2 * Q (2) - Q (2) ** 3 / 3.0;
end PE;
function Lagrangian (T : in Real;
X : in Vector) return AD_Type is
Q : constant AD_Vector := Var (X);
begin
return KE (Q) - PE (Q);
end Lagrangian;
function Hamiltonian (T : in Real;
X : in Vector) return AD_Type is
Q : constant AD_Vector := Var (X);
begin
return KE (Q) + PE (Q);
end Hamiltonian;
-----------------------------------------------
function Get_IC (X : in Vector;
E : in Real) return Vector is
use Real_IO;
Y : Vector := X;
G : Vector;
H : AD_Type;
F, Dw : Real := 1.0;
W : Real renames Y (3); -- Y(3) is ω_t
begin
-- use Newton's method to solve for E - H = 0
W := 1.0;
while abs (F) > 1.0e-14 loop
H := Hamiltonian (0.0, Y);
F := E - Val (H);
G := Grad (H);
Dw := (E - Val (H)) / G (3); -- G(3) is \partial H / \partial ω_t
W := W + Dw;
end loop;
H := Hamiltonian (0.0, Y);
F := E - Val (H);
return Y;
end Get_IC;
function Func (X : in Vector) return Real is
begin
return X (1);
end Func;
function Sgn (X : in Real) return Real is
begin
if X >= 0.0 then return 1.0;
else return -1.0;
end if;
end Sgn;
function Find_State_At_Level (Level : in Real;
A : in Array_Of_Vectors;
T : in Real;
Dt : in Real;
Lower : in out Real;
Upper : in out Real;
Func : not null access function (X : Vector)
return Real) return Variable is
Guess : Variable;
Est : Real := 1.0e10;
Sign : constant Real := Sgn (Func (Interpolate (A, Upper, T, T + Dt)) -
Func (Interpolate (A, Lower, T, T + Dt)));
begin
while abs (Est - Level) > 1.0e-10 loop
Guess.T := 0.5 * (Lower + Upper);
Guess.X := Interpolate (A, Guess.T, T, T + Dt);
Est := Func (Guess.X);
if Est * sign > 0.0 then Upper := Guess.T;
else Lower := Guess.T; end if;
end loop;
return Guess;
end Find_State_At_Level;
-- Initial Conditions ----
Var, State, Guess : Variable := (0.0, (0.0, -0.1, 1.0, 0.0));
X : Vector renames Var.X;
T : Real renames Var.T;
-------------------------------
Y : Real_Vector (1 .. 2 * N * K);
A, Q : Array_Of_Vectors;
Fcsv : File_Type;
H0 : constant Real := 1.0 / 8.0;
T_Final : constant Real := 400_000.0;
Lower, Upper : Real;
AD : AD_Type;
begin
Control.Max_Dt := 10.0;
X := Get_IC (X, H0);
AD := Hamiltonian (0.0, X);
State := Var;
for Item of X loop
Put (Item); New_Line;
end loop;
Put (Val (AD)); New_Line;
Create (Fcsv, Name => "out.csv");
Put_Line (Fcsv, "t, q1, q2, q_dot1, q_dot2, p1, p2, E");
Print_Lagrangian (Fcsv, Var, Lagrangian'Access);
while T < T_Final loop
Put (Var.T); Put (" "); Put (Control.Dt); New_Line;
Y := Update (Lagrangian'Access, Var, Control, Sparse);
A := Chebyshev_Transform (Y);
Q := Split (Y);
for I in 2 .. K loop
if Q (1) (I - 1) * Q (1) (I) < 0.0 then -- If there's a zero, bisect
Lower := Var.T + Control.Dt * Grid (I - 1);
Upper := Var.T + Control.Dt * Grid (I);
Guess := Find_State_At_Level
(0.0, A, Var.T, Control.Dt, Lower, Upper, Func'Access);
----------------------------------------------------------------
if Guess.X (3) > 0.0 then
Print_Lagrangian (Fcsv, Guess, Lagrangian'Access);
end if;
end if;
end loop;
-- Put (Var.T); New_Line;
-- Print_Lagrangian (Fcsv, Var, Lagrangian'Access);
Update (Var => Var, Y => Y, Dt => Control.Dt); -- Update variable Var
end loop;
Close (Fcsv);
end Henon_Heiles;
|
with Startup;
with Bootloader;
procedure Main is
pragma Preelaborate;
begin
Bootloader.Start;
end Main;
|
with Ada.Tags;
package body Controlled5_Pkg is
type Child is new Root with null record;
function Dummy (I : Integer) return Root'Class is
A1 : T_Root_Class := new Child;
My_Var : Root'Class := A1.all;
begin
if I = 0 then
return My_Var;
else
return Dummy (I - 1);
end if;
end Dummy;
end Controlled5_Pkg;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- B I N D E --
-- --
-- S p e c --
-- --
-- Copyright (C) 1992-2016, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
-- This package contains the routine that determines library-level elaboration
-- order.
with ALI; use ALI;
with Namet; use Namet;
with Types; use Types;
with GNAT.Dynamic_Tables;
package Binde is
package Unit_Id_Tables is new GNAT.Dynamic_Tables
(Table_Component_Type => Unit_Id,
Table_Index_Type => Nat,
Table_Low_Bound => 1,
Table_Initial => 500,
Table_Increment => 200);
use Unit_Id_Tables;
subtype Unit_Id_Table is Unit_Id_Tables.Instance;
subtype Unit_Id_Array is Unit_Id_Tables.Table_Type;
procedure Find_Elab_Order
(Elab_Order : out Unit_Id_Table;
First_Main_Lib_File : File_Name_Type);
-- Determine elaboration order.
--
-- The Elab_Order table records the chosen elaboration order. It is used by
-- Gen_Elab_Calls to generate the sequence of elaboration calls. Note that
-- units are included in this table even if they have no elaboration
-- routine, since the table is also used to drive the generation of object
-- files in the binder output. Gen_Elab_Calls skips any units that have no
-- elaboration routine.
end Binde;
|
-- NORX_Definitions
-- Some type / subtype definitions in common use in the NORX code.
-- As some uses of these types are in generic parameters, it is not possible
-- to hide them.
-- Copyright (c) 2016, James Humphry - see LICENSE file for details
pragma Restrictions(No_Implementation_Attributes,
No_Implementation_Identifiers,
No_Implementation_Units,
No_Obsolescent_Features);
package NORX_Definitions
with Pure, SPARK_Mode => On is
subtype Word_Size is Integer
with Static_Predicate => Word_Size in 8 | 16 | 32 | 64;
subtype Round_Count is Integer range 1..63;
subtype Key_Material_Position is Integer
with Static_Predicate => Key_Material_Position in 2 | 4;
type Rotation_Offsets is array (Integer range 0..3) of Natural;
end NORX_Definitions;
|
with Memory; use Memory;
-- Package for generating HDL.
package HDL_Generator is
-- Generate HDL.
-- This function returns a string containing VHDL.
function Generate(mem : Memory_Pointer;
name : String;
addr_bits : Positive) return String;
end HDL_Generator;
|
with System;
package body Web.HTML is
use type String_Maps.Cursor;
procedure By_Stream (Item : in String; Params : in System.Address) is
function To_Pointer (Value : System.Address)
return access Ada.Streams.Root_Stream_Type'Class
with Import, Convention => Intrinsic;
begin
String'Write (To_Pointer (Params), Item);
end By_Stream;
Alt_Quot : aliased constant String := """;
Alt_Apos : aliased constant String := "'";
Alt_LF : aliased constant String := " ";
procedure Write_In_Attribute_Internal (
Version : in HTML_Version;
Item : in String;
Params : in System.Address;
Write : not null access procedure (
Item : in String;
Params : in System.Address))
is
Alt : access constant String;
First : Positive := Item'First;
Last : Natural := First - 1;
I : Positive := Item'First;
begin
while I <= Item'Last loop
case Item (I) is
when '"' =>
Alt := Alt_Quot'Access;
goto FLUSH;
when ''' =>
Alt := Alt_Apos'Access;
goto FLUSH;
when Ada.Characters.Latin_1.LF =>
goto NEW_LINE;
when Ada.Characters.Latin_1.CR =>
if I < Item'Last
and then Item (I + 1) = Ada.Characters.Latin_1.LF
then
goto CONTINUE; -- skip
else
goto NEW_LINE;
end if;
when others =>
Last := I;
goto CONTINUE;
end case;
<<NEW_LINE>>
case Version is
when HTML =>
Alt := Line_Break'Access;
when XHTML =>
Alt := Alt_LF'Access;
end case;
<<FLUSH>>
if First <= Last then
Write (Item (First .. Last), Params);
end if;
Write (Alt.all, Params);
First := I + 1;
goto CONTINUE;
<<CONTINUE>>
I := I + 1;
end loop;
if First <= Last then
Write (Item (First .. Last), Params);
end if;
end Write_In_Attribute_Internal;
Alt_Sp : aliased constant String := " ";
Alt_Amp : aliased constant String := "&";
Alt_LT : aliased constant String := "<";
Alt_GT : aliased constant String := ">";
Alt_BRO : aliased constant String := "<br>";
Alt_BRS : aliased constant String := "<br />";
procedure Write_In_HTML_Internal (
Version : in HTML_Version;
Item : in String;
Pre : in Boolean;
Params : in System.Address;
Write : not null access procedure (
Item : in String;
Params : in System.Address))
is
Alt : access constant String;
First : Positive := Item'First;
Last : Natural := First - 1;
In_Spaces : Boolean := True;
Previous_In_Spaces : Boolean;
I : Positive := Item'First;
begin
while I <= Item'Last loop
Previous_In_Spaces := In_Spaces;
In_Spaces := False;
case Item (I) is
when ' ' =>
if not Pre
and then (
Previous_In_Spaces or else (I < Item'Last and then Item (I + 1) = ' '))
then
In_Spaces := True;
Alt := Alt_Sp'Access;
goto FLUSH;
else
Last := I;
goto CONTINUE;
end if;
when '&' =>
Alt := Alt_Amp'Access;
goto FLUSH;
when '<' =>
Alt := Alt_LT'Access;
goto FLUSH;
when '>' =>
Alt := Alt_GT'Access;
goto FLUSH;
when Ada.Characters.Latin_1.LF =>
goto NEW_LINE;
when Ada.Characters.Latin_1.CR =>
if I < Item'Last and then Item (I + 1) = Ada.Characters.Latin_1.LF then
goto CONTINUE; -- skip
else
goto NEW_LINE;
end if;
when others =>
Last := I;
goto CONTINUE;
end case;
<<NEW_LINE>>
if Pre then
Alt := Line_Break'Access;
else
case Version is
when HTML =>
Alt := Alt_BRO'Access;
when XHTML =>
Alt := Alt_BRS'Access;
end case;
end if;
<<FLUSH>>
if First <= Last then
Write (Item (First .. Last), Params);
end if;
Write (Alt.all, Params);
First := I + 1;
goto CONTINUE;
<<CONTINUE>>
I := I + 1;
end loop;
if First <= Last then
Write (Item (First .. Last), Params);
end if;
end Write_In_HTML_Internal;
procedure Write_Query_In_Attribute_Internal (
Version : in HTML_Version;
Item : in Query_Strings;
Params : in System.Address;
Write : not null access procedure (
Item : in String;
Params : in System.Address)) is
begin
if not Item.Is_Empty then
declare
First : constant String_Maps.Cursor := Item.First;
Position : String_Maps.Cursor := First;
begin
while String_Maps.Has_Element (Position) loop
if Position = First then
Write ("?", Params);
else
Write ("&", Params);
end if;
Write_In_Attribute_Internal (Version, String_Maps.Key (Position), Params,
Write => Write);
Write ("=", Params);
Write_In_Attribute_Internal (Version, String_Maps.Element (Position), Params,
Write => Write);
String_Maps.Next (Position);
end loop;
end;
end if;
end Write_Query_In_Attribute_Internal;
procedure Write_Query_In_HTML_Internal (
Version : in HTML_Version;
Item : in Query_Strings;
Params : in System.Address;
Write : not null access procedure (
Item : in String;
Params : in System.Address))
is
Position : String_Maps.Cursor := Item.First;
begin
while String_Maps.Has_Element (Position) loop
Write ("<input type=""hidden"" name=""", Params);
Write_In_Attribute_Internal (Version, String_Maps.Key (Position), Params,
Write => Write);
Write (""" value=""", Params);
Write_In_Attribute_Internal (Version, String_Maps.Element (Position), Params,
Write => Write);
case Version is
when HTML =>
Write (""">", Params);
when XHTML =>
Write (""" />", Params);
end case;
String_Maps.Next (Position);
end loop;
end Write_Query_In_HTML_Internal;
Begin_Attribute : constant String := "=""";
End_Attribute : constant String := """";
-- implementation of input
function Checkbox_Value (S : String) return Boolean is
begin
return Equal_Case_Insensitive (S, L => "on");
end Checkbox_Value;
-- implementation of output
procedure Generic_Write_In_HTML (
Item : in String;
Pre : in Boolean := False)
is
procedure By_Callback (Item : in String; Params : in System.Address) is
pragma Unreferenced (Params);
begin
Write (Item);
end By_Callback;
begin
Write_In_HTML_Internal (Version, Item, Pre, System.Null_Address,
Write => By_Callback'Access);
end Generic_Write_In_HTML;
procedure Write_In_HTML (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Version : in HTML_Version;
Item : in String;
Pre : in Boolean := False)
is
function To_Address (Value : access Ada.Streams.Root_Stream_Type'Class)
return System.Address
with Import, Convention => Intrinsic;
begin
Write_In_HTML_Internal (Version, Item, Pre, To_Address (Stream),
Write => By_Stream'Access);
end Write_In_HTML;
procedure Generic_Write_Begin_Attribute (Name : in String) is
begin
Write (Name);
Write (Begin_Attribute);
end Generic_Write_Begin_Attribute;
procedure Write_Begin_Attribute (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Name : in String) is
begin
String'Write (Stream, Name);
String'Write (Stream, Begin_Attribute);
end Write_Begin_Attribute;
procedure Generic_Write_In_Attribute (Item : in String) is
procedure By_Callback (Item : in String; Params : in System.Address) is
pragma Unreferenced (Params);
begin
Write (Item);
end By_Callback;
begin
Write_In_Attribute_Internal (Version, Item, System.Null_Address,
Write => By_Callback'Access);
end Generic_Write_In_Attribute;
procedure Write_In_Attribute (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Version : in HTML_Version;
Item : in String)
is
function To_Address (Value : access Ada.Streams.Root_Stream_Type'Class)
return System.Address
with Import, Convention => Intrinsic;
begin
Write_In_Attribute_Internal (Version, Item, To_Address (Stream),
Write => By_Stream'Access);
end Write_In_Attribute;
procedure Generic_Write_End_Attribute is
begin
Write (End_Attribute);
end Generic_Write_End_Attribute;
procedure Write_End_Attribute (
Stream : not null access Ada.Streams.Root_Stream_Type'Class) is
begin
String'Write (Stream, End_Attribute);
end Write_End_Attribute;
procedure Generic_Write_Query_In_HTML (Item : in Query_Strings) is
procedure By_Callback (Item : in String; Params : in System.Address) is
pragma Unreferenced (Params);
begin
Write (Item);
end By_Callback;
begin
Write_Query_In_HTML_Internal (Version, Item, System.Null_Address,
Write => By_Callback'Access);
end Generic_Write_Query_In_HTML;
procedure Write_Query_In_HTML (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Version : in HTML_Version;
Item : in Query_Strings)
is
function To_Address (Value : access Ada.Streams.Root_Stream_Type'Class)
return System.Address
with Import, Convention => Intrinsic;
begin
Write_Query_In_HTML_Internal (Version, Item, To_Address (Stream),
Write => By_Stream'Access);
end Write_Query_In_HTML;
procedure Generic_Write_Query_In_Attribute (Item : in Query_Strings) is
procedure By_Callback (Item : in String; Params : in System.Address) is
pragma Unreferenced (Params);
begin
Write (Item);
end By_Callback;
begin
Write_Query_In_Attribute_Internal (Version, Item, System.Null_Address,
Write => By_Callback'Access);
end Generic_Write_Query_In_Attribute;
procedure Write_Query_In_Attribute (
Stream : not null access Ada.Streams.Root_Stream_Type'Class;
Version : in HTML_Version;
Item : in Query_Strings)
is
function To_Address (Value : access Ada.Streams.Root_Stream_Type'Class)
return System.Address
with Import, Convention => Intrinsic;
begin
Write_Query_In_Attribute_Internal (Version, Item, To_Address (Stream),
Write => By_Stream'Access);
end Write_Query_In_Attribute;
end Web.HTML;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2018, Universidad Politécnica de Madrid --
-- --
-- This is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. This software is distributed in the hope that it will be useful, --
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- --
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public --
-- License for more details. You should have received a copy of the GNU --
-- General Public License distributed with this software; see file --
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy --
-- of the license. --
-- --
------------------------------------------------------------------------------
with Ada.Streams; use Ada.Streams;
package body Serial_Ports is
------------------------
-- Internal procedures--
------------------------
procedure Await_Data_Available
(This : USART;
Timeout : Time_Span := Time_Span_Last;
Timed_Out : out Boolean)
with Inline;
procedure Await_Send_Ready (This : USART)
with Inline;
function Last_Index
(First : Stream_Element_Offset;
Count : Long_Integer)
return Stream_Element_Offset
with Inline;
--------------------------
-- Await_Data_Available --
--------------------------
procedure Await_Data_Available
(This : USART;
Timeout : Time_Span := Time_Span_Last;
Timed_Out : out Boolean)
is
Deadline : constant Time := Clock + Timeout;
begin
Timed_Out := True;
while Clock < Deadline loop
if Rx_Ready (This) then
Timed_Out := False;
exit;
end if;
end loop;
end Await_Data_Available;
----------------------
-- Await_Send_Ready --
----------------------
procedure Await_Send_Ready (This : USART) is
begin
loop
exit when Tx_Ready (This);
end loop;
end Await_Send_Ready;
----------------
-- Last_Index --
----------------
function Last_Index
(First : Stream_Element_Offset;
Count : Long_Integer)
return Stream_Element_Offset
is
begin
if First = Stream_Element_Offset'First and then Count = 0 then
-- we need to return First - 1, but cannot
raise Constraint_Error; -- per RM
else
return First + Stream_Element_Offset (Count) - 1;
end if;
end Last_Index;
----------------
-- Initialize --
----------------
procedure Initialize (This : in out Serial_Port) is
Configuration : GPIO_Port_Configuration;
Device_Pins : constant GPIO_Points
:= This.Device.Rx_Pin & This.Device.Tx_Pin;
begin
Enable_Clock (Device_Pins);
Enable_Clock (This.Device.Transceiver.all);
Configuration := (Mode => Mode_AF,
AF => This.Device.Transceiver_AF,
AF_Speed => Speed_50MHz,
AF_Output_Type => Push_Pull,
Resistors => Pull_Up);
Configure_IO (Device_Pins, Configuration);
end Initialize;
---------------
-- Configure --
---------------
procedure Configure
(This : in out Serial_Port;
Baud_Rate : Baud_Rates;
Parity : Parities := No_Parity;
Data_Bits : Word_Lengths := Word_Length_8;
End_Bits : Stop_Bits := Stopbits_1;
Control : Flow_Control := No_Flow_Control)
is
begin
Disable (This.Device.Transceiver.all);
Set_Baud_Rate (This.Device.Transceiver.all, Baud_Rate);
Set_Mode (This.Device.Transceiver.all, Tx_Rx_Mode);
Set_Stop_Bits (This.Device.Transceiver.all, End_Bits);
Set_Word_Length (This.Device.Transceiver.all, Data_Bits);
Set_Parity (This.Device.Transceiver.all, Parity);
Set_Flow_Control (This.Device.Transceiver.all, Control);
Enable (This.Device.Transceiver.all);
end Configure;
----------
-- Read --
----------
overriding procedure Read
(This : in out Serial_Port;
Buffer : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset)
is
Raw : UInt9;
Timed_Out : Boolean;
Count : Long_Integer := 0;
begin
Receiving : for K in Buffer'Range loop
Await_Data_Available (This.Device.Transceiver.all, This.Timeout, Timed_Out);
exit Receiving when Timed_Out;
Receive (This.Device.Transceiver.all, Raw);
Buffer (K) := Stream_Element (Raw);
Count := Count + 1;
end loop Receiving;
Last := Last_Index (Buffer'First, Count);
end Read;
-----------
-- Write --
-----------
overriding procedure Write
(This : in out Serial_Port;
Buffer : Ada.Streams.Stream_Element_Array)
is
begin
for Next of Buffer loop
Await_Send_Ready (This.Device.Transceiver.all);
Transmit (This.Device.Transceiver.all, Stream_Element'Pos (Next));
end loop;
end Write;
end Serial_Ports;
|
pragma License (Unrestricted);
-- extended unit
with Ada.Iterator_Interfaces;
with Ada.References.Strings;
private with Ada.Finalization;
package Ada.Text_IO.Iterators is
-- Iterators for Ada.Text_IO.File_Type.
-- per line
type Lines_Type is tagged limited private
with
Constant_Indexing => Constant_Reference,
Default_Iterator => Iterate,
Iterator_Element => String;
function Lines (
File : File_Type) -- Input_File_Type
return Lines_Type;
type Line_Cursor is private;
pragma Preelaborable_Initialization (Line_Cursor);
function Has_Element (Position : Line_Cursor) return Boolean;
function Element (Container : Lines_Type'Class; Position : Line_Cursor)
return String;
function Constant_Reference (
Container : aliased Lines_Type;
Position : Line_Cursor)
return References.Strings.Constant_Reference_Type;
package Lines_Iterator_Interfaces is
new Iterator_Interfaces (Line_Cursor, Has_Element);
function Iterate (Container : Lines_Type'Class)
return Lines_Iterator_Interfaces.Forward_Iterator'Class;
private
type Lines_Type is limited new Finalization.Limited_Controlled with record
File : File_Access;
Item : String_Access;
Count : Natural;
end record;
overriding procedure Finalize (Object : in out Lines_Type);
type Lines_Access is access all Lines_Type;
for Lines_Access'Storage_Size use 0;
type Line_Cursor is new Natural;
type Line_Iterator is
new Lines_Iterator_Interfaces.Forward_Iterator with
record
Lines : Lines_Access;
end record;
overriding function First (Object : Line_Iterator) return Line_Cursor;
overriding function Next (Object : Line_Iterator; Position : Line_Cursor)
return Line_Cursor;
end Ada.Text_IO.Iterators;
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Command_Line; use Ada.Command_Line;
with GNAT.OS_Lib;
with Marble_Mania;
procedure Day9 is
Players : Positive;
Last_Marble : Positive;
begin
if Argument_Count /= 2 then
Put_Line
(Standard_Error,
"usage: " & Command_Name & " <#players> <marble-worth>");
GNAT.OS_Lib.OS_Exit (1);
end if;
Players := Positive'Value (Argument (1));
Last_Marble := Positive'Value (Argument (2));
Put_Line
(Positive'Image (Players) & " players; last marble is worth " &
Positive'Image (Last_Marble) & " points: high score is " &
Marble_Mania.Score_Count'Image
(Marble_Mania.Play_Until (Players, Last_Marble)));
end Day9;
|
with Ada.Characters.Handling;
use Ada.Characters.Handling;
package Abc is
type Block_Faces is array(1..2) of Character;
type Block_List is array(positive range <>) of Block_Faces;
function Can_Make_Word(W: String; Blocks: Block_List) return Boolean;
end Abc;
package body Abc is
function Can_Make_Word(W: String; Blocks: Block_List) return Boolean is
Used : array(Blocks'Range) of Boolean := (Others => False);
subtype wIndex is Integer range W'First..W'Last;
wPos : wIndex;
begin
if W'Length = 0 then
return True;
end if;
wPos := W'First;
while True loop
declare
C : Character := To_Upper(W(wPos));
X : constant wIndex := wPos;
begin
for I in Blocks'Range loop
if (not Used(I)) then
if C = To_Upper(Blocks(I)(1)) or C = To_Upper(Blocks(I)(2)) then
Used(I) := True;
if wPos = W'Last then
return True;
end if;
wPos := wIndex'Succ(wPos);
exit;
end if;
end if;
end loop;
if X = wPos then
return False;
end if;
end;
end loop;
return False;
end Can_Make_Word;
end Abc;
with Ada.Text_IO, Ada.Strings.Unbounded, Abc;
use Ada.Text_IO, Ada.Strings.Unbounded, Abc;
procedure Abc_Problem is
Blocks : Block_List := (
('B','O'), ('X','K'), ('D','Q'), ('C','P')
, ('N','A'), ('G','T'), ('R','E'), ('T','G')
, ('Q','D'), ('F','S'), ('J','W'), ('H','U')
, ('V','I'), ('A','N'), ('O','B'), ('E','R')
, ('F','S'), ('L','Y'), ('P','C'), ('Z','M')
);
function "+" (S : String) return Unbounded_String renames To_Unbounded_String;
words : array(positive range <>) of Unbounded_String := (
+"A"
, +"BARK"
, +"BOOK"
, +"TREAT"
, +"COMMON"
, +"SQUAD"
, +"CONFUSE"
-- Border cases:
-- , +"CONFUSE2"
-- , +""
);
begin
for I in words'Range loop
Put_Line ( To_String(words(I)) & ": " & Boolean'Image(Can_Make_Word(To_String(words(I)),Blocks)) );
end loop;
end Abc_Problem;
|
-- Abstract :
--
-- Types and operations for a packrat parser runtime, with nonterm
-- parsing subprograms generated by wisi-generate.
--
-- References:
--
-- see parent.
--
-- Copyright (C) 2018 - 2019 Free Software Foundation, Inc.
--
-- This library is free software; you can redistribute it and/or modify it
-- under terms of the GNU General Public License as published by the Free
-- Software Foundation; either version 3, or (at your option) any later
-- version. This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-- As a special exception under Section 7 of GPL version 3, you are granted
-- additional permissions described in the GCC Runtime Library Exception,
-- version 3.1, as published by the Free Software Foundation.
pragma License (Modified_GPL);
with WisiToken.Syntax_Trees;
package WisiToken.Parse.Packrat.Generated is
Recursive : exception; -- FIXME: delete
type Memo_State is (No_Result, Failure, Success);
subtype Result_States is Memo_State range Failure .. Success;
type Memo_Entry (State : Memo_State := No_Result) is record
case State is
when No_Result =>
Recursive : Boolean := False; -- FIXME: delete
when Failure =>
null;
when Success =>
Result : aliased WisiToken.Syntax_Trees.Valid_Node_Index;
Last_Token : Base_Token_Index; -- FIXME: change to Last_Pos
end case;
end record;
package Memos is new SAL.Gen_Unbounded_Definite_Vectors
(Token_Index, Memo_Entry, Default_Element => (others => <>));
subtype Result_Type is Memo_Entry
with Dynamic_Predicate => Result_Type.State in Result_States;
package Derivs is new SAL.Gen_Unbounded_Definite_Vectors
(Token_ID, Memos.Vector, Default_Element => Memos.Empty_Vector);
type Parse_WisiToken_Accept is access
-- WORKAROUND: using Packrat.Parser'Class here hits a GNAT Bug box in GPL 2018.
function (Parser : in out Base_Parser'Class; Last_Pos : in Base_Token_Index) return Result_Type;
type Parser is new Packrat.Parser with record
Derivs : Generated.Derivs.Vector; -- FIXME: use discriminated array, as in procedural
Parse_WisiToken_Accept : Generated.Parse_WisiToken_Accept;
end record;
overriding procedure Parse (Parser : aliased in out Generated.Parser);
overriding function Tree (Parser : in Generated.Parser) return Syntax_Trees.Tree;
overriding function Any_Errors (Parser : in Generated.Parser) return Boolean;
overriding procedure Put_Errors (Parser : in Generated.Parser);
end WisiToken.Parse.Packrat.Generated;
|
-- MP: a Music Player
-- Copyright (C) 2020 by PragmAda Software Engineering. All rights reserved.
-- Released under the terms of the BSD 3-Clause license; see https://opensource.org/licenses
--
-- 2020-09-15 Initial version
--
with MP.UI;
procedure MP.Program is
-- Empty
begin -- MP.Program
null;
end MP.Program;
|
-- ___ _ ___ _ _ --
-- / __| |/ (_) | | Common SKilL implementation --
-- \__ \ ' <| | | |__ skill containers collection --
-- |___/_|\_\_|_|____| by: Timm Felden --
-- --
pragma Ada_2012;
limited with Skill.Types;
-- this packe solves most of ada container's shortcomings
package Skill.Containers is
-- boxed array access
type Array_Iterator_T is abstract tagged null record;
type Array_Iterator is access all Array_Iterator_T'Class;
function Has_Next (This : access Array_Iterator_T) return Boolean is abstract;
function Next
(This : access Array_Iterator_T) return Skill.Types.Box is abstract;
procedure Free (This : access Array_Iterator_T) is abstract;
-- dispatching arrays
type Boxed_Array_T is abstract tagged null record;
type Boxed_Array is access all Boxed_Array_T'Class;
procedure Append
(This : access Boxed_Array_T;
V : Skill.Types.Box) is abstract;
-- same as append; used for uniformity
procedure Add
(This : access Boxed_Array_T;
V : Skill.Types.Box) is abstract;
function Get
(This : access Boxed_Array_T;
I : Natural) return Skill.Types.Box is abstract;
procedure Update
(This : access Boxed_Array_T;
I : Natural;
V : Skill.Types.Box) is abstract;
procedure Ensure_Size
(This : access Boxed_Array_T;
I : Natural) is abstract;
function Length (This : access Boxed_Array_T) return Natural is abstract;
function Iterator
(This : access Boxed_Array_T) return Array_Iterator is abstract;
-- boxed set access
type Set_Iterator_T is abstract tagged null record;
type Set_Iterator is access all Set_Iterator_T'Class;
function Has_Next (This : access Set_Iterator_T) return Boolean is abstract;
function Next
(This : access Set_Iterator_T) return Skill.Types.Box is abstract;
procedure Free (This : access Set_Iterator_T) is abstract;
-- dispatching sets
type Boxed_Set_T is abstract tagged null record;
type Boxed_Set is access all Boxed_Set_T'Class;
procedure Add (This : access Boxed_Set_T; V : Skill.Types.Box) is abstract;
function Contains
(This : access Boxed_Set_T;
V : Skill.Types.Box) return Boolean is abstract;
function Length (This : access Boxed_Set_T) return Natural is abstract;
function Iterator
(This : access Boxed_Set_T) return Set_Iterator is abstract;
-- boxed map access
type Map_Iterator_T is abstract tagged null record;
type Map_Iterator is access all Map_Iterator_T'Class;
function Has_Next (This : access Map_Iterator_T) return Boolean is abstract;
function Key
(This : access Map_Iterator_T) return Skill.Types.Box is abstract;
function Value
(This : access Map_Iterator_T) return Skill.Types.Box is abstract;
procedure Advance (This : access Map_Iterator_T) is abstract;
procedure Free (This : access Map_Iterator_T) is abstract;
-- dispatching maps
type Boxed_Map_T is abstract tagged null record;
type Boxed_Map is access all Boxed_Map_T'Class;
function Contains
(This : access Boxed_Map_T;
V : Skill.Types.Box) return Boolean is abstract;
function Get
(This : access Boxed_Map_T;
K : Skill.Types.Box) return Skill.Types.Box is abstract;
procedure Update
(This : access Boxed_Map_T;
K : Skill.Types.Box;
V : Skill.Types.Box) is abstract;
procedure Remove
(This : access Boxed_Map_T;
K : Skill.Types.Box) is abstract;
function Length (This : access Boxed_Map_T) return Natural is abstract;
function Iterator
(This : access Boxed_Map_T) return Map_Iterator is abstract;
end Skill.Containers;
|
package body B730006_0.Child2 is
procedure Create (Bay : in out Dock) is
begin
null;
end Create;
end B730006_0.Child2;
|
------------------------------------------------------------------------------
-- --
-- GNAT LIBRARY COMPONENTS --
-- --
-- G N A T . M D 5 --
-- --
-- B o d y --
-- --
-- Copyright (C) 2002-2005, AdaCore --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 2, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING. If not, write --
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
-- Boston, MA 02110-1301, USA. --
-- --
-- As a special exception, if other files instantiate generics from this --
-- unit, or you link this unit with other files to produce an executable, --
-- this unit does not by itself cause the resulting executable to be --
-- covered by the GNU General Public License. This exception does not --
-- however invalidate any other reasons why the executable file might be --
-- covered by the GNU Public License. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
package body GNAT.MD5 is
use Interfaces;
Padding : constant String :=
(1 => Character'Val (16#80#), 2 .. 64 => ASCII.NUL);
Hex_Digit : constant array (Unsigned_32 range 0 .. 15) of Character :=
('0', '1', '2', '3', '4', '5', '6', '7',
'8', '9', 'a', 'b', 'c', 'd', 'e', 'f');
-- Look-up table for each hex digit of the Message-Digest.
-- Used by function Digest (Context).
-- The sixten values used to rotate the context words.
-- Four for each rounds. Used in procedure Transform.
-- Round 1
S11 : constant := 7;
S12 : constant := 12;
S13 : constant := 17;
S14 : constant := 22;
-- Round 2
S21 : constant := 5;
S22 : constant := 9;
S23 : constant := 14;
S24 : constant := 20;
-- Round 3
S31 : constant := 4;
S32 : constant := 11;
S33 : constant := 16;
S34 : constant := 23;
-- Round 4
S41 : constant := 6;
S42 : constant := 10;
S43 : constant := 15;
S44 : constant := 21;
type Sixteen_Words is array (Natural range 0 .. 15)
of Interfaces.Unsigned_32;
-- Sixteen 32-bit words, converted from block of 64 characters.
-- Used in procedure Decode and Transform.
procedure Decode
(Block : String;
X : out Sixteen_Words);
-- Convert a String of 64 characters into 16 32-bit numbers
-- The following functions (F, FF, G, GG, H, HH, I and II) are the
-- equivalent of the macros of the same name in the example
-- C implementation in the annex of RFC 1321.
function F (X, Y, Z : Unsigned_32) return Unsigned_32;
pragma Inline (F);
procedure FF
(A : in out Unsigned_32;
B, C, D : Unsigned_32;
X : Unsigned_32;
AC : Unsigned_32;
S : Positive);
pragma Inline (FF);
function G (X, Y, Z : Unsigned_32) return Unsigned_32;
pragma Inline (G);
procedure GG
(A : in out Unsigned_32;
B, C, D : Unsigned_32;
X : Unsigned_32;
AC : Unsigned_32;
S : Positive);
pragma Inline (GG);
function H (X, Y, Z : Unsigned_32) return Unsigned_32;
pragma Inline (H);
procedure HH
(A : in out Unsigned_32;
B, C, D : Unsigned_32;
X : Unsigned_32;
AC : Unsigned_32;
S : Positive);
pragma Inline (HH);
function I (X, Y, Z : Unsigned_32) return Unsigned_32;
pragma Inline (I);
procedure II
(A : in out Unsigned_32;
B, C, D : Unsigned_32;
X : Unsigned_32;
AC : Unsigned_32;
S : Positive);
pragma Inline (II);
procedure Transform
(C : in out Context;
Block : String);
-- Process one block of 64 characters
------------
-- Decode --
------------
procedure Decode
(Block : String;
X : out Sixteen_Words)
is
Cur : Positive := Block'First;
begin
pragma Assert (Block'Length = 64);
for Index in X'Range loop
X (Index) :=
Unsigned_32 (Character'Pos (Block (Cur))) +
Shift_Left (Unsigned_32 (Character'Pos (Block (Cur + 1))), 8) +
Shift_Left (Unsigned_32 (Character'Pos (Block (Cur + 2))), 16) +
Shift_Left (Unsigned_32 (Character'Pos (Block (Cur + 3))), 24);
Cur := Cur + 4;
end loop;
end Decode;
------------
-- Digest --
------------
function Digest (C : Context) return Message_Digest is
Result : Message_Digest;
Cur : Natural := 1;
-- Index in Result where the next character will be placed
Last_Block : String (1 .. 64);
C1 : Context := C;
procedure Convert (X : Unsigned_32);
-- Put the contribution of one of the four words (A, B, C, D) of the
-- Context in Result. Increments Cur.
-------------
-- Convert --
-------------
procedure Convert (X : Unsigned_32) is
Y : Unsigned_32 := X;
begin
for J in 1 .. 4 loop
Result (Cur + 1) := Hex_Digit (Y and Unsigned_32'(16#0F#));
Y := Shift_Right (Y, 4);
Result (Cur) := Hex_Digit (Y and Unsigned_32'(16#0F#));
Y := Shift_Right (Y, 4);
Cur := Cur + 2;
end loop;
end Convert;
-- Start of processing for Digest
begin
-- Process characters in the context buffer, if any
Last_Block (1 .. C.Last) := C.Buffer (1 .. C.Last);
if C.Last > 56 then
Last_Block (C.Last + 1 .. 64) := Padding (1 .. 64 - C.Last);
Transform (C1, Last_Block);
Last_Block := (others => ASCII.NUL);
else
Last_Block (C.Last + 1 .. 56) := Padding (1 .. 56 - C.Last);
end if;
-- Add the input length (as stored in the context) as 8 characters
Last_Block (57 .. 64) := (others => ASCII.NUL);
declare
L : Unsigned_64 := Unsigned_64 (C.Length) * 8;
Idx : Positive := 57;
begin
while L > 0 loop
Last_Block (Idx) := Character'Val (L and 16#Ff#);
L := Shift_Right (L, 8);
Idx := Idx + 1;
end loop;
end;
Transform (C1, Last_Block);
Convert (C1.A);
Convert (C1.B);
Convert (C1.C);
Convert (C1.D);
return Result;
end Digest;
function Digest (S : String) return Message_Digest is
C : Context;
begin
Update (C, S);
return Digest (C);
end Digest;
function Digest
(A : Ada.Streams.Stream_Element_Array) return Message_Digest
is
C : Context;
begin
Update (C, A);
return Digest (C);
end Digest;
-------
-- F --
-------
function F (X, Y, Z : Unsigned_32) return Unsigned_32 is
begin
return (X and Y) or ((not X) and Z);
end F;
--------
-- FF --
--------
procedure FF
(A : in out Unsigned_32;
B, C, D : Unsigned_32;
X : Unsigned_32;
AC : Unsigned_32;
S : Positive)
is
begin
A := A + F (B, C, D) + X + AC;
A := Rotate_Left (A, S);
A := A + B;
end FF;
-------
-- G --
-------
function G (X, Y, Z : Unsigned_32) return Unsigned_32 is
begin
return (X and Z) or (Y and (not Z));
end G;
--------
-- GG --
--------
procedure GG
(A : in out Unsigned_32;
B, C, D : Unsigned_32;
X : Unsigned_32;
AC : Unsigned_32;
S : Positive)
is
begin
A := A + G (B, C, D) + X + AC;
A := Rotate_Left (A, S);
A := A + B;
end GG;
-------
-- H --
-------
function H (X, Y, Z : Unsigned_32) return Unsigned_32 is
begin
return X xor Y xor Z;
end H;
--------
-- HH --
--------
procedure HH
(A : in out Unsigned_32;
B, C, D : Unsigned_32;
X : Unsigned_32;
AC : Unsigned_32;
S : Positive)
is
begin
A := A + H (B, C, D) + X + AC;
A := Rotate_Left (A, S);
A := A + B;
end HH;
-------
-- I --
-------
function I (X, Y, Z : Unsigned_32) return Unsigned_32 is
begin
return Y xor (X or (not Z));
end I;
--------
-- II --
--------
procedure II
(A : in out Unsigned_32;
B, C, D : Unsigned_32;
X : Unsigned_32;
AC : Unsigned_32;
S : Positive)
is
begin
A := A + I (B, C, D) + X + AC;
A := Rotate_Left (A, S);
A := A + B;
end II;
---------------
-- Transform --
---------------
procedure Transform
(C : in out Context;
Block : String)
is
X : Sixteen_Words;
AA : Unsigned_32 := C.A;
BB : Unsigned_32 := C.B;
CC : Unsigned_32 := C.C;
DD : Unsigned_32 := C.D;
begin
pragma Assert (Block'Length = 64);
Decode (Block, X);
-- Round 1
FF (AA, BB, CC, DD, X (00), 16#D76aa478#, S11); -- 1
FF (DD, AA, BB, CC, X (01), 16#E8c7b756#, S12); -- 2
FF (CC, DD, AA, BB, X (02), 16#242070db#, S13); -- 3
FF (BB, CC, DD, AA, X (03), 16#C1bdceee#, S14); -- 4
FF (AA, BB, CC, DD, X (04), 16#f57c0faf#, S11); -- 5
FF (DD, AA, BB, CC, X (05), 16#4787c62a#, S12); -- 6
FF (CC, DD, AA, BB, X (06), 16#a8304613#, S13); -- 7
FF (BB, CC, DD, AA, X (07), 16#fd469501#, S14); -- 8
FF (AA, BB, CC, DD, X (08), 16#698098d8#, S11); -- 9
FF (DD, AA, BB, CC, X (09), 16#8b44f7af#, S12); -- 10
FF (CC, DD, AA, BB, X (10), 16#ffff5bb1#, S13); -- 11
FF (BB, CC, DD, AA, X (11), 16#895cd7be#, S14); -- 12
FF (AA, BB, CC, DD, X (12), 16#6b901122#, S11); -- 13
FF (DD, AA, BB, CC, X (13), 16#fd987193#, S12); -- 14
FF (CC, DD, AA, BB, X (14), 16#a679438e#, S13); -- 15
FF (BB, CC, DD, AA, X (15), 16#49b40821#, S14); -- 16
-- Round 2
GG (AA, BB, CC, DD, X (01), 16#f61e2562#, S21); -- 17
GG (DD, AA, BB, CC, X (06), 16#c040b340#, S22); -- 18
GG (CC, DD, AA, BB, X (11), 16#265e5a51#, S23); -- 19
GG (BB, CC, DD, AA, X (00), 16#e9b6c7aa#, S24); -- 20
GG (AA, BB, CC, DD, X (05), 16#d62f105d#, S21); -- 21
GG (DD, AA, BB, CC, X (10), 16#02441453#, S22); -- 22
GG (CC, DD, AA, BB, X (15), 16#d8a1e681#, S23); -- 23
GG (BB, CC, DD, AA, X (04), 16#e7d3fbc8#, S24); -- 24
GG (AA, BB, CC, DD, X (09), 16#21e1cde6#, S21); -- 25
GG (DD, AA, BB, CC, X (14), 16#c33707d6#, S22); -- 26
GG (CC, DD, AA, BB, X (03), 16#f4d50d87#, S23); -- 27
GG (BB, CC, DD, AA, X (08), 16#455a14ed#, S24); -- 28
GG (AA, BB, CC, DD, X (13), 16#a9e3e905#, S21); -- 29
GG (DD, AA, BB, CC, X (02), 16#fcefa3f8#, S22); -- 30
GG (CC, DD, AA, BB, X (07), 16#676f02d9#, S23); -- 31
GG (BB, CC, DD, AA, X (12), 16#8d2a4c8a#, S24); -- 32
-- Round 3
HH (AA, BB, CC, DD, X (05), 16#fffa3942#, S31); -- 33
HH (DD, AA, BB, CC, X (08), 16#8771f681#, S32); -- 34
HH (CC, DD, AA, BB, X (11), 16#6d9d6122#, S33); -- 35
HH (BB, CC, DD, AA, X (14), 16#fde5380c#, S34); -- 36
HH (AA, BB, CC, DD, X (01), 16#a4beea44#, S31); -- 37
HH (DD, AA, BB, CC, X (04), 16#4bdecfa9#, S32); -- 38
HH (CC, DD, AA, BB, X (07), 16#f6bb4b60#, S33); -- 39
HH (BB, CC, DD, AA, X (10), 16#bebfbc70#, S34); -- 40
HH (AA, BB, CC, DD, X (13), 16#289b7ec6#, S31); -- 41
HH (DD, AA, BB, CC, X (00), 16#eaa127fa#, S32); -- 42
HH (CC, DD, AA, BB, X (03), 16#d4ef3085#, S33); -- 43
HH (BB, CC, DD, AA, X (06), 16#04881d05#, S34); -- 44
HH (AA, BB, CC, DD, X (09), 16#d9d4d039#, S31); -- 45
HH (DD, AA, BB, CC, X (12), 16#e6db99e5#, S32); -- 46
HH (CC, DD, AA, BB, X (15), 16#1fa27cf8#, S33); -- 47
HH (BB, CC, DD, AA, X (02), 16#c4ac5665#, S34); -- 48
-- Round 4
II (AA, BB, CC, DD, X (00), 16#f4292244#, S41); -- 49
II (DD, AA, BB, CC, X (07), 16#432aff97#, S42); -- 50
II (CC, DD, AA, BB, X (14), 16#ab9423a7#, S43); -- 51
II (BB, CC, DD, AA, X (05), 16#fc93a039#, S44); -- 52
II (AA, BB, CC, DD, X (12), 16#655b59c3#, S41); -- 53
II (DD, AA, BB, CC, X (03), 16#8f0ccc92#, S42); -- 54
II (CC, DD, AA, BB, X (10), 16#ffeff47d#, S43); -- 55
II (BB, CC, DD, AA, X (01), 16#85845dd1#, S44); -- 56
II (AA, BB, CC, DD, X (08), 16#6fa87e4f#, S41); -- 57
II (DD, AA, BB, CC, X (15), 16#fe2ce6e0#, S42); -- 58
II (CC, DD, AA, BB, X (06), 16#a3014314#, S43); -- 59
II (BB, CC, DD, AA, X (13), 16#4e0811a1#, S44); -- 60
II (AA, BB, CC, DD, X (04), 16#f7537e82#, S41); -- 61
II (DD, AA, BB, CC, X (11), 16#bd3af235#, S42); -- 62
II (CC, DD, AA, BB, X (02), 16#2ad7d2bb#, S43); -- 63
II (BB, CC, DD, AA, X (09), 16#eb86d391#, S44); -- 64
C.A := C.A + AA;
C.B := C.B + BB;
C.C := C.C + CC;
C.D := C.D + DD;
end Transform;
------------
-- Update --
------------
procedure Update
(C : in out Context;
Input : String)
is
Inp : constant String := C.Buffer (1 .. C.Last) & Input;
Cur : Positive := Inp'First;
begin
C.Length := C.Length + Input'Length;
while Cur + 63 <= Inp'Last loop
Transform (C, Inp (Cur .. Cur + 63));
Cur := Cur + 64;
end loop;
C.Last := Inp'Last - Cur + 1;
C.Buffer (1 .. C.Last) := Inp (Cur .. Inp'Last);
end Update;
procedure Update
(C : in out Context;
Input : Ada.Streams.Stream_Element_Array)
is
subtype Stream_Array is Ada.Streams.Stream_Element_Array (Input'Range);
subtype Stream_String is
String (1 + Integer (Input'First) .. 1 + Integer (Input'Last));
function To_String is new Ada.Unchecked_Conversion
(Stream_Array, Stream_String);
String_Input : constant String := To_String (Input);
begin
Update (C, String_Input);
end Update;
-----------------
-- Wide_Digest --
-----------------
function Wide_Digest (W : Wide_String) return Message_Digest is
C : Context;
begin
Wide_Update (C, W);
return Digest (C);
end Wide_Digest;
-----------------
-- Wide_Update --
-----------------
procedure Wide_Update
(C : in out Context;
Input : Wide_String)
is
String_Input : String (1 .. 2 * Input'Length);
Cur : Positive := 1;
begin
for Index in Input'Range loop
String_Input (Cur) :=
Character'Val
(Unsigned_32 (Wide_Character'Pos (Input (Index))) and 16#FF#);
Cur := Cur + 1;
String_Input (Cur) :=
Character'Val
(Shift_Right (Unsigned_32 (Wide_Character'Pos (Input (Index))), 8)
and 16#FF#);
Cur := Cur + 1;
end loop;
Update (C, String_Input);
end Wide_Update;
end GNAT.MD5;
|
with System.Storage_Elements;
with TLSF.Config;
with TLSF.Bitmaps;
with TLSF.Mem_Block_Size;
use TLSF.Config;
use TLSF.Bitmaps;
use TLSF.Mem_Block_Size;
package body TLSF.Mem_Blocks is
subtype Free_Block_Header is Block_Header (Free);
subtype Occupied_Block_Header is Block_Header (Occupied);
Block_Header_Size : constant SSE.Storage_Count :=
Block_Header'Max_Size_In_Storage_Elements;
Occupied_Block_Header_Size : constant SSE.Storage_Count :=
Occupied_Block_Header'Max_Size_In_Storage_Elements;
Free_Block_Header_Size : constant SSE.Storage_Count :=
Free_Block_Header'Max_SizRound_Size_Up(e_In_Storage_Elements;
Aligned_Block_Header_Size : constant SSE.Storage_Count :=
Align (Block_Header'Max_Size_In_Storage_Elements);
Aligned_Occupied_Block_Header_Size : constant SSE.Storage_Count :=
Align (Occupied_Block_Header'Max_Size_In_Storage_Elements);
Aligned_Free_Block_Header_Size : constant SSE.Storage_Count :=
Align (Free_Block_Header'Max_Size_In_Storage_Elements);
Small_Block_Size : constant := 2 ** FL_Index_Shift;
use type SSE.Storage_Offset;
use type SSE.Storage_Count;
pragma Assert (Small_Block_Size >= Block_Header_Size);
-- should be >= Block_Header max size in storage elements
function Adjust_And_Align_Size (S : SSE.Storage_Count) return Size is
(Align (Aligned_Occupied_Block_Header_Size + S));
function Is_Free_Block_Too_Large (Free_Block : not null access Block_Header;
Block_Size : Size)
return Boolean
is (Free_Block.Size >= Block_Size + Small_Block_Size);
procedure Block_Make_Occupied
(Block : not null access Block_Header)
is
Blk : Block_Header with Import, Address => Block.all'Address;
begin
Blk := Block_Header'(Status => Occupied,
Prev_Block => Block.Prev_Block,
Prev_Block_Status => Block.Prev_Block_Status,
Next_Block_Status => Block.Next_Block_Status,
Size => Block.Size);
end Block_Make_Occupied;
procedure Block_Make_Free (Block : not null access Block_Header) is
BA : Block_Header with Import, Address => Block.all'Address;
BH : Free_Block_Header := Free_Block_Header'
(Status => Free,
Prev_Block => Block.Prev_Block,
Prev_Block_Status => Block.Prev_Block_Status,
Next_Block_Status => Block.Next_Block_Status,
Size => Block.Size,
Free_List => Free_Blocks_List'(Prev => null,
Next => null));
-- Blk : Block_Header with Import, Address => Block.all'Address;
begin
BA := BH;
--Blk :=
end Block_Make_Free;
function Address_To_Block_Header_Ptr (Addr : System.Address)
return not null access Block_Header
is
use type SSE.Storage_Count;
Block_Addr : System.Address :=
(Addr - Aligned_Occupied_Block_Header_Size);
Block : aliased Block_Header with Import, Address => Block_Addr;
begin
return Block'Unchecked_Access;
end Address_To_Block_Header_Ptr;
function Block_Header_Ptr_To_Address (Block : not null access constant Block_Header)
return System.Address
is
use type SSE.Storage_Count;
begin
return Block.all'Address + Aligned_Occupied_Block_Header_Size;
end Block_Header_Ptr_To_Address;
procedure Notify_Neighbors_Of_Block_Status (Block : access Block_Header) is
Next_Block : access Block_Header := Get_Next_Block (Block);
Prev_Block : access Block_Header := Get_Prev_Block (Block);
begin
if Next_Block /= null then
Next_Block.Prev_Block_Status := Block.Status;
end if;
if Prev_Block /= null then
Prev_Block.Next_Block_Status := Block.Status;
end if;
end Notify_Neighbors_Of_Block_Status;
function Split_Free_Block (Free_Block : not null access Block_Header;
New_Block_Size : Size)
return not null access Block_Header
is
Remaining_Block_Size : Size := Free_Block.Size - New_Block_Size;
Remaining_Block : aliased Block_Header
with
Import,
Address => Free_Block.all'Address + New_Block_Size;
begin
Block_Make_Free ( Remaining_Block'Access );
Remaining_Block := Block_Header'
(Status => Free,
Prev_Block => Free_Block.all'Unchecked_Access,
Prev_Block_Status => Occupied,
Next_Block_Status => Free_Block.Next_Block_Status,
Size => Remaining_Block_Size,
Free_List => Free_Blocks_List'(Prev => null,
Next => null));
Free_Block.Size := New_Block_Size;
Free_Block.Next_Block_Status := Free;
return Remaining_Block'Unchecked_Access;
end Split_Free_Block;
function Insert_To_Free_Blocks_List
(Block_To_Insert : not null access Block_Header;
Block_In_List : access Block_Header)
return not null access Block_Header is
begin
if Block_In_List /= null then
Block_To_Insert.Free_List.Next := Block_In_List;
Block_To_Insert.Free_List.Prev := Block_In_List.Free_List.Prev;
Block_In_List.Free_List.Prev := Block_To_Insert;
return Block_In_List.all'Unchecked_Access;
else
Block_To_Insert.Free_List :=
Free_Blocks_List'(Prev => Block_To_Insert.all'Unchecked_Access,
Next => Block_To_Insert.all'Unchecked_Access);
return Block_To_Insert.all'Unchecked_Access;
end if;
end Insert_To_Free_Blocks_List;
function Get_Next_Block ( Block : not null access Block_Header)
return access Block_Header
is
Next_Block : aliased Block_Header with Import, Address => Block.all'Address + Block.Size;
begin
return (if Block.Next_Block_Status /= Absent
then Next_Block'Unchecked_Access
else null);
end Get_Next_Block;
function Get_Prev_Block ( Block : not null access Block_Header)
return access Block_Header is
begin
return (if Block.Prev_Block_Status /= Absent
then Block.Prev_Block
else null);
end Get_Prev_Block;
function Init_First_Free_Block ( Addr : System.Address;
Sz : SSE.Storage_Count)
return not null access Block_Header
is
Free_Block_Hdr : aliased Block_Header with Import, Address => Addr;
begin
Free_Block_Hdr := Block_Header'
(Status => Free,
Prev_Block => null,
Prev_Block_Status => Absent,
Next_Block_Status => Absent,
Size => Size(Sz),
Free_List => Free_Blocks_List'(Prev => null,
Next => null));
return Free_Block_Hdr'Unchecked_Access;
end Init_First_Free_Block;
function Block_Was_Last_In_Free_List
(Block : not null access constant Block_Header) return Boolean is
-- ERROR here
-- since list is cyclic:
-- /-------\
-- A B
-- \--------/
-- when two last items remain A ->next = B and A->prev = B, so as B
(Block.Free_List.Prev = Block.Free_List.Next);
function Unlink_Block_From_Free_List
(Block : not null access Block_Header)
return access Block_Header is
begin
Block.Free_List.Prev.Free_List.Next := Block.Free_List.Next;
Block.Free_List.Next.Free_List.Prev := Block.Free_List.Prev;
return (if Block_Was_Last_In_Free_List (Block)
then null
else Block.Free_List.Next);
end Unlink_Block_From_Free_List;
procedure Merge_Two_Adjacent_Free_Blocks (Block : not null access Block_Header)
is
Next_Block : access Block_Header := Get_Next_Block (Block);
begin
Block.Next_Block_Status := Next_Block.Next_Block_Status;
Block.Size := Block.Size + Next_Block.Size;
end Merge_Two_Adjacent_Free_Blocks;
function Is_Block_Free (Block : access Block_Header)
return Boolean is
(Block /= null and then Block.Status = Free);
function Search_Suitable_Block
(FL : First_Level_Index;
SL : Second_Level_Index;
Bmp : Levels_Bitmap;
FB_List : Free_Lists)
return not null access Block_Header
is
Block_Hdr : access Block_Header := null;
SL_From : Second_Level_Index := SL;
FL_From : First_Level_Index := FL;
begin
Search_Present (Bmp, FL_From, SL_From);
Block_Hdr := FB_List (FL_From, SL_From);
pragma Assert (Block_Hdr /= null);
-- run-time exception will be raised if no block found
return Block_Hdr;
end Search_Suitable_Block;
procedure Remove_Free_Block_From_Lists_And_Bitmap
(Block : not null access Block_Header;
FB_List : in out Free_Lists;
Bmp : in out Levels_Bitmap)
is
FL : First_Level_Index;
SL : Second_Level_Index;
begin
Mapping_Insert (Block.Size, FL, SL);
FB_List (FL, SL) := Unlink_Block_From_Free_List (Block);
if FB_List (FL, SL) = null then
Set_Not_Present (Bmp, FL, SL);
end if;
end Remove_Free_Block_From_Lists_And_Bitmap;
procedure Insert_Free_Block_To_Lists_And_Bitmap
(Block : not null access Block_Header;
FB_List : in out Free_Lists;
Bmp : in out Levels_Bitmap)
is
FL : First_Level_Index;
SL : Second_Level_Index;
begin
Mapping_Insert (Block.Size, FL, SL);
FB_List (FL, SL) :=
Insert_To_Free_Blocks_List (Block_To_Insert => Block,
Block_In_List => FB_List (FL, SL));
Set_Present (Bmp, FL, SL);
end Insert_Free_Block_To_Lists_And_Bitmap;
end TLSF.Mem_Blocks;
|
-- { dg-do compile }
package Double_Record_Extension3 is
type Rec1 is tagged record
Id : Integer;
end record;
for Rec1 use record
Id at 8 range 0 .. 31;
end record;
type Rec2 (Size : Integer) is new Rec1 with record
Data : String (1 .. Size);
end record;
type Rec3 is new Rec2 (Size => 128) with record
Valid : Boolean;
end record;
end Double_Record_Extension3;
|
with
openGL.Program,
openGL.Model;
package openGL.Visual
is
type Item is tagged private;
type View is access all Item'Class;
type Views is array (Positive range <>) of View;
type Grid is array (Integer range <>, Integer range <>) of Visual.view;
type Grid_view is access all Grid;
procedure free (Self : in out View);
---------
--- Forge
--
package Forge
is
function new_Visual (Model : in openGL.Model.view;
Scale : in Vector_3 := (1.0, 1.0, 1.0);
is_Terrain : in Boolean := False) return Visual.view;
end Forge;
--------------
-- Attributes
--
procedure Model_is (Self : in out Item; Now : in Model.view);
function Model (Self : in Item) return Model.view;
procedure Scale_is (Self : in out Item; Now : in Vector_3);
function Scale (Self : in Item) return Vector_3;
procedure is_Terrain (Self : in out Item; Now : in Boolean := True);
function is_Terrain (Self : in Item) return Boolean;
procedure face_Count_is (Self : in out Item; Now : in Natural);
function face_Count (Self : in Item) return Natural;
procedure apparent_Size_is (Self : in out Item; Now : in Real);
function apparent_Size (Self : in Item) return Real;
procedure mvp_Transform_is (Self : in out Item; Now : in Matrix_4x4);
function mvp_Transform (Self : in Item) return Matrix_4x4;
procedure Transform_is (Self : in out Item; Now : in Matrix_4x4);
function Transform (Self : in Item) return Matrix_4x4;
procedure Site_is (Self : in out Item; Now : in Vector_3);
function Site_of (Self : in Item) return Vector_3;
procedure Spin_is (Self : in out Item; Now : in Matrix_3x3);
function Spin_of (Self : in Item) return Matrix_3x3;
procedure inverse_modelview_Matrix_is (Self : in out Item; Now : in Matrix_3x3);
function inverse_modelview_Matrix (Self : in Item) return Matrix_3x3;
procedure program_Parameters_are (Self : in out Item; Now : in program.Parameters_view);
function program_Parameters (Self : in Item) return program.Parameters_view;
private
type Item is tagged
record
Model : openGL.Model.view;
Scale : Vector_3 := (1.0, 1.0, 1.0);
Transform : Matrix_4x4;
mvp_Transform : Matrix_4x4;
inverse_modelview_Matrix : Matrix_3x3;
program_Parameters : program.Parameters_view;
is_Terrain : Boolean := False;
face_Count : Positive := 1;
apparent_Size : Real; -- A measure of how large the visual is in screen size.
end record;
end openGL.Visual;
|
-- Copyright 2015 Steven Stewart-Gallus
--
-- 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 Interfaces.C; use Interfaces.C;
with Interfaces.C.Strings;
package Libc.Time with
Spark_Mode => Off is
pragma Preelaborate;
subtype clock_t is long;
subtype time_t is long;
type tm is record
tm_sec : aliased int; -- /usr/include/time.h:135
tm_min : aliased int; -- /usr/include/time.h:136
tm_hour : aliased int; -- /usr/include/time.h:137
tm_mday : aliased int; -- /usr/include/time.h:138
tm_mon : aliased int; -- /usr/include/time.h:139
tm_year : aliased int; -- /usr/include/time.h:140
tm_wday : aliased int; -- /usr/include/time.h:141
tm_yday : aliased int; -- /usr/include/time.h:142
tm_isdst : aliased int; -- /usr/include/time.h:143
tm_gmtoff : aliased long; -- /usr/include/time.h:146
tm_zone : Interfaces.C.Strings.chars_ptr; -- /usr/include/time.h:147
end record;
pragma Convention (C_Pass_By_Copy, tm); -- /usr/include/time.h:133
function clock return clock_t; -- /usr/include/time.h:189
pragma Import (C, clock, "clock");
function time
(timer : access time_t) return time_t; -- /usr/include/time.h:192
pragma Import (C, time, "time");
function difftime
(time1 : time_t;
time0 : time_t) return double; -- /usr/include/time.h:195
pragma Import (C, difftime, "difftime");
function mktime (tp : access tm) return time_t; -- /usr/include/time.h:199
pragma Import (C, mktime, "mktime");
function strftime
(s : Interfaces.C.Strings.chars_ptr;
maxsize : size_t;
format : Interfaces.C.Strings.chars_ptr;
tp : access constant tm) return size_t; -- /usr/include/time.h:205
pragma Import (C, strftime, "strftime");
function gmtime
(timer : access time_t) return access tm; -- /usr/include/time.h:239
pragma Import (C, gmtime, "gmtime");
function localtime
(timer : access time_t) return access tm; -- /usr/include/time.h:243
pragma Import (C, localtime, "localtime");
function asctime
(tp : access constant tm)
return Interfaces.C.Strings.chars_ptr; -- /usr/include/time.h:261
pragma Import (C, asctime, "asctime");
function ctime
(timer : access time_t)
return Interfaces.C.Strings.chars_ptr; -- /usr/include/time.h:264
pragma Import (C, ctime, "ctime");
end Libc.Time;
|
with HAL; use HAL;
with HAL.GPIO; use HAL.GPIO;
with USB.Device;
with USB.Device.MIDI;
with USB.Device.Serial;
with USB.Device.HID.Gamepad;
with SAM.Device; use SAM.Device;
with SAM.USB;
with SAM_SVD.USB;
with SAM.Main_Clock;
with SAM.Clock_Generator;
with SAM.Clock_Generator.IDs;
with SAM.Clock_Setup_120Mhz;
with SAM.Port;
with SAM.Functions;
with Interfaces; use Interfaces;
with PyGamer; -- Elaborate PyGamer
pragma Unreferenced (PyGamer);
with PyGamer.Controls;
with pygamer_usb_gamepad_Config;
package body USB_Gamepad is
Stack : USB.Device.USB_Device_Stack (Max_Classes => 3);
Pad : aliased USB.Device.HID.Gamepad.Instance;
UDC : aliased SAM.USB.UDC
(Periph => SAM_SVD.USB.USB_Periph'Access,
EP_Buffers_Size => 512,
Max_Packet_Size => 64);
USB_DP : SAM.Port.GPIO_Point renames PA25;
USB_DM : SAM.Port.GPIO_Point renames PA24;
USB_ID : SAM.Port.GPIO_Point renames PA23;
procedure Run is
use type USB.Device.Init_Result;
begin
SAM.Clock_Generator.Configure_Periph_Channel
(SAM.Clock_Generator.IDs.USB, SAM.Clock_Setup_120Mhz.Clk_48Mhz);
SAM.Main_Clock.USB_On;
USB_DP.Clear;
USB_DP.Set_Mode (HAL.GPIO.Output);
USB_DP.Set_Pull_Resistor (HAL.GPIO.Floating);
USB_DP.Set_Function (SAM.Functions.PA25_USB_DP);
USB_DM.Clear;
USB_DM.Set_Mode (HAL.GPIO.Output);
USB_DM.Set_Pull_Resistor (HAL.GPIO.Floating);
USB_DM.Set_Function (SAM.Functions.PA25_USB_DP);
USB_ID.Clear;
USB_ID.Set_Mode (HAL.GPIO.Output);
USB_ID.Set_Pull_Resistor (HAL.GPIO.Floating);
USB_ID.Set_Function (SAM.Functions.PA23_USB_SOF_1KHZ);
if not Stack.Register_Class (Pad'Access) then
raise Program_Error;
end if;
if Stack.Initialize
(UDC'Access,
USB.To_USB_String ("Fabien"),
USB.To_USB_String ("PyGamer Gamepad"),
USB.To_USB_String (pygamer_usb_gamepad_Config.Crate_Version),
UDC.Max_Packet_Size) /= USB.Device.Ok
then
raise Program_Error;
end if;
Stack.Start;
declare
S : Natural := 1;
begin
loop
Stack.Poll;
if Pad.Ready then
PyGamer.Controls.Scan;
declare
use USB.Device.HID.Gamepad;
X_Val : constant Integer_8 :=
Integer_8 (PyGamer.Controls.Joystick_X);
Y_Val : constant Integer_8 :=
Integer_8 (PyGamer.Controls.Joystick_Y);
Buttons : UInt8 := 0;
begin
Pad.Set_Axis (X, X_Val);
Pad.Set_Axis (Y, Y_Val);
if PyGamer.Controls.Pressed (PyGamer.Controls.A) then
Buttons := Buttons or 2#0000_0001#;
end if;
if PyGamer.Controls.Pressed (PyGamer.Controls.B) then
Buttons := Buttons or 2#0000_0010#;
end if;
if PyGamer.Controls.Pressed (PyGamer.Controls.Sel) then
Buttons := Buttons or 2#0000_0100#;
end if;
if PyGamer.Controls.Pressed (PyGamer.Controls.Start) then
Buttons := Buttons or 2#0000_1000#;
end if;
Pad.Set_Buttons (Buttons);
Pad.Send_Report (UDC);
end;
end if;
end loop;
end;
end Run;
end USB_Gamepad;
|
-- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
with Ada.Calendar.Arithmetic;
with Ada.Calendar.Formatting;
with Ada.Direct_IO;
with Replicant.Platform;
package body PortScan.Buildcycle is
package ACA renames Ada.Calendar.Arithmetic;
package ACF renames Ada.Calendar.Formatting;
package REP renames Replicant;
----------------------
-- initialize_log --
----------------------
function initialize_log (id : builders) return Boolean
is
FA : access TIO.File_Type;
H_ENV : constant String := "Environment";
H_OPT : constant String := "Options";
CFG1 : constant String := "/etc/make.conf";
CFG2 : constant String := "/etc/mk.conf";
UNAME : constant String := JT.USS (uname_mrv);
BENV : constant String := get_environment (id);
COPTS : constant String := get_options_configuration (id);
PTVAR : JT.Text := get_port_variables (id);
begin
trackers (id).dynlink.Clear;
trackers (id).head_time := CAL.Clock;
declare
log_path : constant String := log_name (trackers (id).seq_id);
begin
-- Try to defend malicious symlink: https://en.wikipedia.org/wiki/Symlink_race
if AD.Exists (log_path) then
AD.Delete_File (log_path);
end if;
TIO.Create (File => trackers (id).log_handle,
Mode => TIO.Out_File,
Name => log_path);
FA := trackers (id).log_handle'Access;
exception
when error : others =>
raise cycle_log_error
with "failed to create log " & log_path;
end;
TIO.Put_Line (FA.all, "=> Building " &
get_catport (all_ports (trackers (id).seq_id)));
TIO.Put_Line (FA.all, "Started : " & timestamp (trackers (id).head_time));
TIO.Put (FA.all, "Platform: " & UNAME);
if BENV = discerr then
TIO.Put_Line (FA.all, LAT.LF & "Environment definition failed, " &
"aborting entire build");
return False;
end if;
TIO.Put_Line (FA.all, LAT.LF & log_section (H_ENV, True));
TIO.Put (FA.all, BENV);
TIO.Put_Line (FA.all, log_section (H_ENV, False) & LAT.LF);
TIO.Put_Line (FA.all, log_section (H_OPT, True));
TIO.Put (FA.all, COPTS);
TIO.Put_Line (FA.all, log_section (H_OPT, False) & LAT.LF);
dump_port_variables (id => id, content => PTVAR);
case software_framework is
when ports_collection =>
TIO.Put_Line (FA.all, log_section (CFG1, True));
TIO.Put (FA.all, dump_make_conf (id, CFG1));
TIO.Put_Line (FA.all, log_section (CFG1, False) & LAT.LF);
when pkgsrc =>
TIO.Put_Line (FA.all, log_section (CFG2, True));
TIO.Put (FA.all, dump_make_conf (id, CFG2));
TIO.Put_Line (FA.all, log_section (CFG2, False) & LAT.LF);
end case;
return True;
end initialize_log;
--------------------
-- finalize_log --
--------------------
procedure finalize_log (id : builders) is
begin
TIO.Put_Line (trackers (id).log_handle, log_section ("Termination", True));
trackers (id).tail_time := CAL.Clock;
TIO.Put_Line (trackers (id).log_handle,
"Finished: " & timestamp (trackers (id).tail_time));
TIO.Put_Line (trackers (id).log_handle,
log_duration (start => trackers (id).head_time,
stop => trackers (id).tail_time));
TIO.Close (trackers (id).log_handle);
end finalize_log;
--------------------
-- log_duration --
--------------------
function log_duration (start, stop : CAL.Time) return String
is
raw : JT.Text := JT.SUS ("Duration:");
diff_days : ACA.Day_Count;
diff_secs : Duration;
leap_secs : ACA.Leap_Seconds_Count;
use type ACA.Day_Count;
begin
ACA.Difference (Left => stop,
Right => start,
Days => diff_days,
Seconds => diff_secs,
Leap_Seconds => leap_secs);
if diff_days > 0 then
if diff_days = 1 then
JT.SU.Append (raw, " 1 day and " &
ACF.Image (Elapsed_Time => diff_secs));
else
JT.SU.Append (raw, diff_days'Img & " days and " &
ACF.Image (Elapsed_Time => diff_secs));
end if;
else
JT.SU.Append (raw, " " & ACF.Image (Elapsed_Time => diff_secs));
end if;
return JT.USS (raw);
end log_duration;
------------------------
-- elapsed_HH_MM_SS --
------------------------
function elapsed_HH_MM_SS (start, stop : CAL.Time) return String
is
diff_days : ACA.Day_Count;
diff_secs : Duration;
leap_secs : ACA.Leap_Seconds_Count;
secs_per_hour : constant Integer := 3600;
total_hours : Integer;
total_minutes : Integer;
work_hours : Integer;
work_seconds : Integer;
use type ACA.Day_Count;
begin
ACA.Difference (Left => stop,
Right => start,
Days => diff_days,
Seconds => diff_secs,
Leap_Seconds => leap_secs);
-- Seems the ACF image is shit, so let's roll our own. If more than
-- 100 hours, change format to "HHH:MM.M"
work_seconds := Integer (diff_secs);
total_hours := work_seconds / secs_per_hour;
total_hours := total_hours + Integer (diff_days) * 24;
if total_hours < 24 then
if work_seconds < 0 then
return "--:--:--";
else
work_seconds := work_seconds - (total_hours * secs_per_hour);
total_minutes := work_seconds / 60;
work_seconds := work_seconds - (total_minutes * 60);
return
JT.zeropad (total_hours, 2) & LAT.Colon &
JT.zeropad (total_minutes, 2) & LAT.Colon &
JT.zeropad (work_seconds, 2);
end if;
elsif total_hours < 100 then
if work_seconds < 0 then
return JT.zeropad (total_hours, 2) & ":00:00";
else
work_hours := work_seconds / secs_per_hour;
work_seconds := work_seconds - (work_hours * secs_per_hour);
total_minutes := work_seconds / 60;
work_seconds := work_seconds - (total_minutes * 60);
return
JT.zeropad (total_hours, 2) & LAT.Colon &
JT.zeropad (total_minutes, 2) & LAT.Colon &
JT.zeropad (work_seconds, 2);
end if;
else
if work_seconds < 0 then
return JT.zeropad (total_hours, 3) & ":00.0";
else
work_hours := work_seconds / secs_per_hour;
work_seconds := work_seconds - (work_hours * secs_per_hour);
total_minutes := work_seconds / 60;
work_seconds := (work_seconds - (total_minutes * 60)) * 10 / 60;
return
JT.zeropad (total_hours, 3) & LAT.Colon &
JT.zeropad (total_minutes, 2) & '.' &
JT.int2str (work_seconds);
end if;
end if;
end elapsed_HH_MM_SS;
-------------------
-- elapsed_now --
-------------------
function elapsed_now return String is
begin
return elapsed_HH_MM_SS (start => start_time, stop => CAL.Clock);
end elapsed_now;
-----------------------------
-- generic_system_command --
-----------------------------
function generic_system_command (command : String) return JT.Text
is
content : JT.Text;
status : Integer;
begin
content := Unix.piped_command (command, status);
if status /= 0 then
raise cycle_cmd_error with "cmd: " & command &
" (return code =" & status'Img & ")";
end if;
return content;
end generic_system_command;
---------------------
-- set_uname_mrv --
---------------------
procedure set_uname_mrv
is
-- valid for all platforms
command : constant String := "/usr/bin/uname -mrv";
begin
uname_mrv := generic_system_command (command);
exception
when others =>
uname_mrv := JT.SUS (discerr);
end set_uname_mrv;
----------------
-- get_root --
----------------
function get_root (id : builders) return String
is
id_image : constant String := Integer (id)'Img;
suffix : String := "/SL00";
begin
if id < 10 then
suffix (5) := id_image (2);
else
suffix (4 .. 5) := id_image (2 .. 3);
end if;
return JT.USS (PM.configuration.dir_buildbase) & suffix;
end get_root;
-----------------------
-- get_environment --
-----------------------
function get_environment (id : builders) return String
is
root : constant String := get_root (id);
command : constant String := chroot & root & environment_override;
begin
return JT.USS (generic_system_command (command));
exception
when others =>
return discerr;
end get_environment;
---------------------------------
-- get_options_configuration --
---------------------------------
function get_options_configuration (id : builders) return String
is
root : constant String := get_root (id);
catport : constant String := get_catport (all_ports (trackers (id).seq_id));
command : constant String := chroot & root & environment_override &
chroot_make_program & " -C " & port_specification (catport);
begin
case software_framework is
when ports_collection =>
return JT.USS (generic_system_command (command & " showconfig"));
when pkgsrc =>
return JT.USS (generic_system_command (command & " show-options"));
end case;
exception
when others =>
return discerr;
end get_options_configuration;
------------------------
-- split_collection --
------------------------
function split_collection (line : JT.Text; title : String) return String
is
-- Support spaces in two ways
-- 1) quoted, e.g. TYPING="The Quick Brown Fox"
-- 2) Escaped, e.g. TYPING=The\ Quick\ Brown\ Fox
meat : JT.Text;
waiting : Boolean := True;
escaped : Boolean := False;
quoted : Boolean := False;
keepit : Boolean;
counter : Natural := 0;
meatlen : Natural := 0;
linelen : Natural := JT.SU.Length (line);
onechar : String (1 .. 1);
meatstr : String (1 .. linelen);
begin
loop
counter := counter + 1;
exit when counter > linelen;
keepit := True;
onechar := JT.SU.Slice (Source => line,
Low => counter,
High => counter);
if onechar (1) = LAT.Reverse_Solidus then
-- A) if inside quotes, it's literal
-- B) if it's first RS, don't keep but mark escaped
-- C) If it's second RS, it's literal, remove escaped
-- D) RS can never start a new NV pair
if not quoted then
if not escaped then
keepit := False;
end if;
escaped := not escaped;
end if;
elsif escaped then
-- E) by definition, next character after an escape is literal
-- We know it's not inside quotes. Keep this (could be a space)
waiting := False;
escaped := not escaped;
elsif onechar (1) = LAT.Space then
if waiting then
keepit := False;
else
if not quoted then
-- name-pair ended, reset
waiting := True;
quoted := False;
onechar (1) := LAT.LF;
end if;
end if;
else
waiting := False;
if onechar (1) = LAT.Quotation then
quoted := not quoted;
end if;
end if;
if keepit then
meatlen := meatlen + 1;
meatstr (meatlen) := onechar (1);
end if;
end loop;
return log_section (title, True) & LAT.LF &
meatstr (1 .. meatlen) & LAT.LF &
log_section (title, False) & LAT.LF;
end split_collection;
--------------------------
-- get_port_variables --
--------------------------
function get_port_variables (id : builders) return JT.Text
is
root : constant String := get_root (id);
catport : constant String := get_catport (all_ports (trackers (id).seq_id));
command : constant String := chroot & root & environment_override &
chroot_make_program & " -C " & port_specification (catport);
cmd_fpc : constant String := command &
" -VCONFIGURE_ENV -VCONFIGURE_ARGS -VMAKE_ENV -VMAKE_ARGS" &
" -VPLIST_SUB -VSUB_LIST";
cmd_nps : constant String := command &
" .MAKE.EXPAND_VARIABLES=yes -VCONFIGURE_ENV -VCONFIGURE_ARGS" &
" -VMAKE_ENV -VMAKE_FLAGS -VBUILD_MAKE_FLAGS -VPLIST_SUBST" &
" -VFILES_SUBST";
begin
case software_framework is
when ports_collection =>
return generic_system_command (cmd_fpc);
when pkgsrc =>
return generic_system_command (cmd_nps);
end case;
exception
when others =>
return JT.SUS (discerr);
end get_port_variables;
---------------------------
-- dump_port_variables --
---------------------------
procedure dump_port_variables (id : builders; content : JT.Text)
is
LA : access TIO.File_Type := trackers (id).log_handle'Access;
topline : JT.Text;
concopy : JT.Text := content;
type result_range_fpc is range 1 .. 6;
type result_range_nps is range 1 .. 7;
begin
case software_framework is
when ports_collection =>
for k in result_range_fpc loop
JT.nextline (lineblock => concopy, firstline => topline);
case k is
when 1 => TIO.Put_Line
(LA.all, split_collection (topline, "CONFIGURE_ENV"));
when 2 => TIO.Put_Line
(LA.all, split_collection (topline, "CONFIGURE_ARGS"));
when 3 => TIO.Put_Line
(LA.all, split_collection (topline, "MAKE_ENV"));
when 4 => TIO.Put_Line
(LA.all, split_collection (topline, "MAKE_ARGS"));
when 5 => TIO.Put_Line
(LA.all, split_collection (topline, "PLIST_SUB"));
when 6 => TIO.Put_Line
(LA.all, split_collection (topline, "SUB_LIST"));
end case;
end loop;
when pkgsrc =>
for k in result_range_nps loop
JT.nextline (lineblock => concopy, firstline => topline);
case k is
when 1 => TIO.Put_Line
(LA.all, split_collection (topline, "CONFIGURE_ENV"));
when 2 => TIO.Put_Line
(LA.all, split_collection (topline, "CONFIGURE_ARGS"));
when 3 => TIO.Put_Line
(LA.all, split_collection (topline, "MAKE_ENV"));
when 4 => TIO.Put_Line
(LA.all, split_collection (topline, "MAKE_FLAGS"));
when 5 => TIO.Put_Line
(LA.all, split_collection (topline, "BUILD_MAKE_FLAGS"));
when 6 => TIO.Put_Line
(LA.all, split_collection (topline, "PLIST_SUBST"));
when 7 => TIO.Put_Line
(LA.all, split_collection (topline, "FILES_SUBST"));
end case;
end loop;
end case;
end dump_port_variables;
----------------
-- log_name --
----------------
function log_name (sid : port_id) return String
is
catport : constant String := get_catport (all_ports (sid));
begin
return JT.USS (PM.configuration.dir_logs) & "/" &
JT.part_1 (catport) & "___" & JT.part_2 (catport) & ".log";
end log_name;
-----------------
-- dump_file --
-----------------
function dump_file (filename : String) return String
is
File_Size : Natural := Natural (AD.Size (filename));
subtype File_String is String (1 .. File_Size);
package File_String_IO is new Ada.Direct_IO (File_String);
File : File_String_IO.File_Type;
Contents : File_String;
begin
File_String_IO.Open (File, Mode => File_String_IO.In_File,
Name => filename);
File_String_IO.Read (File, Item => Contents);
File_String_IO.Close (File);
return String (Contents);
end dump_file;
----------------------
-- dump_make_conf --
----------------------
function dump_make_conf (id : builders; conf_file : String) return String
is
root : constant String := get_root (id);
filename : constant String := root & conf_file;
begin
return dump_file (filename);
end dump_make_conf;
------------------
-- initialize --
------------------
procedure initialize (test_mode : Boolean; jail_env : JT.Text) is
begin
set_uname_mrv;
testing := test_mode;
lock_localbase := testing and then Unix.env_variable_defined ("LOCK");
slave_env := jail_env;
declare
logdir : constant String := JT.USS (PM.configuration.dir_logs);
begin
if not AD.Exists (logdir) then
AD.Create_Path (New_Directory => logdir);
end if;
exception
when error : others =>
raise cycle_log_error
with "failed to create " & logdir;
end;
obtain_custom_environment;
end initialize;
-------------------
-- log_section --
-------------------
function log_section (title : String; header : Boolean) return String
is
hyphens : constant String := (1 .. 50 => '-');
begin
if header then
return LAT.LF & hyphens & LAT.LF & "-- " & title & LAT.LF & hyphens;
else
return "";
end if;
end log_section;
---------------------
-- log_phase_end --
---------------------
procedure log_phase_end (id : builders)
is
begin
TIO.Put_Line (trackers (id).log_handle, "" & LAT.LF);
end log_phase_end;
-----------------------
-- log_phase_begin --
-----------------------
procedure log_phase_begin (phase : String; id : builders)
is
hyphens : constant String := (1 .. 80 => '-');
middle : constant String := "-- Phase: " & phase;
begin
TIO.Put_Line (trackers (id).log_handle,
LAT.LF & hyphens & LAT.LF & middle & LAT.LF & hyphens);
end log_phase_begin;
-----------------------
-- generic_execute --
-----------------------
function generic_execute (id : builders; command : String;
dogbite : out Boolean;
time_limit : execution_limit) return Boolean
is
subtype time_cycle is execution_limit range 1 .. time_limit;
subtype one_minute is Positive range 1 .. 230; -- lose 10 in rounding
type dim_watchdog is array (time_cycle) of Natural;
use type Unix.process_exit;
watchdog : dim_watchdog;
squirrel : time_cycle := time_cycle'First;
cycle_done : Boolean := False;
pid : Unix.pid_t;
status : Unix.process_exit;
lock_lines : Natural;
quartersec : one_minute := one_minute'First;
hangmonitor : constant Boolean := True;
synthexec : constant String := host_localbase & "/libexec/synthexec";
truecommand : constant String := synthexec & " " &
log_name (trackers (id).seq_id) & " " & command;
begin
dogbite := False;
watchdog (squirrel) := trackers (id).loglines;
pid := Unix.launch_process (truecommand);
if Unix.fork_failed (pid) then
return False;
end if;
loop
delay 0.25;
if quartersec = one_minute'Last then
quartersec := one_minute'First;
-- increment squirrel
if squirrel = time_cycle'Last then
squirrel := time_cycle'First;
cycle_done := True;
else
squirrel := squirrel + 1;
end if;
if hangmonitor then
lock_lines := trackers (id).loglines;
if cycle_done then
if watchdog (squirrel) = lock_lines then
-- Log hasn't advanced in a full cycle so bail out
dogbite := True;
Unix.kill_process_tree (process_group => pid);
delay 5.0; -- Give some time for error to write to log
return False;
end if;
end if;
watchdog (squirrel) := lock_lines;
end if;
else
quartersec := quartersec + 1;
end if;
status := Unix.process_status (pid);
if status = Unix.exited_normally then
return True;
end if;
if status = Unix.exited_with_error then
return False;
end if;
end loop;
end generic_execute;
------------------------------
-- stack_linked_libraries --
------------------------------
procedure stack_linked_libraries (id : builders; base, filename : String)
is
command : String := chroot & base & " /usr/bin/objdump -p " & filename;
comres : JT.Text;
topline : JT.Text;
crlen1 : Natural;
crlen2 : Natural;
begin
comres := generic_system_command (command);
crlen1 := JT.SU.Length (comres);
loop
JT.nextline (lineblock => comres, firstline => topline);
crlen2 := JT.SU.Length (comres);
exit when crlen1 = crlen2;
crlen1 := crlen2;
if not JT.IsBlank (topline) then
if JT.contains (topline, "NEEDED") then
if not trackers (id).dynlink.Contains (topline) then
trackers (id).dynlink.Append (topline);
end if;
end if;
end if;
end loop;
exception
-- the command result was not zero, so it was an expected format
-- or static file. Just skip it. (Should never happen)
when bad_result : others => null;
end stack_linked_libraries;
----------------------------
-- log_linked_libraries --
----------------------------
procedure log_linked_libraries (id : builders)
is
procedure log_dump (cursor : string_crate.Cursor);
comres : JT.Text;
topline : JT.Text;
crlen1 : Natural;
crlen2 : Natural;
pkgfile : constant String := JT.USS
(all_ports (trackers (id).seq_id).package_name);
pkgname : constant String := pkgfile (1 .. pkgfile'Last - 4);
root : constant String := get_root (id);
command : constant String := chroot & root & environment_override &
REP.root_localbase & "/sbin/pkg-static query %Fp " & pkgname;
procedure log_dump (cursor : string_crate.Cursor) is
begin
TIO.Put_Line (trackers (id).log_handle,
JT.USS (string_crate.Element (Position => cursor)));
end log_dump;
begin
TIO.Put_Line (trackers (id).log_handle,
"=> Checking shared library dependencies");
comres := generic_system_command (command);
crlen1 := JT.SU.Length (comres);
loop
JT.nextline (lineblock => comres, firstline => topline);
crlen2 := JT.SU.Length (comres);
exit when crlen1 = crlen2;
crlen1 := crlen2;
if REP.Platform.dynamically_linked (root, JT.USS (topline)) then
stack_linked_libraries (id, root, JT.USS (topline));
end if;
end loop;
trackers (id).dynlink.Iterate (log_dump'Access);
exception
when others => null;
end log_linked_libraries;
----------------------------
-- environment_override --
----------------------------
function environment_override (enable_tty : Boolean := False) return String
is
function set_terminal (enable_tty : Boolean) return String;
function set_terminal (enable_tty : Boolean) return String is
begin
if enable_tty then
return "TERM=cons25 ";
end if;
return "TERM=dumb ";
end set_terminal;
PATH : constant String := "PATH=/sbin:/bin:/usr/sbin:/usr/bin:"
& REP.root_localbase & "/sbin:" & REP.root_localbase & "/bin ";
TERM : constant String := set_terminal (enable_tty);
USER : constant String := "USER=root ";
HOME : constant String := "HOME=/root ";
LANG : constant String := "LANG=C ";
FTP : constant String := "SSL_NO_VERIFY_PEER=1 ";
PKG8 : constant String := "PORTSDIR=" & dir_ports & " " &
"PKG_DBDIR=/var/db/pkg8 " &
"PKG_CACHEDIR=/var/cache/pkg8 ";
CENV : constant String := JT.USS (customenv);
JENV : constant String := JT.USS (slave_env);
begin
return " /usr/bin/env -i " &
USER & HOME & LANG & PKG8 & TERM & FTP & PATH & JENV & CENV;
end environment_override;
---------------------
-- set_log_lines --
---------------------
procedure set_log_lines (id : builders)
is
log_path : constant String := log_name (trackers (id).seq_id);
command : constant String := "/usr/bin/wc -l " & log_path;
comres : JT.Text;
begin
if not uselog then
trackers (id).loglines := 0;
return;
end if;
comres := JT.trim (generic_system_command (command));
declare
numtext : constant String :=
JT.part_1 (S => JT.USS (comres), separator => " ");
begin
trackers (id).loglines := Natural'Value (numtext);
end;
exception
when others => null; -- just skip this cycle
end set_log_lines;
-----------------------
-- format_loglines --
-----------------------
function format_loglines (numlines : Natural) return String
is
begin
if numlines < 10000000 then -- 10 million
return JT.int2str (numlines);
end if;
declare
kilo : constant Natural := numlines / 1000;
kilotxt : constant String := JT.int2str (kilo);
begin
if numlines < 100000000 then -- 100 million
return kilotxt (1 .. 2) & "." & kilotxt (3 .. 5) & 'M';
elsif numlines < 1000000000 then -- 1 billion
return kilotxt (1 .. 3) & "." & kilotxt (3 .. 4) & 'M';
else
return kilotxt (1 .. 4) & "." & kilotxt (3 .. 3) & 'M';
end if;
end;
end format_loglines;
---------------------
-- elapsed_build --
---------------------
function elapsed_build (id : builders) return String is
begin
return elapsed_HH_MM_SS (start => trackers (id).head_time,
stop => trackers (id).tail_time);
end elapsed_build;
-----------------------------
-- get_packages_per_hour --
-----------------------------
function get_packages_per_hour (packages_done : Natural;
from_when : CAL.Time)
return Natural
is
diff_days : ACA.Day_Count;
diff_secs : Duration;
leap_secs : ACA.Leap_Seconds_Count;
result : Natural;
rightnow : CAL.Time := CAL.Clock;
work_seconds : Integer;
work_days : Integer;
use type ACA.Day_Count;
begin
if packages_done = 0 then
return 0;
end if;
ACA.Difference (Left => rightnow,
Right => from_when,
Days => diff_days,
Seconds => diff_secs,
Leap_Seconds => leap_secs);
work_seconds := Integer (diff_secs);
work_days := Integer (diff_days);
work_seconds := work_seconds + (work_days * 3600 * 24);
if work_seconds < 0 then
-- should be impossible to get here.
return 0;
end if;
result := packages_done * 3600;
result := result / work_seconds;
return result;
exception
when others => return 0;
end get_packages_per_hour;
------------------------
-- mark_file_system --
------------------------
procedure mark_file_system (id : builders; action : String)
is
function attributes (action : String) return String;
function attributes (action : String) return String
is
core : constant String := "uid,gid,mode,md5digest";
begin
if action = "preconfig" then
return core & ",time";
else
return core;
end if;
end attributes;
path_mm : String := JT.USS (PM.configuration.dir_buildbase) & "/Base";
path_sm : String := JT.USS (PM.configuration.dir_buildbase) & "/SL" &
JT.zeropad (Natural (id), 2);
mtfile : constant String := path_mm & "/mtree." & action & ".exclude";
command : constant String := "/usr/sbin/mtree -X " & mtfile &
" -cn -k " & attributes (action) & " -p " & path_sm;
filename : constant String := path_sm & "/tmp/mtree." & action;
result : JT.Text;
resfile : TIO.File_Type;
begin
result := generic_system_command (command);
-- Try to defend malicious symlink: https://en.wikipedia.org/wiki/Symlink_race
if AD.Exists (filename) then
AD.Delete_File (filename);
end if;
TIO.Create (File => resfile, Mode => TIO.Out_File, Name => filename);
TIO.Put (resfile, JT.USS (result));
TIO.Close (resfile);
exception
when others =>
if TIO.Is_Open (resfile) then
TIO.Close (resfile);
end if;
end mark_file_system;
--------------------------------
-- detect_leftovers_and_MIA --
--------------------------------
function detect_leftovers_and_MIA (id : builders; action : String;
description : String) return Boolean
is
package crate is new AC.Vectors (Index_Type => Positive,
Element_Type => JT.Text,
"=" => JT.SU."=");
package sorter is new crate.Generic_Sorting ("<" => JT.SU."<");
function ignore_modifications return Boolean;
procedure print (cursor : crate.Cursor);
procedure close_active_modifications;
path_mm : String := JT.USS (PM.configuration.dir_buildbase) & "/Base";
path_sm : String := JT.USS (PM.configuration.dir_buildbase) & "/SL" &
JT.zeropad (Natural (id), 2);
mtfile : constant String := path_mm & "/mtree." & action & ".exclude";
filename : constant String := path_sm & "/tmp/mtree." & action;
command : constant String := "/usr/sbin/mtree -X " & mtfile & " -f " &
filename & " -p " & path_sm;
status : Integer;
comres : JT.Text;
topline : JT.Text;
crlen1 : Natural;
crlen2 : Natural;
toplen : Natural;
skiprest : Boolean;
passed : Boolean := True;
activemod : Boolean := False;
modport : JT.Text := JT.blank;
reasons : JT.Text := JT.blank;
leftover : crate.Vector;
missing : crate.Vector;
changed : crate.Vector;
function ignore_modifications return Boolean
is
-- Some modifications need to be ignored
-- A) */ls-R
-- #ls-R files from texmf are often regenerated
-- B) share/xml/catalog.ports
-- # xmlcatmgr is constantly updating catalog.ports, ignore
-- C) share/octave/octave_packages
-- # Octave packages database, blank lines can be inserted
-- # between pre-install and post-deinstall
-- D) info/dir | */info/dir
-- E) lib/gio/modules/giomodule.cache
-- # gio modules cache could be modified for any gio modules
-- F) etc/gconf/gconf.xml.defaults/%gconf-tree*.xml
-- # gconftool-2 --makefile-uninstall-rule is unpredictable
-- G) %%PEARDIR%%/.depdb | %%PEARDIR%%/.filemap
-- # The is pear database cache
-- H) "." with timestamp modification
-- # this happens when ./tmp or ./var is used, which is legal
filename : constant String := JT.USS (modport);
fnlen : constant Natural := filename'Length;
begin
if filename = "usr/local/share/xml/catalog.ports" or else
filename = "usr/local/share/octave/octave_packages" or else
filename = "usr/local/info/dir" or else
filename = "usr/local/lib/gio/modules/giomodule.cache" or else
filename = "usr/local/share/pear/.depdb" or else
filename = "usr/local/share/pear/.filemap"
then
return True;
end if;
if filename = "." and then JT.equivalent (reasons, "modification") then
return True;
end if;
if fnlen > 17 and then filename (1 .. 10) = "usr/local/"
then
if filename (fnlen - 4 .. fnlen) = "/ls-R" or else
filename (fnlen - 8 .. fnlen) = "/info/dir"
then
return True;
end if;
end if;
if fnlen > 56 and then filename (1 .. 39) =
"usr/local/etc/gconf/gconf.xml.defaults/" and then
filename (fnlen - 3 .. fnlen) = ".xml"
then
if JT.contains (filename, "/%gconf-tree") then
return True;
end if;
end if;
return False;
end ignore_modifications;
procedure close_active_modifications is
begin
if activemod and then not ignore_modifications then
JT.SU.Append (modport, " [ ");
JT.SU.Append (modport, reasons);
JT.SU.Append (modport, " ]");
if not changed.Contains (modport) then
changed.Append (modport);
end if;
end if;
activemod := False;
reasons := JT.blank;
modport := JT.blank;
end close_active_modifications;
procedure print (cursor : crate.Cursor)
is
dossier : constant String := JT.USS (crate.Element (cursor));
begin
TIO.Put_Line (trackers (id).log_handle, LAT.HT & dossier);
end print;
begin
-- we can't use generic_system_command because exit code /= 0 normally
comres := Unix.piped_command (command, status);
crlen1 := JT.SU.Length (comres);
loop
skiprest := False;
JT.nextline (lineblock => comres, firstline => topline);
crlen2 := JT.SU.Length (comres);
exit when crlen1 = crlen2;
crlen1 := crlen2;
toplen := JT.SU.Length (topline);
if not skiprest and then JT.SU.Length (topline) > 6 then
declare
sx : constant Natural := toplen - 5;
caboose : constant String := JT.SU.Slice (topline, sx, toplen);
filename : JT.Text := JT.SUS (JT.SU.Slice (topline, 1, sx - 1));
begin
if caboose = " extra" then
close_active_modifications;
if not leftover.Contains (filename) then
leftover.Append (filename);
end if;
skiprest := True;
end if;
end;
end if;
if not skiprest and then JT.SU.Length (topline) > 7 then
declare
canopy : constant String := JT.SU.Slice (topline, 1, 7);
filename : JT.Text := JT.SUS (JT.SU.Slice (topline, 8, toplen));
begin
if canopy = "extra: " then
close_active_modifications;
if not leftover.Contains (filename) then
leftover.Append (filename);
end if;
skiprest := True;
end if;
end;
end if;
if not skiprest and then JT.SU.Length (topline) > 10 then
declare
sx : constant Natural := toplen - 7;
caboose : constant String := JT.SU.Slice (topline, sx, toplen);
filename : JT.Text := JT.SUS (JT.SU.Slice (topline, 3, sx - 1));
begin
if caboose = " missing" then
close_active_modifications;
if not missing.Contains (filename) then
missing.Append (filename);
end if;
skiprest := True;
end if;
end;
end if;
if not skiprest then
declare
line : constant String := JT.USS (topline);
blank8 : constant String := " ";
sx : constant Natural := toplen - 7;
begin
if toplen > 5 and then line (1) = LAT.HT then
-- reason, but only valid if modification is active
if activemod then
if JT.IsBlank (reasons) then
reasons := JT.SUS (JT.part_1 (line (2 .. toplen), " "));
else
JT.SU.Append (reasons, " | ");
JT.SU.Append (reasons, JT.part_1
(line (2 .. toplen), " "));
end if;
end if;
skiprest := True;
end if;
if not skiprest and then line (toplen) = LAT.Colon then
close_active_modifications;
activemod := True;
modport := JT.SUS (line (1 .. toplen - 1));
skiprest := True;
end if;
if not skiprest and then
JT.SU.Slice (topline, sx, toplen) = " changed"
then
close_active_modifications;
activemod := True;
modport := JT.SUS (line (1 .. toplen - 8));
skiprest := True;
end if;
end;
end if;
end loop;
close_active_modifications;
sorter.Sort (Container => changed);
sorter.Sort (Container => missing);
sorter.Sort (Container => leftover);
TIO.Put_Line (trackers (id).log_handle, LAT.LF & "=> Checking for " &
"system changes " & description);
if not leftover.Is_Empty then
passed := False;
TIO.Put_Line (trackers (id).log_handle, LAT.LF &
" Left over files/directories:");
leftover.Iterate (Process => print'Access);
end if;
if not missing.Is_Empty then
passed := False;
TIO.Put_Line (trackers (id).log_handle, LAT.LF &
" Missing files/directories:");
missing.Iterate (Process => print'Access);
end if;
if not changed.Is_Empty then
passed := False;
TIO.Put_Line (trackers (id).log_handle, LAT.LF &
" Modified files/directories:");
changed.Iterate (Process => print'Access);
end if;
if passed then
TIO.Put_Line (trackers (id).log_handle, "Everything is fine.");
end if;
return passed;
end detect_leftovers_and_MIA;
-----------------------------
-- interact_with_builder --
-----------------------------
procedure interact_with_builder (id : builders)
is
root : constant String := get_root (id);
command : constant String := chroot & root &
environment_override (enable_tty => True) &
REP.Platform.interactive_shell;
result : Boolean;
begin
TIO.Put_Line ("Entering interactive test mode at the builder root " &
"directory.");
TIO.Put_Line ("Type 'exit' when done exploring.");
result := Unix.external_command (command);
end interact_with_builder;
---------------------------------
-- obtain_custom_environment --
---------------------------------
procedure obtain_custom_environment
is
target_name : constant String := PM.synth_confdir & "/" &
JT.USS (PM.configuration.profile) & "-environment";
fragment : TIO.File_Type;
begin
customenv := JT.blank;
if AD.Exists (target_name) then
TIO.Open (File => fragment, Mode => TIO.In_File, Name => target_name);
while not TIO.End_Of_File (fragment) loop
declare
Line : String := TIO.Get_Line (fragment);
begin
if JT.contains (Line, "=") then
JT.SU.Append (customenv, JT.trim (Line) & " ");
end if;
end;
end loop;
TIO.Close (fragment);
end if;
exception
when others =>
if TIO.Is_Open (fragment) then
TIO.Close (fragment);
end if;
end obtain_custom_environment;
--------------------------------
-- set_localbase_protection --
--------------------------------
procedure set_localbase_protection (id : builders; lock : Boolean)
is
procedure remount (readonly : Boolean);
procedure dismount;
smount : constant String := get_root (id);
slave_local : constant String := smount & "_localbase";
procedure remount (readonly : Boolean)
is
cmd_freebsd : String := "/sbin/mount_nullfs ";
cmd_dragonfly : String := "/sbin/mount_null ";
points : String := slave_local & " " & smount & REP.root_localbase;
options : String := "-o ro ";
cmd : JT.Text;
cmd_output : JT.Text;
begin
if JT.equivalent (PM.configuration.operating_sys, "FreeBSD") then
cmd := JT.SUS (cmd_freebsd);
else
cmd := JT.SUS (cmd_dragonfly);
end if;
if readonly then
JT.SU.Append (cmd, options);
end if;
JT.SU.Append (cmd, points);
if not Unix.piped_mute_command (JT.USS (cmd), cmd_output) then
if uselog then
TIO.Put_Line (trackers (id).log_handle,
"command failed: " & JT.USS (cmd));
if not JT.IsBlank (cmd_output) then
TIO.Put_Line (trackers (id).log_handle, JT.USS (cmd_output));
end if;
end if;
end if;
end remount;
procedure dismount
is
cmd_unmount : constant String := "/sbin/umount " & smount & REP.root_localbase;
cmd_output : JT.Text;
begin
if not Unix.piped_mute_command (cmd_unmount, cmd_output) then
if uselog then
TIO.Put_Line (trackers (id).log_handle,
"command failed: " & cmd_unmount);
if not JT.IsBlank (cmd_output) then
TIO.Put_Line (trackers (id).log_handle, JT.USS (cmd_output));
end if;
end if;
end if;
end dismount;
begin
if lock then
dismount;
remount (readonly => True);
else
dismount;
remount (readonly => False);
end if;
end set_localbase_protection;
------------------------------
-- timeout_multiplier_x10 --
------------------------------
function timeout_multiplier_x10 return Positive
is
average5 : constant Float := REP.Platform.get_5_minute_load;
avefloat : constant Float := average5 / Float (number_cores);
begin
if avefloat <= 1.0 then
return 10;
else
return Integer (avefloat * 10.0);
end if;
exception
when others => return 10;
end timeout_multiplier_x10;
---------------------------
-- valid_test_phase #2 --
---------------------------
function valid_test_phase (afterphase : String) return Boolean is
begin
if afterphase = "extract" or else
afterphase = "patch" or else
afterphase = "configure" or else
afterphase = "build" or else
afterphase = "stage" or else
afterphase = "install" or else
afterphase = "deinstall"
then
return True;
else
return False;
end if;
end valid_test_phase;
---------------------------
-- builder_status_core --
---------------------------
function builder_status_core (id : builders;
shutdown : Boolean := False;
idle : Boolean := False;
phasestr : String)
return Display.builder_rec
is
result : Display.builder_rec;
phaselen : constant Positive := phasestr'Length;
begin
-- 123456789 123456789 123456789 123456789 1234
-- SL elapsed phase lines origin
-- 01 00:00:00 extract-depends 9999999 www/joe
result.id := id;
result.slavid := JT.zeropad (Natural (id), 2);
result.LLines := (others => ' ');
result.phase := (others => ' ');
result.origin := (others => ' ');
result.shutdown := False;
result.idle := False;
if shutdown then
-- Overrides "idle" if both Shutdown and Idle are True
result.Elapsed := "Shutdown";
result.shutdown := True;
return result;
end if;
if idle then
result.Elapsed := "Idle ";
result.idle := True;
return result;
end if;
declare
catport : constant String :=
get_catport (all_ports (trackers (id).seq_id));
numlines : constant String := format_loglines (trackers (id).loglines);
linehead : constant Natural := 8 - numlines'Length;
begin
result.Elapsed := elapsed_HH_MM_SS (start => trackers (id).head_time,
stop => CAL.Clock);
result.LLines (linehead .. 7) := numlines;
if phaselen <= result.phase'Length then
result.phase (1 .. phasestr'Length) := phasestr;
else
-- special handling for long descriptions
if phasestr = "bootstrap-depends" then
result.phase (1 .. 14) := "bootstrap-deps";
else
result.phase := phasestr
(phasestr'First .. phasestr'First + result.phase'Length - 1);
end if;
end if;
if catport'Length > 37 then
result.origin (1 .. 36) := catport (1 .. 36);
result.origin (37) := LAT.Asterisk;
else
result.origin (1 .. catport'Length) := catport;
end if;
end;
return result;
end builder_status_core;
------------------------
-- port_specification --
------------------------
function port_specification (catport : String) return String is
begin
if JT.contains (catport, "@") then
return dir_ports & "/" & JT.part_1 (catport, "@") &
" FLAVOR=" & JT.part_2 (catport, "@");
else
return dir_ports & "/" & catport;
end if;
end port_specification;
end PortScan.Buildcycle;
|
package body CUPS.CUPS is
----------------
-- GetDefault --
----------------
function GetDefault return String is
V : Chars_Ptr := Cups_Cups_H.CupsGetDefault;
begin
if V /= Null_Ptr then
return Interfaces.C.Strings.Value (V);
else
return "";
end if;
end GetDefault;
---------------
-- PrintFile --
---------------
function PrintFile
(Name : String;
Filename : String;
Title : String;
Num_Options : Job_Id;
Options : Option_T) return Job_Id
is
L_Name : Chars_Ptr := New_String (Name);
L_Filename : Chars_Ptr := New_String (Filename);
L_Title : Chars_Ptr := New_String (Title);
L_Num_Options : Int := Int (Num_Options);
Ret : Int;
begin
Ret := Cups_Cups_H.CupsPrintFile
(Name => L_Name,
Filename => L_Filename,
Title => L_Title,
Num_Options => L_Num_Options,
Options => Options);
Free (L_Name);
Free (L_Filename);
Free (L_Title);
return Job_Id (Ret);
end PrintFile;
---------------
-- CancelJob --
---------------
procedure CancelJob
(Name : String := Cups.GetDefault;
JobId : Integer := -1 )
is
L_Name : Chars_Ptr := New_String (Name);
L_Id : Int := Int (JobId);
Ret : Int;
begin
Ret := Cups_Cups_H.CupsCancelJob
(Name => L_Name,
Job_Id => L_Id);
Free (L_Name);
--return Job_Id (Ret);
end CancelJob;
----------------------------
-- GetDefaultPrinterState --
----------------------------
function GetDefaultPrinterState return String
is
L_State : Chars_Ptr := New_String ("printer-state");
Num_Dests : Int;
Dest : aliased Cups.Destination_T := null;
Destinations : aliased Cups.Destination_T := null;
Ret : Chars_Ptr;
begin
Num_Dests := Cups_Cups_H.CupsGetDests (Destinations'Address);
Dest := Cups_Cups_H.CupsGetDest (Name => Interfaces.C.Strings.Null_Ptr,
Instance => Interfaces.C.Strings.Null_Ptr,
Num_Dests => Num_Dests,
Dests => Destinations);
if Dest /= null then
Ada.Text_IO.Put_Line ("Printer found!: " & Value (Dest.Name));
Ret := Cups_Cups_H.CupsGetOption ( Name => L_State,
Num_Options => Dest.Num_Options,
Options => Dest.Options);
if Ret = Interfaces.C.Strings.Null_Ptr then
return "null";
else
return Value (Ret);
end if;
else
return "null";
end if;
end GetDefaultPrinterState;
--------------------
-- PrintRawString --
--------------------
procedure PrintString ( Str : String; Raw : Boolean)
is
package BS_PS is new Ada.Strings.Bounded.Generic_Bounded_Length (Max => 20);
Num_Options : Job_Id := 0;
Printer_State : BS_PS.Bounded_String;
Id : Job_Id := 0;
Cancel_Job : Job_Id := 0;
Options : aliased Cups.Option_T := null;
Temp_File : Ada.Text_IO.File_Type;
Temp_File_Name : Standard.String := "TempPrintFile.txt";
begin
Printer_State := BS_PS.To_Bounded_String (Cups.GetDefaultPrinterState);
Ada.Text_IO.Put_Line ("Printer state: " & BS_PS.To_String (Printer_State));
-- If a printer queue exists
if BS_PS.To_String (Printer_State) /= "null" then
case Raw is
when True =>
SetRawPrinting (Num_Options => Num_Options,
Options => Options);
when False =>
null;
end case;
-- Create the file for printing
Ada.Text_IO.Create (Temp_File, Ada.Text_IO.Out_File, Temp_File_Name);
Ada.Text_IO.Put_Line (Temp_File, Str);
-- Close before sending to printer
Ada.Text_IO.Close (Temp_File);
-- Print file
Id := Cups.PrintFile (Cups.GetDefault, Temp_File_Name, "Test Print", Num_Options, Options);
-- Did the print succeed?
if Id /= 0 then
Ada.Text_IO.Put_Line ("Printing!");
else
Ada.Text_IO.Put_Line ("Printing failed!");
end if;
else
Ada.Text_IO.Put_Line ("No printer found!");
end if;
end PrintString;
---------------------
-- SetRawPrinting --
---------------------
procedure SetRawPrinting (Num_Options : in out Job_ID;
Options : aliased Option_T) is
begin
Num_Options := Cups.AddOption ("raw", "true", Num_Options, Options);
Num_Options := Cups.AddOption ("usb-no-reattach-default", "true", Num_Options, Options);
end SetRawPrinting;
---------------
-- AddOption --
---------------
function AddOption
(Name : String;
Value : String;
Num_Options : Job_Id;
Options : aliased Option_T) return Job_Id
is
L_Name : Chars_Ptr := New_String (Name);
L_Value : Chars_Ptr := New_String (Value);
L_Num_Options : Int := Int (Num_Options);
Ret : Int;
begin
Ret := Cups_Cups_H.CupsAddOption
(Name => L_Name ,
Value => L_Value,
Num_Options => L_Num_Options,
Options => Options'Address);
Free (L_Name);
Free (L_Value);
return Job_Id (Ret);
end AddOption;
---------------
-- GetOption --
---------------
function GetOption
(Name : String;
Num_Options : Job_Id;
Options : Option_T) return String
is
L_Name : Chars_Ptr := New_String (Name);
L_Num_Options : Int := Int (Num_Options);
Ret : Chars_Ptr;
begin
Ret := Cups_Cups_H.CupsGetOption
(Name => L_Name,
Num_Options => L_Num_Options,
Options => Options);
Free (L_Name);
if Ret = Interfaces.C.Strings.Null_Ptr then
return "null";
else
return Value (Ret);
end if;
end GetOption;
end CUPS.CUPS;
|
with Ahven.Framework;
with Ahven.Text_Runner;
with Test_Aircraft.Append;
with Test_Aircraft.Read;
with Test_Aircraft.Write;
with Test_Annotation.Append;
with Test_Annotation.Read;
with Test_Annotation.Write;
with Test_Null_Annotation.Read;
with Test_Null_Annotation.Write;
with Test_Constants.Write;
with Test_Container.Read;
with Test_Container.Write;
with Test_Date.Append;
with Test_Date.Read;
with Test_Floats.Read;
with Test_Floats.Write;
with Test_Foreign.Read;
with Test_Colored_Nodes.Read;
with Test_Node.Read;
with Test_Subtypes.Append;
with Test_Subtypes.Read;
with Test_Subtypes.Write;
with Test_Unknown.Read;
with Test_Unknown.Write;
procedure Tester is
Suite : Ahven.Framework.Test_Suite := Ahven.Framework.Create_Suite ("All");
begin
Ahven.Framework.Add_Test (Suite, new Test_Aircraft.Append.Test);
Ahven.Framework.Add_Test (Suite, new Test_Aircraft.Read.Test);
Ahven.Framework.Add_Test (Suite, new Test_Aircraft.Write.Test);
Ahven.Framework.Add_Test (Suite, new Test_Annotation.Append.Test);
Ahven.Framework.Add_Test (Suite, new Test_Annotation.Read.Test);
Ahven.Framework.Add_Test (Suite, new Test_Annotation.Write.Test);
Ahven.Framework.Add_Test (Suite, new Test_Null_Annotation.Read.Test);
Ahven.Framework.Add_Test (Suite, new Test_Null_Annotation.Write.Test);
Ahven.Framework.Add_Test (Suite, new Test_Constants.Write.Test);
Ahven.Framework.Add_Test (Suite, new Test_Container.Read.Test);
Ahven.Framework.Add_Test (Suite, new Test_Container.Write.Test);
Ahven.Framework.Add_Test (Suite, new Test_Date.Append.Test);
Ahven.Framework.Add_Test (Suite, new Test_Date.Read.Test);
Ahven.Framework.Add_Test (Suite, new Test_Floats.Read.Test);
Ahven.Framework.Add_Test (Suite, new Test_Floats.Write.Test);
Ahven.Framework.Add_Test (Suite, new Test_Foreign.Read.Test);
Ahven.Framework.Add_Test (Suite, new Test_Colored_Nodes.Read.Test);
Ahven.Framework.Add_Test (Suite, new Test_Node.Read.Test);
Ahven.Framework.Add_Test (Suite, new Test_Subtypes.Append.Test);
Ahven.Framework.Add_Test (Suite, new Test_Subtypes.Read.Test);
Ahven.Framework.Add_Test (Suite, new Test_Subtypes.Write.Test);
Ahven.Framework.Add_Test (Suite, new Test_Unknown.Read.Test);
Ahven.Framework.Add_Test (Suite, new Test_Unknown.Write.Test);
Ahven.Text_Runner.Run (Suite);
end Tester;
|
-- { dg-do run }
with Init2; use Init2;
with Text_IO; use Text_IO;
with Dump;
procedure T2 is
Local_R1 : R1;
Local_R2 : R2;
begin
Local_R1.S1 := My_R1.S1 - 1;
Local_R1.I := My_R1.I + 1;
Local_R1.S2 := My_R1.S2 - 1;
Local_R1.A(1) := My_R1.A(1) mod 16;
Local_R1.A(2) := My_R1.A(2) mod 16;
Local_R1.A(3) := My_R1.A(3) mod 16;
Local_R1.B := not My_R1.B;
Put ("Local_R1 :");
Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R1 : e5 59 d1 48 b0 a0 c1 03.*\n" }
Local_R2.S1 := My_R2.S1 - 1;
Local_R2.I := My_R2.I + 1;
Local_R2.S2 := My_R2.S2 - 1;
Local_R2.A(1) := My_R2.A(1) mod 16;
Local_R2.A(2) := My_R2.A(2) mod 16;
Local_R2.A(3) := My_R2.A(3) mod 16;
Local_R2.B := not My_R2.B;
Put ("Local_R2 :");
Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R2 : 44 8d 15 9e 40 58 34 1e.*\n" }
Local_R1 := (S1 => 2,
I => 16#12345678#,
S2 => 1,
A => (16#AB#, 16#CD#, 16#EF#),
B => True);
Put ("Local_R1 :");
Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R1 : e2 59 d1 48 b4 aa d9 bb.*\n" }
Local_R2 := (S1 => 2,
I => 16#12345678#,
S2 => 1,
A => (16#AB#, 16#CD#, 16#EF#),
B => True);
Put ("Local_R2 :");
Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R2 : 84 8d 15 9e 15 5b 35 df.*\n" }
Local_R1.S1 := Local_R1.S1 - 1;
Local_R1.I := Local_R1.I + 1;
Local_R1.S2 := Local_R1.S2 - 1;
Local_R1.A(1) := Local_R1.A(1) mod 16;
Local_R1.A(2) := Local_R1.A(2) mod 16;
Local_R1.A(3) := Local_R1.A(3) mod 16;
Local_R1.B := not Local_R1.B;
Put ("Local_R1 :");
Dump (Local_R1'Address, R1'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R1 : e5 59 d1 48 b0 a0 c1 03.*\n" }
Local_R2.S1 := Local_R2.S1 - 1;
Local_R2.I := Local_R2.I + 1;
Local_R2.S2 := Local_R2.S2 - 1;
Local_R2.A(1) := Local_R2.A(1) mod 16;
Local_R2.A(2) := Local_R2.A(2) mod 16;
Local_R2.A(3) := Local_R2.A(3) mod 16;
Local_R2.B := not Local_R2.B;
Put ("Local_R2 :");
Dump (Local_R2'Address, R2'Max_Size_In_Storage_Elements);
New_Line;
-- { dg-output "Local_R2 : 44 8d 15 9e 40 58 34 1e.*\n" }
end;
|
-- Copyright (c) 2021 Devin Hill
-- zlib License -- see LICENSE for details.
package body GBA.Numerics.Matrices is
use all type V.Element;
use all type V.Vec;
function Pointwise (N, M : Mat) return Mat is
begin
return
( 0 => ( 0 => Operator (N (0, 0), M (0, 0))
, 1 => Operator (N (0, 1), M (0, 1))
)
, 1 => ( 0 => Operator (N (1, 0), M (1, 0))
, 1 => Operator (N (1, 1), M (1, 1))
)
);
end;
function Scalar (M : Mat; E : Element) return Mat is
begin
return
( 0 => ( 0 => Operator (M (0, 0), E)
, 1 => Operator (M (0, 1), E)
)
, 1 => ( 0 => Operator (M (1, 0), E)
, 1 => Operator (M (1, 1), E)
)
);
end;
function To_Affine_Transform (M : Mat)
return Affine_Transform_Matrix is
begin
return
( DX => Affine_Transform_Parameter (M (0, 0))
, DMX => Affine_Transform_Parameter (M (0, 1))
, DY => Affine_Transform_Parameter (M (1, 0))
, DMY => Affine_Transform_Parameter (M (1, 1))
);
end;
function EMul (X, Y : Element) return Element is
( X * Y ) with Inline_Always;
function EDiv (X, Y : Element) return Element is
( X / Y ) with Inline_Always;
function MAdd is new Pointwise ("+");
function MSub is new Pointwise ("-");
function MMul is new Pointwise (EMul);
function MDiv is new Pointwise (EDiv);
function MAdd is new Scalar ("+");
function MSub is new Scalar ("-");
function MMul is new Scalar (EMul);
function MDiv is new Scalar (EDiv);
function "+" (M, N : Mat) return Mat
renames MAdd;
function "-" (M, N : Mat) return Mat
renames MSub;
function "*" (M, N : Mat) return Mat
renames MMul;
function "/" (M, N : Mat) return Mat
renames MDiv;
function "+" (M : Mat; E : Element) return Mat
renames MAdd;
function "-" (M : Mat; E : Element) return Mat
renames MSub;
function "*" (M : Mat; E : Element) return Mat
renames MMul;
function "/" (M : Mat; E : Element) return Mat
renames MDiv;
function From_Cols (C0, C1 : Vec) return Mat is
begin
return
( 0 => (C0 (0), C1 (0))
, 1 => (C0 (1), C1 (1))
);
end;
function From_Rows (R0, R1 : Vec) return Mat is
begin
return
( 0 => (R0 (0), R0 (1))
, 1 => (R1 (0), R1 (1))
);
end;
function Col (M : Mat; C : Dim) return Vec is
begin
return (M (0, C), M (1, C));
end;
function Row (M : Mat; R : Dim) return Vec is
begin
return (M (R, 0), M (R, 1));
end;
function Mul (M : Mat; V : Vec) return Vec is
begin
return
( 0 => Dot (V, Row (M, 0))
, 1 => Dot (V, Row (M, 1))
);
end;
function Mul (M, N : Mat) return Mat is
begin
return From_Cols
( Mul (M, Col (N, 0))
, Mul (M, Col (N, 1))
);
end;
function Determinant (M : Mat) return Element is
begin
return (M (0, 0) * M (1, 1)) - (M (0, 1) * M (1, 0));
end;
function Inverse (M : Mat) return Mat is
N : Mat :=
( ( M (1, 1), - M (0, 1) )
, ( - M (1, 0), M (0, 0) )
);
begin
return N / Determinant (M);
end;
end GBA.Numerics.Matrices; |
-- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
package Display.Console is
-- These are dummy routines to match active ones in Display.Curses
-- This module is only used to support building ravenadm without curses support
function launch_monitor (num_builders : builders) return Boolean;
procedure terminate_monitor;
procedure summarize (data : summary_rec);
procedure update_builder (BR : builder_rec);
procedure set_full_redraw_next_update;
procedure refresh_builder_window;
procedure refresh_history_window;
end Display.Console;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- M L I B . T G T . S P E C I F I C --
-- (Windows Version) --
-- --
-- B o d y --
-- --
-- Copyright (C) 2002-2010, 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. --
-- --
------------------------------------------------------------------------------
-- This is the Windows version of the body. Works only with GCC versions
-- supporting the "-shared" option.
with Opt;
with Output; use Output;
with MLib.Fil;
with MLib.Utl;
package body MLib.Tgt.Specific is
package Files renames MLib.Fil;
package Tools renames MLib.Utl;
-- Non default subprograms
procedure Build_Dynamic_Library
(Ofiles : Argument_List;
Options : Argument_List;
Interfaces : Argument_List;
Lib_Filename : String;
Lib_Dir : String;
Symbol_Data : Symbol_Record;
Driver_Name : Name_Id := No_Name;
Lib_Version : String := "";
Auto_Init : Boolean := False);
function DLL_Ext return String;
function DLL_Prefix return String;
function Is_Archive_Ext (Ext : String) return Boolean;
function Library_Major_Minor_Id_Supported return Boolean;
function PIC_Option return String;
Shared_Libgcc : aliased String := "-shared-libgcc";
Shared_Libgcc_Switch : constant Argument_List :=
(1 => Shared_Libgcc'Access);
---------------------------
-- Build_Dynamic_Library --
---------------------------
procedure Build_Dynamic_Library
(Ofiles : Argument_List;
Options : Argument_List;
Interfaces : Argument_List;
Lib_Filename : String;
Lib_Dir : String;
Symbol_Data : Symbol_Record;
Driver_Name : Name_Id := No_Name;
Lib_Version : String := "";
Auto_Init : Boolean := False)
is
pragma Unreferenced (Symbol_Data);
pragma Unreferenced (Interfaces);
pragma Unreferenced (Lib_Version);
pragma Unreferenced (Auto_Init);
Lib_File : constant String :=
Lib_Dir & Directory_Separator &
DLL_Prefix & Files.Append_To (Lib_Filename, DLL_Ext);
-- Start of processing for Build_Dynamic_Library
begin
if Opt.Verbose_Mode then
Write_Str ("building relocatable shared library ");
Write_Line (Lib_File);
end if;
Tools.Gcc
(Output_File => Lib_File,
Objects => Ofiles,
Options => Shared_Libgcc_Switch,
Options_2 => Options,
Driver_Name => Driver_Name);
end Build_Dynamic_Library;
-------------
-- DLL_Ext --
-------------
function DLL_Ext return String is
begin
return "dll";
end DLL_Ext;
----------------
-- DLL_Prefix --
----------------
function DLL_Prefix return String is
begin
return "lib";
end DLL_Prefix;
--------------------
-- Is_Archive_Ext --
--------------------
function Is_Archive_Ext (Ext : String) return Boolean is
begin
return Ext = ".a" or else Ext = ".dll";
end Is_Archive_Ext;
--------------------------------------
-- Library_Major_Minor_Id_Supported --
--------------------------------------
function Library_Major_Minor_Id_Supported return Boolean is
begin
return False;
end Library_Major_Minor_Id_Supported;
----------------
-- PIC_Option --
----------------
function PIC_Option return String is
begin
return "";
end PIC_Option;
begin
Build_Dynamic_Library_Ptr := Build_Dynamic_Library'Access;
DLL_Ext_Ptr := DLL_Ext'Access;
DLL_Prefix_Ptr := DLL_Prefix'Access;
Is_Archive_Ext_Ptr := Is_Archive_Ext'Access;
PIC_Option_Ptr := PIC_Option'Access;
Library_Major_Minor_Id_Supported_Ptr :=
Library_Major_Minor_Id_Supported'Access;
end MLib.Tgt.Specific;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Web Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2014-2016, 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$
------------------------------------------------------------------------------
-- Defines an object to provide client request information to a servlet. The
-- servlet container creates a ServletRequest object and passes it as an
-- argument to the servlet's service method.
------------------------------------------------------------------------------
with Ada.Streams;
with League.String_Vectors;
with League.Strings;
with Servlet.Contexts;
package Servlet.Requests is
pragma Preelaborate;
type Servlet_Request is limited interface;
type Servlet_Request_Access is access all Servlet_Request'Class;
not overriding function Get_Input_Stream
(Self : Servlet_Request)
return not null access Ada.Streams.Root_Stream_Type'Class is abstract;
-- Retrieves the body of the request as binary data using a stream.
function Get_Parameter
(Self : Servlet_Request'Class;
Name : League.Strings.Universal_String)
return League.Strings.Universal_String;
-- Returns the value of a request parameter as a String, or empty string if
-- the parameter does not exist. Request parameters are extra information
-- sent with the request. For HTTP servlets, parameters are contained in
-- the query string or posted form data.
--
-- You should only use this method when you are sure the parameter has only
-- one value. If the parameter might have more than one value, use
-- Get_Parameter_Values.
--
-- If you use this method with a multivalued parameter, the value returned
-- is equal to the first value in the array returned by
-- Get_Parameter_Values.
--
-- If the parameter data was sent in the request body, such as occurs with
-- an HTTP POST request, then reading the body directly via
-- Get_Input_Stream or Get_Reader can interfere with the execution of this
-- method.
not overriding function Get_Parameter_Names
(Self : Servlet_Request)
return League.String_Vectors.Universal_String_Vector is abstract;
-- Returns an vector of String containing the names of the parameters
-- contained in this request. If the request has no parameters, the method
-- returns an empty vector.
not overriding function Get_Parameter_Values
(Self : Servlet_Request;
Name : League.Strings.Universal_String)
return League.String_Vectors.Universal_String_Vector is abstract;
-- Returns an array of String objects containing all of the values the
-- given request parameter has, or null if the parameter does not exist.
--
-- If the parameter has a single value, the array has a length of 1.
not overriding function Get_Scheme
(Self : Servlet_Request) return League.Strings.Universal_String
is abstract;
-- Returns the name of the scheme used to make this request, for example,
-- http, https, or ftp. Different schemes have different rules for
-- constructing URLs, as noted in RFC 1738.
not overriding function Get_Server_Name
(Self : Servlet_Request) return League.Strings.Universal_String
is abstract;
-- Returns the host name of the server to which the request was sent. It is
-- the value of the part before ":" in the Host header value, if any, or
-- the resolved server name, or the server IP address.
not overriding function Get_Server_Port
(Self : Servlet_Request) return Positive is abstract;
-- Returns the port number to which the request was sent. It is the value
-- of the part after ":" in the Host header value, if any, or the server
-- port where the client connection was accepted on.
not overriding function Get_Servlet_Context
(Self : Servlet_Request)
return access Servlet.Contexts.Servlet_Context'Class is abstract;
-- Gets the servlet context to which this ServletRequest was last
-- dispatched.
not overriding function Is_Async_Supported
(Self : not null access Servlet_Request) return Boolean is abstract;
-- Checks if this request supports asynchronous operation.
end Servlet.Requests;
|
-----------------------------------------------------------------------
-- keystore-marshallers -- Data marshaller for the keystore
-- Copyright (C) 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 Interfaces.C;
with Ada.Calendar.Conversions;
with Util.Encoders.HMAC.SHA256;
with Util.Encoders.AES;
package body Keystore.Marshallers is
use Interfaces;
-- ------------------------------
-- Set the block header with the tag and wallet identifier.
-- ------------------------------
procedure Set_Header (Into : in out Marshaller;
Tag : in Interfaces.Unsigned_16;
Id : in Keystore.Wallet_Identifier) is
Buf : constant Buffers.Buffer_Accessor := Into.Buffer.Data.Value;
begin
Into.Pos := Block_Index'First + 1;
Buf.Data (Block_Index'First) := Stream_Element (Shift_Right (Tag, 8));
Buf.Data (Block_Index'First + 1) := Stream_Element (Tag and 16#0ff#);
Put_Unsigned_16 (Into, 0);
Put_Unsigned_32 (Into, Interfaces.Unsigned_32 (Id));
Put_Unsigned_32 (Into, 0);
Put_Unsigned_32 (Into, 0);
end Set_Header;
procedure Set_Header (Into : in out Marshaller;
Value : in Interfaces.Unsigned_32) is
Buf : constant Buffers.Buffer_Accessor := Into.Buffer.Data.Value;
begin
Buf.Data (Block_Index'First) := Stream_Element (Shift_Right (Value, 24));
Buf.Data (Block_Index'First + 1) := Stream_Element (Shift_Right (Value, 16) and 16#0ff#);
Buf.Data (Block_Index'First + 2) := Stream_Element (Shift_Right (Value, 8) and 16#0ff#);
Buf.Data (Block_Index'First + 3) := Stream_Element (Value and 16#0ff#);
Into.Pos := Block_Index'First + 3;
end Set_Header;
procedure Put_Unsigned_16 (Into : in out Marshaller;
Value : in Interfaces.Unsigned_16) is
Pos : constant Block_Index := Into.Pos;
Buf : constant Buffers.Buffer_Accessor := Into.Buffer.Data.Value;
begin
Into.Pos := Pos + 2;
Buf.Data (Pos + 1) := Stream_Element (Shift_Right (Value, 8));
Buf.Data (Pos + 2) := Stream_Element (Value and 16#0ff#);
end Put_Unsigned_16;
procedure Put_Unsigned_32 (Into : in out Marshaller;
Value : in Interfaces.Unsigned_32) is
Pos : constant Block_Index := Into.Pos;
Buf : constant Buffers.Buffer_Accessor := Into.Buffer.Data.Value;
begin
Into.Pos := Pos + 4;
Buf.Data (Pos + 1) := Stream_Element (Shift_Right (Value, 24));
Buf.Data (Pos + 2) := Stream_Element (Shift_Right (Value, 16) and 16#0ff#);
Buf.Data (Pos + 3) := Stream_Element (Shift_Right (Value, 8) and 16#0ff#);
Buf.Data (Pos + 4) := Stream_Element (Value and 16#0ff#);
end Put_Unsigned_32;
procedure Put_Unsigned_64 (Into : in out Marshaller;
Value : in Interfaces.Unsigned_64) is
begin
Put_Unsigned_32 (Into, Unsigned_32 (Shift_Right (Value, 32)));
Put_Unsigned_32 (Into, Unsigned_32 (Value and 16#0ffffffff#));
end Put_Unsigned_64;
procedure Put_Kind (Into : in out Marshaller;
Value : in Entry_Type) is
begin
case Value is
when T_INVALID =>
Put_Unsigned_16 (Into, 0);
when T_STRING =>
Put_Unsigned_16 (Into, 1);
when T_BINARY =>
Put_Unsigned_16 (Into, 2);
when T_WALLET =>
Put_Unsigned_16 (Into, 3);
when T_FILE =>
Put_Unsigned_16 (Into, 4);
when T_DIRECTORY =>
Put_Unsigned_16 (Into, 5);
end case;
end Put_Kind;
procedure Put_Block_Number (Into : in out Marshaller;
Value : in Block_Number) is
begin
Put_Unsigned_32 (Into, Interfaces.Unsigned_32 (Value));
end Put_Block_Number;
procedure Put_Block_Index (Into : in out Marshaller;
Value : in Block_Index) is
begin
Put_Unsigned_16 (Into, Interfaces.Unsigned_16 (Value));
end Put_Block_Index;
procedure Put_Buffer_Size (Into : in out Marshaller;
Value : in Buffer_Size) is
begin
Put_Unsigned_16 (Into, Interfaces.Unsigned_16 (Value));
end Put_Buffer_Size;
procedure Put_String (Into : in out Marshaller;
Value : in String) is
Pos : Block_Index;
Buf : constant Buffers.Buffer_Accessor := Into.Buffer.Data.Value;
begin
Put_Unsigned_16 (Into, Value'Length);
Pos := Into.Pos;
Into.Pos := Into.Pos + Value'Length;
for C of Value loop
Pos := Pos + 1;
Buf.Data (Pos) := Character'Pos (C);
end loop;
end Put_String;
procedure Put_Date (Into : in out Marshaller;
Value : in Ada.Calendar.Time) is
Unix_Time : Interfaces.C.long;
begin
Unix_Time := Ada.Calendar.Conversions.To_Unix_Time (Value);
Put_Unsigned_64 (Into, Unsigned_64 (Unix_Time));
end Put_Date;
procedure Put_Storage_Block (Into : in out Marshaller;
Value : in Buffers.Storage_Block) is
begin
Put_Unsigned_32 (Into, Interfaces.Unsigned_32 (Value.Storage));
Put_Unsigned_32 (Into, Interfaces.Unsigned_32 (Value.Block));
end Put_Storage_Block;
procedure Put_Secret (Into : in out Marshaller;
Value : in Secret_Key;
Protect_Key : in Secret_Key;
Protect_IV : in Secret_Key) is
Cipher_Key : Util.Encoders.AES.Encoder;
Last : Stream_Element_Offset;
Pos : constant Block_Index := Into.Pos + 1;
Buf : constant Buffers.Buffer_Accessor := Into.Buffer.Data.Value;
IV : constant Util.Encoders.AES.Word_Block_Type
:= (others => Interfaces.Unsigned_32 (Into.Buffer.Block.Block));
begin
Cipher_Key.Set_Key (Protect_Key, Util.Encoders.AES.CBC);
Cipher_Key.Set_IV (Protect_IV, IV);
Cipher_Key.Set_Padding (Util.Encoders.AES.NO_PADDING);
-- Encrypt the key into the key-slot using the protection key.
Last := Pos + Block_Index (Value.Length) - 1;
Cipher_Key.Encrypt_Secret (Secret => Value,
Into => Buf.Data (Pos .. Last));
Into.Pos := Last;
end Put_Secret;
procedure Put_HMAC_SHA256 (Into : in out Marshaller;
Key : in Secret_Key;
Content : in Ada.Streams.Stream_Element_Array) is
Pos : constant Block_Index := Into.Pos;
Buf : constant Buffers.Buffer_Accessor := Into.Buffer.Data.Value;
begin
Into.Pos := Into.Pos + SIZE_HMAC;
-- Make HMAC-SHA256 signature of the data content before encryption.
Util.Encoders.HMAC.SHA256.Sign (Key => Key,
Data => Content,
Result => Buf.Data (Pos + 1 .. Into.Pos));
end Put_HMAC_SHA256;
procedure Put_UUID (Into : in out Marshaller;
Value : in UUID_Type) is
begin
for I in Value'Range loop
Put_Unsigned_32 (Into, Value (I));
end loop;
end Put_UUID;
function Get_Header (From : in out Marshaller) return Interfaces.Unsigned_32 is
Buf : constant Buffers.Buffer_Accessor := From.Buffer.Data.Value;
begin
From.Pos := Block_Index'First + 3;
return Shift_Left (Unsigned_32 (Buf.Data (Block_Index'First)), 24) or
Shift_Left (Unsigned_32 (Buf.Data (Block_Index'First + 1)), 16) or
Shift_Left (Unsigned_32 (Buf.Data (Block_Index'First + 2)), 8) or
Unsigned_32 (Buf.Data (Block_Index'First + 3));
end Get_Header;
function Get_Header_16 (From : in out Marshaller) return Interfaces.Unsigned_16 is
Buf : constant Buffers.Buffer_Accessor := From.Buffer.Data.Value;
begin
From.Pos := Block_Index'First + 1;
return Shift_Left (Unsigned_16 (Buf.Data (Block_Index'First)), 8) or
Unsigned_16 (Buf.Data (Block_Index'First + 1));
end Get_Header_16;
function Get_Unsigned_16 (From : in out Marshaller) return Interfaces.Unsigned_16 is
Pos : constant Block_Index := From.Pos;
Buf : constant Buffers.Buffer_Accessor := From.Buffer.Data.Value;
begin
From.Pos := Pos + 2;
return Shift_Left (Unsigned_16 (Buf.Data (Pos + 1)), 8) or
Unsigned_16 (Buf.Data (Pos + 2));
end Get_Unsigned_16;
function Get_Unsigned_32 (From : in out Marshaller) return Interfaces.Unsigned_32 is
Pos : constant Block_Index := From.Pos;
Buf : constant Buffers.Buffer_Accessor := From.Buffer.Data.Value;
begin
From.Pos := Pos + 4;
return Shift_Left (Unsigned_32 (Buf.Data (Pos + 1)), 24) or
Shift_Left (Unsigned_32 (Buf.Data (Pos + 2)), 16) or
Shift_Left (Unsigned_32 (Buf.Data (Pos + 3)), 8) or
Unsigned_32 (Buf.Data (Pos + 4));
end Get_Unsigned_32;
function Get_Unsigned_64 (From : in out Marshaller) return Interfaces.Unsigned_64 is
High : constant Interfaces.Unsigned_32 := Get_Unsigned_32 (From);
Low : constant Interfaces.Unsigned_32 := Get_Unsigned_32 (From);
begin
return Shift_Left (Unsigned_64 (High), 32) or Unsigned_64 (Low);
end Get_Unsigned_64;
function Get_Storage_Block (From : in out Marshaller) return Buffers.Storage_Block is
Storage : constant Interfaces.Unsigned_32 := Get_Unsigned_32 (From);
Block : constant Interfaces.Unsigned_32 := Get_Unsigned_32 (From);
begin
return Buffers.Storage_Block '(Storage => Buffers.Storage_Identifier (Storage),
Block => Block_Number (Block));
end Get_Storage_Block;
procedure Get_String (From : in out Marshaller;
Result : in out String) is
Pos : Block_Index := From.Pos;
Buf : constant Buffers.Buffer_Accessor := From.Buffer.Data.Value;
begin
From.Pos := From.Pos + Block_Index (Result'Length);
for I in Result'Range loop
Pos := Pos + 1;
Result (I) := Character'Val (Buf.Data (Pos));
end loop;
end Get_String;
function Get_Date (From : in out Marshaller) return Ada.Calendar.Time is
Unix_Time : constant Unsigned_64 := Get_Unsigned_64 (From);
begin
return Ada.Calendar.Conversions.To_Ada_Time (Interfaces.C.long (Unix_Time));
end Get_Date;
function Get_Kind (From : in out Marshaller) return Entry_Type is
Value : constant Unsigned_16 := Get_Unsigned_16 (From);
begin
case Value is
when 0 =>
return T_INVALID;
when 1 =>
return T_STRING;
when 2 =>
return T_BINARY;
when 3 =>
return T_WALLET;
when 4 =>
return T_FILE;
when 5 =>
return T_DIRECTORY;
when others =>
return T_INVALID;
end case;
end Get_Kind;
procedure Get_Secret (From : in out Marshaller;
Secret : out Secret_Key;
Protect_Key : in Secret_Key;
Protect_IV : in Secret_Key) is
Decipher_Key : Util.Encoders.AES.Decoder;
Last : Stream_Element_Offset;
Pos : constant Block_Index := From.Pos + 1;
Buf : constant Buffers.Buffer_Accessor := From.Buffer.Data.Value;
IV : constant Util.Encoders.AES.Word_Block_Type
:= (others => Interfaces.Unsigned_32 (From.Buffer.Block.Block));
begin
Decipher_Key.Set_Key (Protect_Key, Util.Encoders.AES.CBC);
Decipher_Key.Set_IV (Protect_IV, IV);
Decipher_Key.Set_Padding (Util.Encoders.AES.NO_PADDING);
Last := Pos + Block_Index (Secret.Length) - 1;
Decipher_Key.Decrypt_Secret (Data => Buf.Data (Pos .. Last),
Secret => Secret);
From.Pos := Last;
end Get_Secret;
procedure Get_UUID (From : in out Marshaller;
UUID : out UUID_Type) is
begin
for I in UUID'Range loop
UUID (I) := Marshallers.Get_Unsigned_32 (From);
end loop;
end Get_UUID;
procedure Get_Data (From : in out Marshaller;
Size : in Ada.Streams.Stream_Element_Offset;
Data : out Ada.Streams.Stream_Element_Array;
Last : out Ada.Streams.Stream_Element_Offset) is
Buf : constant Buffers.Buffer_Accessor := From.Buffer.Data.Value;
Pos : constant Block_Index := From.Pos + 1;
begin
Last := Data'First + Size - 1;
Data (Data'First .. Last) := Buf.Data (Pos .. Pos + Size - 1);
From.Pos := Pos + Size - 1;
end Get_Data;
procedure Skip (From : in out Marshaller;
Count : in Block_Index) is
begin
From.Pos := From.Pos + Count;
end Skip;
end Keystore.Marshallers;
|
-- Motherlode
-- Copyright (c) 2020 Fabien Chouteau
with HAL; use HAL;
with Pygamer; use Pygamer;
with Pygamer.Screen;
with Render; use Render;
package body HUD is
----------------
-- Draw_Gauge --
----------------
procedure Draw_Gauge (FB : in out HAL.UInt16_Array;
Y : Natural;
C : Character;
Color : UInt16;
Value, Max : Natural)
is
begin
Draw_Char (FB, C, 0, Y);
Draw_H_Line(FB, 9, Y + 1, Max + 1, Color); -- Top
Draw_H_Line(FB, 9, Y + 6, Max + 1, Color); -- Bottom
for H in Y + 2 .. Y + 5 loop
Draw_H_Line(FB, 9, H, Value, Color); -- Content
FB (9 + Max + 1 + H * Screen.Width) := Color; -- Right border of the box
end loop;
end Draw_Gauge;
----------
-- Draw --
----------
procedure Draw
(FB : in out Render.Frame_Buffer;
Money,
Fuel, Fuel_Max,
Cargo, Cargo_Max : Natural;
Depth, Cash_In : Integer)
is
Fuel_Color : constant UInt16 := RGB565 (204, 102, 0);
Cargo_Color : constant UInt16 := RGB565 (0, 102, 204);
begin
Draw_Gauge (FB, 0, 'F', Fuel_Color, Fuel, Fuel_Max);
Draw_Gauge (FB, 9, 'C', Cargo_Color, Cargo, Cargo_Max);
if Cargo = Cargo_Max then
Draw_String_Center (FB, "CARGO FULL", Screen.Width / 2, 90);
end if;
if Fuel = 0 then
Draw_String_Center (FB, "LOW FUEL", Screen.Width / 2, 100);
end if;
declare
Str : String := Money'Img;
begin
Str (Str'First) := '$';
Draw_String (FB, Str,
Screen.Width - Str'Length * 8,
1);
end;
if Cash_In /= 0 then
declare
Str : String := Cash_In'Img;
begin
if Cash_In > 0 then
Str (Str'First) := '+';
end if;
Draw_String (FB, Str,
Screen.Width - Str'Length * 8,
9);
end;
end if;
declare
Str : constant String := Depth'Img;
begin
Draw_String (FB, Str,
Screen.Width - Str'Length * 8,
Screen.Height - 9);
end;
end Draw;
end HUD;
|
-- { dg-do compile }
-- { dg-options "-gnatws" }
package body interface5 is
function F (Object : Child) return access Child is
begin
return null;
end F;
end interface5;
|
package body NXP.Board is
procedure Initialize_Board
is
Configuration : GPIO_Port_Configuration;
begin
Enable_Clock (LEDs);
Configuration.Mode := Mode_Out;
Configuration.Output_Type := Push_Pull;
Configuration.Speed := Speed_Low;
Configuration.Resistors := Floating;
Configure_IO (LEDs,
Config => Configuration);
for Point of LEDs loop
Turn_Off (Point);
end loop;
end Initialize_Board;
end NXP.Board;
|
-----------------------------------------------------------------------
-- util-http-clients-tests -- Unit tests for HTTP client
-- Copyright (C) 2012 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Unchecked_Deallocation;
with Util.Test_Caller;
with Util.Strings.Transforms;
with Util.Http.Tools;
with Util.Strings;
with Util.Log.Loggers;
package body Util.Http.Clients.Tests is
-- The logger
Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Util.Http.Clients.Tests");
package body Http_Tests is
package Caller is new Util.Test_Caller (Http_Test, "Http-" & NAME);
procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is
begin
Caller.Add_Test (Suite, "Test Util.Http.Clients." & NAME & ".Get",
Test_Http_Get'Access);
Caller.Add_Test (Suite, "Test Util.Http.Clients." & NAME & ".Post",
Test_Http_Post'Access);
end Add_Tests;
overriding
procedure Set_Up (T : in out Http_Test) is
begin
Test (T).Set_Up;
Register;
end Set_Up;
end Http_Tests;
overriding
procedure Set_Up (T : in out Test) is
begin
Log.Info ("Starting test server");
T.Server := new Test_Server;
T.Server.Start;
end Set_Up;
overriding
procedure Tear_Down (T : in out Test) is
procedure Free is
new Ada.Unchecked_Deallocation (Object => Test_Server'Class,
Name => Test_Server_Access);
begin
if T.Server /= null then
Log.Info ("Stopping test server");
T.Server.Stop;
Free (T.Server);
T.Server := null;
end if;
end Tear_Down;
-- ------------------------------
-- Process the line received by the server.
-- ------------------------------
overriding
procedure Process_Line (Into : in out Test_Server;
Line : in Ada.Strings.Unbounded.Unbounded_String;
Stream : in out Util.Streams.Texts.Reader_Stream'Class;
Client : in out Util.Streams.Sockets.Socket_Stream'Class) is
L : constant String := Ada.Strings.Unbounded.To_String (Line);
Pos : Natural := Util.Strings.Index (L, ' ');
begin
if Pos > 0 and Into.Method = UNKNOWN then
if L (L'First .. Pos - 1) = "GET" then
Into.Method := GET;
elsif L (L'First .. Pos - 1) = "POST" then
Into.Method := POST;
else
Into.Method := UNKNOWN;
end if;
end if;
Pos := Util.Strings.Index (L, ':');
if Pos > 0 then
if L (L'First .. Pos) = "Content-Type:" then
Into.Content_Type
:= Ada.Strings.Unbounded.To_Unbounded_String (L (Pos + 2 .. L'Last - 2));
elsif L (L'First .. Pos) = "Content-Length:" then
Into.Length := Natural'Value (L (Pos + 1 .. L'Last - 2));
end if;
end if;
if L'Length = 2 and then Into.Length > 0 then
for I in 1 .. Into.Length loop
declare
C : Character;
begin
Stream.Read (C);
Ada.Strings.Unbounded.Append (Into.Result, C);
end;
end loop;
declare
Output : Util.Streams.Texts.Print_Stream;
begin
Output.Initialize (Client'Unchecked_Access);
Output.Write ("HTTP/1.1 200 Found" & ASCII.CR & ASCII.LF);
Output.Write ("Content-Length: 4" & ASCII.CR & ASCII.LF);
Output.Write (ASCII.CR & ASCII.LF);
Output.Write ("OK" & ASCII.CR & ASCII.LF);
Output.Flush;
end;
end if;
Log.Info ("Received: {0}", L);
end Process_Line;
-- ------------------------------
-- Get the test server base URI.
-- ------------------------------
function Get_Uri (T : in Test) return String is
begin
return "http://" & T.Server.Get_Host & ":" & Util.Strings.Image (T.Server.Get_Port);
end Get_Uri;
-- ------------------------------
-- Test the http Get operation.
-- ------------------------------
procedure Test_Http_Get (T : in out Test) is
Request : Client;
Reply : Response;
begin
Request.Get ("http://www.google.com", Reply);
T.Assert (Reply.Get_Status = 200 or Reply.Get_Status = 302,
"Get status is invalid: " & Natural'Image (Reply.Get_Status));
Util.Http.Tools.Save_Response (Util.Tests.Get_Test_Path ("http_get.txt"), Reply, True);
-- Check the content.
declare
Content : constant String := Util.Strings.Transforms.To_Lower_Case (Reply.Get_Body);
begin
Util.Tests.Assert_Matches (T, ".*html.*", Content, "Invalid GET content");
end;
-- Check one header.
declare
Content : constant String := Reply.Get_Header ("Content-Type");
begin
T.Assert (Content'Length > 0, "Empty Content-Type header");
Util.Tests.Assert_Matches (T, ".*text/html.*", Content, "Invalid content type");
end;
end Test_Http_Get;
-- ------------------------------
-- Test the http POST operation.
-- ------------------------------
procedure Test_Http_Post (T : in out Test) is
Request : Client;
Reply : Response;
Uri : constant String := T.Get_Uri;
begin
Log.Info ("Post on " & Uri);
T.Server.Method := UNKNOWN;
Request.Post (Uri & "/post",
"p1=1", Reply);
T.Assert (T.Server.Method = POST, "Invalid method received by server");
Util.Tests.Assert_Equals (T, "application/x-www-form-urlencoded", T.Server.Content_Type,
"Invalid content type received by server");
Util.Tests.Assert_Equals (T, "OK" & ASCII.CR & ASCII.LF, Reply.Get_Body, "Invalid response");
Util.Http.Tools.Save_Response (Util.Tests.Get_Test_Path ("http_post.txt"), Reply, True);
end Test_Http_Post;
end Util.Http.Clients.Tests;
|
-- Generated at 2017-03-29 14:57:31 +0000 by Natools.Static_Hash_Maps
-- from src/natools-web-sites-maps.sx
with Natools.Static_Maps.Web.Sites.Commands;
package body Natools.Static_Maps.Web.Sites is
function To_Command (Key : String) return Command is
N : constant Natural
:= Natools.Static_Maps.Web.Sites.Commands.Hash (Key);
begin
if Map_1_Keys (N).all = Key then
return Map_1_Elements (N);
else
return Error;
end if;
end To_Command;
end Natools.Static_Maps.Web.Sites;
|
-----------------------------------------------------------------------
-- security-policies-roles -- Role based policies
-- Copyright (C) 2010, 2011, 2012, 2017, 2018 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Ada.Strings.Unbounded;
-- == Role Based Security Policy ==
-- The `Security.Policies.Roles` package implements a role based security policy.
-- In this policy, users are assigned one or several roles and permissions are
-- associated with roles. A permission is granted if the user has one of the roles required
-- by the permission.
--
-- === Policy creation ===
-- An instance of the `Role_Policy` must be created and registered in the policy manager.
-- Get or declare the following variables:
--
-- Manager : Security.Policies.Policy_Manager;
-- Policy : Security.Policies.Roles.Role_Policy_Access;
--
-- Create the role policy and register it in the policy manager as follows:
--
-- Policy := new Role_Policy;
-- Manager.Add_Policy (Policy.all'Access);
--
-- === Policy Configuration ===
-- A role is represented by a name in security configuration files. A role based permission
-- is associated with a list of roles. The permission is granted if the user has one of these
-- roles. When the role based policy is registered in the policy manager, the following
-- XML configuration is used:
--
-- <policy-rules>
-- <security-role>
-- <role-name>admin</role-name>
-- </security-role>
-- <security-role>
-- <role-name>manager</role-name>
-- </security-role>
-- <role-permission>
-- <name>create-workspace</name>
-- <role>admin</role>
-- <role>manager</role>
-- </role-permission>
-- ...
-- </policy-rules>
--
-- This definition declares two roles: `admin` and `manager`
-- It defines a permission `create-workspace` that will be granted if the
-- user has either the `admin` or the `manager` role.
--
-- Each role is identified by a name in the configuration file. It is represented by
-- a `Role_Type`. To provide an efficient implementation, the `Role_Type`
-- is represented as an integer with a limit of 64 different roles.
--
-- === Assigning roles to users ===
-- A `Security_Context` must be associated with a set of roles before checking the
-- permission. This is done by using the `Set_Role_Context` operation:
--
-- Security.Policies.Roles.Set_Role_Context (Security.Contexts.Current, "admin");
--
package Security.Policies.Roles is
NAME : constant String := "Role-Policy";
-- Each role is represented by a <b>Role_Type</b> number to provide a fast
-- and efficient role check.
type Role_Type is new Natural range 0 .. 63;
for Role_Type'Size use 8;
type Role_Type_Array is array (Positive range <>) of Role_Type;
type Role_Name_Array is array (Positive range <>) of Ada.Strings.Unbounded.String_Access;
-- The <b>Role_Map</b> represents a set of roles which are assigned to a user.
-- Each role is represented by a boolean in the map. The implementation is limited
-- to 64 roles (the number of different permissions can be higher).
type Role_Map is array (Role_Type'Range) of Boolean;
pragma Pack (Role_Map);
-- Get the number of roles set in the map.
function Get_Count (Map : in Role_Map) return Natural;
-- Return the list of role names separated by ','.
function To_String (List : in Role_Name_Array) return String;
-- ------------------------------
-- Role principal context
-- ------------------------------
-- The <tt>Role_Principal_Context</tt> interface must be implemented by the user
-- <tt>Principal</tt> to be able to use the role based policy. The role based policy
-- controller will first check that the <tt>Principal</tt> implements that interface.
-- It uses the <tt>Get_Roles</tt> function to get the current roles assigned to the user.
type Role_Principal_Context is limited interface;
function Get_Roles (User : in Role_Principal_Context) return Role_Map is abstract;
-- ------------------------------
-- Policy context
-- ------------------------------
-- The <b>Role_Policy_Context</b> gives security context information that the role
-- based policy can use to verify the permission.
type Role_Policy_Context is new Policy_Context with record
Roles : Role_Map;
end record;
type Role_Policy_Context_Access is access all Role_Policy_Context'Class;
-- Set the roles which are assigned to the user in the security context.
-- The role policy will use these roles to verify a permission.
procedure Set_Role_Context (Context : in out Security.Contexts.Security_Context'Class;
Roles : in Role_Map);
-- Set the roles which are assigned to the user in the security context.
-- The role policy will use these roles to verify a permission.
procedure Set_Role_Context (Context : in out Security.Contexts.Security_Context'Class;
Roles : in String);
-- ------------------------------
-- Role based policy
-- ------------------------------
type Role_Policy is new Policy with private;
type Role_Policy_Access is access all Role_Policy'Class;
Invalid_Name : exception;
-- Get the policy name.
overriding
function Get_Name (From : in Role_Policy) return String;
-- Find the role type associated with the role name identified by <b>Name</b>.
-- Raises <b>Invalid_Name</b> if there is no role type.
function Find_Role (Manager : in Role_Policy;
Name : in String) return Role_Type;
-- Get the role name.
function Get_Role_Name (Manager : in Role_Policy;
Role : in Role_Type) return String;
-- Get the roles that grant the given permission.
function Get_Grants (Manager : in Role_Policy;
Permission : in Permissions.Permission_Index) return Role_Map;
-- Get the list of role names that are defined by the role map.
function Get_Role_Names (Manager : in Role_Policy;
Map : in Role_Map) return Role_Name_Array;
-- Create a role
procedure Create_Role (Manager : in out Role_Policy;
Name : in String;
Role : out Role_Type);
-- Get or add a role type for the given name.
procedure Add_Role_Type (Manager : in out Role_Policy;
Name : in String;
Result : out Role_Type);
-- Set the roles specified in the <tt>Roles</tt> parameter. Each role is represented by
-- its name and multiple roles are separated by ','.
-- Raises Invalid_Name if a role was not found.
procedure Set_Roles (Manager : in Role_Policy;
Roles : in String;
Into : out Role_Map);
-- Setup the XML parser to read the <b>role-permission</b> description.
overriding
procedure Prepare_Config (Policy : in out Role_Policy;
Mapper : in out Util.Serialize.Mappers.Processing);
-- Finalize the policy manager.
overriding
procedure Finalize (Policy : in out Role_Policy);
-- Get the role policy associated with the given policy manager.
-- Returns the role policy instance or null if it was not registered in the policy manager.
function Get_Role_Policy (Manager : in Security.Policies.Policy_Manager'Class)
return Role_Policy_Access;
private
-- Array to map a permission index to a list of roles that are granted the permission.
type Permission_Role_Array is array (Permission_Index) of Role_Map;
type Role_Map_Name_Array is array (Role_Type'Range) of Ada.Strings.Unbounded.String_Access;
type Role_Policy is new Policy with record
Names : Role_Map_Name_Array := (others => null);
Next_Role : Role_Type := Role_Type'First;
Name : Util.Beans.Objects.Object;
Roles : Role_Type_Array (1 .. Integer (Role_Type'Last)) := (others => 0);
Count : Natural := 0;
-- The Grants array indicates for each permission the list of roles
-- that are granted the permission. This array allows a O(1) lookup.
-- The implementation is limited to 256 permissions and 64 roles so this array uses 2K.
-- The default is that no role is assigned to the permission.
Grants : Permission_Role_Array := (others => (others => False));
end record;
end Security.Policies.Roles;
|
-- The Beer-Ware License (revision 42)
--
-- Jacob Sparre Andersen <jacob@jacob-sparre.dk> wrote this. As long as you
-- retain this notice you can do whatever you want with this stuff. If we meet
-- some day, and you think this stuff is worth it, you can buy me a beer in
-- return.
--
-- Jacob Sparre Andersen
with Ada.Text_IO, Ada.Text_IO.Text_Streams;
with Sound.Mono;
procedure Microphone_To_WAV is
type Double_Word is mod 2 ** 32;
for Double_Word'Size use 32;
type Word is mod 2 ** 16;
for Word'Size use 16;
type Byte is mod 2 ** 8;
for Byte'Size use 8;
function Little_Endian return Boolean;
-- Checks if we are running on a little-endian architecture.
function Little_Endian return Boolean is
type Word_As_Bytes is array (1 .. 2) of Byte;
for Word_As_Bytes'Size use 16;
As_Word : Word := 11 * 256 + 42;
As_Bytes : Word_As_Bytes;
for As_Bytes'Address use As_Word'Address;
begin
As_Word := 42 + 256 * 11;
return As_Bytes = (42, 11);
end Little_Endian;
Microphone : Sound.Mono.Line_Type;
Resolution : Sound.Sample_Frequency := 44_100;
Buffer_Size : Duration := 0.5;
Period : Duration := 0.1;
Recording : Sound.Mono.Frame_Array (1 .. 44_100 * 10);
Filled_To : Natural;
Target : Ada.Text_IO.Text_Streams.Stream_Access;
begin
if not Little_Endian then
Ada.Text_IO.Put_Line (File => Ada.Text_IO.Standard_Error,
Item => "Big endian is too messy.");
return;
end if;
Sound.Mono.Open (Line => Microphone,
Mode => Sound.Input,
Resolution => Resolution,
Buffer_Size => Buffer_Size,
Period => Period);
Ada.Text_IO.Put_Line
(File => Ada.Text_IO.Standard_Error,
Item => "Resolution [samples/s]: " &
Sound.Sample_Frequency'Image (Resolution));
Ada.Text_IO.Put_Line
(File => Ada.Text_IO.Standard_Error,
Item => "Buffer size [s]: " & Duration'Image (Buffer_Size));
Ada.Text_IO.Put_Line
(File => Ada.Text_IO.Standard_Error,
Item => "Period [s]: " & Duration'Image (Period));
Target := Ada.Text_IO.Text_Streams.Stream (Ada.Text_IO.Standard_Output);
-- RIFF Chunk
String'Write (Target, "RIFF");
Double_Word'Write (Target, 4 + 24 + 8 + 2 * Double_Word (Recording'Length));
String'Write (Target, "WAVE");
-- FORMAT Chunk
String'Write (Target, "fmt ");
Double_Word'Write (Target, 16);
Word'Write (Target, 1);
Word'Write (Target, 1);
Double_Word'Write (Target, Double_Word (Resolution));
Double_Word'Write (Target, 2 * Double_Word (Resolution));
Word'Write (Target, 2);
Word'Write (Target, 16);
-- DATA Chunk
String'Write (Target, "data");
Double_Word'Write (Target, 2 * Double_Word (Recording'Length));
Sound.Mono.Read (Line => Microphone,
Item => Recording,
Last => Filled_To);
Sound.Mono.Frame_Array'Write
(Target, Recording (Recording'First .. Filled_To));
Sound.Mono.Close (Line => Microphone);
end Microphone_To_WAV;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUNTIME COMPONENTS --
-- --
-- S Y S T E M . E X N _ G E N --
-- --
-- S p e c --
-- --
-- $Revision: 2 $ --
-- --
-- Copyright (c) 1992,1993,1994 NYU, All Rights Reserved --
-- --
-- The GNAT library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU Library General Public License as published by --
-- the Free Software Foundation; either version 2, or (at your option) any --
-- later version. The GNAT library is distributed in the hope that it will --
-- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty --
-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- Library General Public License for more details. You should have --
-- received a copy of the GNU Library General Public License along with --
-- the GNAT library; see the file COPYING.LIB. If not, write to the Free --
-- Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. --
-- --
------------------------------------------------------------------------------
-- This package contains the generic functions which are instantiated with
-- predefined integer and real types to generate the runtime exponentiation
-- functions called by expanded code generated by Expand_Op_Expon. This
-- version of the package contains routines that are compiled with overflow
-- checks suppressed, so they are called for exponentiation operations which
-- do not require overflow checking
package System.Exn_Gen is
pragma Pure (System.Exn_Gen);
-- Exponentiation for float types (checks off)
generic
type Type_Of_Base is digits <>;
function Exn_Float_Type
(Left : Type_Of_Base; Right : Integer) return Type_Of_Base;
-- Exponentiation for signed integer base
generic
type Type_Of_Base is range <>;
function Exn_Integer_Type
(Left : Type_Of_Base; Right : Natural) return Type_Of_Base;
end System.Exn_Gen;
|
-- part of AdaYaml, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "copying.txt"
with Ada.Text_IO;
with AUnit.Assertions; use AUnit.Assertions;
package body Text.Chunk_Test is
procedure Register_Tests (T : in out TC) is
use AUnit.Test_Cases.Registration;
begin
Register_Routine
(T, Test_One_String'Access, "One string");
Register_Routine
(T, Test_Two_Strings'Access, "Two strings");
end Register_Tests;
procedure Set_Up (T : in out TC) is
begin
T.P.Create (128);
end Set_Up;
function Name (T : TC) return Message_String is
pragma Unreferenced (T);
begin
return AUnit.Format ("Chunk tests for String_Pool");
end Name;
procedure Test_One_String (T : in out Test_Cases.Test_Case'Class) is
Test_Data : constant String := "123456";
C : constant Reference := TC (T).P.From_String (Test_Data);
begin
Ada.Text_IO.Put_Line ("Test one string, chunk content:");
Ada.Text_IO.Put_Line (TC (T).P.Current_Chunk_As_String);
Assert (C = Test_Data, "Data mismatch!");
declare
C2 : constant Reference := C;
begin
Ada.Text_IO.Put_Line ("Range after copy: (" & C2.Data.all'First'Img &
" .." & C2.Data.all'Last'Img & ')');
end;
end Test_One_String;
procedure Test_Two_Strings (T : in out Test_Cases.Test_Case'Class) is
S1 : constant String := "aaaa";
S2 : constant String := "bbbb";
C1 : constant Reference := TC (T).P.From_String (S1);
C2 : constant Reference := TC (T).P.From_String (S2);
begin
Ada.Text_IO.Put_Line ("Test two strings, chunk content:");
Ada.Text_IO.Put_Line (TC (T).P.Current_Chunk_As_String);
Assert (C1 = S1, "S1 mismatch, is " & C1);
Assert (C2 = S2, "S2 mismatch!");
end Test_Two_Strings;
end Text.Chunk_Test;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
with STM32.Device; use STM32.Device;
with STM32.GPIO; use STM32.GPIO;
use STM32; -- for base addresses
with STM32.SPI;
with STM32.Timers; use STM32.Timers;
with STM32.DMA;
with STM32.I2C; use STM32.I2C;
with STM32.USARTs; use STM32.USARTs;
with HAL.UART;
package OpenMV is
pragma Elaborate_Body;
type LED_Color is (White, Red, Green, Blue, Magenta, Cyan, Yellow, Off);
Image_Width : constant := 128;
Image_Height : constant := 160;
subtype Width is Natural range 0 .. Image_Width - 1;
subtype Height is Natural range 0 .. Image_Height - 1;
procedure Initialize_LEDs;
-- MUST be called prior to any use of the LEDs
procedure Set_RGB_LED (C : LED_Color);
-- Set color of the RGB LED on the board
procedure Turn_On_IR;
-- Turn on infrared LEDs on the board
procedure Turn_Off_IR;
-- Turn off infrared LEDs on the board
procedure Initialize_Shield_SPI;
-- Initialize the SPI port available for shields (SPI2)
procedure Initialize_Shield_USART (Baud : STM32.USARTs.Baud_Rates);
-- Initialize the USART port available for shields (USART3)
function Get_Shield_USART return not null HAL.UART.Any_UART_Port;
-- Get the USART port available for shields (USART3)
Shield_MOSI : GPIO_Point renames PB15;
Shield_MISO : GPIO_Point renames PB14;
Shield_SCK : GPIO_Point renames PB13;
Shield_SEL : GPIO_Point renames PB12;
Shield_TXD : GPIO_Point renames PB10;
Shield_RXD : GPIO_Point renames PB11;
Shield_ADC : GPIO_Point renames PA5;
Shield_SWC : GPIO_Point renames PA14;
Shield_SWD : GPIO_Point renames PA13;
Shield_PWM1 : GPIO_Point renames PD12;
Shield_PWM2 : GPIO_Point renames PD13;
private
--------------
-- LED Pins --
--------------
Red_LED : GPIO_Point renames PC0;
Blue_LED : GPIO_Point renames PC1;
Green_LED : GPIO_Point renames PC2;
IR_LED : GPIO_Point renames PE2;
All_LEDs : constant GPIO_Points := (Red_LED, Blue_LED, Green_LED, IR_LED);
---------------
-- SPI2 Pins --
---------------
SPI2_SCK : GPIO_Point renames PB13;
SPI2_MISO : GPIO_Point renames PB14;
SPI2_MOSI : GPIO_Point renames PB15;
SPI2_NSS : GPIO_Point renames PB12;
Shield_SPI : STM32.SPI.SPI_Port renames STM32.Device.SPI_2;
Shield_SPI_Points : constant STM32.GPIO.GPIO_Points :=
(Shield_MISO,
Shield_MOSI,
Shield_SCK);
------------
-- USART3 --
------------
USART_3_TX : GPIO_Point renames PB10;
USART_3_RX : GPIO_Point renames PB11;
Shield_USART : USART renames USART_3;
Shield_USART_Points : constant STM32.GPIO.GPIO_Points :=
(USART_3_TX,
USART_3_RX);
Shield_USART_AF : constant GPIO_Alternate_Function := GPIO_AF_USART3_7;
---------------
-- I2C1 Pins --
---------------
Sensor_I2C : I2C_Port renames I2C_1;
Sensor_I2C_SCL : GPIO_Point renames PB8;
Sensor_I2C_SDA : GPIO_Point renames PB9;
Sensor_I2C_AF : GPIO_Alternate_Function renames GPIO_AF_I2C1_4;
-----------------
-- Sensor DMA --
-----------------
Sensor_DMA : STM32.DMA.DMA_Controller renames DMA_2;
Sensor_DMA_Chan : STM32.DMA.DMA_Channel_Selector renames
STM32.DMA.Channel_1;
Sensor_DMA_Stream : STM32.DMA.DMA_Stream_Selector renames
STM32.DMA.Stream_1;
---------------
-- I2C2 Pins --
---------------
I2C2_SCL : GPIO_Point renames PB10;
I2C2_SDA : GPIO_Point renames PB11;
---------------
-- DCMI Pins --
---------------
DCMI_HSYNC : GPIO_Point renames PA4;
DCMI_PCLK : GPIO_Point renames PA6;
DCMI_RST : GPIO_Point renames PA10;
DCMI_PWDN : GPIO_Point renames PB5;
DCMI_VSYNC : GPIO_Point renames PB7;
DCMI_D0 : GPIO_Point renames PC6;
DCMI_D1 : GPIO_Point renames PC7;
DCMI_D2 : GPIO_Point renames PE0;
DCMI_D3 : GPIO_Point renames PE1;
DCMI_D4 : GPIO_Point renames PE4;
DCMI_D5 : GPIO_Point renames PB6;
DCMI_D6 : GPIO_Point renames PE5;
DCMI_D7 : GPIO_Point renames PE6;
FS_IN : GPIO_Point renames PD3;
SENSOR_CLK_IO : GPIO_Point renames PA8;
SENSOR_CLK_AF : GPIO_Alternate_Function renames GPIO_AF_TIM1_1;
SENSOR_CLK_TIM : STM32.Timers.Timer renames Timer_1;
SENSOR_CLK_CHAN : constant Timer_Channel := Channel_1;
SENSOR_CLK_FREQ : constant := 12_000_000;
------------------
-- USB OTG Pins --
------------------
OTG_FS_DM : GPIO_Point renames PA11;
OTG_FS_DP : GPIO_Point renames PA12;
---------------
-- SDIO Pins --
---------------
SDIO_CMD : GPIO_Point renames PD2;
SDIO_CLK : GPIO_Point renames PC12;
SDIO_D0 : GPIO_Point renames PC8;
SDIO_D1 : GPIO_Point renames PC9;
SDIO_D2 : GPIO_Point renames PC10;
SDIO_D3 : GPIO_Point renames PC11;
SD_CD : GPIO_Point renames PA15;
---------------
-- TIM4 Pins --
---------------
TIM4_CH1 : GPIO_Point renames PD12;
TIM4_CH2 : GPIO_Point renames PD13;
end OpenMV;
|
with agar.core.tail_queue;
with agar.gui.text;
with agar.gui.widget.box;
package agar.gui.widget.notebook is
use type c.unsigned;
type tab_t;
type tab_access_t is access all tab_t;
pragma convention (c, tab_access_t);
package tab_tail_queue is new agar.core.tail_queue
(entry_type => tab_access_t);
type tab_alignment_t is (
NOTEBOOK_TABS_TOP,
NOTEBOOK_TABS_BOTTOM,
NOTEBOOK_TABS_LEFT,
NOTEBOOK_TABS_RIGHT
);
for tab_alignment_t use (
NOTEBOOK_TABS_TOP => 0,
NOTEBOOK_TABS_BOTTOM => 1,
NOTEBOOK_TABS_LEFT => 2,
NOTEBOOK_TABS_RIGHT => 3
);
for tab_alignment_t'size use c.unsigned'size;
pragma convention (c, tab_alignment_t);
label_max : constant := 64;
type text_t is array (1 .. label_max) of aliased c.char;
pragma convention (c, text_t);
type tab_t is record
box : agar.gui.widget.box.box_t;
label : c.int;
label_text : text_t;
tabs : tab_tail_queue.entry_t;
end record;
pragma convention (c, tab_t);
type flags_t is new c.unsigned;
NOTEBOOK_HFILL : constant flags_t := 16#01#;
NOTEBOOK_VFILL : constant flags_t := 16#02#;
NOTEBOOK_HIDE_TABS : constant flags_t := 16#04#;
NOTEBOOK_EXPAND : constant flags_t := NOTEBOOK_HFILL or NOTEBOOK_VFILL;
type notebook_t is record
widget : aliased widget_t;
tab_align : tab_alignment_t;
flags : flags_t;
bar_w : c.int;
bar_h : c.int;
cont_w : c.int;
cont_h : c.int;
spacing : c.int;
padding : c.int;
tab_font : agar.gui.text.font_access_t;
label_partial : c.int;
label_partial_width : c.int;
sel_tab : tab_access_t;
tabs : tab_tail_queue.head_t;
r : agar.gui.rect.rect_t;
end record;
type notebook_access_t is access all notebook_t;
pragma convention (c, notebook_t);
pragma convention (c, notebook_access_t);
-- API
function allocate
(parent : widget_access_t;
flags : flags_t) return notebook_access_t;
pragma import (c, allocate, "AG_NotebookNew");
procedure set_padding
(notebook : notebook_access_t;
padding : natural);
pragma inline (set_padding);
procedure set_spacing
(notebook : notebook_access_t;
spacing : natural);
pragma inline (set_spacing);
procedure set_tab_alignment
(notebook : notebook_access_t;
alignment : tab_alignment_t);
pragma import (c, set_tab_alignment, "AG_NotebookSetTabAlignment");
procedure set_tab_font
(notebook : notebook_access_t;
font : agar.gui.text.font_access_t);
pragma import (c, set_tab_font, "AG_NotebookSetTabFont");
procedure set_tab_visibility
(notebook : notebook_access_t;
flag : boolean := false);
pragma inline (set_tab_visibility);
-- tabs
procedure add_tab
(notebook : notebook_access_t;
name : string;
box_type : agar.gui.widget.box.type_t);
pragma inline (add_tab);
procedure delete_tab
(notebook : notebook_access_t;
tab : tab_access_t);
pragma import (c, delete_tab, "AG_NotebookDelTab");
procedure select_tab
(notebook : notebook_access_t;
tab : tab_access_t);
pragma import (c, select_tab, "AG_NotebookSelectTab");
function widget (notebook : notebook_access_t) return widget_access_t;
pragma inline (widget);
end agar.gui.widget.notebook;
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Gnat.Heap_Sort_G;
procedure stemleaf is
data : array(Natural Range <>) of Integer := (
0,12,127,28,42,39,113, 42,18,44,118,44,37,113,124,37,48,127,36,29,31,
125,139,131,115,105,132,104,123,35,113,122,42,117,119,58,109,23,105,
63,27,44,105,99,41,128,121,116,125,32,61,37,127,29,113,121,58,114,126,
53,114,96,25,109,7,31,141,46,13,27,43,117,116,27,7,68,40,31,115,124,42,
128,52,71,118,117,38,27,106,33,117,116,111,40,119,47,105,57,122,109,
124,115,43,120,43,27,27,18,28,48,125,107,114,34,133,45,120, 30,127,
31,116,146); -- Position 0 is used for storage during sorting, initialized as 0
procedure Move (from, to : in Natural) is
begin data(to) := data(from);
end Move;
function Cmp (p1, p2 : Natural) return Boolean is
begin return data(p1)<data(p2);
end Cmp;
package Sorty is new GNAT.Heap_Sort_G(Move,Cmp);
min,max,p,stemw: Integer;
begin
Sorty.Sort(data'Last);
min := data(1);
max := data(data'Last);
stemw := Integer'Image(max)'Length;
p := 1;
for stem in min/10..max/10 loop
put(stem,Width=>stemw); put(" |");
Leaf_Loop:
while data(p)/10=stem loop
put(" "); put(data(p) mod 10,Width=>1);
exit Leaf_loop when p=data'Last;
p := p+1;
end loop Leaf_Loop;
new_line;
end loop;
end stemleaf;
|
with Main;
with Config.Tasking;
with Crash; -- must be here, to activate last_chance_handler
with LED_Manager;
pragma Unreferenced (Crash); -- protect the "with" above
-- the entry point after POR
procedure boot with SPARK_Mode is
pragma Priority (Config.Tasking.TASK_PRIO_MAIN);
Self_Test_Passed : Boolean := False;
begin
Main.Initialize;
-- self-checks, unless in air reset
LED_Manager.LED_switchOn;
Main.Perform_Self_Test (Self_Test_Passed);
-- finally jump to main, if checks passed
if Self_Test_Passed then
Main.Run_Loop;
else
LED_Manager.LED_switchOff;
loop
null;
end loop;
end if;
end boot;
|
------------------------------------------------------------------------------
-- Copyright (c) 2006-2013, Maxim Reznik
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
--
-- * Redistributions of source code must retain the above copyright notice,
-- this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * Neither the name of the Maxim Reznik, IE nor the names of its
-- contributors may be used to endorse or promote products derived from
-- this software without specific prior written permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
-- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- POSSIBILITY OF SUCH DAMAGE.
------------------------------------------------------------------------------
package body Asis.Gela.Elements.Decl is
function Discriminant_Part
(Element : Base_Type_Declaration_Node) return Asis.Definition is
begin
return Element.Discriminant_Part;
end Discriminant_Part;
procedure Set_Discriminant_Part
(Element : in out Base_Type_Declaration_Node;
Value : in Asis.Definition) is
begin
Element.Discriminant_Part := Value;
end Set_Discriminant_Part;
function Type_Declaration_View
(Element : Base_Type_Declaration_Node) return Asis.Definition is
begin
return Element.Type_Declaration_View;
end Type_Declaration_View;
procedure Set_Type_Declaration_View
(Element : in out Base_Type_Declaration_Node;
Value : in Asis.Definition) is
begin
Element.Type_Declaration_View := Value;
end Set_Type_Declaration_View;
function Children (Element : access Base_Type_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(False, Element.Discriminant_Part'Access),
(False, Element.Type_Declaration_View'Access));
end Children;
function Corresponding_Type_Declaration
(Element : Ordinary_Type_Declaration_Node) return Asis.Declaration is
begin
return Element.Corresponding_Type_Declaration;
end Corresponding_Type_Declaration;
procedure Set_Corresponding_Type_Declaration
(Element : in out Ordinary_Type_Declaration_Node;
Value : in Asis.Declaration) is
begin
Element.Corresponding_Type_Declaration := Value;
end Set_Corresponding_Type_Declaration;
function New_Ordinary_Type_Declaration_Node
(The_Context : ASIS.Context)
return Ordinary_Type_Declaration_Ptr
is
Result : Ordinary_Type_Declaration_Ptr :=
new Ordinary_Type_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Ordinary_Type_Declaration_Node;
function Declaration_Kind (Element : Ordinary_Type_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return An_Ordinary_Type_Declaration;
end;
function Clone
(Element : Ordinary_Type_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Ordinary_Type_Declaration_Ptr := new Ordinary_Type_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Type_Declaration := Element.Corresponding_Type_Declaration;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Ordinary_Type_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Discriminant_Part :=
Copy (Cloner, Discriminant_Part (Source.all), Asis.Element (Target));
Target.Type_Declaration_View :=
Copy (Cloner, Type_Declaration_View (Source.all), Asis.Element (Target));
end Copy;
function Is_Name_Repeated
(Element : Protected_Type_Declaration_Node) return Boolean is
begin
return Element.Is_Name_Repeated;
end Is_Name_Repeated;
procedure Set_Is_Name_Repeated
(Element : in out Protected_Type_Declaration_Node;
Value : in Boolean) is
begin
Element.Is_Name_Repeated := Value;
end Set_Is_Name_Repeated;
function Corresponding_Body
(Element : Protected_Type_Declaration_Node) return Asis.Declaration is
begin
return Element.Corresponding_Body;
end Corresponding_Body;
procedure Set_Corresponding_Body
(Element : in out Protected_Type_Declaration_Node;
Value : in Asis.Declaration) is
begin
Element.Corresponding_Body := Value;
end Set_Corresponding_Body;
function Progenitor_List
(Element : Protected_Type_Declaration_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List is
begin
return Primary_Expression_Lists.To_Element_List
(Element.Progenitor_List, Include_Pragmas);
end Progenitor_List;
procedure Set_Progenitor_List
(Element : in out Protected_Type_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Progenitor_List := Primary_Expression_Lists.List (Value);
end Set_Progenitor_List;
function Progenitor_List_List
(Element : Protected_Type_Declaration_Node) return Asis.Element is
begin
return Asis.Element (Element.Progenitor_List);
end Progenitor_List_List;
function New_Protected_Type_Declaration_Node
(The_Context : ASIS.Context)
return Protected_Type_Declaration_Ptr
is
Result : Protected_Type_Declaration_Ptr :=
new Protected_Type_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Protected_Type_Declaration_Node;
function Declaration_Kind (Element : Protected_Type_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Protected_Type_Declaration;
end;
function Children (Element : access Protected_Type_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(False, Element.Discriminant_Part'Access),
(True, Asis.Element (Element.Progenitor_List)),
(False, Element.Type_Declaration_View'Access));
end Children;
function Clone
(Element : Protected_Type_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Protected_Type_Declaration_Ptr := new Protected_Type_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Type_Declaration := Element.Corresponding_Type_Declaration;
Result.Is_Name_Repeated := Element.Is_Name_Repeated;
Result.Corresponding_Body := Element.Corresponding_Body;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Protected_Type_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Discriminant_Part :=
Copy (Cloner, Discriminant_Part (Source.all), Asis.Element (Target));
Set_Progenitor_List
(Target.all,
Primary_Expression_Lists.Deep_Copy
(Progenitor_List (Source.all), Cloner, Asis.Element (Target)));
Target.Type_Declaration_View :=
Copy (Cloner, Type_Declaration_View (Source.all), Asis.Element (Target));
end Copy;
function New_Task_Type_Declaration_Node
(The_Context : ASIS.Context)
return Task_Type_Declaration_Ptr
is
Result : Task_Type_Declaration_Ptr :=
new Task_Type_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Task_Type_Declaration_Node;
function Declaration_Kind (Element : Task_Type_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Task_Type_Declaration;
end;
function Clone
(Element : Task_Type_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Task_Type_Declaration_Ptr := new Task_Type_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Type_Declaration := Element.Corresponding_Type_Declaration;
Result.Is_Name_Repeated := Element.Is_Name_Repeated;
Result.Corresponding_Body := Element.Corresponding_Body;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Task_Type_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Discriminant_Part :=
Copy (Cloner, Discriminant_Part (Source.all), Asis.Element (Target));
Set_Progenitor_List
(Target.all,
Primary_Expression_Lists.Deep_Copy
(Progenitor_List (Source.all), Cloner, Asis.Element (Target)));
Target.Type_Declaration_View :=
Copy (Cloner, Type_Declaration_View (Source.all), Asis.Element (Target));
end Copy;
function Trait_Kind
(Element : Private_Type_Declaration_Node) return Asis.Trait_Kinds is
begin
return Element.Trait_Kind;
end Trait_Kind;
procedure Set_Trait_Kind
(Element : in out Private_Type_Declaration_Node;
Value : in Asis.Trait_Kinds) is
begin
Element.Trait_Kind := Value;
end Set_Trait_Kind;
function New_Private_Type_Declaration_Node
(The_Context : ASIS.Context)
return Private_Type_Declaration_Ptr
is
Result : Private_Type_Declaration_Ptr :=
new Private_Type_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Private_Type_Declaration_Node;
function Declaration_Kind (Element : Private_Type_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Private_Type_Declaration;
end;
function Clone
(Element : Private_Type_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Private_Type_Declaration_Ptr := new Private_Type_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Type_Declaration := Element.Corresponding_Type_Declaration;
Result.Trait_Kind := Element.Trait_Kind;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Private_Type_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Discriminant_Part :=
Copy (Cloner, Discriminant_Part (Source.all), Asis.Element (Target));
Target.Type_Declaration_View :=
Copy (Cloner, Type_Declaration_View (Source.all), Asis.Element (Target));
end Copy;
function Progenitor_List
(Element : Private_Extension_Declaration_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List is
begin
return Primary_Expression_Lists.To_Element_List
(Element.Progenitor_List, Include_Pragmas);
end Progenitor_List;
procedure Set_Progenitor_List
(Element : in out Private_Extension_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Progenitor_List := Primary_Expression_Lists.List (Value);
end Set_Progenitor_List;
function Progenitor_List_List
(Element : Private_Extension_Declaration_Node) return Asis.Element is
begin
return Asis.Element (Element.Progenitor_List);
end Progenitor_List_List;
function New_Private_Extension_Declaration_Node
(The_Context : ASIS.Context)
return Private_Extension_Declaration_Ptr
is
Result : Private_Extension_Declaration_Ptr :=
new Private_Extension_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Private_Extension_Declaration_Node;
function Declaration_Kind (Element : Private_Extension_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Private_Extension_Declaration;
end;
function Children (Element : access Private_Extension_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(False, Element.Discriminant_Part'Access),
(True, Asis.Element (Element.Progenitor_List)),
(False, Element.Type_Declaration_View'Access));
end Children;
function Clone
(Element : Private_Extension_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Private_Extension_Declaration_Ptr := new Private_Extension_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Type_Declaration := Element.Corresponding_Type_Declaration;
Result.Trait_Kind := Element.Trait_Kind;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Private_Extension_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Discriminant_Part :=
Copy (Cloner, Discriminant_Part (Source.all), Asis.Element (Target));
Set_Progenitor_List
(Target.all,
Primary_Expression_Lists.Deep_Copy
(Progenitor_List (Source.all), Cloner, Asis.Element (Target)));
Target.Type_Declaration_View :=
Copy (Cloner, Type_Declaration_View (Source.all), Asis.Element (Target));
end Copy;
function Generic_Actual
(Element : Formal_Type_Declaration_Node) return Asis.Expression is
begin
return Element.Generic_Actual;
end Generic_Actual;
procedure Set_Generic_Actual
(Element : in out Formal_Type_Declaration_Node;
Value : in Asis.Expression) is
begin
Element.Generic_Actual := Value;
end Set_Generic_Actual;
function New_Formal_Type_Declaration_Node
(The_Context : ASIS.Context)
return Formal_Type_Declaration_Ptr
is
Result : Formal_Type_Declaration_Ptr :=
new Formal_Type_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Formal_Type_Declaration_Node;
function Declaration_Kind (Element : Formal_Type_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Formal_Type_Declaration;
end;
function Clone
(Element : Formal_Type_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Formal_Type_Declaration_Ptr := new Formal_Type_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Generic_Actual := Element.Generic_Actual;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Formal_Type_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Discriminant_Part :=
Copy (Cloner, Discriminant_Part (Source.all), Asis.Element (Target));
Target.Type_Declaration_View :=
Copy (Cloner, Type_Declaration_View (Source.all), Asis.Element (Target));
end Copy;
function Parameter_Profile
(Element : Base_Callable_Declaration_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List is
begin
return Primary_Parameter_Lists.To_Element_List
(Element.Parameter_Profile, Include_Pragmas);
end Parameter_Profile;
procedure Set_Parameter_Profile
(Element : in out Base_Callable_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Parameter_Profile := Primary_Parameter_Lists.List (Value);
end Set_Parameter_Profile;
function Parameter_Profile_List
(Element : Base_Callable_Declaration_Node) return Asis.Element is
begin
return Asis.Element (Element.Parameter_Profile);
end Parameter_Profile_List;
function Corresponding_Body
(Element : Base_Callable_Declaration_Node) return Asis.Declaration is
begin
return Element.Corresponding_Body;
end Corresponding_Body;
procedure Set_Corresponding_Body
(Element : in out Base_Callable_Declaration_Node;
Value : in Asis.Declaration) is
begin
Element.Corresponding_Body := Value;
end Set_Corresponding_Body;
function Specification
(Element : Base_Callable_Declaration_Node) return Asis.Element is
begin
return Element.Specification;
end Specification;
procedure Set_Specification
(Element : in out Base_Callable_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Specification := Value;
end Set_Specification;
function Children (Element : access Base_Callable_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(True, Asis.Element (Element.Parameter_Profile)));
end Children;
function Corresponding_Subprogram_Derivation
(Element : Procedure_Declaration_Node) return Asis.Declaration is
begin
return Element.Corresponding_Subprogram_Derivation;
end Corresponding_Subprogram_Derivation;
procedure Set_Corresponding_Subprogram_Derivation
(Element : in out Procedure_Declaration_Node;
Value : in Asis.Declaration) is
begin
Element.Corresponding_Subprogram_Derivation := Value;
end Set_Corresponding_Subprogram_Derivation;
function Corresponding_Type
(Element : Procedure_Declaration_Node) return Asis.Type_Definition is
begin
return Element.Corresponding_Type;
end Corresponding_Type;
procedure Set_Corresponding_Type
(Element : in out Procedure_Declaration_Node;
Value : in Asis.Type_Definition) is
begin
Element.Corresponding_Type := Value;
end Set_Corresponding_Type;
function Is_Dispatching_Operation
(Element : Procedure_Declaration_Node) return Boolean is
begin
return Element.Is_Dispatching_Operation;
end Is_Dispatching_Operation;
procedure Set_Is_Dispatching_Operation
(Element : in out Procedure_Declaration_Node;
Value : in Boolean) is
begin
Element.Is_Dispatching_Operation := Value;
end Set_Is_Dispatching_Operation;
function Trait_Kind
(Element : Procedure_Declaration_Node) return Asis.Trait_Kinds is
begin
return Element.Trait_Kind;
end Trait_Kind;
procedure Set_Trait_Kind
(Element : in out Procedure_Declaration_Node;
Value : in Asis.Trait_Kinds) is
begin
Element.Trait_Kind := Value;
end Set_Trait_Kind;
function Overriding_Indicator_Kind
(Element : Procedure_Declaration_Node) return Asis.Overriding_Indicator_Kinds is
begin
return Element.Overriding_Indicator_Kind;
end Overriding_Indicator_Kind;
procedure Set_Overriding_Indicator_Kind
(Element : in out Procedure_Declaration_Node;
Value : in Asis.Overriding_Indicator_Kinds) is
begin
Element.Overriding_Indicator_Kind := Value;
end Set_Overriding_Indicator_Kind;
function Has_Abstract
(Element : Procedure_Declaration_Node) return Boolean is
begin
return Element.Has_Abstract;
end Has_Abstract;
procedure Set_Has_Abstract
(Element : in out Procedure_Declaration_Node;
Value : in Boolean) is
begin
Element.Has_Abstract := Value;
end Set_Has_Abstract;
function Is_Null_Procedure
(Element : Procedure_Declaration_Node) return Boolean is
begin
return Element.Is_Null_Procedure;
end Is_Null_Procedure;
procedure Set_Is_Null_Procedure
(Element : in out Procedure_Declaration_Node;
Value : in Boolean) is
begin
Element.Is_Null_Procedure := Value;
end Set_Is_Null_Procedure;
function Generic_Formal_Part
(Element : Procedure_Declaration_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List is
begin
return Primary_Declaration_Lists.To_Element_List
(Element.Generic_Formal_Part, Include_Pragmas);
end Generic_Formal_Part;
procedure Set_Generic_Formal_Part
(Element : in out Procedure_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Generic_Formal_Part := Primary_Declaration_Lists.List (Value);
end Set_Generic_Formal_Part;
function Generic_Formal_Part_List
(Element : Procedure_Declaration_Node) return Asis.Element is
begin
return Asis.Element (Element.Generic_Formal_Part);
end Generic_Formal_Part_List;
function New_Procedure_Declaration_Node
(The_Context : ASIS.Context)
return Procedure_Declaration_Ptr
is
Result : Procedure_Declaration_Ptr :=
new Procedure_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Procedure_Declaration_Node;
function Declaration_Kind (Element : Procedure_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Procedure_Declaration;
end;
function Children (Element : access Procedure_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Generic_Formal_Part)),
(True, Asis.Element (Element.Names)),
(True, Asis.Element (Element.Parameter_Profile)));
end Children;
function Clone
(Element : Procedure_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Procedure_Declaration_Ptr := new Procedure_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Body := Element.Corresponding_Body;
Result.Specification := Element.Specification;
Result.Corresponding_Subprogram_Derivation := Element.Corresponding_Subprogram_Derivation;
Result.Corresponding_Type := Element.Corresponding_Type;
Result.Is_Dispatching_Operation := Element.Is_Dispatching_Operation;
Result.Trait_Kind := Element.Trait_Kind;
Result.Overriding_Indicator_Kind := Element.Overriding_Indicator_Kind;
Result.Has_Abstract := Element.Has_Abstract;
Result.Is_Null_Procedure := Element.Is_Null_Procedure;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Procedure_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Generic_Formal_Part
(Target.all,
Primary_Declaration_Lists.Deep_Copy
(Generic_Formal_Part (Source.all), Cloner, Asis.Element (Target)));
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Set_Parameter_Profile
(Target.all,
Primary_Parameter_Lists.Deep_Copy
(Parameter_Profile (Source.all), Cloner, Asis.Element (Target)));
end Copy;
function Result_Subtype
(Element : Function_Declaration_Node) return Asis.Definition is
begin
return Element.Result_Subtype;
end Result_Subtype;
procedure Set_Result_Subtype
(Element : in out Function_Declaration_Node;
Value : in Asis.Definition) is
begin
Element.Result_Subtype := Value;
end Set_Result_Subtype;
function Corresponding_Equality_Operator
(Element : Function_Declaration_Node) return Asis.Declaration is
begin
return Element.Corresponding_Equality_Operator;
end Corresponding_Equality_Operator;
procedure Set_Corresponding_Equality_Operator
(Element : in out Function_Declaration_Node;
Value : in Asis.Declaration) is
begin
Element.Corresponding_Equality_Operator := Value;
end Set_Corresponding_Equality_Operator;
function New_Function_Declaration_Node
(The_Context : ASIS.Context)
return Function_Declaration_Ptr
is
Result : Function_Declaration_Ptr :=
new Function_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Function_Declaration_Node;
function Declaration_Kind (Element : Function_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Function_Declaration;
end;
function Children (Element : access Function_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Generic_Formal_Part)),
(True, Asis.Element (Element.Names)),
(True, Asis.Element (Element.Parameter_Profile)),
(False, Element.Result_Subtype'Access));
end Children;
function Clone
(Element : Function_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Function_Declaration_Ptr := new Function_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Body := Element.Corresponding_Body;
Result.Specification := Element.Specification;
Result.Corresponding_Subprogram_Derivation := Element.Corresponding_Subprogram_Derivation;
Result.Corresponding_Type := Element.Corresponding_Type;
Result.Is_Dispatching_Operation := Element.Is_Dispatching_Operation;
Result.Trait_Kind := Element.Trait_Kind;
Result.Overriding_Indicator_Kind := Element.Overriding_Indicator_Kind;
Result.Has_Abstract := Element.Has_Abstract;
Result.Is_Null_Procedure := Element.Is_Null_Procedure;
Result.Corresponding_Equality_Operator := Element.Corresponding_Equality_Operator;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Function_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Generic_Formal_Part
(Target.all,
Primary_Declaration_Lists.Deep_Copy
(Generic_Formal_Part (Source.all), Cloner, Asis.Element (Target)));
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Set_Parameter_Profile
(Target.all,
Primary_Parameter_Lists.Deep_Copy
(Parameter_Profile (Source.all), Cloner, Asis.Element (Target)));
Target.Result_Subtype :=
Copy (Cloner, Result_Subtype (Source.all), Asis.Element (Target));
end Copy;
function Is_Dispatching_Operation
(Element : Procedure_Renaming_Declaration_Node) return Boolean is
begin
return Element.Is_Dispatching_Operation;
end Is_Dispatching_Operation;
procedure Set_Is_Dispatching_Operation
(Element : in out Procedure_Renaming_Declaration_Node;
Value : in Boolean) is
begin
Element.Is_Dispatching_Operation := Value;
end Set_Is_Dispatching_Operation;
function Renamed_Entity
(Element : Procedure_Renaming_Declaration_Node) return Asis.Expression is
begin
return Element.Renamed_Entity;
end Renamed_Entity;
procedure Set_Renamed_Entity
(Element : in out Procedure_Renaming_Declaration_Node;
Value : in Asis.Expression) is
begin
Element.Renamed_Entity := Value;
end Set_Renamed_Entity;
function Corresponding_Base_Entity
(Element : Procedure_Renaming_Declaration_Node) return Asis.Expression is
begin
return Element.Corresponding_Base_Entity;
end Corresponding_Base_Entity;
procedure Set_Corresponding_Base_Entity
(Element : in out Procedure_Renaming_Declaration_Node;
Value : in Asis.Expression) is
begin
Element.Corresponding_Base_Entity := Value;
end Set_Corresponding_Base_Entity;
function Corresponding_Declaration
(Element : Procedure_Renaming_Declaration_Node) return Asis.Declaration is
begin
return Element.Corresponding_Declaration;
end Corresponding_Declaration;
procedure Set_Corresponding_Declaration
(Element : in out Procedure_Renaming_Declaration_Node;
Value : in Asis.Declaration) is
begin
Element.Corresponding_Declaration := Value;
end Set_Corresponding_Declaration;
function Overriding_Indicator_Kind
(Element : Procedure_Renaming_Declaration_Node) return Asis.Overriding_Indicator_Kinds is
begin
return Element.Overriding_Indicator_Kind;
end Overriding_Indicator_Kind;
procedure Set_Overriding_Indicator_Kind
(Element : in out Procedure_Renaming_Declaration_Node;
Value : in Asis.Overriding_Indicator_Kinds) is
begin
Element.Overriding_Indicator_Kind := Value;
end Set_Overriding_Indicator_Kind;
function New_Procedure_Renaming_Declaration_Node
(The_Context : ASIS.Context)
return Procedure_Renaming_Declaration_Ptr
is
Result : Procedure_Renaming_Declaration_Ptr :=
new Procedure_Renaming_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Procedure_Renaming_Declaration_Node;
function Declaration_Kind (Element : Procedure_Renaming_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Procedure_Renaming_Declaration;
end;
function Children (Element : access Procedure_Renaming_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(True, Asis.Element (Element.Parameter_Profile)),
(False, Element.Renamed_Entity'Access));
end Children;
function Clone
(Element : Procedure_Renaming_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Procedure_Renaming_Declaration_Ptr := new Procedure_Renaming_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Body := Element.Corresponding_Body;
Result.Specification := Element.Specification;
Result.Is_Dispatching_Operation := Element.Is_Dispatching_Operation;
Result.Corresponding_Base_Entity := Element.Corresponding_Base_Entity;
Result.Corresponding_Declaration := Element.Corresponding_Declaration;
Result.Overriding_Indicator_Kind := Element.Overriding_Indicator_Kind;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Procedure_Renaming_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Set_Parameter_Profile
(Target.all,
Primary_Parameter_Lists.Deep_Copy
(Parameter_Profile (Source.all), Cloner, Asis.Element (Target)));
Target.Renamed_Entity :=
Copy (Cloner, Renamed_Entity (Source.all), Asis.Element (Target));
end Copy;
function Result_Subtype
(Element : Function_Renaming_Declaration_Node) return Asis.Definition is
begin
return Element.Result_Subtype;
end Result_Subtype;
procedure Set_Result_Subtype
(Element : in out Function_Renaming_Declaration_Node;
Value : in Asis.Definition) is
begin
Element.Result_Subtype := Value;
end Set_Result_Subtype;
function Corresponding_Equality_Operator
(Element : Function_Renaming_Declaration_Node) return Asis.Declaration is
begin
return Element.Corresponding_Equality_Operator;
end Corresponding_Equality_Operator;
procedure Set_Corresponding_Equality_Operator
(Element : in out Function_Renaming_Declaration_Node;
Value : in Asis.Declaration) is
begin
Element.Corresponding_Equality_Operator := Value;
end Set_Corresponding_Equality_Operator;
function New_Function_Renaming_Declaration_Node
(The_Context : ASIS.Context)
return Function_Renaming_Declaration_Ptr
is
Result : Function_Renaming_Declaration_Ptr :=
new Function_Renaming_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Function_Renaming_Declaration_Node;
function Declaration_Kind (Element : Function_Renaming_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Function_Renaming_Declaration;
end;
function Children (Element : access Function_Renaming_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(True, Asis.Element (Element.Parameter_Profile)),
(False, Element.Result_Subtype'Access),
(False, Element.Renamed_Entity'Access));
end Children;
function Clone
(Element : Function_Renaming_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Function_Renaming_Declaration_Ptr := new Function_Renaming_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Body := Element.Corresponding_Body;
Result.Specification := Element.Specification;
Result.Is_Dispatching_Operation := Element.Is_Dispatching_Operation;
Result.Corresponding_Base_Entity := Element.Corresponding_Base_Entity;
Result.Corresponding_Declaration := Element.Corresponding_Declaration;
Result.Overriding_Indicator_Kind := Element.Overriding_Indicator_Kind;
Result.Corresponding_Equality_Operator := Element.Corresponding_Equality_Operator;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Function_Renaming_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Set_Parameter_Profile
(Target.all,
Primary_Parameter_Lists.Deep_Copy
(Parameter_Profile (Source.all), Cloner, Asis.Element (Target)));
Target.Result_Subtype :=
Copy (Cloner, Result_Subtype (Source.all), Asis.Element (Target));
Target.Renamed_Entity :=
Copy (Cloner, Renamed_Entity (Source.all), Asis.Element (Target));
end Copy;
function Entry_Family_Definition
(Element : Entry_Declaration_Node) return Asis.Discrete_Subtype_Definition is
begin
return Element.Entry_Family_Definition;
end Entry_Family_Definition;
procedure Set_Entry_Family_Definition
(Element : in out Entry_Declaration_Node;
Value : in Asis.Discrete_Subtype_Definition) is
begin
Element.Entry_Family_Definition := Value;
end Set_Entry_Family_Definition;
function Overriding_Indicator_Kind
(Element : Entry_Declaration_Node) return Asis.Overriding_Indicator_Kinds is
begin
return Element.Overriding_Indicator_Kind;
end Overriding_Indicator_Kind;
procedure Set_Overriding_Indicator_Kind
(Element : in out Entry_Declaration_Node;
Value : in Asis.Overriding_Indicator_Kinds) is
begin
Element.Overriding_Indicator_Kind := Value;
end Set_Overriding_Indicator_Kind;
function New_Entry_Declaration_Node
(The_Context : ASIS.Context)
return Entry_Declaration_Ptr
is
Result : Entry_Declaration_Ptr :=
new Entry_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Entry_Declaration_Node;
function Declaration_Kind (Element : Entry_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return An_Entry_Declaration;
end;
function Children (Element : access Entry_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(False, Element.Entry_Family_Definition'Access),
(True, Asis.Element (Element.Parameter_Profile)));
end Children;
function Clone
(Element : Entry_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Entry_Declaration_Ptr := new Entry_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Body := Element.Corresponding_Body;
Result.Specification := Element.Specification;
Result.Overriding_Indicator_Kind := Element.Overriding_Indicator_Kind;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Entry_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Entry_Family_Definition :=
Copy (Cloner, Entry_Family_Definition (Source.all), Asis.Element (Target));
Set_Parameter_Profile
(Target.all,
Primary_Parameter_Lists.Deep_Copy
(Parameter_Profile (Source.all), Cloner, Asis.Element (Target)));
end Copy;
function Corresponding_Subunit
(Element : Procedure_Body_Stub_Node) return Asis.Declaration is
begin
return Element.Corresponding_Subunit;
end Corresponding_Subunit;
procedure Set_Corresponding_Subunit
(Element : in out Procedure_Body_Stub_Node;
Value : in Asis.Declaration) is
begin
Element.Corresponding_Subunit := Value;
end Set_Corresponding_Subunit;
function Corresponding_Declaration
(Element : Procedure_Body_Stub_Node) return Asis.Declaration is
begin
return Element.Corresponding_Declaration;
end Corresponding_Declaration;
procedure Set_Corresponding_Declaration
(Element : in out Procedure_Body_Stub_Node;
Value : in Asis.Declaration) is
begin
Element.Corresponding_Declaration := Value;
end Set_Corresponding_Declaration;
function Overriding_Indicator_Kind
(Element : Procedure_Body_Stub_Node) return Asis.Overriding_Indicator_Kinds is
begin
return Element.Overriding_Indicator_Kind;
end Overriding_Indicator_Kind;
procedure Set_Overriding_Indicator_Kind
(Element : in out Procedure_Body_Stub_Node;
Value : in Asis.Overriding_Indicator_Kinds) is
begin
Element.Overriding_Indicator_Kind := Value;
end Set_Overriding_Indicator_Kind;
function New_Procedure_Body_Stub_Node
(The_Context : ASIS.Context)
return Procedure_Body_Stub_Ptr
is
Result : Procedure_Body_Stub_Ptr :=
new Procedure_Body_Stub_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Procedure_Body_Stub_Node;
function Declaration_Kind (Element : Procedure_Body_Stub_Node)
return Asis.Declaration_Kinds is
begin
return A_Procedure_Body_Stub;
end;
function Clone
(Element : Procedure_Body_Stub_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Procedure_Body_Stub_Ptr := new Procedure_Body_Stub_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Body := Element.Corresponding_Body;
Result.Specification := Element.Specification;
Result.Corresponding_Subunit := Element.Corresponding_Subunit;
Result.Corresponding_Declaration := Element.Corresponding_Declaration;
Result.Overriding_Indicator_Kind := Element.Overriding_Indicator_Kind;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Procedure_Body_Stub_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Set_Parameter_Profile
(Target.all,
Primary_Parameter_Lists.Deep_Copy
(Parameter_Profile (Source.all), Cloner, Asis.Element (Target)));
end Copy;
function Result_Subtype
(Element : Function_Body_Stub_Node) return Asis.Definition is
begin
return Element.Result_Subtype;
end Result_Subtype;
procedure Set_Result_Subtype
(Element : in out Function_Body_Stub_Node;
Value : in Asis.Definition) is
begin
Element.Result_Subtype := Value;
end Set_Result_Subtype;
function New_Function_Body_Stub_Node
(The_Context : ASIS.Context)
return Function_Body_Stub_Ptr
is
Result : Function_Body_Stub_Ptr :=
new Function_Body_Stub_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Function_Body_Stub_Node;
function Declaration_Kind (Element : Function_Body_Stub_Node)
return Asis.Declaration_Kinds is
begin
return A_Function_Body_Stub;
end;
function Children (Element : access Function_Body_Stub_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(True, Asis.Element (Element.Parameter_Profile)),
(False, Element.Result_Subtype'Access));
end Children;
function Clone
(Element : Function_Body_Stub_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Function_Body_Stub_Ptr := new Function_Body_Stub_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Body := Element.Corresponding_Body;
Result.Specification := Element.Specification;
Result.Corresponding_Subunit := Element.Corresponding_Subunit;
Result.Corresponding_Declaration := Element.Corresponding_Declaration;
Result.Overriding_Indicator_Kind := Element.Overriding_Indicator_Kind;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Function_Body_Stub_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Set_Parameter_Profile
(Target.all,
Primary_Parameter_Lists.Deep_Copy
(Parameter_Profile (Source.all), Cloner, Asis.Element (Target)));
Target.Result_Subtype :=
Copy (Cloner, Result_Subtype (Source.all), Asis.Element (Target));
end Copy;
function Generic_Formal_Part
(Element : Generic_Procedure_Declaration_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List is
begin
return Primary_Declaration_Lists.To_Element_List
(Element.Generic_Formal_Part, Include_Pragmas);
end Generic_Formal_Part;
procedure Set_Generic_Formal_Part
(Element : in out Generic_Procedure_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Generic_Formal_Part := Primary_Declaration_Lists.List (Value);
end Set_Generic_Formal_Part;
function Generic_Formal_Part_List
(Element : Generic_Procedure_Declaration_Node) return Asis.Element is
begin
return Asis.Element (Element.Generic_Formal_Part);
end Generic_Formal_Part_List;
function New_Generic_Procedure_Declaration_Node
(The_Context : ASIS.Context)
return Generic_Procedure_Declaration_Ptr
is
Result : Generic_Procedure_Declaration_Ptr :=
new Generic_Procedure_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Generic_Procedure_Declaration_Node;
function Declaration_Kind (Element : Generic_Procedure_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Generic_Procedure_Declaration;
end;
function Children (Element : access Generic_Procedure_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Generic_Formal_Part)),
(True, Asis.Element (Element.Names)),
(True, Asis.Element (Element.Parameter_Profile)));
end Children;
function Clone
(Element : Generic_Procedure_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Generic_Procedure_Declaration_Ptr := new Generic_Procedure_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Body := Element.Corresponding_Body;
Result.Specification := Element.Specification;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Generic_Procedure_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Generic_Formal_Part
(Target.all,
Primary_Declaration_Lists.Deep_Copy
(Generic_Formal_Part (Source.all), Cloner, Asis.Element (Target)));
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Set_Parameter_Profile
(Target.all,
Primary_Parameter_Lists.Deep_Copy
(Parameter_Profile (Source.all), Cloner, Asis.Element (Target)));
end Copy;
function Result_Subtype
(Element : Generic_Function_Declaration_Node) return Asis.Definition is
begin
return Element.Result_Subtype;
end Result_Subtype;
procedure Set_Result_Subtype
(Element : in out Generic_Function_Declaration_Node;
Value : in Asis.Definition) is
begin
Element.Result_Subtype := Value;
end Set_Result_Subtype;
function New_Generic_Function_Declaration_Node
(The_Context : ASIS.Context)
return Generic_Function_Declaration_Ptr
is
Result : Generic_Function_Declaration_Ptr :=
new Generic_Function_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Generic_Function_Declaration_Node;
function Declaration_Kind (Element : Generic_Function_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Generic_Function_Declaration;
end;
function Children (Element : access Generic_Function_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Generic_Formal_Part)),
(True, Asis.Element (Element.Names)),
(True, Asis.Element (Element.Parameter_Profile)),
(False, Element.Result_Subtype'Access));
end Children;
function Clone
(Element : Generic_Function_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Generic_Function_Declaration_Ptr := new Generic_Function_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Body := Element.Corresponding_Body;
Result.Specification := Element.Specification;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Generic_Function_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Generic_Formal_Part
(Target.all,
Primary_Declaration_Lists.Deep_Copy
(Generic_Formal_Part (Source.all), Cloner, Asis.Element (Target)));
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Set_Parameter_Profile
(Target.all,
Primary_Parameter_Lists.Deep_Copy
(Parameter_Profile (Source.all), Cloner, Asis.Element (Target)));
Target.Result_Subtype :=
Copy (Cloner, Result_Subtype (Source.all), Asis.Element (Target));
end Copy;
function Body_Declarative_Items
(Element : Base_Body_Declaration_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List is
begin
return Primary_Declaration_Lists.To_Element_List
(Element.Body_Declarative_Items, Include_Pragmas);
end Body_Declarative_Items;
procedure Set_Body_Declarative_Items
(Element : in out Base_Body_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Body_Declarative_Items := Primary_Declaration_Lists.List (Value);
end Set_Body_Declarative_Items;
function Body_Declarative_Items_List
(Element : Base_Body_Declaration_Node) return Asis.Element is
begin
return Asis.Element (Element.Body_Declarative_Items);
end Body_Declarative_Items_List;
function Body_Statements
(Element : Base_Body_Declaration_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List is
begin
return Primary_Statement_Lists.To_Element_List
(Element.Body_Statements, Include_Pragmas);
end Body_Statements;
procedure Set_Body_Statements
(Element : in out Base_Body_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Body_Statements := Primary_Statement_Lists.List (Value);
end Set_Body_Statements;
function Body_Statements_List
(Element : Base_Body_Declaration_Node) return Asis.Element is
begin
return Asis.Element (Element.Body_Statements);
end Body_Statements_List;
function Body_Exception_Handlers
(Element : Base_Body_Declaration_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List is
begin
return Primary_Handler_Lists.To_Element_List
(Element.Body_Exception_Handlers, Include_Pragmas);
end Body_Exception_Handlers;
procedure Set_Body_Exception_Handlers
(Element : in out Base_Body_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Body_Exception_Handlers := Primary_Handler_Lists.List (Value);
end Set_Body_Exception_Handlers;
function Body_Exception_Handlers_List
(Element : Base_Body_Declaration_Node) return Asis.Element is
begin
return Asis.Element (Element.Body_Exception_Handlers);
end Body_Exception_Handlers_List;
function Corresponding_Declaration
(Element : Base_Body_Declaration_Node) return Asis.Declaration is
begin
return Element.Corresponding_Declaration;
end Corresponding_Declaration;
procedure Set_Corresponding_Declaration
(Element : in out Base_Body_Declaration_Node;
Value : in Asis.Declaration) is
begin
Element.Corresponding_Declaration := Value;
end Set_Corresponding_Declaration;
function Corresponding_Body_Stub
(Element : Base_Body_Declaration_Node) return Asis.Declaration is
begin
return Element.Corresponding_Body_Stub;
end Corresponding_Body_Stub;
procedure Set_Corresponding_Body_Stub
(Element : in out Base_Body_Declaration_Node;
Value : in Asis.Declaration) is
begin
Element.Corresponding_Body_Stub := Value;
end Set_Corresponding_Body_Stub;
function Is_Name_Repeated
(Element : Base_Body_Declaration_Node) return Boolean is
begin
return Element.Is_Name_Repeated;
end Is_Name_Repeated;
procedure Set_Is_Name_Repeated
(Element : in out Base_Body_Declaration_Node;
Value : in Boolean) is
begin
Element.Is_Name_Repeated := Value;
end Set_Is_Name_Repeated;
function Handled_Statements
(Element : Base_Body_Declaration_Node) return Asis.Element is
begin
return Element.Handled_Statements;
end Handled_Statements;
procedure Set_Handled_Statements
(Element : in out Base_Body_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Handled_Statements := Value;
end Set_Handled_Statements;
function Compound_Name
(Element : Base_Body_Declaration_Node) return Asis.Element is
begin
return Element.Compound_Name;
end Compound_Name;
procedure Set_Compound_Name
(Element : in out Base_Body_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Compound_Name := Value;
end Set_Compound_Name;
function Children (Element : access Base_Body_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(True, Asis.Element (Element.Body_Declarative_Items)),
(True, Asis.Element (Element.Body_Statements)),
(True, Asis.Element (Element.Body_Exception_Handlers)));
end Children;
function Parameter_Profile
(Element : Procedure_Body_Declaration_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List is
begin
return Primary_Parameter_Lists.To_Element_List
(Element.Parameter_Profile, Include_Pragmas);
end Parameter_Profile;
procedure Set_Parameter_Profile
(Element : in out Procedure_Body_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Parameter_Profile := Primary_Parameter_Lists.List (Value);
end Set_Parameter_Profile;
function Parameter_Profile_List
(Element : Procedure_Body_Declaration_Node) return Asis.Element is
begin
return Asis.Element (Element.Parameter_Profile);
end Parameter_Profile_List;
function Specification
(Element : Procedure_Body_Declaration_Node) return Asis.Element is
begin
return Element.Specification;
end Specification;
procedure Set_Specification
(Element : in out Procedure_Body_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Specification := Value;
end Set_Specification;
function Overriding_Indicator_Kind
(Element : Procedure_Body_Declaration_Node) return Asis.Overriding_Indicator_Kinds is
begin
return Element.Overriding_Indicator_Kind;
end Overriding_Indicator_Kind;
procedure Set_Overriding_Indicator_Kind
(Element : in out Procedure_Body_Declaration_Node;
Value : in Asis.Overriding_Indicator_Kinds) is
begin
Element.Overriding_Indicator_Kind := Value;
end Set_Overriding_Indicator_Kind;
function New_Procedure_Body_Declaration_Node
(The_Context : ASIS.Context)
return Procedure_Body_Declaration_Ptr
is
Result : Procedure_Body_Declaration_Ptr :=
new Procedure_Body_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Procedure_Body_Declaration_Node;
function Declaration_Kind (Element : Procedure_Body_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Procedure_Body_Declaration;
end;
function Children (Element : access Procedure_Body_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(True, Asis.Element (Element.Parameter_Profile)),
(True, Asis.Element (Element.Body_Declarative_Items)),
(True, Asis.Element (Element.Body_Statements)),
(True, Asis.Element (Element.Body_Exception_Handlers)));
end Children;
function Clone
(Element : Procedure_Body_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Procedure_Body_Declaration_Ptr := new Procedure_Body_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Declaration := Element.Corresponding_Declaration;
Result.Corresponding_Body_Stub := Element.Corresponding_Body_Stub;
Result.Is_Name_Repeated := Element.Is_Name_Repeated;
Result.Handled_Statements := Element.Handled_Statements;
Result.Compound_Name := Element.Compound_Name;
Result.Specification := Element.Specification;
Result.Overriding_Indicator_Kind := Element.Overriding_Indicator_Kind;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Procedure_Body_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Set_Parameter_Profile
(Target.all,
Primary_Parameter_Lists.Deep_Copy
(Parameter_Profile (Source.all), Cloner, Asis.Element (Target)));
Set_Body_Declarative_Items
(Target.all,
Primary_Declaration_Lists.Deep_Copy
(Body_Declarative_Items (Source.all), Cloner, Asis.Element (Target)));
Set_Body_Statements
(Target.all,
Primary_Statement_Lists.Deep_Copy
(Body_Statements (Source.all), Cloner, Asis.Element (Target)));
Set_Body_Exception_Handlers
(Target.all,
Primary_Handler_Lists.Deep_Copy
(Body_Exception_Handlers (Source.all), Cloner, Asis.Element (Target)));
end Copy;
function Result_Subtype
(Element : Function_Body_Declaration_Node) return Asis.Definition is
begin
return Element.Result_Subtype;
end Result_Subtype;
procedure Set_Result_Subtype
(Element : in out Function_Body_Declaration_Node;
Value : in Asis.Definition) is
begin
Element.Result_Subtype := Value;
end Set_Result_Subtype;
function New_Function_Body_Declaration_Node
(The_Context : ASIS.Context)
return Function_Body_Declaration_Ptr
is
Result : Function_Body_Declaration_Ptr :=
new Function_Body_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Function_Body_Declaration_Node;
function Declaration_Kind (Element : Function_Body_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Function_Body_Declaration;
end;
function Children (Element : access Function_Body_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(True, Asis.Element (Element.Parameter_Profile)),
(False, Element.Result_Subtype'Access),
(True, Asis.Element (Element.Body_Declarative_Items)),
(True, Asis.Element (Element.Body_Statements)),
(True, Asis.Element (Element.Body_Exception_Handlers)));
end Children;
function Clone
(Element : Function_Body_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Function_Body_Declaration_Ptr := new Function_Body_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Declaration := Element.Corresponding_Declaration;
Result.Corresponding_Body_Stub := Element.Corresponding_Body_Stub;
Result.Is_Name_Repeated := Element.Is_Name_Repeated;
Result.Handled_Statements := Element.Handled_Statements;
Result.Compound_Name := Element.Compound_Name;
Result.Specification := Element.Specification;
Result.Overriding_Indicator_Kind := Element.Overriding_Indicator_Kind;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Function_Body_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Set_Parameter_Profile
(Target.all,
Primary_Parameter_Lists.Deep_Copy
(Parameter_Profile (Source.all), Cloner, Asis.Element (Target)));
Target.Result_Subtype :=
Copy (Cloner, Result_Subtype (Source.all), Asis.Element (Target));
Set_Body_Declarative_Items
(Target.all,
Primary_Declaration_Lists.Deep_Copy
(Body_Declarative_Items (Source.all), Cloner, Asis.Element (Target)));
Set_Body_Statements
(Target.all,
Primary_Statement_Lists.Deep_Copy
(Body_Statements (Source.all), Cloner, Asis.Element (Target)));
Set_Body_Exception_Handlers
(Target.all,
Primary_Handler_Lists.Deep_Copy
(Body_Exception_Handlers (Source.all), Cloner, Asis.Element (Target)));
end Copy;
function New_Package_Body_Declaration_Node
(The_Context : ASIS.Context)
return Package_Body_Declaration_Ptr
is
Result : Package_Body_Declaration_Ptr :=
new Package_Body_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Package_Body_Declaration_Node;
function Declaration_Kind (Element : Package_Body_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Package_Body_Declaration;
end;
function Clone
(Element : Package_Body_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Package_Body_Declaration_Ptr := new Package_Body_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Declaration := Element.Corresponding_Declaration;
Result.Corresponding_Body_Stub := Element.Corresponding_Body_Stub;
Result.Is_Name_Repeated := Element.Is_Name_Repeated;
Result.Handled_Statements := Element.Handled_Statements;
Result.Compound_Name := Element.Compound_Name;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Package_Body_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Set_Body_Declarative_Items
(Target.all,
Primary_Declaration_Lists.Deep_Copy
(Body_Declarative_Items (Source.all), Cloner, Asis.Element (Target)));
Set_Body_Statements
(Target.all,
Primary_Statement_Lists.Deep_Copy
(Body_Statements (Source.all), Cloner, Asis.Element (Target)));
Set_Body_Exception_Handlers
(Target.all,
Primary_Handler_Lists.Deep_Copy
(Body_Exception_Handlers (Source.all), Cloner, Asis.Element (Target)));
end Copy;
function New_Task_Body_Declaration_Node
(The_Context : ASIS.Context)
return Task_Body_Declaration_Ptr
is
Result : Task_Body_Declaration_Ptr :=
new Task_Body_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Task_Body_Declaration_Node;
function Declaration_Kind (Element : Task_Body_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Task_Body_Declaration;
end;
function Clone
(Element : Task_Body_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Task_Body_Declaration_Ptr := new Task_Body_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Declaration := Element.Corresponding_Declaration;
Result.Corresponding_Body_Stub := Element.Corresponding_Body_Stub;
Result.Is_Name_Repeated := Element.Is_Name_Repeated;
Result.Handled_Statements := Element.Handled_Statements;
Result.Compound_Name := Element.Compound_Name;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Task_Body_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Set_Body_Declarative_Items
(Target.all,
Primary_Declaration_Lists.Deep_Copy
(Body_Declarative_Items (Source.all), Cloner, Asis.Element (Target)));
Set_Body_Statements
(Target.all,
Primary_Statement_Lists.Deep_Copy
(Body_Statements (Source.all), Cloner, Asis.Element (Target)));
Set_Body_Exception_Handlers
(Target.all,
Primary_Handler_Lists.Deep_Copy
(Body_Exception_Handlers (Source.all), Cloner, Asis.Element (Target)));
end Copy;
function Parameter_Profile
(Element : Entry_Body_Declaration_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List is
begin
return Primary_Parameter_Lists.To_Element_List
(Element.Parameter_Profile, Include_Pragmas);
end Parameter_Profile;
procedure Set_Parameter_Profile
(Element : in out Entry_Body_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Parameter_Profile := Primary_Parameter_Lists.List (Value);
end Set_Parameter_Profile;
function Parameter_Profile_List
(Element : Entry_Body_Declaration_Node) return Asis.Element is
begin
return Asis.Element (Element.Parameter_Profile);
end Parameter_Profile_List;
function Entry_Index_Specification
(Element : Entry_Body_Declaration_Node) return Asis.Declaration is
begin
return Element.Entry_Index_Specification;
end Entry_Index_Specification;
procedure Set_Entry_Index_Specification
(Element : in out Entry_Body_Declaration_Node;
Value : in Asis.Declaration) is
begin
Element.Entry_Index_Specification := Value;
end Set_Entry_Index_Specification;
function Entry_Barrier
(Element : Entry_Body_Declaration_Node) return Asis.Expression is
begin
return Element.Entry_Barrier;
end Entry_Barrier;
procedure Set_Entry_Barrier
(Element : in out Entry_Body_Declaration_Node;
Value : in Asis.Expression) is
begin
Element.Entry_Barrier := Value;
end Set_Entry_Barrier;
function Specification
(Element : Entry_Body_Declaration_Node) return Asis.Element is
begin
return Element.Specification;
end Specification;
procedure Set_Specification
(Element : in out Entry_Body_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Specification := Value;
end Set_Specification;
function New_Entry_Body_Declaration_Node
(The_Context : ASIS.Context)
return Entry_Body_Declaration_Ptr
is
Result : Entry_Body_Declaration_Ptr :=
new Entry_Body_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Entry_Body_Declaration_Node;
function Declaration_Kind (Element : Entry_Body_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return An_Entry_Body_Declaration;
end;
function Children (Element : access Entry_Body_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(False, Element.Entry_Index_Specification'Access),
(True, Asis.Element (Element.Parameter_Profile)),
(False, Element.Entry_Barrier'Access),
(True, Asis.Element (Element.Body_Declarative_Items)),
(True, Asis.Element (Element.Body_Statements)),
(True, Asis.Element (Element.Body_Exception_Handlers)));
end Children;
function Clone
(Element : Entry_Body_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Entry_Body_Declaration_Ptr := new Entry_Body_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Declaration := Element.Corresponding_Declaration;
Result.Corresponding_Body_Stub := Element.Corresponding_Body_Stub;
Result.Is_Name_Repeated := Element.Is_Name_Repeated;
Result.Handled_Statements := Element.Handled_Statements;
Result.Compound_Name := Element.Compound_Name;
Result.Specification := Element.Specification;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Entry_Body_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Entry_Index_Specification :=
Copy (Cloner, Entry_Index_Specification (Source.all), Asis.Element (Target));
Set_Parameter_Profile
(Target.all,
Primary_Parameter_Lists.Deep_Copy
(Parameter_Profile (Source.all), Cloner, Asis.Element (Target)));
Target.Entry_Barrier :=
Copy (Cloner, Entry_Barrier (Source.all), Asis.Element (Target));
Set_Body_Declarative_Items
(Target.all,
Primary_Declaration_Lists.Deep_Copy
(Body_Declarative_Items (Source.all), Cloner, Asis.Element (Target)));
Set_Body_Statements
(Target.all,
Primary_Statement_Lists.Deep_Copy
(Body_Statements (Source.all), Cloner, Asis.Element (Target)));
Set_Body_Exception_Handlers
(Target.all,
Primary_Handler_Lists.Deep_Copy
(Body_Exception_Handlers (Source.all), Cloner, Asis.Element (Target)));
end Copy;
function Renamed_Entity
(Element : Base_Renaming_Declaration_Node) return Asis.Expression is
begin
return Element.Renamed_Entity;
end Renamed_Entity;
procedure Set_Renamed_Entity
(Element : in out Base_Renaming_Declaration_Node;
Value : in Asis.Expression) is
begin
Element.Renamed_Entity := Value;
end Set_Renamed_Entity;
function Corresponding_Base_Entity
(Element : Base_Renaming_Declaration_Node) return Asis.Expression is
begin
return Element.Corresponding_Base_Entity;
end Corresponding_Base_Entity;
procedure Set_Corresponding_Base_Entity
(Element : in out Base_Renaming_Declaration_Node;
Value : in Asis.Expression) is
begin
Element.Corresponding_Base_Entity := Value;
end Set_Corresponding_Base_Entity;
function Children (Element : access Base_Renaming_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(False, Element.Renamed_Entity'Access));
end Children;
function Object_Declaration_Subtype
(Element : Object_Renaming_Declaration_Node) return Asis.Definition is
begin
return Element.Object_Declaration_Subtype;
end Object_Declaration_Subtype;
procedure Set_Object_Declaration_Subtype
(Element : in out Object_Renaming_Declaration_Node;
Value : in Asis.Definition) is
begin
Element.Object_Declaration_Subtype := Value;
end Set_Object_Declaration_Subtype;
function Has_Null_Exclusion
(Element : Object_Renaming_Declaration_Node) return Boolean is
begin
return Element.Has_Null_Exclusion;
end Has_Null_Exclusion;
procedure Set_Has_Null_Exclusion
(Element : in out Object_Renaming_Declaration_Node;
Value : in Boolean) is
begin
Element.Has_Null_Exclusion := Value;
end Set_Has_Null_Exclusion;
function New_Object_Renaming_Declaration_Node
(The_Context : ASIS.Context)
return Object_Renaming_Declaration_Ptr
is
Result : Object_Renaming_Declaration_Ptr :=
new Object_Renaming_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Object_Renaming_Declaration_Node;
function Declaration_Kind (Element : Object_Renaming_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return An_Object_Renaming_Declaration;
end;
function Children (Element : access Object_Renaming_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(False, Element.Object_Declaration_Subtype'Access),
(False, Element.Renamed_Entity'Access));
end Children;
function Clone
(Element : Object_Renaming_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Object_Renaming_Declaration_Ptr := new Object_Renaming_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Base_Entity := Element.Corresponding_Base_Entity;
Result.Has_Null_Exclusion := Element.Has_Null_Exclusion;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Object_Renaming_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Object_Declaration_Subtype :=
Copy (Cloner, Object_Declaration_Subtype (Source.all), Asis.Element (Target));
Target.Renamed_Entity :=
Copy (Cloner, Renamed_Entity (Source.all), Asis.Element (Target));
end Copy;
function New_Exception_Renaming_Declaration_Node
(The_Context : ASIS.Context)
return Exception_Renaming_Declaration_Ptr
is
Result : Exception_Renaming_Declaration_Ptr :=
new Exception_Renaming_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Exception_Renaming_Declaration_Node;
function Declaration_Kind (Element : Exception_Renaming_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return An_Exception_Renaming_Declaration;
end;
function Clone
(Element : Exception_Renaming_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Exception_Renaming_Declaration_Ptr := new Exception_Renaming_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Base_Entity := Element.Corresponding_Base_Entity;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Exception_Renaming_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Renamed_Entity :=
Copy (Cloner, Renamed_Entity (Source.all), Asis.Element (Target));
end Copy;
function New_Package_Renaming_Declaration_Node
(The_Context : ASIS.Context)
return Package_Renaming_Declaration_Ptr
is
Result : Package_Renaming_Declaration_Ptr :=
new Package_Renaming_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Package_Renaming_Declaration_Node;
function Declaration_Kind (Element : Package_Renaming_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Package_Renaming_Declaration;
end;
function Clone
(Element : Package_Renaming_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Package_Renaming_Declaration_Ptr := new Package_Renaming_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Base_Entity := Element.Corresponding_Base_Entity;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Package_Renaming_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Renamed_Entity :=
Copy (Cloner, Renamed_Entity (Source.all), Asis.Element (Target));
end Copy;
function Empty_Generic_Part
(Element : Generic_Package_Renaming_Declaration_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List is
begin
return Primary_Declaration_Lists.To_Element_List
(Element.Empty_Generic_Part, Include_Pragmas);
end Empty_Generic_Part;
procedure Set_Empty_Generic_Part
(Element : in out Generic_Package_Renaming_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Empty_Generic_Part := Primary_Declaration_Lists.List (Value);
end Set_Empty_Generic_Part;
function Empty_Generic_Part_List
(Element : Generic_Package_Renaming_Declaration_Node) return Asis.Element is
begin
return Asis.Element (Element.Empty_Generic_Part);
end Empty_Generic_Part_List;
function New_Generic_Package_Renaming_Declaration_Node
(The_Context : ASIS.Context)
return Generic_Package_Renaming_Declaration_Ptr
is
Result : Generic_Package_Renaming_Declaration_Ptr :=
new Generic_Package_Renaming_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Generic_Package_Renaming_Declaration_Node;
function Declaration_Kind (Element : Generic_Package_Renaming_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Generic_Package_Renaming_Declaration;
end;
function Clone
(Element : Generic_Package_Renaming_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Generic_Package_Renaming_Declaration_Ptr := new Generic_Package_Renaming_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Base_Entity := Element.Corresponding_Base_Entity;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Generic_Package_Renaming_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Renamed_Entity :=
Copy (Cloner, Renamed_Entity (Source.all), Asis.Element (Target));
end Copy;
function Specification
(Element : Generic_Procedure_Renaming_Declaration_Node) return Asis.Element is
begin
return Element.Specification;
end Specification;
procedure Set_Specification
(Element : in out Generic_Procedure_Renaming_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Specification := Value;
end Set_Specification;
function New_Generic_Procedure_Renaming_Declaration_Node
(The_Context : ASIS.Context)
return Generic_Procedure_Renaming_Declaration_Ptr
is
Result : Generic_Procedure_Renaming_Declaration_Ptr :=
new Generic_Procedure_Renaming_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Generic_Procedure_Renaming_Declaration_Node;
function Declaration_Kind (Element : Generic_Procedure_Renaming_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Generic_Procedure_Renaming_Declaration;
end;
function Clone
(Element : Generic_Procedure_Renaming_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Generic_Procedure_Renaming_Declaration_Ptr := new Generic_Procedure_Renaming_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Base_Entity := Element.Corresponding_Base_Entity;
Result.Specification := Element.Specification;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Generic_Procedure_Renaming_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Renamed_Entity :=
Copy (Cloner, Renamed_Entity (Source.all), Asis.Element (Target));
end Copy;
function New_Generic_Function_Renaming_Declaration_Node
(The_Context : ASIS.Context)
return Generic_Function_Renaming_Declaration_Ptr
is
Result : Generic_Function_Renaming_Declaration_Ptr :=
new Generic_Function_Renaming_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Generic_Function_Renaming_Declaration_Node;
function Declaration_Kind (Element : Generic_Function_Renaming_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Generic_Function_Renaming_Declaration;
end;
function Clone
(Element : Generic_Function_Renaming_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Generic_Function_Renaming_Declaration_Ptr := new Generic_Function_Renaming_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Base_Entity := Element.Corresponding_Base_Entity;
Result.Specification := Element.Specification;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Generic_Function_Renaming_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Renamed_Entity :=
Copy (Cloner, Renamed_Entity (Source.all), Asis.Element (Target));
end Copy;
function Discriminant_Part
(Element : Incomplete_Type_Declaration_Node) return Asis.Definition is
begin
return Element.Discriminant_Part;
end Discriminant_Part;
procedure Set_Discriminant_Part
(Element : in out Incomplete_Type_Declaration_Node;
Value : in Asis.Definition) is
begin
Element.Discriminant_Part := Value;
end Set_Discriminant_Part;
function Corresponding_Type_Declaration
(Element : Incomplete_Type_Declaration_Node) return Asis.Definition is
begin
return Element.Corresponding_Type_Declaration;
end Corresponding_Type_Declaration;
procedure Set_Corresponding_Type_Declaration
(Element : in out Incomplete_Type_Declaration_Node;
Value : in Asis.Definition) is
begin
Element.Corresponding_Type_Declaration := Value;
end Set_Corresponding_Type_Declaration;
function Type_Declaration_View
(Element : Incomplete_Type_Declaration_Node) return Asis.Definition is
begin
return Element.Type_Declaration_View;
end Type_Declaration_View;
procedure Set_Type_Declaration_View
(Element : in out Incomplete_Type_Declaration_Node;
Value : in Asis.Definition) is
begin
Element.Type_Declaration_View := Value;
end Set_Type_Declaration_View;
function New_Incomplete_Type_Declaration_Node
(The_Context : ASIS.Context)
return Incomplete_Type_Declaration_Ptr
is
Result : Incomplete_Type_Declaration_Ptr :=
new Incomplete_Type_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Incomplete_Type_Declaration_Node;
function Declaration_Kind (Element : Incomplete_Type_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return An_Incomplete_Type_Declaration;
end;
function Children (Element : access Incomplete_Type_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(False, Element.Discriminant_Part'Access),
(False, Element.Type_Declaration_View'Access));
end Children;
function Clone
(Element : Incomplete_Type_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Incomplete_Type_Declaration_Ptr := new Incomplete_Type_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Type_Declaration := Element.Corresponding_Type_Declaration;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Incomplete_Type_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Discriminant_Part :=
Copy (Cloner, Discriminant_Part (Source.all), Asis.Element (Target));
Target.Type_Declaration_View :=
Copy (Cloner, Type_Declaration_View (Source.all), Asis.Element (Target));
end Copy;
function Type_Declaration_View
(Element : Subtype_Declaration_Node) return Asis.Definition is
begin
return Element.Type_Declaration_View;
end Type_Declaration_View;
procedure Set_Type_Declaration_View
(Element : in out Subtype_Declaration_Node;
Value : in Asis.Definition) is
begin
Element.Type_Declaration_View := Value;
end Set_Type_Declaration_View;
function Corresponding_First_Subtype
(Element : Subtype_Declaration_Node) return Asis.Declaration is
begin
return Element.Corresponding_First_Subtype;
end Corresponding_First_Subtype;
procedure Set_Corresponding_First_Subtype
(Element : in out Subtype_Declaration_Node;
Value : in Asis.Declaration) is
begin
Element.Corresponding_First_Subtype := Value;
end Set_Corresponding_First_Subtype;
function Corresponding_Last_Constraint
(Element : Subtype_Declaration_Node) return Asis.Declaration is
begin
return Element.Corresponding_Last_Constraint;
end Corresponding_Last_Constraint;
procedure Set_Corresponding_Last_Constraint
(Element : in out Subtype_Declaration_Node;
Value : in Asis.Declaration) is
begin
Element.Corresponding_Last_Constraint := Value;
end Set_Corresponding_Last_Constraint;
function Corresponding_Last_Subtype
(Element : Subtype_Declaration_Node) return Asis.Declaration is
begin
return Element.Corresponding_Last_Subtype;
end Corresponding_Last_Subtype;
procedure Set_Corresponding_Last_Subtype
(Element : in out Subtype_Declaration_Node;
Value : in Asis.Declaration) is
begin
Element.Corresponding_Last_Subtype := Value;
end Set_Corresponding_Last_Subtype;
function New_Subtype_Declaration_Node
(The_Context : ASIS.Context)
return Subtype_Declaration_Ptr
is
Result : Subtype_Declaration_Ptr :=
new Subtype_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Subtype_Declaration_Node;
function Declaration_Kind (Element : Subtype_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Subtype_Declaration;
end;
function Children (Element : access Subtype_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(False, Element.Type_Declaration_View'Access));
end Children;
function Clone
(Element : Subtype_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Subtype_Declaration_Ptr := new Subtype_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_First_Subtype := Element.Corresponding_First_Subtype;
Result.Corresponding_Last_Constraint := Element.Corresponding_Last_Constraint;
Result.Corresponding_Last_Subtype := Element.Corresponding_Last_Subtype;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Subtype_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Type_Declaration_View :=
Copy (Cloner, Type_Declaration_View (Source.all), Asis.Element (Target));
end Copy;
function Object_Declaration_Subtype
(Element : Component_Declaration_Node) return Asis.Definition is
begin
return Element.Object_Declaration_Subtype;
end Object_Declaration_Subtype;
procedure Set_Object_Declaration_Subtype
(Element : in out Component_Declaration_Node;
Value : in Asis.Definition) is
begin
Element.Object_Declaration_Subtype := Value;
end Set_Object_Declaration_Subtype;
function Initialization_Expression
(Element : Component_Declaration_Node) return Asis.Expression is
begin
return Element.Initialization_Expression;
end Initialization_Expression;
procedure Set_Initialization_Expression
(Element : in out Component_Declaration_Node;
Value : in Asis.Expression) is
begin
Element.Initialization_Expression := Value;
end Set_Initialization_Expression;
function New_Component_Declaration_Node
(The_Context : ASIS.Context)
return Component_Declaration_Ptr
is
Result : Component_Declaration_Ptr :=
new Component_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Component_Declaration_Node;
function Declaration_Kind (Element : Component_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Component_Declaration;
end;
function Children (Element : access Component_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(False, Element.Object_Declaration_Subtype'Access),
(False, Element.Initialization_Expression'Access));
end Children;
function Clone
(Element : Component_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Component_Declaration_Ptr := new Component_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Component_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Object_Declaration_Subtype :=
Copy (Cloner, Object_Declaration_Subtype (Source.all), Asis.Element (Target));
Target.Initialization_Expression :=
Copy (Cloner, Initialization_Expression (Source.all), Asis.Element (Target));
end Copy;
function Trait_Kind
(Element : Variable_Declaration_Node) return Asis.Trait_Kinds is
begin
return Element.Trait_Kind;
end Trait_Kind;
procedure Set_Trait_Kind
(Element : in out Variable_Declaration_Node;
Value : in Asis.Trait_Kinds) is
begin
Element.Trait_Kind := Value;
end Set_Trait_Kind;
function New_Variable_Declaration_Node
(The_Context : ASIS.Context)
return Variable_Declaration_Ptr
is
Result : Variable_Declaration_Ptr :=
new Variable_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Variable_Declaration_Node;
function Declaration_Kind (Element : Variable_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Variable_Declaration;
end;
function Clone
(Element : Variable_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Variable_Declaration_Ptr := new Variable_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Trait_Kind := Element.Trait_Kind;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Variable_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Object_Declaration_Subtype :=
Copy (Cloner, Object_Declaration_Subtype (Source.all), Asis.Element (Target));
Target.Initialization_Expression :=
Copy (Cloner, Initialization_Expression (Source.all), Asis.Element (Target));
end Copy;
function New_Constant_Declaration_Node
(The_Context : ASIS.Context)
return Constant_Declaration_Ptr
is
Result : Constant_Declaration_Ptr :=
new Constant_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Constant_Declaration_Node;
function Declaration_Kind (Element : Constant_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Constant_Declaration;
end;
function Clone
(Element : Constant_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Constant_Declaration_Ptr := new Constant_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Trait_Kind := Element.Trait_Kind;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Constant_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Object_Declaration_Subtype :=
Copy (Cloner, Object_Declaration_Subtype (Source.all), Asis.Element (Target));
Target.Initialization_Expression :=
Copy (Cloner, Initialization_Expression (Source.all), Asis.Element (Target));
end Copy;
function New_Return_Object_Specification_Node
(The_Context : ASIS.Context)
return Return_Object_Specification_Ptr
is
Result : Return_Object_Specification_Ptr :=
new Return_Object_Specification_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Return_Object_Specification_Node;
function Declaration_Kind (Element : Return_Object_Specification_Node)
return Asis.Declaration_Kinds is
begin
return A_Return_Object_Specification;
end;
function Clone
(Element : Return_Object_Specification_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Return_Object_Specification_Ptr := new Return_Object_Specification_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Trait_Kind := Element.Trait_Kind;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Return_Object_Specification_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Object_Declaration_Subtype :=
Copy (Cloner, Object_Declaration_Subtype (Source.all), Asis.Element (Target));
Target.Initialization_Expression :=
Copy (Cloner, Initialization_Expression (Source.all), Asis.Element (Target));
end Copy;
function Object_Declaration_Subtype
(Element : Deferred_Constant_Declaration_Node) return Asis.Definition is
begin
return Element.Object_Declaration_Subtype;
end Object_Declaration_Subtype;
procedure Set_Object_Declaration_Subtype
(Element : in out Deferred_Constant_Declaration_Node;
Value : in Asis.Definition) is
begin
Element.Object_Declaration_Subtype := Value;
end Set_Object_Declaration_Subtype;
function Trait_Kind
(Element : Deferred_Constant_Declaration_Node) return Asis.Trait_Kinds is
begin
return Element.Trait_Kind;
end Trait_Kind;
procedure Set_Trait_Kind
(Element : in out Deferred_Constant_Declaration_Node;
Value : in Asis.Trait_Kinds) is
begin
Element.Trait_Kind := Value;
end Set_Trait_Kind;
function New_Deferred_Constant_Declaration_Node
(The_Context : ASIS.Context)
return Deferred_Constant_Declaration_Ptr
is
Result : Deferred_Constant_Declaration_Ptr :=
new Deferred_Constant_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Deferred_Constant_Declaration_Node;
function Declaration_Kind (Element : Deferred_Constant_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Deferred_Constant_Declaration;
end;
function Children (Element : access Deferred_Constant_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(False, Element.Object_Declaration_Subtype'Access));
end Children;
function Clone
(Element : Deferred_Constant_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Deferred_Constant_Declaration_Ptr := new Deferred_Constant_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Trait_Kind := Element.Trait_Kind;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Deferred_Constant_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Object_Declaration_Subtype :=
Copy (Cloner, Object_Declaration_Subtype (Source.all), Asis.Element (Target));
end Copy;
function Progenitor_List
(Element : Single_Protected_Declaration_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List is
begin
return Primary_Expression_Lists.To_Element_List
(Element.Progenitor_List, Include_Pragmas);
end Progenitor_List;
procedure Set_Progenitor_List
(Element : in out Single_Protected_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Progenitor_List := Primary_Expression_Lists.List (Value);
end Set_Progenitor_List;
function Progenitor_List_List
(Element : Single_Protected_Declaration_Node) return Asis.Element is
begin
return Asis.Element (Element.Progenitor_List);
end Progenitor_List_List;
function Object_Declaration_Subtype
(Element : Single_Protected_Declaration_Node) return Asis.Definition is
begin
return Element.Object_Declaration_Subtype;
end Object_Declaration_Subtype;
procedure Set_Object_Declaration_Subtype
(Element : in out Single_Protected_Declaration_Node;
Value : in Asis.Definition) is
begin
Element.Object_Declaration_Subtype := Value;
end Set_Object_Declaration_Subtype;
function Is_Name_Repeated
(Element : Single_Protected_Declaration_Node) return Boolean is
begin
return Element.Is_Name_Repeated;
end Is_Name_Repeated;
procedure Set_Is_Name_Repeated
(Element : in out Single_Protected_Declaration_Node;
Value : in Boolean) is
begin
Element.Is_Name_Repeated := Value;
end Set_Is_Name_Repeated;
function Corresponding_Body
(Element : Single_Protected_Declaration_Node) return Asis.Declaration is
begin
return Element.Corresponding_Body;
end Corresponding_Body;
procedure Set_Corresponding_Body
(Element : in out Single_Protected_Declaration_Node;
Value : in Asis.Declaration) is
begin
Element.Corresponding_Body := Value;
end Set_Corresponding_Body;
function New_Single_Protected_Declaration_Node
(The_Context : ASIS.Context)
return Single_Protected_Declaration_Ptr
is
Result : Single_Protected_Declaration_Ptr :=
new Single_Protected_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Single_Protected_Declaration_Node;
function Declaration_Kind (Element : Single_Protected_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Single_Protected_Declaration;
end;
function Children (Element : access Single_Protected_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(True, Asis.Element (Element.Progenitor_List)),
(False, Element.Object_Declaration_Subtype'Access));
end Children;
function Clone
(Element : Single_Protected_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Single_Protected_Declaration_Ptr := new Single_Protected_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Is_Name_Repeated := Element.Is_Name_Repeated;
Result.Corresponding_Body := Element.Corresponding_Body;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Single_Protected_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Set_Progenitor_List
(Target.all,
Primary_Expression_Lists.Deep_Copy
(Progenitor_List (Source.all), Cloner, Asis.Element (Target)));
Target.Object_Declaration_Subtype :=
Copy (Cloner, Object_Declaration_Subtype (Source.all), Asis.Element (Target));
end Copy;
function New_Single_Task_Declaration_Node
(The_Context : ASIS.Context)
return Single_Task_Declaration_Ptr
is
Result : Single_Task_Declaration_Ptr :=
new Single_Task_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Single_Task_Declaration_Node;
function Declaration_Kind (Element : Single_Task_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Single_Task_Declaration;
end;
function Clone
(Element : Single_Task_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Single_Task_Declaration_Ptr := new Single_Task_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Is_Name_Repeated := Element.Is_Name_Repeated;
Result.Corresponding_Body := Element.Corresponding_Body;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Single_Task_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Set_Progenitor_List
(Target.all,
Primary_Expression_Lists.Deep_Copy
(Progenitor_List (Source.all), Cloner, Asis.Element (Target)));
Target.Object_Declaration_Subtype :=
Copy (Cloner, Object_Declaration_Subtype (Source.all), Asis.Element (Target));
end Copy;
function Initialization_Expression
(Element : Integer_Number_Declaration_Node) return Asis.Expression is
begin
return Element.Initialization_Expression;
end Initialization_Expression;
procedure Set_Initialization_Expression
(Element : in out Integer_Number_Declaration_Node;
Value : in Asis.Expression) is
begin
Element.Initialization_Expression := Value;
end Set_Initialization_Expression;
function Declaration_Kind
(Element : Integer_Number_Declaration_Node) return Asis.Declaration_Kinds is
begin
return Element.Declaration_Kind;
end Declaration_Kind;
procedure Set_Declaration_Kind
(Element : in out Integer_Number_Declaration_Node;
Value : in Asis.Declaration_Kinds) is
begin
Element.Declaration_Kind := Value;
end Set_Declaration_Kind;
function New_Integer_Number_Declaration_Node
(The_Context : ASIS.Context)
return Integer_Number_Declaration_Ptr
is
Result : Integer_Number_Declaration_Ptr :=
new Integer_Number_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Integer_Number_Declaration_Node;
function Children (Element : access Integer_Number_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(False, Element.Initialization_Expression'Access));
end Children;
function Clone
(Element : Integer_Number_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Integer_Number_Declaration_Ptr := new Integer_Number_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Declaration_Kind := Element.Declaration_Kind;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Integer_Number_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Initialization_Expression :=
Copy (Cloner, Initialization_Expression (Source.all), Asis.Element (Target));
end Copy;
function New_Enumeration_Literal_Specification_Node
(The_Context : ASIS.Context)
return Enumeration_Literal_Specification_Ptr
is
Result : Enumeration_Literal_Specification_Ptr :=
new Enumeration_Literal_Specification_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Enumeration_Literal_Specification_Node;
function Declaration_Kind (Element : Enumeration_Literal_Specification_Node)
return Asis.Declaration_Kinds is
begin
return An_Enumeration_Literal_Specification;
end;
function Clone
(Element : Enumeration_Literal_Specification_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Enumeration_Literal_Specification_Ptr := new Enumeration_Literal_Specification_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Enumeration_Literal_Specification_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
end Copy;
function Object_Declaration_Subtype
(Element : Discriminant_Specification_Node) return Asis.Definition is
begin
return Element.Object_Declaration_Subtype;
end Object_Declaration_Subtype;
procedure Set_Object_Declaration_Subtype
(Element : in out Discriminant_Specification_Node;
Value : in Asis.Definition) is
begin
Element.Object_Declaration_Subtype := Value;
end Set_Object_Declaration_Subtype;
function Initialization_Expression
(Element : Discriminant_Specification_Node) return Asis.Expression is
begin
return Element.Initialization_Expression;
end Initialization_Expression;
procedure Set_Initialization_Expression
(Element : in out Discriminant_Specification_Node;
Value : in Asis.Expression) is
begin
Element.Initialization_Expression := Value;
end Set_Initialization_Expression;
function Trait_Kind
(Element : Discriminant_Specification_Node) return Asis.Trait_Kinds is
begin
return Element.Trait_Kind;
end Trait_Kind;
procedure Set_Trait_Kind
(Element : in out Discriminant_Specification_Node;
Value : in Asis.Trait_Kinds) is
begin
Element.Trait_Kind := Value;
end Set_Trait_Kind;
function Has_Null_Exclusion
(Element : Discriminant_Specification_Node) return Boolean is
begin
return Element.Has_Null_Exclusion;
end Has_Null_Exclusion;
procedure Set_Has_Null_Exclusion
(Element : in out Discriminant_Specification_Node;
Value : in Boolean) is
begin
Element.Has_Null_Exclusion := Value;
end Set_Has_Null_Exclusion;
function New_Discriminant_Specification_Node
(The_Context : ASIS.Context)
return Discriminant_Specification_Ptr
is
Result : Discriminant_Specification_Ptr :=
new Discriminant_Specification_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Discriminant_Specification_Node;
function Declaration_Kind (Element : Discriminant_Specification_Node)
return Asis.Declaration_Kinds is
begin
return A_Discriminant_Specification;
end;
function Children (Element : access Discriminant_Specification_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(False, Element.Object_Declaration_Subtype'Access),
(False, Element.Initialization_Expression'Access));
end Children;
function Clone
(Element : Discriminant_Specification_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Discriminant_Specification_Ptr := new Discriminant_Specification_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Trait_Kind := Element.Trait_Kind;
Result.Has_Null_Exclusion := Element.Has_Null_Exclusion;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Discriminant_Specification_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Object_Declaration_Subtype :=
Copy (Cloner, Object_Declaration_Subtype (Source.all), Asis.Element (Target));
Target.Initialization_Expression :=
Copy (Cloner, Initialization_Expression (Source.all), Asis.Element (Target));
end Copy;
function Specification_Subtype_Definition
(Element : Entry_Index_Specification_Node) return Asis.Discrete_Subtype_Definition is
begin
return Element.Specification_Subtype_Definition;
end Specification_Subtype_Definition;
procedure Set_Specification_Subtype_Definition
(Element : in out Entry_Index_Specification_Node;
Value : in Asis.Discrete_Subtype_Definition) is
begin
Element.Specification_Subtype_Definition := Value;
end Set_Specification_Subtype_Definition;
function New_Entry_Index_Specification_Node
(The_Context : ASIS.Context)
return Entry_Index_Specification_Ptr
is
Result : Entry_Index_Specification_Ptr :=
new Entry_Index_Specification_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Entry_Index_Specification_Node;
function Declaration_Kind (Element : Entry_Index_Specification_Node)
return Asis.Declaration_Kinds is
begin
return An_Entry_Index_Specification;
end;
function Children (Element : access Entry_Index_Specification_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(False, Element.Specification_Subtype_Definition'Access));
end Children;
function Clone
(Element : Entry_Index_Specification_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Entry_Index_Specification_Ptr := new Entry_Index_Specification_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Entry_Index_Specification_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Specification_Subtype_Definition :=
Copy (Cloner, Specification_Subtype_Definition (Source.all), Asis.Element (Target));
end Copy;
function Trait_Kind
(Element : Loop_Parameter_Specification_Node) return Asis.Trait_Kinds is
begin
return Element.Trait_Kind;
end Trait_Kind;
procedure Set_Trait_Kind
(Element : in out Loop_Parameter_Specification_Node;
Value : in Asis.Trait_Kinds) is
begin
Element.Trait_Kind := Value;
end Set_Trait_Kind;
function New_Loop_Parameter_Specification_Node
(The_Context : ASIS.Context)
return Loop_Parameter_Specification_Ptr
is
Result : Loop_Parameter_Specification_Ptr :=
new Loop_Parameter_Specification_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Loop_Parameter_Specification_Node;
function Declaration_Kind (Element : Loop_Parameter_Specification_Node)
return Asis.Declaration_Kinds is
begin
return A_Loop_Parameter_Specification;
end;
function Clone
(Element : Loop_Parameter_Specification_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Loop_Parameter_Specification_Ptr := new Loop_Parameter_Specification_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Trait_Kind := Element.Trait_Kind;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Loop_Parameter_Specification_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Specification_Subtype_Definition :=
Copy (Cloner, Specification_Subtype_Definition (Source.all), Asis.Element (Target));
end Copy;
function Mode_Kind
(Element : Formal_Object_Declaration_Node) return Asis.Mode_Kinds is
begin
return Element.Mode_Kind;
end Mode_Kind;
procedure Set_Mode_Kind
(Element : in out Formal_Object_Declaration_Node;
Value : in Asis.Mode_Kinds) is
begin
Element.Mode_Kind := Value;
end Set_Mode_Kind;
function Object_Declaration_Subtype
(Element : Formal_Object_Declaration_Node) return Asis.Definition is
begin
return Element.Object_Declaration_Subtype;
end Object_Declaration_Subtype;
procedure Set_Object_Declaration_Subtype
(Element : in out Formal_Object_Declaration_Node;
Value : in Asis.Definition) is
begin
Element.Object_Declaration_Subtype := Value;
end Set_Object_Declaration_Subtype;
function Initialization_Expression
(Element : Formal_Object_Declaration_Node) return Asis.Expression is
begin
return Element.Initialization_Expression;
end Initialization_Expression;
procedure Set_Initialization_Expression
(Element : in out Formal_Object_Declaration_Node;
Value : in Asis.Expression) is
begin
Element.Initialization_Expression := Value;
end Set_Initialization_Expression;
function Has_Null_Exclusion
(Element : Formal_Object_Declaration_Node) return Boolean is
begin
return Element.Has_Null_Exclusion;
end Has_Null_Exclusion;
procedure Set_Has_Null_Exclusion
(Element : in out Formal_Object_Declaration_Node;
Value : in Boolean) is
begin
Element.Has_Null_Exclusion := Value;
end Set_Has_Null_Exclusion;
function Generic_Actual
(Element : Formal_Object_Declaration_Node) return Asis.Expression is
begin
return Element.Generic_Actual;
end Generic_Actual;
procedure Set_Generic_Actual
(Element : in out Formal_Object_Declaration_Node;
Value : in Asis.Expression) is
begin
Element.Generic_Actual := Value;
end Set_Generic_Actual;
function New_Formal_Object_Declaration_Node
(The_Context : ASIS.Context)
return Formal_Object_Declaration_Ptr
is
Result : Formal_Object_Declaration_Ptr :=
new Formal_Object_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Formal_Object_Declaration_Node;
function Declaration_Kind (Element : Formal_Object_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Formal_Object_Declaration;
end;
function Children (Element : access Formal_Object_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(False, Element.Object_Declaration_Subtype'Access),
(False, Element.Initialization_Expression'Access));
end Children;
function Clone
(Element : Formal_Object_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Formal_Object_Declaration_Ptr := new Formal_Object_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Mode_Kind := Element.Mode_Kind;
Result.Has_Null_Exclusion := Element.Has_Null_Exclusion;
Result.Generic_Actual := Element.Generic_Actual;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Formal_Object_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Object_Declaration_Subtype :=
Copy (Cloner, Object_Declaration_Subtype (Source.all), Asis.Element (Target));
Target.Initialization_Expression :=
Copy (Cloner, Initialization_Expression (Source.all), Asis.Element (Target));
end Copy;
function Trait_Kind
(Element : Parameter_Specification_Node) return Asis.Trait_Kinds is
begin
return Element.Trait_Kind;
end Trait_Kind;
procedure Set_Trait_Kind
(Element : in out Parameter_Specification_Node;
Value : in Asis.Trait_Kinds) is
begin
Element.Trait_Kind := Value;
end Set_Trait_Kind;
function New_Parameter_Specification_Node
(The_Context : ASIS.Context)
return Parameter_Specification_Ptr
is
Result : Parameter_Specification_Ptr :=
new Parameter_Specification_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Parameter_Specification_Node;
function Declaration_Kind (Element : Parameter_Specification_Node)
return Asis.Declaration_Kinds is
begin
return A_Parameter_Specification;
end;
function Clone
(Element : Parameter_Specification_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Parameter_Specification_Ptr := new Parameter_Specification_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Mode_Kind := Element.Mode_Kind;
Result.Has_Null_Exclusion := Element.Has_Null_Exclusion;
Result.Generic_Actual := Element.Generic_Actual;
Result.Trait_Kind := Element.Trait_Kind;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Parameter_Specification_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Object_Declaration_Subtype :=
Copy (Cloner, Object_Declaration_Subtype (Source.all), Asis.Element (Target));
Target.Initialization_Expression :=
Copy (Cloner, Initialization_Expression (Source.all), Asis.Element (Target));
end Copy;
function Is_Name_Repeated
(Element : Package_Declaration_Node) return Boolean is
begin
return Element.Is_Name_Repeated;
end Is_Name_Repeated;
procedure Set_Is_Name_Repeated
(Element : in out Package_Declaration_Node;
Value : in Boolean) is
begin
Element.Is_Name_Repeated := Value;
end Set_Is_Name_Repeated;
function Corresponding_Declaration
(Element : Package_Declaration_Node) return Asis.Declaration is
begin
return Element.Corresponding_Declaration;
end Corresponding_Declaration;
procedure Set_Corresponding_Declaration
(Element : in out Package_Declaration_Node;
Value : in Asis.Declaration) is
begin
Element.Corresponding_Declaration := Value;
end Set_Corresponding_Declaration;
function Corresponding_Body
(Element : Package_Declaration_Node) return Asis.Declaration is
begin
return Element.Corresponding_Body;
end Corresponding_Body;
procedure Set_Corresponding_Body
(Element : in out Package_Declaration_Node;
Value : in Asis.Declaration) is
begin
Element.Corresponding_Body := Value;
end Set_Corresponding_Body;
function Is_Private_Present
(Element : Package_Declaration_Node) return Boolean is
begin
return Element.Is_Private_Present;
end Is_Private_Present;
procedure Set_Is_Private_Present
(Element : in out Package_Declaration_Node;
Value : in Boolean) is
begin
Element.Is_Private_Present := Value;
end Set_Is_Private_Present;
function Generic_Formal_Part
(Element : Package_Declaration_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List is
begin
return Primary_Declaration_Lists.To_Element_List
(Element.Generic_Formal_Part, Include_Pragmas);
end Generic_Formal_Part;
procedure Set_Generic_Formal_Part
(Element : in out Package_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Generic_Formal_Part := Primary_Declaration_Lists.List (Value);
end Set_Generic_Formal_Part;
function Generic_Formal_Part_List
(Element : Package_Declaration_Node) return Asis.Element is
begin
return Asis.Element (Element.Generic_Formal_Part);
end Generic_Formal_Part_List;
function Visible_Part_Declarative_Items
(Element : Package_Declaration_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List is
begin
return Primary_Declaration_Lists.To_Element_List
(Element.Visible_Part_Declarative_Items, Include_Pragmas);
end Visible_Part_Declarative_Items;
procedure Set_Visible_Part_Declarative_Items
(Element : in out Package_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Visible_Part_Declarative_Items := Primary_Declaration_Lists.List (Value);
end Set_Visible_Part_Declarative_Items;
function Visible_Part_Declarative_Items_List
(Element : Package_Declaration_Node) return Asis.Element is
begin
return Asis.Element (Element.Visible_Part_Declarative_Items);
end Visible_Part_Declarative_Items_List;
function Private_Part_Declarative_Items
(Element : Package_Declaration_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List is
begin
return Primary_Declaration_Lists.To_Element_List
(Element.Private_Part_Declarative_Items, Include_Pragmas);
end Private_Part_Declarative_Items;
procedure Set_Private_Part_Declarative_Items
(Element : in out Package_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Private_Part_Declarative_Items := Primary_Declaration_Lists.List (Value);
end Set_Private_Part_Declarative_Items;
function Private_Part_Declarative_Items_List
(Element : Package_Declaration_Node) return Asis.Element is
begin
return Asis.Element (Element.Private_Part_Declarative_Items);
end Private_Part_Declarative_Items_List;
function Package_Specification
(Element : Package_Declaration_Node) return Asis.Element is
begin
return Element.Package_Specification;
end Package_Specification;
procedure Set_Package_Specification
(Element : in out Package_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Package_Specification := Value;
end Set_Package_Specification;
function New_Package_Declaration_Node
(The_Context : ASIS.Context)
return Package_Declaration_Ptr
is
Result : Package_Declaration_Ptr :=
new Package_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Package_Declaration_Node;
function Declaration_Kind (Element : Package_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Package_Declaration;
end;
function Children (Element : access Package_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Generic_Formal_Part)),
(True, Asis.Element (Element.Names)),
(True, Asis.Element (Element.Visible_Part_Declarative_Items)),
(True, Asis.Element (Element.Private_Part_Declarative_Items)));
end Children;
function Clone
(Element : Package_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Package_Declaration_Ptr := new Package_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Is_Name_Repeated := Element.Is_Name_Repeated;
Result.Corresponding_Declaration := Element.Corresponding_Declaration;
Result.Corresponding_Body := Element.Corresponding_Body;
Result.Is_Private_Present := Element.Is_Private_Present;
Result.Package_Specification := Element.Package_Specification;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Package_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Generic_Formal_Part
(Target.all,
Primary_Declaration_Lists.Deep_Copy
(Generic_Formal_Part (Source.all), Cloner, Asis.Element (Target)));
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Set_Visible_Part_Declarative_Items
(Target.all,
Primary_Declaration_Lists.Deep_Copy
(Visible_Part_Declarative_Items (Source.all), Cloner, Asis.Element (Target)));
Set_Private_Part_Declarative_Items
(Target.all,
Primary_Declaration_Lists.Deep_Copy
(Private_Part_Declarative_Items (Source.all), Cloner, Asis.Element (Target)));
end Copy;
function Is_Name_Repeated
(Element : Protected_Body_Declaration_Node) return Boolean is
begin
return Element.Is_Name_Repeated;
end Is_Name_Repeated;
procedure Set_Is_Name_Repeated
(Element : in out Protected_Body_Declaration_Node;
Value : in Boolean) is
begin
Element.Is_Name_Repeated := Value;
end Set_Is_Name_Repeated;
function Corresponding_Declaration
(Element : Protected_Body_Declaration_Node) return Asis.Declaration is
begin
return Element.Corresponding_Declaration;
end Corresponding_Declaration;
procedure Set_Corresponding_Declaration
(Element : in out Protected_Body_Declaration_Node;
Value : in Asis.Declaration) is
begin
Element.Corresponding_Declaration := Value;
end Set_Corresponding_Declaration;
function Protected_Operation_Items
(Element : Protected_Body_Declaration_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List is
begin
return Primary_Declaration_Lists.To_Element_List
(Element.Protected_Operation_Items, Include_Pragmas);
end Protected_Operation_Items;
procedure Set_Protected_Operation_Items
(Element : in out Protected_Body_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Protected_Operation_Items := Primary_Declaration_Lists.List (Value);
end Set_Protected_Operation_Items;
function Protected_Operation_Items_List
(Element : Protected_Body_Declaration_Node) return Asis.Element is
begin
return Asis.Element (Element.Protected_Operation_Items);
end Protected_Operation_Items_List;
function Corresponding_Body_Stub
(Element : Protected_Body_Declaration_Node) return Asis.Declaration is
begin
return Element.Corresponding_Body_Stub;
end Corresponding_Body_Stub;
procedure Set_Corresponding_Body_Stub
(Element : in out Protected_Body_Declaration_Node;
Value : in Asis.Declaration) is
begin
Element.Corresponding_Body_Stub := Value;
end Set_Corresponding_Body_Stub;
function Get_Identifier
(Element : Protected_Body_Declaration_Node) return Asis.Element is
begin
return Element.Identifier;
end Get_Identifier;
procedure Set_Identifier
(Element : in out Protected_Body_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Identifier := Value;
end Set_Identifier;
function New_Protected_Body_Declaration_Node
(The_Context : ASIS.Context)
return Protected_Body_Declaration_Ptr
is
Result : Protected_Body_Declaration_Ptr :=
new Protected_Body_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Protected_Body_Declaration_Node;
function Declaration_Kind (Element : Protected_Body_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Protected_Body_Declaration;
end;
function Children (Element : access Protected_Body_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(True, Asis.Element (Element.Protected_Operation_Items)));
end Children;
function Clone
(Element : Protected_Body_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Protected_Body_Declaration_Ptr := new Protected_Body_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Is_Name_Repeated := Element.Is_Name_Repeated;
Result.Corresponding_Declaration := Element.Corresponding_Declaration;
Result.Corresponding_Body_Stub := Element.Corresponding_Body_Stub;
Result.Identifier := Element.Identifier;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Protected_Body_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Set_Protected_Operation_Items
(Target.all,
Primary_Declaration_Lists.Deep_Copy
(Protected_Operation_Items (Source.all), Cloner, Asis.Element (Target)));
end Copy;
function Corresponding_Subunit
(Element : Package_Body_Stub_Node) return Asis.Declaration is
begin
return Element.Corresponding_Subunit;
end Corresponding_Subunit;
procedure Set_Corresponding_Subunit
(Element : in out Package_Body_Stub_Node;
Value : in Asis.Declaration) is
begin
Element.Corresponding_Subunit := Value;
end Set_Corresponding_Subunit;
function Corresponding_Declaration
(Element : Package_Body_Stub_Node) return Asis.Declaration is
begin
return Element.Corresponding_Declaration;
end Corresponding_Declaration;
procedure Set_Corresponding_Declaration
(Element : in out Package_Body_Stub_Node;
Value : in Asis.Declaration) is
begin
Element.Corresponding_Declaration := Value;
end Set_Corresponding_Declaration;
function New_Package_Body_Stub_Node
(The_Context : ASIS.Context)
return Package_Body_Stub_Ptr
is
Result : Package_Body_Stub_Ptr :=
new Package_Body_Stub_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Package_Body_Stub_Node;
function Declaration_Kind (Element : Package_Body_Stub_Node)
return Asis.Declaration_Kinds is
begin
return A_Package_Body_Stub;
end;
function Clone
(Element : Package_Body_Stub_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Package_Body_Stub_Ptr := new Package_Body_Stub_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Subunit := Element.Corresponding_Subunit;
Result.Corresponding_Declaration := Element.Corresponding_Declaration;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Package_Body_Stub_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
end Copy;
function New_Task_Body_Stub_Node
(The_Context : ASIS.Context)
return Task_Body_Stub_Ptr
is
Result : Task_Body_Stub_Ptr :=
new Task_Body_Stub_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Task_Body_Stub_Node;
function Declaration_Kind (Element : Task_Body_Stub_Node)
return Asis.Declaration_Kinds is
begin
return A_Task_Body_Stub;
end;
function Clone
(Element : Task_Body_Stub_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Task_Body_Stub_Ptr := new Task_Body_Stub_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Subunit := Element.Corresponding_Subunit;
Result.Corresponding_Declaration := Element.Corresponding_Declaration;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Task_Body_Stub_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
end Copy;
function New_Protected_Body_Stub_Node
(The_Context : ASIS.Context)
return Protected_Body_Stub_Ptr
is
Result : Protected_Body_Stub_Ptr :=
new Protected_Body_Stub_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Protected_Body_Stub_Node;
function Declaration_Kind (Element : Protected_Body_Stub_Node)
return Asis.Declaration_Kinds is
begin
return A_Protected_Body_Stub;
end;
function Clone
(Element : Protected_Body_Stub_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Protected_Body_Stub_Ptr := new Protected_Body_Stub_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Subunit := Element.Corresponding_Subunit;
Result.Corresponding_Declaration := Element.Corresponding_Declaration;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Protected_Body_Stub_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
end Copy;
function New_Exception_Declaration_Node
(The_Context : ASIS.Context)
return Exception_Declaration_Ptr
is
Result : Exception_Declaration_Ptr :=
new Exception_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Exception_Declaration_Node;
function Declaration_Kind (Element : Exception_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return An_Exception_Declaration;
end;
function Clone
(Element : Exception_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Exception_Declaration_Ptr := new Exception_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Exception_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
end Copy;
function New_Choice_Parameter_Specification_Node
(The_Context : ASIS.Context)
return Choice_Parameter_Specification_Ptr
is
Result : Choice_Parameter_Specification_Ptr :=
new Choice_Parameter_Specification_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Choice_Parameter_Specification_Node;
function Declaration_Kind (Element : Choice_Parameter_Specification_Node)
return Asis.Declaration_Kinds is
begin
return A_Choice_Parameter_Specification;
end;
function Clone
(Element : Choice_Parameter_Specification_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Choice_Parameter_Specification_Ptr := new Choice_Parameter_Specification_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Choice_Parameter_Specification_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
end Copy;
function Is_Name_Repeated
(Element : Generic_Package_Declaration_Node) return Boolean is
begin
return Element.Is_Name_Repeated;
end Is_Name_Repeated;
procedure Set_Is_Name_Repeated
(Element : in out Generic_Package_Declaration_Node;
Value : in Boolean) is
begin
Element.Is_Name_Repeated := Value;
end Set_Is_Name_Repeated;
function Corresponding_Body
(Element : Generic_Package_Declaration_Node) return Asis.Declaration is
begin
return Element.Corresponding_Body;
end Corresponding_Body;
procedure Set_Corresponding_Body
(Element : in out Generic_Package_Declaration_Node;
Value : in Asis.Declaration) is
begin
Element.Corresponding_Body := Value;
end Set_Corresponding_Body;
function Is_Private_Present
(Element : Generic_Package_Declaration_Node) return Boolean is
begin
return Element.Is_Private_Present;
end Is_Private_Present;
procedure Set_Is_Private_Present
(Element : in out Generic_Package_Declaration_Node;
Value : in Boolean) is
begin
Element.Is_Private_Present := Value;
end Set_Is_Private_Present;
function Visible_Part_Declarative_Items
(Element : Generic_Package_Declaration_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List is
begin
return Primary_Declaration_Lists.To_Element_List
(Element.Visible_Part_Declarative_Items, Include_Pragmas);
end Visible_Part_Declarative_Items;
procedure Set_Visible_Part_Declarative_Items
(Element : in out Generic_Package_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Visible_Part_Declarative_Items := Primary_Declaration_Lists.List (Value);
end Set_Visible_Part_Declarative_Items;
function Visible_Part_Declarative_Items_List
(Element : Generic_Package_Declaration_Node) return Asis.Element is
begin
return Asis.Element (Element.Visible_Part_Declarative_Items);
end Visible_Part_Declarative_Items_List;
function Private_Part_Declarative_Items
(Element : Generic_Package_Declaration_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List is
begin
return Primary_Declaration_Lists.To_Element_List
(Element.Private_Part_Declarative_Items, Include_Pragmas);
end Private_Part_Declarative_Items;
procedure Set_Private_Part_Declarative_Items
(Element : in out Generic_Package_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Private_Part_Declarative_Items := Primary_Declaration_Lists.List (Value);
end Set_Private_Part_Declarative_Items;
function Private_Part_Declarative_Items_List
(Element : Generic_Package_Declaration_Node) return Asis.Element is
begin
return Asis.Element (Element.Private_Part_Declarative_Items);
end Private_Part_Declarative_Items_List;
function Generic_Formal_Part
(Element : Generic_Package_Declaration_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List is
begin
return Primary_Declaration_Lists.To_Element_List
(Element.Generic_Formal_Part, Include_Pragmas);
end Generic_Formal_Part;
procedure Set_Generic_Formal_Part
(Element : in out Generic_Package_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Generic_Formal_Part := Primary_Declaration_Lists.List (Value);
end Set_Generic_Formal_Part;
function Generic_Formal_Part_List
(Element : Generic_Package_Declaration_Node) return Asis.Element is
begin
return Asis.Element (Element.Generic_Formal_Part);
end Generic_Formal_Part_List;
function Specification
(Element : Generic_Package_Declaration_Node) return Asis.Element is
begin
return Element.Specification;
end Specification;
procedure Set_Specification
(Element : in out Generic_Package_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Specification := Value;
end Set_Specification;
function New_Generic_Package_Declaration_Node
(The_Context : ASIS.Context)
return Generic_Package_Declaration_Ptr
is
Result : Generic_Package_Declaration_Ptr :=
new Generic_Package_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Generic_Package_Declaration_Node;
function Declaration_Kind (Element : Generic_Package_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Generic_Package_Declaration;
end;
function Children (Element : access Generic_Package_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Generic_Formal_Part)),
(True, Asis.Element (Element.Names)),
(True, Asis.Element (Element.Visible_Part_Declarative_Items)),
(True, Asis.Element (Element.Private_Part_Declarative_Items)));
end Children;
function Clone
(Element : Generic_Package_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Generic_Package_Declaration_Ptr := new Generic_Package_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Is_Name_Repeated := Element.Is_Name_Repeated;
Result.Corresponding_Body := Element.Corresponding_Body;
Result.Is_Private_Present := Element.Is_Private_Present;
Result.Specification := Element.Specification;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Generic_Package_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Generic_Formal_Part
(Target.all,
Primary_Declaration_Lists.Deep_Copy
(Generic_Formal_Part (Source.all), Cloner, Asis.Element (Target)));
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Set_Visible_Part_Declarative_Items
(Target.all,
Primary_Declaration_Lists.Deep_Copy
(Visible_Part_Declarative_Items (Source.all), Cloner, Asis.Element (Target)));
Set_Private_Part_Declarative_Items
(Target.all,
Primary_Declaration_Lists.Deep_Copy
(Private_Part_Declarative_Items (Source.all), Cloner, Asis.Element (Target)));
end Copy;
function Corresponding_Declaration
(Element : Formal_Package_Declaration_With_Box_Node) return Asis.Declaration is
begin
return Element.Corresponding_Declaration;
end Corresponding_Declaration;
procedure Set_Corresponding_Declaration
(Element : in out Formal_Package_Declaration_With_Box_Node;
Value : in Asis.Declaration) is
begin
Element.Corresponding_Declaration := Value;
end Set_Corresponding_Declaration;
function Corresponding_Body
(Element : Formal_Package_Declaration_With_Box_Node) return Asis.Declaration is
begin
return Element.Corresponding_Body;
end Corresponding_Body;
procedure Set_Corresponding_Body
(Element : in out Formal_Package_Declaration_With_Box_Node;
Value : in Asis.Declaration) is
begin
Element.Corresponding_Body := Value;
end Set_Corresponding_Body;
function Generic_Unit_Name
(Element : Formal_Package_Declaration_With_Box_Node) return Asis.Expression is
begin
return Element.Generic_Unit_Name;
end Generic_Unit_Name;
procedure Set_Generic_Unit_Name
(Element : in out Formal_Package_Declaration_With_Box_Node;
Value : in Asis.Expression) is
begin
Element.Generic_Unit_Name := Value;
end Set_Generic_Unit_Name;
function Normalized_Generic_Actual_Part
(Element : Formal_Package_Declaration_With_Box_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List is
begin
return Secondary_Association_Lists.To_Element_List
(Element.Normalized_Generic_Actual_Part, Include_Pragmas);
end Normalized_Generic_Actual_Part;
procedure Add_To_Normalized_Generic_Actual_Part
(Element : in out Formal_Package_Declaration_With_Box_Node;
Item : in Asis.Element) is
begin
Secondary_Association_Lists.Add (Element.Normalized_Generic_Actual_Part, Item);
end Add_To_Normalized_Generic_Actual_Part;
function Generic_Actual
(Element : Formal_Package_Declaration_With_Box_Node) return Asis.Expression is
begin
return Element.Generic_Actual;
end Generic_Actual;
procedure Set_Generic_Actual
(Element : in out Formal_Package_Declaration_With_Box_Node;
Value : in Asis.Expression) is
begin
Element.Generic_Actual := Value;
end Set_Generic_Actual;
function New_Formal_Package_Declaration_With_Box_Node
(The_Context : ASIS.Context)
return Formal_Package_Declaration_With_Box_Ptr
is
Result : Formal_Package_Declaration_With_Box_Ptr :=
new Formal_Package_Declaration_With_Box_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Formal_Package_Declaration_With_Box_Node;
function Declaration_Kind (Element : Formal_Package_Declaration_With_Box_Node)
return Asis.Declaration_Kinds is
begin
return A_Formal_Package_Declaration_With_Box;
end;
function Children (Element : access Formal_Package_Declaration_With_Box_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(False, Element.Generic_Unit_Name'Access));
end Children;
function Clone
(Element : Formal_Package_Declaration_With_Box_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Formal_Package_Declaration_With_Box_Ptr := new Formal_Package_Declaration_With_Box_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Declaration := Element.Corresponding_Declaration;
Result.Corresponding_Body := Element.Corresponding_Body;
null;
Result.Generic_Actual := Element.Generic_Actual;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Formal_Package_Declaration_With_Box_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Generic_Unit_Name :=
Copy (Cloner, Generic_Unit_Name (Source.all), Asis.Element (Target));
end Copy;
function Generic_Actual_Part
(Element : Package_Instantiation_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List is
begin
return Primary_Association_Lists.To_Element_List
(Element.Generic_Actual_Part, Include_Pragmas);
end Generic_Actual_Part;
procedure Set_Generic_Actual_Part
(Element : in out Package_Instantiation_Node;
Value : in Asis.Element) is
begin
Element.Generic_Actual_Part := Primary_Association_Lists.List (Value);
end Set_Generic_Actual_Part;
function Generic_Actual_Part_List
(Element : Package_Instantiation_Node) return Asis.Element is
begin
return Asis.Element (Element.Generic_Actual_Part);
end Generic_Actual_Part_List;
function New_Package_Instantiation_Node
(The_Context : ASIS.Context)
return Package_Instantiation_Ptr
is
Result : Package_Instantiation_Ptr :=
new Package_Instantiation_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Package_Instantiation_Node;
function Declaration_Kind (Element : Package_Instantiation_Node)
return Asis.Declaration_Kinds is
begin
return A_Package_Instantiation;
end;
function Children (Element : access Package_Instantiation_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(False, Element.Generic_Unit_Name'Access),
(True, Asis.Element (Element.Generic_Actual_Part)));
end Children;
function Clone
(Element : Package_Instantiation_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Package_Instantiation_Ptr := new Package_Instantiation_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Declaration := Element.Corresponding_Declaration;
Result.Corresponding_Body := Element.Corresponding_Body;
null;
Result.Generic_Actual := Element.Generic_Actual;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Package_Instantiation_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Generic_Unit_Name :=
Copy (Cloner, Generic_Unit_Name (Source.all), Asis.Element (Target));
Set_Generic_Actual_Part
(Target.all,
Primary_Association_Lists.Deep_Copy
(Generic_Actual_Part (Source.all), Cloner, Asis.Element (Target)));
end Copy;
function Specification
(Element : Procedure_Instantiation_Node) return Asis.Element is
begin
return Element.Specification;
end Specification;
procedure Set_Specification
(Element : in out Procedure_Instantiation_Node;
Value : in Asis.Element) is
begin
Element.Specification := Value;
end Set_Specification;
function Overriding_Indicator_Kind
(Element : Procedure_Instantiation_Node) return Asis.Overriding_Indicator_Kinds is
begin
return Element.Overriding_Indicator_Kind;
end Overriding_Indicator_Kind;
procedure Set_Overriding_Indicator_Kind
(Element : in out Procedure_Instantiation_Node;
Value : in Asis.Overriding_Indicator_Kinds) is
begin
Element.Overriding_Indicator_Kind := Value;
end Set_Overriding_Indicator_Kind;
function New_Procedure_Instantiation_Node
(The_Context : ASIS.Context)
return Procedure_Instantiation_Ptr
is
Result : Procedure_Instantiation_Ptr :=
new Procedure_Instantiation_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Procedure_Instantiation_Node;
function Declaration_Kind (Element : Procedure_Instantiation_Node)
return Asis.Declaration_Kinds is
begin
return A_Procedure_Instantiation;
end;
function Clone
(Element : Procedure_Instantiation_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Procedure_Instantiation_Ptr := new Procedure_Instantiation_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Declaration := Element.Corresponding_Declaration;
Result.Corresponding_Body := Element.Corresponding_Body;
null;
Result.Generic_Actual := Element.Generic_Actual;
Result.Specification := Element.Specification;
Result.Overriding_Indicator_Kind := Element.Overriding_Indicator_Kind;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Procedure_Instantiation_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Generic_Unit_Name :=
Copy (Cloner, Generic_Unit_Name (Source.all), Asis.Element (Target));
Set_Generic_Actual_Part
(Target.all,
Primary_Association_Lists.Deep_Copy
(Generic_Actual_Part (Source.all), Cloner, Asis.Element (Target)));
end Copy;
function New_Function_Instantiation_Node
(The_Context : ASIS.Context)
return Function_Instantiation_Ptr
is
Result : Function_Instantiation_Ptr :=
new Function_Instantiation_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Function_Instantiation_Node;
function Declaration_Kind (Element : Function_Instantiation_Node)
return Asis.Declaration_Kinds is
begin
return A_Function_Instantiation;
end;
function Clone
(Element : Function_Instantiation_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Function_Instantiation_Ptr := new Function_Instantiation_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Declaration := Element.Corresponding_Declaration;
Result.Corresponding_Body := Element.Corresponding_Body;
null;
Result.Generic_Actual := Element.Generic_Actual;
Result.Specification := Element.Specification;
Result.Overriding_Indicator_Kind := Element.Overriding_Indicator_Kind;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Function_Instantiation_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Generic_Unit_Name :=
Copy (Cloner, Generic_Unit_Name (Source.all), Asis.Element (Target));
Set_Generic_Actual_Part
(Target.all,
Primary_Association_Lists.Deep_Copy
(Generic_Actual_Part (Source.all), Cloner, Asis.Element (Target)));
end Copy;
function New_Formal_Package_Declaration_Node
(The_Context : ASIS.Context)
return Formal_Package_Declaration_Ptr
is
Result : Formal_Package_Declaration_Ptr :=
new Formal_Package_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Formal_Package_Declaration_Node;
function Declaration_Kind (Element : Formal_Package_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Formal_Package_Declaration;
end;
function Clone
(Element : Formal_Package_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Formal_Package_Declaration_Ptr := new Formal_Package_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Corresponding_Declaration := Element.Corresponding_Declaration;
Result.Corresponding_Body := Element.Corresponding_Body;
null;
Result.Generic_Actual := Element.Generic_Actual;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Formal_Package_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Target.Generic_Unit_Name :=
Copy (Cloner, Generic_Unit_Name (Source.all), Asis.Element (Target));
Set_Generic_Actual_Part
(Target.all,
Primary_Association_Lists.Deep_Copy
(Generic_Actual_Part (Source.all), Cloner, Asis.Element (Target)));
end Copy;
function Parameter_Profile
(Element : Formal_Procedure_Declaration_Node;
Include_Pragmas : in Boolean := False) return Asis.Element_List is
begin
return Primary_Parameter_Lists.To_Element_List
(Element.Parameter_Profile, Include_Pragmas);
end Parameter_Profile;
procedure Set_Parameter_Profile
(Element : in out Formal_Procedure_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Parameter_Profile := Primary_Parameter_Lists.List (Value);
end Set_Parameter_Profile;
function Parameter_Profile_List
(Element : Formal_Procedure_Declaration_Node) return Asis.Element is
begin
return Asis.Element (Element.Parameter_Profile);
end Parameter_Profile_List;
function Default_Kind
(Element : Formal_Procedure_Declaration_Node) return Asis.Subprogram_Default_Kinds is
begin
return Element.Default_Kind;
end Default_Kind;
procedure Set_Default_Kind
(Element : in out Formal_Procedure_Declaration_Node;
Value : in Asis.Subprogram_Default_Kinds) is
begin
Element.Default_Kind := Value;
end Set_Default_Kind;
function Formal_Subprogram_Default
(Element : Formal_Procedure_Declaration_Node) return Asis.Expression is
begin
return Element.Formal_Subprogram_Default;
end Formal_Subprogram_Default;
procedure Set_Formal_Subprogram_Default
(Element : in out Formal_Procedure_Declaration_Node;
Value : in Asis.Expression) is
begin
Element.Formal_Subprogram_Default := Value;
end Set_Formal_Subprogram_Default;
function Specification
(Element : Formal_Procedure_Declaration_Node) return Asis.Element is
begin
return Element.Specification;
end Specification;
procedure Set_Specification
(Element : in out Formal_Procedure_Declaration_Node;
Value : in Asis.Element) is
begin
Element.Specification := Value;
end Set_Specification;
function Has_Abstract
(Element : Formal_Procedure_Declaration_Node) return Boolean is
begin
return Element.Has_Abstract;
end Has_Abstract;
procedure Set_Has_Abstract
(Element : in out Formal_Procedure_Declaration_Node;
Value : in Boolean) is
begin
Element.Has_Abstract := Value;
end Set_Has_Abstract;
function Generic_Actual
(Element : Formal_Procedure_Declaration_Node) return Asis.Expression is
begin
return Element.Generic_Actual;
end Generic_Actual;
procedure Set_Generic_Actual
(Element : in out Formal_Procedure_Declaration_Node;
Value : in Asis.Expression) is
begin
Element.Generic_Actual := Value;
end Set_Generic_Actual;
function New_Formal_Procedure_Declaration_Node
(The_Context : ASIS.Context)
return Formal_Procedure_Declaration_Ptr
is
Result : Formal_Procedure_Declaration_Ptr :=
new Formal_Procedure_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Formal_Procedure_Declaration_Node;
function Declaration_Kind (Element : Formal_Procedure_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Formal_Procedure_Declaration;
end;
function Children (Element : access Formal_Procedure_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(True, Asis.Element (Element.Parameter_Profile)),
(False, Element.Formal_Subprogram_Default'Access));
end Children;
function Clone
(Element : Formal_Procedure_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Formal_Procedure_Declaration_Ptr := new Formal_Procedure_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Default_Kind := Element.Default_Kind;
Result.Specification := Element.Specification;
Result.Has_Abstract := Element.Has_Abstract;
Result.Generic_Actual := Element.Generic_Actual;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Formal_Procedure_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Set_Parameter_Profile
(Target.all,
Primary_Parameter_Lists.Deep_Copy
(Parameter_Profile (Source.all), Cloner, Asis.Element (Target)));
Target.Formal_Subprogram_Default :=
Copy (Cloner, Formal_Subprogram_Default (Source.all), Asis.Element (Target));
end Copy;
function Result_Subtype
(Element : Formal_Function_Declaration_Node) return Asis.Definition is
begin
return Element.Result_Subtype;
end Result_Subtype;
procedure Set_Result_Subtype
(Element : in out Formal_Function_Declaration_Node;
Value : in Asis.Definition) is
begin
Element.Result_Subtype := Value;
end Set_Result_Subtype;
function New_Formal_Function_Declaration_Node
(The_Context : ASIS.Context)
return Formal_Function_Declaration_Ptr
is
Result : Formal_Function_Declaration_Ptr :=
new Formal_Function_Declaration_Node;
begin
Set_Enclosing_Compilation_Unit
(Result.all, Current_Unit (The_Context.all));
return Result;
end New_Formal_Function_Declaration_Node;
function Declaration_Kind (Element : Formal_Function_Declaration_Node)
return Asis.Declaration_Kinds is
begin
return A_Formal_Function_Declaration;
end;
function Children (Element : access Formal_Function_Declaration_Node)
return Traverse_List is
begin
return ((True, Asis.Element (Element.Names)),
(True, Asis.Element (Element.Parameter_Profile)),
(False, Element.Formal_Subprogram_Default'Access),
(False, Element.Result_Subtype'Access));
end Children;
function Clone
(Element : Formal_Function_Declaration_Node;
Parent : Asis.Element)
return Asis.Element
is
Result : constant Formal_Function_Declaration_Ptr := new Formal_Function_Declaration_Node;
begin
Result.Enclosing_Element := Parent;
Result.Is_Part_Of_Implicit := Element.Is_Part_Of_Implicit;
Result.Is_Part_Of_Inherited := Element.Is_Part_Of_Inherited;
Result.Is_Part_Of_Instance := Element.Is_Part_Of_Instance;
Result.Start_Position := Element.Start_Position;
Result.End_Position := Element.End_Position;
Result.Enclosing_Compilation_Unit :=
Enclosing_Compilation_Unit (Parent.all);
Result.Hash := Element.Hash;
Result.Declaration_Origin := Element.Declaration_Origin;
Result.Name := Element.Name;
null;
null;
Result.Place := Element.Place;
Result.Default_Kind := Element.Default_Kind;
Result.Specification := Element.Specification;
Result.Has_Abstract := Element.Has_Abstract;
Result.Generic_Actual := Element.Generic_Actual;
return Asis.Element (Result);
end Clone;
procedure Copy
(Source : in Asis.Element;
Target : access Formal_Function_Declaration_Node;
Cloner : in Cloner_Class;
Parent : in Asis.Element)
is
begin
Set_Names
(Target.all,
Primary_Defining_Name_Lists.Deep_Copy
(Names (Source.all), Cloner, Asis.Element (Target)));
Set_Parameter_Profile
(Target.all,
Primary_Parameter_Lists.Deep_Copy
(Parameter_Profile (Source.all), Cloner, Asis.Element (Target)));
Target.Formal_Subprogram_Default :=
Copy (Cloner, Formal_Subprogram_Default (Source.all), Asis.Element (Target));
Target.Result_Subtype :=
Copy (Cloner, Result_Subtype (Source.all), Asis.Element (Target));
end Copy;
end Asis.Gela.Elements.Decl;
|
--
-- 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.Containers.Ordered_Maps;
with Rules;
package body States is
function State_Compare (Left, Right : in Configs.Config_Access) return Boolean;
function State_Compare (Left, Right : in Configs.Config_Access) return Boolean
is
use type Rules.Index_Number;
use type Rules.Dot_Type;
use Configs;
A : Config_Access := Left;
B : Config_Access := Right;
RC : Integer;
begin
RC := 0;
while RC = 0 and A /= null and B /= null loop
RC := Integer (A.Rule.Index - B.Rule.Index);
if RC = 0 then
RC := Integer (A.Dot - B.Dot);
end if;
A := A.Basis;
B := B.Basis;
end loop;
if RC = 0 then
if A /= null then RC := 1; end if;
if B /= null then RC := -1; end if;
end if;
return RC < 0;
end State_Compare;
package State_Maps is
new Ada.Containers.Ordered_Maps (Key_Type => Configs.Config_Access,
Element_Type => State_Access,
"<" => State_Compare);
State_Map : State_Maps.Map;
procedure Initialize is
begin
State_Map.Clear;
end Initialize;
function Find (Config : in not null Configs.Config_Access) return State_Access
is
use State_Maps;
Pos : constant Cursor := State_Map.Find (Config);
begin
return (if Pos = No_Element then null else Element (Pos));
end Find;
function Create return State_Access is
begin
return new State_Record;
end Create;
procedure Insert (State : in State_Access;
Config : in Configs.Config_Access)
is
begin
State_Map.Insert (Config, State);
end Insert;
procedure Iterate_Process (Position : in State_Maps.Cursor);
Static_Process : Process_Access;
procedure Iterate_Process (Position : in State_Maps.Cursor) is
begin
Static_Process.all (State_Maps.Element (Position));
end Iterate_Process;
procedure Iterate (Process : in Process_Access)
is
begin
Static_Process := Process;
State_Map.Iterate (Iterate_Process'Access);
end Iterate;
end States;
|
with Ada.Unchecked_Conversion;
with Ada.Unchecked_Deallocation;
package body YAML is
use type C_Int;
procedure Deallocate is new Ada.Unchecked_Deallocation
(String, String_Access);
procedure Deallocate is new Ada.Unchecked_Deallocation
(Document_Type, Document_Access);
----------------------
-- C symbol imports --
----------------------
procedure C_Document_Delete (Document : in out C_Document_T)
with Import, Convention => C, External_Name => "yaml_document_delete";
function C_Document_Get_Root_Node
(Document : C_Document_Access) return C_Node_Access
with
Import,
Convention => C,
External_Name => "yaml_document_get_root_node";
function C_Document_Get_Node
(Document : C_Document_Access;
Index : C_Int) return C_Node_Access
with
Import, Convention => C, External_Name => "yaml_document_get_node";
function C_Parser_Initialize (Parser : C_Parser_Access) return C_Int
with Import, Convention => C, External_Name => "yaml_parser_initialize";
function Allocate_Parser return C_Parser_Access
with Import, Convention => C, External_Name => "yaml__allocate_parser";
function C_Parser_Load
(Parser : C_Parser_Access; Document : C_Document_Access) return C_Int
with Import, Convention => C, External_Name => "yaml_parser_load";
procedure C_Parser_Set_Input_String
(Parser : C_Parser_Access;
Input : C_Char_Access;
Size : Interfaces.C.size_t)
with
Import,
Convention => C,
External_Name => "yaml_parser_set_input_string";
procedure C_Parser_Set_Input_File
(Parser : C_Parser_Access;
File : C_File_Ptr)
with Import,
Convention => C,
External_Name => "yaml_parser_set_input_file";
procedure C_Parser_Delete (Parser : C_Parser_Access)
with Import, Convention => C, External_Name => "yaml_parser_delete";
procedure Deallocate_Parser (Parser : C_Parser_Access)
with Import, Convention => C, External_Name => "yaml__deallocate_parser";
function C_Fopen
(Path, Mode : Interfaces.C.Strings.chars_ptr) return C_File_Ptr
with Import, Convention => C, External_Name => "fopen";
function C_Fclose (Stream : C_File_Ptr) return C_Int
with Import, Convention => C, External_Name => "fclose";
-------------
-- Helpers --
-------------
function Convert (S : String_Access) return C_Char_Access;
procedure Discard_Input
(Parser : in out Parser_Type'Class;
Re_Initialize : Boolean);
-- Free input holders in parser and delete the C YAML parser. If
-- Re_Initialize, also call Initialize_After_Allocation.
function Get_Node
(Document : Document_Type'Class; Index : C_Int) return Node_Ref;
-- Wrapper around C_Document_Get_Node. Raise a Constraint_Error if Index is
-- out of range.
procedure Initialize_After_Allocation (Parser : in out Parser_Type'Class);
-- Initialize the C YAML parser and assign proper defaults to input holders
-- in Parser.
function Wrap
(Document : Document_Type'Class; N : C_Node_Access) return Node_Ref
is
((Node => N, Document => Document'Unrestricted_Access));
function Wrap (M : C_Mark_T) return Mark_Type is
((Line => Natural (M.Line) + 1, Column => Natural (M.Column) + 1));
function Wrap (Error_View : C_Parser_Error_View) return Error_Type;
function Convert (S : String_Access) return C_Char_Access is
Char_Array : C_Char_Array with Address => S.all'Address;
begin
return Char_Array'Unrestricted_Access;
end Convert;
function Get_Node
(Document : Document_Type'Class; Index : C_Int) return Node_Ref
is
N : constant C_Node_Access :=
C_Document_Get_Node (Document.C_Doc'Unrestricted_Access, Index);
begin
if N = null then
raise Constraint_Error;
end if;
return Wrap (Document, N);
end Get_Node;
procedure Initialize_After_Allocation (Parser : in out Parser_Type'Class) is
begin
if C_Parser_Initialize (Parser.C_Parser) /= 1 then
-- TODO: determine a good error handling scheme
raise Program_Error;
end if;
Parser.Input_Encoding := Any_Encoding;
Parser.Input_String := null;
Parser.Input_File := No_File_Ptr;
end Initialize_After_Allocation;
procedure Discard_Input
(Parser : in out Parser_Type'Class;
Re_Initialize : Boolean) is
begin
C_Parser_Delete (Parser.C_Parser);
Deallocate (Parser.Input_String);
if Parser.Input_File /= No_File_Ptr
and then C_Fclose (Parser.Input_File) /= 0
then
raise File_Error;
end if;
if Re_Initialize then
Initialize_After_Allocation (Parser);
end if;
end Discard_Input;
function Wrap (Error_View : C_Parser_Error_View) return Error_Type is
function Convert
(S : Interfaces.C.Strings.chars_ptr)
return Ada.Strings.Unbounded.Unbounded_String
is (Ada.Strings.Unbounded.To_Unbounded_String
(Interfaces.C.Strings.Value (S)));
Kind : Error_Kind renames Error_View.Error;
Problem : constant Ada.Strings.Unbounded.Unbounded_String :=
Convert (Error_View.Problem);
Problem_Offset : Natural;
Problem_Value : Integer;
Context : Ada.Strings.Unbounded.Unbounded_String;
Context_Mark, Problem_Mark : Mark_Type;
begin
case Kind is
when Reader_Error =>
Problem_Offset := Natural (Error_View.Problem_Offset);
Problem_Value := Integer (Error_View.Problem_Value);
when Scanner_Error | Parser_Error =>
Context := Convert (Error_View.Context);
Context_Mark := Wrap (Error_View.Context_Mark);
Problem_Mark := Wrap (Error_View.Problem_Mark);
when others =>
null;
end case;
case Kind is
when No_Error =>
return (No_Error, Problem);
when Composer_Error =>
return (Composer_Error, Problem);
when Memory_Error =>
return (Memory_Error, Problem);
when Writer_Error =>
return (Writer_Error, Problem);
when Emitter_Error =>
return (Emitter_Error, Problem);
when Reader_Error =>
return (Reader_Error, Problem, Problem_Offset, Problem_Value);
when Scanner_Error =>
return (Scanner_Error,
Problem, Context, Context_Mark, Problem_Mark);
when Parser_Error =>
return (Parser_Error,
Problem, Context, Context_Mark, Problem_Mark);
end case;
end Wrap;
----------
-- Misc --
----------
overriding procedure Initialize (Document : in out Document_Type) is
begin
Document.Ref_Count := 0;
Document.To_Delete := False;
end Initialize;
overriding procedure Finalize (Document : in out Document_Type) is
begin
if Document.To_Delete then
C_Document_Delete (Document.C_Doc);
Document.To_Delete := False;
end if;
end Finalize;
overriding procedure Adjust (Handle : in out Document_Handle) is
begin
Handle.Inc_Ref;
end Adjust;
overriding procedure Finalize (Handle : in out Document_Handle) is
begin
Handle.Dec_Ref;
end Finalize;
procedure Inc_Ref (Handle : in out Document_Handle'Class) is
begin
if Handle /= No_Document_Handle then
Handle.Document.Ref_Count := Handle.Document.Ref_Count + 1;
end if;
end Inc_Ref;
procedure Dec_Ref (Handle : in out Document_Handle'Class) is
begin
if Handle /= No_Document_Handle then
declare
D : Document_Access := Handle.Document;
begin
D.Ref_Count := D.Ref_Count - 1;
if D.Ref_Count = 0 then
Deallocate (D);
end if;
end;
end if;
end Dec_Ref;
overriding procedure Initialize (Parser : in out Parser_Type) is
begin
Parser.C_Parser := Allocate_Parser;
Initialize_After_Allocation (Parser);
end Initialize;
overriding procedure Finalize (Parser : in out Parser_Type) is
begin
Discard_Input (Parser, False);
Deallocate_Parser (Parser.C_Parser);
end Finalize;
-----------------------
-- Public interface --
-----------------------
function Create return Document_Handle is
D : constant Document_Access := new Document_Type;
begin
D.Ref_Count := 1;
return (Ada.Finalization.Controlled with Document => D);
end Create;
function Root_Node (Document : Document_Type'Class) return Node_Ref is
begin
return Wrap
(Document,
C_Document_Get_Root_Node (Document.C_Doc'Unrestricted_Access));
end Root_Node;
function Start_Mark (Document : Document_Type'Class) return Mark_Type is
begin
return Wrap (Document.C_Doc.Start_Mark);
end Start_Mark;
function End_Mark (Document : Document_Type'Class) return Mark_Type is
begin
return Wrap (Document.C_Doc.End_Mark);
end End_Mark;
function Kind (Node : Node_Ref'Class) return Node_Kind is
begin
return Node.Node.Kind;
end Kind;
function Start_Mark (Node : Node_Ref'Class) return Mark_Type is
begin
return Wrap (Node.Node.Start_Mark);
end Start_Mark;
function End_Mark (Node : Node_Ref'Class) return Mark_Type is
begin
return Wrap (Node.Node.End_Mark);
end End_Mark;
function Value (Node : Node_Ref'Class) return UTF8_String is
Data : C_Node_Data renames Node.Node.Data;
Result : UTF8_String (1 .. Natural (Data.Scalar.Length))
with Address => Data.Scalar.Value.all'Address;
begin
return Result;
end Value;
function Length (Node : Node_Ref'Class) return Natural is
use C_Node_Item_Accesses, C_Node_Pair_Accesses;
Data : C_Node_Data renames Node.Node.Data;
begin
return
(case Kind (Node) is
when Sequence_Node => Natural
(Data.Sequence.Items.Seq_Top - Data.Sequence.Items.Seq_Start),
when Mapping_Node => Natural
(Data.Mapping.Pairs.Map_Top - Data.Mapping.Pairs.Map_Start),
when others => raise Program_Error);
end Length;
function Item (Node : Node_Ref'Class; Index : Positive) return Node_Ref
is
use C_Node_Item_Accesses;
Data : C_Node_Data renames Node.Node.Data;
Item : constant C_Node_Item_Access :=
Data.Sequence.Items.Seq_Start + C_Ptr_Diff (Index - 1);
begin
return Get_Node (Node.Document.all, Item.all);
end Item;
function Item (Node : Node_Ref'Class; Index : Positive) return Node_Pair
is
use C_Node_Pair_Accesses;
Data : C_Node_Data renames Node.Node.Data;
Pair : constant C_Node_Pair_Access :=
Data.Mapping.Pairs.Map_Start + C_Ptr_Diff (Index - 1);
begin
return (Key => Get_Node (Node.Document.all, Pair.Key),
Value => Get_Node (Node.Document.all, Pair.Value));
end Item;
function Item (Node : Node_Ref'Class; Key : UTF8_String) return Node_Ref
is
begin
for I in 1 .. Length (Node) loop
declare
Pair : constant Node_Pair := Item (Node, I);
begin
if Kind (Pair.Key) = Scalar_Node
and then Value (Pair.Key) = Key
then
return Pair.Value;
end if;
end;
end loop;
return No_Node_Ref;
end Item;
function Image (Error : Error_Type) return String is
function "+" (US : Ada.Strings.Unbounded.Unbounded_String) return String
renames Ada.Strings.Unbounded.To_String;
function Problem_Image
(Text : Ada.Strings.Unbounded.Unbounded_String;
Mark : Mark_Type) return String
is (+Text & " " & "at line" & Natural'Image (Mark.Line)
& ", column" & Natural'Image (Mark.Column));
begin
case Error.Kind is
when No_Error =>
return "no error";
when Reader_Error =>
declare
Value : constant String :=
(if Error.Problem_Value /= -1
then Integer'Image (Error.Problem_Value)
else "");
begin
return "reader error: " & (+Error.Problem) & ":" & Value
& " at offset" & Natural'Image (Error.Problem_Offset);
end;
when Scanner_Error | Parser_Error =>
declare
Kind : constant String :=
(case Error.Kind is
when Scanner_Error => "scanner error",
when Parser_Error => "parser error",
when others => raise Program_Error);
Context : constant String :=
(if Ada.Strings.Unbounded.Length (Error.Context) > 0
then Problem_Image (Error.Context, Error.Context_Mark) & ": "
else "");
begin
return Kind & ": " & Context
& Problem_Image (Error.Problem, Error.Problem_Mark);
end;
when Composer_Error =>
return "composer error";
when Memory_Error =>
return "memory error";
when Writer_Error =>
return "writer error";
when Emitter_Error =>
return "emitter error";
end case;
end Image;
function Has_Input (P : Parser_Type'Class) return Boolean is
begin
return P.Input_String /= null or else P.Input_File /= No_File_Ptr;
end Has_Input;
procedure Set_Input_String
(Parser : in out Parser_Type'Class;
Input : String;
Encoding : Encoding_Type)
is
begin
Parser.Input_Encoding := Encoding;
Deallocate (Parser.Input_String);
Parser.Input_String := new String'(Input);
C_Parser_Set_Input_String
(Parser.C_Parser,
Convert (Parser.Input_String),
Parser.Input_String'Length);
end Set_Input_String;
procedure Set_Input_File
(Parser : in out Parser_Type'Class;
Filename : String;
Encoding : Encoding_Type)
is
use Interfaces.C.Strings;
C_Mode : chars_ptr := New_String ("r");
C_Filename : chars_ptr := New_String (Filename);
File : constant C_File_Ptr := C_Fopen (C_Filename, C_Mode);
begin
Free (C_Mode);
Free (C_Filename);
if File = No_File_Ptr then
raise File_Error;
end if;
Deallocate (Parser.Input_String);
Parser.Input_Encoding := Encoding;
Parser.Input_File := File;
C_Parser_Set_Input_File (Parser.C_Parser, Parser.Input_File);
end Set_Input_File;
procedure Discard_Input (Parser : in out Parser_Type'Class) is
begin
Discard_Input (Parser, True);
end Discard_Input;
procedure Load
(Parser : in out Parser_Type'Class;
Error : out Error_Type;
Document : in out Document_Type'Class) is
begin
Document.Finalize;
if C_Parser_Load
(Parser.C_Parser, Document.C_Doc'Unrestricted_Access) /= 1
then
declare
Error_View_Address : constant System.Address :=
System.Address (Parser.C_Parser);
Error_View : C_Parser_Error_View
with Import => True,
Convention => Ada,
Address => Error_View_Address;
begin
Error := Wrap (Error_View);
end;
end if;
Document.To_Delete := True;
end Load;
end YAML;
|
-- { dg-do compile }
-- { dg-options "-g -O" }
with Ada.Unchecked_Conversion;
package body Unchecked_Convert8 is
type T1 is range 0 .. 255;
type T2 is
record
A : T1;
B : T1;
end record;
for T2 use
record
A at 0 range 0 .. 7;
B at 1 range 0 .. 7;
end record;
for T2'Size use 16;
type T3 is range 0 .. (2**16 - 1);
for T3'Size use 16;
function T2_TO_T3 is
new Ada.Unchecked_Conversion (Source => T2, Target => T3);
C : constant T3 := T2_TO_T3 (S => (A => 0, B => 0));
procedure Dummy is begin null; end;
end Unchecked_Convert8;
|
with Ada.Assertions; use Ada.Assertions;
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Containers.Synchronized_Queue_Interfaces;
with Ada.Containers.Unbounded_Priority_Queues;
procedure Day22 is
Max_Dim : constant Natural := 800;
Grid : array
(Natural range 0 .. Max_Dim, Natural range 0 .. Max_Dim) of Natural :=
(others => (others => 0));
Depth : Natural;
Target_X : Natural;
Target_Y : Natural;
function Geological_Index (X, Y : Natural) return Natural is
begin
if X = Target_X and Y = Target_Y then
return 0;
elsif Y = 0 then
return X * 16807;
elsif X = 0 then
return Y * 48271;
else
return Grid (X - 1, Y) * Grid (X, Y - 1);
end if;
end Geological_Index;
function Erosion_Level (X, Y : Natural) return Natural is
((Geological_Index (X, Y) + Depth) mod 20183);
File : File_Type;
begin
-- Input Handling
Open (File, In_File, "input.txt");
declare
Line1 : constant String := Get_Line (File);
Line2 : constant String := Get_Line (File);
Comma : Positive := Line2'First;
begin
Depth := Natural'Value (Line1 (8 .. Line1'Last));
while Comma <= Line2'Last loop
exit when Line2 (Comma) = ',';
Comma := Comma + 1;
end loop;
Assert (Comma < Line2'Last, "Invalid input!");
Target_X := Natural'Value (Line2 (9 .. Comma - 1));
Target_Y := Natural'Value (Line2 (Comma + 1 .. Line2'Last));
end;
Close (File);
-- Calculating the erosion levels for the grid.
for Y in Grid'Range (2) loop
for X in Grid'Range (1) loop
Grid (X, Y) := Erosion_Level (X, Y);
end loop;
end loop;
-- Changing grid from erosion Levels to terrain & part 1
declare
Risk_Level : Natural := 0;
begin
for Y in Grid'Range (2) loop
for X in Grid'Range (1) loop
Grid (X, Y) := Grid (X, Y) mod 3;
if X <= Target_X and Y <= Target_Y then
Risk_Level := Risk_Level + Grid (X, Y);
end if;
end loop;
end loop;
Put_Line ("Part 1 =" & Natural'Image (Risk_Level));
end;
-- Part 2
Dijkstra_Algorithm :
declare
type Tool_Type is (Torch, Climbing_Gear, Neither);
type Position is record
X : Integer;
Y : Integer;
end record;
type Node_Type is record
Visited : Boolean;
Distance : Natural;
end record;
type Queue_Element is record
X : Natural;
Y : Natural;
Tool : Tool_Type;
Distance : Natural;
end record;
function Can_Use (Tool : Tool_Type; Terrain : Natural) return Boolean is
begin
case Terrain is
when 0 => return Tool = Climbing_Gear or Tool = Torch;
when 1 => return Tool = Climbing_Gear or Tool = Neither;
when 2 => return Tool = Torch or Tool = Neither;
when others =>
raise Constraint_Error
with "Illegal terrain type:" & Natural'Image (Terrain);
end case;
end Can_Use;
function Get_Priority (Element : Queue_Element) return Natural is
(Element.Distance);
function Before (Left, Right : Natural) return Boolean is (Left < Right);
package QI is new Ada.Containers.Synchronized_Queue_Interfaces
(Element_Type => Queue_Element);
package PQ is new Ada.Containers.Unbounded_Priority_Queues
(Queue_Interfaces => QI, Queue_Priority => Natural);
use PQ;
use Ada.Containers;
Directions : constant array (Positive range <>) of Position :=
((1, 0), (-1, 0), (0, 1), (0, -1));
Nodes : array
(Natural range 0 .. Max_Dim,
Natural range 0 .. Max_Dim,
Tool_Type'Range) of Node_Type :=
(others => (others => (others => (False, 0))));
E : Queue_Element;
Q : Queue;
begin
Q.Enqueue ((0, 0, Torch, 0)); -- Start with torch equipped
while Q.Current_Use > 0 and not Nodes (Target_X, Target_Y, Torch).Visited
loop
Q.Dequeue (E);
if not Nodes (E.X, E.Y, E.Tool).Visited then
Nodes (E.X, E.Y, E.Tool).Visited := True;
Nodes (E.X, E.Y, E.Tool).Distance := E.Distance;
for Dir of Directions loop
if (E.X > 0 or Dir.X >= 0) and
(E.Y > 0 or Dir.Y >= 0) and
(E.X < Max_Dim or Dir.X <= 0) and
(E.Y < Max_Dim or Dir.Y <= 0)
then
declare
New_X : constant Natural := E.X + Dir.X;
New_Y : constant Natural := E.Y + Dir.Y;
begin
if Can_Use (E.Tool, Grid (New_X, New_Y)) and
not Nodes (New_X, New_Y, E.Tool).Visited
then
Q.Enqueue ((New_X, New_Y, E.Tool, E.Distance + 1));
end if;
end;
end if;
end loop;
for Tool in Tool_Type'Range loop
if not Nodes (E.X, E.Y, Tool).Visited and
Can_Use (Tool, Grid (E.X, E.Y))
then
Q.Enqueue ((E.X, E.Y, Tool, E.Distance + 7));
end if;
end loop;
end if;
end loop;
Put_Line
("Part 2 =" &
Natural'Image (Nodes (Target_X, Target_Y, Torch).Distance));
end Dijkstra_Algorithm;
end Day22;
|
pragma License (Unrestricted);
with Ada.Numerics.Generic_Elementary_Functions;
package Ada.Numerics.Short_Elementary_Functions is
new Generic_Elementary_Functions (Short_Float);
pragma Pure (Ada.Numerics.Short_Elementary_Functions);
|
pragma License (Unrestricted);
with Interfaces.C.Char_Pointers;
with Interfaces.C.Generic_Strings;
package Interfaces.C.Strings is
new Generic_Strings (
Character_Type => Character,
String_Type => String,
Element => char,
Element_Array => char_array,
Pointers => Char_Pointers,
To_C => To_char_array,
To_Ada => To_String);
pragma Preelaborate (Interfaces.C.Strings);
|
-- Copyright (c) 1990 Regents of the University of California.
-- All rights reserved.
--
-- The primary authors of ayacc were David Taback and Deepak Tolani.
-- Enhancements were made by Ronald J. Schmalz.
--
-- Send requests for ayacc information to ayacc-info@ics.uci.edu
-- Send bug reports for ayacc to ayacc-bugs@ics.uci.edu
--
-- Redistribution and use in source and binary forms are permitted
-- provided that the above copyright notice and this paragraph are
-- duplicated in all such forms and that any documentation,
-- advertising materials, and other materials related to such
-- distribution and use acknowledge that the software was developed
-- by the University of California, Irvine. The name of the
-- University may not be used to endorse or promote products derived
-- from this software without specific prior written permission.
-- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
-- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
-- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
-- Module : parser_body.ada
-- Component of : ayacc
-- Version : 1.2
-- Date : 11/21/86 12:32:43
-- SCCS File : disk21~/rschm/hasee/sccs/ayacc/sccs/sxparser_body.ada
-- $Header: parser_body.a,v 0.1 86/04/01 15:10:24 ada Exp $
-- $Log: parser_body.a,v $
-- Revision 0.1 86/04/01 15:10:24 ada
-- This version fixes some minor bugs with empty grammars
-- and $$ expansion. It also uses vads5.1b enhancements
-- such as pragma inline.
--
--
-- Revision 0.0 86/02/19 18:40:31 ada
--
-- These files comprise the initial version of Ayacc
-- designed and implemented by David Taback and Deepak Tolani.
-- Ayacc has been compiled and tested under the Verdix Ada compiler
-- version 4.06 on a vax 11/750 running Unix 4.2BSD.
--
-- --
-- The body of the parser for the specification file --
-- --
with Text_IO; use Text_IO;
with Lexical_Analyzer; use Lexical_Analyzer;
-- with STR_Pack; use STR_Pack;
with Symbol_Table; use Symbol_Table;
with Rule_Table; use Rule_Table;
with Actions_File; use Actions_File;
with Tokens_File; use Tokens_File;
with String_Pkg;
package body Parser is
Found_Error : Boolean := False;
Start_Defined : Boolean := False;
procedure Nonfatal_Error(Message: in String) is
begin
Print_Context_Lines;
--RJS Put_Line("--- " & Message);
New_Line;
Put_Line ("Ayacc: " & Message);
Found_Error := True;
end Nonfatal_Error;
procedure Fatal_Error(Message: in String) is
begin
Print_Context_Lines;
--RJS Put_Line("--- " & Message);
New_Line;
Put_Line ("Ayacc: " & Message);
raise Syntax_Error;
end Fatal_Error;
procedure Augment_Grammar(Users_Start_Symbol : in Grammar_Symbol) is
-- Inserts S' -> S $end as a rule in the rule table.
Start_Sym : Grammar_Symbol;
Augmented_Rule : Rule;
begin
Start_Defined := True;
Augmented_Rule := Make_Rule(Start_Symbol);
Append_RHS(Augmented_Rule, Users_Start_Symbol);
Append_RHS(Augmented_Rule, End_Symbol);
end Augment_Grammar;
-- --
-- A recursive descent parser for the rules in the --
-- grammar. --
procedure Parse_Rules is
T : Ayacc_Token;
Current_Rule : Rule;
LHS : Grammar_Symbol;
-- --
-- Gets an action from the file and writes it to --
-- the actions file. --
-- --
-- --
-- Parses a sequence of Symbols --
-- --
procedure Symbols is
ID : Grammar_Symbol;
Got_Action : Boolean := False;
Precedence_Level : Precedence;
begin
loop
T := Get_Token;
exit when T = Vertical_Bar or T = Semicolon or T = Prec;
-- Do we have an action in the middle of a rule?
if Got_Action then
Got_Action := T = Left_Brace;
Handle_Nested_Rule(Current_Rule);
end if;
case T is
-- Update the current rule
when Character_Literal =>
ID := Insert_Terminal(Get_Lexeme_Text);
Append_RHS(Current_Rule, ID);
-- Update the current rule and add to symbol table
when Identifier =>
ID := Insert_Identifier(Get_Lexeme_Text);
Append_RHS(Current_Rule, ID);
-- Got an action
when Left_Brace =>
Handle_Action(Integer(Current_Rule),
Integer(Length_of(Current_Rule)));
Got_Action := True;
when others =>
Fatal_Error("Unexpected symbol");
end case;
end loop;
if T = Prec then
if Got_Action then
Fatal_Error("%prec cannot be preceded by an action");
raise Syntax_Error;
end if;
T := Get_Token;
if T /= Identifier and T /= Character_Literal then
Fatal_Error("Expecting a terminal after %prec");
end if;
ID := Insert_Identifier(Get_Lexeme_Text);
if Is_Nonterminal(ID) then
Fatal_Error("Expecting a terminal after %prec");
end if;
Precedence_Level := Get_Precedence(ID);
if Precedence_Level = 0 then
Fatal_Error("Terminal following %prec has no precedence");
else
Set_Rule_Precedence(Current_Rule, Precedence_Level);
end if;
T := Get_Token;
case T is
when Left_Brace =>
Handle_Action(Integer(Current_Rule),
Integer(Length_of(Current_Rule)));
T := Get_Token;
when Semicolon | Vertical_Bar =>
null;
when others =>
Fatal_Error("Illegal token following %prec");
end case;
end if;
end Symbols;
-- --
-- Parse an Ayacc grammar rule --
-- --
procedure Rule is
begin
T := Get_Token;
if T /= Colon then
Fatal_Error("Expecting a colon after the LHS of the rule");
else
Current_Rule := Make_Rule(LHS);
Symbols;
end if;
while (T = Vertical_Bar) loop
-- Make a new rule with the current LHS grammar symbol
Current_Rule := Make_Rule(LHS);
Symbols;
end loop;
if T /= Semicolon then
Fatal_Error("Expecting a semicolon");
end if;
end Rule;
-- --
-- Parse a sequence of grammar rules --
-- --
procedure Rules is
begin
T := Get_Token;
if T = Identifier then
-- Make the left hand side of the rule
LHS := Insert_Identifier(Get_Lexeme_Text);
if Is_Terminal(LHS) then
Fatal_Error("Terminals cannot be on the LHS of a rule");
end if;
if not Start_Defined then
Augment_Grammar(LHS);
end if;
Rule;
Rules;
elsif T /= Mark then
Fatal_Error("Expecting next section");
end if;
end Rules;
begin -- parse_rules
Actions_File.Initialize;
Rules;
Actions_File.Finish;
-- Check for empty grammars. If the grammar is empty then
-- create a rule S -> $end.
if not Start_Defined then
Append_RHS(Make_Rule(Start_Symbol), End_Symbol);
end if;
exception
when Illegal_Token =>
Fatal_Error("illegal token");
end Parse_Rules;
-- --
-- Parse the declarations section of the source --
-- --
procedure Parse_Declarations is
Precedence_Level : Precedence := 0;
Next_Token : Ayacc_Token;
ID : Grammar_Symbol;
procedure Parse_Start_Symbol is
Users_Start_Symbol : Grammar_Symbol;
begin
if Start_Defined then
Fatal_Error("The start symbol has been defined already.");
end if;
if Next_Token /= Identifier then
if Next_Token = Lexical_Analyzer.Eof_Token then
Fatal_Error("Unexpected end of file before first '%%'");
else
Fatal_Error("Expecting identifier");
end if;
end if;
Users_Start_Symbol := Insert_Identifier(Get_Lexeme_Text);
if Is_Nonterminal(Users_Start_Symbol) then
Augment_Grammar(Users_Start_Symbol);
else
Fatal_Error("Attempt to define terminal as start_symbol");
end if;
Next_Token := Get_Token;
end Parse_Start_Symbol;
procedure Parse_Token_List(Precedence_Value : in Precedence;
Associativity_Value : in Associativity) is
Temp_Sym : Grammar_Symbol;
begin
loop
if Next_Token /= Identifier and then
Next_Token /= Character_Literal then
if Next_Token = Lexical_Analyzer.Eof_Token then
Fatal_Error("Unexpected end of file before first '%%'");
else
Fatal_Error("Expecting token declaration");
end if;
end if;
Temp_Sym := Insert_Terminal(Get_Lexeme_Text,
Precedence_Value,
Associativity_Value);
Next_Token := Get_Token;
if Next_Token = Comma then
Next_Token := Get_Token;
elsif Next_Token = Semicolon then
Next_Token := Get_Token;
exit;
elsif Next_Token /= Identifier and then
Next_Token /= Character_Literal then
exit;
end if;
end loop;
exception
when Illegal_Entry =>
-- I think only trying to insert the "start symbol"
-- in a token list will cause this exception
Fatal_Error("Illegal symbol as token");
end Parse_Token_List;
procedure Parse_Package_Name_List(Context_Clause : in Ayacc_Token) is
use String_Pkg;
begin
if Tokens_Package_Header_Has_Been_Generated then
Fatal_Error ("Context Clause Specifications May Not " &
"Appear After Ada Declarations.");
else
case Context_Clause is
when With_Clause =>
Tokens_File.Write ("with ");
when Use_Clause =>
Tokens_File.Write ("use ");
when others =>
Fatal_Error ("Illegal Context Clause Specification");
end case;
loop
if Next_Token /= Identifier then
if Next_Token = Lexical_Analyzer.Eof_Token then
Fatal_Error("Unexpected end of file before first '%%'");
else
Fatal_Error("Expecting Package Name");
end if;
end if;
Tokens_File.Write (' ' & Value (Mixed (Get_Lexeme_Text)));
Next_Token := Get_Token;
if Next_Token = Comma then
Next_Token := Get_Token;
Tokens_File.Write (",");
elsif Next_Token = Semicolon then
Next_Token := Get_Token;
Tokens_File.Writeln (";");
exit;
elsif Next_Token /= Identifier then
Tokens_File.Writeln (";");
exit;
else
Tokens_File.Write (",");
end if;
end loop;
end if;
end Parse_Package_Name_List;
begin
Next_Token := Get_Token;
loop
case Next_Token is
when Start =>
Next_Token := Get_Token;
Parse_Start_Symbol;
if Next_Token = Semicolon then
Next_Token := Get_Token;
end if;
when Token =>
Next_Token := Get_Token;
Parse_Token_List(0, Undefined);
when Nonassoc =>
Next_Token := Get_Token;
Precedence_Level := Precedence_Level + 1;
Parse_Token_List(Precedence_Level, Nonassociative);
when Right =>
Next_Token := Get_Token;
Precedence_Level := Precedence_Level + 1;
Parse_Token_List(Precedence_Level, Right_Associative);
when Left =>
Next_Token := Get_Token;
Precedence_Level := Precedence_Level + 1;
Parse_Token_List(Precedence_Level, Left_Associative);
when Mark =>
exit;
when Lexical_Analyzer.Eof_Token =>
Fatal_Error("Unexpected end of file before first %%");
when Left_Brace =>
Start_Tokens_Package;
Dump_Declarations; -- to the TOKENS file.
Next_Token := Get_Token;
when With_Clause =>
Next_Token := Get_Token;
Parse_Package_Name_List (With_Clause);
when Use_Clause =>
Next_Token := Get_Token;
Parse_Package_Name_List (Use_Clause);
when others =>
Fatal_Error("Unexpected symbol");
end case;
end loop;
exception
when Illegal_Token =>
Fatal_Error("Bad symbol");
when Redefined_Precedence_Error =>
Fatal_Error("Attempt to redefine precedence");
end Parse_Declarations;
end Parser;
|
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
package Iterateur_Mots is
Erreur_Syntaxe : exception;
type Iterateur_Mot is private;
-- Initialise le record
function Initialiser(Chaine : String; Separateur : Character) return Iterateur_Mot;
-- Indique si l'iterateur est à sa fin
function Fin(Iterateur : Iterateur_Mot) return Boolean;
-- Lit le mot suivant (sans déplacer le curseur)
-- lève Erreur_Syntaxe si caractère innatendu
function Lire_Mot_Suivant(Iterateur : Iterateur_Mot) return String;
-- Avance au mot suivant (déplace le curseur)
function Avancer_Mot_Suivant(Iterateur : in out Iterateur_Mot) return String;
private
function Lire_Mot_Suivant_Interne(Iterateur : Iterateur_Mot; Caracteres_Lus : out Natural) return String;
-- Regroupe les infos de la String
type Iterateur_Mot is record
Chaine : Unbounded_String;
Curseur : Positive;
Separateur : Character;
end record;
end;
|
-----------------------------------------------------------------------
-- wiki-helpers -- Helper operations for wiki parsers and renderer
-- Copyright (C) 2016, 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.Strings;
package Wiki.Helpers is
pragma Preelaborate;
LF : constant Wiki.Strings.WChar := Wiki.Strings.WChar'Val (16#0A#);
CR : constant Wiki.Strings.WChar := Wiki.Strings.WChar'Val (16#0D#);
HT : constant Wiki.Strings.WChar := Wiki.Strings.WChar'Val (16#09#);
NBSP : constant Wiki.Strings.WChar := Wiki.Strings.WChar'Val (16#A0#);
-- Returns True if the character is a space or tab.
function Is_Space (C : in Wiki.Strings.WChar) return Boolean;
-- Returns True if the character is a space, tab or a newline.
function Is_Space_Or_Newline (C : in Wiki.Strings.WChar) return Boolean;
-- Returns True if the character is a line terminator.
function Is_Newline (C : in Wiki.Strings.WChar) return Boolean;
-- Returns True if the text is a valid URL
function Is_Url (Text : in Wiki.Strings.WString) return Boolean;
-- Returns True if the extension part correspond to an image.
-- Recognized extension are: .png, .gif, .jpg, .jpeg.
-- The extension case is ignored.
function Is_Image_Extension (Ext : in Wiki.Strings.WString) return Boolean;
-- Given the current tag on the top of the stack and the new tag that will be pushed,
-- decide whether the current tag must be closed or not.
-- Returns True if the current tag must be closed.
function Need_Close (Tag : in Html_Tag;
Current_Tag : in Html_Tag) return Boolean;
-- Get the dimension represented by the string. The string has one of the following
-- formats:
-- original -> Width, Height := Natural'Last
-- default -> Width := 800, Height := 0
-- upright -> Width := 800, Height := 0
-- <width>px -> Width := <width>, Height := 0
-- x<height>px -> Width := 0, Height := <height>
-- <width>x<height>px -> Width := <width>, Height := <height>
procedure Get_Sizes (Dimension : in Wiki.Strings.WString;
Width : out Natural;
Height : out Natural);
end Wiki.Helpers;
|
-----------------------------------------------------------------------
-- measure -- Benchmark tools
-- Copyright (C) 2008, 2009, 2010, 2011, 2012, 2013, 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.Text_IO;
with Ada.Calendar;
with Ada.Containers;
with Ada.Finalization;
with Util.Streams.Texts;
-- = Performance Measurements =
--
-- Performance measurements is often made using profiling tools such as GNU gprof or others.
-- This profiling is however not always appropriate for production or release delivery.
-- The mechanism presented here is a lightweight performance measurement that can be
-- used in production systems.
--
-- The Ada package `Util.Measures` defines the types and operations to make
-- performance measurements. It is designed to be used for production and multi-threaded
-- environments.
--
-- == Create the measure set ==
--
-- Measures are collected in a `Measure_Set`. Each measure has a name, a counter and
-- a sum of time spent for all the measure. The measure set should be declared as some
-- global variable. The implementation is thread safe meaning that a measure set can
-- be used by several threads at the same time. It can also be associated with
-- a per-thread data (or task attribute).
--
-- To declare the measure set, use:
--
-- with Util.Measures;
-- ...
-- Perf : Util.Measures.Measure_Set;
--
-- == Measure the implementation ==
--
-- A measure is made by creating a variable of type `Stamp`. The declaration of
-- this variable marks the begining of the measure. The measure ends at the
-- next call to the `Report` procedure.
--
-- with Util.Measures;
-- ...
-- declare
-- Start : Util.Measures.Stamp;
-- begin
-- ...
-- Util.Measures.Report (Perf, Start, "Measure for a block");
-- end;
--
-- When the `Report` procedure is called, the time that elapsed between the creation of
-- the `Start` variable and the procedure call is computed. This time is
-- then associated with the measure title and the associated counter is incremented.
-- The precision of the measured time depends on the system. On GNU/Linux, it uses
-- `gettimeofday`.
--
-- If the block code is executed several times, the measure set will report
-- the number of times it was executed.
--
-- == Reporting results ==
--
-- After measures are collected, the results can be saved in a file or in
-- an output stream. When saving the measures, the measure set is cleared.
--
-- Util.Measures.Write (Perf, "Title of measures",
-- Ada.Text_IO.Standard_Output);
--
-- == Measure Overhead ==
--
-- The overhead introduced by the measurement is quite small as it does not exceeds 1.5 us
-- on a 2.6 Ghz Core Quad.
--
-- == What must be measured ==
--
-- Defining a lot of measurements for a production system is in general not very useful.
-- Measurements should be relatively high level measurements. For example:
--
-- * Loading or saving a file
-- * Rendering a page in a web application
-- * Executing a database query
--
package Util.Measures is
type Unit_Type is (Seconds, Milliseconds, Microseconds, Nanoseconds);
-- ------------------------------
-- Measure Set
-- ------------------------------
-- The measure set represent a collection of measures each of them being
-- associated with a same name. Several measure sets can be created to
-- collect different kinds of runtime information. The measure set can be
-- set on a per-thread data and every call to <b>Report</b> will be
-- associated with that measure set.
--
-- Measure set are thread-safe.
type Measure_Set is limited private;
type Measure_Set_Access is access all Measure_Set;
-- Disable collecting measures on the measure set.
procedure Disable (Measures : in out Measure_Set);
-- Enable collecting measures on the measure set.
procedure Enable (Measures : in out Measure_Set);
-- Set the per-thread measure set.
procedure Set_Current (Measures : in Measure_Set_Access);
-- Get the per-thread measure set.
function Get_Current return Measure_Set_Access;
-- Dump an XML result with the measures collected by the measure set.
-- When writing the measures, the measure set is cleared. It is safe
-- to write measures while other measures are being collected.
procedure Write (Measures : in out Measure_Set;
Title : in String;
Stream : in out Util.Streams.Texts.Print_Stream'Class);
-- Dump an XML result with the measures collected by the measure set.
-- When writing the measures, the measure set is cleared. It is safe
-- to write measures while other measures are being collected.
procedure Write (Measures : in out Measure_Set;
Title : in String;
Stream : in Ada.Text_IO.File_Type);
-- Dump an XML result with the measures in a file.
procedure Write (Measures : in out Measure_Set;
Title : in String;
Path : in String);
-- ------------------------------
-- Stamp
-- ------------------------------
-- The stamp marks the beginning of a measure when the variable of such
-- type is declared. The measure represents the time that elapsed between
-- the stamp creation and when the <b>Report</b> method is called.
type Stamp is limited private;
-- Report the time spent between the stamp creation and this method call.
-- Collect the result in the per-thread measure set under the given measure
-- title.
procedure Report (S : in out Stamp;
Title : in String;
Count : in Positive := 1);
-- Report the time spent between the stamp creation and this method call.
-- Collect the result in the measure set under the given measure title.
procedure Report (Measures : in out Measure_Set;
S : in out Stamp;
Title : in String;
Count : in Positive := 1);
-- Report the time spent between the stamp creation and this method call.
-- The report is written in the file with the given title. The duration is
-- expressed in the unit defined in <tt>Unit</tt>.
procedure Report (S : in out Stamp;
File : in out Ada.Text_IO.File_Type;
Title : in String;
Unit : in Unit_Type := Microseconds);
private
type String_Access is access String;
type Stamp is limited record
Start : Ada.Calendar.Time := Ada.Calendar.Clock;
end record;
type Measure;
type Measure_Access is access Measure;
type Measure is limited record
Next : Measure_Access;
Time : Duration;
Count : Positive;
Name : String_Access;
end record;
type Buckets_Type is
array (Ada.Containers.Hash_Type range <>) of Measure_Access;
type Buckets_Access is access all Buckets_Type;
-- To reduce contention we only protect insertion and updates of measures.
-- To write the measure set, we steal the buckets and force the next call
-- to <b>Add</b> to reallocate the buckets.
protected type Measure_Data is
-- Get the measures and clear to start a new set of measures.
-- Return in <b>Time_Start</b> and <b>Time_End</b> the period of time.
procedure Steal_Map (Result : out Buckets_Access;
Time_Start : out Ada.Calendar.Time;
Time_End : out Ada.Calendar.Time);
-- Add the measure
procedure Add (Title : in String;
D : in Duration;
Count : in Positive := 1);
private
Start : Ada.Calendar.Time := Ada.Calendar.Clock;
Buckets : Buckets_Access;
end Measure_Data;
type Measure_Set is new Ada.Finalization.Limited_Controlled with record
Enabled : Boolean := True;
pragma Atomic (Enabled);
Data : Measure_Data;
end record;
-- Finalize the measures and release the storage.
overriding
procedure Finalize (Measures : in out Measure_Set);
end Util.Measures;
|
-- SPDX-FileCopyrightText: 2010-2021 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with WebIDL.Abstract_Sources;
with League.Strings;
with League.String_Vectors;
with League.Strings.Cursors.Characters;
package WebIDL.String_Sources is
pragma Preelaborate;
type String_Source is new WebIDL.Abstract_Sources.Abstract_Source
with private;
overriding function Get_Next
(Self : not null access String_Source)
return WebIDL.Abstract_Sources.Code_Unit_32;
procedure Set_String_Vector
(Self : out String_Source;
Value : League.String_Vectors.Universal_String_Vector);
private
type String_Source is new WebIDL.Abstract_Sources.Abstract_Source with
record
Vector : League.String_Vectors.Universal_String_Vector;
Index : Positive;
Line : League.Strings.Universal_String;
Cursor : League.Strings.Cursors.Characters.Character_Cursor;
end record;
end WebIDL.String_Sources;
|
package raise_from_pure is
pragma Pure;
function Raise_CE_If_0 (P : Integer) return Integer;
end;
|
-- TITLE external_file_manager
-- AUTHOR: John Self (UCI)
-- DESCRIPTION opens external files for other functions
-- NOTES This package opens external files, and thus may be system dependent
-- because of limitations on file names.
-- This version is for the VADS 5.5 Ada development system.
-- $Header: /co/ua/self/arcadia/aflex/ada/src/RCS/file_managerB.a,v 1.5 90/01/12 15:19:58 self Exp Locker: self $
--***************************************************************************
-- This file is subject to the Arcadia License Agreement.
--
-- (see notice in aflex.a)
--
--***************************************************************************
with MISC_DEFS, TSTRING, TEXT_IO, MISC; use MISC_DEFS, TSTRING, TEXT_IO, MISC;
package body EXTERNAL_FILE_MANAGER is
-- FIX comment about compiler dependent
subtype SUFFIX_TYPE is STRING(1 .. 3);
function ADA_SUFFIX return SUFFIX_TYPE is
begin
return "ada";
end ADA_SUFFIX;
function Five(S:String) return String is
begin
if S'Length <= 5 then
return S;
else
return S(S'First..S'First+4);
end if;
end Five;
procedure GET_IO_FILE(F : in out FILE_TYPE) is
begin
if (LEN(INFILENAME) /= 0) then
CREATE(F, OUT_FILE, Five(STR(MISC.BASENAME)) & "_io." & ADA_SUFFIX);
else
CREATE(F, OUT_FILE, "af_yy_io." & ADA_SUFFIX);
end if;
exception
when USE_ERROR | NAME_ERROR =>
MISC.AFLEXFATAL("could not create IO package file");
end GET_IO_FILE;
procedure GET_DFA_FILE(F : in out FILE_TYPE) is
begin
if (LEN(INFILENAME) /= 0) then
CREATE(F, OUT_FILE, Five(STR(MISC.BASENAME)) & "_df." & ADA_SUFFIX);
else
CREATE(F, OUT_FILE, "af_yy_df." & ADA_SUFFIX);
end if;
exception
when USE_ERROR | NAME_ERROR =>
MISC.AFLEXFATAL("could not create DFA package file");
end GET_DFA_FILE;
procedure GET_SCANNER_FILE(F : in out FILE_TYPE) is
OUTFILE_NAME : VSTRING;
begin
if (LEN(INFILENAME) /= 0) then
-- give out infile + ada_suffix
OUTFILE_NAME := MISC.BASENAME & "." & ADA_SUFFIX;
else
OUTFILE_NAME := VSTR("af_yy." & ADA_SUFFIX);
end if;
CREATE(F, OUT_FILE, STR(OUTFILE_NAME));
SET_OUTPUT(F);
exception
when NAME_ERROR | USE_ERROR =>
MISC.AFLEXFATAL("can't create scanner file " & OUTFILE_NAME);
end GET_SCANNER_FILE;
procedure GET_BACKTRACK_FILE(F : in out FILE_TYPE) is
begin
CREATE(F, OUT_FILE, "aflex.bkt");
exception
when USE_ERROR | NAME_ERROR =>
MISC.AFLEXFATAL("could not create backtrack file");
end GET_BACKTRACK_FILE;
procedure INITIALIZE_FILES is
begin
CREATE(STANDARD_ERROR,OUT_FILE,"CON");
end INITIALIZE_FILES;
end EXTERNAL_FILE_MANAGER;
|
-- C87B26B.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT 'ADDRESS, 'CONSTRAINED, 'SIZE, AND 'STORAGE_SIZE MAY BE
-- USED WITH THE DESIGNATED OBJECTS OF ACCESS VALUES RETURNED FROM
-- OVERLOADED FUNCTIONS, AND THAT EXPLICIT DEREFERENCING IS USED BY
-- OVERLOADING RESOLUTION TO RESOLVE THE PREFIXES OF THE ATTRIBUTES.
-- DSJ 22 JUN 83
-- JBG 11/22/83
-- JBG 4/23/84
-- JBG 5/25/85
WITH REPORT; WITH SYSTEM;
USE REPORT; USE SYSTEM;
PROCEDURE C87B26B IS
TYPE REC (D : INTEGER) IS
RECORD
C1, C2 : INTEGER;
END RECORD;
TYPE P_REC IS ACCESS REC;
P_REC_OBJECT : P_REC := NEW REC'(1,1,1);
TYPE BIG_INT IS RANGE 0..SYSTEM.MAX_INT;
TASK TYPE TASK_TYPE IS
-- NOTHING AT ALL
END TASK_TYPE;
TYPE P_TASK IS ACCESS TASK_TYPE;
P_TASK_OBJECT : P_TASK;
TASK BODY TASK_TYPE IS
BEGIN
NULL;
END TASK_TYPE;
------------------------------------------------------------
FUNCTION F RETURN REC IS
BEGIN
RETURN (0,0,0);
END F;
FUNCTION F RETURN P_REC IS
BEGIN
RETURN P_REC_OBJECT;
END F;
------------------------------------------------------------
FUNCTION G RETURN TASK_TYPE IS
NEW_TASK : TASK_TYPE;
BEGIN
RETURN NEW_TASK;
END G;
FUNCTION G RETURN P_TASK IS
BEGIN
RETURN P_TASK_OBJECT;
END G;
------------------------------------------------------------
BEGIN
TEST("C87B26B","CHECK THAT EXPLICIT DEREFERENCING IN AN " &
"ATTRIBUTE PREFIX IS USED IN OVERLOADING RESOLUTION " &
"WITH 'ADDRESS, 'CONSTRAINED, 'SIZE, AND 'STORAGE_SIZE");
DECLARE
A : ADDRESS; -- FOR 'ADDRESS OF RECORD
B : BOOLEAN; -- FOR 'CONSTRAINED OF RECORD
C : INTEGER; -- FOR 'SIZE OF RECORD
D : ADDRESS; -- FOR 'ADDRESS OF TASK
E : BIG_INT; -- FOR 'STORAGE_SIZE OF TASK
BEGIN
P_TASK_OBJECT := NEW TASK_TYPE;
A := F.ALL'ADDRESS;
B := F.ALL'CONSTRAINED;
C := F.ALL'SIZE;
D := G.ALL'ADDRESS;
E := G.ALL'STORAGE_SIZE;
IF A /= P_REC_OBJECT.ALL'ADDRESS THEN
FAILED("INCORRECT RESOLUTION FOR 'ADDRESS - REC");
END IF;
IF B /= P_REC_OBJECT.ALL'CONSTRAINED THEN
FAILED("INCORRECT RESOLUTION FOR 'CONSTRAINED");
END IF;
IF C /= P_REC_OBJECT.ALL'SIZE THEN
FAILED("INCORRECT RESOLUTION FOR 'SIZE");
END IF;
IF D /= P_TASK_OBJECT.ALL'ADDRESS THEN
FAILED("INCORRECT RESOLUTION FOR 'ADDRESS - TASK");
END IF;
IF E /= P_TASK_OBJECT.ALL'STORAGE_SIZE THEN
FAILED("INCORRECT RESOLUTION FOR 'STORAGE_SIZE");
END IF;
IF A = P_REC_OBJECT'ADDRESS THEN
FAILED("INCORRECT DEREFERENCING FOR 'ADDRESS - REC");
END IF;
IF C = P_REC_OBJECT'SIZE AND C /= P_REC_OBJECT.ALL'SIZE THEN
FAILED("INCORRECT DEREFERENCING FOR 'SIZE");
END IF;
IF D = P_TASK_OBJECT'ADDRESS THEN
FAILED("INCORRECT DEREFERENCING FOR 'ADDRESS - TASK");
END IF;
END;
RESULT;
END C87B26B;
|
-------------------------------------------------------------------------------
-- Copyright (c) 2019, Daniel King
-- All rights reserved.
--
-- Redistribution and use in source and binary forms, with or without
-- modification, are permitted provided that the following conditions are met:
-- * Redistributions of source code must retain the above copyright
-- notice, this list of conditions and the following disclaimer.
-- * Redistributions in binary form must reproduce the above copyright
-- notice, this list of conditions and the following disclaimer in the
-- documentation and/or other materials provided with the distribution.
-- * The name of the copyright holder may not be used to endorse or promote
-- Products derived from this software without specific prior written
-- permission.
--
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY
-- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
-- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
-- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
-- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-------------------------------------------------------------------------------
with Interfaces; use Interfaces;
package body Keccak.Generic_MonkeyDuplex is
-------------
-- Start --
-------------
procedure Start (Ctx : out Context;
Rate : in Rate_Bits_Number;
Data : in Keccak.Types.Byte_Array;
Bit_Len : in Natural) is
begin
Ctx.Rate := Rate;
Init_State (Ctx.State);
XOR_Bits_Into_State (A => Ctx.State,
Data => Data,
Bit_Len => Bit_Len);
XOR_Padding_Into_State (A => Ctx.State,
First_Bit => Bit_Len,
Last_Bit => State_Size_Bits - 1);
Permute_Start (Ctx.State);
end Start;
-------------
-- Start --
-------------
function Start (Rate : in Rate_Bits_Number;
Data : in Keccak.Types.Byte_Array;
Bit_Len : in Natural) return Context is
begin
return Ctx : Context do
Start (Ctx, Rate, Data, Bit_Len);
end return;
end Start;
------------
-- Step --
------------
procedure Step (Ctx : in out Context;
In_Data : in Keccak.Types.Byte_Array;
In_Data_Bit_Length : in Natural;
Suffix : in Keccak.Types.Byte;
Suffix_Bit_Length : in Natural;
Out_Data : out Keccak.Types.Byte_Array;
Out_Data_Bit_Length : in Natural) is
begin
Step_Mute (Ctx => Ctx,
In_Data => In_Data,
In_Data_Bit_Length => In_Data_Bit_Length,
Suffix => Suffix,
Suffix_Bit_Length => Suffix_Bit_Length);
Extract_Bits (A => Ctx.State,
Data => Out_Data,
Bit_Len => Out_Data_Bit_Length);
end Step;
-----------------
-- Step_Mute --
-----------------
procedure Step_Mute (Ctx : in out Context;
In_Data : in Keccak.Types.Byte_Array;
In_Data_Bit_Length : in Natural;
Suffix : in Keccak.Types.Byte;
Suffix_Bit_Length : in Natural) is
First_Suffix_Byte : constant Natural := In_Data_Bit_Length / 8;
Last_Suffix_Byte : constant Natural := (In_Data_Bit_Length + Suffix_Bit_Length - 1) / 8;
begin
XOR_Bits_Into_State (Ctx.State, In_Data, In_Data_Bit_Length);
XOR_Byte_Into_State (A => Ctx.State,
Offset => First_Suffix_Byte,
Value => Shift_Left (Suffix, In_Data_Bit_Length mod 8));
if Last_Suffix_Byte /= First_Suffix_Byte then
XOR_Byte_Into_State (A => Ctx.State,
Offset => Last_Suffix_Byte,
Value => Shift_Right (Suffix, 8 - (In_Data_Bit_Length mod 8)));
end if;
XOR_Padding_Into_State (A => Ctx.State,
First_Bit => In_Data_Bit_Length + Suffix_Bit_Length,
Last_Bit => Rate_Of (Ctx) - 1);
Permute_Step (Ctx.State);
end Step_Mute;
--------------
-- Stride --
--------------
procedure Stride (Ctx : in out Context;
In_Data : in Keccak.Types.Byte_Array;
In_Data_Bit_Length : in Natural;
Suffix : in Keccak.Types.Byte;
Suffix_Bit_Length : in Natural;
Out_Data : out Keccak.Types.Byte_Array;
Out_Data_Bit_Length : in Natural) is
First_Suffix_Byte : constant Natural := In_Data_Bit_Length / 8;
Last_Suffix_Byte : constant Natural := (In_Data_Bit_Length + Suffix_Bit_Length - 1) / 8;
begin
XOR_Bits_Into_State (Ctx.State, In_Data, In_Data_Bit_Length);
XOR_Byte_Into_State (A => Ctx.State,
Offset => First_Suffix_Byte,
Value => Shift_Left (Suffix, In_Data_Bit_Length mod 8));
if Last_Suffix_Byte /= First_Suffix_Byte then
XOR_Byte_Into_State (A => Ctx.State,
Offset => Last_Suffix_Byte,
Value => Shift_Right (Suffix, 8 - (In_Data_Bit_Length mod 8)));
end if;
XOR_Padding_Into_State (A => Ctx.State,
First_Bit => In_Data_Bit_Length + Suffix_Bit_Length,
Last_Bit => Rate_Of (Ctx) - 1);
Permute_Stride (Ctx.State);
Extract_Bits (A => Ctx.State,
Data => Out_Data,
Bit_Len => Out_Data_Bit_Length);
end Stride;
end Keccak.Generic_MonkeyDuplex;
|
-- WORDS, a Latin dictionary, by Colonel William Whitaker (USAF, Retired)
--
-- Copyright William A. Whitaker (1936–2010)
--
-- This is a free program, which means it is proper to copy it and pass
-- it on to your friends. Consider it a developmental item for which
-- there is no charge. However, just for form, it is Copyrighted
-- (c). Permission is hereby freely given for any and all use of program
-- and data. You can sell it as your own, but at least tell me.
--
-- This version is distributed without obligation, but the developer
-- would appreciate comments and suggestions.
--
-- All parts of the WORDS system, source code and data files, are made freely
-- available to anyone who wishes to use them, for whatever purpose.
with Text_IO;
--with Strings_package; use Strings_package;
--with latin_file_names; use latin_file_names;
--with inflections_package; use inflections_package;
--with dictionary_package; use dictionary_package;
--with line_stuff; use line_stuff;
procedure Number is
-- package Integer_IO is new Text_IO.Integer_IO (Integer);
use Text_IO;
Input : Text_IO.File_Type;
Numbered : Text_IO.File_Type;
Line : String (1 .. 300) := (others => ' ');
Last, N : Integer := 0;
begin
Put_Line (
"Takes a text file and produces a NUMBERED. file with line numbers");
Put_Line ("What file to NUMBER?");
Text_IO.Get_Line (Line, Last);
Open (Input, In_File, Line (1 .. Last));
Create (Numbered, Out_File, "NUMBERED.");
while not End_Of_File (Input) loop
N := N + 1;
Get_Line (Input, Line, Last);
Text_IO.Put (Numbered, Integer'Image (N));
Set_Col (Numbered, 10);
Text_IO.Put_Line (Numbered, Line (1 .. Last));
end loop;
Close (Numbered);
end Number;
|
-- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../../License.txt
with CommonText;
package Spatial_Data is
package CT renames CommonText;
type Collection_Type is (unset,
single_point,
single_line_string,
single_polygon,
multi_point,
multi_line_string,
multi_polygon,
heterogeneous);
type Geometric_Shape is (point_shape,
line_string_shape,
polygon_shape,
mixture);
-- The range limits are necessary to avoid storage error warnings
subtype Geo_Points is Positive range 1 .. 2 ** 20;
subtype Geo_Units is Natural range 0 .. 2 ** 12;
-- Mutable variant records must be limited if tagged
-- However, limited geometry cannot work. We must be able to change the
-- contents discriminate, so it meants this record cannot be tagged.
type Geometry (contents : Collection_Type := unset;
units : Geo_Units := Geo_Units'First;
subunits : Geo_Units := Geo_Units'First;
points : Geo_Points := Geo_Points'First) is private;
type Geometric_Real is digits 18;
type Geometric_Point is
record
X : Geometric_Real;
Y : Geometric_Real;
end record;
type Geometric_Circle is
record
center_point : Geometric_Point;
radius : Geometric_Real;
end record;
type Slope_Intercept is
record
slope : Geometric_Real;
y_intercept : Geometric_Real;
vertical : Boolean;
end record;
type Standard_Form is
record
A : Geometric_Real;
B : Geometric_Real;
C : Geometric_Real;
end record;
type Geometric_Point_set is array (Positive range <>) of Geometric_Point;
subtype Geometric_Ring is Geometric_Point_set;
subtype Geometric_Line_String is Geometric_Point_set;
subtype Geometric_Line is Geometric_Line_String (1 .. 2);
type Geometric_Polygon (rings : Geo_Units := Geo_Units'First;
points : Geo_Points := Geo_Points'First) is private;
Origin_Point : constant Geometric_Point := (0.0, 0.0);
--------------------------------
-- Initialization functions --
--------------------------------
function start_polygon (outer_ring : Geometric_Ring)
return Geometric_Polygon;
procedure append_inner_ring (polygon : in out Geometric_Polygon;
inner_ring : Geometric_Ring);
function initialize_as_point (point : Geometric_Point)
return Geometry;
function initialize_as_multi_point (point : Geometric_Point)
return Geometry;
function initialize_as_line (line_string : Geometric_Line_String)
return Geometry;
function initialize_as_multi_line (line_string : Geometric_Line_String)
return Geometry;
function initialize_as_polygon (polygon : Geometric_Polygon)
return Geometry;
function initialize_as_multi_polygon (polygon : Geometric_Polygon)
return Geometry;
function initialize_as_collection (anything : Geometry) return Geometry;
-----------------------------------
-- Build collections functions --
-----------------------------------
procedure augment_multi_point (collection : in out Geometry;
point : Geometric_Point);
procedure augment_multi_line (collection : in out Geometry;
line : Geometric_Line_String);
procedure augment_multi_polygon (collection : in out Geometry;
polygon : Geometric_Polygon);
procedure augment_collection (collection : in out Geometry;
anything : Geometry);
---------------------------
-- Retrieval functions --
---------------------------
function type_of_collection (collection : Geometry)
return Collection_Type;
function size_of_collection (collection : Geometry)
return Positive;
function collection_item_type (collection : Geometry;
index : Positive := 1)
return Collection_Type;
function retrieve_subcollection (collection : Geometry;
index : Positive := 1)
return Geometry;
function retrieve_point (collection : Geometry;
index : Positive := 1)
return Geometric_Point;
function retrieve_line (collection : Geometry;
index : Positive := 1)
return Geometric_Line_String;
function retrieve_polygon (collection : Geometry;
index : Positive := 1)
return Geometric_Polygon;
function number_of_rings (polygon : Geometric_Polygon)
return Natural;
function retrieve_ring (polygon : Geometric_Polygon;
ring_index : Positive)
return Geometric_Ring;
-------------------
-- Conversions --
-------------------
function convert_infinite_line (line : Geometric_Line)
return Slope_Intercept;
function convert_infinite_line (line : Geometric_Line) return Standard_Form;
function convert_to_infinite_line (std_form : Standard_Form)
return Geometric_Line;
function convert_to_infinite_line (intercept_form : Slope_Intercept)
return Geometric_Line;
---------------------------
-- Text Representation --
---------------------------
function mysql_text (collection : Geometry;
top_first : Boolean := True) return String;
function Well_Known_Text (collection : Geometry;
top_first : Boolean := True) return String;
function dump (collection : Geometry) return String;
CONVERSION_FAILED : exception;
OUT_OF_COLLECTION_RANGE : exception;
LACKING_POINTS : exception;
ILLEGAL_POLY_HOLE : exception;
ILLEGAL_SHAPE : exception;
private
subtype Geometric_Point_Collection is Geometric_Point_set;
subtype Item_ID_type is Positive range 1 .. 2 ** 10; -- 1024 shapes
type collection_flags is mod 2 ** 24;
type Ring_Structure is
record
Item_Type : Collection_Type;
Item_ID : Item_ID_type;
Ring_ID : Geo_Units;
Ring_Size : Geo_Points;
Ring_Count : Geo_Units;
Point_Index : Geo_Points;
Level_Flags : collection_flags;
Group_ID : Item_ID_type;
end record;
type Ring_Structures is array (Positive range <>) of Ring_Structure;
type Geometric_Polygon (rings : Geo_Units := Geo_Units'First;
points : Geo_Points := Geo_Points'First) is
record
structures : Ring_Structures (1 .. rings);
points_set : Geometric_Point_Collection (1 .. points) :=
(others => Origin_Point);
end record;
type Geometry (contents : Collection_Type := unset;
units : Geo_Units := Geo_Units'First;
subunits : Geo_Units := Geo_Units'First;
points : Geo_Points := Geo_Points'First) is
record
case contents is
when unset => null;
when others =>
structures : Ring_Structures (1 .. subunits);
points_set : Geometric_Point_Collection (1 .. points);
end case;
end record;
-- returns a trimmed floating point image
function format_real (value : Geometric_Real) return String;
-- returns the highest value for Level Flags found
function highest_level (collection : Geometry) return collection_flags;
-- raises exception if index is out of range
procedure check_collection_index (collection : Geometry; index : Positive);
function single_canvas (gm_type : Collection_Type;
items : Item_ID_type;
subunits : Geo_Units;
points : Geo_Points) return Geometry;
function collection_item_shape (collection : Geometry;
index : Positive := 1)
return Geometric_Shape;
end Spatial_Data;
|
pragma Ada_2012;
package body Adventofcode.Day_1 is
----------
-- Eval --
----------
function Eval (Book : Expenses; To : Currency) return Currency is
begin
for A in Book'Range loop
for B in A + 1 .. Book'Last loop
if Book (A) + Book (B) = To then
return Book (A) * Book (B);
end if;
end loop;
end loop;
return 0;
end Eval;
function Eval3 (Book : Expenses; To : Currency) return Currency is
begin
for A in Book'Range loop
for B in A + 1 .. Book'Last loop
for C in B + 1 .. Book'Last loop
if Book (A) + Book (B) + Book (C) = To then
return Book (A) * Book (B) * Book (C);
end if;
end loop;
end loop;
end loop;
return 0;
end Eval3;
end Adventofcode.Day_1;
|
------------------------------------------------------------------------------
-- Copyright (c) 2016, 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. --
------------------------------------------------------------------------------
package body Natools.Parallelism is
procedure Single_Accumulator_Run
(Global : in out Global_State;
Task_Count : in Positive)
is
protected State is
procedure Initialize (Job : out Job_State; Continue : out Boolean);
procedure Next (Job : in out Job_State; Continue : out Boolean);
end State;
task type Worker is
end Worker;
protected body State is
procedure Initialize (Job : out Job_State; Continue : out Boolean) is
begin
Continue := not Is_Finished (Global);
if Continue then
Initialize_Job (Global, Job);
end if;
end Initialize;
procedure Next (Job : in out Job_State; Continue : out Boolean) is
begin
Gather_Result (Global, Job);
Initialize (Job, Continue);
end Next;
end State;
task body Worker is
Job : Job_State;
Continue : Boolean;
begin
State.Initialize (Job, Continue);
while Continue loop
Do_Job (Job);
State.Next (Job, Continue);
end loop;
end Worker;
Workers : array (1 .. Task_Count) of Worker;
pragma Unreferenced (Workers);
begin
null;
end Single_Accumulator_Run;
procedure Per_Task_Accumulator_Run
(Global : in out Global_State;
Task_Count : in Positive)
is
protected State is
procedure Get_Next_Job
(Job : out Job_Description;
Terminated : out Boolean);
procedure Gather (Result : in Task_Result);
end State;
task type Worker is
end Worker;
protected body State is
procedure Get_Next_Job
(Job : out Job_Description;
Terminated : out Boolean) is
begin
Get_Next_Job (Global, Job, Terminated);
end Get_Next_Job;
procedure Gather (Result : in Task_Result) is
begin
Gather_Result (Global, Result);
end Gather;
end State;
task body Worker is
Job : Job_Description;
Result : Task_Result;
Terminated : Boolean;
begin
Initialize (Result);
loop
State.Get_Next_Job (Job, Terminated);
exit when Terminated;
Do_Job (Result, Job);
end loop;
State.Gather (Result);
end Worker;
Workers : array (1 .. Task_Count) of Worker;
pragma Unreferenced (Workers);
begin
null;
end Per_Task_Accumulator_Run;
end Natools.Parallelism;
|
------------------------------------------------------------------------------
-- --
-- Internet Protocol Suite Package --
-- --
-- ------------------------------------------------------------------------ --
-- --
-- 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. --
-- --
------------------------------------------------------------------------------
with Ada.Calendar;
with Ada.Exceptions;
with Interfaces.C;
with INET.IP.Lookup;
package body INET.TCP is
use type Interfaces.C.int;
subtype int is Interfaces.C.int;
function Exception_Information (X: Ada.Exceptions.Exception_Occurrence)
return String
renames Ada.Exceptions.Exception_Information;
------------------------
-- Raise_IO_Exception --
------------------------
-- Given an Operation_Status value, raises the appropriate exception.
procedure Raise_IO_Exception (Status: in UNIX_Sockets.Operation_Status;
Errno : in int)
is
use UNIX_Sockets;
begin
case Status is
when OK | Not_Ready => null;
when Timedout => raise TCP_Timeout;
when Not_Connected =>
-- This only means the user is trying read/write before creating a
-- connection
raise Program_Error with "TCP_Connection must be connected first.";
when Connection_Reset => raise TCP_Connection_Reset;
when Connection_Refused => raise TCP_Connection_Refused;
when Net_Unreachable => raise TCP_Net_Unreachable;
when Host_Unreachable => raise TCP_Host_Unreachable;
when Unauthorized
| Address_Occupied =>
raise TCP_System_Error with "Operation_Status """
& Operation_Status'Image (Status)
& """ not expected during send/recv.";
when Other_Failure =>
raise TCP_System_Error with " errno =" & int'Image (Errno);
end case;
end Raise_IO_Exception;
--
-- TCP_Connection
--
----------------------
-- Generic_Poll_Set --
----------------------
generic
Stream : in out TCP_Connection'Class;
Direction : in UNIX_Sockets.Data_Direction;
Timeout_Set: in Boolean;
Timeout : in Duration;
Start_Time : in Ada.Calendar.Time;
-- Should point at Socket.Read_Block or Write_Block;
package Generic_Poll_Set is
procedure Poll_With_Timeout with Pre => Timeout_Set;
-- Poll_With_Timeout is only invoked if the connection has a timeout set
-- Therefore it also takes responsibility for raising a TCP_Timeout
-- exception if the timout is exceeded.
procedure Poll_Forever with Pre => not Timeout_Set;
-- In this case, we don't give a timeout at all, but it may still
-- might get interrupted. The Generic_Transfer_Loop implementation
-- deals with that condition
end Generic_Poll_Set;
package body Generic_Poll_Set is
use Ada.Calendar;
procedure Poll_With_Timeout is
Elapsed_Time : constant Duration := Clock - Start_Time;
begin
-- Check for a timeout expirty before executing a poll.
if Elapsed_Time >= Stream.Read_Timeout then
raise TCP_Timeout;
end if;
-- This means that Elapsed_Time < Stream.Read_Timeout.
-- This assertion would be checked by the precondition on Wait.
UNIX_Sockets.Wait (Socket => Stream.Socket,
Direction => Direction,
Timeout => Timeout - Elapsed_Time);
end Poll_With_Timeout;
procedure Poll_Forever is
-- In this case, we don't give a timeout at all, but it may still
-- get "interrupted", but that won't concern us. The key is that
-- we won't leave the main loop until Last = Item'Last.
begin
UNIX_Sockets.Wait (Socket => Stream.Socket,
Direction => Direction);
end Poll_Forever;
end Generic_Poll_Set;
------------------
-- Generic_Read --
------------------
procedure Generic_Read (Stream: in out Connection_Type;
Item : out Stream_Element_Array;
Last : out Stream_Element_Offset)
is
use UNIX_Sockets;
Status: Operation_Status;
Errno : int;
Water_Level: Stream_Element_Offset := Item'First - 1;
-- Index of the most recently received storage element
package Poll_Set is new Generic_Poll_Set
(Stream => TCP_Connection'Class(Stream),
Direction => Inbound,
Timeout_Set => Stream.Read_Does_Timeout,
Timeout => Stream.Read_Timeout,
Start_Time => Ada.Calendar.Clock);
-- Select the appropriate polling procedure
Poll: access procedure;
begin
if Item'Length = 0 then
Last := Item'Last;
return;
end if;
if Stream.Read_Does_Timeout then
if Stream.Read_Timeout = 0.0 then
-- This is just the same as a Read_Immediate.
Stream.Read_Immediate (Item, Last);
return;
else
Poll := Poll_Set.Poll_With_Timeout'Access;
end if;
else
Poll := Poll_Set.Poll_Forever'Access;
end if;
loop
Connection_Receive_Immediate
(Connection => Stream,
Buffer => Item (Water_Level + 1 .. Item'Last),
Last => Last,
Status => Status,
Errno => Errno);
exit when Last = Item'Last;
-- If we got everything, even if there was an error, there's no real
-- reason to report it, thus this comes before we check status
if Status not in OK | Not_Ready then
Raise_IO_Exception (Status, Errno);
end if;
if Last > Water_Level then
Water_Level := Last;
end if;
-- We don't have enough and we didn't get an explicit error. Time to
-- sleep on it
Poll.all;
end loop;
end Generic_Read;
-------------------
-- Generic_Write --
-------------------
procedure Generic_Write (Stream: in out Connection_Type;
Item : in Stream_Element_Array)
is
use UNIX_Sockets;
Status: Operation_Status;
Errno : int;
Water_Level: Stream_Element_Offset := Item'First - 1;
Last : Stream_Element_Offset;
-- Index of the most recently sent storage element
package Poll_Set is new Generic_Poll_Set
(Stream => TCP_Connection'Class(Stream),
Direction => Outbound,
Timeout_Set => Stream.Write_Does_Timeout,
Timeout => Stream.Write_Timeout,
Start_Time => Ada.Calendar.Clock);
-- Select the appropriate polling procedure
Poll: access procedure;
begin
if Item'Length = 0 then
return;
end if;
if Stream.Write_Does_Timeout then
if Stream.Write_Timeout = 0.0 then
-- This is just the same as a Wirte_Immediate, however we
-- need to raise an exception if Last is < Item'Last.
Stream.Write_Immediate (Item, Last);
if Last < Item'Last then
-- This implies the write was OK, or Not_Ready, otherwise
-- Write_Immediate would have raised an exception.
raise TCP_Timeout with "INET.TCP.Write: "
& "TCP_Connection is set to non-blocking, but "
& "the write could not be completed.";
end if;
else
Poll := Poll_Set.Poll_With_Timeout'Access;
end if;
else
Poll := Poll_Set.Poll_Forever'Access;
end if;
loop
Connection_Send_Immediate
(Connection => Stream,
Buffer => Item (Water_Level + 1 .. Item'Last),
Last => Last,
Status => Status,
Errno => Errno);
exit when Last = Item'Last;
-- If we got everything, even if there was an error, there's no real
-- reason to report it, thus this comes before we check status
if Status not in OK | Not_Ready then
Raise_IO_Exception (Status, Errno);
end if;
if Last > Water_Level then
Water_Level := Last;
end if;
-- We don't have enough and we didn't get an explicit error. Time to
-- sleep on it
Poll.all;
end loop;
end Generic_Write;
----------
-- Read --
----------
procedure Receive_Immediate_Wrapper
(Connection: in out TCP_Connection;
Buffer : out Stream_Element_Array;
Last : out Stream_Element_Offset;
Status : out UNIX_Sockets.Operation_Status;
Errno : out int)
with Inline is
use UNIX_Sockets;
begin
TCP_Receive_Immediate (Socket => Connection.Socket,
Buffer => Buffer,
Last => Last,
Status => Status,
Errno => Errno);
end;
procedure Read_Actual is new Generic_Read
(Connection_Type => TCP_Connection,
Connection_Receive_Immediate => Receive_Immediate_Wrapper);
procedure Read (Stream: in out TCP_Connection;
Item : out Stream_Element_Array;
Last : out Stream_Element_Offset)
renames Read_Actual;
--------------------
-- Read_Immediate --
--------------------
procedure Read_Immediate (Stream: in out TCP_Connection;
Item : out Stream_Element_Array;
Last : out Stream_Element_Offset)
is
use UNIX_Sockets;
Status: Operation_Status;
Errno : int;
begin
TCP_Receive_Immediate (Socket => Stream.Socket,
Buffer => Item,
Last => Last,
Status => Status,
Errno => Errno);
-- We don't really "care" if that worked or not..
end Read_Immediate;
-----------
-- Write --
-----------
procedure Send_Immediate_Wrapper
(Connection: in out TCP_Connection;
Buffer : in Stream_Element_Array;
Last : out Stream_Element_Offset;
Status : out UNIX_Sockets.Operation_Status;
Errno : out int)
with Inline is
use UNIX_Sockets;
begin
TCP_Send_Immediate (Socket => Connection.Socket,
Buffer => Buffer,
Last => Last,
Status => Status,
Errno => Errno);
end;
procedure Write_Actual is new Generic_Write
(Connection_Type => TCP_Connection,
Connection_Send_Immediate => Send_Immediate_Wrapper);
procedure Write (Stream: in out TCP_Connection;
Item : in Stream_Element_Array)
renames Write_Actual;
---------------------
-- Write_Immediate --
---------------------
procedure Write_Immediate (Stream: in out TCP_Connection;
Item : in Stream_Element_Array;
Last : out Stream_Element_Offset)
is
use UNIX_Sockets;
Status: Operation_Status;
Errno : int;
begin
TCP_Send_Immediate (Socket => Stream.Socket,
Buffer => Item,
Last => Last,
Status => Status,
Errno => Errno);
end Write_Immediate;
-------------------------
-- Destination_Address --
-------------------------
function Destination_Address (Connection: TCP_Connection)
return IP.IP_Address is
(Connection.Destination_Address);
----------------------
-- Destination_Port --
----------------------
function Destination_Port (Connection: TCP_Connection)
return TCP_Port is
(Connection.Destination_Port);
------------------
-- Read_Timeout --
------------------
procedure Read_Timeout (Connection: in out TCP_Connection;
Timeout : in Duration)
is begin
Connection.Read_Does_Timeout := True;
Connection.Read_Timeout := Timeout;
end Read_Timeout;
------------------------
-- Read_Never_Timeout --
------------------------
procedure Read_Never_Timeout (Connection: in out TCP_Connection) is
begin
Connection.Read_Does_Timeout := False;
end Read_Never_Timeout;
-------------------
-- Write_Timeout --
-------------------
procedure Write_Timeout (Connection: in out TCP_Connection;
Timeout : in Duration)
is begin
Connection.Write_Does_Timeout := True;
Connection.Write_Timeout := Timeout;
end Write_Timeout;
-------------------------
-- Write_Never_Timeout --
-------------------------
procedure Write_Never_Timeout (Connection: in out TCP_Connection) is
begin
Connection.Write_Does_Timeout := False;
end Write_Never_Timeout;
-------------
-- Connect --
-------------
procedure Connect (Connection: in out TCP_Connection;
Address : in IP.IP_Address;
Port : in TCP_Port)
is
use UNIX_Sockets;
Status: Operation_Status;
Errno : int;
begin
TCP_Connect (Socket => Connection.Socket,
Address => Address,
Port => Port,
Status => Status,
Errno => Errno);
if Status = OK then
Connection.Destination_Address := Address;
Connection.Destination_Port := Port;
else
pragma Assert (Status /= Not_Connected);
-- This would not make sense..
Raise_IO_Exception (Status, Errno);
end if;
end Connect;
----------------------------------------------------------------------
procedure Connect (Connection: in out TCP_Connection;
Host_Name : in String;
Port : in TCP_Port)
is
use INET.IP.Lookup;
Query : IP_Lookup;
Result: IP_Lookup_Entry;
begin
Query.Lookup (Host_Name => Host_Name,
Protocol => Proto_TCP);
if not Query.Has_More_Entries then
raise TCP_Lookup_Failed with "Lookup of host """
& Host_Name & """ failed.";
end if;
Query.Pop (Result);
Connection.Connect (Address => Result.Address,
Port => Port);
end Connect;
----------------------------------------------------------------------
procedure Connect (Connection : in out TCP_Connection;
Host_Name : in String;
Port : in TCP_Port;
Version : in IP.IP_Version)
is
use INET.IP.Lookup;
Query : IP_Lookup;
Result: IP_Lookup_Entry;
begin
Query.Lookup (Host_Name => Host_Name,
Protocol => Proto_TCP,
Version => Version);
if not Query.Has_More_Entries then
raise TCP_Lookup_Failed with "Lookup of host """
& Host_Name & """ failed.";
end if;
Query.Pop (Result);
Connection.Connect (Address => Result.Address,
Port => Port);
end Connect;
--------------
-- Shutdown --
--------------
procedure Shutdown (Connection: in out TCP_Connection) is
use UNIX_Sockets;
begin
TCP_Shutdown (Socket => Connection.Socket,
Direction => Both);
end Shutdown;
-------------------
-- Shutdown_Read --
-------------------
procedure Shutdown_Read (Connection: in out TCP_Connection) is
use UNIX_Sockets;
begin
TCP_Shutdown (Socket => Connection.Socket,
Direction => Inbound);
end Shutdown_Read;
--------------------
-- Shutdown_Write --
--------------------
procedure Shutdown_Write (Connection: in out TCP_Connection) is
use UNIX_Sockets;
begin
TCP_Shutdown (Socket => Connection.Socket,
Direction => Outbound);
end Shutdown_Write;
--
-- TCP_Listener
--
-------------------------
-- Listener_Bound_Flag --
-------------------------
protected body Listener_Bound_Flag is
procedure Set_Bound is begin
pragma Assert (Bound_Flag = False);
Bound_Flag := True;
end;
function Is_Bound return Boolean is (Bound_Flag);
end Listener_Bound_Flag;
--------------
-- Is_Bound --
--------------
function Is_Bound (Listener: TCP_Listener) return Boolean is
(Listener.Bound_Flag.Is_Bound);
----------
-- Bind --
----------
procedure Bind (Listener: in out TCP_Listener;
Address : in IP.IP_Address;
Port : in TCP_Port)
is
use UNIX_Sockets;
Result: Operation_Status;
Errno : int;
begin
if Listener.Bound_Flag.Is_Bound then
raise Program_Error with "Attempt to Bind a TCP_Listener twice.";
end if;
TCP_Bind_Listener (Socket => Listener.Socket,
Address => Address,
Port => Port,
Backlog => Listener.Queue_Size,
Status => Result,
Errno => Errno);
case Result is
when OK =>
null;
when Unauthorized =>
raise TCP_Bind_Unauthorized;
when Address_Occupied =>
raise TCP_Bind_Occupied;
when others =>
raise TCP_System_Error with
"Bind failed with status: "
& Operation_Status'Image (Result)
& " (errno =" & int'Image (Errno) & ')';
end case;
-- Done
Listener.Bound_Flag.Set_Bound;
exception
when Program_Error
| TCP_System_Error
| TCP_Bind_Unauthorized
| TCP_Bind_Occupied
=>
raise;
when e: others =>
raise TCP_System_Error with "Unexpected exception: "
& Exception_Information (e);
end Bind;
-------------
-- Dequeue --
-------------
procedure Dequeue (Listener : in out TCP_Listener;
Connection: in out TCP_Connection'Class)
is
use UNIX_Sockets;
Status: Operation_Status;
Errno : int;
begin
if not Listener.Is_Bound then
raise TCP_Listener_Not_Bound;
end if;
Connection.Shutdown;
-- The socket will be closed and replaced within the UNIX_Sockets
-- package, if it is active
TCP_Accept_Connection (Listen_Socket => Listener.Socket,
New_Socket => Connection.Socket,
Client_Address => Connection.Destination_Address,
Client_Port => Connection.Destination_Port,
Status => Status,
Errno => Errno);
if Status /= OK then
raise TCP_System_Error with
"Dequeue failed with status: "
& Operation_Status'Image (Status)
& " (errno =" & int'Image (Errno) & ')';
end if;
end Dequeue;
----------------------------------------------------------------------
function Dequeue (Listener: in out TCP_Listener) return TCP_Connection'Class
is begin
return New_Connection: TCP_Connection do
Listener.Dequeue (New_Connection);
end return;
end Dequeue;
end INET.TCP;
|
with Asis.Elements;
package body Asis_Adapter.Element.Pragmas is
procedure Do_Pre_Child_Processing
(Element : in Asis.Element; State : in out Class)
is
Parent_Name : constant String := Module_Name;
Module_Name : constant String := Parent_Name & ".Do_Pre_Child_Processing";
Pragma_Kind : Asis.Pragma_Kinds :=
Asis.Elements.Pragma_Kind (Element);
Result : a_nodes_h.Pragma_Struct :=
a_nodes_h.Support.Default_Pragma_Struct;
procedure Add_Name_Image is
WS : constant Wide_String := Asis.Elements.Pragma_Name_Image (Element);
begin
State.Add_To_Dot_Label ("Pragma_Name_Image", To_String(WS));
Result.Pragma_Name_Image := a_nodes_h.Program_Text(To_Chars_Ptr(WS));
end;
procedure Add_Pragma_Argument_Associations is
begin
Add_Element_List
(This => State,
Elements_In => Asis.Elements.Pragma_Argument_Associations (Element),
Dot_Label_Name => "Pragma_Argument_Associations",
List_Out => Result.Pragma_Argument_Associations,
Add_Edges => True);
end;
begin
--All Pragmas seem to be identical, so there's no reason to seperate things out
State.Add_To_Dot_Label ("Pragma_Kind", Pragma_Kind'Image);
Result.Pragma_Kind := To_Pragma_Kinds (Pragma_Kind);
Add_Name_Image;
Add_Pragma_Argument_Associations;
-- Done making pragma
State.A_Element.Element_Kind := a_nodes_h.A_Pragma;
State.A_Element.the_union.The_Pragma := Result;
end Do_Pre_Child_Processing;
end Asis_Adapter.Element.Pragmas;
|
--
-- This module contains data storage type hierarchy.
--
-- Copyright (c) 2019, George Shapovalov <gshapovalov@gmail.com>
--
-- 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 algorithmic;
use algorithmic;
package data_storage is
type Naive_Data is new Naive_Interface with record
data : Integer;
end record;
overriding function Get_Data (ND : Naive_Data) return Integer;
overriding procedure Set_Data (ND : in out Naive_Data; data : Integer);
overriding
function Do_Complex_Calculation(ND : Naive_Data; input : Integer) return Integer;
type Optimized_Data is new Naive_Data and Optimized_Interface with record
extra_data : Integer;
end record;
overriding function Get_Extra_Data (OD : Optimized_Data) return Integer;
overriding procedure Set_Extra_Data (OD : in out Optimized_Data; data : Integer);
overriding
function Do_Complex_Calculation(OD : Optimized_Data; input : Integer) return Integer;
pragma Inline(Get_Data, Set_Data, Get_Extra_Data, Set_Extra_Data);
-------------------------------------
-- completion of Unrelated_Interface
type Unrelated_Type is new Unrelated_Interface with null record;
end data_storage;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.