repo_name
stringlengths
9
74
language
stringclasses
1 value
length_bytes
int64
11
9.34M
extension
stringclasses
2 values
content
stringlengths
11
9.34M
Tim-Tom/project-euler
Ada
58
ads
package Problem_60 is procedure Solve; end Problem_60;
reznikmm/matreshka
Ada
4,688
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Style.Text_Overline_Width_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Style_Text_Overline_Width_Attribute_Node is begin return Self : Style_Text_Overline_Width_Attribute_Node do Matreshka.ODF_Style.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Style_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Style_Text_Overline_Width_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Text_Overline_Width_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Style_URI, Matreshka.ODF_String_Constants.Text_Overline_Width_Attribute, Style_Text_Overline_Width_Attribute_Node'Tag); end Matreshka.ODF_Style.Text_Overline_Width_Attributes;
stcarrez/ada-el
Ada
4,074
ads
----------------------------------------------------------------------- -- el-methods-proc_1 -- Procedure Binding with 1 argument -- Copyright (C) 2010, 2011, 2012, 2013, 2015, 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 EL.Expressions; with EL.Contexts; with Util.Beans.Methods; with Util.Beans.Basic; generic type Param1_Type (<>) is limited private; package EL.Methods.Proc_1 is use Util.Beans.Methods; -- Returns True if the method is a valid method which accepts the arguments -- defined by the package instantiation. function Is_Valid (Method : in EL.Expressions.Method_Info) return Boolean; -- Execute the method describe by the method expression -- and with the given context. The method signature is: -- -- procedure F (Obj : in out <Bean>; -- Param : in out Param1_Type); -- -- where <Bean> inherits from <b>Readonly_Bean</b> -- (See <b>Bind</b> package) -- -- Raises <b>Invalid_Method</b> if the method referenced by -- the method expression does not exist or does not match -- the signature. procedure Execute (Method : in EL.Expressions.Method_Expression'Class; Param : in out Param1_Type; Context : in EL.Contexts.ELContext'Class); -- Execute the method describe by the method binding object. -- The method signature is: -- -- procedure F (Obj : in out <Bean>; -- Param : in out Param1_Type); -- -- where <Bean> inherits from <b>Readonly_Bean</b> -- (See <b>Bind</b> package) -- -- Raises <b>Invalid_Method</b> if the method referenced by -- the method expression does not exist or does not match -- the signature. procedure Execute (Method : in EL.Expressions.Method_Info; Param : in out Param1_Type); -- Function access to the proxy. type Proxy_Access is access procedure (O : access Util.Beans.Basic.Readonly_Bean'Class; P : in out Param1_Type); -- The binding record which links the method name -- to the proxy function. type Binding is new Method_Binding with record Method : Proxy_Access; end record; type Binding_Access is access constant Binding; -- Proxy for the binding. -- The proxy declares the binding definition that links -- the name to the function and it implements the necessary -- object conversion to translate the <b>Readonly_Bean</b> -- object to the target object type. generic -- Name of the method (as exposed in the EL expression) Name : String; -- The bean type type Bean is abstract limited new Util.Beans.Basic.Readonly_Bean with private; -- The bean method to invoke with procedure Method (O : in out Bean; P1 : in out Param1_Type); package Bind is -- Method that <b>Execute</b> will invoke. procedure Method_Access (O : access Util.Beans.Basic.Readonly_Bean'Class; P1 : in out Param1_Type); F_NAME : aliased constant String := Name; -- The proxy binding that can be exposed through -- the <b>Method_Bean</b> interface. Proxy : aliased constant Binding := Binding '(Name => F_NAME'Access, Method => Method_Access'Access); end Bind; end EL.Methods.Proc_1;
sungyeon/drake
Ada
3,803
adb
with Ada.Exceptions; with Ada.Unchecked_Conversion; with System.Formatting; with System.Interrupt_Numbers; with System.Long_Long_Integer_Types; with System.Unwind.Occurrences; with C.signal; package body System.Native_Interrupts.Vector is use type Ada.Interrupts.Parameterless_Handler; use type C.signed_int; use type C.unsigned_int; subtype Word_Unsigned is Long_Long_Integer_Types.Word_Unsigned; procedure Report ( Interrupt : Interrupt_Id; X : Ada.Exceptions.Exception_Occurrence); procedure Report ( Interrupt : Interrupt_Id; X : Ada.Exceptions.Exception_Occurrence) is function Cast is new Ada.Unchecked_Conversion ( Ada.Exceptions.Exception_Occurrence, Unwind.Exception_Occurrence); Name_Prefix : constant String := "Interrupt "; Name : String (1 .. Name_Prefix'Length + Interrupt_Id'Width); Name_Last : Natural; Error : Boolean; begin Name (1 .. Name_Prefix'Length) := Name_Prefix; Formatting.Image ( Word_Unsigned (Interrupt), Name (Name_Prefix'Length + 1 .. Name'Last), Name_Last, Error => Error); Unwind.Occurrences.Report (Cast (X), Name (1 .. Name_Last)); end Report; type Signal_Rec is record Installed_Handler : Parameterless_Handler; Saved : aliased C.signal.struct_sigaction; end record; pragma Suppress_Initialization (Signal_Rec); type Signal_Vec is array ( C.signed_int range Interrupt_Numbers.First_Interrupt_Id .. Interrupt_Numbers.Last_Interrupt_Id) of Signal_Rec; pragma Suppress_Initialization (Signal_Vec); Table : Signal_Vec; procedure Handler ( Signal_Number : C.signed_int; Info : access C.signal.siginfo_t; Context : C.void_ptr) with Convention => C; procedure Handler ( Signal_Number : C.signed_int; Info : access C.signal.siginfo_t; Context : C.void_ptr) is pragma Unreferenced (Info); pragma Unreferenced (Context); begin Table (Signal_Number).Installed_Handler.all; exception -- CXC3004, an exception propagated from a handler has no effect when E : others => Report (Interrupt_Id (Signal_Number), E); end Handler; -- implementation function Current_Handler (Interrupt : Interrupt_Id) return Parameterless_Handler is begin return Table (Interrupt).Installed_Handler; end Current_Handler; procedure Exchange_Handler ( Old_Handler : out Parameterless_Handler; New_Handler : Parameterless_Handler; Interrupt : Interrupt_Id) is Item : Signal_Rec renames Table (Interrupt); begin Old_Handler := Item.Installed_Handler; if Old_Handler = null and then New_Handler /= null then declare Action : aliased C.signal.struct_sigaction := ( (Unchecked_Tag => 1, sa_sigaction => Handler'Access), others => <>); -- uninitialized Dummy : C.signed_int; begin Action.sa_flags := C.signed_int ( C.unsigned_int'(C.signal.SA_SIGINFO or C.signal.SA_RESTART)); Dummy := C.signal.sigemptyset (Action.sa_mask'Access); if C.signal.sigaction ( Interrupt, Action'Access, Item.Saved'Access) < 0 then raise Program_Error; end if; end; elsif Old_Handler /= null and then New_Handler = null then if C.signal.sigaction (Interrupt, Item.Saved'Access, null) < 0 then raise Program_Error; end if; end if; Item.Installed_Handler := New_Handler; end Exchange_Handler; end System.Native_Interrupts.Vector;
reznikmm/matreshka
Ada
6,795
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. ------------------------------------------------------------------------------ -- An exception handler is an element that specifies a body to execute in -- case the specified exception occurs during the execution of the protected -- node. ------------------------------------------------------------------------------ limited with AMF.UML.Classifiers.Collections; with AMF.UML.Elements; limited with AMF.UML.Executable_Nodes; limited with AMF.UML.Object_Nodes; package AMF.UML.Exception_Handlers is pragma Preelaborate; type UML_Exception_Handler is limited interface and AMF.UML.Elements.UML_Element; type UML_Exception_Handler_Access is access all UML_Exception_Handler'Class; for UML_Exception_Handler_Access'Storage_Size use 0; not overriding function Get_Exception_Input (Self : not null access constant UML_Exception_Handler) return AMF.UML.Object_Nodes.UML_Object_Node_Access is abstract; -- Getter of ExceptionHandler::exceptionInput. -- -- An object node within the handler body. When the handler catches an -- exception, the exception token is placed in this node, causing the body -- to execute. not overriding procedure Set_Exception_Input (Self : not null access UML_Exception_Handler; To : AMF.UML.Object_Nodes.UML_Object_Node_Access) is abstract; -- Setter of ExceptionHandler::exceptionInput. -- -- An object node within the handler body. When the handler catches an -- exception, the exception token is placed in this node, causing the body -- to execute. not overriding function Get_Exception_Type (Self : not null access constant UML_Exception_Handler) return AMF.UML.Classifiers.Collections.Set_Of_UML_Classifier is abstract; -- Getter of ExceptionHandler::exceptionType. -- -- The kind of instances that the handler catches. If an exception occurs -- whose type is any of the classifiers in the set, the handler catches -- the exception and executes its body. not overriding function Get_Handler_Body (Self : not null access constant UML_Exception_Handler) return AMF.UML.Executable_Nodes.UML_Executable_Node_Access is abstract; -- Getter of ExceptionHandler::handlerBody. -- -- A node that is executed if the handler satisfies an uncaught exception. not overriding procedure Set_Handler_Body (Self : not null access UML_Exception_Handler; To : AMF.UML.Executable_Nodes.UML_Executable_Node_Access) is abstract; -- Setter of ExceptionHandler::handlerBody. -- -- A node that is executed if the handler satisfies an uncaught exception. not overriding function Get_Protected_Node (Self : not null access constant UML_Exception_Handler) return AMF.UML.Executable_Nodes.UML_Executable_Node_Access is abstract; -- Getter of ExceptionHandler::protectedNode. -- -- The node protected by the handler. The handler is examined if an -- exception propagates to the outside of the node. not overriding procedure Set_Protected_Node (Self : not null access UML_Exception_Handler; To : AMF.UML.Executable_Nodes.UML_Executable_Node_Access) is abstract; -- Setter of ExceptionHandler::protectedNode. -- -- The node protected by the handler. The handler is examined if an -- exception propagates to the outside of the node. end AMF.UML.Exception_Handlers;
reznikmm/matreshka
Ada
3,674
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Elements; package ODF.DOM.Text_User_Index_Elements is pragma Preelaborate; type ODF_Text_User_Index is limited interface and XML.DOM.Elements.DOM_Element; type ODF_Text_User_Index_Access is access all ODF_Text_User_Index'Class with Storage_Size => 0; end ODF.DOM.Text_User_Index_Elements;
reznikmm/matreshka
Ada
4,215
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with WSDL.AST.Components; package WSDL.AST.Types is pragma Preelaborate; type Types_Node is new WSDL.AST.Components.Component_Node with record null; end record; type Types_Access is access all Types_Node'Class; overriding procedure Enter (Self : not null access Types_Node; Visitor : in out WSDL.Visitors.WSDL_Visitor'Class; Control : in out WSDL.Iterators.Traverse_Control); overriding procedure Leave (Self : not null access Types_Node; Visitor : in out WSDL.Visitors.WSDL_Visitor'Class; Control : in out WSDL.Iterators.Traverse_Control); overriding procedure Visit (Self : not null access Types_Node; Iterator : in out WSDL.Iterators.WSDL_Iterator'Class; Visitor : in out WSDL.Visitors.WSDL_Visitor'Class; Control : in out WSDL.Iterators.Traverse_Control); end WSDL.AST.Types;
AdaCore/libadalang
Ada
192
adb
package body Foo is procedure Reset (A : out Array_Type) is pragma Test (Array_Type); begin for I in A'Range loop A (I) := 0; end loop; end Reset; end Foo;
stcarrez/ada-enet
Ada
2,340
ads
----------------------------------------------------------------------- -- demos -- Utility package for the demos -- Copyright (C) 2016, 2017 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Interfaces; with BMP_Fonts; with STM32.Board; with HAL.Bitmap; with Net; with Net.Buffers; with Net.Interfaces; with Net.Interfaces.STM32; with Net.DHCP; package Demos is use type Interfaces.Unsigned_32; -- Reserve 256 network buffers. NET_BUFFER_SIZE : constant Net.Uint32 := Net.Buffers.NET_ALLOC_SIZE * 256; -- The Ethernet interface driver. Ifnet : aliased Net.Interfaces.STM32.STM32_Ifnet; -- The DHCP client used by the demos. Dhcp : aliased Net.DHCP.Client; Current_Font : BMP_Fonts.BMP_Font := BMP_Fonts.Font12x12; Foreground : HAL.Bitmap.Bitmap_Color := HAL.Bitmap.White; Background : HAL.Bitmap.Bitmap_Color := HAL.Bitmap.Black; -- Write a message on the display. procedure Put (X : in Natural; Y : in Natural; Msg : in String); -- Write the 64-bit integer value on the display. procedure Put (X : in Natural; Y : in Natural; Value : in Net.Uint64); -- Refresh the ifnet statistics on the display. procedure Refresh_Ifnet_Stats; -- Initialize the board and the interface. generic with procedure Header; procedure Initialize (Title : in String); pragma Warnings (Off); -- Get the default font size according to the display size. function Default_Font return BMP_Fonts.BMP_Font is (if STM32.Board.LCD_Natural_Width > 480 then BMP_Fonts.Font12x12 else BMP_Fonts.Font8x8); end Demos;
io7m/coreland-c_string
Ada
1,367
adb
with Ada.Strings.Unbounded; with Ada.Text_IO; with C_String.Arrays; with Interfaces.C; with Test; procedure t_convert2 is package IO renames Ada.Text_IO; package UB_Strings renames Ada.Strings.Unbounded; package C renames Interfaces.C; use type C.unsigned; function ccall_input_term (Strings : in C_String.Arrays.Allocated_Pointer_Array_t) return C.unsigned; pragma Import (c, ccall_input_term, "ccall_input_term"); SA : constant C_String.Arrays.String_Array_t := (0 => UB_Strings.To_Unbounded_String ("string 0"), 1 => UB_Strings.To_Unbounded_String ("string 1"), 2 => UB_Strings.To_Unbounded_String ("string 2"), 3 => UB_Strings.To_Unbounded_String ("string 3"), 4 => UB_Strings.To_Unbounded_String ("string 4")); PA : C_String.Arrays.Allocated_Pointer_Array_t; begin IO.Put_Line ("-- Ada begin"); PA := C_String.Arrays.Convert_To_C_Terminated (SA); Test.Assert (ccall_input_term (PA) = 5); C_String.Arrays.Deallocate_Terminated (PA); PA := C_String.Arrays.Convert_To_C_Terminated (SA (2 .. 3)); Test.Assert (ccall_input_term (PA) = 2); C_String.Arrays.Deallocate_Terminated (PA); PA := C_String.Arrays.Convert_To_C_Terminated (SA (3 .. 4)); Test.Assert (ccall_input_term (PA) = 2); C_String.Arrays.Deallocate_Terminated (PA); IO.Put_Line ("-- Ada exit"); end t_convert2;
reznikmm/matreshka
Ada
3,957
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.Fo_Padding_Attributes; package Matreshka.ODF_Fo.Padding_Attributes is type Fo_Padding_Attribute_Node is new Matreshka.ODF_Fo.Abstract_Fo_Attribute_Node and ODF.DOM.Fo_Padding_Attributes.ODF_Fo_Padding_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Fo_Padding_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Fo_Padding_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Fo.Padding_Attributes;
shintakezou/langkit
Ada
753
adb
-- Check that the constant folding done on relations during the preparation -- for the solver work correctly on Any/All relations that contain a single -- sub-relation. with Langkit_Support.Adalog; use Langkit_Support.Adalog; with Langkit_Support.Adalog.Main_Support; use Langkit_Support.Adalog.Main_Support; procedure Main is use T_Solver; use Refs; X : constant Refs.Logic_Var := Create ("X"); Y : constant Refs.Logic_Var := Create ("Y"); Z : constant Refs.Logic_Var := Create ("X"); begin Cst_Folding_Trace.Set_Active (True); Solve_All (R_All ((R_Any ((1 => R_All ((X = 1, Y = 2)))), Z = 3))); Solve_All (R_Any ((R_All ((1 => R_Any ((X = 1, X = 2)))), X = 3))); end Main;
reznikmm/matreshka
Ada
3,669
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Svg_Y2_Attributes is pragma Preelaborate; type ODF_Svg_Y2_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Svg_Y2_Attribute_Access is access all ODF_Svg_Y2_Attribute'Class with Storage_Size => 0; end ODF.DOM.Svg_Y2_Attributes;
reznikmm/matreshka
Ada
4,042
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. ------------------------------------------------------------------------------ -- The most general class for UML diagram elements that are not rendered as -- lines. ------------------------------------------------------------------------------ with AMF.DI.Shapes; with AMF.UMLDI.UML_Diagram_Elements; package AMF.UMLDI.UML_Shapes is pragma Preelaborate; type UMLDI_UML_Shape is limited interface and AMF.UMLDI.UML_Diagram_Elements.UMLDI_UML_Diagram_Element and AMF.DI.Shapes.DI_Shape; type UMLDI_UML_Shape_Access is access all UMLDI_UML_Shape'Class; for UMLDI_UML_Shape_Access'Storage_Size use 0; end AMF.UMLDI.UML_Shapes;
zhmu/ananas
Ada
294
adb
package body Varsize_Return2_Pkg is function Len return Positive is begin return 4; end; package body G is function Get return Small_T is begin raise Program_Error; return Get; end; end G; end Varsize_Return2_Pkg;
io7m/coreland-plexlog-ada
Ada
2,219
adb
package body Plexlog.Dir_Stack is use type POSIX.FD_t; procedure Push_FD (Stack : in out Dir_Stack_t; FD : in Plexlog.POSIX.FD_t) is Current_FD : constant POSIX.FD_t := POSIX.Open_Read ("."); begin -- save current directory if Current_FD = POSIX.Invalid_FD then raise Push_Error with "could not open current working directory"; end if; -- push current file descriptor onto stack if Stack.Index = Stack.FD_Array'Length then raise Push_Error with "stack overflow"; end if; Stack.FD_Array (Stack.Index) := Current_FD; Stack.Index := Stack.Index + 1; -- switch to new directory if not POSIX.FD_Change_Directory (FD) then Stack.Index := Stack.Index - 1; raise Push_Error with "could not change directory"; end if; exception when others => POSIX.Close (Current_FD); raise; end Push_FD; procedure Push (Stack : in out Dir_Stack_t; Path : in String) is Path_FD : constant POSIX.FD_t := POSIX.Open_Read (Path); begin if Path_FD = POSIX.Invalid_FD then raise Push_Error with "could not open path"; end if; Push_FD (Stack, Path_FD); exception when others => POSIX.Close (Path_FD); raise; end Push; procedure Pop (Stack : in out Dir_Stack_t) is Old_FD : constant POSIX.FD_t := Stack.FD_Array (Stack.Index - 1); begin if not POSIX.FD_Change_Directory (Old_FD) then raise Pop_Error with "could not restore directory"; end if; Stack.FD_Array (Stack.Index) := POSIX.Invalid_FD; Stack.Index := Stack.Index - 1; if not POSIX.Close (Old_FD) then raise Pop_Error with "could not close old directory"; end if; end Pop; procedure Pop_All (Stack : in out Dir_Stack_t) is Saved_Index : constant FD_Array_Index_t := Stack.Index; begin if Stack.Index - FD_Array_Index_t'First > 0 then for Index in FD_Array_Index_t'First .. Saved_Index loop Pop (Stack); end loop; end if; end Pop_All; function Size (Stack : in Dir_Stack_t) return Natural is begin return Natural (Stack.Index - FD_Array_Index_t'First); end Size; end Plexlog.Dir_Stack;
reznikmm/matreshka
Ada
16,097
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2015, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ pragma Restrictions (No_Elaboration_Code); -- GNAT: enforce generation of preinitialized data section instead of -- generation of elaboration code. package Matreshka.Internals.Unicode.Ucd.Core_001B is pragma Preelaborate; Group_001B : aliased constant Core_Second_Stage := (16#00# .. 16#03# => -- 1B00 .. 1B03 (Nonspacing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Other_Alphabetic | Alphabetic | Case_Ignorable | Grapheme_Extend | ID_Continue | XID_Continue => True, others => False)), 16#04# => -- 1B04 (Spacing_Mark, Neutral, Spacing_Mark, Extend, Extend, Combining_Mark, (Other_Alphabetic | Alphabetic | Grapheme_Base | ID_Continue | XID_Continue => True, others => False)), 16#34# => -- 1B34 (Nonspacing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Diacritic | Case_Ignorable | Grapheme_Extend | ID_Continue | XID_Continue => True, others => False)), 16#35# => -- 1B35 (Spacing_Mark, Neutral, Spacing_Mark, Extend, Extend, Combining_Mark, (Other_Alphabetic | Alphabetic | Grapheme_Base | ID_Continue | XID_Continue => True, others => False)), 16#36# .. 16#3A# => -- 1B36 .. 1B3A (Nonspacing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Other_Alphabetic | Alphabetic | Case_Ignorable | Grapheme_Extend | ID_Continue | XID_Continue => True, others => False)), 16#3B# => -- 1B3B (Spacing_Mark, Neutral, Spacing_Mark, Extend, Extend, Combining_Mark, (Other_Alphabetic | Alphabetic | Grapheme_Base | ID_Continue | XID_Continue => True, others => False)), 16#3C# => -- 1B3C (Nonspacing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Other_Alphabetic | Alphabetic | Case_Ignorable | Grapheme_Extend | ID_Continue | XID_Continue => True, others => False)), 16#3D# .. 16#41# => -- 1B3D .. 1B41 (Spacing_Mark, Neutral, Spacing_Mark, Extend, Extend, Combining_Mark, (Other_Alphabetic | Alphabetic | Grapheme_Base | ID_Continue | XID_Continue => True, others => False)), 16#42# => -- 1B42 (Nonspacing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Other_Alphabetic | Alphabetic | Case_Ignorable | Grapheme_Extend | ID_Continue | XID_Continue => True, others => False)), 16#43# => -- 1B43 (Spacing_Mark, Neutral, Spacing_Mark, Extend, Extend, Combining_Mark, (Other_Alphabetic | Alphabetic | Grapheme_Base | ID_Continue | XID_Continue => True, others => False)), 16#44# => -- 1B44 (Spacing_Mark, Neutral, Spacing_Mark, Extend, Extend, Combining_Mark, (Diacritic | Grapheme_Base | Grapheme_Link | ID_Continue | XID_Continue => True, others => False)), 16#4C# .. 16#4F# => -- 1B4C .. 1B4F (Unassigned, Neutral, Other, Other, Other, Unknown, (others => False)), 16#50# .. 16#59# => -- 1B50 .. 1B59 (Decimal_Number, Neutral, Other, Numeric, Numeric, Numeric, (Grapheme_Base | ID_Continue | XID_Continue => True, others => False)), 16#5A# .. 16#5B# => -- 1B5A .. 1B5B (Other_Punctuation, Neutral, Other, Other, S_Term, Break_After, (STerm | Terminal_Punctuation | Grapheme_Base => True, others => False)), 16#5C# => -- 1B5C (Other_Punctuation, Neutral, Other, Other, Other, Alphabetic, (Grapheme_Base => True, others => False)), 16#5D# => -- 1B5D (Other_Punctuation, Neutral, Other, Other, Other, Break_After, (Terminal_Punctuation | Grapheme_Base => True, others => False)), 16#5E# .. 16#5F# => -- 1B5E .. 1B5F (Other_Punctuation, Neutral, Other, Other, S_Term, Break_After, (STerm | Terminal_Punctuation | Grapheme_Base => True, others => False)), 16#60# => -- 1B60 (Other_Punctuation, Neutral, Other, Other, Other, Break_After, (Grapheme_Base => True, others => False)), 16#61# .. 16#6A# => -- 1B61 .. 1B6A (Other_Symbol, Neutral, Other, Other, Other, Alphabetic, (Grapheme_Base => True, others => False)), 16#6B# .. 16#73# => -- 1B6B .. 1B73 (Nonspacing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Diacritic | Case_Ignorable | Grapheme_Extend | ID_Continue | XID_Continue => True, others => False)), 16#74# .. 16#7C# => -- 1B74 .. 1B7C (Other_Symbol, Neutral, Other, Other, Other, Alphabetic, (Grapheme_Base => True, others => False)), 16#7D# .. 16#7F# => -- 1B7D .. 1B7F (Unassigned, Neutral, Other, Other, Other, Unknown, (others => False)), 16#80# .. 16#81# => -- 1B80 .. 1B81 (Nonspacing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Other_Alphabetic | Alphabetic | Case_Ignorable | Grapheme_Extend | ID_Continue | XID_Continue => True, others => False)), 16#82# => -- 1B82 (Spacing_Mark, Neutral, Spacing_Mark, Extend, Extend, Combining_Mark, (Other_Alphabetic | Alphabetic | Grapheme_Base | ID_Continue | XID_Continue => True, others => False)), 16#A1# => -- 1BA1 (Spacing_Mark, Neutral, Spacing_Mark, Extend, Extend, Combining_Mark, (Other_Alphabetic | Alphabetic | Grapheme_Base | ID_Continue | XID_Continue => True, others => False)), 16#A2# .. 16#A5# => -- 1BA2 .. 1BA5 (Nonspacing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Other_Alphabetic | Alphabetic | Case_Ignorable | Grapheme_Extend | ID_Continue | XID_Continue => True, others => False)), 16#A6# .. 16#A7# => -- 1BA6 .. 1BA7 (Spacing_Mark, Neutral, Spacing_Mark, Extend, Extend, Combining_Mark, (Other_Alphabetic | Alphabetic | Grapheme_Base | ID_Continue | XID_Continue => True, others => False)), 16#A8# .. 16#A9# => -- 1BA8 .. 1BA9 (Nonspacing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Other_Alphabetic | Alphabetic | Case_Ignorable | Grapheme_Extend | ID_Continue | XID_Continue => True, others => False)), 16#AA# => -- 1BAA (Spacing_Mark, Neutral, Spacing_Mark, Extend, Extend, Combining_Mark, (Diacritic | Grapheme_Base | Grapheme_Link | ID_Continue | XID_Continue => True, others => False)), 16#AB# => -- 1BAB (Nonspacing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Diacritic | Case_Ignorable | Grapheme_Extend | Grapheme_Link | ID_Continue | XID_Continue => True, others => False)), 16#AC# .. 16#AD# => -- 1BAC .. 1BAD (Nonspacing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Other_Alphabetic | Alphabetic | Case_Ignorable | Grapheme_Extend | ID_Continue | XID_Continue => True, others => False)), 16#B0# .. 16#B9# => -- 1BB0 .. 1BB9 (Decimal_Number, Neutral, Other, Numeric, Numeric, Numeric, (Grapheme_Base | ID_Continue | XID_Continue => True, others => False)), 16#E6# => -- 1BE6 (Nonspacing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Case_Ignorable | Grapheme_Extend | ID_Continue | XID_Continue => True, others => False)), 16#E7# => -- 1BE7 (Spacing_Mark, Neutral, Spacing_Mark, Extend, Extend, Combining_Mark, (Other_Alphabetic | Alphabetic | Grapheme_Base | ID_Continue | XID_Continue => True, others => False)), 16#E8# .. 16#E9# => -- 1BE8 .. 1BE9 (Nonspacing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Other_Alphabetic | Alphabetic | Case_Ignorable | Grapheme_Extend | ID_Continue | XID_Continue => True, others => False)), 16#EA# .. 16#EC# => -- 1BEA .. 1BEC (Spacing_Mark, Neutral, Spacing_Mark, Extend, Extend, Combining_Mark, (Other_Alphabetic | Alphabetic | Grapheme_Base | ID_Continue | XID_Continue => True, others => False)), 16#ED# => -- 1BED (Nonspacing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Other_Alphabetic | Alphabetic | Case_Ignorable | Grapheme_Extend | ID_Continue | XID_Continue => True, others => False)), 16#EE# => -- 1BEE (Spacing_Mark, Neutral, Spacing_Mark, Extend, Extend, Combining_Mark, (Other_Alphabetic | Alphabetic | Grapheme_Base | ID_Continue | XID_Continue => True, others => False)), 16#EF# .. 16#F1# => -- 1BEF .. 1BF1 (Nonspacing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Other_Alphabetic | Alphabetic | Case_Ignorable | Grapheme_Extend | ID_Continue | XID_Continue => True, others => False)), 16#F2# .. 16#F3# => -- 1BF2 .. 1BF3 (Spacing_Mark, Neutral, Spacing_Mark, Extend, Extend, Combining_Mark, (Grapheme_Base | Grapheme_Link | ID_Continue | XID_Continue => True, others => False)), 16#F4# .. 16#FB# => -- 1BF4 .. 1BFB (Unassigned, Neutral, Other, Other, Other, Unknown, (others => False)), 16#FC# .. 16#FF# => -- 1BFC .. 1BFF (Other_Punctuation, Neutral, Other, Other, Other, Alphabetic, (Grapheme_Base => True, others => False)), others => (Other_Letter, Neutral, Other, A_Letter, O_Letter, Alphabetic, (Alphabetic | Grapheme_Base | ID_Continue | ID_Start | XID_Continue | XID_Start => True, others => False))); end Matreshka.Internals.Unicode.Ucd.Core_001B;
Kidev/Ada_Drivers_Library
Ada
912
ads
-- This package was generated by the Ada_Drivers_Library project wizard script package ADL_Config is Max_Mount_Points : constant := 2; -- From default value Max_Mount_Name_Length : constant := 128; -- From default value Has_Ravenscar_Full_Runtime : constant String := "False"; -- From default value Board : constant String := "Native"; -- From command line Has_ZFP_Runtime : constant String := "False"; -- From default value Has_Ravenscar_SFP_Runtime : constant String := "False"; -- From default value Max_Path_Length : constant := 1024; -- From default value Architecture : constant String := "Native"; -- From board definition end ADL_Config;
MinimSecure/unum-sdk
Ada
1,003
adb
-- Copyright 2015-2016 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. package body Bar is procedure Do_Nothing (C : Character) is begin null; end Do_Nothing; function Get_Str (S1 : String; S2 : String := "") return Object_Type is begin return (Ada.Finalization.Controlled with Value => True); end Get_Str; end Bar;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
12,553
ads
pragma Style_Checks (Off); -- This spec has been automatically generated from STM32L0x3.svd pragma Restrictions (No_Elaboration_Code); with System; package STM32_SVD.DAC is pragma Preelaborate; --------------- -- Registers -- --------------- subtype CR_EN1_Field is STM32_SVD.Bit; subtype CR_BOFF1_Field is STM32_SVD.Bit; subtype CR_TEN1_Field is STM32_SVD.Bit; subtype CR_TSEL1_Field is STM32_SVD.UInt3; subtype CR_WAVE1_Field is STM32_SVD.UInt2; subtype CR_MAMP1_Field is STM32_SVD.UInt4; subtype CR_DMAEN1_Field is STM32_SVD.Bit; subtype CR_DMAUDRIE1_Field is STM32_SVD.Bit; -- control register type CR_Register is record -- DAC channel1 enable EN1 : CR_EN1_Field := 16#0#; -- DAC channel1 output buffer disable BOFF1 : CR_BOFF1_Field := 16#0#; -- DAC channel1 trigger enable TEN1 : CR_TEN1_Field := 16#0#; -- DAC channel1 trigger selection TSEL1 : CR_TSEL1_Field := 16#0#; -- DAC channel1 noise/triangle wave generation enable WAVE1 : CR_WAVE1_Field := 16#0#; -- DAC channel1 mask/amplitude selector MAMP1 : CR_MAMP1_Field := 16#0#; -- DAC channel1 DMA enable DMAEN1 : CR_DMAEN1_Field := 16#0#; -- DAC channel1 DMA Underrun Interrupt enable DMAUDRIE1 : CR_DMAUDRIE1_Field := 16#0#; -- unspecified Reserved_14_31 : STM32_SVD.UInt18 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record EN1 at 0 range 0 .. 0; BOFF1 at 0 range 1 .. 1; TEN1 at 0 range 2 .. 2; TSEL1 at 0 range 3 .. 5; WAVE1 at 0 range 6 .. 7; MAMP1 at 0 range 8 .. 11; DMAEN1 at 0 range 12 .. 12; DMAUDRIE1 at 0 range 13 .. 13; Reserved_14_31 at 0 range 14 .. 31; end record; subtype SWTRIGR_SWTRIG1_Field is STM32_SVD.Bit; -- software trigger register type SWTRIGR_Register is record -- Write-only. DAC channel1 software trigger SWTRIG1 : SWTRIGR_SWTRIG1_Field := 16#0#; -- unspecified Reserved_1_31 : STM32_SVD.UInt31 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SWTRIGR_Register use record SWTRIG1 at 0 range 0 .. 0; Reserved_1_31 at 0 range 1 .. 31; end record; subtype DHR12R1_DACC1DHR_Field is STM32_SVD.UInt12; -- channel1 12-bit right-aligned data holding register type DHR12R1_Register is record -- DAC channel1 12-bit right-aligned data DACC1DHR : DHR12R1_DACC1DHR_Field := 16#0#; -- unspecified Reserved_12_31 : STM32_SVD.UInt20 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DHR12R1_Register use record DACC1DHR at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; subtype DHR12L1_DACC1DHR_Field is STM32_SVD.UInt12; -- channel1 12-bit left-aligned data holding register type DHR12L1_Register is record -- unspecified Reserved_0_3 : STM32_SVD.UInt4 := 16#0#; -- DAC channel1 12-bit left-aligned data DACC1DHR : DHR12L1_DACC1DHR_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DHR12L1_Register use record Reserved_0_3 at 0 range 0 .. 3; DACC1DHR at 0 range 4 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype DHR8R1_DACC1DHR_Field is STM32_SVD.Byte; -- channel1 8-bit right-aligned data holding register type DHR8R1_Register is record -- DAC channel1 8-bit right-aligned data DACC1DHR : DHR8R1_DACC1DHR_Field := 16#0#; -- unspecified Reserved_8_31 : STM32_SVD.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DHR8R1_Register use record DACC1DHR at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype DHR12R2_DACC2DHR_Field is STM32_SVD.UInt12; -- channel2 12-bit right-aligned data holding register type DHR12R2_Register is record -- DAC channel2 12-bit right-aligned data DACC2DHR : DHR12R2_DACC2DHR_Field := 16#0#; -- unspecified Reserved_12_31 : STM32_SVD.UInt20 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DHR12R2_Register use record DACC2DHR at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; subtype DHR12L2_DACC2DHR_Field is STM32_SVD.UInt12; -- channel2 12-bit left-aligned data holding register type DHR12L2_Register is record -- unspecified Reserved_0_3 : STM32_SVD.UInt4 := 16#0#; -- DAC channel2 12-bit left-aligned data DACC2DHR : DHR12L2_DACC2DHR_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DHR12L2_Register use record Reserved_0_3 at 0 range 0 .. 3; DACC2DHR at 0 range 4 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype DHR8R2_DACC2DHR_Field is STM32_SVD.Byte; -- channel2 8-bit right-aligned data holding register type DHR8R2_Register is record -- DAC channel2 8-bit right-aligned data DACC2DHR : DHR8R2_DACC2DHR_Field := 16#0#; -- unspecified Reserved_8_31 : STM32_SVD.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DHR8R2_Register use record DACC2DHR at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype DHR12RD_DACC1DHR_Field is STM32_SVD.UInt12; subtype DHR12RD_DACC2DHR_Field is STM32_SVD.UInt12; -- Dual DAC 12-bit right-aligned data holding register type DHR12RD_Register is record -- DAC channel1 12-bit right-aligned data DACC1DHR : DHR12RD_DACC1DHR_Field := 16#0#; -- unspecified Reserved_12_15 : STM32_SVD.UInt4 := 16#0#; -- DAC channel2 12-bit right-aligned data DACC2DHR : DHR12RD_DACC2DHR_Field := 16#0#; -- unspecified Reserved_28_31 : STM32_SVD.UInt4 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DHR12RD_Register use record DACC1DHR at 0 range 0 .. 11; Reserved_12_15 at 0 range 12 .. 15; DACC2DHR at 0 range 16 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; subtype DHR12LD_DACC1DHR_Field is STM32_SVD.UInt12; subtype DHR12LD_DACC2DHR_Field is STM32_SVD.UInt12; -- Dual DAC 12-bit left-aligned data holding register type DHR12LD_Register is record -- unspecified Reserved_0_3 : STM32_SVD.UInt4 := 16#0#; -- DAC channel1 12-bit left-aligned data DACC1DHR : DHR12LD_DACC1DHR_Field := 16#0#; -- unspecified Reserved_16_19 : STM32_SVD.UInt4 := 16#0#; -- DAC channel2 12-bit left-aligned data DACC2DHR : DHR12LD_DACC2DHR_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DHR12LD_Register use record Reserved_0_3 at 0 range 0 .. 3; DACC1DHR at 0 range 4 .. 15; Reserved_16_19 at 0 range 16 .. 19; DACC2DHR at 0 range 20 .. 31; end record; subtype DHR8RD_DACC1DHR_Field is STM32_SVD.Byte; subtype DHR8RD_DACC2DHR_Field is STM32_SVD.Byte; -- Dual DAC 8-bit right-aligned data holding register type DHR8RD_Register is record -- DAC channel1 8-bit right-aligned data DACC1DHR : DHR8RD_DACC1DHR_Field := 16#0#; -- DAC channel2 8-bit right-aligned data DACC2DHR : DHR8RD_DACC2DHR_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DHR8RD_Register use record DACC1DHR at 0 range 0 .. 7; DACC2DHR at 0 range 8 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype DOR1_DACC1DOR_Field is STM32_SVD.UInt12; -- channel1 data output register type DOR1_Register is record -- Read-only. DAC channel1 data output DACC1DOR : DOR1_DACC1DOR_Field; -- unspecified Reserved_12_31 : STM32_SVD.UInt20; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DOR1_Register use record DACC1DOR at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; subtype DOR2_DACC2DOR_Field is STM32_SVD.UInt12; -- channel2 data output register type DOR2_Register is record -- Read-only. DAC channel2 data output DACC2DOR : DOR2_DACC2DOR_Field; -- unspecified Reserved_12_31 : STM32_SVD.UInt20; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DOR2_Register use record DACC2DOR at 0 range 0 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; subtype SR_DMAUDR1_Field is STM32_SVD.Bit; -- status register type SR_Register is record -- unspecified Reserved_0_12 : STM32_SVD.UInt13 := 16#0#; -- DAC channel1 DMA underrun flag DMAUDR1 : SR_DMAUDR1_Field := 16#0#; -- unspecified Reserved_14_31 : STM32_SVD.UInt18 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SR_Register use record Reserved_0_12 at 0 range 0 .. 12; DMAUDR1 at 0 range 13 .. 13; Reserved_14_31 at 0 range 14 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Digital-to-analog converter type DAC_Peripheral is record -- control register CR : aliased CR_Register; -- software trigger register SWTRIGR : aliased SWTRIGR_Register; -- channel1 12-bit right-aligned data holding register DHR12R1 : aliased DHR12R1_Register; -- channel1 12-bit left-aligned data holding register DHR12L1 : aliased DHR12L1_Register; -- channel1 8-bit right-aligned data holding register DHR8R1 : aliased DHR8R1_Register; -- channel2 12-bit right-aligned data holding register DHR12R2 : aliased DHR12R2_Register; -- channel2 12-bit left-aligned data holding register DHR12L2 : aliased DHR12L2_Register; -- channel2 8-bit right-aligned data holding register DHR8R2 : aliased DHR8R2_Register; -- Dual DAC 12-bit right-aligned data holding register DHR12RD : aliased DHR12RD_Register; -- Dual DAC 12-bit left-aligned data holding register DHR12LD : aliased DHR12LD_Register; -- Dual DAC 8-bit right-aligned data holding register DHR8RD : aliased DHR8RD_Register; -- channel1 data output register DOR1 : aliased DOR1_Register; -- channel2 data output register DOR2 : aliased DOR2_Register; -- status register SR : aliased SR_Register; end record with Volatile; for DAC_Peripheral use record CR at 16#0# range 0 .. 31; SWTRIGR at 16#4# range 0 .. 31; DHR12R1 at 16#8# range 0 .. 31; DHR12L1 at 16#C# range 0 .. 31; DHR8R1 at 16#10# range 0 .. 31; DHR12R2 at 16#14# range 0 .. 31; DHR12L2 at 16#18# range 0 .. 31; DHR8R2 at 16#1C# range 0 .. 31; DHR12RD at 16#20# range 0 .. 31; DHR12LD at 16#24# range 0 .. 31; DHR8RD at 16#28# range 0 .. 31; DOR1 at 16#2C# range 0 .. 31; DOR2 at 16#30# range 0 .. 31; SR at 16#34# range 0 .. 31; end record; -- Digital-to-analog converter DAC_Periph : aliased DAC_Peripheral with Import, Address => DAC_Base; end STM32_SVD.DAC;
pchapin/augusta
Ada
153
adb
-- A silly program to just exercise some computations. -- procedure Hello is X : Integer; Y : Integer := 5; begin X := -Y + X; Y := -X * Y; end;
riccardo-bernardini/eugen
Ada
2,765
ads
with Ada.Containers.Indefinite_Doubly_Linked_Lists; with GNAT.Regpat; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; generic type Classified_Line (<>) is private ; package Line_Arrays.Regexp_Classifiers is type Callback_Type is access function (Item : String; Matches : Gnat.Regpat.Match_Array) return Classified_Line; type Regexp_Pair is private; function Is_Default (X : Regexp_Pair) return Boolean; function P (Regexp : String; Callback : Callback_Type) return Regexp_Pair with Pre => Regexp /= "", Post => not Is_Default (P'Result); function "+" (Callback : Callback_Type) return Regexp_Pair with Post => Is_Default ("+"'Result); type Regexp_Array is array (Positive range <>) of Regexp_Pair; type Classifier_Type (<>) is tagged private; function Create (Regexps : Regexp_Array) return Classifier_Type with Pre => (for all I in Regexps'Range => (for all J in I + 1 .. Regexps'Last => (not (Is_Default (Regexps (I)) and Is_Default (Regexps (J)))) ) ); -- The precondition expressed in plain English requires that at most -- one entry of Regexps must be a default expression function Classify (Classifier : Classifier_Type; Line : String) return Classified_Line; Double_Default : exception; private type Regexp_Pair is record Regexp : Unbounded_String; Callback : Callback_Type; end record; function Is_Default (X : Regexp_Pair) return Boolean is (X.Regexp = Null_Unbounded_String); function P (Regexp : String; Callback : Callback_Type) return Regexp_Pair is (Regexp_Pair'(To_Unbounded_String(Regexp), Callback)); function "+" (Callback : Callback_Type) return Regexp_Pair is (Regexp_Pair'(Null_Unbounded_String, Callback)); type Regexp_Descriptor (Size : Gnat.Regpat.Program_Size) is record Matcher : GNAT.Regpat.Pattern_Matcher (Size); Callback : Callback_Type; end record; package Descriptor_Lists is new Ada.Containers.Indefinite_Doubly_Linked_Lists (Regexp_Descriptor); procedure Add (To : in out Classifier_Type; Regexp : String; Callback : Callback_Type); procedure Add_Default (To : in out Classifier_Type; Callback : Callback_Type); type Classifier_Type is tagged record Exprs : Descriptor_Lists.List := Descriptor_Lists.Empty_List; Default : Callback_Type := null; end record; end Line_Arrays.Regexp_Classifiers;
tum-ei-rcs/StratoX
Ada
2,774
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . T A S K I N G . P R O T E C T E D _ O B J E C T S . -- -- M U L T I P R O C E S S O R S -- -- S p e c -- -- -- -- Copyright (C) 2010, 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/>. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ package System.Tasking.Protected_Objects.Multiprocessors with SPARK_Mode => On is procedure Served (Entry_Call : Entry_Call_Link); -- Signal the served Entry_Call to the caller CPU procedure Wakeup_Served_Entry; -- Wake up all tasks corresponding to the Entry_Call calls in the -- Pending_Entry_Call list (for the current CPU). end System.Tasking.Protected_Objects.Multiprocessors;
ph0sph8/amass
Ada
1,436
ads
-- Copyright 2017 Jeff Foley. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. local json = require("json") name = "Spyse" type = "api" function start() setratelimit(2) end function vertical(ctx, domain) if (api == nil or api.key == "") then return end local resp local vurl = buildurl(domain) -- Check if the response data is in the graph database if (api.ttl ~= nil and api.ttl > 0) then resp = obtain_response(vurl, api.ttl) end if (resp == nil or resp == "") then local err resp, err = request({ url=vurl, headers={['Authorization']="Bearer " .. api.key}, }) if (err ~= nil and err ~= "") then return end if (api.ttl ~= nil and api.ttl > 0) then cache_response(vurl, resp) end end local d = json.decode(resp) if (d == nil or #(d['data'].items) == 0) then return end for i, item in pairs(d['data'].items) do sendnames(ctx, item.name) end end function buildurl(domain) return "https://api.spyse.com/v3/data/domain/subdomain?limit=100&domain=" .. domain end function sendnames(ctx, content) local names = find(content, subdomainre) if names == nil then return end for i, v in pairs(names) do newname(ctx, v) end end
zhmu/ananas
Ada
269
adb
package body Aggr24_Pkg is procedure Init (R : out Rec) is begin R := (I1 => 0, I2 => 0, I3 => 0, I4 => 0, I5 => 0, I6 => 0, I7 => 0, S => <>); end; end Aggr24_Pkg;
zhmu/ananas
Ada
174,713
adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S E M _ C H 5 -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ with Aspects; use Aspects; with Atree; use Atree; with Checks; use Checks; with Debug; use Debug; with Einfo; use Einfo; with Einfo.Entities; use Einfo.Entities; with Einfo.Utils; use Einfo.Utils; with Errout; use Errout; with Expander; use Expander; with Exp_Ch6; use Exp_Ch6; with Exp_Tss; use Exp_Tss; with Exp_Util; use Exp_Util; with Freeze; use Freeze; with Ghost; use Ghost; with Lib; use Lib; with Lib.Xref; use Lib.Xref; with Namet; use Namet; with Nlists; use Nlists; with Nmake; use Nmake; with Opt; use Opt; with Sem; use Sem; with Sem_Aux; use Sem_Aux; with Sem_Case; use Sem_Case; with Sem_Ch3; use Sem_Ch3; with Sem_Ch6; use Sem_Ch6; with Sem_Ch8; use Sem_Ch8; with Sem_Dim; use Sem_Dim; with Sem_Disp; use Sem_Disp; with Sem_Elab; use Sem_Elab; with Sem_Eval; use Sem_Eval; with Sem_Res; use Sem_Res; with Sem_Type; use Sem_Type; with Sem_Util; use Sem_Util; with Sem_Warn; use Sem_Warn; with Snames; use Snames; with Stand; use Stand; with Sinfo; use Sinfo; with Sinfo.Nodes; use Sinfo.Nodes; with Sinfo.Utils; use Sinfo.Utils; with Targparm; use Targparm; with Tbuild; use Tbuild; with Ttypes; use Ttypes; with Uintp; use Uintp; package body Sem_Ch5 is Current_Assignment : Node_Id := Empty; -- This variable holds the node for an assignment that contains target -- names. The corresponding flag has been set by the parser, and when -- set the analysis of the RHS must be done with all expansion disabled, -- because the assignment is reanalyzed after expansion has replaced all -- occurrences of the target name appropriately. Unblocked_Exit_Count : Nat := 0; -- This variable is used when processing if statements, case statements, -- and block statements. It counts the number of exit points that are not -- blocked by unconditional transfer instructions: for IF and CASE, these -- are the branches of the conditional; for a block, they are the statement -- sequence of the block, and the statement sequences of any exception -- handlers that are part of the block. When processing is complete, if -- this count is zero, it means that control cannot fall through the IF, -- CASE or block statement. This is used for the generation of warning -- messages. This variable is recursively saved on entry to processing the -- construct, and restored on exit. function Has_Sec_Stack_Call (N : Node_Id) return Boolean; -- N is the node for an arbitrary construct. This function searches the -- construct N to see if any expressions within it contain function -- calls that use the secondary stack, returning True if any such call -- is found, and False otherwise. procedure Preanalyze_Range (R_Copy : Node_Id); -- Determine expected type of range or domain of iteration of Ada 2012 -- loop by analyzing separate copy. Do the analysis and resolution of the -- copy of the bound(s) with expansion disabled, to prevent the generation -- of finalization actions. This prevents memory leaks when the bounds -- contain calls to functions returning controlled arrays or when the -- domain of iteration is a container. ------------------------ -- Analyze_Assignment -- ------------------------ -- WARNING: This routine manages Ghost regions. Return statements must be -- replaced by gotos which jump to the end of the routine and restore the -- Ghost mode. procedure Analyze_Assignment (N : Node_Id) is Lhs : constant Node_Id := Name (N); Rhs : Node_Id := Expression (N); procedure Diagnose_Non_Variable_Lhs (N : Node_Id); -- N is the node for the left hand side of an assignment, and it is not -- a variable. This routine issues an appropriate diagnostic. function Is_Protected_Part_Of_Constituent (Nod : Node_Id) return Boolean; -- Determine whether arbitrary node Nod denotes a Part_Of constituent of -- a single protected type. procedure Kill_Lhs; -- This is called to kill current value settings of a simple variable -- on the left hand side. We call it if we find any error in analyzing -- the assignment, and at the end of processing before setting any new -- current values in place. procedure Set_Assignment_Type (Opnd : Node_Id; Opnd_Type : in out Entity_Id); -- Opnd is either the Lhs or Rhs of the assignment, and Opnd_Type is the -- nominal subtype. This procedure is used to deal with cases where the -- nominal subtype must be replaced by the actual subtype. procedure Transform_BIP_Assignment (Typ : Entity_Id); function Should_Transform_BIP_Assignment (Typ : Entity_Id) return Boolean; -- If the right-hand side of an assignment statement is a build-in-place -- call we cannot build in place, so we insert a temp initialized with -- the call, and transform the assignment statement to copy the temp. -- Transform_BIP_Assignment does the transformation, and -- Should_Transform_BIP_Assignment determines whether we should. -- The same goes for qualified expressions and conversions whose -- operand is such a call. -- -- This is only for nonlimited types; assignment statements are illegal -- for limited types, but are generated internally for aggregates and -- init procs. These limited-type are not really assignment statements -- -- conceptually, they are initializations, so should not be -- transformed. -- -- Similarly, for nonlimited types, aggregates and init procs generate -- assignment statements that are really initializations. These are -- marked No_Ctrl_Actions. function Within_Function return Boolean; -- Determine whether the current scope is a function or appears within -- one. ------------------------------- -- Diagnose_Non_Variable_Lhs -- ------------------------------- procedure Diagnose_Non_Variable_Lhs (N : Node_Id) is begin -- Not worth posting another error if left hand side already flagged -- as being illegal in some respect. if Error_Posted (N) then return; -- Some special bad cases of entity names elsif Is_Entity_Name (N) then declare Ent : constant Entity_Id := Entity (N); begin if Ekind (Ent) = E_Loop_Parameter or else Is_Loop_Parameter (Ent) then Error_Msg_N ("assignment to loop parameter not allowed", N); return; elsif Ekind (Ent) = E_In_Parameter then Error_Msg_N ("assignment to IN mode parameter not allowed", N); return; -- Renamings of protected private components are turned into -- constants when compiling a protected function. In the case -- of single protected types, the private component appears -- directly. elsif (Is_Prival (Ent) and then Within_Function) or else Is_Protected_Component (Ent) then Error_Msg_N ("protected function cannot modify its protected object", N); return; end if; end; -- For indexed components, test prefix if it is in array. We do not -- want to recurse for cases where the prefix is a pointer, since we -- may get a message confusing the pointer and what it references. elsif Nkind (N) = N_Indexed_Component and then Is_Array_Type (Etype (Prefix (N))) then Diagnose_Non_Variable_Lhs (Prefix (N)); return; -- Another special case for assignment to discriminant elsif Nkind (N) = N_Selected_Component then if Present (Entity (Selector_Name (N))) and then Ekind (Entity (Selector_Name (N))) = E_Discriminant then Error_Msg_N ("assignment to discriminant not allowed", N); return; -- For selection from record, diagnose prefix, but note that again -- we only do this for a record, not e.g. for a pointer. elsif Is_Record_Type (Etype (Prefix (N))) then Diagnose_Non_Variable_Lhs (Prefix (N)); return; end if; end if; -- If we fall through, we have no special message to issue Error_Msg_N ("left hand side of assignment must be a variable", N); end Diagnose_Non_Variable_Lhs; -------------------------------------- -- Is_Protected_Part_Of_Constituent -- -------------------------------------- function Is_Protected_Part_Of_Constituent (Nod : Node_Id) return Boolean is Encap_Id : Entity_Id; Var_Id : Entity_Id; begin -- Abstract states and variables may act as Part_Of constituents of -- single protected types, however only variables can be modified by -- an assignment. if Is_Entity_Name (Nod) then Var_Id := Entity (Nod); if Present (Var_Id) and then Ekind (Var_Id) = E_Variable then Encap_Id := Encapsulating_State (Var_Id); -- To qualify, the node must denote a reference to a variable -- whose encapsulating state is a single protected object. return Present (Encap_Id) and then Is_Single_Protected_Object (Encap_Id); end if; end if; return False; end Is_Protected_Part_Of_Constituent; -------------- -- Kill_Lhs -- -------------- procedure Kill_Lhs is begin if Is_Entity_Name (Lhs) then declare Ent : constant Entity_Id := Entity (Lhs); begin if Present (Ent) then Kill_Current_Values (Ent); end if; end; end if; end Kill_Lhs; ------------------------- -- Set_Assignment_Type -- ------------------------- procedure Set_Assignment_Type (Opnd : Node_Id; Opnd_Type : in out Entity_Id) is Decl : Node_Id; begin Require_Entity (Opnd); -- If the assignment operand is an in-out or out parameter, then we -- get the actual subtype (needed for the unconstrained case). If the -- operand is the actual in an entry declaration, then within the -- accept statement it is replaced with a local renaming, which may -- also have an actual subtype. if Is_Entity_Name (Opnd) and then (Ekind (Entity (Opnd)) in E_Out_Parameter | E_In_Out_Parameter | E_Generic_In_Out_Parameter or else (Ekind (Entity (Opnd)) = E_Variable and then Nkind (Parent (Entity (Opnd))) = N_Object_Renaming_Declaration and then Nkind (Parent (Parent (Entity (Opnd)))) = N_Accept_Statement)) then Opnd_Type := Get_Actual_Subtype (Opnd); -- If assignment operand is a component reference, then we get the -- actual subtype of the component for the unconstrained case. elsif Nkind (Opnd) in N_Selected_Component | N_Explicit_Dereference and then not Is_Unchecked_Union (Opnd_Type) then Decl := Build_Actual_Subtype_Of_Component (Opnd_Type, Opnd); if Present (Decl) then Insert_Action (N, Decl); Mark_Rewrite_Insertion (Decl); Analyze (Decl); Opnd_Type := Defining_Identifier (Decl); Set_Etype (Opnd, Opnd_Type); Freeze_Itype (Opnd_Type, N); elsif Is_Constrained (Etype (Opnd)) then Opnd_Type := Etype (Opnd); end if; -- For slice, use the constrained subtype created for the slice elsif Nkind (Opnd) = N_Slice then Opnd_Type := Etype (Opnd); end if; end Set_Assignment_Type; ------------------------------------- -- Should_Transform_BIP_Assignment -- ------------------------------------- function Should_Transform_BIP_Assignment (Typ : Entity_Id) return Boolean is begin if Expander_Active and then not Is_Limited_View (Typ) and then Is_Build_In_Place_Result_Type (Typ) and then not No_Ctrl_Actions (N) then -- This function is called early, before name resolution is -- complete, so we have to deal with things that might turn into -- function calls later. N_Function_Call and N_Op nodes are the -- obvious case. An N_Identifier or N_Expanded_Name is a -- parameterless function call if it denotes a function. -- Finally, an attribute reference can be a function call. declare Unqual_Rhs : constant Node_Id := Unqual_Conv (Rhs); begin case Nkind (Unqual_Rhs) is when N_Function_Call | N_Op => return True; when N_Expanded_Name | N_Identifier => return Ekind (Entity (Unqual_Rhs)) in E_Function | E_Operator; -- T'Input will turn into a call whose result type is T when N_Attribute_Reference => return Attribute_Name (Unqual_Rhs) = Name_Input; when others => return False; end case; end; else return False; end if; end Should_Transform_BIP_Assignment; ------------------------------ -- Transform_BIP_Assignment -- ------------------------------ procedure Transform_BIP_Assignment (Typ : Entity_Id) is -- Tranform "X : [constant] T := F (...);" into: -- -- Temp : constant T := F (...); -- X := Temp; Loc : constant Source_Ptr := Sloc (N); Def_Id : constant Entity_Id := Make_Temporary (Loc, 'Y', Rhs); Obj_Decl : constant Node_Id := Make_Object_Declaration (Loc, Defining_Identifier => Def_Id, Constant_Present => True, Object_Definition => New_Occurrence_Of (Typ, Loc), Expression => Rhs, Has_Init_Expression => True); begin Set_Etype (Def_Id, Typ); Set_Expression (N, New_Occurrence_Of (Def_Id, Loc)); -- At this point, Rhs is no longer equal to Expression (N), so: Rhs := Expression (N); Insert_Action (N, Obj_Decl); end Transform_BIP_Assignment; --------------------- -- Within_Function -- --------------------- function Within_Function return Boolean is Scop_Id : constant Entity_Id := Current_Scope; begin if Ekind (Scop_Id) = E_Function then return True; elsif Ekind (Enclosing_Dynamic_Scope (Scop_Id)) = E_Function then return True; end if; return False; end Within_Function; -- Local variables Saved_GM : constant Ghost_Mode_Type := Ghost_Mode; Saved_IGR : constant Node_Id := Ignored_Ghost_Region; -- Save the Ghost-related attributes to restore on exit T1 : Entity_Id; T2 : Entity_Id; Save_Full_Analysis : Boolean := False; -- Force initialization to facilitate static analysis -- Start of processing for Analyze_Assignment begin Mark_Coextensions (N, Rhs); -- Preserve relevant elaboration-related attributes of the context which -- are no longer available or very expensive to recompute once analysis, -- resolution, and expansion are over. Mark_Elaboration_Attributes (N_Id => N, Checks => True, Modes => True); -- An assignment statement is Ghost when the left hand side denotes a -- Ghost entity. Set the mode now to ensure that any nodes generated -- during analysis and expansion are properly marked as Ghost. Mark_And_Set_Ghost_Assignment (N); if Has_Target_Names (N) then pragma Assert (No (Current_Assignment)); Current_Assignment := N; Expander_Mode_Save_And_Set (False); Save_Full_Analysis := Full_Analysis; Full_Analysis := False; end if; Analyze (Lhs); Analyze (Rhs); -- Ensure that we never do an assignment on a variable marked as -- Is_Safe_To_Reevaluate. pragma Assert (not Is_Entity_Name (Lhs) or else Ekind (Entity (Lhs)) /= E_Variable or else not Is_Safe_To_Reevaluate (Entity (Lhs))); -- Start type analysis for assignment T1 := Etype (Lhs); -- In the most general case, both Lhs and Rhs can be overloaded, and we -- must compute the intersection of the possible types on each side. if Is_Overloaded (Lhs) then declare I : Interp_Index; It : Interp; begin T1 := Any_Type; Get_First_Interp (Lhs, I, It); while Present (It.Typ) loop -- An indexed component with generalized indexing is always -- overloaded with the corresponding dereference. Discard the -- interpretation that yields a reference type, which is not -- assignable. if Nkind (Lhs) = N_Indexed_Component and then Present (Generalized_Indexing (Lhs)) and then Has_Implicit_Dereference (It.Typ) then null; -- This may be a call to a parameterless function through an -- implicit dereference, so discard interpretation as well. elsif Is_Entity_Name (Lhs) and then Has_Implicit_Dereference (It.Typ) then null; elsif Has_Compatible_Type (Rhs, It.Typ) then if T1 = Any_Type then T1 := It.Typ; else -- An explicit dereference is overloaded if the prefix -- is. Try to remove the ambiguity on the prefix, the -- error will be posted there if the ambiguity is real. if Nkind (Lhs) = N_Explicit_Dereference then declare PI : Interp_Index; PI1 : Interp_Index := 0; PIt : Interp; Found : Boolean; begin Found := False; Get_First_Interp (Prefix (Lhs), PI, PIt); while Present (PIt.Typ) loop if Is_Access_Type (PIt.Typ) and then Has_Compatible_Type (Rhs, Designated_Type (PIt.Typ)) then if Found then PIt := Disambiguate (Prefix (Lhs), PI1, PI, Any_Type); if PIt = No_Interp then Error_Msg_N ("ambiguous left-hand side in " & "assignment", Lhs); exit; else Resolve (Prefix (Lhs), PIt.Typ); end if; exit; else Found := True; PI1 := PI; end if; end if; Get_Next_Interp (PI, PIt); end loop; end; else Error_Msg_N ("ambiguous left-hand side in assignment", Lhs); exit; end if; end if; end if; Get_Next_Interp (I, It); end loop; end; if T1 = Any_Type then Error_Msg_N ("no valid types for left-hand side for assignment", Lhs); Kill_Lhs; goto Leave; end if; end if; -- Deal with build-in-place calls for nonlimited types. We don't do this -- later, because resolving the rhs tranforms it incorrectly for build- -- in-place. if Should_Transform_BIP_Assignment (Typ => T1) then -- In certain cases involving user-defined concatenation operators, -- we need to resolve the right-hand side before transforming the -- assignment. case Nkind (Unqual_Conv (Rhs)) is when N_Function_Call => declare Actual : Node_Id := First (Parameter_Associations (Unqual_Conv (Rhs))); Actual_Exp : Node_Id; begin while Present (Actual) loop if Nkind (Actual) = N_Parameter_Association then Actual_Exp := Explicit_Actual_Parameter (Actual); else Actual_Exp := Actual; end if; if Nkind (Actual_Exp) = N_Op_Concat then Resolve (Rhs, T1); exit; end if; Next (Actual); end loop; end; when N_Attribute_Reference | N_Expanded_Name | N_Identifier | N_Op => null; when others => raise Program_Error; end case; Transform_BIP_Assignment (Typ => T1); end if; pragma Assert (not Should_Transform_BIP_Assignment (Typ => T1)); -- The resulting assignment type is T1, so now we will resolve the left -- hand side of the assignment using this determined type. Resolve (Lhs, T1); -- Cases where Lhs is not a variable. In an instance or an inlined body -- no need for further check because assignment was legal in template. if In_Inlined_Body then null; elsif not Is_Variable (Lhs) then -- Ada 2005 (AI-327): Check assignment to the attribute Priority of a -- protected object. declare Ent : Entity_Id; S : Entity_Id; begin if Ada_Version >= Ada_2005 then -- Handle chains of renamings Ent := Lhs; while Nkind (Ent) in N_Has_Entity and then Present (Entity (Ent)) and then Is_Object (Entity (Ent)) and then Present (Renamed_Object (Entity (Ent))) loop Ent := Renamed_Object (Entity (Ent)); end loop; if (Nkind (Ent) = N_Attribute_Reference and then Attribute_Name (Ent) = Name_Priority) -- Renamings of the attribute Priority applied to protected -- objects have been previously expanded into calls to the -- Get_Ceiling run-time subprogram. or else Is_Expanded_Priority_Attribute (Ent) then -- The enclosing subprogram cannot be a protected function S := Current_Scope; while not (Is_Subprogram (S) and then Convention (S) = Convention_Protected) and then S /= Standard_Standard loop S := Scope (S); end loop; if Ekind (S) = E_Function and then Convention (S) = Convention_Protected then Error_Msg_N ("protected function cannot modify its protected " & "object", Lhs); end if; -- Changes of the ceiling priority of the protected object -- are only effective if the Ceiling_Locking policy is in -- effect (AARM D.5.2 (5/2)). if Locking_Policy /= 'C' then Error_Msg_N ("assignment to the attribute PRIORITY has no effect??", Lhs); Error_Msg_N ("\since no Locking_Policy has been specified??", Lhs); end if; goto Leave; end if; end if; end; Diagnose_Non_Variable_Lhs (Lhs); goto Leave; -- Error of assigning to limited type. We do however allow this in -- certain cases where the front end generates the assignments. elsif Is_Limited_Type (T1) and then not Assignment_OK (Lhs) and then not Assignment_OK (Original_Node (Lhs)) then -- CPP constructors can only be called in declarations if Is_CPP_Constructor_Call (Rhs) then Error_Msg_N ("invalid use of 'C'P'P constructor", Rhs); else Error_Msg_N ("left hand of assignment must not be limited type", Lhs); Explain_Limited_Type (T1, Lhs); end if; goto Leave; -- A class-wide type may be a limited view. This illegal case is not -- caught by previous checks. elsif Ekind (T1) = E_Class_Wide_Type and then From_Limited_With (T1) then Error_Msg_NE ("invalid use of limited view of&", Lhs, T1); goto Leave; -- Enforce RM 3.9.3 (8): the target of an assignment operation cannot be -- abstract. This is only checked when the assignment Comes_From_Source, -- because in some cases the expander generates such assignments (such -- in the _assign operation for an abstract type). elsif Is_Abstract_Type (T1) and then Comes_From_Source (N) then Error_Msg_N ("target of assignment operation must not be abstract", Lhs); end if; -- Variables which are Part_Of constituents of single protected types -- behave in similar fashion to protected components. Such variables -- cannot be modified by protected functions. if Is_Protected_Part_Of_Constituent (Lhs) and then Within_Function then Error_Msg_N ("protected function cannot modify its protected object", Lhs); end if; -- Resolution may have updated the subtype, in case the left-hand side -- is a private protected component. Use the correct subtype to avoid -- scoping issues in the back-end. T1 := Etype (Lhs); -- Ada 2005 (AI-50217, AI-326): Check wrong dereference of incomplete -- type. For example: -- limited with P; -- package Pkg is -- type Acc is access P.T; -- end Pkg; -- with Pkg; use Acc; -- procedure Example is -- A, B : Acc; -- begin -- A.all := B.all; -- ERROR -- end Example; if Nkind (Lhs) = N_Explicit_Dereference and then Ekind (T1) = E_Incomplete_Type then Error_Msg_N ("invalid use of incomplete type", Lhs); Kill_Lhs; goto Leave; end if; -- Now we can complete the resolution of the right hand side Set_Assignment_Type (Lhs, T1); -- If the target of the assignment is an entity of a mutable type and -- the expression is a conditional expression, its alternatives can be -- of different subtypes of the nominal type of the LHS, so they must be -- resolved with the base type, given that their subtype may differ from -- that of the target mutable object. if Is_Entity_Name (Lhs) and then Is_Assignable (Entity (Lhs)) and then Is_Composite_Type (T1) and then not Is_Constrained (Etype (Entity (Lhs))) and then Nkind (Rhs) in N_If_Expression | N_Case_Expression then Resolve (Rhs, Base_Type (T1)); else Resolve (Rhs, T1); end if; -- This is the point at which we check for an unset reference Check_Unset_Reference (Rhs); Check_Unprotected_Access (Lhs, Rhs); -- Remaining steps are skipped if Rhs was syntactically in error if Rhs = Error then Kill_Lhs; goto Leave; end if; T2 := Etype (Rhs); if not Covers (T1, T2) then Wrong_Type (Rhs, Etype (Lhs)); Kill_Lhs; goto Leave; end if; -- Ada 2005 (AI-326): In case of explicit dereference of incomplete -- types, use the non-limited view if available if Nkind (Rhs) = N_Explicit_Dereference and then Is_Tagged_Type (T2) and then Has_Non_Limited_View (T2) then T2 := Non_Limited_View (T2); end if; Set_Assignment_Type (Rhs, T2); if Total_Errors_Detected /= 0 then if No (T1) then T1 := Any_Type; end if; if No (T2) then T2 := Any_Type; end if; end if; if T1 = Any_Type or else T2 = Any_Type then Kill_Lhs; goto Leave; end if; -- If the rhs is class-wide or dynamically tagged, then require the lhs -- to be class-wide. The case where the rhs is a dynamically tagged call -- to a dispatching operation with a controlling access result is -- excluded from this check, since the target has an access type (and -- no tag propagation occurs in that case). if (Is_Class_Wide_Type (T2) or else (Is_Dynamically_Tagged (Rhs) and then not Is_Access_Type (T1))) and then not Is_Class_Wide_Type (T1) then Error_Msg_N ("dynamically tagged expression not allowed!", Rhs); elsif Is_Class_Wide_Type (T1) and then not Is_Class_Wide_Type (T2) and then not Is_Tag_Indeterminate (Rhs) and then not Is_Dynamically_Tagged (Rhs) then Error_Msg_N ("dynamically tagged expression required!", Rhs); end if; -- Propagate the tag from a class-wide target to the rhs when the rhs -- is a tag-indeterminate call. if Is_Tag_Indeterminate (Rhs) then if Is_Class_Wide_Type (T1) then Propagate_Tag (Lhs, Rhs); elsif Nkind (Rhs) = N_Function_Call and then Is_Entity_Name (Name (Rhs)) and then Is_Abstract_Subprogram (Entity (Name (Rhs))) then Error_Msg_N ("call to abstract function must be dispatching", Name (Rhs)); elsif Nkind (Rhs) = N_Qualified_Expression and then Nkind (Expression (Rhs)) = N_Function_Call and then Is_Entity_Name (Name (Expression (Rhs))) and then Is_Abstract_Subprogram (Entity (Name (Expression (Rhs)))) then Error_Msg_N ("call to abstract function must be dispatching", Name (Expression (Rhs))); end if; end if; -- Ada 2005 (AI-385): When the lhs type is an anonymous access type, -- apply an implicit conversion of the rhs to that type to force -- appropriate static and run-time accessibility checks. This applies -- as well to anonymous access-to-subprogram types that are component -- subtypes or formal parameters. if Ada_Version >= Ada_2005 and then Is_Access_Type (T1) then if Is_Local_Anonymous_Access (T1) or else Ekind (T2) = E_Anonymous_Access_Subprogram_Type -- Handle assignment to an Ada 2012 stand-alone object -- of an anonymous access type. or else (Ekind (T1) = E_Anonymous_Access_Type and then Nkind (Associated_Node_For_Itype (T1)) = N_Object_Declaration) then Rewrite (Rhs, Convert_To (T1, Relocate_Node (Rhs))); Analyze_And_Resolve (Rhs, T1); end if; end if; -- Ada 2005 (AI-231): Assignment to not null variable if Ada_Version >= Ada_2005 and then Can_Never_Be_Null (T1) and then not Assignment_OK (Lhs) then -- Case where we know the right hand side is null if Known_Null (Rhs) then Apply_Compile_Time_Constraint_Error (N => Rhs, Msg => "(Ada 2005) NULL not allowed in null-excluding objects??", Reason => CE_Null_Not_Allowed); -- We still mark this as a possible modification, that's necessary -- to reset Is_True_Constant, and desirable for xref purposes. Note_Possible_Modification (Lhs, Sure => True); goto Leave; -- If we know the right hand side is non-null, then we convert to the -- target type, since we don't need a run time check in that case. elsif not Can_Never_Be_Null (T2) then Rewrite (Rhs, Convert_To (T1, Relocate_Node (Rhs))); Analyze_And_Resolve (Rhs, T1); end if; end if; if Is_Scalar_Type (T1) then declare function Omit_Range_Check_For_Streaming return Boolean; -- Return True if this assignment statement is the expansion of -- a Some_Scalar_Type'Read procedure call such that all conditions -- of 13.3.2(35)'s "no check is made" rule are met. ------------------------------------ -- Omit_Range_Check_For_Streaming -- ------------------------------------ function Omit_Range_Check_For_Streaming return Boolean is begin -- Have we got an implicitly generated assignment to a -- component of a composite object? If not, return False. if Comes_From_Source (N) or else Serious_Errors_Detected > 0 or else Nkind (Lhs) not in N_Selected_Component | N_Indexed_Component then return False; end if; declare Pref : constant Node_Id := Prefix (Lhs); begin -- Are we in the implicitly-defined Read subprogram -- for a composite type, reading the value of a scalar -- component from the stream? If not, return False. if Nkind (Pref) /= N_Identifier or else not Is_TSS (Scope (Entity (Pref)), TSS_Stream_Read) then return False; end if; -- Return False if Default_Value or Default_Component_Value -- aspect applies. if Has_Default_Aspect (Etype (Lhs)) or else Has_Default_Aspect (Etype (Pref)) then return False; -- Are we assigning to a record component (as opposed to -- an array component)? elsif Nkind (Lhs) = N_Selected_Component then -- Are we assigning to a nondiscriminant component -- that lacks a default initial value expression? -- If so, return True. declare Comp_Id : constant Entity_Id := Original_Record_Component (Entity (Selector_Name (Lhs))); begin if Ekind (Comp_Id) = E_Component and then Nkind (Parent (Comp_Id)) = N_Component_Declaration and then not Present (Expression (Parent (Comp_Id))) then return True; end if; return False; end; -- We are assigning to a component of an array -- (and we tested for both Default_Value and -- Default_Component_Value above), so return True. else pragma Assert (Nkind (Lhs) = N_Indexed_Component); return True; end if; end; end Omit_Range_Check_For_Streaming; begin if not Omit_Range_Check_For_Streaming then Apply_Scalar_Range_Check (Rhs, Etype (Lhs)); end if; end; -- For array types, verify that lengths match. If the right hand side -- is a function call that has been inlined, the assignment has been -- rewritten as a block, and the constraint check will be applied to the -- assignment within the block. elsif Is_Array_Type (T1) and then (Nkind (Rhs) /= N_Type_Conversion or else Is_Constrained (Etype (Rhs))) and then (Nkind (Rhs) /= N_Function_Call or else Nkind (N) /= N_Block_Statement) then -- Assignment verifies that the length of the Lhs and Rhs are equal, -- but of course the indexes do not have to match. If the right-hand -- side is a type conversion to an unconstrained type, a length check -- is performed on the expression itself during expansion. In rare -- cases, the redundant length check is computed on an index type -- with a different representation, triggering incorrect code in the -- back end. Apply_Length_Check_On_Assignment (Rhs, Etype (Lhs), Lhs); else -- Discriminant checks are applied in the course of expansion null; end if; -- Note: modifications of the Lhs may only be recorded after -- checks have been applied. Note_Possible_Modification (Lhs, Sure => True); -- ??? a real accessibility check is needed when ??? -- Post warning for redundant assignment or variable to itself if Warn_On_Redundant_Constructs -- We only warn for source constructs and then Comes_From_Source (N) -- Where the object is the same on both sides and then Same_Object (Lhs, Original_Node (Rhs)) -- But exclude the case where the right side was an operation that -- got rewritten (e.g. JUNK + K, where K was known to be zero). We -- don't want to warn in such a case, since it is reasonable to write -- such expressions especially when K is defined symbolically in some -- other package. and then Nkind (Original_Node (Rhs)) not in N_Op then if Nkind (Lhs) in N_Has_Entity then Error_Msg_NE -- CODEFIX ("?r?useless assignment of & to itself!", N, Entity (Lhs)); else Error_Msg_N -- CODEFIX ("?r?useless assignment of object to itself!", N); end if; end if; -- Check for non-allowed composite assignment if not Support_Composite_Assign_On_Target and then (Is_Array_Type (T1) or else Is_Record_Type (T1)) and then (not Has_Size_Clause (T1) or else Esize (T1) > Ttypes.System_Max_Integer_Size) then Error_Msg_CRT ("composite assignment", N); end if; -- Check elaboration warning for left side if not in elab code if Legacy_Elaboration_Checks and not In_Subprogram_Or_Concurrent_Unit then Check_Elab_Assign (Lhs); end if; -- Save the scenario for later examination by the ABE Processing phase Record_Elaboration_Scenario (N); -- Set Referenced_As_LHS if appropriate. We only set this flag if the -- assignment is a source assignment in the extended main source unit. -- We are not interested in any reference information outside this -- context, or in compiler generated assignment statements. if Comes_From_Source (N) and then In_Extended_Main_Source_Unit (Lhs) then Set_Referenced_Modified (Lhs, Out_Param => False); end if; -- RM 7.3.2 (12/3): An assignment to a view conversion (from a type to -- one of its ancestors) requires an invariant check. Apply check only -- if expression comes from source, otherwise it will be applied when -- value is assigned to source entity. This is not done in GNATprove -- mode, as GNATprove handles invariant checks itself. if Nkind (Lhs) = N_Type_Conversion and then Has_Invariants (Etype (Expression (Lhs))) and then Comes_From_Source (Expression (Lhs)) and then not GNATprove_Mode then Insert_After (N, Make_Invariant_Call (Expression (Lhs))); end if; -- Final step. If left side is an entity, then we may be able to reset -- the current tracked values to new safe values. We only have something -- to do if the left side is an entity name, and expansion has not -- modified the node into something other than an assignment, and of -- course we only capture values if it is safe to do so. if Is_Entity_Name (Lhs) and then Nkind (N) = N_Assignment_Statement then declare Ent : constant Entity_Id := Entity (Lhs); begin if Safe_To_Capture_Value (N, Ent) then -- If simple variable on left side, warn if this assignment -- blots out another one (rendering it useless). We only do -- this for source assignments, otherwise we can generate bogus -- warnings when an assignment is rewritten as another -- assignment, and gets tied up with itself. -- We also omit the warning if the RHS includes target names, -- that is to say the Ada 2022 "@" that denotes an instance of -- the LHS, which indicates that the current value is being -- used. Note that this implicit reference to the entity on -- the RHS is not treated as a source reference. -- There may have been a previous reference to a component of -- the variable, which in general removes the Last_Assignment -- field of the variable to indicate a relevant use of the -- previous assignment. However, if the assignment is to a -- subcomponent the reference may not have registered, because -- it is not possible to determine whether the context is an -- assignment. In those cases we generate a Deferred_Reference, -- to be used at the end of compilation to generate the right -- kind of reference, and we suppress a potential warning for -- a useless assignment, which might be premature. This may -- lose a warning in rare cases, but seems preferable to a -- misleading warning. if Warn_On_Modified_Unread and then Is_Assignable (Ent) and then Comes_From_Source (N) and then In_Extended_Main_Source_Unit (Ent) and then not Has_Deferred_Reference (Ent) and then not Has_Target_Names (N) then Warn_On_Useless_Assignment (Ent, N); end if; -- If we are assigning an access type and the left side is an -- entity, then make sure that the Is_Known_[Non_]Null flags -- properly reflect the state of the entity after assignment. if Is_Access_Type (T1) then if Known_Non_Null (Rhs) then Set_Is_Known_Non_Null (Ent, True); elsif Known_Null (Rhs) and then not Can_Never_Be_Null (Ent) then Set_Is_Known_Null (Ent, True); else Set_Is_Known_Null (Ent, False); if not Can_Never_Be_Null (Ent) then Set_Is_Known_Non_Null (Ent, False); end if; end if; -- For discrete types, we may be able to set the current value -- if the value is known at compile time. elsif Is_Discrete_Type (T1) and then Compile_Time_Known_Value (Rhs) then Set_Current_Value (Ent, Rhs); else Set_Current_Value (Ent, Empty); end if; -- If not safe to capture values, kill them else Kill_Lhs; end if; end; end if; -- If assigning to an object in whole or in part, note location of -- assignment in case no one references value. We only do this for -- source assignments, otherwise we can generate bogus warnings when an -- assignment is rewritten as another assignment, and gets tied up with -- itself. declare Ent : constant Entity_Id := Get_Enclosing_Object (Lhs); begin if Present (Ent) and then Safe_To_Capture_Value (N, Ent) and then Nkind (N) = N_Assignment_Statement and then Warn_On_Modified_Unread and then Is_Assignable (Ent) and then Comes_From_Source (N) and then In_Extended_Main_Source_Unit (Ent) then Set_Last_Assignment (Ent, Lhs); end if; end; Analyze_Dimension (N); <<Leave>> Restore_Ghost_Region (Saved_GM, Saved_IGR); -- If the right-hand side contains target names, expansion has been -- disabled to prevent expansion that might move target names out of -- the context of the assignment statement. Restore the expander mode -- now so that assignment statement can be properly expanded. if Nkind (N) = N_Assignment_Statement then if Has_Target_Names (N) then Expander_Mode_Restore; Full_Analysis := Save_Full_Analysis; Current_Assignment := Empty; end if; pragma Assert (not Should_Transform_BIP_Assignment (Typ => T1)); end if; end Analyze_Assignment; ----------------------------- -- Analyze_Block_Statement -- ----------------------------- procedure Analyze_Block_Statement (N : Node_Id) is procedure Install_Return_Entities (Scop : Entity_Id); -- Install all entities of return statement scope Scop in the visibility -- chain except for the return object since its entity is reused in a -- renaming. ----------------------------- -- Install_Return_Entities -- ----------------------------- procedure Install_Return_Entities (Scop : Entity_Id) is Id : Entity_Id; begin Id := First_Entity (Scop); while Present (Id) loop -- Do not install the return object if Ekind (Id) not in E_Constant | E_Variable or else not Is_Return_Object (Id) then Install_Entity (Id); end if; Next_Entity (Id); end loop; end Install_Return_Entities; -- Local constants and variables Decls : constant List_Id := Declarations (N); Id : constant Node_Id := Identifier (N); HSS : constant Node_Id := Handled_Statement_Sequence (N); Is_BIP_Return_Statement : Boolean; -- Start of processing for Analyze_Block_Statement begin -- If no handled statement sequence is present, things are really messed -- up, and we just return immediately (defence against previous errors). if No (HSS) then Check_Error_Detected; return; end if; -- Detect whether the block is actually a rewritten return statement of -- a build-in-place function. Is_BIP_Return_Statement := Present (Id) and then Present (Entity (Id)) and then Ekind (Entity (Id)) = E_Return_Statement and then Is_Build_In_Place_Function (Return_Applies_To (Entity (Id))); -- Normal processing with HSS present declare EH : constant List_Id := Exception_Handlers (HSS); Ent : Entity_Id := Empty; S : Entity_Id; Save_Unblocked_Exit_Count : constant Nat := Unblocked_Exit_Count; -- Recursively save value of this global, will be restored on exit begin -- Initialize unblocked exit count for statements of begin block -- plus one for each exception handler that is present. Unblocked_Exit_Count := 1; if Present (EH) then Unblocked_Exit_Count := Unblocked_Exit_Count + List_Length (EH); end if; -- If a label is present analyze it and mark it as referenced if Present (Id) then Analyze (Id); Ent := Entity (Id); -- An error defense. If we have an identifier, but no entity, then -- something is wrong. If previous errors, then just remove the -- identifier and continue, otherwise raise an exception. if No (Ent) then Check_Error_Detected; Set_Identifier (N, Empty); else if Ekind (Ent) = E_Label then Reinit_Field_To_Zero (Ent, F_Enclosing_Scope); end if; Mutate_Ekind (Ent, E_Block); Generate_Reference (Ent, N, ' '); Generate_Definition (Ent); if Nkind (Parent (Ent)) = N_Implicit_Label_Declaration then Set_Label_Construct (Parent (Ent), N); end if; end if; end if; -- If no entity set, create a label entity if No (Ent) then Ent := New_Internal_Entity (E_Block, Current_Scope, Sloc (N), 'B'); Set_Identifier (N, New_Occurrence_Of (Ent, Sloc (N))); Set_Parent (Ent, N); end if; Set_Etype (Ent, Standard_Void_Type); Set_Block_Node (Ent, Identifier (N)); Push_Scope (Ent); -- The block served as an extended return statement. Ensure that any -- entities created during the analysis and expansion of the return -- object declaration are once again visible. if Is_BIP_Return_Statement then Install_Return_Entities (Ent); end if; if Present (Decls) then Analyze_Declarations (Decls); Check_Completion; Inspect_Deferred_Constant_Completion (Decls); end if; Analyze (HSS); Process_End_Label (HSS, 'e', Ent); -- If exception handlers are present, then we indicate that enclosing -- scopes contain a block with handlers. We only need to mark non- -- generic scopes. if Present (EH) then S := Scope (Ent); loop Set_Has_Nested_Block_With_Handler (S); exit when Is_Overloadable (S) or else Ekind (S) = E_Package or else Is_Generic_Unit (S); S := Scope (S); end loop; end if; Check_References (Ent); Update_Use_Clause_Chain; End_Scope; if Unblocked_Exit_Count = 0 then Unblocked_Exit_Count := Save_Unblocked_Exit_Count; Check_Unreachable_Code (N); else Unblocked_Exit_Count := Save_Unblocked_Exit_Count; end if; end; end Analyze_Block_Statement; -------------------------------- -- Analyze_Compound_Statement -- -------------------------------- procedure Analyze_Compound_Statement (N : Node_Id) is begin Analyze_List (Actions (N)); end Analyze_Compound_Statement; ---------------------------- -- Analyze_Case_Statement -- ---------------------------- procedure Analyze_Case_Statement (N : Node_Id) is Exp : constant Node_Id := Expression (N); Statements_Analyzed : Boolean := False; -- Set True if at least some statement sequences get analyzed. If False -- on exit, means we had a serious error that prevented full analysis of -- the case statement, and as a result it is not a good idea to output -- warning messages about unreachable code. Is_General_Case_Statement : Boolean := False; -- Set True (later) if type of case expression is not discrete procedure Non_Static_Choice_Error (Choice : Node_Id); -- Error routine invoked by the generic instantiation below when the -- case statement has a non static choice. procedure Process_Statements (Alternative : Node_Id); -- Analyzes the statements associated with a case alternative. Needed -- by instantiation below. package Analyze_Case_Choices is new Generic_Analyze_Choices (Process_Associated_Node => Process_Statements); use Analyze_Case_Choices; -- Instantiation of the generic choice analysis package package Check_Case_Choices is new Generic_Check_Choices (Process_Empty_Choice => No_OP, Process_Non_Static_Choice => Non_Static_Choice_Error, Process_Associated_Node => No_OP); use Check_Case_Choices; -- Instantiation of the generic choice processing package ----------------------------- -- Non_Static_Choice_Error -- ----------------------------- procedure Non_Static_Choice_Error (Choice : Node_Id) is begin Flag_Non_Static_Expr ("choice given in case statement is not static!", Choice); end Non_Static_Choice_Error; ------------------------ -- Process_Statements -- ------------------------ procedure Process_Statements (Alternative : Node_Id) is Choices : constant List_Id := Discrete_Choices (Alternative); Ent : Entity_Id; begin if Is_General_Case_Statement then return; -- Processing deferred in this case; decls associated with -- pattern match bindings don't exist yet. end if; Unblocked_Exit_Count := Unblocked_Exit_Count + 1; Statements_Analyzed := True; -- An interesting optimization. If the case statement expression -- is a simple entity, then we can set the current value within an -- alternative if the alternative has one possible value. -- case N is -- when 1 => alpha -- when 2 | 3 => beta -- when others => gamma -- Here we know that N is initially 1 within alpha, but for beta and -- gamma, we do not know anything more about the initial value. if Is_Entity_Name (Exp) then Ent := Entity (Exp); if Is_Object (Ent) then if List_Length (Choices) = 1 and then Nkind (First (Choices)) in N_Subexpr and then Compile_Time_Known_Value (First (Choices)) then Set_Current_Value (Entity (Exp), First (Choices)); end if; Analyze_Statements (Statements (Alternative)); -- After analyzing the case, set the current value to empty -- since we won't know what it is for the next alternative -- (unless reset by this same circuit), or after the case. Set_Current_Value (Entity (Exp), Empty); return; end if; end if; -- Case where expression is not an entity name of an object Analyze_Statements (Statements (Alternative)); end Process_Statements; -- Local variables Exp_Type : Entity_Id; Exp_Btype : Entity_Id; Others_Present : Boolean; -- Indicates if Others was present Save_Unblocked_Exit_Count : constant Nat := Unblocked_Exit_Count; -- Recursively save value of this global, will be restored on exit -- Start of processing for Analyze_Case_Statement begin Analyze (Exp); -- The expression must be of any discrete type. In rare cases, the -- expander constructs a case statement whose expression has a private -- type whose full view is discrete. This can happen when generating -- a stream operation for a variant type after the type is frozen, -- when the partial of view of the type of the discriminant is private. -- In that case, use the full view to analyze case alternatives. if not Is_Overloaded (Exp) and then not Comes_From_Source (N) and then Is_Private_Type (Etype (Exp)) and then Present (Full_View (Etype (Exp))) and then Is_Discrete_Type (Full_View (Etype (Exp))) then Resolve (Exp); Exp_Type := Full_View (Etype (Exp)); -- For Ada, overloading might be ok because subsequently filtering -- out non-discretes may resolve the ambiguity. -- But GNAT extensions allow casing on non-discretes. elsif Extensions_Allowed and then Is_Overloaded (Exp) then -- It would be nice if we could generate all the right error -- messages by calling "Resolve (Exp, Any_Type);" in the -- same way that they are generated a few lines below by the -- call "Analyze_And_Resolve (Exp, Any_Discrete);". -- Unfortunately, Any_Type and Any_Discrete are not treated -- consistently (specifically, by Sem_Type.Covers), so that -- doesn't work. Error_Msg_N ("selecting expression of general case statement is ambiguous", Exp); return; -- Check for a GNAT-extension "general" case statement (i.e., one where -- the type of the selecting expression is not discrete). elsif Extensions_Allowed and then not Is_Discrete_Type (Etype (Exp)) then Resolve (Exp, Etype (Exp)); Exp_Type := Etype (Exp); Is_General_Case_Statement := True; else Analyze_And_Resolve (Exp, Any_Discrete); Exp_Type := Etype (Exp); end if; Check_Unset_Reference (Exp); Exp_Btype := Base_Type (Exp_Type); -- The expression must be of a discrete type which must be determinable -- independently of the context in which the expression occurs, but -- using the fact that the expression must be of a discrete type. -- Moreover, the type this expression must not be a character literal -- (which is always ambiguous) or, for Ada-83, a generic formal type. -- If error already reported by Resolve, nothing more to do if Exp_Btype = Any_Discrete or else Exp_Btype = Any_Type then return; elsif Exp_Btype = Any_Character then Error_Msg_N ("character literal as case expression is ambiguous", Exp); return; elsif Ada_Version = Ada_83 and then (Is_Generic_Type (Exp_Btype) or else Is_Generic_Type (Root_Type (Exp_Btype))) then Error_Msg_N ("(Ada 83) case expression cannot be of a generic type", Exp); return; elsif not Extensions_Allowed and then not Is_Discrete_Type (Exp_Type) then Error_Msg_N ("expression in case statement must be of a discrete_Type", Exp); return; end if; -- If the case expression is a formal object of mode in out, then treat -- it as having a nonstatic subtype by forcing use of the base type -- (which has to get passed to Check_Case_Choices below). Also use base -- type when the case expression is parenthesized. if Paren_Count (Exp) > 0 or else (Is_Entity_Name (Exp) and then Ekind (Entity (Exp)) = E_Generic_In_Out_Parameter) then Exp_Type := Exp_Btype; end if; -- Call instantiated procedures to analyze and check discrete choices Unblocked_Exit_Count := 0; Analyze_Choices (Alternatives (N), Exp_Type); Check_Choices (N, Alternatives (N), Exp_Type, Others_Present); if Is_General_Case_Statement then -- Work normally done in Process_Statements was deferred; do that -- deferred work now that Check_Choices has had a chance to create -- any needed pattern-match-binding declarations. declare Alt : Node_Id := First (Alternatives (N)); begin while Present (Alt) loop Unblocked_Exit_Count := Unblocked_Exit_Count + 1; Analyze_Statements (Statements (Alt)); Next (Alt); end loop; end; end if; if Exp_Type = Universal_Integer and then not Others_Present then Error_Msg_N ("case on universal integer requires OTHERS choice", Exp); end if; -- If all our exits were blocked by unconditional transfers of control, -- then the entire CASE statement acts as an unconditional transfer of -- control, so treat it like one, and check unreachable code. Skip this -- test if we had serious errors preventing any statement analysis. if Unblocked_Exit_Count = 0 and then Statements_Analyzed then Unblocked_Exit_Count := Save_Unblocked_Exit_Count; Check_Unreachable_Code (N); else Unblocked_Exit_Count := Save_Unblocked_Exit_Count; end if; -- If the expander is active it will detect the case of a statically -- determined single alternative and remove warnings for the case, but -- if we are not doing expansion, that circuit won't be active. Here we -- duplicate the effect of removing warnings in the same way, so that -- we will get the same set of warnings in -gnatc mode. if not Expander_Active and then Compile_Time_Known_Value (Expression (N)) and then Serious_Errors_Detected = 0 then declare Chosen : constant Node_Id := Find_Static_Alternative (N); Alt : Node_Id; begin Alt := First (Alternatives (N)); while Present (Alt) loop if Alt /= Chosen then Remove_Warning_Messages (Statements (Alt)); end if; Next (Alt); end loop; end; end if; end Analyze_Case_Statement; ---------------------------- -- Analyze_Exit_Statement -- ---------------------------- -- If the exit includes a name, it must be the name of a currently open -- loop. Otherwise there must be an innermost open loop on the stack, to -- which the statement implicitly refers. -- Additionally, in SPARK mode: -- The exit can only name the closest enclosing loop; -- An exit with a when clause must be directly contained in a loop; -- An exit without a when clause must be directly contained in an -- if-statement with no elsif or else, which is itself directly contained -- in a loop. The exit must be the last statement in the if-statement. procedure Analyze_Exit_Statement (N : Node_Id) is Target : constant Node_Id := Name (N); Cond : constant Node_Id := Condition (N); Scope_Id : Entity_Id := Empty; -- initialize to prevent warning U_Name : Entity_Id; Kind : Entity_Kind; begin if No (Cond) then Check_Unreachable_Code (N); end if; if Present (Target) then Analyze (Target); U_Name := Entity (Target); if not In_Open_Scopes (U_Name) or else Ekind (U_Name) /= E_Loop then Error_Msg_N ("invalid loop name in exit statement", N); return; else Set_Has_Exit (U_Name); end if; else U_Name := Empty; end if; for J in reverse 0 .. Scope_Stack.Last loop Scope_Id := Scope_Stack.Table (J).Entity; Kind := Ekind (Scope_Id); if Kind = E_Loop and then (No (Target) or else Scope_Id = U_Name) then Set_Has_Exit (Scope_Id); exit; elsif Kind = E_Block or else Kind = E_Loop or else Kind = E_Return_Statement then null; else Error_Msg_N ("cannot exit from program unit or accept statement", N); return; end if; end loop; -- Verify that if present the condition is a Boolean expression if Present (Cond) then Analyze_And_Resolve (Cond, Any_Boolean); Check_Unset_Reference (Cond); end if; -- Chain exit statement to associated loop entity Set_Next_Exit_Statement (N, First_Exit_Statement (Scope_Id)); Set_First_Exit_Statement (Scope_Id, N); -- Since the exit may take us out of a loop, any previous assignment -- statement is not useless, so clear last assignment indications. It -- is OK to keep other current values, since if the exit statement -- does not exit, then the current values are still valid. Kill_Current_Values (Last_Assignment_Only => True); end Analyze_Exit_Statement; ---------------------------- -- Analyze_Goto_Statement -- ---------------------------- procedure Analyze_Goto_Statement (N : Node_Id) is Label : constant Node_Id := Name (N); Scope_Id : Entity_Id; Label_Scope : Entity_Id; Label_Ent : Entity_Id; begin -- Actual semantic checks Check_Unreachable_Code (N); Kill_Current_Values (Last_Assignment_Only => True); Analyze (Label); Label_Ent := Entity (Label); -- Ignore previous error if Label_Ent = Any_Id then Check_Error_Detected; return; -- We just have a label as the target of a goto elsif Ekind (Label_Ent) /= E_Label then Error_Msg_N ("target of goto statement must be a label", Label); return; -- Check that the target of the goto is reachable according to Ada -- scoping rules. Note: the special gotos we generate for optimizing -- local handling of exceptions would violate these rules, but we mark -- such gotos as analyzed when built, so this code is never entered. elsif not Reachable (Label_Ent) then Error_Msg_N ("target of goto statement is not reachable", Label); return; end if; -- Here if goto passes initial validity checks Label_Scope := Enclosing_Scope (Label_Ent); for J in reverse 0 .. Scope_Stack.Last loop Scope_Id := Scope_Stack.Table (J).Entity; if Label_Scope = Scope_Id or else Ekind (Scope_Id) not in E_Block | E_Loop | E_Return_Statement then if Scope_Id /= Label_Scope then Error_Msg_N ("cannot exit from program unit or accept statement", N); end if; return; end if; end loop; raise Program_Error; end Analyze_Goto_Statement; --------------------------------- -- Analyze_Goto_When_Statement -- --------------------------------- procedure Analyze_Goto_When_Statement (N : Node_Id) is begin -- Verify the condition is a Boolean expression Analyze_And_Resolve (Condition (N), Any_Boolean); Check_Unset_Reference (Condition (N)); end Analyze_Goto_When_Statement; -------------------------- -- Analyze_If_Statement -- -------------------------- -- A special complication arises in the analysis of if statements -- The expander has circuitry to completely delete code that it can tell -- will not be executed (as a result of compile time known conditions). In -- the analyzer, we ensure that code that will be deleted in this manner -- is analyzed but not expanded. This is obviously more efficient, but -- more significantly, difficulties arise if code is expanded and then -- eliminated (e.g. exception table entries disappear). Similarly, itypes -- generated in deleted code must be frozen from start, because the nodes -- on which they depend will not be available at the freeze point. procedure Analyze_If_Statement (N : Node_Id) is Save_Unblocked_Exit_Count : constant Nat := Unblocked_Exit_Count; -- Recursively save value of this global, will be restored on exit Save_In_Deleted_Code : Boolean := In_Deleted_Code; Del : Boolean := False; -- This flag gets set True if a True condition has been found, which -- means that remaining ELSE/ELSIF parts are deleted. procedure Analyze_Cond_Then (Cnode : Node_Id); -- This is applied to either the N_If_Statement node itself or to an -- N_Elsif_Part node. It deals with analyzing the condition and the THEN -- statements associated with it. ----------------------- -- Analyze_Cond_Then -- ----------------------- procedure Analyze_Cond_Then (Cnode : Node_Id) is Cond : constant Node_Id := Condition (Cnode); Tstm : constant List_Id := Then_Statements (Cnode); begin Unblocked_Exit_Count := Unblocked_Exit_Count + 1; Analyze_And_Resolve (Cond, Any_Boolean); Check_Unset_Reference (Cond); Set_Current_Value_Condition (Cnode); -- If already deleting, then just analyze then statements if Del then Analyze_Statements (Tstm); -- Compile time known value, not deleting yet elsif Compile_Time_Known_Value (Cond) then Save_In_Deleted_Code := In_Deleted_Code; -- If condition is True, then analyze the THEN statements and set -- no expansion for ELSE and ELSIF parts. if Is_True (Expr_Value (Cond)) then Analyze_Statements (Tstm); Del := True; Expander_Mode_Save_And_Set (False); In_Deleted_Code := True; -- If condition is False, analyze THEN with expansion off else pragma Assert (Is_False (Expr_Value (Cond))); Expander_Mode_Save_And_Set (False); In_Deleted_Code := True; Analyze_Statements (Tstm); Expander_Mode_Restore; In_Deleted_Code := Save_In_Deleted_Code; end if; -- Not known at compile time, not deleting, normal analysis else Analyze_Statements (Tstm); end if; end Analyze_Cond_Then; -- Local variables E : Node_Id; -- For iterating over elsif parts -- Start of processing for Analyze_If_Statement begin -- Initialize exit count for else statements. If there is no else part, -- this count will stay non-zero reflecting the fact that the uncovered -- else case is an unblocked exit. Unblocked_Exit_Count := 1; Analyze_Cond_Then (N); -- Now to analyze the elsif parts if any are present if Present (Elsif_Parts (N)) then E := First (Elsif_Parts (N)); while Present (E) loop Analyze_Cond_Then (E); Next (E); end loop; end if; if Present (Else_Statements (N)) then Analyze_Statements (Else_Statements (N)); end if; -- If all our exits were blocked by unconditional transfers of control, -- then the entire IF statement acts as an unconditional transfer of -- control, so treat it like one, and check unreachable code. if Unblocked_Exit_Count = 0 then Unblocked_Exit_Count := Save_Unblocked_Exit_Count; Check_Unreachable_Code (N); else Unblocked_Exit_Count := Save_Unblocked_Exit_Count; end if; if Del then Expander_Mode_Restore; In_Deleted_Code := Save_In_Deleted_Code; end if; if not Expander_Active and then Compile_Time_Known_Value (Condition (N)) and then Serious_Errors_Detected = 0 then if Is_True (Expr_Value (Condition (N))) then Remove_Warning_Messages (Else_Statements (N)); if Present (Elsif_Parts (N)) then E := First (Elsif_Parts (N)); while Present (E) loop Remove_Warning_Messages (Then_Statements (E)); Next (E); end loop; end if; else Remove_Warning_Messages (Then_Statements (N)); end if; end if; -- Warn on redundant if statement that has no effect -- Note, we could also check empty ELSIF parts ??? if Warn_On_Redundant_Constructs -- If statement must be from source and then Comes_From_Source (N) -- Condition must not have obvious side effect and then Has_No_Obvious_Side_Effects (Condition (N)) -- No elsif parts of else part and then No (Elsif_Parts (N)) and then No (Else_Statements (N)) -- Then must be a single null statement and then List_Length (Then_Statements (N)) = 1 then -- Go to original node, since we may have rewritten something as -- a null statement (e.g. a case we could figure the outcome of). declare T : constant Node_Id := First (Then_Statements (N)); S : constant Node_Id := Original_Node (T); begin if Comes_From_Source (S) and then Nkind (S) = N_Null_Statement then Error_Msg_N ("if statement has no effect?r?", N); end if; end; end if; end Analyze_If_Statement; ---------------------------------------- -- Analyze_Implicit_Label_Declaration -- ---------------------------------------- -- An implicit label declaration is generated in the innermost enclosing -- declarative part. This is done for labels, and block and loop names. -- Note: any changes in this routine may need to be reflected in -- Analyze_Label_Entity. procedure Analyze_Implicit_Label_Declaration (N : Node_Id) is Id : constant Node_Id := Defining_Identifier (N); begin Enter_Name (Id); Mutate_Ekind (Id, E_Label); Set_Etype (Id, Standard_Void_Type); Set_Enclosing_Scope (Id, Current_Scope); end Analyze_Implicit_Label_Declaration; ------------------------------ -- Analyze_Iteration_Scheme -- ------------------------------ procedure Analyze_Iteration_Scheme (N : Node_Id) is Cond : Node_Id; Iter_Spec : Node_Id; Loop_Spec : Node_Id; begin -- For an infinite loop, there is no iteration scheme if No (N) then return; end if; Cond := Condition (N); Iter_Spec := Iterator_Specification (N); Loop_Spec := Loop_Parameter_Specification (N); if Present (Cond) then Analyze_And_Resolve (Cond, Any_Boolean); Check_Unset_Reference (Cond); Set_Current_Value_Condition (N); elsif Present (Iter_Spec) then Analyze_Iterator_Specification (Iter_Spec); else Analyze_Loop_Parameter_Specification (Loop_Spec); end if; end Analyze_Iteration_Scheme; ------------------------------------ -- Analyze_Iterator_Specification -- ------------------------------------ procedure Analyze_Iterator_Specification (N : Node_Id) is Def_Id : constant Node_Id := Defining_Identifier (N); Iter_Name : constant Node_Id := Name (N); Loc : constant Source_Ptr := Sloc (N); Subt : constant Node_Id := Subtype_Indication (N); Bas : Entity_Id := Empty; -- initialize to prevent warning Typ : Entity_Id; procedure Check_Reverse_Iteration (Typ : Entity_Id); -- For an iteration over a container, if the loop carries the Reverse -- indicator, verify that the container type has an Iterate aspect that -- implements the reversible iterator interface. procedure Check_Subtype_Definition (Comp_Type : Entity_Id); -- If a subtype indication is present, verify that it is consistent -- with the component type of the array or container name. -- In Ada 2022, the subtype indication may be an access definition, -- if the array or container has elements of an anonymous access type. function Get_Cursor_Type (Typ : Entity_Id) return Entity_Id; -- For containers with Iterator and related aspects, the cursor is -- obtained by locating an entity with the proper name in the scope -- of the type. ----------------------------- -- Check_Reverse_Iteration -- ----------------------------- procedure Check_Reverse_Iteration (Typ : Entity_Id) is begin if Reverse_Present (N) then if Is_Array_Type (Typ) or else Is_Reversible_Iterator (Typ) or else (Present (Find_Aspect (Typ, Aspect_Iterable)) and then Present (Get_Iterable_Type_Primitive (Typ, Name_Previous))) then null; else Error_Msg_N ("container type does not support reverse iteration", N); end if; end if; end Check_Reverse_Iteration; ------------------------------- -- Check_Subtype_Definition -- ------------------------------- procedure Check_Subtype_Definition (Comp_Type : Entity_Id) is begin if not Present (Subt) then return; end if; if Is_Anonymous_Access_Type (Entity (Subt)) then if not Is_Anonymous_Access_Type (Comp_Type) then Error_Msg_NE ("component type& is not an anonymous access", Subt, Comp_Type); elsif not Conforming_Types (Designated_Type (Entity (Subt)), Designated_Type (Comp_Type), Fully_Conformant) then Error_Msg_NE ("subtype indication does not match component type&", Subt, Comp_Type); end if; elsif Present (Subt) and then (not Covers (Base_Type (Bas), Comp_Type) or else not Subtypes_Statically_Match (Bas, Comp_Type)) then if Is_Array_Type (Typ) then Error_Msg_NE ("subtype indication does not match component type&", Subt, Comp_Type); else Error_Msg_NE ("subtype indication does not match element type&", Subt, Comp_Type); end if; end if; end Check_Subtype_Definition; --------------------- -- Get_Cursor_Type -- --------------------- function Get_Cursor_Type (Typ : Entity_Id) return Entity_Id is Ent : Entity_Id; begin -- If iterator type is derived, the cursor is declared in the scope -- of the parent type. if Is_Derived_Type (Typ) then Ent := First_Entity (Scope (Etype (Typ))); else Ent := First_Entity (Scope (Typ)); end if; while Present (Ent) loop exit when Chars (Ent) = Name_Cursor; Next_Entity (Ent); end loop; if No (Ent) then return Any_Type; end if; -- The cursor is the target of generated assignments in the -- loop, and cannot have a limited type. if Is_Limited_Type (Etype (Ent)) then Error_Msg_N ("cursor type cannot be limited", N); end if; return Etype (Ent); end Get_Cursor_Type; -- Start of processing for Analyze_Iterator_Specification begin Enter_Name (Def_Id); -- AI12-0151 specifies that when the subtype indication is present, it -- must statically match the type of the array or container element. -- To simplify this check, we introduce a subtype declaration with the -- given subtype indication when it carries a constraint, and rewrite -- the original as a reference to the created subtype entity. if Present (Subt) then if Nkind (Subt) = N_Subtype_Indication then declare S : constant Entity_Id := Make_Temporary (Sloc (Subt), 'S'); Decl : constant Node_Id := Make_Subtype_Declaration (Loc, Defining_Identifier => S, Subtype_Indication => New_Copy_Tree (Subt)); begin Insert_Before (Parent (Parent (N)), Decl); Analyze (Decl); Rewrite (Subt, New_Occurrence_Of (S, Sloc (Subt))); end; -- Ada 2022: the subtype definition may be for an anonymous -- access type. elsif Nkind (Subt) = N_Access_Definition then declare S : constant Entity_Id := Make_Temporary (Sloc (Subt), 'S'); Decl : Node_Id; begin if Present (Subtype_Mark (Subt)) then Decl := Make_Full_Type_Declaration (Loc, Defining_Identifier => S, Type_Definition => Make_Access_To_Object_Definition (Loc, All_Present => True, Subtype_Indication => New_Copy_Tree (Subtype_Mark (Subt)))); else Decl := Make_Full_Type_Declaration (Loc, Defining_Identifier => S, Type_Definition => New_Copy_Tree (Access_To_Subprogram_Definition (Subt))); end if; Insert_Before (Parent (Parent (N)), Decl); Analyze (Decl); Freeze_Before (First (Statements (Parent (Parent (N)))), S); Rewrite (Subt, New_Occurrence_Of (S, Sloc (Subt))); end; else Analyze (Subt); end if; -- Save entity of subtype indication for subsequent check Bas := Entity (Subt); end if; Preanalyze_Range (Iter_Name); -- If the domain of iteration is a function call, make sure the function -- itself is frozen. This is an issue if this is a local expression -- function. if Nkind (Iter_Name) = N_Function_Call and then Is_Entity_Name (Name (Iter_Name)) and then Full_Analysis and then (In_Assertion_Expr = 0 or else Assertions_Enabled) then Freeze_Before (N, Entity (Name (Iter_Name))); end if; -- Set the kind of the loop variable, which is not visible within the -- iterator name. Mutate_Ekind (Def_Id, E_Variable); -- Provide a link between the iterator variable and the container, for -- subsequent use in cross-reference and modification information. if Of_Present (N) then Set_Related_Expression (Def_Id, Iter_Name); -- For a container, the iterator is specified through the aspect if not Is_Array_Type (Etype (Iter_Name)) then declare Iterator : constant Entity_Id := Find_Value_Of_Aspect (Etype (Iter_Name), Aspect_Default_Iterator); I : Interp_Index; It : Interp; begin -- The domain of iteration must implement either the RM -- iterator interface, or the SPARK Iterable aspect. if No (Iterator) then if No (Find_Aspect (Etype (Iter_Name), Aspect_Iterable)) then Error_Msg_NE ("cannot iterate over&", N, Base_Type (Etype (Iter_Name))); return; end if; elsif not Is_Overloaded (Iterator) then Check_Reverse_Iteration (Etype (Iterator)); -- If Iterator is overloaded, use reversible iterator if one is -- available. elsif Is_Overloaded (Iterator) then Get_First_Interp (Iterator, I, It); while Present (It.Nam) loop if Ekind (It.Nam) = E_Function and then Is_Reversible_Iterator (Etype (It.Nam)) then Set_Etype (Iterator, It.Typ); Set_Entity (Iterator, It.Nam); exit; end if; Get_Next_Interp (I, It); end loop; Check_Reverse_Iteration (Etype (Iterator)); end if; end; end if; end if; -- If the domain of iteration is an expression, create a declaration for -- it, so that finalization actions are introduced outside of the loop. -- The declaration must be a renaming (both in GNAT and GNATprove -- modes), because the body of the loop may assign to elements. if not Is_Entity_Name (Iter_Name) -- When the context is a quantified expression, the renaming -- declaration is delayed until the expansion phase if we are -- doing expansion. and then (Nkind (Parent (N)) /= N_Quantified_Expression or else (Operating_Mode = Check_Semantics and then not GNATprove_Mode)) -- Do not perform this expansion when expansion is disabled, where the -- temporary may hide the transformation of a selected component into -- a prefixed function call, and references need to see the original -- expression. and then (Expander_Active or GNATprove_Mode) then declare Id : constant Entity_Id := Make_Temporary (Loc, 'R', Iter_Name); Decl : Node_Id; Act_S : Node_Id; begin -- If the domain of iteration is an array component that depends -- on a discriminant, create actual subtype for it. Preanalysis -- does not generate the actual subtype of a selected component. if Nkind (Iter_Name) = N_Selected_Component and then Is_Array_Type (Etype (Iter_Name)) then Act_S := Build_Actual_Subtype_Of_Component (Etype (Selector_Name (Iter_Name)), Iter_Name); Insert_Action (N, Act_S); if Present (Act_S) then Typ := Defining_Identifier (Act_S); else Typ := Etype (Iter_Name); end if; else Typ := Etype (Iter_Name); -- Verify that the expression produces an iterator if not Of_Present (N) and then not Is_Iterator (Typ) and then not Is_Array_Type (Typ) and then No (Find_Aspect (Typ, Aspect_Iterable)) then Error_Msg_N ("expect object that implements iterator interface", Iter_Name); end if; end if; -- Protect against malformed iterator if Typ = Any_Type then Error_Msg_N ("invalid expression in loop iterator", Iter_Name); return; end if; if not Of_Present (N) then Check_Reverse_Iteration (Typ); end if; -- For an element iteration over a slice, we must complete -- the resolution and expansion of the slice bounds. These -- can be arbitrary expressions, and the preanalysis that -- was performed in preparation for the iteration may have -- generated an itype whose bounds must be fully expanded. -- We set the parent node to provide a proper insertion -- point for generated actions, if any. if Nkind (Iter_Name) = N_Slice and then Nkind (Discrete_Range (Iter_Name)) = N_Range and then not Analyzed (Discrete_Range (Iter_Name)) then declare Indx : constant Node_Id := Entity (First_Index (Etype (Iter_Name))); begin Set_Parent (Indx, Iter_Name); Resolve (Scalar_Range (Indx), Etype (Indx)); end; end if; -- The name in the renaming declaration may be a function call. -- Indicate that it does not come from source, to suppress -- spurious warnings on renamings of parameterless functions, -- a common enough idiom in user-defined iterators. Decl := Make_Object_Renaming_Declaration (Loc, Defining_Identifier => Id, Subtype_Mark => New_Occurrence_Of (Typ, Loc), Name => New_Copy_Tree (Iter_Name, New_Sloc => Loc)); Insert_Actions (Parent (Parent (N)), New_List (Decl)); Rewrite (Name (N), New_Occurrence_Of (Id, Loc)); Analyze (Name (N)); Set_Etype (Id, Typ); Set_Etype (Name (N), Typ); end; -- Container is an entity or an array with uncontrolled components, or -- else it is a container iterator given by a function call, typically -- called Iterate in the case of predefined containers, even though -- Iterate is not a reserved name. What matters is that the return type -- of the function is an iterator type. elsif Is_Entity_Name (Iter_Name) then Analyze (Iter_Name); if Nkind (Iter_Name) = N_Function_Call then declare C : constant Node_Id := Name (Iter_Name); I : Interp_Index; It : Interp; begin if not Is_Overloaded (Iter_Name) then Resolve (Iter_Name, Etype (C)); else Get_First_Interp (C, I, It); while It.Typ /= Empty loop if Reverse_Present (N) then if Is_Reversible_Iterator (It.Typ) then Resolve (Iter_Name, It.Typ); exit; end if; elsif Is_Iterator (It.Typ) then Resolve (Iter_Name, It.Typ); exit; end if; Get_Next_Interp (I, It); end loop; end if; end; -- Domain of iteration is not overloaded else Resolve (Iter_Name); end if; if not Of_Present (N) then Check_Reverse_Iteration (Etype (Iter_Name)); end if; end if; -- Get base type of container, for proper retrieval of Cursor type -- and primitive operations. Typ := Base_Type (Etype (Iter_Name)); if Is_Array_Type (Typ) then if Of_Present (N) then Set_Etype (Def_Id, Component_Type (Typ)); -- The loop variable is aliased if the array components are -- aliased. Likewise for the independent aspect. Set_Is_Aliased (Def_Id, Has_Aliased_Components (Typ)); Set_Is_Independent (Def_Id, Has_Independent_Components (Typ)); -- AI12-0047 stipulates that the domain (array or container) -- cannot be a component that depends on a discriminant if the -- enclosing object is mutable, to prevent a modification of the -- domain of iteration in the course of an iteration. -- If the object is an expression it has been captured in a -- temporary, so examine original node. if Nkind (Original_Node (Iter_Name)) = N_Selected_Component and then Is_Dependent_Component_Of_Mutable_Object (Original_Node (Iter_Name)) then Error_Msg_N ("iterable name cannot be a discriminant-dependent " & "component of a mutable object", N); end if; Check_Subtype_Definition (Component_Type (Typ)); -- Here we have a missing Range attribute else Error_Msg_N ("missing Range attribute in iteration over an array", N); -- In Ada 2012 mode, this may be an attempt at an iterator if Ada_Version >= Ada_2012 then Error_Msg_NE ("\if& is meant to designate an element of the array, use OF", N, Def_Id); end if; -- Prevent cascaded errors Mutate_Ekind (Def_Id, E_Loop_Parameter); Set_Etype (Def_Id, Etype (First_Index (Typ))); end if; -- Check for type error in iterator elsif Typ = Any_Type then return; -- Iteration over a container else Mutate_Ekind (Def_Id, E_Loop_Parameter); Error_Msg_Ada_2012_Feature ("container iterator", Sloc (N)); -- OF present if Of_Present (N) then if Has_Aspect (Typ, Aspect_Iterable) then declare Elt : constant Entity_Id := Get_Iterable_Type_Primitive (Typ, Name_Element); begin if No (Elt) then Error_Msg_N ("missing Element primitive for iteration", N); else Set_Etype (Def_Id, Etype (Elt)); Check_Reverse_Iteration (Typ); end if; end; Check_Subtype_Definition (Etype (Def_Id)); -- For a predefined container, the type of the loop variable is -- the Iterator_Element aspect of the container type. else declare Element : constant Entity_Id := Find_Value_Of_Aspect (Typ, Aspect_Iterator_Element); Iterator : constant Entity_Id := Find_Value_Of_Aspect (Typ, Aspect_Default_Iterator); Orig_Iter_Name : constant Node_Id := Original_Node (Iter_Name); Cursor_Type : Entity_Id; begin if No (Element) then Error_Msg_NE ("cannot iterate over&", N, Typ); return; else Set_Etype (Def_Id, Entity (Element)); Cursor_Type := Get_Cursor_Type (Typ); pragma Assert (Present (Cursor_Type)); Check_Subtype_Definition (Etype (Def_Id)); -- If the container has a variable indexing aspect, the -- element is a variable and is modifiable in the loop. if Has_Aspect (Typ, Aspect_Variable_Indexing) then Mutate_Ekind (Def_Id, E_Variable); end if; -- If the container is a constant, iterating over it -- requires a Constant_Indexing operation. if not Is_Variable (Iter_Name) and then not Has_Aspect (Typ, Aspect_Constant_Indexing) then Error_Msg_N ("iteration over constant container require " & "constant_indexing aspect", N); -- The Iterate function may have an in_out parameter, -- and a constant container is thus illegal. elsif Present (Iterator) and then Ekind (Entity (Iterator)) = E_Function and then Ekind (First_Formal (Entity (Iterator))) /= E_In_Parameter and then not Is_Variable (Iter_Name) then Error_Msg_N ("variable container expected", N); end if; -- Detect a case where the iterator denotes a component -- of a mutable object which depends on a discriminant. -- Note that the iterator may denote a function call in -- qualified form, in which case this check should not -- be performed. if Nkind (Orig_Iter_Name) = N_Selected_Component and then Present (Entity (Selector_Name (Orig_Iter_Name))) and then Ekind (Entity (Selector_Name (Orig_Iter_Name))) in E_Component | E_Discriminant and then Is_Dependent_Component_Of_Mutable_Object (Orig_Iter_Name) then Error_Msg_N ("container cannot be a discriminant-dependent " & "component of a mutable object", N); end if; end if; end; end if; -- IN iterator, domain is a range, or a call to Iterate function else -- For an iteration of the form IN, the name must denote an -- iterator, typically the result of a call to Iterate. Give a -- useful error message when the name is a container by itself. -- The type may be a formal container type, which has to have -- an Iterable aspect detailing the required primitives. if Is_Entity_Name (Original_Node (Name (N))) and then not Is_Iterator (Typ) then if Has_Aspect (Typ, Aspect_Iterable) then null; elsif not Has_Aspect (Typ, Aspect_Iterator_Element) then Error_Msg_NE ("cannot iterate over&", Name (N), Typ); else Error_Msg_N ("name must be an iterator, not a container", Name (N)); end if; if Has_Aspect (Typ, Aspect_Iterable) then null; else Error_Msg_NE ("\to iterate directly over the elements of a container, " & "write `of &`", Name (N), Original_Node (Name (N))); -- No point in continuing analysis of iterator spec return; end if; end if; -- If the name is a call (typically prefixed) to some Iterate -- function, it has been rewritten as an object declaration. -- If that object is a selected component, verify that it is not -- a component of an unconstrained mutable object. if Nkind (Iter_Name) = N_Identifier or else (not Expander_Active and Comes_From_Source (Iter_Name)) then declare Orig_Node : constant Node_Id := Original_Node (Iter_Name); Iter_Kind : constant Node_Kind := Nkind (Orig_Node); Obj : Node_Id; begin if Iter_Kind = N_Selected_Component then Obj := Prefix (Orig_Node); elsif Iter_Kind = N_Function_Call then Obj := First_Actual (Orig_Node); -- If neither, the name comes from source else Obj := Iter_Name; end if; if Nkind (Obj) = N_Selected_Component and then Is_Dependent_Component_Of_Mutable_Object (Obj) then Error_Msg_N ("container cannot be a discriminant-dependent " & "component of a mutable object", N); end if; end; end if; -- The result type of Iterate function is the classwide type of -- the interface parent. We need the specific Cursor type defined -- in the container package. We obtain it by name for a predefined -- container, or through the Iterable aspect for a formal one. if Has_Aspect (Typ, Aspect_Iterable) then Set_Etype (Def_Id, Get_Cursor_Type (Parent (Find_Value_Of_Aspect (Typ, Aspect_Iterable)), Typ)); else Set_Etype (Def_Id, Get_Cursor_Type (Typ)); Check_Reverse_Iteration (Etype (Iter_Name)); end if; end if; end if; if Present (Iterator_Filter (N)) then -- Preanalyze the filter. Expansion will take place when enclosing -- loop is expanded. Preanalyze_And_Resolve (Iterator_Filter (N), Standard_Boolean); end if; end Analyze_Iterator_Specification; ------------------- -- Analyze_Label -- ------------------- -- Note: the semantic work required for analyzing labels (setting them as -- reachable) was done in a prepass through the statements in the block, -- so that forward gotos would be properly handled. See Analyze_Statements -- for further details. The only processing required here is to deal with -- optimizations that depend on an assumption of sequential control flow, -- since of course the occurrence of a label breaks this assumption. procedure Analyze_Label (N : Node_Id) is pragma Warnings (Off, N); begin Kill_Current_Values; end Analyze_Label; -------------------------- -- Analyze_Label_Entity -- -------------------------- procedure Analyze_Label_Entity (E : Entity_Id) is begin Mutate_Ekind (E, E_Label); Set_Etype (E, Standard_Void_Type); Set_Enclosing_Scope (E, Current_Scope); Set_Reachable (E, True); end Analyze_Label_Entity; ------------------------------------------ -- Analyze_Loop_Parameter_Specification -- ------------------------------------------ procedure Analyze_Loop_Parameter_Specification (N : Node_Id) is Loop_Nod : constant Node_Id := Parent (Parent (N)); procedure Check_Controlled_Array_Attribute (DS : Node_Id); -- If the bounds are given by a 'Range reference on a function call -- that returns a controlled array, introduce an explicit declaration -- to capture the bounds, so that the function result can be finalized -- in timely fashion. procedure Check_Predicate_Use (T : Entity_Id); -- Diagnose Attempt to iterate through non-static predicate. Note that -- a type with inherited predicates may have both static and dynamic -- forms. In this case it is not sufficient to check the static -- predicate function only, look for a dynamic predicate aspect as well. procedure Process_Bounds (R : Node_Id); -- If the iteration is given by a range, create temporaries and -- assignment statements block to capture the bounds and perform -- required finalization actions in case a bound includes a function -- call that uses the temporary stack. We first preanalyze a copy of -- the range in order to determine the expected type, and analyze and -- resolve the original bounds. -------------------------------------- -- Check_Controlled_Array_Attribute -- -------------------------------------- procedure Check_Controlled_Array_Attribute (DS : Node_Id) is begin if Nkind (DS) = N_Attribute_Reference and then Is_Entity_Name (Prefix (DS)) and then Ekind (Entity (Prefix (DS))) = E_Function and then Is_Array_Type (Etype (Entity (Prefix (DS)))) and then Is_Controlled (Component_Type (Etype (Entity (Prefix (DS))))) and then Expander_Active then declare Loc : constant Source_Ptr := Sloc (N); Arr : constant Entity_Id := Etype (Entity (Prefix (DS))); Indx : constant Entity_Id := Base_Type (Etype (First_Index (Arr))); Subt : constant Entity_Id := Make_Temporary (Loc, 'S'); Decl : Node_Id; begin Decl := Make_Subtype_Declaration (Loc, Defining_Identifier => Subt, Subtype_Indication => Make_Subtype_Indication (Loc, Subtype_Mark => New_Occurrence_Of (Indx, Loc), Constraint => Make_Range_Constraint (Loc, Relocate_Node (DS)))); Insert_Before (Loop_Nod, Decl); Analyze (Decl); Rewrite (DS, Make_Attribute_Reference (Loc, Prefix => New_Occurrence_Of (Subt, Loc), Attribute_Name => Attribute_Name (DS))); Analyze (DS); end; end if; end Check_Controlled_Array_Attribute; ------------------------- -- Check_Predicate_Use -- ------------------------- procedure Check_Predicate_Use (T : Entity_Id) is begin -- A predicated subtype is illegal in loops and related constructs -- if the predicate is not static, or if it is a non-static subtype -- of a statically predicated subtype. if Is_Discrete_Type (T) and then Has_Predicates (T) and then (not Has_Static_Predicate (T) or else not Is_Static_Subtype (T) or else Has_Dynamic_Predicate_Aspect (T)) then -- Seems a confusing message for the case of a static predicate -- with a non-static subtype??? Bad_Predicated_Subtype_Use ("cannot use subtype& with non-static predicate for loop " & "iteration", Discrete_Subtype_Definition (N), T, Suggest_Static => True); elsif Inside_A_Generic and then Is_Generic_Formal (T) and then Is_Discrete_Type (T) then Set_No_Dynamic_Predicate_On_Actual (T); end if; end Check_Predicate_Use; -------------------- -- Process_Bounds -- -------------------- procedure Process_Bounds (R : Node_Id) is Loc : constant Source_Ptr := Sloc (N); function One_Bound (Original_Bound : Node_Id; Analyzed_Bound : Node_Id; Typ : Entity_Id) return Node_Id; -- Capture value of bound and return captured value --------------- -- One_Bound -- --------------- function One_Bound (Original_Bound : Node_Id; Analyzed_Bound : Node_Id; Typ : Entity_Id) return Node_Id is Assign : Node_Id; Decl : Node_Id; Id : Entity_Id; begin -- If the bound is a constant or an object, no need for a separate -- declaration. If the bound is the result of previous expansion -- it is already analyzed and should not be modified. Note that -- the Bound will be resolved later, if needed, as part of the -- call to Make_Index (literal bounds may need to be resolved to -- type Integer). if Analyzed (Original_Bound) then return Original_Bound; elsif Nkind (Analyzed_Bound) in N_Integer_Literal | N_Character_Literal or else Is_Entity_Name (Analyzed_Bound) then Analyze_And_Resolve (Original_Bound, Typ); return Original_Bound; elsif Inside_Class_Condition_Preanalysis then Analyze_And_Resolve (Original_Bound, Typ); return Original_Bound; end if; -- Normally, the best approach is simply to generate a constant -- declaration that captures the bound. However, there is a nasty -- case where this is wrong. If the bound is complex, and has a -- possible use of the secondary stack, we need to generate a -- separate assignment statement to ensure the creation of a block -- which will release the secondary stack. -- We prefer the constant declaration, since it leaves us with a -- proper trace of the value, useful in optimizations that get rid -- of junk range checks. if not Has_Sec_Stack_Call (Analyzed_Bound) then Analyze_And_Resolve (Original_Bound, Typ); -- Ensure that the bound is valid. This check should not be -- generated when the range belongs to a quantified expression -- as the construct is still not expanded into its final form. if Nkind (Parent (R)) /= N_Loop_Parameter_Specification or else Nkind (Parent (Parent (R))) /= N_Quantified_Expression then Ensure_Valid (Original_Bound); end if; Force_Evaluation (Original_Bound); return Original_Bound; end if; Id := Make_Temporary (Loc, 'R', Original_Bound); -- Here we make a declaration with a separate assignment -- statement, and insert before loop header. Decl := Make_Object_Declaration (Loc, Defining_Identifier => Id, Object_Definition => New_Occurrence_Of (Typ, Loc)); Assign := Make_Assignment_Statement (Loc, Name => New_Occurrence_Of (Id, Loc), Expression => Relocate_Node (Original_Bound)); Insert_Actions (Loop_Nod, New_List (Decl, Assign)); -- Now that this temporary variable is initialized we decorate it -- as safe-to-reevaluate to inform to the backend that no further -- asignment will be issued and hence it can be handled as side -- effect free. Note that this decoration must be done when the -- assignment has been analyzed because otherwise it will be -- rejected (see Analyze_Assignment). Set_Is_Safe_To_Reevaluate (Id); Rewrite (Original_Bound, New_Occurrence_Of (Id, Loc)); if Nkind (Assign) = N_Assignment_Statement then return Expression (Assign); else return Original_Bound; end if; end One_Bound; Hi : constant Node_Id := High_Bound (R); Lo : constant Node_Id := Low_Bound (R); R_Copy : constant Node_Id := New_Copy_Tree (R); New_Hi : Node_Id; New_Lo : Node_Id; Typ : Entity_Id; -- Start of processing for Process_Bounds begin Set_Parent (R_Copy, Parent (R)); Preanalyze_Range (R_Copy); Typ := Etype (R_Copy); -- If the type of the discrete range is Universal_Integer, then the -- bound's type must be resolved to Integer, and any object used to -- hold the bound must also have type Integer, unless the literal -- bounds are constant-folded expressions with a user-defined type. if Typ = Universal_Integer then if Nkind (Lo) = N_Integer_Literal and then Present (Etype (Lo)) and then Scope (Etype (Lo)) /= Standard_Standard then Typ := Etype (Lo); elsif Nkind (Hi) = N_Integer_Literal and then Present (Etype (Hi)) and then Scope (Etype (Hi)) /= Standard_Standard then Typ := Etype (Hi); else Typ := Standard_Integer; end if; end if; Set_Etype (R, Typ); New_Lo := One_Bound (Lo, Low_Bound (R_Copy), Typ); New_Hi := One_Bound (Hi, High_Bound (R_Copy), Typ); -- Propagate staticness to loop range itself, in case the -- corresponding subtype is static. if New_Lo /= Lo and then Is_OK_Static_Expression (New_Lo) then Rewrite (Low_Bound (R), New_Copy (New_Lo)); end if; if New_Hi /= Hi and then Is_OK_Static_Expression (New_Hi) then Rewrite (High_Bound (R), New_Copy (New_Hi)); end if; end Process_Bounds; -- Local variables DS : constant Node_Id := Discrete_Subtype_Definition (N); Id : constant Entity_Id := Defining_Identifier (N); DS_Copy : Node_Id; -- Start of processing for Analyze_Loop_Parameter_Specification begin Enter_Name (Id); -- We always consider the loop variable to be referenced, since the loop -- may be used just for counting purposes. Generate_Reference (Id, N, ' '); -- Check for the case of loop variable hiding a local variable (used -- later on to give a nice warning if the hidden variable is never -- assigned). declare H : constant Entity_Id := Homonym (Id); begin if Present (H) and then Ekind (H) = E_Variable and then Is_Discrete_Type (Etype (H)) and then Enclosing_Dynamic_Scope (H) = Enclosing_Dynamic_Scope (Id) then Set_Hiding_Loop_Variable (H, Id); end if; end; -- Analyze the subtype definition and create temporaries for the bounds. -- Do not evaluate the range when preanalyzing a quantified expression -- because bounds expressed as function calls with side effects will be -- incorrectly replicated. if Nkind (DS) = N_Range and then Expander_Active and then Nkind (Parent (N)) /= N_Quantified_Expression then Process_Bounds (DS); -- Either the expander not active or the range of iteration is a subtype -- indication, an entity, or a function call that yields an aggregate or -- a container. else DS_Copy := New_Copy_Tree (DS); Set_Parent (DS_Copy, Parent (DS)); Preanalyze_Range (DS_Copy); -- Ada 2012: If the domain of iteration is: -- a) a function call, -- b) an identifier that is not a type, -- c) an attribute reference 'Old (within a postcondition), -- d) an unchecked conversion or a qualified expression with -- the proper iterator type. -- then it is an iteration over a container. It was classified as -- a loop specification by the parser, and must be rewritten now -- to activate container iteration. The last case will occur within -- an expanded inlined call, where the expansion wraps an actual in -- an unchecked conversion when needed. The expression of the -- conversion is always an object. if Nkind (DS_Copy) = N_Function_Call or else (Is_Entity_Name (DS_Copy) and then not Is_Type (Entity (DS_Copy))) or else (Nkind (DS_Copy) = N_Attribute_Reference and then Attribute_Name (DS_Copy) in Name_Loop_Entry | Name_Old) or else Has_Aspect (Etype (DS_Copy), Aspect_Iterable) or else Nkind (DS_Copy) = N_Unchecked_Type_Conversion or else (Nkind (DS_Copy) = N_Qualified_Expression and then Is_Iterator (Etype (DS_Copy))) then -- This is an iterator specification. Rewrite it as such and -- analyze it to capture function calls that may require -- finalization actions. declare I_Spec : constant Node_Id := Make_Iterator_Specification (Sloc (N), Defining_Identifier => Relocate_Node (Id), Name => DS_Copy, Subtype_Indication => Empty, Reverse_Present => Reverse_Present (N)); Scheme : constant Node_Id := Parent (N); begin Set_Iterator_Specification (Scheme, I_Spec); Set_Loop_Parameter_Specification (Scheme, Empty); Set_Iterator_Filter (I_Spec, Relocate_Node (Iterator_Filter (N))); Analyze_Iterator_Specification (I_Spec); -- In a generic context, analyze the original domain of -- iteration, for name capture. if not Expander_Active then Analyze (DS); end if; -- Set kind of loop parameter, which may be used in the -- subsequent analysis of the condition in a quantified -- expression. Mutate_Ekind (Id, E_Loop_Parameter); return; end; -- Domain of iteration is not a function call, and is side-effect -- free. else -- A quantified expression that appears in a pre/post condition -- is preanalyzed several times. If the range is given by an -- attribute reference it is rewritten as a range, and this is -- done even with expansion disabled. If the type is already set -- do not reanalyze, because a range with static bounds may be -- typed Integer by default. if Nkind (Parent (N)) = N_Quantified_Expression and then Present (Etype (DS)) then null; else Analyze (DS); end if; end if; end if; if DS = Error then return; end if; -- Some additional checks if we are iterating through a type if Is_Entity_Name (DS) and then Present (Entity (DS)) and then Is_Type (Entity (DS)) then -- The subtype indication may denote the completion of an incomplete -- type declaration. if Ekind (Entity (DS)) = E_Incomplete_Type then Set_Entity (DS, Get_Full_View (Entity (DS))); Set_Etype (DS, Entity (DS)); end if; Check_Predicate_Use (Entity (DS)); end if; -- Error if not discrete type if not Is_Discrete_Type (Etype (DS)) then Wrong_Type (DS, Any_Discrete); Set_Etype (DS, Any_Type); end if; Check_Controlled_Array_Attribute (DS); if Nkind (DS) = N_Subtype_Indication then Check_Predicate_Use (Entity (Subtype_Mark (DS))); end if; if Nkind (DS) not in N_Raise_xxx_Error then Make_Index (DS, N); end if; Mutate_Ekind (Id, E_Loop_Parameter); -- A quantified expression which appears in a pre- or post-condition may -- be analyzed multiple times. The analysis of the range creates several -- itypes which reside in different scopes depending on whether the pre- -- or post-condition has been expanded. Update the type of the loop -- variable to reflect the proper itype at each stage of analysis. -- Loop_Nod might not be present when we are preanalyzing a class-wide -- pre/postcondition since preanalysis occurs in a place unrelated to -- the actual code and the quantified expression may be the outermost -- expression of the class-wide condition. if No (Etype (Id)) or else Etype (Id) = Any_Type or else (Present (Etype (Id)) and then Is_Itype (Etype (Id)) and then Present (Loop_Nod) and then Nkind (Parent (Loop_Nod)) = N_Expression_With_Actions and then Nkind (Original_Node (Parent (Loop_Nod))) = N_Quantified_Expression) then Set_Etype (Id, Etype (DS)); end if; -- Treat a range as an implicit reference to the type, to inhibit -- spurious warnings. Generate_Reference (Base_Type (Etype (DS)), N, ' '); Set_Is_Known_Valid (Id, True); -- The loop is not a declarative part, so the loop variable must be -- frozen explicitly. Do not freeze while preanalyzing a quantified -- expression because the freeze node will not be inserted into the -- tree due to flag Is_Spec_Expression being set. if Nkind (Parent (N)) /= N_Quantified_Expression then declare Flist : constant List_Id := Freeze_Entity (Id, N); begin if Is_Non_Empty_List (Flist) then Insert_Actions (N, Flist); end if; end; end if; -- Case where we have a range or a subtype, get type bounds if Nkind (DS) in N_Range | N_Subtype_Indication and then not Error_Posted (DS) and then Etype (DS) /= Any_Type and then Is_Discrete_Type (Etype (DS)) then declare L : Node_Id; H : Node_Id; Null_Range : Boolean := False; begin if Nkind (DS) = N_Range then L := Low_Bound (DS); H := High_Bound (DS); else L := Type_Low_Bound (Underlying_Type (Etype (Subtype_Mark (DS)))); H := Type_High_Bound (Underlying_Type (Etype (Subtype_Mark (DS)))); end if; -- Check for null or possibly null range and issue warning. We -- suppress such messages in generic templates and instances, -- because in practice they tend to be dubious in these cases. The -- check applies as well to rewritten array element loops where a -- null range may be detected statically. if Compile_Time_Compare (L, H, Assume_Valid => True) = GT then if Compile_Time_Compare (L, H, Assume_Valid => False) = GT then -- Since we know the range of the loop is always null, -- set the appropriate flag to remove the loop entirely -- during expansion. Set_Is_Null_Loop (Loop_Nod); Null_Range := True; end if; -- Suppress the warning if inside a generic template or -- instance, since in practice they tend to be dubious in these -- cases since they can result from intended parameterization. if not Inside_A_Generic and then not In_Instance then -- Specialize msg if invalid values could make the loop -- non-null after all. if Null_Range then if Comes_From_Source (N) then Error_Msg_N ("??loop range is null, loop will not execute", DS); end if; -- Here is where the loop could execute because of -- invalid values, so issue appropriate message. elsif Comes_From_Source (N) then Error_Msg_N ("??loop range may be null, loop may not execute", DS); Error_Msg_N ("??can only execute if invalid values are present", DS); end if; end if; -- In either case, suppress warnings in the body of the loop, -- since it is likely that these warnings will be inappropriate -- if the loop never actually executes, which is likely. Set_Suppress_Loop_Warnings (Loop_Nod); -- The other case for a warning is a reverse loop where the -- upper bound is the integer literal zero or one, and the -- lower bound may exceed this value. -- For example, we have -- for J in reverse N .. 1 loop -- In practice, this is very likely to be a case of reversing -- the bounds incorrectly in the range. elsif Reverse_Present (N) and then Nkind (Original_Node (H)) = N_Integer_Literal and then (Intval (Original_Node (H)) = Uint_0 or else Intval (Original_Node (H)) = Uint_1) then -- Lower bound may in fact be known and known not to exceed -- upper bound (e.g. reverse 0 .. 1) and that's OK. if Compile_Time_Known_Value (L) and then Expr_Value (L) <= Expr_Value (H) then null; -- Otherwise warning is warranted else Error_Msg_N ("??loop range may be null", DS); Error_Msg_N ("\??bounds may be wrong way round", DS); end if; end if; -- Check if either bound is known to be outside the range of the -- loop parameter type, this is e.g. the case of a loop from -- 20..X where the type is 1..19. -- Such a loop is dubious since either it raises CE or it executes -- zero times, and that cannot be useful! if Etype (DS) /= Any_Type and then not Error_Posted (DS) and then Nkind (DS) = N_Subtype_Indication and then Nkind (Constraint (DS)) = N_Range_Constraint then declare LLo : constant Node_Id := Low_Bound (Range_Expression (Constraint (DS))); LHi : constant Node_Id := High_Bound (Range_Expression (Constraint (DS))); Bad_Bound : Node_Id := Empty; -- Suspicious loop bound begin -- At this stage L, H are the bounds of the type, and LLo -- Lhi are the low bound and high bound of the loop. if Compile_Time_Compare (LLo, L, Assume_Valid => True) = LT or else Compile_Time_Compare (LLo, H, Assume_Valid => True) = GT then Bad_Bound := LLo; end if; if Compile_Time_Compare (LHi, L, Assume_Valid => True) = LT or else Compile_Time_Compare (LHi, H, Assume_Valid => True) = GT then Bad_Bound := LHi; end if; if Present (Bad_Bound) then Error_Msg_N ("suspicious loop bound out of range of " & "loop subtype??", Bad_Bound); Error_Msg_N ("\loop executes zero times or raises " & "Constraint_Error??", Bad_Bound); end if; if Compile_Time_Compare (LLo, LHi, Assume_Valid => False) = GT then Error_Msg_N ("??constrained range is null", Constraint (DS)); -- Additional constraints on modular types can be -- confusing, add more information. if Ekind (Etype (DS)) = E_Modular_Integer_Subtype then Error_Msg_Uint_1 := Intval (LLo); Error_Msg_Uint_2 := Intval (LHi); Error_Msg_NE ("\iterator has modular type &, " & "so the loop has bounds ^ ..^", Constraint (DS), Subtype_Mark (DS)); end if; Set_Is_Null_Loop (Loop_Nod); Null_Range := True; -- Suppress other warnings about the body of the loop, as -- it will never execute. Set_Suppress_Loop_Warnings (Loop_Nod); end if; end; end if; -- This declare block is about warnings, if we get an exception while -- testing for warnings, we simply abandon the attempt silently. This -- most likely occurs as the result of a previous error, but might -- just be an obscure case we have missed. In either case, not giving -- the warning is perfectly acceptable. exception when others => -- With debug flag K we will get an exception unless an error -- has already occurred (useful for debugging). if Debug_Flag_K then Check_Error_Detected; end if; end; end if; if Present (Iterator_Filter (N)) then Analyze_And_Resolve (Iterator_Filter (N), Standard_Boolean); end if; -- A loop parameter cannot be effectively volatile (SPARK RM 7.1.3(4)). -- This check is relevant only when SPARK_Mode is on as it is not a -- standard Ada legality check. if SPARK_Mode = On and then Is_Effectively_Volatile (Id) then Error_Msg_N ("loop parameter cannot be volatile", Id); end if; end Analyze_Loop_Parameter_Specification; ---------------------------- -- Analyze_Loop_Statement -- ---------------------------- procedure Analyze_Loop_Statement (N : Node_Id) is -- The following exception is raised by routine Prepare_Loop_Statement -- to avoid further analysis of a transformed loop. procedure Prepare_Loop_Statement (Iter : Node_Id; Stop_Processing : out Boolean); -- Determine whether loop statement N with iteration scheme Iter must be -- transformed prior to analysis, and if so, perform it. -- If Stop_Processing is set to True, should stop further processing. ---------------------------- -- Prepare_Loop_Statement -- ---------------------------- procedure Prepare_Loop_Statement (Iter : Node_Id; Stop_Processing : out Boolean) is function Has_Sec_Stack_Default_Iterator (Cont_Typ : Entity_Id) return Boolean; pragma Inline (Has_Sec_Stack_Default_Iterator); -- Determine whether container type Cont_Typ has a default iterator -- that requires secondary stack management. function Is_Sec_Stack_Iteration_Primitive (Cont_Typ : Entity_Id; Iter_Prim_Nam : Name_Id) return Boolean; pragma Inline (Is_Sec_Stack_Iteration_Primitive); -- Determine whether container type Cont_Typ has an iteration routine -- described by its name Iter_Prim_Nam that requires secondary stack -- management. function Is_Wrapped_In_Block (Stmt : Node_Id) return Boolean; pragma Inline (Is_Wrapped_In_Block); -- Determine whether arbitrary statement Stmt is the sole statement -- wrapped within some block, excluding pragmas. procedure Prepare_Iterator_Loop (Iter_Spec : Node_Id; Stop_Processing : out Boolean); pragma Inline (Prepare_Iterator_Loop); -- Prepare an iterator loop with iteration specification Iter_Spec -- for transformation if needed. -- If Stop_Processing is set to True, should stop further processing. procedure Prepare_Param_Spec_Loop (Param_Spec : Node_Id; Stop_Processing : out Boolean); pragma Inline (Prepare_Param_Spec_Loop); -- Prepare a discrete loop with parameter specification Param_Spec -- for transformation if needed. -- If Stop_Processing is set to True, should stop further processing. procedure Wrap_Loop_Statement (Manage_Sec_Stack : Boolean); pragma Inline (Wrap_Loop_Statement); -- Wrap loop statement N within a block. Flag Manage_Sec_Stack must -- be set when the block must mark and release the secondary stack. -- Should stop further processing after calling this procedure. ------------------------------------ -- Has_Sec_Stack_Default_Iterator -- ------------------------------------ function Has_Sec_Stack_Default_Iterator (Cont_Typ : Entity_Id) return Boolean is Def_Iter : constant Node_Id := Find_Value_Of_Aspect (Cont_Typ, Aspect_Default_Iterator); begin return Present (Def_Iter) and then Requires_Transient_Scope (Etype (Def_Iter)); end Has_Sec_Stack_Default_Iterator; -------------------------------------- -- Is_Sec_Stack_Iteration_Primitive -- -------------------------------------- function Is_Sec_Stack_Iteration_Primitive (Cont_Typ : Entity_Id; Iter_Prim_Nam : Name_Id) return Boolean is Iter_Prim : constant Entity_Id := Get_Iterable_Type_Primitive (Cont_Typ, Iter_Prim_Nam); begin return Present (Iter_Prim) and then Requires_Transient_Scope (Etype (Iter_Prim)); end Is_Sec_Stack_Iteration_Primitive; ------------------------- -- Is_Wrapped_In_Block -- ------------------------- function Is_Wrapped_In_Block (Stmt : Node_Id) return Boolean is Blk_HSS : Node_Id; Blk_Id : Entity_Id; Blk_Stmt : Node_Id; begin Blk_Id := Current_Scope; -- The current context is a block. Inspect the statements of the -- block to determine whether it wraps Stmt. if Ekind (Blk_Id) = E_Block and then Present (Block_Node (Blk_Id)) then Blk_HSS := Handled_Statement_Sequence (Parent (Block_Node (Blk_Id))); -- Skip leading pragmas introduced for invariant and predicate -- checks. Blk_Stmt := First (Statements (Blk_HSS)); while Present (Blk_Stmt) and then Nkind (Blk_Stmt) = N_Pragma loop Next (Blk_Stmt); end loop; return Blk_Stmt = Stmt and then No (Next (Blk_Stmt)); end if; return False; end Is_Wrapped_In_Block; --------------------------- -- Prepare_Iterator_Loop -- --------------------------- procedure Prepare_Iterator_Loop (Iter_Spec : Node_Id; Stop_Processing : out Boolean) is Cont_Typ : Entity_Id; Nam : Node_Id; Nam_Copy : Node_Id; begin Stop_Processing := False; -- The iterator specification has syntactic errors. Transform the -- loop into an infinite loop in order to safely perform at least -- some minor analysis. This check must come first. if Error_Posted (Iter_Spec) then Set_Iteration_Scheme (N, Empty); Analyze (N); Stop_Processing := True; -- Nothing to do when the loop is already wrapped in a block elsif Is_Wrapped_In_Block (N) then null; -- Otherwise the iterator loop traverses an array or a container -- and appears in the form -- -- for Def_Id in [reverse] Iterator_Name loop -- for Def_Id [: Subtyp_Indic] of [reverse] Iterable_Name loop else -- Prepare a copy of the iterated name for preanalysis. The -- copy is semi inserted into the tree by setting its Parent -- pointer. Nam := Name (Iter_Spec); Nam_Copy := New_Copy_Tree (Nam); Set_Parent (Nam_Copy, Parent (Nam)); -- Determine what the loop is iterating on Preanalyze_Range (Nam_Copy); Cont_Typ := Etype (Nam_Copy); -- The iterator loop is traversing an array. This case does not -- require any transformation. if Is_Array_Type (Cont_Typ) then null; -- Otherwise unconditionally wrap the loop statement within -- a block. The expansion of iterator loops may relocate the -- iterator outside the loop, thus "leaking" its entity into -- the enclosing scope. Wrapping the loop statement allows -- for multiple iterator loops using the same iterator name -- to coexist within the same scope. -- -- The block must manage the secondary stack when the iterator -- loop is traversing a container using either -- -- * A default iterator obtained on the secondary stack -- -- * Call to Iterate where the iterator is returned on the -- secondary stack. -- -- * Combination of First, Next, and Has_Element where the -- first two return a cursor on the secondary stack. else Wrap_Loop_Statement (Manage_Sec_Stack => Has_Sec_Stack_Default_Iterator (Cont_Typ) or else Has_Sec_Stack_Call (Nam_Copy) or else Is_Sec_Stack_Iteration_Primitive (Cont_Typ, Name_First) or else Is_Sec_Stack_Iteration_Primitive (Cont_Typ, Name_Next)); Stop_Processing := True; end if; end if; end Prepare_Iterator_Loop; ----------------------------- -- Prepare_Param_Spec_Loop -- ----------------------------- procedure Prepare_Param_Spec_Loop (Param_Spec : Node_Id; Stop_Processing : out Boolean) is High : Node_Id; Low : Node_Id; Rng : Node_Id; Rng_Copy : Node_Id; Rng_Typ : Entity_Id; begin Stop_Processing := False; Rng := Discrete_Subtype_Definition (Param_Spec); -- Nothing to do when the loop is already wrapped in a block if Is_Wrapped_In_Block (N) then null; -- The parameter specification appears in the form -- -- for Def_Id in Subtype_Mark Constraint loop elsif Nkind (Rng) = N_Subtype_Indication and then Nkind (Range_Expression (Constraint (Rng))) = N_Range then Rng := Range_Expression (Constraint (Rng)); -- Preanalyze the bounds of the range constraint, setting -- parent fields to associate the copied bounds with the range, -- allowing proper tree climbing during preanalysis. Low := New_Copy_Tree (Low_Bound (Rng)); High := New_Copy_Tree (High_Bound (Rng)); Set_Parent (Low, Rng); Set_Parent (High, Rng); Preanalyze (Low); Preanalyze (High); -- The bounds contain at least one function call that returns -- on the secondary stack. Note that the loop must be wrapped -- only when such a call exists. if Has_Sec_Stack_Call (Low) or else Has_Sec_Stack_Call (High) then Wrap_Loop_Statement (Manage_Sec_Stack => True); Stop_Processing := True; end if; -- Otherwise the parameter specification appears in the form -- -- for Def_Id in Range loop else -- Prepare a copy of the discrete range for preanalysis. The -- copy is semi inserted into the tree by setting its Parent -- pointer. Rng_Copy := New_Copy_Tree (Rng); Set_Parent (Rng_Copy, Parent (Rng)); -- Determine what the loop is iterating on Preanalyze_Range (Rng_Copy); Rng_Typ := Etype (Rng_Copy); -- Wrap the loop statement within a block in order to manage -- the secondary stack when the discrete range is -- -- * Either a Forward_Iterator or a Reverse_Iterator -- -- * Function call whose return type requires finalization -- actions. -- ??? it is unclear why using Has_Sec_Stack_Call directly on -- the discrete range causes the freeze node of an itype to be -- in the wrong scope in complex assertion expressions. if Is_Iterator (Rng_Typ) or else (Nkind (Rng_Copy) = N_Function_Call and then Needs_Finalization (Rng_Typ)) then Wrap_Loop_Statement (Manage_Sec_Stack => True); Stop_Processing := True; end if; end if; end Prepare_Param_Spec_Loop; ------------------------- -- Wrap_Loop_Statement -- ------------------------- procedure Wrap_Loop_Statement (Manage_Sec_Stack : Boolean) is Loc : constant Source_Ptr := Sloc (N); Blk : Node_Id; Blk_Id : Entity_Id; begin Blk := Make_Block_Statement (Loc, Declarations => New_List, Handled_Statement_Sequence => Make_Handled_Sequence_Of_Statements (Loc, Statements => New_List (Relocate_Node (N)))); Add_Block_Identifier (Blk, Blk_Id); Set_Uses_Sec_Stack (Blk_Id, Manage_Sec_Stack); Rewrite (N, Blk); Analyze (N); end Wrap_Loop_Statement; -- Local variables Iter_Spec : constant Node_Id := Iterator_Specification (Iter); Param_Spec : constant Node_Id := Loop_Parameter_Specification (Iter); -- Start of processing for Prepare_Loop_Statement begin Stop_Processing := False; if Present (Iter_Spec) then Prepare_Iterator_Loop (Iter_Spec, Stop_Processing); elsif Present (Param_Spec) then Prepare_Param_Spec_Loop (Param_Spec, Stop_Processing); end if; end Prepare_Loop_Statement; -- Local declarations Id : constant Node_Id := Identifier (N); Iter : constant Node_Id := Iteration_Scheme (N); Loc : constant Source_Ptr := Sloc (N); Ent : Entity_Id; Stmt : Node_Id; -- Start of processing for Analyze_Loop_Statement begin if Present (Id) then -- Make name visible, e.g. for use in exit statements. Loop labels -- are always considered to be referenced. Analyze (Id); Ent := Entity (Id); -- Guard against serious error (typically, a scope mismatch when -- semantic analysis is requested) by creating loop entity to -- continue analysis. if No (Ent) then if Total_Errors_Detected /= 0 then Ent := New_Internal_Entity (E_Loop, Current_Scope, Loc, 'L'); else raise Program_Error; end if; -- Verify that the loop name is hot hidden by an unrelated -- declaration in an inner scope. elsif Ekind (Ent) /= E_Label and then Ekind (Ent) /= E_Loop then Error_Msg_Sloc := Sloc (Ent); Error_Msg_N ("implicit label declaration for & is hidden#", Id); if Present (Homonym (Ent)) and then Ekind (Homonym (Ent)) = E_Label then Set_Entity (Id, Ent); Mutate_Ekind (Ent, E_Loop); end if; else Generate_Reference (Ent, N, ' '); Generate_Definition (Ent); -- If we found a label, mark its type. If not, ignore it, since it -- means we have a conflicting declaration, which would already -- have been diagnosed at declaration time. Set Label_Construct -- of the implicit label declaration, which is not created by the -- parser for generic units. if Ekind (Ent) = E_Label then Reinit_Field_To_Zero (Ent, F_Enclosing_Scope); Mutate_Ekind (Ent, E_Loop); if Nkind (Parent (Ent)) = N_Implicit_Label_Declaration then Set_Label_Construct (Parent (Ent), N); end if; end if; end if; -- Case of no identifier present. Create one and attach it to the -- loop statement for use as a scope and as a reference for later -- expansions. Indicate that the label does not come from source, -- and attach it to the loop statement so it is part of the tree, -- even without a full declaration. else Ent := New_Internal_Entity (E_Loop, Current_Scope, Loc, 'L'); Set_Etype (Ent, Standard_Void_Type); Set_Identifier (N, New_Occurrence_Of (Ent, Loc)); Set_Parent (Ent, N); Set_Has_Created_Identifier (N); end if; -- Determine whether the loop statement must be transformed prior to -- analysis, and if so, perform it. This early modification is needed -- when: -- -- * The loop has an erroneous iteration scheme. In this case the -- loop is converted into an infinite loop in order to perform -- minor analysis. -- -- * The loop is an Ada 2012 iterator loop. In this case the loop is -- wrapped within a block to provide a local scope for the iterator. -- If the iterator specification requires the secondary stack in any -- way, the block is marked in order to manage it. -- -- * The loop is using a parameter specification where the discrete -- range requires the secondary stack. In this case the loop is -- wrapped within a block in order to manage the secondary stack. if Present (Iter) then declare Stop_Processing : Boolean; begin Prepare_Loop_Statement (Iter, Stop_Processing); if Stop_Processing then return; end if; end; end if; -- Kill current values on entry to loop, since statements in the body of -- the loop may have been executed before the loop is entered. Similarly -- we kill values after the loop, since we do not know that the body of -- the loop was executed. Kill_Current_Values; Push_Scope (Ent); Analyze_Iteration_Scheme (Iter); -- Check for following case which merits a warning if the type E of is -- a multi-dimensional array (and no explicit subscript ranges present). -- for J in E'Range -- for K in E'Range if Present (Iter) and then Present (Loop_Parameter_Specification (Iter)) then declare LPS : constant Node_Id := Loop_Parameter_Specification (Iter); DSD : constant Node_Id := Original_Node (Discrete_Subtype_Definition (LPS)); begin if Nkind (DSD) = N_Attribute_Reference and then Attribute_Name (DSD) = Name_Range and then No (Expressions (DSD)) then declare Typ : constant Entity_Id := Etype (Prefix (DSD)); begin if Is_Array_Type (Typ) and then Number_Dimensions (Typ) > 1 and then Nkind (Parent (N)) = N_Loop_Statement and then Present (Iteration_Scheme (Parent (N))) then declare OIter : constant Node_Id := Iteration_Scheme (Parent (N)); OLPS : constant Node_Id := Loop_Parameter_Specification (OIter); ODSD : constant Node_Id := Original_Node (Discrete_Subtype_Definition (OLPS)); begin if Nkind (ODSD) = N_Attribute_Reference and then Attribute_Name (ODSD) = Name_Range and then No (Expressions (ODSD)) and then Etype (Prefix (ODSD)) = Typ then Error_Msg_Sloc := Sloc (ODSD); Error_Msg_N ("inner range same as outer range#??", DSD); end if; end; end if; end; end if; end; end if; -- Analyze the statements of the body except in the case of an Ada 2012 -- iterator with the expander active. In this case the expander will do -- a rewrite of the loop into a while loop. We will then analyze the -- loop body when we analyze this while loop. -- We need to do this delay because if the container is for indefinite -- types the actual subtype of the components will only be determined -- when the cursor declaration is analyzed. -- If the expander is not active then we want to analyze the loop body -- now even in the Ada 2012 iterator case, since the rewriting will not -- be done. Insert the loop variable in the current scope, if not done -- when analysing the iteration scheme. Set its kind properly to detect -- improper uses in the loop body. -- In GNATprove mode, we do one of the above depending on the kind of -- loop. If it is an iterator over an array, then we do not analyze the -- loop now. We will analyze it after it has been rewritten by the -- special SPARK expansion which is activated in GNATprove mode. We need -- to do this so that other expansions that should occur in GNATprove -- mode take into account the specificities of the rewritten loop, in -- particular the introduction of a renaming (which needs to be -- expanded). -- In other cases in GNATprove mode then we want to analyze the loop -- body now, since no rewriting will occur. Within a generic the -- GNATprove mode is irrelevant, we must analyze the generic for -- non-local name capture. if Present (Iter) and then Present (Iterator_Specification (Iter)) then if GNATprove_Mode and then Is_Iterator_Over_Array (Iterator_Specification (Iter)) and then not Inside_A_Generic then null; elsif not Expander_Active then declare I_Spec : constant Node_Id := Iterator_Specification (Iter); Id : constant Entity_Id := Defining_Identifier (I_Spec); begin if Scope (Id) /= Current_Scope then Enter_Name (Id); end if; -- In an element iterator, the loop parameter is a variable if -- the domain of iteration (container or array) is a variable. if not Of_Present (I_Spec) or else not Is_Variable (Name (I_Spec)) then Mutate_Ekind (Id, E_Loop_Parameter); end if; end; Analyze_Statements (Statements (N)); end if; else -- Pre-Ada2012 for-loops and while loops Analyze_Statements (Statements (N)); end if; -- If the loop has no side effects, mark it for removal. if Side_Effect_Free_Loop (N) then Set_Is_Null_Loop (N); end if; -- When the iteration scheme of a loop contains attribute 'Loop_Entry, -- the loop is transformed into a conditional block. Retrieve the loop. Stmt := N; if Subject_To_Loop_Entry_Attributes (Stmt) then Stmt := Find_Loop_In_Conditional_Block (Stmt); end if; -- Finish up processing for the loop. We kill all current values, since -- in general we don't know if the statements in the loop have been -- executed. We could do a bit better than this with a loop that we -- know will execute at least once, but it's not worth the trouble and -- the front end is not in the business of flow tracing. Process_End_Label (Stmt, 'e', Ent); End_Scope; Kill_Current_Values; -- Check for infinite loop. Skip check for generated code, since it -- justs waste time and makes debugging the routine called harder. -- Note that we have to wait till the body of the loop is fully analyzed -- before making this call, since Check_Infinite_Loop_Warning relies on -- being able to use semantic visibility information to find references. if Comes_From_Source (Stmt) then Check_Infinite_Loop_Warning (Stmt); end if; -- Code after loop is unreachable if the loop has no WHILE or FOR and -- contains no EXIT statements within the body of the loop. if No (Iter) and then not Has_Exit (Ent) then Check_Unreachable_Code (Stmt); end if; end Analyze_Loop_Statement; ---------------------------- -- Analyze_Null_Statement -- ---------------------------- -- Note: the semantics of the null statement is implemented by a single -- null statement, too bad everything isn't as simple as this. procedure Analyze_Null_Statement (N : Node_Id) is pragma Warnings (Off, N); begin null; end Analyze_Null_Statement; ------------------------- -- Analyze_Target_Name -- ------------------------- procedure Analyze_Target_Name (N : Node_Id) is procedure Report_Error; -- Complain about illegal use of target_name and rewrite it into unknown -- identifier. ------------------ -- Report_Error -- ------------------ procedure Report_Error is begin Error_Msg_N ("must appear in the right-hand side of an assignment statement", N); Rewrite (N, New_Occurrence_Of (Any_Id, Sloc (N))); end Report_Error; -- Start of processing for Analyze_Target_Name begin -- A target name has the type of the left-hand side of the enclosing -- assignment. -- First, verify that the context is the right-hand side of an -- assignment statement. if No (Current_Assignment) then Report_Error; return; end if; declare Current : Node_Id := N; Context : Node_Id := Parent (N); begin while Present (Context) loop -- Check if target_name appears in the expression of the enclosing -- assignment. if Nkind (Context) = N_Assignment_Statement then if Current = Expression (Context) then pragma Assert (Context = Current_Assignment); Set_Etype (N, Etype (Name (Current_Assignment))); else Report_Error; end if; return; -- Prevent the search from going too far elsif Is_Body_Or_Package_Declaration (Context) then Report_Error; return; end if; Current := Context; Context := Parent (Context); end loop; Report_Error; end; end Analyze_Target_Name; ------------------------ -- Analyze_Statements -- ------------------------ procedure Analyze_Statements (L : List_Id) is Lab : Entity_Id; S : Node_Id; begin -- The labels declared in the statement list are reachable from -- statements in the list. We do this as a prepass so that any goto -- statement will be properly flagged if its target is not reachable. -- This is not required, but is nice behavior. S := First (L); while Present (S) loop if Nkind (S) = N_Label then Analyze (Identifier (S)); Lab := Entity (Identifier (S)); -- If we found a label mark it as reachable if Ekind (Lab) = E_Label then Generate_Definition (Lab); Set_Reachable (Lab); if Nkind (Parent (Lab)) = N_Implicit_Label_Declaration then Set_Label_Construct (Parent (Lab), S); end if; -- If we failed to find a label, it means the implicit declaration -- of the label was hidden. A for-loop parameter can do this to -- a label with the same name inside the loop, since the implicit -- label declaration is in the innermost enclosing body or block -- statement. else Error_Msg_Sloc := Sloc (Lab); Error_Msg_N ("implicit label declaration for & is hidden#", Identifier (S)); end if; end if; Next (S); end loop; -- Perform semantic analysis on all statements Conditional_Statements_Begin; S := First (L); while Present (S) loop Analyze (S); -- Remove dimension in all statements Remove_Dimension_In_Statement (S); Next (S); end loop; Conditional_Statements_End; -- Make labels unreachable. Visibility is not sufficient, because labels -- in one if-branch for example are not reachable from the other branch, -- even though their declarations are in the enclosing declarative part. S := First (L); while Present (S) loop if Nkind (S) = N_Label then Set_Reachable (Entity (Identifier (S)), False); end if; Next (S); end loop; end Analyze_Statements; ---------------------------- -- Check_Unreachable_Code -- ---------------------------- procedure Check_Unreachable_Code (N : Node_Id) is Error_Node : Node_Id; P : Node_Id; begin if Is_List_Member (N) and then Comes_From_Source (N) then declare Nxt : Node_Id; begin Nxt := Original_Node (Next (N)); -- Skip past pragmas while Nkind (Nxt) = N_Pragma loop Nxt := Original_Node (Next (Nxt)); end loop; -- If a label follows us, then we never have dead code, since -- someone could branch to the label, so we just ignore it. if Nkind (Nxt) = N_Label then return; -- Otherwise see if we have a real statement following us elsif Present (Nxt) and then Comes_From_Source (Nxt) and then Is_Statement (Nxt) then -- Special very annoying exception. If we have a return that -- follows a raise, then we allow it without a warning, since -- the Ada RM annoyingly requires a useless return here. if Nkind (Original_Node (N)) /= N_Raise_Statement or else Nkind (Nxt) /= N_Simple_Return_Statement then -- The rather strange shenanigans with the warning message -- here reflects the fact that Kill_Dead_Code is very good -- at removing warnings in deleted code, and this is one -- warning we would prefer NOT to have removed. Error_Node := Nxt; -- If we have unreachable code, analyze and remove the -- unreachable code, since it is useless and we don't -- want to generate junk warnings. -- We skip this step if we are not in code generation mode -- or CodePeer mode. -- This is the one case where we remove dead code in the -- semantics as opposed to the expander, and we do not want -- to remove code if we are not in code generation mode, -- since this messes up the tree or loses useful information -- for CodePeer. -- Note that one might react by moving the whole circuit to -- exp_ch5, but then we lose the warning in -gnatc mode. if Operating_Mode = Generate_Code and then not CodePeer_Mode then loop Nxt := Next (N); -- Quit deleting when we have nothing more to delete -- or if we hit a label (since someone could transfer -- control to a label, so we should not delete it). exit when No (Nxt) or else Nkind (Nxt) = N_Label; -- Statement/declaration is to be deleted Analyze (Nxt); Remove (Nxt); Kill_Dead_Code (Nxt); end loop; end if; Error_Msg ("??unreachable code!", Sloc (Error_Node), Error_Node); end if; -- If the unconditional transfer of control instruction is the -- last statement of a sequence, then see if our parent is one of -- the constructs for which we count unblocked exits, and if so, -- adjust the count. else P := Parent (N); -- Statements in THEN part or ELSE part of IF statement if Nkind (P) = N_If_Statement then null; -- Statements in ELSIF part of an IF statement elsif Nkind (P) = N_Elsif_Part then P := Parent (P); pragma Assert (Nkind (P) = N_If_Statement); -- Statements in CASE statement alternative elsif Nkind (P) = N_Case_Statement_Alternative then P := Parent (P); pragma Assert (Nkind (P) = N_Case_Statement); -- Statements in body of block elsif Nkind (P) = N_Handled_Sequence_Of_Statements and then Nkind (Parent (P)) = N_Block_Statement then -- The original loop is now placed inside a block statement -- due to the expansion of attribute 'Loop_Entry. Return as -- this is not a "real" block for the purposes of exit -- counting. if Nkind (N) = N_Loop_Statement and then Subject_To_Loop_Entry_Attributes (N) then return; end if; -- Statements in exception handler in a block elsif Nkind (P) = N_Exception_Handler and then Nkind (Parent (P)) = N_Handled_Sequence_Of_Statements and then Nkind (Parent (Parent (P))) = N_Block_Statement then null; -- None of these cases, so return else return; end if; -- This was one of the cases we are looking for (i.e. the -- parent construct was IF, CASE or block) so decrement count. Unblocked_Exit_Count := Unblocked_Exit_Count - 1; end if; end; end if; end Check_Unreachable_Code; ------------------------ -- Has_Sec_Stack_Call -- ------------------------ function Has_Sec_Stack_Call (N : Node_Id) return Boolean is function Check_Call (N : Node_Id) return Traverse_Result; -- Check if N is a function call which uses the secondary stack ---------------- -- Check_Call -- ---------------- function Check_Call (N : Node_Id) return Traverse_Result is Nam : Node_Id; Subp : Entity_Id; Typ : Entity_Id; begin if Nkind (N) = N_Function_Call then Nam := Name (N); -- Obtain the subprogram being invoked loop if Nkind (Nam) = N_Explicit_Dereference then Nam := Prefix (Nam); elsif Nkind (Nam) = N_Selected_Component then Nam := Selector_Name (Nam); else exit; end if; end loop; Subp := Entity (Nam); if Present (Subp) then Typ := Etype (Subp); if Requires_Transient_Scope (Typ) then return Abandon; elsif Sec_Stack_Needed_For_Return (Subp) then return Abandon; end if; end if; end if; -- Continue traversing the tree return OK; end Check_Call; function Check_Calls is new Traverse_Func (Check_Call); -- Start of processing for Has_Sec_Stack_Call begin return Check_Calls (N) = Abandon; end Has_Sec_Stack_Call; ---------------------- -- Preanalyze_Range -- ---------------------- procedure Preanalyze_Range (R_Copy : Node_Id) is Save_Analysis : constant Boolean := Full_Analysis; Typ : Entity_Id; begin Full_Analysis := False; Expander_Mode_Save_And_Set (False); -- In addition to the above we must explicitly suppress the generation -- of freeze nodes that might otherwise be generated during resolution -- of the range (e.g. if given by an attribute that will freeze its -- prefix). Set_Must_Not_Freeze (R_Copy); if Nkind (R_Copy) = N_Attribute_Reference then Set_Must_Not_Freeze (Prefix (R_Copy)); end if; Analyze (R_Copy); if Nkind (R_Copy) in N_Subexpr and then Is_Overloaded (R_Copy) then -- Apply preference rules for range of predefined integer types, or -- check for array or iterable construct for "of" iterator, or -- diagnose true ambiguity. declare I : Interp_Index; It : Interp; Found : Entity_Id := Empty; begin Get_First_Interp (R_Copy, I, It); while Present (It.Typ) loop if Is_Discrete_Type (It.Typ) then if No (Found) then Found := It.Typ; else if Scope (Found) = Standard_Standard then null; elsif Scope (It.Typ) = Standard_Standard then Found := It.Typ; else -- Both of them are user-defined Error_Msg_N ("ambiguous bounds in range of iteration", R_Copy); Error_Msg_N ("\possible interpretations:", R_Copy); Error_Msg_NE ("\\}", R_Copy, Found); Error_Msg_NE ("\\}", R_Copy, It.Typ); exit; end if; end if; elsif Nkind (Parent (R_Copy)) = N_Iterator_Specification and then Of_Present (Parent (R_Copy)) then if Is_Array_Type (It.Typ) or else Has_Aspect (It.Typ, Aspect_Iterator_Element) or else Has_Aspect (It.Typ, Aspect_Constant_Indexing) or else Has_Aspect (It.Typ, Aspect_Variable_Indexing) then if No (Found) then Found := It.Typ; Set_Etype (R_Copy, It.Typ); else Error_Msg_N ("ambiguous domain of iteration", R_Copy); end if; end if; end if; Get_Next_Interp (I, It); end loop; end; end if; -- Subtype mark in iteration scheme if Is_Entity_Name (R_Copy) and then Is_Type (Entity (R_Copy)) then null; -- Expression in range, or Ada 2012 iterator elsif Nkind (R_Copy) in N_Subexpr then Resolve (R_Copy); Typ := Etype (R_Copy); if Is_Discrete_Type (Typ) then null; -- Check that the resulting object is an iterable container elsif Has_Aspect (Typ, Aspect_Iterator_Element) or else Has_Aspect (Typ, Aspect_Constant_Indexing) or else Has_Aspect (Typ, Aspect_Variable_Indexing) then null; -- The expression may yield an implicit reference to an iterable -- container. Insert explicit dereference so that proper type is -- visible in the loop. elsif Has_Implicit_Dereference (Etype (R_Copy)) then Build_Explicit_Dereference (R_Copy, Get_Reference_Discriminant (Etype (R_Copy))); end if; end if; Expander_Mode_Restore; Full_Analysis := Save_Analysis; end Preanalyze_Range; end Sem_Ch5;
sbksba/Concurrence-LI330
Ada
2,568
adb
with Ada.Text_IO, Ada.Numerics.Discrete_Random; use Ada.Text_IO; procedure anneau_min is NBSITE : constant positive := 4; type tache; type acc_tache is access tache; task type tache(Valeur : natural) is -- Recupere le pointeur sur la tache suivante entry init (succ : in acc_tache); -- reception du minimum identifie par la tache precedente -- Si la tache qui recoit est celle qui a debute le calcul, elle affiche le -- minimum sinon elle met a jour son minimum local et transmet l'information -- a la suivante entry recevoir(mes : natural); -- entree appelee par la tache Creer_Anneau pour demarrer un calcul de minimum. -- La tache qui debute le calcul est aussi celle qui affiche le resultat entry calcul_Min; end tache; task Creer_Anneau is -- entree grace a laquelle la tache Creer_Anneau est avertie de la fin d'un -- calcul entry fin_calcul; end Creer_Anneau; task body Creer_Anneau is package Random_Natural is new Ada.Numerics.Discrete_Random (Natural); use Random_Natural; G : generator; tab : array (1..NBSITE) of acc_tache; begin reset(g); tab(1):=new tache(random(G) mod 100); for i in 2..NBSITE loop tab(i):=new tache(random(G) mod 100); tab(i-1).init(tab(i)); end loop; tab(NBSITE).init(tab(1)); for i in 1..2 loop Put_Line(""); put_line("lancement n°"&natural'image(i)); tab((random(G) mod NBSITE)+1).calcul_min; accept fin_calcul; end loop; end Creer_Anneau; task body tache is initiateur : boolean := false; min_loc : natural := valeur; succs : acc_tache; begin accept init(succ : in acc_tache) do succs := succ; end init; loop select accept calcul_min; put_line("initiateur"); initiateur := true; succs.all.recevoir(valeur); or accept recevoir(mes : natural) do put(natural'image(mes)&" "&natural'image(min_loc)&" : "); if mes < min_loc then min_loc := mes; end if; end recevoir; if initiateur then put_line(natural'image(min_loc)); initiateur := false; creer_anneau.fin_calcul; Put_Line("Le minimum est : "&Natural'Image(min_loc)); else put_line(natural'image(min_loc)); succs.all.recevoir(min_loc); end if; min_loc := valeur; end select; end loop; end tache; begin null; end anneau_min;
AdaCore/libadalang
Ada
129
ads
generic type T is range <>; package Conversions.Ranges is function Convert (X : T) return Integer; end Conversions.Ranges;
AdaCore/libadalang
Ada
55
ads
generic with procedure Bar; package Foo is end Foo;
ytomino/vampire
Ada
409
ads
-- The Village of Vampire by YT, このソースコードはNYSLです procedure Vampire.R3.Register_Page ( Output : not null access Ada.Streams.Root_Stream_Type'Class; Form : in Forms.Root_Form_Type'Class; Template : in String; Base_Page : in Forms.Base_Page; Village_Id : in Tabula.Villages.Village_Id := Tabula.Villages.Invalid_Village_Id; New_User_Id : in String; New_User_Password : in String);
jorge-real/TTS-Ravenscar
Ada
62
ads
package TTS_Example1 is procedure Main; end TTS_Example1;
flyx/OpenGLAda
Ada
852
ads
-- part of OpenGLAda, (c) 2017 Felix Krause -- released under the terms of the MIT license, see the file "COPYING" private with GL.Low_Level; package GL.Enums.Queries is pragma Preelaborate; -- Texture_Kind is declared in GL.Low_Level.Enums to be accessible for -- OpenCLAda type Parameter is (Time_Elapsed, Samples_Passed, Any_Samples_Passed, Transform_Feedback_Primitives_Written); -- needs to be declared here because of subtypes for Parameter use (Time_Elapsed => 16#88BF#, Samples_Passed => 16#8914#, Any_Samples_Passed => 16#8C2F#, Transform_Feedback_Primitives_Written => 16#8C88#); for Parameter'Size use Low_Level.Enum'Size; private end GL.Enums.Queries;
alexcamposruiz/dds-requestreply
Ada
6,734
adb
pragma Ada_2012; package body DDS.Request_Reply.connext_c_untyped_impl is ---------------------------------------------------- -- RTI_Connext_EntityUntypedImpl_Wait_For_Samples -- ---------------------------------------------------- function RTI_Connext_EntityUntypedImpl_Wait_For_Samples (Self : not null access RTI_Connext_EntityUntypedImpl; Max_Wait : DDS.Duration_T; Min_Sample_Count : DDS.Natural; Waitset : not null DDS.WaitSet.Ref_Access; Initial_Condition : DDS.ReadCondition.Ref_Access; Condition : DDS.ReadCondition.Ref_Access) return Dds.ReturnCode_T is begin pragma Compile_Time_Warning (Standard.True, "RTI_Connext_EntityUntypedImpl_Wait_For_Samples unimplemented"); return raise Program_Error with "Unimplemented function RTI_Connext_EntityUntypedImpl_Wait_For_Samples"; end RTI_Connext_EntityUntypedImpl_Wait_For_Samples; ----------------------------------------------------- -- RTI_Connext_EntityUntypedImpl_Get_Sample_Loaned -- ----------------------------------------------------- function RTI_Connext_EntityUntypedImpl_Get_Sample_Loaned (Self : not null access RTI_Connext_EntityUntypedImpl; Received_Data : System.Address; Data_Count : out DDS.Integer; Is_Loan : DDS.Boolean; DataSeqContiguousBuffer : System.Address; Info_Seq : not null access DDS.SampleInfo_Seq.Sequence; Data_Seq_Len : DDS.long; Data_Seq_Max_Len : DDS.long; Ownership : DDS.Boolean; Max_Samples : DDS.long; Read_Condition : DDS.ReadCondition.Ref_Access; Take : DDS.Boolean) return Dds.ReturnCode_T is begin pragma Compile_Time_Warning (Standard.True, "RTI_Connext_EntityUntypedImpl_Get_Sample_Loaned unimplemented"); return raise Program_Error with "Unimplemented function RTI_Connext_EntityUntypedImpl_Get_Sample_Loaned"; end RTI_Connext_EntityUntypedImpl_Get_Sample_Loaned; ----------------------------------------------- -- RTI_Connext_EntityUntypedImpl_Send_Sample -- ----------------------------------------------- function RTI_Connext_EntityUntypedImpl_Send_Sample (Self : not null access RTI_Connext_EntityUntypedImpl; Data : System.Address; Info : not null access DDS.WriteParams_T) return DDS.ReturnCode_T is begin pragma Compile_Time_Warning (Standard.True, "RTI_Connext_EntityUntypedImpl_Send_Sample unimplemented"); return raise Program_Error with "Unimplemented function RTI_Connext_EntityUntypedImpl_Send_Sample"; end RTI_Connext_EntityUntypedImpl_Send_Sample; ------------------------------------------------------- -- RTI_Connext_EntityUntypedImpl_wait_for_any_sample -- ------------------------------------------------------- function RTI_Connext_EntityUntypedImpl_wait_for_any_sample (Self : not null access RTI_Connext_EntityUntypedImpl; max_wait : Duration_t; Min_Sample_Count : Integer) return DDS .ReturnCode_T is begin pragma Compile_Time_Warning (Standard.True, "RTI_Connext_EntityUntypedImpl_wait_for_any_sample unimplemented"); return raise Program_Error with "Unimplemented function RTI_Connext_EntityUntypedImpl_wait_for_any_sample"; end RTI_Connext_EntityUntypedImpl_wait_for_any_sample; ----------------------------------------------- -- RTI_Connext_EntityUntypedImpl_Return_Loan -- ----------------------------------------------- function RTI_Connext_EntityUntypedImpl_Return_Loan (Self : not null access RTI_Connext_EntityUntypedImpl; dataArray : System.Address; Info_Seq : not null access SampleInfo_Seq.Sequence) return DDS .ReturnCode_T is begin pragma Compile_Time_Warning (Standard.True, "RTI_Connext_EntityUntypedImpl_Return_Loan unimplemented"); return raise Program_Error with "Unimplemented function RTI_Connext_EntityUntypedImpl_Return_Loan"; end RTI_Connext_EntityUntypedImpl_Return_Loan; -------------------------------------------------- -- RTI_Connext_EntityUntypedImpl_Get_Datawriter -- -------------------------------------------------- function RTI_Connext_EntityUntypedImpl_Get_Datawriter (Self : not null access RTI_Connext_EntityUntypedImpl) return DDS.DataWriter.Ref_Access is begin pragma Compile_Time_Warning (Standard.True, "RTI_Connext_EntityUntypedImpl_Get_Datawriter unimplemented"); return raise Program_Error with "Unimplemented function RTI_Connext_EntityUntypedImpl_Get_Datawriter"; end RTI_Connext_EntityUntypedImpl_Get_Datawriter; -------------------------------------------------- -- RTI_Connext_EntityUntypedImpl_Get_Datareader -- -------------------------------------------------- function RTI_Connext_EntityUntypedImpl_Get_Datareader (Self : not null access RTI_Connext_EntityUntypedImpl) return DDS.DataReader.Ref_Access is begin pragma Compile_Time_Warning (Standard.True, "RTI_Connext_EntityUntypedImpl_Get_Datareader unimplemented"); return raise Program_Error with "Unimplemented function RTI_Connext_EntityUntypedImpl_Get_Datareader"; end RTI_Connext_EntityUntypedImpl_Get_Datareader; ------------------------------------------ -- RTI_Connext_EntityUntypedImpl_Delete -- ------------------------------------------ function RTI_Connext_EntityUntypedImpl_Delete (Self : RTI_Connext_EntityUntypedImpl_Access) return ReturnCode_t is begin pragma Compile_Time_Warning (Standard.True, "RTI_Connext_EntityUntypedImpl_Delete unimplemented"); return raise Program_Error with "Unimplemented function RTI_Connext_EntityUntypedImpl_Delete"; end RTI_Connext_EntityUntypedImpl_Delete; ----------------------------------------------------------- -- RTI_Connext_EntityUntypedImpl_Validate_Receive_Params -- ----------------------------------------------------------- function RTI_Connext_EntityUntypedImpl_Validate_Receive_Params (Self : not null access RTI_Connext_EntityUntypedImpl; METHOD_NAME : Standard.String; Min_Count : long; Max_Count : long; Max_Wait : Duration_T) return Boolean is begin pragma Compile_Time_Warning (Standard.True, "RTI_Connext_EntityUntypedImpl_Validate_Receive_Params unimplemented"); return raise Program_Error with "Unimplemented function RTI_Connext_EntityUntypedImpl_Validate_Receive_Params"; end RTI_Connext_EntityUntypedImpl_Validate_Receive_Params; end DDS.Request_Reply.connext_c_untyped_impl;
tum-ei-rcs/StratoX
Ada
7,047
adb
with Units; use Units; with Units.Navigation; use Units.Navigation; with Ada.Text_IO; use Ada.Text_IO; procedure main is generic type T is digits <>; procedure Test_Wrap (STEP : T); -- adds all combinations of type T and prints the result to stdout procedure Test_Wrap (STEP : T) is l1, l2, lr : T; function Wrap_Add is new Wrapped_Addition (T => T); begin l1 := T'First; inc1 : loop l2 := T'First; inc2 : loop lr := Wrap_Add (l1, l2); Put_Line (Float (l1)'Img & ", " & Float (l2)'Img & " , " & Float (lr)'Img); exit inc2 when l2 >= T'Last - STEP; l2 := l2 + STEP; end loop inc2; delay 0.01; exit inc1 when l1 >= T'Last - STEP; l1 := l1 + STEP; end loop inc1; end Test_Wrap; generic type T is digits <>; procedure Test_Sat_Sub (STEP : T); -- adds all combinations of type T and prints the result to stdout procedure Test_Sat_Sub (STEP : T) is l1, l2, lr : T; function Sat_Sub is new Saturated_Subtraction (T => T); begin l1 := T'First; inc1 : loop l2 := T'First; inc2 : loop lr := Sat_Sub (l1, l2); Put_Line (Float (l1)'Img & ", " & Float (l2)'Img & " , " & Float (lr)'Img); exit inc2 when l2 >= T'Last - STEP; l2 := l2 + STEP; end loop inc2; delay 0.01; exit inc1 when l1 >= T'Last - STEP; l1 := l1 + STEP; end loop inc1; end Test_Sat_Sub; generic type T is digits <>; procedure Test_Sat_Add (STEP : T); -- adds all combinations of type T and prints the result to stdout procedure Test_Sat_Add (STEP : T) is l1, l2, lr : T; function Sat_Add is new Saturated_Addition (T => T); begin l1 := T'First; inc1 : loop l2 := T'First; inc2 : loop lr := Sat_Add (l1, l2); Put_Line (Float (l1)'Img & ", " & Float (l2)'Img & " , " & Float (lr)'Img); exit inc2 when l2 >= T'Last - STEP; l2 := l2 + STEP; end loop inc2; delay 0.01; exit inc1 when l1 >= T'Last - STEP; l1 := l1 + STEP; end loop inc1; end Test_Sat_Add; procedure Test_Wrap_Lat is new Test_Wrap (T => Latitude_Type); procedure Test_Wrap_Lon is new Test_Wrap (T => Longitude_Type); procedure Test_Wrap_Alt is new Test_Wrap (T => Altitude_Type); procedure Test_Sat_Sub_Lat is new Test_Sat_Sub (T => Latitude_Type); procedure Test_Sat_Add_Lat is new Test_Sat_Add (T => Latitude_Type); STEP_LAT : constant Latitude_Type := 0.1 * Radian; STEP_LON : constant Longitude_Type := 0.1 * Radian; STEP_ALT : constant Altitude_Type := 100.0 * Meter; begin -- Put_Line ("Latitude wrap:"); -- Test_Wrap_Lat (STEP_LAT); -- -- Put_Line ("Longitude wrap:"); -- -- Test_Wrap_Lon (STEP_LON); -- -- Put_Line ("Altitude wrap:"); -- -- Test_Wrap_Alt (STEP_ALT); -- -- Put_Line ("Latitude sat add:"); -- Test_Sat_Add_Lat (STEP_LAT); -- -- Put_Line ("Latitude sat sub:"); -- Test_Sat_Sub_Lat (STEP_LAT); -- equivalence test of delta_angle -- Put_Line ("Angle1, Angle2, Delta1, DeltaOld"); -- declare -- subtype Heading_Type is Angle_Type range -360.0 * Degree .. 360.0 * Degree; -- a1, a2 : Heading_Type; -- da1, da2 : Float; -- STEP : constant Heading_Type := 5.0 * Degree; -- begin -- a1 := Heading_Type'First; -- inc1 : loop -- a2 := Heading_Type'First; -- inc2 : loop -- da1 := Float (delta_Angle (From => a1, To => a2)); -- begin -- da2 := Float (delta_Angle_deprecated (From => a1, To => a2)); -- exception -- when others => da2 := -600.0; -- end; -- Put_Line (Float (a1)'Img & ", " & Float (a2)'Img & " , " & Float (da1)'Img & " , " & Float (da2)'Img); -- -- exit inc2 when a2 >= Heading_Type'Last - STEP; -- a2 := a2 + STEP; -- end loop inc2; -- -- delay 0.01; -- -- exit inc1 when a1 >= Heading_Type'Last - STEP; -- a1 := a1 + STEP; -- end loop inc1; -- end; Put_Line ("Distance test"); declare function Head2Int (h : Heading_Type) return Integer is ret : Integer; begin ret := Integer (Float (h) * 180.0 / 3.14159); return ret; end Head2Int; s, t : GPS_Loacation_Type; d : Length_Type; c : Heading_Type; begin -- bug from walking around: s := (Latitude => 48.174572 * Degree, Longitude => 11.526941 * Degree, Altitude => 520.0 * Meter); -- W1 t := (Latitude => 48.174511 * Degree, Longitude => 11.528549 * Degree, Altitude => 520.0 * Meter); -- W0 d := Distance (source => s, target => t); c := Bearing (source_location => s, target_location => t); Put_Line ("W0 -> W1, should be 112m/84deg: " & d'Img & " meter & compass=" & Head2Int(c)'Img); -- 161m -- some nice points s := (Latitude => 48.149825 * Degree, Longitude => 11.567860 * Degree, Altitude => 520.0 * Meter); -- TUM t := (Latitude => 48.138912 * Degree, Longitude => 11.572811 * Degree, Altitude => 520.0 * Meter); -- Frauenkirche d := Distance (source => s, target => t); c := Bearing (source_location => s, target_location => t); Put_Line ("TUM -> Frauenkirche: " & d'Img & " meter & compass=" & Head2Int (c)'Img); -- 1.3km s := (Latitude => 48.139618 * Degree, Longitude => 11.570907 * Degree, Altitude => 520.0 * Meter); -- TUM d := Distance (source => s, target => t); c := Bearing (source_location => s, target_location => t); Put_Line ("Frauenkirche -> Michaelskirche: " & d'Img & " meter & compass=" & Head2Int(c)'Img); -- 161m return; -- smoke test t := s; declare STEP : constant := 0.00003 * Degree; var : constant := 0.001 * Degree; lat_t : Latitude_Type; lon_t : Longitude_Type; begin lat_t := s.Latitude - Latitude_Type (var); inc1 : loop lon_t := s.Longitude - Longitude_Type (var); inc2 : loop t.Latitude := lat_t; t.Longitude := lon_t; d := Distance (s, t); c := Bearing (s, t); Put_Line ("S=" & Float(s.Latitude)'Img & "," & Float(s.Longitude)'Img & ", T=" & Float(t.Latitude)'Img & "," & Float(t.Longitude)'Img & " => d=" & Float (d)'Img & ", crs=" & Head2Int (c)'Img); exit inc2 when lon_t > s.Longitude + Longitude_Type (var); lon_t := lon_t + Longitude_Type (STEP); end loop inc2; delay 0.01; exit inc1 when lat_t > s.Latitude + Latitude_Type (var); lat_t := lat_t + Latitude_Type (STEP); end loop inc1; end; end; end main;
MatrixMike/AdaDemo1
Ada
254
adb
package body FunctionX is type Employee is record EmployeeNumber : Integer; FirstName : String(1 .. 8); LastName : String(1 .. 6); HourlySalary : Float; end record; end FunctionX;
zhmu/ananas
Ada
1,242
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . L O N G _ L O N G _ I N T E G E R _ W I D E _ T E X T _ I O -- -- -- -- S p e c -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- -- copy and modify this specification, provided that if you redistribute a -- -- modified version, any changes that you have made are clearly indicated. -- -- -- ------------------------------------------------------------------------------ with Ada.Wide_Text_IO; package Ada.Long_Long_Long_Integer_Wide_Text_IO is new Ada.Wide_Text_IO.Integer_IO (Long_Long_Long_Integer);
PThierry/ewok-kernel
Ada
14,019
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. -- -- with system; with soc.layout; package soc.gpio with spark_mode => on, abstract_state => -- Registers ((gpio_a with external), (gpio_b with external), (gpio_c with external), (gpio_d with external), (gpio_e with external), (gpio_f with external), (gpio_g with external), (gpio_h with external), (gpio_i with external)), initializes => -- Assumed registers are initialized (gpio_a, gpio_b, gpio_c, gpio_d, gpio_e, gpio_f, gpio_h, gpio_i) is type t_gpio_pin_index is range 0 .. 15 with size => 4; type t_gpio_port_index is (GPIO_PA, GPIO_PB, GPIO_PC, GPIO_PD, GPIO_PE, GPIO_PF, GPIO_PG, GPIO_PH, GPIO_PI) with size => 4; ------------------------------------------- -- GPIO port mode register (GPIOx_MODER) -- ------------------------------------------- type t_pin_mode is (MODE_IN, MODE_OUT, MODE_AF, MODE_ANALOG) with size => 2; for t_pin_mode use (MODE_IN => 0, MODE_OUT => 1, MODE_AF => 2, MODE_ANALOG => 3); type t_pins_mode is array (t_gpio_pin_index) of t_pin_mode with pack, size => 32; type t_GPIOx_MODER is record pin : t_pins_mode; end record with pack, size => 32, volatile_full_access; -- Note: volatile_full_access: the register is volatile and the full -- 32-bits needs to be written at once. --------------------------------------------------- -- GPIO port output type register (GPIOx_OTYPER) -- --------------------------------------------------- type t_pin_output_type is (PUSH_PULL, OPEN_DRAIN) with size => 1; for t_pin_output_type use (PUSH_PULL => 0, OPEN_DRAIN => 1); type t_pins_output_type is array (t_gpio_pin_index) of t_pin_output_type with pack, size => 16; type t_GPIOx_OTYPER is record pin : t_pins_output_type; end record with size => 32, volatile_full_access; for t_GPIOx_OTYPER use record pin at 0 range 0 .. 15; end record; ----------------------------------------------------- -- GPIO port output speed register (GPIOx_OSPEEDR) -- ----------------------------------------------------- type t_pin_output_speed is (SPEED_LOW, SPEED_MEDIUM, SPEED_HIGH, SPEED_VERY_HIGH) with size => 2; for t_pin_output_speed use (SPEED_LOW => 0, SPEED_MEDIUM => 1, SPEED_HIGH => 2, SPEED_VERY_HIGH => 3); type t_pins_output_speed is array (t_gpio_pin_index) of t_pin_output_speed with pack, size => 32; type t_GPIOx_OSPEEDR is record pin : t_pins_output_speed; end record with pack, size => 32, volatile_full_access; -------------------------------------------------------- -- GPIO port pull-up/pull-down register (GPIOx_PUPDR) -- -------------------------------------------------------- type t_pin_pupd is (FLOATING, PULL_UP, PULL_DOWN) with size => 2; for t_pin_pupd use (FLOATING => 0, PULL_UP => 1, PULL_DOWN => 2); type t_pins_pupd is array (t_gpio_pin_index) of t_pin_pupd with pack, size => 32; type t_GPIOx_PUPDR is record pin : t_pins_pupd; end record with pack, size => 32, volatile_full_access; ----------------------------------------------- -- GPIO port input data register (GPIOx_IDR) -- ----------------------------------------------- type t_pins_idr is array (t_gpio_pin_index) of bit with pack, size => 16; type t_GPIOx_IDR is record pin : t_pins_idr; end record with size => 32, volatile_full_access; for t_GPIOx_IDR use record pin at 0 range 0 .. 15; end record; ------------------------------------------------ -- GPIO port output data register (GPIOx_ODR) -- ------------------------------------------------ type t_pins_odr is array (t_gpio_pin_index) of bit with pack, size => 16; type t_GPIOx_ODR is record pin : t_pins_odr; end record with size => 32, volatile_full_access; for t_GPIOx_ODR use record pin at 0 range 0 .. 15; end record; --------------------------------------------------- -- GPIO port bit set/reset register (GPIOx_BSRR) -- --------------------------------------------------- type t_pins_bsrr is array (t_gpio_pin_index) of bit with pack, size => 16; type t_GPIOx_BSRR is record BS : t_pins_bsrr; BR : t_pins_bsrr; end record with pack, size => 32, volatile_full_access; -------------------------------------------------------- -- GPIO port configuration lock register (GPIOx_LCKR) -- -------------------------------------------------------- type t_pin_lock is (NOT_LOCKED, LOCKED) with size => 1; for t_pin_lock use (NOT_LOCKED => 0, LOCKED => 1); type t_pins_lock is array (t_gpio_pin_index) of t_pin_lock with pack, size => 16; type t_GPIOx_LCKR is record pin : t_pins_lock; lock_key : bit; end record with size => 32, volatile_full_access; for t_GPIOx_LCKR use record pin at 0 range 0 .. 15; lock_key at 0 range 16 .. 16; end record; ------------------------------------------------------- -- GPIO alternate function low register (GPIOx_AFRL) -- ------------------------------------------------------- type t_pin_alt_func is range 0 .. 15 with size => 4; -- See RM0090, p. 274 GPIO_AF_USART1 : constant t_pin_alt_func := 7; GPIO_AF_USART2 : constant t_pin_alt_func := 7; GPIO_AF_USART3 : constant t_pin_alt_func := 7; GPIO_AF_UART4 : constant t_pin_alt_func := 8; GPIO_AF_UART5 : constant t_pin_alt_func := 8; GPIO_AF_USART6 : constant t_pin_alt_func := 8; GPIO_AF_SDIO : constant t_pin_alt_func := 12; type t_pins_alt_func_0_7 is array (t_gpio_pin_index range 0 .. 7) of t_pin_alt_func with pack, size => 32; type t_pins_alt_func_8_15 is array (t_gpio_pin_index range 8 .. 15) of t_pin_alt_func with pack, size => 32; type t_GPIOx_AFRL is record pin : t_pins_alt_func_0_7; end record with pack, size => 32, volatile_full_access; type t_GPIOx_AFRH is record pin : t_pins_alt_func_8_15; end record with pack, size => 32, volatile_full_access; --------------- -- Utilities -- --------------- -- enable the input RCC clock of the GPIO IP, given its index procedure enable_clock (port : in t_gpio_port_index); -- set the GPIO mode (input, output, alternate, analog) procedure set_mode (port : in t_gpio_port_index; pin : in t_gpio_pin_index; mode : in t_pin_mode) with global => (output => (gpio_a, gpio_b, gpio_c, gpio_d, gpio_e, gpio_f, gpio_g, gpio_h, gpio_i)); -- set the GPIO type (push-pull, open-drain) procedure set_type (port : in t_gpio_port_index; pin : in t_gpio_pin_index; otype : in t_pin_output_type) with global => (output => (gpio_a, gpio_b, gpio_c, gpio_d, gpio_e, gpio_f, gpio_g, gpio_h, gpio_i)); -- set the GPIO speed, from low to very high speed procedure set_speed (port : in t_gpio_port_index; pin : in t_gpio_pin_index; ospeed : in t_pin_output_speed) with global => (output => (gpio_a, gpio_b, gpio_c, gpio_d, gpio_e, gpio_f, gpio_g, gpio_h, gpio_i)); -- set the gpio pull mode (no pull, pull-up or pull-down mode) procedure set_pupd (port : in t_gpio_port_index; pin : in t_gpio_pin_index; pupd : in t_pin_pupd) with global => (output => (gpio_a, gpio_b, gpio_c, gpio_d, gpio_e, gpio_f, gpio_g, gpio_h, gpio_i)); -- set the GPIO behavior on the output data register bit write action -- (reset action) procedure set_bsr_r (port : in t_gpio_port_index; pin : in t_gpio_pin_index; bsr_r : in types.bit) with global => (output => (gpio_a, gpio_b, gpio_c, gpio_d, gpio_e, gpio_f, gpio_g, gpio_h, gpio_i)); -- set the GPIO behavior on the output data register bit write action -- (set action) procedure set_bsr_s (port : in t_gpio_port_index; pin : in t_gpio_pin_index; bsr_s : in types.bit) with global => (output => (gpio_a, gpio_b, gpio_c, gpio_d, gpio_e, gpio_f, gpio_g, gpio_h, gpio_i)); -- lock the GPIO configuration procedure set_lck (port : in t_gpio_port_index; pin : in t_gpio_pin_index; lck : in t_pin_lock) with global => (output => (gpio_a, gpio_b, gpio_c, gpio_d, gpio_e, gpio_f, gpio_g, gpio_h, gpio_i)); -- set the GPIO alternate function (see the SoC datasheet to get the -- list of available alternate functions) procedure set_af (port : in t_gpio_port_index; pin : in t_gpio_pin_index; af : in t_pin_alt_func) with global => (output => (gpio_a, gpio_b, gpio_c, gpio_d, gpio_e, gpio_f, gpio_g, gpio_h, gpio_i)); -- set the GPIO output value on GPIO in output mode procedure write_pin (port : in t_gpio_port_index; pin : in t_gpio_pin_index; value : in bit) with global => (in_out => (gpio_a, gpio_b, gpio_c, gpio_d, gpio_e, gpio_f, gpio_g, gpio_h, gpio_i)), -- Each GPIO port depend on itself and the input value to set depends => (gpio_a =>+ value, gpio_b =>+ value, gpio_c =>+ value, gpio_d =>+ value, gpio_e =>+ value, gpio_f =>+ value, gpio_g =>+ value, gpio_h =>+ value, gpio_i =>+ value, null => (port, pin)); -- set the GPIO input value on GPIO in input mode procedure read_pin (port : in t_gpio_port_index; pin : in t_gpio_pin_index; value : out bit) with global => (in_out=> (gpio_a, gpio_b, gpio_c, gpio_d, gpio_e, gpio_f, gpio_g, gpio_h, gpio_i)), depends => (gpio_a =>+ null, gpio_b =>+ null, gpio_c =>+ null, gpio_d =>+ null, gpio_e =>+ null, gpio_f =>+ null, gpio_g =>+ null, gpio_h =>+ null, gpio_i =>+ null, value => (gpio_a, gpio_b, gpio_c, gpio_d, gpio_e, gpio_f, gpio_h, gpio_i), null => (port, pin)); private type t_GPIO_port is record MODER : t_GPIOx_MODER; OTYPER : t_GPIOx_OTYPER; OSPEEDR : t_GPIOx_OSPEEDR; PUPDR : t_GPIOx_PUPDR; IDR : t_GPIOx_IDR; ODR : t_GPIOx_ODR; BSRR : t_GPIOx_BSRR; LCKR : t_GPIOx_LCKR; AFRL : t_GPIOx_AFRL; AFRH : t_GPIOx_AFRH; end record with volatile; for t_GPIO_port use record MODER at 16#00# range 0 .. 31; OTYPER at 16#04# range 0 .. 31; OSPEEDR at 16#08# range 0 .. 31; PUPDR at 16#0C# range 0 .. 31; IDR at 16#10# range 0 .. 31; ODR at 16#14# range 0 .. 31; BSRR at 16#18# range 0 .. 31; LCKR at 16#1C# range 0 .. 31; AFRL at 16#20# range 0 .. 31; AFRH at 16#24# range 0 .. 31; end record; ---------------------- -- GPIO peripherals -- ---------------------- GPIOA : aliased t_GPIO_port with import, volatile, address => system'to_address (soc.layout.GPIOA_BASE), part_of => gpio_a; GPIOB : aliased t_GPIO_port with import, volatile, address => system'to_address (soc.layout.GPIOB_BASE), part_of => gpio_b; GPIOC : aliased t_GPIO_port with import, volatile, address => system'to_address (soc.layout.GPIOC_BASE), part_of => gpio_c; GPIOD : aliased t_GPIO_port with import, volatile, address => system'to_address (soc.layout.GPIOD_BASE), part_of => gpio_d; GPIOE : aliased t_GPIO_port with import, volatile, address => system'to_address (soc.layout.GPIOE_BASE), part_of => gpio_e; GPIOF : aliased t_GPIO_port with import, volatile, address => system'to_address (soc.layout.GPIOF_BASE), part_of => gpio_f; GPIOG : aliased t_GPIO_port with import, volatile, address => system'to_address (soc.layout.GPIOG_BASE), part_of => gpio_g; GPIOH : aliased t_GPIO_port with import, volatile, address => system'to_address (soc.layout.GPIOH_BASE), part_of => gpio_h; GPIOI : aliased t_GPIO_port with import, volatile, address => system'to_address (soc.layout.GPIOI_BASE), part_of => gpio_i; end soc.gpio;
optikos/oasis
Ada
5,942
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Lexical_Elements; with Program.Elements.Expressions; with Program.Elements.Interface_Types; with Program.Element_Visitors; package Program.Nodes.Interface_Types is pragma Preelaborate; type Interface_Type is new Program.Nodes.Node and Program.Elements.Interface_Types.Interface_Type and Program.Elements.Interface_Types.Interface_Type_Text with private; function Create (Limited_Token : Program.Lexical_Elements.Lexical_Element_Access; Task_Token : Program.Lexical_Elements.Lexical_Element_Access; Protected_Token : Program.Lexical_Elements.Lexical_Element_Access; Synchronized_Token : Program.Lexical_Elements.Lexical_Element_Access; Interface_Token : Program.Lexical_Elements.Lexical_Element_Access; And_Token : Program.Lexical_Elements.Lexical_Element_Access; Progenitors : Program.Elements.Expressions .Expression_Vector_Access) return Interface_Type; type Implicit_Interface_Type is new Program.Nodes.Node and Program.Elements.Interface_Types.Interface_Type with private; function Create (Progenitors : Program.Elements.Expressions .Expression_Vector_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False; Has_Limited : Boolean := False; Has_Task : Boolean := False; Has_Protected : Boolean := False; Has_Synchronized : Boolean := False) return Implicit_Interface_Type with Pre => Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance; private type Base_Interface_Type is abstract new Program.Nodes.Node and Program.Elements.Interface_Types.Interface_Type with record Progenitors : Program.Elements.Expressions.Expression_Vector_Access; end record; procedure Initialize (Self : aliased in out Base_Interface_Type'Class); overriding procedure Visit (Self : not null access Base_Interface_Type; Visitor : in out Program.Element_Visitors.Element_Visitor'Class); overriding function Progenitors (Self : Base_Interface_Type) return Program.Elements.Expressions.Expression_Vector_Access; overriding function Is_Interface_Type_Element (Self : Base_Interface_Type) return Boolean; overriding function Is_Type_Definition_Element (Self : Base_Interface_Type) return Boolean; overriding function Is_Definition_Element (Self : Base_Interface_Type) return Boolean; type Interface_Type is new Base_Interface_Type and Program.Elements.Interface_Types.Interface_Type_Text with record Limited_Token : Program.Lexical_Elements.Lexical_Element_Access; Task_Token : Program.Lexical_Elements.Lexical_Element_Access; Protected_Token : Program.Lexical_Elements.Lexical_Element_Access; Synchronized_Token : Program.Lexical_Elements.Lexical_Element_Access; Interface_Token : Program.Lexical_Elements.Lexical_Element_Access; And_Token : Program.Lexical_Elements.Lexical_Element_Access; end record; overriding function To_Interface_Type_Text (Self : aliased in out Interface_Type) return Program.Elements.Interface_Types.Interface_Type_Text_Access; overriding function Limited_Token (Self : Interface_Type) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Task_Token (Self : Interface_Type) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Protected_Token (Self : Interface_Type) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Synchronized_Token (Self : Interface_Type) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Interface_Token (Self : Interface_Type) return Program.Lexical_Elements.Lexical_Element_Access; overriding function And_Token (Self : Interface_Type) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Has_Limited (Self : Interface_Type) return Boolean; overriding function Has_Task (Self : Interface_Type) return Boolean; overriding function Has_Protected (Self : Interface_Type) return Boolean; overriding function Has_Synchronized (Self : Interface_Type) return Boolean; type Implicit_Interface_Type is new Base_Interface_Type with record Is_Part_Of_Implicit : Boolean; Is_Part_Of_Inherited : Boolean; Is_Part_Of_Instance : Boolean; Has_Limited : Boolean; Has_Task : Boolean; Has_Protected : Boolean; Has_Synchronized : Boolean; end record; overriding function To_Interface_Type_Text (Self : aliased in out Implicit_Interface_Type) return Program.Elements.Interface_Types.Interface_Type_Text_Access; overriding function Is_Part_Of_Implicit (Self : Implicit_Interface_Type) return Boolean; overriding function Is_Part_Of_Inherited (Self : Implicit_Interface_Type) return Boolean; overriding function Is_Part_Of_Instance (Self : Implicit_Interface_Type) return Boolean; overriding function Has_Limited (Self : Implicit_Interface_Type) return Boolean; overriding function Has_Task (Self : Implicit_Interface_Type) return Boolean; overriding function Has_Protected (Self : Implicit_Interface_Type) return Boolean; overriding function Has_Synchronized (Self : Implicit_Interface_Type) return Boolean; end Program.Nodes.Interface_Types;
reznikmm/matreshka
Ada
4,800
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.Generic_Collections; package AMF.UML.Actors.Collections is pragma Preelaborate; package UML_Actor_Collections is new AMF.Generic_Collections (UML_Actor, UML_Actor_Access); type Set_Of_UML_Actor is new UML_Actor_Collections.Set with null record; Empty_Set_Of_UML_Actor : constant Set_Of_UML_Actor; type Ordered_Set_Of_UML_Actor is new UML_Actor_Collections.Ordered_Set with null record; Empty_Ordered_Set_Of_UML_Actor : constant Ordered_Set_Of_UML_Actor; type Bag_Of_UML_Actor is new UML_Actor_Collections.Bag with null record; Empty_Bag_Of_UML_Actor : constant Bag_Of_UML_Actor; type Sequence_Of_UML_Actor is new UML_Actor_Collections.Sequence with null record; Empty_Sequence_Of_UML_Actor : constant Sequence_Of_UML_Actor; private Empty_Set_Of_UML_Actor : constant Set_Of_UML_Actor := (UML_Actor_Collections.Set with null record); Empty_Ordered_Set_Of_UML_Actor : constant Ordered_Set_Of_UML_Actor := (UML_Actor_Collections.Ordered_Set with null record); Empty_Bag_Of_UML_Actor : constant Bag_Of_UML_Actor := (UML_Actor_Collections.Bag with null record); Empty_Sequence_Of_UML_Actor : constant Sequence_Of_UML_Actor := (UML_Actor_Collections.Sequence with null record); end AMF.UML.Actors.Collections;
reznikmm/matreshka
Ada
11,377
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_Packageable_Elements; with AMF.UML.Constraints; with AMF.UML.Dependencies.Collections; with AMF.UML.Elements.Collections; with AMF.UML.Named_Elements; with AMF.UML.Namespaces; with AMF.UML.Packages.Collections; with AMF.UML.Parameterable_Elements; with AMF.UML.String_Expressions; with AMF.UML.Template_Parameters; with AMF.UML.Value_Specifications; with AMF.Visitors; package AMF.Internals.UML_Constraints is type UML_Constraint_Proxy is limited new AMF.Internals.UML_Packageable_Elements.UML_Packageable_Element_Proxy and AMF.UML.Constraints.UML_Constraint with null record; overriding function Get_Constrained_Element (Self : not null access constant UML_Constraint_Proxy) return AMF.UML.Elements.Collections.Ordered_Set_Of_UML_Element; -- Getter of Constraint::constrainedElement. -- -- The ordered set of Elements referenced by this Constraint. overriding function Get_Context (Self : not null access constant UML_Constraint_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Getter of Constraint::context. -- -- Specifies the namespace that owns the NamedElement. overriding procedure Set_Context (Self : not null access UML_Constraint_Proxy; To : AMF.UML.Namespaces.UML_Namespace_Access); -- Setter of Constraint::context. -- -- Specifies the namespace that owns the NamedElement. overriding function Get_Specification (Self : not null access constant UML_Constraint_Proxy) return AMF.UML.Value_Specifications.UML_Value_Specification_Access; -- Getter of Constraint::specification. -- -- A condition that must be true when evaluated in order for the -- constraint to be satisfied. overriding procedure Set_Specification (Self : not null access UML_Constraint_Proxy; To : AMF.UML.Value_Specifications.UML_Value_Specification_Access); -- Setter of Constraint::specification. -- -- A condition that must be true when evaluated in order for the -- constraint to be satisfied. overriding function Get_Client_Dependency (Self : not null access constant UML_Constraint_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_Constraint_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_Constraint_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_Constraint_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_Constraint_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 Get_Owning_Template_Parameter (Self : not null access constant UML_Constraint_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access; -- Getter of ParameterableElement::owningTemplateParameter. -- -- The formal template parameter that owns this element. overriding procedure Set_Owning_Template_Parameter (Self : not null access UML_Constraint_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access); -- Setter of ParameterableElement::owningTemplateParameter. -- -- The formal template parameter that owns this element. overriding function Get_Template_Parameter (Self : not null access constant UML_Constraint_Proxy) return AMF.UML.Template_Parameters.UML_Template_Parameter_Access; -- Getter of ParameterableElement::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding procedure Set_Template_Parameter (Self : not null access UML_Constraint_Proxy; To : AMF.UML.Template_Parameters.UML_Template_Parameter_Access); -- Setter of ParameterableElement::templateParameter. -- -- The template parameter that exposes this element as a formal parameter. overriding function All_Owning_Packages (Self : not null access constant UML_Constraint_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_Constraint_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_Constraint_Proxy) return AMF.UML.Namespaces.UML_Namespace_Access; -- Operation NamedElement::namespace. -- -- Missing derivation for NamedElement::/namespace : Namespace overriding function Is_Compatible_With (Self : not null access constant UML_Constraint_Proxy; P : AMF.UML.Parameterable_Elements.UML_Parameterable_Element_Access) return Boolean; -- Operation ParameterableElement::isCompatibleWith. -- -- The query isCompatibleWith() determines if this parameterable element -- is compatible with the specified parameterable element. By default -- parameterable element P is compatible with parameterable element Q if -- the kind of P is the same or a subtype as the kind of Q. Subclasses -- should override this operation to specify different compatibility -- constraints. overriding function Is_Template_Parameter (Self : not null access constant UML_Constraint_Proxy) return Boolean; -- Operation ParameterableElement::isTemplateParameter. -- -- The query isTemplateParameter() determines if this parameterable -- element is exposed as a formal template parameter. overriding procedure Enter_Element (Self : not null access constant UML_Constraint_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_Constraint_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_Constraint_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_Constraints;
AaronC98/PlaneSystem
Ada
3,214
ads
------------------------------------------------------------------------------ -- Ada Web Server -- -- -- -- Copyright (C) 2005-2015, AdaCore -- -- -- -- This library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU General Public License as published by the -- -- Free Software Foundation; either version 3, or (at your option) any -- -- later version. This library is distributed in the hope that it will be -- -- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- -- -- -- -- -- -- -- -- You should have received a copy of the GNU General Public License and -- -- a copy of the GCC Runtime Library Exception along with this program; -- -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see -- -- <http://www.gnu.org/licenses/>. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ------------------------------------------------------------------------------ -- Internal unit only, should not be used by end-user. This is designed to -- convert simple value without xsi:type information to typed data by the -- SOAP engine. package SOAP.Types.Untyped is type Untyped is new XSD_String with null record; -- This type is used to record value as a string for untyped value found -- while parsing a payload. Such a type will be automatically converted to -- another type (Integer, Short, Unsigned_Long, Time_Instant...) by the -- SOAP.Types.Get routine. overriding function S (V : String; Name : String := "item"; Type_Name : String := XML_String; NS : SOAP.Name_Space.Object := SOAP.Name_Space.No_Name_Space) return Untyped; overriding function S (V : Unbounded_String; Name : String := "item"; Type_Name : String := XML_String; NS : SOAP.Name_Space.Object := SOAP.Name_Space.No_Name_Space) return Untyped; end SOAP.Types.Untyped;
sf17k/sdlada
Ada
1,560
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.Error -- -- Error message handling. -------------------------------------------------------------------------------------------------------------------- package SDL.Error is procedure Clear with Import => True, Convention => C, External_Name => "SDL_ClearError"; procedure Set (S : in String); function Get return String; end SDL.Error;
Gabriel-Degret/adalib
Ada
778
ads
-- Standard Ada library specification -- Copyright (c) 2003-2018 Maxim Reznik <[email protected]> -- Copyright (c) 2004-2016 AXE Consultants -- Copyright (c) 2004, 2005, 2006 Ada-Europe -- Copyright (c) 2000 The MITRE Corporation, Inc. -- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc. -- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual --------------------------------------------------------------------------- with Ada.Containers; generic with package Bounded is new Ada.Strings.Wide_Wide_Bounded.Generic_Bounded_Length (<>); function Ada.Strings.Wide_Wide_Bounded.Wide_Wide_Hash (Key : in Wide_Wide_Bounded.Bounded_Wide_Wide_String) return Containers.Hash_Type; pragma Preelaborate (Wide_Wide_Hash);
MinimSecure/unum-sdk
Ada
905
adb
-- Copyright 2015-2019 Free Software Foundation, Inc. -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 3 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- -- You should have received a copy of the GNU General Public License -- along with this program. If not, see <http://www.gnu.org/licenses/>. package body Aux_Pck is procedure Ambiguous_Func is begin null; end Ambiguous_Func; procedure Ambiguous_Proc is begin null; end Ambiguous_Proc; end Aux_Pck;
AdaCore/libadalang
Ada
393
adb
procedure Main is type Data is record E : Integer; end record; type Rec (F : not null access Data) is null record with Implicit_Dereference => F; I : aliased Data := (E => 2); X : Rec (I'Access); begin I := X; pragma Test_Statement; X := I; pragma Test_Statement; X := X; pragma Test_Statement; X := (E => 2); pragma Test_Statement; end Main;
scls19fr/openphysic
Ada
14,760
adb
with Ada.Text_IO; with Ada.Integer_Text_IO; with Ada.Numerics.Generic_Elementary_Functions; with Ada.Numerics.Generic_Complex_Types; with Generic_Real_Arrays; with Generic_Complex_Arrays; with Generic_Complex_Arrays.Operations; use Ada.Text_IO; procedure Complex_Arrays_Operations_Test is package Real_Arrays is new Generic_Real_Arrays(Float); package Complex_Types is new Ada.Numerics.Generic_Complex_Types(Float); use Real_Arrays; use Complex_Types; package Complex_Arrays is new Generic_Complex_Arrays(Float, Real_Vector, Real_Matrix, Complex); package Complex_Arrays_Operations is new Complex_Arrays.Operations; use Complex_Arrays; use Complex_Arrays_Operations; V_Ptr1, V_Ptr2: Complex_Vector_Ptr; M_Ptr1, M_Ptr2: Complex_Matrix_Ptr; A: Complex_Matrix(2..5, 3..6) := ((( 1.0,16.0), ( 2.0,15.0), ( 3.0,14.0), ( 4.0,13.0)), (( 5.0,12.0), ( 6.0,11.0), ( 7.0,10.0), ( 8.0, 9.0)), (( 9.0, 8.0), (10.0, 7.0), (11.0, 6.0), (12.0, 5.0)), ((13.0, 4.0), (14.0, 3.0), (15.0, 2.0), (16.0, 1.0))); B: Complex_Vector(2..6) := (( 1.0, 5.0), ( 2.0, 4.0), ( 3.0, 3.0), ( 4.0, 2.0), ( 5.0, 1.0)); O: Float; Tests_Failed: Integer := 0; procedure Assert(Test_Case: in Boolean) is begin if not Test_Case then Ada.Text_IO.New_Line; Ada.Text_IO.Put_Line("-=====================-"); Ada.Text_IO.Put_Line("-====== FAILED =======-"); Ada.Text_IO.Put_Line("-=====================-"); Tests_Failed := Tests_Failed + 1; end if; end; function Compare(X1, X2: in Complex_Matrix) return Boolean is begin for R in X1'Range(1) loop for C in X1'Range(2) loop if (Re(X1(R,C)) - Re(X2(X2'First(1)+(R-X1'First(1)), X2'First(2)+(C-X1'FirSt(2))))) > 0.001 or (Im(X1(R,C)) - Im(X2(X2'First(1)+(R-X1'First(1)), X2'First(2)+(C-X1'FirSt(2))))) > 0.001 then return False; end if; end loop; end loop; return True; end Compare; function Compare(X1, X2: in Complex_Vector) return Boolean is begin for I in X1'Range loop if (Re(X1(I)) - Re(X2(X2'First+(I-X1'First)))) > 0.001 or (Im(X1(I)) - Im(X2(X2'First+(I-X1'First)))) > 0.001 then return False; end if; end loop; return True; end Compare; begin -- function Create_Vector(First, Last: in Integer) -- return Complex_Vector_Ptr; Put_Line(" function Create_Vector(First, Last: in Integer)"); Put_Line(" return Complex_Vector_Ptr;"); New_Line; V_Ptr1 := Create_Vector(2, 5); Assert(V_Ptr1'Length = 4); Assert(V_Ptr1'First = 2); Assert(V_Ptr1'Last = 5); -- function Create_Vector(First, Last: in Integer; -- Default_Value: in Complex) -- return Complex_Vector_Ptr; Put_Line(" function Create_Vector(First, Last: in Integer;"); Put_Line(" Default_Value: in Complex)"); Put_Line(" return Complex_Vector_Ptr;"); New_Line; V_Ptr2 := Create_Vector(1, 3, Default_Value => (-3.14, 2.87)); Assert(V_Ptr2'Length = 3); Assert(V_Ptr2'First = 1); Assert(V_Ptr2'Last = 3); Assert(V_Ptr2.All = ((-3.14, 2.87), (-3.14, 2.87), (-3.14, 2.87))); -- procedure Destroy_Vector(X: in out Complex_Vector_Ptr); Put_Line(" procedure Destroy_Vector(X: in out Complex_Vector_Ptr);"); New_Line; Destroy_Vector(V_Ptr1); Destroy_Vector(V_Ptr2); -- function Create_Matrix(First_row, First_col, -- Last_row, Last_col: in Integer) -- return Complex_Matrix_Ptr; Put_Line(" function Create_Matrix(First_row, First_col,"); Put_Line(" Last_row, Last_col: in Integer)"); Put_Line(" return Complex_Matrix_Ptr;"); New_Line; M_Ptr1 := Create_Matrix(2, 3, 4, 4); Assert(M_Ptr1'Length(1) = 3); Assert(M_Ptr1'Length(2) = 2); Assert(M_Ptr1'First(1) = 2); Assert(M_Ptr1'Last(1) = 4); Assert(M_Ptr1'First(2) = 3); Assert(M_Ptr1'Last(2) = 4); -- function Create_Matrix(First_Row, First_Col, -- Last_Row, Last_Col: in Integer; -- Default_Value: in Complex) -- return Complex_Matrix_Ptr; Put_Line(" function Create_Matrix(First_Row, First_Col,"); Put_Line(" Last_Row, Last_Col: in Integer;"); Put_Line(" Default_Value: in Complex)"); Put_Line(" return Complex_Matrix_Ptr;"); New_Line; M_Ptr2 := Create_Matrix(3, 4, 5, 5, Default_Value => (-3.14, 2.87)); Assert(M_Ptr2'Length(1) = 3); Assert(M_Ptr2'Length(2) = 2); Assert(M_Ptr2'First(1) = 3); Assert(M_Ptr2'Last(1) = 5); Assert(M_Ptr2'First(2) = 4); Assert(M_Ptr2'Last(2) = 5); Assert(M_Ptr2.all = (((-3.14, 2.87), (-3.14, 2.87)), ((-3.14, 2.87), (-3.14, 2.87)), ((-3.14, 2.87), (-3.14, 2.87)))); -- procedure Destroy_Matrix(X: in out Complex_Matrix_Ptr); Put_Line(" procedure Destroy_Matrix(X: in out Complex_Matrix_Ptr);"); New_Line; Destroy_Matrix(M_Ptr1); Destroy_Matrix(M_Ptr2); -- function Create_Matrix(first, last: in Integer) -- return Complex_Matrix_Ptr; Put_Line(" function Create_Matrix(first, last: in Integer)"); Put_Line(" return Complex_Matrix_Ptr;"); New_Line; M_Ptr1 := Create_Matrix(3, 7); Assert(M_Ptr1'Length(1) = 5); Assert(M_Ptr1'Length(2) = 5); Assert(M_Ptr1'First(1) = 3); Assert(M_Ptr1'Last(1) = 7); Assert(M_Ptr1'First(2) = 3); Assert(M_Ptr1'Last(2) = 7); Destroy_Matrix(M_Ptr1); -- function Create_Matrix(first, last: in Integer; -- default_value: in Complex) -- return Complex_Matrix_Ptr; Put_Line(" function Create_Matrix(first, last: in Integer;"); Put_Line(" default_value: in Complex)"); Put_Line(" return Complex_Matrix_Ptr;"); New_Line; M_Ptr1 := Create_Matrix(3, 5, Default_Value => (-3.14, 2.87)); Assert(M_Ptr1'Length(1) = 3); Assert(M_Ptr1'Length(2) = 3); Assert(M_Ptr1'First(1) = 3); Assert(M_Ptr1'Last(1) = 5); Assert(M_Ptr1'First(2) = 3); Assert(M_Ptr1'Last(2) = 5); Assert(M_Ptr1.all = (((-3.14, 2.87), (-3.14, 2.87), (-3.14, 2.87)), ((-3.14, 2.87), (-3.14, 2.87), (-3.14, 2.87)), ((-3.14, 2.87), (-3.14, 2.87), (-3.14, 2.87)))); -- function Row(X: in Complex_Matrix; -- row: in Integer) return Complex_Vector; Put_Line(" function Row(X: in Complex_Matrix;"); Put_Line(" row: in Integer) return Complex_Vector;"); New_Line; for I in A'Range(1) loop O := Float((I-A'First(1))*A'Length(2)); Assert(Row(A, I) = (( 1.0+O, 16.0-O), ( 2.0+O, 15.0-O), ( 3.0+O, 14.0-O), ( 4.0+O, 13.0-O))); end loop; -- function Column(X: in Complex_Matrix; -- col: in Integer) return Complex_Vector; Put_Line(" function Column(X: in Complex_Matrix;"); Put_Line(" col: in Integer) return Complex_Vector;"); New_Line; for I in A'Range(2) loop O := Float(I-A'First(2)); Assert(Column(A, I) = (( 1.0+O,16.0-O), ( 5.0+O,12.0-O), ( 9.0+O, 8.0-O), (13.0+O, 4.0-O))); end loop; -- function Diagonal(X: in Complex_Matrix) return Complex_Vector; Put_Line(" function Diagonal(X: in Complex_Matrix) return Complex_Vector;"); New_Line; Assert(Diagonal(A) = (( 1.0,16.0), ( 6.0,11.0), (11.0, 6.0), (16.0, 1.0))); -- function Subvector(X: in Complex_Vector; first, last: in Integer) -- return Complex_Vector; Put_Line(" function Subvector(X: in Complex_Vector; first, last: in Integer)"); Put_Line(" return Complex_Vector;"); New_Line; for I in 1..B'Length-1 loop O := Float(I); Assert(Subvector(B, I+(B'First-1), I+(B'First)) = ((O, 6.0-O), (O+1.0, 5.0-O))); end loop; for I in 1..B'Length-2 loop O := Float(I); Assert(Subvector(B, I+(B'First-1), I+(B'First+1)) = ((O, 6.0-O), (O+1.0, 5.0-O), (O+2.0, 4.0-O))); end loop; for I in 1..B'Length-3 loop O := Float(I); Assert(Subvector(B, I+(B'First-1), I+(B'First+2)) = ((O, 6.0-O), (O+1.0, 5.0-O), (O+2.0, 4.0-O), (O+3.0, 3.0-O))); end loop; for I in 1..B'Length-4 loop O := Float(I); Assert(Subvector(B, I+(B'First-1), I+(B'First+3)) = ((O, 6.0-O), (O+1.0, 5.0-O), (O+2.0, 4.0-O), (O+3.0, 3.0-O), (O+4.0, 2.0-O))); end loop; Assert(Subvector(B, B'First, B'Last) = ((1.0, 5.0), (2.0, 4.0), (3.0, 3.0), (4.0, 2.0), (5.0, 1.0))); -- function Subvector(X: in Complex_Vector; first, last: in Integer; -- First_Index: in Integer) -- return Complex_Vector; Put_Line(" function Subvector(X: in Complex_Vector; First, Last: in Integer;"); Put_Line(" First_Index: in Integer)"); Put_Line(" return Complex_Vector;"); New_Line; for I in 1..B'Length-1 loop O := Float(I); Assert(Subvector(B, I+(B'First-1), I+(B'First), First_Index => 7) = ((O, 6.0-O), (O+1.0, 5.0-O))); end loop; for I in 1..B'Length-2 loop O := Float(I); Assert(Subvector(B, I+(B'First-1), I+(B'First+1), First_Index => 7) = ((O, 6.0-O), (O+1.0, 5.0-O), (O+2.0, 4.0-O))); end loop; for I in 1..B'Length-3 loop O := Float(I); Assert(Subvector(B, I+(B'First-1), I+(B'First+2), First_Index => 7) = ((O, 6.0-O), (O+1.0, 5.0-O), (O+2.0, 4.0-O), (O+3.0, 3.0-O))); end loop; for I in 1..B'Length-4 loop O := Float(I); Assert(Subvector(B, I+(B'First-1), I+(B'First+3), First_Index => 7) = ((O, 6.0-O), (O+1.0, 5.0-O), (O+2.0, 4.0-O), (O+3.0, 3.0-O), (O+4.0, 2.0-O))); end loop; Assert(Subvector(B, B'First, B'Last, First_Index => 7) = ((1.0, 5.0), (2.0, 4.0), (3.0, 3.0), (4.0, 2.0), (5.0, 1.0))); -- function Submatrix(X: in Complex_Matrix; -- First_Row, First_Col, Last_Row, Last_Col: in Integer) -- return Complex_Matrix; Put_Line(" function Submatrix(X: in Complex_Matrix;"); Put_Line(" First_Row, First_Col, Last_Row, Last_Col: in Integer)"); Put_Line(" return Complex_Matrix;"); New_Line; for I in A'Range(1) loop O := Float(4*(I-A'First(1))); Assert(Submatrix(A, I, A'First(2), I, A'Last(2)) = (1 =>((O+1.0, 16.0-O), (O+2.0, 15.0-O), (O+3.0, 14.0-O), (O+4.0, 13.0-O)))); end loop; for I in A'Range(2) loop O := Float(1+(I-A'First(2))); Assert(Submatrix(A, A'First(1), I, A'Last(1), I) = ((1 => (O+ 0.0,17.0-O)), (1 => (O+ 4.0,13.0-O)), (1 => (O+ 8.0, 9.0-O)), (1 => (O+12.0, 5.0-O)))); end loop; for R in A'First(1)..A'Last(1)-2 loop for C in A'First(2)..A'Last(2)-2 loop O := Float((C-A'First(2))+4*(R-A'First(1))); Assert(Submatrix(A, R, C, R+2, C+2) = ((( 1.0+O, 16.0-O), ( 2.0+O, 15.0-O), ( 3.0+O, 14.0-O)), (( 5.0+O, 12.0-O), ( 6.0+O, 11.0-O), ( 7.0+O, 10.0-O)), (( 9.0+O, 8.0-O), (10.0+O, 7.0-O), (11.0+O, 6.0-O)))); end loop; end loop; -- function Submatrix(X: in Complex_Matrix; -- First_Row, First_Col, Last_Row, Last_Col: in Integer; -- First_Row_Index, First_Col_Index: in Integer) -- return Complex_Matrix; Put_Line(" function Submatrix(X: in Complex_Matrix;"); Put_Line(" First_row, First_col, Last_row, Last_col: in Integer;"); Put_Line(" First_row_index, First_col_index: in Integer)"); Put_Line(" return Complex_Matrix;"); New_Line; for I in A'Range(1) loop O := Float(4*(I-A'First(1))); Assert(Submatrix(A, I, A'First(2), I, A'Last(2), First_Row_Index => 15, First_Col_Index => -10) = (1 =>((O+1.0, 16.0-O), (O+2.0, 15.0-O), (O+3.0, 14.0-O), (O+4.0, 13.0-O)))); end loop; for I in A'Range(2) loop O := Float(1+(I-A'First(2))); Assert(Submatrix(A, A'First(1), I, A'Last(1), I, First_Row_Index => 15, First_Col_Index => -10) = ((1 => (O+ 0.0,17.0-O)), (1 => (O+ 4.0,13.0-O)), (1 => (O+ 8.0, 9.0-O)), (1 => (O+12.0, 5.0-O)))); end loop; for R in A'First(1)..A'Last(1)-2 loop for C in A'First(2)..A'Last(2)-2 loop O := Float((C-A'First(2))+4*(R-A'First(1))); Assert(Submatrix(A, R, C, R+2, C+2, First_Row_Index => 15, First_Col_Index => -10) = ((( 1.0+O, 16.0-O), ( 2.0+O, 15.0-O), ( 3.0+O, 14.0-O)), (( 5.0+O, 12.0-O), ( 6.0+O, 11.0-O), ( 7.0+O, 10.0-O)), (( 9.0+O, 8.0-O), (10.0+O, 7.0-O), (11.0+O, 6.0-O)))); end loop; end loop; -- function Det(X : in Complex_Matrix) return Complex; Put_Line(" function Det(X : in Complex_Matrix) return Complex;"); New_Line; Assert(Det((1=>(1=>(-7.0, 3.0)))) = (-7.0, 3.0)); Assert(Det(A) = (0.0, 0.0)); Assert(Det(((( 1.0,-1.0), (-2.0, 1.0)), ((-3.0,-1.0), ( 4.0, 1.0)))) = (-2.0, -2.0)); Ada.Text_IO.Put("Number of failures:"); Ada.Integer_Text_IO.Put(Tests_Failed); end Complex_Arrays_Operations_Test;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
396
ads
with STM32GD.GPIO; generic with package Pin is new STM32GD.GPIO (<>); package STM32GD.GPIO_Polled is pragma Preelaborate; procedure Configure_Trigger (Event : Boolean := False; Rising : Boolean := False; Falling : Boolean := False); procedure Wait_For_Trigger; procedure Clear_Trigger; function Triggered return Boolean; procedure Cancel_Wait; end STM32GD.GPIO_Polled;
reznikmm/matreshka
Ada
3,858
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_Elements.Text.Sequence_Decls; package ODF.DOM.Elements.Text.Sequence_Decls.Internals is function Create (Node : Matreshka.ODF_Elements.Text.Sequence_Decls.Text_Sequence_Decls_Access) return ODF.DOM.Elements.Text.Sequence_Decls.ODF_Text_Sequence_Decls; function Wrap (Node : Matreshka.ODF_Elements.Text.Sequence_Decls.Text_Sequence_Decls_Access) return ODF.DOM.Elements.Text.Sequence_Decls.ODF_Text_Sequence_Decls; end ODF.DOM.Elements.Text.Sequence_Decls.Internals;
reznikmm/matreshka
Ada
3,699
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Chart_Origin_Attributes is pragma Preelaborate; type ODF_Chart_Origin_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Chart_Origin_Attribute_Access is access all ODF_Chart_Origin_Attribute'Class with Storage_Size => 0; end ODF.DOM.Chart_Origin_Attributes;
reznikmm/matreshka
Ada
3,684
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Table_Row_Attributes is pragma Preelaborate; type ODF_Table_Row_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Table_Row_Attribute_Access is access all ODF_Table_Row_Attribute'Class with Storage_Size => 0; end ODF.DOM.Table_Row_Attributes;
zrmyers/VulkanAda
Ada
1,851
ads
-------------------------------------------------------------------------------- -- MIT License -- -- Copyright (c) 2021 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. -------------------------------------------------------------------------------- -------------------------------------------------------------------------------- --< @group Vulkan Math Basic Types -------------------------------------------------------------------------------- --< @summary --< This package provides a single precision floating point matrix with 2 rows --< and 2 columns. -------------------------------------------------------------------------------- package Vulkan.Math.Dmat2x3.Test is -- Test Harness for Mat2x3 regression tests procedure Test_Dmat2x3; end Vulkan.Math.Dmat2x3.Test;
charlie5/lace
Ada
7,815
adb
with ada.unchecked_Conversion, ada.unchecked_Deallocation, interfaces.C.Strings, system.Storage_Elements; package body XML.Reader is package C renames Interfaces.C; package S renames Interfaces.C.Strings; type XML_Char is new C.unsigned_short; type XML_Char_Ptr is access all XML_Char; type Char_Ptr_Ptr is access all S.chars_ptr; procedure XML_SetUserData (XML_Parser : in XML_Parser_Ptr; Parser_Ptr : in Parser); pragma Import (C, XML_SetUserData, "XML_SetUserData"); procedure Internal_Start_Handler (My_Parser : in Parser; Name : in S.chars_ptr; AttAdd : in System.Address); pragma Convention (C, Internal_Start_Handler); procedure Internal_Start_Handler (My_Parser : in Parser; Name : in S.chars_ptr; AttAdd : in System.Address) is use S, System, System.Storage_Elements; procedure Free is new ada.Unchecked_Deallocation (Attributes_t, Attributes_view); function To_CP is new ada.unchecked_Conversion (System.Address, Char_Ptr_Ptr); AA_Size : Storage_Offset; the_Attribute_Array : Attributes_view; N_Atts : Natural; Atts : System.Address; begin -- Calculate the size of a single attribute (name or value) pointer. -- AA_Size := S.Chars_Ptr'Size / System.Storage_Unit; -- Count the number of attributes by scanning for a null pointer. -- N_Atts := 0; Atts := AttAdd; while To_CP (Atts).all /= S.Null_Ptr loop N_Atts := N_Atts + 1; Atts := Atts + (AA_Size * 2); end loop; -- Allocate a new attribute array of the correct size. -- the_Attribute_Array := new Attributes_t (1 .. N_Atts); -- Convert the attribute strings to unbounded_String. -- Atts := AttAdd; for Att in 1 .. N_Atts loop the_Attribute_Array (Att).Name := to_unbounded_String (S.Value (To_CP (Atts).all)); Atts := Atts + AA_Size; the_Attribute_Array (Att).Value := to_unbounded_String (S.Value (To_CP (Atts).all)); Atts := Atts + AA_Size; end loop; -- Call the user's handler. -- My_Parser.Start_Handler (to_unbounded_String (S.Value (Name)), the_Attribute_Array); -- Give back the attribute array. -- Free (the_Attribute_Array); end Internal_Start_Handler; procedure Internal_End_Handler (My_Parser : in Parser; Name : in S.chars_ptr); pragma Convention (C, Internal_End_Handler); procedure Internal_End_Handler (My_Parser : in Parser; Name : in S.chars_ptr) is begin My_Parser.End_Handler (to_unbounded_String (S.Value (Name))); end Internal_End_Handler; procedure Internal_CD_Handler (My_Parser : in Parser; Data : in S.chars_ptr; Len : in C.int); pragma Convention (C, Internal_CD_Handler); procedure Internal_CD_Handler (My_Parser : in Parser; Data : in S.chars_ptr; Len : in C.int) is the_Data : constant unbounded_String := to_unbounded_String (S.Value (Data, c.size_t (Len))); begin if the_Data /= "" then My_Parser.CD_Handler (the_Data); end if; end Internal_CD_Handler; function Create_Parser return Parser is function XML_ParserCreate (Encoding: in XML_Char_Ptr) return XML_Parser_Ptr; pragma Import (C, XML_ParserCreate, "XML_ParserCreate"); begin return new Parser_Rec' (XML_ParserCreate (null), null, null, null); end Create_Parser; procedure Set_Element_Handler (The_Parser : in Parser; Start_Handler : in Start_Element_Handler; End_Handler : in End_Element_Handler) is type Internal_Start_Element_Handler is access procedure (My_Parser : in Parser; Name : in S.chars_ptr; AttAdd : in System.Address); pragma Convention (C, Internal_Start_Element_Handler); type Internal_End_Element_Handler is access procedure (My_Parser : in Parser; Name : in S.chars_ptr); pragma Convention (C, Internal_End_Element_Handler); procedure XML_SetElementHandler (XML_Parser : in XML_Parser_Ptr; Start_Handler : in Internal_Start_Element_Handler; End_Handler : in Internal_End_Element_Handler); pragma Import (C, XML_SetElementHandler, "XML_SetElementHandler"); begin XML_SetUserData (The_Parser.XML_Parser, The_Parser); The_Parser.Start_Handler := Start_Handler; The_Parser.End_Handler := End_Handler; XML_SetElementHandler (The_Parser.XML_Parser, Internal_Start_Handler'Access, Internal_End_Handler 'Access); end Set_Element_Handler; procedure Set_Character_Data_Handler (The_Parser : in Parser; CD_Handler : in Character_Data_Handler) is type Internal_Character_Data_Handler is access procedure (My_Parser : in Parser; Data : in S.chars_ptr; Len : in C.int); pragma Convention (C, Internal_Character_Data_Handler); procedure XML_SetCharacterDataHandler (XML_Parser : in XML_Parser_Ptr; CD_Handler : in Internal_Character_Data_Handler); pragma Import (C, XML_SetCharacterDataHandler, "XML_SetCharacterDataHandler"); begin XML_SetUserData (The_Parser.XML_Parser, The_Parser); The_Parser.CD_Handler := CD_Handler; XML_SetCharacterDataHandler (The_Parser.XML_Parser, Internal_CD_Handler'Access); end Set_Character_Data_Handler; procedure Parse (The_Parser : in Parser; XML : in String; Is_Final : in Boolean) is function XML_Parse (XML_Parser : in XML_Parser_Ptr; XML : in S.chars_ptr; Len : in C.int; Is_Final : in C.int) return C.int; pragma Import (C, XML_Parse, "XML_Parse"); use C; XML_STATUS_ERROR : constant C.int := 0; pragma Unreferenced (XML_STATUS_ERROR); XML_STATUS_OK : constant C.int := 1; Final_Flag : C.int; Status : C.int; XML_Data : S.chars_ptr; begin if Is_Final then Final_Flag := 1; else Final_Flag := 0; end if; XML_Data := S.New_Char_Array (C.To_C (XML)); Status := XML_Parse (The_Parser.XML_Parser, XML_Data, C.int (XML'Length), Final_Flag); S.Free (XML_Data); if Status /= XML_STATUS_OK then raise XML_Parse_Error; end if; end Parse; end XML.Reader;
AdaCore/Ada_Drivers_Library
Ada
6,670
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 HAL; use HAL; with Semihosting; with Semihosting.Filesystem; use Semihosting.Filesystem; with File_Block_Drivers; use File_Block_Drivers; with Partitions; with File_IO; use File_IO; procedure Main is use type Partitions.Status_Code; procedure List_Dir (Path : String); -- List files in directory procedure List_Partitions (Path_To_Disk_Image : String); -- List partition in a disk file -------------- -- List_Dir -- -------------- procedure List_Dir (Path : String) is Status : Status_Code; DD : Directory_Descriptor; begin Status := Open (DD, Path); if Status /= OK then Semihosting.Log_Line ("Open Directory '" & Path & "' Error: " & Status'Img); else Semihosting.Log_Line ("Listing '" & Path & "' content:"); loop declare Ent : constant Directory_Entry := Read (DD); begin if Ent /= Invalid_Dir_Entry then Semihosting.Log_Line (" - '" & Ent.Name & "'"); Semihosting.Log_Line (" Kind: " & Ent.Subdirectory'Img); else exit; end if; end; end loop; end if; end List_Dir; --------------------- -- List_Partitions -- --------------------- procedure List_Partitions (Path_To_Disk_Image : String) is Nbr : Natural; P_Entry : Partitions.Partition_Entry; Disk : aliased File_Block_Driver; Status : Status_Code; begin Status := Disk.Open (Path_To_Disk_Image, Read_Only); if Status /= OK then Semihosting.Log_Line ("Cannot open disk image '" & Path_To_Disk_Image & "' : " & Status'Img); return; end if; Nbr := Partitions.Number_Of_Partitions (Disk'Unchecked_Access); Semihosting.Log_Line ("Disk '" & Path_To_Disk_Image & "' has " & Nbr'Img & " parition(s)"); for Id in 1 .. Nbr loop if Partitions.Get_Partition_Entry (Disk'Unchecked_Access, Id, P_Entry) /= Partitions.Status_Ok then Semihosting.Log_Line ("Cannot read partition :" & Id'Img); else Semihosting.Log_Line (" - partition :" & Id'Img); Semihosting.Log_Line (" Status:" & P_Entry.Status'Img); Semihosting.Log_Line (" Kind: " & P_Entry.Kind'Img); Semihosting.Log_Line (" LBA: " & P_Entry.First_Sector_LBA'Img); Semihosting.Log_Line (" Number of sectors: " & P_Entry.Number_Of_Sectors'Img); end if; end loop; end List_Partitions; My_SHFS : aliased SHFS; Status : Status_Code; FD : File_Descriptor; Data : UInt8_Array (1 .. 10); Amount : File_Size; begin -- Mount semi-hosting filesystem in My_VFS Status := Mount_Volume ("host", My_SHFS'Unchecked_Access); if Status /= OK then Semihosting.Log_Line ("Mount Error: " & Status'Img); end if; -- Open a file on the host Status := Open (FD, "/host/tmp/test.shfs", Read_Only); if Status /= OK then Semihosting.Log_Line ("Open Error: " & Status'Img); return; end if; -- Read the first 10 characters if Read (FD, Data'Address, Data'Length) /= Data'Length then Semihosting.Log_Line ("Read Error: " & Status'Img); return; end if; for C of Data loop Semihosting.Log (Character'Val (Integer (C))); end loop; Semihosting.Log_New_Line; -- Move file cursor Amount := 10; Status := Seek (FD, Forward, Amount); if Status /= OK then Semihosting.Log_Line ("Seek Error: " & Status'Img); return; end if; -- Read the 10 characters more if Read (FD, Data'Address, Data'Length) /= Data'Length then Semihosting.Log_Line ("Read Error: " & Status'Img); return; end if; for C of Data loop Semihosting.Log (Character'Val (Integer (C))); end loop; Semihosting.Log_New_Line; Close (FD); -- List all partitions of a disk image on the host List_Partitions ("/host/tmp/disk_8_partitions.img"); -- Test directory listing List_Dir ("/"); end Main;
Fabien-Chouteau/AGATE
Ada
2,565
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2017-2018, Fabien Chouteau -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ package AGATE.API.Dynamic_Semaphore is function Create (Initial_Count : Semaphore_Count := 0; Name : String) return Semaphore_ID; end AGATE.API.Dynamic_Semaphore;
VitalijBondarenko/notifyada
Ada
5,672
adb
------------------------------------------------------------------------------ -- -- -- Copyright (c) 2014-2023 Vitalii Bondarenko <[email protected]> -- -- -- ------------------------------------------------------------------------------ -- -- -- The MIT License (MIT) -- -- -- -- Permission is hereby granted, free of charge, to any person obtaining a -- -- copy of this software and associated documentation files (the -- -- "Software"), to deal in the Software without restriction, including -- -- without limitation the rights to use, copy, modify, merge, publish, -- -- distribute, sublicense, and/or sell copies of the Software, and to -- -- permit persons to whom the Software is furnished to do so, subject to -- -- the following conditions: -- -- -- -- The above copyright notice and this permission notice shall be included -- -- in all copies or substantial portions of the Software. -- -- -- -- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS -- -- OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -- -- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. -- -- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY -- -- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, -- -- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE -- -- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -- ------------------------------------------------------------------------------ with Interfaces.C.Strings; use Interfaces.C.Strings; with System; use System; package body Notify is ----------------- -- Notify_Init -- ----------------- function Notify_Init (App_Name : UTF8_String) return Boolean is function Internal (App_Name : chars_ptr) return Gboolean; pragma Import (C, Internal, "notify_init"); begin return 0 /= Internal (New_String (App_Name)); end Notify_Init; ----------------- -- Notify_Init -- ----------------- procedure Notify_Init (App_Name : UTF8_String) is Success : Boolean; begin Success := Notify_Init (App_Name); end Notify_Init; ------------------- -- Notify_Uninit -- ------------------- procedure Notify_Uninit is procedure Internal; pragma Import (C, Internal, "notify_uninit"); begin Internal; end Notify_Uninit; ----------------------- -- Notify_Is_Initted -- ----------------------- function Notify_Is_Initted return Boolean is function Internal return Gboolean; pragma Import (C, Internal, "notify_is_initted"); begin return 0 /= Internal; end Notify_Is_Initted; ------------------------- -- Notify_Get_App_Name -- ------------------------- function Notify_Get_App_Name return UTF8_String is function Internal return chars_ptr; pragma Import (C, Internal, "notify_get_app_name"); Name : chars_ptr := Internal; begin if Name = Null_Ptr then return ""; else declare N : UTF8_String := Value (Name); begin Free (Name); return N; end; end if; end Notify_Get_App_Name; ------------------------- -- Notify_Set_App_Name -- ------------------------- procedure Notify_Set_App_Name (App_Name : UTF8_String) is procedure Internal (App_Name : chars_ptr); pragma Import (C, Internal, "notify_set_app_name"); begin Internal (New_String (App_Name)); end Notify_Set_App_Name; ---------------------------- -- Notify_Get_Server_Caps -- ---------------------------- function Notify_Get_Server_Caps return Gtk.Enums.String_List.Glist is function Internal return System.Address; pragma Import (C, Internal, "notify_get_server_caps"); List : Gtk.Enums.String_List.Glist; begin String_List.Set_Object (List, Internal); return List; end Notify_Get_Server_Caps; ---------------------------- -- Notify_Get_Server_Info -- ---------------------------- function Notify_Get_Server_Info (Name : out String_Ptr; Vendor : out String_Ptr; Version : out String_Ptr; Spec_Version : out String_Ptr) return Boolean is function Internal (Name : access chars_ptr; Vendor : access chars_ptr; Version : access chars_ptr; Spec_Version : access chars_ptr) return Gboolean; pragma Import (C, internal, "notify_get_server_info"); R : Boolean; N : aliased chars_ptr; Ven : aliased chars_ptr; Ver : aliased chars_ptr; Spec : aliased chars_ptr; begin R := 0 /= Internal (N'Access, Ven'Access, Ver'Access, Spec'Access); if R then Name := new String'(Value (N)); Vendor := new String'(Value (Ven)); Version := new String'(Value (Ver)); Spec_Version := new String'(Value (Spec)); end if; return R; end Notify_Get_Server_Info; end Notify;
reznikmm/matreshka
Ada
3,679
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with XML.DOM.Attributes; package ODF.DOM.Table_Id_Attributes is pragma Preelaborate; type ODF_Table_Id_Attribute is limited interface and XML.DOM.Attributes.DOM_Attribute; type ODF_Table_Id_Attribute_Access is access all ODF_Table_Id_Attribute'Class with Storage_Size => 0; end ODF.DOM.Table_Id_Attributes;
zhmu/ananas
Ada
3,895
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . P A C K _ 2 4 -- -- -- -- S p e c -- -- -- -- 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. -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ -- Handling of packed arrays with Component_Size = 24 package System.Pack_24 is pragma Preelaborate; Bits : constant := 24; type Bits_24 is mod 2 ** Bits; for Bits_24'Size use Bits; -- In all subprograms below, Rev_SSO is set True if the array has the -- non-default scalar storage order. function Get_24 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_24 with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is extracted and returned. procedure Set_24 (Arr : System.Address; N : Natural; E : Bits_24; Rev_SSO : Boolean) with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is set to the given value. function GetU_24 (Arr : System.Address; N : Natural; Rev_SSO : Boolean) return Bits_24 with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is extracted and returned. This version -- is used when Arr may represent an unaligned address. procedure SetU_24 (Arr : System.Address; N : Natural; E : Bits_24; Rev_SSO : Boolean) with Inline; -- Arr is the address of the packed array, N is the zero-based -- subscript. This element is set to the given value. This version -- is used when Arr may represent an unaligned address end System.Pack_24;
docandrew/troodon
Ada
992
ads
--------------------------------- -- GID - Generic Image Decoder -- --------------------------------- -- -- Private child of GID, with helpers for identifying -- image formats and reading header informations. -- private package GID.Headers is -- -- Crude image signature detection -- procedure Load_signature ( image : in out Image_descriptor; try_tga : Boolean:= False ); -- -- Loading of various format's headers (past signature) -- procedure Load_BMP_header (image: in out Image_descriptor); procedure Load_FITS_header (image: in out Image_descriptor); procedure Load_GIF_header (image: in out Image_descriptor); procedure Load_JPEG_header (image: in out Image_descriptor); procedure Load_PNG_header (image: in out Image_descriptor); procedure Load_PNM_header (image: in out Image_descriptor); procedure Load_TGA_header (image: in out Image_descriptor); procedure Load_TIFF_header (image: in out Image_descriptor); end GID.Headers;
stcarrez/ada-awa
Ada
3,345
adb
----------------------------------------------------------------------- -- awa-helpers-selectors-tests -- Unit tests for selector helpers -- Copyright (C) 2011, 2012, 2013, 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.Test_Caller; with AWA.Tests; with ADO.Sessions; package body AWA.Helpers.Selectors.Tests is package Caller is new Util.Test_Caller (Test, "Helpers.Selectors"); function Create_From_Color is new Create_From_Enum (Color, "color_"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test AWA.Helpers.Selectors.Create_From_Query", Test_Create_From_Query'Access); Caller.Add_Test (Suite, "Test AWA.Helpers.Selectors.Create_From_Enum", Test_Create_From_Enum'Access); end Add_Tests; -- ------------------------------ -- Test creation of selector from an SQL query -- ------------------------------ procedure Test_Create_From_Query (T : in out Test) is Session : constant ADO.Sessions.Session := AWA.Tests.Get_Application.Get_Session; Query : constant String := "SELECT id, name from ado_entity_type order by id"; Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Query); Result : ASF.Models.Selects.Select_Item_List; Found_User : Boolean := False; begin Append_From_Query (Result, Stmt); T.Assert (Result.Length > 0, "The list should not be empty"); for I in 1 .. Result.Length loop declare Item : constant ASF.Models.Selects.Select_Item := Result.Get_Select_Item (I); begin -- The SQL query will return two different columns. -- Just check that label and values are different. T.Assert (Item.Get_Value /= Item.Get_Label, "Item and label are equals"); -- To make this test simple, check only for one known entry in the list. if Item.Get_Label = "awa_user" then Found_User := True; end if; end; end loop; T.Assert (Found_User, "The 'user' entity_type was not found in the selector list"); end Test_Create_From_Query; -- ------------------------------ -- Test creation of selector from an enum definition -- ------------------------------ procedure Test_Create_From_Enum (T : in out Test) is Bundle : Util.Properties.Bundles.Manager; Result : constant ASF.Models.Selects.Select_Item_List := Create_From_Color (Bundle); begin T.Assert (Result.Length > 0, "The list should not be empty"); end Test_Create_From_Enum; end AWA.Helpers.Selectors.Tests;
docandrew/troodon
Ada
813
ads
pragma Ada_2012; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with bits_types_h; package bits_types_struct_timespec_h is -- NB: Include guard matches what <linux/time.h> uses. -- POSIX.1b structure for a time value. This is like a `struct timeval' but -- has nanoseconds instead of microseconds. -- Seconds. type timespec is record tv_sec : aliased bits_types_h.uu_time_t; -- /usr/include/bits/types/struct_timespec.h:12 tv_nsec : aliased bits_types_h.uu_syscall_slong_t; -- /usr/include/bits/types/struct_timespec.h:16 end record with Convention => C_Pass_By_Copy; -- /usr/include/bits/types/struct_timespec.h:10 -- Nanoseconds. -- Padding. -- Nanoseconds. -- Nanoseconds. -- Padding. end bits_types_struct_timespec_h;
reznikmm/matreshka
Ada
5,328
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Web Framework -- -- -- -- Testsuite Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ -- Test:T26 -- -- Description: -- -- Node A sends to node C message with Processing Instruction node. Node C -- ignores PI and returns back Body with test:responseOk element. -- -- Messages: -- -- Message sent from Node A -- -- <?xml version='1.0' ?> -- <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> -- <?xml-stylesheet href="http://example.org/ts-tests/sub.xsl" -- type = "text/xsl"?> -- <env:Body> -- <test:echoOk xmlns:test="http://example.org/ts-tests"> -- foo -- </test:echoOk> -- </env:Body> -- </env:Envelope> -- -- Message sent from Node C -- -- <?xml version='1.0' ?> -- <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"> -- <env:Body> -- <test:responseOk xmlns:test="http://example.org/ts-tests"> -- foo -- </test:responseOk> -- </env:Body> -- </env:Envelope> ------------------------------------------------------------------------------ package SOAPConf.Testcases.Test_T26 is Scenario : constant Testcase_Data := (League.Strings.To_Universal_String ("<?xml version='1.0'?>" & "<env:Envelope" & " xmlns:env='http://www.w3.org/2003/05/soap-envelope'>" & "<?xml-stylesheet" & " href='http://example.org/ts-tests/sub.xsl'" & " type = 'text/xsl'?>" & "<env:Body>" & "<test:echoOk xmlns:test='http://example.org/ts-tests'>" & "foo" & "</test:echoOk>" & "</env:Body>" & "</env:Envelope>"), League.Strings.To_Universal_String ("<?xml version='1.0'?>" & "<env:Envelope xmlns:env='http://www.w3.org/2003/05/soap-envelope'>" & "<env:Body>" & "<test:responseOk xmlns:test='http://example.org/ts-tests'>" & "foo" & "</test:responseOk>" & "</env:Body>" & "</env:Envelope>")); end SOAPConf.Testcases.Test_T26;
reznikmm/matreshka
Ada
4,591
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.Selected_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Form_Selected_Attribute_Node is begin return Self : Form_Selected_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_Selected_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Selected_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Form_URI, Matreshka.ODF_String_Constants.Selected_Attribute, Form_Selected_Attribute_Node'Tag); end Matreshka.ODF_Form.Selected_Attributes;
charlie5/cBound
Ada
1,610
ads
-- This file is generated by SWIG. Please do not modify by hand. -- with Interfaces; with Interfaces.C; with Interfaces.C.Pointers; package xcb.xcb_glx_render_mode_request_t is -- Item -- type Item is record major_opcode : aliased Interfaces.Unsigned_8; minor_opcode : aliased Interfaces.Unsigned_8; length : aliased Interfaces.Unsigned_16; context_tag : aliased xcb.xcb_glx_context_tag_t; mode : aliased Interfaces.Unsigned_32; end record; -- Item_Array -- type Item_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_glx_render_mode_request_t .Item; -- Pointer -- package C_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_render_mode_request_t.Item, Element_Array => xcb.xcb_glx_render_mode_request_t.Item_Array, Default_Terminator => (others => <>)); subtype Pointer is C_Pointers.Pointer; -- Pointer_Array -- type Pointer_Array is array (Interfaces.C .size_t range <>) of aliased xcb.xcb_glx_render_mode_request_t .Pointer; -- Pointer_Pointer -- package C_Pointer_Pointers is new Interfaces.C.Pointers (Index => Interfaces.C.size_t, Element => xcb.xcb_glx_render_mode_request_t.Pointer, Element_Array => xcb.xcb_glx_render_mode_request_t.Pointer_Array, Default_Terminator => null); subtype Pointer_Pointer is C_Pointer_Pointers.Pointer; end xcb.xcb_glx_render_mode_request_t;
reznikmm/matreshka
Ada
6,090
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.CMOF.Named_Elements; with AMF.CMOF.Namespaces.Collections; with AMF.Internals.CMOF_Elements; package AMF.Internals.CMOF_Named_Elements is type CMOF_Named_Element_Proxy is abstract new AMF.Internals.CMOF_Elements.CMOF_Element_Proxy and AMF.CMOF.Named_Elements.CMOF_Named_Element with null record; overriding function All_Namespaces (Self : not null access constant CMOF_Named_Element_Proxy) return AMF.CMOF.Namespaces.Collections.Ordered_Set_Of_CMOF_Namespace; -- Operation NamedElement::allNamespaces. -- -- The query allNamespaces() gives the sequence of namespaces in which the -- NamedElement is nested, working outwards. overriding function Get_Name (Self : not null access constant CMOF_Named_Element_Proxy) return Optional_String; -- Getter of NamedElement::name. -- -- The name of the NamedElement. overriding function Get_Namespace (Self : not null access constant CMOF_Named_Element_Proxy) return AMF.CMOF.Namespaces.CMOF_Namespace_Access; -- Getter of NamedElement::namespace. -- -- Specifies the namespace that owns the NamedElement. overriding function Get_Visibility (Self : not null access constant CMOF_Named_Element_Proxy) return AMF.CMOF.Optional_CMOF_Visibility_Kind; -- Getter of NamedElement::visibility. -- -- Determines where the NamedElement appears within different Namespaces -- within the overall model, and its accessibility. overriding function Qualified_Name (Self : not null access constant CMOF_Named_Element_Proxy) return League.Strings.Universal_String; -- Operation NamedElement::qualifiedName. -- -- When there is a name, and all of the containing namespaces have a name, -- the qualified name is constructed from the names of the containing -- namespaces. overriding function Separator (Self : not null access constant CMOF_Named_Element_Proxy) return League.Strings.Universal_String; -- Operation NamedElement::separator. -- -- The query separator() gives the string that is used to separate names -- when constructing a qualified name. overriding procedure Set_Name (Self : not null access CMOF_Named_Element_Proxy; To : Optional_String); -- Setter of NamedElement::name. -- -- The name of the NamedElement. overriding procedure Set_Visibility (Self : not null access CMOF_Named_Element_Proxy; To : AMF.CMOF.Optional_CMOF_Visibility_Kind); -- Setter of NamedElement::visibility. -- -- Determines where the NamedElement appears within different Namespaces -- within the overall model, and its accessibility. end AMF.Internals.CMOF_Named_Elements;
reznikmm/matreshka
Ada
6,864
adb
------------------------------------------------------------------------------ -- -- -- 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; with AMF.Internals.Helpers; with AMF.Internals.Tables.UML_Attributes; with AMF.UML.Components; with AMF.Visitors.Standard_Profile_L2_Iterators; with AMF.Visitors.Standard_Profile_L2_Visitors; package body AMF.Internals.Standard_Profile_L2_Services is ------------------------ -- Get_Base_Component -- ------------------------ overriding function Get_Base_Component (Self : not null access constant Standard_Profile_L2_Service_Proxy) return AMF.UML.Components.UML_Component_Access is begin return AMF.UML.Components.UML_Component_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.UML_Attributes.Internal_Get_Base_Component (Self.Element))); end Get_Base_Component; ------------------------ -- Set_Base_Component -- ------------------------ overriding procedure Set_Base_Component (Self : not null access Standard_Profile_L2_Service_Proxy; To : AMF.UML.Components.UML_Component_Access) is begin AMF.Internals.Tables.UML_Attributes.Internal_Set_Base_Component (Self.Element, AMF.Internals.Helpers.To_Element (AMF.Elements.Element_Access (To))); end Set_Base_Component; ------------------- -- Enter_Element -- ------------------- overriding procedure Enter_Element (Self : not null access constant Standard_Profile_L2_Service_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class then AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class (Visitor).Enter_Service (AMF.Standard_Profile_L2.Services.Standard_Profile_L2_Service_Access (Self), Control); end if; end Enter_Element; ------------------- -- Leave_Element -- ------------------- overriding procedure Leave_Element (Self : not null access constant Standard_Profile_L2_Service_Proxy; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Visitor in AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class then AMF.Visitors.Standard_Profile_L2_Visitors.Standard_Profile_L2_Visitor'Class (Visitor).Leave_Service (AMF.Standard_Profile_L2.Services.Standard_Profile_L2_Service_Access (Self), Control); end if; end Leave_Element; ------------------- -- Visit_Element -- ------------------- overriding procedure Visit_Element (Self : not null access constant Standard_Profile_L2_Service_Proxy; Iterator : in out AMF.Visitors.Abstract_Iterator'Class; Visitor : in out AMF.Visitors.Abstract_Visitor'Class; Control : in out AMF.Visitors.Traverse_Control) is begin if Iterator in AMF.Visitors.Standard_Profile_L2_Iterators.Standard_Profile_L2_Iterator'Class then AMF.Visitors.Standard_Profile_L2_Iterators.Standard_Profile_L2_Iterator'Class (Iterator).Visit_Service (Visitor, AMF.Standard_Profile_L2.Services.Standard_Profile_L2_Service_Access (Self), Control); end if; end Visit_Element; end AMF.Internals.Standard_Profile_L2_Services;
reznikmm/matreshka
Ada
3,683
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 XML.DOM.Attributes; package ODF.DOM.Attributes.Style.Font_Family_Generic is type ODF_Style_Font_Family_Generic is new XML.DOM.Attributes.DOM_Attribute with private; private type ODF_Style_Font_Family_Generic is new XML.DOM.Attributes.DOM_Attribute with null record; end ODF.DOM.Attributes.Style.Font_Family_Generic;
houey/Amass
Ada
1,231
ads
-- Copyright 2021 Jeff Foley. All rights reserved. -- Use of this source code is governed by Apache 2 LICENSE that can be found in the LICENSE file. local json = require("json") name = "CommonCrawl" type = "api" local urls = {} function start() setratelimit(2) end function vertical(ctx, domain) urls = indexurls(ctx) if (urls == nil or #urls == 0) then return end for _, url in pairs(urls) do scrape(ctx, { ['url']=buildurl(url, domain), headers={['Content-Type']="application/json"}, }) end end function buildurl(url, domain) return url .. "?url=*." .. domain .. "&output=json&fl=url" end function indexurls(ctx) local resp, err = request(ctx, { url="https://index.commoncrawl.org/collinfo.json", headers={['Content-Type']="application/json"}, }) if (err ~= nil and err ~= "") then return nil end local data = json.decode(resp) if (data == nil or #data == 0) then return nil end local urls = {} for _, u in pairs(data) do local url = u["cdx-api"] if (url ~= nil and url ~= "") then table.insert(urls, url) end end return urls end
AdaCore/langkit
Ada
1,161
adb
with Ada.Text_IO; use Ada.Text_IO; with Libfoolang.Analysis; use Libfoolang.Analysis; with Libfoolang.Common; use Libfoolang.Common; procedure Main is Ctx : constant Analysis_Context := Create_Context; U : Analysis_Unit := Ctx.Get_From_Buffer (Filename => "main.txt", Buffer => "example"); begin Put_Line ("main.adb: Running..."); if U.Has_Diagnostics then raise Program_Error; end if; declare Iter : constant Example_Iterator := U.Root.As_Example.P_Entities_Iterator; Elem : Example; begin Put ("main.adb: Iterating once: "); if Next (Iter, Elem) then Put_Line (Image (Elem)); else New_Line; end if; Put_Line ("main.adb: Parsing new unit"); U := Ctx.Get_From_Buffer (Filename => "main2.txt", Buffer => "example"); Put ("main.adb: Iterating once more: "); if Next (Iter, Elem) then Put_Line (Image (Elem)); else New_Line; end if; exception when Stale_Reference_Error => Put_Line ("<Stale_Reference_Error>"); end; Put_Line ("main.adb: Done."); end Main;
pyjarrett/progress_indicators
Ada
1,353
ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2021 The progress_indicators authors -- -- 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 Progress_Indicators.Work_Trackers is -- Tracker used in the tracking of homogenous groups of work farmed out to -- many tasks. The goal is to track the amount of outstanding elements to -- process, without caring too much about any individual element of work. type Status_Report is record Completed : Natural := 0; Total : Natural := 0; end record; protected type Work_Tracker is procedure Start_Work (Amount : Natural); procedure Finish_Work (Amount : Natural); function Report return Status_Report; private Current : Status_Report; end Work_Tracker; end Progress_Indicators.Work_Trackers;
godunko/adawebpack
Ada
6,171
adb
------------------------------------------------------------------------------ -- -- -- AdaWebPack -- -- -- ------------------------------------------------------------------------------ -- Copyright © 2020-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. -- ------------------------------------------------------------------------------ with System; with WASM.Attributes; with WASM.Methods; with WASM.Objects.Attributes; with WASM.Objects.Methods; with Web.HTML.Options; with Web.Strings.WASM_Helpers; package body Web.HTML.Selects is ------------------ -- Get_Disabled -- ------------------ function Get_Disabled (Self : HTML_Select_Element'Class) return Boolean is begin return WASM.Objects.Attributes.Get_Boolean (Self, WASM.Attributes.Disabled); end Get_Disabled; ------------------------ -- Get_Selected_Index -- ------------------------ function Get_Selected_Index (Self : HTML_Select_Element'Class) return Web.DOM_Long is function Imported (Identifier : WASM.Objects.Object_Identifier) return Interfaces.Integer_32 with Import => True, Convention => C, Link_Name => "__adawebpack__html__Select__selectedIndex_getter"; begin return Imported (Self.Identifier); end Get_Selected_Index; --------------- -- Get_Value -- --------------- function Get_Value (Self : HTML_Select_Element'Class) return Web.Strings.Web_String is function Imported (Identifier : WASM.Objects.Object_Identifier) return System.Address with Import => True, Convention => C, Link_Name => "__adawebpack__html__Select__value_getter"; begin return Web.Strings.WASM_Helpers.To_Ada (Imported (Self.Identifier)); end Get_Value; ---------------- -- Named_Item -- ---------------- function Named_Item (Self : HTML_Select_Element'Class; Name : Web.Strings.Web_String) return Web.HTML.Options.HTML_Option_Element is begin return Web.HTML.Options.Instantiate (WASM.Objects.Methods.Call_Object_String (Self, WASM.Methods.Named_Item, Name)); end Named_Item; ------------------ -- Set_Disabled -- ------------------ procedure Set_Disabled (Self : in out HTML_Select_Element; To : Boolean) is begin WASM.Objects.Attributes.Set_Boolean (Self, WASM.Attributes.Disabled, To); end Set_Disabled; ------------------------ -- Set_Selected_Index -- ------------------------ procedure Set_Selected_Index (Self : in out HTML_Select_Element'Class; To : Web.DOM_Long) is procedure Imported (Identifier : WASM.Objects.Object_Identifier; To : Interfaces.Integer_32) with Import => True, Convention => C, Link_Name => "__adawebpack__html__Select__selectedIndex_setter"; begin Imported (Self.Identifier, To); end Set_Selected_Index; --------------- -- Set_Value -- --------------- procedure Set_Value (Self : in out HTML_Select_Element'Class; To : Web.Strings.Web_String) is procedure Imported (Identifier : WASM.Objects.Object_Identifier; Address : System.Address; Size : Interfaces.Unsigned_32) with Import => True, Convention => C, Link_Name => "__adawebpack__html__Select__value_setter"; A : System.Address; S : Interfaces.Unsigned_32; begin Web.Strings.WASM_Helpers.To_JS (To, A, S); Imported (Self.Identifier, A, S); end Set_Value; end Web.HTML.Selects;
dan76/Amass
Ada
985
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 = "BuiltWith" type = "api" function start() set_rate_limit(1) end function check() local c local cfg = datasrc_config() if (cfg ~= nil) then c = cfg.credentials end if (c ~= nil and c.key ~= nil and c.key ~= "") then return true end return false end function vertical(ctx, domain) local c local cfg = datasrc_config() if (cfg ~= nil) then c = cfg.credentials end if (c == nil or c.key == nil or c.key == "") then return end scrape(ctx, {['url']=build_url(domain, "v19", c.key)}) scrape(ctx, {['url']=build_url(domain, "rv1", c.key)}) end function build_url(domain, api, key) return "https://api.builtwith.com/" .. api .. "/api.json?LOOKUP=" .. domain .. "&KEY=" .. key end
optikos/oasis
Ada
10,075
ads
-- Copyright (c) 2019 Maxim Reznik <[email protected]> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Lexical_Elements; with Program.Elements.Defining_Names; with Program.Elements.Parameter_Specifications; with Program.Elements.Expressions; with Program.Elements.Aspect_Specifications; with Program.Elements.Function_Renaming_Declarations; with Program.Element_Visitors; package Program.Nodes.Function_Renaming_Declarations is pragma Preelaborate; type Function_Renaming_Declaration is new Program.Nodes.Node and Program.Elements.Function_Renaming_Declarations .Function_Renaming_Declaration and Program.Elements.Function_Renaming_Declarations .Function_Renaming_Declaration_Text with private; function Create (Not_Token : Program.Lexical_Elements.Lexical_Element_Access; Overriding_Token : Program.Lexical_Elements.Lexical_Element_Access; Function_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Name : not null Program.Elements.Defining_Names .Defining_Name_Access; Left_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access; Parameters : Program.Elements.Parameter_Specifications .Parameter_Specification_Vector_Access; Right_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access; Return_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Not_Token_2 : Program.Lexical_Elements.Lexical_Element_Access; Null_Token : Program.Lexical_Elements.Lexical_Element_Access; Result_Subtype : not null Program.Elements.Element_Access; Renames_Token : Program.Lexical_Elements.Lexical_Element_Access; Renamed_Function : Program.Elements.Expressions.Expression_Access; With_Token : Program.Lexical_Elements.Lexical_Element_Access; Aspects : Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access) return Function_Renaming_Declaration; type Implicit_Function_Renaming_Declaration is new Program.Nodes.Node and Program.Elements.Function_Renaming_Declarations .Function_Renaming_Declaration with private; function Create (Name : not null Program.Elements.Defining_Names .Defining_Name_Access; Parameters : Program.Elements.Parameter_Specifications .Parameter_Specification_Vector_Access; Result_Subtype : not null Program.Elements.Element_Access; Renamed_Function : Program.Elements.Expressions.Expression_Access; Aspects : Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False; Has_Not : Boolean := False; Has_Overriding : Boolean := False; Has_Not_Null : Boolean := False) return Implicit_Function_Renaming_Declaration with Pre => Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance; private type Base_Function_Renaming_Declaration is abstract new Program.Nodes.Node and Program.Elements.Function_Renaming_Declarations .Function_Renaming_Declaration with record Name : not null Program.Elements.Defining_Names .Defining_Name_Access; Parameters : Program.Elements.Parameter_Specifications .Parameter_Specification_Vector_Access; Result_Subtype : not null Program.Elements.Element_Access; Renamed_Function : Program.Elements.Expressions.Expression_Access; Aspects : Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access; end record; procedure Initialize (Self : aliased in out Base_Function_Renaming_Declaration'Class); overriding procedure Visit (Self : not null access Base_Function_Renaming_Declaration; Visitor : in out Program.Element_Visitors.Element_Visitor'Class); overriding function Name (Self : Base_Function_Renaming_Declaration) return not null Program.Elements.Defining_Names.Defining_Name_Access; overriding function Parameters (Self : Base_Function_Renaming_Declaration) return Program.Elements.Parameter_Specifications .Parameter_Specification_Vector_Access; overriding function Result_Subtype (Self : Base_Function_Renaming_Declaration) return not null Program.Elements.Element_Access; overriding function Renamed_Function (Self : Base_Function_Renaming_Declaration) return Program.Elements.Expressions.Expression_Access; overriding function Aspects (Self : Base_Function_Renaming_Declaration) return Program.Elements.Aspect_Specifications .Aspect_Specification_Vector_Access; overriding function Is_Function_Renaming_Declaration_Element (Self : Base_Function_Renaming_Declaration) return Boolean; overriding function Is_Declaration_Element (Self : Base_Function_Renaming_Declaration) return Boolean; type Function_Renaming_Declaration is new Base_Function_Renaming_Declaration and Program.Elements.Function_Renaming_Declarations .Function_Renaming_Declaration_Text with record Not_Token : Program.Lexical_Elements.Lexical_Element_Access; Overriding_Token : Program.Lexical_Elements.Lexical_Element_Access; Function_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Left_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access; Right_Bracket_Token : Program.Lexical_Elements.Lexical_Element_Access; Return_Token : not null Program.Lexical_Elements .Lexical_Element_Access; Not_Token_2 : Program.Lexical_Elements.Lexical_Element_Access; Null_Token : Program.Lexical_Elements.Lexical_Element_Access; Renames_Token : Program.Lexical_Elements.Lexical_Element_Access; With_Token : Program.Lexical_Elements.Lexical_Element_Access; Semicolon_Token : not null Program.Lexical_Elements .Lexical_Element_Access; end record; overriding function To_Function_Renaming_Declaration_Text (Self : aliased in out Function_Renaming_Declaration) return Program.Elements.Function_Renaming_Declarations .Function_Renaming_Declaration_Text_Access; overriding function Not_Token (Self : Function_Renaming_Declaration) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Overriding_Token (Self : Function_Renaming_Declaration) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Function_Token (Self : Function_Renaming_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Left_Bracket_Token (Self : Function_Renaming_Declaration) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Right_Bracket_Token (Self : Function_Renaming_Declaration) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Return_Token (Self : Function_Renaming_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Not_Token_2 (Self : Function_Renaming_Declaration) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Null_Token (Self : Function_Renaming_Declaration) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Renames_Token (Self : Function_Renaming_Declaration) return Program.Lexical_Elements.Lexical_Element_Access; overriding function With_Token (Self : Function_Renaming_Declaration) return Program.Lexical_Elements.Lexical_Element_Access; overriding function Semicolon_Token (Self : Function_Renaming_Declaration) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Has_Not (Self : Function_Renaming_Declaration) return Boolean; overriding function Has_Overriding (Self : Function_Renaming_Declaration) return Boolean; overriding function Has_Not_Null (Self : Function_Renaming_Declaration) return Boolean; type Implicit_Function_Renaming_Declaration is new Base_Function_Renaming_Declaration with record Is_Part_Of_Implicit : Boolean; Is_Part_Of_Inherited : Boolean; Is_Part_Of_Instance : Boolean; Has_Not : Boolean; Has_Overriding : Boolean; Has_Not_Null : Boolean; end record; overriding function To_Function_Renaming_Declaration_Text (Self : aliased in out Implicit_Function_Renaming_Declaration) return Program.Elements.Function_Renaming_Declarations .Function_Renaming_Declaration_Text_Access; overriding function Is_Part_Of_Implicit (Self : Implicit_Function_Renaming_Declaration) return Boolean; overriding function Is_Part_Of_Inherited (Self : Implicit_Function_Renaming_Declaration) return Boolean; overriding function Is_Part_Of_Instance (Self : Implicit_Function_Renaming_Declaration) return Boolean; overriding function Has_Not (Self : Implicit_Function_Renaming_Declaration) return Boolean; overriding function Has_Overriding (Self : Implicit_Function_Renaming_Declaration) return Boolean; overriding function Has_Not_Null (Self : Implicit_Function_Renaming_Declaration) return Boolean; end Program.Nodes.Function_Renaming_Declarations;
reznikmm/matreshka
Ada
4,624
adb
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Open Document Toolkit -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2014, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Matreshka.DOM_Documents; with Matreshka.ODF_String_Constants; with ODF.DOM.Iterators; with ODF.DOM.Visitors; package body Matreshka.ODF_Table.Grand_Total_Attributes is ------------ -- Create -- ------------ overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Table_Grand_Total_Attribute_Node is begin return Self : Table_Grand_Total_Attribute_Node do Matreshka.ODF_Table.Constructors.Initialize (Self'Unchecked_Access, Parameters.Document, Matreshka.ODF_String_Constants.Table_Prefix); end return; end Create; -------------------- -- Get_Local_Name -- -------------------- overriding function Get_Local_Name (Self : not null access constant Table_Grand_Total_Attribute_Node) return League.Strings.Universal_String is pragma Unreferenced (Self); begin return Matreshka.ODF_String_Constants.Grand_Total_Attribute; end Get_Local_Name; begin Matreshka.DOM_Documents.Register_Attribute (Matreshka.ODF_String_Constants.Table_URI, Matreshka.ODF_String_Constants.Grand_Total_Attribute, Table_Grand_Total_Attribute_Node'Tag); end Matreshka.ODF_Table.Grand_Total_Attributes;
reznikmm/matreshka
Ada
3,979
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_Origin_Attributes; package Matreshka.ODF_Chart.Origin_Attributes is type Chart_Origin_Attribute_Node is new Matreshka.ODF_Chart.Abstract_Chart_Attribute_Node and ODF.DOM.Chart_Origin_Attributes.ODF_Chart_Origin_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Chart_Origin_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Chart_Origin_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Chart.Origin_Attributes;
tum-ei-rcs/StratoX
Ada
414
ads
-- Institution: Technische Universität München -- Department: Real-Time Computer Systems (RCS) -- Project: StratoX -- -- Authors: Martin Becker -- @summary -- Target-independent specification for HIL of Random number generator with Interfaces; use Interfaces; package HIL.Random with SPARK_Mode => On is procedure initialize; procedure Get_Unsigned (num : out Unsigned_32); end HIL.Random;
zhmu/ananas
Ada
2,238
ads
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . W I D E _ T E X T _ IO . C O M P L E X _ I O -- -- -- -- S p e c -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- -- copy and modify this specification, provided that if you redistribute a -- -- modified version, any changes that you have made are clearly indicated. -- -- -- ------------------------------------------------------------------------------ with Ada.Numerics.Generic_Complex_Types; generic with package Complex_Types is new Ada.Numerics.Generic_Complex_Types (<>); package Ada.Wide_Text_IO.Complex_IO is Default_Fore : Field := 2; Default_Aft : Field := Complex_Types.Real'Digits - 1; Default_Exp : Field := 3; procedure Get (File : File_Type; Item : out Complex_Types.Complex; Width : Field := 0); procedure Get (Item : out Complex_Types.Complex; Width : Field := 0); procedure Put (File : File_Type; Item : Complex_Types.Complex; Fore : Field := Default_Fore; Aft : Field := Default_Aft; Exp : Field := Default_Exp); procedure Put (Item : Complex_Types.Complex; Fore : Field := Default_Fore; Aft : Field := Default_Aft; Exp : Field := Default_Exp); procedure Get (From : Wide_String; Item : out Complex_Types.Complex; Last : out Positive); procedure Put (To : out Wide_String; Item : Complex_Types.Complex; Aft : Field := Default_Aft; Exp : Field := Default_Exp); end Ada.Wide_Text_IO.Complex_IO;
iyan22/AprendeAda
Ada
233
adb
procedure numtriangular (n1: in Integer; resultado: out Integer) is indice:integer:=0; begin resultado:=0; indice:=n1; while indice/=0 loop resultado:=resultado+indice; indice:=indice-1; end loop; end numtriangular;
pat-rogers/LmcpGen
Ada
7,300
adb
with Ada.Text_IO; use Ada.Text_IO; with Ada.Text_IO.Text_Streams; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with avtas.lmcp; use avtas.lmcp; with avtas.lmcp.types; use avtas.lmcp.types; with afrl.cmasi.enumerations; use afrl.cmasi.enumerations; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with afrl.cmasi.keyValuePair; use afrl.cmasi.keyValuePair; with afrl.cmasi.location3D; use afrl.cmasi.location3D; with afrl.cmasi.AbstractGeometry; use afrl.cmasi.AbstractGeometry; with afrl.cmasi.abstractZone; use afrl.cmasi.abstractZone; with afrl.cmasi.keepInZone; use afrl.cmasi.keepInZone; with afrl.cmasi.circle; use afrl.cmasi.circle; with afrl.cmasi.entityConfiguration; use afrl.cmasi.entityConfiguration; with afrl.cmasi.payloadConfiguration; use afrl.cmasi.payloadConfiguration; with afrl.cmasi.cameraConfiguration; use afrl.cmasi.cameraConfiguration; with afrl.cmasi.gimbalconfiguration; use afrl.cmasi.gimbalconfiguration; with afrl.cmasi.AirVehicleConfiguration; use afrl.cmasi.AirVehicleConfiguration; -- Notes (LRH, 14 Dec): -- -- For each class, made the package name the same as the class. -- This means you have to use the qualified name in some contexts, e.g. -- type Circle is new AbstractGeometry.AbstractGeometry with private; -- -- Every series has a base Object basepackage.object.Object that inherits from -- avtas.lmcp.object.Object. This is because there are a few functions that -- should return the same result for every object in the series. The C/C++ -- implemention just hardcodes these same values for each object in the series. -- The Ada implementation could go either way. -- -- In avtas.lmcp.types, I defined what I hope correspond to C/C++ compatible -- types. I used the Interfaces package. If these types need to change, then we -- only have to change them in one place (and we get short names for the types). -- -- (1) Within an LMCP object, if the object has a field that itself corresponds -- to an LMCP object, the field for that object is an access type (to support -- polymorphism). By default, the accessed object is uninitialized -- (access type is null). Are there any issues here? -- -- (2) When an LMCP object has a field that corresponds to a vector of any type, -- the field is an access type (to avoid copying long vectors). Unlike (1), by -- default, the vector is initialized to a new (empty) vector. Only a get method -- is provided (no set), because once you get the access type, -- you can manipulate the vector. It is not clear that this is the best way to -- implement this, but we're unsure how memory management of objects works in -- Ada. -- -- Right now, all access types are with the 'all' keyword to support aliasing. -- We can likely remove this, but for now it might be convenient. -- -- I use Unbounded_Strings for fields that are Strings. Internally, I think this -- is necessary. However, set/get methods take/return Unbounded_Strings when in -- reality they could easily be modified to work over Strings. So, we may want -- to change that, but for now, it's convenient. -- -- Many methods are still unimplemented. -- -- The underlying mechanism for serialization/deserialization is not -- implemented (ByteBuffer in C++). Derek says the C++ implementation is bad -- (methods have unexpected side effects -- search for rewind(); could probably -- do more with 'native' types). Need to consider a better implementation for -- Ada. -- -- I want to investigate the ZMQ binds for Ada to send/receive LMCP messages. -- Interfaces to SPARK code will likely have to assume things about the LMCP -- messages. That seems fine to me. procedure Main is tempUnboundedString : Unbounded_String; kz : KeepInZone; c : Circle_Acc := new Circle; l3d : Location3D; l3d_Acc : Location3D_Acc; az : AbstractZone; kvp : KeyValuePair; ec : EntityConfiguration; cc_Acc : PayloadConfiguration_Any; gc_Acc : PayloadConfiguration_Any; avc : AirVehicleConfiguration; Stdout : Ada.Text_IO.Text_Streams.Stream_Access; begin l3d.setLatitude(30.43258611); l3d.setLongitude(-87.17408333); l3d.setAltitude(600.0); l3d.setAltitudeType(AltitudeTypeEnum'(MSL)); l3d_Acc := new Location3D; l3d_Acc.setLatitude(30.43258611); l3d_Acc.setLongitude(-87.17408333); l3d_Acc.setAltitude(600.0); -- What if I had aliased l3d instead? -- How is it different here, since both l3d_Acc and c.getCenterPoint -- refer to the same thing? c.setRadius(100.0); c.setCenterPoint(Location3D_Any(l3d_Acc)); New_Line; -- How to control how many digits are output for a float? See toString code -- in afrl.cmasi.circle adb. Put("Print an afrl.cmasi.Circle:"); New_Line; -- Put(c.toString(3)); New_Line; az.getAffectedAircraft.Append(10); az.getAffectedAircraft.Append(11); az.getAffectedAircraft.Append(12); Put("Print the values inside an afrl.cmasi.AbstractZone's AffectedAircraft[] field"); New_Line; -- What is the "best" way of looping over the values stored in a Vector -- pointed to by an access type? This took me awhile to figure out; is it -- making a copy here? for i of az.getAffectedAircraft.all loop Put(i'Image); end loop; New_Line(2); -- This is where we might change the interface to use a String, even -- if internally it's using an Unbounded_String az.setLabel(Unbounded_String'(To_Unbounded_String("AzLabel"))); Put("Print a test label:"); Put(To_String(az.getLabel)); New_Line(2); Put("Print a test FullLmcpTypeName: "); Put(kvp.getFullLmcpTypeName); New_Line(2); -- Set a KeepInZone's Boundary by pointing to a Circle created here. -- Any issues with this? kz.setZoneId(10); kz.setMinAltitude(100.0); kz.setMaxAltitude(750.0); kz.setBoundary(AbstractGeometry_Any(c)); -- Experiment with vectors of tagged types. EntityConfiguration has a vector -- PayloadConfigurationList with several types. Implemented -- CameraConfiguration and GimbalConfiguration. Mix and match. -- -- Eww, I had to define a Class access type PayloadConfiguration_Class_Acc in -- afrl.cmasi.payloadConfiguration. Then afrl.cmasi.entityConfiguration -- has a vector accessed through Vect_PayloadConfiguration_Class_Acc_Acc -- Is that right? What is the convention? It looks like it works though! -- I would need to go back and implement "class accessor" types for all -- classes to support this situation. gc_Acc := new GimbalConfiguration; cc_Acc := new CameraConfiguration; ec.getPayloadConfigurationList.Append(gc_Acc); ec.getPayloadConfigurationList.Append(cc_Acc); -- testing XML output Stdout := Ada.Text_IO.Text_Streams.Stream (File => Ada.Text_IO.Standard_Output); -- KeepInZone covers {SINGLE_PRIMITIVE, SINGLE_ENUM, SINGLE_NODE_STRUCT, SINGLE_LEAF_STRUCT, VECTOR/FIXED_ARRAY _PRIMITIVE} kz.getAffectedAircraft.Append (400); kz.getAffectedAircraft.Append (500); kz.XML_Output (Stdout); New_Line; -- AirVehicleConfiguration covers {VECTOR/FIXED_ARRAY _ENUM} avc.getAvailableTurnTypes.Append (TurnShort); avc.getAvailableTurnTypes.Append (FlyOver); avc.XML_Output (Stdout); New_Line; -- EntityConfiguration covers {VECTOR/FIXED _NODE/LEAF _STRUCT} ec.XML_Output (Stdout); New_Line; end Main;
Tim-Tom/project-euler
Ada
58
ads
package Problem_11 is procedure Solve; end Problem_11;
ekoeppen/STM32_Generic_Ada_Drivers
Ada
3,907
ads
-- This spec has been automatically generated from STM32F030.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with System; package STM32_SVD.PWR is pragma Preelaborate; --------------- -- Registers -- --------------- subtype CR_LPDS_Field is STM32_SVD.Bit; subtype CR_PDDS_Field is STM32_SVD.Bit; subtype CR_CWUF_Field is STM32_SVD.Bit; subtype CR_CSBF_Field is STM32_SVD.Bit; subtype CR_PVDE_Field is STM32_SVD.Bit; subtype CR_PLS_Field is STM32_SVD.UInt3; subtype CR_DBP_Field is STM32_SVD.Bit; subtype CR_FPDS_Field is STM32_SVD.Bit; -- power control register type CR_Register is record -- Low-power deep sleep LPDS : CR_LPDS_Field := 16#0#; -- Power down deepsleep PDDS : CR_PDDS_Field := 16#0#; -- Clear wakeup flag CWUF : CR_CWUF_Field := 16#0#; -- Clear standby flag CSBF : CR_CSBF_Field := 16#0#; -- Power voltage detector enable PVDE : CR_PVDE_Field := 16#0#; -- PVD level selection PLS : CR_PLS_Field := 16#0#; -- Disable backup domain write protection DBP : CR_DBP_Field := 16#0#; -- Flash power down in Stop mode FPDS : CR_FPDS_Field := 16#0#; -- unspecified Reserved_10_31 : STM32_SVD.UInt22 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CR_Register use record LPDS at 0 range 0 .. 0; PDDS at 0 range 1 .. 1; CWUF at 0 range 2 .. 2; CSBF at 0 range 3 .. 3; PVDE at 0 range 4 .. 4; PLS at 0 range 5 .. 7; DBP at 0 range 8 .. 8; FPDS at 0 range 9 .. 9; Reserved_10_31 at 0 range 10 .. 31; end record; subtype CSR_WUF_Field is STM32_SVD.Bit; subtype CSR_SBF_Field is STM32_SVD.Bit; subtype CSR_PVDO_Field is STM32_SVD.Bit; subtype CSR_BRR_Field is STM32_SVD.Bit; subtype CSR_EWUP_Field is STM32_SVD.Bit; subtype CSR_BRE_Field is STM32_SVD.Bit; -- power control/status register type CSR_Register is record -- Read-only. Wakeup flag WUF : CSR_WUF_Field := 16#0#; -- Read-only. Standby flag SBF : CSR_SBF_Field := 16#0#; -- Read-only. PVD output PVDO : CSR_PVDO_Field := 16#0#; -- Read-only. Backup regulator ready BRR : CSR_BRR_Field := 16#0#; -- unspecified Reserved_4_7 : STM32_SVD.UInt4 := 16#0#; -- Enable WKUP pin EWUP : CSR_EWUP_Field := 16#0#; -- Backup regulator enable BRE : CSR_BRE_Field := 16#0#; -- unspecified Reserved_10_31 : STM32_SVD.UInt22 := 16#0#; end record with Volatile_Full_Access, Size => 32, Bit_Order => System.Low_Order_First; for CSR_Register use record WUF at 0 range 0 .. 0; SBF at 0 range 1 .. 1; PVDO at 0 range 2 .. 2; BRR at 0 range 3 .. 3; Reserved_4_7 at 0 range 4 .. 7; EWUP at 0 range 8 .. 8; BRE at 0 range 9 .. 9; Reserved_10_31 at 0 range 10 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Power control type PWR_Peripheral is record -- power control register CR : aliased CR_Register; -- power control/status register CSR : aliased CSR_Register; end record with Volatile; for PWR_Peripheral use record CR at 16#0# range 0 .. 31; CSR at 16#4# range 0 .. 31; end record; -- Power control PWR_Periph : aliased PWR_Peripheral with Import, Address => System'To_Address (16#40007000#); end STM32_SVD.PWR;
Fabien-Chouteau/AGATE
Ada
2,909
ads
------------------------------------------------------------------------------ -- -- -- Copyright (C) 2017-2020, Fabien Chouteau -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with AGATE; use AGATE; package AGATE.Arch.ArmvX_m is procedure Set_PSP (Addr : Process_Stack_Pointer); function PSP return Process_Stack_Pointer; procedure Set_MSP (Addr : Process_Stack_Pointer); function MSP return Process_Stack_Pointer; procedure Set_Control (Val : Word); function Control return Word; procedure Enable_Faults; procedure Disable_Faults; procedure Enable_IRQ; procedure Disable_IRQ; procedure Set_Thread_Unprivileged; procedure Set_Thread_Mode_On_PSP; end AGATE.Arch.ArmvX_m;
melwyncarlo/ProjectEuler
Ada
3,685
adb
with Ada.Text_IO; with Ada.Strings.Fixed; with Ada.Integer_Text_IO; -- Copyright 2021 Melwyn Francis Carlo procedure A029 is use Ada.Text_IO; use Ada.Strings.Fixed; use Ada.Integer_Text_IO; N_Str, N_Str_Copy : String (1 .. 200); Temp_Product : String (1 .. 3); FT : File_Type; Last_Index : Natural; File_Line : String (1 .. 201); File_Name : constant String := "problems/029/temp.dat"; Products_Array : array (Integer range 1 .. 201, Integer range 1 .. 201) of Character; Sum_Val : Integer := 0; Is_First : Boolean := True; Temp_Sum, Str_Length : Integer; begin Create (FT, Out_File, File_Name); for I in 2 .. 100 loop N_Str (1 .. 200) := 200 * "0"; if I < 10 then N_Str (2 .. 2) := Trim (Integer'Image (I), Ada.Strings.Both); else N_Str (1 .. Trim (Integer'Image (I), Ada.Strings.Both)'Length) := Trim (Integer'Image (I), Ada.Strings.Both); end if; Str_Length := 2; Products_Array := (others => (others => Character'Val (0))); for J in 2 .. 100 loop for M in reverse 1 .. Str_Length loop Temp_Sum := I * (Character'Pos (N_Str (M)) - Character'Pos ('0')); Move (Source => Trim (Integer'Image (Temp_Sum), Ada.Strings.Both), Target => Temp_Product (1 .. 3), Justify => Ada.Strings.Right, Pad => '0'); for K1 in 1 .. M loop Products_Array (M, K1) := '0'; end loop; for K2 in (M + 1) .. (M + 3) loop Products_Array (M, K2) := Temp_Product (K2 - M); end loop; for K3 in (M + 4) .. (Str_Length + 3) loop Products_Array (M, K3) := '0'; end loop; end loop; N_Str (1 .. 200) := 200 * "0"; for M in reverse 2 .. (Str_Length + 3) loop Temp_Sum := 0; for N in 1 .. Str_Length loop Temp_Sum := Temp_Sum + Character'Pos (Products_Array (N, M)) - Character'Pos ('0'); end loop; Temp_Sum := Temp_Sum + Character'Pos (N_Str (M - 1)) - Character'Pos ('0'); N_Str (M - 1) := Character'Val ((Temp_Sum mod 10) + Character'Pos ('0')); if (M - 2) > 0 then N_Str (M - 2) := Character'Val (Integer (Float'Floor ( Float (Temp_Sum) / 10.0)) + Character'Pos ('0')); end if; end loop; Str_Length := Str_Length + 2; N_Str_Copy (1 .. 200) := 200 * "0"; N_Str_Copy (201 - Str_Length .. N_Str_Copy'Last) := N_Str (1 .. Str_Length); Reset (FT, In_File); while not End_Of_File (FT) loop Get_Line (FT, File_Line, Last_Index); if File_Line (1 .. Last_Index) = N_Str_Copy then goto Label_10; end if; end loop; if Is_First then Reset (FT, Out_File); Is_First := False; else Reset (FT, Append_File); end if; Put_Line (FT, N_Str_Copy); <<Label_10>> end loop; end loop; Reset (FT, In_File); while not End_Of_File (FT) loop Get_Line (FT, File_Line, Last_Index); Sum_Val := Sum_Val + 1; end loop; Delete (FT); Put (Sum_Val, Width => 0); end A029;
HackInvent/Ada_Drivers_Library
Ada
23,391
ads
-- This spec has been automatically generated from STM32H7x3.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with System; package STM32_SVD.BDMA is pragma Preelaborate; --------------- -- Registers -- --------------- -- DMA interrupt status register type BDMA_ISR_Register is record -- Read-only. Channel x global interrupt flag (x = 1..8) This bit is set -- by hardware. It is cleared by software writing 1 to the corresponding -- bit in the DMA_IFCR register. GIF1 : Boolean; -- Read-only. Channel x transfer complete flag (x = 1..8) This bit is -- set by hardware. It is cleared by software writing 1 to the -- corresponding bit in the DMA_IFCR register. TCIF1 : Boolean; -- Read-only. Channel x half transfer flag (x = 1..8) This bit is set by -- hardware. It is cleared by software writing 1 to the corresponding -- bit in the DMA_IFCR register. HTIF1 : Boolean; -- Read-only. Channel x transfer error flag (x = 1..8) This bit is set -- by hardware. It is cleared by software writing 1 to the corresponding -- bit in the DMA_IFCR register. TEIF1 : Boolean; -- Read-only. Channel x global interrupt flag (x = 1..8) This bit is set -- by hardware. It is cleared by software writing 1 to the corresponding -- bit in the DMA_IFCR register. GIF2 : Boolean; -- Read-only. Channel x transfer complete flag (x = 1..8) This bit is -- set by hardware. It is cleared by software writing 1 to the -- corresponding bit in the DMA_IFCR register. TCIF2 : Boolean; -- Read-only. Channel x half transfer flag (x = 1..8) This bit is set by -- hardware. It is cleared by software writing 1 to the corresponding -- bit in the DMA_IFCR register. HTIF2 : Boolean; -- Read-only. Channel x transfer error flag (x = 1..8) This bit is set -- by hardware. It is cleared by software writing 1 to the corresponding -- bit in the DMA_IFCR register. TEIF2 : Boolean; -- Read-only. Channel x global interrupt flag (x = 1..8) This bit is set -- by hardware. It is cleared by software writing 1 to the corresponding -- bit in the DMA_IFCR register. GIF3 : Boolean; -- Read-only. Channel x transfer complete flag (x = 1..8) This bit is -- set by hardware. It is cleared by software writing 1 to the -- corresponding bit in the DMA_IFCR register. TCIF3 : Boolean; -- Read-only. Channel x half transfer flag (x = 1..8) This bit is set by -- hardware. It is cleared by software writing 1 to the corresponding -- bit in the DMA_IFCR register. HTIF3 : Boolean; -- Read-only. Channel x transfer error flag (x = 1..8) This bit is set -- by hardware. It is cleared by software writing 1 to the corresponding -- bit in the DMA_IFCR register. TEIF3 : Boolean; -- Read-only. Channel x global interrupt flag (x = 1..8) This bit is set -- by hardware. It is cleared by software writing 1 to the corresponding -- bit in the DMA_IFCR register. GIF4 : Boolean; -- Read-only. Channel x transfer complete flag (x = 1..8) This bit is -- set by hardware. It is cleared by software writing 1 to the -- corresponding bit in the DMA_IFCR register. TCIF4 : Boolean; -- Read-only. Channel x half transfer flag (x = 1..8) This bit is set by -- hardware. It is cleared by software writing 1 to the corresponding -- bit in the DMA_IFCR register. HTIF4 : Boolean; -- Read-only. Channel x transfer error flag (x = 1..8) This bit is set -- by hardware. It is cleared by software writing 1 to the corresponding -- bit in the DMA_IFCR register. TEIF4 : Boolean; -- Read-only. Channel x global interrupt flag (x = 1..8) This bit is set -- by hardware. It is cleared by software writing 1 to the corresponding -- bit in the DMA_IFCR register. GIF5 : Boolean; -- Read-only. Channel x transfer complete flag (x = 1..8) This bit is -- set by hardware. It is cleared by software writing 1 to the -- corresponding bit in the DMA_IFCR register. TCIF5 : Boolean; -- Read-only. Channel x half transfer flag (x = 1..8) This bit is set by -- hardware. It is cleared by software writing 1 to the corresponding -- bit in the DMA_IFCR register. HTIF5 : Boolean; -- Read-only. Channel x transfer error flag (x = 1..8) This bit is set -- by hardware. It is cleared by software writing 1 to the corresponding -- bit in the DMA_IFCR register. TEIF5 : Boolean; -- Read-only. Channel x global interrupt flag (x = 1..8) This bit is set -- by hardware. It is cleared by software writing 1 to the corresponding -- bit in the DMA_IFCR register. GIF6 : Boolean; -- Read-only. Channel x transfer complete flag (x = 1..8) This bit is -- set by hardware. It is cleared by software writing 1 to the -- corresponding bit in the DMA_IFCR register. TCIF6 : Boolean; -- Read-only. Channel x half transfer flag (x = 1..8) This bit is set by -- hardware. It is cleared by software writing 1 to the corresponding -- bit in the DMA_IFCR register. HTIF6 : Boolean; -- Read-only. Channel x transfer error flag (x = 1..8) This bit is set -- by hardware. It is cleared by software writing 1 to the corresponding -- bit in the DMA_IFCR register. TEIF6 : Boolean; -- Read-only. Channel x global interrupt flag (x = 1..8) This bit is set -- by hardware. It is cleared by software writing 1 to the corresponding -- bit in the DMA_IFCR register. GIF7 : Boolean; -- Read-only. Channel x transfer complete flag (x = 1..8) This bit is -- set by hardware. It is cleared by software writing 1 to the -- corresponding bit in the DMA_IFCR register. TCIF7 : Boolean; -- Read-only. Channel x half transfer flag (x = 1..8) This bit is set by -- hardware. It is cleared by software writing 1 to the corresponding -- bit in the DMA_IFCR register. HTIF7 : Boolean; -- Read-only. Channel x transfer error flag (x = 1..8) This bit is set -- by hardware. It is cleared by software writing 1 to the corresponding -- bit in the DMA_IFCR register. TEIF7 : Boolean; -- Read-only. Channel x global interrupt flag (x = 1..8) This bit is set -- by hardware. It is cleared by software writing 1 to the corresponding -- bit in the DMA_IFCR register. GIF8 : Boolean; -- Read-only. Channel x transfer complete flag (x = 1..8) This bit is -- set by hardware. It is cleared by software writing 1 to the -- corresponding bit in the DMA_IFCR register. TCIF8 : Boolean; -- Read-only. Channel x half transfer flag (x = 1..8) This bit is set by -- hardware. It is cleared by software writing 1 to the corresponding -- bit in the DMA_IFCR register. HTIF8 : Boolean; -- Read-only. Channel x transfer error flag (x = 1..8) This bit is set -- by hardware. It is cleared by software writing 1 to the corresponding -- bit in the DMA_IFCR register. TEIF8 : Boolean; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for BDMA_ISR_Register use record GIF1 at 0 range 0 .. 0; TCIF1 at 0 range 1 .. 1; HTIF1 at 0 range 2 .. 2; TEIF1 at 0 range 3 .. 3; GIF2 at 0 range 4 .. 4; TCIF2 at 0 range 5 .. 5; HTIF2 at 0 range 6 .. 6; TEIF2 at 0 range 7 .. 7; GIF3 at 0 range 8 .. 8; TCIF3 at 0 range 9 .. 9; HTIF3 at 0 range 10 .. 10; TEIF3 at 0 range 11 .. 11; GIF4 at 0 range 12 .. 12; TCIF4 at 0 range 13 .. 13; HTIF4 at 0 range 14 .. 14; TEIF4 at 0 range 15 .. 15; GIF5 at 0 range 16 .. 16; TCIF5 at 0 range 17 .. 17; HTIF5 at 0 range 18 .. 18; TEIF5 at 0 range 19 .. 19; GIF6 at 0 range 20 .. 20; TCIF6 at 0 range 21 .. 21; HTIF6 at 0 range 22 .. 22; TEIF6 at 0 range 23 .. 23; GIF7 at 0 range 24 .. 24; TCIF7 at 0 range 25 .. 25; HTIF7 at 0 range 26 .. 26; TEIF7 at 0 range 27 .. 27; GIF8 at 0 range 28 .. 28; TCIF8 at 0 range 29 .. 29; HTIF8 at 0 range 30 .. 30; TEIF8 at 0 range 31 .. 31; end record; -- DMA interrupt flag clear register type BDMA_IFCR_Register is record -- Write-only. Channel x global interrupt clear This bit is set and -- cleared by software. CGIF1 : Boolean := False; -- Write-only. Channel x transfer complete clear This bit is set and -- cleared by software. CTCIF1 : Boolean := False; -- Write-only. Channel x half transfer clear This bit is set and cleared -- by software. CHTIF1 : Boolean := False; -- Write-only. Channel x transfer error clear This bit is set and -- cleared by software. CTEIF1 : Boolean := False; -- Write-only. Channel x global interrupt clear This bit is set and -- cleared by software. CGIF2 : Boolean := False; -- Write-only. Channel x transfer complete clear This bit is set and -- cleared by software. CTCIF2 : Boolean := False; -- Write-only. Channel x half transfer clear This bit is set and cleared -- by software. CHTIF2 : Boolean := False; -- Write-only. Channel x transfer error clear This bit is set and -- cleared by software. CTEIF2 : Boolean := False; -- Write-only. Channel x global interrupt clear This bit is set and -- cleared by software. CGIF3 : Boolean := False; -- Write-only. Channel x transfer complete clear This bit is set and -- cleared by software. CTCIF3 : Boolean := False; -- Write-only. Channel x half transfer clear This bit is set and cleared -- by software. CHTIF3 : Boolean := False; -- Write-only. Channel x transfer error clear This bit is set and -- cleared by software. CTEIF3 : Boolean := False; -- Write-only. Channel x global interrupt clear This bit is set and -- cleared by software. CGIF4 : Boolean := False; -- Write-only. Channel x transfer complete clear This bit is set and -- cleared by software. CTCIF4 : Boolean := False; -- Write-only. Channel x half transfer clear This bit is set and cleared -- by software. CHTIF4 : Boolean := False; -- Write-only. Channel x transfer error clear This bit is set and -- cleared by software. CTEIF4 : Boolean := False; -- Write-only. Channel x global interrupt clear This bit is set and -- cleared by software. CGIF5 : Boolean := False; -- Write-only. Channel x transfer complete clear This bit is set and -- cleared by software. CTCIF5 : Boolean := False; -- Write-only. Channel x half transfer clear This bit is set and cleared -- by software. CHTIF5 : Boolean := False; -- Write-only. Channel x transfer error clear This bit is set and -- cleared by software. CTEIF5 : Boolean := False; -- Write-only. Channel x global interrupt clear This bit is set and -- cleared by software. CGIF6 : Boolean := False; -- Write-only. Channel x transfer complete clear This bit is set and -- cleared by software. CTCIF6 : Boolean := False; -- Write-only. Channel x half transfer clear This bit is set and cleared -- by software. CHTIF6 : Boolean := False; -- Write-only. Channel x transfer error clear This bit is set and -- cleared by software. CTEIF6 : Boolean := False; -- Write-only. Channel x global interrupt clear This bit is set and -- cleared by software. CGIF7 : Boolean := False; -- Write-only. Channel x transfer complete clear This bit is set and -- cleared by software. CTCIF7 : Boolean := False; -- Write-only. Channel x half transfer clear This bit is set and cleared -- by software. CHTIF7 : Boolean := False; -- Write-only. Channel x transfer error clear This bit is set and -- cleared by software. CTEIF7 : Boolean := False; -- Write-only. Channel x global interrupt clear This bit is set and -- cleared by software. CGIF8 : Boolean := False; -- Write-only. Channel x transfer complete clear This bit is set and -- cleared by software. CTCIF8 : Boolean := False; -- Write-only. Channel x half transfer clear This bit is set and cleared -- by software. CHTIF8 : Boolean := False; -- Write-only. Channel x transfer error clear This bit is set and -- cleared by software. CTEIF8 : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for BDMA_IFCR_Register use record CGIF1 at 0 range 0 .. 0; CTCIF1 at 0 range 1 .. 1; CHTIF1 at 0 range 2 .. 2; CTEIF1 at 0 range 3 .. 3; CGIF2 at 0 range 4 .. 4; CTCIF2 at 0 range 5 .. 5; CHTIF2 at 0 range 6 .. 6; CTEIF2 at 0 range 7 .. 7; CGIF3 at 0 range 8 .. 8; CTCIF3 at 0 range 9 .. 9; CHTIF3 at 0 range 10 .. 10; CTEIF3 at 0 range 11 .. 11; CGIF4 at 0 range 12 .. 12; CTCIF4 at 0 range 13 .. 13; CHTIF4 at 0 range 14 .. 14; CTEIF4 at 0 range 15 .. 15; CGIF5 at 0 range 16 .. 16; CTCIF5 at 0 range 17 .. 17; CHTIF5 at 0 range 18 .. 18; CTEIF5 at 0 range 19 .. 19; CGIF6 at 0 range 20 .. 20; CTCIF6 at 0 range 21 .. 21; CHTIF6 at 0 range 22 .. 22; CTEIF6 at 0 range 23 .. 23; CGIF7 at 0 range 24 .. 24; CTCIF7 at 0 range 25 .. 25; CHTIF7 at 0 range 26 .. 26; CTEIF7 at 0 range 27 .. 27; CGIF8 at 0 range 28 .. 28; CTCIF8 at 0 range 29 .. 29; CHTIF8 at 0 range 30 .. 30; CTEIF8 at 0 range 31 .. 31; end record; subtype BDMA_CCR_PSIZE_Field is STM32_SVD.UInt2; subtype BDMA_CCR_MSIZE_Field is STM32_SVD.UInt2; subtype BDMA_CCR_PL_Field is STM32_SVD.UInt2; -- DMA channel x configuration register type BDMA_CCR_Register is record -- Channel enable This bit is set and cleared by software. EN : Boolean := False; -- Transfer complete interrupt enable This bit is set and cleared by -- software. TCIE : Boolean := False; -- Half transfer interrupt enable This bit is set and cleared by -- software. HTIE : Boolean := False; -- Transfer error interrupt enable This bit is set and cleared by -- software. TEIE : Boolean := False; -- Data transfer direction This bit is set and cleared by software. DIR : Boolean := False; -- Circular mode This bit is set and cleared by software. CIRC : Boolean := False; -- Peripheral increment mode This bit is set and cleared by software. PINC : Boolean := False; -- Memory increment mode This bit is set and cleared by software. MINC : Boolean := False; -- Peripheral size These bits are set and cleared by software. PSIZE : BDMA_CCR_PSIZE_Field := 16#0#; -- Memory size These bits are set and cleared by software. MSIZE : BDMA_CCR_MSIZE_Field := 16#0#; -- Channel priority level These bits are set and cleared by software. PL : BDMA_CCR_PL_Field := 16#0#; -- Memory to memory mode This bit is set and cleared by software. MEM2MEM : Boolean := False; -- unspecified Reserved_15_31 : STM32_SVD.UInt17 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for BDMA_CCR_Register use record EN at 0 range 0 .. 0; TCIE at 0 range 1 .. 1; HTIE at 0 range 2 .. 2; TEIE at 0 range 3 .. 3; DIR at 0 range 4 .. 4; CIRC at 0 range 5 .. 5; PINC at 0 range 6 .. 6; MINC at 0 range 7 .. 7; PSIZE at 0 range 8 .. 9; MSIZE at 0 range 10 .. 11; PL at 0 range 12 .. 13; MEM2MEM at 0 range 14 .. 14; Reserved_15_31 at 0 range 15 .. 31; end record; subtype BDMA_CNDTR_NDT_Field is STM32_SVD.UInt16; -- DMA channel x number of data register type BDMA_CNDTR_Register is record -- Number of data to transfer Number of data to be transferred (0 up to -- 65535). This register can only be written when the channel is -- disabled. Once the channel is enabled, this register is read-only, -- indicating the remaining bytes to be transmitted. This register -- decrements after each DMA transfer. Once the transfer is completed, -- this register can either stay at zero or be reloaded automatically by -- the value previously programmed if the channel is configured in -- auto-reload mode. If this register is zero, no transaction can be -- served whether the channel is enabled or not. NDT : BDMA_CNDTR_NDT_Field := 16#0#; -- unspecified Reserved_16_31 : STM32_SVD.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for BDMA_CNDTR_Register use record NDT at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- BDMA type BDMA_Peripheral is record -- DMA interrupt status register BDMA_ISR : aliased BDMA_ISR_Register; -- DMA interrupt flag clear register BDMA_IFCR : aliased BDMA_IFCR_Register; -- DMA channel x configuration register BDMA_CCR1 : aliased BDMA_CCR_Register; -- DMA channel x number of data register BDMA_CNDTR1 : aliased BDMA_CNDTR_Register; -- This register must not be written when the channel is enabled. BDMA_CPAR1 : aliased STM32_SVD.UInt32; -- This register must not be written when the channel is enabled. BDMA_CMAR1 : aliased STM32_SVD.UInt32; -- DMA channel x configuration register BDMA_CCR2 : aliased BDMA_CCR_Register; -- DMA channel x number of data register BDMA_CNDTR2 : aliased BDMA_CNDTR_Register; -- This register must not be written when the channel is enabled. BDMA_CPAR2 : aliased STM32_SVD.UInt32; -- This register must not be written when the channel is enabled. BDMA_CMAR2 : aliased STM32_SVD.UInt32; -- DMA channel x configuration register BDMA_CCR3 : aliased BDMA_CCR_Register; -- DMA channel x number of data register BDMA_CNDTR3 : aliased BDMA_CNDTR_Register; -- This register must not be written when the channel is enabled. BDMA_CPAR3 : aliased STM32_SVD.UInt32; -- This register must not be written when the channel is enabled. BDMA_CMAR3 : aliased STM32_SVD.UInt32; -- DMA channel x configuration register BDMA_CCR4 : aliased BDMA_CCR_Register; -- DMA channel x number of data register BDMA_CNDTR4 : aliased BDMA_CNDTR_Register; -- This register must not be written when the channel is enabled. BDMA_CPAR4 : aliased STM32_SVD.UInt32; -- This register must not be written when the channel is enabled. BDMA_CMAR4 : aliased STM32_SVD.UInt32; -- DMA channel x configuration register BDMA_CCR5 : aliased BDMA_CCR_Register; -- DMA channel x number of data register BDMA_CNDTR5 : aliased BDMA_CNDTR_Register; -- This register must not be written when the channel is enabled. BDMA_CPAR5 : aliased STM32_SVD.UInt32; -- This register must not be written when the channel is enabled. BDMA_CMAR5 : aliased STM32_SVD.UInt32; -- DMA channel x configuration register BDMA_CCR6 : aliased BDMA_CCR_Register; -- DMA channel x number of data register BDMA_CNDTR6 : aliased BDMA_CNDTR_Register; -- This register must not be written when the channel is enabled. BDMA_CPAR6 : aliased STM32_SVD.UInt32; -- This register must not be written when the channel is enabled. BDMA_CMAR6 : aliased STM32_SVD.UInt32; -- DMA channel x configuration register BDMA_CCR7 : aliased BDMA_CCR_Register; -- DMA channel x number of data register BDMA_CNDTR7 : aliased BDMA_CNDTR_Register; -- This register must not be written when the channel is enabled. BDMA_CPAR7 : aliased STM32_SVD.UInt32; -- This register must not be written when the channel is enabled. BDMA_CMAR7 : aliased STM32_SVD.UInt32; -- DMA channel x configuration register BDMA_CCR8 : aliased BDMA_CCR_Register; -- DMA channel x number of data register BDMA_CNDTR8 : aliased BDMA_CNDTR_Register; -- This register must not be written when the channel is enabled. BDMA_CPAR8 : aliased STM32_SVD.UInt32; -- This register must not be written when the channel is enabled. BDMA_CMAR8 : aliased STM32_SVD.UInt32; end record with Volatile; for BDMA_Peripheral use record BDMA_ISR at 16#0# range 0 .. 31; BDMA_IFCR at 16#4# range 0 .. 31; BDMA_CCR1 at 16#8# range 0 .. 31; BDMA_CNDTR1 at 16#C# range 0 .. 31; BDMA_CPAR1 at 16#10# range 0 .. 31; BDMA_CMAR1 at 16#14# range 0 .. 31; BDMA_CCR2 at 16#1C# range 0 .. 31; BDMA_CNDTR2 at 16#20# range 0 .. 31; BDMA_CPAR2 at 16#24# range 0 .. 31; BDMA_CMAR2 at 16#28# range 0 .. 31; BDMA_CCR3 at 16#30# range 0 .. 31; BDMA_CNDTR3 at 16#34# range 0 .. 31; BDMA_CPAR3 at 16#38# range 0 .. 31; BDMA_CMAR3 at 16#3C# range 0 .. 31; BDMA_CCR4 at 16#44# range 0 .. 31; BDMA_CNDTR4 at 16#48# range 0 .. 31; BDMA_CPAR4 at 16#4C# range 0 .. 31; BDMA_CMAR4 at 16#50# range 0 .. 31; BDMA_CCR5 at 16#58# range 0 .. 31; BDMA_CNDTR5 at 16#5C# range 0 .. 31; BDMA_CPAR5 at 16#60# range 0 .. 31; BDMA_CMAR5 at 16#64# range 0 .. 31; BDMA_CCR6 at 16#6C# range 0 .. 31; BDMA_CNDTR6 at 16#70# range 0 .. 31; BDMA_CPAR6 at 16#74# range 0 .. 31; BDMA_CMAR6 at 16#78# range 0 .. 31; BDMA_CCR7 at 16#80# range 0 .. 31; BDMA_CNDTR7 at 16#84# range 0 .. 31; BDMA_CPAR7 at 16#88# range 0 .. 31; BDMA_CMAR7 at 16#8C# range 0 .. 31; BDMA_CCR8 at 16#94# range 0 .. 31; BDMA_CNDTR8 at 16#98# range 0 .. 31; BDMA_CPAR8 at 16#9C# range 0 .. 31; BDMA_CMAR8 at 16#A0# range 0 .. 31; end record; -- BDMA BDMA_Periph : aliased BDMA_Peripheral with Import, Address => BDMA_Base; end STM32_SVD.BDMA;
zhmu/ananas
Ada
195
adb
-- { dg-do compile } with Addr16_Pkg; use Addr16_Pkg; procedure Addr16 (R : Rec) is pragma Unsuppress (Alignment_Check); B : Integer; for B'Address use R.A'Address; begin null; end;
AdaCore/ada-traits-containers
Ada
802
ads
pragma Ada_2012; with Formal_Hashed_Sets_Impl; generic type Element_Type (<>) is private; with function "=" (Left, Right : Element_Type) return Boolean is <>; package Formal_Hashed_Sets with SPARK_Mode is package Impl is new Formal_Hashed_Sets_Impl (Element_Type); type Set is new Impl.Base_Set with null record with Iterable => (First => First_Primitive, Next => Next_Primitive, Has_Element => Has_Element_Primitive, Element => Element_Primitive); -- Iteration over sets can be done over cursors or over elements. function Model (Self : Set'Class) return Impl.M.Set is (Impl.Model (Self)) with Ghost; pragma Annotate (GNATprove, Iterable_For_Proof, "Model", Model); end Formal_Hashed_Sets;
zhmu/ananas
Ada
387
adb
-- { dg-do run } with System; use System; procedure Addr15 is function Get_Bound (Param : Integer) return Integer is (Param); type Alpha_Typ is array (1 .. Get_Bound (1)) of Integer; type Beta_Typ is array (1 .. Get_Bound (0)) of Integer; Alpha : Alpha_Typ; Beta : aliased Beta_Typ; begin if Alpha'Address = Beta'Address then raise Program_Error; end if; end;
AdaCore/gpr
Ada
42
ads
package Api is procedure Run; end Api;
reznikmm/matreshka
Ada
4,083
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.Table_Link_To_Source_Data_Attributes; package Matreshka.ODF_Table.Link_To_Source_Data_Attributes is type Table_Link_To_Source_Data_Attribute_Node is new Matreshka.ODF_Table.Abstract_Table_Attribute_Node and ODF.DOM.Table_Link_To_Source_Data_Attributes.ODF_Table_Link_To_Source_Data_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Table_Link_To_Source_Data_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Table_Link_To_Source_Data_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Table.Link_To_Source_Data_Attributes;
stcarrez/ada-servlet
Ada
2,600
ads
----------------------------------------------------------------------- -- servlet-parts -- Servlet Parts -- Copyright (C) 2011, 2012 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Finalization; -- The <b>Servlet.Parts</b> package is an Ada implementation of the Java servlet part -- (JSR 315 3. The Request) provided by the <tt>javax.servlet.http.Part</tt> class. package Servlet.Parts is -- ------------------------------ -- Multi part content -- ------------------------------ -- The <b>Part</b> type describes a mime part received in a request. -- The content is stored in a file and several operations are provided -- to manage the content. type Part is abstract new Ada.Finalization.Limited_Controlled with private; -- Get the size of the mime part. function Get_Size (Data : in Part) return Natural is abstract; -- Get the content name submitted in the mime part. function Get_Name (Data : in Part) return String is abstract; -- Get the path of the local file which contains the part. function Get_Local_Filename (Data : in Part) return String is abstract; -- Get the content type of the part. function Get_Content_Type (Data : in Part) return String is abstract; -- Write the part data item to the file. This method is not guaranteed to succeed -- if called more than once for the same part. This allows a particular implementation -- to use, for example, file renaming, where possible, rather than copying all of -- the underlying data, thus gaining a significant performance benefit. procedure Save (Data : in Part; Path : in String); -- Deletes the underlying storage for a file item, including deleting any associated -- temporary disk file. procedure Delete (Data : in out Part); private type Part is abstract new Ada.Finalization.Limited_Controlled with null record; end Servlet.Parts;
reznikmm/matreshka
Ada
3,913
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_Elements.Text.Notes_Configuration; package ODF.DOM.Elements.Text.Notes_Configuration.Internals is function Create (Node : Matreshka.ODF_Elements.Text.Notes_Configuration.Text_Notes_Configuration_Access) return ODF.DOM.Elements.Text.Notes_Configuration.ODF_Text_Notes_Configuration; function Wrap (Node : Matreshka.ODF_Elements.Text.Notes_Configuration.Text_Notes_Configuration_Access) return ODF.DOM.Elements.Text.Notes_Configuration.ODF_Text_Notes_Configuration; end ODF.DOM.Elements.Text.Notes_Configuration.Internals;
ohenley/ada-util
Ada
5,177
ads
----------------------------------------------------------------------- -- util-texts-builders -- Text builder -- Copyright (C) 2013, 2017 Stephane Carrez -- Written by Stephane Carrez ([email protected]) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- private with Ada.Finalization; -- == Description == -- The <tt>Util.Texts.Builders</tt> generic package was designed to provide string builders. -- The interface was designed to reduce memory copies as much as possible. -- -- * The <tt>Builder</tt> type holds a list of chunks into which texts are appended. -- * The builder type holds an initial chunk whose capacity is defined when the builder -- instance is declared. -- * There is only an <tt>Append</tt> procedure which allows to append text to the builder. -- This is the only time when a copy is made. -- * The package defines the <tt>Iterate</tt> operation that allows to get the content -- collected by the builder. When using the <tt>Iterate</tt> operation, no copy is -- performed since chunks data are passed passed by reference. -- * The type is limited to forbid copies of the builder instance. -- -- == Example == -- First, instantiate the package for the element type (eg, String): -- -- package String_Builder is new Util.Texts.Builders (Character, String); -- -- Declare the string builder instance with its initial capacity: -- -- Builder : String_Builder.Builder (256); -- -- And append to it: -- -- String_Builder.Append (Builder, "Hello"); -- -- To get the content collected in the builder instance, write a procedure that recieves -- the chunk data as parameter: -- -- procedure Collect (Item : in String) is ... -- -- And use the <tt>Iterate</tt> operation: -- -- String_Builder.Iterate (Builder, Collect'Access); -- generic type Element_Type is (<>); type Input is array (Positive range <>) of Element_Type; Chunk_Size : Positive := 80; package Util.Texts.Builders is pragma Preelaborate; type Builder (Len : Positive) is limited private; -- Get the length of the item builder. function Length (Source : in Builder) return Natural; -- Get the capacity of the builder. function Capacity (Source : in Builder) return Natural; -- Get the builder block size. function Block_Size (Source : in Builder) return Positive; -- Set the block size for the allocation of next chunks. procedure Set_Block_Size (Source : in out Builder; Size : in Positive); -- Append the <tt>New_Item</tt> at the end of the source growing the buffer if necessary. procedure Append (Source : in out Builder; New_Item : in Input); -- Append the <tt>New_Item</tt> at the end of the source growing the buffer if necessary. procedure Append (Source : in out Builder; New_Item : in Element_Type); -- Clear the source freeing any storage allocated for the buffer. procedure Clear (Source : in out Builder); -- Iterate over the buffer content calling the <tt>Process</tt> procedure with each -- chunk. procedure Iterate (Source : in Builder; Process : not null access procedure (Chunk : in Input)); -- Get the buffer content as an array. function To_Array (Source : in Builder) return Input; -- Return the content starting from the tail and up to <tt>Length</tt> items. function Tail (Source : in Builder; Length : in Natural) return Input; -- Call the <tt>Process</tt> procedure with the full buffer content, trying to avoid -- secondary stack copies as much as possible. generic with procedure Process (Content : in Input); procedure Get (Source : in Builder); private pragma Inline (Length); pragma Inline (Iterate); type Block; type Block_Access is access all Block; type Block (Len : Positive) is limited record Next_Block : Block_Access; Last : Natural := 0; Content : Input (1 .. Len); end record; type Builder (Len : Positive) is new Ada.Finalization.Limited_Controlled with record Current : Block_Access; Block_Size : Positive := Chunk_Size; Length : Natural := 0; First : aliased Block (Len); end record; pragma Finalize_Storage_Only (Builder); -- Setup the builder. overriding procedure Initialize (Source : in out Builder); -- Finalize the builder releasing the storage. overriding procedure Finalize (Source : in out Builder); end Util.Texts.Builders;
faelys/natools
Ada
20,705
adb
------------------------------------------------------------------------------ -- Copyright (c) 2013-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 Natools.S_Expressions.Interpreter_Loop; with Natools.S_Expressions.Printers.Pretty.Config.Commands; package body Natools.S_Expressions.Printers.Pretty.Config is procedure Read_Screen_Offset (Expression : in Lockable.Descriptor'Class; Value : in out Screen_Offset; Has_Value : out Boolean); -- Decode a screen offset from a S-expression procedure Update_Casing (Casing : in out Encodings.Hex_Casing; Name : in Atom); function To_Atom (Value : in Screen_Offset) return Atom; function To_Atom (Before, After : in Entity) return Atom; function To_String (Value : in Entity) return String; procedure Main_Execute (Param : in out Parameters; Context : in Meaningless_Type; Name : in Atom); procedure Main_Execute (Param : in out Parameters; Context : in Meaningless_Type; Name : in Atom; Arguments : in out Lockable.Descriptor'Class); procedure Newline_Execute (Param : in out Parameters; Context : in Meaningless_Type; Name : in Atom); procedure Newline_Execute (Param : in out Parameters; Context : in Meaningless_Type; Name : in Atom; Arguments : in out Lockable.Descriptor'Class); procedure Newline_Interpreter (Expression : in out Lockable.Descriptor'Class; Param : in out Parameters); procedure Quoted_Execute (Param : in out Parameters; Context : in Meaningless_Type; Name : in Atom); procedure Quoted_Interpreter (Expression : in out Lockable.Descriptor'Class; Param : in out Parameters); procedure Separator_Execute (State : in out Entity_Separator; Value : in Boolean; Name : in Atom); procedure Separator_Execute (State : in out Entity_Separator; Value : in Boolean; Name : in Atom; Arguments : in out Lockable.Descriptor'Class); procedure Separator_Interpreter (Expression : in out Lockable.Descriptor'Class; State : in out Entity_Separator; Context : in Boolean); ------------------ -- Interpreters -- ------------------ procedure Main_Execute (Param : in out Parameters; Context : in Meaningless_Type; Name : in Atom) is pragma Unreferenced (Context); Command : constant String := To_String (Name); begin case Commands.Main (Command) is when Commands.Set_Char_Encoding => Param.Char_Encoding := Commands.To_Character_Encoding (Command); when Commands.Set_Fallback => Param.Fallback := Commands.To_Atom_Encoding (Command); Update_Casing (Param.Hex_Casing, Name); when Commands.Set_Hex_Casing => Param.Hex_Casing := Commands.To_Hex_Casing (Command); when Commands.Set_Indentation => Param.Indentation := 0; when Commands.Set_Newline_Encoding => Param.Newline := Commands.To_Newline_Encoding (Command); when Commands.Set_Quoted => Param.Quoted := Commands.To_Quoted_Option (Command); when Commands.Set_Token => Param.Token := Commands.To_Token_Option (Command); when Commands.Set_Width => Param.Width := 0; when Commands.Set_Newline | Commands.Set_Quoted_String | Commands.Set_Space_At | Commands.Set_Tab_Stop => -- Those commands are meaningless without argument null; end case; end Main_Execute; procedure Main_Execute (Param : in out Parameters; Context : in Meaningless_Type; Name : in Atom; Arguments : in out Lockable.Descriptor'Class) is pragma Unreferenced (Context); Command : constant String := To_String (Name); begin case Commands.Main (Command) is when Commands.Set_Indentation => declare Has_Value : Boolean; Event : Events.Event; begin Read_Screen_Offset (Arguments, Param.Indentation, Has_Value); if Has_Value and then Param.Indentation /= 0 then Arguments.Next (Event); if Event = Events.Add_Atom then declare Unit : constant String := To_String (Arguments.Current_Atom); Last : Natural := Unit'Last; begin if Last > 0 and then Unit (Last) = 's' then Last := Last - 1; end if; if Unit (Unit'First .. Last) = "tab" then Param.Indent := Tabs; elsif Unit (Unit'First .. Last) = "space" then Param.Indent := Spaces; elsif Unit (Unit'First .. Last) = "tabbed-space" then Param.Indent := Tabs_And_Spaces; end if; end; end if; end if; end; when Commands.Set_Newline => Newline_Interpreter (Arguments, Param); when Commands.Set_Quoted_String => Quoted_Interpreter (Arguments, Param); when Commands.Set_Space_At => Separator_Interpreter (Arguments, Param.Space_At, True); when Commands.Set_Tab_Stop => declare Value : Screen_Offset := 0; Has_Value : Boolean; begin Read_Screen_Offset (Arguments, Value, Has_Value); if Has_Value and then Value /= 0 then Param.Tab_Stop := Value; end if; end; when Commands.Set_Token => begin if Arguments.Current_Event = Events.Add_Atom then Param.Token := Commands.To_Token_Option (To_String (Arguments.Current_Atom)); end if; exception when Constraint_Error => null; end; when Commands.Set_Width => declare Has_Value : Boolean; begin Read_Screen_Offset (Arguments, Param.Width, Has_Value); end; when Commands.Set_Char_Encoding | Commands.Set_Fallback | Commands.Set_Hex_Casing | Commands.Set_Newline_Encoding | Commands.Set_Quoted => -- These commands don't do anything with arguments null; end case; end Main_Execute; procedure Newline_Execute (Param : in out Parameters; Context : in Meaningless_Type; Name : in Atom) is pragma Unreferenced (Context); Command : constant String := To_String (Name); begin case Commands.Newline (Command) is when Commands.Set_Newline_Command_Encoding => Param.Newline := Commands.To_Newline_Encoding (Command); when Commands.Set_Newline_Separator => Separator_Execute (Param.Newline_At, True, Name); end case; end Newline_Execute; procedure Newline_Execute (Param : in out Parameters; Context : in Meaningless_Type; Name : in Atom; Arguments : in out Lockable.Descriptor'Class) is pragma Unreferenced (Context); Command : constant String := To_String (Name); begin case Commands.Newline (Command) is when Commands.Set_Newline_Command_Encoding => Param.Newline := Commands.To_Newline_Encoding (Command); when Commands.Set_Newline_Separator => Separator_Execute (Param.Newline_At, True, Name, Arguments); end case; end Newline_Execute; procedure Quoted_Execute (Param : in out Parameters; Context : in Meaningless_Type; Name : in Atom) is pragma Unreferenced (Context); Command : constant String := To_String (Name); begin case Commands.Quoted_String (Command) is when Commands.Set_Quoted_Option => Param.Quoted := Commands.To_Quoted_Option (Command); when Commands.Set_Quoted_Escape => Param.Quoted_Escape := Commands.To_Quoted_Escape (Command); Update_Casing (Param.Hex_Casing, Name); end case; end Quoted_Execute; procedure Separator_Execute (State : in out Entity_Separator; Value : in Boolean; Name : in Atom) is begin case Commands.Separator (To_String (Name)) is when Commands.All_Separators => State := (others => (others => Value)); when Commands.No_Separators => State := (others => (others => not Value)); when Commands.Invert_Separators => null; -- Error, actually when Commands.Open_Open => State (Opening, Opening) := Value; when Commands.Open_Atom => State (Opening, Atom_Data) := Value; when Commands.Open_Close => State (Opening, Closing) := Value; when Commands.Atom_Open => State (Atom_Data, Opening) := Value; when Commands.Atom_Atom => State (Atom_Data, Atom_Data) := Value; when Commands.Atom_Close => State (Atom_Data, Closing) := Value; when Commands.Close_Open => State (Closing, Opening) := Value; when Commands.Close_Atom => State (Closing, Atom_Data) := Value; when Commands.Close_Close => State (Closing, Closing) := Value; end case; end Separator_Execute; procedure Separator_Execute (State : in out Entity_Separator; Value : in Boolean; Name : in Atom; Arguments : in out Lockable.Descriptor'Class) is begin case Commands.Separator (To_String (Name)) is when Commands.Invert_Separators => Separator_Interpreter (Arguments, State, not Value); when Commands.All_Separators | Commands.No_Separators | Commands.Open_Open | Commands.Open_Atom | Commands.Open_Close | Commands.Atom_Open | Commands.Atom_Atom | Commands.Atom_Close | Commands.Close_Open | Commands.Close_Atom | Commands.Close_Close => Separator_Execute (State, Value, Name); end case; end Separator_Execute; procedure Main_Interpreter is new Interpreter_Loop (Parameters, Meaningless_Type, Main_Execute, Main_Execute); procedure Newline_Interpreter is new Interpreter_Loop (Parameters, Meaningless_Type, Newline_Execute, Newline_Execute); procedure Quoted_Interpreter is new Interpreter_Loop (Parameters, Meaningless_Type, Dispatch_Without_Argument => Quoted_Execute); procedure Interpreter is new Interpreter_Loop (Entity_Separator, Boolean, Separator_Execute, Separator_Execute); procedure Newline_Interpreter (Expression : in out Lockable.Descriptor'Class; Param : in out Parameters) is begin Newline_Interpreter (Expression, Param, Meaningless_Value); end Newline_Interpreter; procedure Quoted_Interpreter (Expression : in out Lockable.Descriptor'Class; Param : in out Parameters) is begin Quoted_Interpreter (Expression, Param, Meaningless_Value); end Quoted_Interpreter; procedure Separator_Interpreter (Expression : in out Lockable.Descriptor'Class; State : in out Entity_Separator; Context : in Boolean) renames Interpreter; ------------------------------ -- Local Helper Subprograms -- ------------------------------ procedure Read_Screen_Offset (Expression : in Lockable.Descriptor'Class; Value : in out Screen_Offset; Has_Value : out Boolean) is Result : Screen_Offset := 0; begin Has_Value := False; if Expression.Current_Event /= Events.Add_Atom then return; end if; declare Data : constant Atom := Expression.Current_Atom; begin if Data'Length = 0 then return; end if; for I in Data'Range loop if Data (I) in Encodings.Digit_0 .. Encodings.Digit_9 then Result := Result * 10 + Screen_Offset (Data (I) - Encodings.Digit_0); else return; end if; end loop; Has_Value := True; Value := Result; end; end Read_Screen_Offset; function To_Atom (Value : in Screen_Offset) return Atom is Length : Count; begin Compute_Length : declare Left : Screen_Offset := Value; begin Length := 1; while Left >= 10 loop Length := Length + 1; Left := Left / 10; end loop; end Compute_Length; return Result : Atom (0 .. Length - 1) do declare I : Offset := Result'Last; Left : Screen_Offset := Value; begin loop Result (I) := Encodings.Digit_0 + Octet (Left mod 10); I := I - 1; Left := Left / 10; exit when Left = 0; end loop; pragma Assert (I + 1 = Result'First); end; end return; end To_Atom; function To_Atom (Before, After : in Entity) return Atom is begin return To_Atom (To_String (Before) & "-" & To_String (After)); end To_Atom; function To_String (Value : in Entity) return String is begin case Value is when Opening => return "open"; when Atom_Data => return "atom"; when Closing => return "close"; end case; end To_String; procedure Update_Casing (Casing : in out Encodings.Hex_Casing; Name : in Atom) is begin if Name'Length > 5 then declare Prefix : constant String := To_String (Name (Name'First .. Name'First + 4)); begin if Prefix = "upper" then Casing := Encodings.Upper; elsif Prefix = "lower" then Casing := Encodings.Lower; end if; end; end if; end Update_Casing; --------------------------------- -- Public High Level Interface -- --------------------------------- procedure Print (Output : in out Printers.Printer'Class; Param : in Parameters) is begin -- Newline_At and Newline Output.Open_List; Output.Append_Atom (To_Atom ("newline")); case Param.Newline is when CR => Output.Append_Atom (To_Atom ("cr")); when LF => Output.Append_Atom (To_Atom ("lf")); when CR_LF => Output.Append_Atom (To_Atom ("cr-lf")); when LF_CR => Output.Append_Atom (To_Atom ("lf-cr")); end case; if Param.Newline_At = Entity_Separator'(others => (others => True)) then Output.Append_Atom (To_Atom ("all")); else Output.Append_Atom (To_Atom ("none")); for Before in Entity loop for After in Entity loop if Param.Newline_At (Before, After) then Output.Append_Atom (To_Atom (Before, After)); end if; end loop; end loop; end if; Output.Close_List; -- Space_At Output.Open_List; Output.Append_Atom (To_Atom ("space")); if Param.Space_At = Entity_Separator'(others => (others => True)) then Output.Append_Atom (To_Atom ("all")); else Output.Append_Atom (To_Atom ("none")); for Before in Entity loop for After in Entity loop if Param.Space_At (Before, After) then Output.Append_Atom (To_Atom (Before, After)); end if; end loop; end loop; end if; Output.Close_List; -- Tab_Stop Output.Open_List; Output.Append_Atom (To_Atom ("tab-stop")); Output.Append_Atom (To_Atom (Param.Tab_Stop)); Output.Close_List; -- Width if Param.Width > 0 then Output.Open_List; Output.Append_Atom (To_Atom ("width")); Output.Append_Atom (To_Atom (Param.Width)); Output.Close_List; else Output.Append_Atom (To_Atom ("no-width")); end if; -- Indentation and Indent if Param.Indentation = 0 then Output.Append_Atom (To_Atom ("no-indentation")); else Output.Open_List; Output.Append_Atom (To_Atom ("indentation")); Output.Append_Atom (To_Atom (Param.Indentation)); if Param.Indentation > 1 then case Param.Indent is when Spaces => Output.Append_Atom (To_Atom ("spaces")); when Tabs => Output.Append_Atom (To_Atom ("tabs")); when Tabs_And_Spaces => Output.Append_Atom (To_Atom ("tabbed-spaces")); end case; else case Param.Indent is when Spaces => Output.Append_Atom (To_Atom ("space")); when Tabs => Output.Append_Atom (To_Atom ("tab")); when Tabs_And_Spaces => Output.Append_Atom (To_Atom ("tabbed-space")); end case; end if; Output.Close_List; end if; -- Quoted case Param.Quoted is when No_Quoted => Output.Append_Atom (To_Atom ("no-quoted-string")); when Single_Line => Output.Append_Atom (To_Atom ("single-line-quoted-string")); when When_Shorter => Output.Append_Atom (To_Atom ("quoted-string-when-shorter")); end case; -- Quoted_Escape Output.Open_List; Output.Append_Atom (To_Atom ("escape")); case Param.Quoted_Escape is when Octal_Escape => Output.Append_Atom (To_Atom ("octal")); when Hex_Escape => Output.Append_Atom (To_Atom ("hexadecimal")); end case; Output.Close_List; -- Token Output.Open_List; Output.Append_Atom (To_Atom ("token")); case Param.Token is when No_Token => Output.Append_Atom (To_Atom ("never")); when Extended_Token => Output.Append_Atom (To_Atom ("extended")); when Standard_Token => Output.Append_Atom (To_Atom ("standard")); end case; Output.Close_List; -- Char_Encoding case Param.Char_Encoding is when UTF_8 => Output.Append_Atom (To_Atom ("utf-8")); when ASCII => Output.Append_Atom (To_Atom ("ascii")); when Latin => Output.Append_Atom (To_Atom ("latin-1")); end case; -- Hex_Casing case Param.Hex_Casing is when Encodings.Upper => Output.Append_Atom (To_Atom ("upper-case")); when Encodings.Lower => Output.Append_Atom (To_Atom ("lower-case")); end case; -- Fallback case Param.Fallback is when Base64 => Output.Append_Atom (To_Atom ("base-64")); when Hexadecimal => Output.Append_Atom (To_Atom ("hexadecimal")); when Verbatim => Output.Append_Atom (To_Atom ("verbatim")); end case; end Print; procedure Update (Param : in out Parameters; Expression : in out Lockable.Descriptor'Class) is begin Main_Interpreter (Expression, Param, Meaningless_Value); end Update; end Natools.S_Expressions.Printers.Pretty.Config;
sebsgit/textproc
Ada
1,155
adb
with PixelArray; with Ada.Text_IO; use PixelArray; package body HistogramGenerator is function verticalProjection(image: PixelArray.ImagePlane; r: ImageRegions.Rect) return Histogram.Data is result: Histogram.Data(r.height); begin for h in 0 .. r.height - 1 loop declare total: Float := 0.0; begin for w in 0 .. r.width - 1 loop if image.get(r.x + w, r.y + h) /= PixelArray.Background then total := total + 1.0; end if; end loop; result.set(h, total); end; end loop; return result; end verticalProjection; function horizontalProjection(image:PixelArray.ImagePlane; r: ImageRegions.Rect) return Histogram.Data is result: Histogram.Data(r.width); begin for h in 0 .. r.height - 1 loop for w in 0 .. r.width - 1 loop if image.get(r.x + w, r.y + h) /= PixelArray.Background then result.set(w, result.get(w) + 1.0); end if; end loop; end loop; return result; end horizontalProjection; end HistogramGenerator;
sparre/Ada-2012-Examples
Ada
410
adb
with Ada.Calendar; with Ada.Text_IO; with Eksempel_2; procedure Attribute_Demo is use type Ada.Calendar.Time; use Eksempel_2; Data : Eksempel_2.Goods_Data_Type; begin Data.Set_Production_Date ("311299"); if Data.Production_Date + 1.0 < Ada.Calendar.Clock then Ada.Text_IO.Put_Line ("Strange"); else Ada.Text_IO.Put_Line (Production_Date (Data)); end if; end Attribute_Demo;
damaki/libkeccak
Ada
8,718
adb
------------------------------------------------------------------------------- -- Copyright (c) 2019, Daniel King -- All rights reserved. -- -- Redistribution and use in source and binary forms, with or without -- modification, are permitted provided that the following conditions are met: -- * Redistributions of source code must retain the above copyright -- notice, this list of conditions and the following disclaimer. -- * Redistributions in binary form must reproduce the above copyright -- notice, this list of conditions and the following disclaimer in the -- documentation and/or other materials provided with the distribution. -- * The name of the copyright holder may not be used to endorse or promote -- Products derived from this software without specific prior written -- permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER BE LIABLE FOR ANY -- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF -- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------- package body Gimli with SPARK_Mode => On is Round_Constant : constant Unsigned_32 := 16#9e37_7900#; ------------ -- Swap -- ------------ procedure Swap (A, B : in out Unsigned_32) is Temp : Unsigned_32; begin Temp := A; A := B; B := Temp; end Swap; -------------- -- SP_Box -- -------------- procedure SP_Box (S : in out State) is X : Unsigned_32; Y : Unsigned_32; Z : Unsigned_32; begin for Column in Column_Number loop X := Rotate_Left (S (Column, 0), 24); Y := Rotate_Left (S (Column, 1), 9); Z := S (Column, 2); S (Column, 2) := X xor Shift_Left (Z, 1) xor Shift_Left (Y and Z, 2); S (Column, 1) := Y xor X xor Shift_Left (X or Z, 1); S (Column, 0) := Z xor Y xor Shift_Left (X and Y, 3); end loop; end SP_Box; ------------ -- Init -- ------------ procedure Init (S : out State) is begin S := (others => (others => 0)); end Init; --------------- -- Permute -- --------------- procedure Permute (S : in out State) is begin for Round in reverse Round_Number loop SP_Box (S); -- Small swap: pattern s...s...s... etc. if Round mod 4 = 0 then Swap (S (0, 0), S (1, 0)); Swap (S (2, 0), S (3, 0)); end if; -- Big swap: pattern ..S...S...S etc. if Round mod 4 = 2 then Swap (S (0, 0), S (2, 0)); Swap (S (1, 0), S (3, 0)); end if; if Round mod 4 = 0 then S (0, 0) := S (0, 0) xor (Round_Constant or Unsigned_32 (Round)); end if; end loop; end Permute; --------------------------- -- XOR_Bits_Into_State -- --------------------------- procedure XOR_Bits_Into_State (S : in out State; Data : in Keccak.Types.Byte_Array; Bit_Len : in Natural) is Remaining_Bits : Natural := Bit_Len; Offset : Natural := 0; begin -- Process whole words (32 bits). Outer_Loop : for Row in Row_Number loop pragma Loop_Invariant ((Offset * 8) + Remaining_Bits = Bit_Len); pragma Loop_Invariant (Offset mod 4 = 0); pragma Loop_Invariant (Offset = Natural (Row) * 16); for Column in Column_Number loop pragma Loop_Invariant ((Offset * 8) + Remaining_Bits = Bit_Len); pragma Loop_Invariant (Offset mod 4 = 0); pragma Loop_Invariant (Offset = (Natural (Row) * 16) + (Natural (Column) * 4)); exit Outer_Loop when Remaining_Bits < 32; declare Word : Unsigned_32; begin Word := Unsigned_32 (Data (Data'First + Offset)); Word := Word or Shift_Left (Unsigned_32 (Data (Data'First + Offset + 1)), 8); Word := Word or Shift_Left (Unsigned_32 (Data (Data'First + Offset + 2)), 16); Word := Word or Shift_Left (Unsigned_32 (Data (Data'First + Offset + 3)), 24); S (Column, Row) := S (Column, Row) xor Word; end; Offset := Offset + 4; Remaining_Bits := Remaining_Bits - 32; end loop; end loop Outer_Loop; -- Process any remaining data if Remaining_Bits > 0 then declare Column : constant Column_Number := Column_Number ((Bit_Len / 32) mod 4); Row : constant Row_Number := Row_Number (Bit_Len / 128); Word : Unsigned_32 := 0; Remaining_Bytes : constant Natural := (Remaining_Bits + 7) / 8; begin for I in Natural range 0 .. Remaining_Bytes - 1 loop Word := Word or Shift_Left (Unsigned_32 (Data (Data'First + Offset + I)), I * 8); end loop; S (Column, Row) := S (Column, Row) xor (Word and (2**Remaining_Bits) - 1); end; end if; end XOR_Bits_Into_State; -------------------- -- Extract_Bits -- -------------------- procedure Extract_Bytes (S : in State; Data : out Keccak.Types.Byte_Array) is Remaining : Natural := Data'Length; Offset : Natural := 0; Pos : Keccak.Types.Index_Number; begin -- Process whole words (32 bits). Outer_Loop : for Row in Row_Number loop pragma Loop_Invariant (Offset + Remaining = Data'Length); pragma Loop_Invariant (Offset mod 4 = 0); pragma Loop_Invariant (Offset = Natural (Row) * 16); for Column in Column_Number loop pragma Loop_Invariant (Offset + Remaining = Data'Length); pragma Loop_Invariant (Offset mod 4 = 0); pragma Loop_Invariant (Offset = (Natural (Row) * 16) + (Natural (Column) * 4)); exit Outer_Loop when Remaining < 4; declare Word : constant Unsigned_32 := S (Column, Row); begin Pos := Data'First + Offset; Data (Pos) := Unsigned_8 (Word and 16#FF#); Data (Pos + 1) := Unsigned_8 (Shift_Right (Word, 8) and 16#FF#); Data (Pos + 2) := Unsigned_8 (Shift_Right (Word, 16) and 16#FF#); Data (Pos + 3) := Unsigned_8 (Shift_Right (Word, 24) and 16#FF#); end; Offset := Offset + 4; Remaining := Remaining - 4; end loop; end loop Outer_Loop; pragma Assert (Remaining < 4); -- Process any remaining data if Remaining > 0 then declare Column : constant Column_Number := Column_Number ((Offset / 4) mod 4); Row : constant Row_Number := Row_Number (Offset / 16); Word : constant Unsigned_32 := S (Column, Row); begin for I in Natural range 0 .. Remaining - 1 loop pragma Loop_Invariant (Offset + (Remaining - I) = Data'Length); Data (Data'First + Offset) := Unsigned_8 (Shift_Right (Word, I * 8) and 16#FF#); Offset := Offset + 1; end loop; end; end if; end Extract_Bytes; -------------------- -- Extract_Bits -- -------------------- procedure Extract_Bits (A : in State; Data : out Keccak.Types.Byte_Array; Bit_Len : in Natural) is begin Extract_Bytes (A, Data); -- Avoid exposing more bits than requested by masking away higher bits -- in the last byte. if Bit_Len > 0 and Bit_Len mod 8 /= 0 then Data (Data'Last) := Data (Data'Last) and (2**(Bit_Len mod 8) - 1); end if; end Extract_Bits; end Gimli;
reznikmm/matreshka
Ada
4,005
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.Fo_Border_Bottom_Attributes; package Matreshka.ODF_Fo.Border_Bottom_Attributes is type Fo_Border_Bottom_Attribute_Node is new Matreshka.ODF_Fo.Abstract_Fo_Attribute_Node and ODF.DOM.Fo_Border_Bottom_Attributes.ODF_Fo_Border_Bottom_Attribute with null record; overriding function Create (Parameters : not null access Matreshka.DOM_Attributes.Attribute_L2_Parameters) return Fo_Border_Bottom_Attribute_Node; overriding function Get_Local_Name (Self : not null access constant Fo_Border_Bottom_Attribute_Node) return League.Strings.Universal_String; end Matreshka.ODF_Fo.Border_Bottom_Attributes;
stcarrez/ada-ado
Ada
7,088
adb
-- Generated by gperfhash with Util.Strings.Transforms; with Interfaces; use Interfaces; package body Mysql.Perfect_Hash is C : constant array (Character) of Unsigned_8 := (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, 1, 2, 3, 0, 0, 0, 4, 0, 0, 0, 0, 0, 0, 0, 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 0, 0, 0, 0, 31, 0, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 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); P : constant array (0 .. 8) of Natural := (1, 2, 3, 4, 5, 6, 7, 9, 13); T1 : constant array (0 .. 8, Unsigned_8 range 0 .. 31) of Unsigned_16 := ((54, 398, 393, 33, 16, 243, 125, 331, 154, 49, 229, 271, 138, 252, 32, 107, 282, 38, 401, 127, 287, 15, 47, 386, 77, 164, 48, 268, 67, 373, 106, 405), (277, 121, 284, 221, 268, 319, 52, 298, 446, 6, 375, 363, 158, 332, 427, 288, 289, 374, 293, 164, 170, 16, 117, 197, 140, 165, 334, 22, 430, 34, 237, 263), (201, 445, 317, 37, 452, 376, 94, 398, 117, 318, 58, 353, 43, 164, 267, 82, 150, 175, 305, 304, 328, 430, 353, 272, 99, 440, 288, 82, 274, 416, 309, 176), (228, 167, 432, 313, 192, 170, 88, 229, 88, 178, 242, 354, 207, 410, 220, 17, 390, 157, 15, 398, 16, 340, 227, 202, 381, 313, 249, 398, 57, 101, 212, 156), (276, 430, 314, 22, 188, 328, 26, 57, 338, 78, 405, 270, 2, 10, 442, 395, 277, 17, 1, 19, 81, 368, 452, 61, 282, 400, 410, 78, 413, 291, 236, 395), (113, 448, 115, 47, 40, 169, 431, 368, 200, 106, 190, 20, 279, 184, 376, 448, 11, 261, 172, 300, 209, 368, 123, 132, 323, 299, 222, 154, 94, 176, 447, 396), (38, 1, 198, 36, 413, 4, 55, 295, 408, 305, 15, 383, 330, 179, 130, 187, 386, 35, 119, 137, 338, 375, 26, 225, 339, 139, 401, 185, 254, 41, 211, 377), (193, 364, 266, 418, 82, 399, 22, 249, 15, 371, 367, 29, 402, 431, 56, 326, 400, 109, 68, 169, 339, 416, 317, 301, 209, 135, 179, 324, 257, 248, 94, 352), (113, 96, 296, 112, 370, 267, 317, 417, 381, 274, 161, 178, 248, 361, 89, 417, 319, 441, 125, 289, 419, 44, 418, 215, 88, 37, 228, 432, 132, 115, 283, 100)); T2 : constant array (0 .. 8, Unsigned_8 range 0 .. 31) of Unsigned_16 := ((70, 80, 89, 274, 219, 201, 194, 400, 360, 38, 232, 55, 311, 252, 351, 362, 252, 45, 435, 302, 189, 4, 96, 274, 133, 426, 43, 196, 277, 211, 185, 115), (193, 51, 164, 375, 252, 260, 50, 445, 15, 38, 66, 11, 240, 101, 24, 28, 378, 221, 82, 62, 145, 163, 444, 363, 410, 183, 189, 372, 2, 2, 7, 319), (343, 412, 189, 308, 3, 273, 11, 334, 85, 395, 445, 46, 317, 420, 150, 271, 185, 34, 276, 390, 258, 40, 140, 61, 350, 451, 12, 364, 261, 85, 359, 227), (94, 151, 144, 347, 451, 162, 150, 36, 57, 403, 326, 355, 165, 314, 244, 61, 136, 80, 99, 106, 101, 66, 149, 250, 366, 392, 104, 98, 78, 303, 321, 271), (277, 93, 103, 166, 213, 63, 41, 430, 407, 356, 119, 332, 226, 197, 2, 429, 294, 101, 247, 324, 64, 189, 298, 301, 128, 280, 369, 447, 11, 220, 436, 206), (134, 227, 252, 331, 189, 37, 326, 275, 410, 39, 406, 45, 74, 276, 184, 436, 265, 135, 9, 21, 12, 49, 93, 329, 322, 192, 431, 434, 33, 109, 296, 80), (446, 178, 48, 92, 128, 211, 48, 201, 310, 49, 144, 402, 421, 313, 244, 280, 195, 101, 153, 53, 73, 24, 273, 64, 138, 267, 176, 43, 258, 404, 217, 341), (412, 188, 96, 226, 110, 202, 41, 366, 417, 255, 41, 82, 132, 68, 11, 240, 52, 122, 119, 445, 211, 329, 248, 222, 146, 219, 57, 286, 380, 293, 255, 122), (375, 57, 255, 427, 372, 157, 390, 409, 40, 144, 118, 345, 378, 359, 316, 97, 146, 341, 447, 60, 428, 319, 284, 75, 288, 107, 194, 142, 108, 237, 275, 242)); G : constant array (0 .. 452) of Unsigned_8 := (10, 0, 0, 0, 113, 0, 0, 0, 0, 0, 0, 187, 0, 0, 0, 0, 11, 0, 0, 0, 53, 0, 0, 0, 0, 0, 185, 0, 0, 0, 0, 0, 211, 136, 80, 0, 216, 86, 137, 0, 0, 0, 83, 0, 0, 0, 35, 0, 0, 0, 0, 107, 0, 140, 0, 0, 116, 0, 0, 220, 0, 0, 0, 0, 191, 199, 23, 0, 0, 0, 0, 0, 215, 139, 0, 122, 118, 0, 0, 0, 0, 117, 0, 0, 0, 0, 0, 0, 0, 0, 6, 140, 164, 0, 171, 0, 61, 125, 0, 0, 0, 0, 49, 206, 0, 0, 154, 0, 23, 0, 0, 71, 0, 0, 59, 137, 0, 107, 46, 0, 210, 44, 0, 0, 59, 214, 0, 0, 156, 0, 0, 38, 0, 0, 201, 0, 0, 37, 173, 0, 0, 33, 125, 206, 0, 0, 0, 54, 0, 0, 0, 212, 0, 40, 0, 75, 0, 25, 0, 0, 0, 0, 32, 0, 0, 0, 0, 0, 0, 181, 177, 0, 0, 143, 193, 0, 0, 8, 0, 21, 42, 216, 0, 132, 8, 122, 20, 165, 0, 158, 81, 0, 0, 0, 197, 134, 15, 73, 0, 117, 0, 76, 0, 0, 0, 0, 12, 0, 191, 38, 52, 166, 0, 128, 0, 65, 8, 0, 47, 0, 0, 0, 0, 0, 0, 0, 57, 0, 0, 0, 28, 91, 0, 0, 162, 0, 0, 0, 0, 9, 215, 63, 184, 187, 167, 0, 178, 100, 0, 0, 0, 182, 112, 0, 0, 74, 31, 169, 141, 159, 0, 61, 0, 151, 132, 0, 194, 20, 0, 61, 0, 0, 0, 79, 200, 88, 0, 33, 151, 42, 0, 210, 179, 77, 120, 0, 0, 35, 0, 0, 66, 0, 0, 201, 178, 0, 0, 0, 0, 0, 117, 0, 0, 0, 186, 224, 218, 0, 121, 0, 0, 2, 165, 6, 0, 167, 0, 184, 115, 131, 0, 0, 10, 215, 0, 0, 72, 58, 23, 45, 0, 192, 196, 0, 146, 58, 0, 99, 88, 0, 115, 0, 0, 0, 57, 44, 200, 0, 58, 0, 19, 4, 114, 1, 84, 3, 0, 225, 0, 211, 0, 0, 0, 0, 0, 50, 149, 205, 5, 188, 0, 0, 208, 17, 0, 143, 110, 76, 0, 187, 85, 0, 93, 96, 62, 0, 60, 25, 158, 108, 0, 51, 0, 0, 194, 154, 128, 214, 101, 0, 0, 0, 0, 0, 61, 43, 190, 180, 85, 0, 217, 96, 0, 161, 56, 68, 0, 0, 217, 92, 76, 65, 0, 173, 0, 0, 30, 0, 0, 66, 13, 151, 0, 31, 95, 0, 0, 78, 21, 34, 161, 34, 220, 191, 0, 7, 109, 0, 217, 68, 65, 0, 139); function Hash (S : String) return Natural is F : constant Natural := S'First - 1; L : constant Natural := S'Length; F1, F2 : Natural := 0; J : Unsigned_8; begin for K in P'Range loop exit when L < P (K); J := C (S (P (K) + F)); F1 := (F1 + Natural (T1 (K, J))) mod 453; F2 := (F2 + Natural (T2 (K, J))) mod 453; end loop; return (Natural (G (F1)) + Natural (G (F2))) mod 226; end Hash; -- Returns true if the string <b>S</b> is a keyword. function Is_Keyword (S : in String) return Boolean is H : constant Natural := Hash (S); begin return Keywords (H).all = Util.Strings.Transforms.To_Upper_Case (S); end Is_Keyword; end Mysql.Perfect_Hash;
sebsgit/textproc
Ada
1,642
ads
with PixelArray; with ImageRegions; with ImageMoments; with ImageThresholds; with Morphology; with Histogram; with HistogramDescriptor; with Ada.Containers.Vectors; with Ada.Directories; package ShapeDatabase is pragma Elaborate_Body; pragma Assertion_Policy (Pre => Check, Post => Check, Type_Invariant => Check); type Descriptor is tagged record moments: ImageMoments.HuMoments; orientation: Float; histogram: HistogramDescriptor.Data; end record; type CharacterDescriptor is record c: Character; d: Descriptor; end record; package ShapeVector is new Ada.Containers.Vectors(Index_Type => Natural, Element_Type => CharacterDescriptor); use ShapeVector; type DB is tagged record shapes: ShapeVector.Vector; end record; type MatchScore is record cc: Character; score: Float; end record; function preprocess(image: PixelArray.ImagePlane) return PixelArray.ImagePlane with Post => ImageThresholds.isBinary(preprocess'Result); function Preprocess_And_Detect_Regions(image: in PixelArray.ImagePlane; res: out ImageRegions.RegionVector.Vector) return PixelArray.ImagePlane; function getDB return DB; function match(database: DB; image: PixelArray.ImagePlane; region: ImageRegions.Region) return MatchScore; function loadShapes(imagePath: String) return ShapeVector.Vector with Pre => Ada.Directories.Exists(Name => imagePath), Post => not loadShapes'Result.Is_Empty; private staticDB: DB; end ShapeDatabase;
reznikmm/matreshka
Ada
3,758
ads
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, Vadim Godunko <[email protected]> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Qt4.Strings; with League.Strings; package Modeler is function "+" (Item : Wide_Wide_String) return Qt4.Strings.Q_String renames Qt4.Strings.From_Ucs_4; function "+" (Item : Wide_Wide_String) return League.Strings.Universal_String renames League.Strings.To_Universal_String; function "+" (Item : League.Strings.Universal_String) return Qt4.Strings.Q_String; end Modeler;
ficorax/PortAudioAda
Ada
1,119
ads
with Gtk.Button; use Gtk.Button; with Gtk.Combo_Box; use Gtk.Combo_Box; with Gtk.Handlers; with Gtk.Scale; use Gtk.Scale; with Gtk.Spin_Button; use Gtk.Spin_Button; with Gtk.Widget; use Gtk.Widget; package GA_Sine_Callbacks is package SpinHand is new Gtk.Handlers.Callback (Widget_Type => Gtk_Spin_Button_Record); procedure Frames_Per_Buffer_Callback (widget : access Gtk_Spin_Button_Record'Class); package CombHand is new Gtk.Handlers.Callback (Widget_Type => Gtk_Combo_Box_Record); procedure Sample_Rate_Callback (widget : access Gtk_Combo_Box_Record'Class); package ScaleHand is new Gtk.Handlers.Callback (Widget_Type => Gtk_Hscale_Record); procedure Amplitude_Callback (widget : access Gtk_Hscale_Record'Class); procedure Frequency_Callback (widget : access Gtk_Hscale_Record'Class); package SpinBtn is new Gtk.Handlers.Callback (Widget_Type => Gtk_Button_Record); procedure Start_Callback (widget : access Gtk_Widget_Record'Class); procedure Stop_Callback (widget : access Gtk_Widget_Record'Class); end GA_Sine_Callbacks;