repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
LiberatorUSA/GUCEF
Ada
244
adb
with ada.text_io; package body winicon_callbacks is package io renames ada.text_io; procedure quit (event : gui_event.event_access_t) is begin io.put_line ("winicon: exiting"); agar.core.quit; end quit; end winicon_callbacks;
AdaCore/libadalang
Ada
40
ads
package Aaa is B : Integer; end Aaa;
zhmu/ananas
Ada
4,920
ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- I M P U N I T -- -- -- -- S p e c -- -- -- -- Copyright (C) 2000-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package contains data and functions used to determine if a given unit -- is an internal unit intended only for use by the implementation and which -- should not be directly WITH'ed by user code. It also checks for Ada 2005 -- units that should only be WITH'ed in Ada 2005 mode, and Ada 2012 units -- that should only be WITH'ed in Ada 2012 mode. with Types; use Types; package Impunit is type Kind_Of_Unit is (Implementation_Unit, -- Unit from predefined library intended to be used only by the compiler -- generated code, or from the implementation of the run time. Use of -- such a unit generates a warning unless the client is compiled with -- the -gnatg switch. If we are being super strict, this should be an -- error for the case of Ada units, but that seems over strenuous. Not_Predefined_Unit, -- This is not a predefined unit, so no checks are needed Ada_95_Unit, Ada_2005_Unit, Ada_2012_Unit, Ada_2022_Unit); -- This unit is defined in the Ada RM of the given year. This is used to -- give a warning when withing a unit from a wrong mode (e.g. withing an -- Ada_2012_Unit when compiling with -gnat95). Note that in Ada 83 mode, -- no child units are allowed, so you can't even name such a unit. function Get_Kind_Of_Unit (U : Unit_Number_Type) return Kind_Of_Unit; -- Given the unit number of a unit, this function determines the type -- of the unit, as defined above. If the result is Implementation_Unit, -- then the name of a possible alternative equivalent unit is placed in -- Error_Msg_String/Slen on return. If there is no alternative name, or if -- the result is not Implementation_Unit, then Error_Msg_Slen is zero on -- return, indicating that no alternative name was found. function Get_Kind_Of_File (File : String) return Kind_Of_Unit; -- Same as Get_Kind_Of_Unit, for a given filename function Is_Known_Unit (Nam : Node_Id) return Boolean; -- Nam is the possible name of a child unit, represented as a selected -- component node. This function determines whether the name matches one of -- the known library units, and if so, returns True. If the name does not -- match any known library unit, False is returned. function Not_Impl_Defined_Unit (U : Unit_Number_Type) return Boolean; -- This function returns True if U represents a unit that is permitted by -- the restriction No_Implementation_Units (i.e. a unit in the Ada, System, -- and Interfaces hierarchies that is defined in the RM, or a user defined -- unit. It returns False if U represents a unit that is not permitted by -- this restriction, which includes units in these three hierarchies that -- are GNAT implementation defined. It also returns False for any units in -- the GNAT hierarchy, which is not strictly conforming, but so obviously -- useful that it is a reasonable deviation from the standard. end Impunit;
AdaCore/libadalang
Ada
194
adb
procedure Test is generic package Pkg is type U is null record; pragma Pack (U); end Pkg; package Pkg_I is new Pkg; subtype R_D is Pkg_I.U; begin null; end Test;
yannickmoy/StratoX
Ada
1,501
ads
-- Project: StratoX -- System: Stratosphere Balloon Flight Controller -- Author: Martin Becker ([email protected]) with FAT_Filesystem.Directories.Files; with Interfaces; use Interfaces; -- @summary top-level package for reading/writing logfiles to SD card package SDLog with SPARK_Mode, Abstract_State => State, Initializes => State is subtype SDLog_Data is FAT_Filesystem.Directories.Files.File_Data; procedure Init with Post => Is_Open = False; -- initialize the SD log procedure Close with Post => Is_Open = False; -- closes the SD log procedure Start_Logfile (dirname : String; filename : String; ret : out Boolean); -- @summary create new logfile procedure Write_Log (Data : SDLog_Data; n_written : out Integer) with Pre => Is_Open; -- @summary write bytes to logfile procedure Write_Log (S : String; n_written : out Integer) with Pre => Is_Open; -- convenience function for Write_Log (File_Data) procedure Flush_Log; -- @summary force writing logfile to disk. Not recommended when time is critical! function Logsize return Unsigned_32; -- return log size in bytes function Is_Open return Boolean; -- return true if logfile is opened function To_File_Data (S : String) return SDLog_Data; private log_open : Boolean := False with Part_Of => State; SD_Initialized : Boolean := False with Part_Of => State; Error_State : Boolean := False with Part_Of => State; end SDLog;
jhumphry/Ada_BinToAsc
Ada
2,262
ads
-- BinToAsc_Suite.Base16_Tests -- Unit test utilities for BinToAsc -- Copyright (c) 2015, James Humphry - see LICENSE file for details with AUnit; use AUnit; with AUnit.Test_Cases; use AUnit.Test_Cases; with BinToAsc; with RFC4648; package BinToAsc_Suite.Utils is generic with package BToA is new BinToAsc(<>); type Codec_To_String is new BToA.Codec_To_String with private; type Codec_To_Bin is new BToA.Codec_To_Bin with private; procedure Check_Symmetry (T : in out Test_Cases.Test_Case'Class); generic with package BToA is new BinToAsc(<>); type Codec_To_String is new BToA.Codec_To_String with private; type Codec_To_Bin is new BToA.Codec_To_Bin with private; procedure Check_Length (T : in out Test_Cases.Test_Case'Class); generic Test_Vectors : Test_Vector_Array; type Codec_To_String is new RFC4648.BToA.Codec_To_String with private; procedure Check_Test_Vectors_To_String (T : in out Test_Cases.Test_Case'Class); generic Test_Vectors : Test_Vector_Array; type Codec_To_Bin is new RFC4648.BToA.Codec_To_Bin with private; procedure Check_Test_Vectors_To_Bin (T : in out Test_Cases.Test_Case'Class); generic Test_Vectors : Test_Vector_Array; type Codec_To_String is new RFC4648.BToA.Codec_To_String with private; Max_Buffer_Length : Positive := 20; procedure Check_Test_Vectors_Incremental_To_String (T : in out Test_Cases.Test_Case'Class); generic Test_Vectors : Test_Vector_Array; type Codec_To_Bin is new RFC4648.BToA.Codec_To_Bin with private; Max_Buffer_Length : Positive := 20; procedure Check_Test_Vectors_Incremental_To_Bin (T : in out Test_Cases.Test_Case'Class); generic Test_Vectors : Test_Vector_Array; type Codec_To_String is new RFC4648.BToA.Codec_To_String with private; Max_Buffer_Length : Positive := 20; procedure Check_Test_Vectors_By_Char_To_String (T : in out Test_Cases.Test_Case'Class); generic Test_Vectors : Test_Vector_Array; type Codec_To_Bin is new RFC4648.BToA.Codec_To_Bin with private; Max_Buffer_Length : Positive := 20; procedure Check_Test_Vectors_By_Char_To_Bin (T : in out Test_Cases.Test_Case'Class); end BinToAsc_Suite.Utils;
BrickBot/Bound-T-H8-300
Ada
3,948
adb
-- Bounds.Looping.Opt (body) -- -- Author: Niklas Holsti, Tidorum Ltd -- -- A component of the Bound-T Worst-Case Execution Time Tool. -- ------------------------------------------------------------------------------- -- Copyright (c) 1999 .. 2015 Tidorum Ltd -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- -- 1. Redistributions of source code must retain the above copyright notice, this -- list of conditions and the following disclaimer. -- 2. Redistributions in binary form must reproduce the above copyright notice, -- this list of conditions and the following disclaimer in the documentation -- and/or other materials provided with the distribution. -- -- This software is provided by the copyright holders and contributors "as is" and -- any express or implied warranties, including, but not limited to, the implied -- warranties of merchantability and fitness for a particular purpose are -- disclaimed. In no event shall the copyright owner or contributors be liable for -- any direct, indirect, incidental, special, exemplary, or consequential damages -- (including, but not limited to, procurement of substitute goods or services; -- loss of use, data, or profits; or business interruption) however caused and -- on any theory of liability, whether in contract, strict liability, or tort -- (including negligence or otherwise) arising in any way out of the use of this -- software, even if advised of the possibility of such damage. -- -- Other modules (files) of this software composition should contain their -- own copyright statements, which may have different copyright and usage -- conditions. The above conditions apply to this file. ------------------------------------------------------------------------------- -- -- $Revision: 1.7 $ -- $Date: 2015/10/24 20:05:46 $ -- -- $Log: bounds-looping-opt.adb,v $ -- Revision 1.7 2015/10/24 20:05:46 niklas -- Moved to free licence. -- -- Revision 1.6 2012-02-13 17:52:19 niklas -- BT-CH-0230: Options -max_loop and -max_stack for spurious bounds. -- -- Revision 1.5 2011-09-08 08:54:19 niklas -- Added option "warn sw_neg_step", Warn_Swap_Small_Negative_Step. -- -- Revision 1.4 2011-09-08 08:46:49 niklas -- Added option "sw_neg_step", Swap_Small_Negative_Step. -- -- Revision 1.3 2011-08-31 04:23:33 niklas -- BT-CH-0222: Option registry. Option -dump. External help files. -- -- Revision 1.2 2009-11-27 11:28:06 niklas -- BT-CH-0184: Bit-widths, Word_T, failed modular analysis. -- -- Revision 1.1 2008/05/03 09:22:05 niklas -- BT-CH-0126: Combining joint-counter and each-counter analysis. -- with Options; with Options.Groups; package body Bounds.Looping.Opt is procedure Set_Joint_Counter (State : Boolean) is begin if State then -- "-joint_counter" => Joint. Proc := Joint; else -- "-no_joint_counter" => Trad. Proc := Trad; end if; end Set_Joint_Counter; begin -- Bounds.Looping.Opt -- TBM: Register Use_Positive_Form_Opt under some name. Options.Register ( Option => Trace_Counters_Opt'access, Name => Options.Trace_Item ("counters"), Groups => (Options.Groups.Loops, Options.Groups.Trace)); Options.Register ( Option => Proc_Opt'access, Name => "loop", Group => Options.Groups.Analysis); Options.Register ( Option => Swap_Small_Negative_Step_Opt'access, Name => "sw_neg_step", Group => Options.Groups.Loops); Options.Register ( Option => Warn_Swap_Small_Negative_Step_Opt'access, Name => Options.Warn_Item ("sw_neg_step"), Groups => (Options.Groups.Warn, Options.Groups.Loops)); Options.Register ( Option => Max_Loop_Bound_Opt'Access, Name => "max_loop", Group => Options.Groups.Loops); end Bounds.Looping.Opt;
wookey-project/ewok-legacy
Ada
3,992
ads
-- -- Copyright 2018 The wookey project team <[email protected]> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- package soc.dma.interfaces with spark_mode => off is type t_dma_interrupts is (FIFO_ERROR, DIRECT_MODE_ERROR, TRANSFER_ERROR, HALF_COMPLETE, TRANSFER_COMPLETE); type t_config_mask is record handlers : boolean; buffer_in : boolean; buffer_out : boolean; buffer_size : boolean; mode : boolean; priority : boolean; direction : boolean; end record; for t_config_mask use record handlers at 0 range 0 .. 0; buffer_in at 0 range 1 .. 1; buffer_out at 0 range 2 .. 2; buffer_size at 0 range 3 .. 3; mode at 0 range 4 .. 4; priority at 0 range 5 .. 5; direction at 0 range 6 .. 6; end record; type t_mode is (DIRECT_MODE, FIFO_MODE, CIRCULAR_MODE); type t_transfer_dir is (PERIPHERAL_TO_MEMORY, MEMORY_TO_PERIPHERAL, MEMORY_TO_MEMORY); type t_priority_level is (LOW, MEDIUM, HIGH, VERY_HIGH); type t_data_size is (TRANSFER_BYTE, TRANSFER_HALF_WORD, TRANSFER_WORD); type t_burst_size is (SINGLE_TRANSFER, INCR_4_BEATS, INCR_8_BEATS, INCR_16_BEATS); type t_flow_controller is (DMA_FLOW_CONTROLLER, PERIPH_FLOW_CONTROLLER); type t_dma_config is record dma_id : soc.dma.t_dma_periph_index; stream : soc.dma.t_stream_index; channel : soc.dma.t_channel_index; bytes : unsigned_16; in_addr : system_address; in_priority : t_priority_level; in_handler : system_address; -- ISR out_addr : system_address; out_priority : t_priority_level; out_handler : system_address; -- ISR flow_controller : t_flow_controller; transfer_dir : t_transfer_dir; mode : t_mode; data_size : t_data_size; memory_inc : boolean; periph_inc : boolean; mem_burst_size : t_burst_size; periph_burst_size : t_burst_size; end record; procedure enable_stream (dma_id : in soc.dma.t_dma_periph_index; stream : in soc.dma.t_stream_index); procedure disable_stream (dma_id : in soc.dma.t_dma_periph_index; stream : in soc.dma.t_stream_index); procedure clear_interrupt (dma_id : in soc.dma.t_dma_periph_index; stream : in soc.dma.t_stream_index; interrupt : in t_dma_interrupts); procedure clear_all_interrupts (dma_id : in soc.dma.t_dma_periph_index; stream : in soc.dma.t_stream_index); function get_interrupt_status (dma_id : in soc.dma.t_dma_periph_index; stream : in soc.dma.t_stream_index) return t_dma_stream_int_status; procedure configure_stream (dma_id : in soc.dma.t_dma_periph_index; stream : in soc.dma.t_stream_index; user_config : in t_dma_config); procedure reconfigure_stream (dma_id : in soc.dma.t_dma_periph_index; stream : in soc.dma.t_stream_index; user_config : in t_dma_config; to_configure: in t_config_mask); procedure reset_stream (dma_id : in soc.dma.t_dma_periph_index; stream : in soc.dma.t_stream_index); end soc.dma.interfaces;
stcarrez/ada-awa
Ada
5,596
adb
----------------------------------------------------------------------- -- awa-votes-modules -- Module votes -- Copyright (C) 2013, 2016 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Log.Loggers; with Security.Permissions; with AWA.Modules.Beans; with AWA.Modules.Get; with AWA.Votes.Beans; with AWA.Permissions; with AWA.Services.Contexts; with AWA.Votes.Models; with ADO.SQL; with ADO.Sessions; with ADO.Sessions.Entities; package body AWA.Votes.Modules is use AWA.Services; use ADO.Sessions; Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("AWA.Votes.Module"); package Register is new AWA.Modules.Beans (Module => Vote_Module, Module_Access => Vote_Module_Access); -- ------------------------------ -- Initialize the votes module. -- ------------------------------ overriding procedure Initialize (Plugin : in out Vote_Module; App : in AWA.Modules.Application_Access; Props : in ASF.Applications.Config) is begin Log.Info ("Initializing the votes module"); -- Register here any bean class, servlet, filter. Register.Register (Plugin => Plugin, Name => "AWA.Votes.Beans.Votes_Bean", Handler => AWA.Votes.Beans.Create_Vote_Bean'Access); AWA.Modules.Module (Plugin).Initialize (App, Props); -- Add here the creation of manager instances. end Initialize; -- ------------------------------ -- Get the votes module. -- ------------------------------ function Get_Vote_Module return Vote_Module_Access is function Get is new AWA.Modules.Get (Vote_Module, Vote_Module_Access, NAME); begin return Get; end Get_Vote_Module; -- ------------------------------ -- Vote for the given element and return the total vote for that element. -- ------------------------------ procedure Vote_For (Model : in Vote_Module; Id : in ADO.Identifier; Entity_Type : in String; Permission : in String; Value : in Integer; Total : out Integer) is pragma Unreferenced (Model); Ctx : constant Contexts.Service_Context_Access := AWA.Services.Contexts.Current; User : constant ADO.Identifier := Ctx.Get_User_Identifier; DB : Master_Session := AWA.Services.Contexts.Get_Master_Session (Ctx); Kind : ADO.Entity_Type; Rating : AWA.Votes.Models.Rating_Ref; Vote : AWA.Votes.Models.Vote_Ref; Query : ADO.SQL.Query; Found : Boolean; Ident : constant String := Entity_Type & ADO.Identifier'Image (Id); begin -- Check that the user has the vote permission on the given object. AWA.Permissions.Check (Permission => Security.Permissions.Get_Permission_Index (Permission), Entity => Id); Log.Info ("User {0} votes for {1} rating {2}", ADO.Identifier'Image (User), Ident, Integer'Image (Value)); Ctx.Start; Kind := ADO.Sessions.Entities.Find_Entity_Type (DB, Entity_Type); -- Get the vote associated with the object for the user. Query.Set_Join ("INNER JOIN awa_rating r ON r.id = o.entity_id"); Query.Set_Filter ("r.for_entity_id = :id and r.for_entity_type = :type " & "and o.user_id = :user_id"); Query.Bind_Param ("id", Id); Query.Bind_Param ("type", Kind); Query.Bind_Param ("user_id", User); Vote.Find (DB, Query, Found); if not Found then Query.Clear; -- Get the rating associated with the object. Query.Set_Filter ("for_entity_id = :id and for_entity_type = :type"); Query.Bind_Param ("id", Id); Query.Bind_Param ("type", Kind); Rating.Find (DB, Query, Found); -- Create it if it does not exist. if not Found then Log.Info ("Creating rating for {0}", Ident); Rating.Set_For_Entity_Id (Id); Rating.Set_For_Entity_Type (Kind); Rating.Set_Rating (Value); Rating.Set_Vote_Count (1); else Rating.Set_Vote_Count (Rating.Get_Vote_Count + 1); Rating.Set_Rating (Value + Rating.Get_Rating); end if; Rating.Save (DB); Vote.Set_User_Id (User); Vote.Set_Entity (Rating); else Rating := AWA.Votes.Models.Rating_Ref (Vote.Get_Entity); Rating.Set_Rating (Rating.Get_Rating + Value - Vote.Get_Rating); Rating.Save (DB); end if; Vote.Set_Rating (Value); Vote.Save (DB); -- Return the total rating for the element. Total := Rating.Get_Rating; Ctx.Commit; end Vote_For; end AWA.Votes.Modules;
ashleygay/adaboy
Ada
2,293
adb
with Last_Chance_Handler; pragma Unreferenced (Last_Chance_Handler); with STM32.Board; use STM32.Board; with STM32.DMA2D_Bitmap; use STM32.DMA2D_Bitmap; with HAL; use HAL; with HAL.Bitmap; use HAL.Bitmap; -- We import the gameboy with gameboy_hpp; with Interfaces.C; use Interfaces.C; procedure Main is GB : aliased gameboy_hpp.Class_Gameboy.Gameboy := gameboy_hpp.Class_Gameboy.New_Gameboy; type uchar_array is array (size_t range <>) of aliased unsigned_char; pixels_array : uchar_array (0 .. 23039); ptr : constant access unsigned_char := pixels_array (pixels_array'First)'Access; function Bitmap_Buffer return not null Any_Bitmap_Buffer is begin if Display.Hidden_Buffer (1).all not in DMA2D_Bitmap_Buffer then raise Program_Error with "We expect a DMA2D buffer here"; end if; return Display.Hidden_Buffer (1); end Bitmap_Buffer; X : Natural; Y : Natural; pix : unsigned_char := 0; pix_x : size_t := 0; pix_y : size_t := 0; Width : Natural; Height : Natural; begin Display.Initialize; Display.Initialize_Layer (1, HAL.Bitmap.ARGB_8888); Width := Display.Hidden_Buffer (1).Width; Height := Display.Hidden_Buffer (1).Height; loop Bitmap_Buffer.Set_Source (HAL.Bitmap.Dark_Green); Bitmap_Buffer.Fill; X := 0; Y := 0; pix_x := 0; pix_y := 0; Bitmap_Buffer.Set_Pixel ((Width / 2, Height / 2), HAL.Bitmap.Red); while X < 160 loop while Y < 144 loop pix := pixels_array (pix_y * 144 + pix_x); if pix = 0 then Bitmap_Buffer.Set_Pixel ((X, Y), HAL.Bitmap.White); elsif pix = 1 then Bitmap_Buffer.Set_Pixel ((X, Y), HAL.Bitmap.Light_Grey); elsif pix = 2 then Bitmap_Buffer.Set_Pixel ((X, Y), HAL.Bitmap.Dark_Grey); else Bitmap_Buffer.Set_Pixel ((X, Y), HAL.Bitmap.Black); end if; Y := Y + 1; pix_y := pix_y + 1; end loop; Y := 0; X := X + 1; pix_y := 0; pix_x := pix_x + 1; end loop; Display.Update_Layers; gameboy_hpp.Class_Gameboy.step (GB'Access, ptr); end loop; end Main;
faelys/ada-syslog
Ada
2,375
adb
------------------------------------------------------------------------------ -- 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 Syslog.Timestamps; package body Syslog.RFC_3164 is procedure Build_Message (Output : out String; Last : out Natural; Pri : in Priority; Message : in String; Hostname : in String := "-"; App_Name : in String := ""; Proc_ID : in String := "") is begin Last := Output'First - 1; declare Priority_Image : String := Priority'Image (Pri); begin pragma Assert (Priority_Image (Priority_Image'First) = ' '); Priority_Image (Priority_Image'First) := '<'; Append (Output, Last, Priority_Image); end; Append (Output, Last, ">"); Append (Output, Last, Timestamps.RFC_3164); Append (Output, Last, " "); Append (Output, Last, Check_Nil (Hostname)); Append (Output, Last, " "); if App_Name /= "" then Append (Output, Last, App_Name); if Proc_ID /= "" then Append (Output, Last, "["); Append (Output, Last, Proc_ID); Append (Output, Last, "]"); end if; Append (Output, Last, ": "); end if; Append (Output, Last, Message); end Build_Message; end Syslog.RFC_3164;
jwarwick/aoc_2020
Ada
1,103
adb
with AUnit.Assertions; use AUnit.Assertions; package body Day.Test is procedure Test_Part1 (T : in out AUnit.Test_Cases.Test_Case'Class) is pragma Unreferenced (T); p : constant Program := load_file("test1.txt"); t1 : constant Long_Integer := sum_memory(p); begin Assert(t1 = 165, "Wrong number, expected 165, got" & Long_Integer'IMAGE(t1)); end Test_Part1; procedure Test_Part2 (T : in out AUnit.Test_Cases.Test_Case'Class) is pragma Unreferenced (T); p : constant Program := load_file("test2.txt"); t1 : constant Long_Integer := sum_memory_v2(p); begin Assert(t1 = 208, "Wrong number, expected 208, got" & Long_Integer'IMAGE(t1)); end Test_Part2; function Name (T : Test) return AUnit.Message_String is pragma Unreferenced (T); begin return AUnit.Format ("Test Day package"); end Name; procedure Register_Tests (T : in out Test) is use AUnit.Test_Cases.Registration; begin Register_Routine (T, Test_Part1'Access, "Test Part 1"); Register_Routine (T, Test_Part2'Access, "Test Part 2"); end Register_Tests; end Day.Test;
stcarrez/ada-awa
Ada
1,960
ads
----------------------------------------------------------------------- -- awa-tests-helpers - Helpers for AWA unit tests -- Copyright (C) 2011, 2017, 2020 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with ADO; with ASF.Responses.Mockup; with Ada.Strings.Unbounded; package AWA.Tests.Helpers is -- Extract from the Location header the part that is after the given base string. -- If the Location header does not start with the base string, returns the empty -- string. function Extract_Redirect (Reply : in ASF.Responses.Mockup.Response'Class; Base : in String) return String; function Extract_Redirect (Reply : in ASF.Responses.Mockup.Response'Class; Base : in String) return Ada.Strings.Unbounded.Unbounded_String; -- Extract from the response content a link with a given title. function Extract_Link (Content : in String; Title : in String) return String; -- Extract from the response content an HTML identifier that was generated -- with the given prefix. The format is assumed to be <prefix>-<number>. function Extract_Identifier (Content : in String; Prefix : in String) return ADO.Identifier; end AWA.Tests.Helpers;
reznikmm/matreshka
Ada
3,624
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ with AMF.Elements.Generic_Hash; function AMF.UML.Read_Self_Actions.Hash is new AMF.Elements.Generic_Hash (UML_Read_Self_Action, UML_Read_Self_Action_Access);
tum-ei-rcs/StratoX
Ada
11,770
adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . B B . E X E C U T I O N _ T I M E -- -- -- -- B o d y -- -- -- -- Copyright (C) 2011-2016, AdaCore -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNARL is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- ------------------------------------------------------------------------------ with System.BB.Parameters; with System.BB.Board_Support; with System.BB.Threads.Queues; with System.BB.Protection; with System.Multiprocessors; with System.Multiprocessors.Fair_Locks; with System.Multiprocessors.Spin_Locks; with System.OS_Interface; ------------------------------ -- System.BB.Execution_Time -- ------------------------------ package body System.BB.Execution_Time is use type System.BB.Time.Time; use System.BB.Interrupts; use System.BB.Threads; use System.Multiprocessors; use System.Multiprocessors.Fair_Locks; use System.Multiprocessors.Spin_Locks; Interrupts_Execution_Time : array (Interrupt_ID) of System.BB.Time.Time := (others => System.BB.Time.Time'First); -- Time counter for each interrupt Interrupt_Exec_Time_Lock : Fair_Lock := (Spinning => (others => False), Lock => (Flag => Unlocked)); -- Protect access to interrupt time counters on multiprocessor systems CPU_Clock : array (CPU) of System.BB.Time.Time; -- Date of the last Interrupt procedure Scheduling_Event; -- Assign elapsed time to the executing Task/Interrupt and reset CPU clock. -- This must be called at the end of an execution period: -- -- When the run-time switches from a task to another task -- a task to an interrupt -- an interrupt to a task -- an interrupt to another interrupt function Elapsed_Time return System.BB.Time.Time; -- Function returning the time elapsed since the last scheduling event, -- i.e. the execution time of the currently executing entity (thread or -- interrupt) that has not yet been added to the global counters. function Read_Execution_Time_Atomic (Th : System.BB.Threads.Thread_Id) return System.BB.Time.Time; -- Read the execution time of thread Th. The result is a coherent value: -- if the execution time has changed from A to B (while being read by this -- function), the result will be between A and B. The error is less -- than 2**32 and less than the increment. function To_Time (High, Low : Time.Word) return Time.Time; -- Low level routine to convert a composite execution time to type Time function To_Composite_Execution_Time (T : Time.Time) return Time.Composite_Execution_Time; -- Low level routine to convert a time to a composite execution time ------------------ -- Elapsed_Time -- ------------------ function Elapsed_Time return System.BB.Time.Time is CPU_Id : constant CPU := System.OS_Interface.Current_CPU; Now : constant BB.Time.Time := System.BB.Time.Clock; pragma Assert (Now >= CPU_Clock (CPU_Id)); begin return Now - CPU_Clock (CPU_Id); end Elapsed_Time; ---------------------------- -- Global_Interrupt_Clock -- ---------------------------- function Global_Interrupt_Clock return System.BB.Time.Time is Sum : System.BB.Time.Time := System.BB.Time.Time'First; begin -- Protect shared access on multiprocessor systems if System.BB.Parameters.Multiprocessor then Lock (Interrupt_Exec_Time_Lock); end if; for Interrupt in Interrupt_ID loop Sum := Sum + Interrupts_Execution_Time (Interrupt); end loop; -- If any interrupt is executing, we need to add the elapsed time -- between the last scheduling and now. if System.BB.Interrupts.Current_Interrupt /= No_Interrupt then Sum := Sum + Elapsed_Time; end if; if System.BB.Parameters.Multiprocessor then Unlock (Interrupt_Exec_Time_Lock); end if; return Sum; end Global_Interrupt_Clock; --------------------- -- Interrupt_Clock -- --------------------- function Interrupt_Clock (Interrupt : Interrupt_ID) return System.BB.Time.Time is Value : System.BB.Time.Time; begin -- Protect against interruption the addition between Execution_Time -- and Elapsed_Time. System.BB.Protection.Enter_Kernel; -- Protect shared access on multiprocessor systems if System.BB.Parameters.Multiprocessor then Lock (Interrupt_Exec_Time_Lock); end if; Value := Interrupts_Execution_Time (Interrupt); -- If the interrupt is executing (i.e., if we are requesting the -- interrupt clock from the interrupt handler), we need to add the -- elapsed time between the last scheduling and now. if System.BB.Interrupts.Current_Interrupt = Interrupt then Value := Value + Elapsed_Time; end if; if System.BB.Parameters.Multiprocessor then Unlock (Interrupt_Exec_Time_Lock); end if; System.BB.Protection.Leave_Kernel; return Value; end Interrupt_Clock; -------------------------------- -- Read_Execution_Time_Atomic -- -------------------------------- function Read_Execution_Time_Atomic (Th : System.BB.Threads.Thread_Id) return System.BB.Time.Time is use Time; H1 : Word; L : Word; H2 : Word; begin -- Read parts in that order H1 := Th.Execution_Time.High; L := Th.Execution_Time.Low; H2 := Th.Execution_Time.High; -- If value has changed while being read, keep the latest high part, -- but use 0 for the low part. So the result will be greater than -- the old value and less than the new value. if H1 /= H2 then L := 0; end if; return Time.Time (H2) * 2 ** 32 + Time.Time (L); end Read_Execution_Time_Atomic; ---------------------- -- Scheduling_Event -- ---------------------- procedure Scheduling_Event is Now : constant System.BB.Time.Time := System.BB.Time.Clock; CPU_Id : constant CPU := System.OS_Interface.Current_CPU; Last_CPU_Clock : constant System.BB.Time.Time := CPU_Clock (CPU_Id); Elapsed_Time : System.BB.Time.Time; begin pragma Assert (Now >= Last_CPU_Clock); Elapsed_Time := Now - Last_CPU_Clock; -- Reset the clock CPU_Clock (CPU_Id) := Now; -- Case of CPU currently executing an interrupt if Current_Interrupt /= No_Interrupt then -- Protect shared access on multiprocessor systems if System.BB.Parameters.Multiprocessor then Lock (Interrupt_Exec_Time_Lock); end if; Interrupts_Execution_Time (Current_Interrupt) := Interrupts_Execution_Time (Current_Interrupt) + Elapsed_Time; if System.BB.Parameters.Multiprocessor then Unlock (Interrupt_Exec_Time_Lock); end if; -- This CPU is currently executing a task else declare T : Time.Time; begin T := To_Time (Thread_Self.Execution_Time.High, Thread_Self.Execution_Time.Low); T := T + Elapsed_Time; Thread_Self.Execution_Time := To_Composite_Execution_Time (T); end; end if; end Scheduling_Event; ------------------ -- Thread_Clock -- ------------------ function Thread_Clock (Th : System.BB.Threads.Thread_Id) return System.BB.Time.Time is Res : System.BB.Time.Time; Sec : System.BB.Time.Time; -- Second read of execution time ET : System.BB.Time.Time; -- Elapsed time begin pragma Assert (Th /= Null_Thread_Id); Res := Read_Execution_Time_Atomic (Th); -- If the thread Th is running, we need to add the elapsed time between -- the last scheduling and now. The thread Th is running if it is the -- current one and no interrupt is executed if Th = Thread_Self and then System.BB.Interrupts.Current_Interrupt = No_Interrupt then ET := Elapsed_Time; Sec := Read_Execution_Time_Atomic (Th); if Res /= Sec then -- The whole set of values (Res, ET and Sec) isn't coherent, as -- the execution time has been updated (might happen in case of -- interrupt). Unfortunately, the error in Sec might be as large -- as ET. So lets read again. The error will be small, as the time -- spent between this third read and the second one is small. Res := Read_Execution_Time_Atomic (Th); else Res := Res + ET; end if; end if; return Res; end Thread_Clock; --------------------------------- -- To_Composite_Execution_Time -- --------------------------------- function To_Composite_Execution_Time (T : Time.Time) return Time.Composite_Execution_Time is begin return (High => Time.Word (T / 2 ** 32), Low => Time.Word (T mod 2 ** 32)); end To_Composite_Execution_Time; ------------- -- To_Time -- ------------- function To_Time (High, Low : Time.Word) return Time.Time is begin return Time.Time (High) * 2 ** 32 + Time.Time (Low); end To_Time; begin -- Set the hooks to enable computation System.BB.Time.Scheduling_Event_Hook := Scheduling_Event'Access; -- Initialize CPU_Clock declare Now : constant BB.Time.Time := System.BB.Time.Epoch; -- Calling Clock here is tricky because we may be doing so before timer -- initialization. Hence, we simply get the startup time. begin CPU_Clock := (others => Now); end; end System.BB.Execution_Time;
reznikmm/slimp
Ada
2,616
adb
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Slim.Message_Visiters; package body Slim.Messages.bdac is List : constant Field_Description_Array := ((Uint_8_Field, 1), -- Kind (Custom_Field, 1)); -- Data ---------- -- Read -- ---------- overriding function Read (Data : not null access League.Stream_Element_Vectors.Stream_Element_Vector) return Bdac_Message is begin return Result : Bdac_Message do Read_Fields (Result, List, Data.all); end return; end Read; ----------------------- -- Read_Custom_Field -- ----------------------- overriding procedure Read_Custom_Field (Self : in out Bdac_Message; Index : Positive; Input : in out Ada.Streams.Stream_Element_Offset; Data : League.Stream_Element_Vectors.Stream_Element_Vector) is use type Ada.Streams.Stream_Element_Offset; Content : constant Ada.Streams.Stream_Element_Array (1 .. Data.Length) := Data.To_Stream_Element_Array; begin pragma Assert (Index = 1); Self.Data.Clear; Self.Data.Append (Content (Input .. Content'Last)); Input := Content'Last + 1; end Read_Custom_Field; ---------------- -- Initialize -- ---------------- not overriding procedure Initialize (Self : in out Bdac_Message; Kind : Natural; Value : Ada.Streams.Stream_Element_Array) is begin Self.Data.Clear; Self.Data.Append (Value); Self.Data_8 := (1 => Interfaces.Unsigned_8 (Kind)); end Initialize; ----------- -- Visit -- ----------- overriding procedure Visit (Self : not null access Bdac_Message; Visiter : in out Slim.Message_Visiters.Visiter'Class) is begin Visiter.bdac (Self); end Visit; ----------- -- Write -- ----------- overriding procedure Write (Self : Bdac_Message; Tag : out Message_Tag; Data : out League.Stream_Element_Vectors.Stream_Element_Vector) is begin Tag := "bdac"; Write_Fields (Self, List, Data); end Write; ------------------------ -- Write_Custom_Field -- ------------------------ overriding procedure Write_Custom_Field (Self : Bdac_Message; Index : Positive; Data : in out League.Stream_Element_Vectors.Stream_Element_Vector) is begin pragma Assert (Index = 1); Data.Append (Self.Data); end Write_Custom_Field; end Slim.Messages.bdac;
burratoo/Acton
Ada
18,415
ads
------------------------------------------------------------------------------------------ -- -- -- OAK COMPONENTS -- -- -- -- OAK.AGENT.OAK_AGENT -- -- -- -- Copyright (C) 2013-2021, Patrick Bernardi -- -- -- ------------------------------------------------------------------------------------------ -- This package defines Oak's primative agent Ð Oak Agent Ð from which all -- agents are derived. An Oak Agent is one of Oak's three main data -- structures: the other two being Oak Timers and Oak Messages. Every agent in -- Oak possess an Oak Agent record, in fact except for the sleep agent, no -- agent can be just an Oak Agent: it must use one of the derivative agents. -- The record itself provides the neccessary components to schedule and -- execute Agent in Oak. with Oak.Agent.Storage; with Oak.Oak_Time; with Oak.Memory.Call_Stack; use Oak.Memory.Call_Stack; with Oak.Message; use Oak.Message; with Oak.States; use Oak.States; with System; use System; with System.Storage_Elements; use System.Storage_Elements; package Oak.Agent.Oak_Agent with Preelaborate is subtype Agent_Name_Length is Integer range 0 .. Project_Support_Package.Max_Task_Name_Length; -- A type used to represent the length of the the Agent Name string. A new -- type is used for this based on the maximum length of the name to allow -- the compiler to pick an appropriately size variable. subtype Agent_Name is String (1 .. Agent_Name_Length'Last); -- The name of the Agent. Uses a fixed string to make storage easier. type Charge_Occurrence is (Only_While_Running, Same_Priority, All_Priorities, At_Or_Below_Priority); -- When to charge an Agent which is on a charge list. Priority is -- referenced to the Agent's priority when compared to the current priority -- of the Oak Instance. So for Below_Priority, an Agent will be charged -- when the Oak Instance priority is below the Agent's own priority. type Wake_Destination is (Run_Queue, Remove); -- A type to identify the destination of a woken task. Normally an agent is -- placed back on its Scheduler Agent's run queue when it wakes. The -- exception lies when the agent is waiting on a kernel release (used by -- sporadic tasks), in which case the agent is removed from the Scheduler -- Agent. -- type Memory_Region; -- type Memory_Region_Link is access all Memory_Region; -- type Memory_Permission is (Read_Only, Read_Write); -- -- type Memory_Region is record -- Location : Memory_Slice; -- Next : Memory_Region_Link; -- Previous : Memory_Region_Link; -- end record; ------------------------ -- Setup Subprograms -- ------------------------ procedure Setup_Storage with Pre => not Is_Storage_Ready, Post => Is_Storage_Ready; -- Setup the storage associated with the Oak_Agents. Must be called before -- accessing any of the functions here, and only be called once. Sets up -- the sleep agent as part of the setup routine. function Is_Storage_Ready return Boolean with Ghost; ------------------------ -- Access Subprograms -- ------------------------ function Absolute_Deadline (For_Agent : in Oak_Agent_Id) return Oak_Time.Time; -- The absolute deadline of the agent. function Agent_Message_Address (For_Agent : in Oak_Agent_Id) return Address; -- The address of the Oak Message that the agent sent to Oak. procedure Charge_Execution_Time (To_Agent : in Oak_Agent_Id; Exec_Time : in Oak_Time.Time_Span) with Pre => Is_Storage_Ready; -- Charges the specified execution time to the agent. procedure Charge_Execution_Time_To_List (List : in Charge_List_Head; Exec_Time : in Oak_Time.Time_Span; Current_Agent : in Oak_Agent_Id; Current_Priority : in Any_Priority) with Inline; -- Charges the provided execution time to agents on the the specified -- execution time charge list. Whether an agent is charged is dependent on -- the priority provided by the procedure and the When_To_Charge attribute -- of the agent. procedure Copy_Oak_Message (Destination, Source : in Address) with Inline; -- Optimised procedure to copy oak messages arround function Current_Execution_Time (For_Agent : in Oak_Agent_Id) return Oak_Time.Time_Span with Inline; -- Return the execution time for the current cycle. procedure Delete_Agent (Agent : Oak_Agent_Id); -- Deletes the agent specified and deallocates its storage. function Earliest_Expiring_Budget (Charge_List : in Charge_List_Head; Current_Priority : in Any_Priority) return Oak_Agent_Id with Inline; -- Returns the id of the agent that has the eariliest expiring budget. -- If the list is empty it will return No_Agent. procedure Increment_Execution_Cycle_Count (For_Agent : in Oak_Agent_Id; By : in Natural := 1) with Inline; -- Increments the agent's execution cycle count by the specified amount. function Is_Agent_Interrupted (Agent : in Oak_Agent_Id) return Boolean; -- Returns whether or not the agent had been interrupted. function Max_Execution_Time (For_Agent : in Oak_Agent_Id) return Oak_Time.Time_Span with Inline; -- Return the maximum execution time for any cycle. function Name (Agent : in Oak_Agent_Id) return Agent_Name with Pre => Has_Agent (Agent); -- Fetches the name of the Agent. procedure New_Agent (Agent : in Oak_Agent_Id; Name : in String; Call_Stack_Address : in Address; Call_Stack_Size : in Storage_Count; Run_Loop : in Address; Run_Loop_Parameter : in Address; Normal_Priority : in Any_Priority; Initial_State : in Agent_State; Scheduler_Agent : in Scheduler_Id_With_No := No_Agent; Wake_Time : in Oak_Time.Time := Oak_Time.Time_Last; When_To_Charge_Agent : in Charge_Occurrence := All_Priorities) with Pre => Is_Storage_Ready; -- Allocates a new Oak Agent with the given parameters and allocates a call -- stack for the Agent. This procedure is only called by the New_Agent -- procedure of derivative Agents since this procedure makes no check to -- see if the underlying storage slot assigned to the Agent Id is free. function Next_Agent (Agent : in Oak_Agent_Id) return Oak_Agent_Id with Inline; -- Returns the agent pointed to by the Agent's Next_Agent link. function Next_Charge_Agent (Agent : in Oak_Agent_Id) return Oak_Agent_Id with Inline; -- Returns the agent pointed to by the Agent's Next_Charge_Agent link. function Normal_Priority (Agent : in Oak_Agent_Id) return System.Any_Priority with Pre => Has_Agent (Agent), Inline; -- Retrieves the priority assigned to the agent. function Remaining_Budget (Agent : in Oak_Agent_Id) return Oak_Time.Time_Span with Pre => Has_Agent (Agent); -- Retrieves the amount of execution budget remaining for the agent procedure Replenish_Execution_Budget (For_Agent : in Oak_Agent_Id; By_Amount : in Oak_Time.Time_Span) with Pre => Has_Agent (For_Agent), Inline; -- Add the time span given to the agent's execution budget. function Secondary_Stack_Limit (Agent : in Oak_Agent_Id) return Address; function Secondary_Stack_Pointer (Agent : in Oak_Agent_Id) return Address; function Scheduler_Agent_For_Agent (Agent : in Oak_Agent_Id) return Scheduler_Id_With_No with Pre => Has_Agent (Agent), Inline; -- Fetches the Scheduler Agent responsible for the Agent. procedure Set_Agent_Interrupted (For_Agent : in Oak_Agent_Id; Value : in Boolean := True) with Inline; -- Sets whether the agent was interrupted. procedure Set_Agent_Message_Address (For_Agent : in Oak_Agent_Id; Message_Address : in Address) with Inline; -- Sets the address of the Agent's Oak Message location. procedure Set_Absolute_Deadline (For_Agent : in Oak_Agent_Id; Deadline : in Oak_Time.Time) with Pre => Has_Agent (For_Agent), Inline; -- Set the absolute deadline for the task. procedure Set_Current_Execution_Time (For_Agent : in Oak_Agent_Id; To : in Oak_Time.Time_Span) with Inline; -- Sets the agent's current execution time. procedure Set_Oak_Message (For_Agent : in Oak_Agent_Id; Message : in Oak_Message) with Inline; -- Copies the given message into the agent's message store. procedure Set_Max_Execution_Time (For_Agent : in Oak_Agent_Id; To : in Oak_Time.Time_Span) with Inline; -- Sets the agent's maximum execution time. procedure Set_Next_Agent (For_Agent : in Oak_Agent_Id; Next_Agent : in Oak_Agent_Id) with Inline; -- Set the Next_Agent link for the Agent. procedure Set_Next_Charge_Agent (For_Agent : in Oak_Agent_Id; Next_Agent : in Oak_Agent_Id) with Inline; -- Set the Next_Charge_Agent link for the Agent. procedure Set_Remaining_Budget (For_Agent : in Oak_Agent_Id; To_Amount : in Oak_Time.Time_Span) with Pre => Has_Agent (For_Agent), Inline; -- Set the amount of execution budget remaining for the agent. procedure Set_Secondary_Stack_Pointer (For_Agent : in Oak_Agent_Id; Pointer : in Address) with Inline; -- Set's the agent's secondary stack pointer. procedure Set_Scheduler_Agent (For_Agent : in Oak_Agent_Id; Scheduler : in Scheduler_Id_With_No) with Pre => Has_Agent (For_Agent), Inline; -- Set's the Scheduler Agent responsible for scheduling the agent. procedure Set_Stack_Pointer (For_Agent : in Oak_Agent_Id; Stack_Pointer : in System.Address) with Inline_Always; -- Sets the call stack pointer for the agent. Note that this procedure -- should always be inlined since it is called from within the core -- interrupt routines. procedure Set_State (For_Agent : in Oak_Agent_Id; State : in Agent_State) with Pre => Has_Agent (For_Agent), Inline; -- Set the state of the agent. procedure Set_Wake_Time (For_Agent : in Oak_Agent_Id; Wake_Time : in Oak_Time.Time) with Pre => Has_Agent (For_Agent), Inline; -- Set the wake time of the agent. function Stack (Agent : in Oak_Agent_Id) return Call_Stack_Handler; -- Get the call stack handler for the agent. function Stack_Pointer (Agent : in Oak_Agent_Id) return System.Address with Pre => Has_Agent (Agent); -- Fetches the stack pointer associated with the Agent. Note that this -- procedure should always be inlined should always be inlined since it is -- called from within the core interrupt routines. function State (Agent : in Oak_Agent_Id) return Agent_State with Pre => Has_Agent (Agent); -- Fetches the state of the Agent. function Wake_Time (Agent : in Oak_Agent_Id) return Oak_Time.Time with Pre => Has_Agent (Agent), Inline; -- Fetches the time that the Agent will wake. function When_To_Charge (Agent : in Oak_Agent_Id) return Charge_Occurrence; -- Returns when the agent is to be charged when it is on a charge list. --------------------- -- Ghost Functions -- --------------------- function Has_Agent (Agent : Oak_Agent_Id) return Boolean with Ghost; -- Check whether the Agent existing in the store. private -------------------- -- Private Types -- -------------------- type Previous_Cycle is mod Max_Cycle_Lengths_To_Keep; type Time_Set is array (Previous_Cycle) of Oak_Time.Time_Span; type Oak_Agent_Record is record Name : Agent_Name; -- The name of the Agent. Allows users and debugger to query the name of -- the task to figure out who it is. Name_Length : Agent_Name_Length; -- Specifies the actual length of the name. Required since Task_Name is -- fixed string which may be (much) longer than the name actually is. -- Allows for a smaller string to be returned without the blank space at -- the end or dealing with the hell that end of string tokens are. Call_Stack : Call_Stack_Handler; -- The agent's call stack. Next_Agent : Oak_Agent_Id; -- Used to allow agents to be placed on arbitary linked-lists. In Oak -- these are used for entry queues and activation lists (noting that an -- agent can only be on one list at a time). Next_Charge_Agent : Oak_Agent_Id; -- Used to link a charge list together. State : Agent_State; -- The state of the agent. Scheduler_Agent : Scheduler_Id_With_No; -- The Scheduler Agent responsible for scheduling the agent. Normal_Priority : Any_Priority; -- The priority of the agent under normal conditions. Wake_Time : Oak_Time.Time; -- The time that the agent is eligable to move from a sleeping state -- to a runnable state. Absolute_Deadline : Oak_Time.Time; -- The time when the agent must finish or is expected to finish running. Total_Execution_Time : Oak_Time.Time_Span; -- The total time that the agent has spent executing on the processor. Max_Execution_Time : Oak_Time.Time_Span; -- The maximum exectuion time that the agent has been executing a cycle. -- This cycle is defined by the agent. Current_Execution_Time : Oak_Time.Time_Span; -- The current execution time of current cycle of the agent. -- Updated from the last switch to kernel. Needs to be better -- implemented. Remaining_Budget : Oak_Time.Time_Span; -- The allowed execution time remaining for the agent's current budget. Execution_Cycles : Natural; -- The number of cycle that the agent has been through. What constitutes -- a cycle is agent dependent. -- ??? Change to a mod type? Agent_Message_Address : Address; -- Address of the agent's Oak_Message that is used when it requested -- something from Oak. When_To_Charge : Charge_Occurrence; -- Defines the conditions that an agent who is part of a charge list is -- charged for a member of the charge list executing on the processor. Agent_Interrupted : Boolean; -- Flags whether the agent has been interrupted or not. Indicates -- whether a full register restor is needed when the context is switched -- back to the task. -- Extended timing attributes Last_Cycle : Previous_Cycle; Cycle_Execution_Times : Time_Set; end record; package Oak_Agent_Pool is new Oak.Agent.Storage (Agent_Record_Type => Oak_Agent_Record, Agent_Id_Type => Oak_Agent_Id); ---------------------- -- Access functions -- ---------------------- use Oak_Agent_Pool; function Absolute_Deadline (For_Agent : in Oak_Agent_Id) return Oak_Time.Time is (Agent_Pool (For_Agent).Absolute_Deadline); function Agent_Message_Address (For_Agent : in Oak_Agent_Id) return Address is (Agent_Pool (For_Agent).Agent_Message_Address); function Current_Execution_Time (For_Agent : in Oak_Agent_Id) return Oak_Time.Time_Span is (Agent_Pool (For_Agent).Current_Execution_Time); function Has_Agent (Agent : Oak_Agent_Id) return Boolean is (Oak_Agent_Pool.Has_Agent (Agent)); function Is_Agent_Interrupted (Agent : in Oak_Agent_Id) return Boolean is (Agent_Pool (Agent).Agent_Interrupted); function Is_Storage_Ready return Boolean is (Oak_Agent_Pool.Is_Storage_Ready); function Max_Execution_Time (For_Agent : in Oak_Agent_Id) return Oak_Time.Time_Span is (Agent_Pool (For_Agent).Max_Execution_Time); function Name (Agent : in Oak_Agent_Id) return Agent_Name is (Agent_Pool (Agent).Name (Agent_Name_Length'First .. Agent_Pool (Agent).Name_Length)); function Next_Agent (Agent : in Oak_Agent_Id) return Oak_Agent_Id is (Agent_Pool (Agent).Next_Agent); function Next_Charge_Agent (Agent : in Oak_Agent_Id) return Oak_Agent_Id is (Agent_Pool (Agent).Next_Charge_Agent); function Normal_Priority (Agent : in Oak_Agent_Id) return System.Any_Priority is (Agent_Pool (Agent).Normal_Priority); function Remaining_Budget (Agent : in Oak_Agent_Id) return Oak_Time.Time_Span is (Agent_Pool (Agent).Remaining_Budget); function Secondary_Stack_Limit (Agent : in Oak_Agent_Id) return Address is (Agent_Pool (Agent).Call_Stack.Secondary_Stack_Limit); function Secondary_Stack_Pointer (Agent : in Oak_Agent_Id) return Address is (Agent_Pool (Agent).Call_Stack.Secondary_Stack_Pointer); function Scheduler_Agent_For_Agent (Agent : in Oak_Agent_Id) return Scheduler_Id_With_No is (Agent_Pool (Agent).Scheduler_Agent); function Stack (Agent : in Oak_Agent_Id) return Call_Stack_Handler is (Agent_Pool (Agent).Call_Stack); function Stack_Pointer (Agent : in Oak_Agent_Id) return System.Address is (Agent_Pool (Agent).Call_Stack.Pointer); function State (Agent : in Oak_Agent_Id) return Agent_State is (Agent_Pool (Agent).State); function Wake_Time (Agent : in Oak_Agent_Id) return Oak_Time.Time is (Agent_Pool (Agent).Wake_Time); function When_To_Charge (Agent : in Oak_Agent_Id) return Charge_Occurrence is (Agent_Pool (Agent).When_To_Charge); end Oak.Agent.Oak_Agent;
reznikmm/gela
Ada
732
ads
with League.String_Vectors; with League.Strings; with Gela.Contexts; package Gela.Context_Factories is pragma Preelaborate; function Create_Context (Parameters : League.String_Vectors.Universal_String_Vector; Include : League.Strings.Universal_String) return Gela.Contexts.Context_Access; -- Parameters list of parameters: -- -I<PATH> - include path -- --debug=PROP_LIST, where PROP_LIST list separated by comma of -- UP - print set of possible interpretations -- DOWN - print chosen interpretation -- ENV_IN - print input environment -- ENV_OUT - print output environment -- FULL_NAME - print symbol end Gela.Context_Factories;
rveenker/sdlada
Ada
6,457
ads
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2013-2020, Luke A. Guest -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- -- SDL.Video.Renderers -- -- Renderer. -------------------------------------------------------------------------------------------------------------------- with Ada.Finalization; with Interfaces.C.Strings; private with SDL.C_Pointers; with SDL.Video.Palettes; with SDL.Video.Pixel_Formats; with SDL.Video.Rectangles; with SDL.Video.Surfaces; with SDL.Video.Textures; with SDL.Video.Windows; package SDL.Video.Renderers is -- TODO: Finish this. Renderer_Error : exception; type Renderer_Flags is mod 2 ** 32 with Convention => C; Default_Renderer_Flags : constant Renderer_Flags := 16#0000_0000#; Software : constant Renderer_Flags := 16#0000_0001#; Accelerated : constant Renderer_Flags := 16#0000_0002#; Present_V_Sync : constant Renderer_Flags := 16#0000_0004#; Target_Texture : constant Renderer_Flags := 16#0000_0008#; type Renderer_Flip is (None, Horizontal, Vertical, Both); -- SDL_RendererInfo function Total_Drivers return Positive with Inline => True; -- SDL_GetRenderDriverInfo type Renderer is new Ada.Finalization.Limited_Controlled with private; Null_Renderer : constant Renderer; overriding procedure Finalize (Self : in out Renderer); function Get_Blend_Mode (Self : in Renderer) return Blend_Modes; procedure Set_Blend_Mode (Self : in out Renderer; Mode : in Blend_Modes); function Get_Draw_Colour (Self : in Renderer) return SDL.Video.Palettes.Colour; procedure Set_Draw_Colour (Self : in out Renderer; Colour : in SDL.Video.Palettes.Colour); -- SDL_GetRendererInfo procedure Clear (Self : in out Renderer); procedure Copy (Self : in out Renderer; Copy_From : in SDL.Video.Textures.Texture); procedure Copy (Self : in out Renderer; Copy_From : in SDL.Video.Textures.Texture; From : in SDL.Video.Rectangles.Rectangle; To : in SDL.Video.Rectangles.Rectangle); procedure Copy (Self : in out Renderer; Copy_From : in SDL.Video.Textures.Texture; To : in SDL.Video.Rectangles.Rectangle); procedure Copy (Self : in out Renderer; Copy_From : in SDL.Video.Textures.Texture; From : in SDL.Video.Rectangles.Rectangle; To : in SDL.Video.Rectangles.Rectangle; Angle : in Long_Float; Centre : in SDL.Video.Rectangles.Point; Flip : in Renderer_Flip); procedure Draw (Self : in out Renderer; Line : in SDL.Video.Rectangles.Line_Segment); procedure Draw (Self : in out Renderer; Lines : in SDL.Video.Rectangles.Line_Arrays); procedure Draw (Self : in out Renderer; Point : in SDL.Video.Rectangles.Point); procedure Draw (Self : in out Renderer; Points : in SDL.Video.Rectangles.Point_Arrays); procedure Draw (Self : in out Renderer; Rectangle : in SDL.Video.Rectangles.Rectangle); procedure Draw (Self : in out Renderer; Rectangles : in SDL.Video.Rectangles.Rectangle_Arrays); procedure Fill (Self : in out Renderer; Rectangle : in SDL.Video.Rectangles.Rectangle); procedure Fill (Self : in out Renderer; Rectangles : in SDL.Video.Rectangles.Rectangle_Arrays); procedure Get_Clip (Self : in Renderer; Rectangle : out SDL.Video.Rectangles.Rectangle); procedure Set_Clip (Self : in out Renderer; Rectangle : in SDL.Video.Rectangles.Rectangle); procedure Get_Logical_Size (Self : in Renderer; Size : out SDL.Sizes); procedure Set_Logical_Size (Self : in out Renderer; Size : in SDL.Sizes); procedure Get_Scale (Self : in Renderer; X, Y : out Float); procedure Set_Scale (Self : in out Renderer; X, Y : in Float); procedure Get_Viewport (Self : in Renderer; Rectangle : out SDL.Video.Rectangles.Rectangle); procedure Set_Viewport (Self : in out Renderer; Rectangle : in SDL.Video.Rectangles.Rectangle); procedure Present (Self : in Renderer); procedure Read_Pixels (Self : in Renderer; Rectangle : access SDL.Video.Rectangles.Rectangle; Format : in SDL.Video.Pixel_Formats.Pixel_Format_Names; Pixels : in Interfaces.C.Strings.chars_ptr; Pitch : in Interfaces.C.int); function Supports_Targets (Self : in Renderer) return Boolean; procedure Set_Target (Self : in out Renderer; Target : in SDL.Video.Textures.Texture); function Get_Renderer (Window : in SDL.Video.Windows.Window) return Renderer; procedure Get_Renderer (Self : in out Renderer; From_Window : in SDL.Video.Windows.Window); private type Renderer is new Ada.Finalization.Limited_Controlled with record Internal : SDL.C_Pointers.Renderer_Pointer := null; Owns : Boolean := True; -- Does this Window type own the Internal data? end record; function Get_Internal_Renderer (Self : in Renderer) return SDL.C_Pointers.Renderer_Pointer with Export => True, Convention => Ada; Null_Renderer : constant Renderer := (Ada.Finalization.Limited_Controlled with Internal => null, Owns => True); end SDL.Video.Renderers;
kevans91/synth
Ada
51,412
adb
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt with Ada.Characters.Latin_1; with Ada.Containers.Vectors; with Ada.Directories; with Ada.Exceptions; with GNAT.OS_Lib; with Parameters; with Unix; package body Replicant is package PM renames Parameters; package AC renames Ada.Containers; package AD renames Ada.Directories; package EX renames Ada.Exceptions; package OSL renames GNAT.OS_Lib; package LAT renames Ada.Characters.Latin_1; ------------------- -- mount_point -- ------------------- function location (mount_base : String; point : folder) return String is begin case point is when bin => return mount_base & root_bin; when sbin => return mount_base & root_sbin; when usr_bin => return mount_base & root_usr_bin; when usr_include => return mount_base & root_usr_include; when usr_lib => return mount_base & root_usr_lib; when usr_lib32 => return mount_base & root_usr_lib32; when usr_libdata => return mount_base & root_usr_libdata; when usr_libexec => return mount_base & root_usr_libexec; when usr_local => return mount_base & root_localbase; when usr_sbin => return mount_base & root_usr_sbin; when usr_share => return mount_base & root_usr_share; when usr_src => return mount_base & root_usr_src; when lib => return mount_base & root_lib; when dev => return mount_base & root_dev; when etc => return mount_base & root_etc; when etc_default => return mount_base & root_etc_default; when etc_mtree => return mount_base & root_etc_mtree; when etc_rcd => return mount_base & root_etc_rcd; when tmp => return mount_base & root_tmp; when var => return mount_base & root_var; when home => return mount_base & root_home; when proc => return mount_base & root_proc; when linux => return mount_base & root_linux; when boot => return mount_base & root_boot; when root => return mount_base & root_root; when xports => return mount_base & root_xports; when options => return mount_base & root_options; when libexec => return mount_base & root_libexec; when packages => return mount_base & root_packages; when distfiles => return mount_base & root_distfiles; when wrkdirs => return mount_base & root_wrkdirs; when ccache => return mount_base & root_ccache; end case; end location; -------------------- -- mount_target -- -------------------- function mount_target (point : folder) return String is begin case point is when xports => return JT.USS (PM.configuration.dir_portsdir); when options => return JT.USS (PM.configuration.dir_options); when packages => return JT.USS (PM.configuration.dir_packages); when distfiles => return JT.USS (PM.configuration.dir_distfiles); when ccache => return JT.USS (PM.configuration.dir_ccache); when others => return "ERROR"; end case; end mount_target; ------------------------ -- get_master_mount -- ------------------------ function get_master_mount return String is begin return JT.USS (PM.configuration.dir_buildbase) & "/" & reference_base; end get_master_mount; ----------------------- -- get_slave_mount -- ----------------------- function get_slave_mount (id : builders) return String is begin return JT.USS (PM.configuration.dir_buildbase) & "/" & slave_name (id); end get_slave_mount; ------------------ -- initialize -- ------------------ procedure initialize (testmode : Boolean; num_cores : cpu_range) is opsys : nullfs_flavor := dragonfly; mm : constant String := get_master_mount; maspas : constant String := "/master.passwd"; etcmp : constant String := "/etc" & maspas; command : constant String := "/usr/sbin/pwd_mkdb -p -d " & mm & " " & mm & maspas; begin smp_cores := num_cores; developer_mode := testmode; support_locks := testmode and then Unix.env_variable_defined ("LOCK"); if JT.equivalent (PM.configuration.operating_sys, "FreeBSD") then opsys := freebsd; end if; flavor := opsys; start_abnormal_logging; if AD.Exists (mm) then annihilate_directory_tree (mm); end if; AD.Create_Path (mm); create_base_passwd (mm); execute (command); create_base_group (mm); cache_port_variables (mm); create_mtree_exc_preinst (mm); create_mtree_exc_preconfig (mm); end initialize; ---------------- -- finalize -- ---------------- procedure finalize is mm : constant String := get_master_mount; begin if AD.Exists (mm) then annihilate_directory_tree (mm); end if; stop_abnormal_logging; end finalize; -------------------- -- mount_nullfs -- -------------------- procedure mount_nullfs (target, mount_point : String; mode : mount_mode := readonly) is cmd_freebsd : constant String := "/sbin/mount_nullfs"; cmd_dragonfly : constant String := "/sbin/mount_null"; command : JT.Text; begin if not AD.Exists (mount_point) then raise scenario_unexpected with "mount point " & mount_point & " does not exist"; end if; if not AD.Exists (target) then raise scenario_unexpected with "mount target " & target & " does not exist"; end if; case flavor is when freebsd => command := JT.SUS (cmd_freebsd); when dragonfly => command := JT.SUS (cmd_dragonfly); when unknown => raise scenario_unexpected with "Mounting on unknown operating system"; end case; case mode is when readonly => JT.SU.Append (command, " -o ro"); when readwrite => null; end case; JT.SU.Append (command, " " & target); JT.SU.Append (command, " " & mount_point); execute (JT.USS (command)); end mount_nullfs; ----------------------- -- mount_linprocfs -- ----------------------- procedure mount_linprocfs (mount_point : String) is cmd_freebsd : constant String := "/sbin/mount -t linprocfs linproc " & mount_point; begin -- DragonFly has lost it's Linux Emulation capability. -- FreeBSD has it for both amd64 and i386 -- We should return if FreeBSD arch is not amd64 or i386, but synth -- will not run on any other arches at the moment, so we don't have -- to check (and we don't have that information yet anyway) if flavor = freebsd then execute (cmd_freebsd); end if; end mount_linprocfs; --------------- -- unmount -- --------------- procedure unmount (device_or_node : String) is command : constant String := "/sbin/umount " & device_or_node; begin -- failure to unmount causes stderr squawks which messes up curses display -- Just log it and ignore for now (Add robustness later) execute (command); exception when others => null; -- silently fail end unmount; ----------------------- -- forge_directory -- ----------------------- procedure forge_directory (target : String) is begin AD.Create_Path (New_Directory => target); exception when failed : others => TIO.Put_Line (EX.Exception_Information (failed)); raise scenario_unexpected with "failed to create " & target & " directory"; end forge_directory; ------------------- -- mount_tmpfs -- ------------------- procedure mount_tmpfs (mount_point : String; max_size_M : Natural := 0) is cmd_freebsd : constant String := "/sbin/mount -t tmpfs"; cmd_dragonfly : constant String := "/sbin/mount_tmpfs"; command : JT.Text; begin case flavor is when freebsd => command := JT.SUS (cmd_freebsd); when dragonfly => command := JT.SUS (cmd_dragonfly); when unknown => raise scenario_unexpected with "Mounting on unknown operating system"; end case; if max_size_M > 0 then JT.SU.Append (command, " -o size=" & JT.trim (max_size_M'Img) & "M"); end if; JT.SU.Append (command, " tmpfs " & mount_point); execute (JT.USS (command)); end mount_tmpfs; --------------------- -- mount_devices -- --------------------- procedure mount_devices (path_to_dev : String) is command : constant String := "/sbin/mount -t devfs devfs " & path_to_dev; begin execute (command); end mount_devices; -------------------- -- mount_procfs -- -------------------- procedure mount_procfs (path_to_proc : String) is command : constant String := "/sbin/mount -t procfs proc " & path_to_proc; begin execute (command); end mount_procfs; ------------------ -- get_suffix -- ------------------ function slave_name (id : builders) return String is id_image : constant String := Integer (id)'Img; suffix : String := "SL00"; begin if id < 10 then suffix (4) := id_image (2); else suffix (3 .. 4) := id_image (2 .. 3); end if; return suffix; end slave_name; --------------------- -- folder_access -- --------------------- procedure folder_access (path : String; operation : folder_operation) is cmd_freebsd : constant String := "/bin/chflags"; cmd_dragonfly : constant String := "/usr/bin/chflags"; flag_lock : constant String := " schg "; flag_unlock : constant String := " noschg "; command : JT.Text; begin if not AD.Exists (path) then raise scenario_unexpected with "chflags: " & path & " path does not exist"; end if; case flavor is when freebsd => command := JT.SUS (cmd_freebsd); when dragonfly => command := JT.SUS (cmd_dragonfly); when unknown => raise scenario_unexpected with "Executing cflags on unknown operating system"; end case; case operation is when lock => JT.SU.Append (command, flag_lock & path); when unlock => JT.SU.Append (command, flag_unlock & path); end case; execute (JT.USS (command)); end folder_access; ---------------------- -- create_symlink -- ---------------------- procedure create_symlink (destination, symbolic_link : String) is command : constant String := "/bin/ln -s " & destination & " " & symbolic_link; begin execute (command); end create_symlink; --------------------------- -- populate_var_folder -- --------------------------- procedure populate_var_folder (path : String) is command : constant String := "/usr/sbin/mtree -p " & path & " -f /etc/mtree/BSD.var.dist -deqU"; begin silent_exec (command); end populate_var_folder; --------------- -- execute -- --------------- procedure execute (command : String) is Exit_Status : Integer; output : JT.Text := Unix.piped_command (command, Exit_Status); begin if abn_log_ready and then not JT.IsBlank (output) then TIO.Put_Line (abnormal_log, JT.USS (output)); end if; if Exit_Status /= 0 then raise scenario_unexpected with command & " => failed with code" & Exit_Status'Img; end if; end execute; ------------------- -- silent_exec -- ------------------- procedure silent_exec (command : String) is cmd_output : JT.Text; success : Boolean := Unix.piped_mute_command (command, cmd_output); begin if not success then if abn_log_ready and then not JT.IsBlank (cmd_output) then TIO.Put_Line (abnormal_log, "piped_mute_command failure:"); TIO.Put_Line (abnormal_log, JT.USS (cmd_output)); end if; raise scenario_unexpected with command & " => failed (exit code not 0)"; end if; end silent_exec; ------------------------------ -- internal_system_command -- ------------------------------ function internal_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 scenario_unexpected with "cmd: " & command & " (return code =" & status'Img & ")"; end if; return content; end internal_system_command; ------------------------- -- create_base_group -- ------------------------- procedure create_base_group (path_to_mm : String) is subtype sysgroup is String (1 .. 8); type groupset is array (1 .. 34) of sysgroup; users : constant groupset := ("wheel ", "daemon ", "kmem ", "sys ", "tty ", "operator", "mail ", "bin ", "news ", "man ", "games ", "staff ", "sshd ", "smmsp ", "mailnull", "guest ", "bind ", "proxy ", "authpf ", "_pflogd ", "unbound ", "ftp ", "video ", "hast ", "uucp ", "xten ", "dialer ", "network ", "_sdpd ", "_dhcp ", "www ", "vknet ", "nogroup ", "nobody "); group : TIO.File_Type; live_file : TIO.File_Type; keepit : Boolean; target : constant String := path_to_mm & "/group"; live_origin : constant String := "/etc/group"; begin TIO.Open (File => live_file, Mode => TIO.In_File, Name => live_origin); TIO.Create (File => group, Mode => TIO.Out_File, Name => target); while not TIO.End_Of_File (live_file) loop keepit := False; declare line : String := TIO.Get_Line (live_file); begin for grpindex in groupset'Range loop declare grpcolon : String := JT.trim (users (grpindex)) & ":"; begin if grpcolon'Length <= line'Length then if grpcolon = line (1 .. grpcolon'Last) then keepit := True; exit; end if; end if; end; end loop; if keepit then TIO.Put_Line (group, line); end if; end; end loop; TIO.Close (live_file); TIO.Close (group); end create_base_group; -------------------------- -- create_base_passwd -- -------------------------- procedure create_base_passwd (path_to_mm : String) is subtype syspasswd is String (1 .. 10); type passwdset is array (1 .. 28) of syspasswd; users : constant passwdset := ("root ", "toor ", "daemon ", "operator ", "bin ", "tty ", "kmem ", "mail ", "games ", "news ", "man ", "sshd ", "smmsp ", "mailnull ", "bind ", "unbound ", "proxy ", "_pflogd ", "_dhcp ", "uucp ", "xten ", "pop ", "auditdistd", "_sdpd ", "www ", "_ypldap ", "hast ", "nobody "); masterpwd : TIO.File_Type; live_file : TIO.File_Type; keepit : Boolean; target : constant String := path_to_mm & "/master.passwd"; live_origin : constant String := "/etc/master.passwd"; begin TIO.Open (File => live_file, Mode => TIO.In_File, Name => live_origin); TIO.Create (File => masterpwd, Mode => TIO.Out_File, Name => target); while not TIO.End_Of_File (live_file) loop keepit := False; declare line : String := TIO.Get_Line (live_file); begin for pwdindex in passwdset'Range loop declare pwdcolon : String := JT.trim (users (pwdindex)) & ":"; begin if pwdcolon'Length <= line'Length then if pwdcolon = line (1 .. pwdcolon'Last) then keepit := True; exit; end if; end if; end; end loop; if keepit then TIO.Put_Line (masterpwd, line); end if; end; end loop; TIO.Close (live_file); TIO.Close (masterpwd); end create_base_passwd; -------------------- -- create_group -- -------------------- procedure create_group (path_to_etc : String) is mm : constant String := get_master_mount; group : constant String := "/group"; begin AD.Copy_File (Source_Name => mm & group, Target_Name => path_to_etc & group); end create_group; --------------------- -- create_passwd -- --------------------- procedure create_passwd (path_to_etc : String) is mm : constant String := get_master_mount; maspwd : constant String := "/master.passwd"; passwd : constant String := "/passwd"; spwd : constant String := "/spwd.db"; pwd : constant String := "/pwd.db"; begin AD.Copy_File (Source_Name => mm & passwd, Target_Name => path_to_etc & passwd); AD.Copy_File (Source_Name => mm & maspwd, Target_Name => path_to_etc & maspwd); AD.Copy_File (Source_Name => mm & spwd, Target_Name => path_to_etc & spwd); AD.Copy_File (Source_Name => mm & pwd, Target_Name => path_to_etc & pwd); end create_passwd; ------------------------ -- copy_mtree_files -- ------------------------ procedure copy_mtree_files (path_to_mtree : String) is mtree : constant String := "/etc/mtree"; root : constant String := "/BSD.root.dist"; usr : constant String := "/BSD.usr.dist"; var : constant String := "/BSD.var.dist"; begin AD.Copy_File (Source_Name => mtree & root, Target_Name => path_to_mtree & root); AD.Copy_File (Source_Name => mtree & usr, Target_Name => path_to_mtree & usr); AD.Copy_File (Source_Name => mtree & var, Target_Name => path_to_mtree & var); end copy_mtree_files; ------------------------ -- create_make_conf -- ------------------------ procedure create_make_conf (path_to_etc : String) is makeconf : TIO.File_Type; profilemc : constant String := PM.synth_confdir & "/" & JT.USS (PM.configuration.profile) & "-make.conf"; varcache : constant String := get_master_mount & "/varcache.conf"; begin TIO.Create (File => makeconf, Mode => TIO.Out_File, Name => path_to_etc & "/make.conf"); TIO.Put_Line (makeconf, "USE_PACKAGE_DEPENDS=yes"); TIO.Put_Line (makeconf, "PACKAGE_BUILDING=yes"); TIO.Put_Line (makeconf, "BATCH=yes"); TIO.Put_Line (makeconf, "PKG_CREATE_VERBOSE=yes"); TIO.Put_Line (makeconf, "PORTSDIR=/xports"); TIO.Put_Line (makeconf, "DISTDIR=/distfiles"); TIO.Put_Line (makeconf, "WRKDIRPREFIX=/construction"); TIO.Put_Line (makeconf, "PORT_DBDIR=/options"); TIO.Put_Line (makeconf, "PACKAGES=/packages"); TIO.Put_Line (makeconf, "MAKE_JOBS_NUMBER_LIMIT=" & (JT.trim (PM.configuration.jobs_limit'Img))); if developer_mode then TIO.Put_Line (makeconf, "DEVELOPER=1"); end if; if AD.Exists (JT.USS (PM.configuration.dir_ccache)) then TIO.Put_Line (makeconf, "WITH_CCACHE_BUILD=yes"); TIO.Put_Line (makeconf, "CCACHE_DIR=/ccache"); end if; concatenate_makeconf (makeconf, profilemc); concatenate_makeconf (makeconf, varcache); TIO.Close (makeconf); end create_make_conf; ------------------------ -- copy_resolv_conf -- ------------------------ procedure copy_resolv_conf (path_to_etc : String) is original : constant String := "/etc/resolv.conf"; begin if not AD.Exists (original) then return; end if; AD.Copy_File (Source_Name => original, Target_Name => path_to_etc & "/resolv.conf"); end copy_resolv_conf; ----------------------- -- copy_rc_default -- ----------------------- procedure copy_rc_default (path_to_etc : String) is rc_default : constant String := "/defaults/rc.conf"; etc_rcconf : constant String := "/etc" & rc_default; begin if not AD.Exists (etc_rcconf) then return; end if; AD.Copy_File (Source_Name => etc_rcconf, Target_Name => path_to_etc & rc_default); end copy_rc_default; --------------------------- -- create_etc_services -- --------------------------- procedure create_etc_services (path_to_etc : String) is svcfile : TIO.File_Type; begin TIO.Create (File => svcfile, Mode => TIO.Out_File, Name => path_to_etc & "/services"); TIO.Put_Line (svcfile, "ftp 21/tcp" & LAT.LF & "ftp 21/udp" & LAT.LF & "ssh 22/tcp" & LAT.LF & "ssh 22/udp" & LAT.LF & "http 80/tcp" & LAT.LF & "http 80/udp" & LAT.LF & "https 443/tcp" & LAT.LF & "https 443/udp" & LAT.LF); TIO.Close (svcfile); end create_etc_services; ------------------------ -- create_etc_fstab -- ------------------------ procedure create_etc_fstab (path_to_etc : String) is fstab : TIO.File_Type; begin TIO.Create (File => fstab, Mode => TIO.Out_File, Name => path_to_etc & "/fstab"); TIO.Put_Line (fstab, "linproc /usr/compat/proc linprocfs rw 0 0"); TIO.Close (fstab); end create_etc_fstab; ------------------------ -- execute_ldconfig -- ------------------------ procedure execute_ldconfig (id : builders) is smount : constant String := get_slave_mount (id); command : constant String := chroot & smount & " /sbin/ldconfig -m /lib /usr/lib"; begin execute (command); end execute_ldconfig; ------------------------------- -- standalone_pkg8_install -- ------------------------------- function standalone_pkg8_install (id : builders) return Boolean is smount : constant String := get_slave_mount (id); taropts : constant String := "-C / */pkg-static"; command : constant String := chroot & smount & " /usr/bin/tar -xf /packages/Latest/pkg.txz " & taropts; begin silent_exec (command); return True; exception when others => return False; end standalone_pkg8_install; ------------------------ -- build_repository -- ------------------------ function build_repository (id : builders; sign_command : String := "") return Boolean is smount : constant String := get_slave_mount (id); command : constant String := chroot & smount & " " & host_localbase & "/sbin/pkg-static repo /packages"; sc_cmd : constant String := host_pkg8 & " repo " & smount & "/packages signing_command: "; key_loc : constant String := "/etc/repo.key"; use_key : constant Boolean := AD.Exists (smount & key_loc); use_cmd : constant Boolean := not JT.IsBlank (sign_command); begin if not standalone_pkg8_install (id) then TIO.Put_Line ("Failed to install pkg-static in builder" & id'Img); return False; end if; if use_key then silent_exec (command & " " & key_loc); elsif use_cmd then silent_exec (sc_cmd & sign_command); else silent_exec (command); end if; return True; exception when quepaso : others => TIO.Put_Line (EX.Exception_Message (quepaso)); return False; end build_repository; --------------------------------- -- annihilate_directory_tree -- --------------------------------- procedure annihilate_directory_tree (tree : String) is command : constant String := "/bin/rm -rf " & tree; begin silent_exec (command); exception when others => null; end annihilate_directory_tree; -------------------- -- launch_slave -- -------------------- procedure launch_slave (id : builders; opts : slave_options) is function clean_mount_point (point : folder) return String; slave_base : constant String := get_slave_mount (id); slave_work : constant String := slave_base & "_work"; slave_local : constant String := slave_base & "_localbase"; slave_linux : constant String := slave_base & "_linux"; dir_system : constant String := JT.USS (PM.configuration.dir_system); live_system : constant Boolean := (dir_system = "/"); function clean_mount_point (point : folder) return String is begin if live_system then return location ("", point); else return location (dir_system, point); end if; end clean_mount_point; begin forge_directory (slave_base); mount_tmpfs (slave_base); for mnt in folder'Range loop forge_directory (location (slave_base, mnt)); end loop; for mnt in subfolder'Range loop mount_nullfs (target => clean_mount_point (mnt), mount_point => location (slave_base, mnt)); end loop; folder_access (location (slave_base, home), lock); folder_access (location (slave_base, root), lock); mount_nullfs (mount_target (xports), location (slave_base, xports)); mount_nullfs (mount_target (options), location (slave_base, options)); mount_nullfs (mount_target (packages), location (slave_base, packages), mode => readwrite); mount_nullfs (mount_target (distfiles), location (slave_base, distfiles), mode => readwrite); if PM.configuration.tmpfs_workdir then mount_tmpfs (location (slave_base, wrkdirs), 12 * 1024); else forge_directory (slave_work); mount_nullfs (slave_work, location (slave_base, wrkdirs), readwrite); end if; if not support_locks and then PM.configuration.tmpfs_localbase then mount_tmpfs (slave_base & root_localbase, 12 * 1024); else forge_directory (slave_local); mount_nullfs (slave_local, slave_base & root_localbase, readwrite); end if; if opts.need_procfs then mount_procfs (path_to_proc => location (slave_base, proc)); end if; if flavor = dragonfly then declare bootdir : String := clean_mount_point (boot); begin if AD.Exists (bootdir) then mount_nullfs (target => bootdir, mount_point => location (slave_base, boot)); mount_tmpfs (slave_base & root_lmodules, 100); end if; end; end if; if flavor = freebsd then if opts.need_linprocfs then if PM.configuration.tmpfs_localbase then mount_tmpfs (slave_base & root_linux, 12 * 1024); else forge_directory (slave_linux); mount_nullfs (slave_linux, slave_base & root_linux, readwrite); end if; forge_directory (slave_base & root_linproc); mount_linprocfs (mount_point => slave_base & root_linproc); end if; declare lib32 : String := clean_mount_point (usr_lib32); begin if AD.Exists (lib32) then mount_nullfs (target => lib32, mount_point => location (slave_base, usr_lib32)); end if; end; declare bootdir : String := clean_mount_point (boot); begin if AD.Exists (bootdir) then mount_nullfs (target => bootdir, mount_point => location (slave_base, boot)); mount_tmpfs (slave_base & root_kmodules, 100); end if; end; end if; declare srcdir : String := clean_mount_point (usr_src); begin if AD.Exists (srcdir) then mount_nullfs (srcdir, location (slave_base, usr_src)); if AD.Exists (srcdir & "/sys") then create_symlink (destination => "usr/src/sys", symbolic_link => slave_base & "/sys"); end if; end if; end; if AD.Exists (mount_target (ccache)) then mount_nullfs (mount_target (ccache), location (slave_base, ccache), mode => readwrite); end if; mount_devices (location (slave_base, dev)); populate_var_folder (location (slave_base, var)); copy_mtree_files (location (slave_base, etc_mtree)); copy_rc_default (location (slave_base, etc)); copy_resolv_conf (location (slave_base, etc)); create_make_conf (location (slave_base, etc)); create_passwd (location (slave_base, etc)); create_group (location (slave_base, etc)); create_etc_services (location (slave_base, etc)); create_etc_fstab (location (slave_base, etc)); execute_ldconfig (id); exception when hiccup : others => EX.Reraise_Occurrence (hiccup); end launch_slave; --------------------- -- destroy_slave -- --------------------- procedure destroy_slave (id : builders; opts : slave_options) is slave_base : constant String := get_slave_mount (id); slave_work : constant String := slave_base & "_work"; slave_local : constant String := slave_base & "_localbase"; slave_linux : constant String := slave_base & "_linux"; dir_system : constant String := JT.USS (PM.configuration.dir_system); begin unmount (slave_base & root_localbase); if support_locks or else not PM.configuration.tmpfs_localbase then -- We can't use AD.Delete_Tree because it skips directories -- starting with "." (pretty useless then) annihilate_directory_tree (slave_local); end if; unmount (location (slave_base, wrkdirs)); if not PM.configuration.tmpfs_workdir then annihilate_directory_tree (slave_work); end if; if AD.Exists (root_usr_src) then unmount (location (slave_base, usr_src)); end if; if AD.Exists (mount_target (ccache)) then unmount (location (slave_base, ccache)); end if; if flavor = dragonfly then if AD.Exists (location (dir_system, boot)) then unmount (slave_base & root_lmodules); unmount (location (slave_base, boot)); end if; end if; if flavor = freebsd then if opts.need_linprocfs then unmount (slave_base & root_linproc); unmount (slave_base & root_linux); if not PM.configuration.tmpfs_localbase then annihilate_directory_tree (slave_linux); end if; end if; if AD.Exists (location (dir_system, usr_lib32)) then unmount (location (slave_base, usr_lib32)); end if; if AD.Exists (location (dir_system, boot)) then unmount (slave_base & root_kmodules); unmount (location (slave_base, boot)); end if; end if; if opts.need_procfs then unmount (location (slave_base, proc)); end if; unmount (location (slave_base, dev)); unmount (location (slave_base, xports)); unmount (location (slave_base, options)); unmount (location (slave_base, packages)); unmount (location (slave_base, distfiles)); for mnt in subfolder'Range loop unmount (location (slave_base, mnt)); end loop; folder_access (location (slave_base, home), unlock); folder_access (location (slave_base, root), unlock); folder_access (location (slave_base, var) & "/empty", unlock); unmount (slave_base); annihilate_directory_tree (slave_base); exception when hiccup : others => EX.Reraise_Occurrence (hiccup); end destroy_slave; -------------------------- -- synth_mounts_exist -- -------------------------- function synth_mounts_exist return Boolean is buildbase : constant String := JT.USS (PM.configuration.dir_buildbase); command : constant String := "/bin/df -h"; comres : JT.Text; topline : JT.Text; crlen1 : Natural; crlen2 : Natural; begin comres := internal_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 JT.contains (topline, buildbase) then return True; end if; end loop; return False; exception when others => return True; end synth_mounts_exist; ----------------------------- -- clear_existing_mounts -- ----------------------------- function clear_existing_mounts return Boolean is package crate is new AC.Vectors (Index_Type => Positive, Element_Type => JT.Text, "=" => JT.SU."="); procedure annihilate (cursor : crate.Cursor); buildbase : constant String := JT.USS (PM.configuration.dir_buildbase); command1 : constant String := "/bin/df -h"; comres : JT.Text; topline : JT.Text; crlen1 : Natural; crlen2 : Natural; mindex : Natural; mlength : Natural; mpoints : crate.Vector; procedure annihilate (cursor : crate.Cursor) is mountpoint : constant String := JT.USS (crate.Element (cursor)); begin unmount (mountpoint); if AD.Exists (mountpoint) then AD.Delete_Directory (mountpoint); end if; exception when others => null; end annihilate; begin comres := internal_system_command (command1); crlen1 := JT.SU.Length (comres); loop JT.nextline (lineblock => comres, firstline => topline); crlen2 := JT.SU.Length (comres); exit when crlen1 = crlen2; crlen1 := crlen2; if JT.contains (topline, buildbase) then mindex := JT.SU.Index (topline, buildbase); mlength := JT.SU.Length (topline); mpoints.Append (JT.SUS (JT.SU.Slice (topline, mindex, mlength))); end if; end loop; mpoints.Reverse_Iterate (Process => annihilate'Access); if synth_mounts_exist then return False; end if; -- No need to remove empty dirs, the upcoming run will do that. return True; end clear_existing_mounts; ---------------------------- -- disk_workareas_exist -- ---------------------------- function disk_workareas_exist return Boolean is Search : AD.Search_Type; buildbase : constant String := JT.USS (PM.configuration.dir_buildbase); result : Boolean := False; begin if not AD.Exists (buildbase) then return False; end if; AD.Start_Search (Search => Search, Directory => buildbase, Filter => (AD.Directory => True, others => False), Pattern => "SL*_*"); result := AD.More_Entries (Search => Search); return result; end disk_workareas_exist; -------------------------------- -- clear_existing_workareas -- -------------------------------- function clear_existing_workareas return Boolean is Search : AD.Search_Type; Dir_Ent : AD.Directory_Entry_Type; buildbase : constant String := JT.USS (PM.configuration.dir_buildbase); begin AD.Start_Search (Search => Search, Directory => buildbase, Filter => (AD.Directory => True, others => False), Pattern => "SL*_*"); while AD.More_Entries (Search => Search) loop AD.Get_Next_Entry (Search => Search, Directory_Entry => Dir_Ent); declare target : constant String := buildbase & "/" & AD.Simple_Name (Dir_Ent); begin annihilate_directory_tree (target); end; end loop; return True; exception when others => return False; end clear_existing_workareas; ---------------------------- -- concatenate_makeconf -- ---------------------------- procedure concatenate_makeconf (makeconf_handle : TIO.File_Type; target_name : String) is fragment : TIO.File_Type; begin 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 TIO.Put_Line (makeconf_handle, Line); end; end loop; TIO.Close (fragment); end if; exception when others => null; end concatenate_makeconf; ---------------------------- -- cache_port_variables -- ---------------------------- procedure cache_port_variables (path_to_mm : String) is function create_OSRELEASE (OSRELEASE : String) return String; OSVER : constant String := get_osversion_from_param_header; ARCH : constant String := get_arch_from_bourne_shell; portsdir : constant String := JT.USS (PM.configuration.dir_portsdir); fullport : constant String := portsdir & "/ports-mgmt/pkg"; command : constant String := "/usr/bin/make __MAKE_CONF=/dev/null -C " & fullport & " -VHAVE_COMPAT_IA32_KERN -VCONFIGURE_MAX_CMD_LEN"; content : JT.Text; topline : JT.Text; status : Integer; vconf : TIO.File_Type; type result_range is range 1 .. 2; function create_OSRELEASE (OSRELEASE : String) return String is -- FreeBSD OSVERSION is 6 or 7 digits -- OSVERSION [M]MNNPPP -- DragonFly OSVERSION is 6 digits -- OSVERSION MNNNPP len : constant Natural := OSRELEASE'Length; FL : constant Natural := len - 4; OSR : constant String (1 .. len) := OSRELEASE; MM : String (1 .. 2) := " "; PP : String (1 .. 2) := " "; begin if len < 6 then return "1.0-SYNTH"; end if; if len = 6 then MM (2) := OSR (1); else MM := OSR (1 .. 2); end if; if flavor = dragonfly then if OSR (3) = '0' then PP (2) := OSR (4); else PP := OSR (3 .. 4); end if; else if OSR (FL) = '0' then PP (2) := OSR (FL + 1); else PP := OSR (FL .. FL + 1); end if; end if; return JT.trim (MM) & "." & JT.trim (PP) & "-SYNTH"; end create_OSRELEASE; release : constant String := create_OSRELEASE (OSVER); begin builder_env := JT.blank; content := Unix.piped_command (command, status); if status /= 0 then raise scenario_unexpected with "cache_port_variables: return code =" & status'Img; end if; TIO.Create (File => vconf, Mode => TIO.Out_File, Name => path_to_mm & "/varcache.conf"); for k in result_range loop JT.nextline (lineblock => content, firstline => topline); declare value : constant String := JT.USS (topline); begin case k is when 1 => TIO.Put_Line (vconf, "HAVE_COMPAT_IA32_KERN=" & value); when 2 => TIO.Put_Line (vconf, "CONFIGURE_MAX_CMD_LEN=" & value); end case; end; end loop; TIO.Put_Line (vconf, "_SMP_CPUS=" & JT.int2str (Integer (smp_cores))); TIO.Put_Line (vconf, "UID=0"); TIO.Put_Line (vconf, "ARCH=" & ARCH); TIO.Put (vconf, "OPSYS="); case flavor is when freebsd => TIO.Put_Line (vconf, "FreeBSD"); TIO.Put_Line (vconf, "OSVERSION=" & OSVER); JT.SU.Append (builder_env, "UNAME_s=FreeBSD " & "UNAME_v=FreeBSD\ " & release); when dragonfly => TIO.Put_Line (vconf, "DragonFly"); TIO.Put_Line (vconf, "DFLYVERSION=" & OSVER); TIO.Put_Line (vconf, "OSVERSION=9999999"); JT.SU.Append (builder_env, "UNAME_s=DragonFly " & "UNAME_v=DragonFly\ " & release); when unknown => TIO.Put_Line (vconf, "Unknown"); end case; TIO.Put_Line (vconf, "OSREL=" & release (1 .. release'Last - 6)); TIO.Put_Line (vconf, "_OSRELEASE=" & release); TIO.Close (vconf); JT.SU.Append (builder_env, " UNAME_p=" & ARCH); JT.SU.Append (builder_env, " UNAME_m=" & ARCH); JT.SU.Append (builder_env, " UNAME_r=" & release & " "); end cache_port_variables; --------------------------------------- -- write_common_mtree_exclude_base -- --------------------------------------- procedure write_common_mtree_exclude_base (mtreefile : TIO.File_Type) is begin TIO.Put_Line (mtreefile, "./bin" & LAT.LF & "./boot" & LAT.LF & "./ccache" & LAT.LF & "./compat/linux/proc" & LAT.LF & "./construction" & LAT.LF & "./dev" & LAT.LF & "./distfiles" & LAT.LF & "./lib" & LAT.LF & "./libexec" & LAT.LF & "./home" & LAT.LF & "./options" & LAT.LF & "./packages" & LAT.LF & "./proc" & LAT.LF & "./root" & LAT.LF & "./sbin" & LAT.LF & "./tmp" & LAT.LF & "./usr/bin" & LAT.LF & "./usr/include" & LAT.LF & "./usr/lib" & LAT.LF & "./usr/lib32" & LAT.LF & "./usr/libdata" & LAT.LF & "./usr/libexec" & LAT.LF & "./usr/sbin" & LAT.LF & "./usr/share" & LAT.LF & "./usr/src" & LAT.LF & "./var/db/fontconfig" & LAT.LF & "./var/run" & LAT.LF & "./var/tmp" & LAT.LF & "./xports" ); end write_common_mtree_exclude_base; -------------------------------- -- write_preinstall_section -- -------------------------------- procedure write_preinstall_section (mtreefile : TIO.File_Type) is begin TIO.Put_Line (mtreefile, "./etc/group" & LAT.LF & "./etc/make.conf" & LAT.LF & "./etc/make.conf.bak" & LAT.LF & "./etc/make.nxb.conf" & LAT.LF & "./etc/master.passwd" & LAT.LF & "./etc/passwd" & LAT.LF & "./etc/pwd.db" & LAT.LF & "./etc/shells" & LAT.LF & "./etc/spwd.db" & LAT.LF & "./var/db" & LAT.LF & "./var/log" & LAT.LF & "./var/mail" & LAT.LF & "./var/spool" & LAT.LF & "./var/tmp" & LAT.LF & "./usr/local/etc/gconf/gconf.xml.defaults/%gconf-tree*.xml" & LAT.LF & "./usr/local/lib/gio/modules/giomodule.cache" & LAT.LF & "./usr/local/info/dir" & LAT.LF & "./usr/local/*/info/dir" & LAT.LF & "./usr/local/*/ls-R" & LAT.LF & "./usr/local/share/octave/octave_packages" & LAT.LF & "./usr/local/share/xml/catalog.ports" ); end write_preinstall_section; -------------------------------- -- create_mtree_exc_preinst -- -------------------------------- procedure create_mtree_exc_preinst (path_to_mm : String) is mtreefile : TIO.File_Type; filename : constant String := path_to_mm & "/mtree.prestage.exclude"; begin TIO.Create (File => mtreefile, Mode => TIO.Out_File, Name => filename); write_common_mtree_exclude_base (mtreefile); write_preinstall_section (mtreefile); TIO.Close (mtreefile); end create_mtree_exc_preinst; ---------------------------------- -- create_mtree_exc_preconfig -- ---------------------------------- procedure create_mtree_exc_preconfig (path_to_mm : String) is mtreefile : TIO.File_Type; filename : constant String := path_to_mm & "/mtree.preconfig.exclude"; begin TIO.Create (File => mtreefile, Mode => TIO.Out_File, Name => filename); write_common_mtree_exclude_base (mtreefile); TIO.Close (mtreefile); end create_mtree_exc_preconfig; --------------------------------------- -- get_osversion_from_param_header -- --------------------------------------- function get_osversion_from_param_header return String is function get_pattern return String; function get_pattern return String is DFVER : constant String := "#define __DragonFly_version "; FBVER : constant String := "#define __FreeBSD_version "; BADVER : constant String := "#define __Unknown_version "; begin case flavor is when freebsd => return FBVER; when dragonfly => return DFVER; when unknown => return BADVER; end case; end get_pattern; header : TIO.File_Type; badres : constant String := "100000"; pattern : constant String := get_pattern; paramh : constant String := JT.USS (PM.configuration.dir_system) & "/usr/include/sys/param.h"; begin TIO.Open (File => header, Mode => TIO.In_File, Name => paramh); while not TIO.End_Of_File (header) loop declare Line : constant String := TIO.Get_Line (header); begin if JT.contains (Line, pattern) then declare OSVER : constant String := JT.part_2 (Line, pattern); len : constant Natural := OSVER'Length; begin exit when len < 7; TIO.Close (header); case OSVER (OSVER'First + 6) is when '0' .. '9' => return JT.trim (OSVER (OSVER'First .. OSVER'First + 6)); when others => return JT.trim (OSVER (OSVER'First .. OSVER'First + 5)); end case; end; end if; end; end loop; TIO.Close (header); return badres; exception when others => if TIO.Is_Open (header) then TIO.Close (header); end if; return badres; end get_osversion_from_param_header; ---------------------------------- -- get_arch_from_bourne_shell -- ---------------------------------- function get_arch_from_bourne_shell return String is command : constant String := "/usr/bin/file -b " & JT.USS (PM.configuration.dir_system) & "/bin/sh"; badarch : constant String := "BADARCH"; comres : JT.Text; begin comres := internal_system_command (command); declare unlen : constant Natural := JT.SU.Length (comres) - 1; fileinfo : constant String := JT.USS (comres)(1 .. unlen); arch : constant String (1 .. 11) := fileinfo (fileinfo'First + 27 .. fileinfo'First + 37); begin if arch (1 .. 6) = "x86-64" then case flavor is when freebsd => return "amd64"; when dragonfly => return "x86_64"; when unknown => return badarch; end case; elsif arch = "Intel 80386" then return "i386"; else return badarch; end if; end; exception when others => return badarch; end get_arch_from_bourne_shell; ------------------------ -- jail_environment -- ------------------------ function jail_environment return JT.Text is begin return builder_env; end jail_environment; -------------------------------------- -- boot_modules_directory_missing -- -------------------------------------- function boot_modules_directory_missing return Boolean is begin if JT.equivalent (PM.configuration.operating_sys, "DragonFly") then declare sroot : constant String := JT.USS (PM.configuration.dir_system); bootdir : constant String := sroot & root_boot; modsdir : constant String := sroot & root_lmodules; begin if AD.Exists (bootdir) and then not AD.Exists (modsdir) then return True; end if; end; end if; if JT.equivalent (PM.configuration.operating_sys, "FreeBSD") then declare sroot : constant String := JT.USS (PM.configuration.dir_system); bootdir : constant String := sroot & root_boot; modsdir : constant String := sroot & root_kmodules; begin if AD.Exists (bootdir) and then not AD.Exists (modsdir) then return True; end if; end; end if; return False; end boot_modules_directory_missing; ------------------------------ -- start_abnormal_logging -- ------------------------------ procedure start_abnormal_logging is logpath : constant String := JT.USS (PM.configuration.dir_logs) & "/" & abnormal_cmd_logname; begin if AD.Exists (logpath) then AD.Delete_File (logpath); end if; TIO.Create (File => abnormal_log, Mode => TIO.Out_File, Name => logpath); abn_log_ready := True; exception when others => abn_log_ready := False; end start_abnormal_logging; ----------------------------- -- stop_abnormal_logging -- ----------------------------- procedure stop_abnormal_logging is begin if abn_log_ready then TIO.Close (abnormal_log); end if; end stop_abnormal_logging; end Replicant;
annexi-strayline/ASAP-HEX
Ada
4,309
ads
------------------------------------------------------------------------------ -- -- -- Generic HEX String Handling Package -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2018-2019, ANNEXI-STRAYLINE Trans-Human Ltd. -- -- All rights reserved. -- -- -- -- Original Contributors: -- -- * Richard Wai, Ensi Martini, Aninda Poddar, Noshen Atashe -- -- (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 Hex.Modular_Codec; generic with package Subject is new Hex.Modular_Codec (<>); package Hex.Modular_Unit_Test is type Test_Result is (Pass, Fail); function Execute_Test (First : Subject.Modular_Value := Subject.Modular_Value'First; Last : Subject.Modular_Value := Subject.Modular_Value'Last; Tasks : Positive := 1; Report: Boolean := False) return Test_Result; -- Executes a unit test on a generic instantiation of Modular_Codec. -- -- Each task tests a range of Modular_Value from First .. Last (inclusive), -- testing encoding and decoding of each value in both lower and upper -- cases. -- -- If Report is True, details about the status and any errors are output -- as the test progresses -- -- If Tasks is > 1, separate Tasks are spawned with the work divided as -- evenly as possible between them -- -- This will eventually be replaced with "for parallel" end Hex.Modular_Unit_Test;
godunko/adawebpack
Ada
2,961
ads
------------------------------------------------------------------------------ -- -- -- AdaWebPack -- -- -- ------------------------------------------------------------------------------ -- Copyright © 2022, Vadim Godunko -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- 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. -- ------------------------------------------------------------------------------ -- Root package for API defined by "URL" specification. ------------------------------------------------------------------------------ package Web.URL is pragma Preelaborate; end Web.URL;
reznikmm/matreshka
Ada
11,049
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Internals.UML_Named_Elements; with AMF.UML.Constraints; with AMF.UML.Dependencies.Collections; with AMF.UML.Elements.Collections; with AMF.UML.Extends; with AMF.UML.Extension_Points.Collections; with AMF.UML.Named_Elements; with AMF.UML.Namespaces; with AMF.UML.Packages.Collections; with AMF.UML.String_Expressions; with AMF.UML.Use_Cases; with AMF.Visitors; package AMF.Internals.UML_Extends is type UML_Extend_Proxy is limited new AMF.Internals.UML_Named_Elements.UML_Named_Element_Proxy and AMF.UML.Extends.UML_Extend with null record; overriding function Get_Condition (Self : not null access constant UML_Extend_Proxy) return AMF.UML.Constraints.UML_Constraint_Access; -- Getter of Extend::condition. -- -- References the condition that must hold when the first extension point -- is reached for the extension to take place. If no constraint is -- associated with the extend relationship, the extension is unconditional. overriding procedure Set_Condition (Self : not null access UML_Extend_Proxy; To : AMF.UML.Constraints.UML_Constraint_Access); -- Setter of Extend::condition. -- -- References the condition that must hold when the first extension point -- is reached for the extension to take place. If no constraint is -- associated with the extend relationship, the extension is unconditional. overriding function Get_Extended_Case (Self : not null access constant UML_Extend_Proxy) return AMF.UML.Use_Cases.UML_Use_Case_Access; -- Getter of Extend::extendedCase. -- -- References the use case that is being extended. overriding procedure Set_Extended_Case (Self : not null access UML_Extend_Proxy; To : AMF.UML.Use_Cases.UML_Use_Case_Access); -- Setter of Extend::extendedCase. -- -- References the use case that is being extended. overriding function Get_Extension (Self : not null access constant UML_Extend_Proxy) return AMF.UML.Use_Cases.UML_Use_Case_Access; -- Getter of Extend::extension. -- -- References the use case that represents the extension and owns the -- extend relationship. overriding procedure Set_Extension (Self : not null access UML_Extend_Proxy; To : AMF.UML.Use_Cases.UML_Use_Case_Access); -- Setter of Extend::extension. -- -- References the use case that represents the extension and owns the -- extend relationship. overriding function Get_Extension_Location (Self : not null access constant UML_Extend_Proxy) return AMF.UML.Extension_Points.Collections.Ordered_Set_Of_UML_Extension_Point; -- Getter of Extend::extensionLocation. -- -- An ordered list of extension points belonging to the extended use case, -- specifying where the respective behavioral fragments of the extending -- use case are to be inserted. The first fragment in the extending use -- case is associated with the first extension point in the list, the -- second fragment with the second point, and so on. (Note that, in most -- practical cases, the extending use case has just a single behavior -- fragment, so that the list of extension points is trivial.) overriding function Get_Source (Self : not null access constant UML_Extend_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element; -- Getter of DirectedRelationship::source. -- -- Specifies the sources of the DirectedRelationship. overriding function Get_Target (Self : not null access constant UML_Extend_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element; -- Getter of DirectedRelationship::target. -- -- Specifies the targets of the DirectedRelationship. overriding function Get_Related_Element (Self : not null access constant UML_Extend_Proxy) return AMF.UML.Elements.Collections.Set_Of_UML_Element; -- Getter of Relationship::relatedElement. -- -- Specifies the elements related by the Relationship. overriding function Get_Client_Dependency (Self : not null access constant UML_Extend_Proxy) return AMF.UML.Dependencies.Collections.Set_Of_UML_Dependency; -- Getter of NamedElement::clientDependency. -- -- Indicates the dependencies that reference the client. overriding function Get_Name_Expression (Self : not null access constant UML_Extend_Proxy) return AMF.UML.String_Expressions.UML_String_Expression_Access; -- Getter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding procedure Set_Name_Expression (Self : not null access UML_Extend_Proxy; To : AMF.UML.String_Expressions.UML_String_Expression_Access); -- Setter of NamedElement::nameExpression. -- -- The string expression used to define the name of this named element. overriding function Get_Namespace (Self : not null access constant UML_Extend_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Getter of NamedElement::namespace. -- -- Specifies the namespace that owns the NamedElement. overriding function Get_Qualified_Name (Self : not null access constant UML_Extend_Proxy) return AMF.Optional_String; -- Getter of NamedElement::qualifiedName. -- -- A name which allows the NamedElement to be identified within a -- hierarchy of nested Namespaces. It is constructed from the names of the -- containing namespaces starting at the root of the hierarchy and ending -- with the name of the NamedElement itself. overriding function All_Owning_Packages (Self : not null access constant UML_Extend_Proxy) return AMF.UML.Packages.Collections.Set_Of_UML_Package; -- Operation NamedElement::allOwningPackages. -- -- The query allOwningPackages() returns all the directly or indirectly -- owning packages. overriding function Is_Distinguishable_From (Self : not null access constant UML_Extend_Proxy; N : AMF.UML.Named_Elements.UML_Named_Element_Access; Ns : AMF.UML.Namespaces.UML_Namespace_Access) return Boolean; -- Operation NamedElement::isDistinguishableFrom. -- -- The query isDistinguishableFrom() determines whether two NamedElements -- may logically co-exist within a Namespace. By default, two named -- elements are distinguishable if (a) they have unrelated types or (b) -- they have related types but different names. overriding function Namespace (Self : not null access constant UML_Extend_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Operation NamedElement::namespace. -- -- Missing derivation for NamedElement::/namespace : Namespace overriding procedure Enter_Element (Self : not null access constant UML_Extend_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Leave_Element (Self : not null access constant UML_Extend_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Visit_Element (Self : not null access constant UML_Extend_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of iterator interface. end AMF.Internals.UML_Extends;
zhmu/ananas
Ada
13,396
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . M M A P -- -- -- -- S p e c -- -- -- -- Copyright (C) 2007-2022, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify it -- -- under terms of the GNU General Public License as published by the Free -- -- Software Foundation; either version 3, or (at your option) any later -- -- version. This library is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of 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. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package provides memory mapping of files. Depending on your operating -- system, this might provide a more efficient method for accessing the -- contents of files. -- A description of memory-mapping is available on the sqlite page, at: -- http://www.sqlite.org/mmap.html -- -- The traditional method for reading a file is to allocate a buffer in the -- application address space, then open the file and copy its contents. When -- memory mapping is available though, the application asks the operating -- system to return a pointer to the requested page, if possible. If the -- requested page has been or can be mapped into the application address -- space, the system returns a pointer to that page for the application to -- use without having to copy anything. Skipping the copy step is what makes -- memory mapped I/O faster. -- -- When memory mapping is not available, this package automatically falls -- back to the traditional copy method. -- -- Example of use for this package, when reading a file that can be fully -- mapped -- -- declare -- File : Mapped_File; -- Str : Str_Access; -- begin -- File := Open_Read ("/tmp/file_on_disk"); -- Read (File); -- read the whole file -- Str := Data (File); -- for S in 1 .. Last (File) loop -- Put (Str (S)); -- end loop; -- Close (File); -- end; -- -- When the file is big, or you only want to access part of it at a given -- time, you can use the following type of code. -- declare -- File : Mapped_File; -- Str : Str_Access; -- Offs : File_Size := 0; -- Page : constant Integer := Get_Page_Size; -- begin -- File := Open_Read ("/tmp/file_on_disk"); -- while Offs < Length (File) loop -- Read (File, Offs, Length => Long_Integer (Page) * 4); -- Str := Data (File); -- -- -- Print characters for this chunk: -- for S in Integer (Offs - Offset (File)) + 1 .. Last (File) loop -- Put (Str (S)); -- end loop; -- -- -- Since we are reading multiples of Get_Page_Size, we can simplify -- -- with -- -- for S in 1 .. Last (File) loop ... -- -- Offs := Offs + Long_Integer (Last (File)); -- end loop; with Interfaces.C; with System.Strings; package System.Mmap is type Mapped_File is private; -- File to be mapped in memory. -- This package will use the fastest possible algorithm to load the -- file in memory. On systems that support it, the file is not really -- loaded in memory. Instead, a call to the mmap() system call (or -- CreateFileMapping()) will keep the file on disk, but make it -- accessible as if it was in memory. -- When the system does not support it, the file is actually loaded in -- memory through calls to read(), and written back with write() when you -- close it. This is of course much slower. -- Legacy: each mapped file has a "default" mapped region in it. type Mapped_Region is private; -- A representation of part of a file in memory. Actual reading/writing -- is done through a mapped region. After being returned by Read, a mapped -- region must be free'd when done. If the original Mapped_File was open -- for reading, it can be closed before the mapped region is free'd. Invalid_Mapped_File : constant Mapped_File; Invalid_Mapped_Region : constant Mapped_Region; type Unconstrained_String is new String (Positive); type Str_Access is access all Unconstrained_String; pragma No_Strict_Aliasing (Str_Access); type File_Size is new Interfaces.C.size_t; function To_Str_Access (Str : System.Strings.String_Access) return Str_Access; -- Convert Str. The returned value points to the same memory block, but no -- longer includes the bounds, which you need to manage yourself function Open_Read (Filename : String; Use_Mmap_If_Available : Boolean := True) return Mapped_File; -- Open a file for reading. The same file can be shared by multiple -- processes, that will see each others's changes as they occur. -- Any attempt to write the data might result in a segmentation fault, -- depending on how the file is open. -- Name_Error is raised if the file does not exist. -- Filename should be compatible with the filesystem. function Open_Read_No_Exception (Filename : String; Use_Mmap_If_Available : Boolean := True) return Mapped_File; -- Like Open_Read but return Invalid_Mapped_File in case of error function Open_Write (Filename : String; Use_Mmap_If_Available : Boolean := True) return Mapped_File; -- Open a file for writing. -- You cannot change the length of the file. -- Name_Error is raised if the file does not exist -- Filename should be compatible with the filesystem. procedure Close (File : in out Mapped_File); -- Close the file, and unmap the memory that is used for the region -- contained in File. If the system does not support the unmmap() system -- call or equivalent, or these were not available for the file itself, -- then the file is written back to the disk if it was opened for writing. procedure Free (Region : in out Mapped_Region); -- Unmap the memory that is used for this region and deallocate the region procedure Read (File : Mapped_File; Region : in out Mapped_Region; Offset : File_Size := 0; Length : File_Size := 0; Mutable : Boolean := False); -- Read a specific part of File and set Region to the corresponding mapped -- region, or re-use it if possible. -- Offset is the number of bytes since the beginning of the file at which -- we should start reading. Length is the number of bytes that should be -- read. If set to 0, as much of the file as possible is read (presumably -- the whole file unless you are reading a _huge_ file). -- Note that no (un)mapping is is done if that part of the file is already -- available through Region. -- If the file was opened for writing, any modification you do to the -- data stored in File will be stored on disk (either immediately when the -- file is opened through a mmap() system call, or when the file is closed -- otherwise). -- Mutable is processed only for reading files. If set to True, the -- data can be modified, even through it will not be carried through the -- underlying file, nor it is guaranteed to be carried through remapping. -- This function takes care of page size alignment issues. The accessors -- below only expose the region that has been requested by this call, even -- if more bytes were actually mapped by this function. -- TODO??? Enable to have a private copy for readable files function Read (File : Mapped_File; Offset : File_Size := 0; Length : File_Size := 0; Mutable : Boolean := False) return Mapped_Region; -- Likewise, return a new mapped region procedure Read (File : Mapped_File; Offset : File_Size := 0; Length : File_Size := 0; Mutable : Boolean := False); -- Likewise, use the legacy "default" region in File function Length (File : Mapped_File) return File_Size; -- Size of the file on the disk function Offset (Region : Mapped_Region) return File_Size; -- Return the offset, in the physical file on disk, corresponding to the -- requested mapped region. The first byte in the file has offest 0. function Offset (File : Mapped_File) return File_Size; -- Likewise for the region contained in File function Last (Region : Mapped_Region) return Integer; -- Return the number of requested bytes mapped in this region. It is -- erroneous to access Data for indices outside 1 .. Last (Region). -- Such accesses may cause Storage_Error to be raised. function Last (File : Mapped_File) return Integer; -- Return the number of requested bytes mapped in the region contained in -- File. It is erroneous to access Data for indices outside of 1 .. Last -- (File); such accesses may cause Storage_Error to be raised. function Data (Region : Mapped_Region) return Str_Access; -- The data mapped in Region as requested. The result is an unconstrained -- string, so you cannot use the usual 'First and 'Last attributes. -- Instead, these are respectively 1 and Size. function Data (File : Mapped_File) return Str_Access; -- Likewise for the region contained in File function Is_Mutable (Region : Mapped_Region) return Boolean; -- Return whether it is safe to change bytes in Data (Region). This is true -- for regions from writeable files, for regions mapped with the "Mutable" -- flag set, and for regions that are copied in a buffer. Note that it is -- not specified whether empty regions are mutable or not, since there is -- no byte no modify. function Is_Mmapped (File : Mapped_File) return Boolean; -- Whether regions for this file are opened through an mmap() system call -- or equivalent. This is in general irrelevant to your application, unless -- the file can be accessed by multiple concurrent processes or tasks. In -- such a case, and if the file is indeed mmap-ed, then the various parts -- of the file can be written simulatenously, and thus you cannot ensure -- the integrity of the file. If the file is not mmapped, the latest -- process to Close it overwrite what other processes have done. function Get_Page_Size return Integer; -- Returns the number of bytes in a page. Once a file is mapped from the -- disk, its offset and Length should be multiples of this page size (which -- is ensured by this package in any case). Knowing this page size allows -- you to map as much memory as possible at once, thus potentially reducing -- the number of system calls to read the file by chunks. function Read_Whole_File (Filename : String; Empty_If_Not_Found : Boolean := False) return System.Strings.String_Access; -- Returns the whole contents of the file. -- The returned string must be freed by the user. -- This is a convenience function, which is of course slower than the ones -- above since we also need to allocate some memory, actually read the file -- and copy the bytes. -- If the file does not exist, null is returned. However, if -- Empty_If_Not_Found is True, then the empty string is returned instead. -- Filename should be compatible with the filesystem. private pragma Inline (Data, Length, Last, Offset, Is_Mmapped, To_Str_Access); type Mapped_File_Record; type Mapped_File is access Mapped_File_Record; type Mapped_Region_Record; type Mapped_Region is access Mapped_Region_Record; Invalid_Mapped_File : constant Mapped_File := null; Invalid_Mapped_Region : constant Mapped_Region := null; end System.Mmap;
charlie5/lace
Ada
2,095
adb
with gel.Forge, gel.Window.setup, gel.Applet.gui_world, gel.World, gel.Camera, gel.Sprite, ada.Calendar; pragma Unreferenced (gel.Window.setup); procedure launch_add_rid_sprite_Test -- -- drops a ball onto a box terrain. -- -- is use ada.Calendar; the_Applet : constant gel.Applet.gui_world.view := gel.forge.new_gui_Applet ("Add/Rid Sprite Test", 500, 500); the_Box : constant gel.Sprite.view := gel.forge.new_box_Sprite (the_Applet.gui_World, mass => 0.0); the_Balls : gel.Sprite.views (1 .. 1) := [others => gel.forge.new_ball_Sprite (the_Applet.gui_World, mass => 1.0)]; next_render_Time : ada.calendar.Time; begin the_Applet.gui_Camera.Site_is ([0.0, 5.0, 15.0]); -- Position the camera the_Applet.enable_simple_Dolly (1); -- Enable user camera control via keyboards the_Applet.enable_Mouse (detect_Motion => False); -- Enable mouse events. the_Applet.gui_World.add (the_Box); -- Add the ground box. the_Box.Site_is ([0.0, 0.0, 0.0]); for Each in the_Balls'range loop the_Applet.gui_World.add (the_Balls (Each)); -- Add ball. the_Balls (Each).Site_is ([0.0, 10.0, 0.0]); end loop; for Each in 1 .. 100 loop the_Applet.gui_World.evolve; -- Evolve the world. the_Applet.freshen; -- Handle any new events and update the screen. end loop; for Each in the_Balls'range loop the_Applet.gui_World.rid (the_Balls (Each)); -- Rid ball. gel.Sprite.free (the_Balls (Each)); end loop; next_render_Time := ada.Calendar.clock; while the_Applet.is_open loop the_Applet.gui_World.evolve; -- Evolve the world. the_Applet.freshen; -- Handle any new events and update the screen. next_render_Time := next_render_Time + gel.World.evolve_Period; delay until next_render_Time; end loop; the_Applet.destroy; end launch_add_rid_sprite_Test;
charlie5/cBound
Ada
1,754
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_query_extension_reply_t is -- Item -- type Item is record response_type : aliased Interfaces.Unsigned_8; pad0 : aliased Interfaces.Unsigned_8; sequence : aliased Interfaces.Unsigned_16; length : aliased Interfaces.Unsigned_32; present : aliased Interfaces.Unsigned_8; major_opcode : aliased Interfaces.Unsigned_8; first_event : aliased Interfaces.Unsigned_8; first_error : aliased Interfaces.Unsigned_8; end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_query_extension_reply_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_query_extension_reply_t.Item, Element_Array => xcb.xcb_query_extension_reply_t.Item_Array, Default_Terminator => (others => <>)); subtype Pointer is C_Pointers.Pointer; -- Pointer_Array -- type Pointer_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_query_extension_reply_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_query_extension_reply_t.Pointer, Element_Array => xcb.xcb_query_extension_reply_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_query_extension_reply_t;
seipy/ada-voxel-space-demo
Ada
2,255
adb
with Ada.Numerics.Generic_Elementary_Functions; package body Ada_Voxel is package Float_Functions is new Ada.Numerics.Generic_Elementary_Functions (Float); ------------ -- Render -- ------------ procedure Render (Cam_X : Float; Cam_Y : Float; Cam_Angle : Float; Cam_Height : Float; Horizon : Float; Distance : Float; Scale_Height : Float) is Y_Buffer : array (0 .. Screen_Width - 1) of Integer := (others => Screen_Height); Dz : Float := 1.0; Z : Float := 1.0; begin while Z < Distance loop declare Sin : Float := Float_Functions.Sin (Cam_Angle); Cos : Float := Float_Functions.Cos (Cam_Angle); Left_X : Float := (-Cos * Z - Sin * Z) + Cam_X; Left_Y : Float := ( Sin * Z - Cos * Z) + Cam_Y; Right_X : Float := ( Cos * Z - Sin * Z) + Cam_X; Right_Y : Float := (-Sin * Z - Cos * Z) + Cam_Y; Dx : constant Float := (Right_X - Left_X) / Float (Screen_Width); Dy : constant Float := (Right_Y - Left_Y) / Float (Screen_Width); Height_On_Screen : Float; begin for A in 0 .. Screen_Width - 1 loop Height_On_Screen := Cam_Height - Float (Height_Map (Integer (Left_X), Integer (Left_Y))); Height_On_Screen := Float (Height_On_Screen / Z) * Scale_Height + Horizon; Draw_Vertical_Line (A, Integer (Height_On_Screen), Integer (Y_Buffer (A)), Color_Map (Integer (Left_X), Integer (Left_Y))); if Integer (Height_On_Screen) < Y_Buffer (A) then Y_Buffer (A) := Integer (Height_On_Screen); end if; Left_X := Left_X + Dx; Left_Y := Left_Y + Dy; end loop; end; Z := Z + Dz; Dz := Dz + 0.01; end loop; end Render; end Ada_Voxel;
eqcola/ada-ado
Ada
4,428
ads
----------------------------------------------------------------------- -- ADO Databases -- Database Objects -- Copyright (C) 2009, 2010, 2011, 2012, 2015 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Ada.Streams; with Ada.Calendar; with Util.Refs; package ADO is type Int64 is range -2**63 .. 2**63 - 1; for Int64'Size use 64; type Unsigned64 is mod 2**64; for Unsigned64'Size use 64; DEFAULT_TIME : constant Ada.Calendar.Time; -- ------------------------------ -- Database Identifier -- ------------------------------ -- type Identifier is range -2**47 .. 2**47 - 1; NO_IDENTIFIER : constant Identifier := -1; type Entity_Type is range 0 .. 2**16 - 1; NO_ENTITY_TYPE : constant Entity_Type := 0; type Object_Id is record Id : Identifier; Kind : Entity_Type; end record; pragma Pack (Object_Id); -- ------------------------------ -- Nullable Types -- ------------------------------ -- Most database allow to store a NULL instead of an actual integer, date or string value. -- Unlike Java, there is no easy way to distinguish between a NULL and an actual valid value. -- The <b>Nullable_T</b> types provide a way to specify and check whether a value is null -- or not. -- An integer which can be null. type Nullable_Integer is record Value : Integer := 0; Is_Null : Boolean := True; end record; -- A string which can be null. type Nullable_String is record Value : Ada.Strings.Unbounded.Unbounded_String; Is_Null : Boolean := True; end record; -- A date which can be null. type Nullable_Time is record Value : Ada.Calendar.Time; Is_Null : Boolean := True; end record; -- Return True if the two nullable times are identical (both null or both same time). function "=" (Left, Right : in Nullable_Time) return Boolean; type Nullable_Entity_Type is record Value : Entity_Type := 0; Is_Null : Boolean := True; end record; -- ------------------------------ -- Blob data type -- ------------------------------ -- The <b>Blob</b> type is used to represent database blobs. The data is stored -- in an <b>Ada.Streams.Stream_Element_Array</b> pointed to by the <b>Data</b> member. -- The query statement and bind parameter will use a <b>Blob_Ref</b> which represents -- a reference to the blob data. This is intended to minimize data copy. type Blob (Len : Ada.Streams.Stream_Element_Offset) is new Util.Refs.Ref_Entity with record Data : Ada.Streams.Stream_Element_Array (1 .. Len); end record; type Blob_Access is access all Blob; package Blob_References is new Util.Refs.Indefinite_References (Blob, Blob_Access); subtype Blob_Ref is Blob_References.Ref; -- Create a blob with an allocated buffer of <b>Size</b> bytes. function Create_Blob (Size : in Natural) return Blob_Ref; -- Create a blob initialized with the given data buffer. function Create_Blob (Data : in Ada.Streams.Stream_Element_Array) return Blob_Ref; -- Create a blob initialized with the content from the file whose path is <b>Path</b>. -- Raises an IO exception if the file does not exist. function Create_Blob (Path : in String) return Blob_Ref; -- Return a null blob. function Null_Blob return Blob_Ref; private DEFAULT_TIME : constant Ada.Calendar.Time := Ada.Calendar.Time_Of (Year => 1901, Month => 1, Day => 2, Seconds => 0.0); end ADO;
Lucretia/Cherry
Ada
1,867
ads
-- -- 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 GNAT.Strings; package Options is Show_Conflict : aliased Boolean; Show_Version : aliased Boolean; RP_Flag : aliased Boolean; Basis_Flag : aliased Boolean; Compress : aliased Boolean; Be_Quiet : aliased Boolean; Statistics : aliased Boolean; MH_Flag : aliased Boolean; No_Line_Nos : aliased Boolean; No_Resort : aliased Boolean; Show_Help : aliased Boolean; use GNAT.Strings; Program_Name : aliased String_Access := new String'(""); Input_File : aliased String_Access := new String'("parse.y"); User_Template : aliased String_Access := new String'(""); Output_Dir : aliased String_Access := new String'("."); Placeholder_Dummy : aliased GNAT.Strings.String_Access; Language_String : aliased GNAT.Strings.String_Access := new String'("C"); -- C is the default language like in Lemon. -- High level options type Language_Type is (Language_Ada, Language_C); Language : Language_Type := Language_C; -- Not used by C parts. procedure Set_Language; private -- Option integers pragma Export (C, Show_Conflict, "lemon_show_conflict"); pragma Export (C, Show_Version, "lemon_show_version"); pragma Export (C, Basis_Flag, "lemon_basis_flag"); pragma Export (C, Compress, "lemon_compress"); pragma Export (C, Be_Quiet, "lemon_be_quiet"); pragma Export (C, Statistics, "lemon_statistics"); pragma Export (C, No_Line_Nos, "lemon_no_line_nos"); pragma Export (C, No_Resort, "lemon_no_resort"); end Options;
optikos/ada-lsp
Ada
696
adb
-- Copyright (c) 2017 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with LSP.Servers; with LSP.Stdio_Streams; with Ada_LSP.Contexts; with Ada_LSP.Handlers; procedure Ada_LSP.Driver is Server : aliased LSP.Servers.Server; Stream : aliased LSP.Stdio_Streams.Stdio_Stream; Context : aliased Ada_LSP.Contexts.Context; Handler : aliased Ada_LSP.Handlers.Message_Handler (Server'Access, Context'Access); begin Server.Initialize (Stream'Unchecked_Access, Handler'Unchecked_Access, Handler'Unchecked_Access); Server.Run; end Ada_LSP.Driver;
zhmu/ananas
Ada
9,854
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . M M A P . O S _ I N T E R F A C E -- -- -- -- S p e c -- -- -- -- Copyright (C) 2007-2022, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify it -- -- under terms of the GNU General Public License as published by the Free -- -- Software Foundation; either version 3, or (at your option) any later -- -- version. This library is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of 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. -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- OS pecularities abstraction package for Win32 systems. package System.Mmap.OS_Interface is -- The Win package contains copy of definition found in recent System.Win32 -- unit provided with the GNAT compiler. The copy is needed to be able to -- compile this unit with older compilers. Note that this internal Win -- package can be removed when GNAT 6.1.0 is not supported anymore. package Win is subtype PVOID is Standard.System.Address; type HANDLE is new Interfaces.C.ptrdiff_t; type WORD is new Interfaces.C.unsigned_short; type DWORD is new Interfaces.C.unsigned_long; type LONG is new Interfaces.C.long; type SIZE_T is new Interfaces.C.size_t; type BOOL is new Interfaces.C.int; for BOOL'Size use Interfaces.C.int'Size; FALSE : constant := 0; GENERIC_READ : constant := 16#80000000#; GENERIC_WRITE : constant := 16#40000000#; OPEN_EXISTING : constant := 3; type OVERLAPPED is record Internal : DWORD; InternalHigh : DWORD; Offset : DWORD; OffsetHigh : DWORD; hEvent : HANDLE; end record; type SECURITY_ATTRIBUTES is record nLength : DWORD; pSecurityDescriptor : PVOID; bInheritHandle : BOOL; end record; type SYSTEM_INFO is record dwOemId : DWORD; dwPageSize : DWORD; lpMinimumApplicationAddress : PVOID; lpMaximumApplicationAddress : PVOID; dwActiveProcessorMask : PVOID; dwNumberOfProcessors : DWORD; dwProcessorType : DWORD; dwAllocationGranularity : DWORD; wProcessorLevel : WORD; wProcessorRevision : WORD; end record; type LP_SYSTEM_INFO is access all SYSTEM_INFO; INVALID_HANDLE_VALUE : constant HANDLE := -1; FILE_BEGIN : constant := 0; FILE_SHARE_READ : constant := 16#00000001#; FILE_ATTRIBUTE_NORMAL : constant := 16#00000080#; FILE_MAP_COPY : constant := 1; FILE_MAP_READ : constant := 4; FILE_MAP_WRITE : constant := 2; PAGE_READONLY : constant := 16#0002#; PAGE_READWRITE : constant := 16#0004#; INVALID_FILE_SIZE : constant := 16#FFFFFFFF#; function CreateFile (lpFileName : Standard.System.Address; dwDesiredAccess : DWORD; dwShareMode : DWORD; lpSecurityAttributes : access SECURITY_ATTRIBUTES; dwCreationDisposition : DWORD; dwFlagsAndAttributes : DWORD; hTemplateFile : HANDLE) return HANDLE; pragma Import (Stdcall, CreateFile, "CreateFileW"); function WriteFile (hFile : HANDLE; lpBuffer : Standard.System.Address; nNumberOfBytesToWrite : DWORD; lpNumberOfBytesWritten : access DWORD; lpOverlapped : access OVERLAPPED) return BOOL; pragma Import (Stdcall, WriteFile, "WriteFile"); function ReadFile (hFile : HANDLE; lpBuffer : Standard.System.Address; nNumberOfBytesToRead : DWORD; lpNumberOfBytesRead : access DWORD; lpOverlapped : access OVERLAPPED) return BOOL; pragma Import (Stdcall, ReadFile, "ReadFile"); function CloseHandle (hObject : HANDLE) return BOOL; pragma Import (Stdcall, CloseHandle, "CloseHandle"); function GetFileSize (hFile : HANDLE; lpFileSizeHigh : access DWORD) return DWORD; pragma Import (Stdcall, GetFileSize, "GetFileSize"); function SetFilePointer (hFile : HANDLE; lDistanceToMove : LONG; lpDistanceToMoveHigh : access LONG; dwMoveMethod : DWORD) return DWORD; pragma Import (Stdcall, SetFilePointer, "SetFilePointer"); function CreateFileMapping (hFile : HANDLE; lpSecurityAttributes : access SECURITY_ATTRIBUTES; flProtect : DWORD; dwMaximumSizeHigh : DWORD; dwMaximumSizeLow : DWORD; lpName : Standard.System.Address) return HANDLE; pragma Import (Stdcall, CreateFileMapping, "CreateFileMappingW"); function MapViewOfFile (hFileMappingObject : HANDLE; dwDesiredAccess : DWORD; dwFileOffsetHigh : DWORD; dwFileOffsetLow : DWORD; dwNumberOfBytesToMap : SIZE_T) return Standard.System.Address; pragma Import (Stdcall, MapViewOfFile, "MapViewOfFile"); function UnmapViewOfFile (lpBaseAddress : Standard.System.Address) return BOOL; pragma Import (Stdcall, UnmapViewOfFile, "UnmapViewOfFile"); procedure GetSystemInfo (lpSystemInfo : LP_SYSTEM_INFO); pragma Import (Stdcall, GetSystemInfo, "GetSystemInfo"); end Win; type System_File is record Handle : Win.HANDLE; Mapped : Boolean; -- Whether mapping is requested by the user and available on the system Mapping_Handle : Win.HANDLE; Write : Boolean; -- Whether this file can be written to Length : File_Size; -- Length of the file. Used to know what can be mapped in the file end record; type System_Mapping is record Address : Standard.System.Address; Length : File_Size; end record; Invalid_System_File : constant System_File := (Win.INVALID_HANDLE_VALUE, False, Win.INVALID_HANDLE_VALUE, False, 0); Invalid_System_Mapping : constant System_Mapping := (Standard.System.Null_Address, 0); function Open_Read (Filename : String; Use_Mmap_If_Available : Boolean := True) return System_File; -- Open a file for reading and return the corresponding System_File. Return -- Invalid_System_File if unsuccessful. function Open_Write (Filename : String; Use_Mmap_If_Available : Boolean := True) return System_File; -- Likewise for writing to a file procedure Close (File : in out System_File); -- Close a system file function Read_From_Disk (File : System_File; Offset, Length : File_Size) return System.Strings.String_Access; -- Read a fragment of a file. It is up to the caller to free the result -- when done with it. procedure Write_To_Disk (File : System_File; Offset, Length : File_Size; Buffer : System.Strings.String_Access); -- Write some content to a fragment of a file procedure Create_Mapping (File : System_File; Offset, Length : in out File_Size; Mutable : Boolean; Mapping : out System_Mapping); -- Create a memory mapping for the given File, for the area starting at -- Offset and containing Length bytes. Store it to Mapping. -- Note that Offset and Length may be modified according to the system -- needs (for boudaries, for instance). The caller must cope with actually -- wider mapped areas. procedure Dispose_Mapping (Mapping : in out System_Mapping); -- Unmap a previously-created mapping function Get_Page_Size return File_Size; -- Return the number of bytes in a system page. end System.Mmap.OS_Interface;
AdaCore/gpr
Ada
43
ads
package Pkg1 is procedure P; end Pkg1;
AdaCore/Ada_Drivers_Library
Ada
2,685
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2019, 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 an interface to control the red LED next to the USB-C -- connector. package Feather_STM32F405.LED is procedure Turn_On; -- Turn on the LED procedure Turn_Off; -- Turn off the LED procedure Toggle; -- Toggle the LED between on and off end Feather_STM32F405.LED;
Fabien-Chouteau/shoot-n-loot
Ada
3,680
adb
-- Shoot'n'loot -- Copyright (c) 2020 Fabien Chouteau with HAL; use HAL; with PyGamer.Screen; with PyGamer.Time; with PyGamer.Controls; use PyGamer; with Sound; package body Render is Buffer_Size : constant Positive := PyGamer.Screen.Width * PyGamer.Screen.Height; Render_Buffer : GESTE.Output_Buffer (1 .. Buffer_Size); ----------------- -- Push_Pixels -- ----------------- procedure Push_Pixels (Buffer : GESTE.Output_Buffer) is begin PyGamer.Screen.Push_Pixels (Buffer'Address, Buffer'Length); end Push_Pixels; ---------------------- -- Set_Drawing_Area -- ---------------------- procedure Set_Drawing_Area (Area : GESTE.Pix_Rect) is begin PyGamer.Screen.End_Pixel_TX; PyGamer.Screen.Set_Address (X_Start => HAL.UInt16 (Area.TL.X), X_End => HAL.UInt16 (Area.BR.X), Y_Start => HAL.UInt16 (Area.TL.Y), Y_End => HAL.UInt16 (Area.BR.Y)); PyGamer.Screen.Start_Pixel_TX; end Set_Drawing_Area; ---------------- -- Render_All -- ---------------- procedure Render_All (Background : GESTE_Config.Output_Color) is begin GESTE.Render_All (((0, 0), (Screen.Width - 1, Screen.Height - 1)), Background, Render_Buffer, Push_Pixels'Access, Set_Drawing_Area'Access); PyGamer.Screen.End_Pixel_TX; end Render_All; ------------------ -- Render_Dirty -- ------------------ procedure Render_Dirty (Background : GESTE_Config.Output_Color) is begin GESTE.Render_Dirty (((0, 0), (Screen.Width - 1, Screen.Height - 1)), Background, Render_Buffer, Push_Pixels'Access, Set_Drawing_Area'Access); PyGamer.Screen.End_Pixel_TX; end Render_Dirty; ---------------------- -- Scroll_New_Scene -- ---------------------- procedure Scroll_New_Scene (Background : GESTE_Config.Output_Color) is Period : constant Time.Time_Ms := 1000 / 60; Next_Release : Time.Time_Ms := Time.Clock + Period; Scroll : UInt8 := PyGamer.Screen.Width; Step : constant := 2; X : Natural := 0; begin for Count in 1 .. PyGamer.Screen.Width / Step loop Scroll := Scroll - Step; Screen.Scroll (Scroll); -- Render one column of pixel at Width - Scroll GESTE.Render_All (((X, 0), (X + Step - 1, Screen.Height - 1)), Background, Render_Buffer, Push_Pixels'Access, Set_Drawing_Area'Access); X := X + Step; Screen.End_Pixel_TX; Sound.Tick; Controls.Scan; Time.Delay_Until (Next_Release); Next_Release := Next_Release + Period; end loop; end Scroll_New_Scene; ---------------------- -- Background_Color -- ---------------------- function Background_Color return GESTE_Config.Output_Color is (To_RGB565 (51, 153, 204)); --------------- -- To_RGB565 -- --------------- function To_RGB565 (R, G, B : Unsigned_8) return Unsigned_16 is R16 : constant Unsigned_16 := Shift_Right (Unsigned_16 (R), 3) and 16#1F#; G16 : constant Unsigned_16 := Shift_Right (Unsigned_16 (G), 2) and 16#3F#; B16 : constant Unsigned_16 := Shift_Right (Unsigned_16 (B), 3) and 16#1F#; RGB : constant Unsigned_16 := (Shift_Left (R16, 11) or Shift_Left (G16, 5) or B16); begin return Shift_Right (RGB and 16#FF00#, 8) or (Shift_Left (RGB, 8) and 16#FF00#); end To_RGB565; end Render;
pat-rogers/LmcpGen
Ada
1,237
ads
with AVTAS.LMCP.ByteBuffers; use AVTAS.LMCP.ByteBuffers; package -<full_series_name_dots>-.Factory is HEADER_SIZE : constant := 8; CHECKSUM_SIZE : constant := 4; SERIESNAME_SIZE : constant := 8; LMCP_CONTROL_STR : constant := 16#4c4d4350#; function packMessage(rootObject : in avtas.lmcp.object.Object_Any; enableChecksum : in Boolean) return ByteBuffer; procedure getObject(buffer : in out ByteBuffer; output : out avtas.lmcp.object.Object_Any); function createObject(seriesId : in Int64; msgType : in UInt32; version: in UInt16) return avtas.lmcp.object.Object_Any; function CalculatedChecksum (Buffer : in ByteBuffer; Size : Index) return UInt32; -- Computes the modular checksum for the Buffer contents, ignoring the -- last 4 bytes in which the checksum may or may not be stored. Assumes -- Big Endian byte order. function getObjectSize(buffer : in ByteBuffer) return UInt32; function Validated (Buffer : in ByteBuffer) return Boolean; -- Returns whether a newly computed checksum equals the previously computed -- checksum value stored with the message in the buffer. Assumes the buffer -- is in Big Endian byte order. end -<full_series_name_dots>-.Factory;
charlie5/lace
Ada
2,562
ads
generic package any_Math.any_Algebra.any_linear.any_d2 is pragma Pure; ----------- -- Vector_2 -- function Interpolated (From, To : in Vector_2; Percent : in unit_Percentage) return Vector_2; function Distance (From, To : in Vector_2) return Real; function Midpoint (From, To : in Vector_2) return Vector_2; function Angle_between_pre_Norm (U, V : in Vector_2) return Radians; -- -- Given that the vectors 'U' and 'V' are already normalized, returns a positive angle between 0 and 180 degrees. ------------- -- Matrix_2x2 -- function to_Matrix (Row_1, Row_2 : in Vector_2) return Matrix_2x2; function to_rotation_Matrix (Angle : in Radians) return Matrix_2x2; function up_Direction (Self : in Matrix_2x2) return Vector_2; function right_Direction (Self : in Matrix_2x2) return Vector_2; ------------ -- Transform -- function to_Transform (Rotation : in Matrix_2x2; Translation : in Vector_2) return Matrix_3x3; function to_Transform (From : in Transform_2d) return Matrix_3x3; function to_translation_Transform (Translation : in Vector_2) return Matrix_3x3; function to_rotation_Transform (Rotation : in Matrix_2x2) return Matrix_3x3; function to_rotation_Transform (Angle : in Radians ) return Matrix_3x3; function to_scale_Transform (Scale : in Vector_2) return Matrix_3x3; function to_Transform_2d (From : in Matrix_3x3) return Transform_2d; function to_Transform_2d (Rotation : in Radians; Translation : in Vector_2) return Transform_2d; function "*" (Left : in Vector_2; Right : in Transform_2d) return Vector_2; function "*" (Left : in Vector_2; Right : in Matrix_3x3) return Vector_2; function Invert (Transform : in Transform_2d) return Transform_2d; function inverse_Transform (Transform : in Transform_2d; Vector : in Vector_2) return Vector_2; function get_Rotation (Transform : in Matrix_3x3) return Matrix_2x2; procedure set_Rotation (Transform : in out Matrix_3x3; To : in Matrix_2x2); function get_Translation (Transform : in Matrix_3x3) return Vector_2; procedure set_Translation (Transform : in out Matrix_3x3; To : in Vector_2); end any_Math.any_Algebra.any_linear.any_d2;
charlesdaniels/libagar
Ada
2,703
adb
------------------------------------------------------------------------------ -- AGAR CORE LIBRARY -- -- A G A R . E R R O R -- -- B o d y -- -- -- -- Copyright (c) 2018-2019, Julien Nadeau Carriere ([email protected]) -- -- Copyright (c) 2010, coreland ([email protected]) -- -- -- -- Permission to use, copy, modify, and/or distribute this software for any -- -- purpose with or without fee is hereby granted, provided that the above -- -- copyright notice and this permission notice appear in all copies. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -- ------------------------------------------------------------------------------ package body Agar.Error is function Get_Error return String is begin return C.To_Ada (CS.Value (AG_GetError)); end; procedure Set_Error (Message : in String) is Ch_Message : aliased C.char_array := C.To_C (Message); begin AG_SetErrorS (Message => CS.To_Chars_Ptr (Ch_Message'Unchecked_Access)); end; procedure Fatal_Error (Message : in String) is Ch_Message : aliased C.char_array := C.To_C (Message); begin AG_FatalError (Message => CS.To_Chars_Ptr (Ch_Message'Unchecked_Access)); end; -- -- Proxy procedure to call error callback from C code. -- Error_Callback_Fn : Error_Callback_Access := null; procedure Error_Callback_Proxy (Message : CS.chars_ptr) with Convention => C; procedure Error_Callback_Proxy (Message : CS.chars_ptr) is begin if Error_Callback_Fn /= null then Error_Callback_Fn.all (C.To_Ada (CS.Value (Message))); end if; end; procedure Set_Fatal_Callback (Callback : Error_Callback_Access) is begin Error_Callback_Fn := Callback; AG_SetFatalCallback (Error_Callback_Proxy'Access); end; end Agar.Error;
reznikmm/matreshka
Ada
4,363
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ -- A create link action is a write link action for creating links. ------------------------------------------------------------------------------ limited with AMF.UML.Link_End_Creation_Datas.Collections; with AMF.UML.Write_Link_Actions; package AMF.UML.Create_Link_Actions is pragma Preelaborate; type UML_Create_Link_Action is limited interface and AMF.UML.Write_Link_Actions.UML_Write_Link_Action; type UML_Create_Link_Action_Access is access all UML_Create_Link_Action'Class; for UML_Create_Link_Action_Access'Storage_Size use 0; not overriding function Get_End_Data (Self : not null access constant UML_Create_Link_Action) return AMF.UML.Link_End_Creation_Datas.Collections.Set_Of_UML_Link_End_Creation_Data is abstract; -- Getter of CreateLinkAction::endData. -- -- Specifies ends of association and inputs. end AMF.UML.Create_Link_Actions;
reznikmm/matreshka
Ada
8,001
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- This file is generated, don't edit it. ------------------------------------------------------------------------------ -- A delegation connector is a connector that links the external contract of -- a component (as specified by its ports) to the realization of that -- behavior. It represents the forwarding of events (operation requests and -- events): a signal that arrives at a port that has a delegation connector -- to one or more parts or ports on parts will be passed on to those targets -- for handling. An assembly connector is a connector between two or more -- parts or ports on parts that defines that one or more parts provide the -- services that other parts use. -- -- Specifies a link that enables communication between two or more instances. -- This link may be an instance of an association, or it may represent the -- possibility of the instances being able to communicate because their -- identities are known by virtue of being passed in as parameters, held in -- variables or slots, or because the communicating instances are the same -- instance. The link may be realized by something as simple as a pointer or -- by something as complex as a network connection. In contrast to -- associations, which specify links between any instance of the associated -- classifiers, connectors specify links between instances playing the -- connected parts only. ------------------------------------------------------------------------------ limited with AMF.UML.Associations; limited with AMF.UML.Behaviors.Collections; limited with AMF.UML.Connector_Ends.Collections; limited with AMF.UML.Connectors.Collections; with AMF.UML.Features; package AMF.UML.Connectors is pragma Preelaborate; type UML_Connector is limited interface and AMF.UML.Features.UML_Feature; type UML_Connector_Access is access all UML_Connector'Class; for UML_Connector_Access'Storage_Size use 0; not overriding function Get_Contract (Self : not null access constant UML_Connector) return AMF.UML.Behaviors.Collections.Set_Of_UML_Behavior is abstract; -- Getter of Connector::contract. -- -- The set of Behaviors that specify the valid interaction patterns across -- the connector. not overriding function Get_End (Self : not null access constant UML_Connector) return AMF.UML.Connector_Ends.Collections.Ordered_Set_Of_UML_Connector_End is abstract; -- Getter of Connector::end. -- -- A connector consists of at least two connector ends, each representing -- the participation of instances of the classifiers typing the -- connectable elements attached to this end. The set of connector ends is -- ordered. not overriding function Get_Kind (Self : not null access constant UML_Connector) return AMF.UML.UML_Connector_Kind is abstract; -- Getter of Connector::kind. -- -- Indicates the kind of connector. This is derived: a connector with one -- or more ends connected to a Port which is not on a Part and which is -- not a behavior port is a delegation; otherwise it is an assembly. not overriding function Get_Redefined_Connector (Self : not null access constant UML_Connector) return AMF.UML.Connectors.Collections.Set_Of_UML_Connector is abstract; -- Getter of Connector::redefinedConnector. -- -- A connector may be redefined when its containing classifier is -- specialized. The redefining connector may have a type that specializes -- the type of the redefined connector. The types of the connector ends of -- the redefining connector may specialize the types of the connector ends -- of the redefined connector. The properties of the connector ends of the -- redefining connector may be replaced. not overriding function Get_Type (Self : not null access constant UML_Connector) return AMF.UML.Associations.UML_Association_Access is abstract; -- Getter of Connector::type. -- -- An optional association that specifies the link corresponding to this -- connector. not overriding procedure Set_Type (Self : not null access UML_Connector; To : AMF.UML.Associations.UML_Association_Access) is abstract; -- Setter of Connector::type. -- -- An optional association that specifies the link corresponding to this -- connector. not overriding function Kind (Self : not null access constant UML_Connector) return AMF.UML.UML_Connector_Kind is abstract; -- Operation Connector::kind. -- -- Missing derivation for Connector::/kind : ConnectorKind end AMF.UML.Connectors;
reznikmm/matreshka
Ada
4,027
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with ODF.DOM.Chart_Symbol_Width_Attributes; package Matreshka.ODF_Chart.Symbol_Width_Attributes is type Chart_Symbol_Width_Attribute_Node is new Matreshka.ODF_Chart.Abstract_Chart_Attribute_Node and ODF.DOM.Chart_Symbol_Width_Attributes.ODF_Chart_Symbol_Width_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Chart_Symbol_Width_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Chart_Symbol_Width_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Chart.Symbol_Width_Attributes;
charlie5/cBound
Ada
635
ads
-- This file is generated by SWIG. Please do *not* modify by hand. -- with gmp_c.a_a_mpz_struct; with Interfaces.C; package gmp_c.mpz_srcptr is -- Item -- subtype Item is gmp_c.a_a_mpz_struct.Pointer; -- Items -- type Items is array (Interfaces.C.size_t range <>) of aliased gmp_c.mpz_srcptr.Item; -- Pointer -- type Pointer is access all gmp_c.mpz_srcptr.Item; -- Pointers -- type Pointers is array (Interfaces.C.size_t range <>) of aliased gmp_c.mpz_srcptr.Pointer; -- Pointer_Pointer -- type Pointer_Pointer is access all gmp_c.mpz_srcptr.Pointer; end gmp_c.mpz_srcptr;
gerr135/ada_composition
Ada
2,094
ads
-- -- This is a "fixed" implementation, as a straight (discriminated) array, no memory management. -- -- Copyright (C) 2018 George Shapovalov <[email protected]> -- -- 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. -- generic package Lists.fixed is type List(Last : Index_Base) is new List_Interface with private; -- Last - last index of array, e.g. 1..2 - last:=2; 4..9 - last:=9; -- first index is Index_Type'First overriding function List_Constant_Reference (Container : aliased in List; Position : Cursor) return Constant_Reference_Type; overriding function List_Constant_Reference (Container : aliased in List; Index : Index_Type) return Constant_Reference_Type; overriding function List_Reference (Container : aliased in out List; Position : Cursor) return Reference_Type; overriding function List_Reference (Container : aliased in out List; Index : Index_Type) return Reference_Type; overriding function Iterate (Container : in List) return Iterator_Interface'Class; private type Element_Array is array (Index_Type range <>) of aliased Element_Type; type List(Last : Index_Base) is new List_Interface with record data : Element_Array(Index_Type'First .. Last); end record; function Has_Element (L : List; Position : Index_Base) return Boolean; -- here we also need to implement Reversible_Iterator interface type Iterator is new Iterator_Interface with record Container : List_Access; Index : Index_Type'Base; end record; overriding function First (Object : Iterator) return Cursor; overriding function Last (Object : Iterator) return Cursor; overriding function Next (Object : Iterator; Position : Cursor) return Cursor; overriding function Previous (Object : Iterator; Position : Cursor) return Cursor; end Lists.fixed;
Fabien-Chouteau/GESTE
Ada
3,550
ads
with GESTE; with GESTE.Maths_Types; with GESTE_Config; pragma Style_Checks (Off); package Game_Assets is Palette : aliased GESTE.Palette_Type := ( 0 => 0, 1 => 12548, 2 => 29519, 3 => 65535, 4 => 59192, 5 => 46291, 6 => 19019, 7 => 50611, 8 => 29812, 9 => 36181, 10 => 44633, 11 => 27170, 12 => 41925, 13 => 39748, 14 => 33475, 15 => 8424, 16 => 27702, 17 => 10602, 18 => 19154, 19 => 29942, 20 => 26784, 21 => 37348, 22 => 39588, 23 => 33188, 24 => 46184, 25 => 23409, 26 => 16608, 27 => 29317, 28 => 39782, 29 => 29188, 30 => 18754, 31 => 12448, 32 => 6275, 33 => 22950, 34 => 37382, 35 => 47977, 36 => 50315, 37 => 45672, 38 => 4194, 39 => 10534, 40 => 35364, 41 => 12418, 42 => 18658, 43 => 8322, 44 => 20802, 45 => 44598, 46 => 52719, 47 => 16579, 48 => 20900, 49 => 12548, 50 => 20739, 51 => 16907, 52 => 20904, 53 => 43529, 54 => 57831, 55 => 8453, 56 => 64168, 57 => 64455, 58 => 64809, 59 => 388, 60 => 4805, 61 => 15328, 62 => 4292, 63 => 34048, 64 => 25885, 65 => 17012, 66 => 23451, 67 => 12548, 68 => 10467, 69 => 24995, 70 => 14626, 71 => 65194, 72 => 31923, 73 => 14370, 74 => 16481, 75 => 30977, 76 => 54286, 77 => 10500, 78 => 34367, 79 => 63488, 80 => 22819, 81 => 26977, 82 => 39521, 83 => 47973, 84 => 54570, 85 => 65056, 86 => 50213, 87 => 10436, 88 => 21164, 89 => 65206, 90 => 44440, 91 => 60686, 92 => 39398, 93 => 8521, 94 => 22205, 95 => 63455, 96 => 23442, 97 => 34199, 98 => 10729, 99 => 54316, 100 => 21558, 101 => 29650, 102 => 59327, 103 => 14862, 104 => 44698, 105 => 65404, 106 => 35462, 107 => 39719, 108 => 44074, 109 => 24964, 110 => 29254, 111 => 11270, 112 => 19590, 113 => 25893, 114 => 840, 115 => 518, 116 => 39753, 117 => 43945, 118 => 48170, 119 => 50346, 120 => 1659, 121 => 1238, 122 => 4979, 123 => 10468, 124 => 18853, 125 => 14661, 126 => 39952, 127 => 35561, 128 => 12548, 129 => 10500, 130 => 18724, 131 => 22916, 132 => 31334, 133 => 27109, 134 => 35527, 135 => 2405, 136 => 518, 137 => 2789, 138 => 14761); type Object_Kind is (Rectangle_Obj, Point_Obj, Ellipse_Obj, Polygon_Obj, Tile_Obj, Text_Obj); type String_Access is access all String; type Object (Kind : Object_Kind := Rectangle_Obj) is record Name : String_Access; Id : Natural; X : GESTE.Maths_Types.Value; Y : GESTE.Maths_Types.Value; Width : GESTE.Maths_Types.Value; Height : GESTE.Maths_Types.Value; Str : String_Access; Tile_Id : GESTE_Config.Tile_Index; end record; type Object_Array is array (Natural range <>) of Object; end Game_Assets;
persan/advent-of-code-2020
Ada
1,551
adb
with Ada.Exceptions; with Ada.Text_IO; use Ada.Text_IO; with Ada.Assertions; with Adventofcode.File_Line_Readers; procedure Adventofcode.Day_5.Main is procedure Test (Pattern : String; Expected : Seat_Id_Type) is Actual : constant Seat_Id_Type := Get_Seat_Id (From => Pattern); begin Ada.Assertions.Assert (Actual = Expected, "Got => " & Actual'Img & ", Expected => " & Expected'Img); exception when E : others => Put_Line (Ada.Exceptions.Exception_Information (E)); end; begin Test ("FBFBBFFRLR", 357); Test ("BFFFBBFRRR", 567); Test ("FFFBBBFRRR", 119); Test ("BBFFBBFRLL", 820); Part_1 : declare Max_Seat_Id_Found : Seat_Id_Type := 0; begin for Line of Adventofcode.File_Line_Readers.Read_Lines ("src/day-5/input") loop if Get_Seat_Id (From => Line) > Max_Seat_Id_Found then Max_Seat_Id_Found := Get_Seat_Id (From => Line); end if; end loop; Put_Line ("Max_Seat_Id_Found=>" & Max_Seat_Id_Found'Img); end Part_1; Part_2 : declare Seats : array (Seat_Id_Type) of Boolean := (others => False); begin for Line of Adventofcode.File_Line_Readers.Read_Lines ("src/day-5/input") loop Seats (Get_Seat_Id (From => Line)) := True; end loop; for I in Seats'First + 1 .. Seats'Last - 1 loop if Seats (I - 1) and then Seats (I + 1) and then (not Seats (I)) then Put_Line ("Free Seat=>" & I'Img); end if; end loop; end Part_2; end Adventofcode.Day_5.Main;
stcarrez/ada-awa
Ada
15,628
adb
----------------------------------------------------------------------- -- awa-components-wikis -- Wiki rendering component -- Copyright (C) 2011, 2012, 2013, 2015, 2016, 2018, 2020, 2021, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Strings; with Ada.Characters.Conversions; with ASF.Contexts.Writer; with ASF.Utils; with Wiki.Documents; with Wiki.Parsers; with Wiki.Helpers; with Wiki.Render.Html; with Wiki.Render.Text; with Wiki.Filters.Html; with Wiki.Filters.TOC; with Wiki.Filters.Autolink; with Wiki.Filters.Variables; with Wiki.Streams.Html; package body AWA.Components.Wikis is WIKI_ATTRIBUTE_NAMES : Util.Strings.String_Set.Set; type Html_Writer_Type is limited new Wiki.Streams.Html.Html_Output_Stream with record Writer : ASF.Contexts.Writer.Response_Writer_Access; end record; overriding procedure Write (Writer : in out Html_Writer_Type; Content : in Wide_Wide_String); -- Write a single character to the string builder. overriding procedure Write (Writer : in out Html_Writer_Type; Char : in Wide_Wide_Character); -- Write an XML attribute within an XML element. -- The attribute value is escaped according to the XML escape rules. overriding procedure Write_Wide_Attribute (Writer : in out Html_Writer_Type; Name : in String; Content : in Unbounded_Wide_Wide_String); -- Write an XML attribute within an XML element. -- The attribute value is escaped according to the XML escape rules. overriding procedure Write_Wide_Attribute (Writer : in out Html_Writer_Type; Name : in String; Content : in Wiki.Strings.WString); -- Start an XML element with the given name. overriding procedure Start_Element (Writer : in out Html_Writer_Type; Name : in String); -- Closes an XML element of the given name. overriding procedure End_Element (Writer : in out Html_Writer_Type; Name : in String); -- Write a text escaping any character as necessary. overriding procedure Write_Wide_Text (Writer : in out Html_Writer_Type; Content : in Wiki.Strings.WString); overriding procedure Write (Writer : in out Html_Writer_Type; Content : in Wiki.Strings.WString) is begin Writer.Writer.Write_Wide_Raw (Content); end Write; -- ------------------------------ -- Write a single character to the string builder. -- ------------------------------ overriding procedure Write (Writer : in out Html_Writer_Type; Char : in Wide_Wide_Character) is begin Writer.Writer.Write_Wide_Char (Char); end Write; -- ------------------------------ -- Write an XML attribute within an XML element. -- The attribute value is escaped according to the XML escape rules. -- ------------------------------ overriding procedure Write_Wide_Attribute (Writer : in out Html_Writer_Type; Name : in String; Content : in Unbounded_Wide_Wide_String) is begin Writer.Writer.Write_Wide_Attribute (Name, Content); end Write_Wide_Attribute; -- ------------------------------ -- Write an XML attribute within an XML element. -- The attribute value is escaped according to the XML escape rules. -- ------------------------------ overriding procedure Write_Wide_Attribute (Writer : in out Html_Writer_Type; Name : in String; Content : in Wiki.Strings.WString) is begin Writer.Writer.Write_Wide_Attribute (Name, Content); end Write_Wide_Attribute; -- ------------------------------ -- Start an XML element with the given name. -- ------------------------------ overriding procedure Start_Element (Writer : in out Html_Writer_Type; Name : in String) is begin Writer.Writer.Start_Element (Name); end Start_Element; -- ------------------------------ -- Closes an XML element of the given name. -- ------------------------------ overriding procedure End_Element (Writer : in out Html_Writer_Type; Name : in String) is begin Writer.Writer.End_Element (Name); end End_Element; -- ------------------------------ -- Write a text escaping any character as necessary. -- ------------------------------ overriding procedure Write_Wide_Text (Writer : in out Html_Writer_Type; Content : in Wiki.Strings.WString) is begin Writer.Writer.Write_Wide_Text (Content); end Write_Wide_Text; -- ------------------------------ -- Get the wiki format style. The format style is obtained from the <b>format</b> -- attribute name. -- ------------------------------ function Get_Wiki_Style (UI : in UIWiki; Context : in Faces_Context'Class) return Wiki.Wiki_Syntax is Format : constant String := UI.Get_Attribute (Name => FORMAT_NAME, Context => Context, Default => "dotclear"); begin if Format in "dotclear" | "FORMAT_DOTCLEAR" then return Wiki.SYNTAX_DOTCLEAR; elsif Format = "google" then return Wiki.SYNTAX_GOOGLE; elsif Format in "phpbb" | "FORMAT_PHPBB" then return Wiki.SYNTAX_PHPBB; elsif Format in "creole" | "FORMAT_CREOLE" then return Wiki.SYNTAX_CREOLE; elsif Format in "markdown" | "FORMAT_MARKDOWN" then return Wiki.SYNTAX_MARKDOWN; elsif Format in "mediawiki" | "FORMAT_MEDIAWIKI" then return Wiki.SYNTAX_MEDIA_WIKI; elsif Format in "html" | "FORMAT_HTML" then return Wiki.SYNTAX_HTML; else return Wiki.SYNTAX_MARKDOWN; end if; end Get_Wiki_Style; -- ------------------------------ -- Get the links renderer that must be used to render image and page links. -- ------------------------------ function Get_Links_Renderer (UI : in UIWiki; Context : in Faces_Context'Class) return Wiki.Render.Links.Link_Renderer_Access is Value : constant Util.Beans.Objects.Object := UI.Get_Attribute (Context, LINKS_NAME); Bean : constant access Util.Beans.Basic.Readonly_Bean'Class := Util.Beans.Objects.To_Bean (Value); begin if Bean = null then return null; elsif not (Bean.all in Link_Renderer_Bean'Class) then return null; else return Link_Renderer_Bean'Class (Bean.all)'Access; end if; end Get_Links_Renderer; -- ------------------------------ -- Get the plugin factory that must be used by the Wiki parser. -- ------------------------------ function Get_Plugin_Factory (UI : in UIWiki; Context : in Faces_Context'Class) return Wiki.Plugins.Plugin_Factory_Access is Value : constant Util.Beans.Objects.Object := UI.Get_Attribute (Context, PLUGINS_NAME); Bean : constant access Util.Beans.Basic.Readonly_Bean'Class := Util.Beans.Objects.To_Bean (Value); begin if Bean = null then return null; elsif not (Bean.all in Wiki.Plugins.Plugin_Factory'Class) then return null; else return Wiki.Plugins.Plugin_Factory'Class (Bean.all)'Access; end if; end Get_Plugin_Factory; -- ------------------------------ -- Returns true if we must render a text content instead of html. -- ------------------------------ function Is_Text (UI : in UIWiki; Context : in Faces_Context'Class) return Boolean is use type Util.Beans.Objects.Object; Output : constant Util.Beans.Objects.Object := UI.Get_Attribute (Context, OUTPUT_NAME); begin if Util.Beans.Objects.Is_Null (Output) then return False; end if; return Output = Util.Beans.Objects.To_Object (String '("text")); end Is_Text; -- ------------------------------ -- Render the wiki text -- ------------------------------ overriding procedure Encode_Begin (UI : in UIWiki; Context : in out Faces_Context'Class) is use ASF.Contexts.Writer; use type Wiki.Render.Links.Link_Renderer_Access; use type Wiki.Plugins.Plugin_Factory_Access; begin if not UI.Is_Rendered (Context) then return; end if; declare Writer : constant Response_Writer_Access := Context.Get_Response_Writer; Doc : Wiki.Documents.Document; TOC : aliased Wiki.Filters.TOC.TOC_Filter; Autolink : aliased Wiki.Filters.Autolink.Autolink_Filter; Filter : aliased Wiki.Filters.Html.Html_Filter_Type; Vars : aliased Wiki.Filters.Variables.Variable_Filter; Format : constant Wiki.Wiki_Syntax := UI.Get_Wiki_Style (Context); Value : constant Util.Beans.Objects.Object := UI.Get_Attribute (Context, VALUE_NAME); Is_Text : constant Boolean := UI.Is_Text (Context); Links : Wiki.Render.Links.Link_Renderer_Access; Plugins : Wiki.Plugins.Plugin_Factory_Access; Engine : Wiki.Parsers.Parser; begin if not Is_Text then Writer.Start_Element ("div"); UI.Render_Attributes (Context, WIKI_ATTRIBUTE_NAMES, Writer); end if; if not Util.Beans.Objects.Is_Empty (Value) then Plugins := UI.Get_Plugin_Factory (Context); if Plugins /= null then Engine.Set_Plugin_Factory (Plugins); end if; Links := UI.Get_Links_Renderer (Context); Engine.Add_Filter (Autolink'Unchecked_Access); Engine.Add_Filter (Vars'Unchecked_Access); Engine.Add_Filter (TOC'Unchecked_Access); Engine.Add_Filter (Filter'Unchecked_Access); Engine.Set_Syntax (Format); Engine.Parse (Util.Beans.Objects.To_String (Value), Doc); if not Is_Text then declare Html : aliased Html_Writer_Type; Renderer : aliased Wiki.Render.Html.Html_Renderer; begin Html.Writer := Writer; if Links /= null then Renderer.Set_Link_Renderer (Links); end if; Renderer.Set_Output_Stream (Html'Unchecked_Access); Renderer.Set_Render_TOC (UI.Get_Attribute (TOC_NAME, Context, False)); Renderer.Render (Doc); end; else declare Html : aliased Html_Writer_Type; Renderer : aliased Wiki.Render.Text.Text_Renderer; begin Html.Writer := Writer; Renderer.Set_Output_Stream (Html'Unchecked_Access); Renderer.Render (Doc); end; end if; end if; if not Is_Text then Writer.End_Element ("div"); end if; end; end Encode_Begin; -- ------------------------------ -- Get the value identified by the name. -- ------------------------------ overriding function Get_Value (From : in Link_Renderer_Bean; Name : in String) return Util.Beans.Objects.Object is begin if Name = IMAGE_PREFIX_ATTR then return Util.Beans.Objects.To_Object (From.Image_Prefix); elsif Name = PAGE_PREFIX_ATTR then return Util.Beans.Objects.To_Object (From.Page_Prefix); else return Util.Beans.Objects.Null_Object; end if; end Get_Value; -- ------------------------------ -- Set the value identified by the name. -- ------------------------------ overriding procedure Set_Value (From : in out Link_Renderer_Bean; Name : in String; Value : in Util.Beans.Objects.Object) is begin if Name = IMAGE_PREFIX_ATTR then From.Image_Prefix := Util.Beans.Objects.To_Unbounded_Wide_Wide_String (Value); elsif Name = PAGE_PREFIX_ATTR then From.Page_Prefix := Util.Beans.Objects.To_Unbounded_Wide_Wide_String (Value); end if; end Set_Value; function Starts_With (Content : in Unbounded_Wide_Wide_String; Item : in String) return Boolean is use Ada.Characters.Conversions; Pos : Positive := 1; begin if Length (Content) < Item'Length then return False; end if; for I in Item'Range loop if Item (I) /= To_Character (Element (Content, Pos)) then return False; end if; Pos := Pos + 1; end loop; return True; end Starts_With; procedure Make_Link (Renderer : in Link_Renderer_Bean; Link : in Wiki.Strings.WString; Prefix : in Unbounded_Wide_Wide_String; URI : out Unbounded_Wide_Wide_String) is pragma Unreferenced (Renderer); begin if Wiki.Helpers.Is_Url (Link) then URI := To_Unbounded_Wide_Wide_String (Link); else URI := Prefix & Link; end if; end Make_Link; -- ------------------------------ -- Get the image link that must be rendered from the wiki image link. -- ------------------------------ overriding procedure Make_Image_Link (Renderer : in out Link_Renderer_Bean; Link : in Wiki.Strings.WString; URI : out Unbounded_Wide_Wide_String; Width : in out Natural; Height : in out Natural) is begin Renderer.Make_Link (Link, Renderer.Image_Prefix, URI); Width := 0; Height := 0; end Make_Image_Link; -- ------------------------------ -- Get the page link that must be rendered from the wiki page link. -- ------------------------------ overriding procedure Make_Page_Link (Renderer : in out Link_Renderer_Bean; Link : in Wiki.Strings.WString; URI : out Unbounded_Wide_Wide_String; Exists : out Boolean) is begin Renderer.Make_Link (Link, Renderer.Page_Prefix, URI); Exists := True; end Make_Page_Link; begin ASF.Utils.Set_Text_Attributes (WIKI_ATTRIBUTE_NAMES); end AWA.Components.Wikis;
zhmu/ananas
Ada
453
ads
pragma SPARK_Mode; package Allocator2 is type Nat_Array is array (Positive range <>) of Natural with Default_Component_Value => 0; type Nat_Stack (Max : Natural) is record Content : Nat_Array (1 .. Max); end record; type Stack_Acc is access Nat_Stack; type My_Rec is private; private type My_Rec is record My_Stack : Stack_Acc := new Nat_Stack (Max => 10); end record; procedure Dummy; end Allocator2;
reznikmm/matreshka
Ada
8,332
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with League.Holders; with League.Strings; with AMF.CMOF.Associations; with AMF.CMOF.Classes; with AMF.CMOF.Data_Types; with AMF.CMOF.Packages.Collections; with AMF.Elements; with AMF.Links; package AMF.Factories is pragma Preelaborate; type Factory is limited interface; type Factory_Access is access all Factory'Class; not overriding function Create (Self : not null access Factory; Meta_Class : not null access AMF.CMOF.Classes.CMOF_Class'Class) return not null AMF.Elements.Element_Access is abstract; -- Creates an element that is an instance of the metaClass. -- Object::metaClass == metaClass and metaClass.isInstance(object) == true. -- -- All properties of the element are considered unset. The values are the -- same as if object.unset(property) was invoked for every property. -- -- Returns null if the creation cannot be performed. Classes with abstract -- = true always return null. -- -- The created element’s metaClass == metaClass. -- -- Exception: NullPointerException if class is null. -- -- Exception: IllegalArgumentException if class is not a member of the -- package returned by getPackage(). -- -- Constraints -- -- The following conditions on metaClass: Class and all its Properties must -- be satisfied before the metaClass: Class can be instantiated. If these -- requirements are not met, create() throws exceptions as described above. -- -- [1] Meta object must be set. -- -- [2] Name must be 1 or more characters. -- -- [3] Property type must be set. -- -- [4] Property: 0 <= LowerBound <= UpperBound required. -- -- [5] Property: 1 <= UpperBound required. -- -- [6] Enforcement of read-only properties is optional in EMOF. -- -- [8] Properties of type Class cannot have defaults. -- -- [9] Multivalued properties cannot have defaults. -- -- [10] Property: Container end must not have upperBound >1, a property can -- only be contained in one container. -- -- [11] Property: Only one end may be composite. -- -- [12] Property: Bidirectional opposite ends must reference each other. -- -- [13] Property and DataType: Default value must match type. Items 3-13 -- apply to all Properties of the Class. -- -- These conditions also apply to all superclasses of the class being -- instantiated. not overriding function Create_Link (Self : not null access Factory; Association : not null access AMF.CMOF.Associations.CMOF_Association'Class; First_Element : not null AMF.Elements.Element_Access; Second_Element : not null AMF.Elements.Element_Access) return not null AMF.Links.Link_Access is abstract; procedure Create_Link (Self : not null access Factory'Class; Association : not null access AMF.CMOF.Associations.CMOF_Association'Class; First_Element : not null AMF.Elements.Element_Access; Second_Element : not null AMF.Elements.Element_Access); -- This creates a Link from 2 supplied Elements that is an instance of the -- supplied Association. The firstElement is associated with the first end -- (the properties comprising the association ends are ordered) and must -- conform to its type. And correspondingly for the secondElement. not overriding function Create_From_String (Self : not null access Factory; Data_Type : not null access AMF.CMOF.Data_Types.CMOF_Data_Type'Class; Image : League.Strings.Universal_String) return League.Holders.Holder is abstract; -- Creates an Object initialized from the value of the String. Returns null -- if the creation cannot be performed. -- -- The format of the String is defined by the XML Schema SimpleType -- corresponding to that datatype. -- -- Exception: NullPointerException if datatype is null. -- -- Exception: IllegalArgumentException if datatype is not a member of the -- package returned by getPackage(). not overriding function Convert_To_String (Self : not null access Factory; Data_Type : not null access AMF.CMOF.Data_Types.CMOF_Data_Type'Class; Value : League.Holders.Holder) return League.Strings.Universal_String is abstract; -- Creates a String representation of the object. Returns null if the -- creation cannot be performed. The format of the String is defined by the -- XML Schema SimpleType corresponding to that dataType. -- -- Exception: IllegalArgumentException if datatype is not a member of the -- package returned by getPackage() or the supplied object is not a valid -- instance of that datatype. not overriding function Get_Package (Self : not null access constant Factory) return AMF.CMOF.Packages.Collections.Set_Of_CMOF_Package is abstract; -- Returns the package this is a factory for. end AMF.Factories;
strenkml/EE368
Ada
22,220
adb
with Ada.Unchecked_Deallocation; with Ada.Assertions; use Ada.Assertions; with Device; use Device; with BRAM; with CACTI; with Random_Enum; package body Memory.Cache is MIN_LINE_COUNT : constant := 16; procedure Free is new Ada.Unchecked_Deallocation(Cache_Data, Cache_Data_Pointer); function Create_Cache(mem : access Memory_Type'Class; line_count : Positive := 1; line_size : Positive := 8; associativity : Positive := 1; latency : Time_Type := 1; policy : Policy_Type := LRU; write_back : Boolean := True) return Cache_Pointer is result : constant Cache_Pointer := new Cache_Type; begin Set_Memory(result.all, mem); result.line_size := line_size; result.line_count := line_count; result.associativity := associativity; result.latency := latency; result.policy := policy; result.write_back := write_back; result.data.Set_Length(Count_Type(result.line_count)); for i in 0 .. result.line_count - 1 loop result.data.Replace_Element(i, new Cache_Data); end loop; return result; end Create_Cache; function Random_Policy is new Random_Enum(Policy_Type); function Random_Boolean is new Random_Enum(Boolean); -- Set the latency based on associativity. procedure Update_Latency(mem : in out Cache_Type'Class) is begin if Get_Device = ASIC then mem.latency := CACTI.Get_Time(mem); else case mem.policy is when PLRU => mem.latency := 3 + Time_Type(mem.associativity) / 8; when others => mem.latency := 3 + Time_Type(mem.associativity) / 4; end case; end if; end Update_Latency; function Random_Cache(next : access Memory_Type'Class; generator : Distribution_Type; max_cost : Cost_Type) return Memory_Pointer is result : Cache_Pointer := new Cache_Type; begin -- Start with everything set to the minimum. Set_Memory(result.all, next); result.line_size := Get_Word_Size(next.all); result.line_count := MIN_LINE_COUNT; result.associativity := 1; result.policy := LRU; result.write_back := True; -- If even the minimum cache is too costly, return null. if Get_Cost(result.all) > max_cost then Set_Memory(result.all, null); Destroy(Memory_Pointer(result)); return Memory_Pointer(next); end if; -- Randomly increase parameters, reverting them if we exceed the cost. loop -- Line size. declare line_size : constant Positive := result.line_size; begin if Random_Boolean(Random(generator)) then result.line_size := line_size * 2; if Get_Cost(result.all) > max_cost then result.line_size := line_size; exit; end if; end if; end; -- Line count. declare line_count : constant Positive := result.line_count; begin if Random_Boolean(Random(generator)) then result.line_count := 2 * line_count; if Get_Cost(result.all) > max_cost then result.line_count := line_count; exit; end if; end if; end; -- Associativity. declare associativity : constant Positive := result.associativity; begin if Random_Boolean(Random(generator)) then result.associativity := result.associativity * 2; if result.associativity > result.line_count or else Get_Cost(result.all) > max_cost then result.associativity := associativity; exit; end if; end if; end; -- Policy. declare policy : constant Policy_Type := result.policy; begin result.policy := Random_Policy(Random(generator)); if Get_Cost(result.all) > max_cost then result.policy := policy; exit; end if; end; -- Type. declare write_back : constant Boolean := result.write_back; begin result.write_back := Random_Boolean(Random(generator)); if Get_Cost(result.all) > max_cost then result.write_back := write_back; exit; end if; end; end loop; Update_Latency(result.all); result.data.Set_Length(Count_Type(result.line_count)); for i in 0 .. result.line_count - 1 loop result.data.Replace_Element(i, new Cache_Data); end loop; return Memory_Pointer(result); end Random_Cache; function Clone(mem : Cache_Type) return Memory_Pointer is result : constant Cache_Pointer := new Cache_Type'(mem); begin return Memory_Pointer(result); end Clone; procedure Permute(mem : in out Cache_Type; generator : in Distribution_Type; max_cost : in Cost_Type) is param_count : constant Natural := 8; param : Natural := Random(generator) mod param_count; line_size : constant Positive := mem.line_size; line_count : constant Positive := mem.line_count; associativity : constant Positive := mem.associativity; policy : constant Policy_Type := mem.policy; write_back : constant Boolean := mem.write_back; begin -- Loop until we either change a parameter or we are unable to -- change any parameter. for i in 1 .. param_count loop case param is when 0 => -- Increase line size mem.line_size := line_size * 2; exit when Get_Cost(mem) <= max_cost; mem.line_size := line_size; when 1 => -- Decrease line size if line_size > Get_Word_Size(Get_Memory(mem).all) then mem.line_size := line_size / 2; exit when Get_Cost(mem) <= max_cost; mem.line_size := line_size; end if; when 2 => -- Increase line count mem.line_count := line_count * 2; exit when Get_Cost(mem) <= max_cost; mem.line_count := line_count; when 3 => -- Decrease line count if line_count > MIN_LINE_COUNT and line_count > associativity then mem.line_count := line_count / 2; exit when Get_Cost(mem) <= max_cost; mem.line_count := line_count; end if; when 4 => -- Increase associativity if associativity < line_count then mem.associativity := associativity * 2; exit when Get_Cost(mem) <= max_cost; mem.associativity := associativity; end if; when 5 => -- Decrease associativity if associativity > 1 then mem.associativity := associativity / 2; exit when Get_Cost(mem) <= max_cost; mem.associativity := associativity; end if; when 6 => -- Change policy mem.policy := Random_Policy(Random(generator)); exit when Get_Cost(mem) <= max_cost; mem.policy := policy; when others => -- Change type mem.write_back := Random_Boolean(Random(generator)); exit when Get_Cost(mem) <= max_cost; mem.write_back := write_back; end case; param := (param + 1) mod param_count; end loop; Update_Latency(mem); for i in mem.line_count .. mem.data.Last_Index loop declare dp : Cache_Data_Pointer := mem.data.Element(i); begin Free(dp); end; end loop; mem.data.Set_Length(Count_Type(mem.line_count)); for i in line_count .. mem.line_count - 1 loop mem.data.Replace_Element(i, new Cache_Data); end loop; Assert(Get_Cost(mem) <= max_cost, "Invalid cache permutation"); end Permute; procedure Get_Data(mem : in out Cache_Type; address : in Address_Type; size : in Positive; is_read : in Boolean) is data : Cache_Data_Pointer; mask : constant Address_Type := Address_Type(mem.line_size - 1); tag : constant Address_Type := address and not mask; set_count : constant Natural := mem.line_count / mem.associativity; line_size : constant Address_Type := Address_Type(mem.line_size); word_addr : constant Address_Type := address / line_size; first : constant Natural := Natural(word_addr mod Address_Type(set_count)); line : Natural; to_replace : Natural := 0; age : Long_Integer; age_sum : Natural; begin Advance(mem, mem.latency); -- Update the age of all items in this set. age_sum := 0; for i in 0 .. mem.associativity - 1 loop line := first + i * set_count; data := mem.data.Element(line); if mem.policy = PLRU then age_sum := age_sum + Natural(data.age); else data.age := data.age + 1; Assert(data.age > 0, "invalid age"); end if; end loop; -- First check if this address is already in the cache. -- Here we also keep track of the line to be replaced. if mem.policy = MRU then age := Long_Integer'Last; else age := Long_Integer'First; end if; for i in 0 .. mem.associativity - 1 loop line := first + i * set_count; data := mem.data.Element(line); if tag = data.address then -- Cache hit. if mem.policy = PLRU then -- Reset ages to 0 if we marked all of them. if age_sum + 1 = mem.associativity then for j in 0 .. mem.associativity - 1 loop declare temp : Cache_Data_Pointer; begin temp := mem.data.Element(first + j * set_count); temp.age := 0; end; end loop; end if; -- Make this age most recently used. data.age := 1; elsif mem.policy /= FIFO then -- Other policies reset the age to 0. data.age := 0; end if; if is_read or mem.write_back then data.dirty := data.dirty or not is_read; else Write(Container_Type(mem), tag, mem.line_size); end if; return; elsif mem.policy = MRU then if data.age < age then to_replace := line; age := data.age; end if; elsif mem.policy = PLRU then if data.age = 0 then to_replace := line; age := data.age; end if; else if data.age > age then to_replace := line; age := data.age; end if; end if; end loop; -- If we got here, the item is not in the cache. if is_read or mem.write_back then -- Look up the line to replace. data := mem.data.Element(to_replace); -- Evict the oldest entry. -- On write-through caches, the dirty flag will never be set. if data.dirty then Write(Container_Type(mem), data.address, mem.line_size); data.dirty := False; end if; data.address := tag; data.dirty := not is_read; -- Update the age. if mem.policy = PLRU then if age_sum + 1 = mem.associativity then for j in 0 .. mem.associativity - 1 loop declare temp : Cache_Data_Pointer; begin temp := mem.data.Element(first + j * set_count); temp.age := 0; end; end loop; end if; data.age := 1; else data.age := 0; end if; -- Read the new entry. -- We skip this if this was a write that wrote the entire line. if is_read or size /= mem.line_size then Read(Container_Type(mem), tag, mem.line_size); end if; else -- A write on a write-through cache, forward the write. Write(Container_Type(mem), address, size); end if; end Get_Data; procedure Reset(mem : in out Cache_Type; context : in Natural) is data : Cache_Data_Pointer; begin Reset(Container_Type(mem), context); for i in 0 .. mem.line_count - 1 loop data := mem.data.Element(i); data.address := Address_Type'Last; data.age := 0; data.dirty := False; end loop; end Reset; procedure Read(mem : in out Cache_Type; address : in Address_Type; size : in Positive) is extra : constant Natural := size / mem.line_size; abits : constant Positive := Get_Address_Bits; mask : constant Address_Type := Address_Type(2) ** abits - 1; temp : Address_Type := address; begin for i in 1 .. extra loop Get_Data(mem, temp, mem.line_size, True); temp := (temp + Address_Type(mem.line_size)) and mask; end loop; if size > extra * mem.line_size then Get_Data(mem, temp, size - extra * mem.line_size, True); end if; end Read; procedure Write(mem : in out Cache_Type; address : in Address_Type; size : in Positive) is extra : constant Natural := size / mem.line_size; abits : constant Positive := Get_Address_Bits; mask : constant Address_Type := Address_Type(2) ** abits - 1; temp : Address_Type := address; begin for i in 1 .. extra loop Get_Data(mem, temp, mem.line_size, False); temp := (temp + Address_Type(mem.line_size)) and mask; end loop; if size > extra * mem.line_size then Get_Data(mem, temp, size - extra * mem.line_size, False); end if; end Write; function To_String(mem : Cache_Type) return Unbounded_String is result : Unbounded_String; begin Append(result, "(cache "); Append(result, "(line_size" & Positive'Image(mem.line_size) & ")"); Append(result, "(line_count" & Positive'Image(mem.line_count) & ")"); Append(result, "(associativity" & Positive'Image(mem.associativity) & ")"); Append(result, "(latency" & Time_Type'Image(mem.latency) & ")"); if mem.associativity > 1 then Append(result, "(policy "); case mem.policy is when LRU => Append(result, "lru"); when MRU => Append(result, "mru"); when FIFO => Append(result, "fifo"); when PLRU => Append(result, "plru"); end case; Append(result, ")"); end if; if mem.write_back then Append(result, "(write_back true)"); else Append(result, "(write_back false)"); end if; Append(result, "(memory "); Append(result, To_String(Container_Type(mem))); Append(result, "))"); return result; end To_String; function Get_Cost(mem : Cache_Type) return Cost_Type is -- Bits per line for storing data. lines : constant Natural := mem.line_count; lsize : constant Natural := mem.line_size; line_bits : constant Natural := lsize * 8; -- Bits to store a tag. addr_bits : constant Positive := Get_Address_Bits; wsize : constant Positive := Get_Word_Size(mem); index_bits : constant Natural := Log2(lines - 1); line_words : constant Natural := (lsize + wsize - 1) / wsize; ls_bits : constant Natural := Log2(line_words - 1); tag_bits : constant Natural := addr_bits - index_bits - ls_bits; -- Bits to store the age. assoc : constant Positive := mem.associativity; -- Bits used for storing valid and dirty. valid_bits : constant Natural := 1; dirty_bits : constant Natural := 1; -- Bits per way. This is the width of the memory. width : Natural := valid_bits + line_bits + tag_bits; result : Cost_Type; begin -- Use CACTI to determine the cost for ASICs. if Get_Device = ASIC then result := Get_Cost(Container_Type(mem)); result := result + CACTI.Get_Area(mem); return result; end if; -- Determine the number of age bits. if assoc > 1 then case mem.policy is when PLRU => width := width + 1; when others => width := width + Log2(assoc - 1); end case; end if; -- If this cache is a write-back cache, we need to track a dirty -- bit for each cache line. if mem.write_back then width := width + dirty_bits; end if; -- The memory must be wide enough to allow access to each way. width := width * assoc; -- Given the width and depth of the cache, determine the number -- of BRAMs required. result := Cost_Type(BRAM.Get_Count(width, lines / assoc)); -- Add the cost of the contained memory. result := result + Get_Cost(Container_Type(mem)); return result; end Get_Cost; procedure Generate(mem : in Cache_Type; sigs : in out Unbounded_String; code : in out Unbounded_String) is other : constant Memory_Pointer := Get_Memory(mem); word_bits: constant Natural := 8 * Get_Word_Size(mem); name : constant String := "m" & To_String(Get_ID(mem)); oname : constant String := "m" & To_String(Get_ID(other.all)); lsize : constant Positive := 8 * mem.line_size / word_bits; lcount : constant Positive := mem.line_count; assoc : constant Natural := mem.associativity; begin Generate(other.all, sigs, code); Declare_Signals(sigs, name, word_bits); Line(code, name & "_inst : entity work.cache"); Line(code, " generic map ("); Line(code, " ADDR_WIDTH => ADDR_WIDTH,"); Line(code, " WORD_WIDTH => " & To_String(word_bits) & ","); Line(code, " LINE_SIZE_BITS => " & To_String(Log2(lsize - 1)) & ","); Line(code, " LINE_COUNT_BITS => " & To_String(Log2(lcount / assoc - 1)) & ","); Line(code, " ASSOC_BITS => " & To_String(Log2(assoc - 1)) & ","); case mem.policy is when LRU => Line(code, " REPLACEMENT => 0,"); when MRU => Line(code, " REPLACEMENT => 1,"); when FIFO => Line(code, " REPLACEMENT => 2,"); when PLRU => Line(code, " REPLACEMENT => 3,"); end case; if mem.write_back then Line(code, " WRITE_POLICY => 0"); else Line(code, " WRITE_POLICY => 1"); end if; Line(code, " )"); Line(code, " port map ("); Line(code, " clk => clk,"); Line(code, " rst => rst,"); Line(code, " addr => " & name & "_addr,"); Line(code, " din => " & name & "_din,"); Line(code, " dout => " & name & "_dout,"); Line(code, " re => " & name & "_re,"); Line(code, " we => " & name & "_we,"); Line(code, " mask => " & name & "_mask,"); Line(code, " ready => " & name & "_ready,"); Line(code, " maddr => " & oname & "_addr,"); Line(code, " min => " & oname & "_dout,"); Line(code, " mout => " & oname & "_din,"); Line(code, " mre => " & oname & "_re,"); Line(code, " mwe => " & oname & "_we,"); Line(code, " mmask => " & oname & "_mask,"); Line(code, " mready => " & oname & "_ready"); Line(code, " );"); end Generate; procedure Adjust(mem : in out Cache_Type) is ptr : Cache_Data_Pointer; begin Adjust(Container_Type(mem)); for i in mem.data.First_Index .. mem.data.Last_Index loop ptr := new Cache_Data'(mem.data.Element(i).all); mem.data.Replace_Element(i, ptr); end loop; end Adjust; procedure Finalize(mem : in out Cache_Type) is begin Finalize(Container_Type(mem)); for i in mem.data.First_Index .. mem.data.Last_Index loop declare ptr : Cache_Data_Pointer := mem.data.Element(i); begin Free(ptr); end; end loop; end Finalize; function Get_Line_Size(mem : Cache_Type) return Positive is begin return mem.line_size; end Get_Line_Size; function Get_Line_Count(mem : Cache_Type) return Positive is begin return mem.line_count; end Get_Line_Count; function Get_Associativity(mem : Cache_Type) return Positive is begin return mem.associativity; end Get_Associativity; function Get_Policy(mem : Cache_Type) return Policy_Type is begin return mem.policy; end Get_Policy; end Memory.Cache;
reznikmm/matreshka
Ada
4,639
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Form.Focus_On_Click_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Form_Focus_On_Click_Attribute_Node is begin return Self : Form_Focus_On_Click_Attribute_Node do Matreshka.ODF_Form.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Form_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Form_Focus_On_Click_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Focus_On_Click_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Form_URI, Matreshka.ODF_String_Constants.Focus_On_Click_Attribute, Form_Focus_On_Click_Attribute_Node'Tag); end Matreshka.ODF_Form.Focus_On_Click_Attributes;
AdaCore/ada-traits-containers
Ada
2,693
ads
-- -- Copyright (C) 2015-2016, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception -- -- This package provides a specialization of the Element_Traits package for -- use with indefinite type (i.e. their size might not be known at compile -- time). -- Such elements are returned as reference types, so containers will not -- return the element itself. This is in general more efficient and safer, -- and avoids copying potentially large elements. pragma Ada_2012; generic type Element_Type (<>) is private; with procedure Free (E : in out Element_Type) is null; -- This procedure is called when the element is removed from its -- container. with package Pool is new Conts.Pools (<>); package Conts.Elements.Indefinite is type Element_Access is access all Element_Type; for Element_Access'Storage_Pool use Pool.Pool; type Constant_Reference_Type (Element : not null access constant Element_Type) is null record with Implicit_Dereference => Element; -- ??? Would be nice if we could make this constrained by -- providing a default value for the discriminant, but this is -- illegal. type Reference_Type (Element : not null access Element_Type) is null record with Implicit_Dereference => Element; function To_Element_Access (E : Element_Type) return Element_Access is (new Element_Type'(E)) with Inline; function To_Constant_Ref (E : Element_Access) return Constant_Reference_Type is (Constant_Reference_Type'(Element => E)) with Inline; function To_Element (E : Constant_Reference_Type) return Element_Type is (E.Element.all) with Inline; function To_Ref (E : Element_Access) return Reference_Type is (Reference_Type'(Element => E)) with Inline; function To_Element (E : Reference_Type) return Element_Type is (E.Element.all) with Inline; function Copy (E : Element_Access) return Element_Access is (new Element_Type'(E.all)) with Inline; procedure Release (E : in out Element_Access) with Inline; package Traits is new Conts.Elements.Traits (Element_Type => Element_Type, Stored_Type => Element_Access, Returned_Type => Reference_Type, Constant_Returned_Type => Constant_Reference_Type, To_Stored => To_Element_Access, To_Returned => To_Ref, To_Constant_Returned => To_Constant_Ref, To_Element => To_Element, Copy => Copy, Release => Release, Copyable => False, -- would create aliases Movable => True); end Conts.Elements.Indefinite;
leomlr/sudoku_ada-jewl
Ada
14,783
adb
with JEWL.IO; with ada.Integer_Text_IO; -- Tell compiler to use i/o library with Ada.Strings.Fixed; use ada.Integer_Text_IO; -- Use library routines w/o fully qualified names Package Body sudoku_tools_9 Is -- Function: Show a grid in console. Procedure showGrid (grid: in Matrix_Type) Is Begin Ada.Text_IO.Put_Line("Current Matrix:"); for i in 1..LOOP_LENGTH loop for j in 1..LOOP_LENGTH loop if (grid(i,j) > 64 and grid(i,j) < 72) or (grid(i,j) > 96 and grid(i,j) < 104) then Ada.Text_IO.Put(" " & Character'Val(grid(i,j))); else Ada.Text_IO.Put(Integer'Image(grid(i,j))); end if; if j = BOXES_SIZE or j = 2*BOXES_SIZE or j = 3*BOXES_SIZE then Ada.Text_IO.Put(" "); end if; end loop; if i = BOXES_SIZE or i = 2*BOXES_SIZE or i = 3*BOXES_SIZE then Ada.Text_IO.new_line; end if; Ada.Text_IO.new_line; end loop; Ada.Text_IO.new_line; End showGrid; -- Function: Get grid Line. Function getLine (grid: Matrix_Type; index: in Integer) return List_Type Is list: List_Type; Begin for i in 1..LOOP_LENGTH loop list(i) := grid(index, i); end loop; return list; End getLine; -- Function: Get grid column. Function getColumn (grid: Matrix_Type; index: in Integer) return List_Type Is list: List_Type; Begin for i in 1..LOOP_LENGTH loop list(i) := grid(i, index); end loop; return list; End getColumn; -- Function: Get grid block. Function getBlock (grid: in Matrix_Type; index_i: in Integer; index_j: in Integer) return List_Type Is list: List_Type; index: Integer; start_i: Integer; start_j: Integer; Begin --revoir la formule des getblok pour le 16 index := 1; start_i := (index_i-1)*BOXES_SIZE + 1; start_j := (index_j-1)*BOXES_SIZE + 1; for i in start_i..(start_i + 2) loop for j in start_j..(start_j + 2) loop list(index) := grid(i, j); index := index + 1; end loop; end loop; return list; End getBlock; -- Function: Check a list. Function isValidList (list: in List_Type) return Boolean Is Begin for i in 1..LOOP_LENGTH loop for j in 1..LOOP_LENGTH loop if not (i = j) then if list(i) = list(j) then return False; end if; end if; end loop; end loop; return True; End isValidList; -- Function: Validate a grid; Function isValidGrid (grid: in Matrix_Type) return Boolean Is listToCheck: List_Type; Begin -- Checking Lines for i in 1..LOOP_LENGTH loop listToCheck := getLine(grid, i); if not isValidList(listToCheck) then return False; else Ada.Text_IO.Put_Line("Line " & Integer'Image(i) & " is Ok !"); end if; end loop; -- Checking Columns for i in 1..LOOP_LENGTH loop listToCheck := getColumn(grid, i); if not isValidList(listToCheck) then return False; else Ada.Text_IO.Put_Line("Column " & Integer'Image(i) & " is Ok !"); end if; end loop; -- Checking Blocks for i in 1..BOXES_SIZE loop for j in 1..BOXES_SIZE loop listToCheck := getBlock(grid, i, j); if not isValidList(listToCheck) then return False; else Ada.Text_IO.Put_Line("Block (" & Integer'Image(i) & "," & Integer'Image(j) & ") is Ok !"); end if; end loop; end loop; -- Return True (grid is correct) return True; End isValidGrid; Procedure createGrid (window: in Frame_Type; grid_blocks: out Grid_Block_Type) Is panels: Grid_Panel_Type; Begin for i in 1..BOXES_SIZE loop for j in 1..BOXES_SIZE loop panels(i, j) := Panel (window, (20+(j-1)*BLOCK_WIDTH, 20+(i-1)*BLOCK_WIDTH), BLOCK_WIDTH, BLOCK_WIDTH); -- changer la formule createBlock(panels(i, j), grid_blocks(i, j)); end loop; end loop; End createGrid; Procedure createBlock (panel: in Panel_Type; block: out Block_Editbox_Type) Is Begin for i in 1..BOXES_SIZE loop for j in 1..BOXES_SIZE loop block(i, j) := Editbox (panel, (10+(j-1)*30, 10+(i-1)*30), 20, 20, " 0", False, Font ("Montserrat", 10)); -- changer la formule de recup end loop; end loop; End createBlock; Function getGrid (grid_blocks: in Grid_Block_Type; grid: out Matrix_Type; saving: in Boolean) return Boolean Is block: Block_Editbox_Type; editbox: Editbox_Type; value: Integer; x_index: Integer; y_index: Integer; Begin for i in 1..BOXES_SIZE loop for j in 1..BOXES_SIZE loop for k in 1..BOXES_SIZE loop block := grid_blocks(i, k); for l in 1..BOXES_SIZE loop editbox := block(j, l); x_index := (i-1)*BOXES_SIZE+j; y_index := (k-1)*BOXES_SIZE+l; if isNumeric(Get_Text(editbox)) then value := Integer'Value(Get_Text(editbox)); if not saving then if value /= 0 then grid(x_index, y_index) := value; else return False; end if; else grid(x_index, y_index) := value; end if; else if LOOP_LENGTH = 16 then for i in 1..10 loop value := Character'Pos(Get_Text(editbox)(i)); if value /= 32 then if Get_Text(editbox)'Length > i then if Character'Pos(Get_Text(editbox)(i+1)) /= 32 then return False; end if; end if; exit; end if; end loop; if (value > 64 and value < 72) or (value > 96 and value < 104) then grid(x_index, y_index) := value; else return False; end if; else return False; end if; end if; end loop; end loop; end loop; end loop; return True; End getGrid; Procedure setGrid (grid_blocks: in out Grid_Block_Type; grid: in Matrix_Type; base_filename: in out Unbounded_String) Is block: Block_Editbox_Type; editbox: Editbox_Type; value: Integer; base_grid: Matrix_Type; base_loaded: Boolean := True; Begin if base_filename /= "" then base_loaded := loadBaseMatrix(base_filename, base_grid); end if; if base_loaded then for i in 1..BOXES_SIZE loop for j in 1..BOXES_SIZE loop for k in 1..BOXES_SIZE loop block := grid_blocks(i, k); for l in 1..BOXES_SIZE loop value := grid((i-1)*BOXES_SIZE+j, (k-1)*BOXES_SIZE+l); editbox := block(j, l); if (value > 64 and value < 72) or (value > 96 and value < 104) then Set_Text(editbox, " " & Character'Val(value)); else Set_Text(editbox, Integer'Image(value)); end if; if value /= 0 then if base_filename /= "" then if base_grid((i-1)*BOXES_SIZE+j, (k-1)*BOXES_SIZE+l) /= 0 then Disable(editbox); else Enable(editbox); end if; else Disable(editbox); end if; else Enable(editbox); end if; end loop; end loop; end loop; end loop; end if; End setGrid; Function loadBaseMatrix(base_filename: in out Unbounded_String; grid: out Matrix_Type) return Boolean Is file: Ada.Text_IO.File_Type; open_error: Boolean := False; Begin Begin Ada.Text_IO.Open(file, Ada.Text_IO.IN_FILE, To_String(base_filename)); Exception when others => Ada.Text_IO.Put_Line("Text_IO FileOpeningError: File not found."); open_error := True; End; if not open_error then if fillGrid(readFile(file), grid, base_filename) then Ada.Text_IO.Close(file); return True; end if; end if; return False; End loadBaseMatrix; Function readFile (file: in Ada.Text_IO.File_Type) return Vector Is lines: Vector := Empty_Vector; Begin while not Ada.Text_IO.End_Of_File(file) loop lines.Append(Ada.Text_IO.Get_Line(file)); end loop; return lines; End readFile; Function saveGrid (grid: in Matrix_Type; filename: in String; base_filename: in out Unbounded_String) return Boolean Is file: Ada.Text_IO.File_Type; line: Unbounded_String; Begin Ada.Text_IO.Create(file, Ada.Text_IO.Out_File, filename & ".txt"); Ada.Text_IO.Put_Line(To_String(base_filename)); JEWL.IO.Put_Line(file, To_String(base_filename)); for i in 1..LOOP_LENGTH loop line := To_Unbounded_String(""); for j in 1..LOOP_LENGTH loop if (grid(i,j) > 64 and grid(i,j) < 72) or (grid(i,j) > 96 and grid(i,j) < 104) then line := line & Character'Val(grid(i,j)); else line := line & Integer'Image(grid (i, j))(2); end if; if j /= LOOP_LENGTH then line := line & " "; end if; end loop; JEWL.IO.Put_Line(file, To_String(line)); end loop; Ada.Text_IO.Close(file); return True; End saveGrid; Function split (line: in String; list: out List_Type) return Boolean Is subs : Slice_Set; seps : constant String := " "; index: Integer; value: Integer; item: String (1..1); Begin Ada.Text_IO.Put_Line(line); Create (S => subs, From => line, Separators => seps, Mode => Multiple); for i in 1 .. Slice_Count(subs) loop item := Slice (subs, i); index := Integer'Value(Slice_Number'Image(i)); if isNumeric(item) then value := Integer'Value(item); list(index) := value; else value := Character'Pos(item(1)); if (value > 64 and value < 72) or (value > 96 and value < 104) then list(index) := value; else return False; end if; end if; end loop; return True; End split; Function fillGrid (lines: in vector; grid: out Matrix_Type; base_filename: in out Unbounded_String) return Boolean Is list: List_Type; len: Integer := Integer'Value(Count_Type'Image(lines.Length)); Begin if (len = LOOP_LENGTH + 1) or (len = LOOP_LENGTH + 2) then if (Ada.Strings.Fixed.Index(lines(1), ".txt", 1) > 0) then base_filename := To_Unbounded_String(lines(1)); Ada.Text_IO.Put_Line(To_String(base_filename)); else return False; end if; for i in 1..LOOP_LENGTH loop if split(lines(i+1), list) then for j in 1..LOOP_LENGTH loop grid(i, j) := list(j); end loop; else return False; end if; end loop; else return False; end if; return True; End fillGrid; Function isNumeric (value: in String) return Boolean Is dummy : Float; Begin dummy := Float'Value(value); return True; Exception when others => return False; End isNumeric; End sudoku_tools_9;
AdaCore/libadalang
Ada
191
adb
package body Pack is function My_Fun (I : Integer) return Integer is begin return I + 1; end; My_2 : Integer renames My_Fun (1); --% node.p_is_constant_object end Pack;
zhmu/ananas
Ada
145,285
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- E R R O U T -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2022, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- Warning: Error messages can be generated during Gigi processing by direct -- calls to error message routines, so it is essential that the processing -- in this body be consistent with the requirements for the Gigi processing -- environment, and that in particular, no disallowed table expansion is -- allowed to occur. with Atree; use Atree; with Casing; use Casing; with Csets; use Csets; with Debug; use Debug; with Einfo; use Einfo; with Einfo.Entities; use Einfo.Entities; with Einfo.Utils; use Einfo.Utils; with Erroutc; use Erroutc; with Gnatvsn; use Gnatvsn; with Lib; use Lib; with Opt; use Opt; with Nlists; use Nlists; with Output; use Output; with Scans; use Scans; with Sem_Aux; use Sem_Aux; with Sinput; use Sinput; with Sinfo; use Sinfo; with Sinfo.Nodes; use Sinfo.Nodes; with Sinfo.Utils; use Sinfo.Utils; with Snames; use Snames; with Stand; use Stand; with Stylesw; use Stylesw; with Uname; use Uname; package body Errout is Errors_Must_Be_Ignored : Boolean := False; -- Set to True by procedure Set_Ignore_Errors (True), when calls to error -- message procedures should be ignored (when parsing irrelevant text in -- sources being preprocessed). Finalize_Called : Boolean := False; -- Set True if the Finalize routine has been called Record_Compilation_Errors : Boolean := False; -- Record that a compilation error was witnessed during a given phase of -- analysis for gnat2why. This is needed as Warning_Mode is modified twice -- in gnat2why, hence Erroutc.Compilation_Errors can only return a suitable -- value for each phase of analysis separately. This is updated at each -- call to Compilation_Errors. Warn_On_Instance : Boolean; -- Flag set true for warning message to be posted on instance ------------------------------------ -- Table of Non-Instance Messages -- ------------------------------------ -- This table contains an entry for every error message processed by the -- Error_Msg routine that is not posted on generic (or inlined) instance. -- As explained in further detail in the Error_Msg procedure body, this -- table is used to avoid posting redundant messages on instances. type NIM_Record is record Msg : String_Ptr; Loc : Source_Ptr; end record; -- Type used to store text and location of one message package Non_Instance_Msgs is new Table.Table ( Table_Component_Type => NIM_Record, Table_Index_Type => Int, Table_Low_Bound => 1, Table_Initial => 100, Table_Increment => 100, Table_Name => "Non_Instance_Msgs"); ----------------------- -- Local Subprograms -- ----------------------- procedure Error_Msg_Internal (Msg : String; Span : Source_Span; Opan : Source_Span; Msg_Cont : Boolean; Node : Node_Id); -- This is the low-level routine used to post messages after dealing with -- the issue of messages placed on instantiations (which get broken up -- into separate calls in Error_Msg). Span is the location on which the -- flag will be placed in the output. In the case where the flag is on -- the template, this points directly to the template, not to one of the -- instantiation copies of the template. Opan is the original location -- used to flag the error, and this may indeed point to an instantiation -- copy. So typically we can see Opan pointing to the template location -- in an instantiation copy when Span points to the source location of -- the actual instantiation (i.e the line with the new). Msg_Cont is -- set true if this is a continuation message. Node is the relevant -- Node_Id for this message, to be used to compute the enclosing entity if -- Opt.Include_Subprogram_In_Messages is set. function No_Warnings (N : Node_Or_Entity_Id) return Boolean; -- Determines if warnings should be suppressed for the given node function OK_Node (N : Node_Id) return Boolean; -- Determines if a node is an OK node to place an error message on (return -- True) or if the error message should be suppressed (return False). A -- message is suppressed if the node already has an error posted on it, -- or if it refers to an Etype that has an error posted on it, or if -- it references an Entity that has an error posted on it. procedure Output_JSON_Message (Error_Id : Error_Msg_Id); -- Output error message Error_Id and any subsequent continuation message -- using a JSON format similar to the one GCC uses when passed -- -fdiagnostics-format=json. procedure Output_Source_Line (L : Physical_Line_Number; Sfile : Source_File_Index; Errs : Boolean); -- Outputs text of source line L, in file S, together with preceding line -- number, as described above for Output_Line_Number. The Errs parameter -- indicates if there are errors attached to the line, which forces -- listing on, even in the presence of pragma List (Off). procedure Set_Msg_Insertion_Column; -- Handle column number insertion (@ insertion character) procedure Set_Msg_Insertion_Node; -- Handle node (name from node) insertion (& insertion character) procedure Set_Msg_Insertion_Type_Reference (Flag : Source_Ptr); -- Handle type reference (right brace insertion character). Flag is the -- location of the flag, which is provided for the internal call to -- Set_Msg_Insertion_Line_Number, procedure Set_Msg_Insertion_Unit_Name (Suffix : Boolean := True); -- Handle unit name insertion ($ insertion character). Depending on Boolean -- parameter Suffix, (spec) or (body) is appended after the unit name. procedure Set_Msg_Node (Node : Node_Id); -- Add the sequence of characters for the name associated with the given -- node to the current message. For N_Designator, N_Selected_Component, -- N_Defining_Program_Unit_Name, and N_Expanded_Name, the Prefix is -- included as well. procedure Set_Msg_Text (Text : String; Flag : Source_Ptr); -- Add a sequence of characters to the current message. The characters may -- be one of the special insertion characters (see documentation in spec). -- Flag is the location at which the error is to be posted, which is used -- to determine whether or not the # insertion needs a file name. The -- variables Msg_Buffer are set on return Msglen. procedure Set_Posted (N : Node_Id); -- Sets the Error_Posted flag on the given node, and all its parents that -- are subexpressions and then on the parent non-subexpression construct -- that contains the original expression. If that parent is a named -- association, the flag is further propagated to its parent. This is done -- in order to guard against cascaded errors. Note that this call has an -- effect for a serious error only. procedure Set_Qualification (N : Nat; E : Entity_Id); -- Outputs up to N levels of qualification for the given entity. For -- example, the entity A.B.C.D will output B.C. if N = 2. function Special_Msg_Delete (Msg : String; N : Node_Or_Entity_Id; E : Node_Or_Entity_Id) return Boolean; -- This function is called from Error_Msg_NEL, passing the message Msg, -- node N on which the error is to be posted, and the entity or node E -- to be used for an & insertion in the message if any. The job of this -- procedure is to test for certain cascaded messages that we would like -- to suppress. If the message is to be suppressed then we return True. -- If the message should be generated (the normal case) False is returned. procedure Unwind_Internal_Type (Ent : in out Entity_Id); -- This procedure is given an entity id for an internal type, i.e. a type -- with an internal name. It unwinds the type to try to get to something -- reasonably printable, generating prefixes like "subtype of", "access -- to", etc along the way in the buffer. The value in Ent on return is the -- final name to be printed. Hopefully this is not an internal name, but in -- some internal name cases, it is an internal name, and has to be printed -- anyway (although in this case the message has been killed if possible). -- The global variable Class_Flag is set to True if the resulting entity -- should have 'Class appended to its name (see Add_Class procedure), and -- is otherwise unchanged. function Warn_Insertion return String; -- This is called for warning messages only (so Warning_Msg_Char is set) -- and returns a corresponding string to use at the beginning of generated -- auxiliary messages, such as "in instantiation at ...". -- "?" returns "??" -- " " returns "?" -- other trimmed, prefixed and suffixed with "?". ----------------------- -- Change_Error_Text -- ----------------------- procedure Change_Error_Text (Error_Id : Error_Msg_Id; New_Msg : String) is Save_Next : Error_Msg_Id; Err_Id : Error_Msg_Id := Error_Id; begin Set_Msg_Text (New_Msg, Errors.Table (Error_Id).Sptr.Ptr); Errors.Table (Error_Id).Text := new String'(Msg_Buffer (1 .. Msglen)); -- If in immediate error message mode, output modified error message now -- This is just a bit tricky, because we want to output just a single -- message, and the messages we modified is already linked in. We solve -- this by temporarily resetting its forward pointer to empty. if Debug_Flag_OO then Save_Next := Errors.Table (Error_Id).Next; Errors.Table (Error_Id).Next := No_Error_Msg; Write_Eol; Output_Source_Line (Errors.Table (Error_Id).Line, Errors.Table (Error_Id).Sfile, True); Output_Error_Msgs (Err_Id); Errors.Table (Error_Id).Next := Save_Next; end if; end Change_Error_Text; ------------------------ -- Compilation_Errors -- ------------------------ function Compilation_Errors return Boolean is begin if not Finalize_Called then raise Program_Error; -- Record that a compilation error was witnessed during a given phase of -- analysis for gnat2why. This is needed as Warning_Mode is modified -- twice in gnat2why, hence Erroutc.Compilation_Errors can only return a -- suitable value for each phase of analysis separately. else Record_Compilation_Errors := Record_Compilation_Errors or else Erroutc.Compilation_Errors; return Record_Compilation_Errors; end if; end Compilation_Errors; -------------------------------------- -- Delete_Warning_And_Continuations -- -------------------------------------- procedure Delete_Warning_And_Continuations (Msg : Error_Msg_Id) is Id : Error_Msg_Id; begin pragma Assert (not Errors.Table (Msg).Msg_Cont); Id := Msg; loop declare M : Error_Msg_Object renames Errors.Table (Id); begin if not M.Deleted then M.Deleted := True; Warnings_Detected := Warnings_Detected - 1; if M.Info then Warning_Info_Messages := Warning_Info_Messages - 1; end if; if M.Warn_Err then Warnings_Treated_As_Errors := Warnings_Treated_As_Errors - 1; end if; end if; Id := M.Next; exit when Id = No_Error_Msg; exit when not Errors.Table (Id).Msg_Cont; end; end loop; end Delete_Warning_And_Continuations; --------------- -- Error_Msg -- --------------- -- Error_Msg posts a flag at the given location, except that if the -- Flag_Location/Flag_Span points within a generic template and corresponds -- to an instantiation of this generic template, then the actual message -- will be posted on the generic instantiation, along with additional -- messages referencing the generic declaration. procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr) is begin Error_Msg (Msg, To_Span (Flag_Location), Current_Node); end Error_Msg; procedure Error_Msg (Msg : String; Flag_Span : Source_Span) is begin Error_Msg (Msg, Flag_Span, Current_Node); end Error_Msg; procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr; Is_Compile_Time_Pragma : Boolean) is Save_Is_Compile_Time_Msg : constant Boolean := Is_Compile_Time_Msg; begin Is_Compile_Time_Msg := Is_Compile_Time_Pragma; Error_Msg (Msg, To_Span (Flag_Location), Current_Node); Is_Compile_Time_Msg := Save_Is_Compile_Time_Msg; end Error_Msg; procedure Error_Msg (Msg : String; Flag_Location : Source_Ptr; N : Node_Id) is begin Error_Msg (Msg, To_Span (Flag_Location), N); end Error_Msg; procedure Error_Msg (Msg : String; Flag_Span : Source_Span; N : Node_Id) is Flag_Location : constant Source_Ptr := Flag_Span.Ptr; Sindex : Source_File_Index; -- Source index for flag location Orig_Loc : Source_Ptr; -- Original location of Flag_Location (i.e. location in original -- template in instantiation case, otherwise unchanged). begin -- Return if all errors are to be ignored if Get_Ignore_Errors then return; end if; -- If we already have messages, and we are trying to place a message at -- No_Location, then just ignore the attempt since we assume that what -- is happening is some cascaded junk. Note that this is safe in the -- sense that proceeding will surely bomb. We will also bomb if the flag -- location is No_Location and we don't have any messages so far, but -- that is a real bug and a legitimate bomb, so we go ahead. if Flag_Location = No_Location and then Total_Errors_Detected > 0 then return; end if; -- Start of processing for new message Sindex := Get_Source_File_Index (Flag_Location); Prescan_Message (Msg); Orig_Loc := Original_Location (Flag_Location); -- If the current location is in an instantiation, the issue arises of -- whether to post the message on the template or the instantiation. -- The way we decide is to see if we have posted the same message on -- the template when we compiled the template (the template is always -- compiled before any instantiations). For this purpose, we use a -- separate table of messages. The reason we do this is twofold: -- First, the messages can get changed by various processing -- including the insertion of tokens etc, making it hard to -- do the comparison. -- Second, we will suppress a warning on a template if it is not in -- the current extended source unit. That's reasonable and means we -- don't want the warning on the instantiation here either, but it -- does mean that the main error table would not in any case include -- the message. if Flag_Location = Orig_Loc then Non_Instance_Msgs.Append ((new String'(Msg), Flag_Location)); Warn_On_Instance := False; -- Here we have an instance message else -- Delete if debug flag off, and this message duplicates a message -- already posted on the corresponding template if not Debug_Flag_GG then for J in Non_Instance_Msgs.First .. Non_Instance_Msgs.Last loop if Msg = Non_Instance_Msgs.Table (J).Msg.all and then Non_Instance_Msgs.Table (J).Loc = Orig_Loc then return; end if; end loop; end if; -- No duplicate, so error/warning will be posted on instance Warn_On_Instance := Is_Warning_Msg; end if; -- Ignore warning message that is suppressed for this location. Note -- that style checks are not considered warning messages for this -- purpose. if Is_Warning_Msg and then Warnings_Suppressed (Orig_Loc) /= No_String then return; -- For style messages, check too many messages so far elsif Is_Style_Msg and then Maximum_Messages /= 0 and then Warnings_Detected >= Maximum_Messages then return; -- Suppress warnings inside a loop that is known to be null or is -- probably null (i.e. when loop executes only if invalid values -- present). In either case warnings in the loop are likely to be junk. elsif Is_Warning_Msg and then Present (N) then declare P : Node_Id; begin P := Parent (N); while Present (P) loop if Nkind (P) = N_Loop_Statement and then Suppress_Loop_Warnings (P) then return; end if; P := Parent (P); end loop; end; end if; -- The idea at this stage is that we have two kinds of messages -- First, we have those messages that are to be placed as requested at -- Flag_Location. This includes messages that have nothing to do with -- generics, and also messages placed on generic templates that reflect -- an error in the template itself. For such messages we simply call -- Error_Msg_Internal to place the message in the requested location. if Instantiation (Sindex) = No_Location then Error_Msg_Internal (Msg, Flag_Span, Flag_Span, False, N); return; end if; -- If we are trying to flag an error in an instantiation, we may have -- a generic contract violation. What we generate in this case is: -- instantiation error at ... -- original error message -- or -- warning: in instantiation at ... -- warning: original warning message -- or -- info: in instantiation at ... -- info: original info message -- All these messages are posted at the location of the top level -- instantiation. If there are nested instantiations, then the -- instantiation error message can be repeated, pointing to each -- of the relevant instantiations. -- Note: the instantiation mechanism is also shared for inlining of -- subprogram bodies when front end inlining is done. In this case the -- messages have the form: -- in inlined body at ... -- original error message -- or -- warning: in inlined body at ... -- warning: original warning message -- or -- info: in inlined body at ... -- info: original info message -- OK, here we have an instantiation error, and we need to generate the -- error on the instantiation, rather than on the template. declare Actual_Error_Loc : Source_Ptr; -- Location of outer level instantiation in instantiation case, or -- just a copy of Flag_Location in the normal case. This is the -- location where all error messages will actually be posted. Save_Error_Msg_Sloc : constant Source_Ptr := Error_Msg_Sloc; -- Save possible location set for caller's message. We need to use -- Error_Msg_Sloc for the location of the instantiation error but we -- have to preserve a possible original value. X : Source_File_Index; Msg_Cont_Status : Boolean; -- Used to label continuation lines in instantiation case with -- proper Msg_Cont status. begin -- Loop to find highest level instantiation, where all error -- messages will be placed. X := Sindex; loop Actual_Error_Loc := Instantiation (X); X := Get_Source_File_Index (Actual_Error_Loc); exit when Instantiation (X) = No_Location; end loop; -- Since we are generating the messages at the instantiation point in -- any case, we do not want the references to the bad lines in the -- instance to be annotated with the location of the instantiation. Suppress_Instance_Location := True; Msg_Cont_Status := False; -- Loop to generate instantiation messages Error_Msg_Sloc := Flag_Location; X := Get_Source_File_Index (Flag_Location); while Instantiation (X) /= No_Location loop -- Suppress instantiation message on continuation lines if Msg (Msg'First) /= '\' then -- Case of inlined body if Inlined_Body (X) then if Is_Info_Msg then Error_Msg_Internal (Msg => "info: in inlined body #", Span => To_Span (Actual_Error_Loc), Opan => Flag_Span, Msg_Cont => Msg_Cont_Status, Node => N); elsif Is_Warning_Msg then Error_Msg_Internal (Msg => Warn_Insertion & "in inlined body #", Span => To_Span (Actual_Error_Loc), Opan => Flag_Span, Msg_Cont => Msg_Cont_Status, Node => N); elsif Is_Style_Msg then Error_Msg_Internal (Msg => "style: in inlined body #", Span => To_Span (Actual_Error_Loc), Opan => Flag_Span, Msg_Cont => Msg_Cont_Status, Node => N); else Error_Msg_Internal (Msg => "error in inlined body #", Span => To_Span (Actual_Error_Loc), Opan => Flag_Span, Msg_Cont => Msg_Cont_Status, Node => N); end if; -- Case of generic instantiation else if Is_Info_Msg then Error_Msg_Internal (Msg => "info: in instantiation #", Span => To_Span (Actual_Error_Loc), Opan => Flag_Span, Msg_Cont => Msg_Cont_Status, Node => N); elsif Is_Warning_Msg then Error_Msg_Internal (Msg => Warn_Insertion & "in instantiation #", Span => To_Span (Actual_Error_Loc), Opan => Flag_Span, Msg_Cont => Msg_Cont_Status, Node => N); elsif Is_Style_Msg then Error_Msg_Internal (Msg => "style: in instantiation #", Span => To_Span (Actual_Error_Loc), Opan => Flag_Span, Msg_Cont => Msg_Cont_Status, Node => N); else Error_Msg_Internal (Msg => "instantiation error #", Span => To_Span (Actual_Error_Loc), Opan => Flag_Span, Msg_Cont => Msg_Cont_Status, Node => N); end if; end if; end if; Error_Msg_Sloc := Instantiation (X); X := Get_Source_File_Index (Error_Msg_Sloc); Msg_Cont_Status := True; end loop; Suppress_Instance_Location := False; Error_Msg_Sloc := Save_Error_Msg_Sloc; -- Here we output the original message on the outer instantiation Error_Msg_Internal (Msg => Msg, Span => To_Span (Actual_Error_Loc), Opan => Flag_Span, Msg_Cont => Msg_Cont_Status, Node => N); end; end Error_Msg; ---------------------------------- -- Error_Msg_Ada_2005_Extension -- ---------------------------------- procedure Error_Msg_Ada_2005_Extension (Extension : String) is Loc : constant Source_Ptr := Token_Ptr; begin if Ada_Version < Ada_2005 then Error_Msg (Extension & " is an Ada 2005 extension", Loc); if No (Ada_Version_Pragma) then Error_Msg ("\unit must be compiled with -gnat05 switch", Loc); else Error_Msg_Sloc := Sloc (Ada_Version_Pragma); Error_Msg ("\incompatible with Ada version set#", Loc); end if; end if; end Error_Msg_Ada_2005_Extension; -------------------------------- -- Error_Msg_Ada_2012_Feature -- -------------------------------- procedure Error_Msg_Ada_2012_Feature (Feature : String; Loc : Source_Ptr) is begin if Ada_Version < Ada_2012 then Error_Msg (Feature & " is an Ada 2012 feature", Loc); if No (Ada_Version_Pragma) then Error_Msg ("\unit must be compiled with -gnat2012 switch", Loc); else Error_Msg_Sloc := Sloc (Ada_Version_Pragma); Error_Msg ("\incompatible with Ada version set#", Loc); end if; end if; end Error_Msg_Ada_2012_Feature; -------------------------------- -- Error_Msg_Ada_2022_Feature -- -------------------------------- procedure Error_Msg_Ada_2022_Feature (Feature : String; Loc : Source_Ptr) is begin if Ada_Version < Ada_2022 then Error_Msg (Feature & " is an Ada 2022 feature", Loc); if No (Ada_Version_Pragma) then Error_Msg ("\unit must be compiled with -gnat2022 switch", Loc); else Error_Msg_Sloc := Sloc (Ada_Version_Pragma); Error_Msg ("\incompatible with Ada version set#", Loc); end if; end if; end Error_Msg_Ada_2022_Feature; ------------------ -- Error_Msg_AP -- ------------------ procedure Error_Msg_AP (Msg : String) is S1 : Source_Ptr; C : Character; begin -- If we had saved the Scan_Ptr value after scanning the previous -- token, then we would have exactly the right place for putting -- the flag immediately at hand. However, that would add at least -- two instructions to a Scan call *just* to service the possibility -- of an Error_Msg_AP call. So instead we reconstruct that value. -- We have two possibilities, start with Prev_Token_Ptr and skip over -- the current token, which is made harder by the possibility that this -- token may be in error, or start with Token_Ptr and work backwards. -- We used to take the second approach, but it's hard because of -- comments, and harder still because things that look like comments -- can appear inside strings. So now we take the first approach. -- Note: in the case where there is no previous token, Prev_Token_Ptr -- is set to Source_First, which is a reasonable position for the -- error flag in this situation. S1 := Prev_Token_Ptr; C := Source (S1); -- If the previous token is a string literal, we need a special approach -- since there may be white space inside the literal and we don't want -- to stop on that white space. -- Note: since this is an error recovery issue anyway, it is not worth -- worrying about special UTF_32 line terminator characters here. if Prev_Token = Tok_String_Literal then loop S1 := S1 + 1; if Source (S1) = C then S1 := S1 + 1; exit when Source (S1) /= C; elsif Source (S1) in Line_Terminator then exit; end if; end loop; -- Character literal also needs special handling elsif Prev_Token = Tok_Char_Literal then S1 := S1 + 3; -- Otherwise we search forward for the end of the current token, marked -- by a line terminator, white space, a comment symbol or if we bump -- into the following token (i.e. the current token). -- Again, it is not worth worrying about UTF_32 special line terminator -- characters in this context, since this is only for error recovery. else while Source (S1) not in Line_Terminator and then Source (S1) /= ' ' and then Source (S1) /= ASCII.HT and then (Source (S1) /= '-' or else Source (S1 + 1) /= '-') and then S1 /= Token_Ptr loop S1 := S1 + 1; end loop; end if; -- S1 is now set to the location for the flag Error_Msg (Msg, S1); end Error_Msg_AP; ------------------ -- Error_Msg_BC -- ------------------ procedure Error_Msg_BC (Msg : String) is begin -- If we are at end of file, post the flag after the previous token if Token = Tok_EOF then Error_Msg_AP (Msg); -- If we are at start of file, post the flag at the current token elsif Token_Ptr = Source_First (Current_Source_File) then Error_Msg_SC (Msg); -- If the character before the current token is a space or a horizontal -- tab, then we place the flag on this character (in the case of a tab -- we would really like to place it in the "last" character of the tab -- space, but that it too much trouble to worry about). elsif Source (Token_Ptr - 1) = ' ' or else Source (Token_Ptr - 1) = ASCII.HT then Error_Msg (Msg, Token_Ptr - 1); -- If there is no space or tab before the current token, then there is -- no room to place the flag before the token, so we place it on the -- token instead (this happens for example at the start of a line). else Error_Msg (Msg, Token_Ptr); end if; end Error_Msg_BC; ------------------- -- Error_Msg_CRT -- ------------------- procedure Error_Msg_CRT (Feature : String; N : Node_Id) is begin if No_Run_Time_Mode then Error_Msg_N ('|' & Feature & " not allowed in no run time mode", N); else pragma Assert (Configurable_Run_Time_Mode); Error_Msg_N ('|' & Feature & " not supported by configuration>", N); end if; Configurable_Run_Time_Violations := Configurable_Run_Time_Violations + 1; end Error_Msg_CRT; ------------------ -- Error_Msg_PT -- ------------------ procedure Error_Msg_PT (E : Entity_Id; Iface_Prim : Entity_Id) is begin Error_Msg_N ("illegal overriding of subprogram inherited from interface", E); Error_Msg_Sloc := Sloc (Iface_Prim); if Ekind (E) = E_Function then Error_Msg_N ("\first formal of & declared # must be of mode `IN` " & "or access-to-constant", E); else Error_Msg_N ("\first formal of & declared # must be of mode `OUT`, `IN OUT` " & "or access-to-variable", E); end if; end Error_Msg_PT; ----------------- -- Error_Msg_F -- ----------------- procedure Error_Msg_F (Msg : String; N : Node_Id) is Fst, Lst : Node_Id; begin First_And_Last_Nodes (N, Fst, Lst); Error_Msg_NEL (Msg, N, N, To_Span (Ptr => Sloc (Fst), First => First_Sloc (Fst), Last => Last_Sloc (Lst))); end Error_Msg_F; ------------------ -- Error_Msg_FE -- ------------------ procedure Error_Msg_FE (Msg : String; N : Node_Id; E : Node_Or_Entity_Id) is Fst, Lst : Node_Id; begin First_And_Last_Nodes (N, Fst, Lst); Error_Msg_NEL (Msg, N, E, To_Span (Ptr => Sloc (Fst), First => First_Sloc (Fst), Last => Last_Sloc (Lst))); end Error_Msg_FE; ------------------------------ -- Error_Msg_GNAT_Extension -- ------------------------------ procedure Error_Msg_GNAT_Extension (Extension : String) is Loc : constant Source_Ptr := Token_Ptr; begin if not Extensions_Allowed then Error_Msg (Extension & " is a 'G'N'A'T specific extension", Loc); Error_Msg ("\unit must be compiled with -gnatX switch", Loc); end if; end Error_Msg_GNAT_Extension; ------------------------ -- Error_Msg_Internal -- ------------------------ procedure Error_Msg_Internal (Msg : String; Span : Source_Span; Opan : Source_Span; Msg_Cont : Boolean; Node : Node_Id) is Sptr : constant Source_Ptr := Span.Ptr; Optr : constant Source_Ptr := Opan.Ptr; Next_Msg : Error_Msg_Id; -- Pointer to next message at insertion point Prev_Msg : Error_Msg_Id; -- Pointer to previous message at insertion point Temp_Msg : Error_Msg_Id; Warn_Err : Boolean; -- Set if warning to be treated as error procedure Handle_Serious_Error; -- Internal procedure to do all error message handling for a serious -- error message, other than bumping the error counts and arranging -- for the message to be output. -------------------------- -- Handle_Serious_Error -- -------------------------- procedure Handle_Serious_Error is begin -- Turn off code generation if not done already if Operating_Mode = Generate_Code then Operating_Mode := Check_Semantics; Expander_Active := False; end if; -- Set the fatal error flag in the unit table unless we are in -- Try_Semantics mode (in which case we set ignored mode if not -- currently set. This stops the semantics from being performed -- if we find a serious error. This is skipped if we are currently -- dealing with the configuration pragma file. if Current_Source_Unit /= No_Unit then declare U : constant Unit_Number_Type := Get_Source_Unit (Sptr); begin if Try_Semantics then if Fatal_Error (U) = None then Set_Fatal_Error (U, Error_Ignored); end if; else Set_Fatal_Error (U, Error_Detected); end if; end; end if; -- Disable warnings on unused use clauses and the like. Otherwise, an -- error might hide a reference to an entity in a used package, so -- after fixing the error, the use clause no longer looks like it was -- unused. Check_Unreferenced := False; Check_Unreferenced_Formals := False; end Handle_Serious_Error; -- Start of processing for Error_Msg_Internal begin -- Detect common mistake of prefixing or suffing the message with a -- space character. pragma Assert (Msg (Msg'First) /= ' ' and then Msg (Msg'Last) /= ' '); if Raise_Exception_On_Error /= 0 then raise Error_Msg_Exception; end if; Continuation := Msg_Cont; Continuation_New_Line := False; Suppress_Message := False; Kill_Message := False; Set_Msg_Text (Msg, Sptr); -- Kill continuation if parent message killed if Continuation and Last_Killed then return; end if; -- Return without doing anything if message is suppressed if Suppress_Message and then not All_Errors_Mode and then not Is_Warning_Msg and then not Is_Unconditional_Msg then if not Continuation then Last_Killed := True; end if; return; end if; -- Return without doing anything if message is killed and this is not -- the first error message. The philosophy is that if we get a weird -- error message and we already have had a message, then we hope the -- weird message is a junk cascaded message if Kill_Message and then not All_Errors_Mode and then Total_Errors_Detected /= 0 then if not Continuation then Last_Killed := True; end if; return; end if; -- Special check for warning message to see if it should be output if Is_Warning_Msg then -- Immediate return if warning message and warnings are suppressed if Warnings_Suppressed (Optr) /= No_String or else Warnings_Suppressed (Sptr) /= No_String then Cur_Msg := No_Error_Msg; return; end if; -- If the flag location is in the main extended source unit then for -- sure we want the warning since it definitely belongs if In_Extended_Main_Source_Unit (Sptr) then null; -- If the main unit has not been read yet. The warning must be on -- a configuration file: gnat.adc or user-defined. This means we -- are not parsing the main unit yet, so skip following checks. elsif No (Cunit (Main_Unit)) then null; -- If the flag location is not in the extended main source unit, then -- we want to eliminate the warning, unless it is in the extended -- main code unit and we want warnings on the instance. elsif In_Extended_Main_Code_Unit (Sptr) and then Warn_On_Instance then null; -- Keep warning if debug flag G set elsif Debug_Flag_GG then null; -- Keep warning if message text contains !! elsif Has_Double_Exclam then null; -- Here is where we delete a warning from a with'ed unit else Cur_Msg := No_Error_Msg; if not Continuation then Last_Killed := True; end if; return; end if; end if; -- If message is to be ignored in special ignore message mode, this is -- where we do this special processing, bypassing message output. if Ignore_Errors_Enable > 0 then if Is_Serious_Error then Handle_Serious_Error; end if; return; end if; -- If error message line length set, and this is a continuation message -- then all we do is to append the text to the text of the last message -- with a comma space separator (eliminating a possible (style) or -- info prefix). if Error_Msg_Line_Length /= 0 and then Continuation then Cur_Msg := Errors.Last; declare Oldm : String_Ptr := Errors.Table (Cur_Msg).Text; Newm : String (1 .. Oldm'Last + 2 + Msglen); Newl : Natural; M : Natural; begin -- First copy old message to new one and free it Newm (Oldm'Range) := Oldm.all; Newl := Oldm'Length; Free (Oldm); -- Remove (style) or info: at start of message if Msglen > 8 and then Msg_Buffer (1 .. 8) = "(style) " then M := 9; elsif Msglen > 6 and then Msg_Buffer (1 .. 6) = "info: " then M := 7; else M := 1; end if; -- Now deal with separation between messages. Normally this is -- simply comma space, but there are some special cases. -- If continuation new line, then put actual NL character in msg if Continuation_New_Line then Newl := Newl + 1; Newm (Newl) := ASCII.LF; -- If continuation message is enclosed in parentheses, then -- special treatment (don't need a comma, and we want to combine -- successive parenthetical remarks into a single one with -- separating commas). elsif Msg_Buffer (M) = '(' and then Msg_Buffer (Msglen) = ')' then -- Case where existing message ends in right paren, remove -- and separate parenthetical remarks with a comma. if Newm (Newl) = ')' then Newm (Newl) := ','; Msg_Buffer (M) := ' '; -- Case where we are adding new parenthetical comment else Newl := Newl + 1; Newm (Newl) := ' '; end if; -- Case where continuation not in parens and no new line else Newm (Newl + 1 .. Newl + 2) := ", "; Newl := Newl + 2; end if; -- Append new message Newm (Newl + 1 .. Newl + Msglen - M + 1) := Msg_Buffer (M .. Msglen); Newl := Newl + Msglen - M + 1; Errors.Table (Cur_Msg).Text := new String'(Newm (1 .. Newl)); -- Update warning msg flag and message doc char if needed if Is_Warning_Msg then if not Errors.Table (Cur_Msg).Warn then Errors.Table (Cur_Msg).Warn := True; Errors.Table (Cur_Msg).Warn_Chr := Warning_Msg_Char; elsif Warning_Msg_Char /= " " then Errors.Table (Cur_Msg).Warn_Chr := Warning_Msg_Char; end if; end if; end; return; end if; -- Here we build a new error object Errors.Append ((Text => new String'(Msg_Buffer (1 .. Msglen)), Next => No_Error_Msg, Prev => No_Error_Msg, Sptr => Span, Optr => Optr, Insertion_Sloc => (if Has_Insertion_Line then Error_Msg_Sloc else No_Location), Sfile => Get_Source_File_Index (Sptr), Line => Get_Physical_Line_Number (Sptr), Col => Get_Column_Number (Sptr), Compile_Time_Pragma => Is_Compile_Time_Msg, Warn => Is_Warning_Msg, Info => Is_Info_Msg, Check => Is_Check_Msg, Warn_Err => False, -- reset below Warn_Chr => Warning_Msg_Char, Warn_Runtime_Raise => Is_Runtime_Raise, Style => Is_Style_Msg, Serious => Is_Serious_Error, Uncond => Is_Unconditional_Msg, Msg_Cont => Continuation, Deleted => False, Node => Node)); Cur_Msg := Errors.Last; -- Test if warning to be treated as error Warn_Err := (Is_Warning_Msg or Is_Style_Msg) and then (Warning_Treated_As_Error (Msg_Buffer (1 .. Msglen)) or else Warning_Treated_As_Error (Get_Warning_Tag (Cur_Msg))); -- Propagate Warn_Err to this message and preceding continuations. -- Likewise, propagate Is_Warning_Msg and Is_Runtime_Raise, because the -- current continued message could have been escalated from warning to -- error. for J in reverse 1 .. Errors.Last loop Errors.Table (J).Warn_Err := Warn_Err; Errors.Table (J).Warn := Is_Warning_Msg; Errors.Table (J).Warn_Runtime_Raise := Is_Runtime_Raise; exit when not Errors.Table (J).Msg_Cont; end loop; -- If immediate errors mode set, output error message now. Also output -- now if the -d1 debug flag is set (so node number message comes out -- just before actual error message) if Debug_Flag_OO or else Debug_Flag_1 then Write_Eol; Output_Source_Line (Errors.Table (Cur_Msg).Line, Errors.Table (Cur_Msg).Sfile, True); Temp_Msg := Cur_Msg; Output_Error_Msgs (Temp_Msg); -- If not in immediate errors mode, then we insert the message in the -- error chain for later output by Finalize. The messages are sorted -- first by unit (main unit comes first), and within a unit by source -- location (earlier flag location first in the chain). else -- First a quick check, does this belong at the very end of the chain -- of error messages. This saves a lot of time in the normal case if -- there are lots of messages. if Last_Error_Msg /= No_Error_Msg and then Errors.Table (Cur_Msg).Sfile = Errors.Table (Last_Error_Msg).Sfile and then (Sptr > Errors.Table (Last_Error_Msg).Sptr.Ptr or else (Sptr = Errors.Table (Last_Error_Msg).Sptr.Ptr and then Optr > Errors.Table (Last_Error_Msg).Optr)) then Prev_Msg := Last_Error_Msg; Next_Msg := No_Error_Msg; -- Otherwise do a full sequential search for the insertion point else Prev_Msg := No_Error_Msg; Next_Msg := First_Error_Msg; while Next_Msg /= No_Error_Msg loop exit when Errors.Table (Cur_Msg).Sfile < Errors.Table (Next_Msg).Sfile; if Errors.Table (Cur_Msg).Sfile = Errors.Table (Next_Msg).Sfile then exit when Sptr < Errors.Table (Next_Msg).Sptr.Ptr or else (Sptr = Errors.Table (Next_Msg).Sptr.Ptr and then Optr < Errors.Table (Next_Msg).Optr); end if; Prev_Msg := Next_Msg; Next_Msg := Errors.Table (Next_Msg).Next; end loop; end if; -- Now we insert the new message in the error chain. -- The possible insertion point for the new message is after Prev_Msg -- and before Next_Msg. However, this is where we do a special check -- for redundant parsing messages, defined as messages posted on the -- same line. The idea here is that probably such messages are junk -- from the parser recovering. In full errors mode, we don't do this -- deletion, but otherwise such messages are discarded at this stage. if Prev_Msg /= No_Error_Msg and then Errors.Table (Prev_Msg).Line = Errors.Table (Cur_Msg).Line and then Errors.Table (Prev_Msg).Sfile = Errors.Table (Cur_Msg).Sfile and then Compiler_State = Parsing and then not All_Errors_Mode then -- Don't delete unconditional messages and at this stage, don't -- delete continuation lines; we attempted to delete those earlier -- if the parent message was deleted. if not Errors.Table (Cur_Msg).Uncond and then not Continuation then -- Don't delete if prev msg is warning and new msg is an error. -- This is because we don't want a real error masked by a -- warning. In all other cases (that is parse errors for the -- same line that are not unconditional) we do delete the -- message. This helps to avoid junk extra messages from -- cascaded parsing errors if not (Errors.Table (Prev_Msg).Warn or else Errors.Table (Prev_Msg).Style) or else (Errors.Table (Cur_Msg).Warn or else Errors.Table (Cur_Msg).Style) then -- All tests passed, delete the message by simply returning -- without any further processing. pragma Assert (not Continuation); Last_Killed := True; return; end if; end if; end if; -- Come here if message is to be inserted in the error chain if not Continuation then Last_Killed := False; end if; if Prev_Msg = No_Error_Msg then First_Error_Msg := Cur_Msg; else Errors.Table (Prev_Msg).Next := Cur_Msg; end if; Errors.Table (Cur_Msg).Next := Next_Msg; if Next_Msg = No_Error_Msg then Last_Error_Msg := Cur_Msg; end if; end if; -- Bump appropriate statistics counts if Errors.Table (Cur_Msg).Info then -- Could be (usually is) both "info" and "warning" if Errors.Table (Cur_Msg).Warn then Warning_Info_Messages := Warning_Info_Messages + 1; Warnings_Detected := Warnings_Detected + 1; else Report_Info_Messages := Report_Info_Messages + 1; end if; elsif Errors.Table (Cur_Msg).Warn or else Errors.Table (Cur_Msg).Style then Warnings_Detected := Warnings_Detected + 1; elsif Errors.Table (Cur_Msg).Check then Check_Messages := Check_Messages + 1; else Total_Errors_Detected := Total_Errors_Detected + 1; if Errors.Table (Cur_Msg).Serious then Serious_Errors_Detected := Serious_Errors_Detected + 1; Handle_Serious_Error; -- If not serious error, set Fatal_Error to indicate ignored error else declare U : constant Unit_Number_Type := Get_Source_Unit (Sptr); begin if Fatal_Error (U) = None then Set_Fatal_Error (U, Error_Ignored); end if; end; end if; end if; -- Record warning message issued if Errors.Table (Cur_Msg).Warn and then not Errors.Table (Cur_Msg).Msg_Cont then Warning_Msg := Cur_Msg; end if; -- If too many warnings turn off warnings if Maximum_Messages /= 0 then if Warnings_Detected = Maximum_Messages then Warning_Mode := Suppress; end if; -- If too many errors abandon compilation if Total_Errors_Detected = Maximum_Messages then raise Unrecoverable_Error; end if; end if; end Error_Msg_Internal; ----------------- -- Error_Msg_N -- ----------------- procedure Error_Msg_N (Msg : String; N : Node_Or_Entity_Id) is Fst, Lst : Node_Id; begin First_And_Last_Nodes (N, Fst, Lst); Error_Msg_NEL (Msg, N, N, To_Span (Ptr => Sloc (N), First => First_Sloc (Fst), Last => Last_Sloc (Lst))); end Error_Msg_N; ------------------ -- Error_Msg_NE -- ------------------ procedure Error_Msg_NE (Msg : String; N : Node_Or_Entity_Id; E : Node_Or_Entity_Id) is Fst, Lst : Node_Id; begin First_And_Last_Nodes (N, Fst, Lst); Error_Msg_NEL (Msg, N, E, To_Span (Ptr => Sloc (N), First => First_Sloc (Fst), Last => Last_Sloc (Lst))); end Error_Msg_NE; ------------------- -- Error_Msg_NEL -- ------------------- procedure Error_Msg_NEL (Msg : String; N : Node_Or_Entity_Id; E : Node_Or_Entity_Id; Flag_Location : Source_Ptr) is Fst, Lst : Node_Id; begin First_And_Last_Nodes (N, Fst, Lst); Error_Msg_NEL (Msg, N, E, To_Span (Ptr => Flag_Location, First => Source_Ptr'Min (Flag_Location, First_Sloc (Fst)), Last => Source_Ptr'Max (Flag_Location, Last_Sloc (Lst)))); end Error_Msg_NEL; procedure Error_Msg_NEL (Msg : String; N : Node_Or_Entity_Id; E : Node_Or_Entity_Id; Flag_Span : Source_Span) is begin if Special_Msg_Delete (Msg, N, E) then return; end if; Prescan_Message (Msg); -- Special handling for warning messages if Is_Warning_Msg then -- Suppress if no warnings set for either entity or node if No_Warnings (N) or else No_Warnings (E) then -- Disable any continuation messages as well Last_Killed := True; return; end if; end if; -- Test for message to be output if All_Errors_Mode or else Is_Unconditional_Msg or else Is_Warning_Msg or else OK_Node (N) or else (Msg (Msg'First) = '\' and then not Last_Killed) then Debug_Output (N); Error_Msg_Node_1 := E; Error_Msg (Msg, Flag_Span, N); else Last_Killed := True; end if; if not Get_Ignore_Errors then Set_Posted (N); end if; end Error_Msg_NEL; ------------------ -- Error_Msg_NW -- ------------------ procedure Error_Msg_NW (Eflag : Boolean; Msg : String; N : Node_Or_Entity_Id) is Fst, Lst : Node_Id; begin if Eflag and then In_Extended_Main_Source_Unit (N) and then Comes_From_Source (N) then First_And_Last_Nodes (N, Fst, Lst); Error_Msg_NEL (Msg, N, N, To_Span (Ptr => Sloc (N), First => First_Sloc (Fst), Last => Last_Sloc (Lst))); end if; end Error_Msg_NW; ----------------- -- Error_Msg_S -- ----------------- procedure Error_Msg_S (Msg : String) is begin Error_Msg (Msg, Scan_Ptr); end Error_Msg_S; ------------------ -- Error_Msg_SC -- ------------------ procedure Error_Msg_SC (Msg : String) is begin -- If we are at end of file, post the flag after the previous token if Token = Tok_EOF then Error_Msg_AP (Msg); -- For all other cases the message is posted at the current token -- pointer position else Error_Msg (Msg, Token_Ptr); end if; end Error_Msg_SC; ------------------ -- Error_Msg_SP -- ------------------ procedure Error_Msg_SP (Msg : String) is begin -- Note: in the case where there is no previous token, Prev_Token_Ptr -- is set to Source_First, which is a reasonable position for the -- error flag in this situation Error_Msg (Msg, Prev_Token_Ptr); end Error_Msg_SP; -------------- -- Finalize -- -------------- procedure Finalize (Last_Call : Boolean) is Cur : Error_Msg_Id; Nxt : Error_Msg_Id; F : Error_Msg_Id; procedure Delete_Warning (E : Error_Msg_Id); -- Delete a warning msg if not already deleted and adjust warning count -------------------- -- Delete_Warning -- -------------------- procedure Delete_Warning (E : Error_Msg_Id) is begin if not Errors.Table (E).Deleted then Errors.Table (E).Deleted := True; Warnings_Detected := Warnings_Detected - 1; if Errors.Table (E).Info then Warning_Info_Messages := Warning_Info_Messages - 1; end if; end if; end Delete_Warning; -- Start of processing for Finalize begin -- Set Prev pointers Cur := First_Error_Msg; while Cur /= No_Error_Msg loop Nxt := Errors.Table (Cur).Next; exit when Nxt = No_Error_Msg; Errors.Table (Nxt).Prev := Cur; Cur := Nxt; end loop; -- Eliminate any duplicated error messages from the list. This is -- done after the fact to avoid problems with Change_Error_Text. Cur := First_Error_Msg; while Cur /= No_Error_Msg loop Nxt := Errors.Table (Cur).Next; F := Nxt; while F /= No_Error_Msg and then Errors.Table (F).Sptr.Ptr = Errors.Table (Cur).Sptr.Ptr loop Check_Duplicate_Message (Cur, F); F := Errors.Table (F).Next; end loop; Cur := Nxt; end loop; -- Mark any messages suppressed by specific warnings as Deleted Cur := First_Error_Msg; while Cur /= No_Error_Msg loop declare CE : Error_Msg_Object renames Errors.Table (Cur); Tag : constant String := Get_Warning_Tag (Cur); begin if (CE.Warn and not CE.Deleted) and then (Warning_Specifically_Suppressed (CE.Sptr.Ptr, CE.Text, Tag) /= No_String or else Warning_Specifically_Suppressed (CE.Optr, CE.Text, Tag) /= No_String) then Delete_Warning (Cur); -- If this is a continuation, delete previous parts of message F := Cur; while Errors.Table (F).Msg_Cont loop F := Errors.Table (F).Prev; exit when F = No_Error_Msg; Delete_Warning (F); end loop; -- Delete any following continuations F := Cur; loop F := Errors.Table (F).Next; exit when F = No_Error_Msg; exit when not Errors.Table (F).Msg_Cont; Delete_Warning (F); end loop; end if; end; Cur := Errors.Table (Cur).Next; end loop; Finalize_Called := True; -- Check consistency of specific warnings (may add warnings). We only -- do this on the last call, after all possible warnings are posted. if Last_Call then Validate_Specific_Warnings (Error_Msg'Access); end if; end Finalize; ---------------- -- First_Node -- ---------------- function First_Node (C : Node_Id) return Node_Id is Fst, Lst : Node_Id; begin First_And_Last_Nodes (C, Fst, Lst); return Fst; end First_Node; -------------------------- -- First_And_Last_Nodes -- -------------------------- procedure First_And_Last_Nodes (C : Node_Id; First_Node, Last_Node : out Node_Id) is Orig : constant Node_Id := Original_Node (C); Loc : constant Source_Ptr := Sloc (Orig); Sfile : constant Source_File_Index := Get_Source_File_Index (Loc); Earliest : Node_Id; Latest : Node_Id; Eloc : Source_Ptr; Lloc : Source_Ptr; function Test_First_And_Last (N : Node_Id) return Traverse_Result; -- Function applied to every node in the construct procedure Search_Tree_First_And_Last is new Traverse_Proc (Test_First_And_Last); -- Create traversal procedure ------------------------- -- Test_First_And_Last -- ------------------------- function Test_First_And_Last (N : Node_Id) return Traverse_Result is Norig : constant Node_Id := Original_Node (N); Loc : constant Source_Ptr := Sloc (Norig); begin -- Check for earlier if Loc < Eloc -- Ignore nodes with no useful location information and then Loc /= Standard_Location and then Loc /= No_Location -- Ignore nodes from a different file. This ensures against cases -- of strange foreign code somehow being present. We don't want -- wild placement of messages if that happens. and then Get_Source_File_Index (Loc) = Sfile then Earliest := Norig; Eloc := Loc; end if; -- Check for later if Loc > Lloc -- Ignore nodes with no useful location information and then Loc /= Standard_Location and then Loc /= No_Location -- Ignore nodes from a different file. This ensures against cases -- of strange foreign code somehow being present. We don't want -- wild placement of messages if that happens. and then Get_Source_File_Index (Loc) = Sfile then Latest := Norig; Lloc := Loc; end if; return OK_Orig; end Test_First_And_Last; -- Start of processing for First_And_Last_Nodes begin if Nkind (Orig) in N_Subexpr | N_Declaration | N_Access_To_Subprogram_Definition | N_Generic_Instantiation | N_Later_Decl_Item | N_Use_Package_Clause | N_Array_Type_Definition | N_Renaming_Declaration | N_Generic_Renaming_Declaration | N_Assignment_Statement | N_Raise_Statement | N_Simple_Return_Statement | N_Exit_Statement | N_Pragma | N_Use_Type_Clause | N_With_Clause | N_Attribute_Definition_Clause | N_Subtype_Indication then Earliest := Orig; Eloc := Loc; Latest := Orig; Lloc := Loc; Search_Tree_First_And_Last (Orig); First_Node := Earliest; Last_Node := Latest; else First_Node := Orig; Last_Node := Orig; end if; end First_And_Last_Nodes; ---------------- -- First_Sloc -- ---------------- function First_Sloc (N : Node_Id) return Source_Ptr is SI : constant Source_File_Index := Source_Index (Get_Source_Unit (N)); SF : constant Source_Ptr := Source_First (SI); SL : constant Source_Ptr := Source_Last (SI); F : Node_Id; S : Source_Ptr; begin F := First_Node (N); S := Sloc (F); if S not in SF .. SL then return S; end if; -- The following circuit is a bit subtle. When we have parenthesized -- expressions, then the Sloc will not record the location of the paren, -- but we would like to post the flag on the paren. So what we do is to -- crawl up the tree from the First_Node, adjusting the Sloc value for -- any parentheses we know are present. Yes, we know this circuit is not -- 100% reliable (e.g. because we don't record all possible paren level -- values), but this is only for an error message so it is good enough. Node_Loop : loop Paren_Loop : for J in 1 .. Paren_Count (F) loop -- We don't look more than 12 characters behind the current -- location, and in any case not past the front of the source. Search_Loop : for K in 1 .. 12 loop exit Search_Loop when S = SF; if Source_Text (SI) (S - 1) = '(' then S := S - 1; exit Search_Loop; elsif Source_Text (SI) (S - 1) <= ' ' then S := S - 1; else exit Search_Loop; end if; end loop Search_Loop; end loop Paren_Loop; exit Node_Loop when F = N; F := Parent (F); exit Node_Loop when Nkind (F) not in N_Subexpr; end loop Node_Loop; return S; end First_Sloc; ----------------------- -- Get_Ignore_Errors -- ----------------------- function Get_Ignore_Errors return Boolean is begin return Errors_Must_Be_Ignored; end Get_Ignore_Errors; ---------------- -- Initialize -- ---------------- procedure Initialize is begin Errors.Init; First_Error_Msg := No_Error_Msg; Last_Error_Msg := No_Error_Msg; Serious_Errors_Detected := 0; Total_Errors_Detected := 0; Cur_Msg := No_Error_Msg; List_Pragmas.Init; -- Reset counts for warnings Reset_Warnings; -- Initialize warnings tables Warnings.Init; Specific_Warnings.Init; end Initialize; ------------------------------- -- Is_Size_Too_Small_Message -- ------------------------------- function Is_Size_Too_Small_Message (S : String) return Boolean is Size_For : constant String := "size for"; pragma Assert (Size_Too_Small_Message (1 .. Size_For'Last) = Size_For); -- Assert that Size_Too_Small_Message starts with Size_For begin return S'Length >= Size_For'Length and then S (S'First .. S'First + Size_For'Length - 1) = Size_For; -- True if S starts with Size_For end Is_Size_Too_Small_Message; --------------- -- Last_Node -- --------------- function Last_Node (C : Node_Id) return Node_Id is Fst, Lst : Node_Id; begin First_And_Last_Nodes (C, Fst, Lst); return Lst; end Last_Node; --------------- -- Last_Sloc -- --------------- function Last_Sloc (N : Node_Id) return Source_Ptr is SI : constant Source_File_Index := Source_Index (Get_Source_Unit (N)); SF : constant Source_Ptr := Source_First (SI); SL : constant Source_Ptr := Source_Last (SI); F : Node_Id; S : Source_Ptr; begin F := Last_Node (N); S := Sloc (F); if S not in SF .. SL then return S; end if; -- Skip past an identifier while S in SF .. SL - 1 and then Source_Text (SI) (S + 1) in '0' .. '9' | 'a' .. 'z' | 'A' .. 'Z' | '.' | '_' loop S := S + 1; end loop; -- The following circuit attempts at crawling up the tree from the -- Last_Node, adjusting the Sloc value for any parentheses we know -- are present, similarly to what is done in First_Sloc. Node_Loop : loop Paren_Loop : for J in 1 .. Paren_Count (F) loop -- We don't look more than 12 characters after the current -- location Search_Loop : for K in 1 .. 12 loop exit Node_Loop when S = SL; if Source_Text (SI) (S + 1) = ')' then S := S + 1; exit Search_Loop; elsif Source_Text (SI) (S + 1) <= ' ' then S := S + 1; else exit Search_Loop; end if; end loop Search_Loop; end loop Paren_Loop; exit Node_Loop when F = N; F := Parent (F); exit Node_Loop when Nkind (F) not in N_Subexpr; end loop Node_Loop; -- Remove any trailing space while S in SF + 1 .. SL and then Source_Text (SI) (S) = ' ' loop S := S - 1; end loop; return S; end Last_Sloc; ----------------- -- No_Warnings -- ----------------- function No_Warnings (N : Node_Or_Entity_Id) return Boolean is begin if Error_Posted (N) then return True; elsif Nkind (N) in N_Entity and then Has_Warnings_Off (N) then return True; elsif Is_Entity_Name (N) and then Present (Entity (N)) and then Has_Warnings_Off (Entity (N)) then return True; else return False; end if; end No_Warnings; ------------- -- OK_Node -- ------------- function OK_Node (N : Node_Id) return Boolean is K : constant Node_Kind := Nkind (N); begin if Error_Posted (N) then return False; elsif K in N_Has_Etype and then Present (Etype (N)) and then Error_Posted (Etype (N)) then return False; elsif (K in N_Op or else K = N_Attribute_Reference or else K = N_Character_Literal or else K = N_Expanded_Name or else K = N_Identifier or else K = N_Operator_Symbol) and then Present (Entity (N)) and then Error_Posted (Entity (N)) then return False; else return True; end if; end OK_Node; ------------------------- -- Output_JSON_Message -- ------------------------- procedure Output_JSON_Message (Error_Id : Error_Msg_Id) is function Is_Continuation (E : Error_Msg_Id) return Boolean; -- Return True if E is a continuation message. procedure Write_JSON_Escaped_String (Str : String_Ptr); -- Write each character of Str, taking care of preceding each quote and -- backslash with a backslash. Note that this escaping differs from what -- GCC does. -- -- Indeed, the JSON specification mandates encoding wide characters -- either as their direct UTF-8 representation or as their escaped -- UTF-16 surrogate pairs representation. GCC seems to prefer escaping - -- we choose to use the UTF-8 representation instead. procedure Write_JSON_Location (Sptr : Source_Ptr); -- Write Sptr as a JSON location, an object containing a file attribute, -- a line number and a column number. procedure Write_JSON_Span (Span : Source_Span); -- Write Span as a JSON span, an object containing a "caret" attribute -- whose value is the JSON location of Span.Ptr. If Span.First and -- Span.Last are different from Span.Ptr, they will be printed as JSON -- locations under the names "start" and "finish". ----------------------- -- Is_Continuation -- ----------------------- function Is_Continuation (E : Error_Msg_Id) return Boolean is begin return E <= Last_Error_Msg and then Errors.Table (E).Msg_Cont; end Is_Continuation; ------------------------------- -- Write_JSON_Escaped_String -- ------------------------------- procedure Write_JSON_Escaped_String (Str : String_Ptr) is begin for C of Str.all loop if C = '"' or else C = '\' then Write_Char ('\'); end if; Write_Char (C); end loop; end Write_JSON_Escaped_String; ------------------------- -- Write_JSON_Location -- ------------------------- procedure Write_JSON_Location (Sptr : Source_Ptr) is begin Write_Str ("{""file"":"""); Write_Name (Full_Ref_Name (Get_Source_File_Index (Sptr))); Write_Str (""",""line"":"); Write_Int (Pos (Get_Physical_Line_Number (Sptr))); Write_Str (", ""column"":"); Write_Int (Nat (Get_Column_Number (Sptr))); Write_Str ("}"); end Write_JSON_Location; --------------------- -- Write_JSON_Span -- --------------------- procedure Write_JSON_Span (Span : Source_Span) is begin Write_Str ("{""caret"":"); Write_JSON_Location (Span.Ptr); if Span.Ptr /= Span.First then Write_Str (",""start"":"); Write_JSON_Location (Span.First); end if; if Span.Ptr /= Span.Last then Write_Str (",""finish"":"); Write_JSON_Location (Span.Last); end if; Write_Str ("}"); end Write_JSON_Span; -- Local Variables E : Error_Msg_Id := Error_Id; Print_Continuations : constant Boolean := not Is_Continuation (E); -- Do not print continuations messages as children of the current -- message if the current message is a continuation message. -- Start of processing for Output_JSON_Message begin -- Print message kind Write_Str ("{""kind"":"); if Errors.Table (E).Warn and then not Errors.Table (E).Warn_Err then Write_Str ("""warning"""); elsif Errors.Table (E).Info or else Errors.Table (E).Check then Write_Str ("""note"""); else Write_Str ("""error"""); end if; -- Print message location Write_Str (",""locations"":["); Write_JSON_Span (Errors.Table (E).Sptr); if Errors.Table (E).Optr /= Errors.Table (E).Sptr.Ptr then Write_Str (",{""caret"":"); Write_JSON_Location (Errors.Table (E).Optr); Write_Str ("}"); end if; -- Print message content Write_Str ("],""message"":"""); Write_JSON_Escaped_String (Errors.Table (E).Text); Write_Str (""""); E := E + 1; if Print_Continuations and then Is_Continuation (E) then Write_Str (",""children"": ["); Output_JSON_Message (E); E := E + 1; while Is_Continuation (E) loop Write_Str (", "); Output_JSON_Message (E); E := E + 1; end loop; Write_Str ("]"); end if; Write_Str ("}"); end Output_JSON_Message; --------------------- -- Output_Messages -- --------------------- procedure Output_Messages is -- Local subprograms procedure Write_Error_Summary; -- Write error summary procedure Write_Header (Sfile : Source_File_Index); -- Write header line (compiling or checking given file) procedure Write_Max_Errors; -- Write message if max errors reached procedure Write_Source_Code_Lines (Span : Source_Span; SGR_Span : String); -- Write the source code line corresponding to Span, as follows when -- Span in on one line: -- -- line | actual code line here with Span somewhere -- | ~~~~~^~~~ -- -- where the caret on the line points to location Span.Ptr, and the -- range Span.First..Span.Last is underlined. -- -- or when the span is over multiple lines: -- -- line | beginning of the Span on this line -- ... | ... -- line>| actual code line here with Span.Ptr somewhere -- ... | ... -- line | end of the Span on this line -- -- or when the span is a simple location, as follows: -- -- line | actual code line here with Span somewhere -- | ^ here -- -- where the caret on the line points to location Span.Ptr -- -- SGR_Span is the SGR string to start the section of code in the span, -- that should be closed with SGR_Reset. ------------------------- -- Write_Error_Summary -- ------------------------- procedure Write_Error_Summary is begin -- Extra blank line if error messages or source listing were output if Total_Errors_Detected + Warnings_Detected > 0 or else Full_List then Write_Eol; end if; -- Message giving number of lines read and number of errors detected. -- This normally goes to Standard_Output. The exception is when brief -- mode is not set, verbose mode (or full list mode) is set, and -- there are errors. In this case we send the message to standard -- error to make sure that *something* appears on standard error -- in an error situation. if Total_Errors_Detected + Warnings_Detected /= 0 and then not Brief_Output and then (Verbose_Mode or Full_List) then Set_Standard_Error; end if; -- Message giving total number of lines. Don't give this message if -- the Main_Source line is unknown (this happens in error situations, -- e.g. when integrated preprocessing fails). if Main_Source_File > No_Source_File then Write_Str (" "); Write_Int (Num_Source_Lines (Main_Source_File)); if Num_Source_Lines (Main_Source_File) = 1 then Write_Str (" line: "); else Write_Str (" lines: "); end if; end if; if Total_Errors_Detected = 0 then Write_Str ("No errors"); elsif Total_Errors_Detected = 1 then Write_Str ("1 error"); else Write_Int (Total_Errors_Detected); Write_Str (" errors"); end if; -- We now need to output warnings. When using -gnatwe, all warnings -- should be treated as errors, except for warnings originating from -- the use of the Compile_Time_Warning pragma. Another situation -- where a warning might be treated as an error is when the source -- code contains a Warning_As_Error pragma. -- When warnings are treated as errors, we still log them as -- warnings, but we add a message denoting how many of these warnings -- are also errors. declare Warnings_Count : constant Int := Warnings_Detected - Warning_Info_Messages; Compile_Time_Warnings : Int; -- Number of warnings that come from a Compile_Time_Warning -- pragma. Non_Compile_Time_Warnings : Int; -- Number of warnings that do not come from a Compile_Time_Warning -- pragmas. begin if Warnings_Count > 0 then Write_Str (", "); Write_Int (Warnings_Count); Write_Str (" warning"); if Warnings_Count > 1 then Write_Char ('s'); end if; Compile_Time_Warnings := Count_Compile_Time_Pragma_Warnings; Non_Compile_Time_Warnings := Warnings_Count - Compile_Time_Warnings; if Warning_Mode = Treat_As_Error and then Non_Compile_Time_Warnings > 0 then Write_Str (" ("); if Compile_Time_Warnings > 0 then Write_Int (Non_Compile_Time_Warnings); Write_Str (" "); end if; Write_Str ("treated as error"); if Non_Compile_Time_Warnings > 1 then Write_Char ('s'); end if; Write_Char (')'); elsif Warnings_Treated_As_Errors > 0 then Write_Str (" ("); if Warnings_Treated_As_Errors /= Warnings_Count then Write_Int (Warnings_Treated_As_Errors); Write_Str (" "); end if; Write_Str ("treated as error"); if Warnings_Treated_As_Errors > 1 then Write_Str ("s"); end if; Write_Str (")"); end if; end if; end; if Warning_Info_Messages + Report_Info_Messages /= 0 then Write_Str (", "); Write_Int (Warning_Info_Messages + Report_Info_Messages); Write_Str (" info message"); if Warning_Info_Messages + Report_Info_Messages > 1 then Write_Char ('s'); end if; end if; Write_Eol; Set_Standard_Output; end Write_Error_Summary; ------------------ -- Write_Header -- ------------------ procedure Write_Header (Sfile : Source_File_Index) is begin if Verbose_Mode or Full_List then if Original_Operating_Mode = Generate_Code then Write_Str ("Compiling: "); else Write_Str ("Checking: "); end if; Write_Name (Full_File_Name (Sfile)); if not Debug_Flag_7 then Write_Eol; Write_Str ("Source file time stamp: "); Write_Time_Stamp (Sfile); Write_Eol; Write_Str ("Compiled at: " & Compilation_Time); end if; Write_Eol; end if; end Write_Header; ---------------------- -- Write_Max_Errors -- ---------------------- procedure Write_Max_Errors is begin if Maximum_Messages /= 0 then if Warnings_Detected >= Maximum_Messages then Set_Standard_Error; Write_Line ("maximum number of warnings output"); Write_Line ("any further warnings suppressed"); Set_Standard_Output; end if; -- If too many errors print message if Total_Errors_Detected >= Maximum_Messages then Set_Standard_Error; Write_Line ("fatal error: maximum number of errors detected"); Set_Standard_Output; end if; end if; end Write_Max_Errors; ----------------------------- -- Write_Source_Code_Lines -- ----------------------------- procedure Write_Source_Code_Lines (Span : Source_Span; SGR_Span : String) is function Get_Line_End (Buf : Source_Buffer_Ptr; Loc : Source_Ptr) return Source_Ptr; -- Get the source location for the end of the line in Buf for Loc. If -- Loc is past the end of Buf already, return Buf'Last. function Get_Line_Start (Buf : Source_Buffer_Ptr; Loc : Source_Ptr) return Source_Ptr; -- Get the source location for the start of the line in Buf for Loc function Image (X : Positive; Width : Positive) return String; -- Output number X over Width characters, with whitespace padding. -- Only output the low-order Width digits of X, if X is larger than -- Width digits. procedure Write_Buffer (Buf : Source_Buffer_Ptr; First : Source_Ptr; Last : Source_Ptr); -- Output the characters from First to Last position in Buf, using -- Write_Buffer_Char. procedure Write_Buffer_Char (Buf : Source_Buffer_Ptr; Loc : Source_Ptr); -- Output the characters at position Loc in Buf, translating ASCII.HT -- in a suitable number of spaces so that the output is not modified -- by starting in a different column that 1. procedure Write_Line_Marker (Num : Pos; Mark : Boolean; Width : Positive); -- Output the line number Num over Width characters, with possibly -- a Mark to denote the line with the main location when reporting -- a span over multiple lines. ------------------ -- Get_Line_End -- ------------------ function Get_Line_End (Buf : Source_Buffer_Ptr; Loc : Source_Ptr) return Source_Ptr is Cur_Loc : Source_Ptr := Source_Ptr'Min (Loc, Buf'Last); begin while Cur_Loc < Buf'Last and then Buf (Cur_Loc) /= ASCII.LF loop Cur_Loc := Cur_Loc + 1; end loop; return Cur_Loc; end Get_Line_End; -------------------- -- Get_Line_Start -- -------------------- function Get_Line_Start (Buf : Source_Buffer_Ptr; Loc : Source_Ptr) return Source_Ptr is Cur_Loc : Source_Ptr := Loc; begin while Cur_Loc > Buf'First and then Buf (Cur_Loc - 1) /= ASCII.LF loop Cur_Loc := Cur_Loc - 1; end loop; return Cur_Loc; end Get_Line_Start; ----------- -- Image -- ----------- function Image (X : Positive; Width : Positive) return String is Str : String (1 .. Width); Curr : Natural := X; begin for J in reverse 1 .. Width loop if Curr > 0 then Str (J) := Character'Val (Character'Pos ('0') + Curr mod 10); Curr := Curr / 10; else Str (J) := ' '; end if; end loop; return Str; end Image; ------------------ -- Write_Buffer -- ------------------ procedure Write_Buffer (Buf : Source_Buffer_Ptr; First : Source_Ptr; Last : Source_Ptr) is begin for Loc in First .. Last loop Write_Buffer_Char (Buf, Loc); end loop; end Write_Buffer; ----------------------- -- Write_Buffer_Char -- ----------------------- procedure Write_Buffer_Char (Buf : Source_Buffer_Ptr; Loc : Source_Ptr) is begin -- If the character ASCII.HT is not the last one in the file, -- output as many spaces as the character represents in the -- original source file. if Buf (Loc) = ASCII.HT and then Loc < Buf'Last then for X in Get_Column_Number (Loc) .. Get_Column_Number (Loc + 1) - 1 loop Write_Char (' '); end loop; -- Otherwise output the character itself else Write_Char (Buf (Loc)); end if; end Write_Buffer_Char; ----------------------- -- Write_Line_Marker -- ----------------------- procedure Write_Line_Marker (Num : Pos; Mark : Boolean; Width : Positive) is begin Write_Str (Image (Positive (Num), Width => Width)); Write_Str ((if Mark then ">" else " ") & "|"); end Write_Line_Marker; -- Local variables Loc : constant Source_Ptr := Span.Ptr; Line : constant Pos := Pos (Get_Physical_Line_Number (Loc)); Col : constant Natural := Natural (Get_Column_Number (Loc)); Fst : constant Source_Ptr := Span.First; Line_Fst : constant Pos := Pos (Get_Physical_Line_Number (Fst)); Col_Fst : constant Natural := Natural (Get_Column_Number (Fst)); Lst : constant Source_Ptr := Span.Last; Line_Lst : constant Pos := Pos (Get_Physical_Line_Number (Lst)); Col_Lst : constant Natural := Natural (Get_Column_Number (Lst)); Width : constant := 5; Buf : Source_Buffer_Ptr; Cur_Loc : Source_Ptr := Fst; Cur_Line : Pos := Line_Fst; -- Start of processing for Write_Source_Code_Lines begin if Loc >= First_Source_Ptr then Buf := Source_Text (Get_Source_File_Index (Loc)); -- First line of the span with actual source code. We retrieve -- the beginning of the line instead of relying on Col_Fst, as -- ASCII.HT characters change column numbers by possibly more -- than one. Write_Line_Marker (Cur_Line, Line_Fst /= Line_Lst and then Cur_Line = Line, Width); Write_Buffer (Buf, Get_Line_Start (Buf, Cur_Loc), Cur_Loc - 1); -- Output the first/caret/last lines of the span, as well as -- lines that are directly above/below the caret if they complete -- the gap with first/last lines, otherwise use ... to denote -- intermediate lines. -- If the span is on one line and not a simple source location, -- color it appropriately. if Line_Fst = Line_Lst and then Col_Fst /= Col_Lst then Write_Str (SGR_Span); end if; declare function Do_Write_Line (Cur_Line : Pos) return Boolean is (Cur_Line in Line_Fst | Line | Line_Lst or else (Cur_Line = Line_Fst + 1 and then Cur_Line = Line - 1) or else (Cur_Line = Line + 1 and then Cur_Line = Line_Lst - 1)); begin while Cur_Loc <= Buf'Last and then Cur_Loc <= Lst loop if Do_Write_Line (Cur_Line) then Write_Buffer_Char (Buf, Cur_Loc); end if; if Buf (Cur_Loc) = ASCII.LF then Cur_Line := Cur_Line + 1; -- Output ... for skipped lines if (Cur_Line = Line and then not Do_Write_Line (Cur_Line - 1)) or else (Cur_Line = Line + 1 and then not Do_Write_Line (Cur_Line)) then Write_Str ((1 .. Width - 3 => ' ') & "... | ..."); Write_Eol; end if; -- Display the line marker if the line should be -- displayed. if Do_Write_Line (Cur_Line) then Write_Line_Marker (Cur_Line, Line_Fst /= Line_Lst and then Cur_Line = Line, Width); end if; end if; Cur_Loc := Cur_Loc + 1; end loop; end; if Line_Fst = Line_Lst and then Col_Fst /= Col_Lst then Write_Str (SGR_Reset); end if; -- Output the rest of the last line of the span Write_Buffer (Buf, Cur_Loc, Get_Line_End (Buf, Cur_Loc)); -- If the span is on one line, output a second line with caret -- sign pointing to location Loc if Line_Fst = Line_Lst then Write_Str (String'(1 .. Width => ' ')); Write_Str (" |"); Write_Str (String'(1 .. Col_Fst - 1 => ' ')); Write_Str (SGR_Span); Write_Str (String'(Col_Fst .. Col - 1 => '~')); Write_Str ("^"); Write_Str (String'(Col + 1 .. Col_Lst => '~')); -- If the span is really just a location, add the word "here" -- to clarify this is the location for the message. if Col_Fst = Col_Lst then Write_Str (" here"); end if; Write_Str (SGR_Reset); Write_Eol; end if; end if; end Write_Source_Code_Lines; -- Local variables E : Error_Msg_Id; Err_Flag : Boolean; Use_Prefix : Boolean; -- Start of processing for Output_Messages begin -- Error if Finalize has not been called if not Finalize_Called then raise Program_Error; end if; -- Reset current error source file if the main unit has a pragma -- Source_Reference. This ensures outputting the proper name of -- the source file in this situation. if Main_Source_File <= No_Source_File or else Num_SRef_Pragmas (Main_Source_File) /= 0 then Current_Error_Source_File := No_Source_File; end if; if Opt.JSON_Output then Set_Standard_Error; E := First_Error_Msg; -- Find first printable message while E /= No_Error_Msg and then Errors.Table (E).Deleted loop E := Errors.Table (E).Next; end loop; Write_Char ('['); if E /= No_Error_Msg then Output_JSON_Message (E); E := Errors.Table (E).Next; -- Skip deleted messages. -- Also skip continuation messages, as they have already been -- printed along the message they're attached to. while E /= No_Error_Msg and then not Errors.Table (E).Deleted and then not Errors.Table (E).Msg_Cont loop Write_Char (','); Output_JSON_Message (E); E := Errors.Table (E).Next; end loop; end if; Write_Char (']'); Set_Standard_Output; -- Brief Error mode elsif Brief_Output or (not Full_List and not Verbose_Mode) then Set_Standard_Error; E := First_Error_Msg; while E /= No_Error_Msg loop -- If -gnatdF is used, separate main messages from previous -- messages with a newline (unless it is an info message) and -- make continuation messages follow the main message with only -- an indentation of two space characters, without repeating -- file:line:col: prefix. Use_Prefix := not (Debug_Flag_FF and then Errors.Table (E).Msg_Cont); if not Errors.Table (E).Deleted and then not Debug_Flag_KK then if Debug_Flag_FF then if Errors.Table (E).Msg_Cont then Write_Str (" "); elsif not Errors.Table (E).Info then Write_Eol; end if; end if; if Use_Prefix then Write_Str (SGR_Locus); if Full_Path_Name_For_Brief_Errors then Write_Name (Full_Ref_Name (Errors.Table (E).Sfile)); else Write_Name (Reference_Name (Errors.Table (E).Sfile)); end if; Write_Char (':'); Write_Int (Int (Physical_To_Logical (Errors.Table (E).Line, Errors.Table (E).Sfile))); Write_Char (':'); if Errors.Table (E).Col < 10 then Write_Char ('0'); end if; Write_Int (Int (Errors.Table (E).Col)); Write_Str (": "); Write_Str (SGR_Reset); end if; Output_Msg_Text (E); Write_Eol; -- If -gnatdF is used, write the source code line corresponding -- to the location of the main message (unless it is an info -- message). Also write the source code line corresponding to -- an insertion location inside continuation messages. if Debug_Flag_FF and then not Errors.Table (E).Info then if Errors.Table (E).Msg_Cont then declare Loc : constant Source_Ptr := Errors.Table (E).Insertion_Sloc; begin if Loc /= No_Location then Write_Source_Code_Lines (To_Span (Loc), SGR_Span => SGR_Note); end if; end; else declare SGR_Span : constant String := (if Errors.Table (E).Info then SGR_Note elsif Errors.Table (E).Warn and then not Errors.Table (E).Warn_Err then SGR_Warning else SGR_Error); begin Write_Source_Code_Lines (Errors.Table (E).Sptr, SGR_Span); end; end if; end if; end if; E := Errors.Table (E).Next; end loop; Set_Standard_Output; end if; -- Full source listing case if Full_List then List_Pragmas_Index := 1; List_Pragmas_Mode := True; E := First_Error_Msg; -- Normal case, to stdout (copyright notice already output) if Full_List_File_Name = null then if not Debug_Flag_7 then Write_Eol; end if; -- Output to file else Create_List_File_Access.all (Full_List_File_Name.all); Set_Special_Output (Write_List_Info_Access.all'Access); -- Write copyright notice to file if not Debug_Flag_7 then Write_Str ("GNAT "); Write_Str (Gnat_Version_String); Write_Eol; Write_Str ("Copyright 1992-" & Current_Year & ", Free Software Foundation, Inc."); Write_Eol; end if; end if; -- First list extended main source file units with errors for U in Main_Unit .. Last_Unit loop if In_Extended_Main_Source_Unit (Cunit_Entity (U)) -- If debug flag d.m is set, only the main source is listed and then (U = Main_Unit or else not Debug_Flag_Dot_M) -- If the unit of the entity does not come from source, it is -- an implicit subprogram declaration for a child subprogram. -- Do not emit errors for it, they are listed with the body. and then (No (Cunit_Entity (U)) or else Comes_From_Source (Cunit_Entity (U)) or else not Is_Subprogram (Cunit_Entity (U))) -- If the compilation unit associated with this unit does not -- come from source, it means it is an instantiation that should -- not be included in the source listing. and then Comes_From_Source (Cunit (U)) then declare Sfile : constant Source_File_Index := Source_Index (U); begin Write_Eol; -- Only write the header if Sfile is known if Sfile > No_Source_File then Write_Header (Sfile); Write_Eol; end if; -- Normally, we don't want an "error messages from file" -- message when listing the entire file, so we set the -- current source file as the current error source file. -- However, the old style of doing things was to list this -- message if pragma Source_Reference is present, even for -- the main unit. Since the purpose of the -gnatd.m switch -- is to duplicate the old behavior, we skip the reset if -- this debug flag is set. if not Debug_Flag_Dot_M then Current_Error_Source_File := Sfile; end if; -- Only output the listing if Sfile is known, to avoid -- crashing the compiler. if Sfile > No_Source_File then for N in 1 .. Last_Source_Line (Sfile) loop while E /= No_Error_Msg and then Errors.Table (E).Deleted loop E := Errors.Table (E).Next; end loop; Err_Flag := E /= No_Error_Msg and then Errors.Table (E).Line = N and then Errors.Table (E).Sfile = Sfile; Output_Source_Line (N, Sfile, Err_Flag); if Err_Flag then Output_Error_Msgs (E); if not Debug_Flag_2 then Write_Eol; end if; end if; end loop; end if; end; end if; end loop; -- Then output errors, if any, for subsidiary units not in the -- main extended unit. -- Note: if debug flag d.m set, include errors for any units other -- than the main unit in the extended source unit (e.g. spec and -- subunits for a body). while E /= No_Error_Msg and then (not In_Extended_Main_Source_Unit (Errors.Table (E).Sptr.Ptr) or else (Debug_Flag_Dot_M and then Get_Source_Unit (Errors.Table (E).Sptr.Ptr) /= Main_Unit)) loop if Errors.Table (E).Deleted then E := Errors.Table (E).Next; else Write_Eol; Output_Source_Line (Errors.Table (E).Line, Errors.Table (E).Sfile, True); Output_Error_Msgs (E); end if; end loop; -- If output to file, write extra copy of error summary to the -- output file, and then close it. if Full_List_File_Name /= null then Write_Error_Summary; Write_Max_Errors; Close_List_File_Access.all; Cancel_Special_Output; end if; end if; -- Verbose mode (error lines only with error flags). Normally this is -- ignored in full list mode, unless we are listing to a file, in which -- case we still generate -gnatv output to standard output. if Verbose_Mode and then (not Full_List or else Full_List_File_Name /= null) then Write_Eol; -- Output the header only when Main_Source_File is known if Main_Source_File > No_Source_File then Write_Header (Main_Source_File); end if; E := First_Error_Msg; -- Loop through error lines while E /= No_Error_Msg loop if Errors.Table (E).Deleted then E := Errors.Table (E).Next; else Write_Eol; Output_Source_Line (Errors.Table (E).Line, Errors.Table (E).Sfile, True); Output_Error_Msgs (E); end if; end loop; end if; -- Output error summary if verbose or full list mode if Verbose_Mode or else Full_List then Write_Error_Summary; end if; if not Opt.JSON_Output then Write_Max_Errors; end if; -- Even though Warning_Info_Messages are a subclass of warnings, they -- must not be treated as errors when -gnatwe is in effect. if Warning_Mode = Treat_As_Error then declare Compile_Time_Pragma_Warnings : constant Int := Count_Compile_Time_Pragma_Warnings; begin Total_Errors_Detected := Total_Errors_Detected + Warnings_Detected - Warning_Info_Messages - Compile_Time_Pragma_Warnings; Warnings_Detected := Warning_Info_Messages + Compile_Time_Pragma_Warnings; end; end if; end Output_Messages; ------------------------ -- Output_Source_Line -- ------------------------ procedure Output_Source_Line (L : Physical_Line_Number; Sfile : Source_File_Index; Errs : Boolean) is S : Source_Ptr; C : Character; Line_Number_Output : Boolean := False; -- Set True once line number is output Empty_Line : Boolean := True; -- Set False if line includes at least one character begin if Sfile /= Current_Error_Source_File then Write_Str ("==============Error messages for "); case Sinput.File_Type (Sfile) is when Sinput.Src => Write_Str ("source"); when Sinput.Config => Write_Str ("configuration pragmas"); when Sinput.Def => Write_Str ("symbol definition"); when Sinput.Preproc => Write_Str ("preprocessing data"); end case; Write_Str (" file: "); Write_Name (Full_File_Name (Sfile)); Write_Eol; if Num_SRef_Pragmas (Sfile) > 0 then Write_Str ("--------------Line numbers from file: "); Write_Name (Full_Ref_Name (Sfile)); Write_Str (" (starting at line "); Write_Int (Int (First_Mapped_Line (Sfile))); Write_Char (')'); Write_Eol; end if; Current_Error_Source_File := Sfile; end if; if Errs or List_Pragmas_Mode then Output_Line_Number (Physical_To_Logical (L, Sfile)); Line_Number_Output := True; end if; S := Line_Start (L, Sfile); loop C := Source_Text (Sfile) (S); exit when C = ASCII.LF or else C = ASCII.CR or else C = EOF; -- Deal with matching entry in List_Pragmas table if Full_List and then List_Pragmas_Index <= List_Pragmas.Last and then S = List_Pragmas.Table (List_Pragmas_Index).Ploc then case List_Pragmas.Table (List_Pragmas_Index).Ptyp is when Page => Write_Char (C); -- Ignore if on line with errors so that error flags -- get properly listed with the error line . if not Errs then Write_Char (ASCII.FF); end if; when List_On => List_Pragmas_Mode := True; if not Line_Number_Output then Output_Line_Number (Physical_To_Logical (L, Sfile)); Line_Number_Output := True; end if; Write_Char (C); when List_Off => Write_Char (C); List_Pragmas_Mode := False; end case; List_Pragmas_Index := List_Pragmas_Index + 1; -- Normal case (no matching entry in List_Pragmas table) else if Errs or List_Pragmas_Mode then Write_Char (C); end if; end if; Empty_Line := False; S := S + 1; end loop; -- If we have output a source line, then add the line terminator, with -- training spaces preserved (so we output the line exactly as input). if Line_Number_Output then if Empty_Line then Write_Eol; else Write_Eol_Keep_Blanks; end if; end if; end Output_Source_Line; ----------------------------- -- Remove_Warning_Messages -- ----------------------------- procedure Remove_Warning_Messages (N : Node_Id) is function Check_For_Warning (N : Node_Id) return Traverse_Result; -- This function checks one node for a possible warning message procedure Check_All_Warnings is new Traverse_Proc (Check_For_Warning); -- This defines the traversal operation ----------------------- -- Check_For_Warning -- ----------------------- function Check_For_Warning (N : Node_Id) return Traverse_Result is Loc : constant Source_Ptr := Sloc (N); E : Error_Msg_Id; function To_Be_Removed (E : Error_Msg_Id) return Boolean; -- Returns True for a message that is to be removed. Also adjusts -- warning count appropriately. ------------------- -- To_Be_Removed -- ------------------- function To_Be_Removed (E : Error_Msg_Id) return Boolean is begin if E /= No_Error_Msg -- Don't remove if location does not match and then Errors.Table (E).Optr = Loc -- Don't remove if not warning/info message. Note that we do -- not remove style messages here. They are warning messages -- but not ones we want removed in this context. and then (Errors.Table (E).Warn or else Errors.Table (E).Warn_Runtime_Raise) -- Don't remove unconditional messages and then not Errors.Table (E).Uncond then if Errors.Table (E).Warn then Warnings_Detected := Warnings_Detected - 1; end if; if Errors.Table (E).Info then Warning_Info_Messages := Warning_Info_Messages - 1; end if; return True; -- No removal required else return False; end if; end To_Be_Removed; -- Start of processing for Check_For_Warnings begin while To_Be_Removed (First_Error_Msg) loop First_Error_Msg := Errors.Table (First_Error_Msg).Next; end loop; if First_Error_Msg = No_Error_Msg then Last_Error_Msg := No_Error_Msg; end if; E := First_Error_Msg; while E /= No_Error_Msg loop while To_Be_Removed (Errors.Table (E).Next) loop Errors.Table (E).Next := Errors.Table (Errors.Table (E).Next).Next; if Errors.Table (E).Next = No_Error_Msg then Last_Error_Msg := E; end if; end loop; E := Errors.Table (E).Next; end loop; if Nkind (N) = N_Raise_Constraint_Error and then Is_Rewrite_Substitution (N) and then No (Condition (N)) then -- Warnings may have been posted on subexpressions of the original -- tree. We place the original node back on the tree to remove -- those warnings, whose sloc do not match those of any node in -- the current tree. Given that we are in unreachable code, this -- modification to the tree is harmless. if Is_List_Member (N) then Set_Condition (N, Original_Node (N)); Check_All_Warnings (Condition (N)); else Rewrite (N, Original_Node (N)); Check_All_Warnings (N); end if; end if; return OK; end Check_For_Warning; -- Start of processing for Remove_Warning_Messages begin if Warnings_Detected /= 0 then Check_All_Warnings (N); end if; end Remove_Warning_Messages; procedure Remove_Warning_Messages (L : List_Id) is Stat : Node_Id; begin Stat := First (L); while Present (Stat) loop Remove_Warning_Messages (Stat); Next (Stat); end loop; end Remove_Warning_Messages; -------------------- -- Reset_Warnings -- -------------------- procedure Reset_Warnings is begin Warnings_Treated_As_Errors := 0; Warnings_Detected := 0; Warning_Info_Messages := 0; Warnings_As_Errors_Count := 0; end Reset_Warnings; ---------------------- -- Adjust_Name_Case -- ---------------------- procedure Adjust_Name_Case (Buf : in out Bounded_String; Loc : Source_Ptr) is Src_Ind : constant Source_File_Index := Get_Source_File_Index (Loc); Sbuffer : Source_Buffer_Ptr; Ref_Ptr : Integer; Src_Ptr : Source_Ptr; begin -- We have an all lower case name from Namet, and now we want to set -- the appropriate case. If possible we copy the actual casing from -- the source. If not we use standard identifier casing. Ref_Ptr := 1; Src_Ptr := Loc; -- For standard locations, always use mixed case if Loc <= No_Location then Set_Casing (Buf, Mixed_Case); else -- Determine if the reference we are dealing with corresponds to text -- at the point of the error reference. This will often be the case -- for simple identifier references, and is the case where we can -- copy the casing from the source. Sbuffer := Source_Text (Src_Ind); while Ref_Ptr <= Buf.Length loop exit when Fold_Lower (Sbuffer (Src_Ptr)) /= Fold_Lower (Buf.Chars (Ref_Ptr)); Ref_Ptr := Ref_Ptr + 1; Src_Ptr := Src_Ptr + 1; end loop; -- If we get through the loop without a mismatch, then output the -- name the way it is cased in the source program. if Ref_Ptr > Buf.Length then Src_Ptr := Loc; for J in 1 .. Buf.Length loop Buf.Chars (J) := Sbuffer (Src_Ptr); Src_Ptr := Src_Ptr + 1; end loop; -- Otherwise set the casing using the default identifier casing else Set_Casing (Buf, Identifier_Casing (Src_Ind)); end if; end if; end Adjust_Name_Case; --------------------------- -- Set_Identifier_Casing -- --------------------------- procedure Set_Identifier_Casing (Identifier_Name : System.Address; File_Name : System.Address) is Ident : constant Big_String_Ptr := To_Big_String_Ptr (Identifier_Name); File : constant Big_String_Ptr := To_Big_String_Ptr (File_Name); Flen : Natural; Desired_Case : Casing_Type := Mixed_Case; -- Casing required for result. Default value of Mixed_Case is used if -- for some reason we cannot find the right file name in the table. begin -- Get length of file name Flen := 0; while File (Flen + 1) /= ASCII.NUL loop Flen := Flen + 1; end loop; -- Loop through file names to find matching one. This is a bit slow, but -- we only do it in error situations so it is not so terrible. Note that -- if the loop does not exit, then the desired case will be left set to -- Mixed_Case, this can happen if the name was not in canonical form. for J in 1 .. Last_Source_File loop Get_Name_String (Full_Debug_Name (J)); if Name_Len = Flen and then Name_Buffer (1 .. Name_Len) = String (File (1 .. Flen)) then Desired_Case := Identifier_Casing (J); exit; end if; end loop; -- Copy identifier as given to Name_Buffer for J in Name_Buffer'Range loop Name_Buffer (J) := Ident (J); if Name_Buffer (J) = ASCII.NUL then Name_Len := J - 1; exit; end if; end loop; Set_Casing (Desired_Case); end Set_Identifier_Casing; ----------------------- -- Set_Ignore_Errors -- ----------------------- procedure Set_Ignore_Errors (To : Boolean) is begin Errors_Must_Be_Ignored := To; end Set_Ignore_Errors; ------------------------------ -- Set_Msg_Insertion_Column -- ------------------------------ procedure Set_Msg_Insertion_Column is begin if RM_Column_Check then Set_Msg_Str (" in column "); Set_Msg_Int (Int (Error_Msg_Col) + 1); end if; end Set_Msg_Insertion_Column; ---------------------------- -- Set_Msg_Insertion_Node -- ---------------------------- procedure Set_Msg_Insertion_Node is K : Node_Kind; begin Suppress_Message := Error_Msg_Node_1 = Error or else Error_Msg_Node_1 = Any_Type; if Error_Msg_Node_1 = Empty then Set_Msg_Blank_Conditional; Set_Msg_Str ("<empty>"); elsif Error_Msg_Node_1 = Error then Set_Msg_Blank; Set_Msg_Str ("<error>"); elsif Error_Msg_Node_1 = Standard_Void_Type then Set_Msg_Blank; Set_Msg_Str ("procedure name"); elsif Nkind (Error_Msg_Node_1) in N_Entity and then Ekind (Error_Msg_Node_1) = E_Anonymous_Access_Subprogram_Type then Set_Msg_Blank; Set_Msg_Str ("access to subprogram"); else Set_Msg_Blank_Conditional; -- Output name K := Nkind (Error_Msg_Node_1); -- If we have operator case, skip quotes since name of operator -- itself will supply the required quotations. An operator can be an -- applied use in an expression or an explicit operator symbol, or an -- identifier whose name indicates it is an operator. if K in N_Op or else K = N_Operator_Symbol or else K = N_Defining_Operator_Symbol or else ((K = N_Identifier or else K = N_Defining_Identifier) and then Is_Operator_Name (Chars (Error_Msg_Node_1))) then Set_Msg_Node (Error_Msg_Node_1); -- Normal case, not an operator, surround with quotes else Set_Msg_Quote; Set_Qualification (Error_Msg_Qual_Level, Error_Msg_Node_1); Set_Msg_Node (Error_Msg_Node_1); Set_Msg_Quote; end if; end if; -- The following assignment ensures that a second ampersand insertion -- character will correspond to the Error_Msg_Node_2 parameter. Error_Msg_Node_1 := Error_Msg_Node_2; end Set_Msg_Insertion_Node; -------------------------------------- -- Set_Msg_Insertion_Type_Reference -- -------------------------------------- procedure Set_Msg_Insertion_Type_Reference (Flag : Source_Ptr) is Ent : Entity_Id; begin Set_Msg_Blank; if Error_Msg_Node_1 = Standard_Void_Type then Set_Msg_Str ("package or procedure name"); return; elsif Error_Msg_Node_1 = Standard_Exception_Type then Set_Msg_Str ("exception name"); return; elsif Error_Msg_Node_1 = Any_Array or else Error_Msg_Node_1 = Any_Boolean or else Error_Msg_Node_1 = Any_Character or else Error_Msg_Node_1 = Any_Composite or else Error_Msg_Node_1 = Any_Discrete or else Error_Msg_Node_1 = Any_Fixed or else Error_Msg_Node_1 = Any_Integer or else Error_Msg_Node_1 = Any_Modular or else Error_Msg_Node_1 = Any_Numeric or else Error_Msg_Node_1 = Any_Real or else Error_Msg_Node_1 = Any_Scalar or else Error_Msg_Node_1 = Any_String then Get_Unqualified_Decoded_Name_String (Chars (Error_Msg_Node_1)); Set_Msg_Name_Buffer; return; elsif Error_Msg_Node_1 = Universal_Integer then Set_Msg_Str ("type universal integer"); return; elsif Error_Msg_Node_1 = Universal_Real then Set_Msg_Str ("type universal real"); return; elsif Error_Msg_Node_1 = Universal_Fixed then Set_Msg_Str ("type universal fixed"); return; elsif Error_Msg_Node_1 = Universal_Access then Set_Msg_Str ("type universal access"); return; end if; -- Special case of anonymous array if Nkind (Error_Msg_Node_1) in N_Entity and then Is_Array_Type (Error_Msg_Node_1) and then Present (Related_Array_Object (Error_Msg_Node_1)) then Set_Msg_Str ("type of "); Set_Msg_Node (Related_Array_Object (Error_Msg_Node_1)); Set_Msg_Str (" declared"); Set_Msg_Insertion_Line_Number (Sloc (Related_Array_Object (Error_Msg_Node_1)), Flag); return; end if; -- If we fall through, it is not a special case, so first output -- the name of the type, preceded by private for a private type if Is_Private_Type (Error_Msg_Node_1) then Set_Msg_Str ("private type "); else Set_Msg_Str ("type "); end if; Ent := Error_Msg_Node_1; if Is_Internal_Name (Chars (Ent)) then Unwind_Internal_Type (Ent); end if; -- Types in Standard are displayed as "Standard.name" if Sloc (Ent) <= Standard_Location then Set_Msg_Quote; Set_Msg_Str ("Standard."); Set_Msg_Node (Ent); Add_Class; Set_Msg_Quote; -- Types in other language defined units are displayed as -- "package-name.type-name" elsif Is_Predefined_Unit (Get_Source_Unit (Ent)) then Get_Unqualified_Decoded_Name_String (Unit_Name (Get_Source_Unit (Ent))); Name_Len := Name_Len - 2; Set_Msg_Blank_Conditional; Set_Msg_Quote; Set_Casing (Mixed_Case); Set_Msg_Name_Buffer; Set_Msg_Char ('.'); Set_Casing (Mixed_Case); Set_Msg_Node (Ent); Add_Class; Set_Msg_Quote; -- All other types display as "type name" defined at line xxx -- possibly qualified if qualification is requested. else Set_Msg_Quote; Set_Qualification (Error_Msg_Qual_Level, Ent); Set_Msg_Node (Ent); Add_Class; -- If we did not print a name (e.g. in the case of an anonymous -- subprogram type), there is no name to print, so remove quotes. if Buffer_Ends_With ('"') then Buffer_Remove ('"'); else Set_Msg_Quote; end if; end if; -- If the original type did not come from a predefined file, add the -- location where the type was defined. if Sloc (Error_Msg_Node_1) > Standard_Location and then not Is_Predefined_Unit (Get_Source_Unit (Error_Msg_Node_1)) then Get_Name_String (Unit_File_Name (Get_Source_Unit (Error_Msg_Node_1))); Set_Msg_Str (" defined"); Set_Msg_Insertion_Line_Number (Sloc (Error_Msg_Node_1), Flag); -- If it did come from a predefined file, deal with the case where -- this was a file with a generic instantiation from elsewhere. else if Sloc (Error_Msg_Node_1) > Standard_Location then declare Iloc : constant Source_Ptr := Instantiation_Location (Sloc (Error_Msg_Node_1)); begin if Iloc /= No_Location and then not Suppress_Instance_Location then Set_Msg_Str (" from instance"); Set_Msg_Insertion_Line_Number (Iloc, Flag); end if; end; end if; end if; end Set_Msg_Insertion_Type_Reference; --------------------------------- -- Set_Msg_Insertion_Unit_Name -- --------------------------------- procedure Set_Msg_Insertion_Unit_Name (Suffix : Boolean := True) is begin if Error_Msg_Unit_1 = No_Unit_Name then null; elsif Error_Msg_Unit_1 = Error_Unit_Name then Set_Msg_Blank; Set_Msg_Str ("<error>"); else Get_Unit_Name_String (Error_Msg_Unit_1, Suffix); Set_Msg_Blank; Set_Msg_Quote; Set_Msg_Name_Buffer; Set_Msg_Quote; end if; -- The following assignment ensures that a second percent insertion -- character will correspond to the Error_Msg_Unit_2 parameter. Error_Msg_Unit_1 := Error_Msg_Unit_2; end Set_Msg_Insertion_Unit_Name; ------------------ -- Set_Msg_Node -- ------------------ procedure Set_Msg_Node (Node : Node_Id) is Loc : Source_Ptr; Ent : Entity_Id; Nam : Name_Id; begin case Nkind (Node) is when N_Designator => Set_Msg_Node (Name (Node)); Set_Msg_Char ('.'); Set_Msg_Node (Identifier (Node)); return; when N_Defining_Program_Unit_Name => Set_Msg_Node (Name (Node)); Set_Msg_Char ('.'); Set_Msg_Node (Defining_Identifier (Node)); return; when N_Expanded_Name | N_Selected_Component => Set_Msg_Node (Prefix (Node)); Set_Msg_Char ('.'); Set_Msg_Node (Selector_Name (Node)); return; when others => null; end case; -- The only remaining possibilities are identifiers, defining -- identifiers, pragmas, and pragma argument associations. if Nkind (Node) = N_Pragma then Nam := Pragma_Name (Node); Loc := Sloc (Node); -- The other cases have Chars fields -- First deal with internal names, which generally represent something -- gone wrong. First attempt: if this is a rewritten node that rewrites -- something with a Chars field that is not an internal name, use that. elsif Is_Internal_Name (Chars (Node)) and then Nkind (Original_Node (Node)) in N_Has_Chars and then not Is_Internal_Name (Chars (Original_Node (Node))) then Nam := Chars (Original_Node (Node)); Loc := Sloc (Original_Node (Node)); -- Another shot for internal names, in the case of internal type names, -- we try to find a reasonable representation for the external name. elsif Is_Internal_Name (Chars (Node)) and then ((Is_Entity_Name (Node) and then Present (Entity (Node)) and then Is_Type (Entity (Node))) or else (Nkind (Node) = N_Defining_Identifier and then Is_Type (Node))) then if Nkind (Node) = N_Identifier then Ent := Entity (Node); else Ent := Node; end if; Loc := Sloc (Ent); -- If the type is the designated type of an access_to_subprogram, -- then there is no name to provide in the call. if Ekind (Ent) = E_Subprogram_Type then return; -- Otherwise, we will be able to find some kind of name to output else Unwind_Internal_Type (Ent); Nam := Chars (Ent); end if; -- If not internal name, or if we could not find a reasonable possible -- substitution for the internal name, just use name in Chars field. else Nam := Chars (Node); Loc := Sloc (Node); end if; -- At this stage, the name to output is in Nam Get_Unqualified_Decoded_Name_String (Nam); -- Remove trailing upper case letters from the name (useful for -- dealing with some cases of internal names). while Name_Len > 1 and then Name_Buffer (Name_Len) in 'A' .. 'Z' loop Name_Len := Name_Len - 1; end loop; -- If we have any of the names from standard that start with the -- characters "any " (e.g. Any_Type), then kill the message since -- almost certainly it is a junk cascaded message. if Name_Len > 4 and then Name_Buffer (1 .. 4) = "any " then Kill_Message := True; end if; -- If we still have an internal name, kill the message (will only -- work if we already had errors!) if Is_Internal_Name then Kill_Message := True; end if; -- Remaining step is to adjust casing and possibly add 'Class Adjust_Name_Case (Global_Name_Buffer, Loc); Set_Msg_Name_Buffer; Add_Class; end Set_Msg_Node; ------------------ -- Set_Msg_Text -- ------------------ procedure Set_Msg_Text (Text : String; Flag : Source_Ptr) is C : Character; -- Current character P : Natural; -- Current index; procedure Skip_Msg_Insertion_Warning (C : Character); -- Skip the ? ?? ?x? ?*? ?$? insertion sequences (and the same -- sequences using < instead of ?). The caller has already bumped -- the pointer past the initial ? or < and C is set to this initial -- character (? or <). This procedure skips past the rest of the -- sequence. We do not need to set Msg_Insertion_Char, since this -- was already done during the message prescan. -- No validity check is performed as the insertion sequence is -- supposed to be sane. See Prescan_Message.Parse_Message_Class in -- erroutc.adb for the validity checks. -------------------------------- -- Skip_Msg_Insertion_Warning -- -------------------------------- procedure Skip_Msg_Insertion_Warning (C : Character) is begin if P <= Text'Last and then Text (P) = C then P := P + 1; elsif P < Text'Last and then Text (P + 1) = C and then Text (P) in 'a' .. 'z' | '*' | '$' then P := P + 2; elsif P + 1 < Text'Last and then Text (P + 2) = C and then Text (P) in '.' | '_' and then Text (P + 1) in 'a' .. 'z' then P := P + 3; end if; end Skip_Msg_Insertion_Warning; -- Start of processing for Set_Msg_Text begin Manual_Quote_Mode := False; Msglen := 0; Flag_Source := Get_Source_File_Index (Flag); -- Skip info: at start, we have recorded this in Is_Info_Msg, and this -- will be used (Info field in error message object) to put back the -- string when it is printed. We need to do this, or we get confused -- with instantiation continuations. if Text'Length > 6 and then Text (Text'First .. Text'First + 5) = "info: " then P := Text'First + 6; else P := Text'First; end if; -- Loop through characters of message while P <= Text'Last loop C := Text (P); P := P + 1; -- Check for insertion character or sequence case C is when '%' => if P <= Text'Last and then Text (P) = '%' then P := P + 1; Set_Msg_Insertion_Name_Literal; else Set_Msg_Insertion_Name; end if; when '$' => if P <= Text'Last and then Text (P) = '$' then P := P + 1; Set_Msg_Insertion_Unit_Name (Suffix => False); else Set_Msg_Insertion_Unit_Name; end if; when '{' => Set_Msg_Insertion_File_Name; when '}' => Set_Msg_Insertion_Type_Reference (Flag); when '*' => Set_Msg_Insertion_Reserved_Name; when '&' => Set_Msg_Insertion_Node; when '#' => Set_Msg_Insertion_Line_Number (Error_Msg_Sloc, Flag); when '\' => Continuation := True; if P <= Text'Last and then Text (P) = '\' then Continuation_New_Line := True; P := P + 1; end if; when '@' => Set_Msg_Insertion_Column; when '>' => Set_Msg_Insertion_Run_Time_Name; when '^' => Set_Msg_Insertion_Uint; when '`' => Manual_Quote_Mode := not Manual_Quote_Mode; Set_Msg_Char ('"'); when '!' => null; -- already dealt with when '?' => Skip_Msg_Insertion_Warning ('?'); when '<' => Skip_Msg_Insertion_Warning ('<'); when '|' => null; -- already dealt with when ''' => Set_Msg_Char (Text (P)); P := P + 1; when '~' => Set_Msg_Str (Error_Msg_String (1 .. Error_Msg_Strlen)); -- Upper case letter when 'A' .. 'Z' => -- Start of reserved word if two or more if P <= Text'Last and then Text (P) in 'A' .. 'Z' then P := P - 1; Set_Msg_Insertion_Reserved_Word (Text, P); -- Single upper case letter is just inserted else Set_Msg_Char (C); end if; -- '[' (will be/would have been raised at run time) when '[' => -- Switch the message from a warning to an error if the flag -- -gnatwE is specified to treat run-time exception warnings -- as errors. if Is_Warning_Msg and then Warning_Mode = Treat_Run_Time_Warnings_As_Errors then Is_Warning_Msg := False; Is_Runtime_Raise := True; end if; if Is_Warning_Msg then Set_Msg_Str ("will be raised at run time"); else Set_Msg_Str ("would have been raised at run time"); end if; -- ']' (may be/might have been raised at run time) when ']' => if Is_Warning_Msg then Set_Msg_Str ("may be raised at run time"); else Set_Msg_Str ("might have been raised at run time"); end if; -- Normal character with no special treatment when others => Set_Msg_Char (C); end case; end loop; end Set_Msg_Text; ---------------- -- Set_Posted -- ---------------- procedure Set_Posted (N : Node_Id) is P : Node_Id; begin if Is_Serious_Error then -- We always set Error_Posted on the node itself Set_Error_Posted (N); -- If it is a subexpression, then set Error_Posted on parents up to -- and including the first non-subexpression construct. This helps -- avoid cascaded error messages within a single expression. P := N; loop P := Parent (P); exit when No (P); Set_Error_Posted (P); exit when Nkind (P) not in N_Subexpr; end loop; if Nkind (P) in N_Pragma_Argument_Association | N_Component_Association | N_Discriminant_Association | N_Generic_Association | N_Parameter_Association then Set_Error_Posted (Parent (P)); end if; -- A special check, if we just posted an error on an attribute -- definition clause, then also set the entity involved as posted. -- For example, this stops complaining about the alignment after -- complaining about the size, which is likely to be useless. if Nkind (P) = N_Attribute_Definition_Clause then if Is_Entity_Name (Name (P)) then Set_Error_Posted (Entity (Name (P))); end if; end if; end if; end Set_Posted; ----------------------- -- Set_Qualification -- ----------------------- procedure Set_Qualification (N : Nat; E : Entity_Id) is begin if N /= 0 and then Scope (E) /= Standard_Standard then Set_Qualification (N - 1, Scope (E)); Set_Msg_Node (Scope (E)); Set_Msg_Char ('.'); end if; end Set_Qualification; ------------------------ -- Special_Msg_Delete -- ------------------------ -- Is it really right to have all this specialized knowledge in errout? function Special_Msg_Delete (Msg : String; N : Node_Or_Entity_Id; E : Node_Or_Entity_Id) return Boolean is begin -- Never delete messages in -gnatdO mode if Debug_Flag_OO then return False; -- Processing for "Size too small" messages elsif Is_Size_Too_Small_Message (Msg) then -- Suppress "size too small" errors in CodePeer mode, since code may -- be analyzed in a different configuration than the one used for -- compilation. Even when the configurations match, this message -- may be issued on correct code, because pragma Pack is ignored -- in CodePeer mode. if CodePeer_Mode then return True; -- When a size is wrong for a frozen type there is no explicit size -- clause, and other errors have occurred, suppress the message, -- since it is likely that this size error is a cascaded result of -- other errors. The reason we eliminate unfrozen types is that -- messages issued before the freeze type are for sure OK. elsif Nkind (N) in N_Entity and then Is_Frozen (E) and then Serious_Errors_Detected > 0 and then Nkind (N) /= N_Component_Clause and then Nkind (Parent (N)) /= N_Component_Clause and then No (Get_Attribute_Definition_Clause (E, Attribute_Size)) and then No (Get_Attribute_Definition_Clause (E, Attribute_Object_Size)) and then No (Get_Attribute_Definition_Clause (E, Attribute_Value_Size)) then return True; end if; end if; -- All special tests complete, so go ahead with message return False; end Special_Msg_Delete; ----------------- -- SPARK_Msg_N -- ----------------- procedure SPARK_Msg_N (Msg : String; N : Node_Or_Entity_Id) is begin if SPARK_Mode /= Off then Error_Msg_N (Msg, N); end if; end SPARK_Msg_N; ------------------ -- SPARK_Msg_NE -- ------------------ procedure SPARK_Msg_NE (Msg : String; N : Node_Or_Entity_Id; E : Node_Or_Entity_Id) is begin if SPARK_Mode /= Off then Error_Msg_NE (Msg, N, E); end if; end SPARK_Msg_NE; -------------------------- -- Unwind_Internal_Type -- -------------------------- procedure Unwind_Internal_Type (Ent : in out Entity_Id) is Derived : Boolean := False; Mchar : Character; Old_Ent : Entity_Id; begin -- Undo placement of a quote, since we will put it back later Mchar := Msg_Buffer (Msglen); if Mchar = '"' then Msglen := Msglen - 1; end if; -- The loop here deals with recursive types, we are trying to find a -- related entity that is not an implicit type. Note that the check with -- Old_Ent stops us from getting "stuck". Also, we don't output the -- "type derived from" message more than once in the case where we climb -- up multiple levels. Find : loop Old_Ent := Ent; -- Implicit access type, use directly designated type In Ada 2005, -- the designated type may be an anonymous access to subprogram, in -- which case we can only point to its definition. if Is_Access_Type (Ent) then if Ekind (Ent) = E_Access_Subprogram_Type or else Ekind (Ent) = E_Anonymous_Access_Subprogram_Type or else Is_Access_Protected_Subprogram_Type (Ent) then Ent := Directly_Designated_Type (Ent); if not Comes_From_Source (Ent) then if Buffer_Ends_With ("type ") then Buffer_Remove ("type "); end if; end if; if Ekind (Ent) = E_Function then Set_Msg_Str ("access to function "); elsif Ekind (Ent) = E_Procedure then Set_Msg_Str ("access to procedure "); else Set_Msg_Str ("access to subprogram"); end if; exit Find; -- Type is access to object, named or anonymous else Set_Msg_Str ("access to "); Ent := Directly_Designated_Type (Ent); end if; -- Classwide type elsif Is_Class_Wide_Type (Ent) then Class_Flag := True; Ent := Root_Type (Ent); -- Use base type if this is a subtype elsif Ent /= Base_Type (Ent) then Buffer_Remove ("type "); -- Avoid duplication "subtype of subtype of", and also replace -- "derived from subtype of" simply by "derived from" if not Buffer_Ends_With ("subtype of ") and then not Buffer_Ends_With ("derived from ") then Set_Msg_Str ("subtype of "); end if; Ent := Base_Type (Ent); -- If this is a base type with a first named subtype, use the first -- named subtype instead. This is not quite accurate in all cases, -- but it makes too much noise to be accurate and add 'Base in all -- cases. Note that we only do this is the first named subtype is not -- itself an internal name. This avoids the obvious loop (subtype -> -- basetype -> subtype) which would otherwise occur). else declare FST : constant Entity_Id := First_Subtype (Ent); begin if not Is_Internal_Name (Chars (FST)) then Ent := FST; exit Find; -- Otherwise use root type else if not Derived then Buffer_Remove ("type "); -- Test for "subtype of type derived from" which seems -- excessive and is replaced by "type derived from". Buffer_Remove ("subtype of"); -- Avoid duplicated "type derived from type derived from" if not Buffer_Ends_With ("type derived from ") then Set_Msg_Str ("type derived from "); end if; Derived := True; end if; end if; end; Ent := Etype (Ent); end if; -- If we are stuck in a loop, get out and settle for the internal -- name after all. In this case we set to kill the message if it is -- not the first error message (we really try hard not to show the -- dirty laundry of the implementation to the poor user). if Ent = Old_Ent then Kill_Message := True; exit Find; end if; -- Get out if we finally found a non-internal name to use exit Find when not Is_Internal_Name (Chars (Ent)); end loop Find; if Mchar = '"' then Set_Msg_Char ('"'); end if; end Unwind_Internal_Type; -------------------- -- Warn_Insertion -- -------------------- function Warn_Insertion return String is begin if Warning_Msg_Char = "? " then return "??"; elsif Warning_Msg_Char = " " then return "?"; elsif Warning_Msg_Char (2) = ' ' then return '?' & Warning_Msg_Char (1) & '?'; else return '?' & Warning_Msg_Char & '?'; end if; end Warn_Insertion; end Errout;
stcarrez/mat
Ada
1,747
adb
----------------------------------------------------------------------- -- mat-readers-tests -- Unit tests for MAT readers -- Copyright (C) 2014, 2019, 2021 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Test_Caller; with MAT.Readers.Streams.Files; package body MAT.Readers.Tests is package Caller is new Util.Test_Caller (Test, "Files"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test MAT.Readers.Read_File", Test_Read_File'Access); end Add_Tests; -- ------------------------------ -- Test reading a file into a string -- Reads this ada source file and checks we have read it correctly -- ------------------------------ procedure Test_Read_File (T : in out Test) is pragma Unreferenced (T); Path : constant String := Util.Tests.Get_Path ("regtests/files/file-v1.dat"); Reader : MAT.Readers.Streams.Files.File_Reader_Type; begin Reader.Open (Path); Reader.Read_All; end Test_Read_File; end MAT.Readers.Tests;
io7m/coreland-sdl-ada
Ada
604
adb
package body SDL is use type C.int; function InitSubSystem (Flags : Init_Flags_t) return Boolean is Ret : constant C.int := InitSubSystem (Flags); begin return Ret /= -1; end InitSubSystem; function WasInit (Flags : Init_Flags_t) return Boolean is Ret : constant Init_Flags_t := WasInit (Flags); Rfa : constant Init_Flags_t := Ret and Flags; begin if Rfa = Flags then return True; else return False; end if; end WasInit; function Init (Flags : Init_Flags_t) return Boolean is begin return C.int'(Init (Flags)) /= -1; end Init; end SDL;
sf17k/sdlada
Ada
2,208
ads
-------------------------------------------------------------------------------------------------------------------- -- Copyright (c) 2014-2015 Luke A. Guest -- -- This software is provided 'as-is', without any express or implied -- warranty. In no event will the authors be held liable for any damages -- arising from the use of this software. -- -- Permission is granted to anyone to use this software for any purpose, -- including commercial applications, and to alter it and redistribute it -- freely, subject to the following restrictions: -- -- 1. The origin of this software must not be misrepresented; you must not -- claim that you wrote the original software. If you use this software -- in a product, an acknowledgment in the product documentation would be -- appreciated but is not required. -- -- 2. Altered source versions must be plainly marked as such, and must not be -- misrepresented as being the original software. -- -- 3. This notice may not be removed or altered from any source -- distribution. -------------------------------------------------------------------------------------------------------------------- -- SDL.CPUS -- -- Platform CPU information retrieval. -------------------------------------------------------------------------------------------------------------------- package SDL.CPUS is -- TODO: Add a subprogram to return CPU architecture as not all platforms will have the same one, i.e. -- Android on ARM, MIPS, x86. function Count return Positive; function Cache_Line_Size return Positive with Inline => True; function Has_3DNow return Boolean with Inline => True; function Has_AltiVec return Boolean with Inline => True; function Has_MMX return Boolean with Inline => True; function Has_RDTSC return Boolean with Inline => True; function Has_SSE return Boolean with Inline => True; function Has_SSE_2 return Boolean with Inline => True; function Has_SSE_3 return Boolean with Inline => True; function Has_SSE_4_1 return Boolean with Inline => True; function Has_SSE_4_2 return Boolean with Inline => True; end SDL.CPUS;
AdaCore/Ada_Drivers_Library
Ada
4,621
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2016-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. -- -- -- ------------------------------------------------------------------------------ package STM32.Power_Control is procedure Enable; -- Enable power control module procedure Disable_Backup_Domain_Protection; procedure Enable_Backup_Domain_Protection; function Standby_Flag return Boolean; -- This flag is set by hardware and cleared only by a POR/PDR (power-on -- reset/power-down reset) or by calling the Clear_Standby_Flag procedure. procedure Clear_Standby_Flag; procedure Set_Power_Down_Deepsleep (Enabled : Boolean := True); -- When enabled, the MCU enters Standby mode when CPU enters deepsleep. -- When disabled, the MCU enters Stop mode when CPU enters deepsleep. procedure Set_Low_Power_Deepsleep (Enabled : Boolean := True); -- When enabled, the voltage regulator is in low-power during MCU Stop mode. -- When disabled, the voltage regulator is on during MCU Stop mode. type Wakeup_Pin is range 1 .. 6; -- Pin 1 -> PA0 -- Pin 2 -> PA2 -- Pin 3 -> PC1 -- Pin 4 -> PC13 -- Pin 5 -> PI8 -- Pin 6 -> PI11 type Wakeup_Pin_Polarity is (Rising_Edge, Falling_Edge); function Wakeup_Flag (Pin : Wakeup_Pin) return Boolean; -- This flag is set by hardware and cleared either by a system reset or by -- calling the Clear_Wakeup_Flag procedure. procedure Clear_Wakeup_Flag (Pin : Wakeup_Pin); procedure Enable_Wakeup_Pin (Pin : Wakeup_Pin; Enabled : Boolean := True); -- When enabled, the wakeup pin (PA0) is used for wakeup from Standby mode -- and forced in input pull down configuration (rising edge on WKUP pin -- wakes-up the system from Standby mode). -- When disabled, the wakeup pin is used for general purpose I/O. An event -- on the wakeup pin does not wakeup the device from Standby mode. procedure Set_Wakeup_Pin_Polarity (Pin : Wakeup_Pin; Pol : Wakeup_Pin_Polarity); -- Set the polarity used for event detection on external wake-up pin procedure Enter_Standby_Mode with No_Return; -- Clear the wakeup and standby flag, set the power-down on CPU deep sleep -- and trigger MCU deep sleep. -- MCU gets out of standby with a reset, so this procedure does not return. end STM32.Power_Control;
reznikmm/matreshka
Ada
3,743
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ package Matreshka.ODF_Attributes.Style.Width is type Style_Width_Node is new Matreshka.ODF_Attributes.Style.Style_Node_Base with null record; type Style_Width_Access is access all Style_Width_Node'Class; overriding function Get_Local_Name (Self : not null access constant Style_Width_Node) return League.Strings.Universal_String; end Matreshka.ODF_Attributes.Style.Width;
reznikmm/matreshka
Ada
3,872
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.ODF_Attributes.FO.Background_Color; package ODF.DOM.Attributes.FO.Background_Color.Internals is function Create (Node : Matreshka.ODF_Attributes.FO.Background_Color.FO_Background_Color_Access) return ODF.DOM.Attributes.FO.Background_Color.ODF_FO_Background_Color; function Wrap (Node : Matreshka.ODF_Attributes.FO.Background_Color.FO_Background_Color_Access) return ODF.DOM.Attributes.FO.Background_Color.ODF_FO_Background_Color; end ODF.DOM.Attributes.FO.Background_Color.Internals;
AdaCore/libadalang
Ada
264
adb
procedure A is type T is range 1 .. 10; type U is range 1 .. 10; function "-" (Left : T; Right : U) return U is (1); N : constant := 5; X : constant T := 2; Y : T; Z : U; begin Y := N * (X - 1); pragma Test_Statement; end A;
reznikmm/webdriver
Ada
2,346
adb
with Ada.Wide_Wide_Text_IO; with League.Strings; with League.JSON.Arrays; with League.JSON.Objects; with League.JSON.Values; with WebDriver.Drivers; with WebDriver.Elements; with WebDriver.Remote; with WebDriver.Sessions; procedure Test is function "+" (Text : Wide_Wide_String) return League.Strings.Universal_String renames League.Strings.To_Universal_String; function Headless return League.JSON.Values.JSON_Value; -------------- -- Headless -- -------------- function Headless return League.JSON.Values.JSON_Value is Cap : League.JSON.Objects.JSON_Object; Options : League.JSON.Objects.JSON_Object; Args : League.JSON.Arrays.JSON_Array; begin return Cap.To_JSON_Value; pragma Warnings (Off); Args.Append (League.JSON.Values.To_JSON_Value (+"--headless")); Args.Append (League.JSON.Values.To_JSON_Value (+"--disable-extensions")); Args.Append (League.JSON.Values.To_JSON_Value (+"--no-sandbox")); Options.Insert (+"args", Args.To_JSON_Value); Options.Insert (+"binary", League.JSON.Values.To_JSON_Value (+"/usr/lib64/chromium-browser/headless_shell")); Cap.Insert (+"chromeOptions", Options.To_JSON_Value); return Cap.To_JSON_Value; end Headless; Web_Driver : aliased WebDriver.Drivers.Driver'Class := WebDriver.Remote.Create (+"http://127.0.0.1:9515"); Session : constant WebDriver.Sessions.Session_Access := Web_Driver.New_Session (Headless); begin Session.Go (+"http://www.ada-ru.org/"); Ada.Wide_Wide_Text_IO.Put_Line (Session.Get_Current_URL.To_Wide_Wide_String); declare Body_Element : constant WebDriver.Elements.Element_Access := Session.Find_Element (Strategy => WebDriver.Tag_Name, Selector => +"body"); begin Ada.Wide_Wide_Text_IO.Put_Line ("Selected=" & Boolean'Wide_Wide_Image (Body_Element.Is_Selected)); Ada.Wide_Wide_Text_IO.Put_Line ("itemtype=" & Body_Element.Get_Attribute (+"itemtype").To_Wide_Wide_String); Ada.Wide_Wide_Text_IO.Put_Line ("height=" & Body_Element.Get_CSS_Value (+"height").To_Wide_Wide_String); Ada.Wide_Wide_Text_IO.Put_Line ("tag=" & Body_Element.Get_Tag_Name.To_Wide_Wide_String); end; end Test;
yannickmoy/bbqueue-ada
Ada
9,857
adb
-- with Ada.Text_IO; use Ada.Text_IO; with Atomic; use Atomic; package body BBqueue with SPARK_Mode => On is ----------- -- Grant -- ----------- procedure Grant (This : in out Offsets_Only; G : in out Write_Grant; Size : Count) is Read, Write, Start : Count; Max : constant Count := This.Size; Already_Inverted : Boolean; In_Progress : Boolean; begin if Size = 0 then G.Result := Empty; G.Slice := Empty_Slice; return; end if; Test_And_Set (This.Write_In_Progress, In_Progress, Acq_Rel); if In_Progress then G.Result := Grant_In_Progress; G.Slice := Empty_Slice; return; end if; if Size > This.Size then Clear (This.Write_In_Progress, Release); G.Result := Insufficient_Size; G.Slice := Empty_Slice; return; end if; -- Writer component. Must never write to `read`, -- be careful writing to `load` Write := Atomic_Count.Load (This.Write, Acquire); Read := Atomic_Count.Load (This.Read, Acquire); Already_Inverted := Write < Read; if Already_Inverted then -- The original comparison is ((Write + Size) < Read), it is modified -- to avoid integer overflow. if Count'Last - Size >= Write and then (Write + Size) < Read then -- Inverted, room is still available Start := Write; else -- Inverted, no room is available Clear (This.Write_In_Progress, Release); G.Result := Insufficient_Size; G.Slice := Empty_Slice; This.Granted_Write_Size := 0; return; end if; else -- The original comparison is ((Write + Size) <= Max), it is modified -- to avoid integer overflow. if Count'Last - Size >= Write and then (Write + Size) <= Max then -- Non inverted condition Start := Write; else -- Not inverted, but need to go inverted -- NOTE: We check Size < Read, NOT <=, because -- write must never == read in an inverted condition, since -- we will then not be able to tell if we are inverted or not if Size < Read then Start := 0; else -- Inverted, no room is available Clear (This.Write_In_Progress, Release); G.Result := Insufficient_Size; G.Slice := Empty_Slice; This.Granted_Write_Size := 0; return; end if; end if; end if; -- This is what we want to prove: the granted slice is in the writeable -- area. pragma Assert (Size /= 0); pragma Assert (In_Writable_Area (This, Start)); pragma Assert (In_Writable_Area (This, Start + Size - 1)); Atomic_Count.Store (This.Reserve, Start + Size, Release); This.Granted_Write_Size := Size; G.Result := Valid; G.Slice := (Size, Start, Start + Size - 1); end Grant; ------------ -- Commit -- ------------ procedure Commit (This : in out Offsets_Only; G : in out Write_Grant; Size : Count := Count'Last) is Used, Write, Last, New_Write : Count; Max : constant Count := This.Size; Len : constant Count := This.Granted_Write_Size; begin -- If there is no grant in progress, return early. This -- generally means we are dropping the grant within a -- wrapper structure if not Set (This.Write_In_Progress, Acquire) then return; end if; -- Writer component. Must never write to READ, -- be careful writing to LAST -- Saturate the grant commit Used := Count'Min (Len, Size); Write := Atomic_Count.Load (This.Write, Acquire); Atomic_Count.Sub (This.Reserve, Len - Used, Acq_Rel); Last := Atomic_Count.Load (This.Last, Acquire); New_Write := Atomic_Count.Load (This.Reserve, Acquire); if (New_Write < Write) and then (Write /= Max) then -- We have already wrapped, but we are skipping some bytes at the end -- of the ring. Mark `last` where the write pointer used to be to hold -- the line here Atomic_Count.Store (This.Last, Write, Release); elsif New_Write > Last then -- We're about to pass the last pointer, which was previously the -- artificial end of the ring. Now that we've passed it, we can -- "unlock" the section that was previously skipped. -- -- Since new_write is strictly larger than last, it is safe to move -- this as the other thread will still be halted by the (about to be -- updated) write value Atomic_Count.Store (This.Last, Max, Release); end if; -- else: If new_write == last, either: -- * last == max, so no need to write, OR -- * If we write in the end chunk again, we'll update last to max next -- time -- * If we write to the start chunk in a wrap, we'll update last when we -- move write backwards -- Write must be updated AFTER last, otherwise read could think it was -- time to invert early! Atomic_Count.Store (This.Write, New_Write, Release); -- Nothing granted anymore This.Granted_Write_Size := 0; G.Result := Empty; G.Slice := Empty_Slice; -- Allow subsequent grants Clear (This.Write_In_Progress, Release); end Commit; ---------- -- Read -- ---------- procedure Read (This : in out Offsets_Only; G : in out Read_Grant; Max : Count := Count'Last) is Read, Write, Last, Size : Count; In_Progress : Boolean; begin Test_And_Set (This.Read_In_Progress, In_Progress, Acq_Rel); if In_Progress then G.Result := Grant_In_Progress; G.Slice := Empty_Slice; return; end if; Write := Atomic_Count.Load (This.Write, Acquire); Read := Atomic_Count.Load (This.Read, Acquire); Last := Atomic_Count.Load (This.Last, Acquire); -- Resolve the inverted case or end of read if Read = Last and then Write < Read then Read := 0; -- This has some room for error, the other thread reads this -- Impact to Grant: -- Grant checks if read < write to see if inverted. If not -- inverted, but no space left, Grant will initiate an inversion, -- but will not trigger it -- Impact to Commit: -- Commit does not check read, but if Grant has started an -- inversion, grant could move Last to the prior write position -- MOVING READ BACKWARDS! Atomic_Count.Store (This.Read, 0, Release); end if; Size := (if Write < Read then Last - Read else Write - Read); -- Bound the slice with the maximum size requested by the user Size := Count'Min (Size, Max); if Size = 0 then Clear (This.Read_In_Progress); G.Result := Empty; G.Slice := Empty_Slice; return; end if; -- This is what we want to prove: the granted slice is in the readable -- area. pragma Assert (Size /= 0); pragma Assert (In_Readable_Area (This, Read)); pragma Assert (In_Readable_Area (This, Read + Size - 1)); This.Granted_Read_Size := Size; G.Result := Valid; G.Slice := (Size, Read, Read + Size - 1); end Read; ------------- -- Release -- ------------- procedure Release (This : in out Offsets_Only; G : in out Read_Grant; Size : Count := Count'Last) is Used : Count; begin -- Saturate the grant commit Used := Count'Min (This.Granted_Read_Size, Size); -- If there is no grant in progress, return early. This -- generally means we are dropping the grant within a -- wrapper structure if not Set (This.Read_In_Progress, Acquire) then return; end if; -- This should always be checked by the public interfaces -- debug_assert! (used <= self.buf.len ()); -- This should be fine, purely incrementing Atomic_Count.Add (This.Read, Used, Release); -- Nothing granted anymore This.Granted_Read_Size := 0; G.Result := Empty; G.Slice := Empty_Slice; -- Allow subsequent read Clear (This.Read_In_Progress, Release); end Release; -- ----------- -- -- Print -- -- ----------- -- -- procedure Print (This : Buffer) is -- procedure Print (Pos : Count; C : Character); -- procedure Print (Pos : Count; C : Character) is -- begin -- for Index in Count range This.Buf'First .. This.Buf'Last + 1 loop -- if Pos = Index then -- Put (C); -- else -- Put (' '); -- end if; -- end loop; -- New_Line; -- end Print; -- use type Interfaces.Unsigned_8; -- begin -- for Index in This.Buf'Range loop -- Put (Character'Val (Character'Pos ('0') + (This.Buf (Index) mod 10))); -- end loop; -- New_Line; -- -- Print (Atomic_Count.Load (This.Write, Seq_Cst) + 1, 'W'); -- Print (Atomic_Count.Load (This.Read, Seq_Cst) + 1, 'R'); -- Print (Atomic_Count.Load (This.Reserve, Seq_Cst) + 1, 'G'); -- Print (Atomic_Count.Load (This.Last, Seq_Cst) + 1, 'L'); -- end Print; end BBqueue;
ohenley/ada-util
Ada
2,361
ads
----------------------------------------------------------------------- -- util-streams-buffered-lzma -- LZMA streams -- Copyright (C) 2018 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Encoders; package Util.Streams.Buffered.Lzma is -- ----------------------- -- Compress stream -- ----------------------- -- The <b>Compress_Stream</b> is an output stream which uses the LZMA encoder to -- compress the data before writing it to the output. type Compress_Stream is limited new Util.Streams.Buffered.Output_Buffer_Stream with private; -- Initialize the stream to write on the given stream. -- An internal buffer is allocated for writing the stream. procedure Initialize (Stream : in out Compress_Stream; Output : in Output_Stream_Access; Size : in Natural; Format : in String); -- Close the sink. overriding procedure Close (Stream : in out Compress_Stream); -- Write the buffer array to the output stream. overriding procedure Write (Stream : in out Compress_Stream; Buffer : in Ada.Streams.Stream_Element_Array); -- Flush the buffer by writing on the output stream. -- Raises Data_Error if there is no output stream. overriding procedure Flush (Stream : in out Compress_Stream); private type Compress_Stream is limited new Util.Streams.Buffered.Output_Buffer_Stream with record Transform : Util.Encoders.Transformer_Access; end record; -- Flush the stream and release the buffer. overriding procedure Finalize (Object : in out Compress_Stream); end Util.Streams.Buffered.Lzma;
sungyeon/drake
Ada
4,572
adb
with Ada.Text_IO.Formatting; with System.Formatting.Literals; with System.Long_Long_Integer_Types; package body Ada.Text_IO.Integer_IO is subtype Word_Integer is System.Long_Long_Integer_Types.Word_Integer; procedure Put_To_Field ( To : out String; Last : out Natural; Item : Num; Base : Number_Base); procedure Put_To_Field ( To : out String; Last : out Natural; Item : Num; Base : Number_Base) is begin if Num'Size > Standard'Word_Size then Formatting.Integer_Image (To, Last, Long_Long_Integer (Item), Base); else Formatting.Integer_Image (To, Last, Word_Integer (Item), Base); end if; end Put_To_Field; procedure Get_From_Field ( From : String; Item : out Num; Last : out Positive); procedure Get_From_Field ( From : String; Item : out Num; Last : out Positive) is begin if Num'Size > Standard'Word_Size then declare Base_Item : Long_Long_Integer; Error : Boolean; begin System.Formatting.Literals.Get_Literal ( From, Last, Base_Item, Error => Error); if Error or else Base_Item not in Long_Long_Integer (Num'First) .. Long_Long_Integer (Num'Last) then raise Data_Error; end if; Item := Num (Base_Item); end; else declare Base_Item : Word_Integer; Error : Boolean; begin System.Formatting.Literals.Get_Literal ( From, Last, Base_Item, Error => Error); if Error or else Base_Item not in Word_Integer (Num'First) .. Word_Integer (Num'Last) then raise Data_Error; end if; Item := Num (Base_Item); end; end if; end Get_From_Field; -- implementation procedure Get ( File : File_Type; Item : out Num; Width : Field := 0) is begin if Width /= 0 then declare S : String (1 .. Width); Last_1 : Natural; Last_2 : Natural; begin Formatting.Get_Field (File, S, Last_1); -- checking the predicate Get_From_Field (S (1 .. Last_1), Item, Last_2); if Last_2 /= Last_1 then raise Data_Error; end if; end; else declare S : constant String := Formatting.Get_Numeric_Literal ( File, -- checking the predicate Real => False); Last : Natural; begin Get_From_Field (S, Item, Last); if Last /= S'Last then raise Data_Error; end if; end; end if; end Get; procedure Get ( Item : out Num; Width : Field := 0) is begin Get (Current_Input.all, Item, Width); end Get; procedure Get ( File : not null File_Access; Item : out Num; Width : Field := 0) is begin Get (File.all, Item, Width); end Get; procedure Put ( File : File_Type; Item : Num; Width : Field := Default_Width; Base : Number_Base := Default_Base) is S : String (1 .. 4 + Num'Width + Width); -- "16##" Last : Natural; begin Put_To_Field (S, Last, Item, Base); Formatting.Tail (File, S (1 .. Last), Width); -- checking the predicate end Put; procedure Put ( Item : Num; Width : Field := Default_Width; Base : Number_Base := Default_Base) is begin Put (Current_Output.all, Item, Width, Base); end Put; procedure Put ( File : not null File_Access; Item : Num; Width : Field := Default_Width; Base : Number_Base := Default_Base) is begin Put (File.all, Item, Width, Base); end Put; procedure Get ( From : String; Item : out Num; Last : out Positive) is begin Formatting.Get_Tail (From, First => Last); Get_From_Field (From (Last .. From'Last), Item, Last); end Get; procedure Put ( To : out String; Item : Num; Base : Number_Base := Default_Base) is S : String (1 .. To'Length); Last : Natural; begin Put_To_Field (S, Last, Item, Base); Formatting.Tail (To, S (1 .. Last)); end Put; end Ada.Text_IO.Integer_IO;
jrcarter/Ada_GUI
Ada
6,120
ads
-- -- -- package Copyright (c) Dmitry A. Kazakov -- -- Object.Handle.Generic_Unbounded_Array Luebeck -- -- Interface Spring, 2003 -- -- -- -- Last revision : 20:41 21 Jul 2017 -- -- -- -- This library is free software; you can redistribute it and/or -- -- modify it under the terms of the GNU General Public License as -- -- published by the Free Software Foundation; either version 2 of -- -- the License, or (at your option) any later version. This library -- -- is distributed in the hope that it will be useful, but WITHOUT -- -- ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. You should have -- -- received a copy of the GNU General Public License along with -- -- this library; if not, write to the Free Software Foundation, -- -- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. -- -- -- -- As a special exception, if other files instantiate generics from -- -- this unit, or you link this unit with other files to produce an -- -- executable, this unit does not by itself cause the resulting -- -- executable to be covered by the GNU General Public License. This -- -- exception does not however invalidate any other reasons why the -- -- executable file might be covered by the GNU Public License. -- --____________________________________________________________________-- -- -- This package defines a generic type Unbounded_Array. An instance of -- Unbounded_Array is a dynamically expanded vector of pointers to -- automatically collected objects (see the package Object). The -- package has the following generic parameters: -- -- Index_Type - The array index type -- Handle_Type - A handle type derived from Handle -- Minimal_Size - Minimal additionally allocated size -- Increment - By which the vector is enlarged -- with Generic_Unbounded_Array; generic type Index_Type is (<>); type Handle_Type is new Handle with private; Minimal_Size : Positive := 64; Increment : Natural := 50; package Object.Handle.Generic_Unbounded_Array is type Unbounded_Array is new Ada.Finalization.Controlled with private; -- -- Adjust -- Assignment (part of) -- -- Container - The array -- -- The assignment does not copy the array. It only increments the use -- count of the array body. Only destructive operations like Put cause -- array replication. -- procedure Adjust (Container : in out Unbounded_Array); -- -- Erase -- Delete all array items -- -- Container - The array -- -- This procedure makes Container empty. -- procedure Erase (Container : in out Unbounded_Array); -- -- Finalize -- Destructor -- -- Container - The array -- procedure Finalize (Container : in out Unbounded_Array); -- -- First -- The lower array bound -- -- Container - The array -- -- Returns : -- -- The bound -- -- Exceptions : -- -- Constraint_Error - The array is presently empty -- function First (Container : Unbounded_Array) return Index_Type; -- -- Get -- Get an array element by its index -- -- Container - The array -- Index - Of the element -- -- Returns : -- -- The element or null if none -- function Get ( Container : Unbounded_Array; Index : Index_Type ) return Object_Type_Ptr; -- -- Last -- The upper array bound -- -- Container - The array -- -- Returns : -- -- The bound -- -- Exceptions : -- -- Constraint_Error - The array is presently empty -- function Last (Container : Unbounded_Array) return Index_Type; -- -- Put -- Replace an array element by its index -- -- Container - The array -- Index - Of the element -- Element - The new element (a pointer/handle to) -- -- The array is expanded as necessary. -- procedure Put ( Container : in out Unbounded_Array; Index : Index_Type; Element : Object_Type_Ptr ); procedure Put ( Container : in out Unbounded_Array; Index : Index_Type; Element : Handle_Type ); -- -- Ref -- Get a handle to an array element by its index -- -- Container - The array -- Index - Of the element -- -- Returns : -- -- A handle to the element -- -- Exceptions : -- -- Constraint_Error - No such element -- function Ref ( Container : Unbounded_Array; Index : Index_Type ) return Handle_Type; private pragma Inline (First); pragma Inline (Get); pragma Inline (Last); pragma Inline (Ref); type Object_Ptr_Array_Type is array (Index_Type range <>) of Object_Type_Ptr; package Object_Ptr_Array is new Standard.Generic_Unbounded_Array ( Index_Type => Index_Type, Object_Type => Object_Type_Ptr, Object_Array_Type => Object_Ptr_Array_Type, Null_Element => null, Minimal_Size => Minimal_Size, Increment => Increment ); type Unbounded_Array_Body is new Object.Entity with record Data : Object_Ptr_Array.Unbounded_Array; end record; type Unbounded_Array_Body_Ptr is access Unbounded_Array_Body; type Unbounded_Array is new Ada.Finalization.Controlled with record Ptr : Unbounded_Array_Body_Ptr; end record; end Object.Handle.Generic_Unbounded_Array;
MinimSecure/unum-sdk
Ada
976
adb
-- Copyright 2013-2016 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. with IO; use IO; with Callee; use Callee; package body Caller is procedure Verbose_Increment (Val : in out Float; Msg : String) is begin Put_Line ("DEBUG: " & Msg); Increment (Val, "Verbose_Increment"); end Verbose_Increment; end Caller;
Fabien-Chouteau/Ada_Drivers_Library
Ada
6,634
ads
-- Copyright (c) 2013, Nordic Semiconductor ASA -- 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 Nordic Semiconductor ASA 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 spec has been automatically generated from nrf51.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; package NRF51_SVD.NVMC is pragma Preelaborate; --------------- -- Registers -- --------------- -- NVMC ready. type READY_READY_Field is ( -- NVMC is busy (on-going write or erase operation). Busy, -- NVMC is ready. Ready) with Size => 1; for READY_READY_Field use (Busy => 0, Ready => 1); -- Ready flag. type READY_Register is record -- Read-only. NVMC ready. READY : READY_READY_Field; -- unspecified Reserved_1_31 : HAL.UInt31; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for READY_Register use record READY at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- Program write enable. type CONFIG_WEN_Field is ( -- Read only access. Ren, -- Write enabled. Wen, -- Erase enabled. Een) with Size => 2; for CONFIG_WEN_Field use (Ren => 0, Wen => 1, Een => 2); -- Configuration register. type CONFIG_Register is record -- Program write enable. WEN : CONFIG_WEN_Field := NRF51_SVD.NVMC.Ren; -- unspecified Reserved_2_31 : HAL.UInt30 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CONFIG_Register use record WEN at 0 range 0 .. 1; Reserved_2_31 at 0 range 2 .. 31; end record; -- Starts the erasing of all user NVM (code region 0/1 and UICR registers). type ERASEALL_ERASEALL_Field is ( -- No operation. Nooperation, -- Start chip erase. Erase) with Size => 1; for ERASEALL_ERASEALL_Field use (Nooperation => 0, Erase => 1); -- Register for erasing all non-volatile user memory. type ERASEALL_Register is record -- Starts the erasing of all user NVM (code region 0/1 and UICR -- registers). ERASEALL : ERASEALL_ERASEALL_Field := NRF51_SVD.NVMC.Nooperation; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ERASEALL_Register use record ERASEALL at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; -- It can only be used when all contents of code region 1 are erased. type ERASEUICR_ERASEUICR_Field is ( -- No operation. Nooperation, -- Start UICR erase. Erase) with Size => 1; for ERASEUICR_ERASEUICR_Field use (Nooperation => 0, Erase => 1); -- Register for start erasing User Information Congfiguration Registers. type ERASEUICR_Register is record -- It can only be used when all contents of code region 1 are erased. ERASEUICR : ERASEUICR_ERASEUICR_Field := NRF51_SVD.NVMC.Nooperation; -- unspecified Reserved_1_31 : HAL.UInt31 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for ERASEUICR_Register use record ERASEUICR at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; ----------------- -- Peripherals -- ----------------- type NVMC_Disc is ( Age, Cr1); -- Non Volatile Memory Controller. type NVMC_Peripheral (Discriminent : NVMC_Disc := Age) is record -- Ready flag. READY : aliased READY_Register; -- Configuration register. CONFIG : aliased CONFIG_Register; -- Register for erasing all non-volatile user memory. ERASEALL : aliased ERASEALL_Register; -- Register for erasing a protected non-volatile memory page. ERASEPCR0 : aliased HAL.UInt32; -- Register for start erasing User Information Congfiguration Registers. ERASEUICR : aliased ERASEUICR_Register; case Discriminent is when Age => -- Register for erasing a non-protected non-volatile memory page. ERASEPAGE : aliased HAL.UInt32; when Cr1 => -- Register for erasing a non-protected non-volatile memory page. ERASEPCR1 : aliased HAL.UInt32; end case; end record with Unchecked_Union, Volatile; for NVMC_Peripheral use record READY at 16#400# range 0 .. 31; CONFIG at 16#504# range 0 .. 31; ERASEALL at 16#50C# range 0 .. 31; ERASEPCR0 at 16#510# range 0 .. 31; ERASEUICR at 16#514# range 0 .. 31; ERASEPAGE at 16#508# range 0 .. 31; ERASEPCR1 at 16#508# range 0 .. 31; end record; -- Non Volatile Memory Controller. NVMC_Periph : aliased NVMC_Peripheral with Import, Address => System'To_Address (16#4001E000#); end NRF51_SVD.NVMC;
dan76/Amass
Ada
628
ads
-- Copyright © by Jeff Foley 2017-2023. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. -- SPDX-License-Identifier: Apache-2.0 name = "Reverse DNS" type = "dns" local cfg function start() cfg = config() end function resolved(ctx, name, domain, records) if (cfg == nil or cfg.mode == "passive") then return end if not in_scope(ctx, name) then return end for _, rec in pairs(records) do if (rec.rrtype == 1 or rec.rrtype == 28) then _ = reverse_sweep(ctx, rec.rrdata) end end end
jhumphry/parse_args
Ada
21,051
adb
-- parse_args_suite-parse_args_tests.adb -- Unit tests for the Parse_Args project -- Copyright (c) 2016, James Humphry -- -- Permission to use, copy, modify, and/or distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH -- REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -- AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, -- INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -- LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -- OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -- PERFORMANCE OF THIS SOFTWARE. with System.Assertions; with AUnit.Assertions; with Parse_Args; with Parse_Args.Testable; package body Parse_Args_Suite.Parse_Args_Tests is use AUnit.Assertions; use Parse_Args; use Parse_Args.Testable; -------------------- -- Register_Tests -- -------------------- procedure Register_Tests (T: in out Parse_Args_Test) is use AUnit.Test_Cases.Registration; begin Register_Routine (T, Check_Basics'Access, "Check basic functionality"); Register_Routine (T, Check_Boolean_Usage'Access, "Check Boolean option functionality"); Register_Routine (T, Check_Repeated_Usage'Access, "Check Repeated option functionality"); Register_Routine (T, Check_Integer_Usage'Access, "Check Integer option functionality"); Register_Routine (T, Check_String_Usage'Access, "Check String option functionality"); end Register_Tests; ---------- -- Name -- ---------- function Name (T : Parse_Args_Test) return Test_String is pragma Unreferenced (T); begin return Format ("Tests of Parse_Args package functionality"); end Name; ------------ -- Set_Up -- ------------ procedure Set_Up (T : in out Parse_Args_Test) is pragma Unreferenced (T); begin null; end Set_Up; ------------------ -- Check_Basics -- ------------------ procedure Check_Basics (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced(T); function Setup_AP return Testable_Argument_Parser is begin return Result : Testable_Argument_Parser do Result.Add_Option(O => Make_Boolean_Option(False), Name => "foo", Short_Option => 'f'); Result.Add_Option(O => Make_Boolean_Option(False), Name => "bar", Short_Option => 'b'); Result.Add_Option(O => Make_Boolean_Option(False), Name => "baz", Short_Option => 'z'); Result.Set_Command_Name("parse_args_tests"); end return; end Setup_AP; begin declare AP : Testable_Argument_Parser := Setup_AP; Catch_Message_Too_Soon : Boolean := False; Catch_Repeated_Parsing : Boolean := False; Catch_No_Such_Argument : Boolean := False; begin AP.Clear_Arguments; AP.Append_Arguments((+"--foo", +"-b")); Assert(AP.Ready, "New Argument_Parser not ready for use"); begin declare Dummy : String := AP.Parse_Message; begin null; end; exception when Program_Error | System.Assertions.Assert_Failure => Catch_Message_Too_Soon := True; end; Assert(Catch_Message_Too_Soon, "Returned a parse message before the parse has taken place"); AP.Parse_Command_Line; Assert(AP.Parse_Success, "Argument_Parser did not parse successfully: " & AP.Parse_Message); begin AP.Parse_Command_Line; exception when Program_Error | System.Assertions.Assert_Failure => Catch_Repeated_Parsing := True; end; Assert(Catch_Repeated_Parsing, "Did not object to Parse_Command_Line being called twice"); Assert(AP.Command_Name = "parse_args_tests", "Cannot retrieve command name"); Assert(AP.Get("foo").Set, "Boolean option bar incorrectly not marked as set"); Assert(AP.Get("bar").Set, "Boolean option bar incorrectly not marked as set"); Assert(not AP.Get("baz").Set, "Boolean option baz incorrectly marked as set"); begin declare Dummy : Boolean := AP.Boolean_Value("nosuch"); begin null; end; exception when Constraint_Error => Catch_No_Such_Argument := True; end; Assert(Catch_No_Such_Argument, "Returned a value for a non-existent option"); end; end Check_Basics; ------------------------- -- Check_Boolean_Usage -- ------------------------- procedure Check_Boolean_Usage (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced(T); function Setup_AP return Testable_Argument_Parser is begin return Result : Testable_Argument_Parser do Result.Add_Option(O => Make_Boolean_Option(False), Name => "foo", Short_Option => 'f'); Result.Add_Option(O => Make_Boolean_Option(True), Name => "bar", Short_Option => 'b'); Result.Add_Option(O => Make_Boolean_Option(False), Name => "baz", Short_Option => 'z', Long_Option => "-"); Result.Add_Option(O => Make_Boolean_Option(False), Name => "bork", Short_Option => '-', Long_Option => "borkable"); Result.Set_Command_Name("parse_args_tests"); end return; end Setup_AP; begin declare AP : Testable_Argument_Parser := Setup_AP; begin AP.Clear_Arguments; AP.Append_Arguments((+"--foo", +"-b", +"--borkable")); AP.Parse_Command_Line; Assert(AP.Parse_Success, "Argument_Parser did not parse successfully: " & AP.Parse_Message); Assert(AP.Boolean_Value("foo"), "Boolean option foo (default false) not toggled"); Assert(not AP.Boolean_Value("bar"), "Boolean option bar (default true) not toggled via short option"); Assert(AP.Boolean_Value("bork"), "Boolean option bork (default false) not toggled via renamed long option"); end; declare AP : Testable_Argument_Parser := Setup_AP; begin AP.Clear_Arguments; AP.Append_Argument("-bz"); AP.Parse_Command_Line; Assert(AP.Parse_Success, "Argument_Parser did not parse successfully"); Assert(not AP.Boolean_Value("foo"), "Boolean option foo (default false) set despite not being present in option group"); Assert(not AP.Boolean_Value("bar"), "Boolean option bar (default true) not toggled via short option group"); Assert(AP.Get("baz").Set, "Boolean option baz (default false) not toggled via short option group"); end; declare AP : Testable_Argument_Parser := Setup_AP; begin AP.Clear_Arguments; AP.Append_Arguments((+"--nonesuch", +"--foo")); AP.Parse_Command_Line; Assert(not AP.Parse_Success, "Parse successful despite passing non-existent long option"); end; declare AP : Testable_Argument_Parser := Setup_AP; begin AP.Clear_Arguments; AP.Append_Arguments((+"-n", +"--foo")); AP.Parse_Command_Line; Assert(not AP.Parse_Success, "Parse successful despite passing non-existent short option"); end; declare AP : Testable_Argument_Parser := Setup_AP; begin AP.Clear_Arguments; AP.Append_Argument("-fnz"); AP.Parse_Command_Line; Assert(not AP.Parse_Success, "Parse successful despite passing non-existent grouped short option"); end; declare AP : Testable_Argument_Parser := Setup_AP; begin AP.Clear_Arguments; AP.Append_Arguments((+"--foo", +"invalidarg")); AP.Parse_Command_Line; Assert(not AP.Parse_Success, "Parse successful despite passing an argument to a Boolean option"); end; declare AP : Testable_Argument_Parser := Setup_AP; begin AP.Clear_Arguments; AP.Append_Argument("--baz"); AP.Parse_Command_Line; Assert(not AP.Parse_Success, "Parse successful despite using a long option name on a short-name only option"); end; declare AP : Testable_Argument_Parser := Setup_AP; begin AP.Clear_Arguments; AP.Append_Argument("--bork"); AP.Parse_Command_Line; Assert(not AP.Parse_Success, "Parse successful despite using the underlying option name for a renamed long option"); end; end Check_Boolean_Usage; -------------------------- -- Check_Repeated_Usage -- -------------------------- procedure Check_Repeated_Usage (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced(T); function Setup_AP return Testable_Argument_Parser is begin return Result : Testable_Argument_Parser do Result.Add_Option(O => Make_Repeated_Option, Name => "foo", Short_Option => 'f'); Result.Add_Option(O => Make_Repeated_Option, Name => "bar", Short_Option => 'b'); Result.Add_Option(O => Make_Repeated_Option(5), Name => "baz", Short_Option => 'z'); Result.Add_Option(O => Make_Boolean_Option, Name => "snafu", Short_Option => 's'); Result.Set_Command_Name("parse_args_tests"); end return; end Setup_AP; begin declare AP : Testable_Argument_Parser := Setup_AP; begin AP.Clear_Arguments; AP.Append_Arguments((+"--foo", +"--foo", +"-b", +"-b")); AP.Parse_Command_Line; Assert(AP.Parse_Success, "Argument_Parser did not parse successfully: " & AP.Parse_Message); Assert(AP.Integer_Value("foo") = 2, "Repeated options (using long option type) not working"); Assert(AP.Integer_Value("bar") = 2, "Repeated options (using short option type) not working"); Assert(AP.Integer_Value("baz") = 5, "Repeated options defaults not working"); end; declare AP : Testable_Argument_Parser := Setup_AP; begin AP.Clear_Arguments; AP.Append_Arguments((+"-fbfb", +"--baz", +"-z", +"-z")); AP.Parse_Command_Line; Assert(AP.Parse_Success, "Argument_Parser did not parse successfully: " & AP.Parse_Message); Assert(AP.Integer_Value("foo") = 2, "Repeated options (using short option group) not working"); Assert(AP.Integer_Value("bar") = 2, "Repeated options (using short option group) not working"); Assert(AP.Integer_Value("baz") = 8, "Repeated optionsw with a default and mixed long and short " & "options are not working"); end; declare AP : Testable_Argument_Parser := Setup_AP; begin AP.Clear_Arguments; AP.Append_Arguments((+"-fz", +"--snafu", +"--baz", +"-z", +"-z", +"--foo")); AP.Parse_Command_Line; Assert(AP.Parse_Success, "Argument_Parser did not parse successfully: " & AP.Parse_Message); Assert(AP.Integer_Value("foo") = 2, "Repeated options (using short option group) not working"); Assert(AP.Integer_Value("bar") = 0, "Repeated options (with no default set and not invoked) not " & "returning 0 when retrieved"); Assert(AP.Integer_Value("baz") = 9, "Repeated optionsw with a default and mixed long and short " & "options are not working"); end; end Check_Repeated_Usage; ------------------------- -- Check_Integer_Usage -- ------------------------- procedure Check_Integer_Usage (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced(T); function Setup_AP return Testable_Argument_Parser is begin return Result : Testable_Argument_Parser do Result.Add_Option(O => Make_Integer_Option, Name => "foo", Short_Option => 'f'); Result.Add_Option(O => Make_Natural_Option, Name => "bar", Short_Option => 'b'); Result.Add_Option(O => Make_Positive_Option, Name => "baz", Short_Option => 'z'); Result.Add_Option(O => Make_Integer_Option(Default => 15, Min => 10, Max => 20), Name => "coz", Short_Option => 'c'); Result.Add_Option(O => Make_Boolean_Option, Name => "door", Short_Option => 'd'); Result.Set_Command_Name("parse_args_tests"); end return; end Setup_AP; Catch_No_Such_Argument : Boolean := False; begin declare AP : Testable_Argument_Parser := Setup_AP; begin AP.Clear_Arguments; AP.Append_Arguments((+"--foo", +"5", +"-c", +"12")); AP.Parse_Command_Line; Assert(AP.Parse_Success, "Argument_Parser did not parse successfully: " & AP.Parse_Message); Assert(AP.Integer_Value("foo") = 5, "Integer option (long form) not working"); Assert(AP.Integer_Value("bar") = 0, "Natural Option default not correct"); Assert(AP.Integer_Value("baz") = 1, "Positive option default not correct"); Assert(AP.Integer_Value("coz") = 12, "Integer option (short form) with custom range not working"); end; declare AP : Testable_Argument_Parser := Setup_AP; begin AP.Clear_Arguments; AP.Append_Arguments((+"-f", +"-7")); AP.Append_Arguments((+"-z", +"16#FF#")); AP.Parse_Command_Line; Assert(AP.Parse_Success, "Argument_Parser did not parse successfully: " & AP.Parse_Message); Assert(AP.Integer_Value("foo") = -7, "Positive option did not accept negative input"); Assert(AP.Integer_Value("baz") = 255, "Positive option did not accept hex input"); end; declare AP : Testable_Argument_Parser := Setup_AP; begin AP.Clear_Arguments; AP.Append_Arguments((+"-df", +"8")); AP.Parse_Command_Line; Assert(AP.Parse_Success, "Argument_Parser did not parse successfully: " & AP.Parse_Message); Assert(AP.Integer_Value("foo") = 8, "Integer option (short group) not working"); end; declare AP : Testable_Argument_Parser := Setup_AP; begin AP.Clear_Arguments; AP.Append_Arguments((+"-z", +"0")); AP.Parse_Command_Line; Assert(not AP.Parse_Success, "Argument parser did not reject 0 as input for Positive option"); end; declare AP : Testable_Argument_Parser := Setup_AP; begin AP.Clear_Arguments; AP.Append_Arguments((+"-c", +"8")); AP.Parse_Command_Line; Assert(not AP.Parse_Success, "Argument parser did not reject out-of range value for " & "customised Integer option"); end; declare AP : Testable_Argument_Parser := Setup_AP; begin AP.Clear_Arguments; AP.Append_Arguments((+"-f", +"--bar", +"8")); AP.Parse_Command_Line; Assert(not AP.Parse_Success, "Argument parser did not reject missing option value for an" & "Integer option"); end; declare AP : Testable_Argument_Parser := Setup_AP; begin AP.Clear_Arguments; AP.Append_Arguments((+"-fb", +"8")); AP.Parse_Command_Line; Assert(not AP.Parse_Success, "Argument parser did not reject missing option value for an" & "Integer option as part of a short option group"); end; declare AP : Testable_Argument_Parser := Setup_AP; begin AP.Clear_Arguments; AP.Append_Arguments((+"-f", +"8", +"--foo", +"9")); AP.Parse_Command_Line; Assert(not AP.Parse_Success, "Argument parser did not reject specifying an Integer option" & "twice."); end; declare AP : Testable_Argument_Parser := Setup_AP; begin AP.Parse_Command_Line; declare Dummy : Integer := AP.Integer_Value("nosuch"); begin null; end; exception when Constraint_Error => Catch_No_Such_Argument := True; end; Assert(Catch_No_Such_Argument, "Returned a value for a non-existent integer option"); end Check_Integer_Usage; ------------------------ -- Check_String_Usage -- ------------------------ procedure Check_String_Usage (T : in out Test_Cases.Test_Case'Class) is pragma Unreferenced(T); function Setup_AP return Testable_Argument_Parser is begin return Result : Testable_Argument_Parser do Result.Add_Option(O => Make_String_Option, Name => "foo", Short_Option => 'f'); Result.Add_Option(O => Make_String_Option(Default => "Hello"), Name => "bar", Short_Option => 'b'); Result.Add_Option(O => Make_String_Option, Name => "baz", Short_Option => 'z'); Result.Set_Command_Name("parse_args_tests"); end return; end Setup_AP; Catch_No_Such_Argument : Boolean := False; begin declare AP : Testable_Argument_Parser := Setup_AP; begin AP.Clear_Arguments; AP.Append_Arguments((+"--foo", +"5", +"-z", +"Goodbye")); AP.Parse_Command_Line; Assert(AP.Parse_Success, "Argument_Parser did not parse successfully: " & AP.Parse_Message); Assert(AP.String_Value("foo") = "5", "String option (long form) not working"); Assert(AP.String_Value("bar") = "Hello", "String Option default not correct"); Assert(AP.String_Value("baz") = "Goodbye", "String option (short form) not working"); end; declare AP : Testable_Argument_Parser := Setup_AP; begin AP.Parse_Command_Line; declare Dummy :String := AP.String_Value("nosuch"); begin null; end; exception when Constraint_Error => Catch_No_Such_Argument := True; end; Assert(Catch_No_Such_Argument, "Returned a value for a non-existent string option"); end Check_String_Usage; end Parse_Args_Suite.Parse_Args_Tests;
persan/gprTools
Ada
22
ads
package p4 is end p4;
AdaCore/libadalang
Ada
385
adb
with Ada.Unchecked_Deallocation; procedure Test is A, B : Integer; --% node.p_fully_qualified_name --% a = node.p_defining_names[0] --% b = node.p_defining_names[1] --% a.p_fully_qualified_name --% b.p_fully_qualified_name --% a.p_fully_qualified_name_array --% b.p_fully_qualified_name_array --% b.p_canonical_fully_qualified_name begin null; end Test;
persan/AdaYaml
Ada
518
adb
-- part of AdaYaml, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "copying.txt" with Yaml.Annotation_Test; package body Yaml.Transformation_Tests.Suite is Result : aliased AUnit.Test_Suites.Test_Suite; Annotation_TC : aliased Annotation_Test.TC; function Suite return AUnit.Test_Suites.Access_Test_Suite is begin AUnit.Test_Suites.Add_Test (Result'Access, Annotation_TC'Access); return Result'Access; end Suite; end Yaml.Transformation_Tests.Suite;
reznikmm/matreshka
Ada
4,534
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Svg.Y2_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Svg_Y2_Attribute_Node is begin return Self : Svg_Y2_Attribute_Node do Matreshka.ODF_Svg.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Svg_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Svg_Y2_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Y2_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Svg_URI, Matreshka.ODF_String_Constants.Y2_Attribute, Svg_Y2_Attribute_Node'Tag); end Matreshka.ODF_Svg.Y2_Attributes;
godunko/adagl
Ada
4,481
ads
------------------------------------------------------------------------------ -- -- -- Ada binding for OpenGL/WebGL -- -- -- -- Examples Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2018, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with OpenGL.Generic_Buffers; with OpenGL.Programs; package Pyramid.Programs is type Vertex_Data is record VP : OpenGL.Glfloat_Vector_3; TC : OpenGL.Glfloat_Vector_2; end record; pragma JavaScript_Array_Buffer (Vertex_Data); type Vertex_Data_Array is array (Positive range <>) of Vertex_Data; pragma JavaScript_Array_Buffer (Vertex_Data_Array); package Vertex_Data_Buffers is new OpenGL.Generic_Buffers (Vertex_Data, Positive, Vertex_Data_Array); type Pyramid_Program is new OpenGL.Programs.OpenGL_Program with private; procedure Initialize (Self : in out Pyramid_Program'Class); -- Initialize program object. procedure Set_Vertex_Data_Buffer (Self : in out Pyramid_Program'Class; Buffer : Vertex_Data_Buffers.OpenGL_Buffer'Class); -- Sets buffer with data to draw. procedure Set_Texture_Unit (Self : in out Pyramid_Program'Class; Unit : OpenGL.Texture_Unit); -- Sets texture unit to be used to draw. private type Pyramid_Program is new OpenGL.Programs.OpenGL_Program with record GS : OpenGL.Uniform_Location; VP : OpenGL.Attribute_Location; TC : OpenGL.Attribute_Location; end record; overriding function Link (Self : in out Pyramid_Program) return Boolean; -- Executed at link time. Link shaders into program and extracts locations -- of attributes. end Pyramid.Programs;
annexi-strayline/AURA
Ada
4,559
adb
------------------------------------------------------------------------------ -- -- -- Ada User Repository Annex (AURA) -- -- Reference Implementation -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ package body Stream_Hashing.Collective is ----------------------------- -- Compute_Collective_Hash -- ----------------------------- procedure Compute_Collective_Hash (Collection : in Hash_Collections.Set; Collective_Hash: out Hash_Type) is Engine: aliased Modular_Hashing.SHA1.SHA1_Engine; begin for H of Collection loop Hash_Type'Write (Engine'Access, H); end loop; Collective_Hash := Hash_Type'(Modular_Hashing.SHA1.SHA1_Hash(Engine.Digest) with null record); end Compute_Collective_Hash; -------------------------------------------------- procedure Compute_Collective_Hash (Hash_Queue : in out Hash_Queues.Queue; Collective_Hash: out Hash_Type) is Collection: Hash_Collections.Set; New_Hash: Hash_Type; begin loop select Hash_Queue.Dequeue (New_Hash); else exit; end select; Collection.Include (New_Hash); end loop; Compute_Collective_Hash (Collection, Collective_Hash); end Compute_Collective_Hash; end Stream_Hashing.Collective;
reznikmm/matreshka
Ada
3,743
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ package Matreshka.ODF_Attributes.FO.Hyphenate is type FO_Hyphenate_Node is new Matreshka.ODF_Attributes.FO.FO_Node_Base with null record; type FO_Hyphenate_Access is access all FO_Hyphenate_Node'Class; overriding function Get_Local_Name (Self : not null access constant FO_Hyphenate_Node) return League.Strings.Universal_String; end Matreshka.ODF_Attributes.FO.Hyphenate;
AdaCore/libadalang
Ada
128
adb
procedure Test is X : Integer; Y : Integer; for X use at Y'Address; pragma Test_Statement; begin null; end Test;
jscparker/math_packages
Ada
11,491
adb
-- Test Jacobi Eigendecomposition of real valued square matrices. with Ada.Numerics.Generic_elementary_functions; with Jacobi_Eigen; with Test_Matrices; with Text_IO; use Text_IO; procedure jacobi_eigen_tst_1 is type Real is digits 15; --Matrix_Size : constant := 2277; --Matrix_Size : constant := 597; Matrix_Size : constant := 137; Index_First : constant := 1; -- Sometimes it's faster if you use a storage matrix that's a little -- larger than the original matrix. (Depends on the hardware, the problem, -- and the size of the matrix.) A rule of thumb: Width of storage matrix -- should be an even number, greater than matrix size, and never 2**n. -- -- Most important thing is to avoid 2**n matrix width. -- -- Padding usually doesn't help a lot, but just in case let's add 1 or 2: Padding : constant := 2 - (Matrix_Size - Index_First + 1) mod 2; subtype Index is Integer range 1 .. Matrix_Size + Padding; -- the test matrix is square-shaped matrix on: Index x Index. -- eg Hilbert's matrix is a square matrix with unique elements on the range -- Index'First .. Index'Last. However, you have the option or using any -- diagonal sub-block of the matrix defined by Index x Index subtype Col_Index is Index; Starting_Col : constant Index := Index'First + 0; Final_Col : constant Index := Index'Last - Padding; -- Can't change: Starting_Row : constant Index := Starting_Col; Final_Row : constant Index := Final_Col; type Matrix is array(Index, Index) of Real; --pragma Convention (Fortran, Matrix); --No! prefers Ada convention. package math is new Ada.Numerics.Generic_Elementary_Functions (Real); use math; package Eig is new Jacobi_Eigen (Real => Real, Index => Index, Matrix => Matrix); use Eig; -- Eig exports Col_Vector package Make_Square_Matrix is new Test_Matrices (Real, Index, Matrix); use Make_Square_Matrix; package rio is new Float_IO(Real); use rio; --subtype Real_Extended is Real; -- general case, works fine type Real_Extended is digits 18; -- 18 ok on intel Zero : constant Real := +0.0; One : constant Real := +1.0; Two : constant Real := +2.0; A, A_true, Q_tr : Matrix; Eigenvals : Col_Vector; Frobenius_QtrQ_Err, Frobenius_QQtr_Err, Frobenius_QEQ_Err : Real; No_of_Sweeps_Done, No_of_Rotations : Natural; N : constant Real := Real (Starting_Col) - Real (Final_Col) + 1.0; -------------------- -- Frobenius_Norm -- -------------------- function Frobenius_Norm (A : in Matrix) return Real is Max_A_Val : Real := Zero; Sum, Scaling, tmp : Real := Zero; begin Max_A_Val := Zero; for Row in Starting_Row .. Final_Row loop for Col in Starting_Col .. Final_Col loop if Max_A_Val < Abs A(Row, Col) then Max_A_Val := Abs A(Row, Col); end if; end loop; end loop; Max_A_Val := Max_A_Val + Two ** (Real'Machine_Emin + 4); Scaling := One / Max_A_Val; Sum := Zero; for Row in Starting_Row .. Final_Row loop for Col in Starting_Col .. Final_Col loop tmp := Scaling * A(Row, Col); Sum := Sum + tmp * tmp; end loop; end loop; return Sqrt (Sum) * Max_A_Val; end Frobenius_Norm; ------------------------------------ -- Get_Err_in_Reassembled_Q_and_A -- ------------------------------------ -- check that A = V*E*Q_tr -- E is diagonal with the eigs along the diag. -- V is orthogonal with the eig vecs as columns. procedure Get_Err_in_Reassembled_Q_and_A (A : in Matrix; -- true original A Q_tr : in Matrix; E : in Col_Vector; Final_Col : in Col_Index; Starting_Col : in Col_Index; Frobenius_QtrQ_Err : out Real; Frobenius_QQtr_Err : out Real; Frobenius_QEQ_Err : out Real) is Err, S : Real; Min_Real : constant Real := +2.0 **(Real'Machine_Emin + 4); Sum : Real_Extended; Identity : Matrix := (others => (others => Zero)); Product_QQ : Matrix := (others => (others => Zero)); Product_QEQ : Matrix := (others => (others => Zero)); subtype Index_Subrange is Index range Starting_Col .. Final_Col; begin for r in Index_Subrange loop Identity(r, r) := 1.0; end loop; -- Find error in I - Q*Q' etc. -- Notation: Q' == Q_tr == transpose of Q. for Col in Index_Subrange loop for Row in Index_Subrange loop Sum := +0.0; for j in Index_Subrange loop Sum := Sum + Real_Extended (Q_tr(j, Row)) * Real_Extended (Q_tr(j, Col)); end loop; Product_QQ(Row, Col) := Real (Sum); end loop; end loop; -- Get Frobenius norm of: Product_QQ - I: S := Zero; for Col in Index_Subrange loop for Row in Index_Subrange loop Err := Identity(Row, Col) - Product_QQ(Row, Col); S := S + Err * Err; end loop; end loop; -- Get fractional Frobenius : Frobenius (Product_QQ - I) / Frobenius (I): Frobenius_QQtr_Err := Sqrt(S) / Sqrt (-Real(Starting_Col)+Real(Final_Col)+1.0); -- Find error in I - Q'*Q. -- reuse array Product_QQ: for Col in Index_Subrange loop for Row in Index_Subrange loop Sum := +0.0; for j in Index_Subrange loop Sum := Sum + Real_Extended (Q_tr(Row, j)) * Real_Extended (Q_tr(Col, j)); end loop; Product_QQ(Row, Col) := Real (Sum); end loop; end loop; -- Get Frobenius norm of: Product_QQ - I: S := Zero; for Col in Index_Subrange loop for Row in Index_Subrange loop Err := Identity(Row, Col) - Product_QQ(Row, Col); S := S + Err * Err; end loop; end loop; -- Get fractional Frobenius : Frobenius (Product_QQ - I) / Frobenius (I): Frobenius_QtrQ_Err := Sqrt(S) / Sqrt (-Real(Starting_Col)+Real(Final_Col)+1.0); -- check that A = Q*E*Q_tr -- E is diagonal with the eigs along the diag. -- Q is orthogonal with the eig vecs as columns. -- explicitly calculate Q*E*Q_tr: for Col in Index_Subrange loop for Row in Index_Subrange loop Sum := +0.0; for j in Index_Subrange loop Sum := Sum + Real_Extended (Q_tr(j, Row)) * -- Q(Row, j) Real_Extended (E(j)) * -- j-th eig is const along Q col Real_Extended (Q_tr(j, Col)); end loop; Product_QEQ(Row, Col) := Real (Sum); end loop; end loop; -- resuse array Product_QEQ to get Error Matrix := Product_QEQ - A: for Col in Starting_Col .. Final_Col loop for Row in Starting_Row .. Final_Row loop Product_QEQ(Row, Col) := A(Row, Col) - Product_QEQ(Row, Col); end loop; end loop; Frobenius_QEQ_Err := Frobenius_Norm (Product_QEQ) / (Frobenius_Norm (A) + Min_Real); end Get_Err_in_Reassembled_Q_and_A; ----------- -- Pause -- ----------- procedure Pause (s0,s1,s2,s3,s4,s5,s6,s7,s8,s9 : string := "") is Continue : Character := ' '; begin new_line; if S0 /= "" then put_line (S0); end if; if S1 /= "" then put_line (S1); end if; if S2 /= "" then put_line (S2); end if; if S3 /= "" then put_line (S3); end if; if S4 /= "" then put_line (S4); end if; if S5 /= "" then put_line (S5); end if; if S6 /= "" then put_line (S6); end if; if S7 /= "" then put_line (S7); end if; if S8 /= "" then put_line (S8); end if; if S9 /= "" then put_line (S9); end if; new_line; begin put ("Type a character to continue: "); get_immediate (Continue); exception when others => null; end; end pause; begin Pause( "Test 1: Jacobi Eigendecomposition of matrix A.", " ", "The Jacobi Eigendecomposition of A is successful if the identities Q*Q' = I,", "Q'*Q = I and Q*E*Q' = A are satisfied. Here Q' denotes the transpose of Q, and", "E is any diagonal matrix. (E will hold the Eigvals.) If 15 digit Reals are used,", "then we expect the error in the calculation of A = Q*E*Q' to be (hopefully)", "a few parts per 10**15. In other words ||Q*E*Q' - A|| / ||A|| should be a few", "multiples of 10**(-15). Here ||*|| denotes the Frobenius Norm. Other matrix", "norms give slightly different answers, so its an order of magnitude estimate." ); -- Get A = Q*E*Q_tr, or E = Q_tr*A*Q. -- E is diagonal with the eigs along the diag. -- V is orthogonal with the eig vecs as columns. for Chosen_Matrix in Matrix_Id loop Init_Matrix (A, Chosen_Matrix, Starting_Col, Final_Col); -- Usually A is not symmetric. Eigen_Decompose doesn't care about -- that. It uses the upper triangle of A, and pretends that A is -- symmetric. But for subsequent analysis, we want it symmetrized: for c in Starting_Col .. Final_Col loop for r in Starting_Row .. Final_Row loop A_true(r, c) := 0.5 * (A(c, r) + A(r, c)); end loop; end loop; A := A_true; -- A will be destroyed, so save A_true Eigen_Decompose (A => A, -- A is destroyed Q_tr => Q_tr, Eigenvals => Eigenvals, No_of_Sweeps_Performed => No_of_Sweeps_Done, Total_No_of_Rotations => No_of_Rotations, Final_Col => Final_Col, Start_Col => Starting_Col, Eigenvectors_Desired => True); Sort_Eigs (Eigenvals => Eigenvals, Q_tr => Q_tr, Start_Col => Starting_Col, Final_Col => Final_Col, Sort_Eigvecs_Also => True); --put(Q_tr(1,1)); if False then for I in Starting_Col .. Final_Col loop put(Eigenvals(I)); end loop; new_line(2); end if; new_line; put("For matrix A of type "); put(Matrix_id'Image(Chosen_Matrix)); Get_Err_in_Reassembled_Q_and_A (A => A_True, Q_tr => Q_tr, E => Eigenvals, Final_Col => Final_Col, Starting_Col => Starting_Col, Frobenius_QtrQ_Err => Frobenius_QtrQ_Err, Frobenius_QQtr_Err => Frobenius_QQtr_Err, Frobenius_QEQ_Err => Frobenius_QEQ_Err); -- Froebenius norm fractional error: -- Max_Error_F = ||Err_Matrix|| / ||A|| new_line; put(" No of sweeps performed, and Total_No_of_Rotations / (N*(N-1)/2) ="); new_line; put(Real (No_of_Sweeps_Done)); put(Real (No_of_Rotations) / (N*(N-1.0)/2.0)); new_line; put(" Err in I-Q*Q' (Q = orthogonal) is ||I-Q*Q'|| / ||I|| ="); put(Frobenius_QQtr_Err); new_line; put(" Err in I-Q'*Q (Q = orthogonal) is ||I-Q'*Q|| / ||I|| ="); put(Frobenius_QtrQ_Err); new_line; put(" Err in A-Q*E*Q' (E = eigenvals) is ||A-Q*E*Q'|| / ||A|| ="); put(Frobenius_QEQ_Err); new_line; --Pause; new_line; end loop; end jacobi_eigen_tst_1;
reznikmm/gela
Ada
62,677
adb
------------------------------------------------------------------------------ -- G E L A A S I S -- -- ASIS implementation for Gela project, a portable Ada compiler -- -- http://gela.ada-ru.org -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license at the end of this file -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ -- Purpose: -- Procedural wrapper over Object-Oriented ASIS implementation with Ada.Containers; with Asis.Extensions.Flat_Kinds; with Gela.Compilation_Unit_Sets; with Gela.Compilations; with Gela.Element_Visiters; with Gela.Elements.Compilation_Unit_Bodies; with Gela.Elements.Compilation_Unit_Declarations; with Gela.Elements.Compilation_Units; with Gela.Elements.Context_Items; with Gela.Elements.For_Loop_Statements; with Gela.Elements.Library_Unit_Bodies; with Gela.Elements.Library_Unit_Declarations; with Gela.Elements.Loop_Parameter_Specifications; with Gela.Elements.Parameter_Specifications; with Gela.Elements.Private_Type_Declarations; with Gela.Elements.Private_Type_Definitions; with Gela.Elements.Proper_Bodies; with Gela.Elements.Subunits; with Gela.Lexical_Types; package body Asis.Elements is package F renames Asis.Extensions.Flat_Kinds; ---------------------------- -- Access_Definition_Kind -- ---------------------------- function Access_Definition_Kind (Definition : Asis.Definition) return Asis.Access_Definition_Kinds is Map : constant array (F.An_Access_Definition) of Asis.Access_Definition_Kinds := (F.An_Anonymous_Access_To_Variable => Asis.An_Anonymous_Access_To_Variable, F.An_Anonymous_Access_To_Constant => Asis.An_Anonymous_Access_To_Constant, F.An_Anonymous_Access_To_Procedure => Asis.An_Anonymous_Access_To_Procedure, F.An_Anonymous_Access_To_Protected_Procedure => Asis.An_Anonymous_Access_To_Protected_Procedure, F.An_Anonymous_Access_To_Function => Asis.An_Anonymous_Access_To_Function, F.An_Anonymous_Access_To_Protected_Function => Asis.An_Anonymous_Access_To_Protected_Function); Kind : constant Asis.Extensions.Flat_Kinds.Element_Flat_Kind := Asis.Extensions.Flat_Kinds.Flat_Kind (Definition); begin if Kind in Map'Range then return Map (Kind); else return Not_An_Access_Definition; end if; end Access_Definition_Kind; ---------------------- -- Access_Type_Kind -- ---------------------- function Access_Type_Kind (Definition : in Asis.Access_Type_Definition) return Asis.Access_Type_Kinds is Map : constant array (F.An_Access_Type_Definition) of Asis.Access_Type_Kinds := (F.A_Pool_Specific_Access_To_Variable => Asis.A_Pool_Specific_Access_To_Variable, F.An_Access_To_Variable => Asis.An_Access_To_Variable, F.An_Access_To_Constant => Asis.An_Access_To_Constant, F.An_Access_To_Procedure => Asis.An_Access_To_Procedure, F.An_Access_To_Protected_Procedure => Asis.An_Access_To_Protected_Procedure, F.An_Access_To_Function => Asis.An_Access_To_Function, F.An_Access_To_Protected_Function => Asis.An_Access_To_Protected_Function); Kind : constant Asis.Extensions.Flat_Kinds.Element_Flat_Kind := Asis.Extensions.Flat_Kinds.Flat_Kind (Definition); begin if Kind in Map'Range then return Map (Kind); else return Not_An_Access_Type_Definition; end if; end Access_Type_Kind; ---------------------- -- Association_Kind -- ---------------------- function Association_Kind (Association : in Asis.Association) return Asis.Association_Kinds is Map : constant array (F.An_Association) of Asis.Association_Kinds := (F.A_Pragma_Argument_Association => Asis.A_Pragma_Argument_Association, F.A_Discriminant_Association => Asis.A_Discriminant_Association, F.A_Record_Component_Association => Asis.A_Record_Component_Association, F.An_Array_Component_Association => Asis.An_Array_Component_Association, F.A_Parameter_Association => Asis.A_Parameter_Association, F.A_Generic_Association => Asis.A_Generic_Association); Kind : constant Asis.Extensions.Flat_Kinds.Element_Flat_Kind := Asis.Extensions.Flat_Kinds.Flat_Kind (Association); begin if Kind in Map'Range then return Map (Kind); else return Not_An_Association; end if; end Association_Kind; -------------------- -- Attribute_Kind -- -------------------- function Attribute_Kind (Expression : in Asis.Expression) return Asis.Attribute_Kinds is Map : constant array (F.An_Attribute_Reference) of Asis.Attribute_Kinds := (F.An_Access_Attribute => Asis.An_Access_Attribute, F.An_Address_Attribute => Asis.An_Address_Attribute, F.An_Adjacent_Attribute => Asis.An_Adjacent_Attribute, F.An_Aft_Attribute => Asis.An_Aft_Attribute, F.An_Alignment_Attribute => Asis.An_Alignment_Attribute, F.A_Base_Attribute => Asis.A_Base_Attribute, F.A_Bit_Order_Attribute => Asis.A_Bit_Order_Attribute, F.A_Body_Version_Attribute => Asis.A_Body_Version_Attribute, F.A_Callable_Attribute => Asis.A_Callable_Attribute, F.A_Caller_Attribute => Asis.A_Caller_Attribute, F.A_Ceiling_Attribute => Asis.A_Ceiling_Attribute, F.A_Class_Attribute => Asis.A_Class_Attribute, F.A_Component_Size_Attribute => Asis.A_Component_Size_Attribute, F.A_Compose_Attribute => Asis.A_Compose_Attribute, F.A_Constrained_Attribute => Asis.A_Constrained_Attribute, F.A_Copy_Sign_Attribute => Asis.A_Copy_Sign_Attribute, F.A_Count_Attribute => Asis.A_Count_Attribute, F.A_Definite_Attribute => Asis.A_Definite_Attribute, F.A_Delta_Attribute => Asis.A_Delta_Attribute, F.A_Denorm_Attribute => Asis.A_Denorm_Attribute, F.A_Digits_Attribute => Asis.A_Digits_Attribute, F.An_Exponent_Attribute => Asis.An_Exponent_Attribute, F.An_External_Tag_Attribute => Asis.An_External_Tag_Attribute, F.A_First_Attribute => Asis.A_First_Attribute, F.A_First_Bit_Attribute => Asis.A_First_Bit_Attribute, F.A_Floor_Attribute => Asis.A_Floor_Attribute, F.A_Fore_Attribute => Asis.A_Fore_Attribute, F.A_Fraction_Attribute => Asis.A_Fraction_Attribute, F.An_Identity_Attribute => Asis.An_Identity_Attribute, F.An_Image_Attribute => Asis.An_Image_Attribute, F.An_Input_Attribute => Asis.An_Input_Attribute, F.A_Last_Attribute => Asis.A_Last_Attribute, F.A_Last_Bit_Attribute => Asis.A_Last_Bit_Attribute, F.A_Leading_Part_Attribute => Asis.A_Leading_Part_Attribute, F.A_Length_Attribute => Asis.A_Length_Attribute, F.A_Machine_Attribute => Asis.A_Machine_Attribute, F.A_Machine_Emax_Attribute => Asis.A_Machine_Emax_Attribute, F.A_Machine_Emin_Attribute => Asis.A_Machine_Emin_Attribute, F.A_Machine_Mantissa_Attribute => Asis.A_Machine_Mantissa_Attribute, F.A_Machine_Overflows_Attribute => Asis.A_Machine_Overflows_Attribute, F.A_Machine_Radix_Attribute => Asis.A_Machine_Radix_Attribute, F.A_Machine_Rounding_Attribute => Asis.A_Machine_Rounding_Attribute, F.A_Machine_Rounds_Attribute => Asis.A_Machine_Rounds_Attribute, F.A_Max_Attribute => Asis.A_Max_Attribute, F.A_Max_Size_In_Storage_Elements_Attribute => Asis.A_Max_Size_In_Storage_Elements_Attribute, F.A_Min_Attribute => Asis.A_Min_Attribute, F.A_Mod_Attribute => Asis.A_Mod_Attribute, F.A_Model_Attribute => Asis.A_Model_Attribute, F.A_Model_Emin_Attribute => Asis.A_Model_Emin_Attribute, F.A_Model_Epsilon_Attribute => Asis.A_Model_Epsilon_Attribute, F.A_Model_Mantissa_Attribute => Asis.A_Model_Mantissa_Attribute, F.A_Model_Small_Attribute => Asis.A_Model_Small_Attribute, F.A_Modulus_Attribute => Asis.A_Modulus_Attribute, F.An_Output_Attribute => Asis.An_Output_Attribute, F.A_Partition_ID_Attribute => Asis.A_Partition_ID_Attribute, F.A_Pos_Attribute => Asis.A_Pos_Attribute, F.A_Position_Attribute => Asis.A_Position_Attribute, F.A_Pred_Attribute => Asis.A_Pred_Attribute, F.A_Priority_Attribute => Asis.A_Priority_Attribute, F.A_Range_Attribute => Asis.A_Range_Attribute, F.A_Read_Attribute => Asis.A_Read_Attribute, F.A_Remainder_Attribute => Asis.A_Remainder_Attribute, F.A_Round_Attribute => Asis.A_Round_Attribute, F.A_Rounding_Attribute => Asis.A_Rounding_Attribute, F.A_Safe_First_Attribute => Asis.A_Safe_First_Attribute, F.A_Safe_Last_Attribute => Asis.A_Safe_Last_Attribute, F.A_Scale_Attribute => Asis.A_Scale_Attribute, F.A_Scaling_Attribute => Asis.A_Scaling_Attribute, F.A_Signed_Zeros_Attribute => Asis.A_Signed_Zeros_Attribute, F.A_Size_Attribute => Asis.A_Size_Attribute, F.A_Small_Attribute => Asis.A_Small_Attribute, F.A_Storage_Pool_Attribute => Asis.A_Storage_Pool_Attribute, F.A_Storage_Size_Attribute => Asis.A_Storage_Size_Attribute, F.A_Stream_Size_Attribute => Asis.A_Stream_Size_Attribute, F.A_Succ_Attribute => Asis.A_Succ_Attribute, F.A_Tag_Attribute => Asis.A_Tag_Attribute, F.A_Terminated_Attribute => Asis.A_Terminated_Attribute, F.A_Truncation_Attribute => Asis.A_Truncation_Attribute, F.An_Unbiased_Rounding_Attribute => Asis.An_Unbiased_Rounding_Attribute, F.An_Unchecked_Access_Attribute => Asis.An_Unchecked_Access_Attribute, F.A_Val_Attribute => Asis.A_Val_Attribute, F.A_Valid_Attribute => Asis.A_Valid_Attribute, F.A_Value_Attribute => Asis.A_Value_Attribute, F.A_Version_Attribute => Asis.A_Version_Attribute, F.A_Wide_Image_Attribute => Asis.A_Wide_Image_Attribute, F.A_Wide_Value_Attribute => Asis.A_Wide_Value_Attribute, F.A_Wide_Wide_Image_Attribute => Asis.A_Wide_Wide_Image_Attribute, F.A_Wide_Wide_Value_Attribute => Asis.A_Wide_Wide_Value_Attribute, F.A_Wide_Wide_Width_Attribute => Asis.A_Wide_Wide_Width_Attribute, F.A_Wide_Width_Attribute => Asis.A_Wide_Width_Attribute, F.A_Width_Attribute => Asis.A_Width_Attribute, F.A_Write_Attribute => Asis.A_Write_Attribute, F.An_Implementation_Defined_Attribute => Asis.An_Implementation_Defined_Attribute, F.An_Unknown_Attribute => Asis.An_Unknown_Attribute); Kind : constant Asis.Extensions.Flat_Kinds.Element_Flat_Kind := Asis.Extensions.Flat_Kinds.Flat_Kind (Expression); begin if Kind in Map'Range then return Map (Kind); else return Not_An_Attribute; end if; end Attribute_Kind; ----------------- -- Clause_Kind -- ----------------- function Clause_Kind (Clause : in Asis.Clause) return Asis.Clause_Kinds is begin case F.Flat_Kind (Clause) is when F.A_Use_Package_Clause => return A_Use_Package_Clause; when F.A_Use_Type_Clause => return A_Use_Type_Clause; when F.A_With_Clause => return A_With_Clause; when F.A_Representation_Clause => return A_Representation_Clause; when F.A_Component_Clause => return A_Component_Clause; when others => return Not_A_Clause; end case; end Clause_Kind; ------------------------- -- Compilation_Pragmas -- ------------------------- function Compilation_Pragmas (Compilation_Unit : in Asis.Compilation_Unit) return Asis.Pragma_Element_List is begin Check_Nil_Unit (Compilation_Unit, "Compilation_Pragmas"); Raise_Not_Implemented (""); return Asis.Nil_Element_List; end Compilation_Pragmas; --------------------------- -- Configuration_Pragmas -- --------------------------- function Configuration_Pragmas (The_Context : in Asis.Context) return Asis.Pragma_Element_List is pragma Unreferenced (The_Context); begin -- Check_Context (The_Context); Raise_Not_Implemented (""); return Asis.Nil_Element_List; end Configuration_Pragmas; --------------------- -- Constraint_Kind -- --------------------- function Constraint_Kind (Definition : in Asis.Constraint) return Asis.Constraint_Kinds is Map : constant array (F.A_Constraint) of Asis.Constraint_Kinds := (F.A_Range_Attribute_Reference => Asis.A_Range_Attribute_Reference, F.A_Simple_Expression_Range => Asis.A_Simple_Expression_Range, F.A_Digits_Constraint => Asis.A_Digits_Constraint, F.A_Delta_Constraint => Asis.A_Delta_Constraint, F.An_Index_Constraint => Asis.An_Index_Constraint, F.A_Discriminant_Constraint => Asis.A_Discriminant_Constraint); Kind : constant Asis.Extensions.Flat_Kinds.Element_Flat_Kind := Asis.Extensions.Flat_Kinds.Flat_Kind (Definition); begin if Kind in Map'Range then return Map (Kind); else return Not_A_Constraint; end if; end Constraint_Kind; ----------------------------- -- Context_Clause_Elements -- ----------------------------- function Context_Clause_Elements (Compilation_Unit : in Asis.Compilation_Unit; Include_Pragmas : in Boolean := False) return Asis.Context_Clause_List is pragma Unreferenced (Include_Pragmas); package Get is type Visiter is new Gela.Element_Visiters.Visiter with record Result : Gela.Elements.Context_Items.Context_Item_Sequence_Access; end record; overriding procedure Compilation_Unit_Body (Self : in out Visiter; Node : not null Gela.Elements.Compilation_Unit_Bodies. Compilation_Unit_Body_Access); overriding procedure Compilation_Unit_Declaration (Self : in out Visiter; Node : not null Gela.Elements.Compilation_Unit_Declarations. Compilation_Unit_Declaration_Access); overriding procedure Subunit (Self : in out Visiter; Node : not null Gela.Elements.Subunits.Subunit_Access); end Get; package body Get is overriding procedure Compilation_Unit_Body (Self : in out Visiter; Node : not null Gela.Elements.Compilation_Unit_Bodies. Compilation_Unit_Body_Access) is begin Self.Result := Node.Context_Clause_Elements; end Compilation_Unit_Body; overriding procedure Compilation_Unit_Declaration (Self : in out Visiter; Node : not null Gela.Elements.Compilation_Unit_Declarations. Compilation_Unit_Declaration_Access) is begin Self.Result := Node.Context_Clause_Elements; end Compilation_Unit_Declaration; overriding procedure Subunit (Self : in out Visiter; Node : not null Gela.Elements.Subunits.Subunit_Access) is begin Self.Result := Node.Context_Clause_Elements; end Subunit; end Get; Tree : Gela.Elements.Compilation_Units.Compilation_Unit_Access; V : aliased Get.Visiter; begin Check_Nil_Unit (Compilation_Unit, "Context_Clause_Elements"); Tree := Compilation_Unit.Data.Tree; Tree.Visit (V); return Asis.To_List (Gela.Elements.Element_Sequence_Access (V.Result)); end Context_Clause_Elements; --------------------------- -- Corresponding_Pragmas -- --------------------------- function Corresponding_Pragmas (Element : in Asis.Element) return Asis.Pragma_Element_List is begin Check_Nil_Element (Element, "Corresponding_Pragmas"); Raise_Not_Implemented (""); return Asis.Nil_Element_List; end Corresponding_Pragmas; ----------------- -- Debug_Image -- ----------------- function Debug_Image (Element : in Asis.Element) return Wide_String is pragma Unreferenced (Element); begin return ""; end Debug_Image; ---------------------- -- Declaration_Kind -- ---------------------- function Declaration_Kind (Declaration : in Asis.Declaration) return Asis.Declaration_Kinds is Map : constant array (F.A_Declaration) of Asis.Declaration_Kinds := (F.An_Ordinary_Type_Declaration => Asis.An_Ordinary_Type_Declaration, F.A_Task_Type_Declaration => Asis.A_Task_Type_Declaration, F.A_Protected_Type_Declaration => Asis.A_Protected_Type_Declaration, F.An_Incomplete_Type_Declaration => Asis.An_Incomplete_Type_Declaration, F.A_Private_Type_Declaration => Asis.A_Private_Type_Declaration, F.A_Private_Extension_Declaration => Asis.A_Private_Extension_Declaration, F.A_Subtype_Declaration => Asis.A_Subtype_Declaration, F.A_Variable_Declaration => Asis.A_Variable_Declaration, F.A_Constant_Declaration => Asis.A_Constant_Declaration, F.A_Deferred_Constant_Declaration => Asis.A_Deferred_Constant_Declaration, F.A_Single_Task_Declaration => Asis.A_Single_Task_Declaration, F.A_Single_Protected_Declaration => Asis.A_Single_Protected_Declaration, F.An_Integer_Number_Declaration => Asis.An_Integer_Number_Declaration, F.A_Real_Number_Declaration => Asis.A_Real_Number_Declaration, F.An_Enumeration_Literal_Specification => Asis.An_Enumeration_Literal_Specification, F.A_Discriminant_Specification => Asis.A_Discriminant_Specification, F.A_Component_Declaration => Asis.A_Component_Declaration, F.A_Return_Object_Specification => Asis.A_Return_Object_Specification, F.A_Loop_Parameter_Specification => Asis.A_Loop_Parameter_Specification, F.A_Procedure_Declaration => Asis.A_Procedure_Declaration, F.A_Function_Declaration => Asis.A_Function_Declaration, F.A_Parameter_Specification => Asis.A_Parameter_Specification, F.A_Procedure_Body_Declaration => Asis.A_Procedure_Body_Declaration, F.A_Function_Body_Declaration => Asis.A_Function_Body_Declaration, F.A_Package_Declaration => Asis.A_Package_Declaration, F.A_Package_Body_Declaration => Asis.A_Package_Body_Declaration, F.An_Object_Renaming_Declaration => Asis.An_Object_Renaming_Declaration, F.An_Exception_Renaming_Declaration => Asis.An_Exception_Renaming_Declaration, F.A_Package_Renaming_Declaration => Asis.A_Package_Renaming_Declaration, F.A_Procedure_Renaming_Declaration => Asis.A_Procedure_Renaming_Declaration, F.A_Function_Renaming_Declaration => Asis.A_Function_Renaming_Declaration, F.A_Generic_Package_Renaming_Declaration => Asis.A_Generic_Package_Renaming_Declaration, F.A_Generic_Procedure_Renaming_Declaration => Asis.A_Generic_Procedure_Renaming_Declaration, F.A_Generic_Function_Renaming_Declaration => Asis.A_Generic_Function_Renaming_Declaration, F.A_Task_Body_Declaration => Asis.A_Task_Body_Declaration, F.A_Protected_Body_Declaration => Asis.A_Protected_Body_Declaration, F.An_Entry_Declaration => Asis.An_Entry_Declaration, F.An_Entry_Body_Declaration => Asis.An_Entry_Body_Declaration, F.An_Entry_Index_Specification => Asis.An_Entry_Index_Specification, F.A_Procedure_Body_Stub => Asis.A_Procedure_Body_Stub, F.A_Function_Body_Stub => Asis.A_Function_Body_Stub, F.A_Package_Body_Stub => Asis.A_Package_Body_Stub, F.A_Task_Body_Stub => Asis.A_Task_Body_Stub, F.A_Protected_Body_Stub => Asis.A_Protected_Body_Stub, F.An_Exception_Declaration => Asis.An_Exception_Declaration, F.A_Choice_Parameter_Specification => Asis.A_Choice_Parameter_Specification, F.A_Generic_Procedure_Declaration => Asis.A_Generic_Procedure_Declaration, F.A_Generic_Function_Declaration => Asis.A_Generic_Function_Declaration, F.A_Generic_Package_Declaration => Asis.A_Generic_Package_Declaration, F.A_Package_Instantiation => Asis.A_Package_Instantiation, F.A_Procedure_Instantiation => Asis.A_Procedure_Instantiation, F.A_Function_Instantiation => Asis.A_Function_Instantiation, F.A_Formal_Object_Declaration => Asis.A_Formal_Object_Declaration, F.A_Formal_Type_Declaration => Asis.A_Formal_Type_Declaration, F.A_Formal_Procedure_Declaration => Asis.A_Formal_Procedure_Declaration, F.A_Formal_Function_Declaration => Asis.A_Formal_Function_Declaration, F.A_Formal_Package_Declaration => Asis.A_Formal_Package_Declaration, F.A_Formal_Package_Declaration_With_Box => Asis.A_Formal_Package_Declaration_With_Box); Kind : constant Asis.Extensions.Flat_Kinds.Element_Flat_Kind := Asis.Extensions.Flat_Kinds.Flat_Kind (Declaration); begin if Kind in Map'Range then return Map (Kind); else return Not_A_Declaration; end if; end Declaration_Kind; ------------------------ -- Declaration_Origin -- ------------------------ function Declaration_Origin (Declaration : in Asis.Declaration) return Asis.Declaration_Origins is begin if Assigned (Declaration) then Raise_Not_Implemented (""); return Not_A_Declaration_Origin; else return Not_A_Declaration_Origin; end if; end Declaration_Origin; ------------------ -- Default_Kind -- ------------------ function Default_Kind (Declaration : in Asis.Generic_Formal_Parameter) return Asis.Subprogram_Default_Kinds is begin if Assigned (Declaration) then Raise_Not_Implemented (""); return Not_A_Default; else return Not_A_Default; end if; end Default_Kind; ------------------------ -- Defining_Name_Kind -- ------------------------ function Defining_Name_Kind (Defining_Name : in Asis.Defining_Name) return Asis.Defining_Name_Kinds is begin case F.Flat_Kind (Defining_Name) is when F.A_Defining_Identifier => return Asis.A_Defining_Identifier; when F.A_Defining_Character_Literal => return Asis.A_Defining_Character_Literal; when F.A_Defining_Enumeration_Literal => return Asis.A_Defining_Enumeration_Literal; when F.A_Defining_Operator_Symbol => return Asis.A_Defining_Operator_Symbol; when F.A_Defining_Expanded_Name => return Asis.A_Defining_Expanded_Name; when others => return Not_A_Defining_Name; end case; end Defining_Name_Kind; --------------------- -- Definition_Kind -- --------------------- function Definition_Kind (Definition : in Asis.Definition) return Asis.Definition_Kinds is begin case F.Flat_Kind (Definition) is when F.A_Type_Definition => return Asis.A_Type_Definition; when F.A_Subtype_Indication => return Asis.A_Subtype_Indication; when F.A_Constraint => return Asis.A_Constraint; when F.A_Component_Definition => return Asis.A_Component_Definition; when F.A_Discrete_Subtype_Definition => return Asis.A_Discrete_Subtype_Definition; when F.A_Discrete_Range => return Asis.A_Discrete_Range; when F.An_Unknown_Discriminant_Part => return Asis.An_Unknown_Discriminant_Part; when F.A_Known_Discriminant_Part => return Asis.A_Known_Discriminant_Part; when F.A_Record_Definition => return Asis.A_Record_Definition; when F.A_Null_Record_Definition => return Asis.A_Null_Record_Definition; when F.A_Null_Component => return Asis.A_Null_Component; when F.A_Variant_Part => return Asis.A_Variant_Part; when F.A_Variant => return Asis.A_Variant; when F.An_Others_Choice => return Asis.An_Others_Choice; when F.An_Access_Definition => return Asis.An_Access_Definition; when F.An_Incomplete_Type_Definition => return Asis.An_Incomplete_Type_Definition; when F.A_Tagged_Incomplete_Type_Definition => return Asis.A_Tagged_Incomplete_Type_Definition; when F.A_Private_Type_Definition => return Asis.A_Private_Type_Definition; when F.A_Tagged_Private_Type_Definition => return Asis.A_Tagged_Private_Type_Definition; when F.A_Private_Extension_Definition => return Asis.A_Private_Extension_Definition; when F.A_Task_Definition => return Asis.A_Task_Definition; when F.A_Protected_Definition => return Asis.A_Protected_Definition; when F.A_Formal_Type_Definition => return Asis.A_Formal_Type_Definition; when others => return Asis.Not_A_Definition; end case; end Definition_Kind; ------------------------- -- Discrete_Range_Kind -- ------------------------- function Discrete_Range_Kind (Definition : in Asis.Discrete_Range) return Asis.Discrete_Range_Kinds is Map : constant array (F.A_Discrete_Range) of Asis.Discrete_Range_Kinds := (F.A_Discrete_Subtype_Indication_DR => A_Discrete_Subtype_Indication, F.A_Discrete_Range_Attribute_Reference_DR => A_Discrete_Range_Attribute_Reference, F.A_Discrete_Simple_Expression_Range_DR => A_Discrete_Simple_Expression_Range); Map_2 : constant array (F.A_Discrete_Subtype_Definition) of Asis.Discrete_Range_Kinds := (F.A_Discrete_Subtype_Indication => A_Discrete_Subtype_Indication, F.A_Discrete_Range_Attribute_Reference => A_Discrete_Range_Attribute_Reference, F.A_Discrete_Simple_Expression_Range => A_Discrete_Simple_Expression_Range); Kind : constant Asis.Extensions.Flat_Kinds.Element_Flat_Kind := Asis.Extensions.Flat_Kinds.Flat_Kind (Definition); begin if Kind in Map'Range then return Map (Kind); elsif Kind in Map_2'Range then return Map_2 (Kind); else return Not_A_Discrete_Range; end if; end Discrete_Range_Kind; ------------------ -- Element_Kind -- ------------------ function Element_Kind (Element : in Asis.Element) return Asis.Element_Kinds is begin case F.Flat_Kind (Element) is when F.A_Pragma => return A_Pragma; when F.A_Defining_Name => return A_Defining_Name; when F.A_Declaration => return A_Declaration; when F.A_Definition => return A_Definition; when F.An_Expression => return An_Expression; when F.An_Association => return An_Association; when F.A_Statement => return A_Statement; when F.A_Path => return A_Path; when F.A_Clause => return A_Clause; when F.An_Exception_Handler => return An_Exception_Handler; when others => return Not_An_Element; end case; end Element_Kind; -------------------------------- -- Enclosing_Compilation_Unit -- -------------------------------- function Enclosing_Compilation_Unit (Element : in Asis.Element) return Asis.Compilation_Unit is use type Gela.Compilation_Units.Compilation_Unit_Access; procedure Find (List : Gela.Compilation_Unit_Sets.Compilation_Unit_Set_Access; Unit : out Gela.Compilation_Units.Compilation_Unit_Access); Comp : Gela.Compilations.Compilation_Access; From : Gela.Lexical_Types.Token_Count; To : Gela.Lexical_Types.Token_Count; ---------- -- Find -- ---------- procedure Find (List : Gela.Compilation_Unit_Sets.Compilation_Unit_Set_Access; Unit : out Gela.Compilation_Units.Compilation_Unit_Access) is use Gela.Compilations; use type Gela.Lexical_Types.Token_Count; Tree : Gela.Elements.Compilation_Units.Compilation_Unit_Access; Cursor : Gela.Compilation_Unit_Sets.Compilation_Unit_Cursor'Class := List.First; begin while Cursor.Has_Element loop Unit := Cursor.Element; Tree := Unit.Tree; if Unit.Compilation = Comp and then Tree.First_Token <= From and then Tree.Last_Token >= To then return; end if; Cursor.Next; end loop; Unit := null; end Find; Context : Gela.Contexts.Context_Access; Unit : Gela.Compilation_Units.Compilation_Unit_Access; begin Check_Nil_Element (Element, "Enclosing_Compilation_Unit"); Comp := Element.Data.Enclosing_Compilation; Context := Comp.Context; From := Element.Data.First_Token; To := Element.Data.Last_Token; Find (Context.Library_Unit_Declarations, Unit); if Unit = null then Find (Context.Compilation_Unit_Bodies, Unit); end if; -- Raise_Not_Implemented (""); return (Data => Unit); end Enclosing_Compilation_Unit; ----------------------- -- Enclosing_Element -- ----------------------- function Enclosing_Element (Element : in Asis.Element) return Asis.Element is Next : Asis.Element := Element; begin Check_Nil_Element (Element, "Enclosing_Element"); loop Next := (Data => Next.Data.Enclosing_Element); if not Assigned (Next) or else not Auxilary (Next) then return Next; end if; end loop; end Enclosing_Element; ----------------------- -- Enclosing_Element -- ----------------------- function Enclosing_Element (Element : in Asis.Element; Expected_Enclosing_Element : in Asis.Element) return Asis.Element is pragma Unreferenced (Expected_Enclosing_Element); begin return Enclosing_Element (Element); end Enclosing_Element; --------------------- -- Expression_Kind -- --------------------- function Expression_Kind (Expression : in Asis.Expression) return Asis.Expression_Kinds is begin case F.Flat_Kind (Expression) is when F.A_Box_Expression => return Asis.A_Box_Expression; when F.An_Integer_Literal => return Asis.An_Integer_Literal; when F.A_Real_Literal => return Asis.A_Real_Literal; when F.A_String_Literal => return Asis.A_String_Literal; when F.An_Identifier => return Asis.An_Identifier; when F.An_Operator_Symbol => return Asis.An_Operator_Symbol; when F.A_Character_Literal => return Asis.A_Character_Literal; when F.An_Enumeration_Literal => return Asis.An_Enumeration_Literal; when F.An_Explicit_Dereference => return Asis.An_Explicit_Dereference; when F.A_Function_Call => return Asis.A_Function_Call; when F.An_Indexed_Component => return Asis.An_Indexed_Component; when F.A_Slice => return Asis.A_Slice; when F.A_Selected_Component => return Asis.A_Selected_Component; when F.An_Attribute_Reference => return Asis.An_Attribute_Reference; when F.A_Record_Aggregate => return Asis.A_Record_Aggregate; when F.An_Extension_Aggregate => return Asis.An_Extension_Aggregate; when F.A_Positional_Array_Aggregate => return Asis.A_Positional_Array_Aggregate; when F.A_Named_Array_Aggregate => return Asis.A_Named_Array_Aggregate; when F.An_And_Then_Short_Circuit => return Asis.An_And_Then_Short_Circuit; when F.An_Or_Else_Short_Circuit => return Asis.An_Or_Else_Short_Circuit; when F.An_In_Membership_Test => return Asis.An_In_Membership_Test; when F.A_Not_In_Membership_Test => return Asis.A_Not_In_Membership_Test; when F.A_Null_Literal => return Asis.A_Null_Literal; when F.A_Parenthesized_Expression => return Asis.A_Parenthesized_Expression; when F.A_Type_Conversion => return Asis.A_Type_Conversion; when F.A_Qualified_Expression => return Asis.A_Qualified_Expression; when F.An_Allocation_From_Subtype => return Asis.An_Allocation_From_Subtype; when F.An_Allocation_From_Qualified_Expression => return Asis.An_Allocation_From_Qualified_Expression; when others => return Not_An_Expression; end case; end Expression_Kind; ---------------------- -- Formal_Type_Kind -- ---------------------- function Formal_Type_Kind (Definition : in Asis.Formal_Type_Definition) return Asis.Formal_Type_Kinds is begin if Assigned (Definition) then Raise_Not_Implemented (""); return Not_A_Formal_Type_Definition; else return Not_A_Formal_Type_Definition; end if; end Formal_Type_Kind; ----------------- -- Has_Limited -- ----------------- function Has_Limited (Element : in Asis.Element) return Boolean is begin if Assigned (Element) then Raise_Not_Implemented (""); return False; else return False; end if; end Has_Limited; ----------------- -- Has_Private -- ----------------- function Has_Private (Element : in Asis.Element) return Boolean is begin if Assigned (Element) then Raise_Not_Implemented (""); return False; else return False; end if; end Has_Private; ------------------ -- Has_Abstract -- ------------------ function Has_Abstract (Element : in Asis.Element) return Boolean is begin if Assigned (Element) then Raise_Not_Implemented (""); return False; else return False; end if; end Has_Abstract; ----------------- -- Has_Reverse -- ----------------- function Has_Reverse (Element : in Asis.Element) return Boolean is begin return Trait_Kind (Element) = A_Reverse_Trait; end Has_Reverse; ----------------- -- Has_Aliased -- ----------------- function Has_Aliased (Element : in Asis.Element) return Boolean is begin return Trait_Kind (Element) = An_Aliased_Trait; end Has_Aliased; ---------------------- -- Has_Synchronized -- ---------------------- function Has_Synchronized (Element : in Asis.Element) return Boolean is begin if Assigned (Element) then Raise_Not_Implemented (""); return False; else return False; end if; end Has_Synchronized; ------------------- -- Has_Protected -- ------------------- function Has_Protected (Element : in Asis.Element) return Boolean is begin if Assigned (Element) then Raise_Not_Implemented (""); return False; else return False; end if; end Has_Protected; ---------------- -- Has_Tagged -- ---------------- function Has_Tagged (Element : in Asis.Element) return Boolean is begin if Assigned (Element) then Raise_Not_Implemented (""); return False; else return False; end if; end Has_Tagged; -------------- -- Has_Task -- -------------- function Has_Task (Element : in Asis.Element) return Boolean is begin if Assigned (Element) then Raise_Not_Implemented (""); return False; else return False; end if; end Has_Task; ------------------------ -- Has_Null_Exclusion -- ------------------------ function Has_Null_Exclusion (Element : Asis.Element) return Boolean is begin if Assigned (Element) then Raise_Not_Implemented (""); return False; else return False; end if; end Has_Null_Exclusion; ---------- -- Hash -- ---------- function Hash (Element : in Asis.Element) return Asis.ASIS_Integer is use type Ada.Containers.Hash_Type; X : Ada.Containers.Hash_Type; begin if Assigned (Element) then X := Element.Data.Hash; X := X and Ada.Containers.Hash_Type (ASIS_Integer'Last); return ASIS_Integer (X); else return 0; end if; end Hash; -------------------- -- Interface_Kind -- -------------------- function Interface_Kind (Definition : Asis.Definition) return Asis.Interface_Kinds is begin if Assigned (Definition) then if Type_Kind (Definition) = An_Interface_Type_Definition or Formal_Type_Kind (Definition) = A_Formal_Interface_Type_Definition then if Has_Task (Definition) then return A_Task_Interface; elsif Has_Limited (Definition) then return A_Limited_Interface; elsif Has_Protected (Definition) then return A_Protected_Interface; elsif Has_Synchronized (Definition) then return A_Synchronized_Interface; else return An_Ordinary_Interface; end if; end if; end if; return Not_An_Interface; end Interface_Kind; ---------------------------- -- Is_Abstract_Subprogram -- ---------------------------- function Is_Abstract_Subprogram (Element : in Asis.Element) return Boolean is begin case Declaration_Kind (Element) is when A_Procedure_Declaration | A_Function_Declaration | A_Formal_Procedure_Declaration | A_Formal_Function_Declaration => return Has_Abstract (Element); when others => return False; end case; end Is_Abstract_Subprogram; -------------- -- Is_Equal -- -------------- function Is_Equal (Left : in Asis.Element; Right : in Asis.Element) return Boolean is pragma Unreferenced (Left); pragma Unreferenced (Right); begin Raise_Not_Implemented (""); return False; end Is_Equal; ------------------ -- Is_Identical -- ------------------ function Is_Identical (Left : in Asis.Element; Right : in Asis.Element) return Boolean is use type Gela.Elements.Element_Access; begin return Left.Data = Right.Data; end Is_Identical; ------------ -- Is_Nil -- ------------ function Is_Nil (Right : in Asis.Element) return Boolean is begin return not Assigned (Right); end Is_Nil; ------------ -- Is_Nil -- ------------ function Is_Nil (Right : in Asis.Element_List) return Boolean is begin return Right'Length = 0; end Is_Nil; ----------------------- -- Is_Null_Procedure -- ----------------------- function Is_Null_Procedure (Element : in Asis.Element) return Boolean is begin if Assigned (Element) then Raise_Not_Implemented (""); return False; else return False; end if; end Is_Null_Procedure; ------------------------- -- Is_Part_Of_Implicit -- ------------------------- function Is_Part_Of_Implicit (Element : in Asis.Element) return Boolean is begin if Assigned (Element) then return Element.Data.Is_Part_Of_Implicit; else return False; end if; end Is_Part_Of_Implicit; -------------------------- -- Is_Part_Of_Inherited -- -------------------------- function Is_Part_Of_Inherited (Element : in Asis.Element) return Boolean is begin if Assigned (Element) then return Element.Data.Is_Part_Of_Inherited; else return False; end if; end Is_Part_Of_Inherited; ------------------------- -- Is_Part_Of_Instance -- ------------------------- function Is_Part_Of_Instance (Element : in Asis.Element) return Boolean is begin if Assigned (Element) then return Element.Data.Is_Part_Of_Instance; else return False; end if; end Is_Part_Of_Instance; --------------- -- Mode_Kind -- --------------- function Mode_Kind (Declaration : in Asis.Declaration) return Asis.Mode_Kinds is package Get is type Visiter is new Gela.Element_Visiters.Visiter with record Mode : Asis.Mode_Kinds := Not_A_Mode; end record; overriding procedure Parameter_Specification (Self : in out Visiter; Node : not null Gela.Elements.Parameter_Specifications. Parameter_Specification_Access); end Get; package body Get is overriding procedure Parameter_Specification (Self : in out Visiter; Node : not null Gela.Elements.Parameter_Specifications. Parameter_Specification_Access) is begin if Node.In_Token in Gela.Lexical_Types.Token_Index then if Node.Out_Token in Gela.Lexical_Types.Token_Index then Self.Mode := An_In_Out_Mode; else Self.Mode := An_In_Mode; end if; elsif Node.Out_Token in Gela.Lexical_Types.Token_Index then Self.Mode := An_Out_Mode; else Self.Mode := A_Default_In_Mode; end if; end Parameter_Specification; end Get; V : aliased Get.Visiter; begin if Assigned (Declaration) then Declaration.Data.Visit (V); return V.Mode; else return Not_A_Mode; end if; end Mode_Kind; ------------------- -- Operator_Kind -- ------------------- function Operator_Kind (Element : in Asis.Element) return Asis.Operator_Kinds is begin case F.Flat_Kind (Element) is when F.A_Defining_And_Operator => return An_And_Operator; when F.A_Defining_Or_Operator => return An_Or_Operator; when F.A_Defining_Xor_Operator => return An_Xor_Operator; when F.A_Defining_Equal_Operator => return An_Equal_Operator; when F.A_Defining_Not_Equal_Operator => return A_Not_Equal_Operator; when F.A_Defining_Less_Than_Operator => return A_Less_Than_Operator; when F.A_Defining_Less_Than_Or_Equal_Operator => return A_Less_Than_Or_Equal_Operator; when F.A_Defining_Greater_Than_Operator => return A_Greater_Than_Operator; when F.A_Defining_Greater_Than_Or_Equal_Operator => return A_Greater_Than_Or_Equal_Operator; when F.A_Defining_Plus_Operator => return A_Plus_Operator; when F.A_Defining_Minus_Operator => return A_Minus_Operator; when F.A_Defining_Concatenate_Operator => return A_Concatenate_Operator; when F.A_Defining_Unary_Plus_Operator => return A_Unary_Plus_Operator; when F.A_Defining_Unary_Minus_Operator => return A_Unary_Minus_Operator; when F.A_Defining_Multiply_Operator => return A_Multiply_Operator; when F.A_Defining_Divide_Operator => return A_Divide_Operator; when F.A_Defining_Mod_Operator => return A_Mod_Operator; when F.A_Defining_Rem_Operator => return A_Rem_Operator; when F.A_Defining_Exponentiate_Operator => return An_Exponentiate_Operator; when F.A_Defining_Abs_Operator => return An_Abs_Operator; when F.A_Defining_Not_Operator => return A_Not_Operator; when F.An_And_Operator => return An_And_Operator; when F.An_Or_Operator => return An_Or_Operator; when F.An_Xor_Operator => return An_Xor_Operator; when F.An_Equal_Operator => return An_Equal_Operator; when F.A_Not_Equal_Operator => return A_Not_Equal_Operator; when F.A_Less_Than_Operator => return A_Less_Than_Operator; when F.A_Less_Than_Or_Equal_Operator => return A_Less_Than_Or_Equal_Operator; when F.A_Greater_Than_Operator => return A_Greater_Than_Operator; when F.A_Greater_Than_Or_Equal_Operator => return A_Greater_Than_Or_Equal_Operator; when F.A_Plus_Operator => return A_Plus_Operator; when F.A_Minus_Operator => return A_Minus_Operator; when F.A_Concatenate_Operator => return A_Concatenate_Operator; when F.A_Unary_Plus_Operator => return A_Unary_Plus_Operator; when F.A_Unary_Minus_Operator => return A_Unary_Minus_Operator; when F.A_Multiply_Operator => return A_Multiply_Operator; when F.A_Divide_Operator => return A_Divide_Operator; when F.A_Mod_Operator => return A_Mod_Operator; when F.A_Rem_Operator => return A_Rem_Operator; when F.An_Exponentiate_Operator => return An_Exponentiate_Operator; when F.An_Abs_Operator => return An_Abs_Operator; when F.A_Not_Operator => return A_Not_Operator; when others => return Not_An_Operator; end case; end Operator_Kind; --------------- -- Path_Kind -- --------------- function Path_Kind (Path : in Asis.Path) return Asis.Path_Kinds is Map : constant array (F.A_Path) of Asis.Path_Kinds := (F.An_If_Path => Asis.An_If_Path, F.An_Elsif_Path => Asis.An_Elsif_Path, F.An_Else_Path => Asis.An_Else_Path, F.A_Case_Path => Asis.A_Case_Path, F.A_Select_Path => Asis.A_Select_Path, F.An_Or_Path => Asis.An_Or_Path, F.A_Then_Abort_Path => Asis.A_Then_Abort_Path); Kind : constant Asis.Extensions.Flat_Kinds.Element_Flat_Kind := Asis.Extensions.Flat_Kinds.Flat_Kind (Path); begin if Kind in Map'Range then return Map (Kind); else return Not_A_Path; end if; end Path_Kind; ---------------------------------- -- Pragma_Argument_Associations -- ---------------------------------- function Pragma_Argument_Associations (Pragma_Element : in Asis.Pragma_Element) return Asis.Association_List is begin Check_Nil_Element (Pragma_Element, "Pragma_Argument_Associations"); Raise_Not_Implemented (""); return Asis.Nil_Element_List; end Pragma_Argument_Associations; ----------------- -- Pragma_Kind -- ----------------- function Pragma_Kind (Pragma_Element : in Asis.Pragma_Element) return Asis.Pragma_Kinds is begin if Assigned (Pragma_Element) then return Not_A_Pragma; else return Not_A_Pragma; end if; end Pragma_Kind; ----------------------- -- Pragma_Name_Image -- ----------------------- function Pragma_Name_Image (Pragma_Element : in Asis.Pragma_Element) return Program_Text is begin Check_Nil_Element (Pragma_Element, "Pragma_Name_Image"); Raise_Not_Implemented (""); return ""; end Pragma_Name_Image; ------------- -- Pragmas -- ------------- function Pragmas (The_Element : in Asis.Element) return Asis.Pragma_Element_List is begin Check_Nil_Element (The_Element, "Pragmas"); Raise_Not_Implemented (""); return Asis.Nil_Element_List; end Pragmas; -------------------------------- -- Representation_Clause_Kind -- -------------------------------- function Representation_Clause_Kind (Clause : in Asis.Representation_Clause) return Asis.Representation_Clause_Kinds is Map : constant array (F.A_Representation_Clause) of Asis.Representation_Clause_Kinds := (F.An_Attribute_Definition_Clause => Asis.An_Attribute_Definition_Clause, F.An_Enumeration_Representation_Clause => Asis.An_Enumeration_Representation_Clause, F.A_Record_Representation_Clause => Asis.A_Record_Representation_Clause, F.An_At_Clause => Asis.An_At_Clause); Kind : constant Asis.Extensions.Flat_Kinds.Element_Flat_Kind := Asis.Extensions.Flat_Kinds.Flat_Kind (Clause); begin if Kind in Map'Range then return Map (Kind); else return Not_A_Representation_Clause; end if; end Representation_Clause_Kind; -------------------- -- Root_Type_Kind -- -------------------- function Root_Type_Kind (Definition : in Asis.Root_Type_Definition) return Asis.Root_Type_Kinds is begin if Assigned (Definition) then Raise_Not_Implemented (""); return Not_A_Root_Type_Definition; else return Not_A_Root_Type_Definition; end if; end Root_Type_Kind; -------------------- -- Statement_Kind -- -------------------- function Statement_Kind (Statement : in Asis.Statement) return Asis.Statement_Kinds is Map : constant array (F.A_Statement) of Asis.Statement_Kinds := (F.A_Null_Statement => Asis.A_Null_Statement, F.An_Assignment_Statement => Asis.An_Assignment_Statement, F.An_If_Statement => Asis.An_If_Statement, F.A_Case_Statement => Asis.A_Case_Statement, F.A_Loop_Statement => Asis.A_Loop_Statement, F.A_While_Loop_Statement => Asis.A_While_Loop_Statement, F.A_For_Loop_Statement => Asis.A_For_Loop_Statement, F.A_Block_Statement => Asis.A_Block_Statement, F.An_Exit_Statement => Asis.An_Exit_Statement, F.A_Goto_Statement => Asis.A_Goto_Statement, F.A_Procedure_Call_Statement => Asis.A_Procedure_Call_Statement, F.A_Simple_Return_Statement => Asis.A_Simple_Return_Statement, F.An_Extended_Return_Statement => Asis.An_Extended_Return_Statement, F.An_Accept_Statement => Asis.An_Accept_Statement, F.An_Entry_Call_Statement => Asis.An_Entry_Call_Statement, F.A_Requeue_Statement => Asis.A_Requeue_Statement, F.A_Requeue_Statement_With_Abort => Asis.A_Requeue_Statement_With_Abort, F.A_Delay_Until_Statement => Asis.A_Delay_Until_Statement, F.A_Delay_Relative_Statement => Asis.A_Delay_Relative_Statement, F.A_Terminate_Alternative_Statement => Asis.A_Terminate_Alternative_Statement, F.A_Selective_Accept_Statement => Asis.A_Selective_Accept_Statement, F.A_Timed_Entry_Call_Statement => Asis.A_Timed_Entry_Call_Statement, F.A_Conditional_Entry_Call_Statement => Asis.A_Conditional_Entry_Call_Statement, F.An_Asynchronous_Select_Statement => Asis.An_Asynchronous_Select_Statement, F.An_Abort_Statement => Asis.An_Abort_Statement, F.A_Raise_Statement => Asis.A_Raise_Statement, F.A_Code_Statement => Asis.A_Code_Statement); Kind : constant Asis.Extensions.Flat_Kinds.Element_Flat_Kind := Asis.Extensions.Flat_Kinds.Flat_Kind (Statement); begin if Kind in Map'Range then return Map (Kind); else return Not_A_Statement; end if; end Statement_Kind; ---------------- -- Trait_Kind -- ---------------- function Trait_Kind (Element : in Asis.Element) return Asis.Trait_Kinds is package Get is type Visiter is new Gela.Element_Visiters.Visiter with record Trait : Asis.Trait_Kinds := Not_A_Trait; end record; overriding procedure For_Loop_Statement (Self : in out Visiter; Node : not null Gela.Elements.For_Loop_Statements. For_Loop_Statement_Access); overriding procedure Loop_Parameter_Specification (Self : in out Visiter; Node : not null Gela.Elements.Loop_Parameter_Specifications. Loop_Parameter_Specification_Access); overriding procedure Private_Type_Declaration (Self : in out Visiter; Node : not null Gela.Elements.Private_Type_Declarations. Private_Type_Declaration_Access); overriding procedure Private_Type_Definition (Self : in out Visiter; Node : not null Gela.Elements.Private_Type_Definitions. Private_Type_Definition_Access); end Get; package body Get is overriding procedure For_Loop_Statement (Self : in out Visiter; Node : not null Gela.Elements.For_Loop_Statements. For_Loop_Statement_Access) is begin Node.Loop_Parameter_Specification.Visit (Self); end For_Loop_Statement; overriding procedure Loop_Parameter_Specification (Self : in out Visiter; Node : not null Gela.Elements.Loop_Parameter_Specifications. Loop_Parameter_Specification_Access) is begin if Node.Reverse_Token in Gela.Lexical_Types.Token_Index then Self.Trait := A_Reverse_Trait; end if; end Loop_Parameter_Specification; overriding procedure Private_Type_Declaration (Self : in out Visiter; Node : not null Gela.Elements.Private_Type_Declarations. Private_Type_Declaration_Access) is begin if Node.Type_Declaration_View not in null then Node.Type_Declaration_View.Visit (Self); end if; end Private_Type_Declaration; overriding procedure Private_Type_Definition (Self : in out Visiter; Node : not null Gela.Elements.Private_Type_Definitions. Private_Type_Definition_Access) is begin if Node.Private_Token in Gela.Lexical_Types.Token_Index then if Node.Limited_Token in Gela.Lexical_Types.Token_Index then Self.Trait := A_Limited_Private_Trait; else Self.Trait := A_Private_Trait; end if; elsif Node.Limited_Token in Gela.Lexical_Types.Token_Index then Self.Trait := A_Limited_Trait; end if; end Private_Type_Definition; end Get; V : aliased Get.Visiter; begin if Assigned (Element) then Element.Data.Visit (V); return V.Trait; else return Not_A_Trait; end if; end Trait_Kind; --------------- -- Type_Kind -- --------------- function Type_Kind (Definition : in Asis.Type_Definition) return Asis.Type_Kinds is begin case F.Flat_Kind (Definition) is when F.A_Derived_Type_Definition => return Asis.A_Derived_Type_Definition; when F.A_Derived_Record_Extension_Definition => return Asis.A_Derived_Record_Extension_Definition; when F.An_Enumeration_Type_Definition => return Asis.An_Enumeration_Type_Definition; when F.A_Signed_Integer_Type_Definition => return Asis.A_Signed_Integer_Type_Definition; when F.A_Modular_Type_Definition => return Asis.A_Modular_Type_Definition; when F.A_Root_Type_Definition => return Asis.A_Root_Type_Definition; when F.A_Floating_Point_Definition => return A_Floating_Point_Definition; when F.An_Ordinary_Fixed_Point_Definition => return An_Ordinary_Fixed_Point_Definition; when F.A_Decimal_Fixed_Point_Definition => return A_Decimal_Fixed_Point_Definition; when F.An_Unconstrained_Array_Definition => return An_Unconstrained_Array_Definition; when F.A_Constrained_Array_Definition => return A_Constrained_Array_Definition; when F.A_Record_Type_Definition => return A_Record_Type_Definition; when F.A_Tagged_Record_Type_Definition => return A_Tagged_Record_Type_Definition; when F.An_Interface_Type_Definition => return Asis.An_Interface_Type_Definition; when F.An_Access_Type_Definition => return Asis.An_Access_Type_Definition; when others => return Not_A_Type_Definition; end case; end Type_Kind; ---------------------- -- Unit_Declaration -- ---------------------- function Unit_Declaration (Compilation_Unit : in Asis.Compilation_Unit) return Asis.Declaration is package Get is type Visiter is new Gela.Element_Visiters.Visiter with record Unit : Gela.Elements.Element_Access; end record; overriding procedure Compilation_Unit_Body (Self : in out Visiter; Node : not null Gela.Elements.Compilation_Unit_Bodies. Compilation_Unit_Body_Access); overriding procedure Compilation_Unit_Declaration (Self : in out Visiter; Node : not null Gela.Elements.Compilation_Unit_Declarations. Compilation_Unit_Declaration_Access); overriding procedure Subunit (Self : in out Visiter; Node : not null Gela.Elements.Subunits.Subunit_Access); end Get; package body Get is overriding procedure Compilation_Unit_Body (Self : in out Visiter; Node : not null Gela.Elements.Compilation_Unit_Bodies. Compilation_Unit_Body_Access) is Result : constant Gela.Elements.Library_Unit_Bodies. Library_Unit_Body_Access := Node.Unit_Declaration; begin Self.Unit := Gela.Elements.Element_Access (Result); end Compilation_Unit_Body; overriding procedure Compilation_Unit_Declaration (Self : in out Visiter; Node : not null Gela.Elements.Compilation_Unit_Declarations. Compilation_Unit_Declaration_Access) is Result : constant Gela.Elements.Library_Unit_Declarations. Library_Unit_Declaration_Access := Node.Unit_Declaration; begin Self.Unit := Gela.Elements.Element_Access (Result); end Compilation_Unit_Declaration; overriding procedure Subunit (Self : in out Visiter; Node : not null Gela.Elements.Subunits.Subunit_Access) is Result : constant Gela.Elements.Proper_Bodies.Proper_Body_Access := Node.Unit_Declaration; begin Self.Unit := Gela.Elements.Element_Access (Result); end Subunit; end Get; Tree : Gela.Elements.Compilation_Units.Compilation_Unit_Access; V : aliased Get.Visiter; begin Check_Nil_Unit (Compilation_Unit, "Unit_Declaration"); Tree := Compilation_Unit.Data.Tree; Tree.Visit (V); return (Data => V.Unit); end Unit_Declaration; end Asis.Elements; ------------------------------------------------------------------------------ -- 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. ------------------------------------------------------------------------------
reznikmm/matreshka
Ada
4,606
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Svg.Font_Weight_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Svg_Font_Weight_Attribute_Node is begin return Self : Svg_Font_Weight_Attribute_Node do Matreshka.ODF_Svg.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Svg_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Svg_Font_Weight_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Font_Weight_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Svg_URI, Matreshka.ODF_String_Constants.Font_Weight_Attribute, Svg_Font_Weight_Attribute_Node'Tag); end Matreshka.ODF_Svg.Font_Weight_Attributes;
sebsgit/textproc
Ada
741
ads
with Histogram; with PixelArray; with ImageRegions; package HistogramDescriptor is pragma Assertion_Policy (Pre => Check, Post => Check, Type_Invariant => Check); BinCount: Positive := 20; type Divergence is (JensenShannon, KullbackLeibler); type Data is tagged record horizontal: Histogram.Data(BinCount); vertical: Histogram.Data(BinCount); end record; function create(image: PixelArray.ImagePlane; region: ImageRegions.Rect) return Data with Pre => region.width /= 0 and region.height /= 0; function computeDivergence(h0, h1: Histogram.Data; method: Divergence) return Float with Pre => (h0.Size = h1.Size); end HistogramDescriptor;
thierr26/ada-keystore
Ada
2,916
ads
----------------------------------------------------------------------- -- keystore-files-tests -- Tests for keystore files -- Copyright (C) 2019 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Tests; package Keystore.Files.Tests is procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite); type Test is new Util.Tests.Test with null record; -- Test creation of a keystore and re-opening it. procedure Test_Create (T : in out Test); -- Test opening a keystore when some blocks are corrupted. procedure Test_Corruption (T : in out Test); -- Test adding values to a keystore. procedure Test_Add (T : in out Test); -- Test adding values and getting them back. procedure Test_Add_Get (T : in out Test); -- Test deleting values. procedure Test_Delete (T : in out Test); -- Test update values. procedure Test_Update (T : in out Test); -- Test update values in growing and descending sequences. procedure Test_Update_Sequence (T : in out Test); -- Test opening and closing keystore. procedure Test_Open_Close (T : in out Test); -- Test opening a keystore and listing the entries. procedure Test_List (T : in out Test); -- Test adding values that already exist. procedure Test_Add_Error (T : in out Test); -- Test changing the wallet password. procedure Test_Set_Key (T : in out Test); -- Test adding empty values to a keystore. procedure Test_Add_Empty (T : in out Test); -- Test getting values through an Output_Stream. procedure Test_Get_Stream (T : in out Test); -- Test setting values through an Input_Stream. procedure Test_Set_From_Stream (T : in out Test); procedure Test_Set_From_Larger_Stream (T : in out Test); -- Perforamce test adding values. procedure Test_Perf_Add (T : in out Test); procedure Test_File_Stream (T : in out Test; Name : in String; Input : in String); -- Test setting and getting header data. procedure Test_Header_Data_1 (T : in out Test); procedure Test_Header_Data_10 (T : in out Test); -- Test creating a wallet. procedure Test_Add_Wallet (T : in out Test); end Keystore.Files.Tests;
stcarrez/ada-el
Ada
3,107
adb
----------------------------------------------------------------------- -- Test_Bean - A simple bean for unit tests -- Copyright (C) 2009, 2010, 2011, 2022 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body Test_Bean is use EL.Objects; FIRST_NAME : constant String := "firstName"; LAST_NAME : constant String := "lastName"; AGE : constant String := "age"; WEIGHT : constant String := "weight"; function Create_Person (First_Name, Last_Name : String; Age : Natural) return Person_Access is begin return new Person '(First_Name => To_Unbounded_String (First_Name), Last_Name => To_Unbounded_String (Last_Name), Age => Age, Date => Ada.Calendar.Clock, Weight => 12.0); end Create_Person; -- Get the value identified by the name. overriding function Get_Value (From : Person; Name : String) return EL.Objects.Object is begin if Name = FIRST_NAME then return To_Object (From.First_Name); elsif Name = LAST_NAME then return To_Object (From.Last_Name); elsif Name = AGE then return To_Object (From.Age); elsif Name = WEIGHT then return To_Object (From.Weight); -- elsif Name = DATE then -- return To_Object (From.Date); else return EL.Objects.Null_Object; end if; end Get_Value; -- Set the value identified by the name. overriding procedure Set_Value (From : in out Person; Name : in String; Value : in EL.Objects.Object) is begin if Name = FIRST_NAME then From.First_Name := To_Unbounded_String (Value); elsif Name = LAST_NAME then From.Last_Name := To_Unbounded_String (Value); elsif Name = AGE then From.Age := Natural (To_Integer (Value)); elsif Name = WEIGHT then From.Weight := To_Long_Long_Float (Value); -- elsif Name = DATE then -- From.Date := To_Time (Value); else raise EL.Objects.No_Value; end if; end Set_Value; -- Function to format a string function Format (Arg : EL.Objects.Object) return EL.Objects.Object is S : constant String := To_String (Arg); begin return To_Object ("[" & S & "]"); end Format; end Test_Bean;
PThierry/ewok-kernel
Ada
936
ads
-- -- Copyright 2018 The wookey project team <[email protected]> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- -- Dummy package added to avoid default_handlers.c compilation package default_handlers with spark_mode => on is procedure dummy; end default_handlers;
dannyboywoop/AdventOfCode2019
Ada
681
adb
with File_IO; use File_IO; with Ada.Text_IO; use Ada.Text_IO; with Array_Stuff; use Array_Stuff; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with String_Stuff; use String_Stuff; with Intcode; use Intcode; procedure Main is input: Unbounded_String:=Read_File("input.txt")(1); strings: Str_Arr:=Split(input, ","); program_data: Int_Arr:=Str_To_Int_Array(strings); star_one_data: Int_Arr:=Initialise_Program(program_data, 12, 2); star_one, star_two: Integer; begin star_one:= Run_Program(star_one_data); Put_Line("Star one: "&star_one'Image); star_two:= Find_Start_Vals(program_data, 19690720); Put_Line("Star two: "&star_two'Image); end Main;
charlie5/lace
Ada
980
ads
with openGL.Geometry; package openGL.Model.sphere.colored -- -- Models a colored sphere. -- is type Item is new Model.sphere.item with private; type View is access all Item'Class; --------- --- Forge -- function new_Sphere (Radius : in Real; lat_Count : in Positive := openGL.Model.sphere.default_latitude_Count; long_Count : in Positive := openGL.Model.sphere.default_longitude_Count; Color : in openGL.lucid_Color) return View; -------------- --- Attributes -- overriding function to_GL_Geometries (Self : access Item; Textures : access Texture.name_Map_of_texture'Class; Fonts : in Font.font_id_Map_of_font) return Geometry.views; private type Item is new Model.sphere.item with record Color : openGL.lucid_Color; end record; end openGL.Model.sphere.colored;
AdaCore/libadalang
Ada
205
adb
with System; procedure Test_Subp_Address is function Foo (A : Integer) return Integer is (A * 2); A : System.Address := Foo'Address; pragma Test_Statement; begin null; end Test_Subp_Address;
AdaCore/Ada_Drivers_Library
Ada
5,995
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 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. -- -- -- ------------------------------------------------------------------------------ -- A driver for the Cyclic Redundancy Check CRC-32 calculation processor, -- using DMA to transfer the data to the CRC unit (instead of the CPU). -- Note this API is for the STM32 F4x family. Other STM MCUs have additional -- CRC capabilities. -- See also app note AN4187 "Using CRC through DMA" -- Example usage, assuming prior clock enabling for the CRC unit: -- Checksum_DMA : UInt32 := 0; -- -- Data : constant Block_32 := ( .... ); -- -- ... -- -- Enable_Clock (Controller); -- -- Reset (Controller); -- -- Reset_Calculator (CRC_Unit); -- if need be -- -- Update_CRC (CRC_Unit, Controller'Access, Stream, Input => Data); -- -- DMA_IRQ_Handler.Await_Event (Next_DMA_Interrupt); -- -- if Next_DMA_Interrupt /= Transfer_Complete_Interrupt then -- Panic; -- end if; -- -- Checksum_DMA := Value (CRC_Unit); with STM32.DMA; use STM32.DMA; with System; package STM32.CRC.DMA is pragma Elaborate_Body; -- These routines use the specified controller and stream to transfer -- all of the Input data components to This CRC unit, updating the -- CRC value accordingly. At the end of the transfer the DMA interrupt -- Transfer_Complete_Interrupt is triggered. Clients are expected to have -- an application-defined handler for that interrupt, in order to await -- completion of the transfer. -- These routines can be called multiple times, back-to-back, presumably -- with different input blocks, in order to update the value of the -- calculated CRC checksum within the CRC processor. Each call will -- result in a Transfer_Complete_Interrupt event. -- Note that you can use a slice if the entire block is not intended for -- transfer, but beware alignment boundaries to prevent copying of the -- actual parameter into a temporary. procedure Update_CRC (This : in out CRC_32; Controller : access DMA_Controller; Stream : DMA_Stream_Selector; Input : Block_32); -- Update the calculated CRC value based on all of the 32-bit components -- of Input. Triggers the Transfer_Complete_Interrupt on completion. procedure Update_CRC (This : in out CRC_32; Controller : access DMA_Controller; Stream : DMA_Stream_Selector; Input : Block_16); -- Update the calculated CRC value based on all of the 16-bit components -- of Input. Triggers the Transfer_Complete_Interrupt on completion. procedure Update_CRC (This : in out CRC_32; Controller : access DMA_Controller; Stream : DMA_Stream_Selector; Input : Block_8); -- Update the calculated CRC value based on all of the 8-bit components -- of Input. Triggers the Transfer_Complete_Interrupt on completion. private procedure Transfer_Input_To_CRC (This : in out CRC_32; Controller : access DMA_Controller; Stream : DMA_Stream_Selector; Input_Address : System.Address; Input_Length : UInt16; Data_Width : DMA_Data_Transfer_Widths); -- Configures the DMA controller and stream for transfering memory blocks, -- of the width specified by Data_Width, to This CRC processor. Then uses -- the controller and stream to transfer the data starting at Input_Address -- to This CRC unit, updating the CRC value accordingly. The number of -- Input memory items (of Data_Width size) to be transferred is specified -- by Input_Length. At the end of the transfer the DMA interrupt -- Transfer_Complete_Interrupt is triggered. end STM32.CRC.DMA;
Skyfold/aws_sorter
Ada
1,118
adb
with GNAT.Sockets; with common_types; use common_types; with Ada.Text_IO; procedure client is Client_Socket : GNAT.Sockets.Socket_Type; Server_Address : GNAT.Sockets.Sock_Addr_Type; Client_Number : Positive; Channel : GNAT.Sockets.Stream_Access; Swap_String : Bounded_300.Bounded_String; begin -- Start a socket GNAT.Sockets.Initialize; GNAT.Sockets.Create_Socket (Client_Socket); Server_Address.Addr := GNAT.Sockets.Inet_Addr ("127.0.0.1"); Server_Address.Port := 6789; -- Connect socket to server GNAT.Sockets.Connect_Socket (Client_Socket, Server_Address); Channel := GNAT.Sockets.Stream (Client_Socket); -- Get Client Number Positive'Read (Channel, Client_Number); Ada.Text_IO.Put_Line ("I am client" & Positive'Image (Client_Number)); -- Get text from user and send to server loop Swap_String := Bounded_300.To_Bounded_String (Ada.Text_IO.Get_Line); Bounded_300.Bounded_String'Write (Channel, Swap_String); exit when Bounded_300.Length (Swap_String) = 0; end loop; GNAT.Sockets.Close_Socket (Client_Socket); end client;
reznikmm/matreshka
Ada
99,862
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2010-2013, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ pragma Style_Checks ("-t"); -- GNAT: Disable check for token separation rules, because format of the -- tables is not compatible with them. with Matreshka.Internals.Unicode; private package Matreshka.Internals.Regexps.Compiler.Scanner.Tables is pragma Preelaborate; subtype YY_Secondary_Index is Matreshka.Internals.Unicode.Code_Point range 0 .. 16#FF#; subtype YY_Primary_Index is Matreshka.Internals.Unicode.Code_Point range 0 .. 16#10FF#; type YY_Secondary_Array is array (YY_Secondary_Index) of Integer; type YY_Secondary_Array_Access is not null access constant YY_Secondary_Array; YY_End_Of_Buffer : constant := 155; YY_Jam_State : constant := 1268; YY_First_Template : constant := 1269; INITIAL : constant := 0; LITERAL : constant := 1; CHARACTER_CLASS : constant := 2; MULTIPLICITY : constant := 3; COMMENT : constant := 4; PROPERTY_SPECIFICATION_UNICODE : constant := 5; PROPERTY_SPECIFICATION_POSIX : constant := 6; YY_Accept : constant array (0 .. 1268) of Integer := ( 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 155, 151, 150, 152, 12, 13, 14, 19, 21, 1, 17, 22, 152, 11, 27, 15, 4, 4, 25, 152, 152, 23, 24, 32, 30, 31, 28, 9, 8, 154, 148, 154, 154, 110, 154, 154, 154, 154, 154, 154, 154, 116, 154, 127, 154, 131, 154, 154, 139, 154, 154, 154, 154, 154, 144, 139, 154, 49, 148, 150, 0, 18, 20, 16, 46, 34, 0, 2, 0, 38, 0, 39, 40, 35, 0, 36, 37, 0, 41, 3, 31, 29, 0, 0, 0, 0, 0, 111, 63, 112, 0, 56, 0, 113, 114, 115, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 117, 0, 0, 118, 119, 120, 121, 122, 0, 124, 125, 126, 0, 0, 128, 129, 130, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 132, 133, 134, 135, 136, 137, 0, 138, 0, 0, 0, 0, 140, 97, 0, 141, 142, 143, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 102, 0, 0, 0, 0, 145, 146, 147, 50, 7, 6, 48, 47, 0, 42, 45, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 59, 61, 62, 0, 0, 0, 66, 68, 0, 0, 0, 69, 0, 0, 0, 0, 0, 0, 0, 0, 0, 73, 0, 0, 0, 75, 0, 77, 0, 0, 0, 0, 81, 0, 0, 0, 0, 0, 0, 0, 0, 0, 86, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 51, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 57, 58, 0, 65, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 76, 0, 0, 78, 79, 0, 0, 0, 0, 0, 0, 123, 83, 0, 0, 0, 0, 0, 0, 0, 0, 0, 88, 89, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 104, 105, 0, 0, 0, 52, 0, 0, 0, 53, 54, 0, 0, 0, 55, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 60, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 71, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 80, 0, 0, 0, 0, 0, 0, 82, 0, 0, 0, 0, 84, 0, 0, 0, 0, 0, 0, 91, 0, 0, 0, 110, 0, 0, 0, 0, 94, 0, 131, 95, 0, 0, 0, 0, 0, 0, 103, 0, 98, 0, 0, 0, 0, 100, 0, 0, 101, 0, 0, 0, 0, 0, 0, 0, 106, 107, 0, 0, 43, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 64, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 70, 72, 0, 74, 0, 0, 0, 0, 0, 0, 0, 0, 116, 0, 0, 0, 0, 0, 0, 0, 127, 85, 87, 90, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 92, 0, 93, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 139, 0, 0, 0, 0, 0, 0, 0, 0, 0, 103, 0, 0, 108, 109, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 77, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 96, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 69, 0, 0, 0, 73, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 105, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 82, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 144, 0, 0, 0, 0, 0, 0, 0, 0, 0, 101, 0, 0, 0, 44, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 66, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 75, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 114, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 0, 0, 0, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 76, 0, 0, 0, 0, 0, 80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 120, 0, 130, 0, 143, 0, 0, 0, 0, 131, 0, 0, 0, 0, 0, 0, 0, 104, 0, 54, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 134, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 78, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 99, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 67, 0, 0, 0, 0, 0, 0, 0, 0); YY_Meta : constant array (0 .. 77) of Integer := ( 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 3, 2, 2, 4, 4, 4, 4, 4, 4, 5, 5, 5, 5, 5, 5, 5, 5, 5, 6, 6, 5, 5, 5, 6, 5, 5, 5, 5, 5, 2, 2, 2, 2, 1, 7, 3, 7, 3, 7, 7, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 2, 2, 1, 1, 1, 1, 2, 2, 2, 3); YY_Base : constant array (0 .. 1286) of Integer := ( 0, 0, 75, 350, 348, 146, 216, 16, 18, 373, 369, 291, 0, 13, 19, 376, 3358, 20, 3358, 3358, 359, 3358, 357, 355, 3358, 273, 248, 337, 3358, 3358, 3358, 3358, 210, 3358, 215, 375, 3358, 3358, 3358, 3358, 192, 177, 3358, 3358, 3358, 3358, 7, 0, 428, 16, 63, 71, 2, 76, 79, 7, 480, 146, 150, 532, 584, 69, 0, 634, 79, 80, 109, 144, 76, 205, 4, 0, 3358, 116, 47, 42, 3358, 3358, 3358, 77, 3358, 48, 3358, 0, 3358, 0, 3358, 3358, 3358, 39, 3358, 3358, 0, 3358, 3358, 0, 3358, 19, 79, 95, 95, 81, 3358, 3358, 3358, 147, 3358, 135, 135, 143, 3358, 140, 208, 145, 219, 165, 164, 207, 154, 151, 158, 610, 194, 210, 427, 221, 222, 3358, 212, 219, 3358, 3358, 412, 3358, 3358, 216, 3358, 3358, 3358, 233, 230, 3358, 3358, 225, 227, 229, 347, 344, 359, 349, 365, 362, 360, 354, 357, 3358, 3358, 3358, 3358, 3358, 3358, 363, 3358, 365, 384, 406, 421, 3358, 3358, 422, 3358, 3358, 433, 440, 439, 427, 440, 437, 437, 455, 478, 465, 473, 3358, 485, 480, 493, 516, 3358, 3358, 3358, 3358, 3358, 3358, 3358, 3358, 0, 3358, 3358, 0, 474, 496, 497, 498, 504, 497, 496, 501, 518, 529, 533, 588, 552, 3358, 3358, 3358, 552, 560, 572, 559, 575, 583, 583, 597, 608, 616, 614, 619, 670, 619, 639, 628, 651, 662, 706, 655, 701, 681, 650, 662, 725, 677, 685, 681, 702, 3358, 700, 711, 706, 710, 710, 721, 720, 722, 710, 3358, 747, 740, 706, 716, 728, 739, 730, 760, 776, 744, 766, 753, 752, 770, 779, 761, 779, 766, 767, 784, 774, 776, 784, 772, 787, 789, 789, 781, 803, 847, 822, 800, 800, 0, 0, 3358, 820, 814, 852, 860, 821, 826, 828, 874, 836, 824, 839, 3358, 3358, 843, 898, 838, 836, 863, 852, 856, 862, 873, 876, 880, 892, 916, 896, 887, 889, 897, 929, 909, 908, 917, 910, 906, 913, 921, 952, 929, 921, 933, 923, 980, 938, 982, 943, 937, 3358, 1002, 954, 953, 965, 959, 974, 973, 1010, 963, 987, 3358, 3358, 988, 986, 1013, 977, 1000, 1000, 1030, 983, 1014, 1001, 1008, 1027, 1010, 1023, 1034, 1034, 1022, 1068, 1038, 1029, 1030, 1033, 1047, 1052, 1048, 1048, 1060, 1052, 1074, 1072, 1078, 1099, 1086, 1067, 1063, 1093, 0, 0, 1088, 1123, 1129, 1104, 1076, 1083, 1121, 1143, 1086, 1154, 1118, 1132, 1171, 1159, 1115, 1124, 1139, 1144, 1136, 1139, 3358, 1173, 1145, 1148, 1171, 1164, 1174, 1170, 1161, 1177, 1182, 1218, 1168, 1212, 1187, 1176, 1188, 1189, 3358, 1185, 1194, 1192, 1208, 1193, 1198, 1214, 1208, 1214, 1211, 1221, 1230, 1249, 1230, 1223, 1236, 1223, 1256, 1226, 1243, 1249, 1248, 1269, 1234, 1233, 1254, 3358, 1265, 1266, 1250, 1270, 1253, 1256, 3358, 1291, 1264, 1264, 1353, 1268, 1269, 1276, 1273, 3358, 1272, 1272, 3358, 1275, 1295, 1299, 1326, 1297, 1288, 1349, 1296, 3358, 1308, 1308, 1311, 1325, 3358, 1324, 1337, 1341, 1327, 1390, 1343, 1335, 1332, 1344, 1362, 3358, 3358, 1367, 0, 3358, 1377, 1420, 1379, 1387, 1380, 1395, 1394, 1392, 1425, 1402, 1410, 1402, 1398, 1433, 1406, 1403, 3358, 1416, 1407, 1417, 1427, 1417, 1420, 1413, 1433, 1416, 1429, 1423, 1438, 1465, 1428, 1433, 1444, 1453, 3358, 3358, 1461, 3358, 1462, 1471, 1475, 1457, 1464, 1467, 1467, 1469, 1503, 1468, 1475, 1490, 1479, 1488, 1476, 1492, 3358, 3358, 3358, 3358, 1482, 14, 1533, 1488, 1499, 1487, 1502, 1506, 1515, 1507, 1509, 1507, 1522, 3358, 1538, 3358, 1526, 1536, 1542, 1535, 1533, 1526, 1529, 1564, 1534, 1549, 1548, 1555, 3358, 1556, 1557, 1553, 1558, 1564, 1557, 1581, 1554, 1562, 3358, 1559, 1563, 3358, 3358, 0, 1562, 1566, 1572, 1576, 1575, 1583, 1615, 1585, 1583, 1590, 1581, 1605, 1631, 1646, 1596, 1610, 1606, 1657, 1610, 1621, 1624, 1643, 1629, 1638, 1638, 1638, 3358, 1657, 1674, 1643, 1678, 1653, 1647, 1672, 1695, 1656, 1676, 1666, 1692, 1687, 1694, 1684, 1695, 1701, 1726, 1687, 1685, 1691, 1703, 1703, 1705, 1703, 1704, 1748, 1766, 1705, 1715, 3358, 1722, 1723, 1730, 1768, 1738, 1747, 1744, 1751, 1786, 1750, 1755, 1774, 1769, 1760, 0, 1774, 1799, 1766, 1773, 1771, 1774, 1818, 1770, 1799, 1805, 1804, 1798, 1846, 1800, 1841, 1807, 1804, 1849, 1820, 1824, 1832, 1837, 1836, 1863, 1830, 1834, 3358, 1850, 1839, 1895, 3358, 1836, 1851, 1836, 1845, 1883, 1848, 1846, 1855, 1862, 1862, 1926, 1868, 1869, 1888, 1886, 1933, 1899, 1889, 1885, 1900, 1914, 1900, 1956, 1902, 1902, 1932, 1903, 1920, 1919, 1935, 1937, 1947, 1945, 1947, 1974, 1944, 1932, 1957, 1983, 1953, 1958, 1969, 1965, 1966, 1980, 1986, 2013, 1976, 1990, 1987, 2015, 1998, 2002, 2027, 2003, 2013, 2014, 2007, 2022, 2013, 3358, 0, 2026, 2055, 2021, 2028, 2018, 2019, 2034, 2039, 2039, 2025, 2032, 2086, 2068, 2030, 2028, 2044, 2053, 2055, 2070, 3358, 2099, 2105, 2057, 2060, 2102, 2101, 2092, 2070, 2089, 2096, 2100, 2134, 2086, 2101, 2101, 2120, 2122, 2122, 2165, 2115, 2169, 2129, 2123, 2106, 2119, 2153, 2142, 2163, 2145, 2159, 2154, 2168, 2166, 2155, 2169, 2155, 2161, 2160, 2196, 2171, 2177, 2182, 2174, 2227, 3358, 2186, 2175, 2183, 2239, 2187, 2189, 2242, 2207, 2217, 2249, 2263, 2226, 2212, 3358, 3358, 2230, 2227, 2238, 2226, 2245, 2234, 2231, 2242, 2279, 2241, 2239, 2254, 2268, 2270, 2261, 3358, 2303, 2264, 2280, 2310, 2278, 2285, 2280, 2293, 2285, 2285, 2292, 3358, 2306, 2324, 2298, 2302, 2334, 2316, 2310, 2318, 2305, 2322, 2355, 2316, 2324, 2311, 2325, 2338, 2365, 2343, 2344, 2345, 2358, 2344, 2348, 2350, 2368, 2354, 2352, 2364, 2376, 2395, 2365, 2380, 2366, 2367, 3358, 2375, 2406, 2377, 2390, 2399, 2390, 2391, 2425, 2396, 2408, 3358, 2408, 2439, 2412, 2422, 2442, 2414, 2429, 2430, 2429, 3358, 2436, 2429, 2507, 2441, 2493, 2429, 2444, 2427, 2447, 2435, 2438, 2497, 2456, 2439, 2455, 2470, 2465, 3358, 2476, 2499, 2479, 2484, 2482, 3358, 2486, 2490, 2491, 2491, 2493, 2513, 2498, 2510, 2504, 2517, 2500, 2517, 2505, 2521, 2528, 2523, 3358, 2554, 3358, 2556, 3358, 2559, 2545, 2561, 2558, 3358, 2546, 2546, 2564, 2549, 2563, 2551, 2560, 3358, 2553, 3358, 2570, 113, 2593, 2576, 2563, 2573, 2571, 2565, 2564, 2630, 2582, 2565, 2587, 2584, 2610, 2604, 2622, 2613, 2622, 2608, 2620, 2617, 2614, 2628, 2613, 2619, 2653, 2621, 2637, 2628, 2683, 2628, 2638, 2629, 2689, 2646, 2638, 2642, 2651, 2662, 2684, 2663, 2704, 2677, 2678, 2674, 2675, 2678, 2677, 2694, 2681, 2678, 2692, 2685, 2690, 2698, 2705, 2689, 2698, 2696, 2711, 2706, 2706, 2718, 2732, 2725, 2744, 2761, 2725, 2745, 2746, 2737, 2744, 2772, 2754, 2745, 2750, 2747, 2754, 2781, 2758, 2760, 2784, 2751, 2768, 2768, 2773, 2761, 2797, 2779, 2779, 2781, 2780, 2797, 2804, 2802, 2808, 2807, 2808, 2811, 2805, 2813, 2804, 2810, 2802, 2810, 2813, 2812, 2814, 2811, 2833, 2815, 2834, 2821, 2836, 2827, 2843, 2837, 2874, 2828, 2852, 2858, 2849, 2866, 2868, 2872, 2856, 2859, 2858, 2858, 2874, 2863, 2905, 2879, 2867, 2872, 2868, 2889, 2888, 2882, 2927, 2882, 2879, 2893, 2898, 2914, 2907, 2903, 2911, 2906, 2926, 2911, 2927, 2922, 2923, 2939, 2938, 2956, 2941, 2944, 2943, 2944, 3358, 2929, 2929, 2978, 2965, 2931, 2956, 2949, 2958, 2959, 2966, 2998, 2969, 2983, 2974, 2986, 2984, 2976, 2983, 2980, 2996, 2980, 2999, 3001, 2994, 2997, 3029, 2992, 3005, 3007, 3358, 2993, 3003, 3001, 3049, 3008, 3024, 3042, 3030, 3028, 3032, 3045, 3034, 3032, 3048, 3036, 3037, 3042, 3043, 3055, 3048, 3358, 3052, 3053, 3062, 3062, 3053, 3063, 3064, 3065, 3066, 3068, 3071, 3065, 3069, 3080, 3073, 3087, 3091, 3094, 3358, 3104, 3105, 3107, 3097, 3109, 3111, 3131, 3100, 3106, 3101, 3117, 3111, 3140, 3109, 3112, 3120, 3145, 3126, 3125, 3120, 3171, 3123, 3138, 3144, 3149, 3150, 3163, 3164, 3150, 3166, 3358, 3195, 3197, 3158, 3159, 3168, 3171, 3166, 3358, 3260, 3267, 3274, 3281, 3287, 3292, 3296, 3300, 3305, 3310, 3315, 3320, 3325, 3330, 3335, 3340, 3345, 3350); YY_Def : constant array (0 .. 1286) of Integer := ( 0, 1269, 1269, 1270, 1270, 2, 2, 1271, 1271, 1272, 1272, 1268, 11, 11, 11, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1273, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1273, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 63, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1274, 1268, 1275, 1268, 1268, 1268, 1268, 1268, 1268, 1276, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1277, 1268, 1268, 1278, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1279, 1280, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1281, 1282, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1283, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 467, 467, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1284, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1285, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1286, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 939, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 0, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268); YY_Nxt : constant array (0 .. 3435) of Integer := ( 0, 1268, 17, 17, 18, 18, 19, 20, 21, 22, 23, 18, 18, 24, 95, 18, 25, 166, 17, 17, 17, 17, 74, 74, 184, 100, 1268, 39, 73, 39, 40, 97, 40, 113, 73, 98, 121, 114, 126, 185, 200, 115, 99, 26, 27, 18, 28, 192, 166, 74, 74, 1268, 1268, 1268, 1268, 184, 100, 193, 1268, 1268, 1268, 1268, 97, 1268, 113, 1268, 98, 121, 114, 126, 185, 200, 115, 99, 29, 30, 18, 17, 17, 18, 18, 19, 20, 21, 22, 23, 18, 18, 24, 45, 18, 25, 41, 116, 41, 45, 118, 122, 164, 124, 177, 186, 119, 117, 178, 179, 165, 187, 120, 125, 180, 201, 181, 198, 202, 203, 204, 123, 26, 27, 18, 28, 195, 194, 116, 1268, 182, 118, 122, 164, 124, 177, 186, 119, 117, 178, 179, 165, 187, 120, 125, 180, 201, 181, 183, 202, 203, 204, 123, 29, 30, 18, 18, 18, 18, 18, 18, 182, 33, 18, 1268, 191, 18, 135, 205, 136, 206, 137, 184, 140, 141, 207, 208, 209, 210, 183, 138, 139, 142, 185, 216, 143, 220, 222, 225, 226, 227, 144, 221, 34, 35, 36, 37, 96, 135, 205, 136, 206, 137, 184, 140, 141, 207, 208, 209, 210, 95, 138, 139, 142, 185, 216, 143, 220, 222, 225, 226, 227, 144, 221, 18, 18, 18, 18, 18, 18, 18, 211, 33, 18, 79, 94, 18, 188, 234, 212, 213, 189, 217, 223, 190, 218, 235, 224, 214, 215, 241, 242, 243, 244, 248, 219, 249, 250, 251, 252, 253, 254, 211, 34, 35, 36, 37, 79, 188, 234, 212, 213, 189, 217, 223, 190, 218, 235, 224, 214, 215, 241, 242, 243, 244, 248, 219, 249, 250, 251, 252, 253, 254, 78, 18, 18, 44, 17, 17, 45, 45, 45, 45, 45, 45, 45, 45, 45, 45, 44, 45, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 44, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 44, 69, 45, 45, 45, 45, 44, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 44, 56, 57, 58, 59, 60, 61, 62, 70, 64, 65, 66, 71, 68, 44, 69, 45, 45, 72, 44, 81, 82, 77, 255, 76, 83, 75, 1268, 43, 256, 257, 258, 43, 259, 260, 261, 84, 262, 85, 265, 86, 87, 263, 32, 264, 32, 266, 1268, 1268, 88, 1268, 89, 267, 90, 255, 91, 92, 93, 81, 1268, 256, 257, 258, 83, 259, 260, 261, 1268, 262, 1268, 265, 1268, 1268, 263, 84, 264, 85, 266, 86, 87, 236, 236, 1268, 267, 245, 1268, 246, 88, 268, 89, 237, 90, 269, 91, 92, 93, 101, 238, 102, 239, 103, 104, 247, 105, 106, 270, 271, 107, 272, 108, 109, 273, 274, 240, 110, 245, 111, 246, 112, 268, 275, 1268, 276, 269, 277, 237, 278, 101, 238, 102, 239, 103, 104, 247, 105, 106, 270, 271, 107, 272, 108, 109, 273, 274, 240, 110, 279, 111, 281, 112, 127, 275, 128, 276, 280, 277, 129, 278, 282, 130, 131, 283, 132, 284, 285, 291, 1268, 133, 134, 286, 286, 292, 1268, 293, 294, 1268, 295, 279, 296, 281, 1268, 127, 297, 128, 1268, 280, 298, 129, 1268, 282, 130, 131, 283, 132, 284, 285, 291, 287, 133, 134, 145, 299, 292, 146, 293, 294, 147, 295, 148, 296, 300, 149, 150, 297, 288, 151, 301, 298, 302, 152, 153, 1268, 305, 1268, 1268, 1268, 1268, 306, 287, 1268, 1268, 145, 299, 1268, 146, 1268, 307, 147, 1268, 148, 308, 300, 149, 150, 309, 310, 151, 301, 1268, 302, 152, 153, 154, 305, 155, 156, 157, 158, 306, 311, 159, 303, 312, 228, 228, 313, 160, 307, 304, 161, 162, 308, 163, 1268, 1268, 309, 310, 1268, 229, 230, 314, 1268, 231, 154, 315, 155, 156, 157, 158, 232, 311, 159, 303, 312, 316, 1268, 313, 160, 317, 304, 161, 162, 318, 163, 167, 168, 169, 319, 233, 229, 230, 314, 170, 231, 171, 315, 172, 173, 1268, 320, 232, 174, 175, 228, 228, 316, 176, 321, 1268, 317, 325, 230, 328, 318, 231, 167, 168, 169, 319, 230, 1268, 232, 231, 170, 329, 171, 1268, 172, 173, 232, 320, 326, 174, 175, 236, 236, 1268, 176, 321, 322, 322, 325, 230, 328, 334, 231, 335, 327, 336, 323, 230, 326, 232, 231, 337, 329, 338, 324, 330, 330, 232, 1268, 326, 339, 340, 341, 342, 327, 331, 343, 344, 346, 1268, 347, 332, 334, 353, 335, 327, 336, 348, 348, 326, 354, 323, 337, 345, 338, 324, 355, 351, 356, 333, 357, 339, 340, 341, 342, 327, 349, 343, 344, 346, 331, 347, 332, 352, 353, 358, 359, 359, 1268, 1268, 364, 354, 1268, 365, 345, 366, 367, 355, 351, 356, 333, 357, 350, 368, 369, 370, 371, 349, 372, 373, 374, 375, 376, 377, 352, 378, 358, 379, 380, 360, 361, 364, 381, 362, 365, 382, 366, 367, 383, 1268, 388, 363, 286, 286, 368, 369, 370, 371, 287, 372, 373, 374, 375, 376, 377, 391, 378, 392, 379, 380, 360, 361, 402, 381, 362, 403, 382, 384, 384, 383, 287, 388, 393, 393, 102, 408, 409, 385, 410, 287, 398, 398, 394, 411, 386, 415, 391, 1268, 392, 395, 399, 416, 1268, 402, 404, 404, 403, 1268, 400, 396, 387, 287, 417, 401, 418, 102, 408, 409, 1268, 410, 141, 419, 385, 405, 411, 386, 415, 397, 412, 412, 395, 420, 416, 406, 421, 399, 422, 423, 413, 400, 396, 387, 1268, 417, 401, 418, 424, 424, 427, 407, 428, 141, 419, 429, 405, 430, 425, 324, 414, 322, 322, 431, 420, 426, 406, 421, 432, 422, 423, 328, 433, 434, 435, 413, 438, 436, 441, 324, 439, 427, 1268, 428, 330, 330, 429, 1268, 430, 446, 324, 414, 450, 425, 431, 437, 426, 440, 1268, 432, 436, 451, 328, 433, 434, 435, 455, 438, 436, 441, 324, 439, 442, 442, 447, 447, 1268, 456, 437, 457, 446, 458, 443, 450, 448, 459, 437, 460, 440, 444, 1268, 436, 451, 461, 452, 452, 1268, 455, 349, 462, 463, 467, 348, 348, 453, 464, 464, 449, 456, 437, 457, 468, 458, 469, 470, 465, 459, 445, 460, 448, 444, 349, 359, 359, 461, 471, 472, 454, 1268, 349, 462, 463, 467, 360, 473, 466, 474, 362, 449, 453, 475, 476, 468, 477, 469, 470, 478, 1268, 484, 482, 465, 485, 349, 483, 486, 360, 471, 472, 454, 362, 479, 479, 487, 488, 360, 473, 466, 474, 362, 489, 480, 475, 476, 490, 477, 491, 492, 478, 481, 484, 482, 493, 485, 494, 483, 486, 360, 495, 498, 499, 362, 384, 384, 487, 488, 496, 505, 511, 512, 1268, 489, 401, 500, 501, 490, 480, 491, 492, 496, 481, 502, 497, 493, 509, 494, 506, 506, 1268, 495, 498, 499, 393, 393, 510, 497, 507, 496, 505, 511, 512, 395, 516, 401, 500, 501, 398, 398, 508, 395, 496, 396, 502, 497, 517, 509, 521, 513, 513, 396, 522, 405, 404, 404, 523, 510, 497, 514, 524, 401, 525, 507, 395, 516, 518, 518, 412, 412, 414, 508, 395, 405, 396, 515, 519, 517, 526, 521, 1268, 527, 396, 522, 405, 528, 529, 523, 530, 531, 532, 524, 401, 525, 514, 533, 520, 104, 414, 426, 537, 414, 538, 539, 405, 540, 515, 424, 424, 526, 541, 519, 527, 534, 534, 542, 528, 529, 439, 530, 531, 532, 543, 535, 426, 544, 533, 520, 104, 414, 426, 537, 438, 538, 539, 440, 540, 545, 546, 547, 548, 541, 549, 536, 442, 442, 542, 550, 444, 439, 551, 447, 447, 543, 449, 426, 544, 552, 535, 553, 554, 444, 454, 438, 452, 452, 440, 555, 545, 546, 547, 548, 556, 549, 536, 557, 558, 559, 550, 444, 560, 551, 561, 562, 449, 449, 464, 464, 552, 466, 553, 554, 444, 454, 563, 576, 577, 454, 555, 578, 579, 580, 581, 556, 582, 583, 557, 558, 559, 584, 481, 560, 585, 561, 562, 449, 466, 1268, 1268, 589, 466, 479, 479, 1268, 590, 563, 576, 577, 454, 591, 578, 579, 580, 581, 592, 582, 583, 593, 1268, 481, 584, 481, 594, 585, 586, 586, 1268, 466, 564, 564, 589, 595, 1268, 596, 587, 590, 597, 601, 565, 498, 591, 499, 1268, 566, 1268, 592, 567, 602, 593, 568, 481, 569, 603, 594, 570, 571, 572, 588, 573, 604, 605, 574, 595, 575, 596, 598, 598, 597, 601, 587, 498, 607, 499, 565, 566, 599, 508, 567, 602, 1268, 568, 608, 569, 603, 511, 570, 571, 572, 588, 573, 604, 605, 574, 512, 575, 506, 506, 609, 600, 610, 513, 513, 607, 515, 611, 612, 613, 508, 518, 518, 599, 520, 608, 614, 615, 511, 616, 508, 102, 617, 618, 619, 620, 621, 512, 622, 515, 623, 609, 600, 610, 624, 625, 536, 515, 611, 612, 613, 520, 1268, 534, 534, 520, 626, 614, 615, 627, 616, 508, 102, 617, 618, 619, 620, 621, 628, 622, 515, 623, 629, 630, 631, 624, 625, 536, 632, 633, 634, 635, 520, 536, 550, 636, 640, 626, 1268, 641, 627, 637, 637, 642, 643, 644, 645, 646, 647, 628, 1268, 638, 648, 629, 630, 631, 649, 650, 651, 632, 633, 634, 635, 652, 536, 550, 636, 640, 654, 639, 641, 1268, 1268, 653, 642, 643, 644, 645, 646, 647, 655, 1268, 656, 648, 657, 1268, 638, 649, 650, 651, 658, 659, 660, 661, 652, 662, 663, 664, 665, 654, 639, 666, 586, 586, 653, 588, 667, 668, 669, 670, 671, 655, 672, 656, 673, 657, 1268, 674, 675, 598, 598, 658, 659, 660, 661, 600, 662, 663, 664, 665, 676, 677, 666, 678, 680, 588, 588, 667, 668, 669, 670, 671, 681, 672, 682, 673, 683, 684, 674, 675, 685, 689, 600, 686, 686, 690, 600, 691, 692, 1268, 693, 676, 677, 687, 678, 680, 588, 1268, 700, 694, 694, 701, 702, 681, 1268, 682, 1268, 683, 684, 695, 706, 685, 689, 600, 697, 697, 690, 707, 691, 692, 688, 693, 708, 1268, 698, 703, 703, 696, 687, 700, 709, 710, 701, 702, 711, 704, 712, 699, 713, 1268, 714, 706, 715, 715, 695, 718, 637, 637, 707, 639, 719, 688, 716, 708, 705, 720, 1268, 724, 696, 698, 725, 709, 710, 721, 721, 711, 726, 712, 699, 713, 704, 714, 717, 722, 639, 727, 718, 1268, 728, 729, 639, 719, 730, 731, 732, 705, 720, 716, 724, 737, 738, 725, 723, 739, 733, 733, 1268, 726, 740, 741, 742, 743, 744, 717, 1268, 639, 727, 752, 722, 728, 729, 734, 753, 730, 731, 732, 745, 745, 1268, 754, 737, 738, 1268, 723, 739, 755, 746, 735, 756, 740, 741, 742, 743, 744, 749, 749, 757, 757, 752, 736, 760, 761, 734, 753, 750, 762, 758, 763, 1268, 747, 754, 767, 768, 748, 764, 764, 755, 769, 735, 756, 770, 746, 771, 759, 765, 773, 777, 774, 774, 751, 778, 760, 761, 779, 780, 688, 762, 766, 763, 750, 747, 758, 767, 768, 748, 775, 686, 686, 769, 781, 782, 770, 1268, 771, 759, 783, 773, 777, 784, 765, 751, 778, 788, 696, 779, 780, 688, 789, 766, 694, 694, 699, 776, 790, 785, 785, 775, 697, 697, 791, 781, 782, 792, 688, 786, 793, 783, 705, 1268, 784, 794, 703, 703, 788, 696, 795, 796, 696, 789, 802, 699, 803, 699, 804, 790, 805, 717, 787, 1268, 806, 791, 715, 715, 792, 688, 807, 793, 808, 705, 786, 705, 794, 809, 797, 797, 723, 795, 796, 696, 810, 802, 699, 803, 798, 804, 811, 805, 717, 787, 799, 806, 717, 800, 812, 817, 818, 807, 819, 808, 801, 820, 705, 1268, 809, 721, 721, 723, 821, 822, 823, 810, 813, 813, 1268, 824, 825, 811, 826, 798, 463, 799, 814, 717, 800, 812, 817, 818, 734, 819, 827, 801, 820, 828, 723, 733, 733, 1268, 815, 821, 822, 823, 829, 830, 735, 816, 824, 825, 831, 826, 832, 463, 734, 745, 745, 1268, 747, 814, 833, 734, 748, 827, 749, 749, 828, 723, 1268, 751, 735, 815, 834, 835, 836, 829, 830, 735, 816, 837, 838, 831, 839, 832, 759, 734, 840, 110, 747, 747, 1268, 833, 748, 748, 757, 757, 841, 841, 844, 751, 751, 735, 845, 834, 835, 836, 842, 766, 764, 764, 837, 838, 846, 839, 847, 759, 848, 840, 110, 747, 849, 759, 850, 748, 852, 853, 843, 775, 854, 844, 751, 766, 855, 845, 856, 857, 774, 774, 766, 858, 859, 842, 860, 846, 787, 847, 1268, 848, 864, 785, 785, 849, 759, 850, 775, 852, 853, 843, 775, 854, 865, 866, 766, 855, 867, 856, 857, 861, 861, 868, 858, 859, 875, 860, 876, 787, 1268, 862, 1268, 864, 869, 869, 787, 797, 797, 775, 872, 872, 877, 878, 870, 865, 866, 879, 1268, 867, 880, 863, 799, 799, 868, 800, 800, 875, 881, 876, 885, 871, 801, 801, 886, 887, 862, 787, 873, 882, 882, 888, 889, 877, 878, 890, 171, 894, 879, 870, 895, 880, 863, 799, 799, 874, 800, 800, 896, 881, 815, 885, 871, 801, 801, 886, 887, 816, 883, 873, 891, 891, 888, 889, 813, 813, 890, 171, 894, 897, 892, 895, 898, 899, 884, 900, 901, 902, 903, 896, 904, 815, 905, 906, 907, 908, 893, 909, 816, 883, 815, 910, 910, 1268, 913, 914, 915, 816, 916, 168, 897, 911, 920, 898, 899, 892, 900, 901, 902, 903, 921, 904, 843, 905, 906, 907, 908, 893, 909, 922, 926, 815, 917, 917, 912, 913, 914, 915, 816, 916, 168, 927, 918, 920, 841, 841, 911, 923, 923, 1268, 601, 921, 934, 843, 928, 928, 935, 924, 936, 919, 922, 926, 937, 127, 929, 912, 938, 939, 931, 931, 1268, 940, 927, 925, 843, 941, 863, 918, 932, 942, 930, 601, 1268, 934, 861, 861, 943, 935, 944, 936, 919, 945, 924, 937, 127, 946, 871, 938, 939, 929, 947, 933, 940, 948, 925, 843, 941, 863, 869, 869, 942, 930, 1268, 932, 863, 872, 872, 943, 873, 944, 949, 950, 945, 951, 952, 953, 946, 871, 954, 882, 882, 947, 933, 955, 948, 871, 883, 1268, 959, 956, 956, 960, 961, 873, 962, 863, 963, 893, 964, 873, 965, 949, 950, 1268, 951, 952, 953, 966, 883, 954, 891, 891, 967, 971, 955, 972, 871, 883, 957, 959, 968, 968, 960, 961, 873, 962, 973, 963, 893, 964, 969, 965, 974, 975, 958, 976, 893, 977, 966, 883, 978, 979, 980, 967, 971, 981, 972, 970, 982, 957, 910, 910, 1268, 912, 983, 984, 985, 973, 986, 919, 987, 917, 917, 974, 975, 969, 976, 893, 977, 988, 136, 978, 979, 980, 989, 1268, 981, 925, 970, 982, 923, 923, 990, 912, 912, 983, 984, 985, 919, 986, 919, 987, 991, 930, 928, 928, 992, 931, 931, 1268, 988, 136, 933, 993, 994, 989, 925, 995, 925, 996, 997, 1005, 1009, 990, 912, 1010, 1011, 1268, 1268, 919, 930, 1012, 1013, 991, 930, 1014, 1016, 992, 1017, 539, 933, 1268, 1268, 933, 993, 994, 1268, 925, 995, 1268, 996, 997, 1005, 1009, 1018, 540, 1010, 1011, 1006, 1006, 1019, 930, 1012, 1013, 956, 956, 1014, 1016, 1007, 1017, 539, 933, 998, 998, 1020, 968, 968, 1008, 957, 500, 501, 1021, 999, 142, 1022, 1018, 540, 1015, 1023, 1000, 1024, 1019, 1025, 957, 1026, 1027, 970, 1028, 1001, 1029, 1002, 1030, 970, 1007, 1031, 1020, 1003, 1004, 1008, 957, 500, 501, 1021, 1032, 142, 1022, 1033, 999, 1015, 1023, 1000, 1024, 352, 1025, 957, 1026, 1027, 970, 1028, 1001, 1029, 1002, 1030, 970, 1034, 1031, 1035, 1003, 1004, 1036, 1037, 1038, 1039, 1040, 1032, 1041, 1042, 1033, 1043, 1044, 1045, 1046, 291, 352, 106, 1268, 1047, 1048, 1049, 1050, 1051, 1268, 1268, 1052, 1268, 1034, 1008, 1035, 1053, 1054, 1036, 1037, 1038, 1039, 1040, 1000, 1041, 1042, 1055, 1043, 1044, 1045, 1046, 291, 1001, 106, 1002, 1047, 1048, 1049, 1050, 1051, 1003, 1004, 1052, 1006, 1006, 1008, 1056, 1053, 1054, 141, 1057, 137, 604, 605, 1000, 1058, 1059, 1055, 1060, 1061, 1062, 1063, 1008, 1001, 188, 1002, 1064, 1064, 1067, 1068, 1069, 1003, 1004, 1073, 1074, 1268, 1075, 1056, 1079, 1080, 141, 1057, 137, 604, 605, 1065, 1058, 1059, 1081, 1060, 1061, 1062, 1063, 1008, 1268, 188, 1070, 1070, 1082, 1067, 1068, 1069, 1076, 1076, 1073, 1074, 1071, 1075, 1083, 1079, 1080, 1066, 1084, 1072, 578, 475, 1065, 1085, 1085, 1081, 1088, 1089, 1090, 1091, 1092, 1077, 1093, 1094, 1095, 1082, 1096, 1268, 1097, 1098, 1099, 1100, 1101, 167, 1102, 1083, 1103, 1071, 1104, 1084, 1072, 578, 475, 1078, 1105, 429, 1086, 1088, 1089, 1090, 1091, 1092, 1077, 1093, 1094, 1095, 1106, 1096, 1087, 1097, 1098, 1099, 1100, 1101, 167, 1102, 1107, 1103, 1108, 1104, 1064, 1064, 1109, 1065, 1110, 1105, 429, 1086, 131, 170, 1072, 1070, 1070, 1111, 138, 1112, 1113, 1106, 1114, 1065, 1076, 1076, 1077, 1115, 1115, 1118, 562, 1107, 1072, 1108, 1119, 576, 1120, 1109, 1065, 1110, 1085, 1085, 1268, 131, 170, 1072, 1116, 1077, 1111, 138, 1112, 1113, 1121, 1114, 1065, 1086, 190, 1077, 1122, 1123, 1118, 562, 1124, 1072, 1125, 1119, 576, 1120, 1126, 1127, 1128, 1129, 1117, 1086, 1130, 1131, 1132, 1116, 1077, 1133, 1134, 156, 1135, 1121, 1136, 1137, 1086, 190, 1138, 1122, 1123, 1139, 1140, 1124, 1141, 1125, 130, 1142, 162, 1126, 1127, 1128, 1129, 560, 1086, 1130, 1131, 1132, 1143, 1144, 1133, 1134, 156, 1135, 1116, 1136, 1137, 1115, 1115, 1138, 351, 1145, 1139, 1140, 1146, 1141, 1147, 130, 1142, 162, 1148, 133, 1149, 134, 560, 1150, 1116, 1151, 1153, 1143, 1144, 1157, 1158, 1159, 1152, 1116, 1160, 1161, 1154, 1154, 1162, 351, 1145, 158, 1166, 1146, 1167, 1147, 1155, 1168, 1169, 1148, 133, 1149, 134, 1156, 1150, 1116, 1151, 1153, 1163, 1163, 1157, 1158, 1159, 1152, 1170, 1160, 1161, 1171, 1172, 1162, 160, 1173, 158, 1166, 1174, 1167, 1175, 1164, 1168, 1169, 489, 1155, 1176, 1177, 1156, 1178, 1179, 1154, 1154, 1156, 1180, 1181, 1182, 1183, 1184, 1170, 1163, 1163, 1171, 1172, 1188, 160, 1173, 1165, 1156, 1174, 1164, 1175, 1164, 1185, 1185, 489, 1189, 1176, 1177, 1164, 1178, 1179, 1190, 1191, 1156, 1180, 1181, 1182, 1183, 1184, 1186, 1192, 1268, 1193, 1193, 1188, 1196, 1197, 1198, 1156, 472, 1164, 1199, 183, 1200, 1201, 1202, 1189, 1203, 1204, 1164, 1205, 1206, 1190, 1191, 1207, 1208, 1186, 1187, 1209, 1210, 1186, 1192, 1194, 1185, 1185, 159, 1196, 1197, 1198, 1211, 472, 1212, 1199, 183, 1200, 1201, 1202, 1195, 1203, 1204, 1186, 1205, 1206, 1193, 1193, 1207, 1208, 1186, 1194, 1209, 1210, 1213, 1214, 1194, 189, 1215, 159, 1216, 1217, 1218, 1211, 1219, 1212, 1220, 1221, 1222, 1223, 1224, 1225, 1226, 1227, 1186, 1228, 1194, 561, 1229, 1230, 1231, 1232, 1194, 1233, 1234, 1213, 1214, 1235, 189, 1215, 103, 1216, 1217, 1218, 155, 1219, 1236, 1220, 1221, 1222, 1223, 1224, 1225, 1226, 1227, 1237, 1228, 1194, 561, 1229, 1230, 1231, 1232, 1238, 1233, 1234, 1239, 1240, 1235, 303, 304, 103, 213, 1241, 214, 155, 215, 1236, 1242, 1242, 1245, 245, 456, 1246, 1247, 1248, 1237, 1242, 1242, 1243, 1249, 1253, 1250, 1250, 1238, 1254, 1255, 1239, 1240, 1256, 303, 304, 1251, 213, 1241, 214, 1268, 215, 1243, 1251, 1257, 1245, 245, 456, 1246, 1247, 1248, 1243, 1250, 1250, 1243, 1249, 1253, 1244, 1258, 521, 1254, 1255, 1259, 411, 1256, 1260, 1261, 1251, 1265, 1251, 1263, 1252, 1266, 1243, 1251, 1257, 1262, 1262, 1262, 1262, 1267, 255, 1243, 1268, 1268, 1268, 1268, 1268, 1268, 1258, 521, 1268, 1268, 1259, 411, 1268, 1260, 1261, 1268, 1265, 1251, 1263, 1268, 1266, 1268, 1268, 1263, 1268, 1263, 1268, 1268, 1267, 255, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1264, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1263, 1268, 1263, 16, 16, 16, 16, 16, 16, 16, 31, 31, 31, 31, 31, 31, 31, 38, 38, 38, 38, 38, 38, 38, 42, 42, 42, 42, 42, 42, 42, 80, 1268, 1268, 1268, 80, 80, 196, 196, 1268, 1268, 196, 197, 197, 197, 199, 199, 1268, 1268, 199, 289, 289, 1268, 1268, 289, 290, 290, 1268, 1268, 290, 389, 389, 1268, 1268, 389, 390, 390, 1268, 1268, 390, 503, 503, 1268, 1268, 503, 504, 504, 1268, 1268, 504, 606, 606, 1268, 1268, 606, 679, 679, 1268, 1268, 679, 772, 772, 1268, 1268, 772, 851, 851, 1268, 1268, 851, 15, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268); YY_Chk : constant array (0 .. 3435) of Integer := ( 0, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 95, 1, 1, 62, 7, 7, 8, 8, 17, 17, 71, 47, 564, 7, 13, 8, 7, 46, 8, 49, 14, 46, 52, 49, 55, 70, 97, 49, 46, 1, 1, 1, 1, 75, 62, 74, 74, 0, 0, 0, 0, 71, 47, 75, 0, 0, 0, 564, 46, 0, 49, 0, 46, 52, 49, 55, 70, 97, 49, 46, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 13, 2, 2, 7, 50, 8, 14, 51, 53, 61, 54, 64, 68, 51, 50, 64, 65, 61, 68, 51, 54, 65, 98, 65, 89, 99, 100, 101, 53, 2, 2, 2, 2, 81, 79, 50, 998, 66, 51, 53, 61, 54, 64, 68, 51, 50, 64, 65, 61, 68, 51, 54, 65, 98, 65, 66, 99, 100, 101, 53, 2, 2, 2, 5, 5, 5, 5, 5, 66, 5, 5, 998, 73, 5, 57, 105, 57, 107, 57, 67, 58, 58, 108, 109, 109, 111, 66, 57, 57, 58, 67, 113, 58, 115, 116, 118, 119, 120, 58, 115, 5, 5, 5, 5, 41, 57, 105, 57, 107, 57, 67, 58, 58, 108, 109, 109, 111, 40, 57, 57, 58, 67, 113, 58, 115, 116, 118, 119, 120, 58, 115, 5, 5, 6, 6, 6, 6, 6, 112, 6, 6, 34, 32, 6, 69, 122, 112, 112, 69, 114, 117, 69, 114, 123, 117, 112, 112, 125, 126, 128, 129, 135, 114, 135, 139, 140, 143, 144, 145, 112, 6, 6, 6, 6, 26, 69, 122, 112, 112, 69, 114, 117, 69, 114, 123, 117, 112, 112, 125, 126, 128, 129, 135, 114, 135, 139, 140, 143, 144, 145, 25, 6, 6, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 27, 27, 23, 146, 22, 27, 20, 15, 10, 147, 148, 149, 9, 150, 151, 152, 27, 153, 27, 161, 27, 27, 154, 4, 154, 3, 163, 0, 0, 27, 0, 27, 164, 27, 146, 27, 27, 27, 35, 35, 147, 148, 149, 35, 150, 151, 152, 0, 153, 0, 161, 0, 0, 154, 35, 154, 35, 163, 35, 35, 124, 124, 0, 164, 132, 0, 132, 35, 165, 35, 124, 35, 166, 35, 35, 35, 48, 124, 48, 124, 48, 48, 132, 48, 48, 169, 172, 48, 173, 48, 48, 174, 175, 124, 48, 132, 48, 132, 48, 165, 176, 0, 177, 166, 178, 124, 179, 48, 124, 48, 124, 48, 48, 132, 48, 48, 169, 172, 48, 173, 48, 48, 174, 175, 124, 48, 180, 48, 181, 48, 56, 176, 56, 177, 180, 178, 56, 179, 182, 56, 56, 184, 56, 185, 186, 200, 0, 56, 56, 187, 187, 201, 0, 202, 203, 0, 204, 180, 205, 181, 0, 56, 206, 56, 0, 180, 207, 56, 0, 182, 56, 56, 184, 56, 185, 186, 200, 187, 56, 56, 59, 208, 201, 59, 202, 203, 59, 204, 59, 205, 209, 59, 59, 206, 187, 59, 209, 207, 210, 59, 59, 0, 212, 0, 0, 0, 0, 216, 187, 0, 0, 59, 208, 0, 59, 0, 217, 59, 0, 59, 218, 209, 59, 59, 219, 220, 59, 209, 0, 210, 59, 59, 60, 212, 60, 60, 60, 60, 216, 221, 60, 211, 222, 121, 121, 223, 60, 217, 211, 60, 60, 218, 60, 0, 0, 219, 220, 0, 121, 121, 224, 0, 121, 60, 225, 60, 60, 60, 60, 121, 221, 60, 211, 222, 226, 0, 223, 60, 227, 211, 60, 60, 229, 60, 63, 63, 63, 230, 121, 121, 121, 224, 63, 121, 63, 225, 63, 63, 0, 231, 121, 63, 63, 228, 228, 226, 63, 232, 0, 227, 235, 233, 238, 229, 233, 63, 63, 63, 230, 228, 0, 233, 228, 63, 239, 63, 0, 63, 63, 228, 231, 237, 63, 63, 236, 236, 0, 63, 232, 234, 234, 235, 233, 238, 241, 233, 242, 237, 243, 234, 228, 236, 233, 228, 244, 239, 246, 234, 240, 240, 228, 0, 237, 247, 248, 249, 250, 236, 240, 251, 252, 253, 0, 254, 240, 241, 258, 242, 237, 243, 256, 256, 236, 259, 234, 244, 252, 246, 234, 260, 257, 261, 240, 262, 247, 248, 249, 250, 236, 256, 251, 252, 253, 240, 254, 240, 257, 258, 263, 264, 264, 0, 0, 265, 259, 0, 266, 252, 267, 268, 260, 257, 261, 240, 262, 256, 269, 270, 271, 272, 256, 273, 274, 275, 276, 277, 278, 257, 279, 263, 280, 281, 264, 264, 265, 282, 264, 266, 283, 267, 268, 284, 0, 287, 264, 286, 286, 269, 270, 271, 272, 288, 273, 274, 275, 276, 277, 278, 292, 279, 293, 280, 281, 264, 264, 296, 282, 264, 297, 283, 285, 285, 284, 286, 287, 294, 294, 298, 300, 301, 285, 302, 288, 295, 295, 294, 305, 285, 307, 292, 0, 293, 294, 295, 308, 0, 296, 299, 299, 297, 0, 295, 294, 285, 286, 309, 295, 310, 298, 300, 301, 0, 302, 311, 312, 285, 299, 305, 285, 307, 294, 306, 306, 294, 313, 308, 299, 314, 295, 315, 316, 306, 295, 294, 285, 0, 309, 295, 310, 317, 317, 318, 299, 319, 311, 312, 320, 299, 321, 317, 323, 306, 322, 322, 324, 313, 317, 299, 314, 325, 315, 316, 326, 327, 328, 329, 306, 332, 331, 334, 322, 333, 318, 0, 319, 330, 330, 320, 0, 321, 336, 323, 306, 338, 317, 324, 331, 317, 333, 0, 325, 330, 339, 326, 327, 328, 329, 342, 332, 331, 334, 322, 333, 335, 335, 337, 337, 0, 343, 330, 344, 336, 345, 335, 338, 337, 346, 331, 347, 333, 335, 0, 330, 339, 349, 341, 341, 0, 342, 350, 353, 354, 356, 348, 348, 341, 355, 355, 337, 343, 330, 344, 357, 345, 358, 360, 355, 346, 335, 347, 337, 335, 348, 359, 359, 349, 361, 362, 341, 0, 350, 353, 354, 356, 363, 364, 355, 365, 363, 337, 341, 366, 367, 357, 368, 358, 360, 369, 0, 372, 371, 355, 373, 348, 371, 374, 359, 361, 362, 341, 359, 370, 370, 375, 376, 363, 364, 355, 365, 363, 377, 370, 366, 367, 378, 368, 379, 380, 369, 370, 372, 371, 381, 373, 382, 371, 374, 359, 383, 386, 387, 359, 384, 384, 375, 376, 385, 391, 395, 396, 0, 377, 399, 388, 388, 378, 370, 379, 380, 384, 370, 388, 385, 381, 394, 382, 392, 392, 0, 383, 386, 387, 393, 393, 394, 384, 392, 385, 391, 395, 396, 397, 401, 399, 388, 388, 398, 398, 392, 393, 384, 397, 388, 385, 402, 394, 405, 400, 400, 393, 406, 407, 404, 404, 408, 394, 384, 400, 409, 398, 410, 392, 397, 401, 403, 403, 412, 412, 413, 392, 393, 404, 397, 400, 403, 402, 414, 405, 0, 415, 393, 406, 407, 416, 417, 408, 418, 419, 420, 409, 398, 410, 400, 421, 403, 423, 412, 425, 426, 413, 427, 428, 404, 430, 400, 424, 424, 414, 431, 403, 415, 422, 422, 432, 416, 417, 433, 418, 419, 420, 434, 422, 424, 435, 421, 403, 423, 412, 425, 426, 436, 427, 428, 437, 430, 438, 439, 440, 441, 431, 443, 422, 442, 442, 432, 444, 445, 433, 446, 447, 447, 434, 448, 424, 435, 449, 422, 450, 451, 442, 453, 436, 452, 452, 437, 454, 438, 439, 440, 441, 455, 443, 422, 457, 458, 459, 444, 445, 460, 446, 461, 462, 447, 448, 464, 464, 449, 465, 450, 451, 442, 453, 466, 468, 469, 452, 454, 470, 471, 473, 474, 455, 476, 477, 457, 458, 459, 478, 480, 460, 481, 461, 462, 447, 464, 0, 0, 483, 465, 479, 479, 0, 485, 466, 468, 469, 452, 486, 470, 471, 473, 474, 487, 476, 477, 488, 0, 479, 478, 480, 490, 481, 482, 482, 0, 464, 467, 467, 483, 491, 0, 492, 482, 485, 493, 495, 467, 496, 486, 497, 0, 467, 0, 487, 467, 498, 488, 467, 479, 467, 499, 490, 467, 467, 467, 482, 467, 502, 502, 467, 491, 467, 492, 494, 494, 493, 495, 482, 496, 505, 497, 467, 467, 494, 507, 467, 498, 0, 467, 508, 467, 499, 509, 467, 467, 467, 482, 467, 502, 502, 467, 510, 467, 506, 506, 511, 494, 512, 513, 513, 505, 514, 515, 516, 517, 507, 518, 518, 494, 519, 508, 520, 522, 509, 523, 506, 524, 525, 526, 527, 528, 529, 510, 530, 513, 531, 511, 494, 512, 532, 533, 535, 514, 515, 516, 517, 518, 0, 534, 534, 519, 536, 520, 522, 537, 523, 506, 524, 525, 526, 527, 528, 529, 538, 530, 513, 531, 541, 543, 544, 532, 533, 535, 545, 546, 547, 548, 518, 534, 549, 550, 552, 536, 0, 553, 537, 551, 551, 554, 555, 556, 557, 558, 563, 538, 0, 551, 566, 541, 543, 544, 567, 568, 569, 545, 546, 547, 548, 570, 534, 549, 550, 552, 571, 551, 553, 565, 565, 570, 554, 555, 556, 557, 558, 563, 572, 565, 573, 566, 574, 0, 551, 567, 568, 569, 575, 577, 579, 580, 570, 581, 582, 583, 584, 571, 551, 585, 586, 586, 570, 587, 588, 589, 590, 592, 593, 572, 594, 573, 595, 574, 565, 596, 597, 598, 598, 575, 577, 579, 580, 599, 581, 582, 583, 584, 600, 602, 585, 603, 607, 586, 587, 588, 589, 590, 592, 593, 608, 594, 609, 595, 610, 611, 596, 597, 612, 614, 598, 613, 613, 615, 599, 616, 617, 0, 618, 600, 602, 613, 603, 607, 586, 0, 621, 619, 619, 622, 623, 608, 0, 609, 0, 610, 611, 619, 625, 612, 614, 598, 620, 620, 615, 626, 616, 617, 613, 618, 627, 0, 620, 624, 624, 619, 613, 621, 628, 629, 622, 623, 630, 624, 631, 620, 632, 0, 634, 625, 635, 635, 619, 636, 637, 637, 626, 638, 639, 613, 635, 627, 624, 640, 0, 642, 619, 620, 643, 628, 629, 641, 641, 630, 644, 631, 620, 632, 624, 634, 635, 641, 637, 645, 636, 0, 646, 647, 638, 639, 648, 649, 650, 624, 640, 635, 642, 652, 653, 643, 641, 654, 651, 651, 0, 644, 655, 656, 657, 658, 659, 635, 0, 637, 645, 662, 641, 646, 647, 651, 663, 648, 649, 650, 660, 660, 0, 665, 652, 653, 0, 641, 654, 666, 660, 651, 667, 655, 656, 657, 658, 659, 661, 661, 668, 668, 662, 651, 669, 670, 651, 663, 661, 671, 668, 672, 0, 660, 665, 674, 675, 660, 673, 673, 666, 676, 651, 667, 677, 660, 678, 668, 673, 680, 682, 681, 681, 661, 683, 669, 670, 684, 685, 687, 671, 673, 672, 661, 660, 668, 674, 675, 660, 681, 686, 686, 676, 688, 689, 677, 0, 678, 668, 690, 680, 682, 691, 673, 661, 683, 693, 695, 684, 685, 687, 696, 673, 694, 694, 698, 681, 699, 692, 692, 681, 697, 697, 700, 688, 689, 701, 686, 692, 702, 690, 704, 0, 691, 705, 703, 703, 693, 695, 707, 708, 694, 696, 711, 697, 712, 698, 713, 699, 714, 716, 692, 0, 717, 700, 715, 715, 701, 686, 718, 702, 719, 704, 692, 703, 705, 720, 709, 709, 722, 707, 708, 694, 723, 711, 697, 712, 709, 713, 724, 714, 716, 692, 709, 717, 715, 709, 725, 727, 728, 718, 729, 719, 709, 730, 703, 0, 720, 721, 721, 722, 731, 732, 734, 723, 726, 726, 0, 735, 737, 724, 738, 709, 739, 709, 726, 715, 709, 725, 727, 728, 736, 729, 740, 709, 730, 741, 721, 733, 733, 0, 726, 731, 732, 734, 742, 743, 736, 726, 735, 737, 744, 738, 747, 739, 733, 745, 745, 0, 746, 726, 748, 736, 746, 740, 749, 749, 741, 721, 0, 750, 733, 726, 751, 752, 753, 742, 743, 736, 726, 754, 755, 744, 756, 747, 758, 733, 759, 760, 745, 746, 0, 748, 745, 746, 757, 757, 761, 761, 762, 749, 750, 733, 763, 751, 752, 753, 761, 765, 764, 764, 754, 755, 766, 756, 767, 758, 768, 759, 760, 745, 769, 757, 770, 745, 773, 775, 761, 776, 777, 762, 749, 764, 778, 763, 779, 780, 774, 774, 765, 781, 782, 761, 783, 766, 786, 767, 0, 768, 787, 785, 785, 769, 757, 770, 774, 773, 775, 761, 776, 777, 788, 789, 764, 778, 790, 779, 780, 784, 784, 791, 781, 782, 795, 783, 796, 786, 0, 784, 0, 787, 793, 793, 785, 797, 797, 774, 794, 794, 799, 800, 793, 788, 789, 801, 0, 790, 802, 784, 798, 797, 791, 798, 797, 795, 803, 796, 805, 793, 798, 797, 806, 807, 784, 785, 794, 804, 804, 808, 809, 799, 800, 810, 812, 815, 801, 793, 816, 802, 784, 798, 797, 794, 798, 797, 817, 803, 814, 805, 793, 798, 797, 806, 807, 814, 804, 794, 811, 811, 808, 809, 813, 813, 810, 812, 815, 818, 811, 816, 819, 820, 804, 821, 822, 823, 824, 817, 825, 814, 826, 827, 828, 829, 811, 830, 814, 804, 813, 831, 831, 0, 832, 833, 834, 813, 835, 838, 818, 831, 839, 819, 820, 811, 821, 822, 823, 824, 840, 825, 842, 826, 827, 828, 829, 811, 830, 843, 845, 813, 836, 836, 831, 832, 833, 834, 813, 835, 838, 846, 836, 839, 841, 841, 831, 844, 844, 0, 849, 840, 850, 842, 847, 847, 853, 844, 854, 836, 843, 845, 855, 856, 847, 831, 857, 858, 848, 848, 0, 859, 846, 844, 841, 860, 862, 836, 848, 863, 847, 849, 0, 850, 861, 861, 864, 853, 865, 854, 836, 866, 844, 855, 856, 867, 870, 857, 858, 847, 871, 848, 859, 873, 844, 841, 860, 862, 869, 869, 863, 847, 0, 848, 861, 872, 872, 864, 874, 865, 875, 876, 866, 877, 878, 879, 867, 870, 881, 882, 882, 871, 848, 883, 873, 869, 884, 0, 886, 885, 885, 887, 888, 872, 889, 861, 890, 892, 893, 874, 894, 875, 876, 0, 877, 878, 879, 895, 882, 881, 891, 891, 896, 898, 883, 899, 869, 884, 885, 886, 897, 897, 887, 888, 872, 889, 900, 890, 892, 893, 897, 894, 901, 902, 885, 903, 891, 904, 895, 882, 905, 906, 907, 896, 898, 908, 899, 897, 909, 885, 910, 910, 0, 911, 912, 913, 914, 900, 916, 918, 919, 917, 917, 901, 902, 897, 903, 891, 904, 920, 921, 905, 906, 907, 922, 0, 908, 924, 897, 909, 923, 923, 925, 910, 911, 912, 913, 914, 917, 916, 918, 919, 927, 929, 928, 928, 930, 931, 931, 0, 920, 921, 932, 933, 934, 922, 923, 935, 924, 937, 938, 940, 942, 925, 910, 943, 944, 0, 0, 917, 928, 945, 946, 927, 929, 947, 949, 930, 950, 951, 931, 0, 0, 932, 933, 934, 0, 923, 935, 0, 937, 938, 940, 942, 952, 953, 943, 944, 941, 941, 955, 928, 945, 946, 956, 956, 947, 949, 941, 950, 951, 931, 939, 939, 957, 968, 968, 941, 958, 948, 948, 959, 939, 961, 962, 952, 953, 948, 963, 939, 964, 955, 965, 956, 966, 967, 969, 970, 939, 971, 939, 972, 968, 941, 973, 957, 939, 939, 941, 958, 948, 948, 959, 974, 961, 962, 975, 939, 948, 963, 939, 964, 976, 965, 956, 966, 967, 969, 970, 939, 971, 939, 972, 968, 978, 973, 980, 939, 939, 982, 983, 984, 985, 987, 974, 988, 989, 975, 990, 991, 992, 993, 995, 976, 997, 0, 1000, 1001, 1002, 1003, 1004, 0, 0, 1005, 0, 978, 1007, 980, 1008, 1009, 982, 983, 984, 985, 987, 999, 988, 989, 1010, 990, 991, 992, 993, 995, 999, 997, 999, 1000, 1001, 1002, 1003, 1004, 999, 999, 1005, 1006, 1006, 1007, 1011, 1008, 1009, 1012, 1013, 1014, 1015, 1015, 999, 1016, 1017, 1010, 1018, 1019, 1020, 1021, 1006, 999, 1022, 999, 1023, 1023, 1024, 1025, 1026, 999, 999, 1028, 1029, 0, 1030, 1011, 1032, 1033, 1012, 1013, 1014, 1015, 1015, 1023, 1016, 1017, 1034, 1018, 1019, 1020, 1021, 1006, 0, 1022, 1027, 1027, 1035, 1024, 1025, 1026, 1031, 1031, 1028, 1029, 1027, 1030, 1036, 1032, 1033, 1023, 1037, 1027, 1038, 1040, 1023, 1039, 1039, 1034, 1041, 1042, 1043, 1044, 1045, 1031, 1046, 1047, 1048, 1035, 1049, 0, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1036, 1057, 1027, 1058, 1037, 1027, 1038, 1040, 1031, 1059, 1060, 1039, 1041, 1042, 1043, 1044, 1045, 1031, 1046, 1047, 1048, 1061, 1049, 1039, 1050, 1051, 1052, 1053, 1054, 1055, 1056, 1062, 1057, 1063, 1058, 1064, 1064, 1065, 1066, 1067, 1059, 1060, 1039, 1068, 1069, 1071, 1070, 1070, 1072, 1073, 1074, 1075, 1061, 1077, 1064, 1076, 1076, 1078, 1079, 1079, 1080, 1081, 1062, 1070, 1063, 1082, 1083, 1084, 1065, 1066, 1067, 1085, 1085, 0, 1068, 1069, 1071, 1079, 1076, 1072, 1073, 1074, 1075, 1086, 1077, 1064, 1087, 1088, 1078, 1089, 1090, 1080, 1081, 1091, 1070, 1092, 1082, 1083, 1084, 1093, 1094, 1095, 1096, 1079, 1085, 1097, 1098, 1099, 1079, 1076, 1100, 1101, 1102, 1103, 1086, 1104, 1105, 1087, 1088, 1106, 1089, 1090, 1107, 1108, 1091, 1109, 1092, 1110, 1111, 1112, 1093, 1094, 1095, 1096, 1113, 1085, 1097, 1098, 1099, 1114, 1116, 1100, 1101, 1102, 1103, 1117, 1104, 1105, 1115, 1115, 1106, 1118, 1119, 1107, 1108, 1120, 1109, 1121, 1110, 1111, 1112, 1122, 1123, 1124, 1125, 1113, 1126, 1115, 1127, 1128, 1114, 1116, 1130, 1131, 1132, 1127, 1117, 1133, 1134, 1129, 1129, 1135, 1118, 1119, 1136, 1138, 1120, 1139, 1121, 1129, 1140, 1141, 1122, 1123, 1124, 1125, 1129, 1126, 1115, 1127, 1128, 1137, 1137, 1130, 1131, 1132, 1127, 1142, 1133, 1134, 1143, 1144, 1135, 1145, 1146, 1136, 1138, 1147, 1139, 1148, 1137, 1140, 1141, 1149, 1129, 1150, 1151, 1129, 1152, 1153, 1154, 1154, 1155, 1156, 1157, 1158, 1160, 1161, 1142, 1163, 1163, 1143, 1144, 1164, 1145, 1146, 1137, 1154, 1147, 1165, 1148, 1137, 1162, 1162, 1149, 1166, 1150, 1151, 1163, 1152, 1153, 1167, 1168, 1155, 1156, 1157, 1158, 1160, 1161, 1162, 1169, 0, 1170, 1170, 1164, 1171, 1172, 1173, 1154, 1174, 1165, 1175, 1176, 1177, 1178, 1179, 1166, 1180, 1181, 1163, 1182, 1183, 1167, 1168, 1184, 1186, 1187, 1162, 1188, 1190, 1162, 1169, 1170, 1185, 1185, 1191, 1171, 1172, 1173, 1192, 1174, 1194, 1175, 1176, 1177, 1178, 1179, 1170, 1180, 1181, 1185, 1182, 1183, 1193, 1193, 1184, 1186, 1187, 1195, 1188, 1190, 1196, 1197, 1170, 1198, 1199, 1191, 1200, 1201, 1202, 1192, 1203, 1194, 1204, 1205, 1206, 1207, 1208, 1209, 1211, 1212, 1185, 1213, 1193, 1214, 1215, 1216, 1217, 1218, 1195, 1219, 1220, 1196, 1197, 1221, 1198, 1199, 1222, 1200, 1201, 1202, 1223, 1203, 1224, 1204, 1205, 1206, 1207, 1208, 1209, 1211, 1212, 1225, 1213, 1193, 1214, 1215, 1216, 1217, 1218, 1226, 1219, 1220, 1227, 1228, 1221, 1230, 1231, 1222, 1232, 1233, 1234, 1223, 1235, 1224, 1236, 1236, 1237, 1238, 1239, 1240, 1241, 1243, 1225, 1242, 1242, 1244, 1245, 1247, 1246, 1246, 1226, 1248, 1249, 1227, 1228, 1251, 1230, 1231, 1252, 1232, 1233, 1234, 0, 1235, 1236, 1246, 1253, 1237, 1238, 1239, 1240, 1241, 1243, 1242, 1250, 1250, 1244, 1245, 1247, 1236, 1254, 1255, 1248, 1249, 1256, 1257, 1251, 1258, 1259, 1252, 1263, 1250, 1264, 1246, 1265, 1236, 1246, 1253, 1261, 1261, 1262, 1262, 1266, 1267, 1242, 0, 0, 0, 0, 0, 0, 1254, 1255, 0, 0, 1256, 1257, 0, 1258, 1259, 0, 1263, 1250, 1264, 0, 1265, 0, 0, 1261, 0, 1262, 0, 0, 1266, 1267, 0, 0, 0, 0, 0, 0, 0, 0, 1261, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1261, 0, 1262, 1269, 1269, 1269, 1269, 1269, 1269, 1269, 1270, 1270, 1270, 1270, 1270, 1270, 1270, 1271, 1271, 1271, 1271, 1271, 1271, 1271, 1272, 1272, 1272, 1272, 1272, 1272, 1272, 1273, 0, 0, 0, 1273, 1273, 1274, 1274, 0, 0, 1274, 1275, 1275, 1275, 1276, 1276, 0, 0, 1276, 1277, 1277, 0, 0, 1277, 1278, 1278, 0, 0, 1278, 1279, 1279, 0, 0, 1279, 1280, 1280, 0, 0, 1280, 1281, 1281, 0, 0, 1281, 1282, 1282, 0, 0, 1282, 1283, 1283, 0, 0, 1283, 1284, 1284, 0, 0, 1284, 1285, 1285, 0, 0, 1285, 1286, 1286, 0, 0, 1286, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268, 1268); YY_EC_0000 : aliased constant YY_Secondary_Array := ( 0, 1, 1, 1, 1, 1, 1, 1, 1, 2, 3, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 4, 4, 5, 6, 4, 4, 4, 7, 8, 9, 10, 11, 12, 13, 4, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 15, 4, 4, 4, 4, 16, 4, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 4, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 4, 1, 1, 1, 1, 1, 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 1, 4, 1, 4, 4, 1, 4, 1, 4, 4, 1, 1, 1, 1, 4, 1, 1, 1, 1, 4, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1); YY_EC_0001 : aliased constant YY_Secondary_Array := ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); YY_EC_0020 : aliased constant YY_Secondary_Array := ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 2, 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); YY_EC_0021 : aliased constant YY_Secondary_Array := ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4); YY_EC_0022 : aliased constant YY_Secondary_Array := ( 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4); YY_EC_0024 : aliased constant YY_Secondary_Array := ( 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); YY_EC_0027 : aliased constant YY_Secondary_Array := ( 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4); YY_EC_002E : aliased constant YY_Secondary_Array := ( 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); YY_EC_0030 : aliased constant YY_Secondary_Array := ( 1, 4, 4, 4, 1, 1, 1, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); YY_EC_00FD : aliased constant YY_Secondary_Array := ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); YY_EC_00FE : aliased constant YY_Secondary_Array := ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 4, 4, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); YY_EC_00FF : aliased constant YY_Secondary_Array := ( 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 1, 1, 1, 1, 1, 1, 1, 77, 77, 77, 77, 77, 77, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 77, 77, 77, 77, 77, 77, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1); YY_EC_Base : constant array (YY_Primary_Index) of YY_Secondary_Array_Access := (16#0000# => YY_EC_0000'Access, 16#0020# => YY_EC_0020'Access, 16#0021# => YY_EC_0021'Access, 16#0022# => YY_EC_0022'Access, 16#0023# => YY_EC_0022'Access, 16#0024# => YY_EC_0024'Access, 16#0025# => YY_EC_0022'Access, 16#0026# => YY_EC_0022'Access, 16#0027# => YY_EC_0027'Access, 16#0028# => YY_EC_0022'Access, 16#0029# => YY_EC_0022'Access, 16#002A# => YY_EC_0022'Access, 16#002B# => YY_EC_0022'Access, 16#002E# => YY_EC_002E'Access, 16#0030# => YY_EC_0030'Access, 16#00FD# => YY_EC_00FD'Access, 16#00FE# => YY_EC_00FE'Access, 16#00FF# => YY_EC_00FF'Access, others => YY_EC_0001'Access); end Matreshka.Internals.Regexps.Compiler.Scanner.Tables;
pombredanne/ravenadm
Ada
12,846
adb
-- This file is covered by the Internet Software Consortium (ISC) License -- Reference: ../License.txt with Ada.Strings.Hash; with Ada.Characters.Latin_1; with Ada.Directories; with Parameters; with Utilities; package body PortScan is package LAT renames Ada.Characters.Latin_1; package DIR renames Ada.Directories; package UTL renames Utilities; -------------------------------------------------------------------------------------------- -- port_hash -------------------------------------------------------------------------------------------- function port_hash (key : HT.Text) return CON.Hash_Type is begin return Ada.Strings.Hash (HT.USS (key)); end port_hash; -------------------------------------------------------------------------------------------- -- block_ekey -------------------------------------------------------------------------------------------- function block_hash (key : port_index) return CON.Hash_Type is preresult : constant CON.Hash_Type := CON.Hash_Type (key); use type CON.Hash_Type; begin -- Equivalent to mod 128 return preresult and 2#1111111#; end block_hash; -------------------------------------------------------------------------------------------- -- block_ekey -------------------------------------------------------------------------------------------- function block_ekey (left, right : port_index) return Boolean is begin return left = right; end block_ekey; -------------------------------------- -- "<" function for ranking_crate -- -------------------------------------- function "<" (L, R : queue_record) return Boolean is begin if L.reverse_score = R.reverse_score then return R.ap_index > L.ap_index; end if; return L.reverse_score > R.reverse_score; end "<"; -------------------------------------------------------------------------------------------- -- get_bucket -------------------------------------------------------------------------------------------- function get_bucket (id : port_id) return String is begin if id = port_match_failed or else id > last_port then return "XX"; end if; return all_ports (id).bucket; end get_bucket; -------------------------------------------------------------------------------------------- -- get_port_variant #1 -------------------------------------------------------------------------------------------- function get_port_variant (PR : port_record) return String is use type portkey_crate.Cursor; begin if PR.key_cursor = portkey_crate.No_Element then return "get_port_variant: invalid key_cursor"; end if; return HT.USS (portkey_crate.Key (PR.key_cursor)); end get_port_variant; -------------------------------------------------------------------------------------------- -- get_port_variant #2 -------------------------------------------------------------------------------------------- function get_port_variant (id : port_id) return String is begin if id = port_match_failed or else id > last_port then return "Invalid port ID"; end if; return get_port_variant (all_ports (id)); end get_port_variant; -------------------------------------------------------------------------------------------- -- ignore_reason -------------------------------------------------------------------------------------------- function ignore_reason (id : port_id) return String is begin if id = port_match_failed or else id > last_port then return "Invalid port ID"; end if; return HT.USS (all_ports (id).ignore_reason); end ignore_reason; -------------------------------------------------------------------------------------------- -- valid_port_id -------------------------------------------------------------------------------------------- function valid_port_id (id : port_id) return Boolean is begin return id /= port_match_failed; end valid_port_id; -------------------------------------------------------------------------------------------- -- wipe_make_queue -------------------------------------------------------------------------------------------- procedure wipe_make_queue is begin for j in scanners'Range loop make_queue (j).Clear; end loop; end wipe_make_queue; -------------------------------------------------------------------------------------------- -- reset_ports_tree -------------------------------------------------------------------------------------------- procedure reset_ports_tree is begin for k in dim_all_ports'Range loop declare rec : port_record renames all_ports (k); begin rec.sequence_id := 0; rec.key_cursor := portkey_crate.No_Element; rec.ignore_reason := HT.blank; rec.pkgversion := HT.blank; rec.port_variant := HT.blank; rec.port_namebase := HT.blank; rec.bucket := "00"; rec.unkind_custom := False; rec.ignored := False; rec.scanned := False; rec.rev_scanned := False; rec.unlist_failed := False; rec.work_locked := False; rec.scan_locked := False; rec.use_procfs := False; rec.reverse_score := 0; rec.run_deps.Clear; rec.blocked_by.Clear; rec.blocks.Clear; rec.all_reverse.Clear; rec.options.Clear; rec.subpackages.Clear; end; end loop; ports_keys.Clear; rank_queue.Clear; lot_number := 1; lot_counter := 0; last_port := 0; prescanned := False; wipe_make_queue; for m in scanners'Range loop mq_progress (m) := 0; end loop; end reset_ports_tree; -------------------------------------------------------------------------------------------- -- queue_is_empty -------------------------------------------------------------------------------------------- function queue_is_empty return Boolean is begin return rank_queue.Is_Empty; end queue_is_empty; -------------------------------------------------------------------------------------------- -- queue_is_empty -------------------------------------------------------------------------------------------- function original_queue_size return Natural is begin return Natural (original_queue_len); end original_queue_size; -------------------------------------------------------------------------------------------- -- queue_length -------------------------------------------------------------------------------------------- function queue_length return Integer is begin return Integer (rank_queue.Length); end queue_length; -------------------------------------------------------------------------------------------- -- calculate_package_name -------------------------------------------------------------------------------------------- function calculate_package_name (id : port_id; subpackage : String) return String is namebase : constant String := HT.USS (all_ports (id).port_namebase); variant : constant String := HT.USS (all_ports (id).port_variant); pkgversion : constant String := HT.USS (all_ports (id).pkgversion); begin return namebase & "-" & subpackage & "-" & variant & "-" & pkgversion; end calculate_package_name; -------------------------------------------------------------------------------------------- -- convert_depend_origin_to_portkey -------------------------------------------------------------------------------------------- function convert_depend_origin_to_portkey (origin : String) return String is -- expected format: namebase:subpackage:variant numcolons : Natural := HT.count_char (origin, LAT.Colon); begin if numcolons < 2 then return "error"; end if; declare namebase : String := HT.specific_field (origin, 1, ":"); variant : String := HT.specific_field (origin, 3, ":"); begin return namebase & LAT.Colon & variant; end; end convert_depend_origin_to_portkey; -------------------------------------------------------------------------------------------- -- subpackage_from_pkgname -------------------------------------------------------------------------------------------- function subpackage_from_pkgname (pkgname : String) return String is -- expected format: namebase-subpackage-variant-version.txz -- support namebase-subpackage-variant too numcolons : Natural := HT.count_char (pkgname, LAT.Hyphen); begin if numcolons < 3 then return "error"; end if; return HT.tail (HT.head (HT.head (pkgname, "-"), "-"), "-"); end subpackage_from_pkgname; -------------------------------------------------------------------------------------------- -- scan_progress -------------------------------------------------------------------------------------------- function scan_progress return String is type percent is delta 0.01 digits 5; complete : port_index := 0; pc : percent; maximum : Float := Float (last_port + 1); begin for k in scanners'Range loop complete := complete + mq_progress (k); end loop; pc := percent (100.0 * Float (complete) / maximum); return " progress:" & pc'Img & "% " & LAT.CR; end scan_progress; -------------------------------------------------------------------------------------------- -- insert_into_portlist -------------------------------------------------------------------------------------------- procedure insert_into_portlist (port_variant : String) is pv_text : HT.Text := HT.SUS (port_variant); begin if not portlist.Contains (pv_text) then portlist.Append (pv_text); dupelist.Append (pv_text); end if; end insert_into_portlist; -------------------------------------------------------------------------------------------- -- jail_env_port_specified -------------------------------------------------------------------------------------------- function jail_env_port_specified return Boolean is begin return portlist.Contains (HT.SUS (default_compiler & ":standard")) or else portlist.Contains (HT.SUS ("binutils:ravensys")); end jail_env_port_specified; -------------------------------------------------------------------------------------------- -- requires_procfs -------------------------------------------------------------------------------------------- function requires_procfs (id : port_id) return Boolean is begin return all_ports (id).use_procfs; end requires_procfs; -------------------------------------------------------------------------------------------- -- build_request_length -------------------------------------------------------------------------------------------- function build_request_length return Integer is begin return Integer (dupelist.Length); end build_request_length; -------------------------------------------------------------------------------------------- -- get_buildsheet_from_origin_list -------------------------------------------------------------------------------------------- function get_buildsheet_from_origin_list (index : Positive) return String is procedure search (position : string_crate.Cursor); conspiracy : constant String := HT.USS (Parameters.configuration.dir_conspiracy); unkindness : constant String := HT.USS (Parameters.configuration.dir_unkindness); counter : Natural := 0; answer : HT.Text; procedure search (position : string_crate.Cursor) is begin counter := counter + 1; if counter = index then declare namebase : String := HT.part_1 (HT.USS (string_crate.Element (position)), ":"); bsheetname : String := "/bucket_" & UTL.bucket (namebase) & "/" & namebase; begin if DIR.Exists (unkindness & bsheetname) then answer := HT.SUS (unkindness & bsheetname); else answer := HT.SUS (conspiracy & bsheetname); end if; end; end if; end search; begin dupelist.Iterate (search'Access); return HT.USS (answer); end get_buildsheet_from_origin_list; end PortScan;
zrmyers/VulkanAda
Ada
27,327
ads
-------------------------------------------------------------------------------- -- MIT License -- -- Copyright (c) 2020 Zane Myers -- -- Permission is hereby granted, free of charge, to any person obtaining a copy -- of this software and associated documentation files (the "Software"), to deal -- in the Software without restriction, including without limitation the rights -- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -- copies of the Software, and to permit persons to whom the Software is -- furnished to do so, subject to the following conditions: -- -- The above copyright notice and this permission notice shall be included in all -- copies or substantial portions of the Software. -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -- SOFTWARE. -------------------------------------------------------------------------------- with Vulkan.Math.GenType; with Vulkan.Math.GenBType; with Vulkan.Math.GenIType; use Vulkan.Math.GenBType; use Vulkan.Math.GenIType; -------------------------------------------------------------------------------- --< @group Vulkan Math GenType -------------------------------------------------------------------------------- --< @summary --< This package describes any length vector of Vkm_Double type. --< --< @description --< Provides an instantiation of the generic GenType package with a Base_Type of --< Vkm_Double. This is used to provide the Vkm_GenDType subtype for the Vulkan Math --< library. -------------------------------------------------------------------------------- package Vulkan.Math.GenDType is pragma Preelaborate; pragma Pure; --< @private --< An instance of the generic GenType package, with Vkm_Double as the Base_Type. package GDT is new Vulkan.Math.GenType( Base_Type => Vkm_Double, Default_Value => 0.0, Image => Vkm_Double'Image, Unary_Minus => "-", Multiply => "*"); --< A subtype of the instantiated Vkm_GenType that represents the GenDType --< described in the GLSL specification. subtype Vkm_GenDType is GDT.Vkm_GenType; ---------------------------------------------------------------------------- -- Functions ---------------------------------------------------------------------------- function Image(instance : in Vkm_GenDType) return String is (GDT.Image(GDT.Vkm_GenType(instance))) with inline; ---------------------------------------------------------------------------- -- Generic Operations ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- --< @summary --< Apply function for parameters of Vkm_Double and Vkm_Bool type to GenDType --< and GenBType vectors. --< --< @description --< Applies a supplied function component wise on two GenDType vectors and --< a GenBType vector returning a GenDType vector. --< --< RVD := [Func(IVD1.x, IVD2.x, IVB1.x) ... Func(IVD1.w, IVD2.w, IVB1.w)] --< --< @param IVD1 --< The first input GenDType parameter. --< --< @param IVD2 --< The second input GenDType parameter. --< --< @param IVB1 --< The first input GenBType parameter. --< --< @return --< The result GenDType vector, RVD. ---------------------------------------------------------------------------- generic with function Func(ISD1, ISD2 : in Vkm_Double; ISB1 : in Vkm_Bool ) return Vkm_Double; function Apply_Func_IVD_IVD_IVB_RVD(IVD1, IVD2 : in Vkm_GenDType; IVB1 : in Vkm_GenBType) return Vkm_GenDType; ---------------------------------------------------------------------------- --< @summary --< Apply function on a Vkm_Double input that returns a VKm_Bool component-wise --< to a GenDType vector. --< --< @description --< Applies a supplied function component wise on a GenDType vector returning --< a GenBType vector. --< --< RVB := [Func(IVD1.x) ... Func(IVD1.w)] --< --< @param IVD1 --< The input GenDType parameter. --< --< @return --< The resulting GenBType vector, RVB. ---------------------------------------------------------------------------- generic with function Func(ISD : in Vkm_Double) return Vkm_Bool; function Apply_Func_IVD_RVB(IVD1 : in Vkm_GenDType) return Vkm_GenBType; ---------------------------------------------------------------------------- --< @summary --< Apply function on a Vkm_Double input and a Vkm_Int outut that returns a Vkm_Double --< component-wise to the corresponding vector types. --< --< @description --< Applies a supplied function component wise on a GenDType and GenIType --< vector, returning a GenDType vector. --< --< RVD := [Func(IVD.x,OVI.x) ... Func(IVD.w,OVI.w)] --< --< @param IVD --< The input GenDType parameter. --< --< @param OVI --< The output GenIType parameter. --< --< @return --< The resulting GenDType vector, RVD. ---------------------------------------------------------------------------- generic with function Func (ISD : in Vkm_Double; ISI : out Vkm_Int) return Vkm_Double; function Apply_Func_IVD_OVI_RVD(IVD : in Vkm_GenDType; OVI : out Vkm_GenIType) return Vkm_GenDType; ---------------------------------------------------------------------------- --< @summary --< Apply function on a Vkm_Double and a Vkm_Int input that returns a Vkm_Double --< component-wise to the corresponding vector types. --< --< @description --< Applies a supplied function component wise on a GenDType and GenIType --< vector, returning a GenDType vector. --< --< RVD := [Func(IVD.x,IVI.x) ... Func(IVD.w,IVI.w)] --< --< @param IVD --< The input GenDType parameter. --< --< @param IVI --< The input GenIType parameter. --< --< @return --< The resulting GenDType vector, RVD. ---------------------------------------------------------------------------- generic with function Func (ISD : in Vkm_Double; ISI : in Vkm_Int) return Vkm_Double; function Apply_Func_IVD_IVI_RVD(IVD : in Vkm_GenDType; IVI : in Vkm_GenIType) return Vkm_GenDType; ---------------------------------------------------------------------------- --< @summary --< Apply function on two Vkm_Double inputs that returns a Vkm_Bool component-wise --< to two Vkm_GenDType vectors. --< --< @description --< Applies a supplied function component wise on two GenDType vectors, --< returning a GenBType vector. --< --< RVB := [Func(IVD1.x,IVD2.x) ... Func(IVD1.w,IVD2.w)] --< --< @param IVD1 --< The first input GenDType parameter. --< --< @param IVD2 --< The second input GenDType parameter. --< --< @return --< The resulting GenBType vector, RVB. ---------------------------------------------------------------------------- generic with function Func (ISD1 : in Vkm_Double; ISD2 : in Vkm_Double) return Vkm_Bool; function Apply_Func_IVD_IVD_RVB(IVD1, IVD2 : in Vkm_GenDType) return Vkm_GenBType; ---------------------------------------------------------------------------- -- The Operators for double precision floating point vectors are defined here. -- -- A summary of operators that can be used with GenDType values of different -- size: -- - "&", Concatenation -- -- A summary of operators that are component-wise Unary: -- - "+" , Unary plus operator. -- - "-" , Unary minus operator. -- - "abs", Absolute value operator. -- -- A summary of operators that are component-wise on two input vectors of the -- same length. Additionally, a scalar may appear instead of a vector on the -- left or right hand side of these operators: -- - "mod", Modulus operator. -- - "**", Power operator. -- - "+", Addition operator. -- - "-", Subtraction operator. -- - "rem", Remainder operator. -- - "*", Multiplication operator. -- - "/", Division operator. -- -- A summary of relational operators that are component-wise on two input vecotrs -- of the same length, and return a vector of booleans of the same length: -- - "<", Less than operator -- - ">", Greater than operator -- - "<=", Less than or equal to operator -- - ">=", Greater than or equal to operator -- -- A summary of relational operators which return a scalar boolean value. -- - "=", Equality operator -- - "/=", Non-Equality operator -- ---------------------------------------------------------------------------- -- GenDType Concatenation Operators ---------------------------------------------------------------------------- ---------------------------------------------------------------------------- --< @summary --< GenDType concatenation operator. --< --< @description --< Concatenate two GenDType vectors. --< vector := vector & vector --< --< @param left --< Parameter to the left of the '&' symbol. --< --< @param right --< Parameter to the right of the '&' symbol. --< --< @return --< Append right vector to left vector. ---------------------------------------------------------------------------- function "&" (left, right : in Vkm_GenDType) return Vkm_GenDType renames GDT.Concatenate; ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType concatenation operator. --< --< @description --< Concatenate a Vkm_Double and a Vkm_GenDType vector. --< vector := scalar & vector --< --< @param left --< Parameter to the left of the '&' symbol. --< --< @param right --< Parameter to the right of the '&' symbol. --< --< @return --< Append right vector to left scalar. ---------------------------------------------------------------------------- function "&" (left : in Vkm_Double ; right : in Vkm_GenDType) return Vkm_GenDType is (GDT.Make_GenType(left).Concatenate(right)) with Inline; ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType concatenation operator. --< --< @description --< Concatenate a Vkm_Double and a Vkm_GenDType vector. --< vector := vector & scalar --< --< @param left --< Parameter to the left of the '&' symbol. --< --< @param right --< Parameter to the right of the '&' symbol. --< --< @return --< Append right scalar to left vector. ---------------------------------------------------------------------------- function "&" (left : in Vkm_GenDType; right : in Vkm_Double ) return Vkm_GenDType is (left.Concatenate(GDT.Make_GenType(right))) with Inline; ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType concatenation operator. --< --< @description --< Concatenate two Vkm_Doubles to form a Vkm_GenDType vector. --< vector := scalar & scalar --< --< @param left --< Parameter to the left of the '&' symbol. --< --< @param right --< Parameter to the right of the '&' symbol. --< --< @return --< Append right scalar to left scalar. ---------------------------------------------------------------------------- function "&" (left, right : in Vkm_Double ) return Vkm_GenDType is (GDT.Make_GenType(left, right)) with Inline; ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType unary plus operator. --< --< @description --< Return the unmodified vector. --< vector := +vector; ---------------------------------------------------------------------------- function "+" is new GDT.Apply_Func_IV_RV("+"); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType unary minus operator. --< --< @description --< Return the negation of the vector. --< vector := -vector; ---------------------------------------------------------------------------- function "-" is new GDT.Apply_Func_IV_RV("-"); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType absolute value operator. --< --< @description --< Return the absolute value for each component of the vector. --< vector := abs vector; ---------------------------------------------------------------------------- function "abs" is new GDT.Apply_Func_IV_RV("abs"); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType modulo operator. --< --< @description --< Return the component-wise modulo of the two vectors. --< vector := vector mod vector; ---------------------------------------------------------------------------- function "mod" is new GDT.Apply_Func_IV_IV_RV("mod"); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType modulo operator. --< --< @description --< Return the component-wise modulo of a vector and a scalar. --< vector := vector mod scalar; ---------------------------------------------------------------------------- function "mod" is new GDT.Apply_Func_IV_IS_RV("mod"); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType modulo operator. --< --< @description --< Return the component-wise modulo of a vector and a scalar. --< vector := scalar mod vector; ---------------------------------------------------------------------------- function "mod" is new GDT.Apply_Func_IS_IV_RV("mod"); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType power operator. --< --< @description --< Apply the power operation component-wise on two vectors. --< vector := vector ** vector; ---------------------------------------------------------------------------- function "**" is new GDT.Apply_Func_IV_IV_RV("**"); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType power operator. --< --< @description --< Apply the power operation component-wise on a vector and a scalar. --< vector := vector ** scalar; ---------------------------------------------------------------------------- function "**" is new GDT.Apply_Func_IV_IS_RV("**"); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType power operator. --< --< @description --< Apply the power operation component-wise on a vector and a scalar. --< vector := scalar ** vector; ---------------------------------------------------------------------------- function "**" is new GDT.Apply_Func_IS_IV_RV("**"); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType addition operator. --< --< @description --< Apply the additon operation component-wise on two vectors. --< vector := vector + vector; ---------------------------------------------------------------------------- function "+" is new GDT.Apply_Func_IV_IV_RV("+"); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType addition operator. --< --< @description --< Apply the additon operation component-wise on a vector and a scalar. --< vector := vector + scalar; ---------------------------------------------------------------------------- function "+" is new GDT.Apply_Func_IV_IS_RV("+"); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType addition operator. --< --< @description --< Apply the additon operation component-wise on a vector and a scalar. --< vector := scalar + vector; ---------------------------------------------------------------------------- function "+" is new GDT.Apply_Func_IS_IV_RV("+"); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType subtraction operator. --< --< @description --< Apply the subtraction operation component-wise on two vectors. --< vector := vector - vector; ---------------------------------------------------------------------------- function "-" is new GDT.Apply_Func_IV_IV_RV("-"); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType subtraction operator. --< --< @description --< Apply the subtraction operation component-wise on a vector and a scalar. --< vector := vector - scalar; ---------------------------------------------------------------------------- function "-" is new GDT.Apply_Func_IV_IS_RV("-"); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType subtraction operator. --< --< @description --< Apply the subtraction operation component-wise on a vector and a scalar. --< vector := scalar - vector; ---------------------------------------------------------------------------- function "-" is new GDT.Apply_Func_IS_IV_RV("-"); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType remainder operator. --< --< @description --< Calculate the remainder of division of left by right: --< scalar := left rem right; --< --< @param left --< The numerator in the division for which the remainder is returned. --< --< @param right --< The denominator in the division for which the remainder is returned. --< --< @return --< The remainder of left divided by right. ---------------------------------------------------------------------------- function "rem" (left, right : in Vkm_Double) return Vkm_Double renames Vkm_Double'Remainder; ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType remainder operator. --< --< @description --< Calculate the remainder of division of for two vectors. --< vector := vector rem vector; ---------------------------------------------------------------------------- function "rem" is new GDT.Apply_Func_IV_IV_RV("rem"); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType remainder operator. --< --< @description --< Calculate the remainder of division of for a vector and a scalar. --< vector := vector rem scalar; ---------------------------------------------------------------------------- function "rem" is new GDT.Apply_Func_IV_IS_RV("rem"); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType remainder operator. --< --< @description --< Calculate the remainder of division of for a vector and a scalar. --< vector := scalar rem vector; ---------------------------------------------------------------------------- function "rem" is new GDT.Apply_Func_IS_IV_RV("rem"); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType multiplication operator. --< --< @description --< Apply the multiplication operation component-wise on two vectors. --< vector := vector * vector; ---------------------------------------------------------------------------- function "*" is new GDT.Apply_Func_IV_IV_RV("*"); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType multiplication operator. --< --< @description --< Apply the multiplication operation component-wise on a vector and a scalar. --< vector := vector * scalar; ---------------------------------------------------------------------------- function "*" is new GDT.Apply_Func_IV_IS_RV("*"); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType multiplication operator. --< --< @description --< Apply the multiplication operation component-wise on a vector and a scalar. --< vector := scalar * vector; ---------------------------------------------------------------------------- function "*" is new GDT.Apply_Func_IS_IV_RV("*"); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType division operator. --< --< @description --< Calculate the component-wise division of two vectors. --< vector := vector / vector; ---------------------------------------------------------------------------- function "/" is new GDT.Apply_Func_IV_IV_RV("/"); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType division operator. --< --< @description --< Calculate the component-wise division of a vector and a scalar. --< vector := vector / scalar; ---------------------------------------------------------------------------- function "/" is new GDT.Apply_Func_IV_IS_RV("/"); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType division operator. --< --< @description --< Calculate the component-wise division of a vector and a scalar. --< vector := scalar / vector; ---------------------------------------------------------------------------- function "/" is new GDT.Apply_Func_IS_IV_RV("/"); ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType less than operator. --< --< @description --< Return the result of the component-wise less than operator on two vectors. --< bool_vector := vector < vector; ---------------------------------------------------------------------------- function "<" (left, right : in Vkm_GenDType) return Vkm_GenBType; ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType less than or equal to operator. --< --< @description --< Return the result of the component-wise less than or equal to operator on --< two vectors. --< bool_vector := vector < vector; ---------------------------------------------------------------------------- function "<=" (left, right : in Vkm_GenDType) return Vkm_GenBType; ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType greater than operator. --< --< @description --< Return the result of the component-wise greater than operator on --< two vectors. --< bool_vector := vector < vector; ---------------------------------------------------------------------------- function ">" (left, right : in Vkm_GenDType) return Vkm_GenBType; ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType greater than or equal operator. --< --< @description --< Return the result of the component-wise greater than or equal to operator --< on two vectors. --< bool_vector := vector < vector; ---------------------------------------------------------------------------- function ">=" (left, right : in Vkm_GenDType) return Vkm_GenBType; ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType equality operator. --< --< @description --< Return true if each component of two vectors are equal to each other. --< Otherwise return false. --< is_equal := vector = vector; --< --< @param left --< The left vector in the comparison. --< --< @param right --< The right vector in the comparison. --< --< @return --< Whether the two vectors are equal to each other. ---------------------------------------------------------------------------- function "=" (left, right : in Vkm_GenDType) return Vkm_Bool renames GDT.Equals; ---------------------------------------------------------------------------- --< @summary --< Vkm_GenDType inequality operator. --< --< @description --< Return true if any component of the two vectors are not equal to each other. --< Otherwise return false. --< is_equal := vector /= vector; --< --< @param left --< The left vector in the comparison. --< --< @param right --< The right vector in the comparison. --< --< @return --< Whether the two vectors are equal to each other. ---------------------------------------------------------------------------- function "/=" (left, right : in Vkm_GenDType) return Vkm_Bool is (not (left = right)) with Inline; end Vulkan.Math.GenDType;
AdaCore/gpr
Ada
2,734
adb
-- -- Copyright (C) 2019-2023, AdaCore -- -- SPDX-License-Identifier: Apache-2.0 -- with Ada.Directories; with Ada.Text_IO; with Ada.Strings.Fixed; with GPR2.Project.View; with GPR2.Project.Tree; with GPR2.Project.Attribute.Set; with GPR2.Project.Registry.Attribute; with GPR2.Project.Variable.Set; with GPR2.Context; procedure Main is use Ada; use GPR2; use GPR2.Project; procedure Display (Prj : Project.View.Object; Full : Boolean := True); ------------- -- Display -- ------------- procedure Display (Prj : Project.View.Object; Full : Boolean := True) is use GPR2.Project.Attribute.Set; use GPR2.Project.Variable.Set.Set; use type GPR2.Project.Registry.Attribute.Value_Kind; begin Text_IO.Put (String (Prj.Name) & " "); Text_IO.Set_Col (10); Text_IO.Put_Line (Prj.Qualifier'Img); if Full then for A in Prj.Attributes (With_Defaults => False).Iterate loop Text_IO.Put ("A: " & Image (Attribute.Set.Element (A).Name.Id.Attr)); Text_IO.Put (" ->"); if not Element (A).Values.Is_Empty then for V of Element (A).Values loop Text_IO.Put (" " & V.Text); end loop; end if; Text_IO.New_Line; end loop; if Prj.Has_Variables then for V in Prj.Variables.Iterate loop Text_IO.Put ("V: " & String (Key (V))); Text_IO.Put (" -> "); if Element (V).Kind = Registry.Attribute.Single then Text_IO.Put (Element (V).Value.Text); elsif not Element (V).Values.Is_Empty then for Va of Element (V).Values loop Text_IO.Put (" " & Va.Text); end loop; end if; Text_IO.New_Line; end loop; end if; Text_IO.New_Line; end if; end Display; Prj : Project.Tree.Object; Ctx : Context.Object; begin Project.Tree.Load (Prj, Create ("common.gpr"), Ctx); for P of Prj loop Display (P, Full => True); end loop; exception when GPR2.Project_Error => if Prj.Has_Messages then Text_IO.Put_Line ("Messages found:"); for M of Prj.Log_Messages.all loop declare Mes : constant String := M.Format; L : constant Natural := Strings.Fixed.Index (Mes, "/common"); begin if L /= 0 then Text_IO.Put_Line (Mes (L .. Mes'Last)); else Text_IO.Put_Line (Mes); end if; end; end loop; end if; end Main;
zhmu/ananas
Ada
151
ads
package Return4_Pkg is type Rec is record I1, I2, I3 : Integer; end record; function Get_Value (I : Integer) return Rec; end Return4_Pkg;
ekoeppen/Ada_Drivers_Library
Ada
5,363
adb
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015-2016, AdaCore -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with Ada.Real_Time; use Ada.Real_Time; with STM32.Board; use STM32.Board; with STM32.Device; use STM32.Device; with STM32.GPIO; use STM32.GPIO; with STM32.EXTI; use STM32.EXTI; package body STM32.User_Button is Button_High : Boolean := True; Debounce_Time : constant Time_Span := Milliseconds (250); EXTI_Line : constant External_Line_Number := User_Button_Point.Interrupt_Line_Number; Initialization_Complete : Boolean := False; ------------ -- Button -- ------------ protected Button is pragma Interrupt_Priority; function Current_State return Boolean; procedure Clear_State; private procedure Interrupt; pragma Attach_Handler (Interrupt, User_Button_Interrupt); Pressed : Boolean := False; Start_Time : Time := Clock; end Button; ------------ -- Button -- ------------ protected body Button is --------------- -- Interrupt -- --------------- procedure Interrupt is begin Clear_External_Interrupt (EXTI_Line); if (Button_High and then User_Button_Point.Set) or else (not Button_High and then not User_Button_Point.Set) then if Clock - Start_Time > Debounce_Time then Pressed := True; end if; end if; end Interrupt; ------------------- -- Current_State -- ------------------- function Current_State return Boolean is begin return Pressed; end Current_State; ----------------- -- Clear_State -- ----------------- procedure Clear_State is begin if Pressed then Start_Time := Clock; Pressed := False; end if; end Clear_State; end Button; ---------------- -- Initialize -- ---------------- procedure Initialize (Use_Rising_Edge : Boolean := True) is Edge : constant EXTI.External_Triggers := (if Use_Rising_Edge then Interrupt_Rising_Edge else Interrupt_Falling_Edge); begin Enable_Clock (User_Button_Point); User_Button_Point.Configure_IO ((Mode => Mode_In, Output_Type => Push_Pull, Speed => Speed_2MHz, Resistors => (if Use_Rising_Edge then Pull_Down else Pull_Up))); -- Connect the button's pin to the External Interrupt Handler User_Button_Point.Configure_Trigger (Edge); Button_High := Use_Rising_Edge; Initialization_Complete := True; end Initialize; ---------------------- -- Has_Been_Pressed -- ---------------------- function Has_Been_Pressed return Boolean is State : Boolean; begin State := Button.Current_State; Button.Clear_State; return State; end Has_Been_Pressed; ----------------- -- Initialized -- ----------------- function Initialized return Boolean is (Initialization_Complete); end STM32.User_Button;
tum-ei-rcs/StratoX
Ada
1,907
ads
-- General Profiler -- Author: Emanuel Regnath ([email protected]) -- -- Description: measures execution time between 'start' and 'stop'. -- Stores maximum execution time. -- -- Usage: enter loop, call 'start', execute code, call 'stop'. -- call 'get_Max' outside of loop to retrieve longest execution time. -- ToDo: Add middle stops with Ada.Real_Time; use Ada.Real_Time; package Profiler with SPARK_Mode is type Profile_Tag is tagged private; CFG_PROFILER_PROFILING : constant Boolean := True; CFG_PROFILER_LOGGING : constant Boolean := True; procedure enableProfiling; procedure disableProfiling; procedure init(Self : in out Profile_Tag; name : String); procedure reset(Self : in out Profile_Tag); procedure start(Self : in out Profile_Tag); procedure stop(Self : in out Profile_Tag); procedure log(Self : in Profile_Tag); function get_Name(Self : in Profile_Tag) return String; function get_Start(Self : in Profile_Tag) return Time; function get_Stop(Self : in Profile_Tag) return Time; -- elapsed time before stop or last measurement time after stop function get_Elapsed(Self : in Profile_Tag) return Time_Span; function get_Max(Self : in Profile_Tag) return Time_Span; private subtype Name_Length_Type is Integer range 0 .. 30; subtype Name_Type is String(1 .. 30); type Profile_Tag is tagged record name : Name_Type := (others => ' '); name_length : Name_Length_Type := 0; max_duration : Time_Span := Milliseconds( 0 ); start_Time : Time := Time_First; stop_Time : Time := Time_First; end record; type State_Type is record isEnabled : Boolean := True; end record; G_state : State_Type; procedure Read_From_Memory(Self : in out Profile_Tag); procedure Write_To_Memory(Self : in out Profile_Tag); end Profiler;
sungyeon/drake
Ada
1,758
ads
pragma License (Unrestricted); -- extended unit private with System.Unbounded_Allocators; package System.Storage_Pools.Unbounded is -- Separated storage pool for local scope. -- The compiler (gcc) does not support scope-based automatic deallocation. -- Instead, some custom pool, like System.Pool_Local.Unbounded_Reclaim_Pool -- of GNAT runtime, using separated storage by every pool object and -- having different lifetime from the standard storage pool can be used -- for deallocating all of allocated from each pool object, at once. -- This package provides the similar pool. pragma Preelaborate; type Unbounded_Pool is limited new Root_Storage_Pool with private; pragma Unreferenced_Objects (Unbounded_Pool); -- [gcc-4.8] warnings private type Unbounded_Pool is limited new Root_Storage_Pool with record Allocator : Unbounded_Allocators.Unbounded_Allocator; end record; pragma Finalize_Storage_Only (Unbounded_Pool); overriding procedure Initialize (Object : in out Unbounded_Pool); overriding procedure Finalize (Object : in out Unbounded_Pool); overriding procedure Allocate ( Pool : in out Unbounded_Pool; Storage_Address : out Address; Size_In_Storage_Elements : Storage_Elements.Storage_Count; Alignment : Storage_Elements.Storage_Count); overriding procedure Deallocate ( Pool : in out Unbounded_Pool; Storage_Address : Address; Size_In_Storage_Elements : Storage_Elements.Storage_Count; Alignment : Storage_Elements.Storage_Count); overriding function Storage_Size (Pool : Unbounded_Pool) return Storage_Elements.Storage_Count is (Storage_Elements.Storage_Count'Last); end System.Storage_Pools.Unbounded;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
50
ads
package Startup is pragma Pure; end Startup;
reznikmm/matreshka
Ada
7,804
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with AMF.Internals.UML_Elements; with AMF.UML.Input_Pins; with AMF.UML.Link_End_Destruction_Datas; with AMF.UML.Properties; with AMF.UML.Qualifier_Values.Collections; with AMF.Visitors; package AMF.Internals.UML_Link_End_Destruction_Datas is type UML_Link_End_Destruction_Data_Proxy is limited new AMF.Internals.UML_Elements.UML_Element_Proxy and AMF.UML.Link_End_Destruction_Datas.UML_Link_End_Destruction_Data with null record; overriding function Get_Destroy_At (Self : not null access constant UML_Link_End_Destruction_Data_Proxy) return AMF.UML.Input_Pins.UML_Input_Pin_Access; -- Getter of LinkEndDestructionData::destroyAt. -- -- Specifies the position of an existing link to be destroyed in ordered -- nonunique association ends. The type of the pin is UnlimitedNatural, -- but the value cannot be zero or unlimited. overriding procedure Set_Destroy_At (Self : not null access UML_Link_End_Destruction_Data_Proxy; To : AMF.UML.Input_Pins.UML_Input_Pin_Access); -- Setter of LinkEndDestructionData::destroyAt. -- -- Specifies the position of an existing link to be destroyed in ordered -- nonunique association ends. The type of the pin is UnlimitedNatural, -- but the value cannot be zero or unlimited. overriding function Get_Is_Destroy_Duplicates (Self : not null access constant UML_Link_End_Destruction_Data_Proxy) return Boolean; -- Getter of LinkEndDestructionData::isDestroyDuplicates. -- -- Specifies whether to destroy duplicates of the value in nonunique -- association ends. overriding procedure Set_Is_Destroy_Duplicates (Self : not null access UML_Link_End_Destruction_Data_Proxy; To : Boolean); -- Setter of LinkEndDestructionData::isDestroyDuplicates. -- -- Specifies whether to destroy duplicates of the value in nonunique -- association ends. overriding function Get_End (Self : not null access constant UML_Link_End_Destruction_Data_Proxy) return AMF.UML.Properties.UML_Property_Access; -- Getter of LinkEndData::end. -- -- Association end for which this link-end data specifies values. overriding procedure Set_End (Self : not null access UML_Link_End_Destruction_Data_Proxy; To : AMF.UML.Properties.UML_Property_Access); -- Setter of LinkEndData::end. -- -- Association end for which this link-end data specifies values. overriding function Get_Qualifier (Self : not null access constant UML_Link_End_Destruction_Data_Proxy) return AMF.UML.Qualifier_Values.Collections.Set_Of_UML_Qualifier_Value; -- Getter of LinkEndData::qualifier. -- -- List of qualifier values overriding function Get_Value (Self : not null access constant UML_Link_End_Destruction_Data_Proxy) return AMF.UML.Input_Pins.UML_Input_Pin_Access; -- Getter of LinkEndData::value. -- -- Input pin that provides the specified object for the given end. This -- pin is omitted if the link-end data specifies an 'open' end for reading. overriding procedure Set_Value (Self : not null access UML_Link_End_Destruction_Data_Proxy; To : AMF.UML.Input_Pins.UML_Input_Pin_Access); -- Setter of LinkEndData::value. -- -- Input pin that provides the specified object for the given end. This -- pin is omitted if the link-end data specifies an 'open' end for reading. overriding procedure Enter_Element (Self : not null access constant UML_Link_End_Destruction_Data_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Leave_Element (Self : not null access constant UML_Link_End_Destruction_Data_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of visitor interface. overriding procedure Visit_Element (Self : not null access constant UML_Link_End_Destruction_Data_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control); -- Dispatch call to corresponding subprogram of iterator interface. end AMF.Internals.UML_Link_End_Destruction_Datas;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
196
ads
with STM32_SVD; use STM32_SVD; generic Filename : String; package STM32GD.USART.Peripheral is pragma Preelaborate; procedure Transmit (Data : in Byte); end STM32GD.USART.Peripheral;