id
int64
0
30.9k
extension
stringclasses
1 value
max_stars_count
int64
0
17k
max_stars_repo_name
stringlengths
7
106
max_stars_repo_path
stringlengths
5
136
text
stringlengths
9
1M
29,600
ada
7
98devin/ada-gba-dev
demo/src/Sprites.ads
-- Copyright (c) 2021 <NAME> -- zlib License -- see LICENSE for details. procedure Sprites with Linker_Section => ".iwram", No_Inline; pragma Machine_Attribute (Sprites, "target", "arm");
29,601
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c4/c43004c.ada
-- C43004C.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- OBJECTIVE: -- CHECK THAT CONSTRAINT_ERROR IS RAISED IF THE VALUE OF A -- DISCRIMINANT OF A CONSTRAINED COMPONENT OF AN AGGREGATE DOES -- NOT EQUAL THE CORRESPONDING DISCRIMINANT VALUE FOR THE -- COMPONENT'S SUBTYPE. -- HISTORY: -- BCB 07/19/88 CREATED ORIGINAL TEST. WITH REPORT; USE REPORT; PROCEDURE C43004C IS ZERO : INTEGER := 0; TYPE REC (D : INTEGER := 0) IS RECORD COMP1 : INTEGER; END RECORD; TYPE DREC (DD : INTEGER := ZERO) IS RECORD DCOMP1 : INTEGER; END RECORD; TYPE REC1 IS RECORD A : REC(0); END RECORD; TYPE REC2 IS RECORD B : DREC(ZERO); END RECORD; TYPE REC3 (D3 : INTEGER := 0) IS RECORD C : REC(D3); END RECORD; V : REC1; W : REC2; X : REC3; PACKAGE P IS TYPE PRIV1 (D : INTEGER := 0) IS PRIVATE; TYPE PRIV2 (DD : INTEGER := ZERO) IS PRIVATE; FUNCTION INIT (I : INTEGER) RETURN PRIV1; PRIVATE TYPE PRIV1 (D : INTEGER := 0) IS RECORD NULL; END RECORD; TYPE PRIV2 (DD : INTEGER := ZERO) IS RECORD NULL; END RECORD; END P; TYPE REC7 IS RECORD H : P.PRIV1 (0); END RECORD; Y : REC7; GENERIC TYPE GP IS PRIVATE; FUNCTION GEN_EQUAL (X, Y : GP) RETURN BOOLEAN; FUNCTION GEN_EQUAL (X, Y : GP) RETURN BOOLEAN IS BEGIN RETURN X = Y; END GEN_EQUAL; PACKAGE BODY P IS TYPE REC4 IS RECORD E : PRIV1(0); END RECORD; TYPE REC5 IS RECORD F : PRIV2(ZERO); END RECORD; TYPE REC6 (D6 : INTEGER := 0) IS RECORD G : PRIV1(D6); END RECORD; VV : REC4; WW : REC5; XX : REC6; FUNCTION REC4_EQUAL IS NEW GEN_EQUAL (REC4); FUNCTION REC5_EQUAL IS NEW GEN_EQUAL (REC5); FUNCTION REC6_EQUAL IS NEW GEN_EQUAL (REC6); FUNCTION INIT (I : INTEGER) RETURN PRIV1 IS VAR : PRIV1; BEGIN VAR := (D => I); RETURN VAR; END INIT; BEGIN TEST ("C43004C", "CHECK THAT CONSTRAINT_ERROR IS RAISED " & "IF THE VALUE OF A DISCRIMINANT OF A " & "CONSTRAINED COMPONENT OF AN AGGREGATE " & "DOES NOT EQUAL THE CORRESPONDING " & "DISCRIMINANT VALUE FOR THECOMPONENT'S " & "SUBTYPE"); BEGIN VV := (E => (D => 1)); FAILED ("CONSTRAINT_ERROR NOT RAISED - 1"); IF REC4_EQUAL (VV,VV) THEN COMMENT ("DON'T OPTIMIZE VV"); END IF; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("OTHER EXCEPTION RAISED - 1"); END; BEGIN WW := (F => (DD => 1)); FAILED ("CONSTRAINT_ERROR NOT RAISED - 2"); IF REC5_EQUAL (WW,WW) THEN COMMENT ("DON'T OPTIMIZE WW"); END IF; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("OTHER EXCEPTION RAISED - 2"); END; BEGIN XX := (D6 => 1, G => (D => 5)); FAILED ("CONSTRAINT_ERROR NOT RAISED - 3"); IF REC6_EQUAL (XX,XX) THEN COMMENT ("DON'T OPTIMIZE XX"); END IF; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("OTHER EXCEPTION RAISED - 3"); END; END P; USE P; FUNCTION REC1_EQUAL IS NEW GEN_EQUAL (REC1); FUNCTION REC2_EQUAL IS NEW GEN_EQUAL (REC2); FUNCTION REC3_EQUAL IS NEW GEN_EQUAL (REC3); FUNCTION REC7_EQUAL IS NEW GEN_EQUAL (REC7); BEGIN BEGIN V := (A => (D => 1, COMP1 => 2)); FAILED ("CONSTRAINT_ERROR NOT RAISED - 4"); IF REC1_EQUAL (V,V) THEN COMMENT ("DON'T OPTIMIZE V"); END IF; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("OTHER EXCEPTION RAISED - 4"); END; BEGIN W := (B => (DD => 1, DCOMP1 => 2)); FAILED ("CONSTRAINT_ERROR NOT RAISED - 5"); IF REC2_EQUAL (W,W) THEN COMMENT ("DON'T OPTIMIZE W"); END IF; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("OTHER EXCEPTION RAISED - 5"); END; BEGIN X := (D3 => 1, C => (D => 5, COMP1 => 2)); FAILED ("CONSTRAINT_ERROR NOT RAISED - 6"); IF REC3_EQUAL (X,X) THEN COMMENT ("DON'T OPTIMIZE X"); END IF; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("OTHER EXCEPTION RAISED - 6"); END; BEGIN Y := (H => INIT (1)); FAILED ("CONSTRAINT_ERROR NOT RAISED - 7"); IF REC7_EQUAL (Y,Y) THEN COMMENT ("DON'T OPTIMIZE Y"); END IF; EXCEPTION WHEN CONSTRAINT_ERROR => NULL; WHEN OTHERS => FAILED ("OTHER EXCEPTION RAISED - 7"); END; RESULT; END C43004C;
29,602
ada
0
djamal2727/Main-Bearing-Analytical-Model
Validation/pyFrame3DD-master/gcc-master/gcc/ada/debug_a.adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- D E B U G _ A -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2020, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Atree; use Atree; with Debug; use Debug; with Sinfo; use Sinfo; with Sinput; use Sinput; with Output; use Output; package body Debug_A is Debug_A_Depth : Natural := 0; -- Output for the debug A flag is preceded by a sequence of vertical bar -- characters corresponding to the recursion depth of the actions being -- recorded (analysis, expansion, resolution and evaluation of nodes) -- This variable records the depth. Max_Node_Ids : constant := 200; -- Maximum number of Node_Id values that get stacked Node_Ids : array (1 .. Max_Node_Ids) of Node_Id; -- A stack used to keep track of Node_Id values for setting the value of -- Current_Error_Node correctly. Note that if we have more than 200 -- recursion levels, we just don't reset the right value on exit, which -- is not crucial, since this is only for debugging. ----------------------- -- Local Subprograms -- ----------------------- procedure Debug_Output_Astring; -- Outputs Debug_A_Depth number of vertical bars, used to preface messages ------------------- -- Debug_A_Entry -- ------------------- procedure Debug_A_Entry (S : String; N : Node_Id) is begin -- Output debugging information if -gnatda flag set if Debug_Flag_A then Debug_Output_Astring; Write_Str (S); Write_Str ("Node_Id = "); Write_Int (Int (N)); Write_Str (" "); Write_Location (Sloc (N)); Write_Str (" "); Write_Str (Node_Kind'Image (Nkind (N))); Write_Eol; end if; -- Now push the new element -- Why is this done unconditionally??? Debug_A_Depth := Debug_A_Depth + 1; if Debug_A_Depth <= Max_Node_Ids then Node_Ids (Debug_A_Depth) := N; end if; -- Set Current_Error_Node only if the new node has a decent Sloc -- value, since it is for the Sloc value that we set this anyway. -- If we don't have a decent Sloc value, we leave it unchanged. if Sloc (N) > No_Location then Current_Error_Node := N; end if; end Debug_A_Entry; ------------------ -- Debug_A_Exit -- ------------------ procedure Debug_A_Exit (S : String; N : Node_Id; Comment : String) is begin Debug_A_Depth := Debug_A_Depth - 1; -- We look down the stack to find something with a decent Sloc. (If -- we find nothing, just leave it unchanged which is not so terrible) -- This seems nasty overhead for the normal case ??? for J in reverse 1 .. Integer'Min (Max_Node_Ids, Debug_A_Depth) loop if Sloc (Node_Ids (J)) > No_Location then Current_Error_Node := Node_Ids (J); exit; end if; end loop; -- Output debugging information if -gnatda flag set if Debug_Flag_A then Debug_Output_Astring; Write_Str (S); Write_Str ("Node_Id = "); Write_Int (Int (N)); Write_Str (Comment); Write_Eol; end if; end Debug_A_Exit; -------------------------- -- Debug_Output_Astring -- -------------------------- procedure Debug_Output_Astring is Vbars : constant String := "|||||||||||||||||||||||||"; -- Should be constant, removed because of GNAT 1.78 bug ??? begin if Debug_A_Depth > Vbars'Length then for I in Vbars'Length .. Debug_A_Depth loop Write_Char ('|'); end loop; Write_Str (Vbars); else Write_Str (Vbars (1 .. Debug_A_Depth)); end if; end Debug_Output_Astring; end Debug_A;
29,603
ada
0
Tim-Tom/scratch
random-bet/ada/src/RandomBet.adb
<gh_stars>0 with Ada.Text_IO; procedure RandomBet is package IO renames Ada.Text_IO; Max_Starting_Bet : constant := 255; Max_Bet_Pool : constant := Max_Starting_Bet * 3; type Offset_Array is Array (1 .. Max_Starting_Bet, 1 .. (Max_Bet_Pool - 1) / 2) of Natural; type Memory_Record is record Predecessor : Integer; Next_Record : Integer; P1,P2,P3 : Natural; end record; type Memory_Array is Array (Natural range <>) of Memory_Record; type Memory_Array_Access is access Memory_Array; Offsets : Offset_Array; function Init_Offsets return Natural is sum : Natural := 0; begin for x in Offsets'Range(1) loop for y in Offsets'Range(2) loop if y < x or 2*y + x > Max_Bet_Pool then Offsets(x,y) := 0; else Offsets(x,y) := sum; sum := sum + (Max_Bet_Pool - x - 2*y + 1); end if; end loop; end loop; return sum; end Init_Offsets; function Get_Offset(p1, p2, p3 : Natural) return Natural is base : constant Natural := Offsets(p1, p2); begin return base + p3 - p2; end Get_Offset; Memory_Size : constant Natural := Init_Offsets; Memory : constant Memory_Array_Access := new Memory_Array(0 .. Memory_Size); Next_Record : Integer := -1; Last_Record : Integer := -1; procedure Evaluate_Candidate(predecessor, p1, p2, p3: Natural) is offset : Natural; begin -- IO.Put_Line(Integer'Image(predecessor) & Integer'Image(p1) & Integer'Image(p2) & Integer'Image(p3)); if p1 = p2 or else p2 = p3 then return; end if; offset := Get_Offset(p1, p2, p3); if Memory(offset).Predecessor /= -1 then return; end if; Memory(offset).Predecessor := predecessor; Memory(Last_Record).Next_Record := offset; Last_Record := offset; end Evaluate_Candidate; procedure Evaluate_Candidate_Sort(predecessor, p1, p2, p3: Natural) is begin if p1 <= p2 then if p2 <= p3 then Evaluate_Candidate(predecessor, p1, p2, p3); elsif p1 <= p3 then Evaluate_Candidate(predecessor, p1, p3, p2); else Evaluate_Candidate(predecessor, p3, p1, p2); end if; elsif p2 <= p3 then if p1 <= p3 then Evaluate_Candidate(predecessor, p2, p1, p3); else Evaluate_Candidate(predecessor, p2, p3, p1); end if; else Evaluate_Candidate(predecessor, p3, p2, p1); end if; end Evaluate_Candidate_Sort; procedure Print_Solution(offset : Natural) is nr : Integer := offset; begin while nr /= -1 loop IO.Put_Line(Integer'Image(memory(nr).P1) & Integer'Image(memory(nr).P2) & Integer'Image(memory(nr).P3)); nr := memory(nr).Predecessor; end loop; end Print_Solution; Processed : Natural := 0; begin for x in 1 .. Max_Starting_Bet loop for y in x .. (Max_Bet_Pool - x) / 2 loop for z in y .. (Max_Bet_Pool - x - y) loop declare offset : Natural; begin offset := Get_Offset(x, y, z); Memory(offset).P1 := x; Memory(offset).P2 := y; Memory(offset).P3 := z; Memory(offset).Predecessor := -1; Memory(offset).Next_Record := -1; end; end loop; end loop; end loop; for x in 1 .. Max_Starting_Bet loop declare offset : Integer; begin if x mod 2 = 0 then offset := Get_Offset(x,x,x); Memory(offset).Next_Record := Next_Record; Next_Record := offset; end if; for y in x + 1 .. Max_Bet_Pool - 2*x loop if x mod 2 = 0 or else y mod 2 = 0 then offset := Get_Offset(x,x,y); Memory(offset).Next_Record := Next_Record; Next_Record := offset; end if; end loop; for y in x + 1 .. (Max_Bet_Pool - x)/2 loop if x mod 2 = 0 or else y mod 2 = 0 then offset := Get_Offset(x,y,y); Memory(offset).Next_Record := Next_Record; Next_Record := offset; end if; end loop; end; end loop; -- 1,1,2 is always the first record encountered. Last_Record := Get_Offset(1,1,2); while Next_Record /= -1 loop processed := processed + 1; declare mr : Memory_Record renames Memory(Next_Record); half : Natural; begin if mr.P1 mod 2 = 0 then half := mr.P1 / 2; Evaluate_Candidate_Sort(Next_Record, half, mr.P2 + half, mr.P3); Evaluate_Candidate_Sort(Next_Record, half, mr.P2, mr.P3 + half); end if; if mr.P2 mod 2 = 0 then half := mr.P2 / 2; Evaluate_Candidate_Sort(Next_Record, half, mr.P1 + half, mr.P3); Evaluate_Candidate_Sort(Next_Record, half, mr.P1, mr.P3 + half); end if; if mr.P3 mod 2 = 0 then half := mr.P3 / 2; Evaluate_Candidate_Sort(Next_Record, half, mr.P1 + half, mr.P2); Evaluate_Candidate_Sort(Next_Record, half, mr.P1, mr.P2 + half); end if; Next_Record := mr.Next_Record; end; end loop; IO.Put_Line("Processed " & Integer'Image(processed) & " records"); Print_Solution(Get_Offset(175, 199, 223)); end RandomBet;
29,604
ada
192
rocher/Ada_Drivers_Library
examples/STM32F4_DISCO/accelerometer/src/main.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. -- -- -- ------------------------------------------------------------------------------ -- This is a demo of the features available on the STM32F4-DISCOVERY board. -- -- Tilt the board and the LED closer to the ground will light up. with Ada.Real_Time; use Ada.Real_Time; with HAL; use HAL; with STM32.Board; use STM32.Board; with LIS3DSH; use LIS3DSH; procedure Main is Values : LIS3DSH.Axes_Accelerations; Threshold_High : constant LIS3DSH.Axis_Acceleration := 200; Threshold_Low : constant LIS3DSH.Axis_Acceleration := -200; procedure My_Delay (Milli : Natural); procedure My_Delay (Milli : Natural) is begin delay until Clock + Milliseconds (Milli); end My_Delay; begin Initialize_LEDs; Initialize_Accelerometer; Accelerometer.Configure (Output_DataRate => Data_Rate_100Hz, Axes_Enable => XYZ_Enabled, SPI_Wire => Serial_Interface_4Wire, Self_Test => Self_Test_Normal, Full_Scale => Fullscale_2g, Filter_BW => Filter_800Hz); if Accelerometer.Device_Id /= I_Am_LIS3DSH then All_LEDs_On; My_Delay (100); All_LEDs_Off; My_Delay (100); else loop Accelerometer.Get_Accelerations (Values); if abs Values.X > abs Values.Y then if Values.X > Threshold_High then STM32.Board.Red_LED.Set; elsif Values.X < Threshold_Low then STM32.Board.Green_LED.Set; end if; My_Delay (10); else if Values.Y > Threshold_High then STM32.Board.Orange_LED.Set; elsif Values.Y < Threshold_Low then STM32.Board.Blue_LED.Set; end if; My_Delay (10); end if; All_LEDs_Off; end loop; end if; end Main;
29,605
ada
32
robdaemon/AdaYaml
src/interface/yaml-events.ads
<reponame>robdaemon/AdaYaml -- part of AdaYaml, (c) 2017 <NAME> -- released under the terms of the MIT license, see the file "copying.txt" package Yaml.Events is -- parent of several event-holding collection types -- raised when trying to manipulate an event holder object while a -- Stream_Instance based on that object exists. State_Error : exception; private type Event_Array is array (Positive range <>) of aliased Event; type Event_Array_Access is access Event_Array; type Event_Holder is abstract limited new Refcount_Base with record Length : Natural := 0; Data : not null Event_Array_Access := new Event_Array (1 .. 256); end record; overriding procedure Finalize (Object : in out Event_Holder); procedure Copy_Data (Source : Event_Holder; Target : not null Event_Array_Access) with Pre => Target.all'Length >= Source.Data.all'Length; procedure Grow (Object : in out Event_Holder'Class); end Yaml.Events;
29,606
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/aggr12.ads
<reponame>best08618/asylo package Aggr12 is type Hair_Color_Type is (Black, Brown, Blonde, Grey, White, Red); type Rec is record I1, I2 : Hair_Color_Type; end record; A : constant Rec := (Black, Blonde); procedure Print (Data : String); procedure Test; end Aggr12;
29,607
ada
2
stcarrez/wi2wic
src/wi2wic-rest.adb
<gh_stars>1-10 ----------------------------------------------------------------------- -- wi2wic-rest -- REST entry points -- Copyright (C) 2020 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Wiki.Strings; with Wiki.Streams; with Wiki.Parsers; with Wiki.Filters.Html; with Wiki.Render.Html; with Wiki.Render.Wiki; with Wiki.Streams.Html.Stream; with Util.Http.Clients; with Util.Strings; with Servlet.Rest.Operation; package body Wi2wic.Rest is use type Wiki.Wiki_Syntax; URI_Prefix : constant String := "/v1"; package API_Import is new Servlet.Rest.Operation (Handler => Import'Access, Method => Servlet.Rest.POST, URI => URI_Prefix & "/import/{target}"); package API_Convert is new Servlet.Rest.Operation (Handler => Convert'Access, Method => Servlet.Rest.POST, URI => URI_Prefix & "/converter/{format}/{target}"); package API_Render is new Servlet.Rest.Operation (Handler => Render'Access, Method => Servlet.Rest.POST, URI => URI_Prefix & "/render/{format}"); Invalid_Format : exception; function Get_Syntax (Name : in String) return Wiki.Wiki_Syntax is begin if Name = "markdown" then return Wiki.SYNTAX_MARKDOWN; elsif Name = "dotclear" then return Wiki.SYNTAX_DOTCLEAR; elsif Name = "creoler" then return Wiki.SYNTAX_CREOLE; elsif Name = "mediawiki" then return Wiki.SYNTAX_MEDIA_WIKI; elsif Name = "html" then return Wiki.SYNTAX_HTML; else raise Invalid_Format; end if; end Get_Syntax; procedure Import_Doc (Doc : in out Wiki.Documents.Document; Syntax : in Wiki.Wiki_Syntax; Stream : in out Servlet.Streams.Input_Stream'Class) is type Input_Stream is new Wiki.Streams.Input_Stream with null record; -- Read one character from the input stream and return False to the <tt>Eof</tt> indicator. -- When there is no character to read, return True in the <tt>Eof</tt> indicator. overriding procedure Read (Input : in out Input_Stream; Char : out Wiki.Strings.WChar; Eof : out Boolean); overriding procedure Read (Input : in out Input_Stream; Char : out Wiki.Strings.WChar; Eof : out Boolean) is begin Stream.Read (Char); Eof := Stream.Is_Eof; exception when others => Eof := True; end Read; Html_Filter : aliased Wiki.Filters.Html.Html_Filter_Type; In_Stream : aliased Input_Stream; Engine : Wiki.Parsers.Parser; begin Html_Filter.Hide (Wiki.FOOTER_TAG); Html_Filter.Hide (Wiki.HEAD_TAG); Html_Filter.Hide (Wiki.HEADER_TAG); Html_Filter.Hide (Wiki.ADDRESS_TAG); Html_Filter.Hide (Wiki.IFRAME_TAG); Engine.Set_Syntax (Syntax); Engine.Add_Filter (Html_Filter'Unchecked_Access); Engine.Parse (In_Stream'Unchecked_Access, Doc); end Import_Doc; procedure Render_Doc (Doc : in out Wiki.Documents.Document; Syntax : in Wiki.Wiki_Syntax; Output : in out Servlet.Rest.Output_Stream'Class) is type Output_Stream is limited new Wiki.Streams.Output_Stream with null record; -- Write the string to the output stream. overriding procedure Write (Stream : in out Output_Stream; Content : in Wiki.Strings.WString); -- Write a single character to the output stream. overriding procedure Write (Stream : in out Output_Stream; Char : in Wiki.Strings.WChar); -- Write the string to the output stream. overriding procedure Write (Stream : in out Output_Stream; Content : in Wiki.Strings.WString) is begin Output.Write_Wide (Content); end Write; -- Write a single character to the output stream. overriding procedure Write (Stream : in out Output_Stream; Char : in Wiki.Strings.WChar) is begin Output.Write_Wide (Char); end Write; Out_Stream : aliased Output_Stream; Renderer : Wiki.Render.Wiki.Wiki_Renderer; begin Renderer.Set_Output_Stream (Out_Stream'Unchecked_Access, Syntax); Renderer.Render (Doc); end Render_Doc; procedure Render_Html (Doc : in out Wiki.Documents.Document; Output : in out Servlet.Rest.Output_Stream'Class) is type Output_Stream is limited new Wiki.Streams.Output_Stream with null record; -- Write the string to the output stream. overriding procedure Write (Stream : in out Output_Stream; Content : in Wiki.Strings.WString); -- Write a single character to the output stream. overriding procedure Write (Stream : in out Output_Stream; Char : in Wiki.Strings.WChar); -- Write the string to the output stream. overriding procedure Write (Stream : in out Output_Stream; Content : in Wiki.Strings.WString) is begin Output.Write_Wide (Content); end Write; -- Write a single character to the output stream. overriding procedure Write (Stream : in out Output_Stream; Char : in Wiki.Strings.WChar) is begin Output.Write_Wide (Char); end Write; package Html_Stream is new Wiki.Streams.Html.Stream (Output_Stream); Out_Stream : aliased Html_Stream.Html_Output_Stream; Renderer : Wiki.Render.Html.Html_Renderer; begin Renderer.Set_Render_TOC (True); Renderer.Set_Output_Stream (Out_Stream'Unchecked_Access); Renderer.Render (Doc); end Render_Html; -- ------------------------------ -- Import an HTML content by getting the HTML content from a URL -- and convert to the target wiki syntax. -- ------------------------------ procedure Import (Req : in out Servlet.Requests.Request'Class; Reply : in out Servlet.Responses.Response'Class; Stream : in out Servlet.Rest.Output_Stream'Class) is Doc : Wiki.Documents.Document; Target : constant String := Req.Get_Path_Parameter (1); URL : constant String := Req.Get_Parameter ("url"); Syntax : Wiki.Wiki_Syntax; Download : Util.Http.Clients.Client; Content : Util.Http.Clients.Response; begin Syntax := Get_Syntax (Target); if not Util.Strings.Starts_With (URL, "http://") and not Util.Strings.Starts_With (URL, "https://") then Reply.Set_Status (Util.Http.SC_BAD_REQUEST); return; end if; Download.Add_Header ("X-Requested-By", "wi2wic"); Download.Set_Timeout (5.0); begin Download.Get (URL, Content); exception when Util.Http.Clients.Connection_Error => Reply.Set_Status (Util.Http.SC_REQUEST_TIMEOUT); return; when others => Reply.Set_Status (Util.Http.SC_EXPECTATION_FAILED); return; end; declare Html_Filter : aliased Wiki.Filters.Html.Html_Filter_Type; Engine : Wiki.Parsers.Parser; Data : constant String := Content.Get_Body; begin Html_Filter.Hide (Wiki.FOOTER_TAG); Html_Filter.Hide (Wiki.HEAD_TAG); Html_Filter.Hide (Wiki.HEADER_TAG); Html_Filter.Hide (Wiki.ADDRESS_TAG); Html_Filter.Hide (Wiki.IFRAME_TAG); Engine.Set_Syntax (Wiki.SYNTAX_HTML); Engine.Add_Filter (Html_Filter'Unchecked_Access); Engine.Parse (Data, Doc); end; Render_Doc (Doc, Syntax, Stream); exception when Invalid_Format => Reply.Set_Status (Util.Http.SC_NOT_FOUND); end Import; -- ------------------------------ -- Convert a Wiki text from one format to another. -- ------------------------------ procedure Convert (Req : in out Servlet.Requests.Request'Class; Reply : in out Servlet.Responses.Response'Class; Stream : in out Servlet.Rest.Output_Stream'Class) is Doc : Wiki.Documents.Document; Format : constant String := Req.Get_Path_Parameter (1); Target : constant String := Req.Get_Path_Parameter (2); begin Import_Doc (Doc, Get_Syntax (Format), Req.Get_Input_Stream.all); Render_Doc (Doc, Get_Syntax (Target), Stream); exception when Invalid_Format => Reply.Set_Status (Util.Http.SC_NOT_FOUND); end Convert; -- ------------------------------ -- Render the Wiki content in HTML. -- ------------------------------ procedure Render (Req : in out Servlet.Requests.Request'Class; Reply : in out Servlet.Responses.Response'Class; Stream : in out Servlet.Rest.Output_Stream'Class) is Doc : Wiki.Documents.Document; Format : constant String := Req.Get_Path_Parameter (1); begin Import_Doc (Doc, Get_Syntax (Format), Req.Get_Input_Stream.all); Render_Html (Doc, Stream); exception when Invalid_Format => Reply.Set_Status (Util.Http.SC_NOT_FOUND); end Render; procedure Register (Server : in out Servlet.Core.Servlet_Registry'Class) is begin Servlet.Rest.Register (Server, API_Convert.Definition); Servlet.Rest.Register (Server, API_Render.Definition); Servlet.Rest.Register (Server, API_Import.Definition); end Register; end Wi2wic.Rest;
29,608
ada
60
Letractively/ada-util
samples/properties.adb
<reponame>Letractively/ada-util ----------------------------------------------------------------------- -- properties -- Example of properties -- Copyright (C) 2001, 2002, 2003, 2006, 2008, 2009, 2010 <NAME> -- Written by <NAME> (<EMAIL>) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Text_IO; with Ada.Exceptions; with Util.Properties.Basic; procedure Properties is use Util.Properties.Basic; Properties : Util.Properties.Manager; Count : Integer; begin Properties.Load_Properties (Path => "samples/test.properties"); Count := Integer_Property.Get (Properties, "test.count"); Ada.Text_IO.Put_Line ("test.count = " & Integer'Image (Count)); Count := Integer_Property.Get (Properties, "test.repeat"); Ada.Text_IO.Put_Line ("test.repeat = " & Integer'Image (Count)); exception when E : Util.Properties.NO_PROPERTY => Ada.Text_IO.Put_Line (Ada.Exceptions.Exception_Message (E)); end Properties;
29,609
ada
10
jrmarino/libsodium-ada
examples/encryption/demo_ada.adb
<reponame>jrmarino/libsodium-ada with Sodium.Functions; use Sodium.Functions; with Ada.Text_IO; use Ada.Text_IO; procedure Demo_Ada is message : constant String := "JRM wrote this note."; message2 : constant String := "1972 <NAME>"; cipherlen : constant Positive := Cipher_Length (message); cipher2len : constant Positive := Cipher_Length (message2); begin if not initialize_sodium_library then Put_Line ("Initialization failed"); return; end if; declare alice_public_key : Public_Box_Key; alice_secret_key : Secret_Box_Key; bob_public_key : Public_Box_Key; bob_secret_key : Secret_Box_Key; shared_key : Box_Shared_Key; new_nonce : Box_Nonce := Random_Nonce; cipher_text : Encrypted_Data (1 .. cipherlen); cipher2_text : Encrypted_Data (1 .. cipher2len); clear_text : String (1 .. message'Length); clear_text2 : String (1 .. message2'Length); new_box_seed : Sign_Key_Seed := Random_Box_Key_seed; begin Generate_Box_Keys (alice_public_key, alice_secret_key); Generate_Box_Keys (bob_public_key, bob_secret_key, new_box_seed); Put_Line ("Alice Public Key: " & As_Hexidecimal (alice_public_key)); Put_Line ("Alice Secret Key: " & As_Hexidecimal (alice_secret_key)); Put_Line ("Bob Public Key: " & As_Hexidecimal (bob_public_key)); Put_Line ("Bob Secret Key: " & As_Hexidecimal (bob_secret_key)); cipher_text := Encrypt_Message (plain_text_message => message, recipient_public_key => bob_public_key, sender_secret_key => alice_secret_key, unique_nonce => new_nonce); Put_Line ("CipherText (Alice): " & As_Hexidecimal (cipher_text)); clear_text := Decrypt_Message (ciphertext => cipher_text, sender_public_key => alice_public_key, recipient_secret_key => bob_secret_key, unique_nonce => new_nonce); Put_Line ("Back again: " & clear_text); shared_key := Generate_Shared_Key (recipient_public_key => alice_public_key, sender_secret_key => bob_secret_key); Put_Line (""); Put_Line ("Shared Key (Bob): " & As_Hexidecimal (shared_key)); new_nonce := Random_Nonce; cipher2_text := Encrypt_Message (plain_text_message => message2, shared_key => shared_key, unique_nonce => new_nonce); Put_Line ("CipherText2 (Bob): " & As_Hexidecimal (cipher2_text)); clear_text2 := Decrypt_Message (ciphertext => cipher2_text, shared_key => shared_key, unique_nonce => new_nonce); Put_Line ("Back again: " & clear_text2); end; end Demo_Ada;
29,610
ada
92
RomanWlm/lib-ledger-core
core/lib/soci/languages/ada/soci.ads
-- -- Thin wrapper for the simple interface of the SOCI database access library. -- -- Copyright (C) 2008-2011 <NAME> -- Distributed under the Boost Software License, Version 1.0. -- (See accompanying file LICENSE_1_0.txt or copy at -- http://www.boost.org/LICENSE_1_0.txt) with Ada.Calendar; with Interfaces.C; private with System; private with Ada.Finalization; package SOCI is -- -- General exception related to database and library usage. -- Database_Error : exception; -- -- Session. -- type Session is tagged limited private; not overriding function Make_Session (Connection_String : in String) return Session; not overriding procedure Open (This : in out Session; Connection_String : in String); not overriding procedure Close (This : in out Session); not overriding function Is_Open (This : in Session) return Boolean; -- Transaction management. not overriding procedure Start (This : in Session); not overriding procedure Commit (This : in Session); not overriding procedure Rollback (This : in Session); -- Immediate query execution. not overriding procedure Execute (This : in Session; Query : in String); -- -- Connection pool management. -- type Connection_Pool (Size : Positive) is tagged limited private; not overriding procedure Open (This : in out Connection_Pool; Position : in Positive; Connection_String : in String); not overriding procedure Close (This : in out Connection_Pool; Position : in Positive); not overriding procedure Lease (This : in out Connection_Pool; S : in out Session'Class); -- -- Statement. -- type Statement (<>) is tagged limited private; type Data_State is (Data_Null, Data_Not_Null); type Into_Position is private; type Vector_Index is new Natural; not overriding function Make_Statement (Sess : in Session'Class) return Statement; -- Statement preparation and execution. not overriding procedure Prepare (This : in Statement; Query : in String); not overriding procedure Execute (This : in Statement; With_Data_Exchange : in Boolean := False); not overriding function Execute (This : in Statement; With_Data_Exchange : in Boolean := False) return Boolean; not overriding function Fetch (This : in Statement) return Boolean; not overriding function Got_Data (This : in Statement) return Boolean; -- -- Data items handling. -- -- Database-specific types. -- These types are most likely identical to standard Integer, -- Long_Long_Integer and Long_Float, but are defined distinctly -- to avoid interfacing problems with other compilers. type DB_Integer is new Interfaces.C.int; type DB_Long_Long_Integer is new Interfaces.Integer_64; type DB_Long_Float is new Interfaces.C.double; -- Creation of single into elements. not overriding function Into_String (This : in Statement) return Into_Position; not overriding function Into_Integer (This : in Statement) return Into_Position; not overriding function Into_Long_Long_Integer (This : in Statement) return Into_Position; not overriding function Into_Long_Float (This : in Statement) return Into_Position; not overriding function Into_Time (This : in Statement) return Into_Position; -- Creation of vector into elements. not overriding function Into_Vector_String (This : in Statement) return Into_Position; not overriding function Into_Vector_Integer (This : in Statement) return Into_Position; not overriding function Into_Vector_Long_Long_Integer (This : in Statement) return Into_Position; not overriding function Into_Vector_Long_Float (This : in Statement) return Into_Position; not overriding function Into_Vector_Time (This : in Statement) return Into_Position; -- Inspection of single into elements. not overriding function Get_Into_State (This : in Statement; Position : in Into_Position) return Data_State; not overriding function Get_Into_String (This : in Statement; Position : in Into_Position) return String; not overriding function Get_Into_Integer (This : in Statement; Position : in Into_Position) return DB_Integer; not overriding function Get_Into_Long_Long_Integer (This : in Statement; Position : in Into_Position) return DB_Long_Long_Integer; not overriding function Get_Into_Long_Float (This : in Statement; Position : in Into_Position) return DB_Long_Float; not overriding function Get_Into_Time (This : in Statement; Position : in Into_Position) return Ada.Calendar.Time; -- Inspection of vector into elements. not overriding function Get_Into_Vectors_Size (This : in Statement) return Natural; not overriding function Into_Vectors_First_Index (This : in Statement) return Vector_Index; not overriding function Into_Vectors_Last_Index (This : in Statement) return Vector_Index; not overriding procedure Into_Vectors_Resize (This : in Statement; New_Size : in Natural); not overriding function Get_Into_Vector_State (This : in Statement; Position : in Into_Position; Index : in Vector_Index) return Data_State; not overriding function Get_Into_Vector_String (This : in Statement; Position : in Into_Position; Index : in Vector_Index) return String; not overriding function Get_Into_Vector_Integer (This : in Statement; Position : in Into_Position; Index : in Vector_Index) return DB_Integer; not overriding function Get_Into_Vector_Long_Long_Integer (This : in Statement; Position : in Into_Position; Index : in Vector_Index) return DB_Long_Long_Integer; not overriding function Get_Into_Vector_Long_Float (This : in Statement; Position : in Into_Position; Index : in Vector_Index) return DB_Long_Float; not overriding function Get_Into_Vector_Time (This : in Statement; Position : in Into_Position; Index : in Vector_Index) return Ada.Calendar.Time; -- Creation of single use elements. not overriding procedure Use_String (This : in Statement; Name : in String); not overriding procedure Use_Integer (This : in Statement; Name : in String); not overriding procedure Use_Long_Long_Integer (This : in Statement; Name : in String); not overriding procedure Use_Long_Float (This : in Statement; Name : in String); not overriding procedure Use_Time (This : in Statement; Name : in String); -- Creation of vector use elements. not overriding procedure Use_Vector_String (This : in Statement; Name : in String); not overriding procedure Use_Vector_Integer (This : in Statement; Name : in String); not overriding procedure Use_Vector_Long_Long_Integer (This : in Statement; Name : in String); not overriding procedure Use_Vector_Long_Float (This : in Statement; Name : in String); not overriding procedure Use_Vector_Time (This : in Statement; Name : in String); -- Modifiers for single use elements. not overriding procedure Set_Use_State (This : in Statement; Name : in String; State : in Data_State); not overriding procedure Set_Use_String (This : in Statement; Name : in String; Value : in String); not overriding procedure Set_Use_Integer (This : in Statement; Name : in String; Value : in DB_Integer); not overriding procedure Set_Use_Long_Long_Integer (This : in Statement; Name : in String; Value : in DB_Long_Long_Integer); not overriding procedure Set_Use_Long_Float (This : in Statement; Name : in String; Value : in DB_Long_Float); not overriding procedure Set_Use_Time (This : in Statement; Name : in String; Value : in Ada.Calendar.Time); -- Modifiers for vector use elements. not overriding function Get_Use_Vectors_Size (This : in Statement) return Natural; not overriding function Use_Vectors_First_Index (This : in Statement) return Vector_Index; not overriding function Use_Vectors_Last_Index (This : in Statement) return Vector_Index; not overriding procedure Use_Vectors_Resize (This : in Statement; New_Size : in Natural); not overriding procedure Set_Use_Vector_State (This : in Statement; Name : in String; Index : in Vector_Index; State : in Data_State); not overriding procedure Set_Use_Vector_String (This : in Statement; Name : in String; Index : in Vector_Index; Value : in String); not overriding procedure Set_Use_Vector_Integer (This : in Statement; Name : in String; Index : in Vector_Index; Value : in DB_Integer); not overriding procedure Set_Use_Vector_Long_Long_Integer (This : in Statement; Name : in String; Index : in Vector_Index; Value : in DB_Long_Long_Integer); not overriding procedure Set_Use_Vector_Long_Float (This : in Statement; Name : in String; Index : in Vector_Index; Value : in DB_Long_Float); not overriding procedure Set_Use_Vector_Time (This : in Statement; Name : in String; Index : in Vector_Index; Value : in Ada.Calendar.Time); -- Inspection of single use elements. -- -- Note: Use elements can be modified by the database if they -- are bound to out and inout parameters of stored procedures -- (although this is not supported by all database backends). -- This feature is available only for single use elements. not overriding function Get_Use_State (This : in Statement; Name : in String) return Data_State; not overriding function Get_Use_String (This : in Statement; Name : in String) return String; not overriding function Get_Use_Integer (This : in Statement; Name : in String) return DB_Integer; not overriding function Get_Use_Long_Long_Integer (This : in Statement; Name : in String) return DB_Long_Long_Integer; not overriding function Get_Use_Long_Float (This : in Statement; Name : in String) return DB_Long_Float; not overriding function Get_Use_Time (This : in Statement; Name : in String) return Ada.Calendar.Time; private -- Connection pool and supporting types. type Connection_Array is array (Positive range <>) of Session; type Used_Array is array (Positive range <>) of Boolean; -- Protected state for the connection pool. protected type Connection_Pool_PS (Size : Positive) is procedure Open (Position : in Positive; Connection_String : in String); procedure Close (Position : in Positive); entry Lease (S : in out Session'Class); procedure Give_Back (Position : in Positive); private Connections : Connection_Array (1 .. Size); Is_Used : Used_Array (1 .. Size) := (others => False); Available : Boolean := True; end Connection_Pool_PS; type Connection_Pool_PS_Ptr is access all Connection_Pool_PS; type Connection_Pool (Size : Positive) is tagged limited record Pool : aliased Connection_Pool_PS (Size); end record; -- Session and supporting types. type Session_Handle is new System.Address; Null_Session_Handle : constant Session_Handle := Session_Handle (System.Null_Address); type Session is new Ada.Finalization.Limited_Controlled with record Handle : Session_Handle; Initialized : Boolean := False; Belongs_To_Pool : Boolean := False; Pool : Connection_Pool_PS_Ptr; Position_In_Pool : Positive; end record; overriding procedure Finalize (This : in out Session); -- Statement and supporting types. type Statement_Handle is new System.Address; Null_Statement_Handle : constant Statement_Handle := Statement_Handle (System.Null_Address); type Statement is new Ada.Finalization.Limited_Controlled with record Handle : Statement_Handle; Initialized : Boolean := False; end record; overriding procedure Finalize (This : in out Statement); type Into_Position is new Natural; end SOCI;
29,611
ada
0
morellam-dev/cs-4308-concepts-of-programming-languages
module-06/src/oedipus.ads
-- FILE: oedipus.ads -- LICENSE: MIT © 2021 <NAME> with Ada.Exceptions; use Ada.Exceptions; package Oedipus is -- defines the Complex type, which represents a complex number A + Bi type Complex is private; function Create_Complex (A, B : in Float) return Complex; -- PRECOND: none -- POSTCOND: Complex number with real and imaginary components function Get_Real (C : in Complex) return Float; -- PRECOND: none -- POSTCOND: real component of C is returned function Get_Imaginary (C : in Complex) return Float; -- PRECOND: none -- POSTCOND: imaginary component of C is returned private type Complex is record Real : Float := 0.0; Imaginary : Float := 0.0; end record; end Oedipus;
29,612
ada
0
optikos/oasis
source/nodes/program-nodes-elsif_paths.ads
-- Copyright (c) 2019 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Program.Lexical_Elements; with Program.Elements.Expressions; with Program.Element_Vectors; with Program.Elements.Elsif_Paths; with Program.Element_Visitors; package Program.Nodes.Elsif_Paths is pragma Preelaborate; type Elsif_Path is new Program.Nodes.Node and Program.Elements.Elsif_Paths.Elsif_Path and Program.Elements.Elsif_Paths.Elsif_Path_Text with private; function Create (Elsif_Token : not null Program.Lexical_Elements.Lexical_Element_Access; Condition : not null Program.Elements.Expressions.Expression_Access; Then_Token : not null Program.Lexical_Elements.Lexical_Element_Access; Statements : not null Program.Element_Vectors.Element_Vector_Access) return Elsif_Path; type Implicit_Elsif_Path is new Program.Nodes.Node and Program.Elements.Elsif_Paths.Elsif_Path with private; function Create (Condition : not null Program.Elements.Expressions .Expression_Access; Statements : not null Program.Element_Vectors .Element_Vector_Access; Is_Part_Of_Implicit : Boolean := False; Is_Part_Of_Inherited : Boolean := False; Is_Part_Of_Instance : Boolean := False) return Implicit_Elsif_Path with Pre => Is_Part_Of_Implicit or Is_Part_Of_Inherited or Is_Part_Of_Instance; private type Base_Elsif_Path is abstract new Program.Nodes.Node and Program.Elements.Elsif_Paths.Elsif_Path with record Condition : not null Program.Elements.Expressions.Expression_Access; Statements : not null Program.Element_Vectors.Element_Vector_Access; end record; procedure Initialize (Self : aliased in out Base_Elsif_Path'Class); overriding procedure Visit (Self : not null access Base_Elsif_Path; Visitor : in out Program.Element_Visitors.Element_Visitor'Class); overriding function Condition (Self : Base_Elsif_Path) return not null Program.Elements.Expressions.Expression_Access; overriding function Statements (Self : Base_Elsif_Path) return not null Program.Element_Vectors.Element_Vector_Access; overriding function Is_Elsif_Path_Element (Self : Base_Elsif_Path) return Boolean; overriding function Is_Path_Element (Self : Base_Elsif_Path) return Boolean; type Elsif_Path is new Base_Elsif_Path and Program.Elements.Elsif_Paths.Elsif_Path_Text with record Elsif_Token : not null Program.Lexical_Elements.Lexical_Element_Access; Then_Token : not null Program.Lexical_Elements.Lexical_Element_Access; end record; overriding function To_Elsif_Path_Text (Self : aliased in out Elsif_Path) return Program.Elements.Elsif_Paths.Elsif_Path_Text_Access; overriding function Elsif_Token (Self : Elsif_Path) return not null Program.Lexical_Elements.Lexical_Element_Access; overriding function Then_Token (Self : Elsif_Path) return not null Program.Lexical_Elements.Lexical_Element_Access; type Implicit_Elsif_Path is new Base_Elsif_Path with record Is_Part_Of_Implicit : Boolean; Is_Part_Of_Inherited : Boolean; Is_Part_Of_Instance : Boolean; end record; overriding function To_Elsif_Path_Text (Self : aliased in out Implicit_Elsif_Path) return Program.Elements.Elsif_Paths.Elsif_Path_Text_Access; overriding function Is_Part_Of_Implicit (Self : Implicit_Elsif_Path) return Boolean; overriding function Is_Part_Of_Inherited (Self : Implicit_Elsif_Path) return Boolean; overriding function Is_Part_Of_Instance (Self : Implicit_Elsif_Path) return Boolean; end Program.Nodes.Elsif_Paths;
29,613
ada
20
charlie5/lace
2-low/collada/source/collada-library-controllers.adb
<reponame>charlie5/lace package body collada.Library.controllers is ----------- --- Utility -- function "+" (From : in ada.Strings.unbounded.unbounded_String) return String renames ada.Strings.unbounded.to_String; ------------------ --- vertex weights -- function joint_Offset_of (Self : in vertex_Weights) return math.Index is the_Input : constant Input_t := find_in (Self.Inputs.all, Joint); begin return math.Index (the_Input.Offset); end joint_Offset_of; function weight_Offset_of (Self : in vertex_Weights) return math.Index is the_Input : constant Input_t := find_in (Self.Inputs.all, Weight); begin return math.Index (the_Input.Offset); end weight_Offset_of; -------- --- Skin -- function Source_of (Self : in Skin; source_Name : in String) return Source is use ada.Strings.unbounded; begin for i in Self.Sources'Range loop if Self.Sources (i).Id = source_Name (source_Name'First+1 .. source_Name'Last) then return Self.Sources (i); end if; end loop; declare null_Source : Source; begin return null_Source; end; end Source_of; function Weights_of (Self : in Skin) return access float_Array is the_Input : constant Input_t := find_in (Self.vertex_weights.Inputs.all, Weight); begin if the_Input = null_Input then return null; end if; declare the_Source : constant Source := Source_of (Self, +the_Input.Source); begin return the_Source.Floats; end; end Weights_of; function raw_bind_Poses_of (Self : in Skin) return access float_Array is the_Input : constant Input_t := find_in (Self.joints.Inputs.all, inv_bind_Matrix); begin if the_Input = null_Input then return null; end if; declare the_Source : constant Source := Source_of (Self, +the_Input.Source); begin return the_Source.Floats; end; end raw_bind_Poses_of; function bind_shape_Matrix_of (Self : in Skin) return Matrix_4x4 is Raw : constant float_Array := Self.bind_shape_Matrix; First : constant math.Index := 1; the_Matrix : Matrix_4x4; begin the_Matrix := (1 => (Raw (First), Raw (First+1), Raw (First+2), Raw (First+3)), -- These are column vectors. 2 => (Raw (First+4), Raw (First+5), Raw (First+6), Raw (First+7)), 3 => (Raw (First+8), Raw (First+9), Raw (First+10), Raw (First+11)), 4 => (Raw (First+12), Raw (First+13), Raw (First+14), Raw (First+15))); return the_Matrix; end bind_shape_Matrix_of; function bind_Poses_of (Self : in Skin) return Matrix_4x4_array is Raw : constant access float_Array := raw_bind_Poses_of (Self); the_Poses : Matrix_4x4_array (1 .. Raw'Length / 16); First : math.Index := 1; begin for i in the_Poses'Range loop the_Poses (i) := (1 => (Raw (First), Raw (First+1), Raw (First+2), Raw (First+3)), -- These are column vectors. 2 => (Raw (First+4), Raw (First+5), Raw (First+6), Raw (First+7)), 3 => (Raw (First+8), Raw (First+9), Raw (First+10), Raw (First+11)), 4 => (Raw (First+12), Raw (First+13), Raw (First+14), Raw (First+15))); First := First + 16; end loop; return the_Poses; end bind_Poses_of; function joint_Names_of (Self : in Skin) return Text_array is the_Input : constant Input_t := find_in (Self.Joints.Inputs.all, Joint); begin declare the_Source : constant Source := Source_of (Self, +the_Input.Source); begin return the_Source.Texts.all; end; end joint_Names_of; end collada.Library.controllers;
29,614
ada
1
brucegua/moocos
tools/scitools/conf/understand/ada/ada95/s-wchwts.ads
------------------------------------------------------------------------------ -- -- -- GNAT RUNTIME COMPONENTS -- -- -- -- S Y S T E M . W C H _ W T S -- -- -- -- S p e c -- -- -- -- $Revision: 2 $ -- -- -- -- Copyright (c) 1992,1993,1994 NYU, All Rights Reserved -- -- -- -- The GNAT library is free software; you can redistribute it and/or modify -- -- it under terms of the GNU Library General Public License as published by -- -- the Free Software Foundation; either version 2, or (at your option) any -- -- later version. The GNAT library is distributed in the hope that it will -- -- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty -- -- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- Library General Public License for more details. You should have -- -- received a copy of the GNU Library General Public License along with -- -- the GNAT library; see the file COPYING.LIB. If not, write to the Free -- -- Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. -- -- -- ------------------------------------------------------------------------------ -- This package contains the routine used to convert wide strings to -- strings for use by wide character attributes (value, image etc.) with System.WCh_Con; package System.WCh_WtS is pragma Pure (WCh_WtS); function Wide_String_To_String (S : Wide_String; EM : System.WCh_Con.WC_Encoding_Method) return String; -- This routine simply takes its argument and converts it to a string, -- using the internal compiler escape sequence convention (defined in -- package Widechar) to translate characters that are out of range -- of type String. In the context of the Wide_Value attribute, the -- argument is the original attribute argument, and the result is used -- in a call to the corresponding Value attribute function. If the method -- for encoding is a shift-in, shift-out convention, then it is assumed -- that normal (non-wide character) mode holds at the start and end of -- the result string. EM indicates the wide character encoding method. end System.WCh_WtS;
29,615
ada
0
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/complex1_pkg.ads
package Complex1_Pkg is procedure Coord (x,y : out Float); end Complex1_Pkg;
29,616
ada
1
greyblue9/binutils-gdb
gdb/testsuite/gdb.ada/enum_idx_packed/pck.adb
<reponame>greyblue9/binutils-gdb<filename>gdb/testsuite/gdb.ada/enum_idx_packed/pck.adb -- Copyright 2012-2021 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 Pck is function New_Small_Table (Low: Color; High: Color) return Small_Table is Result : Small_Table (Low .. High); begin for J in Low .. High loop Result (J) := (J = Black or J = Green or J = White); end loop; return Result; end New_Small_Table; function New_Multi_Table (Low, High: Color; LS, HS: Strength) return Multi_Table is Result : Multi_Table (Low .. High, LS .. HS); Next : Boolean := True; begin for J in Low .. High loop for K in LS .. HS loop Result (J, K) := Next; Next := not Next; end loop; end loop; return Result; end New_Multi_Table; function New_Multi_Multi_Table (L1, H1, L2, H2, L3, H3: Positive) return Multi_Multi_Table is Result : Multi_Multi_Table (L1 .. H1, L2 .. H2, L3 .. H3); Next : Boolean := True; begin for J in L1 .. H1 loop for K in L2 .. H2 loop for L in L3 .. H3 loop Result (J, K, L) := Next; Next := not Next; end loop; end loop; end loop; return Result; end New_Multi_Multi_Table; procedure Do_Nothing (A : System.Address) is begin null; end Do_Nothing; end Pck;
29,617
ada
1
ekoeppen/STM32_Generic_Ada_Drivers
examples/stm32f3/nested_generics/peripherals.ads
with STM32GD.GPIO.Pin; generic with package Input is new STM32GD.GPIO.Pin (<>); with package Output is new STM32GD.GPIO.Pin (<>); package Peripherals is procedure Init; procedure Run; end Peripherals;
29,618
ada
0
bracke/Meaning
source/Controller_Choices.ads
with RASCAL.ConfiX; use RASCAL.ConfiX; with RASCAL.OS; use RASCAL.OS; package Controller_Choices is type TEL_ViewChoices_Type is new Toolbox_UserEventListener(16#10#,-1,-1) with null record; type MEL_Message_ConfiX is new AMEL_Message_ConfiX with null record; -- -- The user wants to view the choices. -- procedure Handle (The : in TEL_ViewChoices_Type); -- -- User has changed the choices - we should read them. -- procedure Handle (The : in MEL_Message_ConfiX); end Controller_Choices;
29,619
ada
4
faelys/gela-asis
tools/uaflex/read_unicode.adb
<gh_stars>1-10 ------------------------------------------------------------------------------ -- G E L A A S I S -- -- ASIS implementation for Gela project, a portable Ada compiler -- -- http://gela.ada-ru.org -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license at the end of this file -- ------------------------------------------------------------------------------ -- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $ -- Run this to generate symbols-unicode.adb file. -- It requires UnicodeData.txt and PropertyValueAliases.txt from Unicode.org with Ada.Text_IO; with Ada.Strings.Maps; with Ada.Strings.Fixed; with Ada.Strings.Unbounded; --with Ada.Text_IO.Integer_IO; with Ada.Containers.Vectors; procedure Read_Unicode is use Ada.Text_IO; use Ada.Strings; package U renames Ada.Strings.Unbounded; type Code_Point is range 0 .. 16#10FFFF#; package Code_Point_IO is new Ada.Text_IO.Integer_IO (Code_Point); Semicolumn : Maps.Character_Set := Maps.To_Set (";"); type Category is record Alias : String (1 .. 2); Name : U.Unbounded_String; Count : Natural := 0; end record; type Categories is array (Positive range <>) of Category; type Unicode_Data_Item is record From, To : Code_Point; Category : String (1 .. 2); end record; package Vectors is new Ada.Containers.Vectors (Positive, Unicode_Data_Item); function Read_Categories return Categories; procedure Read_Characters (Data : out Vectors.Vector); procedure Get_Field (Line : in String; From : out Positive; To : out Natural; Last : in out Natural); procedure P (Text : String); function Is_Range (Text : String) return Boolean; function Is_Last_Name (Name : String) return Boolean; function To_Code_Point (Text : String) return Code_Point; procedure To_Code_Points (Text : String; From : out Code_Point; To : out Code_Point); function Less_Category (Left, Right : Unicode_Data_Item) return Boolean; package Category_Sorting is new Vectors.Generic_Sorting (Less_Category); function "+" (Value : Natural) return String; function "+" (Value : Code_Point) return String; --------- -- "+" -- --------- function "+" (Value : Natural) return String is Image : constant String := Natural'Image (Value); begin return Image (2 .. Image'Last); end "+"; --------- -- "+" -- --------- function "+" (Value : Code_Point) return String is Text : String (1 .. 10); begin Code_Point_IO.Put (Text, Value, Base => 16); return Text; end "+"; --------------- -- Get_Field -- --------------- procedure Get_Field (Line : in String; From : out Positive; To : out Natural; Last : in out Natural) is use Ada.Strings.Fixed; begin Find_Token (Line (Last .. Line'Last), Semicolumn, Outside, From, To); if To = 0 then Last := 0; else Last := To + 1; From := Index_Non_Blank (Line (From .. To)); To := Index_Non_Blank (Line (From .. To), Backward); end if; end Get_Field; ------------------ -- Is_Last_Name -- ------------------ function Is_Last_Name (Name : String) return Boolean is begin return Fixed.Index (Name, ", Last>") > 0; end Is_Last_Name; -------------- -- Is_Range -- -------------- function Is_Range (Text : String) return Boolean is begin return Fixed.Index (Text, "..") > 0; end Is_Range; ------------------- -- Less_Category -- ------------------- function Less_Category (Left, Right : Unicode_Data_Item) return Boolean is begin return Left.Category < Right.Category or else (Left.Category = Right.Category and Left.From < Right.From); end Less_Category; ------- -- P -- ------- procedure P (Text : String) is begin Put_Line (Text); end P; -------------------- -- Print_Function -- -------------------- procedure Print_Function (List : Categories) is begin P (" function General_Category (Name : String) return Symbol_Set is"); P (" type General_Category is"); for J in List'Range loop if J = 1 then P (" (" & U.To_String (List (J).Name) & ","); elsif J = List'Last then P (" " & U.To_String (List (J).Name) & ");"); else P (" " & U.To_String (List (J).Name) & ","); end if; end loop; P (""); P (" Category : General_Category_Alias;"); P (" GC : General_Category;"); P (""); P (" begin"); P (" if Name'Length = 2 then"); P (" Category := General_Category_Alias'Value (Name);"); P (" else"); P (" GC := General_Category'Value (Name);"); P (" Category := General_Category_Alias'Val " & "(General_Category'Pos (GC));"); P (" end if;"); P (" return Values (Category);"); P (" end General_Category;"); P (""); P ("end Symbols.Unicode;"); end Print_Function; ------------------ -- Print_Header -- ------------------ procedure Print_Header is begin P ("-- This file is generated by read_unicode.adb. DON'T EDIT!"); P (""); P ("package body Symbols.Unicode is"); P (""); P (" type General_Category_Alias is"); end Print_Header; ------------------ -- Print_Values -- ------------------ procedure Print_Values (List : Categories) is begin P (" Values : constant array (General_Category_Alias) " & "of Symbol_Set :="); for J in List'Range loop if J = 1 then P (" (" & List (J).Alias & " => (F.Controlled with " & List (J).Alias & "_Node'Access),"); elsif J = List'Last then P (" " & List (J).Alias & " => (F.Controlled with " & List (J).Alias & "_Node'Access));"); else P (" " & List (J).Alias & " => (F.Controlled with " & List (J).Alias & "_Node'Access),"); end if; end loop; P (""); end Print_Values; --------------------- -- Read_Categories -- --------------------- function Read_Categories return Categories is Input : File_Type; Result : Categories (1 .. 30); Last : Natural := 0; begin Open (Input, In_File, "PropertyValueAliases.txt"); while not End_Of_File (Input) loop declare Line : constant String := Get_Line (Input); From : Positive; To : Natural; Pos : Natural := Line'First; begin Get_Field (Line, From, To, Pos); if Pos > 0 and then Line (From .. To) = "gc" then Get_Field (Line, From, To, Pos); if To - From = 1 and then Line (From .. To) /= "LC" then Last := Last + 1; Result (Last).Alias := Line (From .. To); Get_Field (Line, From, To, Pos); Result (Last).Name := U.To_Unbounded_String (Line (From .. To)); end if; end if; end; end loop; Close (Input); return Result (1 .. Last); end Read_Categories; procedure Read_Characters (Data : out Vectors.Vector) is Input : File_Type; begin Open (Input, In_File, "UnicodeData.txt"); Vectors.Reserve_Capacity (Data, 18_000); while not End_Of_File (Input) loop declare Item : Unicode_Data_Item; Text : constant String := Get_Line (Input); From : Positive; To : Natural; From2 : Positive; To2 : Natural; Last : Natural := Text'First; begin Get_Field (Text, From, To, Last); if Last > 0 then Get_Field (Text, From2, To2, Last); if Is_Range (Text (From .. To)) then To_Code_Points (Text (From .. To), Item.From, Item.To); elsif Is_Last_Name (Text (From2 .. To2)) then Item := Vectors.Last_Element (Data); Vectors.Delete_Last (Data); Item.To := To_Code_Point (Text (From .. To)); else Item.From := To_Code_Point (Text (From .. To)); Item.To := Item.From; end if; Get_Field (Text, From2, To2, Last); Item.Category := Text (From2 .. To2); Vectors.Append (Data, Item); end if; end; end loop; Close (Input); end Read_Characters; ------------------- -- To_Code_Point -- ------------------- function To_Code_Point (Text : String) return Code_Point is Image : constant String := "16#" & Text & "#"; begin return Code_Point'Value (Image); end To_Code_Point; -------------------- -- To_Code_Points -- -------------------- procedure To_Code_Points (Text : String; From : out Code_Point; To : out Code_Point) is Pos : constant Positive := Fixed.Index (Text, ".."); begin From := To_Code_Point (Text (Text'First .. Pos - 1)); To := To_Code_Point (Text (Pos + 2 .. Text'Last)); end To_Code_Points; List : Categories := Read_Categories; Data : Vectors.Vector; begin Print_Header; for J in List'Range loop if J = 1 then P (" (" & List (J).Alias & ","); elsif J = List'Last then P (" " & List (J).Alias & ");"); else P (" " & List (J).Alias & ","); end if; end loop; P (""); Read_Characters (Data); Category_Sorting.Sort (Data); declare Current : String (1 .. 2) := " "; Index : Positive; Last : Code_Point; procedure Count_Category (Position : Vectors.Cursor) is Item : constant Unicode_Data_Item := Vectors.Element (Position); begin if Current = Item.Category then if Item.From /= Last + 1 then List (Index).Count := List (Index).Count + 1; end if; Last := Item.To; else Current := Item.Category; for J in List'Range loop if List (J).Alias = Item.Category then Index := J; exit; end if; end loop; List (Index).Count := 1; Last := Item.To; end if; end Count_Category; begin Vectors.Iterate (Data, Count_Category'Access); end; declare Pos : Vectors.Cursor := Vectors.First (Data); From, To : Code_Point; First : Boolean; begin for J in List'Range loop if List (J).Count > 0 then P (" " & List (J).Alias & "_Node : aliased Set_Node :="); P (" (" & (+List (J).Count) & ", 2, ("); First := True; while Vectors.Has_Element (Pos) loop declare Item : Unicode_Data_Item := Vectors.Element (Pos); begin exit when Item.Category /= List (J).Alias; if First then From := Item.From; To := Item.To; First := False; elsif To + 1 = Item.From then To := Item.To; else P (" (" & (+From) & ", " & (+To) & "),"); From := Item.From; To := Item.To; end if; end; Pos := Vectors.Next (Pos); end loop; if List (J).Count = 1 then P (" 1 => (" & (+From) & ", " & (+To) & ")));"); else P (" (" & (+From) & ", " & (+To) & ")));"); end if; P (""); end if; end loop; end; P (" Cn_Node : aliased Set_Node :="); P (" (0, 2, (others => (Not_A_Symbol, Not_A_Symbol)));"); P (""); Print_Values (List); Print_Function (List); end Read_Unicode; ------------------------------------------------------------------------------ -- Copyright (c) 2006-2013, <NAME> -- 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 <NAME>, IE nor the names of its -- contributors may be used to endorse or promote products derived from -- this software without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------
29,620
ada
0
Lucretia/old_nehe_ada95
thirdparty/adasdl/thin/adasdl/AdaSDL-from-glut/examples/abgr.adb
-- Copyright (c) <NAME>, 1994. -- Ported to Ada by <NAME> -- http://www.adapower.net/~avargas -- mailto: <EMAIL> -- /** -- * (c) Copyright 1993, Silicon Graphics, Inc. -- * ALL RIGHTS RESERVED -- * Permission to use, copy, modify, and distribute this software for -- * any purpose and without fee is hereby granted, provided that the above -- * copyright notice appear in all copies and that both the copyright notice -- * and this permission notice appear in supporting documentation, and that -- * the name of Silicon Graphics, Inc. not be used in advertising -- * or publicity pertaining to distribution of the software without specific, -- * written prior permission. -- * -- * THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" -- * AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, -- * INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR -- * FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON -- * GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, -- * SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY -- * KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, -- * LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF -- * THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN -- * ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON -- * ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE -- * POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. -- * -- * US Government Users Restricted Rights -- * Use, duplication, or disclosure by the Government is subject to -- * restrictions set forth in FAR 52.227.19(c)(2) or subparagraph -- * (c)(1)(ii) of the Rights in Technical Data and Computer Software -- * clause at DFARS 252.227-7013 and/or in similar or successor -- * clauses in the FAR or the DOD or NASA FAR Supplement. -- * Unpublished-- rights reserved under the copyright laws of the -- * United States. Contractor/manufacturer is Silicon Graphics, -- * Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. -- * -- * OpenGL(TM) is a trademark of Silicon Graphics, Inc. -- /* abgr.c - Demonstrates the use of the extension EXT_abgr. -- -- The same image data is used for both ABGR and RGBA formats -- in glDrawPixels and glTexImage2D. The left side uses ABGR, -- the right side RGBA. The top polygon demonstrates use of texture, -- and the bottom image is drawn with glDrawPixels. -- Note that the textures are defined as 3 component, so the alpha -- value is not used in applying the DECAL environment. */ with Interfaces.C; with Ada.Text_IO; use Ada.Text_IO; with Ada.Command_Line; with GNAT.OS_Lib; with gl_h; use gl_h; with glu_h; use glu_h; with AdaGL; use AdaGL; with SDL.Types; use SDL.Types; with SDL.Video; with SDL.Error; with SDL.Events; with SDL.Quit; with SDL.Keyboard; with SDL.Keysym; procedure abgr is package C renames Interfaces.C; use type C.int; package CL renames Ada.Command_Line; package Vd renames SDL.Video; use type Vd.Surface_Flags; use type Vd.Surface_ptr; package Er renames SDL.Error; package Ev renames SDL.Events; package Kb renames SDL.Keyboard; package Ks renames SDL.Keysym; doubleBuffer : GLenum; ubImage : GLubyte_Array (0 .. 65535); -- =================================================================== procedure Init is img_index : Integer; imgWidth : GLsizei := 128; begin glMatrixMode (GL_PROJECTION); glLoadIdentity; gluPerspective (60.0, 1.0, 0.1, 1000.0); glMatrixMode (GL_MODELVIEW); glDisable (GL_DITHER); -- Create image img_index := 0; for j in 0 .. 31 * imgWidth loop ubImage (img_index .. img_index + 3) := (16#ff#, 16#00#, 16#00#, 16#ff#); img_index := img_index + 4; end loop; for j in 0 .. 31 * imgWidth loop ubImage (img_index .. img_index + 3) := (16#ff#, 16#00#, 16#ff#, 16#00#); img_index := img_index + 4; end loop; for j in 0 .. 31 * imgWidth loop ubImage (img_index .. img_index + 3) := (16#ff#, 16#ff#, 16#00#, 16#00#); img_index := img_index + 4; end loop; for j in 0 .. 31 * imgWidth loop ubImage (img_index .. img_index + 3) := (16#00#, 16#ff#, 16#00#, 16#ff#); img_index := img_index + 4; end loop; end Init; -- =================================================================== procedure TextFunc is begin glEnable (GL_TEXTURE_2D); glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, Float (GL_REPEAT)); glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, Float (GL_REPEAT)); glTexParameterf (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, Float (GL_NEAREST)); glTexEnvf (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, Float (GL_DECAL)); -- #if GL_EXT_abgr glTexImage2D (GL_TEXTURE_2D, 0, 3, 128, 128, 0, GL_ABGR_EXT, GL_UNSIGNED_BYTE, ubImage); glBegin (GL_POLYGON); glTexCoord2f (1.0, 1.0); glVertex3f (-0.2, 0.8, -100.0); glTexCoord2f (0.0, 1.0); glVertex3f (-0.8, 0.8, -2.0); glTexCoord2f (0.0, 0.0); glVertex3f (-0.8, 0.2, -2.0); glTexCoord2f (1.0, 0.0); glVertex3f (-0.2, 0.2, -100.0); glEnd; -- #endif glTexImage2D (GL_TEXTURE_2D, 0, 3, 128, 128, 0, GL_RGBA, GL_UNSIGNED_BYTE, ubImage); glBegin (GL_POLYGON); glTexCoord2f (1.0, 1.0); glVertex3f (0.8, 0.8, -2.0); glTexCoord2f (0.0, 1.0); glVertex3f (0.2, 0.8, -100.0); glTexCoord2f (0.0, 0.0); glVertex3f (0.2, 0.2, -100.0); glTexCoord2f (1.0, 0.0); glVertex3f (0.8, 0.2, -2.0); glEnd; glDisable (GL_TEXTURE_2D); end TextFunc; -- =================================================================== procedure Draw is begin glClearColor (0.0, 0.0, 0.0, 1.0); glClear (GL_COLOR_BUFFER_BIT); -- #if GL_EXT_abgr glRasterPos3f (-0.8, -0.8, -1.5); glDrawPixels (128, 128, GL_ABGR_EXT, GL_UNSIGNED_BYTE, ubImage); -- #endif glRasterPos3f (0.2, -0.8, -1.5); glDrawPixels (128, 128, GL_RGBA, GL_UNSIGNED_BYTE, ubImage); TextFunc; if doubleBuffer /= 0 then Vd.GL_SwapBuffers; else glFlush; end if; end Draw; -- =================================================================== argc : Integer := CL.Argument_Count; Screen_Width : C.int := 640; Screen_Hight : C.int := 480; Full_Screen : Boolean := True; -- =================================================================== procedure Args is begin doubleBuffer := GL_TRUE; for i in 1 .. argc loop if argc >= 1 then if CL.Argument (argc) = "-sb" then doubleBuffer := GL_FALSE; argc := argc - 1; elsif CL.Argument (argc) = "-db" then doubleBuffer := GL_TRUE; argc := argc - 1; elsif CL.Argument (argc) = "-window" then Full_Screen := False; argc := argc - 1; elsif CL.Argument (argc) = "-1024x768" then Screen_Width := 1024; Screen_Hight := 768; argc := argc - 1; elsif CL.Argument (argc) = "-800x600" then Screen_Width := 800; Screen_Hight := 600; argc := argc - 1; else Put_Line ("Usage: " & CL.Command_Name & " " & "[ -sb | -db ] [-window] [-h] " & "[-800x600 | -1024x768]"); GNAT.OS_Lib.OS_Exit (0); end if; end if; end loop; end Args; -- =================================================================== screen : Vd.Surface_ptr; Video_Flags : Vd.Surface_Flags; keys : Uint8_ptr; Done : Boolean := False; -- =================================================================== procedure Main_System_Loop is begin while not Done loop declare event : Ev.Event; PollEvent_Result : C.int; begin loop Ev.PollEventVP (PollEvent_Result, event); exit when PollEvent_Result = 0; case event.the_type is when Ev.QUIT => Done := True; when others => null; end case; end loop; keys := Kb.GetKeyState (null); if Kb.Is_Key_Pressed (keys, Ks.K_ESCAPE) then Done := True; end if; Draw; end; -- declare end loop; end Main_System_Loop; -- =================================================================== -- Abgr Procedure body -- =================================================================== begin Args; if SDL.Init (SDL.INIT_VIDEO) < 0 then Put_Line ("Couldn't load SDL: " & Er.Get_Error); GNAT.OS_Lib.OS_Exit (1); end if; Video_Flags := Vd.OPENGL; if Full_Screen then Video_Flags := Video_Flags or Vd.FULLSCREEN; end if; screen := Vd.SetVideoMode (Screen_Width, Screen_Hight, 16, Video_Flags); if screen = null then Put_Line ("Couldn't set " & C.int'Image (Screen_Width) & "x" & C.int'Image (Screen_Hight) & " GL video mode: " & Er.Get_Error); SDL.SDL_Quit; GNAT.OS_Lib.OS_Exit (2); end if; Vd.WM_Set_Caption ("ABGR extension", "abgr"); Init; Main_System_Loop; SDL.SDL_Quit; end abgr;
29,621
ada
52
onox/orka
orka_egl/src/egl.adb
<reponame>onox/orka<gh_stars>10-100 -- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2020 onox <<EMAIL>> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with Ada.Strings.Fixed; package body EGL is package SF renames Ada.Strings.Fixed; function Trim (Value : C.Strings.chars_ptr) return String is (SF.Trim (C.Strings.Value (Value), Ada.Strings.Right)); function Extensions (Value : C.Strings.chars_ptr) return String_List is Extensions : constant String := Trim (Value); Index : Positive := Extensions'First; begin return Result : String_List (1 .. SF.Count (Extensions, " ") + 1) do for I in Result'First .. Result'Last - 1 loop declare Next_Index : constant Positive := SF.Index (Extensions, " ", Index + 1); begin Result (I) := SU.To_Unbounded_String (Extensions (Index .. Next_Index - 1)); Index := Next_Index + 1; end; end loop; Result (Result'Last) := SU.To_Unbounded_String (Extensions (Index .. Extensions'Last)); end return; end Extensions; function Has_Extension (Extensions : String_List; Name : String) return Boolean is use type SU.Unbounded_String; begin return (for some Extension of Extensions => Extension = Name); end Has_Extension; procedure Check_Extension (Extensions : String_List; Name : String) is begin if not Has_Extension (Extensions, Name) then raise Feature_Not_Supported with Name & " not supported"; end if; end Check_Extension; end EGL;
29,622
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/aggr11_pkg.ads
<reponame>best08618/asylo<filename>gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/aggr11_pkg.ads package Aggr11_Pkg is type Error_Type is (No_Error, Error); type Rec (Kind : Error_Type := No_Error) is record case Kind is when Error => null; when others => B : Boolean; end case; end record; type Arr is array (1..6) of Rec; end Aggr11_Pkg;
29,623
ada
33
ytomino/drake
source/environment/a-locale.adb
<reponame>ytomino/drake<gh_stars>10-100 -- reference: -- http://www.loc.gov/standards/iso639-2/php/code_list.php pragma Check_Policy (Validate => Ignore); with System.Native_Locales; with System.Once; package body Ada.Locales is type Long_Boolean is new Boolean; for Long_Boolean'Size use Long_Integer'Size; function expect (exp, c : Long_Boolean) return Long_Boolean with Import, Convention => Intrinsic, External_Name => "__builtin_expect"; type Alpha_2_NP is new String (1 .. 2); -- no predicate type Alpha_3_NP is new String (1 .. 3); function Compare (Left, Right : Alpha_2_NP) return Integer; function Compare (Left, Right : Alpha_2_NP) return Integer is type Compare_Integer is mod 16#10000#; Left_Value : constant Compare_Integer := Character'Pos (Left (1)) * 16#100# or Character'Pos (Left (2)); Right_Value : constant Compare_Integer := Character'Pos (Right (1)) * 16#100# or Character'Pos (Right (2)); begin return Integer (Left_Value) - Integer (Right_Value); end Compare; function Compare (Left, Right : Alpha_3_NP) return Integer; function Compare (Left, Right : Alpha_3_NP) return Integer is type Compare_Integer is mod 16#1000000#; Left_Value : constant Compare_Integer := Character'Pos (Left (1)) * 16#10000# or Character'Pos (Left (2)) * 16#100# or Character'Pos (Left (3)); Right_Value : constant Compare_Integer := Character'Pos (Right (1)) * 16#10000# or Character'Pos (Right (2)) * 16#100# or Character'Pos (Right (3)); begin return Integer (Left_Value) - Integer (Right_Value); end Compare; type Language_Table_Element is record Alpha_3 : Alpha_3_NP; Alpha_2 : Alpha_2_NP; end record; pragma Suppress_Initialization (Language_Table_Element); type Language_Table_Array is array (Positive range <>) of Language_Table_Element; pragma Suppress_Initialization (Language_Table_Array); type Language_Table_Array_Access is access Language_Table_Array; unde : constant Alpha_2_NP := (1 => ISO_639_Alpha_2_Unknown (1), 2 => ISO_639_Alpha_2_Unknown (2)); Language_Table : constant Language_Table_Array := ( ("aar", "aa"), -- "Afar", "afar" ("abk", "ab"), -- "Abkhazian", "abkhaze" ("ace", unde), -- "Achinese", "aceh" ("ach", unde), -- "Acoli", "acoli" ("ada", unde), -- "Adangme", "adangme" ("ady", unde), -- "Adyghe; Adygei", "adyghé" ("afa", unde), -- "Afro-Asiatic languages", "afro-asiatiques, langues" ("afh", unde), -- "Afrihili", "afrihili" ("afr", "af"), -- "Afrikaans", "afrikaans" ("ain", unde), -- "Ainu", "aïnou" ("aka", "ak"), -- "Akan", "akan" ("akk", unde), -- "Akkadian", "akkadien" ("alb", "sq"), -- (B) ("sqi", "sq"), -- (T) "Albanian", "albanais" ("ale", unde), -- "Aleut", "aléoute" ("alg", unde), -- "Algonquian languages", "algonquines, langues" ("alt", unde), -- "Southern Altai", "altai du Sud" ("amh", "am"), -- "Amharic", "amharique" ("ang", unde), -- "English, Old (ca.450-1100)", -- "anglo-saxon (ca.450-1100)" ("anp", unde), -- "Angika", "angika" ("apa", unde), -- "Apache languages", "apaches, langues" ("ara", "ar"), -- "Arabic", "arabe" ("arc", unde), -- "Official Aramaic (700-300 BCE); " -- & "Imperial Aramaic (700-300 BCE)", -- "araméen d'empire (700-300 BCE)" ("arg", "an"), -- "Aragonese", "aragonais" ("arm", "hy"), -- (B) ("hye", "hy"), -- (T) "Armenian", "arménien" ("arn", unde), -- "Mapudungun; Mapuche", "mapudungun; mapuche; mapuce" ("arp", unde), -- "Arapaho", "arapaho" ("art", unde), -- "Artificial languages", "artificielles, langues" ("arw", unde), -- "Arawak", "arawak" ("asm", "as"), -- "Assamese", "assamais" ("ast", unde), -- "Asturian; Bable; Leonese; Asturleonese", -- "asturien; bable; léonais; asturoléonais" ("ath", unde), -- "Athapascan languages", "athapascanes, langues" ("aus", unde), -- "Australian languages", "australiennes, langues" ("ava", "av"), -- "Avaric", "avar" ("ave", "ae"), -- "Avestan", "avestique" ("awa", unde), -- "Awadhi", "awadhi" ("aym", "ay"), -- "Aymara", "aymara" ("aze", "az"), -- "Azerbaijani", "azéri" ("bad", unde), -- "Banda languages", "banda, langues" ("bai", unde), -- "Bamileke languages", "bamiléké, langues" ("bak", "ba"), -- "Bashkir", "bachkir" ("bal", unde), -- "Baluchi", "baloutchi" ("bam", "bm"), -- "Bambara", "bambara" ("ban", unde), -- "Balinese", "balinais" ("baq", "eu"), -- (B) ("eus", "eu"), -- (T) "Basque", "basque" ("bas", unde), -- "Basa", "basa" ("bat", unde), -- "Baltic languages", "baltes, langues" ("bej", unde), -- "Beja; Bedawiyet", "bedja" ("bel", "be"), -- "Belarusian", "biélorusse" ("bem", unde), -- "Bemba", "bemba" ("ben", "bn"), -- "Bengali", "bengali" ("ber", unde), -- "Berber languages", "berbères, langues" ("bho", unde), -- "Bhojpuri", "bhojpuri" ("bih", "bh"), -- "Bihari languages", "langues biharis" ("bik", unde), -- "Bikol", "bikol" ("bin", unde), -- "Bini; Edo", "bini; edo" ("bis", "bi"), -- "Bislama", "bichlamar" ("bla", unde), -- "Siksika", "blackfoot" ("bnt", unde), -- "Bantu languages", "bantou, langues" ("tib", "bo"), -- (B) ("bod", "bo"), -- (T) "Tibetan", "tibétain" ("bos", "bs"), -- "Bosnian", "bosniaque" ("bra", unde), -- "Braj", "braj" ("bre", "br"), -- "Breton", "breton" ("btk", unde), -- "Batak languages", "batak, langues" ("bua", unde), -- "Buriat", "bouriate" ("bug", unde), -- "Buginese", "bugi" ("bul", "bg"), -- "Bulgarian", "bulgare" ("bur", "my"), -- (B) ("mya", "my"), -- (T) "Burmese", "birman" ("byn", unde), -- "Blin; Bilin", "blin; bilen" ("cad", unde), -- "Caddo", "caddo" ("cai", unde), -- "Central American Indian languages", -- "amérindiennes de l'Amérique centrale, langues" ("car", unde), -- "<NAME>", "karib; galibi; carib" ("cat", "ca"), -- "Catalan; Valencian", "catalan; valencien" ("cau", unde), -- "Caucasian languages", "caucasiennes, langues" ("ceb", unde), -- "Cebuano", "cebuano" ("cel", unde), -- "Celtic languages", -- "celtiques, langues; celtes, langues" ("cze", "cs"), -- (B) ("ces", "cs"), -- (T) "Czech", "tchèque" ("cha", "ch"), -- "Chamorro", "chamorro" ("chb", unde), -- "Chibcha", "chibcha" ("che", "ce"), -- "Chechen", "tchétchène" ("chg", unde), -- "Chagatai", "djaghataï" ("chi", "zh"), -- (B) ("zho", "zh"), -- (T) "Chinese", "chinois" ("chk", unde), -- "Chuukese", "chuuk" ("chm", unde), -- "Mari", "mari" ("chn", unde), -- "Chinook jargon", "chinook, jargon" ("cho", unde), -- "Choctaw", "choctaw" ("chp", unde), -- "Chipewyan; D<NAME>", "chipewyan" ("chr", unde), -- "Cherokee", "cherokee" ("chu", "cu"), -- "Church Slavic; Old Slavonic; Church Slavonic; " -- & "Old Bulgarian; Old Church Slavonic", -- "slavon d'église; vieux slave; slavon liturgique; " -- & "vieux bulgare" ("chv", "cv"), -- "Chuvash", "tchouvache" ("chy", unde), -- "Cheyenne", "cheyenne" ("cmc", unde), -- "Chamic languages", "chames, langues" ("cop", unde), -- "Coptic", "copte" ("cor", "kw"), -- "Cornish", "cornique" ("cos", "co"), -- "Corsican", "corse" ("cpe", unde), -- "Creoles and pidgins, English based", -- "créoles et pidgins basés sur l'anglais" ("cpf", unde), -- "Creoles and pidgins, French-based", -- "créoles et pidgins basés sur le français" ("cpp", unde), -- "Creoles and pidgins, Portuguese-based", -- "créoles et pidgins basés sur le portugais" ("cre", "cr"), -- "Cree", "cree" ("crh", unde), -- "Crimean Tatar; Crimean Turkish", "tatar de Crimé" ("crp", unde), -- "Creoles and pidgins", "créoles et pidgins" ("csb", unde), -- "Kashubian", "kachoube" ("cus", unde), -- "Cushitic languages", "couchitiques, langues" ("wel", "cy"), -- (B) ("cym", "cy"), -- (T) "Welsh", "gallois" ("dak", unde), -- "Dakota", "dakota" ("dan", "da"), -- "Danish", "danois" ("dar", unde), -- "Dargwa", "dargwa" ("day", unde), -- "Land Dayak languages", "dayak, langues" ("del", unde), -- "Delaware", "delaware" ("den", unde), -- "Slave (Athapascan)", "esclave (athapascan)" ("ger", "de"), -- (B) ("deu", "de"), -- (T) "German", "allemand" ("dgr", unde), -- "Dogrib", "dogrib" ("din", unde), -- "Dinka", "dinka" ("div", "dv"), -- "Divehi; Dhivehi; Maldivian", "maldivien" ("doi", unde), -- "Dogri", "dogri" ("dra", unde), -- "Dravidian languages", "dravidiennes, langues" ("dsb", unde), -- "Lower Sorbian", "bas-sorabe" ("dua", unde), -- "Duala", "douala" ("dum", unde), -- "Dutch, Middle (ca.1050-1350)", -- "néerlandais moyen (ca. 1050-1350)" ("dut", "nl"), -- (B) ("nld", "nl"), -- (T) "Dutch; Flemish", "néerlandais; flamand" ("dyu", unde), -- "Dyula", "dioula" ("dzo", "dz"), -- "Dzongkha", "dzongkha" ("efi", unde), -- "Efik", "efik" ("egy", unde), -- "Egyptian (Ancient)", "égyptien" ("eka", unde), -- "Ekajuk", "ekajuk" ("gre", "el"), -- (B) ("ell", "el"), -- (T) "Greek, Modern (1453-)", -- "grec moderne (après 1453)" ("elx", unde), -- "Elamite", "élamite" ("eng", "en"), -- "English", "anglais" ("enm", unde), -- "English, Middle (1100-1500)", -- "anglais moyen (1100-1500)" ("epo", "eo"), -- "Esperanto", "espéranto" ("est", "et"), -- "Estonian", "estonien" ("ewe", "ee"), -- "Ewe", "éwé" ("ewo", unde), -- "Ewondo", "éwondo" ("fan", unde), -- "Fang", "fang" ("fao", "fo"), -- "Faroese", "féroïen" ("per", "fa"), -- (B) ("fas", "fa"), -- (T) "Persian", "persan" ("fat", unde), -- "Fanti", "fanti" ("fij", "fj"), -- "Fijian", "fidjien" ("fil", unde), -- "Filipino; Pilipino", "filipino; pilipino" ("fin", "fi"), -- "Finnish", "finnois" ("fiu", unde), -- "Finno-Ugrian languages", "finno-ougriennes, langues" ("fon", unde), -- "Fon", "fon" ("fre", "fr"), -- (B) ("fra", "fr"), -- (T) "French", "français" ("frm", unde), -- "French, Middle (ca.1400-1600)", -- "français moyen (1400-1600)" ("fro", unde), -- "French, Old (842-ca.1400)", -- "français ancien (842-ca.1400)" ("frr", unde), -- "Northern Frisian", "frison septentrional" ("frs", unde), -- "Eastern Frisian", "frison oriental" ("fry", "fy"), -- "Western Frisian", "frison occidental" ("ful", "ff"), -- "Fulah", "peul" ("fur", unde), -- "Friulian", "frioulan" ("gaa", unde), -- "Ga", "ga" ("gay", unde), -- "Gayo", "gayo" ("gba", unde), -- "Gbaya", "gbaya" ("gem", unde), -- "Germanic languages", "germaniques, langues" ("geo", "ka"), -- (B) ("kat", "ka"), -- (T) "Georgian", "géorgien" ("gez", unde), -- "Geez", "guèze" ("gil", unde), -- "Gilbertese", "kiribati" ("gla", "gd"), -- "Gaelic; Scottish Gaelic", -- "gaélique; gaélique écossais" ("gle", "ga"), -- "Irish", "irlandais" ("glg", "gl"), -- "Galician", "galicien" ("glv", "gv"), -- "Manx", "manx; mannois" ("gmh", unde), -- "German, Middle High (ca.1050-1500)", -- "allemand, moyen haut (ca. 1050-1500)" ("goh", unde), -- "German, Old High (ca.750-1050)", -- "allemand, vieux haut (ca. 750-1050)" ("gon", unde), -- "Gondi", "gond" ("gor", unde), -- "Gorontalo", "gorontalo" ("got", unde), -- "Gothic", "gothique" ("grb", unde), -- "Grebo", "grebo" ("grc", unde), -- "Greek, Ancient (to 1453)", -- "grec ancien (jusqu'à 1453)" ("grn", "gn"), -- "Guarani", "guarani" ("gsw", unde), -- "Swiss German; Alemannic; Alsatian", -- "suisse alémanique; alémanique; alsacien" ("guj", "gu"), -- "Gujarati", "goudjrati" ("gwi", unde), -- "Gwich'in", "gwich'in" ("hai", unde), -- "Haida", "haida" ("hat", "ht"), -- "Haitian; Haitian Creole", -- "haïtien; créole haïtien" ("hau", "ha"), -- "Hausa", "haoussa" ("haw", unde), -- "Hawaiian", "hawaïen" ("heb", "he"), -- "Hebrew", "hébreu" ("her", "hz"), -- "Herero", "herero" ("hil", unde), -- "Hiligaynon", "hiligaynon" ("him", unde), -- "Himachali languages; Western Pahari languages", -- "langues himachalis; langues paharis occidentales" ("hin", "hi"), -- "Hindi", "hindi" ("hit", unde), -- "Hittite", "hittite" ("hmn", unde), -- "Hmong; Mong", "hmong" ("hmo", "ho"), -- "<NAME>", "hiri motu" ("hrv", "hr"), -- "Croatian", "croate" ("hsb", unde), -- "Upper Sorbian", "haut-sorabe" ("hun", "hu"), -- "Hungarian", "hongrois" ("hup", unde), -- "Hupa", "hupa" ("iba", unde), -- "Iban", "iban" ("ibo", "ig"), -- "Igbo", "igbo" ("ice", "is"), -- (B) ("isl", "is"), -- (T) "Icelandic", "islandais" ("ido", "io"), -- "Ido", "ido" ("iii", "ii"), -- "S<NAME>; Nuosu", "yi de Sichuan" ("ijo", unde), -- "Ijo languages", "ijo, langues" ("iku", "iu"), -- "Inuktitut", "inuktitut" ("ile", "ie"), -- "Interlingue; Occidental", "interlingue" ("ilo", unde), -- "Iloko", "ilocano" ("ina", "ia"), -- "Interlingua (International Auxiliary Language Association)", -- "interlingua (langue auxiliaire internationale)" ("inc", unde), -- "Indic languages", "indo-aryennes, langues" ("ind", "id"), -- "Indonesian", "indonésien" ("ine", unde), -- "Indo-European languages", -- "indo-européennes, langues" ("inh", unde), -- "Ingush", "ingouche" ("ipk", "ik"), -- "Inupiaq", "inupiaq" ("ira", unde), -- "Iranian languages", "iraniennes, langues" ("iro", unde), -- "Iroquoian languages", "iroquoises, langues" ("ita", "it"), -- "Italian", "italien" ("jav", "jv"), -- "Javanese", "javanais" ("jbo", unde), -- "Lojban", "lojban" ("jpn", "ja"), -- "Japanese", "japonais" ("jpr", unde), -- "Judeo-Persian", "judéo-persan" ("jrb", unde), -- "Judeo-Arabic", "judéo-arabe" ("kaa", unde), -- "Kara-Kalpak", "karakalpak" ("kab", unde), -- "Kabyle", "kabyle" ("kac", unde), -- "Kachin; Jingpho", "kachin; jingpho" ("kal", "kl"), -- "Kalaallisut; Greenlandic", "groenlandais" ("kam", unde), -- "Kamba", "kamba" ("kan", "kn"), -- "Kannada", "kannada" ("kar", unde), -- "Karen languages", "karen, langues" ("kas", "ks"), -- "Kashmiri", "kashmiri" ("kau", "kr"), -- "Kanuri", "kanouri" ("kaw", unde), -- "Kawi", "kawi" ("kaz", "kk"), -- "Kazakh", "kazakh" ("kbd", unde), -- "Kabardian", "kabardien" ("kha", unde), -- "Khasi", "khasi" ("khi", unde), -- "Khoisan languages", "khoïsan, langues" ("khm", "km"), -- "Central Khmer", "khmer central" ("kho", unde), -- "Khotanese; Sakan", "khotanais; sakan" ("kik", "ki"), -- "Kikuyu; Gikuyu", "kikuyu" ("kin", "rw"), -- "Kinyarwanda", "rwanda" ("kir", "ky"), -- "Kirghiz; Kyrgyz", "kirghiz" ("kmb", unde), -- "Kimbundu", "kimbundu" ("kok", unde), -- "Konkani", "konkani" ("kom", "kv"), -- "Komi", "kom" ("kon", "kg"), -- "Kongo", "kongo" ("kor", "ko"), -- "Korean", "coréen" ("kos", unde), -- "Kosraean", "kosrae" ("kpe", unde), -- "Kpelle", "kpellé" ("krc", unde), -- "Karachay-Balkar", "karatchai balkar" ("krl", unde), -- "Karelian", "carélien" ("kro", unde), -- "Kru languages", "krou, langues" ("kru", unde), -- "Kurukh", "kurukh" ("kua", "kj"), -- "Kuanyama; Kwanyama", "kuanyama; kwanyama" ("kum", unde), -- "Kumyk", "koumyk" ("kur", "ku"), -- "Kurdish", "kurde" ("kut", unde), -- "Kutenai", "kutenai" ("lad", unde), -- "Ladino", "judéo-espagnol" ("lah", unde), -- "Lahnda", "lahnda" ("lam", unde), -- "Lamba", "lamba" ("lao", "lo"), -- "Lao", "lao" ("lat", "la"), -- "Latin", "latin" ("lav", "lv"), -- "Latvian", "letton" ("lez", unde), -- "Lezghian", "lezghien" ("lim", "li"), -- "Limburgan; Limburger; Limburgish", "limbourgeois" ("lin", "ln"), -- "Lingala", "lingala" ("lit", "lt"), -- "Lithuanian", "lituanien" ("lol", unde), -- "Mongo", "mongo" ("loz", unde), -- "Lozi", "lozi" ("ltz", "lb"), -- "Luxembourgish; Letzeburgesch", "luxembourgeois" ("lua", unde), -- "Luba-Lulua", "luba-lulua" ("lub", "lu"), -- "Luba-Katanga", "luba-katanga" ("lug", "lg"), -- "Ganda", "ganda" ("lui", unde), -- "Luiseno", "luiseno" ("lun", unde), -- "Lunda", "lunda" ("luo", unde), -- "Luo (Kenya and Tanzania)", "luo (Kenya et Tanzanie)" ("lus", unde), -- "Lushai", "lushai" ("mac", "mk"), -- (B) ("mkd", "mk"), -- (T) "Macedonian", "macédonien" ("mad", unde), -- "Madurese", "madourais" ("mag", unde), -- "Magahi", "magahi" ("mah", "mh"), -- "Marshallese", "marshall" ("mai", unde), -- "Maithili", "maithili" ("mak", unde), -- "Makasar", "makassar" ("mal", "ml"), -- "Malayalam", "malayalam" ("man", unde), -- "Mandingo", "mandingue" ("mao", "mi"), -- (B) ("mri", "mi"), -- (T) "Maori", "maori" ("map", unde), -- "Austronesian languages", "austronésiennes, langues" ("mar", "mr"), -- "Marathi", "marathe" ("mas", unde), -- "Masai", "massaï" ("may", "ms"), -- (B) ("msa", "ms"), -- (T) "Malay", "malais" ("mdf", unde), -- "Moksha", "moksa" ("mdr", unde), -- "Mandar", "mandar" ("men", unde), -- "Mende", "mendé" ("mga", unde), -- "Irish, Middle (900-1200)", -- "irlandais moyen (900-1200)" ("mic", unde), -- "Mi'kmaq; Micmac", "mi'kmaq; micmac" ("min", unde), -- "Minangkabau", "minangkabau" ("mkh", unde), -- "Mon-Khmer languages", "môn-khmer, langues" ("mlg", "mg"), -- "Malagasy", "malgache" ("mlt", "mt"), -- "Maltese", "maltais" ("mnc", unde), -- "Manchu", "mandchou" ("mni", unde), -- "Manipuri", "manipuri" ("mno", unde), -- "Manobo languages", "manobo, langues" ("moh", unde), -- "Mohawk", "mohawk" ("mon", "mn"), -- "Mongolian", "mongol" ("mos", unde), -- "Mossi", "moré" ("mun", unde), -- "Munda languages", "mounda, langues" ("mus", unde), -- "Creek", "muskogee" ("mwl", unde), -- "Mirandese", "mirandais" ("mwr", unde), -- "Marwari", "marvari" ("myn", unde), -- "Mayan languages", "maya, langues" ("myv", unde), -- "Erzya", "erza" ("nah", unde), -- "Nahuatl languages", "nahuatl, langues" ("nai", unde), -- "North American Indian languages", -- "nord-amérindiennes, langues" ("nap", unde), -- "Neapolitan", "napolitain" ("nau", "na"), -- "Nauru", "nauruan" ("nav", "nv"), -- "Navajo; Navaho", "navaho" ("nbl", "nr"), -- "Ndebele, South; South Ndebele", "ndébélé du Sud" ("nde", "nd"), -- "Ndebele, North; North Ndebele", "ndébélé du Nord" ("ndo", "ng"), -- "Ndonga", "ndonga" ("nds", unde), -- "Low German; Low Saxon; German, Low; Saxon, Low", -- "bas allemand; bas saxon; allemand, bas; saxon, bas" ("nep", "ne"), -- "Nepali", "népalais" ("new", unde), -- "Nepal Bhasa; Newari", "nepal bhasa; newari" ("nia", unde), -- "Nias", "nias" ("nic", unde), -- "Niger-Kordofanian languages", -- "nigéro-kordofaniennes, langues" ("niu", unde), -- "Niuean", "niué" ("nno", "nn"), -- "Norwegian Nynorsk; Nynorsk, Norwegian", -- "norvégien nynorsk; nynorsk, norvégien" ("nob", "nb"), -- "Bokmål, Norwegian; Norwegian Bokmål", -- "norvégien bokmål" ("nog", unde), -- "Nogai", "nogaï; nogay" ("non", unde), -- "Norse, Old", "norrois, vieux" ("nor", "no"), -- "Norwegian", "norvégien" ("nqo", unde), -- "N'Ko", "n'ko" ("nso", unde), -- "Pedi; Sepedi; Northern Sotho", -- "pedi; sepedi; sotho du Nord" ("nub", unde), -- "Nubian languages", "nubiennes, langues" ("nwc", unde), -- "Classical Newari; Old Newari; Classical Nepal Bhasa", -- "newari classique" ("nya", "ny"), -- "Chichewa; Chewa; Nyanja", "chichewa; chewa; nyanja" ("nym", unde), -- "Nyamwezi", "nyamwezi" ("nyn", unde), -- "Nyankole", "nyankolé" ("nyo", unde), -- "Nyoro", "nyoro" ("nzi", unde), -- "Nzima", "nzema" ("oci", "oc"), -- "Occitan (post 1500)", "occitan (après 1500)" ("oji", "oj"), -- "Ojibwa", "ojibwa" ("ori", "or"), -- "Oriya", "oriya" ("orm", "om"), -- "Oromo", "galla" ("osa", unde), -- "Osage", "osage" ("oss", "os"), -- "Ossetian; Ossetic", "ossète" ("ota", unde), -- "Turkish, Ottoman (1500-1928)", -- "turc ottoman (1500-1928)" ("oto", unde), -- "Otomian languages", "otomi, langues" ("paa", unde), -- "Papuan languages", "papoues, langues" ("pag", unde), -- "Pangasinan", "pangasinan" ("pal", unde), -- "Pahlavi", "pahlavi" ("pam", unde), -- "Pampanga; Kapampangan", "pampangan" ("pan", "pa"), -- "Panjabi; Punjabi", "pendjabi" ("pap", unde), -- "Papiamento", "papiamento" ("pau", unde), -- "Palauan", "palau" ("peo", unde), -- "Persian, Old (ca.600-400 B.C.)", -- "perse, vieux (ca. 600-400 av. J.-C.)" ("phi", unde), -- "Philippine languages", "philippines, langues" ("phn", unde), -- "Phoenician", "phénicien" ("pli", "pi"), -- "Pali", "pali" ("pol", "pl"), -- "Polish", "polonais" ("pon", unde), -- "Pohnpeian", "pohnpei" ("por", "pt"), -- "Portuguese", "portugais" ("pra", unde), -- "Prakrit languages", "prâkrit, langues" ("pro", unde), -- "Provençal, Old (to 1500); Occitan, Old (to 1500)", -- "provençal ancien (jusqu'à 1500); " -- & "occitan ancien (jusqu'à 1500)" ("pus", "ps"), -- "Pushto; Pashto", "pachto" ("que", "qu"), -- "Quechua", "quechua" ("raj", unde), -- "Rajasthani", "rajasthani" ("rap", unde), -- "Rapanui", "rapanui" ("rar", unde), -- "Rarotongan; Cook Islands Maori", -- "rarotonga; maori des îles Cook" ("roa", unde), -- "Romance languages", "romanes, langues" ("roh", "rm"), -- "Romansh", "romanche" ("rom", unde), -- "Romany", "tsigane" ("rum", "ro"), -- (B) ("ron", "ro"), -- (T) "Romanian; Moldavian; Moldovan", "roumain; moldave" ("run", "rn"), -- "Rundi", "rundi" ("rup", unde), -- "Aromanian; Arumanian; Macedo-Romanian", -- "aroumain; macédo-roumain" ("rus", "ru"), -- "Russian", "russe" ("sad", unde), -- "Sandawe", "sandawe" ("sag", "sg"), -- "Sango", "sango" ("sah", unde), -- "Yakut", "iakoute" ("sai", unde), -- "South American Indian languages", -- "sud-amérindiennes, langues" ("sal", unde), -- "Salishan languages", "salishennes, langues" ("sam", unde), -- "Samaritan Aramaic", "samaritain" ("san", "sa"), -- "Sanskrit", "sanskrit" ("sas", unde), -- "Sasak", "sasak" ("sat", unde), -- "Santali", "santal" ("scn", unde), -- "Sicilian", "sicilien" ("sco", unde), -- "Scots", "écossais" ("sel", unde), -- "Selkup", "selkoupe" ("sem", unde), -- "Semitic languages", "sémitiques, langues" ("sga", unde), -- "Irish, Old (to 900)", -- "irlandais ancien (jusqu'à 900)" ("sgn", unde), -- "Sign Languages", "langues des signes" ("shn", unde), -- "Shan", "chan" ("sid", unde), -- "Sidamo", "sidamo" ("sin", "si"), -- "Sinhala; Sinhalese", "singhalais" ("sio", unde), -- "Siouan languages", "sioux, langues" ("sit", unde), -- "Sino-Tibetan languages", "sino-tibétaines, langues" ("sla", unde), -- "Slavic languages", "slaves, langues" ("slo", "sk"), -- (B) ("slk", "sk"), -- (T) "Slovak", "slovaque" ("slv", "sl"), -- "Slovenian", "slovène" ("sma", unde), -- "Southern Sami", "sami du Sud" ("sme", "se"), -- "Northern Sami", "sami du Nord" ("smi", unde), -- "Sami languages", "sames, langues" ("smj", unde), -- "<NAME>", "sami de Lule" ("smn", unde), -- "In<NAME>", "sami d'Inari" ("smo", "sm"), -- "Samoan", "samoan" ("sms", unde), -- "<NAME>", "<NAME>" ("sna", "sn"), -- "Shona", "shona" ("snd", "sd"), -- "Sindhi", "sindhi" ("snk", unde), -- "Soninke", "soninké" ("sog", unde), -- "Sogdian", "sogdien" ("som", "so"), -- "Somali", "somali" ("son", unde), -- "Songhai languages", "songhai, langues" ("sot", "st"), -- "Sotho, Southern", "sotho du Sud" ("spa", "es"), -- "Spanish; Castilian", "espagnol; castillan" ("srd", "sc"), -- "Sardinian", "sarde" ("srn", unde), -- "S<NAME>", "sranan tongo" ("srp", "sr"), -- "Serbian", "serbe" ("srr", unde), -- "Serer", "sérère" ("ssa", unde), -- "Nilo-Saharan languages", "nilo-sahariennes, langues" ("ssw", "ss"), -- "Swati", "swati" ("suk", unde), -- "Sukuma", "sukuma" ("sun", "su"), -- "Sundanese", "soundanais" ("sus", unde), -- "Susu", "soussou" ("sux", unde), -- "Sumerian", "sumérien" ("swa", "sw"), -- "Swahili", "swahili" ("swe", "sv"), -- "Swedish", "suédois" ("syc", unde), -- "Classical Syriac", "syriaque classique" ("syr", unde), -- "Syriac", "syriaque" ("tah", "ty"), -- "Tahitian", "tahitien" ("tai", unde), -- "Tai languages", "tai, langues" ("tam", "ta"), -- "Tamil", "tamoul" ("tat", "tt"), -- "Tatar", "tatar" ("tel", "te"), -- "Telugu", "télougou" ("tem", unde), -- "Timne", "temne" ("ter", unde), -- "Tereno", "tereno" ("tet", unde), -- "Tetum", "tetum" ("tgk", "tg"), -- "Tajik", "tadjik" ("tgl", "tl"), -- "Tagalog", "tagalog" ("tha", "th"), -- "Thai", "thaï" ("tig", unde), -- "Tigre", "tigré" ("tir", "ti"), -- "Tigrinya", "tigrigna" ("tiv", unde), -- "Tiv", "tiv" ("tkl", unde), -- "Tokelau", "tokelau" ("tlh", unde), -- "Klingon; tlhIngan-Hol", "klingon" ("tli", unde), -- "Tlingit", "tlingit" ("tmh", unde), -- "Tamashek", "tamacheq" ("tog", unde), -- "Tonga (Nyasa)", "tonga (Nyasa)" ("ton", "to"), -- "Tonga (Tonga Islands)", "tongan (Îles Tonga)" ("tpi", unde), -- "<NAME>", "<NAME>" ("tsi", unde), -- "Tsimshian", "tsimshian" ("tsn", "tn"), -- "Tswana", "tswana" ("tso", "ts"), -- "Tsonga", "tsonga" ("tuk", "tk"), -- "Turkmen", "turkmène" ("tum", unde), -- "Tumbuka", "tumbuka" ("tup", unde), -- "Tupi languages", "tupi, langues" ("tur", "tr"), -- "Turkish", "turc" ("tut", unde), -- "Altaic languages", "altaïques, langues" ("tvl", unde), -- "Tuvalu", "tuvalu" ("twi", "tw"), -- "Twi", "twi" ("tyv", unde), -- "Tuvinian", "touva" ("udm", unde), -- "Udmurt", "oudmourte" ("uga", unde), -- "Ugaritic", "ougaritique" ("uig", "ug"), -- "Uighur; Uyghur", "ouïgour" ("ukr", "uk"), -- "Ukrainian", "ukrainien" ("umb", unde), -- "Umbundu", "umbundu" ("urd", "ur"), -- "Urdu", "ourdou" ("uzb", "uz"), -- "Uzbek", "ouszbek" ("vai", unde), -- "Vai", "vaï" ("ven", "ve"), -- "Venda", "venda" ("vie", "vi"), -- "Vietnamese", "vietnamien" ("vol", "vo"), -- "Volapük", "volapük" ("vot", unde), -- "Votic", "vote" ("wak", unde), -- "Wakashan languages", "wakashanes, langues" ("wal", unde), -- "Wolaitta; Wolaytta", "wolaitta; wolaytta" ("war", unde), -- "Waray", "waray" ("was", unde), -- "Washo", "washo" ("wen", unde), -- "Sorbian languages", "sorabes, langues" ("wln", "wa"), -- "Walloon", "wallon" ("wol", "wo"), -- "Wolof", "wolof" ("xal", unde), -- "Kalmyk; Oirat", "kalmouk; oïrat" ("xho", "xh"), -- "Xhosa", "xhosa" ("yao", unde), -- "Yao", "yao" ("yap", unde), -- "Yapese", "yapois" ("yid", "yi"), -- "Yiddish", "yiddish" ("yor", "yo"), -- "Yoruba", "yoruba" ("ypk", unde), -- "Yupik languages", "yupik, langues" ("zap", unde), -- "Zapotec", "zapotèque" ("zbl", unde), -- "Blissymbols; Blissymbolics; Bliss", -- "symboles Bliss; Bliss" ("zen", unde), -- "Zenaga", "zenaga" ("zha", "za"), -- "Zhuang; Chuang", "zhuang; chuang" ("znd", unde), -- "Zande languages", "zandé, langues" ("zul", "zu"), -- "Zulu", "zoulou" ("zun", unde), -- "Zuni", "zuni" ("zza", unde)); -- "Zaza; Dimili; Dimli; Kirdki; Kirmanjki; Zazaki", -- "zaza; dimili; dimli; kirdki; kirmanjki; zazaki" -- mis, mul, qaa-qtz, und, zxx are excluded Lang_Map_3 : Language_Table_Array_Access; Lang_Map_3_Flag : aliased System.Once.Flag := 0; procedure Lang_Map_3_Init; procedure Lang_Map_3_Init is begin -- copy table Lang_Map_3 := new Language_Table_Array'(Language_Table); -- check duplicated? pragma Check (Validate, Check => (for all I in Lang_Map_3'First .. Lang_Map_3'Last - 1 => (for all J in I + 1 .. Lang_Map_3'Last => Lang_Map_3 (I).Alpha_3 /= Lang_Map_3 (J).Alpha_3))); -- sort for I in Lang_Map_3'First + 1 .. Lang_Map_3'Last loop for J in reverse Lang_Map_3'First .. I - 1 loop exit when Compare ( Lang_Map_3 (J + 1).Alpha_3, Lang_Map_3 (J).Alpha_3) >= 0; declare Temp : constant Language_Table_Element := Lang_Map_3 (J); begin Lang_Map_3 (J) := Lang_Map_3 (J + 1); Lang_Map_3 (J + 1) := Temp; end; end loop; end loop; end Lang_Map_3_Init; function To_Alpha_2 (Item : ISO_639_Alpha_3) return ISO_639_Alpha_2 is pragma Check (Dynamic_Predicate, Check => (for all E of Item => E in 'a' .. 'z')); begin System.Once.Initialize (Lang_Map_3_Flag'Access, Lang_Map_3_Init'Access); declare First : Positive := Lang_Map_3'First; Last : Natural := Lang_Map_3'Last; begin while First <= Last loop declare Middle : constant Positive := (First + Last) / 2; Middle_Item : Language_Table_Element renames Lang_Map_3 (Middle); Compared : constant Integer := Compare (Middle_Item.Alpha_3, Alpha_3_NP (Item)); begin if Compared > 0 then Last := Middle - 1; elsif expect (Long_Boolean (Compared < 0), True) then First := Middle + 1; else return ( 1 => Middle_Item.Alpha_2 (1), 2 => Middle_Item.Alpha_2 (2)); end if; end; end loop; return ISO_639_Alpha_2_Unknown; end; end To_Alpha_2; Lang_Map_2 : Language_Table_Array_Access; Lang_Map_2_Flag : aliased System.Once.Flag := 0; procedure Lang_Map_2_Init; procedure Lang_Map_2_Init is begin -- copy table -- select terminology (second) declare Num : Natural := 0; J : Positive; begin for I in Language_Table'Range loop if Language_Table (I).Alpha_2 /= unde and then ( I = Language_Table'Last or else Language_Table (I).Alpha_2 /= Language_Table (I + 1).Alpha_2) then Num := Num + 1; end if; end loop; Lang_Map_2 := new Language_Table_Array (1 .. Num); J := Lang_Map_2'First; for I in Language_Table'Range loop if Language_Table (I).Alpha_2 /= unde and then ( I = Language_Table'Last or else Language_Table (I).Alpha_2 /= Language_Table (I + 1).Alpha_2) then Lang_Map_2 (J) := Language_Table (I); J := J + 1; end if; end loop; end; -- check duplicated? pragma Check (Validate, Check => (for all I in Lang_Map_2'First .. Lang_Map_2'Last - 1 => (for all J in I + 1 .. Lang_Map_2'Last => Lang_Map_2 (I).Alpha_2 /= Lang_Map_2 (J).Alpha_2))); -- sort for I in Lang_Map_2'First + 1 .. Lang_Map_2'Last loop for J in reverse Lang_Map_2'First .. I - 1 loop exit when Compare ( Lang_Map_2 (J + 1).Alpha_2, Lang_Map_2 (J).Alpha_2) >= 0; declare Temp : constant Language_Table_Element := Lang_Map_2 (J); begin Lang_Map_2 (J) := Lang_Map_2 (J + 1); Lang_Map_2 (J + 1) := Temp; end; end loop; end loop; end Lang_Map_2_Init; function To_Alpha_3 (Item : ISO_639_Alpha_2) return ISO_639_Alpha_3 is pragma Check (Dynamic_Predicate, Check => (for all E of Item => E in 'a' .. 'z')); begin System.Once.Initialize (Lang_Map_2_Flag'Access, Lang_Map_2_Init'Access); declare First : Positive := Lang_Map_2'First; Last : Natural := Lang_Map_2'Last; begin while First <= Last loop declare Middle : constant Positive := (First + Last) / 2; Middle_Item : Language_Table_Element renames Lang_Map_2 (Middle); Compared : constant Integer := Compare (Middle_Item.Alpha_2, Alpha_2_NP (Item)); begin if Compared > 0 then Last := Middle - 1; elsif expect (Long_Boolean (Compared < 0), True) then First := Middle + 1; else return ( 1 => Middle_Item.Alpha_3 (1), 2 => Middle_Item.Alpha_3 (2), 3 => Middle_Item.Alpha_3 (3)); end if; end; end loop; return ISO_639_Alpha_3_Unknown; end; end To_Alpha_3; function Language return ISO_639_Alpha_2 renames System.Native_Locales.Language; function Language return ISO_639_Alpha_3 renames System.Native_Locales.Language; function Country return ISO_3166_1_Alpha_2 renames System.Native_Locales.Country; end Ada.Locales;
29,624
ada
0
JCGobbi/Nucleo-STM32G474RE
bb-runtimes/src/s-textio__leon.adb
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- S Y S T E M . T E X T _ I O -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2016, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. -- -- -- -- 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. -- -- -- ------------------------------------------------------------------------------ with System.BB.Board_Parameters; package body System.Text_IO is ----------- -- Local -- ----------- type Scaler_12 is mod 2 ** 12; for Scaler_12'Size use 12; type Reserved_20 is array (0 .. 19) of Boolean; for Reserved_20'Size use 20; pragma Pack (Reserved_20); type Reserved_23 is array (0 .. 22) of Boolean; for Reserved_23'Size use 23; pragma Pack (Reserved_23); type Reserved_24 is array (0 .. 23) of Boolean; for Reserved_24'Size use 24; pragma Pack (Reserved_24); type Reserved_25 is array (0 .. 24) of Boolean; for Reserved_25'Size use 25; pragma Pack (Reserved_25); UART_1_Data_Register_Address : constant System.Address := 16#80000070#; UART_1_Status_Register_Address : constant System.Address := 16#80000074#; UART_1_Control_Register_Address : constant System.Address := 16#80000078#; UART_1_Scaler_Register_Address : constant System.Address := 16#8000007C#; type UART_Data_Register is record RTD : Character; Reserved : Reserved_24; end record; for UART_Data_Register use record RTD at 0 range 24 .. 31; Reserved at 0 range 0 .. 23; end record; for UART_Data_Register'Size use 32; pragma Suppress_Initialization (UART_Data_Register); type UART_Status_Register is record DR : Boolean; TS : Boolean; TH : Boolean; BR : Boolean; OV : Boolean; PE : Boolean; FE : Boolean; Reserved : Reserved_25; end record; for UART_Status_Register use record DR at 0 range 31 .. 31; TS at 0 range 30 .. 30; TH at 0 range 29 .. 29; BR at 0 range 28 .. 28; OV at 0 range 27 .. 27; PE at 0 range 26 .. 26; FE at 0 range 25 .. 25; Reserved at 0 range 0 .. 24; end record; for UART_Status_Register'Size use 32; pragma Suppress_Initialization (UART_Status_Register); type UART_Control_Register is record RE : Boolean; TE : Boolean; RI : Boolean; TI : Boolean; PS : Boolean; PE : Boolean; FL : Boolean; LB : Boolean; EC : Boolean; Reserved : Reserved_23; end record; for UART_Control_Register use record RE at 0 range 31 .. 31; TE at 0 range 30 .. 30; RI at 0 range 29 .. 29; TI at 0 range 28 .. 28; PS at 0 range 27 .. 27; PE at 0 range 26 .. 26; FL at 0 range 25 .. 25; LB at 0 range 24 .. 24; EC at 0 range 23 .. 23; Reserved at 0 range 0 .. 22; end record; for UART_Control_Register'Size use 32; pragma Suppress_Initialization (UART_Control_Register); type UART_Scaler_Register is record UART_Scaler : Scaler_12; Reserved : Reserved_20; end record; for UART_Scaler_Register use record UART_Scaler at 0 range 20 .. 31; Reserved at 0 range 0 .. 19; end record; for UART_Scaler_Register'Size use 32; pragma Suppress_Initialization (UART_Scaler_Register); UART_1_Data : UART_Data_Register; pragma Atomic (UART_1_Data); for UART_1_Data'Address use UART_1_Data_Register_Address; UART_1_Status : UART_Status_Register; pragma Atomic (UART_1_Status); for UART_1_Status'Address use UART_1_Status_Register_Address; UART_1_Control : UART_Control_Register; pragma Atomic (UART_1_Control); for UART_1_Control'Address use UART_1_Control_Register_Address; UART_1_Scaler : UART_Scaler_Register; pragma Atomic (UART_1_Scaler); for UART_1_Scaler'Address use UART_1_Scaler_Register_Address; --------- -- Get -- --------- function Get return Character is begin -- Will never be called raise Program_Error; return ASCII.NUL; end Get; ---------------- -- Initialize -- ---------------- procedure Initialize is Control_Aux : UART_Control_Register; Scaler_Aux : UART_Scaler_Register; begin Control_Aux := UART_1_Control; Scaler_Aux := (UART_Scaler => Scaler_12 ((System.BB.Board_Parameters.Clock_Frequency * 10 / (115200 * 8) - 5) / 10), Reserved => (others => False)); Control_Aux.RE := True; Control_Aux.TE := True; Control_Aux.RI := False; Control_Aux.PE := False; Control_Aux.PS := False; Control_Aux.FL := False; Control_Aux.LB := False; Control_Aux.EC := False; Control_Aux.Reserved := (others => False); UART_1_Control := Control_Aux; UART_1_Scaler := Scaler_Aux; Initialized := True; end Initialize; ----------------- -- Is_Rx_Ready -- ----------------- function Is_Rx_Ready return Boolean is begin return False; end Is_Rx_Ready; ----------------- -- Is_Tx_Ready -- ----------------- function Is_Tx_Ready return Boolean is UART_Status_Aux : constant UART_Status_Register := UART_1_Status; begin return UART_Status_Aux.TH; end Is_Tx_Ready; --------- -- Put -- --------- procedure Put (C : Character) is UART_Tx : constant UART_Data_Register := (RTD => C, Reserved => (others => False)); begin UART_1_Data := UART_Tx; end Put; ---------------------------- -- Use_Cr_Lf_For_New_Line -- ---------------------------- function Use_Cr_Lf_For_New_Line return Boolean is begin return True; end Use_Cr_Lf_For_New_Line; end System.Text_IO;
29,625
ada
4
faelys/gela-asis
source/asis/spec/ada-strings-wide_wide_maps.ads
------------------------------------------------------------------------------ -- A d a r u n - t i m e s p e c i f i c a t i o n -- -- ASIS implementation for Gela project, a portable Ada compiler -- -- http://gela.ada-ru.org -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license at the end of ada.ads file -- ------------------------------------------------------------------------------ -- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $ package Ada.Strings.Wide_Wide_Maps is pragma Preelaborate(Wide_Wide_Maps); -- Representation for a set of Wide_Wide_Character values: type Wide_Wide_Character_Set is private; pragma Preelaborable_Initialization(Wide_Wide_Character_Set); Null_Set : constant Wide_Wide_Character_Set; type Wide_Wide_Character_Range is record Low : Wide_Wide_Character; High : Wide_Wide_Character; end record; -- Represents Wide_Wide_Character range Low..High type Wide_Wide_Character_Ranges is array (Positive range <>) of Wide_Wide_Character_Range; function To_Set (Ranges : in Wide_Wide_Character_Ranges) return Wide_Wide_Character_Set; function To_Set (Span : in Wide_Wide_Character_Range) return Wide_Wide_Character_Set; function To_Ranges (Set : in Wide_Wide_Character_Set) return Wide_Wide_Character_Ranges; function "=" (Left, Right : in Wide_Wide_Character_Set) return Boolean; function "not" (Right : in Wide_Wide_Character_Set) return Wide_Wide_Character_Set; function "and" (Left, Right : in Wide_Wide_Character_Set) return Wide_Wide_Character_Set; function "or" (Left, Right : in Wide_Wide_Character_Set) return Wide_Wide_Character_Set; function "xor" (Left, Right : in Wide_Wide_Character_Set) return Wide_Wide_Character_Set; function "-" (Left, Right : in Wide_Wide_Character_Set) return Wide_Wide_Character_Set; function Is_In (Element : in Wide_Wide_Character; Set : in Wide_Wide_Character_Set) return Boolean; function Is_Subset (Elements : in Wide_Wide_Character_Set; Set : in Wide_Wide_Character_Set) return Boolean; function "<=" (Left : in Wide_Wide_Character_Set; Right : in Wide_Wide_Character_Set) return Boolean renames Is_Subset; -- Alternative representation for a set of Wide_Wide_Character values: subtype Wide_Wide_Character_Sequence is Wide_Wide_String; function To_Set (Sequence : in Wide_Wide_Character_Sequence) return Wide_Wide_Character_Set; function To_Set (Singleton : in Wide_Wide_Character) return Wide_Wide_Character_Set; function To_Sequence (Set : in Wide_Wide_Character_Set) return Wide_Wide_Character_Sequence; -- Representation for a Wide_Wide_Character to Wide_Wide_Character -- mapping: type Wide_Wide_Character_Mapping is private; pragma Preelaborable_Initialization(Wide_Wide_Character_Mapping); function Value (Map : in Wide_Wide_Character_Mapping; Element : in Wide_Wide_Character) return Wide_Wide_Character; Identity : constant Wide_Wide_Character_Mapping; function To_Mapping (From, To : in Wide_Wide_Character_Sequence) return Wide_Wide_Character_Mapping; function To_Domain (Map : in Wide_Wide_Character_Mapping) return Wide_Wide_Character_Sequence; function To_Range (Map : in Wide_Wide_Character_Mapping) return Wide_Wide_Character_Sequence; type Wide_Wide_Character_Mapping_Function is access function (From : in Wide_Wide_Character) return Wide_Wide_Character; private pragma Import (Ada, Wide_Wide_Character_Set); pragma Import (Ada, Null_Set); pragma Import (Ada, Wide_Wide_Character_Mapping); pragma Import (Ada, Identity); end Ada.Strings.Wide_Wide_Maps;
29,626
ada
0
skill-lang/adaCommon
src/skill-tasks.ads
<gh_stars>0 -- ___ _ ___ _ _ -- -- / __| |/ (_) | | Common SKilL implementation -- -- \__ \ ' <| | | |__ tasks package -- -- |___/_|\_\_|_|____| by: <NAME> -- -- -- pragma Ada_2012; -- usage: -- X : Run (Some_Procedure'Access); -- X.Start; package Skill.Tasks is pragma Preelaborate; type Closure_T is tagged null record; type Closure is not null access Closure_T'Class; task type Run (Runnable : not null access procedure(C : Closure)) is entry Start (C : Closure); end Run; end Skill.Tasks;
29,627
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c3/c37305a.ada
-- C37305A.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- CHECK THAT CHOICES DENOTING A NULL RANGE OF VALUES ARE PERMITTED, -- AND THAT FOR CHOICES CONSISTING OF A SUBTYPE NAME FOLLOWED BY A -- RANGE CONSTRAINT WHERE THE LOWER BOUND IS GREATER THAN THE UPPER -- BOUND, THE BOUNDS NEED NOT BE IN THE RANGE OF THE SUBTYPE VALUES. -- CHECK THAT AN OTHERS ALTERNATIVE CAN BE PROVIDED EVEN IF ALL VALUES -- OF THE CASE EXPRESSION HAVE BEEN COVERED BY PRECEDING ALTERNATIVES. -- ASL 7/14/81 -- JWC 6/28/85 RENAMED TO -AB WITH REPORT; PROCEDURE C37305A IS USE REPORT; BEGIN TEST ("C37305A","NULL RANGES ALLOWED IN CHOICES FOR VARIANT " & "PARTS. OTHERS ALTERNATIVE ALLOWED AFTER ALL VALUES " & "PREVIOUSLY COVERED"); DECLARE SUBTYPE ST IS INTEGER RANGE 1..10; TYPE REC(DISC : ST := 1) IS RECORD CASE DISC IS WHEN 0..-1 => NULL; WHEN 1..-3 => NULL; WHEN 6..5 => COMP : INTEGER; WHEN 11..10 => NULL; WHEN 15..12 => NULL; WHEN 11..0 => NULL; WHEN 1..10 => NULL; WHEN OTHERS => NULL; END CASE; END RECORD; R : REC; BEGIN R := (DISC => 4); IF EQUAL(3,4) THEN R := (DISC => 7); END IF; IF R.DISC /= 4 THEN FAILED ("ASSIGNMENT FAILED"); END IF; EXCEPTION WHEN OTHERS => FAILED ("EXCEPTION RAISED"); END; RESULT; END C37305A;
29,628
ada
0
caqg/linux-home
.emacs.d/elpa/wisi-3.0.1/sal-gen_unbounded_definite_vectors_sorted.adb
-- Abstract : -- -- See spec. -- -- Copyright (C) 2019 Free Software Foundation, Inc. -- -- This library is free software; you can redistribute it and/or modify it -- under terms of the GNU General Public License as published by the Free -- Software Foundation; either version 3, or (at your option) any later -- version. This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- As a special exception under Section 7 of GPL version 3, you are granted -- additional permissions described in the GCC Runtime Library Exception, -- version 3.1, as published by the Free Software Foundation. pragma License (Modified_GPL); package body SAL.Gen_Unbounded_Definite_Vectors_Sorted is ---------- -- Body subprograms, arbitrary order procedure Grow (Elements : in out Array_Access; Index : in Base_Peek_Type) is -- Reallocate Elements so Elements (Index) is a valid element. Old_First : constant Peek_Type := Elements'First; Old_Last : constant Peek_Type := Elements'Last; New_First : Peek_Type := Old_First; New_Last : Peek_Type := Old_Last; New_Length : Peek_Type := Elements'Length; New_Array : Array_Access; begin loop exit when New_First <= Index; New_Length := New_Length * 2; New_First := Peek_Type'Max (Peek_Type'First, Old_Last - New_Length + 1); end loop; loop exit when New_Last >= Index; New_Length := New_Length * 2; New_Last := Peek_Type'Min (Peek_Type'Last, New_First + New_Length - 1); end loop; New_Array := new Array_Type (New_First .. New_Last); -- We'd like to use this: -- -- New_Array (New_First .. Old_First - 1) := (others => <>); -- -- but that can overflow the stack, since the aggregate is allocated -- on the stack. for I in New_First .. Old_First - 1 loop New_Array (I .. I) := (others => <>); end loop; New_Array (Old_First .. Old_Last) := Elements.all; for I in Old_Last + 1 .. New_Last loop New_Array (I .. I) := (others => <>); end loop; Free (Elements); Elements := New_Array; end Grow; procedure Find (Container : in Vector; Key : in Key_Type; Found : out Boolean; At_After : out Base_Peek_Type) with Pre => Container.Last /= No_Index is -- If Found is True, item is at At_After. If False, item should be -- inserted after At_After. Low : Base_Peek_Type := Peek_Type'First - 1; High : Base_Peek_Type := Container.Last + 1; I : Base_Peek_Type := Low + High / 2; begin loop case Key_Compare (Key, To_Key (Container.Elements (I))) is when Less => High := I; if I = Low then Found := False; At_After := I; return; elsif I - 1 = Low then Found := False; At_After := I - 1; return; else I := I - (I - Low) / 2; end if; when Equal => Found := True; At_After := I; return; when Greater => Low := I; if I = High then Found := False; At_After := I - 1; return; elsif I + 1 = High then Found := False; At_After := I; return; else I := I + (High - I) / 2; end if; end case; end loop; end Find; ---------- -- Public subprograms overriding procedure Finalize (Container : in out Vector) is begin Free (Container.Elements); Container.Last := No_Index; end Finalize; overriding procedure Adjust (Container : in out Vector) is begin if Container.Elements /= null then Container.Elements := new Array_Type'(Container.Elements.all); end if; end Adjust; function Length (Container : in Vector) return Ada.Containers.Count_Type is begin -- We assume the type ranges are sensible, so no exceptions occur -- here. if Container.Elements = null then return 0; else return Ada.Containers.Count_Type (Container.Last - Container.Elements'First + 1); end if; end Length; function Capacity (Container : in Vector) return Ada.Containers.Count_Type is begin if Container.Elements = null then return 0; else return Ada.Containers.Count_Type (Container.Elements'Length); end if; end Capacity; procedure Set_Capacity (Container : in out Vector; Length : in Ada.Containers.Count_Type) is use all type Ada.Containers.Count_Type; First_Peek : constant Peek_Type := Peek_Type'First; Last_Peek : constant Base_Peek_Type := Base_Peek_Type (Length); begin if Length = 0 then return; elsif Container.Elements = null then Container.Elements := new Array_Type (First_Peek .. Last_Peek); else if First_Peek < Container.Elements'First then Grow (Container.Elements, First_Peek); end if; if Last_Peek < Container.Elements'Last then Grow (Container.Elements, Last_Peek); end if; end if; end Set_Capacity; function Has_Element (Position : Cursor) return Boolean is begin return Position.Index /= Invalid_Peek_Index; end Has_Element; function "&" (Left, Right : in Element_Type) return Vector is begin return Result : Vector do Result.Insert (Left); Result.Insert (Right); end return; end "&"; function "&" (Left : in Vector; Right : in Element_Type) return Vector is begin return Result : Vector := Left do Result.Insert (Right); end return; end "&"; function Contains (Container : in Vector; Key : in Key_Type) return Boolean is Found : Boolean; I : Base_Peek_Type; begin if Container.Last = No_Index then return False; end if; Find (Container, Key, Found, I); return Found; end Contains; procedure Insert (Container : in out Vector; New_Item : in Element_Type) is New_Key : constant Key_Type := To_Key (New_Item); J : constant Peek_Type := Peek_Type'First; K : constant Base_Peek_Type := Container.Last; I : Base_Peek_Type := K; begin if Container.Last = No_Index then Container.Last := Peek_Type'First; I := Container.Last; if Container.Elements = null then Container.Elements := new Array_Type (I .. I); -- else Set_Capacity called. end if; Container.Elements (I) := New_Item; return; else Container.Last := Container.Last + 1; end if; pragma Assert (Container.Elements /= null); if I + 1 > Container.Elements'Last then Grow (Container.Elements, I + 1); end if; loop exit when I < J; case Key_Compare (New_Key, To_Key (Container.Elements (I))) is when Less => -- Linear search is simple, we assume insert is used far less often -- than Find. And this is optimal when inserting in Key order. I := I - 1; when Equal => -- Insert after I exit; when Greater => -- Insert after I exit; end case; end loop; if I < J then -- Insert before all Container.Elements (J + 1 .. K + 1) := Container.Elements (J .. K); Container.Elements (J) := New_Item; else -- Insert after I Container.Elements (I + 2 .. K + 1) := Container.Elements (I + 1 .. K); Container.Elements (I + 1) := New_Item; end if; end Insert; function Find (Container : aliased in Vector; Key : in Key_Type) return Find_Reference_Type is Found : Boolean; I : Base_Peek_Type; begin if Container.Last = No_Index then return (Element => null, Dummy => 1); end if; Find (Container, Key, Found, I); if Found then return (Element => Container.Elements (I)'Access, Dummy => 1); else return (Element => null, Dummy => 1); end if; end Find; function Find_Constant (Container : aliased in Vector; Key : in Key_Type) return Find_Reference_Constant_Type is Found : Boolean; I : Base_Peek_Type; begin if Container.Last = No_Index then return (Element => null, Dummy => 1); end if; Find (Container, Key, Found, I); if Found then return (Element => Container.Elements (I)'Access, Dummy => 1); else return (Element => null, Dummy => 1); end if; end Find_Constant; overriding function First (Object : Iterator) return Cursor is begin if Object.Container.Elements = null then return (null, Invalid_Peek_Index); else return (Object.Container, Peek_Type'First); end if; end First; overriding function Last (Object : Iterator) return Cursor is begin if Object.Container.Elements = null then return (null, Invalid_Peek_Index); else return (Object.Container, Object.Container.Last); end if; end Last; overriding function Next (Object : in Iterator; Position : in Cursor) return Cursor is begin if Position.Index = Object.Container.Last then return (null, Invalid_Peek_Index); else return (Object.Container, Position.Index + 1); end if; end Next; overriding function Previous (Object : in Iterator; Position : in Cursor) return Cursor is begin if Position.Index = Peek_Type'First then return (null, Invalid_Peek_Index); else return (Object.Container, Position.Index - 1); end if; end Previous; function Iterate (Container : aliased in Vector) return Iterator_Interfaces.Reversible_Iterator'Class is begin return Iterator'(Container => Container'Unrestricted_Access); end Iterate; function Constant_Ref (Container : aliased Vector; Position : in Cursor) return Constant_Reference_Type is begin return (Element => Container.Elements (Position.Index)'Access, Dummy => 1); end Constant_Ref; function Last_Index (Container : aliased Vector) return Base_Peek_Type is begin return Container.Last; end Last_Index; function Constant_Ref (Container : aliased Vector; Index : in Peek_Type) return Constant_Reference_Type is begin return (Element => Container.Elements (Index)'Access, Dummy => 1); end Constant_Ref; end SAL.Gen_Unbounded_Definite_Vectors_Sorted;
29,629
ada
4
MOUDDENEHamza/ENSEEIHT
1A/S5/PIM/tps/tp6/illustrer_affectation_pile.adb
<gh_stars>1-10 with Piles; with Ada.Text_IO; use Ada.Text_IO; -- Montrer le risque d'autoriser l'affectation entre variables dont le type -- est une structure chaînée. procedure Illustrer_Affectation_Pile is package Pile is new Piles (Character); use Pile; procedure Afficher is new Pile.Afficher (Put); P1, P2 : T_Pile; begin -- construire la pile P1 Initialiser (P1); Empiler (P1, 'A'); Empiler (P1, 'B'); Afficher (P1); New_Line; -- XXX Qu'est ce qui s'affiche ? A B P2 := P1; -- XXX Conseillé ? NON pragma Assert (P1 = P2); Depiler (P2); -- XXX Quel effet ? P2 : A P1 : A B Afficher (P2); New_Line; -- XXX Qu'est ce qui s'affiche ? A Afficher (P1); New_Line; -- XXX Qu'est ce qui s'affiche ? A -- XXX Que donne l'exécution avec valkyrie ? -- Elle donne plusieurs problème de mémoire. Depiler (P1); -- XXX correct ? OUI end Illustrer_Affectation_Pile;
29,630
ada
0
xeenta/learning-ada
src/003/test_age_madness.adb
with Ada.Text_IO; use Ada.Text_IO; procedure Test_Age_Madness is subtype Age_Type is Natural range 0 .. 140; subtype Age_Distance is Integer; -- the following subtype is better --subtype Age_Distance is Integer range -Age_Type'Last .. Age_Type'Last; Adult_Age : constant Age_Type := 18; -- Q: "How many years ago have you kissed?" -- A: "Well, let me think, it must be fiftysix years ago or so" function Get_Dist_From_First_Kiss return Age_Distance is (56); -- Age guessed by the AI analyzing the subject function Guess_Age return Age_Type is (19); -- Q: "Have you ever kissed?" -- A: "Sure, I did!" function Have_You_Ever_Kissed return Boolean is (True); -- We have the number of years passed since subject's first kiss, -- and subject's age. Let's compute the age she had her first kiss. function Age_Of_Kiss (Current_Age : Age_Type) return Age_Type is Dist_Of_First_Kiss : constant Age_Distance := Get_Dist_From_First_Kiss; begin return Current_Age - Dist_Of_First_Kiss; end Age_Of_Kiss; First_Kiss_Age : Age_Type; begin if Have_You_Ever_Kissed then First_Kiss_Age := Age_Of_Kiss (Guess_Age); if First_Kiss_Age < Adult_Age then Put_Line ("you weren't adult!"); else Put_Line ("so, you waiting for so long..."); end if; end if; end Test_Age_Madness;
29,631
ada
13
annexi-strayline/AURA
configuration-step_4.adb
<filename>configuration-step_4.adb ------------------------------------------------------------------------------ -- -- -- Ada User Repository Annex (AURA) -- -- ANNEXI-STRAYLINE Reference Implementation -- -- -- -- Command Line Interface -- -- -- -- ------------------------------------------------------------------------ -- -- -- -- Copyright (C) 2020, ANNEXI-STRAYLINE Trans-Human Ltd. -- -- All rights reserved. -- -- -- -- Original Contributors: -- -- * <NAME> (ANNEXI-STRAYLINE) -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions are -- -- met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- -- -- * Neither the name of the copyright holder nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A -- -- PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ with Ada.Directories; with Registrar.Registration; separate (Configuration) procedure Step_4 (Target: in out Subsystem) is use Ada.Directories; SS_Root_Path: constant String := Current_Directory & '/' & Target.Name.To_UTF8_String; Search: Search_Type; Subdir: Directory_Entry_Type; begin -- Note that Codepaths will always be empty for the root configuration -- unit, since codepaths are explicitly disallowed. It seemed better form to -- let it come here anyways, rather than explicitly ending at Step_3 with a -- special case, since the outcome is identical, and performance impact very -- minimal. In fact, the root config is only explictly processed once, so -- having a check in step 3 would be less performant for Codepath of Target.Configuration.Codepaths loop declare Full_Path: constant String := SS_Root_Path & '/' & UBS.To_String (Codepath.Value); Subdir_Name: constant String := Simple_Name (Full_Path); begin Start_Search (Search => Search, Directory => Containing_Directory (Full_Path), Pattern => Subdir_Name, Filter => Filter_Type'(Directory => True, others => False)); Assert (Check => More_Entries (Search), Message => "Could not find codepath """ & UBS.To_String (Codepath.Value) & '"'); Get_Next_Entry (Search => Search, Directory_Entry => Subdir); Registrar.Registration.Enter_Directory (Directory => Subdir, AURA_Subsystem => Target); end; end loop; Complete (Target); end Step_4;
29,632
ada
52
onox/orka
orka/src/gl/interface/gl-blending.ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2013 <NAME> <<EMAIL>> -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. with GL.Buffers; with GL.Types.Colors; private with GL.Low_Level; package GL.Blending is pragma Preelaborate; ----------------------------------------------------------------------------- -- Blending -- ----------------------------------------------------------------------------- -- Enable blending by enabling Blend in package GL.Toggles type Blend_Factor is (Zero, One, Src_Color, One_Minus_Src_Color, Src_Alpha, One_Minus_Src_Alpha, Dst_Alpha, One_Minus_Dst_Alpha, Dst_Color, One_Minus_Dst_Color, Src_Alpha_Saturate, Constant_Color, One_Minus_Constant_Color, Constant_Alpha, One_Minus_Constant_Alpha, Src1_Alpha, Src1_Color, One_Minus_Src1_Color, One_Minus_Src1_Alpha); -- Table 17.2 of the OpenGL specification type Blend_Factors is record Src_RGB, Dst_RGB, Src_Alpha, Dst_Alpha : Blend_Factor; end record; type Equation is (Func_Add, Min, Max, Func_Subtract, Func_Reverse_Substract); type Blend_Equations is record RGB, Alpha : Equation; end record; procedure Set_Blend_Func (Factors : Blend_Factors); procedure Set_Blend_Func (Draw_Buffer : Buffers.Draw_Buffer_Index; Factors : Blend_Factors); function Blend_Func return Blend_Factors; procedure Set_Blend_Color (Value : Types.Colors.Color); function Blend_Color return Types.Colors.Color; procedure Set_Blend_Equation (Equations : Blend_Equations); procedure Set_Blend_Equation (Draw_Buffer : Buffers.Draw_Buffer_Index; Equations : Blend_Equations); function Blend_Equation return Blend_Equations; ----------------------------------------------------------------------------- -- Logical Operation -- ----------------------------------------------------------------------------- -- Enable logical operations by enabling Color_Logic_Op in -- package GL.Toggles. Enabling logical operation will disable -- blending. The logical operation has no effect if the attached -- textures of the framebuffer are floating-point or sRGB. type Logic_Op is (Clear, And_Op, And_Reverse, Copy, And_Inverted, Noop, Xor_Op, Or_Op, Nor, Equiv, Invert, Or_Reverse, Copy_Inverted, Or_Inverted, Nand, Set); -- Table 17.3 of the OpenGL specification procedure Set_Logic_Op_Mode (Value : Logic_Op); -- Set the logical operation to be applied to the color of the -- fragment and the current colors in the color buffers which -- are enabled for writing function Logic_Op_Mode return Logic_Op; private for Blend_Factor use (Zero => 0, One => 1, Src_Color => 16#0300#, One_Minus_Src_Color => 16#0301#, Src_Alpha => 16#0302#, One_Minus_Src_Alpha => 16#0303#, Dst_Alpha => 16#0304#, One_Minus_Dst_Alpha => 16#0305#, Dst_Color => 16#0306#, One_Minus_Dst_Color => 16#0307#, Src_Alpha_Saturate => 16#0308#, Constant_Color => 16#8001#, One_Minus_Constant_Color => 16#8002#, Constant_Alpha => 16#8003#, One_Minus_Constant_Alpha => 16#8004#, Src1_Alpha => 16#8589#, Src1_Color => 16#88F9#, One_Minus_Src1_Color => 16#88FA#, One_Minus_Src1_Alpha => 16#88FB#); for Blend_Factor'Size use Low_Level.Enum'Size; for Equation use (Func_Add => 16#8006#, Min => 16#8007#, Max => 16#8008#, Func_Subtract => 16#800A#, Func_Reverse_Substract => 16#800B#); for Equation'Size use Low_Level.Enum'Size; ----------------------------------------------------------------------------- for Logic_Op use (Clear => 16#1500#, And_Op => 16#1501#, And_Reverse => 16#1502#, Copy => 16#1503#, And_Inverted => 16#1504#, Noop => 16#1505#, Xor_Op => 16#1506#, Or_Op => 16#1507#, Nor => 16#1508#, Equiv => 16#1509#, Invert => 16#150A#, Or_Reverse => 16#150B#, Copy_Inverted => 16#150C#, Or_Inverted => 16#150D#, Nand => 16#150E#, Set => 16#150F#); for Logic_Op'Size use Low_Level.Enum'Size; end GL.Blending;
29,633
ada
33
ytomino/drake
source/tasking/machine-w64-mingw32/s-natint.ads
<gh_stars>10-100 pragma License (Unrestricted); -- implementation unit specialized for Windows with C; package System.Native_Interrupts is pragma Preelaborate; subtype Interrupt_Id is C.signed_int; function Is_Blocked (Interrupt : Interrupt_Id) return Boolean is (False); procedure Block (Interrupt : Interrupt_Id) with Import, Convention => Ada, External_Name => "__drake_program_error"; -- signal mask is not available in mingw-w64 procedure Unblock (Interrupt : Interrupt_Id) is null; pragma Inline (Unblock); -- [gcc-7] can not skip calling null procedure procedure Raise_Interrupt (Interrupt : Interrupt_Id); end System.Native_Interrupts;
29,634
ada
1
fabiojna02/OpenCellular
firmware/coreboot/3rdparty/libgfxinit/common/hw-gfx-gma-pch.ads
<reponame>fabiojna02/OpenCellular -- -- Copyright (C) 2015-2016 secunet Security Networks AG -- -- This program is free software; you can redistribute it and/or modify -- it under the terms of the GNU General Public License as published by -- the Free Software Foundation; either version 2 of the License, or -- (at your option) any later version. -- -- This program is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -- GNU General Public License for more details. -- with HW.GFX.GMA.Config; private package HW.GFX.GMA.PCH is type FDI_Port_Type is (FDI_A, FDI_B, FDI_C); ---------------------------------------------------------------------------- -- common to all PCH outputs PCH_TRANSCODER_SELECT_SHIFT : constant := (case Config.CPU is when Ironlake => 30, when Sandybridge | Ivybridge => 29, when others => 0); PCH_TRANSCODER_SELECT_MASK : constant := (case Config.CPU is when Ironlake => 1 * 2 ** 30, when Sandybridge | Ivybridge => 3 * 2 ** 29, when others => 0); type PCH_TRANSCODER_SELECT_Array is array (FDI_Port_Type) of Word32; PCH_TRANSCODER_SELECT : constant PCH_TRANSCODER_SELECT_Array := (FDI_A => 0 * 2 ** PCH_TRANSCODER_SELECT_SHIFT, FDI_B => 1 * 2 ** PCH_TRANSCODER_SELECT_SHIFT, FDI_C => 2 * 2 ** PCH_TRANSCODER_SELECT_SHIFT); end HW.GFX.GMA.PCH;
29,635
ada
0
cborao/Ada-P2
chat_server.adb
--PRÁCTICA 2: <NAME> (chat_server) with Ada.Text_IO; with Chat_Messages; with Lower_Layer_UDP; with Ada.Command_Line; with Client_Collections; with Ada.Strings.Unbounded; procedure Chat_Server is package ATI renames Ada.Text_IO; package CM renames Chat_Messages; package LLU renames Lower_Layer_UDP; package ACL renames Ada.Command_Line; package CC renames Client_Collections; package ASU renames Ada.Strings.Unbounded; use type CM.Message_Type; Server_EP: LLU.End_Point_Type; EP: LLU.End_Point_Type; Expired: Boolean; Port: Integer; Buffer_In: aliased LLU.Buffer_Type(1024); Buffer_Out: aliased LLU.Buffer_Type(1024); Collection_W: CC.Collection_Type; Collection_R: CC.Collection_Type; Unique: Boolean; Mess: CM.Message_Type; Nick: ASU.Unbounded_String; Comment: ASU.Unbounded_String; Nick_Server: ASU.Unbounded_String; Password: ASU.Unbounded_String; Data: ASU.Unbounded_String; Admin_EP: LLU.End_Point_Type; Admin_Pass: ASU.Unbounded_String; Shutdown: Boolean; begin -- Asignación y bindeado del Servidor Port := Integer'Value(ACL.Argument(1)); Password := ASU.To_Unbounded_String(ACL.Argument(2)); Server_EP := LLU.Build (LLU.To_IP(LLU.Get_Host_Name), Port); LLU.Bind (Server_EP); Shutdown := False; loop LLU.Reset (Buffer_In); LLU.Reset (Buffer_Out); LLU.Receive (Server_EP, Buffer_In'Access, 1000.0, Expired); if Expired then ATI.Put_Line ("Please, try again"); else Mess := CM.Message_Type'Input (Buffer_In'Access); if Mess = CM.Init then EP := LLU.End_Point_Type'Input (Buffer_In'Access); Nick := ASU.Unbounded_String'Input (Buffer_In'Access); ATI.Put("INIT received from " & ASU.To_String(Nick)); if ASU.To_String (Nick) = "reader" then Unique := False; CC.Add_Client (Collection_R, EP, Nick, Unique); else Unique := True; begin CC.Add_Client (Collection_W, EP, Nick, Unique); --Aviso de entrada al servidor Mess := CM.Server; CM.Message_Type'Output(Buffer_Out'Access, Mess); Nick_Server := ASU.To_Unbounded_String("server"); ASU.Unbounded_String'Output(Buffer_Out'Access, Nick_Server); Comment := ASU.To_Unbounded_String(ASU.To_String(Nick) & " joins the chat"); ASU.Unbounded_String'Output(Buffer_Out'Access, Comment); CC.Send_To_All (Collection_R, Buffer_Out'Access); exception when CC.Client_Collection_Error => ATI.Put (". IGNORED, nick already used"); end; end if; ATI.New_Line; LLU.Reset(Buffer_In); LLU.Reset(Buffer_Out); elsif Mess = CM.Writer then begin EP := LLU.End_Point_Type'Input (Buffer_In'Access); Comment := ASU.Unbounded_String'Input (Buffer_In'Access); Nick := CC.Search_Client (Collection_W, EP); --reenvío del mensaje a los readers Mess := CM.Server; CM.Message_Type'Output(Buffer_Out'Access, Mess); ASU.Unbounded_String'Output(Buffer_Out'Access, Nick); ASU.Unbounded_String'Output(Buffer_Out'Access, Comment); CC.Send_To_All (Collection_R, Buffer_Out'Access); Ada.Text_IO.Put_Line ("WRITER received from " & ASU.To_String (Nick) & ": " & ASU.To_String(Comment)); LLU.Reset(Buffer_In); LLU.Reset(Buffer_Out); exception when CC.Client_Collection_Error => ATI.Put_Line ("WRITER received from unknown client. IGNORED"); end; elsif Mess = CM.Collection_Request then ATI.Put_Line("LIST_REQUEST received"); Admin_EP := LLU.End_Point_Type'Input (Buffer_In'Access); Admin_Pass := ASU.Unbounded_String'Input (Buffer_In'Access); if ASU.To_String(Admin_Pass) = ASU.To_String(Password) then --Enviamos respuesta Mess := CM.Collection_Data; Data := ASU.To_Unbounded_String(CC.Collection_Image(Collection_W)); CM.Message_Type'Output (Buffer_Out'Access, Mess); ASU.Unbounded_String'Output (Buffer_Out'Access, Data); LLU.Send(Admin_EP, Buffer_Out'Access); LLU.Reset(Buffer_In); LLU.Reset(Buffer_Out); end if; elsif Mess = CM.Ban then begin Admin_Pass := ASU.Unbounded_String'Input (Buffer_In'Access); Nick := ASU.Unbounded_String'Input (Buffer_In'Access); ATI.Put_Line("BAN received for " & ASU.To_String(Nick)); if ASU.To_String(Admin_Pass) = ASU.To_String(Password) then CC.Delete_Client (Collection_W, Nick); end if; exception when CC.Client_Collection_Error => ATI.Put_Line ("BAN received for " & ASU.To_String(Nick) & ". IGNORED, nick not found"); end; elsif Mess = CM.Shutdown then ATI.Put_Line("SHUTDOWN received"); Admin_Pass := ASU.Unbounded_String'Input (Buffer_In'Access); if ASU.To_String(Admin_Pass) = ASU.To_String(Password) then Shutdown := True; end if; end if; end if; exit when Shutdown; end loop; LLU.Finalize; end Chat_Server;
29,636
ada
17
WinterAlexander/Ada-IntelliJ
src/main/resources/project-templates/aws_web_server_blocks/src/@_project_name_@-web_blocks.ads
<gh_stars>10-100 with AWS.Status; with AWS.Templates; with AWS.Services.Web_Block.Context; package @_Project_Name_@.Web_Blocks is use AWS; use AWS.Services; procedure Widget_Counter (Request : in Status.Data; Context : not null access Web_Block.Context.Object; Translations : in out Templates.Translate_Set); end @_Project_Name_@.Web_Blocks;
29,637
ada
3
jwarwick/aoc_2020
day23/src/day.ads
-- AOC 2020, Day 23 package Day is type Cup_Number is range 1..9; type Cup_Number_Mod is mod Cup_Number'Last + 1; type Cup_Index is range 0..8; type Cup_Index_Mod is mod Cup_Index'Last + 1; type Cup_Array is array(Cup_Index) of Cup_Number; function play(c : in Cup_Array; steps : in Natural) return String; function play2(c : in Cup_Array; total_cups : in Natural; steps : in Natural) return Long_Integer; end Day;
29,638
ada
0
twinbee/dekkerAda
as1.ads
--------------------------------------------------------------- -- SPECIFICATIONS FILE --------------------------------------------------------------- -- Author: <NAME> --- -- Class: CSC410 Burgess --- -- Date: 09-01-04 Modified: 9-02-04 --- -- Desc: Assignment 1:DEKKER's ALGORITHM --- -- a simple implementation of --- -- Dekker's algorithm which describes mutual exclusion for --- -- two processes (TASKS) assuming fair hardware. --- -- Dekker's algorithm as described in --- -- "Algorithms for Mutual Exclusion", <NAME> --- -- MIT PRESS Cambridge, 1974 ISBN: 0-262-18119-3 --- ---------------------------------------------------------------- PACKAGE as1 IS --package for assignment #1, dekkers algorithm PROCEDURE dekker; END as1;
29,639
ada
0
HeisenbugLtd/msg_passing
sources/mailbox_sharing.ads
------------------------------------------------------------------------ -- Copyright (C) 2010-2020 by Heisenbug Ltd. (<EMAIL>) -- -- This work is free. You can redistribute it and/or modify it under -- the terms of the Do What The Fuck You Want To Public License, -- Version 2, as published by Sam Hocevar. See the LICENSE file for -- more details. ------------------------------------------------------------------------ pragma License (Unrestricted); ------------------------------------------------------------------------ -- Mailbox_Sharing -- -- Supports import and export of mailboxes from any instantiation of -- the generic Local_Message_Passing package. -- -- This package should be viewed and used like a private child of -- Local_Message_Passing, meaning it should not be used by user code at -- all! -- ------------------------------------------------------------------------ with Ada.Real_Time; with System.Storage_Elements; package Mailbox_Sharing is package SSE renames System.Storage_Elements; -- -- Package configuration. May be adapted for different purposes. -- -- Configured maximum number of mailboxes to handle. MAX_MAILBOXES : constant Positive := 100; -- Number of significant characters in mailbox names. MAX_NAME_LENGTH : constant Positive := 31; -- -- Several exception objects to indicate erroneous situations. -- -- A mailbox with this name has already been exported. Already_Exported : exception; -- There are no more slots in the static list to export a mailbox. -- MAX_MAILBOXES should be increased. Too_Many_Mailboxes : exception; -- Raised when the maximum timeout for a connection attempt is gone -- by and the requested mailbox has not been exported yet. No_Such_Mailbox : exception; --------------------------------------------------------------------- -- Add_Mailbox -- -- Adds a mailbox to the global pool. Each mailbox name can be -- exported once only. --------------------------------------------------------------------- procedure Add_Mailbox (Mbx_Address : in System.Address; Name : in String; Msg_Size : in SSE.Storage_Count); --------------------------------------------------------------------- -- Find_Mailbox -- -- Finds a mailbox in the global pool up until the time specified. -- For a successful connection both name and message size of the -- mailbox must match. --------------------------------------------------------------------- function Find_Mailbox (Name : in String; Msg_Size : in SSE.Storage_Count; Latest : in Ada.Real_Time.Time) return System.Address; end Mailbox_Sharing;
29,640
ada
1
ShiroixD/pag_zad_2
thirdparty/glut/progs/ada/fog_procs.adb
-- -- (c) Copyright 1993,1994,1995,1996 Silicon Graphics, Inc. -- ALL RIGHTS RESERVED -- Permission to use, copy, modify, and distribute this software for -- any purpose and without fee is hereby granted, provided that the above -- copyright notice appear in all copies and that both the copyright notice -- and this permission notice appear in supporting documentation, and that -- the name of Silicon Graphics, Inc. not be used in advertising -- or publicity pertaining to distribution of the software without specific, -- written prior permission. -- -- THE MATERIAL EMBODIED ON THIS SOFTWARE IS PROVIDED TO YOU "AS-IS" -- AND WITHOUT WARRANTY OF ANY KIND, EXPRESS, IMPLIED OR OTHERWISE, -- INCLUDING WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY OR -- FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SILICON -- GRAPHICS, INC. BE LIABLE TO YOU OR ANYONE ELSE FOR ANY DIRECT, -- SPECIAL, INCIDENTAL, INDIRECT OR CONSEQUENTIAL DAMAGES OF ANY -- KIND, OR ANY DAMAGES WHATSOEVER, INCLUDING WITHOUT LIMITATION, -- LOSS OF PROFIT, LOSS OF USE, SAVINGS OR REVENUE, OR THE CLAIMS OF -- THIRD PARTIES, WHETHER OR NOT SILICON GRAPHICS, INC. HAS BEEN -- ADVISED OF THE POSSIBILITY OF SUCH LOSS, HOWEVER CAUSED AND ON -- ANY THEORY OF LIABILITY, ARISING OUT OF OR IN CONNECTION WITH THE -- POSSESSION, USE OR PERFORMANCE OF THIS SOFTWARE. -- -- US Government Users Restricted Rights -- Use, duplication, or disclosure by the Government is subject to -- restrictions set forth in FAR 52.227.19(c)(2) or subparagraph -- (c)(1)(ii) of the Rights in Technical Data and Computer Software -- clause at DFARS 252.227-7013 and/or in similar or successor -- clauses in the FAR or the DOD or NASA FAR Supplement. -- Unpublished-- rights reserved under the copyright laws of the -- United States. Contractor/manufacturer is Silicon Graphics, -- Inc., 2011 N. Shoreline Blvd., Mountain View, CA 94039-7311. -- -- OpenGL(TM) is a trademark of Silicon Graphics, Inc. -- with GL; use GL; with Glut; use Glut; with Text_IO; use Text_IO; with Unchecked_Conversion; package body Fog_Procs is package tio renames Text_IO; function FogToInt is new Unchecked_Conversion (Source => FogMode, Target => GLint); procedure CycleFog (btn: Integer; state: Integer; x, y: Integer) is begin if btn = GLUT_LEFT_BUTTON then if state = GLUT_DOWN then if fogType = GL_EXP then fogType := GL_EXP2; elsif fogType = GL_EXP2 then fogType := GL_LINEAR; glFogf (GL_FOG_START, 1.0); glFogf (GL_FOG_END, 5.0); elsif fogType = GL_LINEAR then fogType := GL_EXP; end if; -- tio.Put_Line("Fog mode is " & FogMode'IMAGE (fogType)); glFogi (GL_FOG_MODE, FogToInt (fogType)); glutPostRedisplay; end if; end if; end CycleFog; procedure Initialize is position : array (0 .. 3) of aliased GLfloat := (0.0, 3.0, 3.0, 0.0); local_view : aliased GLfloat := 0.0; fogColor : array (0 .. 3) of aliased GLfloat := (0.5, 0.5, 0.5, 1.0); begin glEnable (GL_DEPTH_TEST); glDepthFunc (GL_LESS); glLightfv (GL_LIGHT0, GL_POSITION, position (0)'Access); glLightModelfv (GL_LIGHT_MODEL_LOCAL_VIEWER, local_view'Access); glFrontFace (GL_CW); glEnable (GL_LIGHTING); glEnable (GL_LIGHT0); glEnable (GL_AUTO_NORMAL); glEnable (GL_NORMALIZE); glEnable (GL_FOG); fogType := GL_EXP; glFogi (GL_FOG_MODE, FogToInt (fogType)); glFogfv (GL_FOG_COLOR, fogColor (0)'Access); glFogf (GL_FOG_DENSITY, 0.35); glHint (GL_FOG_HINT, GL_DONT_CARE); glClearColor (0.5, 0.5, 0.5, 1.0); end Initialize; procedure RenderRedTeapot (x : GLfloat; y : GLfloat; z : GLfloat) is mat : array (0 .. 3) of aliased GLfloat; begin glPushMatrix; glTranslatef (x, y, z); mat (0) := 0.1745; mat (1) := 0.01175; mat (2) := 0.01175; mat (3) := 1.0; glMaterialfv (GL_FRONT, GL_AMBIENT, mat (0)'Access); mat (0) := 0.61424; mat (1) := 0.04136; mat (2) := 0.04136; glMaterialfv (GL_FRONT, GL_DIFFUSE, mat (0)'Access); mat (0) := 0.727811; mat (1) := 0.626959; mat (2) := 0.626959; glMaterialfv (GL_FRONT, GL_SPECULAR, mat (0)'Access); glMaterialf (GL_FRONT, GL_SHININESS, 0.6*128.0); glutSolidTeapot (1.0); glPopMatrix; end RenderRedTeapot; procedure Display is begin glClear (GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT); RenderRedTeapot (-4.0, -0.5, -1.0); RenderRedTeapot (-2.0, -0.5, -2.0); RenderRedTeapot (0.0, -0.5, -3.0); RenderRedTeapot (2.0, -0.5, -4.0); RenderRedTeapot (4.0, -0.5, -5.0); glFlush; end Display; procedure HandleReshape (w : Integer; h : Integer) is begin glViewport (0, 0, GLsizei(w), GLsizei(h)); glMatrixMode (GL_PROJECTION); glLoadIdentity; if w <= (h * 3) then glOrtho (-6.0, 6.0, GLdouble (-2.0 * (GLdouble (h) * 3.0) / GLdouble (w)), GLdouble (2.0 * (GLdouble (h) * 3.0 / GLdouble (w))), 0.0, 10.0); else glOrtho (GLdouble (-6.0 * GLdouble (w) / (GLdouble (h) * 3.0)), GLdouble (6.0 * GLdouble (w) / (GLdouble (h) * 3.0)), -2.0, 2.0, 0.0, 10.0); end if; glMatrixMode (GL_MODELVIEW); glLoadIdentity; end HandleReshape; end Fog_Procs;
29,641
ada
3
Heziode/aoc-ada-2021
10/2/src/main.adb
<filename>10/2/src/main.adb with Ada.Characters, Ada.Containers.Hashed_Maps, Ada.Containers.Vectors, Ada.Execution_Time, Ada.Long_Long_Integer_Text_IO, Ada.Real_Time, Ada.Text_IO; with Utils; procedure Main is use Ada.Execution_Time, Ada.Real_Time, Ada.Text_IO; use Utils; subtype Chunks is Character with Static_Predicate => Chunks in '(' .. '(' | '{' .. '{' | '[' .. '[' | '<' .. '<' | ')' .. ')' | '}' .. '}' | ']' .. ']' | '>' .. '>'; subtype Open_Chunks is Chunks with Static_Predicate => Open_Chunks in '(' .. '(' | '{' .. '{' | '[' .. '[' | '<' .. '<'; subtype Close_Chunks is Chunks with Static_Predicate => Close_Chunks in ')' .. ')' | '}' .. '}' | ']' .. ']' | '>' .. '>'; function ID_Hashed (Id : Open_Chunks) return Ada.Containers.Hash_Type is (Ada.Containers.Hash_Type (Open_Chunks'Pos (Id))); package Corresponding_Chunk_Maps is new Ada.Containers.Hashed_Maps (Key_Type => Open_Chunks, Element_Type => Close_Chunks, Hash => ID_Hashed, Equivalent_Keys => "="); package Chunks_Vectors is new Ada.Containers.Vectors (Natural, Chunks); subtype Long_Long_Natural is Long_Long_Integer range 0 .. Long_Long_Integer'Last; package Natural_Vectors is new Ada.Containers.Vectors (Natural, Long_Long_Natural); package Natural_Vectors_Sorting is new Natural_Vectors.Generic_Sorting; package Chunks_Vectors_Vectors is new Ada.Containers.Vectors (Natural, Chunks_Vectors.Vector, Chunks_Vectors."="); Corresponding_Chunk : Corresponding_Chunk_Maps.Map; File : File_Type; Start_Time, End_Time : CPU_Time; Execution_Duration : Time_Span; Values : Chunks_Vectors_Vectors.Vector := Chunks_Vectors_Vectors.Empty_Vector; Result : Long_Long_Natural := 0; begin Get_File (File); -- Get all values while not End_Of_File (File) loop declare use Chunks_Vectors; Str : constant String := Get_Line (File); Row : Vector := Empty_Vector; begin for Char of Str loop Row.Append (Char); end loop; Values.Append (Row); end; end loop; -- Exit the program if there is no values if Values.Is_Empty then Close_If_Open (File); Put_Line ("The input file is empty."); return; end if; Corresponding_Chunk_Maps.Insert (Corresponding_Chunk, '(', ')'); Corresponding_Chunk_Maps.Insert (Corresponding_Chunk, '{', '}'); Corresponding_Chunk_Maps.Insert (Corresponding_Chunk, '[', ']'); Corresponding_Chunk_Maps.Insert (Corresponding_Chunk, '<', '>'); -- Do the puzzle Start_Time := Ada.Execution_Time.Clock; Solve_Puzzle : declare Solutions : Natural_Vectors.Vector; begin for Row of Values loop declare use Chunks_Vectors; Open_Chunk : Vector; Current_Open_Chunk : Open_Chunks; Current_Close_Chunck : Close_Chunks; Is_Valid : Boolean := True; begin Check_Line : for Char of Row loop if Char in Open_Chunks then Open_Chunk.Append (Char); else Current_Open_Chunk := Open_Chunk.Last_Element; Open_Chunk.Delete_Last; Current_Close_Chunck := Char; if Corresponding_Chunk.Element (Current_Open_Chunk) /= Current_Close_Chunck then Is_Valid := False; exit Check_Line; end if; end if; end loop Check_Line; if Is_Valid then while not Open_Chunk.Is_Empty loop Current_Open_Chunk := Open_Chunk.Last_Element; Open_Chunk.Delete_Last; Current_Close_Chunck := Corresponding_Chunk.Element (Current_Open_Chunk); case Current_Close_Chunck is when ')' => Result := Result * 5 + 1; when ']' => Result := Result * 5 + 2; when '}' => Result := Result * 5 + 3; when '>' => Result := Result * 5 + 4; end case; end loop; Natural_Vectors.Append (Solutions, Result); Result := Long_Long_Natural'First; end if; end; end loop; Natural_Vectors_Sorting.Sort (Solutions); declare use Natural_Vectors, Ada.Containers; Index : constant Count_Type := Solutions.Length / Count_Type (2); begin Result := Solutions.Element (Integer (Index)); end; end Solve_Puzzle; End_Time := Ada.Execution_Time.Clock; Execution_Duration := End_Time - Start_Time; Put ("Result: "); Ada.Long_Long_Integer_Text_IO.Put (Item => Result, Width => 0); New_Line; Put_Line ("(Took " & Duration'Image (To_Duration (Execution_Duration) * 1_000_000) & "µs)"); Close_If_Open (File); exception when others => Close_If_Open (File); raise; end Main;
29,642
ada
1
brucegua/moocos
tools/scitools/conf/understand/ada/ada83/io_exceptions.ads
<reponame>brucegua/moocos --****************************************************************************** -- -- package IO_EXCEPTIONS -- --****************************************************************************** package IO_EXCEPTIONS is STATUS_ERROR : exception; MODE_ERROR : exception; NAME_ERROR : exception; USE_ERROR : exception; DEVICE_ERROR : exception; END_ERROR : exception; DATA_ERROR : exception; LAYOUT_ERROR : exception; end IO_EXCEPTIONS; --****************************************************************************** -- -- package AUX_IO_EXCEPTIONS -- --****************************************************************************** package AUX_IO_EXCEPTIONS is LOCK_ERROR : exception; EXISTENCE_ERROR : exception; KEY_ERROR : exception; end AUX_IO_EXCEPTIONS;
29,643
ada
4
faelys/gela-asis
source/libgela/gela-hash-crc-b32.ads
<filename>source/libgela/gela-hash-crc-b32.ads ------------------------------------------------------------------------------ -- G E L A A S I S -- -- ASIS implementation for Gela project, a portable Ada compiler -- -- http://gela.ada-ru.org -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license at the end of this file -- ------------------------------------------------------------------------------ -- Purpose: -- Name : CRC-32 [Ethernet, PKZip, AUTODIN II, FDDI] -- Width : 32 -- Poly : 0x04C11DB7 x^32 + x^26 + x^22 + x^16 + x^12 + x^11 -- + x^10 + x^8 + x^7 + x^5 + x^4 + x^2 + x^1 + 1 -- Init : 0xFFFFFFFF -- RefIn : True -- RefOut: True -- XorOut: 0xFFFFFFFF -- Check : 0xCBF43926 ("123456789") -- MaxLen: 4095 byte (32767 bit) with Ada.Streams; with Interfaces; package Gela.Hash.CRC.b32 is type CRC32 is new Interfaces.Unsigned_32; type Hasher is private; Initial_Hasher : constant Hasher; procedure Update (This : in out Hasher; Value : in String); procedure Wide_Update (This : in out Hasher; Value : in Wide_String); procedure Wide_Wide_Update (This : in out Hasher; Value : in Wide_Wide_String); procedure Update (This : in out Hasher; Value : in Ada.Streams.Stream_Element_Array); function Result (This : in Hasher) return CRC32; function Calculate (Value : in String) return CRC32; function Wide_Calculate (Value : in Wide_String) return CRC32; function Wide_Wide_Calculate (Value : in Wide_Wide_String) return CRC32; function Calculate (Value : in Ada.Streams.Stream_Element_Array) return CRC32; function To_Hash (T : in CRC32) return Hash_Type; pragma Inline (To_Hash); function Calculate (Value : in String) return Hash_Type; pragma Inline (Calculate); function Wide_Calculate (Value : in Wide_String) return Hash_Type; pragma Inline (Calculate); function Wide_Wide_Calculate (Value : in Wide_Wide_String) return Hash_Type; pragma Inline (Calculate); function Calculate (Value : in Ada.Streams.Stream_Element_Array) return Hash_Type; pragma Inline (Calculate); private type Hasher is record Length : Integer := 0; Cm_Reg : CRC32 := 16#FFFFFFFF#; end record; Initial_Hasher : constant Hasher := (Length => 0, Cm_Reg => 16#FFFFFFFF#); end Gela.Hash.CRC.b32; ------------------------------------------------------------------------------ -- Copyright (c) 2006, <NAME> -- 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. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------ ------------------------------------------------------------------------------ -- Copyright (c) 2006-2013, <NAME> -- 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 <NAME>, IE nor the names of its -- contributors may be used to endorse or promote products derived from -- this software without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------
29,644
ada
0
reznikmm/gela
source/visibility/program-visibility.adb
-- SPDX-FileCopyrightText: 2019-2021 <NAME> <<EMAIL>> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with System.Storage_Elements; with Program.Elements.Defining_Identifiers; with Program.Elements.Identifiers; with Program.Safe_Element_Visitors; package body Program.Visibility is procedure Step (Self : Region_Immediate_Visible_Iterator'Class; Cursor : in out View_Cursor); procedure Step_Use (Self : Use_Visible_Iterator'Class; Cursor : in out View_Cursor); type Allocated_Snapshot is access all Snapshot; procedure Append_Item (Self : in out Context'Class; Value : in out Entity; Region : Boolean := True; Replace : Boolean := False); -- Append new Value to the Self.Top region, updating Value.Prev by -- pointer to an entity with the same symbol (or No_Entity if no such -- entity found). If Replace = True and there is an entity with the same -- Symbol in the region, the replace it by Value and don't appent the new -- entity function Get_View (Env : not null Constant_Context_Access; Index : Entity_Reference) return View; function To_Vector (List : View_Array) return Entity_References.Vector; function Find_Direct (Self : Context'Class; Symbol : Program.Symbols.Symbol) return Entity_Reference; -- Find a symbol in Self.Directly, return No_Entity if not found package Getters is type Visitor (Env : not null Constant_Context_Access) is new Program.Safe_Element_Visitors.Safe_Element_Visitor with record Result : View; end record; overriding procedure Identifier (Self : in out Visitor; Element : not null Program.Elements.Identifiers.Identifier_Access); end Getters; package body Getters is overriding procedure Identifier (Self : in out Visitor; Element : not null Program.Elements.Identifiers.Identifier_Access) is Name : constant Program.Elements.Defining_Identifiers .Defining_Identifier_Access := Element.Corresponding_Defining_Identifier; Cursor : constant Defining_Name_Maps.Cursor := Self.Env.Xref.Find (Name.To_Defining_Name); begin if Defining_Name_Maps.Has_Element (Cursor) then Self.Result := Get_View (Self.Env, Defining_Name_Maps.Element (Cursor)); end if; end Identifier; end Getters; --------------------- -- Add_Use_Package -- --------------------- not overriding procedure Add_Use_Package (Self : in out Context'Class; Pkg : View) is Item : Entity renames Self.Data (Pkg.Index.Region).Entities (Pkg.Index.Entity_Id); Reg : constant Region_Identifier := Item.Region; begin if not Self.Data (Self.Top).Uses.Contains (Reg) then Self.Data (Self.Top).Uses.Append (Reg); end if; end Add_Use_Package; ----------------- -- Append_Item -- ----------------- procedure Append_Item (Self : in out Context'Class; Value : in out Entity; Region : Boolean := True; Replace : Boolean := False) is Prev : constant Entity_Maps.Cursor := Self.Directly.Find (Value.Symbol); Next : constant Entity_Reference := (Self.Top, Self.Data (Self.Top).Entities.Last_Index + 1); begin if Entity_Maps.Has_Element (Prev) then declare Ref : constant Entity_Reference := Entity_Maps.Element (Prev); begin if Replace and then Ref.Region = Self.Top then Value.Prev := Self.Data (Self.Top).Entities (Ref.Entity_Id).Prev; Self.Data (Self.Top).Entities.Replace_Element (Ref.Entity_Id, Value); else Value.Prev := Ref; Self.Directly.Replace_Element (Prev, Next); Self.Data (Self.Top).Entities.Append (Value); Self.Xref.Insert (Value.Name, Next); end if; end; else Value.Prev := No_Entity; Self.Directly.Insert (Value.Symbol, Next); Self.Data (Self.Top).Entities.Append (Value); Self.Xref.Insert (Value.Name, Next); end if; if Region then Self.Data.Append ((Enclosing => Self.Top, Entities => Entity_Vectors.Empty_Vector, Uses => Region_Id_Vectors.Empty_Vector)); Self.Top := Self.Data.Last_Index; end if; end Append_Item; --------------- -- Component -- --------------- function Component (Self : View) return View is Type_Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); begin return Get_View (Self.Env, Type_Item.Component); end Component; ----------------------- -- Create_Array_Type -- ----------------------- not overriding procedure Create_Array_Type (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name; Indexes : View_Array; Component : View) is Value : Entity := (Kind => Array_Type_View, Symbol => Symbol, Name => Name, Prev => <>, Indexes => To_Vector (Indexes), Component => Component.Index, Region => Self.Data.Last_Index + 1); begin Self.Append_Item (Value); end Create_Array_Type; ------------------------------ -- Create_Character_Literal -- ------------------------------ not overriding procedure Create_Character_Literal (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name; Enumeration_Type : View) is Value : Entity := (Kind => Character_Literal_View, Symbol => Symbol, Name => Name, Prev => <>, Character_Type => Enumeration_Type.Index.Entity_Id); begin pragma Assert (Self.Top = Enumeration_Type.Index.Region); Self.Append_Item (Value, Region => False); declare Type_Item : Entity renames Self.Data (Enumeration_Type.Index.Region).Entities (Enumeration_Type.Index.Entity_Id); begin Type_Item.Last_Literal := Self.Data (Self.Top).Entities.Last_Index; Type_Item.Is_Character_Type := True; end; end Create_Character_Literal; ------------------------------ -- Create_Character_Literal -- ------------------------------ not overriding procedure Create_Character_Literal (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name; Meta_Character : Meta_Character_Literal_Kind; Enumeration_Type : View) is pragma Unreferenced (Meta_Character); begin Self.Create_Character_Literal (Symbol, Name, Enumeration_Type); end Create_Character_Literal; ---------------------- -- Create_Component -- ---------------------- procedure Create_Component (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name; Has_Default : Boolean) is Value : Entity := (Kind => Component_View, Symbol => Symbol, Name => Name, Prev => <>, Object_Def => (1, 1), Mode => <>, Has_Default => Has_Default, Region => Self.Data.Last_Index + 1); begin Self.Append_Item (Value); end Create_Component; -------------------------- -- Create_Empty_Context -- -------------------------- procedure Create_Empty_Context (Self : in out Context'Class) is begin Self.Data.Clear; -- Reserve the very first region to be always empty Self.Data.Append ((Enclosing => 0, Entities => Entity_Vectors.Empty_Vector, Uses => Region_Id_Vectors.Empty_Vector)); -- Append a root region Self.Data.Append ((Enclosing => 0, Entities => Entity_Vectors.Empty_Vector, Uses => Region_Id_Vectors.Empty_Vector)); Self.Top := Self.Data.Last_Index; end Create_Empty_Context; -------------------------------- -- Create_Enumeration_Literal -- -------------------------------- not overriding procedure Create_Enumeration_Literal (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name; Enumeration_Type : View) is Value : Entity := (Kind => Enumeration_Literal_View, Symbol => Symbol, Name => Name, Prev => <>, Enumeration_Type => Enumeration_Type.Index.Entity_Id); begin pragma Assert (Self.Top = Enumeration_Type.Index.Region); Self.Append_Item (Value, Region => False); declare Type_Item : Entity renames Self.Data (Enumeration_Type.Index.Region).Entities (Enumeration_Type.Index.Entity_Id); begin Type_Item.Last_Literal := Self.Data (Self.Top).Entities.Last_Index; end; end Create_Enumeration_Literal; ----------------------------- -- Create_Enumeration_Type -- ----------------------------- procedure Create_Enumeration_Type (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name) is Last : constant Entity_Identifier'Base := Self.Data (Self.Top).Entities.Last_Index; Value : Entity := (Kind => Enumeration_Type_View, Symbol => Symbol, Name => Name, Prev => <>, Is_Character_Type => False, First_Literal => Last + 2, Last_Literal => Last + 2); begin Self.Append_Item (Value, Region => False); end Create_Enumeration_Type; ---------------------- -- Create_Exception -- ---------------------- procedure Create_Exception (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name) is Value : Entity := (Kind => Exception_View, Symbol => Symbol, Name => Name, Prev => <>); begin Self.Append_Item (Value, Region => False); end Create_Exception; ----------------------------- -- Create_Float_Point_Type -- ----------------------------- procedure Create_Float_Point_Type (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name) is Value : Entity := (Kind => Float_Point_Type_View, Symbol => Symbol, Name => Name, Prev => <>); begin Self.Append_Item (Value); end Create_Float_Point_Type; --------------------- -- Create_Function -- --------------------- procedure Create_Function (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name) is Value : Entity := (Kind => Function_View, Symbol => Symbol, Name => Name, Prev => <>, Region => Self.Data.Last_Index + 1, Result_Def => (1, 1)); begin Self.Append_Item (Value); end Create_Function; -------------------------- -- Create_Implicit_Type -- -------------------------- procedure Create_Implicit_Type (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name) is Value : Entity := (Kind => Implicit_Type_View, Symbol => Symbol, Name => Name, Prev => <>); begin Self.Append_Item (Value, Region => False); end Create_Implicit_Type; ---------------------------- -- Create_Incomplete_Type -- ---------------------------- procedure Create_Incomplete_Type (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name) is Value : Entity := (Kind => Incomplete_Type_View, Symbol => Symbol, Name => Name, Prev => <>, Region => Self.Data.Last_Index + 1); begin Self.Append_Item (Value); end Create_Incomplete_Type; ------------------------- -- Create_Modular_Type -- ------------------------- procedure Create_Modular_Type (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name) is Value : Entity := (Kind => Modular_Type_View, Symbol => Symbol, Name => Name, Prev => <>); begin Self.Append_Item (Value); end Create_Modular_Type; ------------------------------- -- Create_Object_Access_Type -- ------------------------------- procedure Create_Object_Access_Type (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name; Designated : View) is Value : Entity := (Kind => Object_Access_Type_View, Symbol => Symbol, Name => Name, Prev => <>, Designated_Type => Designated.Index); begin Self.Append_Item (Value, Region => False); end Create_Object_Access_Type; -------------------- -- Create_Package -- -------------------- procedure Create_Package (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name) is Value : Entity := (Kind => Package_View, Symbol => Symbol, Name => Name, Prev => <>, Region => Self.Data.Last_Index + 1); begin Self.Append_Item (Value); end Create_Package; ---------------------- -- Create_Parameter -- ---------------------- not overriding procedure Create_Parameter (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name; Mode : Parameter_Mode; Has_Default : Boolean) is Value : Entity := (Kind => Parameter_View, Symbol => Symbol, Name => Name, Prev => <>, Object_Def => (1, 1), Mode => Mode, Has_Default => Has_Default, Region => Self.Data.Last_Index + 1); begin Self.Append_Item (Value); end Create_Parameter; ---------------------- -- Create_Procedure -- ---------------------- procedure Create_Procedure (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name) is Value : Entity := (Kind => Procedure_View, Symbol => Symbol, Name => Name, Prev => <>, Region => Self.Data.Last_Index + 1); begin Self.Append_Item (Value); end Create_Procedure; ------------------------ -- Create_Record_Type -- ------------------------ procedure Create_Record_Type (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name) is Value : Entity := (Kind => Record_Type_View, Symbol => Symbol, Name => Name, Prev => <>, Region => Self.Data.Last_Index + 1); begin Self.Append_Item (Value, Replace => True); end Create_Record_Type; -------------------------------- -- Create_Signed_Integer_Type -- -------------------------------- procedure Create_Signed_Integer_Type (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name) is Value : Entity := (Kind => Signed_Integer_Type_View, Symbol => Symbol, Name => Name, Prev => <>); begin Self.Append_Item (Value); end Create_Signed_Integer_Type; --------------------- -- Create_Snapshot -- --------------------- function Create_Snapshot (Self : in out Context'Class) return Snapshot_Access is Top : Region renames Self.Data (Self.Top); Result : constant Allocated_Snapshot := new Snapshot'(Region_Id => Self.Top, Entities => Top.Entities, Uses => Top.Uses); begin return Snapshot_Access (Result); end Create_Snapshot; -------------------- -- Create_Subtype -- -------------------- not overriding procedure Create_Subtype (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name; Subtype_Mark : View; Has_Constraint : Boolean) is Value : Entity := (Kind => Subtype_View, Symbol => Symbol, Name => Name, Prev => <>, Subtype_Mark => Subtype_Mark.Index, Has_Constraint => Has_Constraint); begin Self.Append_Item (Value); end Create_Subtype; --------------------- -- Create_Variable -- --------------------- procedure Create_Variable (Self : in out Context'Class; Symbol : Program.Visibility.Symbol; Name : Defining_Name) is Value : Entity := (Kind => Variable_View, Symbol => Symbol, Name => Name, Prev => <>, Object_Def => (1, 1), Mode => <>, Has_Default => <>, Region => Self.Data.Last_Index + 1); begin Self.Append_Item (Value); end Create_Variable; -------------------- -- Enter_Snapshot -- -------------------- not overriding procedure Enter_Snapshot (Self : in out Context'Class; Snapshot : not null Snapshot_Access) is begin if Snapshot.Entities.Is_Empty then Self.Data.Append ((Enclosing => Self.Data.Last_Index, Entities => Entity_Vectors.Empty_Vector, Uses => Region_Id_Vectors.Empty_Vector)); Self.Top := Self.Data.Last_Index; else Self.Top := Snapshot.Region_Id; end if; Self.Restore_Snapshot (Snapshot); end Enter_Snapshot; -------------------------- -- Enumeration_Literals -- -------------------------- function Enumeration_Literals (Self : View) return View_Array is Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); Index : Entity_Identifier := Item.First_Literal; Count : constant Natural := Natural (Item.Last_Literal - Index) + 1; begin return Result : View_Array (1 .. Count) do for X of Result loop X := Get_View (Self.Env, (Self.Index.Region, Index)); Index := Index + 1; end loop; end return; end Enumeration_Literals; ---------------------- -- Enumeration_Type -- ---------------------- function Enumeration_Type (Self : View) return View is Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); begin return Get_View (Self.Env, (Self.Index.Region, Item.Enumeration_Type)); end Enumeration_Type; --------------------- -- Designated_Type -- --------------------- function Designated_Type (Self : View) return View is Value : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); begin return Get_View (Self.Env, Value.Designated_Type); end Designated_Type; ---------------------- -- Directly_Visible -- ---------------------- function Directly_Visible (Self : Context'Class; Symbol : Program.Visibility.Symbol) return Directly_Visible_Name_Iterator is begin return (Immediate => (Context => Self'Unchecked_Access, First => Self.Find_Direct (Symbol)), Uses => (Context => Self'Unchecked_Access, Region => Self.Top, Symbol => Symbol)); end Directly_Visible; ----------------- -- Find_Direct -- ----------------- function Find_Direct (Self : Context'Class; Symbol : Program.Symbols.Symbol) return Entity_Reference is Prev : constant Entity_Maps.Cursor := Self.Directly.Find (Symbol); begin if Entity_Maps.Has_Element (Prev) then return Entity_Maps.Element (Prev); else return No_Entity; end if; end Find_Direct; ----------- -- First -- ----------- overriding function First (Self : Region_Immediate_Visible_Iterator) return View_Cursor is begin return Result : View_Cursor := (Self.Region, 1, others => <>) do Self.Step (Result); end return; end First; ----------- -- First -- ----------- overriding function First (Self : Context_Immediate_Visible_Iterator) return View_Cursor is begin if Self.First = No_Entity then return (Region => Self.First.Region, Entity => 0, Use_Id => Positive'Last, View => <>); else return (Region => Self.First.Region, Entity => Self.First.Entity_Id, Use_Id => Positive'Last, View => Get_View (Self.Context, Self.First)); end if; end First; ----------- -- First -- ----------- overriding function First (Self : Use_Visible_Iterator) return View_Cursor is begin return Result : View_Cursor := (Self.Region, 1, 1, View => <>) do Self.Step_Use (Result); end return; end First; ----------- -- First -- ----------- overriding function First (Self : Directly_Visible_Name_Iterator) return View_Cursor is begin return Result : View_Cursor := First (Self.Immediate) do if not Has_Element (Result) then Result := Self.Uses.First; end if; end return; end First; ------------------- -- First_Subtype -- ------------------- function First_Subtype (Self : View) return View is Result : View := Self; begin while Result.Kind = Subtype_View loop Result := Subtype_Mark (Result); end loop; return Result; end First_Subtype; ------------------- -- Get_Name_View -- ------------------- function Get_Name_View (Self : Context'Class; Name : not null Program.Elements.Element_Access) return View is Visitor : Getters.Visitor (Self'Unchecked_Access); begin Visitor.Visit (Name); return Visitor.Result; end Get_Name_View; -------------- -- Get_View -- -------------- function Get_View (Env : not null Constant_Context_Access; Index : Entity_Reference) return View is Value : Entity renames Env.Data (Index.Region).Entities (Index.Entity_Id); begin return (Value.Kind, Env, Index); end Get_View; -------------- -- Get_View -- -------------- function Get_View (Self : View_Cursor) return View is begin return Self.View; end Get_View; -------------------- -- Has_Constraint -- -------------------- function Has_Constraint (Self : View) return Boolean is Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); begin return Item.Has_Constraint; end Has_Constraint; ----------------- -- Has_Default -- ----------------- function Has_Default (Self : View) return Boolean is Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); begin return Item.Has_Default; end Has_Default; ----------------- -- Has_Element -- ----------------- function Has_Element (Self : View_Cursor) return Boolean is begin return Self.Entity > 0; end Has_Element; ---------------- -- Has_Region -- ---------------- function Has_Region (Self : View) return Boolean is begin return Self.Kind in Has_Region_Kind; end Has_Region; ---------- -- Hash -- ---------- function Hash (Value : Program.Elements.Defining_Names.Defining_Name_Access) return Ada.Containers.Hash_Type is Addr : constant System.Storage_Elements.Integer_Address := System.Storage_Elements.To_Integer (Value.all'Address); begin return Ada.Containers.Hash_Type'Mod (Addr); end Hash; ----------------------- -- Immediate_Visible -- ----------------------- function Immediate_Visible (Self : View; Symbol : Program.Visibility.Symbol) return View_Iterator is Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); begin return Region_Immediate_Visible_Iterator' (Context => Self.Env, Region => Item.Region, Symbol => Symbol); end Immediate_Visible; ----------------------- -- Immediate_Visible -- ----------------------- function Immediate_Visible (Self : Context'Class; Symbol : Program.Visibility.Symbol) return View_Iterator is begin return Context_Immediate_Visible_Iterator' (Context => Self'Unchecked_Access, First => Self.Find_Direct (Symbol)); end Immediate_Visible; ------------- -- Indexes -- ------------- function Indexes (Self : View) return View_Array is Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); Last : Positive := 1; begin return Result : View_Array (1 .. Item.Indexes.Last_Index) do for J of Item.Indexes loop Result (Last) := Get_View (Self.Env, J); Last := Last + 1; end loop; end return; end Indexes; ----------------------- -- Is_Character_Type -- ----------------------- function Is_Character_Type (Self : View) return Boolean is Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); begin return Item.Is_Character_Type; end Is_Character_Type; ---------------------- -- Is_Expected_Type -- ---------------------- function Is_Expected_Type (Self, Expected : View) return Boolean is begin return Self = Expected; end Is_Expected_Type; ----------------- -- Latest_View -- ----------------- function Latest_View (Self : Context'Class) return View is Top : Region renames Self.Data (Self.Top); Index : Entity_Reference; begin if Top.Entities.Is_Empty then Index := (Top.Enclosing, Self.Data (Top.Enclosing).Entities.Last_Index); else Index := (Self.Top, Top.Entities.Last_Index); end if; return Get_View (Self'Unchecked_Access, Index); end Latest_View; ------------------------------ -- Leave_Declarative_Region -- ------------------------------ procedure Leave_Declarative_Region (Self : in out Context'Class) is Enclosing : constant Region_Identifier'Base := Self.Data (Self.Top).Enclosing; begin for E of reverse Self.Data (Self.Top).Entities loop if E.Prev = No_Entity then Self.Directly.Delete (E.Symbol); else Self.Directly.Replace (E.Symbol, E.Prev); end if; end loop; if Self.Data.Last_Index = Self.Top and then Self.Data (Self.Top).Entities.Is_Empty then -- Delete an unused (without any entity) region Self.Data.Delete_Last; declare Reg : Region renames Self.Data (Enclosing); Item : Entity renames Reg.Entities (Reg.Entities.Last_Index); begin if Item.Kind in Has_Region_Kind and then Item.Region = Self.Top then Item.Region := 1; -- Reserver always empty region end if; end; end if; Self.Top := Enclosing; end Leave_Declarative_Region; ---------- -- Mode -- ---------- function Mode (Self : View) return Parameter_Mode is Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); begin return Item.Mode; end Mode; ---------- -- Name -- ---------- function Name (Self : View) return Defining_Name is Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); begin return Item.Name; end Name; ---------- -- Next -- ---------- overriding function Next (Self : Region_Immediate_Visible_Iterator; Position : View_Cursor) return View_Cursor is begin return Result : View_Cursor := (Position.Region, Position.Entity + 1, others => <>) do Self.Step (Result); end return; end Next; ---------- -- Next -- ---------- overriding function Next (Self : Context_Immediate_Visible_Iterator; Position : View_Cursor) return View_Cursor is Prev : constant Entity_Reference := Self.Context.Data (Position.Region).Entities (Position.Entity).Prev; begin if Prev = No_Entity then return (Region => Self.First.Region, Entity => 0, Use_Id => 1, View => <>); else return (Region => Self.First.Region, Entity => Self.First.Entity_Id, Use_Id => 1, View => Get_View (Self.Context, Self.First)); end if; end Next; ---------- -- Next -- ---------- overriding function Next (Self : Use_Visible_Iterator; Position : View_Cursor) return View_Cursor is begin return Result : View_Cursor := (Position.Region, Position.Entity + 1, Position.Use_Id, View => <>) do Self.Step_Use (Result); end return; end Next; ---------- -- Next -- ---------- overriding function Next (Self : Directly_Visible_Name_Iterator; Position : View_Cursor) return View_Cursor is Result : View_Cursor; begin if Position.Use_Id = Positive'Last then Result := Self.Immediate.Next (Position); if Has_Element (Result) then return Result; else return Self.Uses.First; end if; end if; return Self.Uses.Next (Position); end Next; ---------------- -- Parameters -- ---------------- function Parameters (Self : View) return View_Array is Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); Reg : Region renames Self.Env.Data (Item.Region); Last : Natural := 0; begin for J in 1 .. Reg.Entities.Last_Index loop if Reg.Entities (J).Kind = Parameter_View then Last := Last + 1; else exit; end if; end loop; return Result : View_Array (1 .. Last) do for J in Result'Range loop Result (J) := Get_View (Self.Env, (Item.Region, Entity_Identifier (J))); end loop; end return; end Parameters; ------------------ -- Region_Items -- ------------------ function Region_Items (Self : View) return View_Array is Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); Reg : Region renames Self.Env.Data (Item.Region); begin return Result : View_Array (1 .. Natural (Reg.Entities.Last_Index)) do for J in Result'Range loop Result (J) := Get_View (Self.Env, (Item.Region, Entity_Identifier (J))); end loop; end return; end Region_Items; ---------------------- -- Restore_Snapshot -- ---------------------- not overriding procedure Restore_Snapshot (Self : in out Context'Class; Snapshot : not null Snapshot_Access) is use type Program.Visibility.Symbol; Top : Region renames Self.Data (Self.Top); Last_Common : constant Entity_Identifier := Entity_Identifier'Min (Top.Entities.Last_Index, Snapshot.Entities.Last_Index); begin -- Ignore Snapshot.Region_Id if empty, because we can recreate an empty -- region with a differect id. pragma Assert (Snapshot.Entities.Is_Empty or Self.Top = Snapshot.Region_Id); -- We expect all common entities have the same symbols. Reuse Prev for J in 1 .. Last_Common loop pragma Assert (Top.Entities (J).Symbol = Snapshot.Entities (J).Symbol); Snapshot.Entities (J).Prev := Top.Entities (J).Prev; end loop; -- Clean up old entities outside of common slice if Top.Entities.Last_Index > Last_Common then for Cursor in reverse Top.Entities.Iterate (Start => Top.Entities.To_Cursor (Last_Common + 1)) loop declare Value : Entity renames Top.Entities (Cursor); begin if Value.Prev = No_Entity then Self.Directly.Delete (Value.Symbol); else Self.Directly.Replace (Value.Symbol, Value.Prev); end if; end; end loop; end if; -- Update new entities outside of common slice if Snapshot.Entities.Last_Index > Last_Common then for Cursor in Snapshot.Entities.Iterate (Start => Snapshot.Entities.To_Cursor (Last_Common + 1)) loop declare Value : Entity renames Snapshot.Entities (Cursor); Next : constant Entity_Reference := (Self.Top, Entity_Vectors.To_Index (Cursor)); Prev : constant Entity_Maps.Cursor := Self.Directly.Find (Value.Symbol); begin if Entity_Maps.Has_Element (Prev) then Value.Prev := Entity_Maps.Element (Prev); Self.Directly.Replace_Element (Prev, Next); else Value.Prev := No_Entity; Self.Directly.Insert (Value.Symbol, Next); end if; end; end loop; end if; Top.Entities := Snapshot.Entities; Top.Uses := Snapshot.Uses; for J in 1 .. Snapshot.Entities.Last_Index loop Self.Xref.Include (Snapshot.Entities (J).Name, (Self.Top, J)); end loop; end Restore_Snapshot; ------------ -- Result -- ------------ function Result (Self : View) return View is Item : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); begin return Get_View (Self.Env, Item.Result_Def); end Result; ------------------------ -- Set_Parameter_Type -- ------------------------ not overriding procedure Set_Object_Type (Self : in out Context'Class; Definition : View) is Top : Region renames Self.Data (Self.Top); Last : Entity renames Top.Entities (Top.Entities.Last_Index); begin pragma Assert (Last.Kind in Object_View); Last.Object_Def := Definition.Index; end Set_Object_Type; --------------------- -- Set_Result_Type -- --------------------- procedure Set_Result_Type (Self : in out Context'Class; Definition : View) is Top : Region renames Self.Data (Self.Top); Enclosing : Region renames Self.Data (Top.Enclosing); Last : Entity renames Enclosing.Entities (Enclosing.Entities.Last_Index); begin pragma Assert (Last.Kind = Function_View); Last.Result_Def := Definition.Index; end Set_Result_Type; ---------- -- Step -- ---------- procedure Step (Self : Region_Immediate_Visible_Iterator'Class; Cursor : in out View_Cursor) is use type Program.Symbols.Symbol; Value : Program.Visibility.Region renames Self.Context.Data (Cursor.Region); begin for Index in Cursor.Entity .. Value.Entities.Last_Index loop if Value.Entities (Index).Symbol = Self.Symbol then Cursor := (Cursor.Region, Index, 1, Get_View (Self.Context, (Cursor.Region, Index))); return; end if; end loop; Cursor.Entity := 0; end Step; -------------- -- Step_Use -- -------------- procedure Step_Use (Self : Use_Visible_Iterator'Class; Cursor : in out View_Cursor) is Next : Region_Identifier'Base := Cursor.Region; begin loop -- Over each nested region declare Top : Region renames Self.Context.Data (Next); begin if Cursor.Use_Id <= Top.Uses.Last_Index then -- have use_cl Cursor.Region := Top.Uses (Cursor.Use_Id); -- rewrite reg Self.Step (Cursor); else Cursor.Entity := 0; -- clear cursor end if; if Has_Element (Cursor) then Cursor.Region := Next; -- restore region return; elsif Cursor.Use_Id >= Top.Uses.Last_Index then Next := Self.Context.Data (Next).Enclosing; exit when Next = 0; Cursor.Use_Id := 1; else Cursor.Use_Id := Cursor.Use_Id + 1; end if; Cursor.Entity := 1; end; end loop; Cursor := (Self.Region, Entity => 0, others => <>); end Step_Use; ------------------ -- Subtype_Mark -- ------------------ function Subtype_Mark (Self : View) return View is Value : Entity renames Self.Env.Data (Self.Index.Region).Entities (Self.Index.Entity_Id); begin case Value.Kind is when Subtype_View => return Get_View (Self.Env, Value.Subtype_Mark); when Object_View => return Get_View (Self.Env, Value.Object_Def); when others => raise Constraint_Error; end case; end Subtype_Mark; --------------- -- To_Vector -- --------------- function To_Vector (List : View_Array) return Entity_References.Vector is begin return Result : Entity_References.Vector do Result.Reserve_Capacity (List'Length); for View of List loop Result.Append (View.Index); end loop; end return; end To_Vector; ------------- -- Type_Of -- ------------- function Type_Of (Self : View) return View is begin case Self.Kind is when Enumeration_Literal_View | Character_Literal_View => return Enumeration_Type (Self); when Object_View => return Subtype_Mark (Self); when others => raise Program_Error; end case; end Type_Of; ----------------- -- Use_Visible -- ----------------- function Use_Visible (Self : Context'Class; Symbol : Program.Visibility.Symbol) return View_Iterator is begin return Use_Visible_Iterator' (Context => Self'Unchecked_Access, Region => Self.Top, Symbol => Symbol); end Use_Visible; end Program.Visibility;
29,645
ada
24
svn2github/matreshka
source/amf/uml/amf-internals-factories-primitive_types_factories.adb
<reponame>svn2github/matreshka ------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Ada Modeling Framework -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012, <NAME> <<EMAIL>> -- -- 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.Internals.Elements; with AMF.Internals.Helpers; with AMF.Internals.Links; with AMF.Internals.Tables.Primitive_Types_Metamodel; package body AMF.Internals.Factories.Primitive_Types_Factories is function Convert_Boolean_To_String (Value : League.Holders.Holder) return League.Strings.Universal_String is separate; function Create_Boolean_From_String (Image : League.Strings.Universal_String) return League.Holders.Holder is separate; function Convert_Integer_To_String (Value : League.Holders.Holder) return League.Strings.Universal_String is separate; function Create_Integer_From_String (Image : League.Strings.Universal_String) return League.Holders.Holder is separate; function Convert_Real_To_String (Value : League.Holders.Holder) return League.Strings.Universal_String is separate; function Create_Real_From_String (Image : League.Strings.Universal_String) return League.Holders.Holder is separate; function Convert_String_To_String (Value : League.Holders.Holder) return League.Strings.Universal_String is separate; function Create_String_From_String (Image : League.Strings.Universal_String) return League.Holders.Holder is separate; function Convert_Unlimited_Natural_To_String (Value : League.Holders.Holder) return League.Strings.Universal_String is separate; function Create_Unlimited_Natural_From_String (Image : League.Strings.Universal_String) return League.Holders.Holder is separate; ----------------- -- Constructor -- ----------------- function Constructor (Extent : AMF.Internals.AMF_Extent) return not null AMF.Factories.Factory_Access is begin return new Primitive_Types_Factory'(Extent => Extent); end Constructor; ----------------------- -- Convert_To_String -- ----------------------- overriding function Convert_To_String (Self : not null access Primitive_Types_Factory; Data_Type : not null access AMF.CMOF.Data_Types.CMOF_Data_Type'Class; Value : League.Holders.Holder) return League.Strings.Universal_String is pragma Unreferenced (Self); DT : constant AMF.Internals.CMOF_Element := AMF.Internals.Elements.Element_Base'Class (Data_Type.all).Element; begin if DT = AMF.Internals.Tables.Primitive_Types_Metamodel.MC_Primitive_Types_Boolean then return Convert_Boolean_To_String (Value); elsif DT = AMF.Internals.Tables.Primitive_Types_Metamodel.MC_Primitive_Types_Integer then return Convert_Integer_To_String (Value); elsif DT = AMF.Internals.Tables.Primitive_Types_Metamodel.MC_Primitive_Types_Real then return Convert_Real_To_String (Value); elsif DT = AMF.Internals.Tables.Primitive_Types_Metamodel.MC_Primitive_Types_String then return Convert_String_To_String (Value); elsif DT = AMF.Internals.Tables.Primitive_Types_Metamodel.MC_Primitive_Types_Unlimited_Natural then return Convert_Unlimited_Natural_To_String (Value); else raise Program_Error; end if; end Convert_To_String; ------------ -- Create -- ------------ overriding function Create (Self : not null access Primitive_Types_Factory; Meta_Class : not null access AMF.CMOF.Classes.CMOF_Class'Class) return not null AMF.Elements.Element_Access is begin raise Program_Error; return null; end Create; ------------------------ -- Create_From_String -- ------------------------ overriding function Create_From_String (Self : not null access Primitive_Types_Factory; Data_Type : not null access AMF.CMOF.Data_Types.CMOF_Data_Type'Class; Image : League.Strings.Universal_String) return League.Holders.Holder is pragma Unreferenced (Self); use type League.Strings.Universal_String; DT : constant AMF.Internals.CMOF_Element := AMF.Internals.Elements.Element_Base'Class (Data_Type.all).Element; begin if DT = AMF.Internals.Tables.Primitive_Types_Metamodel.MC_Primitive_Types_Boolean then return Create_Boolean_From_String (Image); elsif DT = AMF.Internals.Tables.Primitive_Types_Metamodel.MC_Primitive_Types_Integer then return Create_Integer_From_String (Image); elsif DT = AMF.Internals.Tables.Primitive_Types_Metamodel.MC_Primitive_Types_Real then return Create_Real_From_String (Image); elsif DT = AMF.Internals.Tables.Primitive_Types_Metamodel.MC_Primitive_Types_String then return Create_String_From_String (Image); elsif DT = AMF.Internals.Tables.Primitive_Types_Metamodel.MC_Primitive_Types_Unlimited_Natural then return Create_Unlimited_Natural_From_String (Image); else raise Program_Error; end if; end Create_From_String; ----------------- -- Create_Link -- ----------------- overriding function Create_Link (Self : not null access Primitive_Types_Factory; Association : not null access AMF.CMOF.Associations.CMOF_Association'Class; First_Element : not null AMF.Elements.Element_Access; Second_Element : not null AMF.Elements.Element_Access) return not null AMF.Links.Link_Access is pragma Unreferenced (Self); begin return AMF.Internals.Links.Proxy (AMF.Internals.Links.Create_Link (AMF.Internals.Elements.Element_Base'Class (Association.all).Element, AMF.Internals.Helpers.To_Element (First_Element), AMF.Internals.Helpers.To_Element (Second_Element))); end Create_Link; ----------------- -- Get_Package -- ----------------- overriding function Get_Package (Self : not null access constant Primitive_Types_Factory) return AMF.CMOF.Packages.Collections.Set_Of_CMOF_Package is pragma Unreferenced (Self); begin return Result : AMF.CMOF.Packages.Collections.Set_Of_CMOF_Package do Result.Add (Get_Package); end return; end Get_Package; ----------------- -- Get_Package -- ----------------- function Get_Package return not null AMF.CMOF.Packages.CMOF_Package_Access is begin return AMF.CMOF.Packages.CMOF_Package_Access (AMF.Internals.Helpers.To_Element (AMF.Internals.Tables.Primitive_Types_Metamodel.MM_Primitive_Types_Primitive_Types)); end Get_Package; end AMF.Internals.Factories.Primitive_Types_Factories;
29,646
ada
0
dpr1005/Tiempo-Real-Ejercicios
Practica 02/P02_Lista_Alumnos/src/lista_alumnos.adb
<reponame>dpr1005/Tiempo-Real-Ejercicios<gh_stars>0 with Menu,Alumnos,Clases; procedure Lista_Alumnos is Tercero_B : Clases.Clase; Eleccion : Menu.Opcion; Alu : Alumnos.Alumno; Num : Clases.Num_Alumno; begin loop Menu.Pide_Opcion (Eleccion); case Eleccion is when Menu.Insertar => if Clases.Llena(Tercero_B) then Menu.Mensaje_Error("No caben mas alumnos"); else Alumnos.Lee(Alu); Clases.Inserta_Alumno(Alu,Tercero_B); end if; when Menu.Mirar => Menu.Lee_Num_Alumno(Num); if Num>Clases.Numero_Alumnos(Tercero_B) then Menu.Mensaje_Error("Alumno no existe"); else Alu:=Clases.Dame_Alumno(Num,Tercero_B); Alumnos.Escribe(Alu); end if; when Menu.Salir => exit; end case; end loop; end Lista_Alumnos;
29,647
ada
0
Lucretia/old_nehe_ada95
thirdparty/adasdl/thin/adasdl/AdaSDL/binding/sdl-timer.ads
<filename>thirdparty/adasdl/thin/adasdl/AdaSDL/binding/sdl-timer.ads -- ----------------------------------------------------------------- -- -- AdaSDL -- -- Binding to Simple Direct Media Layer -- -- Copyright (C) 2001 A.M.F.Vargas -- -- <NAME> -- -- Ponta Delgada - Azores - Portugal -- -- http://www.adapower.net/~avargas -- -- E-mail: <EMAIL> -- -- ----------------------------------------------------------------- -- -- -- -- This library is free software; you can redistribute it and/or -- -- modify it under the terms of the GNU General Public -- -- License as published by the Free Software Foundation; either -- -- version 2 of the License, or (at your option) any later version. -- -- -- -- This library is distributed in the hope that it will be useful, -- -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- -- General Public License for more details. -- -- -- -- You should have received a copy of the GNU General Public -- -- License along with this library; if not, write to the -- -- Free Software Foundation, Inc., 59 Temple Place - Suite 330, -- -- Boston, MA 02111-1307, USA. -- -- -- -- As a special exception, if other files instantiate generics from -- -- this unit, or you link this unit with other files to produce an -- -- executable, this unit does not by itself cause the resulting -- -- executable to be covered by the GNU General Public License. This -- -- exception does not however invalidate any other reasons why the -- -- executable file might be covered by the GNU Public License. -- -- ----------------------------------------------------------------- -- -- **************************************************************** -- -- This is an Ada binding to SDL ( Simple DirectMedia Layer from -- -- Sam Lantinga - www.libsld.org ) -- -- **************************************************************** -- -- In order to help the Ada programmer, the comments in this file -- -- are, in great extent, a direct copy of the original text in the -- -- SDL header files. -- -- **************************************************************** -- with System; with SDL.Types; use SDL.Types; package SDL.Timer is -- This is the OS scheduler timeslice, in milliseconds TIMESLICE : constant := 10; -- This is the maximum resolution of the SDL timer on all platforms RESOLUTION : constant := 10; -- Experimentally determined -- Get the number of milliseconds since the SDL library initialization. -- Note that this value wraps if the program runs for more than ~49 days. function GetTicks return Uint32; pragma Import (C, GetTicks, "SDL_GetTicks"); -- Wait a specified number of milliseconds before returning procedure SDL_Delay (ms : Uint32); pragma Import (C, SDL_Delay, "SDL_Delay"); -- Function pointer prototype for the timer callback function type TimerCallback_ptr is access function (interval : Uint32) return Uint32; pragma Convention (C, TimerCallback_ptr); -- Set a callback to run after the specified number of milliseconds has -- elapsed. The callback function is passed the current timer interval -- and returns the next timer interval. If the returned value is the -- same as the one passed in, the periodic alarm continues, otherwise a -- new alarm is scheduled. If the callback returns 0, the periodic alarm -- is cancelled. -- To cancel a currently running timer, call SetTimer(0, NULL); -- The timer callback function may run in a different thread than your -- main code, and so shouldn't call any functions from within itself. -- The maximum resolution of this timer is 10 ms, which means that if -- you request a 16 ms timer, your callback will run approximately 20 ms -- later on an unloaded system. If you wanted to set a flag signaling -- a frame update at 30 frames per second (every 33 ms), you might set a -- timer for 30 ms: -- SetTimer((33/10)*10, flag_update); -- If you use this function, you need to pass INIT_TIMER to SDL_Init(). -- Under UNIX, you should not use raise or use SIGALRM and this function -- in the same program, as it is implemented using setitimer(). You also -- should not use this function in multi-threaded applications as signals -- to multi-threaded apps have undefined behavior in some implementations. function SetTimer ( interval : Uint32; callback : TimerCallback_ptr) return C.int; procedure SetTimer ( interval : Uint32; callback : TimerCallback_ptr); pragma Import (C, SetTimer, "SDL_SetTimer"); -- New timer API, supports multiple timers -- Written by <NAME> <<EMAIL>> -- Function prototype for the new timer callback function. -- The callback function is passed the current timer interval and returns -- the next timer interval. If the returned value is the same as the one -- passed in, the periodic alarm continues, otherwise a new alarm is -- scheduled. If the callback returns 0, the periodic alarm is cancelled. type NewTimerCallback_ptr is access function ( interval : Uint32; param : System.Address) return Uint32; pragma Convention (C, NewTimerCallback_ptr); -- Definition of the timer ID type type TimerID is new System.Address; Null_TimerID : constant TimerID := TimerID (System.Null_Address); -- Add a new timer to the pool of timers already running. -- Returns a timer ID, or NULL when an error occurs. function AddTimer ( interval : Uint32; callback : NewTimerCallback_ptr; param : System.Address) return TimerID; pragma Import (C, AddTimer, "SDL_AddTimer"); -- Remove one of the multiple timers knowing its ID. -- Returns a boolean value indicating success. function RemoveTimer (t : TimerID) return SDL_bool; pragma Import (C, RemoveTimer, "SDL_RemoveTimer"); end SDL.Timer;
29,648
ada
1
vidkidz/crossbridge
llvm-gcc-4.2-2.9/gcc/ada/scans.adb
<reponame>vidkidz/crossbridge ------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S C A N S -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2006, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, -- -- Boston, MA 02110-1301, USA. -- -- -- -- As a special exception, if other files instantiate generics from this -- -- unit, or you link this unit with other files to produce an executable, -- -- this unit does not by itself cause the resulting executable to be -- -- covered by the GNU General Public License. This exception does not -- -- however invalidate any other reasons why the executable file might be -- -- covered by the GNU Public License. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Namet; use Namet; with Snames; use Snames; package body Scans is ----------------------------- -- Initialize_Ada_Keywords -- ----------------------------- procedure Initialize_Ada_Keywords is procedure Set_Reserved (N : Name_Id; T : Token_Type); pragma Inline (Set_Reserved); -- Set given name as a reserved word (T is the corresponding token) ------------------ -- Set_Reserved -- ------------------ procedure Set_Reserved (N : Name_Id; T : Token_Type) is begin -- Set up Token_Type values in Names table entries for reserved -- words. We use the Pos value of the Token_Type value. Note that -- Is_Keyword_Name relies on the fact that Token_Type'Val (0) is not -- a reserved word! Set_Name_Table_Byte (N, Token_Type'Pos (T)); end Set_Reserved; -- Start of processing for Initialize_Ada_Keywords begin -- Establish reserved words Set_Reserved (Name_Abort, Tok_Abort); Set_Reserved (Name_Abs, Tok_Abs); Set_Reserved (Name_Abstract, Tok_Abstract); Set_Reserved (Name_Accept, Tok_Accept); Set_Reserved (Name_Access, Tok_Access); Set_Reserved (Name_And, Tok_And); Set_Reserved (Name_Aliased, Tok_Aliased); Set_Reserved (Name_All, Tok_All); Set_Reserved (Name_Array, Tok_Array); Set_Reserved (Name_At, Tok_At); Set_Reserved (Name_Begin, Tok_Begin); Set_Reserved (Name_Body, Tok_Body); Set_Reserved (Name_Case, Tok_Case); Set_Reserved (Name_Constant, Tok_Constant); Set_Reserved (Name_Declare, Tok_Declare); Set_Reserved (Name_Delay, Tok_Delay); Set_Reserved (Name_Delta, Tok_Delta); Set_Reserved (Name_Digits, Tok_Digits); Set_Reserved (Name_Do, Tok_Do); Set_Reserved (Name_Else, Tok_Else); Set_Reserved (Name_Elsif, Tok_Elsif); Set_Reserved (Name_End, Tok_End); Set_Reserved (Name_Entry, Tok_Entry); Set_Reserved (Name_Exception, Tok_Exception); Set_Reserved (Name_Exit, Tok_Exit); Set_Reserved (Name_For, Tok_For); Set_Reserved (Name_Function, Tok_Function); Set_Reserved (Name_Generic, Tok_Generic); Set_Reserved (Name_Goto, Tok_Goto); Set_Reserved (Name_If, Tok_If); Set_Reserved (Name_In, Tok_In); Set_Reserved (Name_Is, Tok_Is); Set_Reserved (Name_Limited, Tok_Limited); Set_Reserved (Name_Loop, Tok_Loop); Set_Reserved (Name_Mod, Tok_Mod); Set_Reserved (Name_New, Tok_New); Set_Reserved (Name_Not, Tok_Not); Set_Reserved (Name_Null, Tok_Null); Set_Reserved (Name_Of, Tok_Of); Set_Reserved (Name_Or, Tok_Or); Set_Reserved (Name_Others, Tok_Others); Set_Reserved (Name_Out, Tok_Out); Set_Reserved (Name_Package, Tok_Package); Set_Reserved (Name_Pragma, Tok_Pragma); Set_Reserved (Name_Private, Tok_Private); Set_Reserved (Name_Procedure, Tok_Procedure); Set_Reserved (Name_Protected, Tok_Protected); Set_Reserved (Name_Raise, Tok_Raise); Set_Reserved (Name_Range, Tok_Range); Set_Reserved (Name_Record, Tok_Record); Set_Reserved (Name_Rem, Tok_Rem); Set_Reserved (Name_Renames, Tok_Renames); Set_Reserved (Name_Requeue, Tok_Requeue); Set_Reserved (Name_Return, Tok_Return); Set_Reserved (Name_Reverse, Tok_Reverse); Set_Reserved (Name_Select, Tok_Select); Set_Reserved (Name_Separate, Tok_Separate); Set_Reserved (Name_Subtype, Tok_Subtype); Set_Reserved (Name_Tagged, Tok_Tagged); Set_Reserved (Name_Task, Tok_Task); Set_Reserved (Name_Terminate, Tok_Terminate); Set_Reserved (Name_Then, Tok_Then); Set_Reserved (Name_Type, Tok_Type); Set_Reserved (Name_Until, Tok_Until); Set_Reserved (Name_Use, Tok_Use); Set_Reserved (Name_When, Tok_When); Set_Reserved (Name_While, Tok_While); Set_Reserved (Name_With, Tok_With); Set_Reserved (Name_Xor, Tok_Xor); -- Ada 2005 reserved words Set_Reserved (Name_Interface, Tok_Interface); Set_Reserved (Name_Overriding, Tok_Overriding); Set_Reserved (Name_Synchronized, Tok_Synchronized); end Initialize_Ada_Keywords; ------------------------ -- Restore_Scan_State -- ------------------------ procedure Restore_Scan_State (Saved_State : Saved_Scan_State) is begin Scan_Ptr := Saved_State.Save_Scan_Ptr; Token := Saved_State.Save_Token; Token_Ptr := Saved_State.Save_Token_Ptr; Current_Line_Start := Saved_State.Save_Current_Line_Start; Start_Column := Saved_State.Save_Start_Column; Checksum := Saved_State.Save_Checksum; First_Non_Blank_Location := Saved_State.Save_First_Non_Blank_Location; Token_Node := Saved_State.Save_Token_Node; Token_Name := Saved_State.Save_Token_Name; Prev_Token := Saved_State.Save_Prev_Token; Prev_Token_Ptr := Saved_State.Save_Prev_Token_Ptr; end Restore_Scan_State; --------------------- -- Save_Scan_State -- --------------------- procedure Save_Scan_State (Saved_State : out Saved_Scan_State) is begin Saved_State.Save_Scan_Ptr := Scan_Ptr; Saved_State.Save_Token := Token; Saved_State.Save_Token_Ptr := Token_Ptr; Saved_State.Save_Current_Line_Start := Current_Line_Start; Saved_State.Save_Start_Column := Start_Column; Saved_State.Save_Checksum := Checksum; Saved_State.Save_First_Non_Blank_Location := First_Non_Blank_Location; Saved_State.Save_Token_Node := Token_Node; Saved_State.Save_Token_Name := Token_Name; Saved_State.Save_Prev_Token := Prev_Token; Saved_State.Save_Prev_Token_Ptr := Prev_Token_Ptr; end Save_Scan_State; end Scans;
29,649
ada
1
ForYouEyesOnly/Space-Convoy
Sources/Swarm/swarm_control_concurrent_generic.adb
<filename>Sources/Swarm/swarm_control_concurrent_generic.adb -- -- Jan & <NAME>, Australia, July 2011 -- with Exceptions; use Exceptions; with Swarm_Control; use Swarm_Control; with Swarm_Data; use Swarm_Data; with Swarm_Structures; use Swarm_Structures; with Swarm_Structures_Base; use Swarm_Structures_Base; package body Swarm_Control_Concurrent_Generic is -- protected Synchroniser is entry All_Jobs_Done; private Synchroniser_Open : Boolean := False; end Synchroniser; -- protected body Synchroniser is entry All_Jobs_Done when All_Jobs_Done'Count = No_Of_CPU_Cores + 1 or else Synchroniser_Open is begin Synchroniser_Open := All_Jobs_Done'Count > 0; end All_Jobs_Done; end Synchroniser; -- -- -- task type Worker is entry Set_Job (Job : Job_Type; Start_Index, End_Index : Swarm_Element_Index); end Worker; -- Workers : array (1 .. No_Of_CPU_Cores) of Worker; -- task body Worker is Current_Job : Job_Type; Start, Finish : Swarm_Element_Index; begin loop select accept Set_Job (Job : Job_Type; Start_Index, End_Index : Swarm_Element_Index) do Current_Job := Job; Start := Start_Index; Finish := End_Index; end Set_Job; for Element_Index in Start .. Finish loop case Current_Job is when Set_Accelerations => Set_Acceleration (Element_Index); when Forward_Messages => Forward_Messages (Element_Index); when Move_Elements => Move_Element (Element_Index); when Update_Rotations => Update_Rotation (Element_Index); when No_Job => null; end case; end loop; Synchroniser.All_Jobs_Done; or terminate; end select; end loop; exception when E : others => Show_Exception (E); end Worker; -------------------------------------- -- Distribute_Jobs -- -------------------------------------- procedure Distribute_Jobs (Job : Job_Type) is use Swarm_Vectors; First_Element_Ix : constant Swarm_Element_Index := First_Index (Swarm_State); Last_Element_Ix : constant Swarm_Element_Index := Last_Index (Swarm_State); No_Of_Elements : constant Swarm_Element_Index := Swarm_Element_Index (Length (Swarm_State)); Elements_Per_Task : constant Swarm_Element_Index := Natural'Max (1, No_Of_Elements / No_Of_CPU_Cores); begin for Task_Index in Workers'First .. Workers'Last - 1 loop declare From_Ix : constant Integer := Swarm_Element_Index ((Integer (Task_Index) - Workers'First) * Elements_Per_Task + First_Element_Ix); To_Ix : constant Integer := Swarm_Element_Index ((Integer (Task_Index) - Workers'First + 1) * Elements_Per_Task + First_Element_Ix - 1); begin if From_Ix >= First_Element_Ix and then To_Ix <= Last_Element_Ix then Workers (Task_Index).Set_Job (Job, From_Ix, To_Ix); else Workers (Task_Index).Set_Job (No_Job, From_Ix, To_Ix); end if; end; end loop; declare From_Ix : constant Integer := Swarm_Element_Index ((Integer (Workers'Last) - Workers'First) * Elements_Per_Task + First_Element_Ix); To_Ix : constant Integer := Last_Element_Ix; begin if From_Ix >= First_Element_Ix and then To_Ix <= Last_Element_Ix then Workers (Workers'Last).Set_Job (Job, From_Ix, To_Ix); else Workers (Workers'Last).Set_Job (No_Job, From_Ix, To_Ix); end if; end; Synchroniser.All_Jobs_Done; end Distribute_Jobs; -- end Swarm_Control_Concurrent_Generic;
29,650
ada
79
Roldak/OpenGLAda
src/gl/interface/gl.ads
-- part of OpenGLAda, (c) 2017 <NAME> -- released under the terms of the MIT license, see the file "COPYING" with Interfaces.C; package GL is pragma Preelaborate; package C renames Interfaces.C; ----------------------------------------------------------------------------- -- Basics -- ----------------------------------------------------------------------------- -- this is an OpenGLAda-specific procedure that must be called once at -- startup and loads all function pointers for post-1.1 OpenGL functionality. -- it is idempotent (i.e. can be called multiple times without further -- effect). procedure Init; procedure Flush; procedure Finish; -- index types for vectors and matrices type Index_Homogeneous is (X, Y, Z, W); subtype Index_3D is Index_Homogeneous range X .. Z; subtype Index_2D is Index_Homogeneous range X .. Y; -- raised when a function that is not available for the current context -- is called. Feature_Not_Supported_Exception : exception; -- raised when OpenGLAda does not support a certain OpenGL feature -- (either because it's too new and has not yet been wrapped, or because -- it's so deprecated that you shouldn't use it anyway) Not_Implemented_Exception : exception; private ----------------------------------------------------------------------------- -- Internal functions -- ----------------------------------------------------------------------------- procedure Raise_Exception_On_OpenGL_Error; pragma Inline (Raise_Exception_On_OpenGL_Error); end GL;
29,651
ada
1
LaudateCorpus1/RosettaCodeData
Task/Morse-code/Ada/morse-code-2.ada
with Ada.Strings.Maps, Ada.Characters.Handling, Interfaces.C; use Ada, Ada.Strings, Ada.Strings.Maps, Interfaces; package body Morse is Dit, Dah, Lettergap, Wordgap : Duration; -- in seconds Dit_ms, Dah_ms : C.unsigned; -- durations expressed in ms Freq : constant C.unsigned := 1280; -- in Herz Morse_Sequence : constant Character_Sequence := " ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; Morse_charset : constant Character_Set := To_Set (Morse_Sequence); function Convert (Input : String) return Morse_Str is Cap_String : constant String := Characters.Handling.To_Upper (Input); Result : Morse_Str (1 .. 7 * Input'Length); -- Upper Capacity First, Last : Natural := 0; Char_code : Codings; begin for I in Cap_String'Range loop if Is_In (Cap_String (I), Morse_charset) then First := Last + 1; if Cap_String (I) = ' ' then Result (First) := ' '; Last := Last + 1; else Char_code := Table (Reschars (Cap_String (I))); Last := First + Char_code.L - 1; Result (First .. Last) := Char_code.Code (1 .. Char_code.L); Last := Last + 1; Result (Last) := Nul; end if; end if; end loop; if Result (Last) /= ' ' then Last := Last + 1; Result (Last) := ' '; end if; return Result (1 .. Last); end Convert; procedure Morsebeep (Input : Morse_Str) is -- Beep is not portable : adapt to your OS/sound board -- Implementation for Windows XP / interface to fn in stdlib procedure win32xp_beep (dwFrequency : C.unsigned; dwDuration : C.unsigned); pragma Import (C, win32xp_beep, "_beep"); begin for I in Input'Range loop case Input (I) is when Nul => delay Lettergap; when Dot => win32xp_beep (Freq, Dit_ms); delay Dit; when Dash => win32xp_beep (Freq, Dah_ms); delay Dit; when ' ' => delay Wordgap; end case; end loop; end Morsebeep; begin Dit := 0.20; Lettergap := 2 * Dit; Dah := 3 * Dit; Wordgap := 4 * Dit; Dit_ms := C.unsigned (Integer (Dit * 1000)); Dah_ms := C.unsigned (Integer (Dah * 1000)); end Morse;
29,652
ada
2
sinkinben/pok
examples/arinc653-threads/sample-ada/cpu/part1/main.ads
pragma No_Run_Time; with Interfaces.C; with APEX; use APEX; with APEX.Processes; use APEX.Processes; with APEX.Partitions; use APEX.Partitions; with Activity; package Main is procedure Compute; procedure Main; pragma Export (C, Main, "main"); end Main;
29,653
ada
9
SALLYPEMDAS/DW1000
src/dw1000-register_types.ads
<reponame>SALLYPEMDAS/DW1000 ------------------------------------------------------------------------------- -- Copyright (c) 2016 <NAME> -- -- 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 DW1000.System_Time; with DW1000.Types; use DW1000.Types; with System; -- This package defines types for each of the DW1000 registers. -- -- Each register type has a representation clause to match the layout of the -- register according to the DW1000 User Manual. package DW1000.Register_Types with SPARK_Mode => On is ---------------------------------------------------------------------------- -- DEV_ID register file type DEV_ID_Type is record REV : Types.Bits_4 := 2#0000#; VER : Types.Bits_4 := 2#0011#; MODEL : Types.Bits_8 := 16#01#; RIDTAG : Types.Bits_16 := 16#DECA#; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for DEV_ID_Type use record REV at 0 range 0 .. 3; VER at 0 range 4 .. 7; MODEL at 0 range 8 .. 15; RIDTAG at 0 range 16 .. 31; end record; ---------------------------------------------------------------------------- -- EUI register file type EUI_Type is record EUI : Types.Bits_64; end record with Size => 64, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for EUI_Type use record EUI at 0 range 0 .. 63; end record; ---------------------------------------------------------------------------- -- PANDADR register file type PANADR_Type is record SHORT_ADDR : Types.Bits_16 := 16#FFFF#; PAN_ID : Types.Bits_16 := 16#FFFF#; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for PANADR_Type use record SHORT_ADDR at 0 range 0 .. 15; PAN_ID at 0 range 16 .. 31; end record; ---------------------------------------------------------------------------- -- SYS_CFG register file type SYS_CFG_FFEN_Field is (Disabled, Enabled) with Size => 1; -- Frame Filtering Enable. type SYS_CFG_FFBC_Field is (Disabled, Enabled) with Size => 1; -- Frame Filtering Behave as a Coordinator. type SYS_CFG_FFAB_Field is (Not_Allowed, Allowed) with Size => 1; -- Frame Filtering Allow Beacon frame reception. type SYS_CFG_FFAD_Field is (Not_Allowed, Allowed) with Size => 1; -- Frame Filtering Allow Data frame reception. type SYS_CFG_FFAA_Field is (Not_Allowed, Allowed) with Size => 1; -- Frame Filtering Allow Acknowledgment frame reception. type SYS_CFG_FFAM_Field is (Not_Allowed, Allowed) with Size => 1; -- Frame Filtering Allow MAC command frame reception. type SYS_CFG_FFAR_Field is (Not_Allowed, Allowed) with Size => 1; -- Frame Filtering Allow Reserved frame types. type SYS_CFG_FFA4_Field is (Not_Allowed, Allowed) with Size => 1; -- Frame Filtering Allow frames with frame type field of 4, (binary 100). type SYS_CFG_FFA5_Field is (Not_Allowed, Allowed) with Size => 1; -- Frame Filtering Allow frames with frame type field of 5, (binary 101). type SYS_CFG_HIRQ_Pol_Field is (Active_Low, Active_High) with Size => 1; -- Host interrupt polarity. type SYS_CFG_SPI_EDGE_Field is (Sampling_Edge, Opposite_Edge) with Size => 1; -- SPI data launch edge. type SYS_CFG_DIS_FCE_Field is (Not_Disabled, Disabled) with Size => 1; -- Disable frame check error handling. type SYS_CFG_DIS_DRXB_Field is (Not_Disabled, Disabled) with Size => 1; -- Disable Double RX Buffer. type SYS_CFG_DIS_PHE_Field is (Not_Disabled, Disabled) with Size => 1; -- Disable receiver abort on PHR error. type SYS_CFG_DIS_RSDE_Field is (Not_Disabled, Disabled) with Size => 1; -- Disable Receiver Abort on RSD (Reed-Solomon Decoder) error. type SYS_CFG_FCS_INIT2F_Field is (All_Zeroes, All_Ones) with Size => 1; -- This bit allows selection of the initial seed value for the FCS -- generation and checking function that is set at the start of each frame -- transmission and reception. type SYS_CFG_PHR_MODE_Field is (Standard_Frames_Mode, Reserved_01, Reserved_10, Long_Frames_Mode) with Size => 2; -- Standard (max. 127 octets) or long (max. 1023 octets) frames. type SYS_CFG_DIS_STXP_Field is (Not_Disabled, Disabled) with Size => 1; -- Disable Smart TX Power control. type SYS_CFG_RXM110K_Field is (SFD_850K_6M8, SFD_110K) with Size => 1; -- Receiver Mode 110 kbps data rate. type SYS_CFG_RXWTOE_Field is (Disabled, Enabled) with Size => 1; -- Receive Wait Timeout Enable. type SYS_CFG_RXAUTR_Field is (Disabled, Enabled) with Size => 1; -- Receiver Auto-Re-enable. type SYS_CFG_AUTOACK_Field is (Disabled, Enabled) with Size => 1; -- Automatic Acknowledgement Enable. type SYS_CFG_AACKPEND_Field is (Disabled, Enabled) with Size => 1; -- Automatic Acknowledgement Pending bit control. type SYS_CFG_Type is record FFEN : SYS_CFG_FFEN_Field := Disabled; FFBC : SYS_CFG_FFBC_Field := Disabled; FFAB : SYS_CFG_FFAB_Field := Not_Allowed; FFAD : SYS_CFG_FFAD_Field := Not_Allowed; FFAA : SYS_CFG_FFAA_Field := Not_Allowed; FFAM : SYS_CFG_FFAM_Field := Not_Allowed; FFAR : SYS_CFG_FFAR_Field := Not_Allowed; FFA4 : SYS_CFG_FFA4_Field := Not_Allowed; FFA5 : SYS_CFG_FFA5_Field := Not_Allowed; HIRQ_POL : SYS_CFG_HIRQ_Pol_Field := Active_High; SPI_EDGE : SYS_CFG_SPI_EDGE_Field := Sampling_Edge; DIS_FCE : SYS_CFG_DIS_FCE_Field := Not_Disabled; DIS_DRXB : SYS_CFG_DIS_DRXB_Field := Disabled; DIS_PHE : SYS_CFG_DIS_PHE_Field := Not_Disabled; DIS_RSDE : SYS_CFG_DIS_RSDE_Field := Not_Disabled; FCS_INT2F : SYS_CFG_FCS_INIT2F_Field := All_Zeroes; PHR_MODE : SYS_CFG_PHR_MODE_Field := Standard_Frames_Mode; DIS_STXP : SYS_CFG_DIS_STXP_Field := Not_Disabled; RXM110K : SYS_CFG_RXM110K_Field := SFD_850K_6M8; RXWTOE : SYS_CFG_RXWTOE_Field := Disabled; RXAUTR : SYS_CFG_RXAUTR_Field := Disabled; AUTOACK : SYS_CFG_AUTOACK_Field := Disabled; AACKPEND : SYS_CFG_AACKPEND_Field := Disabled; Reserved_1 : Types.Bits_3 := 0; Reserved_2 : Types.Bits_5 := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for SYS_CFG_Type use record FFEN at 0 range 0 .. 0; FFBC at 0 range 1 .. 1; FFAB at 0 range 2 .. 2; FFAD at 0 range 3 .. 3; FFAA at 0 range 4 .. 4; FFAM at 0 range 5 .. 5; FFAR at 0 range 6 .. 6; FFA4 at 0 range 7 .. 7; FFA5 at 0 range 8 .. 8; HIRQ_POL at 0 range 9 .. 9; SPI_EDGE at 0 range 10 .. 10; DIS_FCE at 0 range 11 .. 11; DIS_DRXB at 0 range 12 .. 12; DIS_PHE at 0 range 13 .. 13; DIS_RSDE at 0 range 14 .. 14; FCS_INT2F at 0 range 15 .. 15; PHR_MODE at 0 range 16 .. 17; DIS_STXP at 0 range 18 .. 18; Reserved_1 at 0 range 19 .. 21; RXM110K at 0 range 22 .. 22; Reserved_2 at 0 range 23 .. 27; RXWTOE at 0 range 28 .. 28; RXAUTR at 0 range 29 .. 29; AUTOACK at 0 range 30 .. 30; AACKPEND at 0 range 31 .. 31; end record; ---------------------------------------------------------------------------- -- SYS_TIME register file type SYS_TIME_Type is record SYS_TIME : System_Time.Coarse_System_Time; end record with Pack, Size => 40, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; ---------------------------------------------------------------------------- -- TX_FCTRL register file type TX_FCTRL_TFLEN_Field is range 0 .. 127 with Size => 7; -- Transmit Frame Length. type TX_FCTRL_TFLE_Field is range 0 .. 7 with Size => 3; -- Transmit Frame Length Extension. type TX_FCTRL_TXBR_Field is (Data_Rate_110K, Data_Rate_850K, Data_Rate_6M8, Reserved) with Size => 2; -- Transmit Bit Rate. type TX_FCTRL_TR_Field is (Disabled, Enabled) with Size => 1; -- Transmit Ranging enable. type TX_FCTRL_TXPRF_Field is (PRF_4MHz, PRF_16MHz, PRF_64MHz, Reserved) with Size => 2; -- Transmit Pulse Repetition Frequency. type TX_FCTRL_TXPSR_Field is (PLEN_16, PLEN_64, PLEN_1024, PLEN_4096) with Size => 2; -- Transmit Preamble Symbol Repetitions (PSR). type TX_FCTRL_PE_Field is range 0 .. 3 with Size => 2; -- Preamble Extension. type TX_FCTRL_TXBOFFS_Field is range 0 .. 2**10 - 1 with Size => 10; -- Transmit buffer index offset. type TX_FCTRL_IFSDELAY_Field is range 0 .. 255 with Size => 8; -- Inter-Frame Spacing. type TX_FCTRL_Type is record TFLEN : TX_FCTRL_TFLEN_Field := 12; TFLE : TX_FCTRL_TFLE_Field := 0; R : Types.Bits_3 := 0; TXBR : TX_FCTRL_TXBR_Field := Data_Rate_6M8; TR : TX_FCTRL_TR_Field := Disabled; TXPRF : TX_FCTRL_TXPRF_Field := PRF_16MHz; TXPSR : TX_FCTRL_TXPSR_Field := PLEN_64; PE : TX_FCTRL_PE_Field := 0; TXBOFFS : TX_FCTRL_TXBOFFS_Field := 0; IFSDELAY : TX_FCTRL_IFSDELAY_Field := 0; end record with Size => 40, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for TX_FCTRL_Type use record TFLEN at 0 range 0 .. 6; TFLE at 0 range 7 .. 9; R at 0 range 10 .. 12; TXBR at 0 range 13 .. 14; TR at 0 range 15 .. 15; TXPRF at 0 range 16 .. 17; TXPSR at 0 range 18 .. 19; PE at 0 range 20 .. 21; TXBOFFS at 0 range 22 .. 31; IFSDELAY at 0 range 32 .. 39; end record; ---------------------------------------------------------------------------- -- TX_BUFFER register file type TX_BUFFER_Type is record TX_BUFFER : Types.Byte_Array (1 .. 1024) := (others => 0); end record with Size => 8192, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for TX_BUFFER_Type use record TX_BUFFER at 0 range 0 .. 8191; end record; ---------------------------------------------------------------------------- -- DX_TIME register file type DX_TIME_Type is record DX_TIME : System_Time.Coarse_System_Time := 0.0; end record with Pack, Size => 40, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; ---------------------------------------------------------------------------- -- RX_FWTO register file type RX_FWTO_Type is record RXFWTO : System_Time.Frame_Wait_Timeout_Time := 0.0; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for RX_FWTO_Type use record RXFWTO at 0 range 0 .. 15; end record; ---------------------------------------------------------------------------- -- SYS_CTRL register file type SYS_CTRL_SFCST_Field is (Not_Suppressed, Suppressed) with Size => 1; -- Suppress auto-FCS Transmission (on this next frame). type SYS_CTRL_TXSTRT_Field is (No_Action, Start_Tx) with Size => 1; -- Transmit Start. type SYS_CTRL_TXDLYS_Field is (Not_Delayed, Delayed) with Size => 1; -- Transmitter Delayed Sending. type SYS_CTRL_CANSFCS_Field is (Not_Cancelled, Cancelled) with Size => 1; -- Cancel Suppression of auto-FCS transmission (on the current frame). type SYS_CTRL_TRXOFF_Field is (No_Action, Transceiver_Off) with Size => 1; -- Transceiver Off. type SYS_CTRL_WAIT4RESP_Field is (No_Wait, Wait) with Size => 1; -- Wait for Response. type SYS_CTRL_RXENAB_Field is (No_Action, Start_Rx) with Size => 1; -- Enable Receiver. type SYS_CTRL_RXDLYE_Field is (Not_Delayed, Delayed) with Size => 1; -- Receiver Delayed Enable. type SYS_CTRL_HRBPT_Field is (No_Action, Toggle) with Size => 1; -- Host Side Receive Buffer Pointer Toggle. type SYS_CTRL_Type is record SFCST : SYS_CTRL_SFCST_Field := Not_Suppressed; TXSTRT : SYS_CTRL_TXSTRT_Field := No_Action; TXDLYS : SYS_CTRL_TXDLYS_Field := Not_Delayed; CANSFCS : SYS_CTRL_CANSFCS_Field := Not_Cancelled; TRXOFF : SYS_CTRL_TRXOFF_Field := No_Action; WAIT4RESP : SYS_CTRL_WAIT4RESP_Field := No_Wait; RXENAB : SYS_CTRL_RXENAB_Field := No_Action; RXDLYE : SYS_CTRL_RXDLYE_Field := Not_Delayed; HRBPT : SYS_CTRL_HRBPT_Field := No_Action; Reserved_1 : Types.Bits_2 := 0; Reserved_2 : Types.Bits_14 := 0; Reserved_3 : Types.Bits_7 := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for SYS_CTRL_Type use record SFCST at 0 range 0 .. 0; TXSTRT at 0 range 1 .. 1; TXDLYS at 0 range 2 .. 2; CANSFCS at 0 range 3 .. 3; Reserved_1 at 0 range 4 .. 5; TRXOFF at 0 range 6 .. 6; WAIT4RESP at 0 range 7 .. 7; RXENAB at 0 range 8 .. 8; RXDLYE at 0 range 9 .. 9; Reserved_2 at 0 range 10 .. 23; HRBPT at 0 range 24 .. 24; Reserved_3 at 0 range 25 .. 31; end record; ---------------------------------------------------------------------------- -- SYS_MASK register file type SYS_MASK_Mask_Field is (Masked, Not_Masked) with Size => 1; -- Mask event. type SYS_MASK_Type is record MCPLOCK : SYS_MASK_Mask_Field := Masked; MESYNCR : SYS_MASK_Mask_Field := Masked; MAAT : SYS_MASK_Mask_Field := Masked; MTXFRB : SYS_MASK_Mask_Field := Masked; MTXPRS : SYS_MASK_Mask_Field := Masked; MTXPHS : SYS_MASK_Mask_Field := Masked; MTXFRS : SYS_MASK_Mask_Field := Masked; MRXPRD : SYS_MASK_Mask_Field := Masked; MRXSFDD : SYS_MASK_Mask_Field := Masked; MLDEDONE : SYS_MASK_Mask_Field := Masked; MRXPHD : SYS_MASK_Mask_Field := Masked; MRXPHE : SYS_MASK_Mask_Field := Masked; MRXDFR : SYS_MASK_Mask_Field := Masked; MRXFCG : SYS_MASK_Mask_Field := Masked; MRXFCE : SYS_MASK_Mask_Field := Masked; MRXRFSL : SYS_MASK_Mask_Field := Masked; MRXRFTO : SYS_MASK_Mask_Field := Masked; MLDEERR : SYS_MASK_Mask_Field := Masked; MRXOVRR : SYS_MASK_Mask_Field := Masked; MRXPTO : SYS_MASK_Mask_Field := Masked; MGPIOIRQ : SYS_MASK_Mask_Field := Masked; MSLP2INIT : SYS_MASK_Mask_Field := Masked; MRFPLLLL : SYS_MASK_Mask_Field := Masked; MCPLLLL : SYS_MASK_Mask_Field := Masked; MRXSFDTO : SYS_MASK_Mask_Field := Masked; MHPDWARN : SYS_MASK_Mask_Field := Masked; MTXBERR : SYS_MASK_Mask_Field := Masked; MAFFREJ : SYS_MASK_Mask_Field := Masked; Reserved_1 : Types.Bits_1 := 0; Reserved_2 : Types.Bits_1 := 0; Reserved_3 : Types.Bits_2 := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for SYS_MASK_Type use record Reserved_1 at 0 range 0 .. 0; MCPLOCK at 0 range 1 .. 1; MESYNCR at 0 range 2 .. 2; MAAT at 0 range 3 .. 3; MTXFRB at 0 range 4 .. 4; MTXPRS at 0 range 5 .. 5; MTXPHS at 0 range 6 .. 6; MTXFRS at 0 range 7 .. 7; MRXPRD at 0 range 8 .. 8; MRXSFDD at 0 range 9 .. 9; MLDEDONE at 0 range 10 .. 10; MRXPHD at 0 range 11 .. 11; MRXPHE at 0 range 12 .. 12; MRXDFR at 0 range 13 .. 13; MRXFCG at 0 range 14 .. 14; MRXFCE at 0 range 15 .. 15; MRXRFSL at 0 range 16 .. 16; MRXRFTO at 0 range 17 .. 17; MLDEERR at 0 range 18 .. 18; Reserved_2 at 0 range 19 .. 19; MRXOVRR at 0 range 20 .. 20; MRXPTO at 0 range 21 .. 21; MGPIOIRQ at 0 range 22 .. 22; MSLP2INIT at 0 range 23 .. 23; MRFPLLLL at 0 range 24 .. 24; MCPLLLL at 0 range 25 .. 25; MRXSFDTO at 0 range 26 .. 26; MHPDWARN at 0 range 27 .. 27; MTXBERR at 0 range 28 .. 28; MAFFREJ at 0 range 29 .. 29; Reserved_3 at 0 range 30 .. 31; end record; ---------------------------------------------------------------------------- -- SYS_STATUS register file type SYS_STATUS_Type is record IRQS : Types.Bits_1 := 0; CPLOCK : Types.Bits_1 := 0; ESYNCR : Types.Bits_1 := 0; AAT : Types.Bits_1 := 0; TXFRB : Types.Bits_1 := 0; TXPRS : Types.Bits_1 := 0; TXPHS : Types.Bits_1 := 0; TXFRS : Types.Bits_1 := 0; RXPRD : Types.Bits_1 := 0; RXSFDD : Types.Bits_1 := 0; LDEDONE : Types.Bits_1 := 0; RXPHD : Types.Bits_1 := 0; RXPHE : Types.Bits_1 := 0; RXDFR : Types.Bits_1 := 0; RXFCG : Types.Bits_1 := 0; RXFCE : Types.Bits_1 := 0; RXRFSL : Types.Bits_1 := 0; RXRFTO : Types.Bits_1 := 0; LDEERR : Types.Bits_1 := 0; RXOVRR : Types.Bits_1 := 0; RXPTO : Types.Bits_1 := 0; GPIOIRQ : Types.Bits_1 := 0; SLP2INIT : Types.Bits_1 := 0; RFPLL_LL : Types.Bits_1 := 0; CLKPLL_LL : Types.Bits_1 := 0; RXSFDTO : Types.Bits_1 := 0; HPDWARN : Types.Bits_1 := 0; TXBERR : Types.Bits_1 := 0; AFFREJ : Types.Bits_1 := 0; HSRBP : Types.Bits_1 := 0; ICRBP : Types.Bits_1 := 0; RXRSCS : Types.Bits_1 := 0; RXPREJ : Types.Bits_1 := 0; TXPUTE : Types.Bits_1 := 0; Reserved_1 : Types.Bits_1 := 0; Reserved_2 : Types.Bits_5 := 0; end record with Size => 40, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for SYS_STATUS_Type use record IRQS at 0 range 0 .. 0; CPLOCK at 0 range 1 .. 1; ESYNCR at 0 range 2 .. 2; AAT at 0 range 3 .. 3; TXFRB at 0 range 4 .. 4; TXPRS at 0 range 5 .. 5; TXPHS at 0 range 6 .. 6; TXFRS at 0 range 7 .. 7; RXPRD at 0 range 8 .. 8; RXSFDD at 0 range 9 .. 9; LDEDONE at 0 range 10 .. 10; RXPHD at 0 range 11 .. 11; RXPHE at 0 range 12 .. 12; RXDFR at 0 range 13 .. 13; RXFCG at 0 range 14 .. 14; RXFCE at 0 range 15 .. 15; RXRFSL at 0 range 16 .. 16; RXRFTO at 0 range 17 .. 17; LDEERR at 0 range 18 .. 18; Reserved_1 at 0 range 19 .. 19; RXOVRR at 0 range 20 .. 20; RXPTO at 0 range 21 .. 21; GPIOIRQ at 0 range 22 .. 22; SLP2INIT at 0 range 23 .. 23; RFPLL_LL at 0 range 24 .. 24; CLKPLL_LL at 0 range 25 .. 25; RXSFDTO at 0 range 26 .. 26; HPDWARN at 0 range 27 .. 27; TXBERR at 0 range 28 .. 28; AFFREJ at 0 range 29 .. 29; HSRBP at 0 range 30 .. 30; ICRBP at 0 range 31 .. 31; RXRSCS at 4 range 0 .. 0; RXPREJ at 4 range 1 .. 1; TXPUTE at 4 range 2 .. 2; Reserved_2 at 4 range 3 .. 7; end record; ---------------------------------------------------------------------------- -- RX_FINFO register file type RX_FINFO_RXFLEN_Field is range 0 .. 127 with Size => 7; -- Receive Frame Length. type RX_FINFO_RXFLE_Field is range 0 .. 7 with Size => 3; -- Receive Frame Length Extension. type RX_FINFO_RXNSPL_Field is range 0 .. 3 with Size => 2; -- Receive non-standard preamble length. type RX_FINFO_RXBR_Field is (Data_Rate_110K, Data_Rate_850K, Data_Rate_6M8, Reserved) with Size => 2; -- Receive Bit Rate report. type RX_FINFO_RNG_Field is (Disabled, Enabled) with Size => 1; -- Receiver Ranging. type RX_FINFO_RXPRFR_Field is (Reserved_00, PRF_16MHz, PRF_64MHz, Reserved_11) with Size => 2; -- RX Pulse Repetition Rate report. type RX_FINFO_RXPSR_Field is (PLEN_16, PLEN_64, PLEN_1024, PLEN_4096) with Size => 2; -- RX Preamble Repetition. type RX_FINFO_RXPACC_Field is range 0 .. 2**12 - 1 with Size => 12; type RX_FINFO_Type is record RXFLEN : RX_FINFO_RXFLEN_Field := 0; RXFLE : RX_FINFO_RXFLE_Field := 0; RXNSPL : RX_FINFO_RXNSPL_Field := 0; RXBR : RX_FINFO_RXBR_Field := Data_Rate_110K; RNG : RX_FINFO_RNG_Field := Disabled; RXPRF : RX_FINFO_RXPRFR_Field := Reserved_00; RXPSR : RX_FINFO_RXPSR_Field := PLEN_16; RXPACC : RX_FINFO_RXPACC_Field := 0; Reserved : Types.Bits_1 := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for RX_FINFO_Type use record RXFLEN at 0 range 0 .. 6; RXFLE at 0 range 7 .. 9; Reserved at 0 range 10 .. 10; RXNSPL at 0 range 11 .. 12; RXBR at 0 range 13 .. 14; RNG at 0 range 15 .. 15; RXPRF at 0 range 16 .. 17; RXPSR at 0 range 18 .. 19; RXPACC at 0 range 20 .. 31; end record; ---------------------------------------------------------------------------- -- RX_BUFFER register file type RX_BUFFER_Type is record RX_BUFFER : Types.Byte_Array (1 .. 1024) := (others => 0); end record with Size => 8192, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for RX_BUFFER_Type use record RX_BUFFER at 0 range 0 .. 8191; end record; ---------------------------------------------------------------------------- -- RX_FQUAL register file type RX_FQUAL_STD_NOISE_Field is range 0 .. 2**16 - 1 with Size => 16; -- Standard Deviation of Noise. type RX_FQUAL_FP_AMPL2_Field is range 0 .. 2**16 - 1 with Size => 16; -- First Path Amplitude point 2. type RX_FQUAL_FP_AMPL3_Field is range 0 .. 2**16 - 1 with Size => 16; -- First Path Amplitude point 3. type RX_FQUAL_CIR_PWR_Field is range 0 .. 2**16 - 1 with Size => 16; -- Channel Impulse Response Power. type RX_FQUAL_Type is record STD_NOISE : RX_FQUAL_STD_NOISE_Field := 0; FP_AMPL2 : RX_FQUAL_FP_AMPL2_Field := 0; FP_AMPL3 : RX_FQUAL_FP_AMPL3_Field := 0; CIR_PWR : RX_FQUAL_CIR_PWR_Field := 0; end record with Size => 64, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for RX_FQUAL_Type use record STD_NOISE at 0 range 0 .. 15; FP_AMPL2 at 0 range 16 .. 31; FP_AMPL3 at 4 range 0 .. 15; CIR_PWR at 4 range 16 .. 31; end record; ---------------------------------------------------------------------------- -- RX_TTCKI register file type RX_TTCKI_RXTTCKI_Field is range 0 .. 2**32 - 1 with Size => 32; -- RX time tracking interval. type RX_TTCKI_Type is record RXTTCKI : RX_TTCKI_RXTTCKI_Field := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for RX_TTCKI_Type use record RXTTCKI at 0 range 0 .. 31; end record; ---------------------------------------------------------------------------- -- RX_TTCKO register file type RX_TTCKO_RXTOFS_Field is range -2**18 .. 2**18 - 1 with Size => 19; -- RX time tracking offset. type RX_TTCKO_RSMPDEL_Field is range 0 .. 255 with Size => 8; -- This 8-bit field reports an internal re-sampler delay value. type RX_TTCKO_RCPHASE_Field is delta 360.0 / 127.0 range 0.0 .. 360.0 with Small => 360.0 / 127.0, Size => 7; -- This 7-bit field reports the receive carrier phase adjustment at time -- the ranging timestamp is made. This gives the phase (7 bits = 360 degrees) -- of the internal carrier tracking loop at the time that the RX timestamp -- is received. type RX_TTCKO_Type is record RXTOFS : RX_TTCKO_RXTOFS_Field := 0; RSMPDEL : RX_TTCKO_RSMPDEL_Field := 0; RCPHASE : RX_TTCKO_RCPHASE_Field := RX_TTCKO_RCPHASE_Field'First; Reserved_1 : Types.Bits_5 := 0; Reserved_2 : Types.Bits_1 := 0; end record with Size => 40, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for RX_TTCKO_Type use record RXTOFS at 0 range 0 .. 18; Reserved_1 at 0 range 19 .. 23; RSMPDEL at 0 range 24 .. 31; RCPHASE at 0 range 32 .. 38; Reserved_2 at 0 range 39 .. 39; end record; ---------------------------------------------------------------------------- -- RX_TIME register file type RX_TIME_FP_INDEX_Field is range 0 .. 2**16 - 1 with Size => 16; -- First path index. type RX_TIME_FP_AMPL1_Field is range 0 .. 2**16 - 1 with Size => 16; -- First Path Amplitude point 1. type RX_TIME_Type is record RX_STAMP : System_Time.Fine_System_Time := 0.0; FP_INDEX : RX_TIME_FP_INDEX_Field := 0; FP_AMPL1 : RX_TIME_FP_AMPL1_Field := 0; RX_RAWST : System_Time.Coarse_System_Time := 0.0; end record with Size => 8 * 14, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for RX_TIME_Type use record RX_STAMP at 0 range 0 .. 39; FP_INDEX at 4 range 8 .. 23; FP_AMPL1 at 4 range 24 .. 39; RX_RAWST at 8 range 8 .. 47; end record; ---------------------------------------------------------------------------- -- TX_TIME register file type TX_TIME_Type is record TX_STAMP : System_Time.Fine_System_Time := 0.0; TX_RAWST : System_Time.Coarse_System_Time := 0.0; end record with Size => 80, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for TX_TIME_Type use record TX_STAMP at 0 range 0 .. 39; TX_RAWST at 4 range 8 .. 47; end record; ---------------------------------------------------------------------------- -- TX_ANTD register file type TX_ANTD_Type is record TX_ANTD : System_Time.Antenna_Delay_Time := 0.0; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for TX_ANTD_Type use record TX_ANTD at 0 range 0 .. 15; end record; ---------------------------------------------------------------------------- -- SYS_STATE register file type SYS_STATE_TX_STATE_Field is (Idle, Transmitting_Preamble, Transmitting_SFD, Transmitting_PHR, Transmitting_SDE, Transmitting_DATA, Reserved_0110, Reserved_0111, Reserved_1000, Reserved_1001, Reserved_1010, Reserved_1011, Reserved_1100, Reserved_1101, Reserved_1110, Reserved_1111) with Size => 4; -- Current Transmit State Machine value type SYS_STATE_RX_STATE_Field is (Idle, Start_Analog, Reserved_00010, Reserved_00011, Rx_Ready, Preamble_Search, Preamble_Timeout, SFD_Search, Configure_PHR_Rx, PHY_Rx_Start, Data_Rate_Ready, Reserved_01011, Data_Rx_Seq, Configure_Data_Rx, PHR_Not_OK, Last_Symbol, Wait_RSD_Done, RSD_OK, RSD_Not_OK, Reconfigure_110K, Wait_110K_PHR, Reserved_10101, Reserved_10110, Reserved_10111, Reserved_11000, Reserved_11001, Reserved_11010, Reserved_11011, Reserved_11100, Reserved_11101, Reserved_11110, Reserved_11111) with Size => 5; -- Current Receive State Machine value type SYS_STATE_PMSC_STATE_Field is (Init, Idle, TX_Wait, RX_Wait, Tx, Rx, Reserved_0110, Reserved_0111, Reserved_1000, Reserved_1001, Reserved_1010, Reserved_1011, Reserved_1100, Reserved_1101, Reserved_1110, Reserved_1111) with Size => 4; type SYS_STATE_Type is record TX_STATE : SYS_STATE_TX_STATE_Field := Idle; RX_STATE : SYS_STATE_RX_STATE_Field := Idle; PMSC_STATE : SYS_STATE_PMSC_STATE_Field := Idle; Reserved_1 : Bits_4 := 0; Reserved_2 : Bits_3 := 0; Reserved_3 : Bits_12 := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for SYS_STATE_Type use record TX_STATE at 0 range 0 .. 3; Reserved_1 at 0 range 4 .. 7; RX_STATE at 0 range 8 .. 12; Reserved_2 at 0 range 13 .. 15; PMSC_STATE at 0 range 16 .. 19; Reserved_3 at 0 range 20 .. 31; end record; ---------------------------------------------------------------------------- -- ACK_RESP_T register file type ACK_RESP_T_ACK_TIM_Field is range 0 .. 255 with Size => 8; -- Auto-Acknowledgement turn-around Time (in number of preamble symbols). type ACK_RESP_T_Type is record W4D_TIM : System_Time.Response_Wait_Timeout_Time := 0.0; ACK_TIM : ACK_RESP_T_ACK_TIM_Field := 0; Reserved : Types.Bits_4 := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for ACK_RESP_T_Type use record W4D_TIM at 0 range 0 .. 19; Reserved at 0 range 20 .. 23; ACK_TIM at 0 range 24 .. 31; end record; ---------------------------------------------------------------------------- -- RX_SNIFF register file type RX_SNIFF_SNIFF_ONT_Field is range 0 .. 15 with Size => 4; -- SNIFF Mode ON time. This parameter is specified in units of PAC. type RX_SNIFF_Type is record SNIFF_ONT : RX_SNIFF_SNIFF_ONT_Field := 0; SNIFF_OFFT : System_Time.Sniff_Off_Time := 0.0; Reserved_1 : Types.Bits_4 := 0; Reserved_2 : Types.Bits_16 := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for RX_SNIFF_Type use record SNIFF_ONT at 0 range 0 .. 3; Reserved_1 at 0 range 4 .. 7; SNIFF_OFFT at 0 range 8 .. 15; Reserved_2 at 0 range 16 .. 31; end record; ---------------------------------------------------------------------------- -- TX_POWER register file type TX_POWER_COARSE_Field is (Gain_15_dB, Gain_12_5_dB, Gain_10_dB, Gain_7_5_dB, Gain_5_dB, Gain_2_5_dB, Gain_0_dB, Off) -- No output when used with Size => 3; -- Coarse (DA setting) gain in 2.5 dB steps. -- -- Unfortunately we can't use a fixed-point type here (like the fine gain) -- due to the reversed HW representation of the coarse gain and the -- need for the special "Off" setting. type TX_POWER_FINE_Field is delta 0.5 range 0.0 .. 15.5 with Size => 5; -- Fine (Mixer) gain in dB (Decibels) in 0.5 dB steps. type TX_POWER_Field is record Fine_Gain : TX_POWER_FINE_Field := 0.0; Coarse_Gain : TX_POWER_COARSE_Field := Gain_15_dB; end record with Size => 8; for TX_POWER_Field use record Fine_Gain at 0 range 0 .. 4; Coarse_Gain at 0 range 5 .. 7; end record; type TX_POWER_Type is record BOOSTNORM : TX_POWER_Field := (Fine_Gain => 1.0, Coarse_Gain => Gain_12_5_dB); BOOSTP500 : TX_POWER_Field := (Fine_Gain => 1.0, Coarse_Gain => Gain_15_dB); BOOSTP250 : TX_POWER_Field := (Fine_Gain => 4.0, Coarse_Gain => Gain_15_dB); BOOSTP125 : TX_POWER_Field := (Fine_Gain => 7.0, Coarse_Gain => Gain_15_dB); end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for TX_POWER_Type use record BOOSTNORM at 0 range 0 .. 7; BOOSTP500 at 0 range 8 .. 15; BOOSTP250 at 0 range 16 .. 23; BOOSTP125 at 0 range 24 .. 31; end record; ---------------------------------------------------------------------------- -- CHAN_CTRL register file type CHAN_CTRL_Channel_Field is range 0 .. 15 with Size => 4; -- This selects the transmit/receive channel. type CHAN_CTRL_DWSFD_Field is (Disabled, Enabled) with Size => 1; -- This bit enables a non-standard Decawave proprietary SFD sequence. type CHAN_CTRL_RXPRF_Field is (Reserved_00, PRF_16MHz, PRF_64MHz, Reserved_11) with Size => 2; -- This two bit field selects the PRF used in the receiver. type CHAN_CTRL_TNSSFD_Field is (Disabled, Enabled) with Size => 1; -- This bit enables the use of a user specified (non-standard) SFD in the -- transmitter. type CHAN_CTRL_RNSSFD_Field is (Disabled, Enabled) with Size => 1; -- This bit enables the use of a user specified (non-standard) SFD in the -- receiver. type CHAN_CTRL_PCODE_Field is range 0 .. 31 with Size => 5; -- This field selects the preamble code used in the transmitter/receiver. type CHAN_CTRL_Type is record TX_CHAN : CHAN_CTRL_Channel_Field := 5; RX_CHAN : CHAN_CTRL_Channel_Field := 5; DWSFD : CHAN_CTRL_DWSFD_Field := Disabled; RXPRF : CHAN_CTRL_RXPRF_Field := Reserved_00; TNSSFD : CHAN_CTRL_TNSSFD_Field := Disabled; RNSSFD : CHAN_CTRL_RNSSFD_Field := Disabled; TX_PCODE : CHAN_CTRL_PCODE_Field := 0; RX_PCODE : CHAN_CTRL_PCODE_Field := 0; Reserved : Types.Bits_9 := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for CHAN_CTRL_Type use record TX_CHAN at 0 range 0 .. 3; RX_CHAN at 0 range 4 .. 7; Reserved at 0 range 8 .. 16; DWSFD at 0 range 17 .. 17; RXPRF at 0 range 18 .. 19; TNSSFD at 0 range 20 .. 20; RNSSFD at 0 range 21 .. 21; TX_PCODE at 0 range 22 .. 26; RX_PCODE at 0 range 27 .. 31; end record; ---------------------------------------------------------------------------- -- USR_SFD register file type USR_SFD_Type is record Sub_Registers : Types.Byte_Array (0 .. 40); end record with Size => 41 * 8, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for USR_SFD_Type use record Sub_Registers at 0 range 0 .. (41 * 8) - 1; end record; ---------------------------------------------------------------------------- -- AGC_CTRL register file ------------------------------ -- AGC_CTRL1 sub-register -- ------------------------------ type AGC_CTRL1_DIS_AM_Field is (Not_Disabled, Disabled) with Size => 1; type AGC_CTRL1_Type is record DIS_AM : AGC_CTRL1_DIS_AM_Field := Disabled; Reserved : Types.Bits_15 := 0; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for AGC_CTRL1_Type use record DIS_AM at 0 range 0 .. 0; Reserved at 0 range 1 .. 15; end record; ------------------------------ -- AGC_TUNE1 sub-register -- ------------------------------ type AGC_TUNE1_Field is new Bits_16; AGC_TUNE1_PRF_16MHz : constant AGC_TUNE1_Field := 16#8870#; AGC_TUNE1_PRF_64MHz : constant AGC_TUNE1_Field := 16#889B#; type AGC_TUNE1_Type is record AGC_TUNE1 : AGC_TUNE1_Field; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for AGC_TUNE1_Type use record AGC_TUNE1 at 0 range 0 .. 15; end record; ------------------------------ -- AGC_TUNE2 sub-register -- ------------------------------ type AGC_TUNE2_Field is new Bits_32; AGC_TUNE2_Value : constant AGC_TUNE2_Field := 16#2502A907#; type AGC_TUNE2_Type is record AGC_TUNE2 : AGC_TUNE2_Field; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for AGC_TUNE2_Type use record AGC_TUNE2 at 0 range 0 .. 31; end record; ------------------------------ -- AGC_TUNE3 sub-register -- ------------------------------ type AGC_TUNE3_Field is new Bits_16; AGC_TUNE3_Value : constant AGC_TUNE3_Field := 16#0035#; type AGC_TUNE3_Type is record AGC_TUNE3 : AGC_TUNE3_Field; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for AGC_TUNE3_Type use record AGC_TUNE3 at 0 range 0 .. 15; end record; ------------------------------ -- AGC_STAT1 sub-register -- ------------------------------ type AGC_STAT1_EDG1_Field is range 0 .. 2**5 - 1 with Size => 5; -- This 5-bit gain value relates to input noise power measurement. type AGC_STAT1_EDV2_Field is range 0 .. 2**9 - 1 with Size => 9; -- This 9-bit value relates to the input noise power measurement. type AGC_STAT1_Type is record EDG1 : AGC_STAT1_EDG1_Field; EDV2 : AGC_STAT1_EDV2_Field; Reserved_1 : Types.Bits_6; Reserved_2 : Types.Bits_4; end record with Size => 24, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for AGC_STAT1_Type use record Reserved_1 at 0 range 0 .. 5; EDG1 at 0 range 6 .. 10; EDV2 at 0 range 11 .. 19; Reserved_2 at 0 range 20 .. 23; end record; ---------------------------------------------------------------------------- -- EXT_SYNC register file --------------------------- -- EC_CTRL sub-register -- --------------------------- type EC_CTRL_OSTSM_Field is (Disabled, Enabled) with Size => 1; -- External transmit synchronisation mode enable. type EC_CTRL_OSRSM_Field is (Disabled, Enabled) with Size => 1; -- External receive synchronisation mode enable. type EC_CTRL_PLLLDT_Field is (Disabled, Enabled) with Size => 1; -- Clock PLL lock detect tune. type EC_CTRL_WAIT_Field is range 0 .. 255 with Size => 8; -- Wait counter used for external transmit synchronisation and external -- timebase reset. -- -- The wait time is the number of external clock cycles (@ 38.4 MHz). type EC_CTRL_OSTRM_Field is (Disabled, Enabled) with Size => 1; type EC_CTRL_Type is record OSTSM : EC_CTRL_OSTSM_Field := Disabled; OSRSM : EC_CTRL_OSRSM_Field := Disabled; PLLLDT : EC_CTRL_PLLLDT_Field := Enabled; WAIT : EC_CTRL_WAIT_Field := 0; OSTRM : EC_CTRL_OSTRM_Field := Disabled; Reserved : Types.Bits_20 := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for EC_CTRL_Type use record OSTSM at 0 range 0 .. 0; OSRSM at 0 range 1 .. 1; PLLLDT at 0 range 2 .. 2; WAIT at 0 range 3 .. 10; OSTRM at 0 range 11 .. 11; Reserved at 0 range 12 .. 31; end record; --------------------------- -- EC_RXTC sub-register -- --------------------------- type EC_RCTC_RX_TS_EST_Field is range 0 .. 2**32 - 1 with Size => 32; -- External clock synchronisation counter captured on RMARKER. type EC_RXTC_Type is record RX_TS_EST : EC_RCTC_RX_TS_EST_Field; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for EC_RXTC_Type use record RX_TS_EST at 0 range 0 .. 31; end record; --------------------------- -- EC_GOLP sub-register -- --------------------------- type EC_GOLP_OFFSET_EXT_Field is range 0 .. 2**6 - 1 with Size => 6; type EC_GOLP_Type is record OFFSET_EXT : EC_GOLP_OFFSET_EXT_Field := 0; Reserved : Types.Bits_26 := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for EC_GOLP_Type use record OFFSET_EXT at 0 range 0 .. 5; Reserved at 0 range 6 .. 31; end record; ---------------------------------------------------------------------------- -- ACC_MEM register file type ACC_MEM_Number_Type is range -32_768 .. 32_767 with Size => 16; type ACC_MEM_Sample_Type is record Real : ACC_MEM_Number_Type; Imag : ACC_MEM_Number_Type; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for ACC_MEM_Sample_Type use record Real at 0 range 0 .. 15; Imag at 2 range 0 .. 15; end record; type ACC_MEM_CIR_Array is array (Types.Index range <>) of ACC_MEM_Sample_Type; type ACC_MEM_Type is record CIR : ACC_MEM_CIR_Array (0 .. 1015); end record with Size => 4064 * 8, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for ACC_MEM_Type use record CIR at 0 range 0 .. (4064 * 8) - 1; end record; ---------------------------------------------------------------------------- -- GPIO_CTRL register file ----------------------------- -- GPIO_MODE sub-register -- ----------------------------- type GPIO_MODE_MSGP0_Field is (GPIO0, RXOKLED, Reserved_10, Reserved_11) with Size => 2; -- Mode Selection for GPIO0/RXOKLED. type GPIO_MODE_MSGP1_Field is (GPIO1, SFDLED, Reserved_10, Reserved_11) with Size => 2; -- Mode Selection for GPIO1/SFDLED. type GPIO_MODE_MSGP2_Field is (GPIO2, RXLED, Reserved_10, Reserved_11) with Size => 2; -- Mode Selection for GPIO2/RXLED type GPIO_MODE_MSGP3_Field is (GPIO3, TXLED, Reserved_10, Reserved_11) with Size => 2; -- Mode Selection for GPIO3/TXLED type GPIO_MODE_MSGP4_Field is (GPIO4, EXTPA, Reserved_10, Reserved_11) with Size => 2; -- Mode Selection for GPIO4/EXTPA type GPIO_MODE_MSGP5_Field is (GPIO5, EXTTXE, Reserved_10, Reserved_11) with Size => 2; -- Mode Selection for GPIO5/EXTTXE type GPIO_MODE_MSGP6_Field is (GPIO6, EXTRXE, Reserved_10, Reserved_11) with Size => 2; -- Mode Selection for GPIO6/EXTRXE type GPIO_MODE_MSGP7_Field is (SYNC, GPIO7, Reserved_10, Reserved_11) with Size => 2; -- Mode Selection for SYNC/GPIO7 type GPIO_MODE_MSGP8_Field is (IRQ, GPIO8, Reserved_10, Reserved_11) with Size => 2; -- Mode Selection for IRQ/GPIO8 type GPIO_MODE_Type is record MSGP0 : GPIO_MODE_MSGP0_Field := GPIO0; MSGP1 : GPIO_MODE_MSGP1_Field := GPIO1; MSGP2 : GPIO_MODE_MSGP2_Field := GPIO2; MSGP3 : GPIO_MODE_MSGP3_Field := GPIO3; MSGP4 : GPIO_MODE_MSGP4_Field := GPIO4; MSGP5 : GPIO_MODE_MSGP5_Field := GPIO5; MSGP6 : GPIO_MODE_MSGP6_Field := GPIO6; MSGP7 : GPIO_MODE_MSGP7_Field := SYNC; MSGP8 : GPIO_MODE_MSGP8_Field := IRQ; Reserved_1 : Types.Bits_6 := 0; Reserved_2 : Types.Bits_8 := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for GPIO_MODE_Type use record Reserved_1 at 0 range 0 .. 5; MSGP0 at 0 range 6 .. 7; MSGP1 at 0 range 8 .. 9; MSGP2 at 0 range 10 .. 11; MSGP3 at 0 range 12 .. 13; MSGP4 at 0 range 14 .. 15; MSGP5 at 0 range 16 .. 17; MSGP6 at 0 range 18 .. 19; MSGP7 at 0 range 20 .. 21; MSGP8 at 0 range 22 .. 23; Reserved_2 at 0 range 24 .. 31; end record; ---------------------------- -- GPIO_DIR sub-register -- ---------------------------- type GPIO_DIR_GDP_Field is (Output, Input) with Size => 1; -- Direction Selection for GPIOx type GPIO_DIR_GDM_Field is (Clear, Set) with Size => 1; -- Mask for setting the direction of GPIOx. -- -- When writing to GDP0 so select the I/O direction of GPIOx, the value of -- GDPx is only changed if this GDMx mask bit is Set for the write -- operation. GDMx will always read as 0. type GPIO_DIR_Type is record GDP0 : GPIO_DIR_GDP_Field := Input; GDP1 : GPIO_DIR_GDP_Field := Input; GDP2 : GPIO_DIR_GDP_Field := Input; GDP3 : GPIO_DIR_GDP_Field := Input; GDM0 : GPIO_DIR_GDM_Field := Clear; GDM1 : GPIO_DIR_GDM_Field := Clear; GDM2 : GPIO_DIR_GDM_Field := Clear; GDM3 : GPIO_DIR_GDM_Field := Clear; GDP4 : GPIO_DIR_GDP_Field := Input; GDP5 : GPIO_DIR_GDP_Field := Input; GDP6 : GPIO_DIR_GDP_Field := Input; GDP7 : GPIO_DIR_GDP_Field := Input; GDM4 : GPIO_DIR_GDM_Field := Clear; GDM5 : GPIO_DIR_GDM_Field := Clear; GDM6 : GPIO_DIR_GDM_Field := Clear; GDM7 : GPIO_DIR_GDM_Field := Clear; GDP8 : GPIO_DIR_GDP_Field := Input; GDM8 : GPIO_DIR_GDM_Field := Clear; Reserved_1 : Types.Bits_3 := 0; Reserved_2 : Types.Bits_11 := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for GPIO_DIR_Type use record GDP0 at 0 range 0 .. 0; GDP1 at 0 range 1 .. 1; GDP2 at 0 range 2 .. 2; GDP3 at 0 range 3 .. 3; GDM0 at 0 range 4 .. 4; GDM1 at 0 range 5 .. 5; GDM2 at 0 range 6 .. 6; GDM3 at 0 range 7 .. 7; GDP4 at 0 range 8 .. 8; GDP5 at 0 range 9 .. 9; GDP6 at 0 range 10 .. 10; GDP7 at 0 range 11 .. 11; GDM4 at 0 range 12 .. 12; GDM5 at 0 range 13 .. 13; GDM6 at 0 range 14 .. 14; GDM7 at 0 range 15 .. 15; GDP8 at 0 range 16 .. 16; Reserved_1 at 0 range 17 .. 19; GDM8 at 0 range 20 .. 20; Reserved_2 at 0 range 21 .. 31; end record; ----------------------------- -- GPIO_DOUT sub-register -- ----------------------------- type GPIO_DOUT_GOM_Field is (Clear, Set) with Size => 1; type GPIO_DOUT_Type is record GOP0 : Types.Bits_1 := 0; GOP1 : Types.Bits_1 := 0; GOP2 : Types.Bits_1 := 0; GOP3 : Types.Bits_1 := 0; GOM0 : GPIO_DOUT_GOM_Field := Clear; GOM1 : GPIO_DOUT_GOM_Field := Clear; GOM2 : GPIO_DOUT_GOM_Field := Clear; GOM3 : GPIO_DOUT_GOM_Field := Clear; GOP4 : Types.Bits_1 := 0; GOP5 : Types.Bits_1 := 0; GOP6 : Types.Bits_1 := 0; GOP7 : Types.Bits_1 := 0; GOM4 : GPIO_DOUT_GOM_Field := Clear; GOM5 : GPIO_DOUT_GOM_Field := Clear; GOM6 : GPIO_DOUT_GOM_Field := Clear; GOM7 : GPIO_DOUT_GOM_Field := Clear; GOP8 : Types.Bits_1 := 0; GOM8 : GPIO_DOUT_GOM_Field := Clear; Reserved_1 : Types.Bits_3 := 0; Reserved_2 : Types.Bits_11 := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for GPIO_DOUT_Type use record GOP0 at 0 range 0 .. 0; GOP1 at 0 range 1 .. 1; GOP2 at 0 range 2 .. 2; GOP3 at 0 range 3 .. 3; GOM0 at 0 range 4 .. 4; GOM1 at 0 range 5 .. 5; GOM2 at 0 range 6 .. 6; GOM3 at 0 range 7 .. 7; GOP4 at 0 range 8 .. 8; GOP5 at 0 range 9 .. 9; GOP6 at 0 range 10 .. 10; GOP7 at 0 range 11 .. 11; GOM4 at 0 range 12 .. 12; GOM5 at 0 range 13 .. 13; GOM6 at 0 range 14 .. 14; GOM7 at 0 range 15 .. 15; GOP8 at 0 range 16 .. 16; Reserved_1 at 0 range 17 .. 19; GOM8 at 0 range 20 .. 20; Reserved_2 at 0 range 21 .. 31; end record; ----------------------------- -- GPIO_IRQE sub-register -- ----------------------------- type GPIO_IREQ_GIRQE_Field is (Disabled, Enabled) with Size => 1; -- GPIO IRQ Enable for GPIOx input. type GPIO_IRQE_Type is record GIRQE0 : GPIO_IREQ_GIRQE_Field := Disabled; GIRQE1 : GPIO_IREQ_GIRQE_Field := Disabled; GIRQE2 : GPIO_IREQ_GIRQE_Field := Disabled; GIRQE3 : GPIO_IREQ_GIRQE_Field := Disabled; GIRQE4 : GPIO_IREQ_GIRQE_Field := Disabled; GIRQE5 : GPIO_IREQ_GIRQE_Field := Disabled; GIRQE6 : GPIO_IREQ_GIRQE_Field := Disabled; GIRQE7 : GPIO_IREQ_GIRQE_Field := Disabled; GIRQE8 : GPIO_IREQ_GIRQE_Field := Disabled; Reserved : Types.Bits_23 := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for GPIO_IRQE_Type use record GIRQE0 at 0 range 0 .. 0; GIRQE1 at 0 range 1 .. 1; GIRQE2 at 0 range 2 .. 2; GIRQE3 at 0 range 3 .. 3; GIRQE4 at 0 range 4 .. 4; GIRQE5 at 0 range 5 .. 5; GIRQE6 at 0 range 6 .. 6; GIRQE7 at 0 range 7 .. 7; GIRQE8 at 0 range 8 .. 8; Reserved at 0 range 9 .. 31; end record; ----------------------------- -- GPIO_ISEN sub-register -- ----------------------------- type GPIO_ISEN_GISEN_Field is (Active_High, Active_Low) with Size => 1; -- GPIO IRQ Sense selection GPIO0 input. type GPIO_ISEN_Type is record GISEN0 : GPIO_ISEN_GISEN_Field := Active_High; GISEN1 : GPIO_ISEN_GISEN_Field := Active_High; GISEN2 : GPIO_ISEN_GISEN_Field := Active_High; GISEN3 : GPIO_ISEN_GISEN_Field := Active_High; GISEN4 : GPIO_ISEN_GISEN_Field := Active_High; GISEN5 : GPIO_ISEN_GISEN_Field := Active_High; GISEN6 : GPIO_ISEN_GISEN_Field := Active_High; GISEN7 : GPIO_ISEN_GISEN_Field := Active_High; GISEN8 : GPIO_ISEN_GISEN_Field := Active_High; Reserved : Types.Bits_23 := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for GPIO_ISEN_Type use record GISEN0 at 0 range 0 .. 0; GISEN1 at 0 range 1 .. 1; GISEN2 at 0 range 2 .. 2; GISEN3 at 0 range 3 .. 3; GISEN4 at 0 range 4 .. 4; GISEN5 at 0 range 5 .. 5; GISEN6 at 0 range 6 .. 6; GISEN7 at 0 range 7 .. 7; GISEN8 at 0 range 8 .. 8; Reserved at 0 range 9 .. 31; end record; ------------------------------ -- GPIO_IMODE sub-register -- ------------------------------ type GPIO_IMODE_GIMOD_Field is (Level, Edge) with Size => 1; -- GPIO IRQ Mode selection for GPIOx input. type GPIO_IMODE_Type is record GIMOD0 : GPIO_IMODE_GIMOD_Field := Level; GIMOD1 : GPIO_IMODE_GIMOD_Field := Level; GIMOD2 : GPIO_IMODE_GIMOD_Field := Level; GIMOD3 : GPIO_IMODE_GIMOD_Field := Level; GIMOD4 : GPIO_IMODE_GIMOD_Field := Level; GIMOD5 : GPIO_IMODE_GIMOD_Field := Level; GIMOD6 : GPIO_IMODE_GIMOD_Field := Level; GIMOD7 : GPIO_IMODE_GIMOD_Field := Level; GIMOD8 : GPIO_IMODE_GIMOD_Field := Level; Reserved : Types.Bits_23 := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for GPIO_IMODE_Type use record GIMOD0 at 0 range 0 .. 0; GIMOD1 at 0 range 1 .. 1; GIMOD2 at 0 range 2 .. 2; GIMOD3 at 0 range 3 .. 3; GIMOD4 at 0 range 4 .. 4; GIMOD5 at 0 range 5 .. 5; GIMOD6 at 0 range 6 .. 6; GIMOD7 at 0 range 7 .. 7; GIMOD8 at 0 range 8 .. 8; Reserved at 0 range 9 .. 31; end record; ----------------------------- -- GPIO_IBES sub-register -- ----------------------------- type GPIO_IBES_GIBES_Field is (Use_GPIO_IMODE, Both_Edges) with Size => 1; -- GPIO IRQ "Both Edge" selection for GPIOx input. type GPIO_IBES_Type is record GIBES0 : GPIO_IBES_GIBES_Field := Use_GPIO_IMODE; GIBES1 : GPIO_IBES_GIBES_Field := Use_GPIO_IMODE; GIBES2 : GPIO_IBES_GIBES_Field := Use_GPIO_IMODE; GIBES3 : GPIO_IBES_GIBES_Field := Use_GPIO_IMODE; GIBES4 : GPIO_IBES_GIBES_Field := Use_GPIO_IMODE; GIBES5 : GPIO_IBES_GIBES_Field := Use_GPIO_IMODE; GIBES6 : GPIO_IBES_GIBES_Field := Use_GPIO_IMODE; GIBES7 : GPIO_IBES_GIBES_Field := Use_GPIO_IMODE; GIBES8 : GPIO_IBES_GIBES_Field := Use_GPIO_IMODE; Reserved : Types.Bits_23 := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for GPIO_IBES_Type use record GIBES0 at 0 range 0 .. 0; GIBES1 at 0 range 1 .. 1; GIBES2 at 0 range 2 .. 2; GIBES3 at 0 range 3 .. 3; GIBES4 at 0 range 4 .. 4; GIBES5 at 0 range 5 .. 5; GIBES6 at 0 range 6 .. 6; GIBES7 at 0 range 7 .. 7; GIBES8 at 0 range 8 .. 8; Reserved at 0 range 9 .. 31; end record; ----------------------------- -- GPIO_ICLR sub-register -- ----------------------------- type GPIO_ICLR_GICLR_Field is (No_Action, Clear_IRQ_Latch) with Size => 1; -- GPIO IRQ latch clear for GPIOx input. type GPIO_ICLR_Type is record GICLR0 : GPIO_ICLR_GICLR_Field := No_Action; GICLR1 : GPIO_ICLR_GICLR_Field := No_Action; GICLR2 : GPIO_ICLR_GICLR_Field := No_Action; GICLR3 : GPIO_ICLR_GICLR_Field := No_Action; GICLR4 : GPIO_ICLR_GICLR_Field := No_Action; GICLR5 : GPIO_ICLR_GICLR_Field := No_Action; GICLR6 : GPIO_ICLR_GICLR_Field := No_Action; GICLR7 : GPIO_ICLR_GICLR_Field := No_Action; GICLR8 : GPIO_ICLR_GICLR_Field := No_Action; Reserved : Types.Bits_23 := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for GPIO_ICLR_Type use record GICLR0 at 0 range 0 .. 0; GICLR1 at 0 range 1 .. 1; GICLR2 at 0 range 2 .. 2; GICLR3 at 0 range 3 .. 3; GICLR4 at 0 range 4 .. 4; GICLR5 at 0 range 5 .. 5; GICLR6 at 0 range 6 .. 6; GICLR7 at 0 range 7 .. 7; GICLR8 at 0 range 8 .. 8; Reserved at 0 range 9 .. 31; end record; ----------------------------- -- GPIO_IDBE sub-register -- ----------------------------- type GPIO_IDBE_GIDBE_Field is (Disabled, Enabled) with Size => 1; -- GPIO IRQ de-bounce enable for GPIOx. type GPIO_IDBE_Type is record GIDBE0 : GPIO_IDBE_GIDBE_Field := Disabled; GIDBE1 : GPIO_IDBE_GIDBE_Field := Disabled; GIDBE2 : GPIO_IDBE_GIDBE_Field := Disabled; GIDBE3 : GPIO_IDBE_GIDBE_Field := Disabled; GIDBE4 : GPIO_IDBE_GIDBE_Field := Disabled; GIDBE5 : GPIO_IDBE_GIDBE_Field := Disabled; GIDBE6 : GPIO_IDBE_GIDBE_Field := Disabled; GIDBE7 : GPIO_IDBE_GIDBE_Field := Disabled; GIDBE8 : GPIO_IDBE_GIDBE_Field := Disabled; Reserved : Types.Bits_23 := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for GPIO_IDBE_Type use record GIDBE0 at 0 range 0 .. 0; GIDBE1 at 0 range 1 .. 1; GIDBE2 at 0 range 2 .. 2; GIDBE3 at 0 range 3 .. 3; GIDBE4 at 0 range 4 .. 4; GIDBE5 at 0 range 5 .. 5; GIDBE6 at 0 range 6 .. 6; GIDBE7 at 0 range 7 .. 7; GIDBE8 at 0 range 8 .. 8; Reserved at 0 range 9 .. 31; end record; ---------------------------- -- GPIO_RAW sub-register -- ---------------------------- type GPIO_RAW_Type is record GRAWP0 : Types.Bits_1 := 0; GRAWP1 : Types.Bits_1 := 0; GRAWP2 : Types.Bits_1 := 0; GRAWP3 : Types.Bits_1 := 0; GRAWP4 : Types.Bits_1 := 0; GRAWP5 : Types.Bits_1 := 0; GRAWP6 : Types.Bits_1 := 0; GRAWP7 : Types.Bits_1 := 0; GRAWP8 : Types.Bits_1 := 0; Reserved : Types.Bits_23 := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for GPIO_RAW_Type use record GRAWP0 at 0 range 0 .. 0; GRAWP1 at 0 range 1 .. 1; GRAWP2 at 0 range 2 .. 2; GRAWP3 at 0 range 3 .. 3; GRAWP4 at 0 range 4 .. 4; GRAWP5 at 0 range 5 .. 5; GRAWP6 at 0 range 6 .. 6; GRAWP7 at 0 range 7 .. 7; GRAWP8 at 0 range 8 .. 8; Reserved at 0 range 9 .. 31; end record; ---------------------------------------------------------------------------- -- DRX_CONF register file ------------------------------ -- DRX_TUNE0b sub-register -- ------------------------------ type DRX_TUNE0b_Field is new Bits_16; DRX_TUNE0b_110K_STD : constant DRX_TUNE0b_Field := 16#000A#; DRX_TUNE0b_110K_Non_STD : constant DRX_TUNE0b_Field := 16#0016#; DRX_TUNE0b_850K_STD : constant DRX_TUNE0b_Field := 16#0001#; DRX_TUNE0b_850K_Non_STD : constant DRX_TUNE0b_Field := 16#0006#; DRX_TUNE0b_6M8_STD : constant DRX_TUNE0b_Field := 16#0001#; DRX_TUNE0b_6M8_Non_STD : constant DRX_TUNE0b_Field := 16#0002#; type DRX_TUNE0b_Type is record DRX_TUNE0b : DRX_TUNE0b_Field; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for DRX_TUNE0b_Type use record DRX_TUNE0b at 0 range 0 .. 15; end record; ------------------------------ -- DRX_TUNE1a sub-register -- ------------------------------ type DRX_TUNE1a_Field is new Bits_16; DRX_TUNE1a_16MHz : constant DRX_TUNE1a_Field := 16#0087#; DRX_TUNE1a_64MHz : constant DRX_TUNE1a_Field := 16#008D#; type DRX_TUNE1a_Type is record DRX_TUNE1a : DRX_TUNE1a_Field; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for DRX_TUNE1a_Type use record DRX_TUNE1a at 0 range 0 .. 15; end record; ------------------------------ -- DRX_TUNE1b sub-register -- ------------------------------ type DRX_TUNE1b_Field is new Bits_16; DRX_TUNE1b_110K : constant DRX_TUNE1b_Field := 16#0064#; -- Preamble lengths > 1024 symbols, for 110 kbps operation DRX_TUNE1b_850K_6M8 : constant DRX_TUNE1b_Field := 16#0020#; -- Preamble lengths 128 to 1024 symbols, for 850 kbps and 6.8 Mbps operation DRX_TUNE1b_6M8 : constant DRX_TUNE1b_Field := 16#0010#; -- Preamble length = 64 symbols, for 6.8 Mbps operation type DRX_TUNE1b_Type is record DRX_TUNE1b : DRX_TUNE1b_Field; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for DRX_TUNE1b_Type use record DRX_TUNE1b at 0 range 0 .. 15; end record; ------------------------------ -- DRX_TUNE2 sub-register -- ------------------------------ type DRX_TUNE2_Field is new Bits_32; DRX_TUNE2_PAC8_16MHz : constant DRX_TUNE2_Field := 16#311A002D#; DRX_TUNE2_PAC8_64MHz : constant DRX_TUNE2_Field := 16#313B006B#; DRX_TUNE2_PAC16_16MHz : constant DRX_TUNE2_Field := 16#331A0052#; DRX_TUNE2_PAC16_64MHz : constant DRX_TUNE2_Field := 16#333B00BE#; DRX_TUNE2_PAC32_16MHz : constant DRX_TUNE2_Field := 16#351A009A#; DRX_TUNE2_PAC32_64MHz : constant DRX_TUNE2_Field := 16#353B015E#; DRX_TUNE2_PAC64_16MHz : constant DRX_TUNE2_Field := 16#371A011D#; DRX_TUNE2_PAC64_64MHz : constant DRX_TUNE2_Field := 16#373B0296#; type DRX_TUNE2_Type is record DRX_TUNE2 : DRX_TUNE2_Field; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for DRX_TUNE2_Type use record DRX_TUNE2 at 0 range 0 .. 31; end record; ------------------------------ -- DRX_SFDTOC sub-register -- ------------------------------ type DRX_SFDTOC_Field is range 0 .. 2**16 - 1 with Size => 16; -- SFD detection timeout count (in units of preamble symbols) type DRX_SFDTOC_Type is record DRX_SFDTOC : DRX_SFDTOC_Field; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for DRX_SFDTOC_Type use record DRX_SFDTOC at 0 range 0 .. 15; end record; ------------------------------ -- DRX_PRETOC sub-register -- ------------------------------ type DRX_PRETOC_Field is range 0 .. 2**16 - 1 with Size => 16; -- Preamble detection timeout count (in units of PAC size symbols) type DRX_PRETOC_Type is record DRX_PRETOC : DRX_PRETOC_Field; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for DRX_PRETOC_Type use record DRX_PRETOC at 0 range 0 .. 15; end record; ------------------------------ -- DRX_TUNE4H sub-register -- ------------------------------ type DRX_TUNE4H_Field is new Bits_16; DRX_TUNE4H_Preamble_64 : constant DRX_TUNE4H_Field := 16#0010#; -- 64 DRX_TUNE4H_Others : constant DRX_TUNE4H_Field := 16#0028#; -- 128 or greater type DRX_TUNE4H_Type is record DRX_TUNE4H : DRX_TUNE4H_Field; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for DRX_TUNE4H_Type use record DRX_TUNE4H at 0 range 0 .. 15; end record; -------------------------------- -- RXPACC_NOSAT sub-register -- -------------------------------- type RXPACC_NOSAT_Field is range 0 .. 2**16 - 1 with Size => 16; type RXPACC_NOSAT_Type is record RXPACC_NOSAT : RXPACC_NOSAT_Field; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for RXPACC_NOSAT_Type use record RXPACC_NOSAT at 0 range 0 .. 15; end record; ---------------------------------------------------------------------------- -- RF_CONF register file --------------------------- -- RF_CONF sub-register -- --------------------------- type RF_CONF_TXFEN_Field is new Bits_5; -- Transmit block force enable. RF_CONF_TXFEN_Force_Enable : constant RF_CONF_TXFEN_Field := 16#1F#; type RF_CONF_PLLFEN_Field is new Bits_3; -- PLL block force enables. RF_CONF_PLLFEN_Force_Enable : constant RF_CONF_PLLFEN_Field := 16#5#; type RF_CONF_LDOFEN_Field is new Bits_5; -- Write 0x1F to force the enable to all LDOs. RF_CONF_LDOFEN_Force_Enable : constant RF_CONF_LDOFEN_Field := 16#1F#; type RF_CONF_TXRXSW_Field is new Bits_2; RF_CONF_TXRXSW_Force_Tx : constant RF_CONF_TXRXSW_Field := 16#2#; RF_CONF_TXRXSW_Force_Rx : constant RF_CONF_TXRXSW_Field := 16#1#; type RF_CONF_Type is record TXFEN : RF_CONF_TXFEN_Field := 0; PLLFEN : RF_CONF_PLLFEN_Field := 0; LDOFEN : RF_CONF_LDOFEN_Field := 0; TXRXSW : RF_CONF_TXRXSW_Field := 0; Reserved_1 : Types.Bits_8 := 0; Reserved_2 : Types.Bits_9 := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for RF_CONF_Type use record Reserved_1 at 0 range 0 .. 7; TXFEN at 0 range 8 .. 12; PLLFEN at 0 range 13 .. 15; LDOFEN at 0 range 16 .. 20; TXRXSW at 0 range 21 .. 22; Reserved_2 at 0 range 23 .. 31; end record; ------------------------------ -- RF_RXCTRLH sub-register -- ------------------------------ type RF_RXCTRLH_Field is new Bits_8; RF_RXCTRLH_500MHz : constant RF_RXCTRLH_Field := 16#D8#; -- Channels 1,2,3,5 RF_RXCTRLH_900MHz : constant RF_RXCTRLH_Field := 16#BC#; -- Channels 4,7 type RF_RXCTRLH_Type is record RF_RXCTRLH : RF_RXCTRLH_Field; end record with Size => 8, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for RF_RXCTRLH_Type use record RF_RXCTRLH at 0 range 0 .. 7; end record; ----------------------------- -- RF_TXCTRL sub-register -- ----------------------------- type RF_TXCTRL_Field is new Bits_32; RF_TXCTRL_Channel_1 : constant RF_TXCTRL_Field := 16#00005C40#; RF_TXCTRL_Channel_2 : constant RF_TXCTRL_Field := 16#00045CA0#; RF_TXCTRL_Channel_3 : constant RF_TXCTRL_Field := 16#00086CC0#; RF_TXCTRL_Channel_4 : constant RF_TXCTRL_Field := 16#00045C80#; RF_TXCTRL_Channel_5 : constant RF_TXCTRL_Field := 16#001E3FE3#; RF_TXCTRL_Channel_7 : constant RF_TXCTRL_Field := 16#001E7DE0#; type RF_TXCTRL_Type is record RF_TXCTRL : RF_TXCTRL_Field; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for RF_TXCTRL_Type use record RF_TXCTRL at 0 range 0 .. 31; end record; ----------------------------- -- RF_STATUS sub-register -- ----------------------------- type RF_STATUS_CPLLLOCK_Field is (Not_Locked, Locked) with Size => 1; -- Clock PLL Lock status. type RF_STATUS_CPLLLOW_Field is (Not_Low, Low) with Size => 1; -- Clock PLL Low flag status. type RF_STATUS_CPLLHIGH_Field is (Not_High, High) with Size => 1; -- Clock PLL High flag status. type RF_STATUS_RFPLLLOCK_Field is (Not_Locked, Locked) with Size => 1; -- RF PLL Lock status. type RF_STATUS_Type is record CPLLLOCK : RF_STATUS_CPLLLOCK_Field := Not_Locked; CPLLLOW : RF_STATUS_CPLLLOW_Field := Not_Low; CPLLHIGH : RF_STATUS_CPLLHIGH_Field := Not_High; RFPLLLOCK : RF_STATUS_RFPLLLOCK_Field := Not_Locked; Reserved : Types.Bits_4 := 0; end record with Size => 8, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for RF_STATUS_Type use record CPLLLOCK at 0 range 0 .. 0; CPLLLOW at 0 range 1 .. 1; CPLLHIGH at 0 range 2 .. 2; RFPLLLOCK at 0 range 3 .. 3; Reserved at 0 range 4 .. 7; end record; --------------------------- -- LDOTUNE sub-register -- --------------------------- type LDOTUNE_Field is new Bits_40; type LDOTUNE_Type is record LDOTUNE : LDOTUNE_Field := 16#88_8888_8888#; end record with Size => 40, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for LDOTUNE_Type use record LDOTUNE at 0 range 0 .. 39; end record; ---------------------------------------------------------------------------- -- TX_CAL register file --------------------------- -- TC_SARC sub-register -- --------------------------- type TC_SARC_SAR_CTRL_Field is (Disabled, Enabled) with Size => 1; -- Enable or disable the SAR type TC_SARC_Type is record SAR_CTRL : TC_SARC_SAR_CTRL_Field := Disabled; Reserved : Types.Bits_15 := 0; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for TC_SARC_Type use record SAR_CTRL at 0 range 0 .. 0; Reserved at 0 range 1 .. 15; end record; --------------------------- -- TC_SARL sub-register -- --------------------------- type TC_SARL_SAR_LVBAT_Field is range 0 .. 255 with Size => 8; -- Latest SAR reading for Voltage level. type TC_SARL_SAR_LTEMP_Field is range 0 .. 255 with Size => 8; -- Latest SAR reading for Temperature level. type TC_SARL_Type is record SAR_LVBAT : TC_SARL_SAR_LVBAT_Field := 0; SAR_LTEMP : TC_SARL_SAR_LTEMP_Field := 0; Reserved : Types.Bits_8 := 0; end record with Size => 24, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for TC_SARL_Type use record SAR_LVBAT at 0 range 0 .. 7; SAR_LTEMP at 0 range 8 .. 15; Reserved at 0 range 16 .. 23; end record; --------------------------- -- TC_SARW sub-register -- --------------------------- type TC_SARW_WVBAT_Field is range 0 .. 255 with Size => 8; -- SAR reading of Voltage level taken at last wakeup event. type TC_SARW_WTEMP_Field is range 0 .. 255 with Size => 8; -- SAR reading of temperature level taken at last wakeup event. type TC_SARW_Type is record SAR_WVBAT : TC_SARW_WVBAT_Field := 0; SAR_WTEMP : TC_SARW_WTEMP_Field := 0; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for TC_SARW_Type use record SAR_WVBAT at 0 range 0 .. 7; SAR_WTEMP at 0 range 8 .. 15; end record; ------------------------------- -- TC_PG_CTRL sub-register -- ------------------------------- type TC_PG_CTRL_PG_START_Field is (No_Action, Start) with Size => 1; -- Start the pulse generator calibration. type TC_PG_CTRL_PG_TMEAS_Field is range 0 .. 15 with Size => 4; -- Number of clock cycles over which to run the pulse generator cal counter. type TC_PG_CTRL_Type is record PG_START : TC_PG_CTRL_PG_START_Field := No_Action; PG_TMEAS : TC_PG_CTRL_PG_TMEAS_Field := 0; Reserved_1 : Bits_1; Reserved_2 : Bits_2; end record with Size => 8, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for TC_PG_CTRL_Type use record PG_START at 0 range 0 .. 0; Reserved_1 at 0 range 1 .. 1; PG_TMEAS at 0 range 2 .. 5; Reserved_2 at 0 range 6 .. 7; end record; --------------------------------- -- TC_PG_STATUS sub-register -- --------------------------------- type TC_PG_STATUS_DELAY_CNT_Field is range 0 .. 2**12 - 1 with Size => 12; -- Reference value required for temperature bandwidth compensation type TC_PG_STATUS_Type is record DELAY_CNT : TC_PG_STATUS_DELAY_CNT_Field := 0; Reserved : Bits_4; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for TC_PG_STATUS_Type use record DELAY_CNT at 0 range 0 .. 11; Reserved at 0 range 12 .. 15; end record; ------------------------------ -- TC_PGDELAY sub-register -- ------------------------------ type TC_PGDELAY_Field is new Bits_8; -- 8-bit configuration register for setting the Pulse Generator Delay value. TC_PGDELAY_Channel_1 : constant TC_PGDELAY_Field := 16#C9#; TC_PGDELAY_Channel_2 : constant TC_PGDELAY_Field := 16#C2#; TC_PGDELAY_Channel_3 : constant TC_PGDELAY_Field := 16#C5#; TC_PGDELAY_Channel_4 : constant TC_PGDELAY_Field := 16#95#; TC_PGDELAY_Channel_5 : constant TC_PGDELAY_Field := 16#B5#; TC_PGDELAY_Channel_7 : constant TC_PGDELAY_Field := 16#93#; type TC_PGDELAY_Type is record TC_PGDELAY : TC_PGDELAY_Field; end record with Size => 8, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for TC_PGDELAY_Type use record TC_PGDELAY at 0 range 0 .. 7; end record; ----------------------------- -- TC_PGTEST sub-register -- ----------------------------- type TC_PGTEST_Field is new Bits_8; -- 8-bit configuration register for use in setting the transmitter into -- continuous wave (CW) mode. TC_PGTEST_Normal_Operation : constant TC_PGTEST_Field := 16#00#; TC_PGTEST_Continuous_Wave : constant TC_PGTEST_Field := 16#13#; type TC_PGTEST_Type is record TC_PGTEST : TC_PGTEST_Field := TC_PGTEST_Normal_Operation; end record with Size => 8, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for TC_PGTEST_Type use record TC_PGTEST at 0 range 0 .. 7; end record; ---------------------------------------------------------------------------- -- FS_CTRL register file ----------------------------- -- FS_PLLCFG sub-register -- ----------------------------- type FS_PLLCFG_Field is new Bits_32; FS_PLLCFG_Channel_1 : constant FS_PLLCFG_Field := 16#09000407#; FS_PLLCFG_Channel_2 : constant FS_PLLCFG_Field := 16#08400508#; FS_PLLCFG_Channel_3 : constant FS_PLLCFG_Field := 16#08401009#; FS_PLLCFG_Channel_4 : constant FS_PLLCFG_Field := 16#08400508#; FS_PLLCFG_Channel_5 : constant FS_PLLCFG_Field := 16#0800041D#; FS_PLLCFG_Channel_7 : constant FS_PLLCFG_Field := 16#0800041D#; type FS_PLLCFG_Type is record FS_PLLCFG : FS_PLLCFG_Field; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for FS_PLLCFG_Type use record FS_PLLCFG at 0 range 0 .. 31; end record; ------------------------------ -- FS_PLLTUNE sub-register -- ------------------------------ type FS_PLLTUNE_Field is new Bits_8; FS_PLLTUNE_Channel_1 : constant FS_PLLTUNE_Field := 16#1E#; FS_PLLTUNE_Channel_2 : constant FS_PLLTUNE_Field := 16#26#; FS_PLLTUNE_Channel_3 : constant FS_PLLTUNE_Field := 16#56#; FS_PLLTUNE_Channel_4 : constant FS_PLLTUNE_Field := 16#26#; FS_PLLTUNE_Channel_5 : constant FS_PLLTUNE_Field := 16#BE#; FS_PLLTUNE_Channel_7 : constant FS_PLLTUNE_Field := 16#BE#; type FS_PLLTUNE_Type is record FS_PLLTUNE : FS_PLLTUNE_Field; end record with Size => 8, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for FS_PLLTUNE_Type use record FS_PLLTUNE at 0 range 0 .. 7; end record; ---------------------------- -- FS_XTALT sub-register -- ---------------------------- type FS_XTALT_Field is range 0 .. 2**5 - 1 with Size => 5; -- Crystal Trim. type FS_XTALT_Type is record XTALT : FS_XTALT_Field := 0; Reserved : Types.Bits_3 := 2#011#; end record with Size => 8, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for FS_XTALT_Type use record XTALT at 0 range 0 .. 4; Reserved at 0 range 5 .. 7; end record; ---------------------------------------------------------------------------- -- AON register file ---------------------------- -- AON_WCFG sub-register -- ---------------------------- type AON_WCFG_ONW_RADC_Field is (Disabled, Enabled) with Size => 1; -- On Wake-up Run the (temperature and voltage) Analog-to-Digital Convertors. type AON_WCFG_ONW_RX_Field is (Disabled, Enabled) with Size => 1; -- On Wake-up turn on the Receiver. type AON_WCFG_ONW_LEUI_Field is (Disabled, Enabled) with Size => 1; -- On Wake-up load the EUI from OTP memory into the EUI register. type AON_WCFG_ONW_LDC_Field is (Disabled, Enabled) with Size => 1; -- On Wake-upload configurations from the AON memory into the host -- interface register set. type AON_WCFG_ONW_L64_Field is (Disabled, Enabled) with Size => 1; -- On Wake-up load the Length64 receiver operating parameter set. type AON_WCFG_PRES_SLEEP_Field is (Disabled, Enabled) with Size => 1; -- Preserve Sleep. type AON_WCFG_ONW_LLDE_Field is (Disabled, Enabled) with Size => 1; -- On Wake-up load the LDE microcode. type AON_WCFG_ONW_LLD0_Field is (Disabled, Enabled) with Size => 1; -- On Wake-up load the LDOTUNE value from OTP. type AON_WCFG_Type is record ONW_RADC : AON_WCFG_ONW_RADC_Field := Disabled; ONW_RX : AON_WCFG_ONW_RX_Field := Disabled; ONW_LEUI : AON_WCFG_ONW_LEUI_Field := Disabled; ONW_LDC : AON_WCFG_ONW_LDC_Field := Disabled; ONW_L64 : AON_WCFG_ONW_L64_Field := Disabled; PRES_SLEEP : AON_WCFG_PRES_SLEEP_Field := Disabled; ONW_LLDE : AON_WCFG_ONW_LLDE_Field := Disabled; ONW_LLD0 : AON_WCFG_ONW_LLD0_Field := Disabled; Reserved_1 : Types.Bits_1 := 0; Reserved_2 : Types.Bits_2 := 0; Reserved_3 : Types.Bits_2 := 0; Reserved_4 : Types.Bits_3 := 0; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for AON_WCFG_Type use record ONW_RADC at 0 range 0 .. 0; ONW_RX at 0 range 1 .. 1; Reserved_1 at 0 range 2 .. 2; ONW_LEUI at 0 range 3 .. 3; Reserved_2 at 0 range 4 .. 5; ONW_LDC at 0 range 6 .. 6; ONW_L64 at 0 range 7 .. 7; PRES_SLEEP at 0 range 8 .. 8; Reserved_3 at 0 range 9 .. 10; ONW_LLDE at 0 range 11 .. 11; ONW_LLD0 at 0 range 12 .. 12; Reserved_4 at 0 range 13 .. 15; end record; ---------------------------- -- AON_CTRL sub-register -- ---------------------------- type AON_CTRL_RESTORE_Field is (No_Action, Restore) with Size => 1; -- When this bit is set the DW1000 will copy the user configurations from -- the AON memory to the host interface register set. type AON_CTRL_SAVE_Field is (No_Action, Save) with Size => 1; -- When this bit is set the DW1000 will copy the user configurations from -- the host interface register set into the AON memory. type AON_CTRL_UPL_CFG_Field is (No_Action, Upload) with Size => 1; -- Upload the AON block configurations to the AON. type AON_CTRL_DCA_READ_Field is (No_Action, Trigger_Read) with Size => 1; -- Direct AON memory access read. type AON_CTRL_DCA_ENAB_Field is (Disabled, Enabled) with Size => 1; -- Direct AON memory access enable bit. type AON_CTRL_Type is record RESTORE : AON_CTRL_RESTORE_Field := No_Action; SAVE : AON_CTRL_SAVE_Field := No_Action; UPL_CFG : AON_CTRL_UPL_CFG_Field := No_Action; DCA_READ : AON_CTRL_DCA_READ_Field := No_Action; DCA_ENAB : AON_CTRL_DCA_ENAB_Field := Disabled; Reserved : Types.Bits_3 := 0; end record with Size => 8, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for AON_CTRL_Type use record RESTORE at 0 range 0 .. 0; SAVE at 0 range 1 .. 1; UPL_CFG at 0 range 2 .. 2; DCA_READ at 0 range 3 .. 3; Reserved at 0 range 4 .. 6; DCA_ENAB at 0 range 7 .. 7; end record; ---------------------------- -- AON_RDAT sub-register -- ---------------------------- type AON_RDAT_Type is record AON_RDAT : Types.Bits_8; end record with Size => 8, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for AON_RDAT_Type use record AON_RDAT at 0 range 0 .. 7; end record; ---------------------------- -- AON_ADDR sub-register -- ---------------------------- type AON_ADDR_Field is new Bits_8; type AON_ADDR_Type is record AON_ADDR : AON_ADDR_Field; end record with Size => 8, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for AON_ADDR_Type use record AON_ADDR at 0 range 0 .. 7; end record; ---------------------------- -- AON_CFG0 sub-register -- ---------------------------- type AON_CFG0_SLEEP_EN_Field is (Disabled, Enabled) with Size => 1; -- This is the sleep enable configuration bit. type AON_CFG0_WAKE_PIN_Field is (Disabled, Enabled) with Size => 1; -- Wake using WAKEUP pin. type AON_CFG0_WAKE_SPI_Pin_Field is (Disabled, Enabled) with Size => 1; -- Wake using SPI access. type AON_CFG0_WAKE_CNT_Pin_Field is (Disabled, Enabled) with Size => 1; -- Wake when sleep counter elapses. type AON_CFG0_LPDIV_EN_Field is (Disabled, Enabled) with Size => 1; -- Low power divider enable configuration. type AON_CFG0_LPCLKDIVA_Field is range 0 .. 2**11 - 1 with Size => 11; -- This field specifies a divider count for dividing the raw DW1000 XTAL -- oscillator frequency to set an LP clock frequency. type AON_CFG0_SLEEP_TIM_Field is range 0 .. 2**16 - 1 with Size => 16; -- Sleep time. type AON_CFG0_Type is record SLEEP_EN : AON_CFG0_SLEEP_EN_Field := Disabled; WAKE_PIN : AON_CFG0_WAKE_PIN_Field := Enabled; WAKE_SPI : AON_CFG0_WAKE_SPI_Pin_Field := Enabled; WAKE_CNT : AON_CFG0_WAKE_CNT_Pin_Field := Enabled; LPDIV_EN : AON_CFG0_LPDIV_EN_Field := Disabled; LPCLKDIVA : AON_CFG0_LPCLKDIVA_Field := 255; SLEEP_TIM : AON_CFG0_SLEEP_TIM_Field := 20735; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for AON_CFG0_Type use record SLEEP_EN at 0 range 0 .. 0; WAKE_PIN at 0 range 1 .. 1; WAKE_SPI at 0 range 2 .. 2; WAKE_CNT at 0 range 3 .. 3; LPDIV_EN at 0 range 4 .. 4; LPCLKDIVA at 0 range 5 .. 15; SLEEP_TIM at 0 range 16 .. 31; end record; ---------------------------- -- AON_CFG1 sub-register -- ---------------------------- type AON_CFG1_SLEEP_CE_Field is (Disabled, Enabled) with Size => 1; -- This bit enables the sleep counter. type AON_CFG1_SMXX_Field is (Clear, Set) with Size => 1; -- This bit needs to be Cleared for correct operation in the SLEEP state -- within the DW1000. By default this bit is Set. type AON_CFG1_LPOSC_C_Field is (Disabled, Enabled) with Size => 1; -- This bit enables the calibration function that measures the period of the -- IC's internal low powered oscillator type AON_CFG1_Type is record SLEEP_CE : AON_CFG1_SLEEP_CE_Field := Enabled; SMXX : AON_CFG1_SMXX_Field := Set; LPOSC_C : AON_CFG1_LPOSC_C_Field := Enabled; Reserved : Types.Bits_13 := 0; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for AON_CFG1_Type use record SLEEP_CE at 0 range 0 .. 0; SMXX at 0 range 1 .. 1; LPOSC_C at 0 range 2 .. 2; Reserved at 0 range 3 .. 15; end record; ---------------------------------------------------------------------------- -- OTP_IF register file ---------------------------- -- OTP_WDAT sub-register -- ---------------------------- type OTP_WDAT_Type is record OTP_WDAT : Types.Bits_32; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for OTP_WDAT_Type use record OTP_WDAT at 0 range 0 .. 31; end record; ---------------------------- -- OTP_ADDR sub-register -- ---------------------------- type OTP_ADDR_Field is new Bits_11; type OTP_ADDR_Type is record OTP_ADDR : OTP_ADDR_Field; Reserved : Types.Bits_5 := 0; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for OTP_ADDR_Type use record OTP_ADDR at 0 range 0 .. 10; Reserved at 0 range 11 .. 15; end record; ---------------------------- -- OTP_CTRL sub-register -- ---------------------------- type OTP_CTRL_OPTRDEN_Field is (Disabled, Enabled) with Size => 1; -- This bit forces the OTP into manual read mode. type OTP_CTRL_OTPREAD_Field is (No_Action, Trigger_Read) with Size => 1; -- This bit commands a read operation from the address specified in the -- OTP_ADDR register, the value read will then be available in the OTP_RDAT -- register. type OTP_CTRL_OTPMRWR_Field is (Clear, Set) with Size => 1; -- OTP mode register write. type OTP_CTRL_PPROG_Field is (Clear, Set) with Size => 1; -- Setting this bit will cause the contents of OTP_WDAT to be written to -- OTP_ADDR. type OTP_CTRL_OTPMR_Field is (Clear, Set) with Size => 1; type OTP_CTRL_LDELOAD_Field is (No_Action, Load_LDE_Microcode) with Size => 1; -- This bit forces a load of LDE microcode. type OTP_CTRL_Type is record OTPRDEN : OTP_CTRL_OPTRDEN_Field := Disabled; OTPREAD : OTP_CTRL_OTPREAD_Field := No_Action; OTPMRWR : OTP_CTRL_OTPMRWR_Field := Clear; OTPPROG : OTP_CTRL_PPROG_Field := Clear; OTPMR : OTP_CTRL_OTPMR_Field := Clear; LDELOAD : OTP_CTRL_LDELOAD_Field := No_Action; Reserved_1 : Types.Bits_1 := 0; Reserved_2 : Types.Bits_2 := 0; Reserved_3 : Types.Bits_4 := 0; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for OTP_CTRL_Type use record OTPRDEN at 0 range 0 .. 0; OTPREAD at 0 range 1 .. 1; Reserved_1 at 0 range 2 .. 2; OTPMRWR at 0 range 3 .. 3; Reserved_2 at 0 range 4 .. 5; OTPPROG at 0 range 6 .. 6; OTPMR at 0 range 7 .. 10; Reserved_3 at 0 range 11 .. 14; LDELOAD at 0 range 15 .. 15; end record; ---------------------------- -- OTP_STAT sub-register -- ---------------------------- type OTP_STAT_Type is record OTPPRGD : Types.Bits_1 := 0; OTPVPOK : Types.Bits_1 := 0; Reserved : Types.Bits_14 := 0; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for OTP_STAT_Type use record OTPPRGD at 0 range 0 .. 0; OTPVPOK at 0 range 1 .. 1; Reserved at 0 range 2 .. 15; end record; ---------------------------- -- OTP_RDAT sub-register -- ---------------------------- type OTP_RDAT_Type is record OTP_RDAT : Types.Bits_32; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for OTP_RDAT_Type use record OTP_RDAT at 0 range 0 .. 31; end record; ----------------------------- -- OTP_SRDAT sub-register -- ----------------------------- type OTP_SRDAT_Type is record OTP_SRDAT : Types.Bits_32; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for OTP_SRDAT_Type use record OTP_SRDAT at 0 range 0 .. 31; end record; -------------------------- -- OTP_SF sub-register -- -------------------------- type OTP_SF_OPS_KICK_Field is (Clear, Set) with Size => 1; -- This bit when set initiates a load of the operating parameter set -- selected by the OPS_SEL configuration below. type OTP_SF_LDO_KICK_Field is (Clear, Set) with Size => 1; -- This bit when set initiates the loading of the LDOTUNE_CAL parameter -- from OTP address 0x4 into the LDOTUNE register type OTP_SF_OPS_SEL_Field is (Length64, Tight, Default, Reserved) with Size => 2; -- Operating parameter set selection. type OTP_SF_Type is record OPS_KICK : OTP_SF_OPS_KICK_Field := Clear; LDO_KICK : OTP_SF_LDO_KICK_Field := Clear; OPS_SEL : OTP_SF_OPS_SEL_Field := Length64; Reserved_1 : Types.Bits_3 := 0; Reserved_2 : Types.Bits_1 := 0; end record with Size => 8, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for OTP_SF_Type use record OPS_KICK at 0 range 0 .. 0; LDO_KICK at 0 range 1 .. 1; Reserved_1 at 0 range 2 .. 4; OPS_SEL at 0 range 5 .. 6; Reserved_2 at 0 range 7 .. 7; end record; ---------------------------------------------------------------------------- -- LDE_IF register file ------------------------------ -- LDE_THRESH sub-register -- ------------------------------ type LDE_THRESH_Field is range 0 .. 2**16 - 1 with Size => 16; type LDE_THRESH_Type is record LDE_THRESH : LDE_THRESH_Field; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for LDE_THRESH_Type use record LDE_THRESH at 0 range 0 .. 15; end record; ---------------------------- -- LDE_CFG1 sub-register -- ---------------------------- type LDE_CFG1_NTM_Field is range 0 .. 31 with Size => 5; -- Noise Threshold Multiplier. type LDE_CFG1_PMULT_Field is range 0 .. 7 with Size => 3; -- Peak Multiplier. type LDE_CFG1_Type is record NTM : LDE_CFG1_NTM_Field := 12; PMULT : LDE_CFG1_PMULT_Field := 3; end record with Size => 8, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for LDE_CFG1_Type use record NTM at 0 range 0 .. 4; PMULT at 0 range 5 .. 7; end record; ------------------------------ -- LDE_PPINDX sub-register -- ------------------------------ type LDE_PPINDX_Field is range 0 .. 2**16 - 1 with Size => 16; type LDE_PPINDX_Type is record LDE_PPINDX : LDE_PPINDX_Field; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for LDE_PPINDX_Type use record LDE_PPINDX at 0 range 0 .. 15; end record; ------------------------------ -- LDE_PPAMPL sub-register -- ------------------------------ type LDE_PPAMLP_Field is range 0 .. 2**16 - 1 with Size => 16; type LDE_PPAMPL_Type is record LDE_PPAMPL : LDE_PPAMLP_Field; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for LDE_PPAMPL_Type use record LDE_PPAMPL at 0 range 0 .. 15; end record; ------------------------------ -- LDE_RXANTD sub-register -- ------------------------------ type LDE_RXANTD_Type is record LDE_RXANTD : System_Time.Antenna_Delay_Time; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for LDE_RXANTD_Type use record LDE_RXANTD at 0 range 0 .. 15; end record; ---------------------------- -- LDE_CFG2 sub-register -- ---------------------------- type LDE_CFG2_Field is new Bits_16; LDE_CFG2_16MHz : constant LDE_CFG2_Field := 16#1607#; LDE_CFG2_64MHz : constant LDE_CFG2_Field := 16#0607#; type LDE_CFG2_Type is record LDE_CFG2 : LDE_CFG2_Field; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for LDE_CFG2_Type use record LDE_CFG2 at 0 range 0 .. 15; end record; ---------------------------- -- LDE_REPC sub-register -- ---------------------------- type LDE_REPC_Field is new Bits_16; LDE_REPC_PCODE_1 : constant LDE_REPC_Field := 16#5998#; LDE_REPC_PCODE_2 : constant LDE_REPC_Field := 16#5998#; LDE_REPC_PCODE_3 : constant LDE_REPC_Field := 16#51EA#; LDE_REPC_PCODE_4 : constant LDE_REPC_Field := 16#428E#; LDE_REPC_PCODE_5 : constant LDE_REPC_Field := 16#451E#; LDE_REPC_PCODE_6 : constant LDE_REPC_Field := 16#2E14#; LDE_REPC_PCODE_7 : constant LDE_REPC_Field := 16#8000#; LDE_REPC_PCODE_8 : constant LDE_REPC_Field := 16#51EA#; LDE_REPC_PCODE_9 : constant LDE_REPC_Field := 16#28F4#; LDE_REPC_PCODE_10 : constant LDE_REPC_Field := 16#3332#; LDE_REPC_PCODE_11 : constant LDE_REPC_Field := 16#3AE0#; LDE_REPC_PCODE_12 : constant LDE_REPC_Field := 16#3D70#; LDE_REPC_PCODE_13 : constant LDE_REPC_Field := 16#3AE0#; LDE_REPC_PCODE_14 : constant LDE_REPC_Field := 16#35C2#; LDE_REPC_PCODE_15 : constant LDE_REPC_Field := 16#2B84#; LDE_REPC_PCODE_16 : constant LDE_REPC_Field := 16#35C2#; LDE_REPC_PCODE_17 : constant LDE_REPC_Field := 16#3332#; LDE_REPC_PCODE_18 : constant LDE_REPC_Field := 16#35C2#; LDE_REPC_PCODE_19 : constant LDE_REPC_Field := 16#35C2#; LDE_REPC_PCODE_20 : constant LDE_REPC_Field := 16#47AE#; LDE_REPC_PCODE_21 : constant LDE_REPC_Field := 16#3AE0#; LDE_REPC_PCODE_22 : constant LDE_REPC_Field := 16#3850#; LDE_REPC_PCODE_23 : constant LDE_REPC_Field := 16#30A2#; LDE_REPC_PCODE_24 : constant LDE_REPC_Field := 16#3850#; type LDE_REPC_Type is record LDE_REPC : LDE_REPC_Field; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for LDE_REPC_Type use record LDE_REPC at 0 range 0 .. 15; end record; ---------------------------------------------------------------------------- -- DIG_DIAG register file ---------------------------- -- EVC_CTRL sub-register -- ---------------------------- type EVC_CTRL_EVC_EN_Field is (Disabled, Enabled) with Size => 1; -- Event Counters Enable. type EVC_CTRL_EVC_CLR_Field is (No_Action, Clear_Counters) with Size => 1; -- Event Counters Clear. type EVC_CTRL_Type is record EVC_EN : EVC_CTRL_EVC_EN_Field := Disabled; EVC_CLR : EVC_CTRL_EVC_CLR_Field := No_Action; Reserved : Types.Bits_30 := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for EVC_CTRL_Type use record EVC_EN at 0 range 0 .. 0; EVC_CLR at 0 range 1 .. 1; Reserved at 0 range 2 .. 31; end record; --------------------------- -- EVC_PHE sub-register -- --------------------------- type EVC_Counter_Field is range 0 .. 2**12 - 1 with Size => 12; -- Event counter field type EVC_PHE_Type is record EVC_PHE : EVC_Counter_Field := 0; Reserved : Types.Bits_4 := 0; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for EVC_PHE_Type use record EVC_PHE at 0 range 0 .. 11; Reserved at 0 range 12 .. 15; end record; --------------------------- -- EVC_RSE sub-register -- --------------------------- type EVC_RSE_Type is record EVC_RSE : EVC_Counter_Field := 0; Reserved : Types.Bits_4 := 0; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for EVC_RSE_Type use record EVC_RSE at 0 range 0 .. 11; Reserved at 0 range 12 .. 15; end record; --------------------------- -- EVC_FCG sub-register -- --------------------------- type EVC_FCG_Type is record EVC_FCG : EVC_Counter_Field := 0; Reserved : Types.Bits_4 := 0; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for EVC_FCG_Type use record EVC_FCG at 0 range 0 .. 11; Reserved at 0 range 12 .. 15; end record; --------------------------- -- EVC_FCE sub-register -- --------------------------- type EVC_FCE_Type is record EVC_FCE : EVC_Counter_Field := 0; Reserved : Types.Bits_4 := 0; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for EVC_FCE_Type use record EVC_FCE at 0 range 0 .. 11; Reserved at 0 range 12 .. 15; end record; --------------------------- -- EVC_FFR sub-register -- --------------------------- type EVC_FFR_Type is record EVC_FFR : EVC_Counter_Field := 0; Reserved : Types.Bits_4 := 0; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for EVC_FFR_Type use record EVC_FFR at 0 range 0 .. 11; Reserved at 0 range 12 .. 15; end record; --------------------------- -- EVC_OVR sub-register -- --------------------------- type EVC_OVR_Type is record EVC_OVR : EVC_Counter_Field := 0; Reserved : Types.Bits_4 := 0; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for EVC_OVR_Type use record EVC_OVR at 0 range 0 .. 11; Reserved at 0 range 12 .. 15; end record; --------------------------- -- EVC_STO sub-register -- --------------------------- type EVC_STO_Type is record EVC_STO : EVC_Counter_Field := 0; Reserved : Types.Bits_4 := 0; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for EVC_STO_Type use record EVC_STO at 0 range 0 .. 11; Reserved at 0 range 12 .. 15; end record; --------------------------- -- EVC_PTO sub-register -- --------------------------- type EVC_PTO_Type is record EVC_PTO : EVC_Counter_Field := 0; Reserved : Types.Bits_4 := 0; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for EVC_PTO_Type use record EVC_PTO at 0 range 0 .. 11; Reserved at 0 range 12 .. 15; end record; ---------------------------- -- EVC_FWTO sub-register -- ---------------------------- type EVC_FWTO_Type is record EVC_FWTO : EVC_Counter_Field := 0; Reserved : Types.Bits_4 := 0; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for EVC_FWTO_Type use record EVC_FWTO at 0 range 0 .. 11; Reserved at 0 range 12 .. 15; end record; ---------------------------- -- EVC_TXFS sub-register -- ---------------------------- type EVC_TXFS_Type is record EVC_TXFS : EVC_Counter_Field := 0; Reserved : Types.Bits_4 := 0; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for EVC_TXFS_Type use record EVC_TXFS at 0 range 0 .. 11; Reserved at 0 range 12 .. 15; end record; --------------------------- -- EVC_HPW sub-register -- --------------------------- type EVC_HPW_Type is record EVC_HPW : EVC_Counter_Field := 0; Reserved : Types.Bits_4 := 0; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for EVC_HPW_Type use record EVC_HPW at 0 range 0 .. 11; Reserved at 0 range 12 .. 15; end record; --------------------------- -- EVC_TPW sub-register -- --------------------------- type EVC_TPW_Type is record EVC_TPW : EVC_Counter_Field := 0; Reserved : Types.Bits_4; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for EVC_TPW_Type use record EVC_TPW at 0 range 0 .. 11; Reserved at 0 range 12 .. 15; end record; ---------------------------- -- DIAG_TMC sub-register -- ---------------------------- type DIAG_TMC_TX_PSTM_Field is (Disabled, Enabled) with Size => 1; -- Transmit Power Spectrum Test Mode. type DIAG_TMC_Type is record TX_PSTM : DIAG_TMC_TX_PSTM_Field := Disabled; Reserved_1 : Types.Bits_4 := 0; Reserved_2 : Types.Bits_11 := 0; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for DIAG_TMC_Type use record Reserved_1 at 0 range 0 .. 3; TX_PSTM at 0 range 4 .. 4; Reserved_2 at 0 range 5 .. 15; end record; ---------------------------------------------------------------------------- -- PMSC register file type PMSC_CTRL0_SYSCLKS_Field is (Auto, Force_XTI, Force_PLL, Reserved) with Size => 2; -- System Clock Selection. type PMSC_CTRL0_RXCLKS_Field is (Auto, Force_XTI, Force_PLL, Force_Off) with Size => 2; -- Receiver Clock Selection. type PMSC_CTRL0_TXCLKS_Field is new PMSC_CTRL0_RXCLKS_Field; -- Transmitter Clock Selection. type PMSC_CTRL0_FACE_Field is (Disabled, Enabled) with Size => 1; -- Force Accumulator Clock Enable. type PMSC_CTRL0_ADCCE_Field is (Disabled, Enabled) with Size => 1; -- (temperature and voltage) Analog-to-Digital Convertor Clock Enable. type PMSC_CTRL0_AMCE_Field is (Disabled, Enabled) with Size => 1; -- Accumulator Memory Clock Enable. type PMSC_CTRL0_GPCE_Field is (Disabled, Enabled) with Size => 1; -- GPIO clock Enable. type PMSC_CTRL0_GPRN_Field is (Disabled, Enabled) with Size => 1; -- GPIO reset (NOT), active low. type PMSC_CTRL0_GPDCE_Field is (Disabled, Enabled) with Size => 1; -- GPIO De-bounce Clock Enable. type PMSC_CTRL0_GPDRN_Field is (Disabled, Enabled) with Size => 1; -- GPIO de-bounce reset (NOT), active low. type PMSC_CTRL0_KHZCLKEN_Field is (Disabled, Enabled) with Size => 1; -- Kilohertz clock Enable. type PMSC_CTRL0_PLL2_SEQ_EN_Field is (Normal, Sniff) with Size => 1; type PMSC_CTRL0_SOFTRESET_Field is new Bits_4; -- These four bits reset the IC TX, RX, Host Interface and the PMSC itself, -- essentially allowing a reset of the IC under software control. PMSC_CTRL0_SOFTRESET_Reset : constant PMSC_CTRL0_SOFTRESET_Field := 2#0000#; PMSC_CTRL0_SOFTRESET_Reset_Rx : constant PMSC_CTRL0_SOFTRESET_Field := 2#0111#; PMSC_CTRL0_SOFTRESET_Set_All : constant PMSC_CTRL0_SOFTRESET_Field := 2#1111#; type PMSC_CTRL0_Type is record SYSCLKS : PMSC_CTRL0_SYSCLKS_Field := Auto; RXCLKS : PMSC_CTRL0_RXCLKS_Field := Auto; TXCLKS : PMSC_CTRL0_TXCLKS_Field := Auto; FACE : PMSC_CTRL0_FACE_Field := Disabled; ADCCE : PMSC_CTRL0_ADCCE_Field := Disabled; AMCE : PMSC_CTRL0_AMCE_Field := Disabled; GPCE : PMSC_CTRL0_GPCE_Field := Disabled; GPRN : PMSC_CTRL0_GPRN_Field := Disabled; GPDCE : PMSC_CTRL0_GPDCE_Field := Disabled; GPDRN : PMSC_CTRL0_GPDRN_Field := Disabled; KHZCLKEN : PMSC_CTRL0_KHZCLKEN_Field := Disabled; PLL2_SEQ_EN : PMSC_CTRL0_PLL2_SEQ_EN_Field := Normal; SOFTRESET : PMSC_CTRL0_SOFTRESET_Field := PMSC_CTRL0_SOFTRESET_Set_All; Reserved_1 : Types.Bits_3 := 2#100#; Reserved_2 : Types.Bits_4 := 0; Reserved_3 : Types.Bits_3 := 2#011#; Reserved_4 : Types.Bits_3 := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for PMSC_CTRL0_Type use record SYSCLKS at 0 range 0 .. 1; RXCLKS at 0 range 2 .. 3; TXCLKS at 0 range 4 .. 5; FACE at 0 range 6 .. 6; Reserved_1 at 0 range 7 .. 9; ADCCE at 0 range 10 .. 10; Reserved_2 at 0 range 11 .. 14; AMCE at 0 range 15 .. 15; GPCE at 0 range 16 .. 16; GPRN at 0 range 17 .. 17; GPDCE at 0 range 18 .. 18; GPDRN at 0 range 19 .. 19; Reserved_3 at 0 range 20 .. 22; KHZCLKEN at 0 range 23 .. 23; PLL2_SEQ_EN at 0 range 24 .. 24; Reserved_4 at 0 range 25 .. 27; SOFTRESET at 0 range 28 .. 31; end record; ------------------------------ -- PMSC_CTRL1 sub-register -- ------------------------------ type PMSC_CTRL1_ARX2INIT_Field is (Disabled, Enabled) with Size => 1; -- Automatic transition from receive mode into the INIT state. type PMSC_CTRL1_PKTSEQ_Field is new Bits_8; PMSC_CTRL1_Disabled : constant PMSC_CTRL1_PKTSEQ_Field := 16#00#; PMSC_CTRL1_Enabled : constant PMSC_CTRL1_PKTSEQ_Field := 16#E7#; type PMSC_CTRL1_ATXSLP_Field is (Disabled, Enabled) with Size => 1; -- After TX automatically Sleep. type PMSC_CTRL1_ARXSLP_Field is (Disabled, Enabled) with Size => 1; -- After RX automatically Sleep. type PMSC_CTRL1_SNOZE_Field is (Disabled, Enabled) with Size => 1; -- Snooze Enable. type PMSC_CTRL1_SNOZR_Field is (Disabled, Enabled) with Size => 1; -- Snooze Repeat. type PMSC_CTRL1_PLLSYN_Field is (Disabled, Enabled) with Size => 1; -- This enables a special 1 GHz clock used for some external SYNC modes. type PMSC_CTRL1_LDERUNE_Field is (Disabled, Enabled) with Size => 1; -- LDE run enable. type PMSC_CTRL1_KHZCLKDIV_Field is range 0 .. 2**6 - 1 with Size => 6; type PMSC_CTRL1_Type is record ARX2INIT : PMSC_CTRL1_ARX2INIT_Field := Disabled; PKTSEQ : PMSC_CTRL1_PKTSEQ_Field := PMSC_CTRL1_Enabled; ATXSLP : PMSC_CTRL1_ATXSLP_Field := Disabled; ARXSLP : PMSC_CTRL1_ARXSLP_Field := Disabled; SNOZE : PMSC_CTRL1_SNOZE_Field := Disabled; SNOZR : PMSC_CTRL1_SNOZR_Field := Disabled; PLLSYN : PMSC_CTRL1_PLLSYN_Field := Disabled; LDERUNE : PMSC_CTRL1_LDERUNE_Field := Enabled; KHZCLKDIV : PMSC_CTRL1_KHZCLKDIV_Field := 32; Reserved_1 : Types.Bits_1 := 0; Reserved_2 : Types.Bits_1 := 0; Reserved_3 : Types.Bits_1 := 0; Reserved_4 : Types.Bits_8 := 2#0100_0000#; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for PMSC_CTRL1_Type use record Reserved_1 at 0 range 0 .. 0; ARX2INIT at 0 range 1 .. 1; Reserved_2 at 0 range 2 .. 2; PKTSEQ at 0 range 3 .. 10; ATXSLP at 0 range 11 .. 11; ARXSLP at 0 range 12 .. 12; SNOZE at 0 range 13 .. 13; SNOZR at 0 range 14 .. 14; PLLSYN at 0 range 15 .. 15; Reserved_3 at 0 range 16 .. 16; LDERUNE at 0 range 17 .. 17; Reserved_4 at 0 range 18 .. 25; KHZCLKDIV at 0 range 26 .. 31; end record; ------------------------------ -- PMSC_SNOZT sub-register -- ------------------------------ type PMSC_SNOZT_Type is record SNOZ_TIM : System_Time.Snooze_Time := 0.001_706_667; end record with Size => 8, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for PMSC_SNOZT_Type use record SNOZ_TIM at 0 range 0 .. 7; end record; ------------------------------- -- PMSC_TXFSEQ sub-register -- ------------------------------- type PMSC_TXFSEQ_Field is new Bits_16; type PMSC_TXFSEQ_Type is record TXFINESEQ : PMSC_TXFSEQ_Field := 2#0000_1011_0011_1100#; end record with Size => 16, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for PMSC_TXFSEQ_Type use record TXFINESEQ at 0 range 0 .. 15; end record; ----------------------------- -- PMSC_LEDC sub-register -- ----------------------------- type PMSC_LEDC_BLINKEN_Field is (Disabled, Enabled) with Size => 1; -- Blink Enable. type PMSC_LEDC_BLNKNOW_Field is (No_Action, Blink_Now) with Size => 1; type PMSC_LEDC_Type is record BLINK_TIM : System_Time.Blink_Time := 0.448; BLNKEN : PMSC_LEDC_BLINKEN_Field := Disabled; BLNKNOW_RXOKLED : PMSC_LEDC_BLNKNOW_Field := No_Action; BLNKNOW_SFDLED : PMSC_LEDC_BLNKNOW_Field := No_Action; BLNKNOW_RXLED : PMSC_LEDC_BLNKNOW_Field := No_Action; BLNKNOW_TXLED : PMSC_LEDC_BLNKNOW_Field := No_Action; Reserved_1 : Types.Bits_7 := 0; Reserved_2 : Types.Bits_12 := 0; end record with Size => 32, Bit_Order => System.Low_Order_First, Scalar_Storage_Order => System.Low_Order_First; for PMSC_LEDC_Type use record BLINK_TIM at 0 range 0 .. 7; BLNKEN at 0 range 8 .. 8; Reserved_1 at 0 range 9 .. 15; BLNKNOW_RXOKLED at 0 range 16 .. 16; BLNKNOW_SFDLED at 0 range 17 .. 17; BLNKNOW_RXLED at 0 range 18 .. 18; BLNKNOW_TXLED at 0 range 19 .. 19; Reserved_2 at 0 range 20 .. 31; end record; end DW1000.Register_Types;
29,654
ada
33
ytomino/drake
source/containers/a-cogeso.ads
pragma License (Unrestricted); -- Ada 2012 generic type Index_Type is (<>); with function Before (Left, Right : Index_Type) return Boolean; with procedure Swap (Left, Right : Index_Type); procedure Ada.Containers.Generic_Sort (First, Last : Index_Type'Base); pragma Pure (Ada.Containers.Generic_Sort);
29,655
ada
1
zrmyers/VulkanAda
src/vulkan-math/vulkan-math-relational.adb
-------------------------------------------------------------------------------- -- MIT License -- -- Copyright (c) 2020 <NAME> -- -- 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. -------------------------------------------------------------------------------- -- -- This package provides operator definitions for all types. -------------------------------------------------------------------------------- package body Vulkan.Math.Relational is ---------------------------------------------------------------------------- function Is_Any (x : in Vkm_GenBType) return Vkm_Bool is Result : Vkm_Bool := False; begin for I in x.data'Range loop Result := Result or x.data(I); end loop; return Result; end Is_Any; ---------------------------------------------------------------------------- function Is_All (x : in Vkm_GenBType) return Vkm_Bool is Result : Vkm_Bool := True; begin for I in x.data'Range loop Result := Result and x.data(I); end loop; return Result; end Is_All; end Vulkan.Math.Relational;
29,656
ada
24
svn2github/matreshka
source/uaflex/debug.adb
<filename>source/uaflex/debug.adb ------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Tools Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2011-2012, <NAME> <<EMAIL>> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ with Ada.Wide_Wide_Text_IO; with League.Character_Sets; with Matreshka.Internals.Graphs; with Nodes; package body Debug is procedure Print is use Ada.Wide_Wide_Text_IO; procedure Each_Condition (Cursor : Nodes.Start_Condition_Maps.Cursor); procedure Each_Condition (Cursor : Nodes.Start_Condition_Maps.Cursor) is Item : constant Nodes.Start_Condition := Nodes.Start_Condition_Maps.Element (Cursor); begin if Item.Exclusive then Put_Line ("%x " & Nodes.Start_Condition_Maps.Key (Cursor). To_Wide_Wide_String); else Put_Line ("%s " & Nodes.Start_Condition_Maps.Key (Cursor). To_Wide_Wide_String); end if; end Each_Condition; procedure Print_Macro (Position : Nodes.Macro_Maps.Cursor) is begin Put_Line (Nodes.Macro_Maps.Key (Position).To_Wide_Wide_String & " " & Nodes.Macro_Maps.Element (Position).To_Wide_Wide_String); end Print_Macro; begin Nodes.Conditions.Iterate (Each_Condition'Access); Nodes.Macros.Iterate (Print_Macro'Access); Put_Line ("%%"); for J in 1 .. Nodes.Rules.Length loop Put_Line (Nodes.Rules.Element (J).To_Wide_Wide_String & " " & Nodes.Actions.Element (J).To_Wide_Wide_String); end loop; end Print; ----------------------------- -- Print_Character_Classes -- ----------------------------- procedure Print_Character_Classes (Vector : Matreshka.Internals.Finite_Automatons.Vectors.Vector) is subtype Wide is Wide_Wide_Character range Wide_Wide_Character'Val (0) .. Wide_Wide_Character'Val (16#10FFFF#); use Ada.Wide_Wide_Text_IO; begin for J in Vector.First_Index .. Vector.Last_Index loop Put_Line (Matreshka.Internals.Graphs.Edge_Identifier'Wide_Wide_Image (J)); declare Item : constant League.Character_Sets.Universal_Character_Set := Vector.Element (J); begin for K in Wide loop if Item.Has (K) then Put (K); end if; end loop; New_Line; end; end loop; end Print_Character_Classes; end Debug;
29,657
ada
0
VitalijBondarenko/Formatted_Output_NG
src/formatted_output-enumeration_output.adb
------------------------------------------------------------------------------ -- -- -- Copyright (c) 2016-2021 <NAME> <<EMAIL>> -- -- -- ------------------------------------------------------------------------------ -- -- -- 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 Ada.Text_IO; use Ada.Text_IO; with Ada.Characters.Handling; use Ada.Characters.Handling; with Ada.Strings; use Ada.Strings; with Ada.Strings.Fixed; use Ada.Strings.Fixed; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; package body Formatted_Output.Enumeration_Output is package Item_Type_IO is new Ada.Text_IO.Enumeration_IO (Item_Type); use Item_Type_IO; type Style_Type is (Capitalized, Upper_Case, Lower_Case); function Format (Value : Item_Type; Initial_Width : Integer; Justification : Alignment; Style : Style_Type) return String; ------------ -- Format -- ------------ function Format (Value : Item_Type; Initial_Width : Integer; Justification : Alignment; Style : Style_Type) return String is Img : String (1 .. Maximal_Item_Length); Width : Integer; Real_Width : Integer; Past_Last : Integer := 1; begin case Style is when Capitalized => Put (Img, Value, Type_Set'(Lower_Case)); Img (1) := To_Upper (Img (1)); when Lower_Case => Put (Img, Value, Type_Set'(Lower_Case)); when Upper_Case => Put (Img, Value, Type_Set'(Upper_Case)); end case; while Img (Past_Last) /= ' ' loop Past_Last := Past_Last + 1; end loop; Real_Width := Past_Last - 1; if Initial_Width < Real_Width then Width := Real_Width; else Width := Initial_Width; end if; declare S : String (1 .. Width); begin Move (Img (Past_Last - Real_Width .. Past_Last - 1), S, Justify => Justification, Pad => Filler); return S; end; end Format; --------- -- "&" -- --------- function "&" (Fmt : Format_Type; Value : Item_Type) return Format_Type is Command_Start : constant Integer := Scan_To_Percent_Sign (Fmt); Width : Integer := 0; Digit_Occured : Boolean := False; Justification_Changed : Boolean := False; Justification : Alignment := Right; Fmt_Copy : Unbounded_String; begin if Command_Start /= 0 then Fmt_Copy := Unbounded_String (Fmt); for I in Command_Start + 1 .. Length (Fmt_Copy) loop case Element (Fmt_Copy, I) is when 'c' => Replace_Slice (Fmt_Copy, Command_Start, I, Format (Value, Width, Justification, Capitalized)); return Format_Type (Fmt_Copy); when 'u' => Replace_Slice (Fmt_Copy, Command_Start, I, Format (Value, Width, Justification, Upper_Case)); return Format_Type (Fmt_Copy); when 'l' => Replace_Slice (Fmt_Copy, Command_Start, I, Format (Value, Width, Justification, Lower_Case)); return Format_Type (Fmt_Copy); when '-' | '+' | '*' => if Justification_Changed or else Digit_Occured then raise Format_Error; end if; Justification_Changed := True; case Element (Fmt_Copy, I) is when '-' => Justification := Left; when '+' => Justification := Right; when '*' => Justification := Center; when others => null; end case; when '0' .. '9' => Width := Width * 10 + Character'Pos (Element (Fmt_Copy, I)) - Character'Pos ('0'); when others => raise Format_Error; end case; end loop; end if; raise Format_Error; end "&"; end Formatted_Output.Enumeration_Output;
29,658
ada
33
ytomino/drake
source/numerics/a-nugear.adb
<gh_stars>10-100 -- reference: Netgen's Eigensystem routine. package body Ada.Numerics.Generic_Arrays is -- vector selection, conversion, and composition operations procedure Apply_Vector (X : in out Vector; Param : Parameter_Vector) is Length : constant Integer := X'Length; begin for I in 0 .. Length - 1 loop pragma Loop_Optimize (Vector); Apply (X (X'First + I), Param (Param'First + I)); end loop; end Apply_Vector; -- vector arithmetic operations function Operator_Vector (Right : Vector) return Result_Vector is begin return Result : Result_Vector (Right'Range) do for I in Result'Range loop pragma Loop_Optimize (Vector); Result (I) := Operator (Right (I)); end loop; end return; end Operator_Vector; function Operator_Vector_Param (X : Vector; Y : Parameter_Type) return Result_Vector is begin return Result : Result_Vector (X'Range) do for I in Result'Range loop pragma Loop_Optimize (Vector); Result (I) := Operator (X (I), Y); end loop; end return; end Operator_Vector_Param; function Operator_Vector_Vector (Left : Left_Vector; Right : Right_Vector) return Result_Vector is begin return Result : Result_Vector (Left'Range) do declare Length : constant Integer := Result'Length; begin for I in 0 .. Length - 1 loop pragma Loop_Optimize (Vector); Result (Result'First + I) := Operator (Left (Left'First + I), Right (Right'First + I)); end loop; end; end return; end Operator_Vector_Vector; function Operator_Vector_Vector_Param (X, Y : Vector; Z : Parameter_Type) return Result_Vector is begin return Result : Result_Vector (X'Range) do declare Length : constant Integer := Result'Length; begin for I in 0 .. Length - 1 loop pragma Loop_Optimize (Vector); Result (Result'First + I) := Operator (X (X'First + I), Y (Y'First + I), Z); end loop; end; end return; end Operator_Vector_Vector_Param; function Absolute (Right : Vector) return Result_Type is Squared : Result_Type := Zero; begin for I in Right'Range loop pragma Loop_Optimize (Vector); declare X : constant Result_Type := abs Right (I); begin Squared := Squared + X * X; end; end loop; return Sqrt (Squared); end Absolute; function Inner_Production (Left : Left_Vector; Right : Right_Vector) return Result_Type is Result : Result_Type := Zero; Length : constant Integer := Left'Length; begin for I in 0 .. Length - 1 loop pragma Loop_Optimize (Vector); Result := Result + Left (Left'First + I) * Right (Right'First + I); end loop; return Result; end Inner_Production; -- other vector operations function Unit_Vector ( Index : Integer; Order : Positive; First : Integer := 1) return Vector is begin return Result : Vector (First .. First + Order - 1) do for I in Result'Range loop pragma Loop_Optimize (Vector); Result (I) := Zero; end loop; Result (Index) := One; end return; end Unit_Vector; -- matrix selection, conversion, and composition operations procedure Apply_Matrix (X : in out Matrix; Param : Parameter_Matrix) is Length_1 : constant Integer := X'Length (1); Length_2 : constant Integer := X'Length (2); begin for I in 0 .. Length_1 - 1 loop for J in 0 .. Length_2 - 1 loop pragma Loop_Optimize (Vector); Apply ( X (X'First (1) + I, X'First (2) + J), Param (Param'First (1) + I, Param'First (2) + J)); end loop; end loop; end Apply_Matrix; -- matrix arithmetic operations function Operator_Matrix (Right : Matrix) return Result_Matrix is begin return Result : Result_Matrix (Right'Range (1), Right'Range (2)) do for I in Result'Range (1) loop for J in Result'Range (2) loop pragma Loop_Optimize (Vector); Result (I, J) := Operator (Right (I, J)); end loop; end loop; end return; end Operator_Matrix; function Operator_Matrix_Param (X : Matrix; Y : Parameter_Type) return Result_Matrix is begin return Result : Result_Matrix (X'Range (1), X'Range (2)) do for I in Result'Range (1) loop for J in Result'Range (2) loop pragma Loop_Optimize (Vector); Result (I, J) := Operator (X (I, J), Y); end loop; end loop; end return; end Operator_Matrix_Param; function Operator_Matrix_Matrix (Left : Left_Matrix; Right : Right_Matrix) return Result_Matrix is begin return Result : Result_Matrix (Left'Range (1), Left'Range (2)) do declare Length_1 : constant Integer := Result'Length (1); Length_2 : constant Integer := Result'Length (2); begin for I in 0 .. Length_1 - 1 loop for J in 0 .. Length_2 - 1 loop pragma Loop_Optimize (Vector); Result (Result'First (1) + I, Result'First (2) + J) := Operator ( Left (Left'First (1) + I, Left'First (2) + J), Right (Right'First (1) + I, Right'First (2) + J)); end loop; end loop; end; end return; end Operator_Matrix_Matrix; function Operator_Matrix_Matrix_Param (X, Y : Matrix; Z : Parameter_Type) return Result_Matrix is begin return Result : Result_Matrix (X'Range (1), X'Range (2)) do declare Length_1 : constant Integer := Result'Length (1); Length_2 : constant Integer := Result'Length (2); begin for I in 0 .. Length_1 - 1 loop for J in 0 .. Length_2 - 1 loop pragma Loop_Optimize (Vector); Result (Result'First (1) + I, Result'First (2) + J) := Operator ( X (X'First (1) + I, X'First (2) + J), Y (Y'First (1) + I, Y'First (2) + J), Z); end loop; end loop; end; end return; end Operator_Matrix_Matrix_Param; function Transpose (X : Matrix) return Matrix is begin return Result : Matrix (X'Range (2), X'Range (1)) do for I in Result'Range (1) loop for J in Result'Range (2) loop pragma Loop_Optimize (Vector); Result (I, J) := X (J, I); end loop; end loop; end return; end Transpose; function Multiply_Matrix_Matrix (Left : Left_Matrix; Right : Right_Matrix) return Result_Matrix is begin return Result : Result_Matrix (Left'Range (1), Right'Range (2)) do declare Length_Folded : constant Integer := Left'Length (2); begin for I in Result'Range (1) loop for K in 0 .. Length_Folded - 1 loop for J in Result'Range (2) loop pragma Loop_Optimize (Vector); declare Z : Result_Type; begin if K = 0 then Z := Zero; else Z := Result (I, J); end if; Result (I, J) := Z + Left (I, Left'First (2) + K) * Right (Right'First (1) + K, J); end; end loop; end loop; end loop; end; end return; end Multiply_Matrix_Matrix; function Multiply_Vector_Vector (Left : Left_Vector; Right : Right_Vector) return Result_Matrix is begin return Result : Result_Matrix (Left'Range, Right'Range) do for I in Result'Range (1) loop for J in Result'Range (2) loop pragma Loop_Optimize (Vector); Result (I, J) := Left (I) * Right (J); end loop; end loop; end return; end Multiply_Vector_Vector; function Multiply_Vector_Matrix (Left : Left_Vector; Right : Right_Matrix) return Result_Vector is begin return Result : Result_Vector (Right'Range (2)) do declare Length_Folded : constant Integer := Left'Length; begin for J in Result'Range loop declare Z : Result_Type := Zero; begin for K in 0 .. Length_Folded - 1 loop pragma Loop_Optimize (Vector); Z := Z + Left (Left'First + K) * Right (Right'First (1) + K, J); end loop; Result (J) := Z; end; end loop; end; end return; end Multiply_Vector_Matrix; function Multiply_Matrix_Vector (Left : Left_Matrix; Right : Right_Vector) return Result_Vector is begin return Result : Result_Vector (Left'Range (1)) do declare Length_Folded : constant Integer := Right'Length; begin for I in Result'Range loop declare Z : Result_Type := Zero; begin for K in 0 .. Length_Folded - 1 loop pragma Loop_Optimize (Vector); Z := Z + Left (I, Left'First (2) + K) * Right (Right'First + K); end loop; Result (I) := Z; end; end loop; end; end return; end Multiply_Matrix_Vector; -- matrix inversion and related operations function Minor (A : Matrix; I, J : Integer) return Matrix is begin return Result : Matrix ( A'First (1) + 1 .. A'Last (1), A'First (2) + 1 .. A'Last (2)) do for I2 in Result'First (1) .. I loop for J2 in Result'First (2) .. J loop pragma Loop_Optimize (Vector); Result (I2, J2) := A (I2 - 1, J2 - 1); end loop; for J2 in J + 1 .. Result'Last (2) loop pragma Loop_Optimize (Vector); Result (I2, J2) := A (I2 - 1, J2); end loop; end loop; for I2 in I + 1 .. Result'Last (1) loop for J2 in Result'First (2) .. J loop pragma Loop_Optimize (Vector); Result (I2, J2) := A (I2, J2 - 1); end loop; for J2 in J + 1 .. Result'Last (2) loop pragma Loop_Optimize (Vector); Result (I2, J2) := A (I2, J2); end loop; end loop; end return; end Minor; function Inverse (A : Matrix) return Matrix is detA : constant Number := Determinant (A); Master_Sign : Number := One; Sign : Number; begin return Result : Matrix (A'Range (2), A'Range (1)) do declare Length : constant Integer := Result'Length (1); -- square matrix begin for I in 0 .. Length - 1 loop for J in 0 .. Length - 1 loop pragma Loop_Optimize (Vector); if J rem 2 = 0 then Sign := Master_Sign; else Sign := -Master_Sign; end if; Result (Result'First (1) + I, Result'First (2) + J) := Sign * Determinant ( Minor (A, Result'First (1) + J, Result'First (2) + I)) / detA; end loop; Master_Sign := -Master_Sign; end loop; end; end return; end Inverse; function Determinant (A : Matrix) return Number is begin case A'Length (1) is when 1 => return A (A'First (1), A'First (2)); when 2 => return A (A'First (1), A'First (2)) * A (A'Last (1), A'Last (2)) - A (A'First (1), A'Last (2)) * A (A'Last (1), A'First (2)); when others => declare Result : Number := Zero; Sign : Number := One; begin for X in A'Range (1) loop -- cannot vectorize Result := Result + Sign * A (X, A'First (2)) * Determinant (Minor (A, X, A'First (2))); Sign := -Sign; end loop; return Result; end; end case; end Determinant; -- eigenvalues and vectors of a hermitian matrix procedure Eigensystem ( A : Matrix; Values : out Real_Vector; Vectors : out Matrix) is mat1 : Matrix renames A; lami : Real_Vector renames Values; eigenvecs : Matrix renames Vectors; n : constant Integer := A'Length (1); mat : Matrix := mat1; a11, a12, a22, p, q, y11, y12, y21, y22, y, v1, v2 : Number; begin for i in eigenvecs'Range (1) loop for j in eigenvecs'Range (2) loop pragma Loop_Optimize (Vector); eigenvecs (i, j) := Zero; end loop; end loop; for i in 0 .. eigenvecs'Length (1) - 1 loop pragma Loop_Optimize (Vector); eigenvecs (eigenvecs'First (1) + i, eigenvecs'First (2) + i) := One; end loop; for l in 0 .. 99 loop for i in 0 .. n - 1 loop for j in 0 .. i - 1 loop -- find eigensystem of a(i-j,i-j) a11 := mat (mat'First (1) + i, mat'First (2) + i); a12 := mat (mat'First (1) + i, mat'First (2) + j); a22 := mat (mat'First (1) + j, mat'First (2) + j); if Is_Small (a12 * a12) then -- 1.0e-32 * abs (a11 * a22) null; -- continue else p := (a22 - a11) / Two; q := a12; -- compute eigenvectors: y11 := a12; if not Is_Minus (p) then y12 := p + Sqrt (p * p + q * q); else y12 := -q * q / (p - Sqrt (p * p + q * q)); end if; y := Sqrt (y11 * y11 + y12 * y12); y11 := y11 / y; y12 := y12 / y; y21 := a12; if Is_Minus (p) then y22 := p - Sqrt (p * p + q * q); else y22 := -q * q / (p + Sqrt (p * p + q * q)); end if; y := Sqrt (y21 * y21 + y22 * y22); y21 := y21 / y; y22 := y22 / y; -- V^T A V = V^T G^{-1} . (G^T A G) . G^{-1} V for k in 0 .. n - 1 loop pragma Loop_Optimize (Vector); v1 := mat (mat'First (1) + k, mat'First (2) + i); v2 := mat (mat'First (1) + k, mat'First (2) + j); mat (mat'First (1) + k, mat'First (2) + i) := v1 * y11 + v2 * y12; mat (mat'First (1) + k, mat'First (2) + j) := v1 * y21 + v2 * y22; end loop; for k in 0 .. n - 1 loop pragma Loop_Optimize (Vector); v1 := mat (mat'First (1) + i, mat'First (2) + k); v2 := mat (mat'First (1) + j, mat'First (2) + k); mat (mat'First (1) + i, mat'First (2) + k) := v1 * y11 + v2 * y12; mat (mat'First (1) + j, mat'First (2) + k) := v1 * y21 + v2 * y22; end loop; mat (mat'First (1) + i, mat'First (2) + j) := Zero; mat (mat'First (1) + j, mat'First (2) + i) := Zero; for k in 0 .. n - 1 loop pragma Loop_Optimize (Vector); v1 := eigenvecs ( eigenvecs'First (1) + i, eigenvecs'First (2) + k); v2 := eigenvecs ( eigenvecs'First (1) + j, eigenvecs'First (2) + k); eigenvecs ( eigenvecs'First (1) + i, eigenvecs'First (2) + k) := v1 * y11 + v2 * y12; eigenvecs ( eigenvecs'First (1) + j, eigenvecs'First (2) + k) := v1 * y21 + v2 * y22; end loop; end if; end loop; end loop; end loop; declare Length : constant Integer := lami'Length; begin for i in 0 .. Length - 1 loop pragma Loop_Optimize (Vector); lami (lami'First + i) := To_Real (mat (mat'First (1) + i, mat'First (2) + i)); end loop; end; end Eigensystem; -- other matrix operations function Unit_Matrix (Order : Positive; First_1, First_2 : Integer := 1) return Matrix is begin return Result : Matrix ( First_1 .. First_1 + Order - 1, First_2 .. First_2 + Order - 1) do for I in Result'Range (1) loop for J in Result'Range (2) loop pragma Loop_Optimize (Vector); Result (I, J) := Zero; end loop; end loop; for I in 0 .. Order - 1 loop pragma Loop_Optimize (Vector); Result (First_1 + I, First_2 + I) := One; end loop; end return; end Unit_Matrix; end Ada.Numerics.Generic_Arrays;
29,659
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/ada/sem_elab.ads
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S E M _ E L A B -- -- -- -- S p e c -- -- -- -- Copyright (C) 1997-2015, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING3. If not, go to -- -- http://www.gnu.org/licenses for a complete copy of the license. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ -- This package contains the routines used to deal with issuing warnings -- for cases of calls that may require warnings about possible access -- before elaboration. with Types; use Types; package Sem_Elab is ----------------------------- -- Description of Approach -- ----------------------------- -- Every non-static call that is encountered by Sem_Res results in a call -- to Check_Elab_Call, with N being the call node, and Outer set to its -- default value of True. In addition X'Access is treated like a call -- for the access-to-procedure case, and in SPARK mode only we also -- check variable references. -- The goal of Check_Elab_Call is to determine whether or not the reference -- in question can generate an access before elaboration error (raising -- Program_Error) either by directly calling a subprogram whose body -- has not yet been elaborated, or indirectly, by calling a subprogram -- whose body has been elaborated, but which contains a call to such a -- subprogram. -- In addition, in SPARK mode, we are checking for a variable reference in -- another package, which requires an explicit Elaborate_All pragma. -- The only references that we need to look at the outer level are -- references that occur in elaboration code. There are two cases. The -- reference can be at the outer level of elaboration code, or it can -- be within another unit, e.g. the elaboration code of a subprogram. -- In the case of an elaboration call at the outer level, we must trace -- all calls to outer level routines either within the current unit or to -- other units that are with'ed. For calls within the current unit, we can -- determine if the body has been elaborated or not, and if it has not, -- then a warning is generated. -- Note that there are two subcases. If the original call directly calls a -- subprogram whose body has not been elaborated, then we know that an ABE -- will take place, and we replace the call by a raise of Program_Error. -- If the call is indirect, then we don't know that the PE will be raised, -- since the call might be guarded by a conditional. In this case we set -- Do_Elab_Check on the call so that a dynamic check is generated, and -- output a warning. -- For calls to a subprogram in a with'ed unit or a 'Access or variable -- refernece (SPARK mode case), we require that a pragma Elaborate_All -- or pragma Elaborate be present, or that the referenced unit have a -- pragma Preelaborate, pragma Pure, or pragma Elaborate_Body. If none -- of these conditions is met, then a warning is generated that a pragma -- Elaborate_All may be needed (error in the SPARK case), or an implicit -- pragma is generated. -- For the case of an elaboration call at some inner level, we are -- interested in tracing only calls to subprograms at the same level, -- i.e. those that can be called during elaboration. Any calls to -- outer level routines cannot cause ABE's as a result of the original -- call (there might be an outer level call to the subprogram from -- outside that causes the ABE, but that gets analyzed separately). -- Note that we never trace calls to inner level subprograms, since -- these cannot result in ABE's unless there is an elaboration problem -- at a lower level, which will be separately detected. -- Note on pragma Elaborate. The checking here assumes that a pragma -- Elaborate on a with'ed unit guarantees that subprograms within the -- unit can be called without causing an ABE. This is not in fact the -- case since pragma Elaborate does not guarantee the transitive -- coverage guaranteed by Elaborate_All. However, we decide to trust -- the user in this case. -------------------------------------- -- Instantiation Elaboration Errors -- -------------------------------------- -- A special case arises when an instantiation appears in a context -- that is known to be before the body is elaborated, e.g. -- generic package x is ... -- ... -- package xx is new x; -- ... -- package body x is ... -- In this situation it is certain that an elaboration error will -- occur, and an unconditional raise Program_Error statement is -- inserted before the instantiation, and a warning generated. -- The problem is that in this case we have no place to put the -- body of the instantiation. We can't put it in the normal place, -- because it is too early, and will cause errors to occur as a -- result of referencing entities before they are declared. -- Our approach in this case is simply to avoid creating the body -- of the instantiation in such a case. The instantiation spec is -- modified to include dummy bodies for all subprograms, so that -- the resulting code does not contain subprogram specs with no -- corresponding bodies. procedure Check_Elab_Call (N : Node_Id; Outer_Scope : Entity_Id := Empty; In_Init_Proc : Boolean := False); -- Check a call for possible elaboration problems. The node N is either an -- N_Function_Call or N_Procedure_Call_Statement node or an access -- attribute reference whose prefix is a subprogram. -- -- If SPARK_Mode is On, then N can also be a variablr reference, since -- SPARK requires the use of Elaborate_All for references to variables -- in other packages. -- The Outer_Scope argument indicates whether this is an outer level -- call from Sem_Res (Outer_Scope set to Empty), or an internal recursive -- call (Outer_Scope set to entity of outermost call, see body). The flag -- In_Init_Proc should be set whenever the current context is a type -- init proc. -- Note: this might better be called Check_Elab_Reference (to recognize -- the SPARK case), but we prefer to keep the original name, since this -- is primarily used for checking for calls that could generate an ABE). procedure Check_Elab_Calls; -- Not all the processing for Check_Elab_Call can be done at the time -- of calls to Check_Elab_Call. This is because for internal calls, we -- need to wait to complete the check until all generic bodies have been -- instantiated. The Check_Elab_Calls procedure cleans up these waiting -- checks. It is called once after the completion of instantiation. procedure Check_Elab_Assign (N : Node_Id); -- N is either the left side of an assignment, or a procedure argument for -- a mode OUT or IN OUT formal. This procedure checks for a possible case -- of access to an entity from elaboration code before the entity has been -- initialized, and issues appropriate warnings. procedure Check_Elab_Instantiation (N : Node_Id; Outer_Scope : Entity_Id := Empty); -- Check an instantiation for possible elaboration problems. N is an -- instantiation node (N_Package_Instantiation, N_Function_Instantiation, -- or N_Procedure_Instantiation), and Outer_Scope indicates if this is -- an outer level call from Sem_Ch12 (Outer_Scope set to Empty), or an -- internal recursive call (Outer_Scope set to scope of outermost call, -- see body for further details). The returned value is relevant only -- for an outer level call, and is set to False if an elaboration error -- is bound to occur on the instantiation, and True otherwise. This is -- used by the caller to signal that the body of the instance should -- not be generated (see detailed description in body). procedure Check_Task_Activation (N : Node_Id); -- Tt the point at which tasks are activated in a package body, check -- that the bodies of the tasks are elaborated. end Sem_Elab;
29,660
ada
10
astyl/AcrobatomaticBuildSystem
sampleprj/adalib/src/exemple.adb
<reponame>astyl/AcrobatomaticBuildSystem package body Example is function Hello(i: in Integer) return Integer is begin return i+1; end Hello; end Example;
29,661
ada
24
svn2github/matreshka
tools/ayacc/src/symbol_table.adb
-- Copyright (c) 1990 Regents of the University of California. -- All rights reserved. -- -- The primary authors of ayacc were <NAME> and <NAME>. -- Enhancements were made by <NAME>. -- -- Send requests for ayacc information to <EMAIL> -- Send bug reports for ayacc to <EMAIL> -- -- Redistribution and use in source and binary forms are permitted -- provided that the above copyright notice and this paragraph are -- duplicated in all such forms and that any documentation, -- advertising materials, and other materials related to such -- distribution and use acknowledge that the software was developed -- by the University of California, Irvine. The name of the -- University may not be used to endorse or promote products derived -- from this software without specific prior written permission. -- THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR -- IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED -- WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. -- Module : symbol_table_body.ada -- Component of : ayacc -- Version : 1.2 -- Date : 11/21/86 12:37:53 -- SCCS File : disk21~/rschm/hasee/sccs/ayacc/sccs/sxsymbol_table_body.ada -- $Header: symbol_table_body.a,v 0.1 86/04/01 15:13:55 ada Exp $ -- $Log: symbol_table_body.a,v $ -- Revision 0.1 86/04/01 15:13:55 ada -- This version fixes some minor bugs with empty grammars -- and $$ expansion. It also uses vads5.1b enhancements -- such as pragma inline. -- -- -- Revision 0.0 86/02/19 18:54:02 ada -- -- These files comprise the initial version of Ayacc -- designed and implemented by <NAME> and <NAME>. -- Ayacc has been compiled and tested under the Verdix Ada compiler -- version 4.06 on a vax 11/750 running Unix 4.2BSD. -- package body Symbol_Table is SCCS_ID : constant String := "@(#) symbol_table_body.ada, Version 1.2"; Next_Free_Terminal : Grammar_Symbol := 0; Next_Free_Nonterminal : Grammar_Symbol := -1; Start_Symbol_Pos, End_Symbol_Pos : Grammar_Symbol; type String_Pointer is access String; type Table_Entry(ID : Grammar_Symbol); type Entry_Pointer is access Table_Entry; type Table_Entry(ID :Grammar_Symbol) is record Name : String_Pointer; Next : Entry_Pointer; case ID is when 0..Grammar_Symbol'Last => -- Terminal Prec : Precedence; Assoc : Associativity; when others => -- Nonterminal null; end case; end record; Hash_Table_Size : constant := 613; -- A large prime number type Hash_Index is range 0..Hash_Table_Size-1; Hash_Table : array(Hash_Index) of Entry_Pointer; -- -- Create a 'dynamic' array for looking up an entry -- for a given grammar_symbol. -- Block_Size : constant Grammar_Symbol := 100; type Lookup_Array is array(Grammar_Symbol range 0..Block_Size-1) of Entry_Pointer; type Block; type Block_Pointer is access Block; type Block is record Lookup : Lookup_Array; Next : Block_Pointer := null; end record; -- have separate blocks for terminals and nonterminals. Terminal_Blocks, Nonterminal_Blocks : Block_Pointer := new Block; procedure Make_Lookup_Table_Entry (ID : in Grammar_Symbol; Entry_Ptr : in Entry_Pointer) is ID_Block : Block_Pointer; Block_Number : Integer; begin if ID >= 0 then ID_Block := Terminal_Blocks; else ID_Block := Nonterminal_Blocks; end if; Block_Number := Integer (abs ID / Block_Size); for I in 1..Block_Number loop if ID_Block.Next = null then ID_Block.Next := new Block; end if; ID_Block := ID_Block.Next; end loop; ID_Block.Lookup((abs ID) mod Block_Size) := Entry_Ptr; end Make_Lookup_Table_Entry; function Get_Lookup_Table_Entry(ID: Grammar_Symbol) return Entry_Pointer is ID_Block : Block_Pointer; begin if ID >= 0 then ID_Block := Terminal_Blocks; else ID_Block := Nonterminal_Blocks; end if; for I in 1.. abs ID / Block_Size loop ID_Block := ID_Block.Next; end loop; return ID_Block.Lookup((abs ID) mod Block_Size); end Get_Lookup_Table_Entry; -- some day someone should put in a good hash function. function Hash_Value (S : String) return Hash_Index is H : Integer; Mid : Integer; begin Mid := (S'First + S'Last) / 2; H := ((Character'Pos(S(S'First)) + Character'Pos(S(Mid)) + Character'Pos(S(S'Last))) * S'Length * 16 ) mod Hash_Table_Size; return Hash_Index(H); end Hash_Value; function Insert_Identifier (Name: in String) return Grammar_Symbol is Index : Hash_Index; Entry_Ptr : Entry_Pointer; begin Index := Hash_Value(Name); Entry_Ptr := Hash_Table(Index); if Entry_Ptr = null then Entry_Ptr := new Table_Entry(Next_Free_Nonterminal); Entry_Ptr.Name := new String(1..Name'Length); Entry_Ptr.Name.all := Name; Hash_Table(Index) := Entry_Ptr; Make_Lookup_Table_Entry(Next_Free_Nonterminal, Entry_Ptr); Next_Free_Nonterminal := Next_Free_Nonterminal - 1; else loop if Entry_Ptr.Name.all = Name then return Entry_Ptr.ID; end if; if Entry_Ptr.Next = null then exit; end if; Entry_Ptr := Entry_Ptr.Next; end loop; Entry_Ptr.Next := new Table_Entry(Next_Free_Nonterminal); Entry_Ptr := Entry_Ptr.Next; Entry_Ptr.Name := new String(1..Name'Length); Entry_Ptr.Name.all := Name; Make_Lookup_Table_Entry(Next_Free_Nonterminal, Entry_Ptr); Next_Free_Nonterminal := Next_Free_Nonterminal - 1; end if; return Next_Free_Nonterminal + 1; end Insert_Identifier; function Insert_Terminal (Name : String; Prec : Precedence := 0; Assoc : Associativity := Undefined) return Grammar_Symbol is Index : Hash_Index; Entry_Ptr : Entry_Pointer; begin Index := Hash_Value(Name); Entry_Ptr := Hash_Table(Index); if Entry_Ptr = null then Entry_Ptr := new Table_Entry(Next_Free_Terminal); Entry_Ptr.Name := new String(1..Name'Length); Entry_Ptr.Name.all := Name; Entry_Ptr.Assoc := Assoc; Entry_Ptr.Prec := Prec; Hash_Table(Index) := Entry_Ptr; Make_Lookup_Table_Entry(Next_Free_Terminal, Entry_Ptr); Next_Free_Terminal := Next_Free_Terminal + 1; else loop if Entry_Ptr.Name.all = Name then if Entry_Ptr.ID < 0 then -- Look out for nonterminals raise Illegal_Entry; end if; if Prec /= 0 then if Entry_Ptr.Prec /= 0 then raise Redefined_Precedence_Error; end if; Entry_Ptr.Prec := Prec; Entry_Ptr.Assoc := Assoc; end if; return Entry_Ptr.ID; end if; if Entry_Ptr.Next = null then exit; end if; Entry_Ptr := Entry_Ptr.Next; end loop; Entry_Ptr.Next := new Table_Entry(Next_Free_Terminal); Entry_Ptr := Entry_Ptr.Next; Entry_Ptr.Name := new String(1..Name'Length); Entry_Ptr.Name.all := Name; Entry_Ptr.Assoc := Assoc; Entry_Ptr.Prec := Prec; Make_Lookup_Table_Entry(Next_Free_Terminal, Entry_Ptr); Next_Free_Terminal := Next_Free_Terminal + 1; end if; return Next_Free_Terminal - 1; end Insert_Terminal; function Get_Associativity (ID: Grammar_Symbol) return Associativity is begin return Get_Lookup_Table_Entry(ID).Assoc; end; function Get_Precedence (ID: Grammar_Symbol) return Precedence is begin return Get_Lookup_Table_Entry(ID).Prec; end; function Get_Symbol_Name (ID: Grammar_Symbol) return String is begin return Get_Lookup_Table_Entry(ID).Name.all; end; function First_Symbol (Kind: Symbol_Type) return Grammar_Symbol is begin if Kind = Terminal then return 0; else return Next_Free_Nonterminal + 1; end if; end; function Last_Symbol (Kind: Symbol_Type) return Grammar_Symbol is begin if Kind = Terminal then return Next_Free_Terminal - 1; else return -1; end if; end; function First_Terminal return Grammar_Symbol is begin return 0; end; function Last_Terminal return Grammar_Symbol is begin return Next_Free_Terminal - 1; end; function Start_Symbol return Grammar_Symbol is begin return Start_Symbol_Pos; end; function End_Symbol return Grammar_Symbol is begin return End_Symbol_Pos; end; function Is_Terminal (ID: Grammar_Symbol) return Boolean is begin return ID >= 0; end; function Is_Nonterminal (ID: Grammar_Symbol) return Boolean is begin return ID < 0; end; begin End_Symbol_Pos := Insert_Terminal("END_OF_INPUT"); Start_Symbol_Pos := Insert_Identifier("$accept"); -- declare a dummy symbol to insert the "error" token. declare Dummy_Sym : Grammar_Symbol; begin Dummy_Sym := Insert_Terminal("ERROR"); end; end Symbol_Table;
29,662
ada
3
vasil-sd/ada-tlsf
tlsf/src/main.adb
with Interfaces; with Bits; -- with Bit_Vectors_Prove; -- with BitOperations.Search.Axiom; -- with BitOperations.Search.Axiom.Most_Significant_Bit; -- with BitOperations.Shift.Axiom; -- with BitOperations.Shift.Axiom.Logic_Left; -- with BitOperations.Shift.Axiom.Logic_Right; with TLSF; with System.Storage_Elements; procedure main with SPARK_Mode is begin null; -- -- Axioms_Logic_Left.Equal_Mult_By_Power_2(V, 3); -- V := B.Logic_Left(V, 3); -- pragma Assert( V = 8); -- V := B.Make_Mask(5); -- pragma Assert(V = 31); -- V := B.Logic_Right(V, 3); -- -- Axioms_Logic_Right.Equal_Div_By_Power_2(V,3); -- pragma Assert(V = 3); -- I := B.Most_Significant_Bit(V); -- -- A_MSB.Result_Is_Correct(V, I); -- pragma Assert(I = 1); -- -- pragma Assert ( Nth(Unsigned_64(V), I)); -- -- pragma Assert (MSB(Unsigned_64(V)) = 1); -- -- pragma Assert (MSB(Unsigned_64(V)) = I); -- -- Bits_Unsigned.T52.BM.Functions.Shifts.Lemmata.Logic_Right_Lemmas.Lemma1(2,1); end;
29,663
ada
1
ekoeppen/STM32_Generic_Ada_Drivers
examples/stm32f0/rfm69_moter/modem/controller.ads
with Ada.Real_Time; use Ada.Real_Time; package Controller is Period : constant Time_Span := Milliseconds (200); procedure Periodic_Tasks; procedure Handle_Host_Data; procedure Handle_RF_Data; procedure Send_Log_Message (Message : String); end Controller;
29,664
ada
1
LaudateCorpus1/RosettaCodeData
Task/Maze-generation/Ada/maze-generation-3.ada
with Mazes; procedure Main is package Small_Mazes is new Mazes (Height => 8, Width => 11); My_Maze : Small_Mazes.Maze_Grid; begin Small_Mazes.Initialize (My_Maze); Small_Mazes.Put (My_Maze); end Main;
29,665
ada
4
faelys/gela-asis
source/asis/asis-gela-static.adb
<reponame>faelys/gela-asis ------------------------------------------------------------------------------ -- G E L A A S I S -- -- ASIS implementation for Gela project, a portable Ada compiler -- -- http://gela.ada-ru.org -- -- - - - - - - - - - - - - - - - -- -- Read copyright and license at the end of this file -- ------------------------------------------------------------------------------ -- $Revision: 209 $ $Date: 2013-11-30 21:03:24 +0200 (Сб., 30 нояб. 2013) $: with XASIS.Utils; with Asis.Elements; with Asis.Extensions; with Asis.Definitions; with Asis.Expressions; with Asis.Declarations; with Asis.Gela.Classes; package body Asis.Gela.Static is use Asis.Elements; package E renames Asis.Extensions; -- return function declaration or attribute_reference function Statically_Denote (Element : in Asis.Expression) return Asis.Element; function Has_Static_Params (Call : in Asis.Expression; Func : in Asis.Element) return Boolean; function Is_Static_Function (Element : in Asis.Element; Place : in Asis.Element) return Boolean; function Is_Statically_Constrained (Place : in Asis.Element; Element : in Asis.Declaration) return Boolean; function Is_Static_Range (Place : in Asis.Element; Element : in Asis.Range_Constraint) return Boolean; function Is_Static_Discrete_Subtype (Place : in Asis.Element; Element : in Asis.Definition) return Boolean; function Is_Static_Bound (Place : in Asis.Element; Element : in Asis.Expression) return Boolean; function Is_Static_Indication (Place : in Asis.Element; Element : in Asis.Definition) return Boolean; function Is_Static_Constraint (Place : in Asis.Element; Element : in Asis.Constraint) return Boolean; function Is_Static_Constant (Place : in Asis.Element; Element : in Asis.Declaration) return Boolean; function Denote_Static_Subtype (Place : Asis.Element; Mark : Asis.Expression; Constraint : Asis.Constraint := Asis.Nil_Element; Scalar : Boolean := False) return Boolean; function Is_Descendant_Of_Formal (Info : Classes.Type_Info) return Boolean; --------------------------- -- Denote_Static_Subtype -- --------------------------- function Denote_Static_Subtype (Place : Asis.Element; Mark : Asis.Expression; Constraint : Asis.Constraint := Asis.Nil_Element; Scalar : Boolean := False) return Boolean is use Asis.Gela.Classes; Info : Type_Info := Type_From_Subtype_Mark (Mark, Place); Constr : Asis.Constraint := Constraint; Name : Asis.Expression := Mark; Decl : Asis.Declaration; Def : Asis.Definition; begin if Is_Descendant_Of_Formal (Info) then return False; elsif Is_String (Info) then if Scalar then return False; end if; declare use Asis.Definitions; Def : Asis.Definition := Get_Type_Def (Info); Comp : Asis.Definition := Array_Component_Definition (Def); Ind : Asis.Definition := Component_Subtype_Indication (Comp); begin if not Is_Static_Indication (Place, Ind) then return False; end if; case Type_Kind (Def) is when An_Unconstrained_Array_Definition => if not Denote_Static_Subtype (Place, Index_Subtype_Definitions (Def) (1)) then return False; end if; when A_Constrained_Array_Definition => if not Is_Static_Discrete_Subtype (Place, Discrete_Subtype_Definitions (Def) (1)) then return False; end if; when others => return False; end case; end; elsif not Is_Scalar (Info) then return False; end if; loop if not Is_Static_Constraint (Place, Constr) then return False; end if; case Expression_Kind (Name) is when An_Attribute_Reference => return Attribute_Kind (Name) = A_Base_Attribute; when others => Decl := XASIS.Utils.Selected_Name_Declaration (Name, False); case Declaration_Kind (Decl) is when A_Subtype_Declaration => Def := Asis.Declarations.Type_Declaration_View (Decl); Name := Asis.Definitions.Subtype_Mark (Def); Constr := Asis.Definitions.Subtype_Constraint (Def); when An_Ordinary_Type_Declaration => return True; when others => return False; end case; end case; end loop; end Denote_Static_Subtype; ----------------------- -- Has_Static_Params -- ----------------------- function Has_Static_Params (Call : in Asis.Expression; Func : in Asis.Element) return Boolean is use Asis.Expressions; Norm : constant Boolean := Expression_Kind (Func) /= An_Attribute_Reference; Args : Asis.Association_List := Function_Call_Parameters (Call, Norm); begin for J in Args'Range loop if not E.Is_Static_Expression (Actual_Parameter (Args (J))) then return False; end if; end loop; return True; end Has_Static_Params; ----------------------------- -- Is_Descendant_Of_Formal -- ----------------------------- function Is_Descendant_Of_Formal (Info : Classes.Type_Info) return Boolean is use Asis.Gela.Classes; Temp : Type_Info := Info; begin while not Is_Not_Type (Temp) loop case Definition_Kind (Get_Type_Def (Temp)) is when A_Formal_Type_Definition => return True; when others => Temp := Parent_Type (Temp); end case; end loop; return False; end Is_Descendant_Of_Formal; --------------------- -- Is_Static_Bound -- --------------------- function Is_Static_Bound (Place : in Asis.Element; Element : in Asis.Expression) return Boolean is use Asis.Expressions; use Asis.Gela.Classes; Info : Type_Info; Arr : Asis.Element; begin if Denote_Static_Subtype (Place, Prefix (Element), Scalar => True) then return True; end if; Arr := Statically_Denote (Prefix (Element)); Info := Type_From_Declaration (Arr, Place); if Is_Array (Info) then return Is_Statically_Constrained (Place, Arr); end if; Info := Type_Of_Declaration (Arr, Place); return Is_Array (Info) and then Is_Statically_Constrained (Place, Arr); end Is_Static_Bound; -------------------------- -- Is_Static_Constraint -- -------------------------- function Is_Static_Constraint (Place : in Asis.Element; Element : in Asis.Constraint) return Boolean is use Asis.Definitions; use Asis.Expressions; To_Do_Error : exception; begin case Constraint_Kind (Element) is when A_Range_Attribute_Reference => return Is_Static_Bound (Place, Range_Attribute (Element)); when A_Simple_Expression_Range => return E.Is_Static_Expression (Lower_Bound (Element)) and then E.Is_Static_Expression (Upper_Bound (Element)); when A_Digits_Constraint | A_Delta_Constraint => return Is_Static_Constraint (Place, Real_Range_Constraint (Element)); when An_Index_Constraint => declare List : Asis.Discrete_Range_List := Discrete_Ranges (Element); begin for J in List'Range loop if not Is_Static_Discrete_Subtype (Place, List (J)) then return False; end if; end loop; -- TODO 4.9 (30) (and index subtype of array is static) return True; end; when Not_A_Constraint => return Is_Nil (Element); when others => raise To_Do_Error; -- RM 4.9 (31) why we need it? end case; end Is_Static_Constraint; --------------------------------------- -- Is_Statically_Constrained_Subtype -- --------------------------------------- function Is_Statically_Constrained_Subtype (Place : in Asis.Element; Element : in Asis.Declaration) return Boolean is use Asis.Definitions; use Asis.Declarations; Def : Asis.Definition; begin case Declaration_Kind (Element) is when An_Ordinary_Type_Declaration => Def := Type_Declaration_View (Element); when A_Variable_Declaration | A_Constant_Declaration => Def := Object_Declaration_View (Element); case Definition_Kind (Def) is when A_Type_Definition => null; when A_Subtype_Indication => declare Name : Asis.Expression := Asis.Definitions.Subtype_Mark (Def); Constr : Asis.Constraint := Asis.Definitions.Subtype_Constraint (Def); Decl : Asis.Declaration := XASIS.Utils.Selected_Name_Declaration (Name, False); begin if Is_Nil (Constr) then return Is_Statically_Constrained_Subtype (Place, Decl); else return Is_Static_Constraint (Place, Constr); end if; end; when others => return False; end case; when others => return False; end case; case Type_Kind (Def) is when A_Constrained_Array_Definition => declare List : Asis.Definition_List := Discrete_Subtype_Definitions (Def); begin for J in List'Range loop if not Is_Static_Discrete_Subtype (Place, List (J)) then return False; end if; end loop; return True; end; when others => return False; end case; end Is_Statically_Constrained_Subtype; ------------------------------- -- Is_Statically_Constrained -- ------------------------------- function Is_Statically_Constrained (Place : in Asis.Element; Element : in Asis.Declaration) return Boolean is use Asis.Gela.Classes; Info : Type_Info; begin case Declaration_Kind (Element) is when A_Constant_Declaration => if Is_Statically_Constrained_Subtype (Place, Element) then return True; end if; Info := Type_Of_Declaration (Element, Place); return Is_String (Info) and then Is_Static_Constant (Place, Element); when others => return Is_Statically_Constrained_Subtype (Place, Element); end case; end Is_Statically_Constrained; ------------------------ -- Is_Static_Constant -- ------------------------ function Is_Static_Constant (Place : in Asis.Element; Element : in Asis.Declaration) return Boolean is begin case Declaration_Kind (Element) is when An_Object_Renaming_Declaration => declare use Asis.Declarations; Mark : Asis.Expression := Declaration_Subtype_Mark (Element); begin return Denote_Static_Subtype (Place, Mark) and then E.Is_Static_Expression (Renamed_Entity (Element)); end; when A_Constant_Declaration => declare use Asis.Declarations; View : Asis.Definition := Object_Declaration_View (Element); Init : Asis.Expression := Initialization_Expression (Element); begin return Is_Static_Indication (Place, View) and then E.Is_Static_Expression (Init); end; when others => return False; end case; end Is_Static_Constant; -------------------------------- -- Is_Static_Discrete_Subtype -- -------------------------------- function Is_Static_Discrete_Subtype (Place : in Asis.Element; Element : in Asis.Definition) return Boolean is use Asis.Definitions; begin case Discrete_Range_Kind (Element) is when A_Discrete_Subtype_Indication => return Is_Static_Indication (Place, Element); when A_Discrete_Range_Attribute_Reference => return Is_Static_Bound (Place, Range_Attribute (Element)); when A_Discrete_Simple_Expression_Range => return E.Is_Static_Expression (Lower_Bound (Element)) and then E.Is_Static_Expression (Upper_Bound (Element)); when others => null; end case; return False; end Is_Static_Discrete_Subtype; -------------------------- -- Is_Static_Expression -- -------------------------- function Is_Static_Expression (Element : in Asis.Expression) return Boolean is use Asis.Expressions; begin case Expression_Kind (Element) is when An_Integer_Literal | A_Real_Literal | An_Enumeration_Literal | A_Character_Literal => return True; when A_String_Literal => -- TODO return True; when An_Identifier | A_Selected_Component => declare Decl : Asis.Declaration := XASIS.Utils.Selected_Name_Declaration (Element, False); begin case Declaration_Kind (Decl) is when An_Integer_Number_Declaration | A_Real_Number_Declaration => return True; when others => return Is_Static_Constant (Element, Decl); end case; end; when A_Function_Call => declare Func : Asis.Element := Statically_Denote (Prefix (Element)); begin return Is_Static_Function (Func, Element) and then Has_Static_Params (Element, Func); end; when An_Attribute_Reference => case Attribute_Kind (Element) is when An_Aft_Attribute | An_Alignment_Attribute | A_Bit_Order_Attribute | A_Delta_Attribute | A_Denorm_Attribute | A_Digits_Attribute | A_Fore_Attribute | A_Machine_Emax_Attribute | A_Machine_Emin_Attribute | A_Machine_Mantissa_Attribute | A_Machine_Overflows_Attribute | A_Machine_Radix_Attribute | A_Machine_Rounds_Attribute | A_Max_Size_In_Storage_Elements_Attribute | A_Model_Emin_Attribute | A_Model_Epsilon_Attribute | A_Model_Mantissa_Attribute | A_Model_Small_Attribute | A_Modulus_Attribute | A_Safe_First_Attribute | A_Safe_Last_Attribute | A_Scale_Attribute | A_Signed_Zeros_Attribute | A_Size_Attribute | A_Small_Attribute | A_Stream_Size_Attribute | A_Wide_Wide_Width_Attribute | A_Wide_Width_Attribute | A_Width_Attribute => return Denote_Static_Subtype (Element, Prefix (Element), Scalar => True); when A_First_Attribute | A_Last_Attribute | A_Length_Attribute => return Is_Static_Bound (Element, Element); when others => null; end case; when A_Type_Conversion => declare Mark : Asis.Expression := Converted_Or_Qualified_Subtype_Mark (Element); Arg : Asis.Expression := Converted_Or_Qualified_Expression (Element); begin return Denote_Static_Subtype (Element, Mark, Scalar => True) and then E.Is_Static_Expression (Arg); end; when A_Qualified_Expression => declare Mark : Asis.Expression := Converted_Or_Qualified_Subtype_Mark (Element); Arg : Asis.Expression := Converted_Or_Qualified_Expression (Element); begin return Denote_Static_Subtype (Element, Mark) and then E.Is_Static_Expression (Arg); end; when An_In_Range_Membership_Test | A_Not_In_Range_Membership_Test => declare Rng : Asis.Range_Constraint := Membership_Test_Range (Element); Arg : Asis.Expression := Membership_Test_Expression (Element); begin return E.Is_Static_Expression (Arg) and then Is_Static_Range (Element, Rng); end; when An_In_Type_Membership_Test | A_Not_In_Type_Membership_Test => declare Mark : Asis.Expression := Membership_Test_Subtype_Mark (Element); Arg : Asis.Expression := Membership_Test_Expression (Element); begin return E.Is_Static_Expression (Arg) and then Denote_Static_Subtype (Element, Mark); end; when An_And_Then_Short_Circuit | An_Or_Else_Short_Circuit => declare Left : Asis.Expression := Short_Circuit_Operation_Left_Expression (Element); Right : Asis.Expression := Short_Circuit_Operation_Right_Expression (Element); begin return E.Is_Static_Expression (Left) and then E.Is_Static_Expression (Right); end; when A_Parenthesized_Expression => return E.Is_Static_Expression (Expression_Parenthesized (Element)); when others => null; end case; return False; end Is_Static_Expression; ------------------------ -- Is_Static_Function -- ------------------------ function Is_Static_Function (Element : in Asis.Element; Place : in Asis.Element) return Boolean is function Check (Info : Classes.Type_Info) return Boolean is use Asis.Gela.Classes; begin return Is_Scalar (Info) and then not Is_Descendant_Of_Formal (Info); end Check; begin if Element_Kind (Element) = A_Declaration then if XASIS.Utils.Is_Predefined_Operator (Element) then declare use Asis.Declarations; Name : Asis.Defining_Name := XASIS.Utils.Declaration_Name (Element); Result : Asis.Expression := Result_Profile (Element); Info : Classes.Type_Info := Classes.Type_From_Subtype_Mark (Result, Place); List : Asis.Parameter_Specification_List := Parameter_Profile (Element); begin if Operator_Kind (Name) = A_Concatenate_Operator then return Classes.Is_String (Info); end if; if not Check (Info) then return False; end if; for J in List'Range loop Info := Classes.Type_Of_Declaration (List (J), Place); if not Check (Info) then return False; end if; end loop; return True; end; elsif Declaration_Kind (Element) = An_Enumeration_Literal_Specification then return True; end if; elsif Expression_Kind (Element) = An_Attribute_Reference then declare Mark : Asis.Expression := Asis.Expressions.Prefix (Element); begin if not Denote_Static_Subtype (Place, Mark, Scalar => True) then return False; end if; case Attribute_Kind (Element) is when An_Adjacent_Attribute | A_Ceiling_Attribute | A_Compose_Attribute | A_Copy_Sign_Attribute | An_Exponent_Attribute | A_Floor_Attribute | A_Fraction_Attribute | A_Leading_Part_Attribute | A_Machine_Attribute | A_Machine_Rounding_Attribute | A_Max_Attribute | A_Min_Attribute | A_Mod_Attribute | A_Model_Attribute | A_Pos_Attribute | A_Pred_Attribute | A_Remainder_Attribute | A_Round_Attribute | A_Rounding_Attribute | A_Scaling_Attribute | A_Succ_Attribute | A_Truncation_Attribute | An_Unbiased_Rounding_Attribute | A_Val_Attribute => return True; when others => null; end case; end; end if; return False; end Is_Static_Function; -------------------------- -- Is_Static_Indication -- -------------------------- function Is_Static_Indication (Place : in Asis.Element; Element : in Asis.Definition) return Boolean is Mark : Asis.Expression := Asis.Definitions.Subtype_Mark (Element); Cons : Asis.Expression := Asis.Definitions.Subtype_Constraint (Element); begin return Denote_Static_Subtype (Place, Mark, Cons); end Is_Static_Indication; --------------------- -- Is_Static_Range -- --------------------- function Is_Static_Range (Place : in Asis.Element; Element : in Asis.Range_Constraint) return Boolean is begin return Is_Static_Constraint (Place, Element); end Is_Static_Range; ----------------------- -- Statically_Denote -- ----------------------- function Statically_Denote (Element : in Asis.Expression) return Asis.Element is use Asis.Expressions; use Asis.Declarations; Expr : Asis.Expression := Element; Decl : Asis.Declaration; begin case Expression_Kind (Element) is when An_Attribute_Reference => if Assigned (Statically_Denote (Prefix (Element))) then return Element; else return Asis.Nil_Element; end if; when An_Identifier | An_Operator_Symbol | A_Character_Literal | An_Enumeration_Literal | A_Selected_Component => if Expression_Kind (Element) = A_Selected_Component then if XASIS.Utils.Is_Expanded_Name (Element) then Expr := Selector (Element); else return Asis.Nil_Element; end if; end if; Decl := Corresponding_Name_Declaration (Expr); if Declaration_Kind (Decl) = An_Object_Renaming_Declaration then return Statically_Denote (Renamed_Entity (Decl)); else return Decl; end if; when others => return Asis.Nil_Element; end case; end Statically_Denote; end Asis.Gela.Static; ------------------------------------------------------------------------------ -- Copyright (c) 2006-2013, <NAME> -- 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 <NAME>, IE nor the names of its -- contributors may be used to endorse or promote products derived from -- this software without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -- POSSIBILITY OF SUCH DAMAGE. ------------------------------------------------------------------------------
29,666
ada
52
onox/orka
orka/src/orka/interface/orka-loggers-terminal.ads
-- SPDX-License-Identifier: Apache-2.0 -- -- Copyright (c) 2019 onox <<EMAIL>> -- -- 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 Orka.Loggers.Terminal is pragma Preelaborate; protected type Logger_Object (Min_Level : Severity) is new Orka.Loggers.Logger with overriding procedure Log (From : Source; Kind : Message_Type; Level : Severity; Message : String); end Logger_Object; Logger : aliased Logger_Object (Min_Level => Debug); -- A logger that logs messages to the terminal function Create_Logger (Level : Severity := Debug) return Logger_Ptr; -- Create and return a logger that only logs messages to the terminal -- with the minimum specified severity end Orka.Loggers.Terminal;
29,667
ada
0
hannesb0/rtpl18
src/test01/src/calculate.adb
<gh_stars>0 -- Task 2 of RTPL WS17/18 -- Team members: <NAME>. and <NAME>. with Ada.Text_IO; use Ada.Text_IO; with Ada.Float_Text_IO; -- For float input -- with Ada.Numerics.Generic_Elementary_Functions; package body calculate with SPARK_Mode is -- Procedure for option 4 procedure opt4 is begin -- User input Put_Line ("Please input (x / y / z) values of a vector:"); Put ("x: "); Ada.Float_Text_IO.Get (V1.x); Put ("y: "); Ada.Float_Text_IO.Get (V1.y); Put ("z: "); Ada.Float_Text_IO.Get (V1.z); -- Print results Put ("Result: "); Ada.Float_Text_IO.Put (myVecAbs (V1), 2, 2, 0); end opt4; function myVecAbs (vec : myVec) return Float is sum : Float := 0.0; mag : Float := 0.0; begin -- Replace this with the correct function sum := vec.x * vec.x + vec.y * vec.y + vec.z * vec.z; mag := sqrt (sum); return mag; end myVecAbs; function sqrt (x : Float) return Float is root : Float := x / 3.0; root_prev : Float := root; begin if x <= 0.0 then return 0.0; end if; for i in Integer range 0 .. 31 loop root_prev := root; root := (root + x / root) / 2.0; exit when root_prev = root; end loop; return root; end sqrt; -- Declaration of generic function generic type Element_T is private; with function "+" (x, y : Element_T) return Element_T; function myAdd (x, y : in Element_T) return Element_T; -- Definition of generic function function myAdd (x, y : in Element_T) return Element_T is begin return x + y; end myAdd; -- Procedure for option 9 procedure opt9 is -- Instanciation of generic function function Add_Float is new myAdd (Element_T => Float, "+" => "+"); -- Float values for user input F1 : Float := 0.0; F2 : Float := 0.0; F3 : Float; begin -- User input Put_Line ("Please input two floats to be added:"); Put ("First: "); Ada.Float_Text_IO.Get (F1); Put ("Second: "); Ada.Float_Text_IO.Get (F2); -- Calculate Sum F3 := Add_Float (F1, F2); -- Print Sum Put ("Sum is: "); Ada.Float_Text_IO.Put (F3, 2, 2, 0); end opt9; end calculate;
29,668
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c7/c72001b.ada
<filename>gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c7/c72001b.ada -- C72001B.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- CHECK THAT A PACKAGE BODY CAN BE PROVIDED FOR A PACKAGE SPECIFICATION -- THAT DOES NOT CONTAIN ANY SUBPROGRAM OR TASK DECLARATIONS AND THAT -- STATEMENTS WITHIN THE PACKAGE BODIES CAN BE USED TO INITIALIZE -- VARIABLES VISIBLE WITHIN THE PACKAGE BODY. -- RM 04/30/81 -- RM 05/07/81 (TO INCORPORATE OLD TEST OBJECTIVE 7.1/T1 ) -- ABW 6/10/82 -- SPS 11/4/82 -- JBG 9/15/83 WITH REPORT; PROCEDURE C72001B IS USE REPORT; BEGIN TEST( "C72001B" , "CHECK: PACKAGE BODIES CAN INITIALIZE VISIBLE" & " VARIABLES" ); DECLARE PACKAGE P5 IS A : CHARACTER := 'B'; B : BOOLEAN := FALSE; PACKAGE P6 IS I : INTEGER := IDENT_INT(6); END P6; END P5; PACKAGE BODY P5 IS PACKAGE BODY P6 IS BEGIN A := 'C'; I := 17; B := IDENT_BOOL(TRUE); END P6; BEGIN A := 'A'; END P5; USE P5; USE P6; BEGIN IF A /= 'A' THEN FAILED ("INITIALIZATIONS NOT CORRECT - 1"); END IF; IF B /= TRUE THEN FAILED ("INITIALIZATIONS NOT CORRECT - 2"); END IF; IF I /= 17 THEN FAILED ("INITIALIZATIONS NOT CORRECT - 3"); END IF; END; RESULT; END C72001B;
29,669
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/itype.adb
<reponame>best08618/asylo<gh_stars>1-10 package body itype is function G return not null access constant T is X : aliased T; begin return X'Unchecked_Access; end G; end itype;
29,670
ada
20
charlie5/lace
3-mid/impact/source/3d/math/impact-d3-min_max.adb
<filename>3-mid/impact/source/3d/math/impact-d3-min_max.adb package body impact.d3.min_max is function btClamped (a : in Real; lower_Bound, upper_Bound : in Real) return Real is begin if a < lower_Bound then return lower_Bound; elsif upper_Bound < a then return upper_Bound; else return a; end if; end btClamped; procedure btSetMin (a : in out Real; b : in Real) is begin if b < a then a := b; end if; end btSetMin; procedure btSetMax (a : in out Real; b : in Real) is begin if a < b then a := b; end if; end btSetMax; procedure btClamp (a : in out Real; lower_Bound, upper_Bound : in Real) is begin if a < lower_Bound then a := lower_Bound; elsif upper_Bound < a then a := upper_Bound; end if; end btClamp; end impact.d3.min_max;
29,671
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/cc/cc3601c.ada
<filename>gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/cc/cc3601c.ada -- CC3601C.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- CHECK THAT "/=" MAY BE PASSED AS A GENERIC ACTUAL FUNCTION -- PARAMETER. -- DAT 10/6/81 -- SPS 10/27/82 -- JRK 2/9/83 WITH REPORT; USE REPORT; PROCEDURE CC3601C IS BEGIN TEST ("CC3601C", "/= AS GENERIC ACTUAL PARAMETER"); DECLARE PACKAGE PK IS TYPE LP IS LIMITED PRIVATE; FUNCTION "=" (X, Y : LP) RETURN BOOLEAN;-- RETURNS FALSE. TYPE INT IS NEW INTEGER; PRIVATE TASK TYPE LP; END PK; USE PK; V1, V2 : LP; TYPE REC IS RECORD C : LP; END RECORD; R1, R2 : REC; TYPE INT IS NEW INTEGER; B1 : BOOLEAN := TRUE; B2 : BOOLEAN := TRUE; INTEGER_3 : INTEGER := 3; INTEGER_4 : INTEGER := 4; INT_3 : INT := 3; INT_4 : INT := 4; INT_5 : INT := 5; PK_INT_M1 : PK.INT := -1; PK_INT_M2 : PK.INT := -2; PK_INT_1 : PK.INT := 1; PK_INT_2 : PK.INT := 2; PK_INT_3 : PK.INT := 3; FUNCTION "=" (Q, R : LP) RETURN BOOLEAN;-- RETURNS TRUE. GENERIC TYPE T IS LIMITED PRIVATE; V1, V2 : IN OUT T; WITH FUNCTION NE (ZA : IN T; ZB : T) RETURN BOOLEAN; VALUE : IN BOOLEAN; -- SHOULD BE VALUE OF NE(V1,V2). STR : STRING; PACKAGE GP IS END GP; FUNCTION "=" (Q, R : IN REC) RETURN BOOLEAN; FUNCTION NE (Q : INT; R : IN INT) RETURN BOOLEAN RENAMES "/="; FUNCTION NE (Q : PK.INT; R : IN PK.INT) RETURN BOOLEAN RENAMES "/="; PACKAGE BODY GP IS BEGIN IF IDENT_BOOL(VALUE) /= NE (V1, V2) THEN FAILED ("WRONG /= ACTUAL GENERIC PARAMETER " & STR); END IF; END GP; FUNCTION "=" (Q, R : IN REC) RETURN BOOLEAN IS BEGIN RETURN FALSE; END "="; FUNCTION "=" (Q, R : LP) RETURN BOOLEAN IS BEGIN RETURN TRUE; END "="; PACKAGE BODY PK IS FUNCTION "=" (X, Y : LP) RETURN BOOLEAN IS BEGIN RETURN R1 = R1; -- FALSE. END "="; TASK BODY LP IS BEGIN NULL; END; END PK; PACKAGE P1 IS NEW GP (LP, V1, V2, "/=", FALSE, "1"); FUNCTION "NOT" (X : BOOLEAN) RETURN BOOLEAN IS BEGIN RETURN X; END "NOT"; -- ENSURES USE OF PREDEFINED "NOT" PACKAGE P2 IS NEW GP (LP, V1, V2, "/=", FALSE, "2"); PACKAGE P3 IS NEW GP (LP, V1, V2, PK."/=", TRUE, "3"); PACKAGE P4 IS NEW GP (PK.LP, V1, V2, "/=", FALSE, "4"); PACKAGE P5 IS NEW GP (PK.LP, V1, V2, PK."/=", TRUE, "5"); PACKAGE P6 IS NEW GP (REC, R1, R2, "/=", TRUE, "6"); PACKAGE P7 IS NEW GP (INTEGER, INTEGER_3, INTEGER_4, "/=", TRUE, "7"); PACKAGE P8 IS NEW GP (BOOLEAN, B1, B2, "/=", FALSE,"8"); PACKAGE P9 IS NEW GP (INT, INT_3, INT_5, "/=", TRUE, "9"); PACKAGE P10 IS NEW GP (INT, INT_3, INT_3, "/=", FALSE, "10"); PACKAGE P11 IS NEW GP (INT, INT_3, INT_4, NE, TRUE, "11"); PACKAGE P12 IS NEW GP (INT, INT_3, INT_3, NE, FALSE, "12"); PACKAGE P13 IS NEW GP (PK.INT, PK_INT_3, PK_INT_3, NE, FALSE, "13"); PACKAGE P14 IS NEW GP (PK.INT, PK_INT_M1, PK_INT_M2, NE, TRUE, "14"); PACKAGE P15 IS NEW GP (PK.INT, PK_INT_1, PK_INT_1, "/=", FALSE, "15"); PACKAGE P16 IS NEW GP (PK.INT, PK_INT_1, PK_INT_2, "/=", TRUE, "16"); PACKAGE P17 IS NEW GP (PK.INT, PK_INT_1, PK_INT_1, PK."/=", FALSE, "17"); PACKAGE P18 IS NEW GP (PK.INT, PK_INT_1, PK_INT_2, PK."/=", TRUE, "18"); BEGIN NULL; END; RESULT; END CC3601C;
29,672
ada
5
onox/dcf-ada
dcf/src/dcf-zip.ads
<filename>dcf/src/dcf-zip.ads -- SPDX-License-Identifier: MIT -- -- Copyright (c) 1999 - 2019 <NAME> -- SWITZERLAND -- -- 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 Ada.Finalization; with Ada.Streams; with DCF.Streams; package DCF.Zip is pragma Preelaborate; subtype File_Size_Type is Unsigned_32; -- Data sizes in archive subtype Time is DCF.Streams.Time; type Zip_Name_Encoding is (IBM_437, UTF_8); -- Entry names within Zip archives are encoded either with -- * the IBM PC (the one with a monochrome screen, only text mode)'s -- character set: IBM 437 -- or -- * Unicode UTF-8 -- -- Documentation: PKWARE's Appnote.txt, APPENDIX D - Language Encoding (EFS) ----------------------------------------------------------------------------- type Archived_File is tagged limited private; function Name (Object : Archived_File) return String; function Name_Encoding (Object : Archived_File) return Zip_Name_Encoding; function Compressed_Size (Object : Archived_File) return File_Size_Type; function Uncompressed_Size (Object : Archived_File) return File_Size_Type; function Date_Time (Object : Archived_File) return Time; function Compressed (Object : Archived_File) return Boolean; function Encrypted (Object : Archived_File) return Boolean; function File_Index (Object : Archived_File) return DCF.Streams.Zs_Index_Type; function CRC_32 (Object : Archived_File) return Unsigned_32; ----------------------------------------------------------------------------- type Zip_Info is new Ada.Finalization.Controlled with private; procedure Load (Info : out Zip_Info; From : in out DCF.Streams.Root_Zipstream_Type'Class; Case_Sensitive : in Boolean := False) with Post => Info.Is_Loaded; -- Load an archive from a stream Archive_Corrupted : exception; Duplicate_Name : exception; -- Old name for Archive_corrupted. Change: 22-Oct-2017 -- Issues: archive stream is not necessarily a *file*; the naming -- ("Error") didn't clarify that it covered cases where the data -- is corrupted, which is different than an usual I/O error. function Is_Loaded (Info : in Zip_Info) return Boolean; function Name (Info : in Zip_Info) return String with Pre => Info.Is_Loaded; function Comment (Info : in Zip_Info) return String with Pre => Info.Is_Loaded; function Stream (Info : in Zip_Info) return not null DCF.Streams.Zipstream_Class_Access with Pre => Info.Is_Loaded; function Entries (Info : in Zip_Info) return Natural; -- Compression "methods" - actually, formats - in the "official" PKWARE Zip format -- Details in appnote.txt, part V.J type Pkzip_Method is (Store, Deflate); -- Technical: translates the method code as set in zip archives function Method_From_Code (Code : Unsigned_16) return Pkzip_Method; generic with procedure Action (File : Archived_File); procedure Traverse (Z : Zip_Info); -- Traverse a whole Zip_info directory in sorted order, giving the -- name and other technical information for each archived file to an -- user-defined "Action" procedure. -- -- Concretely, you can process a whole Zip file that way, by extracting data -- with Extract, or open a reader stream with UnZip.Streams. generic with procedure Action (File : Archived_File); procedure Traverse_One_File (Z : Zip_Info; Name : String); File_Name_Not_Found : exception; function Exists (Info : Zip_Info; Name : String) return Boolean with Pre => Info.Is_Loaded; -- User-defined procedure for feedback occuring during -- compression or decompression type Feedback_Proc is access procedure (Percents_Done : in Natural; -- %'s completed User_Abort : out Boolean); -- e.g. transmit a "click on Cancel" here ------------------------------------------------------------------------- -- Goodies - things used internally by Zip-Ada but are not bound to -- -- Zip archive purposes and that might be generally useful. -- ------------------------------------------------------------------------- -- BlockRead: general-purpose procedure (nothing really specific to Zip / -- UnZip): reads either the whole buffer from a file, or if the end of -- the file lays inbetween, a part of the buffer. -- -- The procedure's names and parameters match Borland Pascal / Delphi subtype Byte is Unsigned_8; type Byte_Buffer is array (Integer range <>) of aliased Byte; type P_Byte_Buffer is access Byte_Buffer; -- Same for general streams procedure Blockread (Stream : in out DCF.Streams.Root_Zipstream_Type'Class; Buffer : out Byte_Buffer; Actually_Read : out Natural); -- = buffer'Length if no end of stream before last buffer element -- Same, but instead of giving actually_read, raises End_Error if -- the buffer cannot be fully read. -- This mimics the 'Read stream attribute; can be a lot faster, depending -- on the compiler's run-time library. procedure Blockread (Stream : in out DCF.Streams.Root_Zipstream_Type'Class; Buffer : out Byte_Buffer); procedure Blockread (Stream : in out DCF.Streams.Root_Zipstream_Type'Class; Buffer : out Ada.Streams.Stream_Element_Array); -- This mimics the 'Write stream attribute; can be a lot faster, depending -- on the compiler's run-time library. -- NB: here we can use the root stream type: no question of size, index, etc. procedure Blockwrite (Stream : in out Ada.Streams.Root_Stream_Type'Class; Buffer : in Byte_Buffer); procedure Copy_Chunk (From : in out DCF.Streams.Root_Zipstream_Type'Class; Into : in out Ada.Streams.Root_Stream_Type'Class; Bytes : Ada.Streams.Stream_Element_Count; Feedback : Feedback_Proc := null); -- Copy a chunk from a stream into another one, using a temporary buffer User_Abort : exception; ----------------------------------------------------------------- -- Information about this package - e.g., for an "about" box -- ----------------------------------------------------------------- Version : constant String := "2.0.2"; private Default_Buffer_Size : constant := 1024 * 1024; -- 1 MiB -- Zip_info, 23.VI.1999. -- -- The PKZIP central directory is coded here as a binary tree -- to allow a fast retrieval of the searched offset in zip file. -- E.g. for a 1000-file archive, the offset will be found in less -- than 11 moves: 2**10=1024 (balanced case), without any read -- in the archive. -- -- *Note* 19-Oct-2018: rev. 670 to 683 used a Hashed Map and a -- Vector (Ada.Containers). The loading of the dictionary was -- much faster (2x), but there were performance bottlenecks elsewhere, -- not solved by profiling. On an archive with 18000 small entries of -- around 1 KB each, comp_zip ran 100x slower! -- Neither the restricted use of Unbounded_String, nor the replacement -- of the Vector by an array helped solving the performance issue. type Dir_Node; type P_Dir_Node is access Dir_Node; type Dir_Node (Name_Len : Natural) is record Left, Right : P_Dir_Node; Dico_Name : String (1 .. Name_Len); -- UPPER if case-insensitive search File_Name : String (1 .. Name_Len); File_Index : DCF.Streams.Zs_Index_Type; Comp_Size : File_Size_Type; Uncomp_Size : File_Size_Type; Crc_32 : Unsigned_32; Date_Time : Time; Method : Pkzip_Method; Name_Encoding : Zip_Name_Encoding; Read_Only : Boolean; -- TBD: attributes of most supported systems Encrypted_2_X : Boolean; end record; type Zip_Archive_Format_Type is (Zip_32, Zip_64); -- Supported so far: Zip_32 type P_String is access String; type Zip_Info is new Ada.Finalization.Controlled with record Loaded : Boolean := False; Case_Sensitive : Boolean; Zip_Input_Stream : DCF.Streams.Zipstream_Class_Access; Dir_Binary_Tree : P_Dir_Node; Total_Entries : Natural; Zip_File_Comment : P_String; Zip_Archive_Format : Zip_Archive_Format_Type := Zip_32; end record; overriding procedure Adjust (Info : in out Zip_Info); -- After a copy, need to clone a few things overriding procedure Finalize (Info : in out Zip_Info); -- Free heap-allocated memory -- Codes for compression formats in Zip archives -- See PKWARE's Appnote, "4.4.5 compression method" package Compression_Format_Code is Store : constant := 0; Deflate : constant := 8; end Compression_Format_Code; type Archived_File is tagged limited record Node : P_Dir_Node; end record; end DCF.Zip;
29,673
ada
0
Lucretia/interview-questions
ada/src/nearest_coin.adb
-- From https://www.youtube.com/watch?v=xC8CGv1CyFk with Ada.Text_IO; use Ada.Text_IO; -- In the C++ above, the coins are at coords: -- (1, 0), (1, 3), (0, 3), (5, 5) -- Map is 0 based. -- distance ( (2, 1) => (1, 3) => 3 (1 left + 2 down)) -- distance ( (2, 1) => (4, 2) => 5 (2 right + 1 down)) -- distance ( (2, 1) => (5, 5) => 7 (3 right + 4 down)) -- +-----------------------+ -- | . | x | . | . | . | . | -- +-----------------------+ -- | . | . | . | o | . | . | -- +-----------------------+ -- | o | . | . | . | . | . | -- +-----------------------+ -- | . | . | . | . | . | . | -- +-----------------------+ -- | . | . | . | . | o | . | -- +-----------------------+ -- | . | . | . | . | . | . | -- +-----------------------+ procedure Nearest_Coin is subtype Map_Dimensions is Natural range 1 .. 6; type Point is record X, Y : Map_Dimensions; end record; function Manhattan_Distance (P1, P2 : in Point) return Natural is (abs (P1.X - P2.X) + abs (P1.Y - P2.Y)); type Points is array (Natural range <>) of Point; function Closest (My_Position : in Point; Coins : in Points) return Positive is Index : Natural := Natural'First; Index_Distance : Natural := Manhattan_Distance (My_Position, Coins (Index)); Coin_Distance : Natural := Natural'First; begin -- Assume the array is > 1 in length. -- Go through each coin in the array and calculate their distance, My_Position - p. for Coin_Index in Coins'First + 1 .. Coins'Last loop Coin_Distance := Manhattan_Distance (My_Position, Coins (Coin_Index)); -- Skip if equal or greater than. if Coin_Distance < Index_Distance then Index := Coin_Index; Index_Distance := Coin_Distance; end if; end loop; return Index_Distance; end Closest; Result : Positive; package PIO is new Integer_IO (Positive); use PIO; My_Position : constant Point := (2, 1); begin Result := Closest (My_Position, Coins => Points'((1, 3), (4, 2), (5, 5))); Put ("Result : "); -- 3 (1 left + 2 down) Put (Result); New_Line; Result := Closest (My_Position, Coins => Points'((4, 2), (1, 3), (5, 5))); Put ("Result : "); -- 3 as above Put (Result); New_Line; Result := Closest (My_Position, Coins => Points'((4, 2), (1, 3), (5, 5), (1, 2))); Put ("Result : "); -- 2 (1 left + 1 down) Put (Result); New_Line; Result := Closest (My_Position, Coins => Points'((4, 2), (1, 3), (5, 5), (2, 2))); Put ("Result : "); -- 1 (1 down) Put (Result); New_Line; end Nearest_Coin;
29,674
ada
1
OneWingedShark/Risi
src/risi_script-types-identifier.ads
Pragma Ada_2012; Pragma Wide_Character_Encoding( UTF8 ); with Ada.Characters.Handling; -- Ada.Containers.Indefinite_Vectors; Package Risi_Script.Types.Identifier is SubType Identifier is String with Dynamic_Predicate => Is_Valid( Identifier ) or else raise Parse_Error with "Invalid identifier: """ & Identifier & '"'; Private Function Is_Valid( Input: String ) return Boolean is ( Input'Length in Positive and then Ada.Characters.Handling.Is_Letter(Input(Input'First)) and then Ada.Characters.Handling.Is_Alphanumeric(Input(Input'Last)) and then (for all Ch of Input => Ch = '_' or Ada.Characters.Handling.Is_Alphanumeric(Ch)) and then (for all Index in Input'First..Positive'Pred(Input'Last) => (if Input(Index) = '_' then Input(Index+1) /= '_') ) ); -- Type Scope is new Scope_Vector.Vector with null record; End Risi_Script.Types.Identifier;
29,675
ada
10
persan/gdnative_ada
examples/adventure_game/src/engine_hooks.ads
with GDNative; use GDNative; with GDNative.Thin; package Engine_Hooks is procedure On_GDNative_Init (p_options : access Thin.godot_gdnative_init_options) with Export => True, Convention => C, External_Name => "adventure_gdnative_init"; procedure On_GDNative_Terminate (p_options : access Thin.godot_gdnative_terminate_options) with Export => True, Convention => C, External_Name => "adventure_gdnative_terminate"; procedure On_Nativescript_Init (p_handle : Thin.Nativescript_Handle) with Export => True, Convention => C, External_Name => "adventure_nativescript_init"; end;
29,676
ada
1
io7m/coreland-openal-ada
openal-extension-efx_thin.adb
-- Automatically generated, do not edit. with OpenAL.Load; package body OpenAL.Extension.EFX_Thin is -- -- Load function for API pointers -- function Load_API return API_t is function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Auxiliary_Effect_Slotf_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Auxiliary_Effect_Slotfv_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Auxiliary_Effect_Sloti_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Auxiliary_Effect_Slotiv_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Delete_Auxiliary_Effect_Slots_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Delete_Effects_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Delete_Filters_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Effectf_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Effectfv_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Effecti_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Effectiv_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Filterf_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Filterfv_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Filteri_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Filteriv_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Gen_Auxiliary_Effect_Slots_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Gen_Effects_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Gen_Filters_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Get_Auxiliary_Effect_Slotf_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Get_Auxiliary_Effect_Slotfv_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Get_Auxiliary_Effect_Sloti_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Get_Auxiliary_Effect_Slotiv_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Get_Effectf_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Get_Effectfv_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Get_Effecti_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Get_Effectiv_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Get_Filterf_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Get_Filterfv_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Get_Filteri_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Get_Filteriv_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Is_Auxiliary_Effect_Slot_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Is_Effect_t); function Load_Function is new Load.Load_Subprogram (Subprogram_Access_Type => Is_Filter_t); begin return API_t' (Auxiliary_Effect_Slotf => Load_Function ("alAuxiliaryEffectSlotf"), Auxiliary_Effect_Slotfv => Load_Function ("alAuxiliaryEffectSlotfv"), Auxiliary_Effect_Sloti => Load_Function ("alAuxiliaryEffectSloti"), Auxiliary_Effect_Slotiv => Load_Function ("alAuxiliaryEffectSlotiv"), Delete_Auxiliary_Effect_Slots => Load_Function ("alDeleteAuxiliaryEffectSlots"), Delete_Effects => Load_Function ("alDeleteEffects"), Delete_Filters => Load_Function ("alDeleteFilters"), Effectf => Load_Function ("alEffectf"), Effectfv => Load_Function ("alEffectfv"), Effecti => Load_Function ("alEffecti"), Effectiv => Load_Function ("alEffectiv"), Filterf => Load_Function ("alFilterf"), Filterfv => Load_Function ("alFilterfv"), Filteri => Load_Function ("alFilteri"), Filteriv => Load_Function ("alFilteriv"), Gen_Auxiliary_Effect_Slots => Load_Function ("alGenAuxiliaryEffectSlots"), Gen_Effects => Load_Function ("alGenEffects"), Gen_Filters => Load_Function ("alGenFilters"), Get_Auxiliary_Effect_Slotf => Load_Function ("alGetAuxiliaryEffectSlotf"), Get_Auxiliary_Effect_Slotfv => Load_Function ("alGetAuxiliaryEffectSlotfv"), Get_Auxiliary_Effect_Sloti => Load_Function ("alGetAuxiliaryEffectSloti"), Get_Auxiliary_Effect_Slotiv => Load_Function ("alGetAuxiliaryEffectSlotiv"), Get_Effectf => Load_Function ("alGetEffectf"), Get_Effectfv => Load_Function ("alGetEffectfv"), Get_Effecti => Load_Function ("alGetEffecti"), Get_Effectiv => Load_Function ("alGetEffectiv"), Get_Filterf => Load_Function ("alGetFilterf"), Get_Filterfv => Load_Function ("alGetFilterfv"), Get_Filteri => Load_Function ("alGetFilteri"), Get_Filteriv => Load_Function ("alGetFilteriv"), Is_Auxiliary_Effect_Slot => Load_Function ("alIsAuxiliaryEffectSlot"), Is_Effect => Load_Function ("alIsEffect"), Is_Filter => Load_Function ("alIsFilter")); end Load_API; end OpenAL.Extension.EFX_Thin;
29,677
ada
24
svn2github/matreshka
source/league/ucd/matreshka-internals-unicode-ucd-core_0013.ads
<reponame>svn2github/matreshka ------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2012-2015, <NAME> <<EMAIL>> -- -- 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_0013 is pragma Preelaborate; Group_0013 : aliased constant Core_Second_Stage := (16#11# => -- 1311 (Unassigned, Neutral, Other, Other, Other, Unknown, (others => False)), 16#16# .. 16#17# => -- 1316 .. 1317 (Unassigned, Neutral, Other, Other, Other, Unknown, (others => False)), 16#5B# .. 16#5C# => -- 135B .. 135C (Unassigned, Neutral, Other, Other, Other, Unknown, (others => False)), 16#5D# .. 16#5E# => -- 135D .. 135E (Nonspacing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Case_Ignorable | Grapheme_Extend | ID_Continue | XID_Continue => True, others => False)), 16#5F# => -- 135F (Nonspacing_Mark, Neutral, Extend, Extend, Extend, Combining_Mark, (Other_Alphabetic | Alphabetic | Case_Ignorable | Grapheme_Extend | ID_Continue | XID_Continue => True, others => False)), 16#60# => -- 1360 (Other_Punctuation, Neutral, Other, Other, Other, Alphabetic, (Grapheme_Base => True, others => False)), 16#61# => -- 1361 (Other_Punctuation, Neutral, Other, Other, Other, Break_After, (Terminal_Punctuation | Grapheme_Base => True, others => False)), 16#62# => -- 1362 (Other_Punctuation, Neutral, Other, Other, S_Term, Alphabetic, (STerm | Terminal_Punctuation | Grapheme_Base => True, others => False)), 16#63# .. 16#66# => -- 1363 .. 1366 (Other_Punctuation, Neutral, Other, Other, Other, Alphabetic, (Terminal_Punctuation | Grapheme_Base => True, others => False)), 16#67# .. 16#68# => -- 1367 .. 1368 (Other_Punctuation, Neutral, Other, Other, S_Term, Alphabetic, (STerm | Terminal_Punctuation | Grapheme_Base => True, others => False)), 16#69# .. 16#71# => -- 1369 .. 1371 (Other_Number, Neutral, Other, Other, Other, Alphabetic, (Other_ID_Continue | Grapheme_Base | ID_Continue | XID_Continue => True, others => False)), 16#72# .. 16#7C# => -- 1372 .. 137C (Other_Number, Neutral, Other, Other, Other, Alphabetic, (Grapheme_Base => True, others => False)), 16#7D# .. 16#7F# => -- 137D .. 137F (Unassigned, Neutral, Other, Other, Other, Unknown, (others => False)), 16#90# .. 16#99# => -- 1390 .. 1399 (Other_Symbol, Neutral, Other, Other, Other, Alphabetic, (Grapheme_Base => True, others => False)), 16#9A# .. 16#9F# => -- 139A .. 139F (Unassigned, Neutral, Other, Other, Other, Unknown, (others => False)), 16#F5# .. 16#FF# => -- 13F5 .. 13FF (Unassigned, Neutral, Other, Other, Other, Unknown, (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_0013;
29,678
ada
1
LaudateCorpus1/RosettaCodeData
Task/Zig-zag-matrix/Ada/zig-zag-matrix.ada
with Ada.Text_IO; use Ada.Text_IO; procedure Test_Zig_Zag is type Matrix is array (Positive range <>, Positive range <>) of Natural; function Zig_Zag (Size : Positive) return Matrix is Data : Matrix (1..Size, 1..Size); I, J : Integer := 1; begin Data (1, 1) := 0; for Element in 1..Size**2 - 1 loop if (I + J) mod 2 = 0 then -- Even stripes if J < Size then J := J + 1; else I := I + 2; end if; if I > 1 then I := I - 1; end if; else -- Odd stripes if I < Size then I := I + 1; else J := J + 2; end if; if J > 1 then J := J - 1; end if; end if; Data (I, J) := Element; end loop; return Data; end Zig_Zag; procedure Put (Data : Matrix) is begin for I in Data'Range (1) loop for J in Data'Range (2) loop Put (Integer'Image (Data (I, J))); end loop; New_Line; end loop; end Put; begin Put (Zig_Zag (5)); end Test_Zig_Zag;
29,679
ada
15
My-Colaborations/dynamo
src/asis/asis-definitions.adb
<filename>src/asis/asis-definitions.adb ------------------------------------------------------------------------------ -- -- -- ASIS-for-GNAT IMPLEMENTATION COMPONENTS -- -- -- -- A S I S . D E F I N I T I O N S -- -- -- -- B o d y -- -- -- -- Copyright (C) 1995-2011, Free Software Foundation, Inc. -- -- -- -- ASIS-for-GNAT is free software; you can redistribute it and/or modify it -- -- under terms of the GNU General Public License as published by the Free -- -- Software Foundation; either version 2, or (at your option) any later -- -- version. ASIS-for-GNAT is distributed in the hope that it will be use- -- -- ful, but WITHOUT ANY WARRANTY; without even the implied warranty of MER- -- -- CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General -- -- Public License for more details. You should have received a copy of the -- -- GNU General Public License distributed with ASIS-for-GNAT; see file -- -- COPYING. If not, write to the Free Software Foundation, 51 Franklin -- -- Street, Fifth Floor, Boston, MA 02110-1301, USA. -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- ASIS-for-GNAT was originally developed by the ASIS-for-GNAT team at the -- -- Software Engineering Laboratory of the Swiss Federal Institute of -- -- Technology (LGL-EPFL) in Lausanne, Switzerland, in cooperation with the -- -- Scientific Research Computer Center of Moscow State University (SRCC -- -- MSU), Russia, with funding partially provided by grants from the Swiss -- -- National Science Foundation and the Swiss Academy of Engineering -- -- Sciences. ASIS-for-GNAT is now maintained by AdaCore -- -- (http://www.adacore.com). -- -- -- ------------------------------------------------------------------------------ with Asis.Declarations; use Asis.Declarations; with Asis.Elements; use Asis.Elements; with Asis.Errors; use Asis.Errors; with Asis.Exceptions; use Asis.Exceptions; with Asis.Extensions; use Asis.Extensions; with Asis.Set_Get; use Asis.Set_Get; with A4G.A_Sem; use A4G.A_Sem; with A4G.Asis_Tables; use A4G.Asis_Tables; with A4G.Contt.UT; use A4G.Contt.UT; with A4G.Mapping; use A4G.Mapping; with A4G.Norm; use A4G.Norm; with A4G.Stand; use A4G.Stand; with A4G.Vcheck; use A4G.Vcheck; with Atree; use Atree; with Einfo; use Einfo; with Namet; use Namet; with Nlists; use Nlists; with Sinfo; use Sinfo; package body Asis.Definitions is Package_Name : constant String := "Asis.Definitions."; ------------------------------------------------------------------------------ --------------------------- -- ASIS 2005 Draft stuff -- --------------------------- --------------------------------------------- -- Anonymous_Access_To_Object_Subtype_Mark -- --------------------------------------------- function Anonymous_Access_To_Object_Subtype_Mark (Definition : Asis.Definition) return Asis.Expression is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Definition); Arg_Node : Node_Id; begin Check_Validity (Definition, Package_Name & "Anonymous_Access_To_Object_Subtype_Mark"); if not (Arg_Kind = An_Anonymous_Access_To_Variable or else Arg_Kind = An_Anonymous_Access_To_Constant) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Anonymous_Access_To_Object_Subtype_Mark", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Definition); return Node_To_Element_New (Node => Subtype_Mark (Arg_Node), Starting_Element => Definition); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Definition, Outer_Call => Package_Name & "Anonymous_Access_To_Object_Subtype_Mark"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Anonymous_Access_To_Object_Subtype_Mark", Ex => Ex, Arg_Element => Definition); end Anonymous_Access_To_Object_Subtype_Mark; ------------------------------- -- Component_Definition_View -- ------------------------------- function Component_Definition_View (Component_Definition : Asis.Component_Definition) return Asis.Definition is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Component_Definition); Res_Node : Node_Id; Result_Kind : Internal_Element_Kinds := Not_An_Element; begin Check_Validity (Component_Definition, Package_Name & "Component_Definition_View"); if not (Arg_Kind = A_Component_Definition) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Component_Definition_View", Wrong_Kind => Arg_Kind); end if; Res_Node := R_Node (Component_Definition); if Is_Rewrite_Substitution (Res_Node) or else Present (Access_Definition (Res_Node)) then Res_Node := Access_Definition (Original_Node (Res_Node)); else Result_Kind := A_Subtype_Indication; Res_Node := Sinfo.Subtype_Indication (Res_Node); end if; return Node_To_Element_New (Node => Res_Node, Starting_Element => Component_Definition, Internal_Kind => Result_Kind); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Component_Definition, Outer_Call => Package_Name & "Component_Definition_View"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Component_Definition_View", Ex => Ex, Arg_Element => Component_Definition); end Component_Definition_View; ------------------------------- -- Definition_Interface_List -- ------------------------------- function Definition_Interface_List (Type_Definition : Asis.Definition) return Asis.Expression_List is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Type_Definition); Arg_Node : Node_Id; First_I : Node_Id; I_Kind : Internal_Element_Kinds; begin Check_Validity (Type_Definition, Package_Name & "Definition_Interface_List"); if not (Arg_Kind = A_Derived_Record_Extension_Definition or else Arg_Kind = A_Private_Extension_Definition or else Arg_Kind in Internal_Interface_Kinds or else Arg_Kind = A_Formal_Derived_Type_Definition or else Arg_Kind in Internal_Formal_Interface_Kinds) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Definition_Interface_List", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Type_Definition); if Nkind (Arg_Node) = N_Record_Definition and then not Interface_Present (Arg_Node) then return Nil_Element_List; elsif Nkind (Arg_Node) = N_Derived_Type_Definition and then Interface_Present (Arg_Node) then -- The first interface name in the list is represented as -- Subtype_Indication field in N_Derived_Type_Definition node First_I := Sinfo.Subtype_Indication (Arg_Node); if Nkind (First_I) = N_Identifier then I_Kind := An_Identifier; else I_Kind := A_Selected_Component; end if; return Node_To_Element_New (Node => First_I, Starting_Element => Type_Definition, Internal_Kind => I_Kind) & N_To_E_List_New (List => Interface_List (Arg_Node), Starting_Element => Type_Definition); else return N_To_E_List_New (List => Interface_List (Arg_Node), Starting_Element => Type_Definition); end if; exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Type_Definition, Outer_Call => Package_Name & "Definition_Interface_List"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Definition_Interface_List", Ex => Ex, Arg_Element => Type_Definition); end Definition_Interface_List; --------------------------- -- ASIS 2012 Draft stuff -- --------------------------- ----------------------- -- Aspect_Definition -- ----------------------- function Aspect_Definition (Aspect_Specification : Asis.Element) return Asis.Element is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Aspect_Specification); begin Check_Validity (Aspect_Specification, Package_Name & "Aspect_Definition"); if Arg_Kind /= An_Aspect_Specification then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Aspect_Definition", Wrong_Kind => Arg_Kind); end if; return Node_To_Element_New (Node => Sinfo.Expression (Node (Aspect_Specification)), Starting_Element => Aspect_Specification); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Aspect_Specification, Outer_Call => Package_Name & "Aspect_Definition"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Aspect_Definition", Ex => Ex, Arg_Element => Aspect_Specification); end Aspect_Definition; ----------------- -- Aspect_Mark -- ----------------- function Aspect_Mark (Aspect_Specification : Asis.Element) return Asis.Element is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Aspect_Specification); Res_Node : Node_Id; Res_Kind : Internal_Element_Kinds := An_Identifier; begin Check_Validity (Aspect_Specification, Package_Name & "Aspect_Mark"); if Arg_Kind /= An_Aspect_Specification then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Aspect_Mark", Wrong_Kind => Arg_Kind); end if; Res_Node := Node (Aspect_Specification); if Class_Present (Res_Node) then Res_Kind := A_Class_Attribute; end if; Res_Node := Sinfo.Identifier (Res_Node); return Node_To_Element_New (Node => Res_Node, Starting_Element => Aspect_Specification, Internal_Kind => Res_Kind); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Aspect_Specification, Outer_Call => Package_Name & "Aspect_Mark"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Aspect_Mark", Ex => Ex, Arg_Element => Aspect_Specification); end Aspect_Mark; ------------------------------------------------------------------------------ -- NOT IMPLEMENTED -- The query is implemented with the following ramification of its -- definition: -- -- 1. The list of appropriate kinds is: -- -- Appropriate Definition_Kinds: -- A_Type_Definition -- A_Formal_Type_Declaration -- A_Private_Type_Definition -- A_Tagged_Private_Type_Definition -- A_Private_Extension_Definition -- A_Task_Definition -- A_Protected_Definition -- -- 2. The query returns only primitive operators of the type, except if the -- argument is A_Formal_Type_Declaration. In the latter case the result -- contains inherited user-defined operators and all the formal -- operators defined for this type -- -- 3. Any operator that satisfy conditions given in (2) and that has a -- parameter or returns the result of the argument type is returned. -- -- 4. In case of a private type and private extension, the query returns -- the same results when applied to the private and to the full view. -- -- 5. Implicit declarations of predefined operators are not supported. So -- they are not included in the result of the query function Corresponding_Type_Operators (Type_Definition : Asis.Type_Definition) return Asis.Declaration_List is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Type_Definition); begin Check_Validity (Type_Definition, Package_Name & "Corresponding_Type_Operators"); if not (Arg_Kind in Internal_Type_Kinds or else Arg_Kind in Internal_Formal_Type_Kinds or else Arg_Kind in A_Private_Type_Definition .. A_Protected_Definition) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Corresponding_Type_Operators", Wrong_Kind => Arg_Kind); end if; return Inherited_Type_Operators (Type_Definition) & Explicit_Type_Operators (Type_Definition); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Type_Definition, Outer_Call => Package_Name & "Corresponding_Type_Operators"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Corresponding_Type_Operators", Ex => Ex, Arg_Element => Type_Definition); end Corresponding_Type_Operators; ----------------------------------------------------------------------------- function Parent_Subtype_Indication (Type_Definition : Asis.Type_Definition) return Asis.Subtype_Indication is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Type_Definition); Arg_Node : Node_Id; begin Check_Validity (Type_Definition, Package_Name & "Parent_Subtype_Indication"); if not (Arg_Kind = A_Derived_Type_Definition or else Arg_Kind = A_Derived_Record_Extension_Definition) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Parent_Subtype_Indication", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Type_Definition); return Node_To_Element_New (Node => Sinfo.Subtype_Indication (Arg_Node), Starting_Element => Type_Definition, Internal_Kind => A_Subtype_Indication); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Type_Definition, Outer_Call => Package_Name & "Parent_Subtype_Indication"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Parent_Subtype_Indication", Ex => Ex, Arg_Element => Type_Definition); end Parent_Subtype_Indication; ----------------------------------------------------------------------------- function Record_Definition (Type_Definition : Asis.Type_Definition) return Asis.Record_Definition is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Type_Definition); Arg_Node : Node_Id; Result_Kind : Internal_Element_Kinds; Result_Node : Node_Id; begin Check_Validity (Type_Definition, Package_Name & "Record_Definition"); if not (Arg_Kind = A_Derived_Record_Extension_Definition or else Arg_Kind = A_Record_Type_Definition or else Arg_Kind = A_Tagged_Record_Type_Definition) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Record_Definition", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Type_Definition); if Arg_Kind = A_Derived_Record_Extension_Definition then Result_Node := Record_Extension_Part (Arg_Node); else Result_Node := Arg_Node; end if; if Null_Present (Result_Node) then Result_Kind := A_Null_Record_Definition; else Result_Kind := A_Record_Definition; end if; return Node_To_Element_New (Node => Result_Node, Starting_Element => Type_Definition, Internal_Kind => Result_Kind); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Type_Definition, Outer_Call => Package_Name & "Record_Definition"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Record_Definition", Ex => Ex, Arg_Element => Type_Definition); end Record_Definition; ------------------------------------------------------------------------------ -- NOT IMPLEMENTED??? function Implicit_Inherited_Declarations (Definition : Asis.Definition) return Asis.Declaration_List is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Definition); Type_Entity_Node : Node_Id; Type_Decl_Node : Node_Id; Inherit_Discrims : Boolean := True; begin Check_Validity (Definition, Package_Name & "Implicit_Inherited_Declarations"); if not (Arg_Kind = A_Private_Extension_Definition or else Arg_Kind = A_Derived_Type_Definition or else Arg_Kind = A_Derived_Record_Extension_Definition or else Arg_Kind = A_Formal_Derived_Type_Definition) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Implicit_Inherited_Declarations", Wrong_Kind => Arg_Kind); end if; Type_Entity_Node := Defining_Identifier (Parent (R_Node (Definition))); if not (Is_Record_Type (Type_Entity_Node) or else Is_Enumeration_Type (Type_Entity_Node) or else Is_Task_Type (Type_Entity_Node) or else Is_Protected_Type (Type_Entity_Node)) then return Nil_Element_List; end if; Type_Decl_Node := Parent (R_Node (Definition)); if Present (Discriminant_Specifications (Original_Node (Type_Decl_Node))) then Inherit_Discrims := False; end if; if Is_Record_Type (Type_Entity_Node) then Set_Inherited_Components (Definition, Inherit_Discrims); elsif Is_Concurrent_Type (Type_Entity_Node) then Set_Concurrent_Inherited_Components (Definition, Inherit_Discrims); elsif Is_Enumeration_Type (Type_Entity_Node) then if Present (First_Literal (Type_Entity_Node)) then Set_Inherited_Literals (Definition); else -- Type derived (directly or indirectly) from Standard.Character -- or Standard.Wide_Character return Standard_Char_Decls (Type_Definition => Definition, Implicit => True); end if; else Not_Implemented_Yet (Diagnosis => Package_Name & "Implicit_Inherited_Declarations"); end if; for J in 1 .. Asis_Element_Table.Last loop Set_From_Implicit (Asis_Element_Table.Table (J), True); Set_From_Inherited (Asis_Element_Table.Table (J), True); Set_Node_Field_1 (Asis_Element_Table.Table (J), Type_Decl_Node); end loop; return Asis.Declaration_List (Asis_Element_Table.Table (1 .. Asis_Element_Table.Last)); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Definition, Outer_Call => Package_Name & "Implicit_Inherited_Declarations"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Implicit_Inherited_Declarations", Ex => Ex, Arg_Element => Definition); end Implicit_Inherited_Declarations; ------------------------------------------------------------------------------ function Implicit_Inherited_Subprograms (Definition : Asis.Definition) return Asis.Declaration_List is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Definition); Type_Entity_Node : Node_Id; Next_Subpr_Node : Node_Id; Next_Expl_Subpr : Node_Id; Expl_Subpr_Name : Node_Id; Next_Subpr_Kind : Internal_Element_Kinds; Next_Subpr_Element : Element; Result_Unit : Compilation_Unit; begin Check_Validity (Definition, Package_Name & "Implicit_Inherited_Subprograms"); if not (Arg_Kind = A_Private_Extension_Definition or else Arg_Kind = A_Derived_Type_Definition or else Arg_Kind = A_Derived_Record_Extension_Definition or else Arg_Kind = A_Formal_Derived_Type_Definition or else Arg_Kind in Internal_Interface_Kinds or else Arg_Kind in Internal_Formal_Interface_Kinds) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Implicit_Inherited_Subprograms", Wrong_Kind => Arg_Kind); end if; Type_Entity_Node := R_Node (Definition); if Nkind (Type_Entity_Node) /= N_Private_Extension_Declaration then Type_Entity_Node := Parent (Type_Entity_Node); end if; Type_Entity_Node := Defining_Identifier (Type_Entity_Node); Result_Unit := Encl_Unit (Definition); Asis_Element_Table.Init; Next_Subpr_Node := Next_Entity (Type_Entity_Node); -- All the inherited subprograms can be *after* the type entity only Type_Entity_Node := Parent (Type_Entity_Node); -- now Type_Entity_Node points to the type declaration of the type -- which inherits the result subprograms while Present (Next_Subpr_Node) loop if (Ekind (Next_Subpr_Node) = E_Procedure or else Ekind (Next_Subpr_Node) = E_Function) and then Parent (Next_Subpr_Node) = Type_Entity_Node and then not (Is_Hidden (Next_Subpr_Node) and then Present (Interface_Alias (Next_Subpr_Node))) then -- This entity node represents the user-defined inherited -- subprogram for Type_Entity_Node Next_Expl_Subpr := Explicit_Parent_Subprogram (Next_Subpr_Node); Expl_Subpr_Name := Next_Expl_Subpr; if Is_Generic_Instance (Expl_Subpr_Name) then -- Go to the instantiation entity node, because for the -- expanded subprogram the front-end creates an artificial -- name: while Nkind (Expl_Subpr_Name) /= N_Package_Declaration loop Expl_Subpr_Name := Parent (Expl_Subpr_Name); end loop; while Nkind (Expl_Subpr_Name) not in N_Generic_Instantiation loop Expl_Subpr_Name := Next (Expl_Subpr_Name); end loop; Expl_Subpr_Name := Defining_Unit_Name (Expl_Subpr_Name); end if; if Chars (Next_Subpr_Node) = Chars (Expl_Subpr_Name) then -- For this condition, see the discussion in 8215-007 Next_Expl_Subpr := Parent (Next_Expl_Subpr); if Ekind (Next_Subpr_Node) = E_Function then Next_Subpr_Kind := A_Function_Declaration; elsif Null_Present (Next_Expl_Subpr) then Next_Subpr_Kind := A_Null_Procedure_Declaration; else Next_Subpr_Kind := A_Procedure_Declaration; end if; Next_Expl_Subpr := Parent (Next_Expl_Subpr); Next_Subpr_Element := Node_To_Element_New (Node => Next_Expl_Subpr, Node_Field_1 => Next_Subpr_Node, Internal_Kind => Next_Subpr_Kind, Inherited => True, In_Unit => Result_Unit); -- See the comment in the body of -- A4G.A_Sem.Get_Corr_Called_Entity if Is_From_Instance (Next_Subpr_Node) then Set_From_Instance (Next_Subpr_Element, True); else Set_From_Instance (Next_Subpr_Element, False); end if; Asis_Element_Table.Append (Next_Subpr_Element); end if; end if; Next_Subpr_Node := Next_Entity (Next_Subpr_Node); end loop; return Asis.Declaration_List (Asis_Element_Table.Table (1 .. Asis_Element_Table.Last)); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Definition, Outer_Call => Package_Name & "Implicit_Inherited_Subprograms"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Implicit_Inherited_Subprograms", Ex => Ex, Arg_Element => Definition); end Implicit_Inherited_Subprograms; ----------------------------------------------------------------------------- function Corresponding_Parent_Subtype (Type_Definition : Asis.Type_Definition) return Asis.Declaration is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Type_Definition); Type_Mark_Node : Node_Id; Result_Node : Node_Id; Result_Unit : Asis.Compilation_Unit; Result : Asis.Element := Nil_Element; begin Check_Validity (Type_Definition, Package_Name & "Corresponding_Parent_Subtype"); if not (Arg_Kind = A_Derived_Type_Definition or else Arg_Kind = A_Derived_Record_Extension_Definition) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Corresponding_Parent_Subtype", Wrong_Kind => Arg_Kind); end if; Type_Mark_Node := Sinfo.Subtype_Indication (Node (Type_Definition)); if Nkind (Type_Mark_Node) = N_Subtype_Indication then Type_Mark_Node := Sinfo.Subtype_Mark (Type_Mark_Node); end if; if Nkind (Original_Node (Type_Mark_Node)) /= N_Attribute_Reference then Result_Node := Entity (Type_Mark_Node); Result_Node := Parent (Result_Node); Result_Unit := Enclosing_Unit (Encl_Cont_Id (Type_Definition), Result_Node); Result := Node_To_Element_New (Node => Result_Node, In_Unit => Result_Unit); end if; return Result; exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Type_Definition, Outer_Call => Package_Name & "Corresponding_Parent_Subtype"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Corresponding_Parent_Subtype", Ex => Ex, Arg_Element => Type_Definition); end Corresponding_Parent_Subtype; ----------------------------------------------------------------------------- function Corresponding_Root_Type (Type_Definition : Asis.Type_Definition) return Asis.Declaration is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Type_Definition); Result_El : Asis.Declaration; Result_Kind : Internal_Element_Kinds; Def_El : Asis.Type_Definition; Def_Kind : Internal_Element_Kinds; begin Check_Validity (Type_Definition, Package_Name & "Corresponding_Root_Type"); if not (Arg_Kind = A_Derived_Type_Definition or else Arg_Kind = A_Derived_Record_Extension_Definition) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Corresponding_Root_Type", Wrong_Kind => Arg_Kind); end if; Result_El := Corresponding_Parent_Subtype_Unwind_Base (Type_Definition); loop Result_Kind := Int_Kind (Result_El); if Result_Kind = A_Subtype_Declaration then Result_El := Corresponding_First_Subtype (Result_El); else -- Result_El can be of An_Ordinary_Type_Declaration, -- A_Task_Type_Declaration, A_Protected_Type_Declaration, -- A_Private_Type_Declaration, A_Private_Extension_Declaration -- or A_Formal_Type_Declaration only if Result_Kind = An_Ordinary_Type_Declaration or else Result_Kind = A_Formal_Type_Declaration then Def_El := Type_Declaration_View (Result_El); Def_Kind := Int_Kind (Def_El); if Def_Kind = A_Derived_Type_Definition or else Def_Kind = A_Derived_Record_Extension_Definition then Result_El := Corresponding_Parent_Subtype_Unwind_Base (Def_El); else exit; end if; else exit; end if; end if; end loop; return Result_El; exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Type_Definition, Outer_Call => Package_Name & "Corresponding_Root_Type"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Corresponding_Root_Type", Ex => Ex, Arg_Element => Type_Definition); end Corresponding_Root_Type; ------------------------------------------------------------------------------ function Corresponding_Type_Structure (Type_Definition : Asis.Type_Definition) return Asis.Declaration is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Type_Definition); Result_El : Asis.Element; Type_Def_El : Asis.Element; Res_Entity_Node : Node_Id; Tmp_Node : Node_Id; begin Check_Validity (Type_Definition, Package_Name & "Corresponding_Type_Structure"); if not (Arg_Kind = A_Derived_Type_Definition or else Arg_Kind = A_Derived_Record_Extension_Definition) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Corresponding_Type_Structure", Wrong_Kind => Arg_Kind); end if; -- The implementation approach: -- 1. We are considering, that the following things change the -- type structure (type representation): -- (1) adding the new component to a tagged record type; -- (2) applying any representation pragma or representation -- clause to a type in the derivation chain -- ??? What about adding a new primitive operation in case of a -- ??? tagged type? It changes the representation of the tag. -- -- 2. The implementation is based on other semantic queries from -- this package. The idea is to make the implementation more -- stable and to isolate the code which depends on processing of -- implicit types in the tree Result_El := Enclosing_Element (Type_Definition); Res_Entity_Node := Defining_Identifier (Node (Result_El)); Derivation_Chain : loop -- In this loop we are iterating through the derivation chain. -- There are three reasons to exit the loop: -- 1. Result_El has representation items; -- 2. Result_El is not a derived type -- 3. Result_El defines a new component Tmp_Node := First_Rep_Item (Res_Entity_Node); while Present (Tmp_Node) loop if not Is_Derived_Rep_Item (Res_Entity_Node, Tmp_Node) then exit Derivation_Chain; end if; Tmp_Node := Next_Rep_Item (Tmp_Node); end loop; Type_Def_El := Type_Declaration_View (Result_El); case Int_Kind (Type_Def_El) is when A_Derived_Type_Definition | A_Formal_Derived_Type_Definition => null; when A_Derived_Record_Extension_Definition => -- Here we are iterating through the list of the components -- checking if there is a new, non-inherited component: Tmp_Node := First_Entity (Res_Entity_Node); while Present (Tmp_Node) loop if (Ekind (Tmp_Node) = E_Component or else Ekind (Tmp_Node) = E_Discriminant) and then Original_Record_Component (Tmp_Node) = Tmp_Node then -- Note that we can have implicit (sub)types in the chain exit Derivation_Chain; end if; Tmp_Node := Next_Entity (Tmp_Node); end loop; when others => exit Derivation_Chain; end case; Result_El := Type_Declaration_View (Result_El); Result_El := Corresponding_Parent_Subtype (Result_El); if Int_Kind (Result_El) = A_Subtype_Declaration then Result_El := Corresponding_First_Subtype (Result_El); end if; Res_Entity_Node := Defining_Identifier (Node (Result_El)); end loop Derivation_Chain; return Result_El; exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Type_Definition, Outer_Call => Package_Name & "Corresponding_Type_Structure"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Corresponding_Type_Structure", Ex => Ex, Arg_Element => Type_Definition); end Corresponding_Type_Structure; ------------------------------------------------------------------------------ function Enumeration_Literal_Declarations (Type_Definition : Asis.Type_Definition) return Asis.Declaration_List is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Type_Definition); Arg_Node : Node_Id; begin Check_Validity (Type_Definition, Package_Name & "Enumeration_Literal_Declarations"); if not (Arg_Kind = An_Enumeration_Type_Definition) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Enumeration_Literal_Declarations", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Type_Definition); if Is_Standard_Char_Type (Arg_Node) then -- There is no Literals list for standard char types, so a special -- processing is needed return Standard_Char_Decls (Type_Definition); else return N_To_E_List_New (List => Literals (Arg_Node), Starting_Element => Type_Definition, Internal_Kind => An_Enumeration_Literal_Specification); end if; exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Type_Definition, Outer_Call => Package_Name & "Enumeration_Literal_Declarations"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Enumeration_Literal_Declarations", Ex => Ex, Arg_Element => Type_Definition); end Enumeration_Literal_Declarations; ------------------------------------------------------------------------------ -- OPEN PROBLEMS: -- -- 1. Standard.Character and Standard.Whide_Character types have -- to be processed specifically (See Sinfo.ads item for -- N_Enumeration_Type_Definition Node. This is not implemented yet. ------------------------------------------------------------------------------ function Integer_Constraint (Type_Definition : Asis.Type_Definition) return Asis.Range_Constraint is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Type_Definition); Arg_Node : Node_Id; begin Check_Validity (Type_Definition, Package_Name & "Integer_Constraint"); if not (Arg_Kind = A_Signed_Integer_Type_Definition) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Integer_Constraint", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Type_Definition); return Node_To_Element_New (Node => Arg_Node, Starting_Element => Type_Definition, Internal_Kind => A_Simple_Expression_Range); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Type_Definition, Outer_Call => Package_Name & "Integer_Constraint"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Integer_Constraint", Ex => Ex, Arg_Element => Type_Definition); end Integer_Constraint; ----------------------------------------------------------------------------- function Mod_Static_Expression (Type_Definition : Asis.Type_Definition) return Asis.Expression is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Type_Definition); Arg_Node : Node_Id; begin Check_Validity (Type_Definition, Package_Name & "Mod_Static_Expression"); if not (Arg_Kind = A_Modular_Type_Definition) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Mod_Static_Expression", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Type_Definition); return Node_To_Element_New (Node => Sinfo.Expression (Arg_Node), Starting_Element => Type_Definition); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Type_Definition, Outer_Call => Package_Name & "Mod_Static_Expression"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Mod_Static_Expression", Ex => Ex, Arg_Element => Type_Definition); end Mod_Static_Expression; ----------------------------------------------------------------------------- function Digits_Expression (Definition : Asis.Definition) return Asis.Expression is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Definition); Arg_Node : Node_Id; begin Check_Validity (Definition, Package_Name & "Digits_Expression"); if not (Arg_Kind = A_Floating_Point_Definition or else Arg_Kind = A_Decimal_Fixed_Point_Definition or else Arg_Kind = A_Digits_Constraint) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Digits_Expression", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Definition); return Node_To_Element_New (Node => Digits_Expression (Arg_Node), Starting_Element => Definition); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Definition, Outer_Call => Package_Name & "Digits_Expression"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Digits_Expression", Ex => Ex, Arg_Element => Definition); end Digits_Expression; ----------------------------------------------------------------------------- function Delta_Expression (Definition : Asis.Definition) return Asis.Expression is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Definition); Arg_Node : Node_Id; begin Check_Validity (Definition, Package_Name & "Delta_Expression"); if not (Arg_Kind = An_Ordinary_Fixed_Point_Definition or else Arg_Kind = A_Decimal_Fixed_Point_Definition or else Arg_Kind = A_Delta_Constraint) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Delta_Expression", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Definition); return Node_To_Element_New (Node => Delta_Expression (Arg_Node), Starting_Element => Definition); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Definition, Outer_Call => Package_Name & "Delta_Expression"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Delta_Expression", Ex => Ex, Arg_Element => Definition); end Delta_Expression; ----------------------------------------------------------------------------- function Real_Range_Constraint (Definition : Asis.Definition) return Asis.Range_Constraint is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Definition); Arg_Node : Node_Id; Result_Node : Node_Id; begin Check_Validity (Definition, Package_Name & "Real_Range_Constraint"); if not (Arg_Kind = A_Floating_Point_Definition or else Arg_Kind = An_Ordinary_Fixed_Point_Definition or else Arg_Kind = A_Decimal_Fixed_Point_Definition or else Arg_Kind = A_Digits_Constraint or else Arg_Kind = A_Delta_Constraint) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Real_Range_Constraint", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Definition); if Arg_Kind = A_Floating_Point_Definition or else Arg_Kind = An_Ordinary_Fixed_Point_Definition or else Arg_Kind = A_Decimal_Fixed_Point_Definition then Result_Node := Real_Range_Specification (Arg_Node); else -- Arg_Kind = A_Digits_Constraint or Arg_Kind = A_Delta_Constraint Result_Node := Sinfo.Range_Constraint (Arg_Node); end if; if No (Result_Node) then return Nil_Element; else return Node_To_Element_New (Node => Result_Node, Starting_Element => Definition, Internal_Kind => A_Simple_Expression_Range); end if; exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information ( Argument => Definition, Outer_Call => Package_Name & "Real_Range_Constraint"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Real_Range_Constraint", Ex => Ex, Arg_Element => Definition); end Real_Range_Constraint; ----------------------------------------------------------------------------- function Index_Subtype_Definitions (Type_Definition : Asis.Type_Definition) return Asis.Expression_List is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Type_Definition); Arg_Node : Node_Id; begin Check_Validity (Type_Definition, Package_Name & "Index_Subtype_Definitions"); if not (Arg_Kind = An_Unconstrained_Array_Definition or else Arg_Kind = A_Formal_Unconstrained_Array_Definition) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Index_Subtype_Definitions", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Type_Definition); return N_To_E_List_New (List => Subtype_Marks (Arg_Node), Starting_Element => Type_Definition); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information ( Argument => Type_Definition, Outer_Call => Package_Name & "Index_Subtype_Definitions"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Index_Subtype_Definitions", Ex => Ex, Arg_Element => Type_Definition); end Index_Subtype_Definitions; ----------------------------------------------------------------------------- function Discrete_Subtype_Definitions (Type_Definition : Asis.Type_Definition) return Asis.Definition_List is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Type_Definition); Arg_Node : Node_Id; begin Check_Validity (Type_Definition, Package_Name & "Discrete_Subtype_Definitions"); if not (Arg_Kind = A_Constrained_Array_Definition or else Arg_Kind = A_Formal_Constrained_Array_Definition) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Discrete_Subtype_Definitions", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Type_Definition); return N_To_E_List_New ( List => Discrete_Subtype_Definitions (Arg_Node), Starting_Element => Type_Definition); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Type_Definition, Outer_Call => Package_Name & "Discrete_Subtype_Definitions"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Discrete_Subtype_Definitions", Ex => Ex, Arg_Element => Type_Definition); end Discrete_Subtype_Definitions; -------------------------------- -- Array_Component_Definition -- -------------------------------- function Array_Component_Definition (Type_Definition : Asis.Type_Definition) return Asis.Component_Definition is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Type_Definition); Arg_Node : Node_Id; begin Check_Validity (Type_Definition, Package_Name & "Array_Component_Definition"); if not (Arg_Kind = An_Unconstrained_Array_Definition or else Arg_Kind = A_Constrained_Array_Definition or else Arg_Kind = A_Formal_Unconstrained_Array_Definition or else Arg_Kind = A_Formal_Constrained_Array_Definition) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Array_Component_Definition", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Type_Definition); return Node_To_Element_New (Node => Sinfo.Component_Definition (Arg_Node), Starting_Element => Type_Definition, Internal_Kind => A_Component_Definition); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Type_Definition, Outer_Call => Package_Name & "Array_Component_Definition"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Array_Component_Definition", Ex => Ex, Arg_Element => Type_Definition); end Array_Component_Definition; ----------------------------------------------------------------------------- function Access_To_Object_Definition (Type_Definition : Asis.Type_Definition) return Asis.Subtype_Indication is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Type_Definition); Arg_Node : Node_Id; begin Check_Validity (Type_Definition, Package_Name & "Access_To_Object_Definition"); if not (Arg_Kind = A_Pool_Specific_Access_To_Variable or else Arg_Kind = An_Access_To_Variable or else Arg_Kind = An_Access_To_Constant or else Arg_Kind = A_Formal_Pool_Specific_Access_To_Variable or else Arg_Kind = A_Formal_Access_To_Variable or else Arg_Kind = A_Formal_Access_To_Constant) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Access_To_Object_Definition", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Type_Definition); return Node_To_Element_New (Node => Sinfo.Subtype_Indication (Arg_Node), Starting_Element => Type_Definition, Internal_Kind => A_Subtype_Indication); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Type_Definition, Outer_Call => Package_Name & "Access_To_Object_Definition"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Access_To_Object_Definition", Ex => Ex, Arg_Element => Type_Definition); end Access_To_Object_Definition; ----------------------------------------------------------------------------- function Access_To_Subprogram_Parameter_Profile (Type_Definition : Asis.Type_Definition) return Asis.Parameter_Specification_List is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Type_Definition); Arg_Node : Node_Id; Result_List : List_Id; begin Check_Validity (Type_Definition, Package_Name & "Access_To_Subprogram_Parameter_Profile"); if not (Arg_Kind = An_Access_To_Procedure or else Arg_Kind = An_Access_To_Protected_Procedure or else Arg_Kind = An_Access_To_Function or else Arg_Kind = An_Access_To_Protected_Function or else Arg_Kind = A_Formal_Access_To_Procedure or else Arg_Kind = A_Formal_Access_To_Protected_Procedure or else Arg_Kind = A_Formal_Access_To_Function or else Arg_Kind = A_Formal_Access_To_Protected_Function or else -- --|A2005 start Arg_Kind = An_Anonymous_Access_To_Procedure or else Arg_Kind = An_Anonymous_Access_To_Protected_Procedure or else Arg_Kind = An_Anonymous_Access_To_Function or else Arg_Kind = An_Anonymous_Access_To_Protected_Function) -- --|A2005 end then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Access_To_Subprogram_Parameter_Profile", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Type_Definition); -- --|A2005 start if Nkind (Arg_Node) = N_Access_Definition then Arg_Node := Sinfo.Access_To_Subprogram_Definition (Arg_Node); end if; -- --|A2005 end Result_List := Parameter_Specifications (Arg_Node); if No (Result_List) then return Nil_Element_List; else return N_To_E_List_New (List => Result_List, Starting_Element => Type_Definition, Internal_Kind => A_Parameter_Specification); end if; exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Type_Definition, Outer_Call => Package_Name & "Access_To_Subprogram_Parameter_Profile"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Access_To_Subprogram_Parameter_Profile", Ex => Ex, Arg_Element => Type_Definition); end Access_To_Subprogram_Parameter_Profile; ----------------------------------------------------------------------------- function Access_To_Function_Result_Profile (Type_Definition : Asis.Type_Definition) return Asis.Expression is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Type_Definition); Arg_Node : Node_Id; begin Check_Validity (Type_Definition, Package_Name & "Access_To_Function_Result_Profile"); if not (Arg_Kind = An_Access_To_Function or else Arg_Kind = An_Access_To_Protected_Function or else Arg_Kind = A_Formal_Access_To_Function or else Arg_Kind = A_Formal_Access_To_Protected_Function or else -- --|A2005 start Arg_Kind = An_Anonymous_Access_To_Function or else Arg_Kind = An_Anonymous_Access_To_Protected_Function) -- --|A2005 end then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Access_To_Function_Result_Profile", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Type_Definition); -- --|A2005 start if Nkind (Arg_Node) = N_Access_Definition then Arg_Node := Sinfo.Access_To_Subprogram_Definition (Arg_Node); end if; -- --|A2005 end return Node_To_Element_New (Node => Sinfo.Result_Definition (Arg_Node), Starting_Element => Type_Definition); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Type_Definition, Outer_Call => Package_Name & "Access_To_Function_Result_Profile"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Access_To_Function_Result_Profile", Ex => Ex, Arg_Element => Type_Definition); end Access_To_Function_Result_Profile; ----------------------------------------------------------------------------- function Subtype_Mark (Definition : Asis.Definition) return Asis.Expression is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Definition); Arg_Node : Node_Id; Result_Node : Node_Id; Result_Kind : Internal_Element_Kinds := Not_An_Element; begin Check_Validity (Definition, Package_Name & "Subtype_Mark"); if not (Arg_Kind = A_Subtype_Indication or else Arg_Kind = A_Discrete_Subtype_Indication or else Arg_Kind = A_Formal_Derived_Type_Definition or else Arg_Kind = A_Discrete_Subtype_Indication_As_Subtype_Definition) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Subtype_Mark", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Definition); if Nkind (Arg_Node) = N_Subtype_Indication or else Nkind (Arg_Node) = N_Formal_Derived_Type_Definition then Result_Node := Sinfo.Subtype_Mark (Arg_Node); else Result_Node := R_Node (Definition); end if; if Nkind (Original_Node (Result_Node)) = N_Identifier and then not Is_Rewrite_Substitution (Result_Node) then if Is_Part_Of_Instance (Definition) then if Represents_Class_Wide_Type_In_Instance (Result_Node) then Result_Kind := A_Class_Attribute; elsif Represents_Base_Type_In_Instance (Result_Node) then Result_Kind := A_Base_Attribute; else Result_Kind := An_Identifier; end if; else Result_Kind := An_Identifier; end if; elsif Nkind (Original_Node (Result_Node)) = N_Expanded_Name then Result_Kind := A_Selected_Component; end if; return Node_To_Element_New (Node => Result_Node, Starting_Element => Definition, Internal_Kind => Result_Kind); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Definition, Outer_Call => Package_Name & "Subtype_Mark"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Subtype_Mark", Ex => Ex, Arg_Element => Definition); end Subtype_Mark; ----------------------------------------------------------------------------- function Subtype_Constraint (Definition : Asis.Definition) return Asis.Constraint is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Definition); Arg_Node : Node_Id; Result_Node : Node_Id := Empty; Result_Kind : Internal_Element_Kinds := Not_An_Element; begin Check_Validity (Definition, Package_Name & "Subtype_Constraint"); if not (Arg_Kind = A_Subtype_Indication or else Arg_Kind = A_Discrete_Subtype_Indication or else Arg_Kind = A_Discrete_Subtype_Indication_As_Subtype_Definition) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Subtype_Constraint", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Definition); if Nkind (Arg_Node) = N_Subtype_Indication then Result_Node := Sinfo.Constraint (Arg_Node); elsif Sloc (Arg_Node) <= Standard_Location and then Nkind (Parent (Arg_Node)) = N_Subtype_Declaration then -- This is either Standard.Positive or Standard.Natural, -- they have the constraint information not in -- N_Subtype_Declaration node, but in N_Defining_Identifier node Result_Node := Scalar_Range (Defining_Identifier (Parent (Arg_Node))); Result_Kind := A_Simple_Expression_Range; end if; return Node_To_Element_New (Node => Result_Node, Starting_Element => Definition, Internal_Kind => Result_Kind); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Definition, Outer_Call => Package_Name & "Subtype_Constraint"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Subtype_Constraint", Ex => Ex, Arg_Element => Definition); end Subtype_Constraint; ----------------------------------------------------------------------------- function Lower_Bound (Constraint : Asis.Range_Constraint) return Asis.Expression is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Constraint); Arg_Node : Node_Id; Result_Node : Node_Id; begin Check_Validity (Constraint, Package_Name & "Lower_Bound"); if not (Arg_Kind = A_Simple_Expression_Range or else Arg_Kind = A_Discrete_Simple_Expression_Range or else Arg_Kind = A_Discrete_Simple_Expression_Range_As_Subtype_Definition) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Lower_Bound", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Constraint); if Nkind (Arg_Node) = N_Range_Constraint then Result_Node := Low_Bound (Range_Expression (Arg_Node)); elsif Nkind (Arg_Node) = N_Component_Clause then Result_Node := First_Bit (Arg_Node); else -- Nkind (Arg_Node) = N_Range or else -- Nkind (Arg_Node) = N_Real_Range_Specification Result_Node := Low_Bound (Arg_Node); end if; return Node_To_Element_New (Node => Result_Node, Starting_Element => Constraint); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Constraint, Outer_Call => Package_Name & "Lower_Bound"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Lower_Bound", Ex => Ex, Arg_Element => Constraint); end Lower_Bound; ----------------------------------------------------------------------------- function Upper_Bound (Constraint : Asis.Range_Constraint) return Asis.Expression is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Constraint); Arg_Node : Node_Id; Result_Node : Node_Id; begin Check_Validity (Constraint, Package_Name & "Upper_Bound"); if not (Arg_Kind = A_Simple_Expression_Range or else Arg_Kind = A_Discrete_Simple_Expression_Range or else Arg_Kind = A_Discrete_Simple_Expression_Range_As_Subtype_Definition) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Upper_Bound", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Constraint); if Nkind (Arg_Node) = N_Range_Constraint then Result_Node := High_Bound (Range_Expression (Arg_Node)); elsif Nkind (Arg_Node) = N_Component_Clause then Result_Node := Last_Bit (Arg_Node); else Result_Node := High_Bound (Arg_Node); end if; return Node_To_Element_New (Node => Result_Node, Starting_Element => Constraint); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Constraint, Outer_Call => Package_Name & "Upper_Bound"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Upper_Bound", Ex => Ex, Arg_Element => Constraint); end Upper_Bound; ----------------------------------------------------------------------------- function Range_Attribute (Constraint : Asis.Range_Constraint) return Asis.Expression is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Constraint); Arg_Node : constant Node_Id := Node (Constraint); Result_Node : Node_Id; begin Check_Validity (Constraint, Package_Name & "Range_Attribute"); if not (Arg_Kind = A_Range_Attribute_Reference or else Arg_Kind = A_Discrete_Range_Attribute_Reference or else Arg_Kind = A_Discrete_Range_Attribute_Reference_As_Subtype_Definition) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Range_Attribute", Wrong_Kind => Arg_Kind); end if; if Nkind (Arg_Node) = N_Range_Constraint then -- one step down to N_Attruibute_Reference node Result_Node := Range_Expression (Arg_Node); else Result_Node := R_Node (Constraint); end if; return Node_To_Element_New (Starting_Element => Constraint, Node => Result_Node, Internal_Kind => A_Range_Attribute); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Constraint, Outer_Call => Package_Name & "Range_Attribute"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Range_Attribute", Ex => Ex, Arg_Element => Constraint); end Range_Attribute; ------------------------------------------------------------------------- function Discrete_Ranges (Constraint : Asis.Constraint) return Asis.Discrete_Range_List is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Constraint); Arg_Node : Node_Id; begin Check_Validity (Constraint, Package_Name & "Discrete_Ranges"); if not (Arg_Kind = An_Index_Constraint) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Discrete_Ranges", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Constraint); return N_To_E_List_New (List => Constraints (Arg_Node), Starting_Element => Constraint); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Constraint, Outer_Call => Package_Name & "Discrete_Ranges"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Discrete_Ranges", Ex => Ex, Arg_Element => Constraint); end Discrete_Ranges; ------------------------------------------------------------------------------ -- ??? PARTIALLY IMPLEMENTED, CANNOT PROCESS THE CASE WHEN -- ??? NORMALIZED = TRUE function Discriminant_Associations (Constraint : Asis.Constraint; Normalized : Boolean := False) return Asis.Discriminant_Association_List is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Constraint); Arg_Node : Node_Id; begin Check_Validity (Constraint, Package_Name & "Discriminant_Associations"); if not (Arg_Kind = A_Discriminant_Constraint) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Discriminant_Associations", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Constraint); if Normalized then return Normalized_Discriminant_Associations ( Constr_Elem => Constraint, Constr_Node => Arg_Node); else return N_To_E_List_New (List => Constraints (Arg_Node), Internal_Kind => A_Discriminant_Association, Starting_Element => Constraint); end if; exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Constraint, Bool_Par => Normalized, Outer_Call => Package_Name & "Discriminant_Associations"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Discriminant_Associations", Ex => Ex, Arg_Element => Constraint, Bool_Par_ON => Normalized); end Discriminant_Associations; ----------------------------------------------------------------------------- function Component_Subtype_Indication (Component_Definition : Asis.Definition) return Asis.Definition is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Component_Definition); Arg_Node : Node_Id; begin Check_Validity (Component_Definition, Package_Name & "Component_Subtype_Indication"); if not (Arg_Kind = A_Component_Definition) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Component_Subtype_Indication", Wrong_Kind => Arg_Kind); end if; Arg_Node := Sinfo.Subtype_Indication (R_Node (Component_Definition)); return Node_To_Element_New (Node => Arg_Node, Starting_Element => Component_Definition, Internal_Kind => A_Subtype_Indication); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Component_Definition, Outer_Call => Package_Name & "Component_Subtype_Indication"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Component_Subtype_Indication", Ex => Ex, Arg_Element => Component_Definition); end Component_Subtype_Indication; ----------------------------------------------------------------------------- function Discriminants (Definition : Asis.Definition) return Asis.Discriminant_Specification_List is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Definition); Arg_Node : Node_Id; begin Check_Validity (Definition, Package_Name & "Discriminations"); if not (Arg_Kind = A_Known_Discriminant_Part) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Discriminations", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Definition); return N_To_E_List_New (List => Discriminant_Specifications (Arg_Node), Starting_Element => Definition, Internal_Kind => A_Discriminant_Specification); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Definition, Outer_Call => Package_Name & "Discriminations"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Discriminations", Ex => Ex, Arg_Element => Definition); end Discriminants; ----------------------------------------------------------------------------- function Record_Components (Definition : Asis.Record_Definition; Include_Pragmas : Boolean := False) return Asis.Record_Component_List is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Definition); Arg_Node : Node_Id; Component_List_Node : Node_Id; Result_List : List_Id; -- All nodes except the Variant Node Variant_Part_Node : Node_Id; begin Check_Validity (Definition, Package_Name & "Record_Components"); if not (Arg_Kind = A_Record_Definition or else Arg_Kind = A_Variant) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Record_Components", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Definition); Component_List_Node := Component_List (Arg_Node); -- first, we should check the null record case: if Null_Present (Component_List_Node) then return Element_List'(1 => Node_To_Element_New (Node => Arg_Node, Starting_Element => Definition, Internal_Kind => A_Null_Component)); end if; Result_List := Component_Items (Component_List_Node); Variant_Part_Node := Variant_Part (Component_List_Node); if No (Variant_Part_Node) then return N_To_E_List_New (List => Result_List, Include_Pragmas => Include_Pragmas, Starting_Element => Definition); else return ( N_To_E_List_New (List => Result_List, Include_Pragmas => Include_Pragmas, Starting_Element => Definition) & Element_List'(1 => Node_To_Element_New (Node => Variant_Part_Node, Starting_Element => Definition, Internal_Kind => A_Variant_Part)) ); end if; exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Definition, Bool_Par => Include_Pragmas, Outer_Call => Package_Name & "Record_Components"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Record_Components", Ex => Ex, Arg_Element => Definition, Bool_Par_ON => Include_Pragmas); end Record_Components; ------------------------------------------------------------------------------ -- NOT IMPLEMENTED function Implicit_Components (Definition : Asis.Record_Definition) return Asis.Record_Component_List is begin Check_Validity (Definition, Package_Name & "Implicit_Components"); Not_Implemented_Yet (Diagnosis => Package_Name & "Implicit_Components"); -- ASIS_Failed is raised, Not_Implemented_Error status is set return Nil_Element_List; -- to make the code syntactically correct exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Definition, Outer_Call => Package_Name & "Implicit_Components"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Implicit_Components", Ex => Ex, Arg_Element => Definition); end Implicit_Components; ----------------------------------------------------------------------------- function Discriminant_Direct_Name (Variant_Part : Asis.Record_Component) return Asis.Name is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Variant_Part); Arg_Node : Node_Id; begin Check_Validity (Variant_Part, Package_Name & "Discriminant_Direct_Name"); if not (Arg_Kind = A_Variant_Part) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Discriminant_Direct_Name", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Variant_Part); return Node_To_Element_New (Node => Sinfo.Name (Arg_Node), Starting_Element => Variant_Part, Internal_Kind => An_Identifier); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Variant_Part, Outer_Call => Package_Name & "Discriminant_Direct_Name"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Discriminant_Direct_Name", Ex => Ex, Arg_Element => Variant_Part); end Discriminant_Direct_Name; ----------------------------------------------------------------------------- function Variants (Variant_Part : Asis.Record_Component; Include_Pragmas : Boolean := False) return Asis.Variant_List is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Variant_Part); Arg_Node : Node_Id; begin Check_Validity (Variant_Part, Package_Name & "Variants"); if not (Arg_Kind = A_Variant_Part) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Variants", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Variant_Part); return N_To_E_List_New (List => Variants (Arg_Node), Include_Pragmas => Include_Pragmas, Starting_Element => Variant_Part); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Variant_Part, Bool_Par => Include_Pragmas, Outer_Call => Package_Name & "Variants"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Variants", Ex => Ex, Arg_Element => Variant_Part, Bool_Par_ON => Include_Pragmas); end Variants; ----------------------------------------------------------------------------- function Variant_Choices (Variant : Asis.Variant) return Asis.Element_List is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Variant); Arg_Node : Node_Id; begin Check_Validity (Variant, Package_Name & "Variant_Choices"); if not (Arg_Kind = A_Variant) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Variant_Choices", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Variant); return Discrete_Choice_Node_To_Element_List (Choice_List => Discrete_Choices (Arg_Node), Starting_Element => Variant); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Variant, Outer_Call => Package_Name & "Variant_Choices"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Variant_Choices", Ex => Ex, Arg_Element => Variant); end Variant_Choices; ------------------------------------------------------------------------------ -- OPEN PROBLEMS: -- -- 1. Is using of the special list construction function -- Discrete_Choice_Node_To_Element_List really necessary here? We should -- try to replace it by non-special (trivial) constructor (all -- necessary local mapping items for Nodes in the Node List have -- already been defined - ???). -- -- IT SEEMS TO BE NOT ONLY OK, BUT REALLY NECESSARY HERE (03.11.95) ------------------------------------------------------------------------------ function Ancestor_Subtype_Indication (Definition : Asis.Definition) return Asis.Definition is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Definition); Arg_Node : Node_Id; begin Check_Validity (Definition, Package_Name & "Ancestor_Subtype_Indication"); if not (Arg_Kind = A_Private_Extension_Definition) then Raise_ASIS_Inappropriate_Element (Diagnosis => Package_Name & "Ancestor_Subtype_Indication", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Definition); return Node_To_Element_New (Node => Sinfo.Subtype_Indication (Arg_Node), Starting_Element => Definition, Internal_Kind => A_Subtype_Indication); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Definition, Outer_Call => Package_Name & "Ancestor_Subtype_Indication"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Ancestor_Subtype_Indication", Ex => Ex, Arg_Element => Definition); end Ancestor_Subtype_Indication; ----------------------------------------------------------------------------- function Visible_Part_Items (Definition : Asis.Definition; Include_Pragmas : Boolean := False) return Asis.Definition_List is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Definition); Arg_Node : Node_Id; begin Check_Validity (Definition, Package_Name & "Visible_Part_Items"); if not (Arg_Kind = A_Task_Definition or else Arg_Kind = A_Protected_Definition) then Raise_ASIS_Inappropriate_Element (Package_Name & "Visible_Part_Items", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Definition); return N_To_E_List_New (List => Visible_Declarations (Arg_Node), Include_Pragmas => Include_Pragmas, Starting_Element => Definition); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Definition, Bool_Par => Include_Pragmas, Outer_Call => Package_Name & "Visible_Part_Items"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Visible_Part_Items", Ex => Ex, Arg_Element => Definition, Bool_Par_ON => Include_Pragmas); end Visible_Part_Items; ----------------------------------------------------------------------------- function Private_Part_Items (Definition : Asis.Definition; Include_Pragmas : Boolean := False) return Asis.Definition_List is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Definition); Arg_Node : Node_Id; begin Check_Validity (Definition, Package_Name & "Private_Part_Items"); if not (Arg_Kind = A_Task_Definition or else Arg_Kind = A_Protected_Definition) then Raise_ASIS_Inappropriate_Element (Package_Name & "Private_Part_Items", Wrong_Kind => Arg_Kind); end if; Arg_Node := Node (Definition); return N_To_E_List_New (List => Private_Declarations (Arg_Node), Include_Pragmas => Include_Pragmas, Starting_Element => Definition); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Definition, Bool_Par => Include_Pragmas, Outer_Call => Package_Name & "Private_Part_Items"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Private_Part_Items", Ex => Ex, Arg_Element => Definition, Bool_Par_ON => Include_Pragmas); end Private_Part_Items; ----------------------------------------------------------------------------- function Is_Private_Present (Definition : Asis.Definition) return Boolean is Arg_Kind : constant Internal_Element_Kinds := Int_Kind (Definition); Arg_Node : Node_Id; begin Check_Validity (Definition, Package_Name & "Is_Private_Present"); if not (Arg_Kind = A_Task_Definition or else Arg_Kind = A_Protected_Definition) then -- unexpected element return False; end if; Arg_Node := Node (Definition); return Present (Private_Declarations (Arg_Node)); exception when ASIS_Inappropriate_Element => raise; when ASIS_Failed => if Status_Indicator = Unhandled_Exception_Error then Add_Call_Information (Argument => Definition, Outer_Call => Package_Name & "Is_Private_Present"); end if; raise; when Ex : others => Report_ASIS_Bug (Query_Name => Package_Name & "Is_Private_Present", Ex => Ex, Arg_Element => Definition); end Is_Private_Present; ----------------------------------------------------------------------------- end Asis.Definitions;
29,680
ada
0
fintatarta/fakedsp
Ada/src/fakelib/utilities-task_reaper.ads
-- -- A characteristic of Ada task is that if an exception happens they -- silently die. This can make debugging difficult. The procedure -- Install_Reaper installs a handler that print some useful information -- to standard error when a task dies. -- package Utilities.Task_Reaper is type Verbosity_Level is (Exception_Only, Abort_Or_Exception, Always); procedure Install_Reaper (Level : Verbosity_Level := Exception_Only); -- Install a reaper. If Level is Exception_Only, a message is printed -- only if a task die because of an exception; if Level is -- Abort_Or_Exception a message is printed if the task call is aborted -- or die by an exception; if Level is Always the message is printed -- also for normal termination. end Utilities.Task_Reaper;
29,681
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/wide_boolean_pkg.ads
<filename>gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/wide_boolean_pkg.ads package Wide_Boolean_Pkg is type TBOOL is new BOOLEAN; for TBOOL use (FALSE => 0, TRUE => 1); for TBOOL'SIZE use 8; type TUINT32 is mod (2 ** 32); for TUINT32'SIZE use 32; type TREC is record H : TUINT32; B : TBOOL; end record; for TREC use record H at 0 range 0..31; B at 4 range 0..31; end record; procedure Modify (LH : in out TUINT32; LB : in out TBOOL); pragma export(C, Modify, "Modify"); end Wide_Boolean_Pkg;
29,682
ada
10
sveljko/goertzel
ada/src/goertzel.adb
<gh_stars>1-10 with Ada.Numerics.Generic_Elementary_Functions; package body goertzel with SPARK_Mode => On is package Ef is new Ada.Numerics.Generic_Elementary_Functions(Value); use Ef; function Calc_Koef(F, Fs: Value) return Value is (2.0 * Cos(2.0 * Ada.Numerics.Pi * F / Fs)) with Pre => (Fs < 100_000.0) and (F < Fs / 2.0) and (Fs > 0.0); procedure Reset(Vn: out Vn2) is begin Vn.m1 := 0.0; Vn.m2 := 0.0; end; function Make(F, Fs: Value) return Filter is ( F, Fs, Calc_Koef(F, Fs), (0.0, 0.0) ); procedure Reset(Flt: in out Filter) is begin Reset(Flt.Vn); end; procedure Kernel(Sample: Samples; K: Value; Vn: in out Vn2) is T: Value; begin for I in Sample'Range loop T := K * Vn.m1 - Vn.m2 + Sample(I); Vn.m2 := Vn.m1; Vn.m1 := T; end loop; end; function Power(Koef: Value; Vn: Vn2; N: Sample_Count) return Value is Rslt: Value; begin Rslt := Vn.m1 * Vn.m1 + Vn.m2* Vn.m2 - Koef * Vn.m1 * Vn.m2; if Rslt < Value'Model_Epsilon then Rslt := Value'Model_Epsilon; end if; return Rslt / Value(N*N); end Power; function DBm(Power: Value) return Value is (10.0 * Log(2.0 * Power * 1000.0 / 600.0, 10.0)); procedure Process(Flt: in out Filter; Sample: Samples; Rslt: out Value) is begin Kernel(Sample, Flt.Koef, Flt.Vn); Rslt := Power(Flt.Koef, Flt.Vn, Sample'Length); end Process; end goertzel;
29,683
ada
5
jhumphry/SPARK_SipHash
src/tests/siphash24_c.ads
<filename>src/tests/siphash24_c.ads -- SipHash24_C -- an Ada specification for the reference C implementation of SipHash and -- Half Siphash -- Copyright (c) 2015-2016, <NAME> - see LICENSE file for details with Ada.Unchecked_Conversion; with Interfaces, Interfaces.C, Interfaces.C.Strings; use Interfaces; package SipHash24_c is subtype U8 is Interfaces.Unsigned_8; type U8_Access is access all U8; subtype U32 is Interfaces.Unsigned_32; subtype U64 is Interfaces.Unsigned_64; type U8_Array is array (Natural range <>) of aliased U8; subtype U8_Array4 is U8_Array(0..3); subtype U8_Array8 is U8_Array(0..7); function chars_ptr_to_U8_Access is new Ada.Unchecked_Conversion(Source => Interfaces.C.Strings.chars_ptr, Target => U8_Access); function C_SipHash24 ( c_in : access Interfaces.Unsigned_8; inlen : Interfaces.C.size_t; k : access Interfaces.Unsigned_8; c_out : access Interfaces.Unsigned_8; outlen : Interfaces.C.size_t ) return C.int; pragma Import (C, C_SipHash24, "siphash"); function C_HalfSipHash24 ( c_in : access Interfaces.Unsigned_8; inlen : Interfaces.C.size_t; k : access Interfaces.Unsigned_8; c_out : access Interfaces.Unsigned_8; outlen : Interfaces.C.size_t ) return C.int; pragma Import (C, C_HalfSipHash24, "halfsiphash"); function U8_Array4_to_U32 (c : U8_Array4) return U32 is (U32(c(0)) or Shift_Left(U32(c(1)), 8) or Shift_Left(U32(c(2)), 16) or Shift_Left(U32(c(3)), 24)); function U8_Array8_to_U64 (c : U8_Array8) return U64 is (U64(c(0)) or Shift_Left(U64(c(1)), 8) or Shift_Left(U64(c(2)), 16) or Shift_Left(U64(c(3)), 24) or Shift_Left(U64(c(4)), 32) or Shift_Left(U64(c(5)), 40) or Shift_Left(U64(c(6)), 48) or Shift_Left(U64(c(7)), 56)); end SipHash24_c;
29,684
ada
0
Tim-Tom/scratch
single-substitution-cipher/ada/src/Word_List.adb
<reponame>Tim-Tom/scratch with Ada.Text_IO; package body Word_List is package IO renames Ada.Text_IO; use Word_Lists; use Pattern_Sets; function "<"(a, b: pattern) return Boolean is begin return String(a) < String(b); end "<"; function "="(a, b: pattern) return Boolean is begin return String(a) = String(b); end "="; function Make_Pattern(w : Word) return Pattern is p : Pattern := (others => ' '); seen : Array(1 .. 26) of Character; seen_max : Natural := 0; function Map_Letter(c : Character) return Character is begin for i in 1 .. seen_max loop if seen(i) = c then return Character'Val(Character'Pos('a') + i); end if; end loop; seen_max := seen_max + 1; seen(seen_max) := c; return Character'Val(Character'Pos('a') + seen_max); end Map_Letter; begin for i in w'Range loop exit when w(i) = ' '; p(i) := Map_Letter(w(i)); end loop; return p; end Make_Pattern; function Build_Word_List(filename : String; patterns : Pattern_Set) return Word_List is list : Word_List; input : IO.File_Type; w : Word; p : Pattern; last : Natural; c : Word_Lists.Cursor; inserted : Boolean; begin IO.Open(input, IO.In_File, filename); while not IO.End_Of_File(input) loop IO.Get_Line(input, w, last); if last = Word'Last then IO.Put_Line(w); raise Constraint_Error; end if; w(last + 1 .. Word'Last) := (others => ' '); p := Make_Pattern(w); if Pattern_Sets.Find(patterns, p) /= Pattern_Sets.No_Element then c := Word_Lists.Find(list, p); if c = Word_Lists.No_Element then Word_Lists.Insert(list, p, new Word_Vectors.Vector, c, inserted); end if; Word_Vectors.Append(Word_Lists.Element(c).all, w); end if; end loop; return list; end Build_Word_List; end Word_List;
29,685
ada
20
charlie5/lace
3-mid/impact/source/2d/impact-d2-types.ads
<filename>3-mid/impact/source/2d/impact-d2-types.ads with impact.d2.Math; package Impact.d2.Types -- -- Internal types. -- is use impact.d2.Math; -- This is an internal structure. -- type b2Position is record c : b2Vec2; a : float32; end record; -- This is an internal structure. -- type b2Velocity is record v : b2Vec2; w : float32; end record; type Position_view is access all b2Position; type Velocity_view is access all b2Velocity; type Position_views is array (int32 range <>) of Position_view; type Velocity_views is array (int32 range <>) of Velocity_view; type access_Position_views is access all Position_views; type access_Velocity_views is access all Velocity_views; end Impact.d2.Types;
29,686
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/ada/acats/tests/c5/c52104k.ada
-- C52104K.ADA -- Grant of Unlimited Rights -- -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687, -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained -- unlimited rights in the software and documentation contained herein. -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making -- this public release, the Government intends to confer upon all -- recipients unlimited rights equal to those held by the Government. -- These rights include rights to use, duplicate, release or disclose the -- released technical data and computer software in whole or in part, in -- any manner and for any purpose whatsoever, and to have or permit others -- to do so. -- -- DISCLAIMER -- -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A -- PARTICULAR PURPOSE OF SAID MATERIAL. --* -- CHECK THAT LENGTHS MUST MATCH IN ARRAY AND SLICE ASSIGNMENTS. -- MORE SPECIFICALLY, TEST THAT ATTEMPTED ASSIGNMENTS BETWEEN -- ARRAYS WITH NON-MATCHING LENGTHS LEAVE THE DESTINATION ARRAY -- INTACT AND CAUSE CONSTRAINT_ERROR TO BE RAISED. -- (OVERLAPS BETWEEN THE OPERANDS OF THE ASSIGNMENT STATEMENT -- ARE TREATED ELSEWHERE.) -- DIVISION C : NON-NULL LENGTHS NOT DETERMINABLE STATICALLY. -- RM 07/20/81 -- SPS 3/22/83 WITH REPORT; PROCEDURE C52104K IS USE REPORT ; BEGIN TEST( "C52104K" , "CHECK THAT IN ARRAY ASSIGNMENTS AND IN SLICE" & " ASSIGNMENTS THE LENGTHS MUST MATCH" ); -- IN THIS TEST WE CAN'T USE AGGREGATE ASSIGNMENT (EXCEPT WHEN -- THE AGGREGATES ARE STRING LITERALS); THEREFORE: -- -- (1) ARRAYS WILL BE INITIALIZED BY INDIVIDUAL ASSIGNMENTS; -- (2) CAN'T USE NON-NULL CONSTANT ARRAYS. -- WE ASSUME THAT IN AN ARRAY_TYPE_DEFINITION THE INDEX PORTION -- AND THE COMPONENT_TYPE PORTION ARE FUNCTIONALLY ORTHOGONAL -- ALSO AT THE IMPLEMENTATION LEVEL, I.E. THAT THE CORRECTNESS -- OF THE ACCESSING MECHANISM FOR ARRAYS DOES NOT DEPEND ON -- COMPONENT_TYPE. ACCORDINGLY WE ARE TESTING FOR SOME BUT -- NOT ALL KINDS OF COMPONENT_TYPE. (COMPONENT_TYPES INCLUDED: -- INTEGER , CHARACTER , BOOLEAN .) -- CASES DISTINGUISHED: ( 8 SELECTED CASES ARE IMPLEMENTED) -- -- ( THE 8 SELECTIONS ARE THE 5-CASE -- SERIES 10-11-12-13-14 FOLLOWED -- BY 7 , 8 , 9 (IN THIS ORDER). ) -- -- -- ( EACH DIVISION COMPRISES 3 FILES, -- COVERING RESPECTIVELY THE FIRST -- 3 , NEXT 2 , AND LAST 3 OF THE 8 -- SELECTIONS FOR THE DIVISION.) -- -- -- (1..6) (DO NOT APPLY TO NON-MATCHING OBJECTS, SINCE WE WANT -- THE OBJECTS TO HAVE THE S A M E BASE TYPE.) -- -- -- (7) UNSLICED OBJECTS OF THE PREDEFINED TYPE 'STRING' (BY -- THEMSELVES). -- -- -- (8) SLICED OBJECTS OF THE PREDEFINED TYPE 'STRING' , WITH -- STRING LITERALS. -- -- -- (9) SLICED OBJECTS OF THE PREDEFINED TYPE 'STRING' (BY -- THEMSELVES). -- -- -- (-) CONSTRAINABLE TYPES: ONLY SUBTESTS 2, 3, 4, 5, 6 -- WILL BE REPLICATED -- AS SUBTESTS 10, 11, 12, 13, 14 . -- -- -- (10) MULTIDIMENSIONAL ARRAY OBJECTS WHOSE TYPEMARKS WERE -- DEFINED USING THE "BOX" COMPOUND SYMBOL. -- (TWO-DIMENSIONAL ARRAYS OF INTEGERS.) -- -- -- (11) UNSLICED ONE-DIMENSIONAL ARRAY OBJECTS WHOSE TYPEMARKS -- WERE DEFINED USING THE "BOX" SYMBOL -- AND FOR WHICH THE COMPONENT TYPE IS NOT 'CHARACTER' . -- ((ONE-DIMENSIONAL) ARRAYS OF INTEGERS.) -- -- -- (12) SLICED ONE-DIMENSIONAL ARRAY OBJECTS WHOSE TYPEMARKS -- WERE DEFINED USING THE "BOX" SYMBOL -- AND FOR WHICH THE COMPONENT TYPE IS NOT 'CHARACTER' . -- ((ONE-DIMENSIONAL) ARRAYS OF BOOLEANS.) -- -- -- (13) UNSLICED ONE-DIMENSIONAL ARRAY OBJECTS WHOSE TYPEMARKS -- WERE DEFINED USING THE "BOX" SYMBOL -- AND FOR WHICH THE COMPONENT TYPE IS 'CHARACTER' . -- -- (STRING LITERALS ARE THE ONLY AGGREGATES WE ARE USING -- IN THIS TEST. TO FORCE SLIDING, THE LOWER LIMIT IMPLIED -- BY THE TYPEMARK WILL NOT BE 1 .) -- -- -- (14) SLICED ONE-DIMENSIONAL ARRAY OBJECTS WHOSE TYPEMARKS -- WERE DEFINED USING THE "BOX" SYMBOL -- AND FOR WHICH THE COMPONENT TYPE IS 'CHARACTER' . -- -- -- -- (-) SPECIAL CASES: NULL ARRAYS....... TREATED IN DIVISION B. -- SUPERLONG ARRAYS.. (TREATED FOR DYNAMIC -- ARRAYS ONLY, -- DIVISIONS C AND D .) -- -- -- (-) THE STATIC-ARRAY COUNTERPARTS OF THESE TESTS ARE IN DI- -- VISIONS A (FOR NON-NULL ARRAYS) AND B (FOR NULL ARRAYS). -- -- ------------------------------------------------------------------- -- (1..6: NOT APPLICABLE) -- -- ------------------------------------------------------------------- -- (10) MULTIDIMENSIONAL ARRAY OBJECTS WHOSE TYPEMARKS WERE -- DEFINED USING THE "BOX" COMPOUND SYMBOL. -- (TWO-DIMENSIONAL ARRAYS OF INTEGERS.) DECLARE TYPE TABOX0 IS ARRAY( INTEGER RANGE <> , INTEGER RANGE <> ) OF INTEGER ; SUBTYPE TABOX01 IS TABOX0( IDENT_INT(1)..IDENT_INT(5) , IDENT_INT(0)..IDENT_INT(7) ); SUBTYPE TABOX02 IS TABOX0( IDENT_INT(0)..IDENT_INT(5) , IDENT_INT(2)..IDENT_INT(9) ); ARRX01 : TABOX01 ; ARRX02 : TABOX02 ; BEGIN -- INITIALIZATION OF RHS ARRAY: FOR I IN IDENT_INT(1)..IDENT_INT(5) LOOP FOR J IN IDENT_INT(0)..IDENT_INT(7) LOOP ARRX01( I , J ) := I * I * J ; END LOOP; END LOOP; -- INITIALIZATION OF LHS ARRAY: FOR I IN IDENT_INT(0)..IDENT_INT(5) LOOP FOR J IN IDENT_INT(2)..IDENT_INT(9) LOOP ARRX02( I , J ) := I * I * J * 3 ; END LOOP; END LOOP; -- ARRAY ASSIGNMENT: ARRX02 := ARRX01 ; FAILED( "EXCEPTION NOT RAISED - SUBTEST 10" ); EXCEPTION WHEN CONSTRAINT_ERROR => -- CHECKING THE VALUES AFTER THE ARRAY ASSIGNMENT: FOR I IN IDENT_INT(0)..IDENT_INT(5) LOOP FOR J IN IDENT_INT(2)..IDENT_INT(9) LOOP IF ARRX02( I , J ) /= I * I * J * 3 THEN FAILED( "ORIG. VALUE ALTERED (10)" ); END IF; END LOOP; END LOOP; WHEN OTHERS => FAILED( "WRONG EXCEPTION RAISED - SUBTEST 10" ); END ; ------------------------------------------------------------------- -- (11) UNSLICED ONE-DIMENSIONAL ARRAY OBJECTS WHOSE TYPEMARKS -- WERE DEFINED USING THE "BOX" SYMBOL -- AND FOR WHICH THE COMPONENT TYPE IS NOT 'CHARACTER' . -- ((ONE-DIMENSIONAL) ARRAYS OF INTEGERS.) DECLARE TYPE TABOX1 IS ARRAY( INTEGER RANGE <> ) OF INTEGER ; SUBTYPE TABOX11 IS TABOX1( IDENT_INT(1)..IDENT_INT(5) ) ; ARRX11 : TABOX11 ; ARRX12 : TABOX1( IDENT_INT(6)..IDENT_INT(9) ); BEGIN -- INITIALIZATION OF RHS ARRAY: FOR I IN IDENT_INT(1)..IDENT_INT(5) LOOP ARRX11( I ) := I * I ; END LOOP; -- INITIALIZATION OF LHS ARRAY: FOR I IN IDENT_INT(6)..IDENT_INT(9) LOOP ARRX12( I ) := I * I * 3 ; END LOOP; -- ARRAY ASSIGNMENT: ARRX12 := ARRX11 ; FAILED( "EXCEPTION NOT RAISED - SUBTEST 11" ); EXCEPTION WHEN CONSTRAINT_ERROR => -- CHECKING THE VALUES AFTER THE ARRAY ASSIGNMENT: FOR I IN IDENT_INT(6)..IDENT_INT(9) LOOP IF ARRX12( I ) /= I * I * 3 THEN FAILED( "ORIG. VALUE ALTERED (11)" ); END IF; END LOOP; WHEN OTHERS => FAILED( "WRONG EXCEPTION RAISED - SUBTEST 11" ); END ; ------------------------------------------------------------------- -- (12) SLICED ONE-DIMENSIONAL ARRAY OBJECTS WHOSE TYPEMARKS -- WERE DEFINED USING THE "BOX" SYMBOL -- AND FOR WHICH THE COMPONENT TYPE IS NOT 'CHARACTER' . -- ((ONE-DIMENSIONAL) ARRAYS OF BOOLEANS.) DECLARE TYPE TABOX5 IS ARRAY( INTEGER RANGE <> ) OF BOOLEAN ; SUBTYPE TABOX51 IS TABOX5( IDENT_INT(1)..IDENT_INT(5) ); ARRX51 : TABOX51 ; ARRX52 : TABOX5( IDENT_INT(5)..IDENT_INT(9) ); BEGIN -- INITIALIZATION OF LHS ARRAY: FOR I IN IDENT_INT(5)..IDENT_INT(9) LOOP ARRX52( I ) := FALSE ; END LOOP; -- INITIALIZATION OF RHS ARRAY: FOR I IN IDENT_INT(1)..IDENT_INT(5) LOOP ARRX51( I ) := TRUE ; END LOOP; -- SLICE ASSIGNMENT: ARRX52( IDENT_INT(6)..IDENT_INT(9) ) := ARRX51( IDENT_INT(3)..IDENT_INT(3) ) ; FAILED( "EXCEPTION NOT RAISED (12)" ); EXCEPTION WHEN CONSTRAINT_ERROR => -- CHECKING THE VALUES AFTER THE SLICE ASSIGNMENT: FOR I IN IDENT_INT(5)..IDENT_INT(9) LOOP IF ARRX52( I ) /= FALSE THEN FAILED( "LHS ARRAY ALTERED ( 12 ) " ); END IF; END LOOP; WHEN OTHERS => FAILED( "EXCEPTION RAISED - SUBTEST 12" ); END ; ------------------------------------------------------------------- RESULT ; END C52104K;
29,687
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/ada/prj-attr.adb
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- P R J . A T T R -- -- -- -- B o d y -- -- -- -- Copyright (C) 2001-2015, 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 Osint; with Prj.Com; use Prj.Com; with GNAT.Case_Util; use GNAT.Case_Util; package body Prj.Attr is use GNAT; -- Data for predefined attributes and packages -- Names are in lower case and end with '#' or 'D' -- Package names are preceded by 'P' -- Attribute names are preceded by two or three letters: -- The first letter is one of -- 'S' for Single -- 's' for Single with optional index -- 'L' for List -- 'l' for List of strings with optional indexes -- The second letter is one of -- 'V' for single variable -- 'A' for associative array -- 'a' for case insensitive associative array -- 'b' for associative array, case insensitive if file names are case -- insensitive -- 'c' same as 'b', with optional index -- The third optional letter is -- 'R' the attribute is read-only -- 'O' others is allowed as an index for an associative array -- If the character after the name in lower case letter is a 'D' (for -- default), then 'D' must be followed by an enumeration value of type -- Attribute_Default_Value, followed by a '#'. -- Example: -- "SVobject_dirDdot_value#" -- End is indicated by two consecutive '#'. Initialization_Data : constant String := -- project level attributes -- General "SVRname#" & "SVRproject_dir#" & "lVmain#" & "LVlanguages#" & "Lbroots#" & "SVexternally_built#" & -- Directories "SVobject_dirDdot_value#" & "SVexec_dirDobject_dir_value#" & "LVsource_dirsDdot_value#" & "Lainherit_source_path#" & "LVexcluded_source_dirs#" & "LVignore_source_sub_dirs#" & -- Source files "LVsource_files#" & "LVlocally_removed_files#" & "LVexcluded_source_files#" & "SVsource_list_file#" & "SVexcluded_source_list_file#" & "LVinterfaces#" & -- Projects (in aggregate projects) "LVproject_files#" & "LVproject_path#" & "SAexternal#" & -- Libraries "SVlibrary_dir#" & "SVlibrary_name#" & "SVlibrary_kind#" & "SVlibrary_version#" & "LVlibrary_interface#" & "SVlibrary_standalone#" & "LVlibrary_encapsulated_options#" & "SVlibrary_encapsulated_supported#" & "SVlibrary_auto_init#" & "LVleading_library_options#" & "LVlibrary_options#" & "Lalibrary_rpath_options#" & "SVlibrary_src_dir#" & "SVlibrary_ali_dir#" & "SVlibrary_gcc#" & "SVlibrary_symbol_file#" & "SVlibrary_symbol_policy#" & "SVlibrary_reference_symbol_file#" & -- Configuration - General "SVdefault_language#" & "LVrun_path_option#" & "SVrun_path_origin#" & "SVseparate_run_path_options#" & "Satoolchain_version#" & "Satoolchain_description#" & "Saobject_generated#" & "Saobjects_linked#" & "SVtargetDtarget_value#" & "SaruntimeDruntime_value#" & -- Configuration - Libraries "SVlibrary_builder#" & "SVlibrary_support#" & -- Configuration - Archives "LVarchive_builder#" & "LVarchive_builder_append_option#" & "LVarchive_indexer#" & "SVarchive_suffix#" & "LVlibrary_partial_linker#" & -- Configuration - Shared libraries "SVshared_library_prefix#" & "SVshared_library_suffix#" & "SVsymbolic_link_supported#" & "SVlibrary_major_minor_id_supported#" & "SVlibrary_auto_init_supported#" & "LVshared_library_minimum_switches#" & "LVlibrary_version_switches#" & "SVlibrary_install_name_option#" & "Saruntime_library_dir#" & "Saruntime_source_dir#" & -- package Naming -- Some attributes are obsolescent, and renamed in the tree (see -- Prj.Dect.Rename_Obsolescent_Attributes). "Pnaming#" & "Saspecification_suffix#" & -- Always renamed to "spec_suffix" in tree "Saspec_suffix#" & "Saimplementation_suffix#" & -- Always renamed to "body_suffix" in tree "Sabody_suffix#" & "SVseparate_suffix#" & "SVcasing#" & "SVdot_replacement#" & "saspecification#" & -- Always renamed to "spec" in project tree "saspec#" & "saimplementation#" & -- Always renamed to "body" in project tree "sabody#" & "Laspecification_exceptions#" & "Laimplementation_exceptions#" & -- package Compiler "Pcompiler#" & "Ladefault_switches#" & "LcOswitches#" & "SVlocal_configuration_pragmas#" & "Salocal_config_file#" & -- Configuration - Compiling "Sadriver#" & "Salanguage_kind#" & "Sadependency_kind#" & "Larequired_switches#" & "Laleading_required_switches#" & "Latrailing_required_switches#" & "Lapic_option#" & "Sapath_syntax#" & "Lasource_file_switches#" & "Saobject_file_suffix#" & "Laobject_file_switches#" & "Lamulti_unit_switches#" & "Samulti_unit_object_separator#" & -- Configuration - Mapping files "Lamapping_file_switches#" & "Samapping_spec_suffix#" & "Samapping_body_suffix#" & -- Configuration - Config files "Laconfig_file_switches#" & "Saconfig_body_file_name#" & "Saconfig_body_file_name_index#" & "Saconfig_body_file_name_pattern#" & "Saconfig_spec_file_name#" & "Saconfig_spec_file_name_index#" & "Saconfig_spec_file_name_pattern#" & "Saconfig_file_unique#" & -- Configuration - Dependencies "Ladependency_switches#" & "Ladependency_driver#" & -- Configuration - Search paths "Lainclude_switches#" & "Sainclude_path#" & "Sainclude_path_file#" & "Laobject_path_switches#" & -- package Builder "Pbuilder#" & "Ladefault_switches#" & "LcOswitches#" & "Lcglobal_compilation_switches#" & "Scexecutable#" & "SVexecutable_suffix#" & "SVglobal_configuration_pragmas#" & "Saglobal_config_file#" & -- package gnatls "Pgnatls#" & "LVswitches#" & -- package Binder "Pbinder#" & "Ladefault_switches#" & "LcOswitches#" & -- Configuration - Binding "Sadriver#" & "Larequired_switches#" & "Saprefix#" & "Saobjects_path#" & "Saobjects_path_file#" & -- package Linker "Plinker#" & "LVrequired_switches#" & "Ladefault_switches#" & "LcOleading_switches#" & "LcOswitches#" & "LcOtrailing_switches#" & "LVlinker_options#" & "SVmap_file_option#" & -- Configuration - Linking "SVdriver#" & -- Configuration - Response files "SVmax_command_line_length#" & "SVresponse_file_format#" & "LVresponse_file_switches#" & -- package Clean "Pclean#" & "LVswitches#" & "Lasource_artifact_extensions#" & "Laobject_artifact_extensions#" & "LVartifacts_in_exec_dir#" & "LVartifacts_in_object_dir#" & -- package Cross_Reference "Pcross_reference#" & "Ladefault_switches#" & "LbOswitches#" & -- package Finder "Pfinder#" & "Ladefault_switches#" & "LbOswitches#" & -- package Pretty_Printer "Ppretty_printer#" & "Ladefault_switches#" & "LbOswitches#" & -- package gnatstub "Pgnatstub#" & "Ladefault_switches#" & "LbOswitches#" & -- package Check "Pcheck#" & "Ladefault_switches#" & "LbOswitches#" & -- package Eliminate "Peliminate#" & "Ladefault_switches#" & "LbOswitches#" & -- package Metrics "Pmetrics#" & "Ladefault_switches#" & "LbOswitches#" & -- package Ide "Pide#" & "Ladefault_switches#" & "SVremote_host#" & "SVprogram_host#" & "SVcommunication_protocol#" & "Sacompiler_command#" & "SVdebugger_command#" & "SVgnatlist#" & "SVvcs_kind#" & "SVvcs_file_check#" & "SVvcs_log_check#" & "SVdocumentation_dir#" & -- package Install "Pinstall#" & "SVprefix#" & "SVsources_subdir#" & "SVexec_subdir#" & "SVlib_subdir#" & "SVproject_subdir#" & "SVactive#" & "LAartifacts#" & "SVmode#" & "SVinstall_name#" & -- package Remote "Premote#" & "SVroot_dir#" & "LVexcluded_patterns#" & "LVincluded_patterns#" & "LVincluded_artifact_patterns#" & -- package Stack "Pstack#" & "LVswitches#" & -- package Codepeer "Pcodepeer#" & "SVoutput_directory#" & "SVdatabase_directory#" & "SVmessage_patterns#" & "SVadditional_patterns#" & "LVswitches#" & "LVexcluded_source_files#" & -- package Prove "Pprove#" & -- package GnatTest "Pgnattest#" & "#"; Initialized : Boolean := False; -- A flag to avoid multiple initialization Package_Names : String_List_Access := new Strings.String_List (1 .. 20); Last_Package_Name : Natural := 0; -- Package_Names (1 .. Last_Package_Name) contains the list of the known -- package names, coming from the Initialization_Data string or from -- calls to one of the two procedures Register_New_Package. procedure Add_Package_Name (Name : String); -- Add a package name in the Package_Name list, extending it, if necessary function Name_Id_Of (Name : String) return Name_Id; -- Returns the Name_Id for Name in lower case ---------------------- -- Add_Package_Name -- ---------------------- procedure Add_Package_Name (Name : String) is begin if Last_Package_Name = Package_Names'Last then declare New_List : constant Strings.String_List_Access := new Strings.String_List (1 .. Package_Names'Last * 2); begin New_List (Package_Names'Range) := Package_Names.all; Package_Names := New_List; end; end if; Last_Package_Name := Last_Package_Name + 1; Package_Names (Last_Package_Name) := new String'(Name); end Add_Package_Name; -------------------------- -- Attribute_Default_Of -- -------------------------- function Attribute_Default_Of (Attribute : Attribute_Node_Id) return Attribute_Default_Value is begin if Attribute = Empty_Attribute then return Empty_Value; else return Attrs.Table (Attribute.Value).Default; end if; end Attribute_Default_Of; ----------------------- -- Attribute_Kind_Of -- ----------------------- function Attribute_Kind_Of (Attribute : Attribute_Node_Id) return Attribute_Kind is begin if Attribute = Empty_Attribute then return Unknown; else return Attrs.Table (Attribute.Value).Attr_Kind; end if; end Attribute_Kind_Of; ----------------------- -- Attribute_Name_Of -- ----------------------- function Attribute_Name_Of (Attribute : Attribute_Node_Id) return Name_Id is begin if Attribute = Empty_Attribute then return No_Name; else return Attrs.Table (Attribute.Value).Name; end if; end Attribute_Name_Of; -------------------------- -- Attribute_Node_Id_Of -- -------------------------- function Attribute_Node_Id_Of (Name : Name_Id; Starting_At : Attribute_Node_Id) return Attribute_Node_Id is Id : Attr_Node_Id := Starting_At.Value; begin while Id /= Empty_Attr and then Attrs.Table (Id).Name /= Name loop Id := Attrs.Table (Id).Next; end loop; return (Value => Id); end Attribute_Node_Id_Of; ---------------- -- Initialize -- ---------------- procedure Initialize is Start : Positive := Initialization_Data'First; Finish : Positive := Start; Current_Package : Pkg_Node_Id := Empty_Pkg; Current_Attribute : Attr_Node_Id := Empty_Attr; Is_An_Attribute : Boolean := False; Var_Kind : Variable_Kind := Undefined; Optional_Index : Boolean := False; Attr_Kind : Attribute_Kind := Single; Package_Name : Name_Id := No_Name; Attribute_Name : Name_Id := No_Name; First_Attribute : Attr_Node_Id := Attr.First_Attribute; Read_Only : Boolean; Others_Allowed : Boolean; Default : Attribute_Default_Value; function Attribute_Location return String; -- Returns a string depending if we are in the project level attributes -- or in the attributes of a package. ------------------------ -- Attribute_Location -- ------------------------ function Attribute_Location return String is begin if Package_Name = No_Name then return "project level attributes"; else return "attribute of package """ & Get_Name_String (Package_Name) & """"; end if; end Attribute_Location; -- Start of processing for Initialize begin -- Don't allow Initialize action to be repeated if Initialized then return; end if; -- Make sure the two tables are empty Attrs.Init; Package_Attributes.Init; while Initialization_Data (Start) /= '#' loop Is_An_Attribute := True; case Initialization_Data (Start) is when 'P' => -- New allowed package Start := Start + 1; Finish := Start; while Initialization_Data (Finish) /= '#' loop Finish := Finish + 1; end loop; Package_Name := Name_Id_Of (Initialization_Data (Start .. Finish - 1)); for Index in First_Package .. Package_Attributes.Last loop if Package_Name = Package_Attributes.Table (Index).Name then Osint.Fail ("duplicate name """ & Initialization_Data (Start .. Finish - 1) & """ in predefined packages."); end if; end loop; Is_An_Attribute := False; Current_Attribute := Empty_Attr; Package_Attributes.Increment_Last; Current_Package := Package_Attributes.Last; Package_Attributes.Table (Current_Package) := (Name => Package_Name, Known => True, First_Attribute => Empty_Attr); Start := Finish + 1; Add_Package_Name (Get_Name_String (Package_Name)); when 'S' => Var_Kind := Single; Optional_Index := False; when 's' => Var_Kind := Single; Optional_Index := True; when 'L' => Var_Kind := List; Optional_Index := False; when 'l' => Var_Kind := List; Optional_Index := True; when others => raise Program_Error; end case; if Is_An_Attribute then -- New attribute Start := Start + 1; case Initialization_Data (Start) is when 'V' => Attr_Kind := Single; when 'A' => Attr_Kind := Associative_Array; when 'a' => Attr_Kind := Case_Insensitive_Associative_Array; when 'b' => if Osint.File_Names_Case_Sensitive then Attr_Kind := Associative_Array; else Attr_Kind := Case_Insensitive_Associative_Array; end if; when 'c' => if Osint.File_Names_Case_Sensitive then Attr_Kind := Optional_Index_Associative_Array; else Attr_Kind := Optional_Index_Case_Insensitive_Associative_Array; end if; when others => raise Program_Error; end case; Start := Start + 1; Read_Only := False; Others_Allowed := False; Default := Empty_Value; if Initialization_Data (Start) = 'R' then Read_Only := True; Default := Read_Only_Value; Start := Start + 1; elsif Initialization_Data (Start) = 'O' then Others_Allowed := True; Start := Start + 1; end if; Finish := Start; while Initialization_Data (Finish) /= '#' and then Initialization_Data (Finish) /= 'D' loop Finish := Finish + 1; end loop; Attribute_Name := Name_Id_Of (Initialization_Data (Start .. Finish - 1)); if Initialization_Data (Finish) = 'D' then Start := Finish + 1; Finish := Start; while Initialization_Data (Finish) /= '#' loop Finish := Finish + 1; end loop; declare Default_Name : constant String := Initialization_Data (Start .. Finish - 1); pragma Unsuppress (All_Checks); begin Default := Attribute_Default_Value'Value (Default_Name); exception when Constraint_Error => Osint.Fail ("illegal default value """ & Default_Name & """ for attribute " & Get_Name_String (Attribute_Name)); end; end if; Attrs.Increment_Last; if Current_Attribute = Empty_Attr then First_Attribute := Attrs.Last; if Current_Package /= Empty_Pkg then Package_Attributes.Table (Current_Package).First_Attribute := Attrs.Last; end if; else -- Check that there are no duplicate attributes for Index in First_Attribute .. Attrs.Last - 1 loop if Attribute_Name = Attrs.Table (Index).Name then Osint.Fail ("duplicate attribute """ & Initialization_Data (Start .. Finish - 1) & """ in " & Attribute_Location); end if; end loop; Attrs.Table (Current_Attribute).Next := Attrs.Last; end if; Current_Attribute := Attrs.Last; Attrs.Table (Current_Attribute) := (Name => Attribute_Name, Var_Kind => Var_Kind, Optional_Index => Optional_Index, Attr_Kind => Attr_Kind, Read_Only => Read_Only, Others_Allowed => Others_Allowed, Default => Default, Next => Empty_Attr); Start := Finish + 1; end if; end loop; Initialized := True; end Initialize; ------------------ -- Is_Read_Only -- ------------------ function Is_Read_Only (Attribute : Attribute_Node_Id) return Boolean is begin return Attrs.Table (Attribute.Value).Read_Only; end Is_Read_Only; ---------------- -- Name_Id_Of -- ---------------- function Name_Id_Of (Name : String) return Name_Id is begin Name_Len := 0; Add_Str_To_Name_Buffer (Name); To_Lower (Name_Buffer (1 .. Name_Len)); return Name_Find; end Name_Id_Of; -------------------- -- Next_Attribute -- -------------------- function Next_Attribute (After : Attribute_Node_Id) return Attribute_Node_Id is begin if After = Empty_Attribute then return Empty_Attribute; else return (Value => Attrs.Table (After.Value).Next); end if; end Next_Attribute; ----------------------- -- Optional_Index_Of -- ----------------------- function Optional_Index_Of (Attribute : Attribute_Node_Id) return Boolean is begin if Attribute = Empty_Attribute then return False; else return Attrs.Table (Attribute.Value).Optional_Index; end if; end Optional_Index_Of; function Others_Allowed_For (Attribute : Attribute_Node_Id) return Boolean is begin if Attribute = Empty_Attribute then return False; else return Attrs.Table (Attribute.Value).Others_Allowed; end if; end Others_Allowed_For; ----------------------- -- Package_Name_List -- ----------------------- function Package_Name_List return Strings.String_List is begin return Package_Names (1 .. Last_Package_Name); end Package_Name_List; ------------------------ -- Package_Node_Id_Of -- ------------------------ function Package_Node_Id_Of (Name : Name_Id) return Package_Node_Id is begin for Index in Package_Attributes.First .. Package_Attributes.Last loop if Package_Attributes.Table (Index).Name = Name then if Package_Attributes.Table (Index).Known then return (Value => Index); else return Unknown_Package; end if; end if; end loop; -- If there is no package with this name, return Empty_Package return Empty_Package; end Package_Node_Id_Of; ---------------------------- -- Register_New_Attribute -- ---------------------------- procedure Register_New_Attribute (Name : String; In_Package : Package_Node_Id; Attr_Kind : Defined_Attribute_Kind; Var_Kind : Defined_Variable_Kind; Index_Is_File_Name : Boolean := False; Opt_Index : Boolean := False; Default : Attribute_Default_Value := Empty_Value) is Attr_Name : Name_Id; First_Attr : Attr_Node_Id := Empty_Attr; Curr_Attr : Attr_Node_Id; Real_Attr_Kind : Attribute_Kind; begin if Name'Length = 0 then Fail ("cannot register an attribute with no name"); raise Project_Error; end if; if In_Package = Empty_Package then Fail ("attempt to add attribute """ & Name & """ to an undefined package"); raise Project_Error; end if; Attr_Name := Name_Id_Of (Name); First_Attr := Package_Attributes.Table (In_Package.Value).First_Attribute; -- Check if attribute name is a duplicate Curr_Attr := First_Attr; while Curr_Attr /= Empty_Attr loop if Attrs.Table (Curr_Attr).Name = Attr_Name then Fail ("duplicate attribute name """ & Name & """ in package """ & Get_Name_String (Package_Attributes.Table (In_Package.Value).Name) & """"); raise Project_Error; end if; Curr_Attr := Attrs.Table (Curr_Attr).Next; end loop; Real_Attr_Kind := Attr_Kind; -- If Index_Is_File_Name, change the attribute kind if necessary if Index_Is_File_Name and then not Osint.File_Names_Case_Sensitive then case Attr_Kind is when Associative_Array => Real_Attr_Kind := Case_Insensitive_Associative_Array; when Optional_Index_Associative_Array => Real_Attr_Kind := Optional_Index_Case_Insensitive_Associative_Array; when others => null; end case; end if; -- Add the new attribute Attrs.Increment_Last; Attrs.Table (Attrs.Last) := (Name => Attr_Name, Var_Kind => Var_Kind, Optional_Index => Opt_Index, Attr_Kind => Real_Attr_Kind, Read_Only => False, Others_Allowed => False, Default => Default, Next => First_Attr); Package_Attributes.Table (In_Package.Value).First_Attribute := Attrs.Last; end Register_New_Attribute; -------------------------- -- Register_New_Package -- -------------------------- procedure Register_New_Package (Name : String; Id : out Package_Node_Id) is Pkg_Name : Name_Id; Found : Boolean := False; begin if Name'Length = 0 then Fail ("cannot register a package with no name"); Id := Empty_Package; return; end if; Pkg_Name := Name_Id_Of (Name); for Index in Package_Attributes.First .. Package_Attributes.Last loop if Package_Attributes.Table (Index).Name = Pkg_Name then if Package_Attributes.Table (Index).Known then Fail ("cannot register a package with a non unique name """ & Name & """"); Id := Empty_Package; return; else Found := True; Id := (Value => Index); exit; end if; end if; end loop; if not Found then Package_Attributes.Increment_Last; Id := (Value => Package_Attributes.Last); end if; Package_Attributes.Table (Id.Value) := (Name => Pkg_Name, Known => True, First_Attribute => Empty_Attr); Add_Package_Name (Get_Name_String (Pkg_Name)); end Register_New_Package; procedure Register_New_Package (Name : String; Attributes : Attribute_Data_Array) is Pkg_Name : Name_Id; Attr_Name : Name_Id; First_Attr : Attr_Node_Id := Empty_Attr; Curr_Attr : Attr_Node_Id; Attr_Kind : Attribute_Kind; begin if Name'Length = 0 then Fail ("cannot register a package with no name"); raise Project_Error; end if; Pkg_Name := Name_Id_Of (Name); for Index in Package_Attributes.First .. Package_Attributes.Last loop if Package_Attributes.Table (Index).Name = Pkg_Name then Fail ("cannot register a package with a non unique name """ & Name & """"); raise Project_Error; end if; end loop; for Index in Attributes'Range loop Attr_Name := Name_Id_Of (Attributes (Index).Name); Curr_Attr := First_Attr; while Curr_Attr /= Empty_Attr loop if Attrs.Table (Curr_Attr).Name = Attr_Name then Fail ("duplicate attribute name """ & Attributes (Index).Name & """ in new package """ & Name & """"); raise Project_Error; end if; Curr_Attr := Attrs.Table (Curr_Attr).Next; end loop; Attr_Kind := Attributes (Index).Attr_Kind; if Attributes (Index).Index_Is_File_Name and then not Osint.File_Names_Case_Sensitive then case Attr_Kind is when Associative_Array => Attr_Kind := Case_Insensitive_Associative_Array; when Optional_Index_Associative_Array => Attr_Kind := Optional_Index_Case_Insensitive_Associative_Array; when others => null; end case; end if; Attrs.Increment_Last; Attrs.Table (Attrs.Last) := (Name => Attr_Name, Var_Kind => Attributes (Index).Var_Kind, Optional_Index => Attributes (Index).Opt_Index, Attr_Kind => Attr_Kind, Read_Only => False, Others_Allowed => False, Default => Attributes (Index).Default, Next => First_Attr); First_Attr := Attrs.Last; end loop; Package_Attributes.Increment_Last; Package_Attributes.Table (Package_Attributes.Last) := (Name => Pkg_Name, Known => True, First_Attribute => First_Attr); Add_Package_Name (Get_Name_String (Pkg_Name)); end Register_New_Package; --------------------------- -- Set_Attribute_Kind_Of -- --------------------------- procedure Set_Attribute_Kind_Of (Attribute : Attribute_Node_Id; To : Attribute_Kind) is begin if Attribute /= Empty_Attribute then Attrs.Table (Attribute.Value).Attr_Kind := To; end if; end Set_Attribute_Kind_Of; -------------------------- -- Set_Variable_Kind_Of -- -------------------------- procedure Set_Variable_Kind_Of (Attribute : Attribute_Node_Id; To : Variable_Kind) is begin if Attribute /= Empty_Attribute then Attrs.Table (Attribute.Value).Var_Kind := To; end if; end Set_Variable_Kind_Of; ---------------------- -- Variable_Kind_Of -- ---------------------- function Variable_Kind_Of (Attribute : Attribute_Node_Id) return Variable_Kind is begin if Attribute = Empty_Attribute then return Undefined; else return Attrs.Table (Attribute.Value).Var_Kind; end if; end Variable_Kind_Of; ------------------------ -- First_Attribute_Of -- ------------------------ function First_Attribute_Of (Pkg : Package_Node_Id) return Attribute_Node_Id is begin if Pkg = Empty_Package or else Pkg = Unknown_Package then return Empty_Attribute; else return (Value => Package_Attributes.Table (Pkg.Value).First_Attribute); end if; end First_Attribute_Of; end Prj.Attr;
29,688
ada
0
JCGobbi/Nucleo-STM32G474RE
ADL/drivers/stm32g474/stm32-timers.ads
<gh_stars>0 ------------------------------------------------------------------------------ -- -- -- Copyright (C) 2015, 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 STMicroelectronics nor the names of its -- -- contributors may be used to endorse or promote products derived -- -- from this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -- -- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -- -- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -- -- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -- -- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -- -- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- -- -- -- This file is based on: -- -- -- -- @file stm32f4xx_hal_tim.h -- -- @author MCD Application Team -- -- @version V1.1.0 -- -- @date 19-June-2014 -- -- @brief Header file of timers HAL module. -- -- -- -- COPYRIGHT(c) 2014 STMicroelectronics -- ------------------------------------------------------------------------------ -- This file provides definitions for the timers on the STM32F3 (ARM Cortex -- M4F) microcontrollers from ST Microelectronics. pragma Restrictions (No_Elaboration_Code); with System; use System; with STM32_SVD; package STM32.Timers is type Timer is limited private; procedure Enable (This : in out Timer) with Post => Enabled (This); procedure Disable (This : in out Timer) with Post => (if No_Outputs_Enabled (This) then not Enabled (This)); function Enabled (This : Timer) return Boolean; -- The Configure routines are overloaded for the sake of -- additional timer-class specific parameters. procedure Configure (This : in out Timer; Prescaler : UInt16; Period : UInt32) with Pre => (if Period > UInt32 (UInt16'Last) then Has_32bit_Counter (This)), Post => Current_Prescaler (This) = Prescaler and Current_Autoreload (This) = Period; procedure Set_Counter (This : in out Timer; Value : UInt16) with Post => Current_Counter (This) = UInt32 (Value); procedure Set_Counter (This : in out Timer; Value : UInt32) with Pre => Has_32bit_Counter (This), Post => Current_Counter (This) = Value; function Current_Counter (This : Timer) return UInt32; -- For those timers that actually have a 32-bit counter this function will -- return the full word value. For the other timers, the upper half-word of -- the result will be all zeros so in effect the result will be a half-word -- value. procedure Set_Repetition_Counter (This : in out Timer; Value : UInt32) with Pre => Complementary_Outputs_Supported (This) and (if Value > UInt32 (UInt8'Last) then Advanced_Timer (This)), Post => Current_Repetition_Counter (This) = Value; function Current_Repetition_Counter (This : Timer) return UInt32 with Pre => Complementary_Outputs_Supported (This); procedure Set_Autoreload (This : in out Timer; Value : UInt32) with Pre => (if Value > UInt32 (UInt16'Last) then Has_32bit_Counter (This)), Post => Current_Autoreload (This) = Value; function Current_Autoreload (This : Timer) return UInt32; -- Returns the value of the timer's Auto Reload Register (ARR) type Timer_Clock_Divisor is (Div1, Div2, Div4); procedure Set_Clock_Division (This : in out Timer; Value : Timer_Clock_Divisor) with Pre => not Basic_Timer (This), Post => Current_Clock_Division (This) = Value; function Current_Clock_Division (This : Timer) return Timer_Clock_Divisor; type Timer_Counter_Alignment_Mode is (Up, Down, Center_Aligned1, Center_Aligned2, Center_Aligned3); -- We combine the up-down direction and the center-aligned mode selection -- into a single type because the two are interdependent and we don't want -- the user to have to remember to set the direction when not using one -- of the center-aligned choices. The discontiguous binary values used to -- represent the enumerals reflect the combination of the adjacent fields -- within the timer representation. for Timer_Counter_Alignment_Mode use (Up => 2#000#, Down => 2#001#, Center_Aligned1 => 2#010#, Center_Aligned2 => 2#100#, Center_Aligned3 => 2#110#); procedure Set_Counter_Mode (This : in out Timer; Value : Timer_Counter_Alignment_Mode) with Post => Current_Counter_Mode (This) = Value; function Current_Counter_Mode (This : Timer) return Timer_Counter_Alignment_Mode; -- Note that the basic timers only count up. procedure Configure (This : in out Timer; Prescaler : UInt16; Period : UInt32; Clock_Divisor : Timer_Clock_Divisor; Counter_Mode : Timer_Counter_Alignment_Mode) with Pre => not Basic_Timer (This) and (if Period > UInt32 (UInt16'Last) then Has_32bit_Counter (This)), Post => Current_Prescaler (This) = Prescaler and Current_Clock_Division (This) = Clock_Divisor and Current_Counter_Mode (This) = Counter_Mode and Current_Autoreload (This) = Period; type Timer_Prescaler_Reload_Mode is (Update, Immediate); procedure Configure_Prescaler (This : in out Timer; Prescaler : UInt16; Reload_Mode : Timer_Prescaler_Reload_Mode) with Post => Current_Prescaler (This) = Prescaler; function Current_Prescaler (This : Timer) return UInt16; procedure Set_UpdateDisable (This : in out Timer; To : Boolean); type Timer_Update_Source is (Global, Regular); procedure Set_UpdateRequest (This : in out Timer; Source : Timer_Update_Source); procedure Set_Autoreload_Preload (This : in out Timer; To : Boolean); type Timer_One_Pulse_Mode is (Repetitive, Single); procedure Select_One_Pulse_Mode (This : in out Timer; Mode : Timer_One_Pulse_Mode) with Post => (if Mode = Single then not Enabled (This)); procedure Compute_Prescaler_And_Period (This : access Timer; Requested_Frequency : UInt32; Prescaler : out UInt32; Period : out UInt32) with Pre => Requested_Frequency > 0; -- Computes the minimum prescaler and thus the maximum resolution for the -- given timer, based on the system clocks and the requested frequency. -- Computes the period required for the requested frequency. Invalid_Request : exception; -- Raised when the requested frequency is too high or too low for the given -- timer and system clocks when calling Configure_PWM_Timer, or when -- the requested time is too high for the specified frequency when calling -- Set_Duty_Time. ---------------------------------------------------------------------------- -- Interrupts, DMA, Flags Management -------------------------------------- ---------------------------------------------------------------------------- type Timer_Interrupt is (Timer_Update_Interrupt, Timer_CC1_Interrupt, Timer_CC2_Interrupt, Timer_CC3_Interrupt, Timer_CC4_Interrupt, Timer_COM_Interrupt, Timer_Trigger_Interrupt, Timer_Break_Interrupt); for Timer_Interrupt use (Timer_Update_Interrupt => 2#00000001#, Timer_CC1_Interrupt => 2#00000010#, Timer_CC2_Interrupt => 2#00000100#, Timer_CC3_Interrupt => 2#00001000#, Timer_CC4_Interrupt => 2#00010000#, Timer_COM_Interrupt => 2#00100000#, Timer_Trigger_Interrupt => 2#01000000#, Timer_Break_Interrupt => 2#10000000#); procedure Enable_Interrupt (This : in out Timer; Source : Timer_Interrupt) with Pre => (if Basic_Timer (This) then Source = Timer_Update_Interrupt) and (if Source in Timer_COM_Interrupt | Timer_Break_Interrupt then Advanced_Timer (This)), Post => Interrupt_Enabled (This, Source); type Timer_Interrupt_List is array (Positive range <>) of Timer_Interrupt; procedure Enable_Interrupt (This : in out Timer; Sources : Timer_Interrupt_List) with Pre => (for all Source of Sources => (if Basic_Timer (This) then Source = Timer_Update_Interrupt) and (if Source in Timer_COM_Interrupt | Timer_Break_Interrupt then Advanced_Timer (This))), Post => (for all Source of Sources => Interrupt_Enabled (This, Source)); procedure Disable_Interrupt (This : in out Timer; Source : Timer_Interrupt) with Pre => (if Basic_Timer (This) then Source = Timer_Update_Interrupt) and (if Source in Timer_COM_Interrupt | Timer_Break_Interrupt then Advanced_Timer (This)), Post => not Interrupt_Enabled (This, Source); procedure Clear_Pending_Interrupt (This : in out Timer; Source : Timer_Interrupt) with Pre => (if Basic_Timer (This) then Source = Timer_Update_Interrupt) and (if Source in Timer_COM_Interrupt | Timer_Break_Interrupt then Advanced_Timer (This)); function Interrupt_Enabled (This : Timer; Source : Timer_Interrupt) return Boolean with Pre => (if Basic_Timer (This) then Source = Timer_Update_Interrupt) and (if Source in Timer_COM_Interrupt | Timer_Break_Interrupt then Advanced_Timer (This)); type Timer_Event_Source is (Event_Source_Update, Event_Source_CC1, Event_Source_CC2, Event_Source_CC3, Event_Source_CC4, Event_Source_COM, Event_Source_Trigger, Event_Source_Break, Event_Source_Break2); for Timer_Event_Source use (Event_Source_Update => 16#0001#, Event_Source_CC1 => 16#0002#, Event_Source_CC2 => 16#0004#, Event_Source_CC3 => 16#0008#, Event_Source_CC4 => 16#0010#, Event_Source_COM => 16#0020#, Event_Source_Trigger => 16#0040#, Event_Source_Break => 16#0080#, Event_Source_Break2 => 16#0100#); -- TODO: consider alternative to bit-masks procedure Generate_Event (This : in out Timer; Source : Timer_Event_Source) with Pre => (if Basic_Timer (This) then Source = Event_Source_Update) and (if Source in Event_Source_COM | Event_Source_Break then Advanced_Timer (This)); type Timer_Status_Flag is (Timer_Update_Indicated, Timer_CC1_Indicated, Timer_CC2_Indicated, Timer_CC3_Indicated, Timer_CC4_Indicated, Timer_COM_Indicated, Timer_Trigger_Indicated, Timer_Break_Indicated, Timer_Break2_Indicated, Timer_CC1_Overcap_Indicated, Timer_CC2_Overcap_Indicated, Timer_CC3_Overcap_Indicated, Timer_CC4_Overcap_Indicated, Timer_CC5_Indicated, Timer_CC6_Indicated); for Timer_Status_Flag use (Timer_Update_Indicated => 16#00000001#, Timer_CC1_Indicated => 16#00000002#, Timer_CC2_Indicated => 16#00000004#, Timer_CC3_Indicated => 16#00000008#, Timer_CC4_Indicated => 16#00000010#, Timer_COM_Indicated => 16#00000020#, Timer_Trigger_Indicated => 16#00000040#, Timer_Break_Indicated => 16#00000080#, Timer_Break2_Indicated => 16#00000100#, Timer_CC1_Overcap_Indicated => 16#00000200#, Timer_CC2_Overcap_Indicated => 16#00000400#, Timer_CC3_Overcap_Indicated => 16#00000800#, Timer_CC4_Overcap_Indicated => 16#00001000#, Timer_CC5_Indicated => 16#00010000#, Timer_CC6_Indicated => 16#00020000#); function Status (This : Timer; Flag : Timer_Status_Flag) return Boolean with Pre => (if Basic_Timer (This) then Flag = Timer_Update_Indicated) and (if Flag in Timer_COM_Indicated | Timer_Break_Indicated then Advanced_Timer (This)); procedure Clear_Status (This : in out Timer; Flag : Timer_Status_Flag) with Pre => (if Basic_Timer (This) then Flag = Timer_Update_Indicated) and (if Flag in Timer_COM_Indicated | Timer_Break_Indicated then Advanced_Timer (This)), Post => not Status (This, Flag); type Timer_DMA_Source is (Timer_DMA_Update, Timer_DMA_CC1, Timer_DMA_CC2, Timer_DMA_CC3, Timer_DMA_CC4, Timer_DMA_COM, Timer_DMA_Trigger); for Timer_DMA_Source use (Timer_DMA_Update => 2#00000001_00000000#, Timer_DMA_CC1 => 2#00000010_00000000#, Timer_DMA_CC2 => 2#00000100_00000000#, Timer_DMA_CC3 => 2#00001000_00000000#, Timer_DMA_CC4 => 2#00010000_00000000#, Timer_DMA_COM => 2#00100000_00000000#, Timer_DMA_Trigger => 2#01000000_00000000#); -- TODO: consider using a packed array of booleans in the SR representation -- instead of bit-patterns, thereby obviating this rep clause procedure Enable_DMA_Source (This : in out Timer; Source : Timer_DMA_Source) with Pre => ((if Basic_Timer (This) then Source = Timer_DMA_Update) and (if Source in Timer_DMA_COM | Timer_DMA_Trigger then Advanced_Timer (This))) or else DMA_Supported (This), Post => DMA_Source_Enabled (This, Source); procedure Disable_DMA_Source (This : in out Timer; Source : Timer_DMA_Source) with Pre => ((if Basic_Timer (This) then Source = Timer_DMA_Update) and (if Source in Timer_DMA_COM | Timer_DMA_Trigger then Advanced_Timer (This))) or else DMA_Supported (This), Post => not DMA_Source_Enabled (This, Source); function DMA_Source_Enabled (This : Timer; Source : Timer_DMA_Source) return Boolean with Pre => ((if Basic_Timer (This) then Source = Timer_DMA_Update) and (if Source in Timer_DMA_COM | Timer_DMA_Trigger then Advanced_Timer (This))) or else DMA_Supported (This); type Timer_DMA_Burst_Length is (DMA_Burst_Length_1, DMA_Burst_Length_2, DMA_Burst_Length_3, DMA_Burst_Length_4, DMA_Burst_Length_5, DMA_Burst_Length_6, DMA_Burst_Length_7, DMA_Burst_Length_8, DMA_Burst_Length_9, DMA_Burst_Length_10, DMA_Burst_Length_11, DMA_Burst_Length_12, DMA_Burst_Length_13, DMA_Burst_Length_14, DMA_Burst_Length_15, DMA_Burst_Length_16, DMA_Burst_Length_17, DMA_Burst_Length_18, DMA_Burst_Length_19, DMA_Burst_Length_20, DMA_Burst_Length_21, DMA_Burst_Length_22, DMA_Burst_Length_23, DMA_Burst_Length_24, DMA_Burst_Length_25, DMA_Burst_Length_26); type Timer_DMA_Base_Address is (DMA_Base_CR1, DMA_Base_CR2, DMA_Base_SMCR, DMA_Base_DIER, DMA_Base_SR, DMA_Base_EGR, DMA_Base_CCMR1, DMA_Base_CCMR2, DMA_Base_CCER, DMA_Base_CNT, DMA_Base_PSC, DMA_Base_ARR, DMA_Base_RCR, DMA_Base_CCR1, DMA_Base_CCR2, DMA_Base_CCR3, DMA_Base_CCR4, DMA_Base_BDTR, DMA_Base_CCR5, DMA_Base_CCR6, DMA_Base_CCMR3, DMA_Base_DTR2, DMA_Base_ECR, DMA_Base_TISEL, DMA_Base_AF1, DMA_Base_AF2, DMA_Base_26, DMA_Base_27, DMA_Base_28, DMA_Base_29, DMA_Base_30, DMA_Base_31); procedure Configure_DMA (This : in out Timer; Base_Address : Timer_DMA_Base_Address; Burst_Length : Timer_DMA_Burst_Length); procedure Enable_Capture_Compare_DMA (This : in out Timer); procedure Disable_Capture_Compare_DMA (This : in out Timer); ---------------------------------------------------------------------------- -- Output Compare Management ---------------------------------------------- ---------------------------------------------------------------------------- type Timer_Channel is (Channel_1, Channel_2, Channel_3, Channel_4, Channel_5, Channel_6); procedure Enable_Channel (This : in out Timer; Channel : Timer_Channel) with Pre => not Basic_Timer (This), Post => Channel_Enabled (This, Channel); procedure Disable_Channel (This : in out Timer; Channel : Timer_Channel) with Pre => not Basic_Timer (This), Post => not Channel_Enabled (This, Channel); function Channel_Enabled (This : Timer; Channel : Timer_Channel) return Boolean; procedure Enable_Complementary_Channel (This : in out Timer; Channel : Timer_Channel) with Pre => Complementary_Outputs_Supported (This, Channel), Post => Complementary_Channel_Enabled (This, Channel); procedure Disable_Complementary_Channel (This : in out Timer; Channel : Timer_Channel) with Pre => Complementary_Outputs_Supported (This, Channel), Post => not Complementary_Channel_Enabled (This, Channel); function Complementary_Channel_Enabled (This : Timer; Channel : Timer_Channel) return Boolean with Pre => Complementary_Outputs_Supported (This, Channel); Timer_Channel_Access_Error : exception; -- Raised when accessing a given channel configuration with the wrong view: -- as an input when it is set to be an output, and vice versa type Timer_Output_Compare_And_PWM_Mode is (Frozen, Active, Inactive, Toggle, Force_Inactive, Force_Active, PWM1, PWM2, Retriggerable_OPM1, Retriggerable_OPM2, Combined_PWM1, Combined_PWM2, Asymmetric_PWM1, Asymmetric_PWM2); -- See RM pg 457 for the effects of these values for Timer_Output_Compare_And_PWM_Mode use (Frozen => 2#0000#, Active => 2#0001#, Inactive => 2#0010#, Toggle => 2#0011#, Force_Inactive => 2#0100#, Force_Active => 2#0101#, PWM1 => 2#0110#, PWM2 => 2#0111#, Retriggerable_OPM1 => 2#1000#, Retriggerable_OPM2 => 2#1001#, Combined_PWM1 => 2#1100#, Combined_PWM2 => 2#1101#, Asymmetric_PWM1 => 2#1110#, Asymmetric_PWM2 => 2#1111#); type Timer_Capture_Compare_State is (Disable, Enable); type Timer_Output_Compare_Polarity is (High, Low); procedure Configure_Channel_Output (This : in out Timer; Channel : Timer_Channel; Mode : Timer_Output_Compare_And_PWM_Mode; State : Timer_Capture_Compare_State; Pulse : UInt32; Polarity : Timer_Output_Compare_Polarity) with Pre => (CC_Channel_Exists (This, Channel) and Specific_Channel_Output_Supported (This, Channel)) and (if not Has_32bit_CC_Values (This) then Pulse <= 16#FFFF#), Post => (if State = Enable then Channel_Enabled (This, Channel) else not Channel_Enabled (This, Channel)); procedure Set_Compare_Value (This : in out Timer; Channel : Timer_Channel; Word_Value : UInt32) with Pre => Has_32bit_CC_Values (This), Post => Current_Capture_Value (This, Channel) = Word_Value; procedure Set_Compare_Value (This : in out Timer; Channel : Timer_Channel; Value : UInt16) with Pre => CC_Channel_Exists (This, Channel), Post => Current_Capture_Value (This, Channel) = Value; type Timer_Capture_Compare_Modes is (Output, Direct_TI, Indirect_TI, TRC); function Current_Capture_Compare_Mode (This : Timer; Channel : Timer_Channel) return Timer_Capture_Compare_Modes; -- A convenience routine that sets the capture/compare selection to be that -- of a single channel output and assigns all the controls of that output, -- as an alternative to calling the individual routines. Does not raise the -- access error exception because it explicitly sets the mode to Output. procedure Set_Single_Output (This : in out Timer; Channel : Timer_Channel; Mode : Timer_Output_Compare_And_PWM_Mode; OC_Clear_Enabled : Boolean; Preload_Enabled : Boolean; Fast_Enabled : Boolean) with Pre => CC_Channel_Exists (This, Channel), Post => Current_Capture_Compare_Mode (This, Channel) = Output; procedure Set_Output_Compare_Mode (This : in out Timer; Channel : Timer_Channel; Mode : Timer_Output_Compare_And_PWM_Mode) with Pre => (not Basic_Timer (This)) and (if Current_Capture_Compare_Mode (This, Channel) /= Output then raise Timer_Channel_Access_Error); procedure Set_Output_Preload_Enable (This : in out Timer; Channel : Timer_Channel; Enabled : Boolean) with Pre => CC_Channel_Exists (This, Channel) and (if Current_Capture_Compare_Mode (This, Channel) /= Output then raise Timer_Channel_Access_Error); procedure Set_Output_Fast_Enable (This : in out Timer; Channel : Timer_Channel; Enabled : Boolean) with Pre => CC_Channel_Exists (This, Channel) and (if Current_Capture_Compare_Mode (This, Channel) /= Output then raise Timer_Channel_Access_Error); procedure Set_Clear_Control (This : in out Timer; Channel : Timer_Channel; Enabled : Boolean) with Pre => CC_Channel_Exists (This, Channel) and (if Current_Capture_Compare_Mode (This, Channel) /= Output then raise Timer_Channel_Access_Error); procedure Set_Output_Forced_Action (This : in out Timer; Channel : Timer_Channel; Active : Boolean) with Pre => CC_Channel_Exists (This, Channel) and (if Current_Capture_Compare_Mode (This, Channel) /= Output then raise Timer_Channel_Access_Error); procedure Set_Output_Polarity (This : in out Timer; Channel : Timer_Channel; Polarity : Timer_Output_Compare_Polarity) with Pre => not Basic_Timer (This); procedure Set_Output_Complementary_Polarity (This : in out Timer; Channel : Timer_Channel; Polarity : Timer_Output_Compare_Polarity) with Pre => Advanced_Timer (This); function No_Outputs_Enabled (This : Timer) return Boolean; -- Indicates whether all outputs are disabled for all channels of the given -- timer. ---------------------------------------------------------------------------- -- Input Capture Management ----------------------------------------------- ---------------------------------------------------------------------------- type Timer_Input_Capture_Filter is (No_Filter, FCK_INT_N2, FCK_INT_N4, FCK_INT_N8, FDTS2_N6, FDTS2_N8, FDTS4_N6, FDTS4_N8, FDTS8_N6, FDTS8_N8, FDTS16_N5, FDTS16_N6, FDTS16_N8, FDTS32_N5, FDTS32_N6, FDTS32_N8); type Timer_Input_Capture_Polarity is (Rising, Falling, Both_Edges); subtype Timer_Input_Capture_Selection is Timer_Capture_Compare_Modes range Direct_TI .. TRC; type Timer_Input_Capture_Prescaler is (Div1, -- Capture performed each time an edge is detected on input Div2, -- Capture performed once every 2 events Div4, -- Capture performed once every 4 events Div8); -- Capture performed once every 8 events procedure Configure_Channel_Input (This : in out Timer; Channel : Timer_Channel; Polarity : Timer_Input_Capture_Polarity; Selection : Timer_Input_Capture_Selection; Prescaler : Timer_Input_Capture_Prescaler; Filter : Timer_Input_Capture_Filter) with Pre => CC_Channel_Exists (This, Channel) and (if Filter > FDTS4_N8 then Advanced_Timer (This)), Post => Channel_Enabled (This, Channel) and Current_Capture_Compare_Mode (This, Channel) = Selection; procedure Configure_Channel_Input_PWM (This : in out Timer; Channel : Timer_Channel; Selection : Timer_Input_Capture_Selection; Polarity : Timer_Input_Capture_Polarity; Prescaler : Timer_Input_Capture_Prescaler; Filter : Timer_Input_Capture_Filter) with Pre => Has_At_Least_2_CC_Channels (This) and Channel in Channel_1 | Channel_2, Post => Channel_Enabled (This, Channel) and Current_Capture_Compare_Mode (This, Channel) = Selection and Current_Input_Prescaler (This, Channel) = Prescaler; procedure Set_Input_Prescaler (This : in out Timer; Channel : Timer_Channel; Value : Timer_Input_Capture_Prescaler) with Pre => not Basic_Timer (This) and Current_Capture_Compare_Mode (This, Channel) /= Output, Post => Current_Input_Prescaler (This, Channel) = Value; function Current_Input_Prescaler (This : Timer; Channel : Timer_Channel) return Timer_Input_Capture_Prescaler; function Current_Capture_Value (This : Timer; Channel : Timer_Channel) return UInt32; -- Reading the upper reserved area of the CCR register does no harm when -- the timer does not support 32-bit CC registers so we do not protect -- this function with a precondition. function Current_Capture_Value (This : Timer; Channel : Timer_Channel) return UInt16; ---------------------------------------------------------------------------- -- Advanced control timers ------------------------------------------------ ---------------------------------------------------------------------------- procedure Enable_Main_Output (This : in out Timer) with Pre => Advanced_Timer (This), Post => Main_Output_Enabled (This); procedure Disable_Main_Output (This : in out Timer) with Pre => Advanced_Timer (This), Post => (if No_Outputs_Enabled (This) then not Main_Output_Enabled (This)); function Main_Output_Enabled (This : Timer) return Boolean; procedure Configure (This : in out Timer; Prescaler : UInt16; Period : UInt32; Clock_Divisor : Timer_Clock_Divisor; Counter_Mode : Timer_Counter_Alignment_Mode; Repetitions : UInt8) with Pre => Advanced_Timer (This) and (if Period > UInt32 (UInt16'Last) then Has_32bit_Counter (This)), Post => Current_Prescaler (This) = Prescaler and Current_Autoreload (This) = Period; procedure Configure_Channel_Output (This : in out Timer; Channel : Timer_Channel; Mode : Timer_Output_Compare_And_PWM_Mode; State : Timer_Capture_Compare_State; Pulse : UInt32; Polarity : Timer_Output_Compare_Polarity; Idle_State : Timer_Capture_Compare_State; Complementary_Polarity : Timer_Output_Compare_Polarity; Complementary_Idle_State : Timer_Capture_Compare_State) with Pre => Advanced_Timer (This) and (if not Has_32bit_CC_Values (This) then Pulse <= 16#FFFF#), Post => (if State = Enable then Channel_Enabled (This, Channel) else not Channel_Enabled (This, Channel)); procedure Enable_CC_Preload_Control (This : in out Timer) with Pre => Advanced_Timer (This); procedure Disable_CC_Preload_Control (This : in out Timer) with Pre => Advanced_Timer (This); procedure Select_Commutation (This : in out Timer) with Pre => Advanced_Timer (This); procedure Deselect_Commutation (This : in out Timer) with Pre => Advanced_Timer (This); type Timer_Break_Polarity is (Low, High); type Timer_Break_Filter is (No_Filter, FCK_INT_N2, FCK_INT_N4, FCK_INT_N8, FDTS2_N6, FDTS2_N8, FDTS4_N6, FDTS4_N8, FDTS8_N6, FDTS8_N8, FDTS16_N5, FDTS16_N6, FDTS16_N8, FDTS32_N5, FDTS32_N6, FDTS32_N8); type Timer_Lock_Level is (Off, Level_1, Level_2, Level_3); procedure Configure_Break (This : in out Timer; Automatic_Output_Enabled : Boolean; Break_Polarity : Timer_Break_Polarity; Break_Enabled : Boolean; Break_Filter : Timer_Break_Filter; Off_State_Selection_Run_Mode : Bit; Off_State_Selection_Idle_Mode : Bit) with Pre => Complementary_Outputs_Supported (This); procedure Configure_Break (This : in out Timer; Automatic_Output_Enabled : Boolean; Break_Polarity : Timer_Break_Polarity; Break_Enabled : Boolean; Break_Filter : Timer_Break_Filter; Break_2_Polarity : Timer_Break_Polarity; Break_2_Enabled : Boolean; Break_2_Filter : Timer_Break_Filter; Off_State_Selection_Run_Mode : Bit; Off_State_Selection_Idle_Mode : Bit) with Pre => Advanced_Timer (This); procedure Configure_Deadtime (This : in out Timer; Time : Float) with Pre => Complementary_Outputs_Supported (This); -- Configure the DTG bit-field for timer register BDTR such that -- the requested deadtime Time is obtained. -- Please refer to STM32F4 reference manual for details. procedure Set_BDTR_Lock (This : in out Timer; Lock : Timer_Lock_Level) with Pre => Complementary_Outputs_Supported (This); -- Write protection against software errors. ---------------------------------------------------------------------------- -- Synchronization Management --------------------------------------------- ---------------------------------------------------------------------------- type Timer_Trigger_Input_Source is (Internal_Trigger_0, -- ITR0 Internal_Trigger_1, -- ITR1 Internal_Trigger_2, -- ITR2 Internal_Trigger_3, -- ITR3 TI1_Edge_Detector, -- TI1F_ED Filtered_Timer_Input_1, -- TI1FP1 Filtered_Timer_Input_2, -- TI2FP2 External_Trigger_Input, -- ETRF Internal_Trigger_4, -- ITR4 Internal_Trigger_5, -- ITR5 Internal_Trigger_6, -- ITR6 Internal_Trigger_7, -- ITR7 Internal_Trigger_8, -- ITR8 Internal_Trigger_9, -- ITR9 Internal_Trigger_10) -- ITR10 with Size => 5; -- See RM0440 for ITRx internal connections: -- TIM1, TIM8, TIM20 - table 250, pg 1090, section 28.3.2. -- TIM2, TIM3, TIM4, TIM5, TIM6, TIM7 don't have. -- TIM15, TIM16, TIM17 table 290, pg 1351, section 30.4.2. procedure Select_Input_Trigger (This : in out Timer; Source : Timer_Trigger_Input_Source) with Pre => not Basic_Timer (This); type Timer_Trigger_Output_Source is (Reset, Enable, Update, Compare_Pulse_CC1, Compare_OC1Ref, Compare_OC2Ref, Compare_OC3Ref, Compare_OC4Ref); type Timer_Trigger_Output_Source_ADC is (Reset, Enable, Update, Compare_Pulse_CC1, Compare_OC1Ref, Compare_OC2Ref, Compare_OC3Ref, Compare_OC4Ref, Compare_OC5Ref, Compare_OC6Ref, Compare_Pulse_OC4Ref_R_F, Compare_Pulse_OC6Ref_R_F, Compare_Pulse_OC4Ref_R_OC6Ref_R, Compare_Pulse_OC4Ref_R_OC6Ref_F, Compare_Pulse_OC5Ref_R_OC6Ref_R, Compare_Pulse_OC5Ref_R_OC6Ref_F); procedure Select_Output_Trigger (This : in out Timer; Source : Timer_Trigger_Output_Source) with Pre => Trigger_Output_Selectable (This); -- any of Timer 1 .. 8 type Timer_Slave_Mode is (Disabled, Quadrature_Encoder_Mode_1, -- x2 mode, counting up/down on TI1FP1 edge depending on TI2FP2 -- level. Quadrature_Encoder_Mode_2, -- x2 mode, counting up/down on TI2FP2 edge depending on TI1FP1 -- level. Quadrature_Encoder_Mode_3, -- x4 mode, counting up/down on both TI1FP1 & TI2FP2 edges depending -- on the level of the other input. Reset, -- Counter reinitialize and update registers on TRGI rising edge. Gated, -- Counter is enabled when TRGI is high and stops when low without reset. Trigger, -- Counter starts at TRGI trigger rising edge. External_1, -- Counter clocked by TRGI rising edges. Combined_Reset_Trigger, -- Counter reinitialize, update registers and start the counter on TRGI. Combined_Reset_Gated, -- Counter reinitialize, update registers and start the counter on TRGI. Encoder_Mode_1, -- Clock plus direction, x2 mode. Encoder_Mode_2, -- Clock plus direction, x1 mode, TI2FP2 edge sensitivity is set by CC2P. Encoder_Mode_3, -- Directional clock, x2 mode. Encoder_Mode_4, -- Directional clock, x1 mode, TI1FP1 and TI2FP2 edge sensitivity is -- set by CC1P and CC2P. Quadrature_Encoder_Mode_4, -- x1 mode, counting on TI1FP1 edges only, edge sensitivity is set by CC1P. Quadrature_Encoder_Mode_5) -- x1 mode, counting on TI2FP2 edges only, edge sensitivity is set by CC2P. with Size => 4; procedure Select_Slave_Mode (This : in out Timer; Mode : Timer_Slave_Mode) with Pre => Slave_Mode_Supported (This); procedure Enable_Master_Slave_Mode (This : in out Timer) with Pre => Slave_Mode_Supported (This); procedure Disable_Master_Slave_Mode (This : in out Timer) with Pre => Slave_Mode_Supported (This); type Timer_External_Trigger_Polarity is (NonInverted, Inverted); type Timer_External_Trigger_Prescaler is (Off, Div_2, Div_4, Div_8); type Timer_External_Trigger_Filter is (No_Filter, FCK_INT_N2, FCK_INT_N4, FCK_INT_N8, FDTS2_N6, FDTS2_N8, FDTS4_N6, FDTS4_N8, FDTS8_N6, FDTS8_N8, FDTS16_N5, FDTS16_N6, FDTS16_N8, FDTS32_N5, FDTS32_N6, FDTS32_N8); procedure Configure_External_Trigger (This : in out Timer; Polarity : Timer_External_Trigger_Polarity; Prescaler : Timer_External_Trigger_Prescaler; Filter : Timer_External_Trigger_Filter) with Pre => External_Trigger_Supported (This); ---------------------------------------------------------------------------- -- Clocks Management ------------------------------------------------------ ---------------------------------------------------------------------------- procedure Select_Internal_Clock (This : in out Timer) renames Disable_Master_Slave_Mode; subtype Timer_Internal_Trigger_Source is Timer_Trigger_Input_Source range Internal_Trigger_0 .. Internal_Trigger_3; procedure Configure_As_External_Clock (This : in out Timer; Source : Timer_Internal_Trigger_Source) with Pre => Clock_Management_Supported (This); subtype Timer_External_Clock_Source is Timer_Trigger_Input_Source range TI1_Edge_Detector .. Filtered_Timer_Input_2; procedure Configure_As_External_Clock (This : in out Timer; Source : Timer_External_Clock_Source; Polarity : Timer_Input_Capture_Polarity; Filter : Timer_Input_Capture_Filter) with Pre => not Basic_Timer (This); procedure Configure_External_Clock_Mode1 (This : in out Timer; Polarity : Timer_External_Trigger_Polarity; Prescaler : Timer_External_Trigger_Prescaler; Filter : Timer_External_Trigger_Filter) with Pre => External_Trigger_Supported (This); procedure Configure_External_Clock_Mode2 (This : in out Timer; Polarity : Timer_External_Trigger_Polarity; Prescaler : Timer_External_Trigger_Prescaler; Filter : Timer_External_Trigger_Filter) with Pre => External_Trigger_Supported (This); ---------------------------------------------------------------------------- -- Misc functions --------------------------------------------------------- ---------------------------------------------------------------------------- type Timer_Encoder_Mode is -- subtype of Timer_Slave_Mode (Quadrature_Encoder_Mode_1, -- x2 mode, counting up/down on TI1FP1 edge depending on TI2FP2 -- level. Quadrature_Encoder_Mode_2, -- x2 mode, counting up/down on TI2FP2 edge depending on TI1FP1 -- level. Quadrature_Encoder_Mode_3, -- x4 mode, counting up/down on both TI1FP1 & TI2FP2 edges depending -- on the level of the other input. Encoder_Mode_1, -- Clock plus direction, x2 mode. Encoder_Mode_2, -- Clock plus direction, x1 mode, TI2FP2 edge sensitivity is set by CC2P. Encoder_Mode_3, -- Directional clock, x2 mode. Encoder_Mode_4, -- Directional clock, x1 mode, TI1FP1 and TI2FP2 edge sensitivity is -- set by CC1P and CC2P. Quadrature_Encoder_Mode_4, -- x1 mode, counting on TI1FP1 edges only, edge sensitivity is set by CC1P. Quadrature_Encoder_Mode_5) -- x1 mode, counting on TI2FP2 edges only, edge sensitivity is set by CC2P. with Size => 4; for Timer_Encoder_Mode use (Quadrature_Encoder_Mode_1 => 2#0001#, Quadrature_Encoder_Mode_2 => 2#0010#, Quadrature_Encoder_Mode_3 => 2#0011#, Encoder_Mode_1 => 2#1010#, Encoder_Mode_2 => 2#1011#, Encoder_Mode_3 => 2#1100#, Encoder_Mode_4 => 2#1101#, Quadrature_Encoder_Mode_4 => 2#1110#, Quadrature_Encoder_Mode_5 => 2#1111#); procedure Configure_Encoder_Interface (This : in out Timer; Mode : Timer_Encoder_Mode; IC1_Polarity : Timer_Input_Capture_Polarity; IC2_Polarity : Timer_Input_Capture_Polarity) with Pre => Has_At_Least_2_CC_Channels (This); procedure Enable_Hall_Sensor (This : in out Timer) with Pre => Hall_Sensor_Supported (This); procedure Disable_Hall_Sensor (This : in out Timer) with Pre => Hall_Sensor_Supported (This); type UIF_Remapping_State is (Disable, Enable); -- See RM pg. 443 ---------------------------------------------------------------------------- -- Classifier functions --------------------------------------------------- ---------------------------------------------------------------------------- -- Timers 6 and 7 function Basic_Timer (This : Timer) return Boolean is (This'Address = STM32_SVD.TIM6_Base or This'Address = STM32_SVD.TIM7_Base); -- Timer 1, 8 and 20 function Advanced_Timer (This : Timer) return Boolean is (This'Address = STM32_SVD.TIM1_Base or This'Address = STM32_SVD.TIM8_Base or This'Address = STM32_SVD.TIM20_Base); -- Timer 2 and 5 function Has_32bit_Counter (This : Timer) return Boolean is (This'Address = STM32_SVD.TIM2_Base or This'Address = STM32_SVD.TIM5_Base); -- The RM0440 section 29.5.13 pg 1327, indicates that timer 2 and 5 -- actually have the upper half of the counter available, and that the -- others must keep it reserved. This would appear to confirm the text -- in the introduction to timers 2, 3, 4 and 5 in the section 29.3. -- Timer 2 and 5 function Has_32bit_CC_Values (This : Timer) return Boolean renames Has_32bit_Counter; -- Timers 1 .. 5, 8, 15, 20 function Clock_Management_Supported (This : Timer) return Boolean is (This'Address = STM32_SVD.TIM1_Base or This'Address = STM32_SVD.TIM2_Base or This'Address = STM32_SVD.TIM3_Base or This'Address = STM32_SVD.TIM4_Base or This'Address = STM32_SVD.TIM5_Base or This'Address = STM32_SVD.TIM8_Base or This'Address = STM32_SVD.TIM15_Base or This'Address = STM32_SVD.TIM20_Base); -- Timers 1 .. 3, 15 function Has_At_Least_2_CC_Channels (This : Timer) return Boolean is (This'Address = STM32_SVD.TIM1_Base or This'Address = STM32_SVD.TIM2_Base or This'Address = STM32_SVD.TIM3_Base or This'Address = STM32_SVD.TIM15_Base); -- Timers 1 .. 5, 8 and 20 function Has_At_Least_3_CC_Channels (This : Timer) return Boolean is (This'Address = STM32_SVD.TIM1_Base or This'Address = STM32_SVD.TIM2_Base or This'Address = STM32_SVD.TIM3_Base or This'Address = STM32_SVD.TIM4_Base or This'Address = STM32_SVD.TIM5_Base or This'Address = STM32_SVD.TIM8_Base or This'Address = STM32_SVD.TIM20_Base); -- Timers 1 .. 5, 8 and 20 function Has_At_Least_4_CC_Channels (This : Timer) return Boolean renames Has_At_Least_3_CC_Channels; -- Timers 1, 8 and 20 function Has_At_Least_5_CC_Channels (This : Timer) return Boolean is (This'Address = STM32_SVD.TIM1_Base or This'Address = STM32_SVD.TIM8_Base or This'Address = STM32_SVD.TIM20_Base); -- Timers 1, 8 and 20 function Has_At_Least_6_CC_Channels (This : Timer) return Boolean renames Has_At_Least_5_CC_Channels; -- Not all timers have four channels available for capture/compare function CC_Channel_Exists (This : Timer; Channel : Timer_Channel) return Boolean is ((if Channel = Channel_1 then not Basic_Timer (This)) or (if Channel = Channel_2 then Has_At_Least_2_CC_Channels (This)) or (if Channel = Channel_3 then Has_At_Least_3_CC_Channels (This)) or (if Channel = Channel_4 then Has_At_Least_4_CC_Channels (This)) or (if Channel = Channel_5 then Has_At_Least_5_CC_Channels (This)) or (if Channel = Channel_6 then Has_At_Least_6_CC_Channels (This))); -- Timers 1 .. 5, 8 and 20 function Hall_Sensor_Supported (This : Timer) return Boolean is (This'Address = STM32_SVD.TIM1_Base or This'Address = STM32_SVD.TIM2_Base or This'Address = STM32_SVD.TIM3_Base or This'Address = STM32_SVD.TIM4_Base or This'Address = STM32_SVD.TIM5_Base or This'Address = STM32_SVD.TIM8_Base or This'Address = STM32_SVD.TIM20_Base); -- Timers 1 .. 5, 8, 15 and 20 function Input_XOR_Supported (This : Timer) return Boolean is (This'Address = STM32_SVD.TIM1_Base or This'Address = STM32_SVD.TIM2_Base or This'Address = STM32_SVD.TIM3_Base or This'Address = STM32_SVD.TIM4_Base or This'Address = STM32_SVD.TIM5_Base or This'Address = STM32_SVD.TIM8_Base or This'Address = STM32_SVD.TIM15_Base or This'Address = STM32_SVD.TIM20_Base); -- Timers 1 .. 5, 6, 7, 8, 15 ..17, 20 function DMA_Supported (This : Timer) return Boolean is (This'Address = STM32_SVD.TIM1_Base or This'Address = STM32_SVD.TIM2_Base or This'Address = STM32_SVD.TIM3_Base or This'Address = STM32_SVD.TIM4_Base or This'Address = STM32_SVD.TIM5_Base or This'Address = STM32_SVD.TIM6_Base or This'Address = STM32_SVD.TIM7_Base or This'Address = STM32_SVD.TIM8_Base or This'Address = STM32_SVD.TIM15_Base or This'Address = STM32_SVD.TIM16_Base or This'Address = STM32_SVD.TIM17_Base or This'Address = STM32_SVD.TIM20_Base); -- Timers 1 .. 5, 8, 15, 20 function Slave_Mode_Supported (This : Timer) return Boolean is (This'Address = STM32_SVD.TIM1_Base or This'Address = STM32_SVD.TIM2_Base or This'Address = STM32_SVD.TIM3_Base or This'Address = STM32_SVD.TIM4_Base or This'Address = STM32_SVD.TIM5_Base or This'Address = STM32_SVD.TIM8_Base or This'Address = STM32_SVD.TIM15_Base or This'Address = STM32_SVD.TIM20_Base); -- Timers 1 .. 5, 8, 15, 20 function Trigger_Output_Selectable (This : Timer) return Boolean is (This'Address = STM32_SVD.TIM1_Base or This'Address = STM32_SVD.TIM2_Base or This'Address = STM32_SVD.TIM3_Base or This'Address = STM32_SVD.TIM4_Base or This'Address = STM32_SVD.TIM5_Base or This'Address = STM32_SVD.TIM8_Base or This'Address = STM32_SVD.TIM15_Base or This'Address = STM32_SVD.TIM20_Base); -- Timers 1 .. 5, 8, 15, 20 function External_Trigger_Supported (This : Timer) return Boolean is (This'Address = STM32_SVD.TIM1_Base or This'Address = STM32_SVD.TIM2_Base or This'Address = STM32_SVD.TIM3_Base or This'Address = STM32_SVD.TIM4_Base or This'Address = STM32_SVD.TIM5_Base or This'Address = STM32_SVD.TIM8_Base or This'Address = STM32_SVD.TIM15_Base or This'Address = STM32_SVD.TIM20_Base); -- Timers 1 .. 8, 15 .. 17, 20 function Remapping_Capability_Supported (This : Timer) return Boolean is (This'Address = STM32_SVD.TIM1_Base or This'Address = STM32_SVD.TIM2_Base or This'Address = STM32_SVD.TIM3_Base or This'Address = STM32_SVD.TIM4_Base or This'Address = STM32_SVD.TIM5_Base or This'Address = STM32_SVD.TIM6_Base or This'Address = STM32_SVD.TIM7_Base or This'Address = STM32_SVD.TIM8_Base or This'Address = STM32_SVD.TIM15_Base or This'Address = STM32_SVD.TIM16_Base or This'Address = STM32_SVD.TIM17_Base or This'Address = STM32_SVD.TIM20_Base); -- Not all timers support output on all channels function Specific_Channel_Output_Supported (This : Timer; Channel : Timer_Channel) return Boolean is (This'Address = STM32_SVD.TIM1_Base or This'Address = STM32_SVD.TIM8_Base or This'Address = STM32_SVD.TIM20_Base -- all the above can be with any six channels or ((This'Address = STM32_SVD.TIM2_Base or This'Address = STM32_SVD.TIM3_Base or This'Address = STM32_SVD.TIM4_Base or This'Address = STM32_SVD.TIM5_Base) and Channel in Channel_1 | Channel_2 | Channel_3 | Channel_4) -- all the above can be with any four channels or (This'Address = STM32_SVD.TIM15_Base and Channel in Channel_1 | Channel_2) or ((This'Address = STM32_SVD.TIM16_Base or This'Address = STM32_SVD.TIM17_Base) and Channel = Channel_1)); -- Timer 1, 15, 16, 17 function Complementary_Outputs_Supported (This : Timer) return Boolean is (This'Address = STM32_SVD.TIM1_Base or This'Address = STM32_SVD.TIM8_Base or This'Address = STM32_SVD.TIM15_Base or This'Address = STM32_SVD.TIM16_Base or This'Address = STM32_SVD.TIM17_Base or This'Address = STM32_SVD.TIM20_Base); -- Timer 1, 8, 20 channels 1 .. 4, timers 15 .. 17 channel 1 function Complementary_Outputs_Supported (This : Timer; Channel : Timer_Channel) return Boolean is (((This'Address = STM32_SVD.TIM1_Base or This'Address = STM32_SVD.TIM8_Base or This'Address = STM32_SVD.TIM20_Base) and Channel in Channel_1 | Channel_2 | Channel_3 | Channel_4) or ((This'Address = STM32_SVD.TIM15_Base or This'Address = STM32_SVD.TIM16_Base or This'Address = STM32_SVD.TIM17_Base) and Channel = Channel_1)); private type TIMx_CR1 is record Reserved0 : UInt3; Dithering_Enable : Boolean; UIFREMAP : UIF_Remapping_State; Reserved1 : Bit; Clock_Division : Timer_Clock_Divisor; ARPE : Boolean; -- Auto-reload preload enable Mode_And_Dir : Timer_Counter_Alignment_Mode; One_Pulse_Mode : Timer_One_Pulse_Mode; Update_Request_Source : Boolean; Update_Disable : Boolean; Timer_Enabled : Boolean; end record with Volatile_Full_Access, Size => 32; for TIMx_CR1 use record Reserved0 at 0 range 13 .. 15; Dithering_Enable at 0 range 12 .. 12; UIFREMAP at 0 range 11 .. 11; Reserved1 at 0 range 10 .. 10; Clock_Division at 0 range 8 .. 9; ARPE at 0 range 7 .. 7; Mode_And_Dir at 0 range 4 .. 6; One_Pulse_Mode at 0 range 3 .. 3; Update_Request_Source at 0 range 2 .. 2; Update_Disable at 0 range 1 .. 1; Timer_Enabled at 0 range 0 .. 0; end record; ------------------------ representation for CR2 -------------------------- type TIMx_CR2 is record Reserved0 : UInt8; Master_Mode_Selection_2 : Timer_Trigger_Output_Source_ADC; Reserved1 : Bit; Channel_6_Output_Idle_State : Timer_Capture_Compare_State; Reserved2 : Bit; Channel_5_Output_Idle_State : Timer_Capture_Compare_State; Reserved3 : Bit; Channel_4_Output_Idle_State : Timer_Capture_Compare_State; Channel_3_Complementary_Output_Idle_State : Timer_Capture_Compare_State; Channel_3_Output_Idle_State : Timer_Capture_Compare_State; Channel_2_Complementary_Output_Idle_State : Timer_Capture_Compare_State; Channel_2_Output_Idle_State : Timer_Capture_Compare_State; Channel_1_Complementary_Output_Idle_State : Timer_Capture_Compare_State; Channel_1_Output_Idle_State : Timer_Capture_Compare_State; TI1_Selection : Boolean; Master_Mode_Selection : Timer_Trigger_Output_Source; Capture_Compare_DMA_Selection : Boolean; Capture_Compare_Control_Update_Selection : Boolean; Reserved4 : Bit; Capture_Compare_Preloaded_Control : Boolean; end record with Volatile_Full_Access, Size => 32; for TIMx_CR2 use record Reserved0 at 0 range 24 .. 31; Master_Mode_Selection_2 at 0 range 20 .. 23; Reserved1 at 0 range 19 .. 19; Channel_6_Output_Idle_State at 0 range 18 .. 18; Reserved2 at 0 range 17 .. 17; Channel_5_Output_Idle_State at 0 range 16 .. 16; Reserved3 at 0 range 15 .. 15; Channel_4_Output_Idle_State at 0 range 14 .. 14; Channel_3_Complementary_Output_Idle_State at 0 range 13 .. 13; Channel_3_Output_Idle_State at 0 range 12 .. 12; Channel_2_Complementary_Output_Idle_State at 0 range 11 .. 11; Channel_2_Output_Idle_State at 0 range 10 .. 10; Channel_1_Complementary_Output_Idle_State at 0 range 9 .. 9; Channel_1_Output_Idle_State at 0 range 8 .. 8; TI1_Selection at 0 range 7 .. 7; Master_Mode_Selection at 0 range 4 .. 6; Capture_Compare_DMA_Selection at 0 range 3 .. 3; Capture_Compare_Control_Update_Selection at 0 range 2 .. 2; Reserved4 at 0 range 1 .. 1; Capture_Compare_Preloaded_Control at 0 range 0 .. 0; end record; ------------ representation for slave mode control register -------------- type TIMx_SMCR is record Reserved0 : UInt6; SMS_Preload_Source : Boolean; SMS_Preload_Enable : Boolean; Reserved1 : UInt2; Trigger_Selection_1 : UInt2; -- Timer_External_Trigger_Filter Reserved2 : UInt3; Slave_Mode_Selection_2 : Boolean; -- Timer_Slave_Mode External_Trigger_Polarity : Timer_External_Trigger_Polarity; External_Clock_Enable : Boolean; External_Trigger_Prescaler : Timer_External_Trigger_Prescaler; External_Trigger_Filter : Timer_External_Trigger_Filter; Master_Slave_Mode : Boolean; Trigger_Selection : UInt3; -- Timer_External_Trigger_Filter OCREF_Clear_Selection : Boolean; Slave_Mode_Selection : UInt3; -- Timer_Slave_Mode end record with Volatile_Full_Access, Size => 32; for TIMx_SMCR use record Reserved0 at 0 range 26 .. 31; SMS_Preload_Source at 0 range 25 .. 25; SMS_Preload_Enable at 0 range 24 .. 24; Reserved1 at 0 range 22 .. 23; Trigger_Selection_1 at 0 range 20 .. 21; Reserved2 at 0 range 17 .. 19; Slave_Mode_Selection_2 at 0 range 16 .. 16; External_Trigger_Polarity at 0 range 15 .. 15; External_Clock_Enable at 0 range 14 .. 14; External_Trigger_Prescaler at 0 range 12 .. 13; External_Trigger_Filter at 0 range 8 .. 11; Master_Slave_Mode at 0 range 7 .. 7; Trigger_Selection at 0 range 4 .. 6; OCREF_Clear_Selection at 0 range 3 .. 3; Slave_Mode_Selection at 0 range 0 .. 2; end record; ------------ representation for CCMR1 and CCMR2 -------------------------- -- Per the ST Reference Manual, there are two words (registers) -- allocated within a timer to describe the capture-compare input/output -- configurations for the four channels. These are CCMR1 and CCMR2. Both -- currently only use the lower half of the word, with the upper half -- reserved. -- Each description is either that of a single input or a single output -- for the given channel. Both kinds of description require eight -- bits, therefore there are two channel descriptions in each word. -- Although both the input and output descriptions are the same size in -- terms of bits (eight bits each), they do not have the same logical fields. -- We use two distinct types to represent individual input and output -- descriptions. type Lower_Channel_Output_Descriptor is record OCxClear_Enable : Boolean; OCxMode : UInt3; OCxPreload_Enable : Boolean; OCxFast_Enable : Boolean; end record with Size => 6; for Lower_Channel_Output_Descriptor use record OCxClear_Enable at 0 range 5 .. 5; OCxMode at 0 range 2 .. 4; OCxPreload_Enable at 0 range 1 .. 1; OCxFast_Enable at 0 range 0 .. 0; end record; type Higher_Channel_Output_Descriptor is record OCxMode_3 : Boolean; end record with Size => 1; for Higher_Channel_Output_Descriptor use record OCxMode_3 at 0 range 0 .. 0; end record; type Lower_Channel_Input_Descriptor is record ICxFilter : Timer_Input_Capture_Filter; ICxPrescaler : Timer_Input_Capture_Prescaler; end record with Size => 6; for Lower_Channel_Input_Descriptor use record ICxFilter at 0 range 2 .. 5; ICxPrescaler at 0 range 0 .. 1; end record; -- So any given sixteen-bit description uses seven bits for the specific fields -- describing the input or output configuration. The other two bits are -- taken by a field selecting the kind of description, i.e., either an -- input or an output description. In the RM register definitions this -- is "CCxS" (where 'x' is a place-holder for a channel number). Although -- there is one kind of output, there are in fact three kinds of inputs. -- Thus any given channel description is a sixtenn-bit quantity that -- both indicates the kind and contains another set of dependent fields -- representing that kind. The dependent fields are logically mutually -- exclusive, i.e., if the CCxS selection field indicates an input then -- the output fields are not present, and vice versa. This logical layout -- is naturally represented in Ada as a discriminated type, where the -- discriminant is the CCxS "Selection" indicator. -- Note that the discriminant default value "Output" matches the default -- value of the hardware register bits when the device is powered up. -- Therefore we don't strictly speaking need pragma Import on the -- declarations of Timer objects, but it won't hurt. type Lower_IO_Descriptor (CCxSelection : Timer_Capture_Compare_Modes := Output) is record case CCxSelection is when Direct_TI .. TRC => Capture : Lower_Channel_Input_Descriptor; when Output => Compare_1 : Lower_Channel_Output_Descriptor; end case; end record with Size => 8; -- Per the RM, the input fields and the output fields are in the same -- locations in memory, that is, they overlay, coming after the common -- CCxS field. for Lower_IO_Descriptor use record Capture at 0 range 2 .. 7; Compare_1 at 0 range 2 .. 7; CCxSelection at 0 range 0 .. 1; end record; type Higher_IO_Descriptor (CCxSelection : Timer_Capture_Compare_Modes := Output) is record case CCxSelection is when Direct_TI .. TRC => Reserved : UInt6; when Output => Compare_2 : Higher_Channel_Output_Descriptor; end case; end record with Size => 8; for Higher_IO_Descriptor use record CCxSelection at 0 range 6 .. 7; Reserved at 0 range 0 .. 5; Compare_2 at 0 range 0 .. 0; end record; -- Thus we have a means of describing any single channel's configuration -- as either an input or an output. But how to get to them? As mentioned -- above, there are four channels so there are four I/O descriptions, -- spread across the two words of CCMR1 and CCMR2 in the timer -- representation. Specifically, the descriptions for channels 1 and 2 are -- in CCMR1, and the descriptions for channels 3 and 4 are in CCMR2. Rather -- than determine which register to use by having a dedicated routine -- for each channel, we use an array of descriptions allocated across the -- memory for the two registers and compute the description to use within -- the array for that channel. -- -- The remaining difficulty is the reserved upper halves of each of the -- two registers in memory. We cannot simply allocate four components in -- our array because we must skip the reserved areas, but we don't have -- non-contiguous arrays in Ada (nor should we). As a result we must -- either declare two arrays, each with two descriptions, thus requiring -- additional types to specify the reserved areas, or we declare one -- array of eight descriptions and only access the four "real" ones. If we -- take the latter approach the other four descriptions would occupy the -- reserved areas and would never be accessed. As long as the reserved -- areas remain at their reset values (all zeroes) all should be well... -- except that we also have the requirement to access the memory for the -- two registers as either half-words or words, so any simplicity gained -- from declaring an array larger than required would be lost when -- processing it. Hence the following takes the first approach, not -- mapping anything to the reserved upper halves of the two words. subtype Half_Index is Integer range 1 .. 2; -- Register CCMRx from bits 0 - 7 and 16 - 23 or -- from bits 8 - 15 and 24 - 31 type TIMx_CCMRx_Lower_Half is array (Half_Index) of Lower_IO_Descriptor with Volatile_Components, Component_Size => 8, Size => 16; type TIMx_CCMRx_Higher_Half is array (Half_Index) of Higher_IO_Descriptor with Volatile_Components, Component_Size => 8, Size => 16; type TIMx_CCMRx is record High_Descriptors : TIMx_CCMRx_Higher_Half; Low_Descriptors : TIMx_CCMRx_Lower_Half; end record with Volatile_Full_Access, Size => 32; for TIMx_CCMRx use record High_Descriptors at 0 range 16 .. 31; Low_Descriptors at 0 range 0 .. 15; end record; -- Then we can define the array of this final record type TIMx_CCMRx, -- taking the space of the two CCMR1 and CCMR2 register words in memory. subtype CCMRx_Index is Integer range 1 .. 3; -- Is this better than using bit masks? There's certainly a good bit more -- required for the declarations of the data structure! But the access code -- is pretty small and we would argue that the compile-time checking, and -- the readability, imply greater robustness and maintainability. (That -- said, the existing C libraries are very stable and mature.) This part -- of the hardware is definitely complicated in itself, and overlaying the -- input and output descriptions in memory didn't help. Performance should -- be reasonable, although not as good as bit-masking would be. Nowadays -- that's not necessarily where the money is, so we go with this approach -- for now... procedure Write_Channel_Input_Description (This : in out Timer; Channel : Timer_Channel; Kind : Timer_Input_Capture_Selection; Description : Lower_Channel_Input_Descriptor) with Pre => not Channel_Enabled (This, Channel); ------------ representation for the CCER --------------------------------- -- The CCER register is composed of a logical grouping of four sets of -- bits, one per channel. The type Single_CCE describe these four bits. -- Channels 1 through 4 have all four bits, channels 5 and 6 don't have the -- complementary enable and polarity bits. We pretend that it does for -- the type declaration and then treat it accordingly in the accessing -- subprograms. type Single_CCE is record CCxE : Timer_Capture_Compare_State; CCxP : Bit; CCxNE : Timer_Capture_Compare_State; CCxNP : Bit; end record with Size => 4; for Single_CCE use record CCxE at 0 range 0 .. 0; CCxP at 0 range 1 .. 1; CCxNE at 0 range 2 .. 2; CCxNP at 0 range 3 .. 3; end record; type TIMx_CCER is array (Timer_Channel'Range) of Single_CCE with Volatile_Full_Access, Component_Size => 4, Size => 24; -------- representation for CCR1 through CCR4 ---------------------------- -- Instead of declaring four individual record components, one per channel, -- each one a word in size, we just declare an array component representing -- all four values, indexed by the channel. Timers 2 and 5 actually use all -- 32 bits of each, the other timers only use the lower half. type Capture_Compare_Registers is array (Channel_1 .. Channel_4) of UInt32 with Volatile_Components, Component_Size => 32, Size => 128; ---------- representation for the Break and Dead Time Register - ---------- type TIMx_BDTR is record Reserved : UInt2; Break_2_Bidirectional : Boolean; Break_Bidirectional : Boolean; Break_2_Disarm : Boolean; Break_Disarm : Boolean; Break_2_Polarity : Timer_Break_Polarity; Break_2_Enable : Boolean; Break_2_Filter : Timer_Break_Filter; Break_Filter : Timer_Break_Filter; Main_Output_Enabled : Boolean; Automatic_Output_Enabled : Boolean; Break_Polarity : Timer_Break_Polarity; Break_Enable : Boolean; Off_State_Selection_Run_Mode : Bit; Off_State_Selection_Idle_Mode : Bit; Lock : Timer_Lock_Level; Deadtime_Generator : UInt8; end record with Volatile_Full_Access, Size => 32; for TIMx_BDTR use record Reserved at 0 range 30 .. 31; Break_2_Bidirectional at 0 range 29 .. 29; Break_Bidirectional at 0 range 28 .. 28; Break_2_Disarm at 0 range 27 .. 27; Break_Disarm at 0 range 26 .. 26; Break_2_Polarity at 0 range 25 .. 25; Break_2_Enable at 0 range 24 .. 24; Break_2_Filter at 0 range 20 .. 23; Break_Filter at 0 range 16 .. 19; Main_Output_Enabled at 0 range 15 .. 15; Automatic_Output_Enabled at 0 range 14 .. 14; Break_Polarity at 0 range 13 .. 13; Break_Enable at 0 range 12 .. 12; Off_State_Selection_Run_Mode at 0 range 11 .. 11; Off_State_Selection_Idle_Mode at 0 range 10 .. 10; Lock at 0 range 8 .. 9; Deadtime_Generator at 0 range 0 .. 7; end record; ----------- representation for the DMA Control Register type ------------- type TIMx_DCR is record Reserved0 : UInt16; Reserved1 : UInt3; Burst_Length : Timer_DMA_Burst_Length; Reserved2 : UInt3; Base_Address : Timer_DMA_Base_Address; end record with Volatile_Full_Access, Size => 32; for TIMx_DCR use record Reserved0 at 0 range 16 .. 31; Reserved1 at 0 range 13 .. 15; Burst_Length at 0 range 8 .. 12; Reserved2 at 0 range 5 .. 7; Base_Address at 0 range 0 .. 4; end record; ---------------- representation for the whole Timer type ----------------- type Timer is limited record CR1 : TIMx_CR1; CR2 : TIMx_CR2; SMCR : TIMx_SMCR; DIER : UInt32; SR : UInt32; EGR : UInt32; CCMR1 : TIMx_CCMRx; CCMR2 : TIMx_CCMRx; CCER : TIMx_CCER; Counter : UInt32 with Atomic; -- a full word for timer 2 Prescaler : UInt16; Reserved_Prescaler : UInt16; ARR : UInt32; RCR : UInt32; CCR1_4 : Capture_Compare_Registers; BDTR : TIMx_BDTR; CCR5 : UInt32; CCR6 : UInt32; CCMR3 : TIMx_CCMRx; DTR2 : UInt32; ECR : UInt32; TISEL : UInt32; AF1 : UInt32; AF2 : UInt32; DCR : TIMx_DCR; DMAR : UInt32; end record with Volatile, Size => 249 * 32; for Timer use record CR1 at 16#000# range 0 .. 31; CR2 at 16#004# range 0 .. 31; SMCR at 16#008# range 0 .. 31; DIER at 16#00C# range 0 .. 31; SR at 16#010# range 0 .. 31; EGR at 16#014# range 0 .. 31; CCMR1 at 16#018# range 0 .. 31; CCMR2 at 16#01C# range 0 .. 31; CCER at 16#020# range 0 .. 31; Counter at 16#024# range 0 .. 31; Prescaler at 16#028# range 0 .. 15; Reserved_Prescaler at 16#028# range 16 .. 31; ARR at 16#02C# range 0 .. 31; RCR at 16#030# range 0 .. 31; CCR1_4 at 16#034# range 0 .. 127; -- ie, 4 words BDTR at 16#044# range 0 .. 31; CCR5 at 16#048# range 0 .. 31; CCR6 at 16#04C# range 0 .. 31; CCMR3 at 16#050# range 0 .. 31; DTR2 at 16#054# range 0 .. 31; ECR at 16#058# range 0 .. 31; TISEL at 16#05C# range 0 .. 31; AF1 at 16#060# range 0 .. 31; AF2 at 16#064# range 0 .. 31; DCR at 16#3DC# range 0 .. 31; DMAR at 16#3E0# range 0 .. 31; end record; end STM32.Timers;
29,689
ada
0
charlesincharge/Intro_to_Ada
prime.adb
-- Taken from Ada Crash Course by <NAME>) -- Context clause specifies packages that will be used. -- `use` includes that package in the namespace with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; -- Our main function is "Prime" procedure Prime is -- Declare local variables here Num : Integer; -- Type comes after the name begin Put("Enter an integer: "); Get(Num); -- Retrieve the input into Num. if Num < 2 then Put("The value "); Put(Num, 0); Put_Line(" is bad."); else Put("The value "); Put(Num, 0); -- For loop syntax similar to Python range -- Requires reverse loop for decrementing for idx in 2 .. (Num - 1) loop -- rem is % in C. Single `=` to test for equality -- Assignment uses := if Num rem idx = 0 then Put_Line(" is not prime."); return; end if; exit when (idx * idx > Num); -- Break early when we've hit all possible factors. end loop; Put_Line(" is prime."); end if; end Prime;
29,690
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/env_compile_capacity.adb
<reponame>best08618/asylo -- { dg-do compile } with My_Env_Versioned_Value_Set_G; package body Env_Compile_Capacity is generic with package Env_Obj_Set_Instance is new My_Env_Versioned_Value_Set_G(<>); with function Updated_Entity (Value : Env_Obj_Set_Instance.Value_T) return Boolean is <>; with package Entity_Upd_Iteration is new Env_Obj_Set_Instance.Update_G (Updated_Entity); procedure Compile_G; procedure Compile_G is begin null; end; package My_Env_Aerodrome is new My_Env_Versioned_Value_Set_G (Value_T => String); function Updated_Entity (Id : in String) return Boolean is begin return True; end; package Iteration_Aerodrome_Arrival is new My_Env_Aerodrome.Update_G (Updated_Entity); procedure Aerodrome_Arrival is new Compile_G (Env_Obj_Set_Instance => My_Env_Aerodrome, Updated_Entity => Updated_Entity, Entity_Upd_Iteration => Iteration_Aerodrome_Arrival); end Env_Compile_Capacity;
29,691
ada
0
reznikmm/cvsweb2git
source/cvsweb-http.adb
<filename>source/cvsweb-http.adb -- BSD 3-Clause License -- -- Copyright (c) 2017, <NAME> -- 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 copyright holder nor the names of its -- contributors may be used to endorse or promote products derived from -- this software without specific prior written permission. -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -- SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -- INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -- CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -- ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF -- THE POSSIBILITY OF SUCH DAMAGE. with Ada.Wide_Wide_Text_IO; with AWS.URL; with AWS.Response; package body CvsWeb.HTTP is --------- -- Get -- --------- not overriding procedure Get (Self : in out Connection; URL : League.Strings.Universal_String; Result : out League.Stream_Element_Vectors.Stream_Element_Vector; Success : out Boolean) is Request : constant AWS.URL.Object := AWS.URL.Parse (URL.To_UTF_8_String); Response : AWS.Response.Data; begin if not Self.Ready then AWS.Client.Create (Connection => Self.Server, Host => AWS.URL.URL (Request)); Self.Ready := True; end if; Ada.Wide_Wide_Text_IO.Put_Line (URL.To_Wide_Wide_String); AWS.Client.Get (Connection => Self.Server, Result => Response, URI => AWS.URL.Pathname_And_Parameters (Request)); Result.Clear; Result.Append (AWS.Response.Message_Body (Response)); Success := True; exception when others => Success := False; end Get; end CvsWeb.HTTP;
29,692
ada
0
fintatarta/protypo
src/Internals/protypo-match_data_wrappers.ads
with Ada.Strings.Unbounded; with Gnat.Regpat; with Protypo.Api.Engine_Values.Handlers; with Protypo.Api.Engine_Values.Engine_Value_Vectors; use Protypo.Api.Engine_Values; package Protypo.Match_Data_Wrappers is type Match_Data_Wrapper (<>) is new Handlers.Ambivalent_Interface with private; type Match_Data_Wrapper_Access is access Match_Data_Wrapper; function Wrap (Match_Data : Gnat.Regpat.Match_Array; Source : String) return Handlers.Ambivalent_Interface_Access; function Wrap (Match_Data : Gnat.Regpat.Match_Array; Source : String) return Engine_Value; function Is_Field (X : Match_Data_Wrapper; Field : Id) return Boolean; function Get (X : Match_Data_Wrapper; Field : Id) return Handler_Value; function Get (X : Match_Data_Wrapper; Index : Engine_Value_Vectors.Vector) return Handler_Value; private use Ada.Strings.Unbounded; type Submatches_Array is array (Natural range <>) of Unbounded_String; type Match_Data_Wrapper (N : Natural)is new Api.Engine_Values.Handlers.Ambivalent_Interface with record Matched : Boolean; Submatches : Submatches_Array (0 .. N); end record; end Protypo.Match_Data_Wrappers;
29,693
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/aggr19_pkg.adb
package body Aggr19_Pkg is procedure Proc (Pool : in out Rec5) is begin Pool.Ent := (Kind => Two, Node => Pool.Ent.Node, I => 0); end; end ;
29,694
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/addr8.adb
<filename>gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/addr8.adb -- { dg-do compile } package body Addr8 is procedure Proc (B: Bytes) is O: Integer; for O'Address use B'Address; begin null; end; end Addr8;
29,695
ada
12
TUM-EI-RCS/StratoX
tests/assert_cut/src/calc.ads
package calc with SPARK_Mode is procedure Forgetful_Assert (X, Y : out Integer); end calc;
29,696
ada
7
best08618/asylo
gcc-gcc-7_3_0-release/gcc/testsuite/gnat.dg/specs/formal_type.ads
-- { dg-do compile } with Ada.Strings.Bounded; package formal_type is generic with package BI is new Ada.Strings.Bounded.Generic_Bounded_Length (<>); type NB is new BI.Bounded_String; package G is end; package BI is new Ada.Strings.Bounded.Generic_Bounded_Length (30); type NB is new BI.Bounded_String; Thing : NB; package GI is new G (BI, NB); end;
29,697
ada
5
docandrew/troodon
include/bits_pthreadtypes_h.ads
pragma Ada_2012; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; with bits_struct_mutex_h; with bits_thread_shared_types_h; with bits_struct_rwlock_h; package bits_pthreadtypes_h is -- Declaration of common pthread types for all architectures. -- Copyright (C) 2017-2021 Free Software Foundation, Inc. -- This file is part of the GNU C Library. -- The GNU C Library is free software; you can redistribute it and/or -- modify it under the terms of the GNU Lesser General Public -- License as published by the Free Software Foundation; either -- version 2.1 of the License, or (at your option) any later version. -- The GNU C Library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -- Lesser General Public License for more details. -- You should have received a copy of the GNU Lesser General Public -- License along with the GNU C Library; if not, see -- <https://www.gnu.org/licenses/>. -- For internal mutex and condition variable definitions. -- Thread identifiers. The structure of the attribute type is not -- exposed on purpose. subtype pthread_t is unsigned_long; -- /usr/include/bits/pthreadtypes.h:27 -- Data structures for mutex handling. The structure of the attribute -- type is not exposed on purpose. -- skipped anonymous struct anon_8 subtype pthread_mutexattr_t_array1001 is Interfaces.C.char_array (0 .. 3); type pthread_mutexattr_t (discr : unsigned := 0) is record case discr is when 0 => uu_size : aliased pthread_mutexattr_t_array1001; -- /usr/include/bits/pthreadtypes.h:34 when others => uu_align : aliased int; -- /usr/include/bits/pthreadtypes.h:35 end case; end record with Convention => C_Pass_By_Copy, Unchecked_Union => True; -- /usr/include/bits/pthreadtypes.h:36 -- Data structure for condition variable handling. The structure of -- the attribute type is not exposed on purpose. -- skipped anonymous struct anon_9 subtype pthread_condattr_t_array1001 is Interfaces.C.char_array (0 .. 3); type pthread_condattr_t (discr : unsigned := 0) is record case discr is when 0 => uu_size : aliased pthread_condattr_t_array1001; -- /usr/include/bits/pthreadtypes.h:43 when others => uu_align : aliased int; -- /usr/include/bits/pthreadtypes.h:44 end case; end record with Convention => C_Pass_By_Copy, Unchecked_Union => True; -- /usr/include/bits/pthreadtypes.h:45 -- Keys for thread-specific data subtype pthread_key_t is unsigned; -- /usr/include/bits/pthreadtypes.h:49 -- Once-only execution subtype pthread_once_t is int; -- /usr/include/bits/pthreadtypes.h:53 subtype pthread_attr_t_array1009 is Interfaces.C.char_array (0 .. 55); type pthread_attr_t (discr : unsigned := 0) is record case discr is when 0 => uu_size : aliased pthread_attr_t_array1009; -- /usr/include/bits/pthreadtypes.h:58 when others => uu_align : aliased long; -- /usr/include/bits/pthreadtypes.h:59 end case; end record with Convention => C_Pass_By_Copy, Unchecked_Union => True; -- /usr/include/bits/pthreadtypes.h:56 -- skipped anonymous struct anon_10 subtype pthread_mutex_t_array1014 is Interfaces.C.char_array (0 .. 39); type pthread_mutex_t (discr : unsigned := 0) is record case discr is when 0 => uu_data : aliased bits_struct_mutex_h.uu_pthread_mutex_s; -- /usr/include/bits/pthreadtypes.h:69 when 1 => uu_size : aliased pthread_mutex_t_array1014; -- /usr/include/bits/pthreadtypes.h:70 when others => uu_align : aliased long; -- /usr/include/bits/pthreadtypes.h:71 end case; end record with Convention => C_Pass_By_Copy, Unchecked_Union => True; -- /usr/include/bits/pthreadtypes.h:72 -- skipped anonymous struct anon_11 subtype pthread_cond_t_array1018 is Interfaces.C.char_array (0 .. 47); type pthread_cond_t (discr : unsigned := 0) is record case discr is when 0 => uu_data : aliased bits_thread_shared_types_h.uu_pthread_cond_s; -- /usr/include/bits/pthreadtypes.h:77 when 1 => uu_size : aliased pthread_cond_t_array1018; -- /usr/include/bits/pthreadtypes.h:78 when others => uu_align : aliased Long_Long_Integer; -- /usr/include/bits/pthreadtypes.h:79 end case; end record with Convention => C_Pass_By_Copy, Unchecked_Union => True; -- /usr/include/bits/pthreadtypes.h:80 -- Data structure for reader-writer lock variable handling. The -- structure of the attribute type is deliberately not exposed. -- skipped anonymous struct anon_12 subtype pthread_rwlock_t_array1009 is Interfaces.C.char_array (0 .. 55); type pthread_rwlock_t (discr : unsigned := 0) is record case discr is when 0 => uu_data : aliased bits_struct_rwlock_h.uu_pthread_rwlock_arch_t; -- /usr/include/bits/pthreadtypes.h:88 when 1 => uu_size : aliased pthread_rwlock_t_array1009; -- /usr/include/bits/pthreadtypes.h:89 when others => uu_align : aliased long; -- /usr/include/bits/pthreadtypes.h:90 end case; end record with Convention => C_Pass_By_Copy, Unchecked_Union => True; -- /usr/include/bits/pthreadtypes.h:91 -- skipped anonymous struct anon_13 subtype pthread_rwlockattr_t_array1024 is Interfaces.C.char_array (0 .. 7); type pthread_rwlockattr_t (discr : unsigned := 0) is record case discr is when 0 => uu_size : aliased pthread_rwlockattr_t_array1024; -- /usr/include/bits/pthreadtypes.h:95 when others => uu_align : aliased long; -- /usr/include/bits/pthreadtypes.h:96 end case; end record with Convention => C_Pass_By_Copy, Unchecked_Union => True; -- /usr/include/bits/pthreadtypes.h:97 -- POSIX spinlock data type. subtype pthread_spinlock_t is int; -- /usr/include/bits/pthreadtypes.h:103 -- POSIX barriers data type. The structure of the type is -- deliberately not exposed. -- skipped anonymous struct anon_14 subtype pthread_barrier_t_array1030 is Interfaces.C.char_array (0 .. 31); type pthread_barrier_t (discr : unsigned := 0) is record case discr is when 0 => uu_size : aliased pthread_barrier_t_array1030; -- /usr/include/bits/pthreadtypes.h:110 when others => uu_align : aliased long; -- /usr/include/bits/pthreadtypes.h:111 end case; end record with Convention => C_Pass_By_Copy, Unchecked_Union => True; -- /usr/include/bits/pthreadtypes.h:112 -- skipped anonymous struct anon_15 subtype pthread_barrierattr_t_array1001 is Interfaces.C.char_array (0 .. 3); type pthread_barrierattr_t (discr : unsigned := 0) is record case discr is when 0 => uu_size : aliased pthread_barrierattr_t_array1001; -- /usr/include/bits/pthreadtypes.h:116 when others => uu_align : aliased int; -- /usr/include/bits/pthreadtypes.h:117 end case; end record with Convention => C_Pass_By_Copy, Unchecked_Union => True; -- /usr/include/bits/pthreadtypes.h:118 end bits_pthreadtypes_h;
29,698
ada
1
ekoeppen/STM32_Generic_Ada_Drivers
boards/stm32l031_rfm69/stm32gd-board.adb
with STM32_SVD; use STM32_SVD; with STM32_SVD.RCC; use STM32_SVD.RCC; with STM32_SVD.GPIO; use STM32_SVD.GPIO; with STM32_SVD.PWR; use STM32_SVD.PWR; with STM32_SVD.SCB; use STM32_SVD.SCB; with STM32_SVD.Flash; use STM32_SVD.Flash; with STM32GD.Startup; package body STM32GD.Board is procedure Init is begin Clocks.Init; RCC_Periph.APB1ENR.PWREN := 1; RCC_Periph.IOPENR.IOPAEN := 1; RCC_Periph.IOPENR.IOPBEN := 1; RCC_Periph.APB2ENR.USART1EN := 1; RCC_Periph.APB2ENR.SPI1EN := 1; -- RCC_Periph.APB2ENR.ADCEN := 1; RCC_Periph.APB1ENR.I2C1EN := 1; -- BUTTON.Init; -- LED.Init; -- LED2.Init; -- LED3.Init; TX.Init; RX.Init; -- RFM69_RESET.Init; -- SCL.Init; -- SDA.Init; CSN.Init; CSN.Set; SCLK.Init; MISO.Init; MOSI.Init; IRQ.Init; USART.Init; SPI.Init; RTC.Init; -- I2C.Init; end Init; procedure Power_Down is begin RCC_Periph.IOPENR := (Reserved_5_6 => 0, Reserved_8_31 => 0, others => 1); GPIOA_Periph.MODER.Val := 16#FFFF_FFFF#; GPIOB_Periph.MODER.Val := 16#FFFF_FFFF#; GPIOC_Periph.MODER.Val := 16#FFFF_FFFF#; GPIOD_Periph.MODER.Val := 16#FFFF_FFFF#; GPIOE_Periph.MODER.Val := 16#FFFF_FFFF#; GPIOH_Periph.MODER.Val := 16#FFFF_FFFF#; RCC_Periph.IOPENR := (Reserved_5_6 => 0, Reserved_8_31 => 0, others => 0); STM32_SVD.RCC.RCC_Periph.APB2ENR.USART1EN := 0; STM32_SVD.RCC.RCC_Periph.APB2ENR.SPI1EN := 0; STM32_SVD.RCC.RCC_Periph.APB2ENR.ADCEN := 0; STM32_SVD.RCC.RCC_Periph.APB1ENR.I2C1EN := 0; end Power_Down; procedure Power_Up is begin Init; end Power_Up; procedure Stop is begin Flash_Periph.ACR.SLEEP_PD := 1; PWR_Periph.CR.LPDS := 1; PWR_Periph.CR.PDDS := 0; PWR_Periph.CR.ULP := 1; SCB_Periph.SCR.SLEEPDEEP := 1; end Stop; end STM32GD.Board;
29,699
ada
2
kanigsson/base58
src/base.ads
<gh_stars>1-10 package Base with SPARK_Mode is type Number is array (Positive range <>) of Character; function Encode (S : String) return Number -- length of result will be longer than input, so need to guard against -- too large input. Selecting some very restricted value, we could -- probably bound this much better with Pre => S'Length < Integer'Last / 200; function Decode (N : Number) return String; end Base;