content
stringlengths
23
1.05M
with GESTE; with GESTE.Tile_Bank; with GESTE.Sprite; with GESTE_Config; use GESTE_Config; with GESTE.Maths_Types; use GESTE.Maths_Types; with GESTE.Physics; with Game_Assets; with Game_Assets.Tileset; package body Player is type Player_Type (Bank : not null GESTE.Tile_Bank.Const_Ref; Init_Frame : GESTE_Config.Tile_Index) is limited new GESTE.Physics.Object with record Sprite : aliased GESTE.Sprite.Instance (Bank, Init_Frame); end record; Tile_Bank : aliased GESTE.Tile_Bank.Instance (Game_Assets.Tileset.Tiles'Access, GESTE.No_Collisions, Game_Assets.Palette'Access); P : aliased Player_Type (Tile_Bank'Access, 79); Max_Jump_Frame : constant := 7; Jumping : Boolean := False; Do_Jump : Boolean := False; Jump_Cnt : Natural := 0; Going_Left : Boolean := False; Going_Right : Boolean := False; type Collision_Points is (BL, BR, Left, Right, TL, TR); Collides : array (Collision_Points) of Boolean; Offset : constant array (Collision_Points) of GESTE.Pix_Point := (BL => (-4, 7), BR => (4, 7), Left => (-6, 5), Right => (6, 5), TL => (-4, -7), TR => (4, -7)); Grounded : Boolean := False; procedure Update_Collisions; ----------------------- -- Update_Collisions -- ----------------------- procedure Update_Collisions is X : constant Integer := Integer (P.Position.X); Y : constant Integer := Integer (P.Position.Y); begin for Pt in Collision_Points loop Collides (Pt) := GESTE.Collides ((X + Offset (Pt).X, Y + Offset (Pt).Y)); end loop; end Update_Collisions; ---------- -- Move -- ---------- procedure Move (Pt : GESTE.Pix_Point) is begin P.Set_Position (GESTE.Maths_Types.Point'(Value (Pt.X), Value (Pt.Y))); end Move; -------------- -- Position -- -------------- function Position return GESTE.Pix_Point is ((Integer (P.Position.X), Integer (P.Position.Y))); ------------ -- Update -- ------------ procedure Update is Old : constant Point := P.Position; begin if Going_Right then P.Sprite.Flip_Vertical (False); P.Sprite.Set_Tile (Tile_Index (79 + (Integer (Old.X) / 2) mod 3)); elsif Going_Left then P.Sprite.Flip_Vertical (True); P.Sprite.Set_Tile (Tile_Index (79 + (Integer (Old.X) / 2) mod 3)); end if; if Grounded then if Going_Right then P.Apply_Force ((14_000.0, 0.0)); elsif Going_Left then P.Apply_Force ((-14_000.0, 0.0)); else -- Friction P.Apply_Force ( (Value (Value (-800.0) * P.Speed.X), 0.0)); end if; else if Going_Right then P.Apply_Force ((7_000.0, 0.0)); elsif Going_Left then P.Apply_Force ((-7_000.0, 0.0)); end if; P.Apply_Gravity (Value (-500.0)); end if; if Do_Jump then P.Apply_Force ((0.0, -20_0000.0)); Jumping := True; end if; P.Step (Value (1.0 / 60.0)); Update_Collisions; if Collides (BL) or else Collides (BR) or else Collides (TL) or else Collides (TR) then P.Set_Position ((P.Position.X, Old.Y)); P.Set_Speed ((P.Speed.X, Value (0.0))); Jump_Cnt := 0; end if; if Collides (TL) or else Collides (TR) then Jump_Cnt := Max_Jump_Frame + 1; end if; Grounded := Collides (BL) or else Collides (BR); Jumping := Jumping and not Grounded; if (P.Speed.X > Value (0.0) and then (Collides (Right) or else Collides (TR))) or else (P.Speed.X < Value (0.0) and then (Collides (Left) or else Collides (TL))) then P.Set_Position ((Old.X, P.Position.Y)); P.Set_Speed ((Value (0.0), P.Speed.Y)); end if; P.Sprite.Move ((Integer (P.Position.X) - 8, Integer (P.Position.Y) - 8)); Do_Jump := False; Going_Left := False; Going_Right := False; end Update; ---------- -- Jump -- ---------- procedure Jump is begin if Grounded or else (Jumping and then Jump_Cnt < Max_Jump_Frame) then Do_Jump := True; Jump_Cnt := Jump_Cnt + 1; end if; end Jump; --------------- -- Move_Left -- --------------- procedure Move_Left is begin Going_Left := True; end Move_Left; ---------------- -- Move_Right -- ---------------- procedure Move_Right is begin Going_Right := True; end Move_Right; begin P.Set_Mass (Value (90.0)); GESTE.Add (P.Sprite'Access, 3); end Player;
-- -- -- package Object Copyright (c) Dmitry A. Kazakov -- -- Interface Luebeck -- -- Winter, 2002 -- -- -- -- Last revision : 10:32 11 May 2019 -- -- -- -- 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. -- --____________________________________________________________________-- -- -- The package Object provides the type Entity serving as the base type -- for all derived types which require a garbage collection and handles -- (see the child package Object.Handle). The type Entity is derived -- from Ada.Finalization.Limited_Controlled. -- with Ada.Finalization; package Object is -- -- Entity -- The abstract base of all reference counted objects. Though -- the component Use_Count is exposed, it shall never be -- updated directly. -- type Entity is new Ada.Finalization.Limited_Controlled with record Use_Count : Natural := 0; -- Reference count end record; type Entity_Ptr is access all Entity'Class; -- -- Decrement_Count -- Decrement object's use count -- -- Object - The object -- Use_Count - The new use count value -- -- This procedure can be overridden in order to provide additional -- semantics of decrementing object reference count. -- -- Exceptions : -- -- Program_Error - Use count is zero -- procedure Decrement_Count ( Object : in out Entity; Use_Count : out Natural ); -- -- Equal, Less -- Comparisons -- -- Left - An object (dispatching) -- Right - An object (class) -- Flag - Recursion flag (used by implementation) -- -- Note that because Ada 95 has no proper multiple dispatch, one -- argument has to be made class-wide to avoid exceptions when type tags -- differ. When the second argument is in Handle'Class then the -- addresses of of the objects are compared. Otherwise, the function -- re-dispatches according to the second argument. A derived type may -- override this method in the first argument, which action will then -- have a symmeric effect. The parameter Flag is used internally to -- distinguish recursive calls. An implementation sets this parameter to -- true when it makes a recursive call the function. It is necessary to -- avoid infinite recursion when the function is inherited. -- -- Returns : -- -- The result of comparison -- function Equal ( Left : Entity; Right : Entity'Class; Flag : Boolean := False ) return Boolean; function Less ( Left : Entity; Right : Entity'Class; Flag : Boolean := False ) return Boolean; -- -- Finalize -- To be called by any derived type -- -- Object - The object to finalized -- -- Exceptions : -- -- Program_Error - The object is still in use -- procedure Finalize (Object : in out Entity); -- -- Increment_Count -- Increment object's use count -- -- Object - The object -- -- This procedure can be overridden in order to provide additional -- semantics of incrementing the object reference count. Typically it is -- used in order to make reference counting tasking safe. -- procedure Increment_Count (Object : in out Entity); -- -- Initialize -- To be called by any derived type -- -- This - The object to initialize -- procedure Initialize (Object : in out Entity); -- -- Release -- Decrement object's use count -- -- Ptr - To the object -- -- The object pointed by Ptr is deleted if its use count in 1. Otherwise -- the use count is decremented. Nothing happens if Ptr is null. -- -- Exceptions : -- -- Program_Error - Use count is already zero -- procedure Release (Ptr : in out Entity_Ptr); ------------------------------------------------------------------------ -- Object use traceback. The default implementation of these procedures -- do nothing. There is an implementation that support tracebug is the -- corresponding project option is chosen. -- -- Put_Traceback -- Write traceback of an object -- -- Object - To trace -- procedure Put_Traceback (Object : Entity'Class); -- -- Set_Trace_File -- Set trace file, the default is standard output -- -- File - The file name to open -- -- Exceptions : -- -- Upon file creation -- procedure Set_Trace_File (File : String); private pragma Inline (Decrement_Count); pragma Inline (Increment_Count); end Object;
-- { dg-options "-cargs -O2 -g -margs" } package body Debug13 is procedure Compile (P : Natural) is Max_Pos : constant Natural := P; type Position_Set is array (1 .. Max_Pos) of Boolean; Empty : constant Position_Set := (others => False); type Position_Set_Array is array (1 .. Max_Pos) of Position_Set; Follow : Position_Set_Array := (others => Empty); function Get_Follows return Position_Set; procedure Make_DFA; function Get_Follows return Position_Set is Result : Position_Set := Empty; begin Result := Result or Follow (1); return Result; end Get_Follows; procedure Make_DFA is Next : constant Position_Set := Get_Follows; begin null; end Make_DFA; begin Make_DFA; end Compile; end Debug13;
with avtas.lmcp.types; use avtas.lmcp.types; with afrl.cmasi.object; use afrl.cmasi.object; with afrl.cmasi.enumerations; use afrl.cmasi.enumerations; with afrl.cmasi.payloadConfiguration; use afrl.cmasi.payloadConfiguration; with Ada.Containers.Vectors; package afrl.cmasi.gimbalconfiguration is type GimbalConfiguration is new afrl.cmasi.payloadConfiguration.PayloadConfiguration with private; type GimbalConfiguration_Acc is access all GimbalConfiguration; -- Technically, nothing inherits from this, so we don't need a class access type type GimbalConfiguration_Class_Acc is access all GimbalConfiguration'Class; package Vect_GimbalPointingModeEnum is new Ada.Containers.Vectors (Index_Type => Natural, Element_Type => GimbalPointingModeEnum); type Vect_GimbalPointingModeEnum_Acc is access all Vect_GimbalPointingModeEnum.Vector; package Vect_Int64_t is new Ada.Containers.Vectors (Index_Type => Natural, Element_Type => Int64_t); type Vect_Int64_t_Acc is access all Vect_Int64_t.Vector; function getFullLmcpTypeName(this : GimbalConfiguration'Class) return String; function getLmcpTypeName(this : GimbalConfiguration'Class) return String; function getLmcpType(this : GimbalConfiguration'Class) return UInt32_t; SupportedPointingModes : Vect_GimbalPointingModeEnum_Acc; MinAzimuth : Float_t := -180.0; MaxAzimuth : Float_t := 180.0; IsAzimuthClamped : Boolean := False; MinElevation: Float_t := -180.0; MaxElevation : Float_t := 180.0; IsElevationClamped : Boolean := False; MinRotation: Float_t := 0.0; MaxRotation : Float_t := 0.0; IsRotationClamped : Boolean := True; MaxAzimuthSlewRate : Float_t := 0.0; MaxElevationSlewRate : Float_t := 0.0; MaxRotationRate : Float_t := 0.0; ContainedPayloadList : Vect_Int64_t_Acc; function getSupportedPointingModes(this : GimbalConfiguration'Class) return Vect_GimbalPointingModeEnum_Acc; function getMinAzimuth(this : GimbalConfiguration'Class) return Float_t; procedure setMinAzimuth(this : out GimbalConfiguration'Class; MinAzimuth : in Float_t); function getMaxAzimuth(this : GimbalConfiguration'Class) return Float_t; procedure setMaxAzimuth(this : out GimbalConfiguration'Class; MaxAzimuth : in Float_t); function getIsAzimuthClamped(this : GimbalConfiguration'Class) return Boolean; procedure setIsAzimuthClamped(this : out GimbalConfiguration'Class; IsAzimuthClamped : in Boolean); function getMinElevation(this : GimbalConfiguration'Class) return Float_t; procedure setMinElevation(this : out GimbalConfiguration'Class; MinElevation : in Float_t); function getMaxElevation(this : GimbalConfiguration'Class) return Float_t; procedure setMaxElevation(this : out GimbalConfiguration'Class; MaxElevation : in Float_t); function getIsElevationClamped(this : GimbalConfiguration'Class) return Boolean; procedure setIsElevationClamped(this : out GimbalConfiguration'Class; IsElevationClamped : in Boolean); function getMinRotation(this : GimbalConfiguration'Class) return Float_t; procedure getMinRotation(this : out GimbalConfiguration'Class; MinRotation : in Float_t); function getMaxRotation(this : GimbalConfiguration'Class) return Float_t; procedure setMaxRotation(this : out GimbalConfiguration'Class; MaxRotation : in Float_t); function getIsRotationClamped(this : GimbalConfiguration'Class) return Boolean; procedure setIsRotationClamped(this : out GimbalConfiguration'Class; IsRotationClamped : in Boolean); function getMaxAzimuthSlewRate(this : GimbalConfiguration'Class) return Float_t; procedure setMaxAzimuthSlewRate(this : out GimbalConfiguration'Class; MaxAzimuthSlewRate : in Float_t); function getMaxElevationSlewRate(this : GimbalConfiguration'Class) return Float_t; procedure setMaxElevationSlewRate(this : out GimbalConfiguration'Class; MaxElevationSlewRate : in Float_t); function getMaxRotationRate(this : GimbalConfiguration'Class) return Float_t; procedure setMaxRotationRate(this : out GimbalConfiguration'Class; MaxRotationRate : in Float_t); function getContainedPayloadList(this : GimbalConfiguration'Class) return Vect_Int64_t_Acc; private type GimbalConfiguration is new afrl.cmasi.payloadConfiguration.PayloadConfiguration with record SupportedPointingModes : Vect_GimbalPointingModeEnum_Acc; MinAzimuth : Float_t := -180.0; MaxAzimuth : Float_t := 180.0; IsAzimuthClamped : Boolean := False; MinElevation: Float_t := -180.0; MaxElevation : Float_t := 180.0; IsElevationClamped : Boolean := False; MinRotation: Float_t := 0.0; MaxRotation : Float_t := 0.0; IsRotationClamped : Boolean := True; MaxAzimuthSlewRate : Float_t := 0.0; MaxElevationSlewRate : Float_t := 0.0; MaxRotationRate : Float_t := 0.0; ContainedPayloadList : Vect_Int64_t_Acc; end record; end afrl.cmasi.gimbalconfiguration;
with ObjectPack, AbstractStrategyCombinatorPackage, IntrospectorPackage, StrategyPackage; use ObjectPack, AbstractStrategyCombinatorPackage, IntrospectorPackage, StrategyPackage; package OmegaStrategy is ARG : constant Integer := 0; type Omega is new AbstractStrategyCombinator and Object with record indexPosition: Integer := 0; end record; ---------------------------------------------------------------------------- -- Object implementation ---------------------------------------------------------------------------- function toString(o: Omega) return String; ---------------------------------------------------------------------------- -- Strategy implementation ---------------------------------------------------------------------------- function visitLight(str:access Omega; any: ObjectPtr; i: access Introspector'Class) return ObjectPtr; function visit(str: access Omega; i: access Introspector'Class) return Integer; ---------------------------------------------------------------------------- procedure makeOmega(om : in out Omega; ip: Integer; v: StrategyPtr); function newOmega(ip: Integer; v: StrategyPtr) return StrategyPtr; function getPos(om : Omega) return Integer; end OmegaStrategy;
with Interfaces; use Interfaces; package P1 with SPARK_Mode is type Byte_Array is array (Natural range <>) of Unsigned_8; function toBytes(uint : Unsigned_16) return Byte_Array is (1 => Unsigned_8( uint mod 2**8 ), 2 => Unsigned_8 ( uint / 2**8 ) ); end P1;
----------------------------------------------------------------------- -- gen-artifacts-distribs-copies -- Copy based distribution artifact -- Copyright (C) 2012, 2013 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Directories; with Util.Log.Loggers; -- The <b>Gen.Artifacts.Distribs.Copies</b> package provides distribution rules -- to copy a file or a directory to the distribution area. package body Gen.Artifacts.Distribs.Copies is use Util.Log; Log : constant Loggers.Logger := Loggers.Create ("Gen.Artifacts.Distribs.Copies"); -- ------------------------------ -- Create a distribution rule to copy a set of files or directories. -- ------------------------------ function Create_Rule (Node : in DOM.Core.Node; Copy_First_File : in Boolean) return Distrib_Rule_Access is pragma Unreferenced (Node); Result : constant Copy_Rule_Access := new Copy_Rule; begin Result.Copy_First_File := Copy_First_File; return Result.all'Access; end Create_Rule; -- ------------------------------ -- Get a name to qualify the installation rule (used for logs). -- ------------------------------ overriding function Get_Install_Name (Rule : in Copy_Rule) return String is pragma Unreferenced (Rule); begin return "copy"; end Get_Install_Name; overriding procedure Install (Rule : in Copy_Rule; Path : in String; Files : in File_Vector; Context : in out Generator'Class) is pragma Unreferenced (Context); use type Ada.Containers.Count_Type; Source : constant String := Get_Source_Path (Files, Rule.Copy_First_File); Dir : constant String := Ada.Directories.Containing_Directory (Path); begin if Files.Length > 1 then Log.Info ("copy {0} to {1} (ignoring {2} files)", Source, Path, Natural'Image (Natural (Files.Length) - 1)); else Log.Info ("copy {0} to {1}", Source, Path); end if; Ada.Directories.Create_Path (Dir); Ada.Directories.Copy_File (Source_Name => Source, Target_Name => Path, Form => "preserve=all_attributes, mode=overwrite"); end Install; end Gen.Artifacts.Distribs.Copies;
with C.string; package body MPC is function Version return String is S : constant C.char_const_ptr := C.mpc.mpc_get_version; Length : constant Natural := Natural (C.string.strlen (S)); Result : String (1 .. Length); for Result'Address use S.all'Address; begin return Result; end Version; function Compose ( Real_Rounding : MPFR.Rounding; Imaginary_Rounding : MPFR.Rounding) return Rounding is begin return MPFR.Rounding'Enum_Rep (Real_Rounding) + MPFR.Rounding'Enum_Rep (Imaginary_Rounding) * (2 ** 4); end Compose; function Default_Rounding return Rounding is begin return Compose (MPFR.Default_Rounding, MPFR.Default_Rounding); end Default_Rounding; end MPC;
with Ada.Containers.Indefinite_Doubly_Linked_Lists; with GNAT.Regpat; with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; generic type Classified_Line (<>) is private ; package Line_Arrays.Regexp_Classifiers is type Callback_Type is access function (Item : String; Matches : Gnat.Regpat.Match_Array) return Classified_Line; type Regexp_Pair is private; function Is_Default (X : Regexp_Pair) return Boolean; function P (Regexp : String; Callback : Callback_Type) return Regexp_Pair with Pre => Regexp /= "", Post => not Is_Default (P'Result); function "+" (Callback : Callback_Type) return Regexp_Pair with Post => Is_Default ("+"'Result); type Regexp_Array is array (Positive range <>) of Regexp_Pair; type Classifier_Type (<>) is tagged private; function Create (Regexps : Regexp_Array) return Classifier_Type with Pre => (for all I in Regexps'Range => (for all J in I + 1 .. Regexps'Last => (not (Is_Default (Regexps (I)) and Is_Default (Regexps (J)))) ) ); -- The precondition expressed in plain English requires that at most -- one entry of Regexps must be a default expression function Classify (Classifier : Classifier_Type; Line : String) return Classified_Line; Double_Default : exception; private type Regexp_Pair is record Regexp : Unbounded_String; Callback : Callback_Type; end record; function Is_Default (X : Regexp_Pair) return Boolean is (X.Regexp = Null_Unbounded_String); function P (Regexp : String; Callback : Callback_Type) return Regexp_Pair is (Regexp_Pair'(To_Unbounded_String(Regexp), Callback)); function "+" (Callback : Callback_Type) return Regexp_Pair is (Regexp_Pair'(Null_Unbounded_String, Callback)); type Regexp_Descriptor (Size : Gnat.Regpat.Program_Size) is record Matcher : GNAT.Regpat.Pattern_Matcher (Size); Callback : Callback_Type; end record; package Descriptor_Lists is new Ada.Containers.Indefinite_Doubly_Linked_Lists (Regexp_Descriptor); procedure Add (To : in out Classifier_Type; Regexp : String; Callback : Callback_Type); procedure Add_Default (To : in out Classifier_Type; Callback : Callback_Type); type Classifier_Type is tagged record Exprs : Descriptor_Lists.List := Descriptor_Lists.Empty_List; Default : Callback_Type := null; end record; end Line_Arrays.Regexp_Classifiers;
package body problem_21 is function Sum_Of_Divisors( Num : Integer ) return Integer is Sum : Integer := 1; I : Integer := 2; begin for I in 2 .. (Num / 2) loop if Num mod I = 0 then Sum := Sum + I; end if; end loop; return Sum; end Sum_Of_Divisors; function Solution_1 return Int64 is Solution : Integer := 0; Sum : Int64 := 0; begin for I in 1 .. 9999 loop Solution := Sum_Of_Divisors(I); if Sum_Of_Divisors(Solution) = I then if I /= Solution then Sum := Sum + Int64(I); end if; end if; end loop; return Sum; end Solution_1; procedure Test_Solution_1 is Solution : constant Int64 := 31626; begin Assert( Solution = Solution_1 ); end Test_Solution_1; function Get_Solutions return Solution_Case is Ret : Solution_Case; begin Set_Name( Ret, "Problem 21" ); Add_Test( Ret, Test_Solution_1'Access ); return Ret; end Get_Solutions; end problem_21;
-- C36180A.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 AN INDEX CONSTRAINT CAN HAVE THE FORM A'RANGE, -- WHERE A IS A PREVIOUSLY DECLARED ARRAY OBJECT OR CONSTRAINED -- ARRAY SUBTYPE. -- HISTORY: -- BCB 01/21/88 CREATED ORIGINAL TEST. WITH REPORT; USE REPORT; PROCEDURE C36180A IS TYPE J IS ARRAY (INTEGER RANGE <>) OF INTEGER; TYPE K IS ARRAY (1..10) OF INTEGER; SUBTYPE A IS J (0 .. 50); SUBTYPE W IS J (A'RANGE); SUBTYPE X IS J (K'RANGE); TYPE Y IS ACCESS J; TYPE Z IS ACCESS J; TYPE F IS NEW J (A'RANGE); TYPE G IS NEW J (K'RANGE); B : ARRAY (A'RANGE) OF INTEGER; C : ARRAY (K'RANGE) OF INTEGER; D : ARRAY (1 .. 10) OF INTEGER; E : ARRAY (D'RANGE) OF INTEGER; H : J (A'RANGE); I : J (K'RANGE); L : J (D'RANGE); V1 : W; V2 : X; V3 : Y := NEW J (A'RANGE); V4 : Z := NEW J (K'RANGE); V5 : F; V6 : G; BEGIN TEST ("C36180A", "CHECK THAT AN INDEX CONSTRAINT CAN HAVE THE " & "FORM A'RANGE, WHERE A IS A PREVIOUSLY " & "DECLARED ARRAY OBJECT OR CONSTRAINED ARRAY " & "SUBTYPE"); IF B'FIRST /= IDENT_INT (0) OR B'LAST /= IDENT_INT (50) THEN FAILED ("IMPROPER VALUE FOR B'FIRST OR B'LAST"); END IF; IF C'FIRST /= IDENT_INT (1) OR C'LAST /= IDENT_INT (10) THEN FAILED ("IMPROPER VALUE FOR C'FIRST OR C'LAST"); END IF; IF E'FIRST /= IDENT_INT (1) OR E'LAST /= IDENT_INT (10) THEN FAILED ("IMPROPER VALUE FOR E'FIRST OR E'LAST"); END IF; IF H'FIRST /= IDENT_INT (0) OR H'LAST /= IDENT_INT (50) THEN FAILED ("IMPROPER VALUE FOR H'FIRST OR H'LAST"); END IF; IF I'FIRST /= IDENT_INT (1) OR I'LAST /= IDENT_INT (10) THEN FAILED ("IMPROPER VALUE FOR I'FIRST OR I'LAST"); END IF; IF L'FIRST /= IDENT_INT (1) OR L'LAST /= IDENT_INT (10) THEN FAILED ("IMPROPER VALUE FOR L'FIRST OR L'LAST"); END IF; IF V1'FIRST /= IDENT_INT (0) OR V1'LAST /= IDENT_INT (50) THEN FAILED ("IMPROPER VALUE FOR V1'FIRST OR V1'LAST"); END IF; IF V2'FIRST /= IDENT_INT (1) OR V2'LAST /= IDENT_INT (10) THEN FAILED ("IMPROPER VALUE FOR V2'FIRST OR V2'LAST"); END IF; IF V3.ALL'FIRST /= IDENT_INT (0) OR V3.ALL'LAST /= IDENT_INT (50) THEN FAILED ("IMPROPER VALUE FOR V3'FIRST OR V3'LAST"); END IF; IF V4.ALL'FIRST /= IDENT_INT (1) OR V4.ALL'LAST /= IDENT_INT (10) THEN FAILED ("IMPROPER VALUE FOR V4'FIRST OR V4'LAST"); END IF; IF V5'FIRST /= IDENT_INT (0) OR V5'LAST /= IDENT_INT (50) THEN FAILED ("IMPROPER VALUE FOR V5'FIRST OR V5'LAST"); END IF; IF V6'FIRST /= IDENT_INT (1) OR V6'LAST /= IDENT_INT (10) THEN FAILED ("IMPROPER VALUE FOR V6'FIRST OR V6'LAST"); END IF; RESULT; END C36180A;
-- Copyright 2019 Michael Casadevall <michael@casadevall.pro> -- -- 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.Strings.Unbounded; use Ada.Strings.Unbounded; with Ada.Streams; use Ada.Streams; with Ada.Unchecked_Conversion; with GNAT.Sockets; use GNAT.Sockets; with Interfaces.C.Extensions; use Interfaces.C.Extensions; with System; -- @summary -- Global types used throughout the DNSCatcher library -- -- @description -- DNSCatcher has several types used to define items like DNS Packet Headers, -- RData data and much more. For the moment to prevent circular dependencies -- much of this information is stored here in a Types top level module. It is -- intended to retire this as soon as realistically possible -- package DNSCatcher.Types is -- Header field for DNS Packets, common to all DNS messages as described in -- RFC 1035 (and others). This field is marked big-endian (network order), -- as it's directly laid over the starting prefix bytes of all DNS packets. -- This causes issues with GDB on little endian platforms, but performs -- correctly when compiled in the test suite. -- -- @field Identifier -- 16-bit field used to match multiple client requests and answers back to -- each other -- -- @field Query_Response_Flag -- Identifies a given DNS packet as a client request (FALSE), or server -- response (TRUE). This flag is used with the Identifier to complete DNS -- transactions. -- -- @field Opcode -- Identifies the DNS operation in action. The values for this field are -- managed by IANA. -- -- @field Authoritative_Answer Determines if a given answer is authoritive -- and that a given server is authoritive for the answers given in the -- Authoritive Answer section. This is known as the AA-bit in most DNS -- documentation. -- -- @field Truncated -- This field is only used in UDP transmissions. It is set if the packet is -- greater than 512 ocelets *or* if EDNS is in use, greater than the clients -- max packet size. If so, the answers are cut down to the point they are -- fit and Truncated is set. The client is expected to reconnect via TCP/IP -- to get the remainder of the data it needs. -- -- @field Recursion_Desired -- Set by the client, the RD-bit asks the server to perform a recursive -- lookup on it's behalf. This flag, as suggested, is a suggestion and the -- server may ignore it (set by the RA bit below). RD is mirrored between -- client response, and server response. -- -- @field Recursion_Available -- Only used in server responses, it denotes recursive lookup services are -- available. RA can be used to determine if a lookup was recursed if RD was -- set. -- -- @field Zero -- Must be zero; this bit is reserved for future use. -- -- @field Authenticated_Data -- Defines if the data returned from the server was authenticated via -- DNSSEC. AD is set regardless if EDNS DO=1 was sent (indicating the -- client wishes to get DNSSEC information). -- -- @field Checking_Disabled -- Set by the client, CD determines if DNSSEC information should be checked -- at all This field primarily exists to allow retrieval of missigned DNSSEC -- records. -- -- @field Response_Code -- Non-EDNS result of the client's last request. Response_Code is somewhat -- complicated as there is a set of Extended response codes that exceed the -- 4-bit limit of this field. In those cases, the remaining top bits are set -- in the EDNS packet so handling of this field requires knowing if EDNS is -- in use or not, and then combining it with the OPT data record to create -- the actual response code. -- -- @field Question_Count -- Number of Questions held in this DNS Packet. Questions are sent from the -- client to the server specifying the name, class, and record type desired. -- See Raw_DNS_Question below for more information. -- -- @field Answer_Record_Count -- Number of Answers Records returned in this DNS packet. Answers are -- responses directly relating to the question answered by the client. -- -- @field Authority_Record_Count Number of Authority Records in this packet. -- Authority records are pointers and hints to where AA=1 information can be -- found. They are optional from recursive resolvers. -- -- @field Additional_Record_Count Records that the server deems "useful" -- even though they don't directly answer the client's question. This is -- primary where EDNS OPT record lives as well as glue record information -- for IPv4/IPv6 lookups. -- type DNS_Packet_Header is record Identifier : Unsigned_16; Query_Response_Flag : Boolean; Opcode : Unsigned_4; Authoritative_Answer : Boolean; Truncated : Boolean; Recursion_Desired : Boolean; Recursion_Available : Boolean; Zero : Boolean; Authenticated_Data : Boolean; Checking_Disabled : Boolean; Response_Code : Unsigned_4; Question_Count : Unsigned_16; Answer_Record_Count : Unsigned_16; Authority_Record_Count : Unsigned_16; Additional_Record_Count : Unsigned_16; end record; for DNS_Packet_Header'Bit_Order use System.High_Order_First; for DNS_Packet_Header'Scalar_Storage_Order use System.High_Order_First; pragma Pack (DNS_Packet_Header); type DNS_Packet_Header_Ptr is access all DNS_Packet_Header; -- Represents the fixed size of the header section of a DNS packet. -- -- I don't know if this is spec, or a bug with GNAT, but 'Size returns the -- wrong value and I get 128 which means I need to calculate this like this -- which is kinda bullshit. This is likely due to the use of Pack confusing -- the compiler. DNS_PACKET_HEADER_SIZE : constant Stream_Element_Offset := 12; -- Data section of a DNS packet type Stream_Element_Array_Ptr is access all Stream_Element_Array; subtype Raw_DNS_Packet_Data_Ptr is Stream_Element_Array_Ptr; -- Represents the raw DNS packet. -- -- DNS packets have a fixed size header, and variable sized data length -- which is handled in the message. When used over TCP/IP, packets start -- with a two bit length that defines the full size of the DNS packet. This -- implementation detail is handled transparently by the network transport -- layer as it needs to be read and calculated on the fly for each DNS -- packet. -- -- This record is stored big endian, and is packed, and used to directly map -- incoming data by the network stack to DNS information. -- -- @field Header -- Fixed sized DNS packet header; mapped to the DNS_Packet_Header type by an -- Unchecked_Conversion in the network handling stack. -- -- @field Data -- Variable length data section of the packet. This is a subtype of -- Stream_Element_Array which is what is returned from Ada.Streams -- and GNAT.Sockets. -- type Raw_DNS_Packet is record Header : DNS_Packet_Header; Data : Raw_DNS_Packet_Data_Ptr; end record; for Raw_DNS_Packet'Bit_Order use System.High_Order_First; for Raw_DNS_Packet'Scalar_Storage_Order use System.High_Order_First; pragma Pack (Raw_DNS_Packet); type Raw_DNS_Packet_Ptr is access Raw_DNS_Packet; -- Extracts the DNS Packet Header from the start of a Stream_Element_Array -- -- Used to substatiate the unchecked conversions to and from. -- subtype SEA_DNS_Packet_Header is Stream_Element_Array (1 .. DNS_PACKET_HEADER_SIZE); -- Conversion functions -- Converts a Stream_Element_Array to a DNS Packet Header. -- -- This is implemented as an unchecked conversion so responsibility is on -- the caller to ensure valid data exists within the SEA. -- function SEA_To_DNS_Packet_Header is new Ada.Unchecked_Conversion (Source => Stream_Element_Array, Target => DNS_Packet_Header); -- Converts a DNS Packet_Header to Stream_Element_Array -- -- This allows conversion of packed data from the record to wire format, -- used in sending DNS packets when operating as a DNS client. -- function DNS_Packet_Header_To_SEA is new Ada.Unchecked_Conversion (Source => DNS_Packet_Header, Target => SEA_DNS_Packet_Header); -- Basic unit of a raw DNS packet before any processing is performed -- -- The Raw_Packet_Unit is used by the network stack to represent where a -- packet is going and coming from. It also contains a From/To port for UDP -- packets as these need to be sent in two stages to respond back properly. -- -- This record is also formed for outgoing responses as part of the -- DNS_Client operation. -- -- This record is primarily used by the transaction manager to safely return -- the right packet to the right client. -- -- @field From_Address -- Origin of this packet. For packets originating from this system, it can -- be left blank. -- -- @field From_Port -- Represents the source port on the remote system. This is required to -- match and return UDP responses. -- -- @field To_Address -- Destinaton of a packet. For packets arriving on this system, it may be -- left blank. -- -- @field To_Port -- Destination port of the packet. -- -- @field Raw_Data -- Raw data of a given packet field already memory mapped to DNS component -- parts. -- -- @field Raw_Data_Length -- Full length of the raw data component -- type Raw_Packet_Record is record From_Address : Unbounded_String; From_Port : Port_Type; To_Address : Unbounded_String; To_Port : Port_Type; Raw_Data : Raw_DNS_Packet; Raw_Data_Length : Stream_Element_Offset; end record; type Raw_Packet_Record_Ptr is access Raw_Packet_Record; -- Deallocation function for Raw_DNS_Packet -- -- Due to the fact that raw DNS packet data is returned as an access type -- this helper procedure is used to deallocate this record correctly. -- -- @value Packet Raw_DNS_Packet to be freed -- procedure Free_Raw_DNS_Packet (Packet : in out Raw_DNS_Packet); -- Deallocation function for Raw_Packet_Record -- -- Handles properly deallocating Raw_Packet_Records due to the dynamic -- memory components stored in these records -- -- @value Ptr -- The raw packet to be freed. -- procedure Free_Raw_Packet_Record_Ptr (Ptr : in out Raw_Packet_Record_Ptr); end DNSCatcher.Types;
-- -- Copyright (C) 2015-2016 secunet Security Networks AG -- Copyright (C) 2016 Nico Huber <nico.h@gmx.de> -- -- 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; with HW.GFX.GMA.Panel; with HW.GFX.GMA.Connectors.EDP; with HW.GFX.GMA.Connectors.FDI; with HW.GFX.GMA.PCH.VGA; with HW.GFX.GMA.PCH.LVDS; with HW.GFX.GMA.PCH.HDMI; with HW.GFX.GMA.PCH.DP; with HW.GFX.GMA.PCH.Transcoder; with HW.Debug; with GNAT.Source_Info; package body HW.GFX.GMA.Connectors is procedure Post_Reset_Off is null; procedure Initialize is null; function Is_Internal (Port_Cfg : Port_Config) return Boolean is begin return Port_Cfg.Port = DIGI_A or (Port_Cfg.Is_FDI and Port_Cfg.PCH_Port = PCH_LVDS); end Is_Internal; ---------------------------------------------------------------------------- procedure Pre_On (Pipe : in Pipe_Index; Port_Cfg : in Port_Config; PLL_Hint : in Word32; Success : out Boolean) is begin pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); if Port_Cfg.Port = DIGI_A then EDP.Pre_On (Pipe, Port_Cfg); elsif Port_Cfg.Port in FDI.GPU_FDI_Port then FDI.Pre_On (Port_Cfg); end if; Success := True; end Pre_On; procedure Post_On (Pipe : in Pipe_Index; Port_Cfg : in Port_Config; PLL_Hint : in Word32; Success : out Boolean) is begin pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); if Port_Cfg.Port = DIGI_A then EDP.Pre_Training; Panel.On (Wait => True); EDP.Post_On (Port_Cfg.DP, Success); elsif Port_Cfg.Port in FDI.GPU_FDI_Port then declare FDI_Port : constant PCH.FDI_Port_Type := FDI.PCH_FDIs (Port_Cfg.Port); begin FDI.Post_On (Port_Cfg, Success); if Success then PCH.Transcoder.On (Port_Cfg, FDI_Port, PLL_Hint); if Port_Cfg.PCH_Port = PCH_DAC then PCH.VGA.On (FDI_Port, Port_Cfg.Mode); elsif Port_Cfg.PCH_Port = PCH_LVDS then PCH.LVDS.On (Port_Cfg, FDI_Port); elsif Port_Cfg.PCH_Port in PCH_HDMI_Port then PCH.HDMI.On (Port_Cfg, FDI_Port); elsif Port_Cfg.PCH_Port in PCH_DP_Port then PCH.DP.On (Port_Cfg, Success); end if; end if; end; else Success := False; end if; if Success and Is_Internal (Port_Cfg) then Panel.On (Wait => False); Panel.Backlight_On; end if; end Post_On; ---------------------------------------------------------------------------- procedure Pre_Off (Port_Cfg : Port_Config) is begin pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); if Is_Internal (Port_Cfg) then Panel.Backlight_Off; Panel.Off; end if; end Pre_Off; procedure Post_Off (Port_Cfg : Port_Config) is begin pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); if Port_Cfg.Port = DIGI_A then EDP.Off (Port_Cfg.Port); elsif Port_Cfg.Port in FDI.GPU_FDI_Port then declare FDI_Port : constant PCH.FDI_Port_Type := FDI.PCH_FDIs (Port_Cfg.Port); begin if Port_Cfg.PCH_Port in PCH_DP_Port then PCH.DP.Off (Port_Cfg.PCH_Port); end if; FDI.Off (Port_Cfg.Port, FDI.Link_Off); if Port_Cfg.PCH_Port = PCH_DAC then PCH.VGA.Off; elsif Port_Cfg.PCH_Port = PCH_LVDS then PCH.LVDS.Off; elsif Port_Cfg.PCH_Port in PCH_HDMI_Port then PCH.HDMI.Off (Port_Cfg.PCH_Port); end if; PCH.Transcoder.Off (FDI_Port); FDI.Off (Port_Cfg.Port, FDI.Clock_Off); end; end if; end Post_Off; ---------------------------------------------------------------------------- procedure Pre_All_Off is begin pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); Panel.Backlight_Off; Panel.Off; end Pre_All_Off; procedure Post_All_Off is begin pragma Debug (Debug.Put_Line (GNAT.Source_Info.Enclosing_Entity)); EDP.Off (DIGI_A); for Port in FDI.GPU_FDI_Port loop FDI.Off (Port, FDI.Link_Off); end loop; PCH.VGA.Off; PCH.LVDS.Off; PCH.HDMI.All_Off; PCH.DP.All_Off; for Port in PCH.FDI_Port_Type loop PCH.Transcoder.Off (Port); end loop; for Port in FDI.GPU_FDI_Port loop FDI.Off (Port, FDI.Clock_Off); end loop; end Post_All_Off; end HW.GFX.GMA.Connectors;
with Ada.Text_IO; use Ada.Text_IO; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Ada.Float_Text_IO; use Ada.Float_Text_IO; procedure Somme_Entier_Reel is Entier : Integer; -- l'entier lu au clavier Reel : Float; -- le réel lu au clavier Somme : Float; -- la somme de l'entier par le réel begin -- Demander l'entier Get (Entier); -- Demander le réel Get (Reel); -- Calculer la somme de l'entier et du réel Somme := Float(Entier) + Reel; -- Afficher la somme Put ("Somme : "); Put (Somme, Exp => 0); -- Exp => 0 signifie utiliser 0 chiffre pour l'exposant (si possible) New_Line; end Somme_Entier_Reel;
separate (Numerics) function Abs_Max_IA (Item : in Int_Array) return Integer is Result : Integer := 0; begin for N of Item loop Result := Integer'Max (Result, abs (N)); end loop; return Result; end Abs_Max_IA;
with ada.Numerics.Discrete_Random,Ada.Text_IO; use Ada.Text_IO; package body estado_casillero is package estado_aleatorio is new ada.Numerics.Discrete_Random(t_estado_casillero); use estado_aleatorio; function random_estado return t_estado_casillero is g:Generator; begin Reset(g); return Random(g); end random_estado; procedure put_estado_casillero (c : in t_estado_casillero) is begin if c = Limpio then put("L"); else put("S"); end if; end put_estado_casillero; end estado_casillero;
with Ada.Command_Line; use Ada.Command_Line; with Ada.Exceptions; use Ada.Exceptions; with Ada.Text_IO; use Ada.Text_IO; with TJa.Sockets; use TJa.Sockets; with Ada.Integer_Text_IO; use Ada.Integer_Text_IO; with Server_Assets_Package; use Server_Assets_Package; with Klient_Assets_Package; use Klient_Assets_Package; procedure Server is --| Servern behöver en Listener_type för att ta emot inkommande anslutningar Lyssnare : Listener_Type; --| Socket_type används för att kunna kommunicera med en klient Socket1, Socket2 : Socket_Type; Emptyprotocoll1, Emptyprotocoll2: Protocoll_Type; begin --| Denna rutin kontrollerar att programmet startas med en parameter. --| Annars kastas ett fel. --| Argumentet skall vara portnummret, programmet kan t.ex. startas med: --| > server 3400 if Argument_Count /= 1 then Raise_Exception(Constraint_Error'Identity, "Usage: " & Command_Name & " port"); end if; --| Initierar lyssnaren på en port (klienter bara utanför "localhost").\ Connect_To_Klients(Socket1, Socket2, Lyssnare, Natural'Value(Argument(1))); -- Fill protocolls empty For x in 1..15 loop Emptyprotocoll1(x) := -1; Emptyprotocoll2(x) := -1; end loop; -- Start main loop Yatzyloop(Socket1, Socket2, Emptyprotocoll1, Emptyprotocoll2, 1); exception --| Lite felhantering when Constraint_Error => Put_Line("Du matade inte in en parameter innehållande portnummer"); when others => --| kanske end_error eller socket_error, det betyder att --| klienten stängt sin socket. Då skall den stängas även --| här. Put_Line("Nu dog klienten"); Close(Socket1); Close(Socket2); end Server;
-------------------------------------------------------------------------------- -- Copyright (c) 2013, Felix Krause <contact@flyx.org> -- -- Permission to use, copy, modify, and/or distribute this software for any -- purpose with or without fee is hereby granted, provided that the above -- copyright notice and this permission notice appear in all copies. -- -- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -------------------------------------------------------------------------------- with CL.Platforms; with CL.Contexts; with CL_Test.Helpers; with Ada.Text_IO; with Ada.Strings.Fixed; with Ada.Exceptions; procedure CL_Test.Context is package ATI renames Ada.Text_IO; Pfs : constant CL.Platforms.Platform_List := CL.Platforms.List; pragma Assert (Pfs'Length > 0); Pf : constant CL.Platforms.Platform := Pfs (1); Dvs : constant CL.Platforms.Device_List := Pf.Devices(CL.Platforms.Device_Kind_All); pragma Assert (Dvs'Length > 0); use Ada.Strings.Fixed; use type CL.Size; begin ATI.Put_Line ("Device count is" & Dvs'Length'Img); -- create a context for the first device declare Context : constant CL.Contexts.Context := CL.Contexts.Constructors.Create_For_Devices (Pf, Dvs (1 .. 1), CL_Test.Helpers.Callback'Access); begin ATI.Put ("Created context, reference count is"); ATI.Put_Line (Context.Reference_Count'Img); declare pragma Warnings (Off); Context2 : constant CL.Contexts.Context := Context; pragma Warnings (On); begin ATI.Put ("Duplicated context, reference count is"); ATI.Put_Line (Context.Reference_Count'Img); end; ATI.Put ("Duplicated terminated, reference count is"); ATI.Put_Line (Context.Reference_Count'Img); declare Devices : constant CL.Platforms.Device_List := Context.Devices; begin ATI.Put ("Number of Devices is"); ATI.Put_Line (Devices'Length'Img); for Index in Devices'Range loop ATI.Put ("#" & Index'Img & ": "); ATI.Put_Line (Devices (Index).Name); end loop; end; exception when Error : others => ATI.Put_Line ("Encountered Error: " & Ada.Exceptions.Exception_Name (Error) & " -- " & Ada.Exceptions.Exception_Message (Error) ); end; ATI.Put_Line (80 * '-'); -- create a context for all GPU devices declare GPU_Devices : constant CL.Platforms.Device_Kind := CL.Platforms.Device_Kind'(GPU => True, others => False); Context : constant CL.Contexts.Context := CL.Contexts.Constructors.Create_From_Type (Pf, GPU_Devices, CL_Test.Helpers.Callback'Access); Returned_Pf : constant CL.Platforms.Platform := Context.Platform; use type CL.Platforms.Platform; begin ATI.Put ("Created context, reference count is"); ATI.Put_Line (Context.Reference_Count'Img); pragma Assert (Returned_Pf = Pf); exception when Error : others => ATI.Put_Line ("Encountered Error: " & Ada.Exceptions.Exception_Name (Error) & " -- " & Ada.Exceptions.Exception_Message (Error) ); end; end CL_Test.Context;
package body System.Tasking.Protected_Objects is procedure Initialize_Protection ( Object : not null access Protection; Ceiling_Priority : Integer) is pragma Unreferenced (Ceiling_Priority); begin Synchronous_Objects.Initialize (Object.Lock); end Initialize_Protection; procedure Finalize_Protection (Object : in out Protection) is begin Synchronous_Objects.Finalize (Object.Lock); end Finalize_Protection; procedure Lock (Object : not null access Protection) is begin -- in locking, abort is deferred -- so checking the aborted flag inside of r/w-lock is meaningless Synchronous_Objects.Enter_Writing (Object.Lock); end Lock; procedure Lock_Read_Only (Object : not null access Protection) is begin Synchronous_Objects.Enter_Reading (Object.Lock); end Lock_Read_Only; procedure Unlock (Object : not null access Protection) is begin Synchronous_Objects.Leave (Object.Lock); end Unlock; function Get_Ceiling (Object : not null access Protection) return Any_Priority is begin raise Program_Error; -- unimplemented return Get_Ceiling (Object); end Get_Ceiling; end System.Tasking.Protected_Objects;
for Value in 3 .. 12 loop if Value mod 3 = 0 then put(Value, 0); put(", ") end if; end loop; put("what's a word that rhymes with ""twelve""?");
with SPARKNaCl; use SPARKNaCl; with SPARKNaCl.Debug; use SPARKNaCl.Debug; with SPARKNaCl.Scalar; use SPARKNaCl.Scalar; procedure Scalarmult is AliceSK : constant Bytes_32 := (16#77#, 16#07#, 16#6d#, 16#0a#, 16#73#, 16#18#, 16#a5#, 16#7d#, 16#3c#, 16#16#, 16#c1#, 16#72#, 16#51#, 16#b2#, 16#66#, 16#45#, 16#df#, 16#4c#, 16#2f#, 16#87#, 16#eb#, 16#c0#, 16#99#, 16#2a#, 16#b1#, 16#77#, 16#fb#, 16#a5#, 16#1d#, 16#b9#, 16#2c#, 16#2a#); AlicePK : Bytes_32; begin AlicePK := Mult_Base (AliceSK); DH ("AlicePK is", AlicePK); end Scalarmult;
-- The Cupcake GUI Toolkit -- (c) Kristian Klomsten Skordal 2012 <kristian.skordal@gmail.com> -- Report bugs and issues on <http://github.com/skordal/cupcake/issues> -- vim:ts=3:sw=3:et:si:sta package body Cupcake.Backends is -- Gets the backend class to be used: function Get_Backend return Backend_Access is begin return Active_Backend; end Get_Backend; -- Sets the backend to be used: procedure Set_Backend (Use_Backend : in Backend_Access) is begin Active_Backend := Use_Backend; end Set_Backend; end Cupcake.Backends;
-- C83F03C2M.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. --* -- MAIN PROGRAM REQUIRING A SEPARATELY COMPILED PACKAGE -- ( C83F03C0 ; SPECIFICATION IN C83F03C0.ADA , -- BODY IN C83F03C1.ADA ) -- CHECK THAT IF A PACKAGE BODY IS NESTED INSIDE A SEPARATELY COMPILED -- PACKAGE BODY -- THE INNER PACKAGE BODY CAN CONTAIN A LABEL IDENTIFIER IDENTICAL -- TO A LABEL IDENTIFIER IN THE OUTER PACKAGE BODY OR TO AN IDENTI- -- FIER DECLARED IN THE OUTER PACKAGE BODY OR IN ITS SPECIFICATION. -- CASE 1: PACKAGE IS A FULL-FLEDGED COMPILATION UNIT -- RM 05 SEPTEMBER 1980 WITH REPORT , C83F03C0 ; PROCEDURE C83F03C2M IS USE REPORT , C83F03C0 ; BEGIN TEST( "C83F03C" , "CHECK THAT IF A PACKAGE BODY IS NESTED" & " INSIDE A SEPARATELY COMPILED PACKAGE BODY" & " LIBRARY UNIT, THE INNER" & " PACKAGE BODY CAN CONTAIN A LABEL IDENTIFIER" & " IDENTICAL TO A LABEL IDENTIFIER IN THE OUTER" & " PACKAGE BODY OR TO AN IDENTIFIER DECLARED IN" & " THE OUTER PACKAGE BODY OR IN ITS SPECIFICA" & "TION" ) ; IF FLOW_INDEX /= 5 THEN FAILED( "INCORRECT FLOW OF CONTROL" ); END IF; RESULT; -- POSS. ERROR DURING ELABORATION OF P END C83F03C2M;
-- The Village of Vampire by YT, このソースコードはNYSLです with Ada.Exceptions; with Ada.Streams.Stream_IO; with Serialization.YAML; with YAML.Streams; with Vampire.Villages.Village_IO; procedure Vampire.Villages.Load ( Name : in String; Village : in out Village_Type; Info_Only : in Boolean := False) is File : Ada.Streams.Stream_IO.File_Type; begin Ada.Streams.Stream_IO.Open ( File, Ada.Streams.Stream_IO.In_File, Name => Name); declare Parser : aliased YAML.Parser := YAML.Streams.Create (Ada.Streams.Stream_IO.Stream (File)); begin Village_IO.IO ( Serialization.YAML.Reading (Parser'Access, Village_IO.Yaml_Type).Serializer, Village, Info_Only); YAML.Finish (Parser); end; Ada.Streams.Stream_IO.Close (File); exception when E : others => declare Message : constant String := Name & ": " & Ada.Exceptions.Exception_Message (E); begin Ada.Debug.Put (Message); Ada.Exceptions.Raise_Exception ( Ada.Exceptions.Exception_Identity (E), Message); end; end Vampire.Villages.Load;
-- -- The author disclaims copyright to this source code. In place of -- a legal notice, here is a blessing: -- -- May you do good and not evil. -- May you find forgiveness for yourself and forgive others. -- May you share freely, not taking more than you give. -- with Types; with Configs; with Action_Lists; with Action_Tables; limited with Rules; package States is subtype Action_Value is Action_Tables.Action_Value; subtype Offset_Type is Types.Offset_Type; type State_Boolean is (Syntax_Error, False, True); -- Syntax_Error is used to trigger syntax error !!! type State_Number is new Integer; -- Identification number for state. -- Each state of the generated parser's finite state machine -- is encoded as an instance of the following structure. type State_Record is record Basis : Configs.Config_Access; -- The basis configurations for this state Config : Configs.Config_Access; -- All configurations in this set Number : State_Number; -- Sequential number for this state Action : Action_Lists.List; -- List of actions for this state Num_Token : aliased Action_Value; Num_Nonterminal : aliased Action_Value; -- Number of actions on terminals and nonterminals Token_Offset : Offset_Type; Nonterm_Offset : Offset_Type; -- yy_action[] offset for terminals and nonterms Default_Reduce : State_Boolean; -- Default action is to REDUCE by this rule Default_Reduce_Rule : access Rules.Rule_Record; -- The default REDUCE rule. Auto_Reduce : Boolean; -- True if this is an auto-reduce state end record; type State_Access is access all State_Record; procedure Initialize; -- Initialize states function Find (Config : in not null Configs.Config_Access) return State_Access; -- Find state from Config function Create return State_Access; -- Create state procedure Insert (State : in State_Access; Config : in Configs.Config_Access); -- Insert state type Process_Access is access procedure (State : in State_Access); procedure Iterate (Process : in Process_Access); end States;
pragma Ada_2005; pragma Style_Checks (Off); with Interfaces.C; use Interfaces.C; package avx512vldqintrin_h is -- Copyright (C) 2014-2017 Free Software Foundation, Inc. -- This file is part of GCC. -- GCC 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, or (at your option) -- any later version. -- GCC 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. -- 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/>. -- skipped func _mm256_cvttpd_epi64 -- skipped func _mm256_mask_cvttpd_epi64 -- skipped func _mm256_maskz_cvttpd_epi64 -- skipped func _mm_cvttpd_epi64 -- skipped func _mm_mask_cvttpd_epi64 -- skipped func _mm_maskz_cvttpd_epi64 -- skipped func _mm256_cvttpd_epu64 -- skipped func _mm256_mask_cvttpd_epu64 -- skipped func _mm256_maskz_cvttpd_epu64 -- skipped func _mm_cvttpd_epu64 -- skipped func _mm_mask_cvttpd_epu64 -- skipped func _mm_maskz_cvttpd_epu64 -- skipped func _mm256_cvtpd_epi64 -- skipped func _mm256_mask_cvtpd_epi64 -- skipped func _mm256_maskz_cvtpd_epi64 -- skipped func _mm_cvtpd_epi64 -- skipped func _mm_mask_cvtpd_epi64 -- skipped func _mm_maskz_cvtpd_epi64 -- skipped func _mm256_cvtpd_epu64 -- skipped func _mm256_mask_cvtpd_epu64 -- skipped func _mm256_maskz_cvtpd_epu64 -- skipped func _mm_cvtpd_epu64 -- skipped func _mm_mask_cvtpd_epu64 -- skipped func _mm_maskz_cvtpd_epu64 -- skipped func _mm256_cvttps_epi64 -- skipped func _mm256_mask_cvttps_epi64 -- skipped func _mm256_maskz_cvttps_epi64 -- skipped func _mm_cvttps_epi64 -- skipped func _mm_mask_cvttps_epi64 -- skipped func _mm_maskz_cvttps_epi64 -- skipped func _mm256_cvttps_epu64 -- skipped func _mm256_mask_cvttps_epu64 -- skipped func _mm256_maskz_cvttps_epu64 -- skipped func _mm_cvttps_epu64 -- skipped func _mm_mask_cvttps_epu64 -- skipped func _mm_maskz_cvttps_epu64 -- skipped func _mm256_broadcast_f64x2 -- skipped func _mm256_mask_broadcast_f64x2 -- skipped func _mm256_maskz_broadcast_f64x2 -- skipped func _mm256_broadcast_i64x2 -- skipped func _mm256_mask_broadcast_i64x2 -- skipped func _mm256_maskz_broadcast_i64x2 -- skipped func _mm256_broadcast_f32x2 -- skipped func _mm256_mask_broadcast_f32x2 -- skipped func _mm256_maskz_broadcast_f32x2 -- skipped func _mm256_broadcast_i32x2 -- skipped func _mm256_mask_broadcast_i32x2 -- skipped func _mm256_maskz_broadcast_i32x2 -- skipped func _mm_broadcast_i32x2 -- skipped func _mm_mask_broadcast_i32x2 -- skipped func _mm_maskz_broadcast_i32x2 -- skipped func _mm256_mullo_epi64 -- skipped func _mm256_mask_mullo_epi64 -- skipped func _mm256_maskz_mullo_epi64 -- skipped func _mm_mullo_epi64 -- skipped func _mm_mask_mullo_epi64 -- skipped func _mm_maskz_mullo_epi64 -- skipped func _mm256_mask_andnot_pd -- skipped func _mm256_maskz_andnot_pd -- skipped func _mm_mask_andnot_pd -- skipped func _mm_maskz_andnot_pd -- skipped func _mm256_mask_andnot_ps -- skipped func _mm256_maskz_andnot_ps -- skipped func _mm_mask_andnot_ps -- skipped func _mm_maskz_andnot_ps -- skipped func _mm256_cvtps_epi64 -- skipped func _mm256_mask_cvtps_epi64 -- skipped func _mm256_maskz_cvtps_epi64 -- skipped func _mm_cvtps_epi64 -- skipped func _mm_mask_cvtps_epi64 -- skipped func _mm_maskz_cvtps_epi64 -- skipped func _mm256_cvtps_epu64 -- skipped func _mm256_mask_cvtps_epu64 -- skipped func _mm256_maskz_cvtps_epu64 -- skipped func _mm_cvtps_epu64 -- skipped func _mm_mask_cvtps_epu64 -- skipped func _mm_maskz_cvtps_epu64 -- skipped func _mm256_cvtepi64_ps -- skipped func _mm256_mask_cvtepi64_ps -- skipped func _mm256_maskz_cvtepi64_ps -- skipped func _mm_cvtepi64_ps -- skipped func _mm_mask_cvtepi64_ps -- skipped func _mm_maskz_cvtepi64_ps -- skipped func _mm256_cvtepu64_ps -- skipped func _mm256_mask_cvtepu64_ps -- skipped func _mm256_maskz_cvtepu64_ps -- skipped func _mm_cvtepu64_ps -- skipped func _mm_mask_cvtepu64_ps -- skipped func _mm_maskz_cvtepu64_ps -- skipped func _mm256_cvtepi64_pd -- skipped func _mm256_mask_cvtepi64_pd -- skipped func _mm256_maskz_cvtepi64_pd -- skipped func _mm_cvtepi64_pd -- skipped func _mm_mask_cvtepi64_pd -- skipped func _mm_maskz_cvtepi64_pd -- skipped func _mm256_cvtepu64_pd -- skipped func _mm256_mask_cvtepu64_pd -- skipped func _mm256_maskz_cvtepu64_pd -- skipped func _mm256_mask_and_pd -- skipped func _mm256_maskz_and_pd -- skipped func _mm_mask_and_pd -- skipped func _mm_maskz_and_pd -- skipped func _mm256_mask_and_ps -- skipped func _mm256_maskz_and_ps -- skipped func _mm_mask_and_ps -- skipped func _mm_maskz_and_ps -- skipped func _mm_cvtepu64_pd -- skipped func _mm_mask_cvtepu64_pd -- skipped func _mm_maskz_cvtepu64_pd -- skipped func _mm256_mask_xor_pd -- skipped func _mm256_maskz_xor_pd -- skipped func _mm_mask_xor_pd -- skipped func _mm_maskz_xor_pd -- skipped func _mm256_mask_xor_ps -- skipped func _mm256_maskz_xor_ps -- skipped func _mm_mask_xor_ps -- skipped func _mm_maskz_xor_ps -- skipped func _mm256_mask_or_pd -- skipped func _mm256_maskz_or_pd -- skipped func _mm_mask_or_pd -- skipped func _mm_maskz_or_pd -- skipped func _mm256_mask_or_ps -- skipped func _mm256_maskz_or_ps -- skipped func _mm_mask_or_ps -- skipped func _mm_maskz_or_ps -- skipped func _mm_movm_epi32 -- skipped func _mm256_movm_epi32 -- skipped func _mm_movm_epi64 -- skipped func _mm256_movm_epi64 -- skipped func _mm_movepi32_mask -- skipped func _mm256_movepi32_mask -- skipped func _mm_movepi64_mask -- skipped func _mm256_movepi64_mask end avx512vldqintrin_h;
----------------------------------------------------------------------- -- mat-memory-tools - Tools for memory maps -- Copyright (C) 2014 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- package body MAT.Memory.Tools is -- ------------------------------ -- Collect the information about memory slot sizes for the memory slots in the map. -- ------------------------------ procedure Size_Information (Memory : in MAT.Memory.Allocation_Map; Sizes : in out Size_Info_Map) is procedure Update_Count (Size : in MAT.Types.Target_Size; Info : in out Size_Info_Type); procedure Collect (Addr : in MAT.Types.Target_Addr; Slot : in Allocation); procedure Update_Count (Size : in MAT.Types.Target_Size; Info : in out Size_Info_Type) is pragma Unreferenced (Size); begin Info.Count := Info.Count + 1; end Update_Count; procedure Collect (Addr : in MAT.Types.Target_Addr; Slot : in Allocation) is pragma Unreferenced (Addr); Pos : constant Size_Info_Cursor := Sizes.Find (Slot.Size); begin if Size_Info_Maps.Has_Element (Pos) then Sizes.Update_Element (Pos, Update_Count'Access); else declare Info : Size_Info_Type; begin Info.Count := 1; Sizes.Insert (Slot.Size, Info); end; end if; end Collect; Iter : Allocation_Cursor := Memory.First; begin while Allocation_Maps.Has_Element (Iter) loop Allocation_Maps.Query_Element (Iter, Collect'Access); Allocation_Maps.Next (Iter); end loop; end Size_Information; -- ------------------------------ -- Collect the information about threads and the memory allocations they've made. -- ------------------------------ procedure Thread_Information (Memory : in MAT.Memory.Allocation_Map; Threads : in out Memory_Info_Map) is procedure Collect (Addr : in MAT.Types.Target_Addr; Slot : in Allocation); procedure Collect (Addr : in MAT.Types.Target_Addr; Slot : in Allocation) is procedure Update_Count (Thread : in MAT.Types.Target_Thread_Ref; Info : in out Memory_Info); procedure Update_Count (Thread : in MAT.Types.Target_Thread_Ref; Info : in out Memory_Info) is pragma Unreferenced (Thread); Size : constant MAT.Types.Target_Size := Slot.Size; begin Info.Alloc_Count := Info.Alloc_Count + 1; if Size < Info.Min_Slot_Size then Info.Min_Slot_Size := Size; end if; if Size > Info.Max_Slot_Size then Info.Max_Slot_Size := Size; end if; if Addr < Info.Min_Addr then Info.Min_Addr := Addr; end if; if Addr + Size > Info.Max_Addr then Info.Max_Addr := Addr + Size; end if; Info.Total_Size := Info.Total_Size + Size; end Update_Count; Pos : constant Memory_Info_Cursor := Threads.Find (Slot.Thread); begin if Memory_Info_Maps.Has_Element (Pos) then Threads.Update_Element (Pos, Update_Count'Access); else declare Info : Memory_Info; begin Info.Total_Size := Slot.Size; Info.Alloc_Count := 1; Info.Min_Slot_Size := Slot.Size; Info.Max_Slot_Size := Slot.Size; Info.Min_Addr := Addr; Info.Max_Addr := Addr + Slot.Size; Threads.Insert (Slot.Thread, Info); end; end if; end Collect; Iter : Allocation_Cursor := Memory.First; begin while Allocation_Maps.Has_Element (Iter) loop Allocation_Maps.Query_Element (Iter, Collect'Access); Allocation_Maps.Next (Iter); end loop; end Thread_Information; -- ------------------------------ -- Collect the information about frames and the memory allocations they've made. -- ------------------------------ procedure Frame_Information (Memory : in MAT.Memory.Allocation_Map; Level : in Natural; Frames : in out Frame_Info_Map) is procedure Collect (Addr : in MAT.Types.Target_Addr; Slot : in Allocation); procedure Collect (Addr : in MAT.Types.Target_Addr; Slot : in Allocation) is procedure Update_Count (Frame_Addr : in MAT.Types.Target_Addr; Info : in out Frame_Info); procedure Update_Count (Frame_Addr : in MAT.Types.Target_Addr; Info : in out Frame_Info) is pragma Unreferenced (Frame_Addr); Size : constant MAT.Types.Target_Size := Slot.Size; begin Info.Memory.Alloc_Count := Info.Memory.Alloc_Count + 1; if Size < Info.Memory.Min_Slot_Size then Info.Memory.Min_Slot_Size := Size; end if; if Size > Info.Memory.Max_Slot_Size then Info.Memory.Max_Slot_Size := Size; end if; if Addr < Info.Memory.Min_Addr then Info.Memory.Min_Addr := Addr; end if; if Addr + Size > Info.Memory.Max_Addr then Info.Memory.Max_Addr := Addr + Size; end if; Info.Memory.Total_Size := Info.Memory.Total_Size + Size; end Update_Count; Frame : constant MAT.Frames.Frame_Table := MAT.Frames.Backtrace (Slot.Frame, Level); Pos : Frame_Info_Cursor; begin for I in Frame'Range loop Pos := Frames.Find (Frame (I)); if Frame_Info_Maps.Has_Element (Pos) then Frames.Update_Element (Pos, Update_Count'Access); else declare Info : Frame_Info; begin Info.Thread := Slot.Thread; Info.Memory.Total_Size := Slot.Size; Info.Memory.Alloc_Count := 1; Info.Memory.Min_Slot_Size := Slot.Size; Info.Memory.Max_Slot_Size := Slot.Size; Info.Memory.Min_Addr := Addr; Info.Memory.Max_Addr := Addr + Slot.Size; Frames.Insert (Frame (I), Info); end; end if; end loop; end Collect; Iter : Allocation_Cursor := Memory.First; begin while Allocation_Maps.Has_Element (Iter) loop Allocation_Maps.Query_Element (Iter, Collect'Access); Allocation_Maps.Next (Iter); end loop; end Frame_Information; -- ------------------------------ -- Find from the <tt>Memory</tt> map the memory slots whose address intersects -- the region [From .. To] and which is selected by the given filter expression. -- Add the memory slot in the <tt>Into</tt> list if it does not already contains -- the memory slot. -- ------------------------------ procedure Find (Memory : in MAT.Memory.Allocation_Map; From : in MAT.Types.Target_Addr; To : in MAT.Types.Target_Addr; Filter : in MAT.Expressions.Expression_Type; Into : in out MAT.Memory.Allocation_Map) is procedure Collect (Addr : in MAT.Types.Target_Addr; Slot : in Allocation); procedure Collect (Addr : in MAT.Types.Target_Addr; Slot : in Allocation) is begin if MAT.Expressions.Is_Selected (Filter, Addr, Slot) then Into.Insert (Addr, Slot); end if; end Collect; Iter : MAT.Memory.Allocation_Cursor := Memory.Ceiling (From); Pos : MAT.Memory.Allocation_Cursor; Addr : MAT.Types.Target_Addr; Size : MAT.Types.Target_Size; begin -- If there was no slot with the ceiling From address, we have to start from the last -- node because the memory slot may intersect our region. if not Allocation_Maps.Has_Element (Iter) then Iter := Memory.Last; if not Allocation_Maps.Has_Element (Iter) then return; end if; Addr := Allocation_Maps.Key (Iter); Size := Allocation_Maps.Element (Iter).Size; if Addr + Size < From then return; end if; end if; -- Move backward until the previous memory slot does not overlap anymore our region. -- In theory, going backward once is enough but if there was a target malloc issue, -- several malloc may overlap the same region (which is bad for the target). loop Pos := Allocation_Maps.Previous (Iter); exit when not Allocation_Maps.Has_Element (Pos); Addr := Allocation_Maps.Key (Pos); Size := Allocation_Maps.Element (Pos).Size; exit when Addr + Size < From; Iter := Pos; end loop; -- Add the memory slots until we moved to the end of the region. while Allocation_Maps.Has_Element (Iter) loop Addr := Allocation_Maps.Key (Iter); exit when Addr > To; Pos := Into.Find (Addr); if not Allocation_Maps.Has_Element (Pos) then Allocation_Maps.Query_Element (Iter, Collect'Access); end if; Allocation_Maps.Next (Iter); end loop; end Find; end MAT.Memory.Tools;
with STM32_SVD.Interrupts; with STM32GD.GPIO; use STM32GD.GPIO; with STM32GD.GPIO.Pin; with STM32GD.GPIO.Polled; with STM32GD.SPI; with STM32GD.SPI.Peripheral; with STM32GD.Timer; with STM32GD.Timer.Peripheral; with STM32GD.Board; with Drivers; with Drivers.NRF24; package Peripherals is package CE is new Pin (Pin => Pin_10, Port => Port_B, Mode => Mode_Out); package IRQ is new Pin (Pin => Pin_4, Port => Port_B, Mode => Mode_In); package Timer is new STM32GD.Timer.Peripheral; package Radio is new Drivers.NRF24 ( SPI => STM32GD.Board.SPI, Chip_Select => STM32GD.Board.CSN, Chip_Enable => CE, IRQ => IRQ); procedure Init; end Peripherals;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . A S Y N C H R O N O U S _ T A S K _ C O N T R O L -- -- -- -- S p e c -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. In accordance with the copyright of that document, you can freely -- -- copy and modify this specification, provided that if you redistribute a -- -- modified version, any changes that you have made are clearly indicated. -- -- -- ------------------------------------------------------------------------------ -- This unit is not implemented in typical GNAT implementations that lie on -- top of operating systems, because it is infeasible to implement in such -- environments. The RM anticipates this situation (RM D.11(10)), and permits -- an implementation to leave this unimplemented even if the Real-Time Systems -- annex is fully supported. -- If a target environment provides appropriate support for this package, then -- the Unimplemented_Unit pragma should be removed from this spec, and an -- appropriate body provided. The framework for such a body is included in the -- distributed sources. with Ada.Task_Identification; package Ada.Asynchronous_Task_Control is pragma Preelaborate; -- In accordance with Ada 2005 AI-362 pragma Unimplemented_Unit; procedure Hold (T : Ada.Task_Identification.Task_Id); procedure Continue (T : Ada.Task_Identification.Task_Id); function Is_Held (T : Ada.Task_Identification.Task_Id) return Boolean; end Ada.Asynchronous_Task_Control;
------------------------------------------------------------------------------ -- -- -- Matreshka Project -- -- -- -- Localization, Internationalization, Globalization for Ada -- -- -- -- Runtime Library Component -- -- -- ------------------------------------------------------------------------------ -- -- -- Copyright © 2013-2014, Vadim Godunko <vgodunko@gmail.com> -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- -- -- * Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- -- -- * Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in the -- -- documentation and/or other materials provided with the distribution. -- -- -- -- * Neither the name of the Vadim Godunko, IE nor the names of its -- -- contributors may be used to endorse or promote products derived from -- -- this software without specific prior written permission. -- -- -- -- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -- -- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -- -- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -- -- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -- -- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -- -- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED -- -- TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR -- -- PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF -- -- LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING -- -- NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -- -- SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -- -- -- ------------------------------------------------------------------------------ -- $Revision$ $Date$ ------------------------------------------------------------------------------ pragma Ada_2012; private with Ada.Finalization; limited with League.JSON.Documents; limited with League.JSON.Values; with League.Holders; private with Matreshka.JSON_Types; package League.JSON.Arrays is pragma Preelaborate; type JSON_Array is tagged private with Iterator_Element => League.JSON.Values.JSON_Value, Constant_Indexing => Element; pragma Preelaborable_Initialization (JSON_Array); Empty_JSON_Array : constant JSON_Array; procedure Append (Self : in out JSON_Array'Class; Value : League.JSON.Values.JSON_Value); -- Inserts value at the end of the array. procedure Delete (Self : in out JSON_Array'Class; Index : Positive); -- Removes the value at index position Index. Index must be a valid index -- position in the array. procedure Delete_First (Self : in out JSON_Array'Class); -- Removes the first item in the array. procedure Delete_Last (Self : in out JSON_Array'Class); -- Removes the last item in the array. function Element (Self : JSON_Array'Class; Index : Positive) return League.JSON.Values.JSON_Value; -- Returns a JSON_Value representing the value for index Index. function First_Element (Self : JSON_Array'Class) return League.JSON.Values.JSON_Value; -- Returns the first value stored in the array. procedure Insert (Self : in out JSON_Array'Class; Index : Positive; Value : League.JSON.Values.JSON_Value); -- Inserts value at index position Index in the array. If Index is 1, the -- value is prepended to the array. If Index is large when Length, the -- value is appended to the array. function Is_Empty (Self : JSON_Array'Class) return Boolean; -- Returns true if the object is empty. function Last_Element (Self : JSON_Array'Class) return League.JSON.Values.JSON_Value; -- Returns the last value stored in the array. function Length (Self : JSON_Array'Class) return Natural; -- Returns the number of values stored in the array. procedure Prepend (Self : in out JSON_Array'Class; Value : League.JSON.Values.JSON_Value); -- Inserts value at the beginning of the array. procedure Replace (Self : in out JSON_Array'Class; Index : Positive; Value : League.JSON.Values.JSON_Value); -- Replaces the item at index position Index with Value. Index must be a -- valid index position in the array. function Take (Self : in out JSON_Array'Class; Index : Positive) return League.JSON.Values.JSON_Value; -- Removes the item at index position Index and returns it. Index must be a -- valid index position in the array. function To_JSON_Value (Self : JSON_Array'Class) return League.JSON.Values.JSON_Value; -- Converts JSON_Array into JSON_Value. function To_JSON_Document (Self : JSON_Array'Class) return League.JSON.Documents.JSON_Document; -- Converts JSON_Array into JSON_Document. function First (Self : aliased JSON_Array) return League.Holders.Iterable_Holder_Cursors.Cursor'Class; -- Return cursor used in iterable holders private type JSON_Array is new Ada.Finalization.Controlled with record Data : Matreshka.JSON_Types.Shared_JSON_Array_Access := Matreshka.JSON_Types.Empty_Shared_JSON_Array'Access; end record; overriding procedure Adjust (Self : in out JSON_Array); overriding procedure Finalize (Self : in out JSON_Array); Empty_JSON_Array : constant JSON_Array := (Ada.Finalization.Controlled with Data => Matreshka.JSON_Types.Empty_Shared_JSON_Array'Access); end League.JSON.Arrays;
with Ada.Directories; use Ada.Directories; with GNATCOLL.Projects; use GNATCOLL.Projects; with GNATCOLL.VFS; use GNATCOLL.VFS; with Libadalang.Project_Provider; use Libadalang.Project_Provider; with Rejuvenation.File_Utils; use Rejuvenation.File_Utils; package body Rejuvenation.Simple_Factory is function Diagnostics_To_String (Unit : Analysis_Unit'Class) return String; -- Diagnostics to string -- ends with line feed function Diagnostics_To_String (Unit : Analysis_Unit'Class) return String is Message : Unbounded_String; begin for Diagnostic of Unit.Diagnostics loop Message := Message & Unit.Format_GNU_Diagnostic (Diagnostic) & ASCII.LF; end loop; return To_String (Message); end Diagnostics_To_String; procedure Put_Diagnostics (File : File_Type; Unit : Analysis_Unit) is begin Put (File, Diagnostics_To_String (Unit)); end Put_Diagnostics; procedure Put_Diagnostics (Unit : Analysis_Unit) is begin Put (Diagnostics_To_String (Unit)); end Put_Diagnostics; function Analyze_Fragment (Fragment : String; Rule : Grammar_Rule := Default_Grammar_Rule) return Analysis_Unit is Context : constant Analysis_Context := Create_Context; Unit : constant Analysis_Unit := Context.Get_From_Buffer ("Fragment", "", Fragment, Rule); begin if Unit.Has_Diagnostics then Put_Line ("On"); Put_Line (Fragment); Put_Line ("Parse Exception"); Put_Diagnostics (Unit); raise Parse_Exception with Diagnostics_To_String (Unit) & "On" & ASCII.LF & Fragment; else return Unit; end if; end Analyze_Fragment; function Analyze_File_In_Context (Filename : String; Context : Analysis_Context'Class) return Analysis_Unit; function Analyze_File_In_Context (Filename : String; Context : Analysis_Context'Class) return Analysis_Unit is Unit : constant Analysis_Unit := Context.Get_From_File (Filename); begin if Unit.Has_Diagnostics then raise Parse_Exception with Diagnostics_To_String (Unit) & "In" & ASCII.LF & Filename; else return Unit; end if; end Analyze_File_In_Context; function Analyze_File (Filename : String) return Analysis_Unit is Context : constant Analysis_Context := Create_Context; begin return Analyze_File_In_Context (Filename, Context); end Analyze_File; function Analyze_File_In_Project (Filename : String; Project_Filename : String) return Analysis_Unit is Project_File : constant Virtual_File := Create (+Project_Filename); Env : Project_Environment_Access; Project : constant Project_Tree_Access := new Project_Tree; begin Initialize (Env); Project.Load (Project_File, Env); declare Provider : constant Unit_Provider_Reference := Create_Project_Unit_Provider (Project, Project.Root_Project, Env); Context : constant Analysis_Context := Create_Context (Unit_Provider => Provider); begin return Analyze_File_In_Context (Filename, Context); end; end Analyze_File_In_Project; function Is_Ada_File (Tree : Project_Tree_Access; File : Virtual_File) return Boolean; function Is_Ada_File (Tree : Project_Tree_Access; File : Virtual_File) return Boolean is Info : constant File_Info := Tree.Info (Create (+File.Display_Full_Name)); begin return Info.Language = "ada"; end Is_Ada_File; function Get_Ada_Source_Files_From_Project (Project_Filename : String; Recursive : Boolean := True) return Unbounded_Strings.Vector is Project_File : constant Virtual_File := Create (+Project_Filename); Env : Project_Environment_Access; Project : constant Project_Tree_Access := new Project_Tree; Results : Unbounded_Strings.Vector; begin Initialize (Env); Project.Load (Project_File, Env); for File of Project.Root_Project.Source_Files (Recursive => Recursive, Include_Externally_Built => False).all loop if Is_Ada_File (Project, File) then Results.Append (To_Unbounded_String (+File.Full_Name)); end if; end loop; return Results; end Get_Ada_Source_Files_From_Project; function Get_Ada_Source_Files_From_Directory (Directory_Name : String; Recursive : Boolean := True) return Unbounded_Strings.Vector is Results : Unbounded_Strings.Vector; procedure Append (Item : Directory_Entry_Type); procedure Append (Item : Directory_Entry_Type) is begin Results.Append (To_Unbounded_String (Full_Name (Item))); end Append; begin Walk_Files (Directory_Name, File_Pattern => "*.ad[bs]", Process_File => Append'Access, Recursive => Recursive); return Results; end Get_Ada_Source_Files_From_Directory; function Analyze_Project (Project_Filename : String; Recursive : Boolean := True) return Analysis_Units.Vector is Project_File : constant Virtual_File := Create (+Project_Filename); Env : Project_Environment_Access; Project : constant Project_Tree_Access := new Project_Tree; begin Initialize (Env); Project.Load (Project_File, Env); declare Provider : constant Unit_Provider_Reference := Create_Project_Unit_Provider (Project, Project.Root_Project, Env); Context : constant Analysis_Context := Create_Context (Unit_Provider => Provider); Results : Analysis_Units.Vector; begin for File of Project.Root_Project.Source_Files (Recursive => Recursive, Include_Externally_Built => False).all loop if Is_Ada_File (Project, File) then Results.Append (Analyze_File_In_Context (+File.Full_Name, Context)); end if; end loop; return Results; end; end Analyze_Project; end Rejuvenation.Simple_Factory;
with DDS.Request_Reply.Tests.Simple.String_Replier; with DDS.Request_Reply.Tests.Simple.Octets_Replier; procedure DDS.Request_Reply.Tests.Simple.Server.Main is Listner : aliased Ref; Octets_Replier : Simple.Octets_Replier.Ref_Access := Simple.Octets_Replier.Create (Participant => Participant, Service_Name => Service_Name_Octets, Library_Name => Qos_Library, Profile_Name => Qos_Profile, A_Listner => Listner'Unchecked_Access, Mask => DDS.STATUS_MASK_ALL); String_Replier : Simple.String_Replier.Ref_Access := Simple.String_Replier.Create (Participant => Participant, Service_Name => Service_Name, Library_Name => Qos_Library, Profile_Name => Qos_Profile, A_Listner => Listner'Unchecked_Access, Mask => DDS.STATUS_MASK_ALL); Service_Time : constant Duration := 60 * 60.0; -- one hour begin delay Service_Time; Simple.String_Replier.Delete (String_Replier); Simple.Octets_Replier.Delete (Octets_Replier); end DDS.Request_Reply.Tests.Simple.Server.Main;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded; with GL.Objects.Programs; with GL.Types; with Multivectors; package Graphic_Data is Num_Names : Integer := 9; Model_Names : array (1 .. Num_Names) of Unbounded_String := (To_Unbounded_String ("teapot"), To_Unbounded_String ("cube"), To_Unbounded_String ("sphere"), To_Unbounded_String ("cone"), To_Unbounded_String ("torus"), To_Unbounded_String ("dodecahedron"), To_Unbounded_String ("octahedron"), To_Unbounded_String ("tetrahedron"), To_Unbounded_String ("icosahedron")); GLUT_Read_Exception : Exception; procedure Get_GLUT_Model_2D (Render_Program : GL.Objects.Programs.Program; Model_Name : Ada.Strings.Unbounded.Unbounded_String; Model_Rotor : Multivectors.Rotor); procedure Solid_Cube (Size : Float); procedure Solid_Cone (Base, Height : Float; Slices, Stacks : Integer); procedure Solid_Dodecahedron; procedure Solid_Icosahedron; procedure Solid_Octahedron; procedure Solid_Sphere (Radius : Float; Slices, Stacks : Integer); procedure Solid_Teapot (Size : Float); procedure Solid_Tetrahedron; procedure Solid_Torus (Inner_Radius, Outer_Radius : Float; Sides, Rings : Integer); end Graphic_Data;
with AUnit.Test_Cases; package Tc is type Test_Case is new AUnit.Test_Cases.Test_Case with null record; function Name (Test : Test_Case) return AUnit.Message_String; procedure Register_Tests (Test : in out Test_Case); end tc;
pragma Ada_2012; package body Line_Parsers.Receivers.Multi_Receivers is ------------- -- Receive -- ------------- overriding procedure Receive (Handler : in out Multi_Receiver; Name : String; Value : String; Position : Natural) is Basic : Basic_Receiver; begin Basic.Receive (Name, Value, Position); Handler.Values.Append (Basic); Handler.Set := True; end Receive; end Line_Parsers.Receivers.Multi_Receivers;
package Yeison_Experiments is -- Test the use of several function profiles with a single aspect type List is tagged private with Aggregate => (Empty => Empty, Add_Unnamed => Append); function Empty return List is (null record); procedure Append (L : in out List; I : Integer); Procedure Append (L : in out List; S : String); type Base is tagged null record; type Int is new Base with record I : Integer; end record; -- function Make return Base'Class is ((I => 1)); Fails with "Type of -- aggregate cannot be class-wide". This is the same problem afflicting -- our initializations of maps. function Make return Base'Class is (Int'(I => 1)); private type List is tagged null record; end Yeison_Experiments;
package Apollonius is type Point is record X, Y : Long_Float := 0.0; end record; type Circle is record Center : Point; Radius : Long_Float := 0.0; end record; type Tangentiality is (External, Internal); function Solve_CCC (Circle_1, Circle_2, Circle_3 : Circle; T1, T2, T3 : Tangentiality := External) return Circle; end Apollonius;
with Emulator_8080.Processor; private with GNAT.Sockets; package Emulator_8080.Vram_Sender is procedure Initialize(Port : in Natural; Ip_Address : in String); procedure Close; procedure Send_Vram(Vram : in Emulator_8080.Processor.Vram_Type); private Sender_Socket : GNAT.Sockets.Socket_Type; end Emulator_8080.Vram_Sender;
with Graphe; with Ada.Text_Io; use Ada.Text_Io; with Ada.Integer_Text_Io; use Ada.Integer_Text_Io; procedure Scenario_Graphe is subtype T_Etiquette_Sommet is Integer; type T_Etiquette_Arete is (A_Pour_Parent, A_Pour_Enfant, A_Pour_Frere, A_Pour_Conjoint); package Graphe_Genealogique is new Graphe (T_Etiquette_Sommet, T_Etiquette_Arete); use Graphe_Genealogique; Graphe1 : T_Graphe; Adjacence : T_Liste_Adjacence; Arete : T_Arete_Etiquetee; Sommet : T_Etiquette_Sommet; begin Initialiser (Graphe1); Ajouter_Sommet (Graphe1, 42); Ajouter_Sommet (Graphe1, 1337); Ajouter_Arete (Graphe1, 42, A_Pour_Parent, 1337); Ajouter_Arete (Graphe1, 1337, A_Pour_Enfant, 42); Ajouter_Sommet (Graphe1, 1); Ajouter_Sommet (Graphe1, 2); Ajouter_Sommet (Graphe1, 3); Ajouter_Arete (Graphe1, 42, A_Pour_Parent, 1); Ajouter_Arete (Graphe1, 1, A_Pour_Enfant, 42); Ajouter_Arete (Graphe1, 42, A_Pour_Frere, 2); Ajouter_Arete (Graphe1, 2, A_Pour_Frere, 42); Ajouter_Arete (Graphe1, 42, A_Pour_Conjoint, 3); Ajouter_Arete (Graphe1, 3, A_Pour_Conjoint, 42); Sommet := 42; --Get (Sommet); --Skip_Line; Chaine_Adjacence (Adjacence, Graphe1, Sommet); while Adjacence_Non_Vide (Adjacence) loop Arete_Suivante (Adjacence, Arete); Put (Sommet, 0); Put (" " & T_Etiquette_Arete'image(Arete.Etiquette) & " "); Put (Arete.Destination, 0); New_Line; end loop; Supprimer_Arete(Graphe1,42,A_Pour_Frere,2); New_Line; Sommet := 42; Chaine_Adjacence(Adjacence,Graphe1,Sommet); while Adjacence_Non_Vide (Adjacence) loop Arete_Suivante(Adjacence,Arete); Put(Sommet,0); Put(" " & T_Etiquette_Arete'image(Arete.Etiquette) & " "); Put(Arete.Destination,0); New_Line; end loop; Detruire (Graphe1); end Scenario_Graphe;
-- SPDX-FileCopyrightText: 2020 Max Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT ------------------------------------------------------------- with Program.Safe_Element_Visitors; package body Program.Simple_Resolvers is type Visitor (SR : not null Simple_Resolver_Access; Setter : not null Program.Cross_Reference_Updaters.Cross_Reference_Updater_Access) is new Program.Safe_Element_Visitors.Safe_Element_Visitor with null record; overriding procedure Identifier (Self : in out Visitor; Element : not null Program.Elements.Identifiers.Identifier_Access); ---------------- -- Identifier -- ---------------- overriding procedure Identifier (Self : in out Visitor; Element : not null Program.Elements.Identifiers.Identifier_Access) is begin Self.SR.Resolve_Identifier (Element, Self.Setter); end Identifier; ------------- -- Resolve -- ------------- procedure Resolve (Self : aliased in out Simple_Resolver'Class; Name : Program.Elements.Expressions.Expression_Access; Setter : not null Program.Cross_Reference_Updaters.Cross_Reference_Updater_Access) is V : Visitor (Self'Unchecked_Access, Setter); begin V.Visit (Name); end Resolve; end Program.Simple_Resolvers;
package p1 is type t1 is private ; private type t1 is record null; end record ; end ; with p1; use p1 ; package p2 is subtype same is t1 ; thing: same ; end ;
package Loop_Optimization10_Pkg is pragma Pure (Loop_Optimization10_Pkg); type Limit_Type is record Low : Float; High : Float; end record; function F (Low, High : in Float) return Limit_Type; end Loop_Optimization10_Pkg;
----------------------------------------------------------------------- -- util-serialize-io -- IO Drivers for serialization -- Copyright (C) 2010, 2011, 2016, 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Util.Streams.Files; with Ada.Streams; with Ada.Streams.Stream_IO; with Ada.Exceptions; with Ada.IO_Exceptions; package body Util.Serialize.IO is -- use Util.Log; use type Util.Log.Loggers.Logger_Access; -- The logger' Log : aliased constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Util.Serialize.IO", Util.Log.WARN_LEVEL); procedure Write_Attribute (Stream : in out Output_Stream'Class; Name : in String; Value : in Ada.Strings.Unbounded.Unbounded_String) is begin Stream.Write_Attribute (Name, Ada.Strings.Unbounded.To_String (Value)); end Write_Attribute; procedure Write_Entity (Stream : in out Output_Stream'Class; Name : in String; Value : in Ada.Strings.Unbounded.Unbounded_String) is begin Stream.Write_Entity (Name, Ada.Strings.Unbounded.To_String (Value)); end Write_Entity; procedure Write_Entity (Stream : in out Output_Stream'Class; Name : in String; Value : in Util.Nullables.Nullable_String) is begin if Value.Is_Null then Stream.Write_Null_Entity (Name); else Stream.Write_Entity (Name, Value.Value); end if; end Write_Entity; procedure Write_Entity (Stream : in out Output_Stream'Class; Name : in String; Value : in Util.Nullables.Nullable_Time) is begin if Value.Is_Null then Stream.Write_Null_Entity (Name); else Stream.Write_Entity (Name, Value.Value); end if; end Write_Entity; procedure Write_Entity (Stream : in out Output_Stream'Class; Name : in String; Value : in Util.Nullables.Nullable_Boolean) is begin if Value.Is_Null then Stream.Write_Null_Entity (Name); else Stream.Write_Entity (Name, Value.Value); end if; end Write_Entity; procedure Write_Entity (Stream : in out Output_Stream'Class; Name : in String; Value : in Util.Nullables.Nullable_Integer) is begin if Value.Is_Null then Stream.Write_Null_Entity (Name); else Stream.Write_Entity (Name, Value.Value); end if; end Write_Entity; procedure Write_Entity (Stream : in out Output_Stream'Class; Name : in String; Value : in Util.Nullables.Nullable_Long) is begin if Value.Is_Null then Stream.Write_Null_Entity (Name); else Stream.Write_Entity (Name, Integer (Value.Value)); end if; end Write_Entity; -- ------------------------------ -- Read the file and parse it using the JSON parser. -- ------------------------------ procedure Parse (Handler : in out Parser; File : in String; Sink : in out Reader'Class) is Stream : aliased Util.Streams.Files.File_Stream; Buffer : Util.Streams.Buffered.Input_Buffer_Stream; begin if Handler.Error_Logger = null then Handler.Error_Logger := Log'Access; end if; Handler.Error_Logger.Info ("Reading file {0}", File); Handler.File := Ada.Strings.Unbounded.To_Unbounded_String (File); Buffer.Initialize (Input => Stream'Unchecked_Access, Size => 1024); Stream.Open (Mode => Ada.Streams.Stream_IO.In_File, Name => File); Sink.Start_Document; Parser'Class (Handler).Parse (Buffer, Sink); exception -- when Util.Serialize.Mappers.Field_Fatal_Error => -- null; when Ada.IO_Exceptions.Name_Error => Parser'Class (Handler).Error ("File '" & File & "' does not exist."); when E : others => if not Handler.Error_Flag then Parser'Class (Handler).Error ("Exception " & Ada.Exceptions.Exception_Name (E)); end if; end Parse; -- ------------------------------ -- Parse the content string. -- ------------------------------ procedure Parse_String (Handler : in out Parser; Content : in String; Sink : in out Reader'Class) is Stream : aliased Util.Streams.Buffered.Input_Buffer_Stream; begin if Handler.Error_Logger = null then Handler.Error_Logger := Log'Access; end if; Handler.File := Ada.Strings.Unbounded.To_Unbounded_String ("<inline>"); Stream.Initialize (Content => Content); Sink.Start_Document; Parser'Class (Handler).Parse (Stream, Sink); exception -- when Util.Serialize.Mappers.Field_Fatal_Error => -- null; when E : others => if not Handler.Error_Flag then Parser'Class (Handler).Error ("Exception " & Ada.Exceptions.Exception_Name (E)); end if; end Parse_String; -- ------------------------------ -- Returns true if the <b>Parse</b> operation detected at least one error. -- ------------------------------ function Has_Error (Handler : in Parser) return Boolean is begin return Handler.Error_Flag; end Has_Error; -- ------------------------------ -- Set the error logger to report messages while parsing and reading the input file. -- ------------------------------ procedure Set_Logger (Handler : in out Parser; Logger : in Util.Log.Loggers.Logger_Access) is begin Handler.Error_Logger := Logger; end Set_Logger; -- ------------------------------ -- Get the current location (file and line) to report an error message. -- ------------------------------ function Get_Location (Handler : in Parser) return String is begin return Ada.Strings.Unbounded.To_String (Handler.File); end Get_Location; -- ------------------------------ -- Report an error while parsing the input stream. The error message will be reported -- on the logger associated with the parser. The parser will be set as in error so that -- the <b>Has_Error</b> function will return True after parsing the whole file. -- ------------------------------ procedure Error (Handler : in out Parser; Message : in String) is begin Handler.Error_Logger.Error ("{0}: {1}", Parser'Class (Handler).Get_Location, Message); Handler.Error_Flag := True; end Error; end Util.Serialize.IO;
-------------------------------------------- -- -- -- PACKAGE GAME - PARTIE ADA -- -- -- -- GAME-GTYPE.ADS -- -- -- -- Gestion des types -- -- -- -- Créateur : CAPELLE Mikaël -- -- Adresse : capelle.mikael@gmail.com -- -- -- -- Dernière modification : 14 / 06 / 2011 -- -- -- -------------------------------------------- with Interfaces.C, Interfaces.C.Extensions; use Interfaces.C, Interfaces.C.Extensions; package Game.gtype is -- Type utilisé pour l'activation ou la désactivation de fonction spécifique type Active is (ENABLE,DISABLE); Max_Profondeur : constant := 32; type Profondeur is range 0 .. Max_Profondeur ; Max_Size : constant Natural := 2**16 - 1; subtype Size is Natural range 0 .. Max_Size; Max_Coordonnee : constant Integer := 2**15 - 1; subtype Coord is Integer range (- Max_Coordonnee + 1) .. Max_Coordonnee; -- Type servant à définir un rectangle type Rect is record X,Y : Coord := 0; -- Point haut gauche du rectangle W,H : Size := 0; -- Largeur et Hauteur end record; -- Les fonctions suivantes retournent respectivement la largeur, la -- hauteur et la profondeur d'une Surface function Get_Width (S : in Surface) return Size; function Get_Height (S : in Surface) return Size; function Get_Depth (S : in Surface) return Profondeur; -- Retourne un Rect contenant la largeur et la hauteur de la Surface, -- les coordonnées X,Y du résultat sont mis (0,0) function Get_Rect(S : in Surface) return Rect; -- Type pour créer des couleurs à partir des composantes rouge, -- verte et bleu type Color is record R : Integer range 0..255; G : Integer range 0..255; B : Integer range 0..255; end record; -- Retourne la valeur d'une couleur à partir de son code hexadécimal -- Le code doit commencer par 0x -- Ex : +"0xff00ff" retourne (255,0,255) -- +"0x000000" retourne (0,0,0) -- L'utilisation d'un mauvais code hexadécimal lève l'exception Constraint_Error function "+" (S : in String) return Color; -- Valeur de différentes couleurs basique Blanc : constant Color := (255,255,255); Noir : constant Color := ( 0, 0, 0); Rouge : constant Color := (255, 0, 0); Bleu : constant Color := ( 0, 0,255); Violet : constant Color := (255, 0,255); Jaune : constant Color := (255,255, 0); Vert : constant Color := ( 0,255, 0); Cyan : constant Color := ( 0,255,255); ------------------------------------------------------------------------------------ ---------------------- Partie INUTILE pour l'utilisateur --------------------------- ------------------------------------------------------------------------------------ type C_Rect is record X,Y : Signed_16; W,H : Unsigned_16; end record; pragma Convention(C,C_Rect); function To_C_Rect (Re : in Rect) return C_Rect; type C_Color is record R,G,B,U : Unsigned_8; end record; pragma Convention(C,C_Color); function To_C_Col (C : in Color) return C_Color; end Game.gtype;
with physics.Space, physics.Joint, physics.Object, lace.Observer, lace.Any, ada.Tags; package physics.Engine -- -- Provides a task which evolves a physical space. -- is type Item is tagged limited private; type View is access all Item'Class; -- procedure start (Self : access Item; space_Kind : in physics.space_Kind); procedure start (Self : access Item; the_Space : in Space.view); procedure stop (Self : access Item); procedure add (Self : access Item; the_Object : in Object.view); procedure rid (Self : in out Item; the_Object : in Object.view); procedure add (Self : in out Item; the_Joint : in Joint.view); procedure rid (Self : in out Item; the_Joint : in Joint.view); procedure update_Scale (Self : in out Item; of_Object : in Object.view; To : in math.Vector_3); procedure apply_Force (Self : in out Item; to_Object : in Object.view; Force : in math.Vector_3); procedure update_Site (Self : in out Item; of_Object : in Object.view; To : in math.Vector_3); procedure set_Speed (Self : in out Item; of_Object : in Object.view; To : in math.Vector_3); procedure set_Gravity (Self : in out Item; To : in math.Vector_3); procedure set_xy_Spin (Self : in out Item; of_Object : in Object.view; To : in math.Radians); procedure update_Bounds (Self : in out Item; of_Object : in Object.view); procedure set_local_Anchor (Self : in out Item; for_Joint : in Joint.view; To : in math.Vector_3; is_Anchor_A : in Boolean); private task type Evolver (Self : access Engine.item'Class) is -- entry start (space_Kind : in physics.space_Kind); entry start (the_Space : in Space.view); entry stop; entry reset_Age; pragma Storage_Size (20_000_000); end Evolver; -- Engine Commands -- type Any_limited_view is access all lace.Any.limited_item'Class; type command_Kind is (add_Object, rid_Object, scale_Object, destroy_Object, update_Bounds, update_Site, set_Speed, apply_Force, set_xy_Spin, add_Joint, rid_Joint, set_Joint_local_Anchor, free_Joint, cast_Ray, -- new_impact_Response, set_Gravity); type Command (Kind : command_Kind := command_Kind'First) is record Object : physics.Object.view; case Kind is when add_Object => add_Children : Boolean; -- Model : physics.Model.view; when rid_Object => rid_Children : Boolean; when update_Site => Site : math.Vector_3; when scale_Object => Scale : math.Vector_3; when apply_Force => Force : math.Vector_3; when set_Speed => Speed : math.Vector_3; when set_Gravity => Gravity : math.Vector_3; when set_xy_Spin => xy_Spin : math.Radians; when add_Joint | rid_Joint | free_Joint => Joint : physics.Joint.view; when set_Joint_local_Anchor => anchor_Joint : physics.Joint.view; is_Anchor_A : Boolean; -- When false, is anchor B. local_Anchor : math.Vector_3; when cast_Ray => From, To : math.Vector_3; Observer : lace.Observer.view; Context : Any_limited_view; event_Kind : ada.Tags.Tag; -- when new_impact_Response => -- Filter : impact_Filter; -- Response : impact_Response; when others => null; end case; end record; type Commands is array (Positive range 1 .. 200_000) of Command; protected type safe_command_Set is function is_Empty return Boolean; procedure add (the_Command : in Command); procedure Fetch (To : out Commands; Count : out Natural); private Set : Commands; the_Count : Natural := 0; end safe_command_Set; type safe_command_Set_view is access all safe_command_Set; type Item is tagged limited record Age : Duration := 0.0; Space : physics.Space.view; Commands : safe_command_Set_view := new safe_command_Set; Evolver : engine.Evolver (Item'Access); end record; end physics.Engine;
--- src/core/aws-net.adb.orig 2021-05-19 05:14:31 UTC +++ src/core/aws-net.adb @@ -655,7 +655,7 @@ package body AWS.Net is -- to be shure that it is S1 and S2 connected together - exit when Peer_Addr (STC (S2)) = Local_Host + exit when Peer_Addr (STC (S2)) = Get_Addr (STC (S1)) and then Peer_Port (STC (S2)) = Get_Port (STC (S1)) and then Peer_Port (STC (S1)) = Get_Port (STC (S2));
with Ada.Text_IO; use Ada.Text_IO; with Ada.Strings.Fixed; use Ada.Strings.Fixed; procedure Multiplication_Table is package IO is new Integer_IO (Integer); use IO; begin Put (" | "); for Row in 1..12 loop Put (Row, Width => 4); end loop; New_Line; Put_Line ("--+-" & 12 * 4 * '-'); for Row in 1..12 loop Put (Row, Width => 2); Put ("| "); for Column in 1..12 loop if Column < Row then Put (" "); else Put (Row * Column, Width => 4); end if; end loop; New_Line; end loop; end Multiplication_Table;
with Types; package Printer is function Pr_Str (M : Types.Lovelace_Handle) return String; end Printer;
------------------------------------------------------------------------------ -- GNAT COMPILER COMPONENTS -- -- -- -- G N A T . R E W R I T E _ D A T A -- -- -- -- S p e c -- -- -- -- Copyright (C) 2014-2019, 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. -- -- -- ------------------------------------------------------------------------------ -- This package can be used to rewrite data on the fly. All occurrences of a -- string (named pattern) will be replaced by another string. -- It is not necessary to load all data in memory and so this package can be -- used for large data chunks like disk files for example. The pattern is -- a standard string and not a regular expression. -- There is no dynamic allocation in the implementation. -- For example, to replace all occurrences of "Gnat" with "GNAT": -- Rewriter : Buffer := Create (Pattern => "Gnat", Value => "GNAT"); -- The output procedure that will receive the rewritten data: -- procedure Do (Data : Stream_Element_Array) is -- begin -- <implementation to handle Data> -- end Do; -- Then: -- Write (Rewriter, "Let's talk about Gnat compiler", Do'Access); -- Write (Rewriter, "Gnat is an Ada compiler", Do'Access); -- Flush (Rewriter, Do'Access); -- Another possible usage is to specify a method to get the input data: -- procedure Get -- (Buffer : out Stream_Element_Array; -- Last : out Stream_Element_Offset) -- is -- begin -- <get some data from a file, a socket, etc...> -- Last := ... -- Buffer := ... -- end Get; -- Then we can rewrite the whole file with: -- Rewrite (Rewriter, Input => Get'Access, Output => Do'Access); with Ada.Streams; use Ada.Streams; package GNAT.Rewrite_Data is type Buffer (<>) is limited private; type Buffer_Ref is access all Buffer; function Create (Pattern, Value : String; Size : Stream_Element_Offset := 1_024) return Buffer; -- Create a rewrite buffer. Pattern is the string to be rewritten as Value. -- Size represents the size of the internal buffer used to store the data -- ready to be output. A larger buffer may improve the performance, as the -- Output routine (see Write, Rewrite below) will be called only when this -- buffer is full. Note that Size cannot be lower than Pattern'Length, and -- if this is the case, then Size value is set to Pattern'Length. function Size (B : Buffer) return Natural; -- Returns the current size of the buffer (count of Stream_Array_Element) procedure Flush (B : in out Buffer; Output : not null access procedure (Data : Stream_Element_Array)); -- Call Output for all remaining data in the buffer. The buffer is -- reset and ready for another use after this call. procedure Reset (B : in out Buffer); pragma Inline (Reset); -- Clear all data in buffer, B is ready for another use. Note that this is -- not needed after a Flush. Note: all data remaining in Buffer is lost. procedure Write (B : in out Buffer; Data : Stream_Element_Array; Output : not null access procedure (Data : Stream_Element_Array)); -- Write Data into the buffer, call Output for any prepared data. Flush -- must be called when the last piece of Data as been sent in the Buffer. procedure Rewrite (B : in out Buffer; Input : not null access procedure (Buffer : out Stream_Element_Array; Last : out Stream_Element_Offset); Output : not null access procedure (Data : Stream_Element_Array)); -- Read data from Input, rewrite it, and then call Output. When there is -- no more data to be read from Input, Last must be set to 0. Before -- leaving this routine, call Flush above to send all remaining data to -- Output. procedure Link (From : in out Buffer; To : Buffer_Ref); -- Link two rewrite buffers. That is, all data sent to From buffer will be -- rewritten and then passed to the To rewrite buffer. private type Buffer (Size, Size_Pattern, Size_Value : Stream_Element_Offset) is limited record Pos_C : Stream_Element_Offset; -- last valid element in Current Pos_B : Stream_Element_Offset; -- last valid element in Buffer Next : Buffer_Ref; -- A link to another rewriter if any Buffer : Stream_Element_Array (1 .. Size); -- Fully prepared/rewritten data waiting to be output Current : Stream_Element_Array (1 .. Size_Pattern); -- Current data checked, this buffer contains every piece of data -- starting with the pattern. It means that at any point: -- Current (1 .. Pos_C) = Pattern (1 .. Pos_C). Pattern : Stream_Element_Array (1 .. Size_Pattern); -- The pattern to look for Value : Stream_Element_Array (1 .. Size_Value); -- The value the pattern is replaced by end record; end GNAT.Rewrite_Data;
with Interfaces.C; use Interfaces.C; package JNI_MD is -- pragma Pure; subtype jint is int; subtype jlong is long; subtype jbyte is signed_char; end JNI_MD;
-- WORDS, a Latin dictionary, by Colonel William Whitaker (USAF, Retired) -- -- Copyright William A. Whitaker (1936–2010) -- -- This is a free program, which means it is proper to copy it and pass -- it on to your friends. Consider it a developmental item for which -- there is no charge. However, just for form, it is Copyrighted -- (c). Permission is hereby freely given for any and all use of program -- and data. You can sell it as your own, but at least tell me. -- -- This version is distributed without obligation, but the developer -- would appreciate comments and suggestions. -- -- All parts of the WORDS system, source code and data files, are made freely -- available to anyone who wishes to use them, for whatever purpose. with Ada.Text_IO; procedure Slash is package Integer_IO is new Ada.Text_IO.Integer_IO (Integer); use Ada.Text_IO; use Integer_IO; F1, F2, F3 : File_Type; F : String (1 .. 100); S : String (1 .. 2500); Bs : constant String (1 .. 2500) := (others => ' '); N : Integer := 0; L : Integer := 0; Ls : Integer := 0; type Reply_Type is (Columns, Lines); Reply : Reply_Type; Reply_Character : Character; function Which (R : Character) return Reply_Type is begin case R is when 'C' | 'c' => return Columns; when 'L' | 'l' => return Lines; when others => raise Data_Error; end case; end Which; begin Put_Line ("Breaks a file into two, by row or column."); Put ("What file to SLASH from =>"); Get_Line (F, L); Put ("=> "); Open (F1, In_File, F (1 .. L)); Put_Line ("Opened input file"); Put ("Do you wish to SLASH C)olumns or L)ines? =>"); Get (Reply_Character); Skip_Line; Reply := Which (Reply_Character); New_Line; Put ("How many lines/columns to leave after SLASHing =>"); Get (N); Skip_Line; New_Line; Put ("Where to put the first =>"); Get_Line (F, L); Put ("=> "); Create (F2, Out_File, F (1 .. L)); Put_Line ("Created SLASH file first"); Put ("Where to put the rest =>"); Get_Line (F, L); Put ("=> "); Create (F3, Out_File, F (1 .. L)); Put_Line ("Created SLASH file rest"); if Reply = Columns then while not End_Of_File (F1) loop S := Bs; Get_Line (F1, S, Ls); if Ls <= N then -- Line shorter than break Put_Line (F2, S (1 .. Ls)); Put_Line (F3, ""); -- Put a blank line so there will be a line else -- Line runs past break Put_Line (F2, S (1 .. N)); Put_Line (F3, S (N + 1 .. Ls)); end if; end loop; Close (F2); Close (F3); elsif Reply = Lines then First : begin for I in 1 .. N loop Get_Line (F1, S, Ls); Put_Line (F2, S (1 .. Ls)); end loop; exception when End_Error => null; end First; Close (F2); Second : begin loop Get_Line (F1, S, Ls); Put_Line (F3, S (1 .. Ls)); end loop; exception when End_Error => null; end Second; Close (F3); end if; Put_Line ("Done SLASHing"); exception when Data_Error => Put_Line ("***************** WRONG REPLY *****************"); New_Line (2); Put_Line ("Try again"); when others => New_Line (2); Put_Line ("Unexpected exception raised in SLASH *********"); end Slash;
----------------------------------------------------------------------- -- hestia-scheduler -- Hestia Scheduler -- Copyright (C) 2016, 2017 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with UI.Texts; package body Hestia.Scheduler is use type Hestia.Time.Day_Name; use type Hestia.Time.Minute_Number; type Schedule_Array_Type is array (Scheduler_Index) of Schedule_Type; Zones : Schedule_Array_Type; Schedule_Middle : constant Schedule_Unit := (Schedule_Unit'Last - Schedule_Unit'First) / 2; -- Button colors (inactive). Hot_Color : constant HAL.Bitmap.Bitmap_Color := HAL.Bitmap.Red; Cold_Color : constant HAL.Bitmap.Bitmap_Color := HAL.Bitmap.Blue; Now_Color : constant HAL.Bitmap.Bitmap_Color := HAL.Bitmap.White_Smoke; -- ------------------------------ -- Compare two scheduler day and time. -- ------------------------------ function "<" (Left, Right : in Day_Time) return Boolean is begin if Left.Day < Right.Day then return True; elsif Left.Day > Right.Day then return False; elsif Left.Hour < Right.Hour then return True; elsif Left.Hour > Right.Hour then return False; else return Left.Minute < Right.Minute; end if; end "<"; -- ------------------------------ -- Add some minutes to the scheduler day and time. -- ------------------------------ function "+" (Date : in Day_Time; Minutes : in Natural) return Day_Time is use Hestia.Time; Result : Day_Time := Date; Mins : Natural := (Date.Minute + Minutes) mod 60; Hours : Natural := Date.Hour + ((Date.Minute + Minutes) / 60); Days : Natural := Hours / 24; begin while Days > 0 loop if Result.Day = Day_Name'Last then Result.Day := Day_Name'First; else Result.Day := Day_Name'Succ (Result.Day); end if; Days := Days - 1; end loop; Result.Hour := Hours mod 24; Result.Minute := Mins; return Result; end "+"; -- ------------------------------ -- Subtract two scheduler day and time and get the difference in minutes. -- ------------------------------ function "-" (Left, Right : in Day_Time) return Integer is use Hestia.Time; L1 : Natural := Day_Name'Pos (Left.Day) * 24 * 60 + Left.Hour * 60 + Left.Minute; L2 : Natural := Day_Name'Pos (Right.Day) * 24 * 60 + Right.Hour * 60 + Right.Minute; begin return L1 - L2; end "-"; -- ------------------------------ -- Format the time. -- ------------------------------ function Format_Time (Date : in Day_Time) return String is H : constant String := Hestia.Time.Hour_Number'Image (Date.Hour); M : String := Hestia.Time.Minute_Number'Image (Date.Minute); begin if Date.Minute < 10 then return H (H'First + 1 .. H'Last) & ":0" & M (M'First + 1 .. M'Last); else return H (H'First + 1 .. H'Last) & ":" & M (M'First + 1 .. M'Last); end if; end Format_Time; function Get_State (Date : in Hestia.Time.Date_Time; Zone : in Scheduler_Index) return State_Type is Pos : Schedule_Unit; begin Pos := Schedule_Unit (Date.Hour * 12) + Schedule_Unit (Date.Minute / 5); return Zones (Zone).Week (Date.Week_Day) (Pos); end Get_State; -- ------------------------------ -- Get the scheduler state for the given day and time. -- ------------------------------ function Get_State (Date : in Day_Time; Zone : in Scheduler_Index) return State_Type is Pos : Schedule_Unit; begin Pos := Schedule_Unit (Date.Hour * 12) + Schedule_Unit (Date.Minute / 5); return Zones (Zone).Week (Date.Day) (Pos); end Get_State; -- ------------------------------ -- Set the scheduler state for the given day and time. -- ------------------------------ procedure Set_State (Date : in Day_Time; Zone : in Scheduler_Index; State : in State_Type) is Pos : Schedule_Unit; begin Pos := Schedule_Unit (Date.Hour * 12) + Schedule_Unit (Date.Minute / 5); Zones (Zone).Week (Date.Day) (Pos) := State; end Set_State; -- ------------------------------ -- Display the heat schedule on the display based on the current date and time. -- ------------------------------ procedure Display (Buffer : in out HAL.Bitmap.Bitmap_Buffer'Class; Date : in Hestia.Time.Date_Time) is Pos : Schedule_Unit; Start : Schedule_Unit; X : Natural := 100; Y : Natural := 180; W : constant Natural := Buffer.Width - X; Count : constant Natural := Natural (Schedule_Unit'Last - Schedule_Unit'First); begin Pos := Schedule_Unit (Date.Hour * 12) + Schedule_Unit (Date.Minute / 5); for Zone in Zones'Range loop if Zones (Zone).Week (Date.Week_Day) (Pos) = ON then Hestia.Ports.Set_Zone (Zone, Hestia.Ports.H_CONFORT); else Hestia.Ports.Set_Zone (Zone, Hestia.Ports.H_ECO); end if; end loop; Y := 165; for Zone in Zones'Range loop UI.Texts.Draw_String (Buffer, (100, Y), 250, Zones (Zone).Name); Y := Y + 30; end loop; if Pos >= Schedule_Middle then Start := Pos - Schedule_Middle; else Start := Pos + Schedule_Middle; end if; for I in Schedule_Unit'First .. Schedule_Unit'Last loop X := 100 + (Natural (I) * W) / Count; Y := 180; for Zone in Zones'Range loop if Zones (Zone).Week (Date.Week_Day) (Start) = ON then Buffer.Set_Source (Hot_Color); else Buffer.Set_Source (Cold_Color); end if; if Y + (W / Count) + 1 < W then Buffer.Fill_Rect (Area => (Position => (X, Y), Width => (W / Count) + 1, Height => 10)); else Buffer.Fill_Rect (Area => (Position => (X, Y), Width => (W / Count), Height => 10)); end if; Y := Y + 30; end loop; if Start = Schedule_Unit'Last then Start := Schedule_Unit'First; else Start := Start + 1; end if; end loop; Buffer.Set_Source (Now_Color); Buffer.Draw_Vertical_Line (Pt => (100 + W / 2, 180 - 5), Height => 30 + 30 + 20); end Display; begin Zones (1).Name := "Salon "; Zones (2).Name := "Chambres "; Zones (3).Name := "Salles de bains "; for Day in Hestia.Time.Day_Name'Range loop -- On from 7:00 to 22:00. Zones (1).Week (Day) := (84 .. 264 => ON, others => OFF); -- On from 7:00 to 10:00 and 18:00 to 22:00. Zones (2).Week (Day) := (84 .. 120 => ON, 216 .. 260 => ON, others => OFF); -- On from 7:00 to 10:00 and 18:00 to 22:00. Zones (3).Week (Day) := (84 .. 120 => ON, 216 .. 260 => ON, others => OFF); end loop; end Hestia.Scheduler;
------------------------------------------------------------------------------ -- -- -- ASIS-for-GNAT IMPLEMENTATION COMPONENTS -- -- -- -- A S I S . I M P L E M E N T A T I O N . P E R M I S S I O N S -- -- -- -- B o d y -- -- -- -- Copyright (C) 1995-2007, 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). -- -- -- ------------------------------------------------------------------------------ package body Asis.Implementation.Permissions is ------------------------------ -- Attributes_Are_Supported -- ------------------------------ function Attributes_Are_Supported return Boolean is begin return False; end Attributes_Are_Supported; ------------------------------------------ -- Call_Statement_Parameters_Normalized -- ------------------------------------------ function Call_Statement_Parameters_Normalized return Boolean is begin return False; end Call_Statement_Parameters_Normalized; ------------------------------- -- Default_In_Mode_Supported -- ------------------------------- function Default_In_Mode_Supported return Boolean is begin return True; end Default_In_Mode_Supported; ------------------------------------------ -- Discriminant_Associations_Normalized -- ------------------------------------------ function Discriminant_Associations_Normalized return Boolean is begin return False; end Discriminant_Associations_Normalized; ----------------------------------------- -- Function_Call_Parameters_Normalized -- ----------------------------------------- function Function_Call_Parameters_Normalized return Boolean is begin return False; end Function_Call_Parameters_Normalized; ------------------------------------ -- Generic_Actual_Part_Normalized -- ------------------------------------ function Generic_Actual_Part_Normalized return Boolean is begin return False; end Generic_Actual_Part_Normalized; --------------------------------------- -- Generic_Macro_Expansion_Supported -- --------------------------------------- function Generic_Macro_Expansion_Supported return Boolean is begin return True; end Generic_Macro_Expansion_Supported; ----------------------------------- -- Implicit_Components_Supported -- ----------------------------------- function Implicit_Components_Supported return Boolean is begin return False; end Implicit_Components_Supported; -------------------------------------- -- Inherited_Declarations_Supported -- -------------------------------------- function Inherited_Declarations_Supported return Boolean is begin return True; end Inherited_Declarations_Supported; ------------------------------------- -- Inherited_Subprograms_Supported -- ------------------------------------- function Inherited_Subprograms_Supported return Boolean is begin return True; end Inherited_Subprograms_Supported; ----------------------------- -- Is_Commentary_Supported -- ----------------------------- function Is_Commentary_Supported return Boolean is begin return True; end Is_Commentary_Supported; -------------------------------------------------- -- Is_Formal_Parameter_Named_Notation_Supported -- -------------------------------------------------- function Is_Formal_Parameter_Named_Notation_Supported return Boolean is begin return True; end Is_Formal_Parameter_Named_Notation_Supported; ------------------------------ -- Is_Line_Number_Supported -- ------------------------------ function Is_Line_Number_Supported return Boolean is begin return True; end Is_Line_Number_Supported; ------------------------------ -- Is_Prefix_Call_Supported -- ------------------------------ function Is_Prefix_Call_Supported return Boolean is begin return True; end Is_Prefix_Call_Supported; --------------------------------------- -- Is_Span_Column_Position_Supported -- --------------------------------------- function Is_Span_Column_Position_Supported return Boolean is begin return True; end Is_Span_Column_Position_Supported; ------------------------------------ -- Object_Declarations_Normalized -- ------------------------------------ function Object_Declarations_Normalized return Boolean is begin return False; end Object_Declarations_Normalized; ------------------------------------- -- Predefined_Operations_Supported -- ------------------------------------- function Predefined_Operations_Supported return Boolean is begin return False; end Predefined_Operations_Supported; ---------------------------------------------- -- Record_Component_Associations_Normalized -- ---------------------------------------------- function Record_Component_Associations_Normalized return Boolean is begin return False; end Record_Component_Associations_Normalized; end Asis.Implementation.Permissions;
with Ada.Text_IO, Ada.Command_Line, Generic_Perm; procedure Print_Perms is package CML renames Ada.Command_Line; package TIO renames Ada.Text_IO; begin declare package Perms is new Generic_Perm(Positive'Value(CML.Argument(1))); P : Perms.Permutation; Done : Boolean := False; procedure Print(P: Perms.Permutation) is begin for I in P'Range loop TIO.Put (Perms.Element'Image (P (I))); end loop; TIO.New_Line; end Print; begin Perms.Set_To_First(P, Done); loop Print(P); exit when Done; Perms.Go_To_Next(P, Done); end loop; end; exception when Constraint_Error => TIO.Put_Line ("*** Error: enter one numerical argument n with n >= 1"); end Print_Perms;
-- -- -- with Ada.Text_IO; with Rules; with Types; with Symbols.IO; package body Debugs is procedure JQ_Dump_Rules (Session : in Sessions.Session_Type; Mode : in Integer) is use Ada.Text_IO; use type Rules.Rule_Symbol_Access; subtype Index_Number is Rules.Index_Number; subtype Rule_Number is Rules.Rule_Number; subtype Line_Number is Types.Line_Number; begin for Rule of Session.Rule loop Put ("RULE INDEX"); Put (Index_Number'Image (Rule.Index)); Put (" RULE"); Put (Rule_Number'Image (Rule.Number)); Put (" LINE"); Put (Line_Number'Image (Rule.Line)); Put (" RULELINE"); Put (Line_Number'Image (Rule.Rule_Line)); if Mode = 1 then Put (" PREC"); if Rule.Prec_Symbol = null then Put (" <null>"); else Put (Types.Symbol_Index'Image (Rule.Prec_Symbol.Index)); end if; end if; New_Line; end loop; end JQ_Dump_Rules; procedure Put_States (Session : in Sessions.Session_Type; Mode : in Integer) is begin for State of Session.Sorted loop Put_State (State); Ada.Text_IO.New_Line; if Mode = 1 then Put_Configs (Session, Config_List => State.Config); end if; end loop; end Put_States; procedure Put_State (State : in States.State_Access) is use Ada.Text_IO; use States; begin Put ("NUM"); Put (State.Number'Image); Put (" AC.LEN"); Put (" 999"); -- Put (State.Action.Length'Image); end Put_State; procedure Put_Configs (Session : in Sessions.Session_Type; Config_List : in Configs.Config_Access) is use Configs; Config : Config_Access := Config_List; begin while Config /= null loop Put_Config (Session, Config); Ada.Text_IO.New_Line; Config := Config.Next; end loop; end Put_Configs; procedure Put_Config (Session : in Sessions.Session_Type; Config : in Configs.Config_Access) is use Ada.Text_IO; use Configs; begin Put (" "); Put ("RULE"); Put (Config.Rule.Index'Image); Put (" DOT"); Put (Config.Dot'Image); -- Put ("STATE"); Put (" STATUS "); Put (Config.Status'Image); Put (" FS "); Symbols.IO.Put_Named (Session, Set => Config.Follow_Set); end Put_Config; procedure Debug (On : in Boolean; Message : in String) is begin if On then Ada.Text_IO.Put_Line (Message); end if; end Debug; end Debugs;
-- -- Raytracer implementation in Ada -- by John Perry (github: johnperry-math) -- 2021 -- -- specification for Colors, both RGB ("Color_Type") -- and RGBA ("Transparent_Color_Type") -- -- local packages with RayTracing_Constants; use RayTracing_Constants; -- @summary -- specification for Colors, both RGB ("Color_Type") -- and RGBA ("Transparent_Color_Type") package Colors is type Color_Type is record Blue, Green, Red: Float15; end record; -- RGB channels only; for transparency channel see Color_With_Transparency White: constant Color_Type := ( 1.0, 1.0, 1.0 ); Grey: constant Color_Type := ( 0.5, 0.5, 0.5 ); Black: constant Color_Type := ( 0.0, 0.0, 0.0 ); Background: constant Color_Type := Black; Default_Color: constant Color_Type := Black; type Color_With_Transparency_Type is record Blue, Green, Red, Alpha: UInt8; end record; -- R, G, B, and Alpha (transparency) channels function Create_Color( Red, Green, Blue: Float15 ) return Color_Type; function Scale( Color: Color_Type; K: Float15 ) return Color_Type; -- scales Color by a factor of K, returns result pragma Inline_Always(Scale); procedure Scale_Self( Color: in out Color_Type; K: Float15 ); -- scales Color by a factor of K, modifies self pragma Inline_Always(Scale); function "*"(First, Second: Color_Type) return Color_Type; -- componentwise product of First and Second, returns result pragma Inline_Always("*"); procedure Color_Multiply_Self(First: in out Color_Type; Second: Color_Type); pragma Inline_Always(Color_Multiply_Self); function "+"(First, Second: Color_Type) return Color_Type; -- returns sum of First and Second pragma Inline_Always("+"); function Legalize(C: Float15) return UInt8; -- modifies C, expected in the range 0.0 .. 1.0, to the range 0 .. 255, -- with values less than 0.0 converted to 0, and values greater than 1.0 -- converted to 255 pragma Inline_Always(Legalize); function To_Drawing_Color(C: Color_Type) return Color_With_Transparency_Type; -- converts RGB to RGBA with A = 255 pragma Inline_Always(To_Drawing_Color); end Colors;
with STM32GD.GPIO.Pin; generic with package Pin is new STM32GD.GPIO.Pin (<>); package STM32GD.GPIO.IRQ is procedure Configure_Trigger (Event : Boolean := False; Rising : Boolean := False; Falling : Boolean := False); procedure Wait_For_Trigger; procedure Clear_Trigger; function Triggered return Boolean; procedure Cancel_Wait; end STM32GD.GPIO.IRQ;
with System; with ACO.Utils.Generic_Pubsub; private with ACO.Utils.DS.Generic_Protected_Queue; generic type Item_Type is private; Max_Nof_Subscribers : Positive; Max_Nof_Queued_Events : Positive; package ACO.Utils.Generic_Event is pragma Preelaborate; package PS is new ACO.Utils.Generic_Pubsub (Item_Type => Item_Type, Max_Nof_Subscribers => Max_Nof_Subscribers); subtype Subscriber is PS.Sub; type Subscriber_Access is access all Subscriber'Class; type Event_Publisher is limited new PS.Pub with null record; type Queued_Event_Publisher (Priority_Ceiling : System.Priority) is new Event_Publisher with private; function Events_Waiting (This : Queued_Event_Publisher) return Natural; procedure Put (This : in out Queued_Event_Publisher; Data : in Item_Type) with Pre => This.Events_Waiting < Max_Nof_Queued_Events; procedure Process (This : in out Queued_Event_Publisher); private package PQ is new ACO.Utils.DS.Generic_Protected_Queue (Item_Type => Item_Type, Maximum_Nof_Items => Max_Nof_Queued_Events); type Queued_Event_Publisher (Priority_Ceiling : System.Priority) is new Event_Publisher with record Queue : PQ.Protected_Queue (Priority_Ceiling); end record; end ACO.Utils.Generic_Event;
with Ada.Exceptions; with Ada.Text_IO; with Ada.Strings.Wide_Fixed; with Ada.Wide_Text_IO; with Ada.Wide_Text_IO.Wide_Unbounded_IO; with Symbex.Lex; with Symbex.Parse; with Symbex.Walk; procedure Dump is package Exceptions renames Ada.Exceptions; package IO renames Ada.Text_IO; package Lex renames Symbex.Lex; package Parse renames Symbex.Parse; package Walk renames Symbex.Walk; package WIO renames Ada.Wide_Text_IO; package WUIO renames Ada.Wide_Text_IO.Wide_Unbounded_IO; package Fixed renames Ada.Strings.Wide_Fixed; use type Lex.Lexer_Status_t; use type Lex.Lexer_t; use type Lex.Token_Kind_t; use type Parse.Tree_Status_t; use type Parse.List_Depth_t; use type Parse.List_Length_t; use type Walk.Walk_Status_t; Done : Boolean; Lexer_State : Lex.Lexer_t; Lexer_Status : Lex.Lexer_Status_t; Token : Lex.Token_t; Tree : Parse.Tree_t; Tree_Status : Parse.Tree_Status_t; Failure : exception; -- -- Read one character from standard input. -- procedure Read_Character (Item : out Wide_Character; Status : out Lex.Stream_Status_t) is begin WIO.Get_Immediate (File => WIO.Current_Input, Item => Item); Status := Lex.Stream_OK; exception when WIO.End_Error => Status := Lex.Stream_EOF; when others => Status := Lex.Stream_Error; end Read_Character; procedure Get_Lexer_Token is new Lex.Get_Token (Read_Item => Read_Character); -- -- Walk tree. -- Indent : Natural := 0; procedure Handle_List_Open (List_ID : in Parse.List_ID_t; Depth : in Parse.List_Depth_t; Status : out Walk.Walk_Status_t) is pragma Assert (List_ID'Valid); pragma Assert (Depth'Valid); begin if Depth > 1 then WIO.New_Line; WIO.Put (Fixed."*" (Indent, " ") & "("); Indent := Indent + 2; end if; Status := Walk.Walk_Continue; end Handle_List_Open; procedure Handle_Symbol (Name : in Parse.Node_Symbol_Name_t; List_ID : in Parse.List_ID_t; List_Position : in Parse.List_Position_t; List_Length : in Parse.List_Length_t; Status : out Walk.Walk_Status_t) is pragma Assert (List_ID'Valid); pragma Assert (List_Position'Valid); pragma Assert (List_Length'Valid); begin WUIO.Put (Name); if Parse.List_Length_t (List_Position) /= List_Length then WIO.Put (" "); end if; Status := Walk.Walk_Continue; end Handle_Symbol; procedure Handle_String (Data : in Parse.Node_String_Data_t; List_ID : in Parse.List_ID_t; List_Position : in Parse.List_Position_t; List_Length : in Parse.List_Length_t; Status : out Walk.Walk_Status_t) is pragma Assert (List_ID'Valid); pragma Assert (List_Position'Valid); pragma Assert (List_Length'Valid); begin WIO.Put (""""); WUIO.Put (Data); WIO.Put (""""); if Parse.List_Length_t (List_Position) /= List_Length then WIO.Put (" "); end if; Status := Walk.Walk_Continue; end Handle_String; procedure Handle_List_Close (List_ID : in Parse.List_ID_t; Depth : in Parse.List_Depth_t; Status : out Walk.Walk_Status_t) is pragma Assert (List_ID'Valid); pragma Assert (Depth'Valid); begin if Depth > 1 then WIO.Put (")"); WIO.New_Line; Indent := Indent - 2; end if; Status := Walk.Walk_Continue; end Handle_List_Close; procedure Dump_Tree is new Symbex.Walk.Walk_Tree (Handle_List_Open => Handle_List_Open, Handle_Symbol => Handle_Symbol, Handle_String => Handle_String, Handle_List_Close => Handle_List_Close); Walk_Status : Walk.Walk_Status_t; begin Done := False; Lexer_Status := Lex.Lexer_OK; Lex.Initialize_Lexer (Lexer => Lexer_State, Status => Lexer_Status); pragma Assert (Lexer_Status = Lex.Lexer_OK); Parse.Initialize_Tree (Tree => Tree, Status => Tree_Status); pragma Assert (Tree_Status = Parse.Tree_OK); -- Parse loop. loop exit when Done; Get_Lexer_Token (Lexer => Lexer_State, Token => Token, Status => Lexer_Status); if Lexer_Status in Lex.Lexer_Error_Status_t then raise Failure with Lex.Lexer_Error_Status_t'Image (Lexer_Status); else if Lexer_Status = Lex.Lexer_OK then if Token.Kind = Lex.Token_EOF then Done := True; end if; -- Consume token. Parse.Process_Token (Tree => Tree, Token => Token, Status => Tree_Status); if Tree_Status in Parse.Tree_Error_Status_t then raise Failure with Parse.Tree_Error_Status_t'Image (Tree_Status); end if; end if; end if; end loop; -- Dump tree. Dump_Tree (Tree => Tree, Status => Walk_Status); pragma Assert (Walk_Status = Walk.Walk_Continue); exception when E : Failure => IO.Put_Line ("error: " & Exceptions.Exception_Message (E)); end Dump;
pragma License (Unrestricted); with Ada.Containers; generic with package Bounded is new Generic_Bounded_Length (<>); function Ada.Strings.Wide_Bounded.Wide_Hash ( Key : Bounded.Bounded_Wide_String) return Containers.Hash_Type; pragma Preelaborate (Ada.Strings.Wide_Bounded.Wide_Hash);
with Ada.Numerics.Big_Numbers.Big_Integers; use Ada.Numerics.Big_Numbers.Big_Integers; --- @summary --- The `Spark_Unbound` package contains various unbound generic data structures. --- All data structures are formally proven by Spark and `Storage_Error` for heap allocation is handled internally. --- --- @description --- The `Spark_Unbound` package contains the following unbound generic data structures: --- --- - `Unbound_Array`: The package `Spark_Unbound.Arrays` provides the type and functionality for this data structure. --- --- The functionality for safe heap allocation is provided in the package `Spark_Unbound.Safe_Alloc`. --- --- The source code is MIT licensed and can be found at: https://github.com/mhatzl/spark_unbound package Spark_Unbound with SPARK_Mode is package Long_Integer_To_Big is new Signed_Conversions(Int => Long_Integer); subtype Long_Natural is Long_Integer range 0 .. Long_Integer'Last; package Long_Natural_To_Big is new Signed_Conversions(Int => Long_Natural); subtype Long_Positive is Long_Integer range 1 .. Long_Integer'Last; package Long_Positive_To_Big is new Signed_Conversions(Int => Long_Positive); end Spark_Unbound;
package body Controller_Dummy is -- procedure Handle (The : in TEL_Dummy) is begin null; end Handle; -- end Controller_Dummy;
package body openGL.Model.sphere is overriding function Bounds (Self : in Item) return openGL.Bounds is Radius : constant Real := Self.Scale (1) / 2.0; begin return (Ball => Radius, Box => (Lower => (-Radius, -Radius, -Radius), Upper => ( Radius, Radius, Radius))); end Bounds; end openGL.Model.sphere;
package Input is type Entry_Type is (Shift_Start, Fall_Asleep, Wake_Up); type Record_Entry is record Action : Entry_Type; Data : Natural; end record; Repose_Records : constant array (Positive range <>) of Record_Entry := ((Shift_Start, 3209), (Fall_Asleep, 13), (Wake_Up, 21), (Shift_Start, 751), (Fall_Asleep, 54), (Wake_Up, 57), (Shift_Start, 2857), (Fall_Asleep, 27), (Wake_Up, 50), (Shift_Start, 2339), (Fall_Asleep, 37), (Wake_Up, 55), (Shift_Start, 523), (Fall_Asleep, 17), (Wake_Up, 48), (Shift_Start, 3187), (Fall_Asleep, 04), (Wake_Up, 32), (Shift_Start, 1999), (Shift_Start, 2339), (Fall_Asleep, 21), (Wake_Up, 49), (Fall_Asleep, 56), (Wake_Up, 57), (Shift_Start, 2857), (Fall_Asleep, 54), (Wake_Up, 56), (Shift_Start, 2339), (Fall_Asleep, 12), (Wake_Up, 42), (Shift_Start, 1627), (Fall_Asleep, 07), (Wake_Up, 54), (Shift_Start, 373), (Fall_Asleep, 29), (Wake_Up, 58), (Shift_Start, 863), (Fall_Asleep, 19), (Wake_Up, 51), (Shift_Start, 3229), (Fall_Asleep, 20), (Wake_Up, 38), (Fall_Asleep, 43), (Wake_Up, 45), (Fall_Asleep, 51), (Wake_Up, 52), (Shift_Start, 3229), (Fall_Asleep, 32), (Wake_Up, 44), (Shift_Start, 3209), (Fall_Asleep, 43), (Wake_Up, 44), (Fall_Asleep, 50), (Wake_Up, 56), (Shift_Start, 1031), (Fall_Asleep, 23), (Wake_Up, 54), (Shift_Start, 3187), (Fall_Asleep, 09), (Wake_Up, 35), (Fall_Asleep, 51), (Wake_Up, 55), (Shift_Start, 2143), (Fall_Asleep, 34), (Wake_Up, 51), (Shift_Start, 2857), (Fall_Asleep, 19), (Wake_Up, 59), (Shift_Start, 3229), (Fall_Asleep, 25), (Wake_Up, 56), (Shift_Start, 3229), (Fall_Asleep, 03), (Wake_Up, 33), (Shift_Start, 1999), (Shift_Start, 601), (Fall_Asleep, 25), (Wake_Up, 27), (Fall_Asleep, 33), (Wake_Up, 38), (Fall_Asleep, 45), (Wake_Up, 53), (Fall_Asleep, 57), (Wake_Up, 58), (Shift_Start, 1627), (Fall_Asleep, 07), (Wake_Up, 19), (Fall_Asleep, 22), (Wake_Up, 33), (Fall_Asleep, 46), (Wake_Up, 49), (Fall_Asleep, 52), (Wake_Up, 58), (Shift_Start, 2857), (Fall_Asleep, 12), (Wake_Up, 44), (Fall_Asleep, 48), (Wake_Up, 51), (Shift_Start, 2339), (Fall_Asleep, 17), (Wake_Up, 23), (Fall_Asleep, 29), (Wake_Up, 47), (Shift_Start, 173), (Fall_Asleep, 34), (Wake_Up, 39), (Shift_Start, 3229), (Fall_Asleep, 06), (Wake_Up, 35), (Fall_Asleep, 46), (Wake_Up, 47), (Fall_Asleep, 53), (Wake_Up, 58), (Shift_Start, 2539), (Fall_Asleep, 26), (Wake_Up, 44), (Fall_Asleep, 50), (Wake_Up, 53), (Shift_Start, 521), (Fall_Asleep, 01), (Wake_Up, 44), (Fall_Asleep, 51), (Wake_Up, 59), (Shift_Start, 2143), (Fall_Asleep, 47), (Wake_Up, 54), (Fall_Asleep, 57), (Wake_Up, 58), (Shift_Start, 2539), (Fall_Asleep, 16), (Wake_Up, 35), (Fall_Asleep, 41), (Wake_Up, 48), (Shift_Start, 3229), (Fall_Asleep, 14), (Wake_Up, 36), (Shift_Start, 173), (Fall_Asleep, 04), (Wake_Up, 57), (Shift_Start, 2857), (Fall_Asleep, 48), (Wake_Up, 53), (Shift_Start, 373), (Fall_Asleep, 11), (Wake_Up, 37), (Fall_Asleep, 47), (Wake_Up, 54), (Shift_Start, 521), (Fall_Asleep, 31), (Wake_Up, 58), (Shift_Start, 601), (Fall_Asleep, 13), (Wake_Up, 33), (Shift_Start, 2143), (Fall_Asleep, 11), (Wake_Up, 34), (Shift_Start, 419), (Fall_Asleep, 01), (Wake_Up, 45), (Fall_Asleep, 53), (Wake_Up, 59), (Shift_Start, 863), (Fall_Asleep, 39), (Wake_Up, 57), (Shift_Start, 419), (Fall_Asleep, 07), (Wake_Up, 47), (Fall_Asleep, 54), (Wake_Up, 56), (Shift_Start, 2143), (Fall_Asleep, 19), (Wake_Up, 53), (Shift_Start, 829), (Shift_Start, 419), (Fall_Asleep, 16), (Wake_Up, 18), (Shift_Start, 751), (Fall_Asleep, 18), (Wake_Up, 25), (Fall_Asleep, 32), (Wake_Up, 46), (Shift_Start, 173), (Fall_Asleep, 08), (Wake_Up, 36), (Fall_Asleep, 40), (Wake_Up, 59), (Shift_Start, 1031), (Fall_Asleep, 29), (Wake_Up, 55), (Shift_Start, 419), (Fall_Asleep, 14), (Wake_Up, 40), (Fall_Asleep, 53), (Wake_Up, 58), (Shift_Start, 2857), (Fall_Asleep, 14), (Wake_Up, 27), (Fall_Asleep, 54), (Wake_Up, 57), (Shift_Start, 2857), (Fall_Asleep, 12), (Wake_Up, 57), (Shift_Start, 523), (Fall_Asleep, 27), (Wake_Up, 34), (Fall_Asleep, 42), (Wake_Up, 44), (Fall_Asleep, 49), (Wake_Up, 52), (Shift_Start, 2857), (Fall_Asleep, 07), (Wake_Up, 27), (Fall_Asleep, 33), (Wake_Up, 50), (Shift_Start, 1597), (Fall_Asleep, 18), (Wake_Up, 59), (Shift_Start, 2143), (Fall_Asleep, 40), (Wake_Up, 52), (Fall_Asleep, 55), (Wake_Up, 59), (Shift_Start, 863), (Fall_Asleep, 13), (Wake_Up, 59), (Shift_Start, 863), (Fall_Asleep, 03), (Wake_Up, 33), (Fall_Asleep, 41), (Wake_Up, 52), (Shift_Start, 431), (Fall_Asleep, 28), (Wake_Up, 33), (Fall_Asleep, 42), (Wake_Up, 50), (Shift_Start, 373), (Fall_Asleep, 01), (Wake_Up, 43), (Shift_Start, 1637), (Fall_Asleep, 04), (Wake_Up, 18), (Fall_Asleep, 34), (Wake_Up, 36), (Shift_Start, 2339), (Fall_Asleep, 27), (Wake_Up, 33), (Fall_Asleep, 40), (Wake_Up, 50), (Shift_Start, 431), (Fall_Asleep, 03), (Wake_Up, 39), (Shift_Start, 863), (Fall_Asleep, 21), (Wake_Up, 40), (Fall_Asleep, 46), (Wake_Up, 59), (Shift_Start, 431), (Fall_Asleep, 37), (Wake_Up, 44), (Shift_Start, 1637), (Fall_Asleep, 47), (Wake_Up, 50), (Fall_Asleep, 54), (Wake_Up, 58), (Shift_Start, 431), (Fall_Asleep, 34), (Wake_Up, 40), (Fall_Asleep, 49), (Wake_Up, 51), (Shift_Start, 991), (Shift_Start, 751), (Fall_Asleep, 11), (Wake_Up, 46), (Shift_Start, 601), (Fall_Asleep, 04), (Wake_Up, 36), (Fall_Asleep, 39), (Wake_Up, 47), (Shift_Start, 523), (Fall_Asleep, 01), (Wake_Up, 15), (Fall_Asleep, 25), (Wake_Up, 58), (Shift_Start, 1597), (Fall_Asleep, 01), (Wake_Up, 36), (Fall_Asleep, 48), (Wake_Up, 57), (Shift_Start, 3229), (Fall_Asleep, 27), (Wake_Up, 34), (Fall_Asleep, 41), (Wake_Up, 53), (Shift_Start, 173), (Fall_Asleep, 02), (Wake_Up, 06), (Fall_Asleep, 27), (Wake_Up, 39), (Shift_Start, 419), (Fall_Asleep, 33), (Wake_Up, 48), (Shift_Start, 431), (Fall_Asleep, 31), (Wake_Up, 49), (Shift_Start, 3209), (Fall_Asleep, 23), (Wake_Up, 56), (Shift_Start, 751), (Fall_Asleep, 21), (Wake_Up, 57), (Shift_Start, 1627), (Fall_Asleep, 12), (Wake_Up, 48), (Fall_Asleep, 54), (Wake_Up, 57), (Shift_Start, 1637), (Fall_Asleep, 02), (Wake_Up, 27), (Fall_Asleep, 36), (Wake_Up, 39), (Shift_Start, 3209), (Fall_Asleep, 20), (Wake_Up, 30), (Shift_Start, 523), (Fall_Asleep, 08), (Wake_Up, 15), (Fall_Asleep, 38), (Wake_Up, 52), (Shift_Start, 2539), (Fall_Asleep, 19), (Wake_Up, 24), (Fall_Asleep, 46), (Wake_Up, 57), (Shift_Start, 419), (Fall_Asleep, 23), (Wake_Up, 51), (Shift_Start, 2857), (Fall_Asleep, 31), (Wake_Up, 35), (Fall_Asleep, 55), (Wake_Up, 56), (Shift_Start, 2339), (Fall_Asleep, 22), (Wake_Up, 40), (Shift_Start, 173), (Fall_Asleep, 01), (Wake_Up, 20), (Fall_Asleep, 24), (Wake_Up, 45), (Shift_Start, 1031), (Fall_Asleep, 12), (Wake_Up, 15), (Fall_Asleep, 49), (Wake_Up, 54), (Shift_Start, 2143), (Fall_Asleep, 26), (Wake_Up, 49), (Shift_Start, 2857), (Fall_Asleep, 38), (Wake_Up, 46), (Fall_Asleep, 51), (Wake_Up, 55), (Shift_Start, 173), (Fall_Asleep, 00), (Wake_Up, 45), (Shift_Start, 3187), (Fall_Asleep, 02), (Wake_Up, 17), (Fall_Asleep, 40), (Wake_Up, 58), (Shift_Start, 1597), (Fall_Asleep, 06), (Wake_Up, 36), (Fall_Asleep, 49), (Wake_Up, 59), (Shift_Start, 373), (Fall_Asleep, 39), (Wake_Up, 44), (Fall_Asleep, 47), (Wake_Up, 57), (Shift_Start, 1627), (Fall_Asleep, 43), (Wake_Up, 57), (Shift_Start, 2339), (Fall_Asleep, 09), (Wake_Up, 41), (Fall_Asleep, 48), (Wake_Up, 51), (Fall_Asleep, 54), (Wake_Up, 58), (Shift_Start, 3229), (Fall_Asleep, 28), (Wake_Up, 40), (Shift_Start, 521), (Fall_Asleep, 05), (Wake_Up, 33), (Fall_Asleep, 39), (Wake_Up, 55), (Shift_Start, 373), (Fall_Asleep, 37), (Wake_Up, 42), (Fall_Asleep, 46), (Wake_Up, 47), (Fall_Asleep, 50), (Wake_Up, 59), (Shift_Start, 3209), (Fall_Asleep, 04), (Wake_Up, 55), (Shift_Start, 521), (Fall_Asleep, 45), (Wake_Up, 49), (Shift_Start, 751), (Fall_Asleep, 49), (Wake_Up, 53), (Fall_Asleep, 57), (Wake_Up, 58), (Shift_Start, 2339), (Fall_Asleep, 40), (Wake_Up, 53), (Shift_Start, 1637), (Fall_Asleep, 01), (Wake_Up, 20), (Fall_Asleep, 24), (Wake_Up, 35), (Fall_Asleep, 41), (Wake_Up, 43), (Shift_Start, 601), (Fall_Asleep, 08), (Wake_Up, 56), (Shift_Start, 373), (Fall_Asleep, 26), (Wake_Up, 58), (Shift_Start, 523), (Fall_Asleep, 29), (Wake_Up, 50), (Shift_Start, 1031), (Fall_Asleep, 10), (Wake_Up, 25), (Fall_Asleep, 31), (Wake_Up, 44), (Fall_Asleep, 55), (Wake_Up, 58), (Shift_Start, 2539), (Fall_Asleep, 11), (Wake_Up, 32), (Shift_Start, 2339), (Fall_Asleep, 27), (Wake_Up, 30), (Fall_Asleep, 38), (Wake_Up, 54), (Shift_Start, 3209), (Fall_Asleep, 13), (Wake_Up, 58), (Shift_Start, 3229), (Fall_Asleep, 29), (Wake_Up, 54), (Shift_Start, 3229), (Fall_Asleep, 37), (Wake_Up, 57), (Shift_Start, 863), (Fall_Asleep, 16), (Wake_Up, 56), (Shift_Start, 373), (Fall_Asleep, 00), (Wake_Up, 24), (Fall_Asleep, 37), (Wake_Up, 49), (Shift_Start, 173), (Fall_Asleep, 06), (Wake_Up, 11), (Fall_Asleep, 23), (Wake_Up, 58), (Shift_Start, 521), (Fall_Asleep, 45), (Wake_Up, 47), (Fall_Asleep, 50), (Wake_Up, 52), (Shift_Start, 373), (Fall_Asleep, 05), (Wake_Up, 14), (Fall_Asleep, 20), (Wake_Up, 54), (Shift_Start, 1031), (Fall_Asleep, 31), (Wake_Up, 56), (Shift_Start, 3187), (Fall_Asleep, 11), (Wake_Up, 15), (Shift_Start, 373), (Fall_Asleep, 36), (Wake_Up, 41), (Fall_Asleep, 44), (Wake_Up, 57), (Shift_Start, 523), (Fall_Asleep, 03), (Wake_Up, 59), (Shift_Start, 1597), (Fall_Asleep, 18), (Wake_Up, 39), (Shift_Start, 863), (Fall_Asleep, 17), (Wake_Up, 38), (Fall_Asleep, 51), (Wake_Up, 52), (Shift_Start, 173), (Fall_Asleep, 40), (Wake_Up, 57), (Shift_Start, 521), (Fall_Asleep, 26), (Wake_Up, 37), (Fall_Asleep, 48), (Wake_Up, 57), (Shift_Start, 2539), (Fall_Asleep, 23), (Wake_Up, 32), (Fall_Asleep, 36), (Wake_Up, 41), (Fall_Asleep, 48), (Wake_Up, 54), (Shift_Start, 431), (Fall_Asleep, 24), (Wake_Up, 32), (Fall_Asleep, 42), (Wake_Up, 43), (Shift_Start, 2339), (Fall_Asleep, 35), (Wake_Up, 52), (Shift_Start, 2857), (Fall_Asleep, 09), (Wake_Up, 49), (Shift_Start, 1597), (Fall_Asleep, 05), (Wake_Up, 08), (Fall_Asleep, 27), (Wake_Up, 35), (Fall_Asleep, 46), (Wake_Up, 47), (Shift_Start, 1627), (Fall_Asleep, 03), (Wake_Up, 33), (Fall_Asleep, 42), (Wake_Up, 44), (Fall_Asleep, 47), (Wake_Up, 59), (Shift_Start, 523), (Fall_Asleep, 19), (Wake_Up, 22), (Fall_Asleep, 36), (Wake_Up, 57), (Shift_Start, 431), (Fall_Asleep, 31), (Wake_Up, 40), (Fall_Asleep, 45), (Wake_Up, 58), (Shift_Start, 863), (Fall_Asleep, 05), (Wake_Up, 36), (Fall_Asleep, 51), (Wake_Up, 54), (Shift_Start, 1627), (Fall_Asleep, 29), (Wake_Up, 33), (Fall_Asleep, 36), (Wake_Up, 41), (Shift_Start, 3187), (Fall_Asleep, 09), (Wake_Up, 36), (Fall_Asleep, 51), (Wake_Up, 57), (Shift_Start, 419), (Fall_Asleep, 35), (Wake_Up, 43), (Shift_Start, 3187), (Fall_Asleep, 35), (Wake_Up, 48), (Shift_Start, 1031), (Fall_Asleep, 18), (Wake_Up, 24), (Fall_Asleep, 27), (Wake_Up, 45), (Shift_Start, 3187), (Fall_Asleep, 01), (Wake_Up, 52), (Shift_Start, 431), (Fall_Asleep, 01), (Wake_Up, 35), (Fall_Asleep, 38), (Wake_Up, 44), (Shift_Start, 373), (Fall_Asleep, 40), (Wake_Up, 58), (Shift_Start, 2539), (Fall_Asleep, 46), (Wake_Up, 52), (Fall_Asleep, 56), (Wake_Up, 57), (Shift_Start, 1637), (Fall_Asleep, 08), (Wake_Up, 21), (Fall_Asleep, 35), (Wake_Up, 51), (Shift_Start, 3187), (Fall_Asleep, 18), (Wake_Up, 19), (Fall_Asleep, 35), (Wake_Up, 59), (Shift_Start, 3209), (Fall_Asleep, 12), (Wake_Up, 27), (Shift_Start, 431), (Fall_Asleep, 26), (Wake_Up, 30), (Fall_Asleep, 44), (Wake_Up, 54), (Shift_Start, 3209), (Fall_Asleep, 08), (Wake_Up, 27), (Shift_Start, 2339), (Fall_Asleep, 42), (Wake_Up, 57), (Shift_Start, 373), (Fall_Asleep, 40), (Wake_Up, 45), (Fall_Asleep, 57), (Wake_Up, 59), (Shift_Start, 2339), (Fall_Asleep, 34), (Wake_Up, 35), (Shift_Start, 3209), (Fall_Asleep, 03), (Wake_Up, 59), (Shift_Start, 1637), (Fall_Asleep, 08), (Wake_Up, 20), (Fall_Asleep, 41), (Wake_Up, 52), (Shift_Start, 1627), (Fall_Asleep, 00), (Wake_Up, 10), (Fall_Asleep, 37), (Wake_Up, 50), (Shift_Start, 523), (Fall_Asleep, 08), (Wake_Up, 27), (Fall_Asleep, 38), (Wake_Up, 41), (Shift_Start, 751), (Fall_Asleep, 13), (Wake_Up, 46), (Shift_Start, 173), (Fall_Asleep, 06), (Wake_Up, 34), (Shift_Start, 173), (Fall_Asleep, 34), (Wake_Up, 37), (Shift_Start, 3209), (Fall_Asleep, 37), (Wake_Up, 40), (Fall_Asleep, 43), (Wake_Up, 54), (Shift_Start, 3209), (Fall_Asleep, 06), (Wake_Up, 42), (Shift_Start, 3187), (Fall_Asleep, 45), (Wake_Up, 57), (Shift_Start, 3229), (Fall_Asleep, 20), (Wake_Up, 51), (Shift_Start, 863), (Fall_Asleep, 31), (Wake_Up, 59), (Shift_Start, 3187), (Fall_Asleep, 13), (Wake_Up, 22), (Fall_Asleep, 36), (Wake_Up, 41), (Shift_Start, 523), (Fall_Asleep, 21), (Wake_Up, 58), (Shift_Start, 3209), (Fall_Asleep, 00), (Wake_Up, 16), (Shift_Start, 173), (Fall_Asleep, 21), (Wake_Up, 23), (Fall_Asleep, 32), (Wake_Up, 43), (Shift_Start, 523), (Fall_Asleep, 46), (Wake_Up, 55), (Shift_Start, 2143), (Fall_Asleep, 00), (Wake_Up, 34), (Fall_Asleep, 54), (Wake_Up, 58), (Shift_Start, 2857), (Fall_Asleep, 12), (Wake_Up, 16), (Fall_Asleep, 27), (Wake_Up, 39), (Shift_Start, 373), (Fall_Asleep, 11), (Wake_Up, 35), (Fall_Asleep, 38), (Wake_Up, 43), (Fall_Asleep, 46), (Wake_Up, 58), (Shift_Start, 2143), (Fall_Asleep, 35), (Wake_Up, 36), (Fall_Asleep, 42), (Wake_Up, 45), (Shift_Start, 173), (Fall_Asleep, 30), (Wake_Up, 48), (Shift_Start, 431), (Fall_Asleep, 00), (Wake_Up, 44), (Fall_Asleep, 49), (Wake_Up, 50), (Shift_Start, 1637), (Fall_Asleep, 16), (Wake_Up, 47), (Shift_Start, 173), (Fall_Asleep, 17), (Wake_Up, 32), (Fall_Asleep, 36), (Wake_Up, 48), (Fall_Asleep, 57), (Wake_Up, 58), (Shift_Start, 373), (Fall_Asleep, 38), (Wake_Up, 43), (Fall_Asleep, 54), (Wake_Up, 55), (Shift_Start, 1627), (Fall_Asleep, 23), (Wake_Up, 44), (Shift_Start, 2339), (Fall_Asleep, 37), (Wake_Up, 56), (Shift_Start, 2143), (Fall_Asleep, 40), (Wake_Up, 51), (Fall_Asleep, 57), (Wake_Up, 58), (Shift_Start, 373), (Fall_Asleep, 02), (Wake_Up, 47), (Fall_Asleep, 55), (Wake_Up, 59), (Shift_Start, 431), (Fall_Asleep, 28), (Wake_Up, 30), (Fall_Asleep, 40), (Wake_Up, 59), (Shift_Start, 419), (Fall_Asleep, 24), (Wake_Up, 46), (Shift_Start, 1627), (Fall_Asleep, 38), (Wake_Up, 57), (Shift_Start, 419), (Fall_Asleep, 02), (Wake_Up, 45), (Shift_Start, 1637), (Fall_Asleep, 00), (Wake_Up, 20), (Fall_Asleep, 32), (Wake_Up, 46), (Fall_Asleep, 49), (Wake_Up, 56), (Shift_Start, 863), (Fall_Asleep, 18), (Wake_Up, 58), (Shift_Start, 3209), (Fall_Asleep, 03), (Wake_Up, 24), (Fall_Asleep, 39), (Wake_Up, 46), (Shift_Start, 1637), (Fall_Asleep, 52), (Wake_Up, 57), (Shift_Start, 2857), (Fall_Asleep, 17), (Wake_Up, 59), (Shift_Start, 1031), (Fall_Asleep, 26), (Wake_Up, 54), (Shift_Start, 863), (Fall_Asleep, 08), (Wake_Up, 32), (Fall_Asleep, 38), (Wake_Up, 53), (Shift_Start, 373), (Fall_Asleep, 32), (Wake_Up, 53), (Shift_Start, 1627), (Fall_Asleep, 18), (Wake_Up, 51), (Shift_Start, 419), (Fall_Asleep, 18), (Wake_Up, 44), (Shift_Start, 1597), (Fall_Asleep, 01), (Wake_Up, 58), (Shift_Start, 1597), (Fall_Asleep, 16), (Wake_Up, 51), (Shift_Start, 173), (Fall_Asleep, 08), (Wake_Up, 35), (Shift_Start, 2857), (Fall_Asleep, 00), (Wake_Up, 47), (Shift_Start, 863), (Fall_Asleep, 02), (Wake_Up, 52), (Shift_Start, 1627), (Fall_Asleep, 10), (Wake_Up, 22), (Fall_Asleep, 36), (Wake_Up, 55), (Shift_Start, 373), (Fall_Asleep, 28), (Wake_Up, 47), (Shift_Start, 2339), (Fall_Asleep, 11), (Wake_Up, 58), (Shift_Start, 751), (Fall_Asleep, 42), (Wake_Up, 51), (Shift_Start, 373), (Fall_Asleep, 01), (Wake_Up, 20), (Shift_Start, 1597), (Fall_Asleep, 28), (Wake_Up, 34), (Shift_Start, 3229), (Fall_Asleep, 09), (Wake_Up, 42), (Fall_Asleep, 46), (Wake_Up, 59), (Shift_Start, 3209), (Fall_Asleep, 06), (Wake_Up, 14), (Fall_Asleep, 32), (Wake_Up, 43), (Fall_Asleep, 46), (Wake_Up, 52), (Shift_Start, 419), (Fall_Asleep, 11), (Wake_Up, 31), (Fall_Asleep, 49), (Wake_Up, 53), (Shift_Start, 3209), (Fall_Asleep, 20), (Wake_Up, 44), (Fall_Asleep, 53), (Wake_Up, 57), (Shift_Start, 863), (Fall_Asleep, 27), (Wake_Up, 52), (Shift_Start, 2857), (Fall_Asleep, 07), (Wake_Up, 36), (Shift_Start, 431), (Fall_Asleep, 27), (Wake_Up, 35), (Shift_Start, 521), (Fall_Asleep, 13), (Wake_Up, 24), (Fall_Asleep, 52), (Wake_Up, 56), (Shift_Start, 2539), (Fall_Asleep, 13), (Wake_Up, 14), (Fall_Asleep, 31), (Wake_Up, 46), (Fall_Asleep, 51), (Wake_Up, 57), (Shift_Start, 2539), (Fall_Asleep, 13), (Wake_Up, 52), (Fall_Asleep, 56), (Wake_Up, 57), (Shift_Start, 3187), (Fall_Asleep, 23), (Wake_Up, 38), (Fall_Asleep, 44), (Wake_Up, 48), (Fall_Asleep, 51), (Wake_Up, 53), (Shift_Start, 1637), (Fall_Asleep, 07), (Wake_Up, 52), (Shift_Start, 1627), (Fall_Asleep, 43), (Wake_Up, 53), (Shift_Start, 1637), (Fall_Asleep, 18), (Wake_Up, 47), (Shift_Start, 3187), (Fall_Asleep, 24), (Wake_Up, 47), (Fall_Asleep, 51), (Wake_Up, 53), (Shift_Start, 601), (Fall_Asleep, 18), (Wake_Up, 30), (Shift_Start, 523), (Fall_Asleep, 13), (Wake_Up, 22), (Fall_Asleep, 31), (Wake_Up, 47), (Fall_Asleep, 51), (Wake_Up, 52), (Shift_Start, 521), (Fall_Asleep, 15), (Wake_Up, 21), (Fall_Asleep, 39), (Wake_Up, 51), (Shift_Start, 2143), (Fall_Asleep, 30), (Wake_Up, 45), (Shift_Start, 3187), (Fall_Asleep, 47), (Wake_Up, 53), (Shift_Start, 1637), (Fall_Asleep, 31), (Wake_Up, 32), (Fall_Asleep, 35), (Wake_Up, 58), (Shift_Start, 2857), (Fall_Asleep, 05), (Wake_Up, 38), (Shift_Start, 3229), (Fall_Asleep, 36), (Wake_Up, 56), (Shift_Start, 1627), (Fall_Asleep, 08), (Wake_Up, 41), (Fall_Asleep, 45), (Wake_Up, 55), (Shift_Start, 3187), (Fall_Asleep, 55), (Wake_Up, 59), (Shift_Start, 521), (Fall_Asleep, 46), (Wake_Up, 50), (Shift_Start, 3229), (Fall_Asleep, 16), (Wake_Up, 52), (Shift_Start, 1031), (Fall_Asleep, 18), (Wake_Up, 27), (Fall_Asleep, 37), (Wake_Up, 54), (Shift_Start, 3229), (Fall_Asleep, 10), (Wake_Up, 18), (Fall_Asleep, 25), (Wake_Up, 36), (Fall_Asleep, 40), (Wake_Up, 44), (Fall_Asleep, 52), (Wake_Up, 56), (Shift_Start, 1637), (Fall_Asleep, 08), (Wake_Up, 33), (Fall_Asleep, 45), (Wake_Up, 57), (Shift_Start, 523), (Fall_Asleep, 47), (Wake_Up, 49), (Shift_Start, 173), (Fall_Asleep, 09), (Wake_Up, 20), (Fall_Asleep, 32), (Wake_Up, 56), (Shift_Start, 521), (Fall_Asleep, 11), (Wake_Up, 25), (Fall_Asleep, 31), (Wake_Up, 49), (Fall_Asleep, 54), (Wake_Up, 59), (Shift_Start, 1597), (Fall_Asleep, 36), (Wake_Up, 43), (Fall_Asleep, 48), (Wake_Up, 58), (Shift_Start, 2143), (Fall_Asleep, 34), (Wake_Up, 54), (Shift_Start, 1597), (Fall_Asleep, 07), (Wake_Up, 30), (Shift_Start, 521), (Fall_Asleep, 05), (Wake_Up, 51), (Shift_Start, 3229), (Fall_Asleep, 25), (Wake_Up, 54), (Shift_Start, 3209), (Fall_Asleep, 25), (Wake_Up, 34), (Shift_Start, 863), (Fall_Asleep, 36), (Wake_Up, 49), (Fall_Asleep, 54), (Wake_Up, 59), (Shift_Start, 601), (Fall_Asleep, 10), (Wake_Up, 52), (Shift_Start, 521), (Fall_Asleep, 26), (Wake_Up, 54), (Shift_Start, 419), (Fall_Asleep, 23), (Wake_Up, 31), (Fall_Asleep, 34), (Wake_Up, 46), (Fall_Asleep, 56), (Wake_Up, 59), (Shift_Start, 3209), (Fall_Asleep, 16), (Wake_Up, 24), (Fall_Asleep, 33), (Wake_Up, 53), (Shift_Start, 991), (Shift_Start, 173), (Fall_Asleep, 34), (Wake_Up, 40), (Shift_Start, 431), (Fall_Asleep, 14), (Wake_Up, 57), (Shift_Start, 2143), (Fall_Asleep, 05), (Wake_Up, 30), (Fall_Asleep, 55), (Wake_Up, 57), (Shift_Start, 1627), (Fall_Asleep, 14), (Wake_Up, 55), (Shift_Start, 419), (Fall_Asleep, 33), (Wake_Up, 45), (Fall_Asleep, 48), (Wake_Up, 57), (Shift_Start, 373), (Fall_Asleep, 23), (Wake_Up, 52), (Shift_Start, 3187), (Fall_Asleep, 19), (Wake_Up, 44), (Fall_Asleep, 54), (Wake_Up, 55), (Shift_Start, 2339), (Fall_Asleep, 18), (Wake_Up, 53), (Shift_Start, 1597), (Fall_Asleep, 15), (Wake_Up, 55), (Shift_Start, 419), (Fall_Asleep, 10), (Wake_Up, 51), (Shift_Start, 431), (Fall_Asleep, 29), (Wake_Up, 48), (Shift_Start, 431), (Fall_Asleep, 01), (Wake_Up, 26), (Fall_Asleep, 30), (Wake_Up, 39), (Fall_Asleep, 45), (Wake_Up, 55), (Shift_Start, 521), (Fall_Asleep, 07), (Wake_Up, 14), (Fall_Asleep, 17), (Wake_Up, 45), (Fall_Asleep, 53), (Wake_Up, 55), (Shift_Start, 521), (Fall_Asleep, 11), (Wake_Up, 43), (Fall_Asleep, 47), (Wake_Up, 55), (Shift_Start, 1597), (Fall_Asleep, 28), (Wake_Up, 59), (Shift_Start, 3187), (Fall_Asleep, 20), (Wake_Up, 22), (Fall_Asleep, 34), (Wake_Up, 45), (Fall_Asleep, 54), (Wake_Up, 57), (Shift_Start, 751), (Fall_Asleep, 30), (Wake_Up, 42), (Fall_Asleep, 47), (Wake_Up, 56), (Shift_Start, 863), (Fall_Asleep, 49), (Wake_Up, 58), (Shift_Start, 523), (Fall_Asleep, 00), (Wake_Up, 34), (Fall_Asleep, 47), (Wake_Up, 55), (Shift_Start, 2143), (Fall_Asleep, 21), (Wake_Up, 41), (Shift_Start, 2143), (Fall_Asleep, 43), (Wake_Up, 47), (Shift_Start, 173), (Fall_Asleep, 12), (Wake_Up, 32), (Shift_Start, 2339), (Fall_Asleep, 28), (Wake_Up, 33), (Fall_Asleep, 36), (Wake_Up, 49), (Fall_Asleep, 52), (Wake_Up, 54), (Shift_Start, 3209), (Fall_Asleep, 15), (Wake_Up, 43), (Shift_Start, 863), (Fall_Asleep, 46), (Wake_Up, 47), (Fall_Asleep, 51), (Wake_Up, 59), (Shift_Start, 3229), (Fall_Asleep, 09), (Wake_Up, 52), (Shift_Start, 991), (Shift_Start, 431), (Fall_Asleep, 25), (Wake_Up, 58), (Shift_Start, 863), (Fall_Asleep, 21), (Wake_Up, 31), (Shift_Start, 1637), (Fall_Asleep, 44), (Wake_Up, 51), (Fall_Asleep, 55), (Wake_Up, 58), (Shift_Start, 863), (Fall_Asleep, 16), (Wake_Up, 49), (Fall_Asleep, 54), (Wake_Up, 57), (Shift_Start, 2339), (Fall_Asleep, 24), (Wake_Up, 35), (Fall_Asleep, 38), (Wake_Up, 56), (Shift_Start, 1627), (Fall_Asleep, 09), (Wake_Up, 44), (Fall_Asleep, 50), (Wake_Up, 57), (Shift_Start, 863), (Fall_Asleep, 32), (Wake_Up, 50), (Fall_Asleep, 56), (Wake_Up, 59), (Shift_Start, 751), (Fall_Asleep, 27), (Wake_Up, 32), (Fall_Asleep, 41), (Wake_Up, 47), (Shift_Start, 991), (Shift_Start, 1031), (Fall_Asleep, 16), (Wake_Up, 35), (Shift_Start, 419), (Fall_Asleep, 34), (Wake_Up, 41), (Shift_Start, 2339), (Fall_Asleep, 32), (Wake_Up, 44), (Shift_Start, 3187), (Fall_Asleep, 41), (Wake_Up, 51), (Shift_Start, 373), (Fall_Asleep, 11), (Wake_Up, 45), (Shift_Start, 1031), (Fall_Asleep, 12), (Wake_Up, 20), (Fall_Asleep, 39), (Wake_Up, 46), (Shift_Start, 1637), (Fall_Asleep, 37), (Wake_Up, 47), (Shift_Start, 3229), (Fall_Asleep, 24), (Wake_Up, 36), (Fall_Asleep, 45), (Wake_Up, 54), (Shift_Start, 523), (Fall_Asleep, 42), (Wake_Up, 49), (Shift_Start, 523), (Fall_Asleep, 08), (Wake_Up, 49), (Shift_Start, 1637), (Fall_Asleep, 00), (Wake_Up, 55), (Shift_Start, 521), (Fall_Asleep, 13), (Wake_Up, 51), (Shift_Start, 523), (Fall_Asleep, 38), (Wake_Up, 55), (Shift_Start, 2143), (Fall_Asleep, 09), (Wake_Up, 24), (Fall_Asleep, 55), (Wake_Up, 58), (Shift_Start, 3209), (Fall_Asleep, 12), (Wake_Up, 55), (Shift_Start, 2143), (Fall_Asleep, 14), (Wake_Up, 44), (Shift_Start, 419), (Fall_Asleep, 37), (Wake_Up, 49), (Shift_Start, 173), (Fall_Asleep, 25), (Wake_Up, 48), (Shift_Start, 1597), (Fall_Asleep, 06), (Wake_Up, 19), (Shift_Start, 3209), (Fall_Asleep, 14), (Wake_Up, 32), (Shift_Start, 1999), (Shift_Start, 1597), (Fall_Asleep, 36), (Wake_Up, 58), (Shift_Start, 523), (Fall_Asleep, 01), (Wake_Up, 24), (Fall_Asleep, 34), (Wake_Up, 58), (Shift_Start, 1627), (Fall_Asleep, 06), (Wake_Up, 52), (Shift_Start, 751), (Fall_Asleep, 02), (Wake_Up, 54), (Shift_Start, 2339), (Fall_Asleep, 22), (Wake_Up, 37), (Shift_Start, 2857), (Fall_Asleep, 10), (Wake_Up, 42), (Fall_Asleep, 55), (Wake_Up, 56)); end Input;
package return1 is type Base is abstract tagged null record; type Child is new Base with record Anon_Access : access Base'Class; end record; function X_Func (O : access Child) return access Base'Class; end return1;
-- { dg-do compile } -- { dg-options "-O3" } package body Loop_Optimization15 is type Integer_Array_T is array (B16_T range <>) of Integer; Len : constant B16_T := 10; Src : constant Integer_Array_T (1 .. Len) := (others => 0); Dst : Integer_Array_T (1 .. Len); procedure Proc (L : B16_T) is begin for I in 1 .. B16_T'Min (L, Len) loop Dst (I) := Src (I); end loop; end; end Loop_Optimization15;
-- See LICENSE file for cc0 license details with Ada.Directories; with Ada.Exceptions; use Ada.Exceptions; -- TODO remove with Ada.Strings; with Ada.Strings.Maps.Constants; with Ada.Strings.Unbounded; -- TODO needed? with Ada.Text_Io; with Iictl; -- TODO unecessary? with Posix.Io; with Posix.Process_Identification; with Posix.Process_Primitives; with Posix.Unsafe_Process_Primitives; -- TODO is there safe fork? with util; package body Srv_Conn is package AD renames Ada.Directories; package AS renames Ada.Strings; package ASMC renames Ada.Strings.Maps.Constants; package ASU renames Ada.Strings.Unbounded; -- TODO unneeded? package ATIO renames Ada.Text_Io; package IUSV renames Util.Unbounded_String_Vectors; package PIO renames Posix.Io; package PPI renames Posix.Process_Identification; package PPP renames Posix.Process_Primitives; package PUPP renames Posix.Unsafe_Process_Primitives; -- TODO remove unused packages -- TODO explicit in? procedure Reconnect_Servers (Irc_Dir : String; Nick : String) is Server_List : Util.Unbounded_String_Vector; -- TODO rename Directory_List? Process_List : Util.Unbounded_String_Vector; -- TODO garbage collector? begin Reap_Defunct_Procs; Server_List := Scan_Server_Directory (Irc_Dir); Process_List := Scan_Ii_Procs; Respawn_Clients (Server_List, Process_List); end Reconnect_Servers; -- TODO better formatting procedure Maintain_Connection (Dir_Ent : in AD.Directory_Entry_Type; Nick : in String) is Srv_Path : String := AD.Full_Name (Dir_Ent); -- TODO simple_name begin if not Util.Is_Fifo_Up (Srv_Path) then Spawn_Client (AD.Simple_Name (Dir_Ent), Nick); else Util.Verbose_Print ("Iictl: Maintain_Connection: " & Srv_Path & " is running"); -- TODO remove -- TODO someone COULD be cat'ing the in file end if; end Maintain_Connection; procedure Spawn_Client (Srv_Name : String; Nick : String) is use type PPI.Process_Id; Cmd : Posix.Filename := "ii"; Argv : Posix.Posix_String_List; begin -- TODO don't assume cwd? -- TODO check if Nick is given if PUPP.Fork = PPI.Null_Process_Id then -- New process Util.Verbose_Print ("Iictl: Spawn_Client: " & Srv_Name); Posix.Append (Argv, Cmd); Posix.Append (Argv, "-s"); Posix.Append (Argv, Posix.To_Posix_String(Srv_Name)); if Nick'Length /= 0 then Posix.Append (Argv, "-n"); Posix.Append (Argv, Posix.To_Posix_String(Nick)); end if; -- TODO exec with ii -i prefix -- TODO refactor PUPP.Exec_Search (Cmd, Argv); else -- Old process null; -- TODO wait for new process to launch ii end if; -- TODO check return or exception -- TODO keep track of PID? end Spawn_Client; procedure Reap_Defunct_Procs is use type Posix.Error_Code; Status : PPP.Termination_Status; begin loop -- TODO upper limit PPP.Wait_For_Child_Process (Status => Status, Block => False); -- TODO use more named parameters --if Status = didnotreap then if not PPP.Status_Available (Status) then exit; end if; Util.Verbose_Print ("Iictl: Reap_Defunct_Procs: Reaped one child"); end loop; exception when Error : Posix.Posix_Error => if Posix.Get_Error_Code = Posix.No_Child_Process then Util.Verbose_Print ("Iictl: Reap_Defunct_Procs: " & "No childs yet!"); -- TODO clean this else raise Posix.Posix_Error with Exception_Message (Error); end if; end; procedure Respawn_Clients (Server_List : Util.Unbounded_String_Vector; Process_List : Util.Unbounded_String_Vector) is begin -- TODO use iterator in other functions as well Server_Loop: for S of Server_List loop if Process_List.Find_Index (S) = IUSV.No_Index then -- TODO find another way to use No_Index Util.Verbose_Print ("Iictl: Respawn_Clients: No proc " & ASU.To_String (S)); Spawn_Client (ASU.To_String (S), "nick"); -- TODO Send name as Unbounded_String -- TODO get nick and all other flags else Util.Verbose_Print ("Iictl: Respawn_Clients: Found proc: " & ASU.To_String (S)); -- TODO remove end if; end loop Server_Loop; end; function Is_Srv_Dir (Dir_Ent : AD.Directory_Entry_Type) return Boolean is use type AD.File_Kind; Name : String := AD.Simple_Name (Dir_Ent); begin if AD.Kind (Dir_Ent) /= AD.Directory then return False; elsif Name (Name'First) = '.' then return False; -- TODO else if no */in */out else return True; end if; end Is_Srv_Dir; function Scan_Server_Directory (Irc_Dir : in String) return Util.Unbounded_String_Vector is Search : AD.Search_Type; Dir_Ent : AD.Directory_Entry_Type; Server_Name : ASU.Unbounded_String; Server_List : Util.Unbounded_String_Vector; begin AD.Start_Search (Search, Irc_Dir, ""); while AD.More_Entries (Search) loop AD.Get_Next_Entry (Search, Dir_Ent); if Is_Srv_Dir (Dir_Ent) then Server_Name := ASU.To_Unbounded_String (AD.Simple_Name (Dir_Ent)); Server_List.Append (Server_Name); Util.Verbose_Print ("Iictl: Scan_Server_Directory: found " & ASU.To_String (Server_Name)); end if; end loop; AD.End_Search (Search); return Server_List; end; function Scan_Ii_Procs return Util.Unbounded_String_Vector is Search : AD.Search_Type; Dir_Ent : AD.Directory_Entry_Type; Process_List : Util.Unbounded_String_Vector; Server_Name : ASU.Unbounded_String; begin AD.Start_Search (Search, "/proc", ""); while AD.More_Entries (Search) loop AD.Get_Next_Entry (Search, Dir_Ent); if Is_Ii_Proc (Dir_Ent) then Server_Name := Get_Server_Name (Dir_Ent); Util.Verbose_Print ("Iictl: Scan_Ii_Procs: Found " & ASU.To_String (Server_Name)); Process_List.Append (Server_Name); end if; end loop; AD.End_Search (Search); return Process_List; end; function Is_Ii_Proc (Dir_Ent : AD.Directory_Entry_Type) return Boolean is Dir_Name : String := AD.Simple_Name (Dir_Ent); File : ATIO.File_Type; Cmdline : ASU.Unbounded_String; Ret : Boolean := False; begin if not Util.Is_Integral (Dir_Name) then return False; end if; ATIO.Open (File, ATIO.In_File, "/proc/" & Dir_Name & "/cmdline"); Cmdline := ASU.To_Unbounded_String (ATIO.Get_Line (File)); -- TODO check only pids for current user --for I in Integer range 1 .. Cmdline.Length loop -- TODO I = 0 .. length for I in Integer range 1 .. ASU.Length (Cmdline) loop --if Cmdline.Element (I) = Character'Val (0) then if ASU.Element (Cmdline, I) = Character'Val (0) then if ASU.Element (Cmdline, I - 1) /= 'i' then ret := False; elsif ASU.Element (Cmdline, I - 2) /= 'i' then ret := False; else Util.Verbose_Print ("Iictl: Is_Ii_Proc: found " & ASU.To_String (Cmdline)); ret := True; end if; -- TODO other programs ending in ii? -- TODO check "*/ii" or "^ii" goto Exit_Is_Ii_Proc; end if; -- TODO non null-terminated cmdline end loop; -- TODO refactor Ret := False; -- Cmdline was not null-terminated <<Exit_Is_Ii_Proc>> ATIO.Close (File); return Ret; exception when ATIO.End_Error => -- TODO goto Exit_Is_Ii_Proc ATIO.Close (File); return False; end; -- TODO rename Get_Server_Flags to get host, nick, port etc function Get_Server_Name (Dir_Ent : AD.Directory_Entry_Type) return ASU.Unbounded_String is -- TODO define type for proc pid string File : ATIO.File_Type; Cmdline : ASU.Unbounded_String; Flag_First : Natural := 0; -- TODO rename Flag_Start? Ctrl_First : Positive; Ctrl_Last : Natural; Ret : ASU.Unbounded_String; Null_Char : ASU.Unbounded_String; begin ATIO.Open (File, ATIO.In_File, "/proc/" & AD.Simple_Name (Dir_Ent) & "/cmdline"); Cmdline := ASU.To_Unbounded_String (ATIO.Get_Line (File)); Flag_First := ASU.Index (Cmdline, "-s"); if Flag_First = 0 then Ret := ASU.To_Unbounded_String ("irc.freenode.net"); -- TODO consider default host else ASU.Find_Token (Cmdline, ASMC.Control_Set, Flag_First + 3, AS.Inside, Ctrl_First, Ctrl_Last); if Ctrl_Last = 0 then Ctrl_Last := ASU.Length (Cmdline); end if; Ret := ASU.Unbounded_Slice (CmdLine, Flag_First + 3, Ctrl_Last - 1); end if; ATIO.Close (File); Util.Verbose_Print ("Iictl: Get_Server_Name: found name " & ASU.To_String (Ret)); return Ret; end; end Srv_Conn;
with Ada.Characters.Handling; use Ada.Characters.Handling; with Ada.Containers; with Ada.Strings.Equal_Case_Insensitive; with Ada.Strings.Hash_Case_Insensitive; with Ada.Strings.Hash; use Ada.Strings; package Symbol_Tables is type ID_Type is new String with Dynamic_Predicate => Is_Valid_ID (String (ID_Type)); function Is_Valid_ID (X : String) return Boolean is (X'Length > 0 and then Is_Letter (X (X'First)) and then (for all C of X => Is_Alphanumeric (C) or C = '_')); function Equivalent_Id (X, Y : ID_Type) return Boolean is (X = Y); function Equal_Case_Insensitive_Id (X, Y : ID_Type) return Boolean is (Equal_Case_Insensitive (String (X), String (Y))); function Hash_Id (X : ID_Type) return Ada.Containers.Hash_Type is (Hash (String (X))); function Hash_Case_Insensitive_ID (X : ID_Type) return Ada.Containers.Hash_Type is (Hash_Case_Insensitive (String (X))); end Symbol_Tables;
with gel.World, ada.unchecked_Conversion; limited with openGL.Renderer.lean; package gel.World.simple -- -- Provides a simple gel world. -- is type Item is limited new gel.World.item with private; type View is access all Item'Class; type Views is array (Positive range <>) of View; --------- -- Forge -- package Forge is function to_World (Name : in String; Id : in world_Id; space_Kind : in physics.space_Kind; Renderer : access openGL.Renderer.lean.item'Class) return gel.World.simple.item; function new_World (Name : in String; Id : in world_Id; space_Kind : in physics.space_Kind; Renderer : access openGL.Renderer.lean.item'Class) return gel.World.simple.view; end Forge; private -------------- --- sprite_Map -- type sprite_Map is limited new World.sprite_Map with record Map : id_Maps_of_sprite.Map; end record; overriding function fetch (From : in sprite_Map) return id_Maps_of_sprite.Map; overriding procedure add (To : in out sprite_Map; the_Sprite : in Sprite.view); overriding procedure rid (From : in out sprite_Map; the_Sprite : in Sprite.view); -------------- --- World Item -- type Item is limited new gel.World.item with record all_Sprites : aliased sprite_Map; end record; overriding function all_Sprites (Self : access Item) return access World.sprite_Map'Class; end gel.World.simple;
with Ada.Text_IO; use Ada.Text_IO; with Filesystem.Native; use Filesystem.Native; with Test_Directories; use Test_Directories; with File_Block_Drivers; use File_Block_Drivers; with File_IO; use File_IO; with Filesystem.FAT; use Filesystem.FAT; with HAL.Filesystem; use HAL.Filesystem; with Compare_Files; procedure TC_FAT_Read is function Check_Dir (Dirname : String) return Boolean; function Check_File (Basename : String; Dirname : String) return Boolean; function Check_Expected_Number return Boolean; Number_Of_Files_Checked : Natural := 0; --------------- -- Check_Dir -- --------------- function Check_Dir (Dirname : String) return Boolean is DD : Directory_Descriptor; Status : File_IO.Status_Code; begin Put_Line ("Checking directory: '" & Dirname & "'"); Status := Open (DD, Dirname); if Status /= OK then Put_Line ("Cannot open directory: '" & Dirname & "'"); Put_Line ("Status: " & Status'Img); return False; end if; loop declare Ent : constant Directory_Entry := Read (DD); begin if Ent /= Invalid_Dir_Entry then if Ent.Name = "." or else Ent.Name = ".." then null; -- do nothing elsif Ent.Subdirectory then if not Check_Dir (Dirname & "/" & Ent.Name) then return False; end if; elsif not Ent.Symlink then if not Check_File (Ent.Name, Dirname) then return False; end if; end if; else exit; end if; end; end loop; return True; end Check_Dir; ---------------- -- Check_File -- ---------------- function Check_File (Basename : String; Dirname : String) return Boolean is FD : File_Descriptor; Status : File_IO.Status_Code; Path : constant String := Dirname & "/" & Basename; begin Status := Open (FD, Path, Read_Only); if Status /= OK then Put_Line ("Cannot open file: '" & Path & "'"); Put_Line ("Status: " & Status'Img); return False; end if; declare Hash_Str : constant String := Compare_Files.Compute_Hash (FD); begin if Hash_Str /= Basename then Put_Line ("Error: Hash is different than filename"); return False; else Number_Of_Files_Checked := Number_Of_Files_Checked + 1; return True; end if; end; end Check_File; --------------------------- -- Check_Expected_Number -- --------------------------- function Check_Expected_Number return Boolean is FD : File_Descriptor; Status : File_IO.Status_Code; Path : constant String := "/disk_img/number_of_files_to_check"; C : Character; Amount : File_IO.File_Size; begin Status := Open (FD, Path, Read_Only); if Status /= OK then Put_Line ("Cannot open file: '" & Path & "'"); Put_Line ("Status: " & Status'Img); return False; end if; Amount := 1; if Read (FD, C'Address, Amount) /= Amount then Put_Line ("Cannot read file: '" & Path & "'"); Put_Line ("Status: " & Status'Img); return False; end if; if C in '0' .. '9' and then Number_Of_Files_Checked = (Character'Pos (C) - Character'Pos ('0')) then return True; else Put_Line ("Incorrect number of files"); return False; end if; end Check_Expected_Number; Disk_Img_Path : constant String := "/test_dir/fat.fs"; Disk : aliased File_Block_Driver; FAT_FS : access FAT_Filesystem; FIO_Status : File_IO.Status_Code; HALFS_Status : HAL.Filesystem.Status_Code; begin Test_Directories.Mount_Test_Directory ("test_dir"); FIO_Status := Disk.Open (Disk_Img_Path, Read_Only); if FIO_Status /= OK then Put_Line ("Cannot open disk image '" & Disk_Img_Path & "': " & FIO_Status'Img); return; end if; FAT_FS := new FAT_Filesystem; HALFS_Status := Open (Controller => Disk'Unchecked_Access, LBA => 0, FS => FAT_FS.all); if HALFS_Status /= OK then Put_Line ("Cannot open FAT FS - Status:" & HALFS_Status'Img); return; end if; FIO_Status := File_IO.Mount_Volume (Mount_Point => "disk_img", FS => FAT_FS); if FIO_Status /= OK then Put_Line ("Cannot mount volume - Status: " & FIO_Status'Img); return; end if; if Check_Dir ("/disk_img/read_test") and then Check_Expected_Number then Put_Line ("PASS"); else Put_Line ("FAIL"); end if; end TC_FAT_Read;
-- Copyright (c) 2020 Raspberry Pi (Trading) Ltd. -- -- SPDX-License-Identifier: BSD-3-Clause -- This spec has been automatically generated from rp2040.svd pragma Restrictions (No_Elaboration_Code); pragma Ada_2012; pragma Style_Checks (Off); with HAL; with System; -- Programmable IO block package RP_SVD.PIO1 is pragma Preelaborate; --------------- -- Registers -- --------------- subtype CTRL_SM_ENABLE_Field is HAL.UInt4; subtype CTRL_SM_RESTART_Field is HAL.UInt4; subtype CTRL_CLKDIV_RESTART_Field is HAL.UInt4; -- PIO control register type CTRL_Register is record -- Enable state machine SM_ENABLE : CTRL_SM_ENABLE_Field := 16#0#; -- After a write operation all bits in the field are cleared (set to -- zero). Clear internal SM state which is otherwise difficult to -- access\n (e.g. shift counters). Self-clearing. SM_RESTART : CTRL_SM_RESTART_Field := 16#0#; -- After a write operation all bits in the field are cleared (set to -- zero). Force clock dividers to restart their count and clear -- fractional\n accumulators. Restart multiple dividers to synchronise -- them. CLKDIV_RESTART : CTRL_CLKDIV_RESTART_Field := 16#0#; -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for CTRL_Register use record SM_ENABLE at 0 range 0 .. 3; SM_RESTART at 0 range 4 .. 7; CLKDIV_RESTART at 0 range 8 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; subtype FSTAT_RXFULL_Field is HAL.UInt4; subtype FSTAT_RXEMPTY_Field is HAL.UInt4; subtype FSTAT_TXFULL_Field is HAL.UInt4; subtype FSTAT_TXEMPTY_Field is HAL.UInt4; -- FIFO status register type FSTAT_Register is record -- Read-only. State machine RX FIFO is full RXFULL : FSTAT_RXFULL_Field; -- unspecified Reserved_4_7 : HAL.UInt4; -- Read-only. State machine RX FIFO is empty RXEMPTY : FSTAT_RXEMPTY_Field; -- unspecified Reserved_12_15 : HAL.UInt4; -- Read-only. State machine TX FIFO is full TXFULL : FSTAT_TXFULL_Field; -- unspecified Reserved_20_23 : HAL.UInt4; -- Read-only. State machine TX FIFO is empty TXEMPTY : FSTAT_TXEMPTY_Field; -- unspecified Reserved_28_31 : HAL.UInt4; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for FSTAT_Register use record RXFULL at 0 range 0 .. 3; Reserved_4_7 at 0 range 4 .. 7; RXEMPTY at 0 range 8 .. 11; Reserved_12_15 at 0 range 12 .. 15; TXFULL at 0 range 16 .. 19; Reserved_20_23 at 0 range 20 .. 23; TXEMPTY at 0 range 24 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; subtype FDEBUG_RXSTALL_Field is HAL.UInt4; subtype FDEBUG_RXUNDER_Field is HAL.UInt4; subtype FDEBUG_TXOVER_Field is HAL.UInt4; subtype FDEBUG_TXSTALL_Field is HAL.UInt4; -- FIFO debug register type FDEBUG_Register is record -- Write data bit of one shall clear (set to zero) the corresponding bit -- in the field. State machine has stalled on full RX FIFO. Write 1 to -- clear. RXSTALL : FDEBUG_RXSTALL_Field := 16#0#; -- unspecified Reserved_4_7 : HAL.UInt4 := 16#0#; -- Write data bit of one shall clear (set to zero) the corresponding bit -- in the field. RX FIFO underflow has occurred. Write 1 to clear. RXUNDER : FDEBUG_RXUNDER_Field := 16#0#; -- unspecified Reserved_12_15 : HAL.UInt4 := 16#0#; -- Write data bit of one shall clear (set to zero) the corresponding bit -- in the field. TX FIFO overflow has occurred. Write 1 to clear. TXOVER : FDEBUG_TXOVER_Field := 16#0#; -- unspecified Reserved_20_23 : HAL.UInt4 := 16#0#; -- Write data bit of one shall clear (set to zero) the corresponding bit -- in the field. State machine has stalled on empty TX FIFO. Write 1 to -- clear. TXSTALL : FDEBUG_TXSTALL_Field := 16#0#; -- unspecified Reserved_28_31 : HAL.UInt4 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for FDEBUG_Register use record RXSTALL at 0 range 0 .. 3; Reserved_4_7 at 0 range 4 .. 7; RXUNDER at 0 range 8 .. 11; Reserved_12_15 at 0 range 12 .. 15; TXOVER at 0 range 16 .. 19; Reserved_20_23 at 0 range 20 .. 23; TXSTALL at 0 range 24 .. 27; Reserved_28_31 at 0 range 28 .. 31; end record; subtype FLEVEL_TX0_Field is HAL.UInt4; subtype FLEVEL_RX0_Field is HAL.UInt4; subtype FLEVEL_TX1_Field is HAL.UInt4; subtype FLEVEL_RX1_Field is HAL.UInt4; subtype FLEVEL_TX2_Field is HAL.UInt4; subtype FLEVEL_RX2_Field is HAL.UInt4; subtype FLEVEL_TX3_Field is HAL.UInt4; subtype FLEVEL_RX3_Field is HAL.UInt4; -- FIFO levels type FLEVEL_Register is record -- Read-only. TX0 : FLEVEL_TX0_Field; -- Read-only. RX0 : FLEVEL_RX0_Field; -- Read-only. TX1 : FLEVEL_TX1_Field; -- Read-only. RX1 : FLEVEL_RX1_Field; -- Read-only. TX2 : FLEVEL_TX2_Field; -- Read-only. RX2 : FLEVEL_RX2_Field; -- Read-only. TX3 : FLEVEL_TX3_Field; -- Read-only. RX3 : FLEVEL_RX3_Field; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for FLEVEL_Register use record TX0 at 0 range 0 .. 3; RX0 at 0 range 4 .. 7; TX1 at 0 range 8 .. 11; RX1 at 0 range 12 .. 15; TX2 at 0 range 16 .. 19; RX2 at 0 range 20 .. 23; TX3 at 0 range 24 .. 27; RX3 at 0 range 28 .. 31; end record; subtype IRQ_IRQ_Field is HAL.UInt8; -- Interrupt request register. Write 1 to clear type IRQ_Register is record -- Write data bit of one shall clear (set to zero) the corresponding bit -- in the field. IRQ : IRQ_IRQ_Field := 16#0#; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for IRQ_Register use record IRQ at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype IRQ_FORCE_IRQ_FORCE_Field is HAL.UInt8; -- Writing a 1 to each of these bits will forcibly assert the corresponding -- IRQ.\n Note this is different to the INTF register: writing here affects -- PIO internal\n state. INTF just asserts the processor-facing IRQ signal -- for testing ISRs,\n and is not visible to the state machines. type IRQ_FORCE_Register is record -- Write-only. IRQ_FORCE : IRQ_FORCE_IRQ_FORCE_Field := 16#0#; -- unspecified Reserved_8_31 : HAL.UInt24 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for IRQ_FORCE_Register use record IRQ_FORCE at 0 range 0 .. 7; Reserved_8_31 at 0 range 8 .. 31; end record; subtype DBG_CFGINFO_FIFO_DEPTH_Field is HAL.UInt6; subtype DBG_CFGINFO_SM_COUNT_Field is HAL.UInt4; subtype DBG_CFGINFO_IMEM_SIZE_Field is HAL.UInt6; -- The PIO hardware has some free parameters that may vary between chip -- products.\n These should be provided in the chip datasheet, but are also -- exposed here. type DBG_CFGINFO_Register is record -- Read-only. The depth of the state machine TX/RX FIFOs, measured in -- words.\n Joining fifos via SHIFTCTRL_FJOIN gives one FIFO with -- double\n this depth. FIFO_DEPTH : DBG_CFGINFO_FIFO_DEPTH_Field; -- unspecified Reserved_6_7 : HAL.UInt2; -- Read-only. The number of state machines this PIO instance is equipped -- with. SM_COUNT : DBG_CFGINFO_SM_COUNT_Field; -- unspecified Reserved_12_15 : HAL.UInt4; -- Read-only. The size of the instruction memory, measured in units of -- one instruction IMEM_SIZE : DBG_CFGINFO_IMEM_SIZE_Field; -- unspecified Reserved_22_31 : HAL.UInt10; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for DBG_CFGINFO_Register use record FIFO_DEPTH at 0 range 0 .. 5; Reserved_6_7 at 0 range 6 .. 7; SM_COUNT at 0 range 8 .. 11; Reserved_12_15 at 0 range 12 .. 15; IMEM_SIZE at 0 range 16 .. 21; Reserved_22_31 at 0 range 22 .. 31; end record; subtype INSTR_MEM0_INSTR_MEM0_Field is HAL.UInt16; -- Write-only access to instruction memory location 0 type INSTR_MEM0_Register is record INSTR_MEM0 : INSTR_MEM0_INSTR_MEM0_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM0_Register use record INSTR_MEM0 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM1_INSTR_MEM1_Field is HAL.UInt16; -- Write-only access to instruction memory location 1 type INSTR_MEM1_Register is record INSTR_MEM1 : INSTR_MEM1_INSTR_MEM1_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM1_Register use record INSTR_MEM1 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM2_INSTR_MEM2_Field is HAL.UInt16; -- Write-only access to instruction memory location 2 type INSTR_MEM2_Register is record INSTR_MEM2 : INSTR_MEM2_INSTR_MEM2_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM2_Register use record INSTR_MEM2 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM3_INSTR_MEM3_Field is HAL.UInt16; -- Write-only access to instruction memory location 3 type INSTR_MEM3_Register is record INSTR_MEM3 : INSTR_MEM3_INSTR_MEM3_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM3_Register use record INSTR_MEM3 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM4_INSTR_MEM4_Field is HAL.UInt16; -- Write-only access to instruction memory location 4 type INSTR_MEM4_Register is record INSTR_MEM4 : INSTR_MEM4_INSTR_MEM4_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM4_Register use record INSTR_MEM4 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM5_INSTR_MEM5_Field is HAL.UInt16; -- Write-only access to instruction memory location 5 type INSTR_MEM5_Register is record INSTR_MEM5 : INSTR_MEM5_INSTR_MEM5_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM5_Register use record INSTR_MEM5 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM6_INSTR_MEM6_Field is HAL.UInt16; -- Write-only access to instruction memory location 6 type INSTR_MEM6_Register is record INSTR_MEM6 : INSTR_MEM6_INSTR_MEM6_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM6_Register use record INSTR_MEM6 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM7_INSTR_MEM7_Field is HAL.UInt16; -- Write-only access to instruction memory location 7 type INSTR_MEM7_Register is record INSTR_MEM7 : INSTR_MEM7_INSTR_MEM7_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM7_Register use record INSTR_MEM7 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM8_INSTR_MEM8_Field is HAL.UInt16; -- Write-only access to instruction memory location 8 type INSTR_MEM8_Register is record INSTR_MEM8 : INSTR_MEM8_INSTR_MEM8_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM8_Register use record INSTR_MEM8 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM9_INSTR_MEM9_Field is HAL.UInt16; -- Write-only access to instruction memory location 9 type INSTR_MEM9_Register is record INSTR_MEM9 : INSTR_MEM9_INSTR_MEM9_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM9_Register use record INSTR_MEM9 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM10_INSTR_MEM10_Field is HAL.UInt16; -- Write-only access to instruction memory location 10 type INSTR_MEM10_Register is record INSTR_MEM10 : INSTR_MEM10_INSTR_MEM10_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM10_Register use record INSTR_MEM10 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM11_INSTR_MEM11_Field is HAL.UInt16; -- Write-only access to instruction memory location 11 type INSTR_MEM11_Register is record INSTR_MEM11 : INSTR_MEM11_INSTR_MEM11_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM11_Register use record INSTR_MEM11 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM12_INSTR_MEM12_Field is HAL.UInt16; -- Write-only access to instruction memory location 12 type INSTR_MEM12_Register is record INSTR_MEM12 : INSTR_MEM12_INSTR_MEM12_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM12_Register use record INSTR_MEM12 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM13_INSTR_MEM13_Field is HAL.UInt16; -- Write-only access to instruction memory location 13 type INSTR_MEM13_Register is record INSTR_MEM13 : INSTR_MEM13_INSTR_MEM13_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM13_Register use record INSTR_MEM13 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM14_INSTR_MEM14_Field is HAL.UInt16; -- Write-only access to instruction memory location 14 type INSTR_MEM14_Register is record INSTR_MEM14 : INSTR_MEM14_INSTR_MEM14_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM14_Register use record INSTR_MEM14 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM15_INSTR_MEM15_Field is HAL.UInt16; -- Write-only access to instruction memory location 15 type INSTR_MEM15_Register is record INSTR_MEM15 : INSTR_MEM15_INSTR_MEM15_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM15_Register use record INSTR_MEM15 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM16_INSTR_MEM16_Field is HAL.UInt16; -- Write-only access to instruction memory location 16 type INSTR_MEM16_Register is record INSTR_MEM16 : INSTR_MEM16_INSTR_MEM16_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM16_Register use record INSTR_MEM16 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM17_INSTR_MEM17_Field is HAL.UInt16; -- Write-only access to instruction memory location 17 type INSTR_MEM17_Register is record INSTR_MEM17 : INSTR_MEM17_INSTR_MEM17_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM17_Register use record INSTR_MEM17 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM18_INSTR_MEM18_Field is HAL.UInt16; -- Write-only access to instruction memory location 18 type INSTR_MEM18_Register is record INSTR_MEM18 : INSTR_MEM18_INSTR_MEM18_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM18_Register use record INSTR_MEM18 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM19_INSTR_MEM19_Field is HAL.UInt16; -- Write-only access to instruction memory location 19 type INSTR_MEM19_Register is record INSTR_MEM19 : INSTR_MEM19_INSTR_MEM19_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM19_Register use record INSTR_MEM19 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM20_INSTR_MEM20_Field is HAL.UInt16; -- Write-only access to instruction memory location 20 type INSTR_MEM20_Register is record INSTR_MEM20 : INSTR_MEM20_INSTR_MEM20_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM20_Register use record INSTR_MEM20 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM21_INSTR_MEM21_Field is HAL.UInt16; -- Write-only access to instruction memory location 21 type INSTR_MEM21_Register is record INSTR_MEM21 : INSTR_MEM21_INSTR_MEM21_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM21_Register use record INSTR_MEM21 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM22_INSTR_MEM22_Field is HAL.UInt16; -- Write-only access to instruction memory location 22 type INSTR_MEM22_Register is record INSTR_MEM22 : INSTR_MEM22_INSTR_MEM22_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM22_Register use record INSTR_MEM22 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM23_INSTR_MEM23_Field is HAL.UInt16; -- Write-only access to instruction memory location 23 type INSTR_MEM23_Register is record INSTR_MEM23 : INSTR_MEM23_INSTR_MEM23_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM23_Register use record INSTR_MEM23 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM24_INSTR_MEM24_Field is HAL.UInt16; -- Write-only access to instruction memory location 24 type INSTR_MEM24_Register is record INSTR_MEM24 : INSTR_MEM24_INSTR_MEM24_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM24_Register use record INSTR_MEM24 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM25_INSTR_MEM25_Field is HAL.UInt16; -- Write-only access to instruction memory location 25 type INSTR_MEM25_Register is record INSTR_MEM25 : INSTR_MEM25_INSTR_MEM25_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM25_Register use record INSTR_MEM25 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM26_INSTR_MEM26_Field is HAL.UInt16; -- Write-only access to instruction memory location 26 type INSTR_MEM26_Register is record INSTR_MEM26 : INSTR_MEM26_INSTR_MEM26_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM26_Register use record INSTR_MEM26 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM27_INSTR_MEM27_Field is HAL.UInt16; -- Write-only access to instruction memory location 27 type INSTR_MEM27_Register is record INSTR_MEM27 : INSTR_MEM27_INSTR_MEM27_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM27_Register use record INSTR_MEM27 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM28_INSTR_MEM28_Field is HAL.UInt16; -- Write-only access to instruction memory location 28 type INSTR_MEM28_Register is record INSTR_MEM28 : INSTR_MEM28_INSTR_MEM28_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM28_Register use record INSTR_MEM28 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM29_INSTR_MEM29_Field is HAL.UInt16; -- Write-only access to instruction memory location 29 type INSTR_MEM29_Register is record INSTR_MEM29 : INSTR_MEM29_INSTR_MEM29_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM29_Register use record INSTR_MEM29 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM30_INSTR_MEM30_Field is HAL.UInt16; -- Write-only access to instruction memory location 30 type INSTR_MEM30_Register is record INSTR_MEM30 : INSTR_MEM30_INSTR_MEM30_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM30_Register use record INSTR_MEM30 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype INSTR_MEM31_INSTR_MEM31_Field is HAL.UInt16; -- Write-only access to instruction memory location 31 type INSTR_MEM31_Register is record INSTR_MEM31 : INSTR_MEM31_INSTR_MEM31_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INSTR_MEM31_Register use record INSTR_MEM31 at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype SM0_CLKDIV_FRAC_Field is HAL.UInt8; subtype SM0_CLKDIV_INT_Field is HAL.UInt16; -- Clock divider register for state machine 0\n Frequency = clock freq / -- (CLKDIV_INT + CLKDIV_FRAC / 256) type SM0_CLKDIV_Register is record -- unspecified Reserved_0_7 : HAL.UInt8 := 16#0#; -- Fractional part of clock divider FRAC : SM0_CLKDIV_FRAC_Field := 16#0#; -- Effective frequency is sysclk/int.\n Value of 0 is interpreted as max -- possible value INT : SM0_CLKDIV_INT_Field := 16#1#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SM0_CLKDIV_Register use record Reserved_0_7 at 0 range 0 .. 7; FRAC at 0 range 8 .. 15; INT at 0 range 16 .. 31; end record; subtype SM0_EXECCTRL_STATUS_N_Field is HAL.UInt4; -- Comparison used for the MOV x, STATUS instruction. type SM0_EXECCTRL_STATUS_SEL_Field is (-- All-ones if TX FIFO level < N, otherwise all-zeroes Txlevel, -- All-ones if RX FIFO level < N, otherwise all-zeroes Rxlevel) with Size => 1; for SM0_EXECCTRL_STATUS_SEL_Field use (Txlevel => 0, Rxlevel => 1); subtype SM0_EXECCTRL_WRAP_BOTTOM_Field is HAL.UInt5; subtype SM0_EXECCTRL_WRAP_TOP_Field is HAL.UInt5; subtype SM0_EXECCTRL_OUT_EN_SEL_Field is HAL.UInt5; subtype SM0_EXECCTRL_JMP_PIN_Field is HAL.UInt5; -- Execution/behavioural settings for state machine 0 type SM0_EXECCTRL_Register is record -- Comparison level for the MOV x, STATUS instruction STATUS_N : SM0_EXECCTRL_STATUS_N_Field := 16#0#; -- Comparison used for the MOV x, STATUS instruction. STATUS_SEL : SM0_EXECCTRL_STATUS_SEL_Field := RP_SVD.PIO1.Txlevel; -- unspecified Reserved_5_6 : HAL.UInt2 := 16#0#; -- After reaching wrap_top, execution is wrapped to this address. WRAP_BOTTOM : SM0_EXECCTRL_WRAP_BOTTOM_Field := 16#0#; -- After reaching this address, execution is wrapped to wrap_bottom.\n -- If the instruction is a jump, and the jump condition is true, the -- jump takes priority. WRAP_TOP : SM0_EXECCTRL_WRAP_TOP_Field := 16#1F#; -- Continuously assert the most recent OUT/SET to the pins OUT_STICKY : Boolean := False; -- If 1, use a bit of OUT data as an auxiliary write enable\n When used -- in conjunction with OUT_STICKY, writes with an enable of 0 will\n -- deassert the latest pin write. This can create useful -- masking/override behaviour\n due to the priority ordering of state -- machine pin writes (SM0 < SM1 < ...) INLINE_OUT_EN : Boolean := False; -- Which data bit to use for inline OUT enable OUT_EN_SEL : SM0_EXECCTRL_OUT_EN_SEL_Field := 16#0#; -- The GPIO number to use as condition for JMP PIN. Unaffected by input -- mapping. JMP_PIN : SM0_EXECCTRL_JMP_PIN_Field := 16#0#; -- Side-set data is asserted to pin OEs instead of pin values SIDE_PINDIR : Boolean := False; -- If 1, the delay MSB is used as side-set enable, rather than a\n -- side-set data bit. This allows instructions to perform side-set -- optionally,\n rather than on every instruction. SIDE_EN : Boolean := False; -- Read-only. An instruction written to SMx_INSTR is stalled, and -- latched by the\n state machine. Will clear once the instruction -- completes. EXEC_STALLED : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SM0_EXECCTRL_Register use record STATUS_N at 0 range 0 .. 3; STATUS_SEL at 0 range 4 .. 4; Reserved_5_6 at 0 range 5 .. 6; WRAP_BOTTOM at 0 range 7 .. 11; WRAP_TOP at 0 range 12 .. 16; OUT_STICKY at 0 range 17 .. 17; INLINE_OUT_EN at 0 range 18 .. 18; OUT_EN_SEL at 0 range 19 .. 23; JMP_PIN at 0 range 24 .. 28; SIDE_PINDIR at 0 range 29 .. 29; SIDE_EN at 0 range 30 .. 30; EXEC_STALLED at 0 range 31 .. 31; end record; subtype SM0_SHIFTCTRL_PUSH_THRESH_Field is HAL.UInt5; subtype SM0_SHIFTCTRL_PULL_THRESH_Field is HAL.UInt5; -- Control behaviour of the input/output shift registers for state machine -- 0 type SM0_SHIFTCTRL_Register is record -- unspecified Reserved_0_15 : HAL.UInt16 := 16#0#; -- Push automatically when the input shift register is filled AUTOPUSH : Boolean := False; -- Pull automatically when the output shift register is emptied AUTOPULL : Boolean := False; -- 1 = shift input shift register to right (data enters from left). 0 = -- to left. IN_SHIFTDIR : Boolean := True; -- 1 = shift out of output shift register to right. 0 = to left. OUT_SHIFTDIR : Boolean := True; -- Number of bits shifted into RXSR before autopush or conditional -- push.\n Write 0 for value of 32. PUSH_THRESH : SM0_SHIFTCTRL_PUSH_THRESH_Field := 16#0#; -- Number of bits shifted out of TXSR before autopull or conditional -- pull.\n Write 0 for value of 32. PULL_THRESH : SM0_SHIFTCTRL_PULL_THRESH_Field := 16#0#; -- When 1, TX FIFO steals the RX FIFO's storage, and becomes twice as -- deep.\n RX FIFO is disabled as a result (always reads as both full -- and empty).\n FIFOs are flushed when this bit is changed. FJOIN_TX : Boolean := False; -- When 1, RX FIFO steals the TX FIFO's storage, and becomes twice as -- deep.\n TX FIFO is disabled as a result (always reads as both full -- and empty).\n FIFOs are flushed when this bit is changed. FJOIN_RX : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SM0_SHIFTCTRL_Register use record Reserved_0_15 at 0 range 0 .. 15; AUTOPUSH at 0 range 16 .. 16; AUTOPULL at 0 range 17 .. 17; IN_SHIFTDIR at 0 range 18 .. 18; OUT_SHIFTDIR at 0 range 19 .. 19; PUSH_THRESH at 0 range 20 .. 24; PULL_THRESH at 0 range 25 .. 29; FJOIN_TX at 0 range 30 .. 30; FJOIN_RX at 0 range 31 .. 31; end record; subtype SM0_ADDR_SM0_ADDR_Field is HAL.UInt5; -- Current instruction address of state machine 0 type SM0_ADDR_Register is record -- Read-only. SM0_ADDR : SM0_ADDR_SM0_ADDR_Field; -- unspecified Reserved_5_31 : HAL.UInt27; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SM0_ADDR_Register use record SM0_ADDR at 0 range 0 .. 4; Reserved_5_31 at 0 range 5 .. 31; end record; subtype SM0_INSTR_SM0_INSTR_Field is HAL.UInt16; -- Instruction currently being executed by state machine 0\n Write to -- execute an instruction immediately (including jumps) and then resume -- execution. type SM0_INSTR_Register is record SM0_INSTR : SM0_INSTR_SM0_INSTR_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SM0_INSTR_Register use record SM0_INSTR at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype SM0_PINCTRL_OUT_BASE_Field is HAL.UInt5; subtype SM0_PINCTRL_SET_BASE_Field is HAL.UInt5; subtype SM0_PINCTRL_SIDESET_BASE_Field is HAL.UInt5; subtype SM0_PINCTRL_IN_BASE_Field is HAL.UInt5; subtype SM0_PINCTRL_OUT_COUNT_Field is HAL.UInt6; subtype SM0_PINCTRL_SET_COUNT_Field is HAL.UInt3; subtype SM0_PINCTRL_SIDESET_COUNT_Field is HAL.UInt3; -- State machine pin control type SM0_PINCTRL_Register is record -- The virtual pin corresponding to OUT bit 0 OUT_BASE : SM0_PINCTRL_OUT_BASE_Field := 16#0#; -- The virtual pin corresponding to SET bit 0 SET_BASE : SM0_PINCTRL_SET_BASE_Field := 16#0#; -- The virtual pin corresponding to delay field bit 0 SIDESET_BASE : SM0_PINCTRL_SIDESET_BASE_Field := 16#0#; -- The virtual pin corresponding to IN bit 0 IN_BASE : SM0_PINCTRL_IN_BASE_Field := 16#0#; -- The number of pins asserted by an OUT. Value of 0 -> 32 pins OUT_COUNT : SM0_PINCTRL_OUT_COUNT_Field := 16#0#; -- The number of pins asserted by a SET. Max of 5 SET_COUNT : SM0_PINCTRL_SET_COUNT_Field := 16#5#; -- The number of delay bits co-opted for side-set. Inclusive of the -- enable bit, if present. SIDESET_COUNT : SM0_PINCTRL_SIDESET_COUNT_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SM0_PINCTRL_Register use record OUT_BASE at 0 range 0 .. 4; SET_BASE at 0 range 5 .. 9; SIDESET_BASE at 0 range 10 .. 14; IN_BASE at 0 range 15 .. 19; OUT_COUNT at 0 range 20 .. 25; SET_COUNT at 0 range 26 .. 28; SIDESET_COUNT at 0 range 29 .. 31; end record; subtype SM1_CLKDIV_FRAC_Field is HAL.UInt8; subtype SM1_CLKDIV_INT_Field is HAL.UInt16; -- Clock divider register for state machine 1\n Frequency = clock freq / -- (CLKDIV_INT + CLKDIV_FRAC / 256) type SM1_CLKDIV_Register is record -- unspecified Reserved_0_7 : HAL.UInt8 := 16#0#; -- Fractional part of clock divider FRAC : SM1_CLKDIV_FRAC_Field := 16#0#; -- Effective frequency is sysclk/int.\n Value of 0 is interpreted as max -- possible value INT : SM1_CLKDIV_INT_Field := 16#1#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SM1_CLKDIV_Register use record Reserved_0_7 at 0 range 0 .. 7; FRAC at 0 range 8 .. 15; INT at 0 range 16 .. 31; end record; subtype SM1_EXECCTRL_STATUS_N_Field is HAL.UInt4; -- Comparison used for the MOV x, STATUS instruction. type SM1_EXECCTRL_STATUS_SEL_Field is (-- All-ones if TX FIFO level < N, otherwise all-zeroes Txlevel, -- All-ones if RX FIFO level < N, otherwise all-zeroes Rxlevel) with Size => 1; for SM1_EXECCTRL_STATUS_SEL_Field use (Txlevel => 0, Rxlevel => 1); subtype SM1_EXECCTRL_WRAP_BOTTOM_Field is HAL.UInt5; subtype SM1_EXECCTRL_WRAP_TOP_Field is HAL.UInt5; subtype SM1_EXECCTRL_OUT_EN_SEL_Field is HAL.UInt5; subtype SM1_EXECCTRL_JMP_PIN_Field is HAL.UInt5; -- Execution/behavioural settings for state machine 1 type SM1_EXECCTRL_Register is record -- Comparison level for the MOV x, STATUS instruction STATUS_N : SM1_EXECCTRL_STATUS_N_Field := 16#0#; -- Comparison used for the MOV x, STATUS instruction. STATUS_SEL : SM1_EXECCTRL_STATUS_SEL_Field := RP_SVD.PIO1.Txlevel; -- unspecified Reserved_5_6 : HAL.UInt2 := 16#0#; -- After reaching wrap_top, execution is wrapped to this address. WRAP_BOTTOM : SM1_EXECCTRL_WRAP_BOTTOM_Field := 16#0#; -- After reaching this address, execution is wrapped to wrap_bottom.\n -- If the instruction is a jump, and the jump condition is true, the -- jump takes priority. WRAP_TOP : SM1_EXECCTRL_WRAP_TOP_Field := 16#1F#; -- Continuously assert the most recent OUT/SET to the pins OUT_STICKY : Boolean := False; -- If 1, use a bit of OUT data as an auxiliary write enable\n When used -- in conjunction with OUT_STICKY, writes with an enable of 0 will\n -- deassert the latest pin write. This can create useful -- masking/override behaviour\n due to the priority ordering of state -- machine pin writes (SM0 < SM1 < ...) INLINE_OUT_EN : Boolean := False; -- Which data bit to use for inline OUT enable OUT_EN_SEL : SM1_EXECCTRL_OUT_EN_SEL_Field := 16#0#; -- The GPIO number to use as condition for JMP PIN. Unaffected by input -- mapping. JMP_PIN : SM1_EXECCTRL_JMP_PIN_Field := 16#0#; -- Side-set data is asserted to pin OEs instead of pin values SIDE_PINDIR : Boolean := False; -- If 1, the delay MSB is used as side-set enable, rather than a\n -- side-set data bit. This allows instructions to perform side-set -- optionally,\n rather than on every instruction. SIDE_EN : Boolean := False; -- Read-only. An instruction written to SMx_INSTR is stalled, and -- latched by the\n state machine. Will clear once the instruction -- completes. EXEC_STALLED : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SM1_EXECCTRL_Register use record STATUS_N at 0 range 0 .. 3; STATUS_SEL at 0 range 4 .. 4; Reserved_5_6 at 0 range 5 .. 6; WRAP_BOTTOM at 0 range 7 .. 11; WRAP_TOP at 0 range 12 .. 16; OUT_STICKY at 0 range 17 .. 17; INLINE_OUT_EN at 0 range 18 .. 18; OUT_EN_SEL at 0 range 19 .. 23; JMP_PIN at 0 range 24 .. 28; SIDE_PINDIR at 0 range 29 .. 29; SIDE_EN at 0 range 30 .. 30; EXEC_STALLED at 0 range 31 .. 31; end record; subtype SM1_SHIFTCTRL_PUSH_THRESH_Field is HAL.UInt5; subtype SM1_SHIFTCTRL_PULL_THRESH_Field is HAL.UInt5; -- Control behaviour of the input/output shift registers for state machine -- 1 type SM1_SHIFTCTRL_Register is record -- unspecified Reserved_0_15 : HAL.UInt16 := 16#0#; -- Push automatically when the input shift register is filled AUTOPUSH : Boolean := False; -- Pull automatically when the output shift register is emptied AUTOPULL : Boolean := False; -- 1 = shift input shift register to right (data enters from left). 0 = -- to left. IN_SHIFTDIR : Boolean := True; -- 1 = shift out of output shift register to right. 0 = to left. OUT_SHIFTDIR : Boolean := True; -- Number of bits shifted into RXSR before autopush or conditional -- push.\n Write 0 for value of 32. PUSH_THRESH : SM1_SHIFTCTRL_PUSH_THRESH_Field := 16#0#; -- Number of bits shifted out of TXSR before autopull or conditional -- pull.\n Write 0 for value of 32. PULL_THRESH : SM1_SHIFTCTRL_PULL_THRESH_Field := 16#0#; -- When 1, TX FIFO steals the RX FIFO's storage, and becomes twice as -- deep.\n RX FIFO is disabled as a result (always reads as both full -- and empty).\n FIFOs are flushed when this bit is changed. FJOIN_TX : Boolean := False; -- When 1, RX FIFO steals the TX FIFO's storage, and becomes twice as -- deep.\n TX FIFO is disabled as a result (always reads as both full -- and empty).\n FIFOs are flushed when this bit is changed. FJOIN_RX : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SM1_SHIFTCTRL_Register use record Reserved_0_15 at 0 range 0 .. 15; AUTOPUSH at 0 range 16 .. 16; AUTOPULL at 0 range 17 .. 17; IN_SHIFTDIR at 0 range 18 .. 18; OUT_SHIFTDIR at 0 range 19 .. 19; PUSH_THRESH at 0 range 20 .. 24; PULL_THRESH at 0 range 25 .. 29; FJOIN_TX at 0 range 30 .. 30; FJOIN_RX at 0 range 31 .. 31; end record; subtype SM1_ADDR_SM1_ADDR_Field is HAL.UInt5; -- Current instruction address of state machine 1 type SM1_ADDR_Register is record -- Read-only. SM1_ADDR : SM1_ADDR_SM1_ADDR_Field; -- unspecified Reserved_5_31 : HAL.UInt27; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SM1_ADDR_Register use record SM1_ADDR at 0 range 0 .. 4; Reserved_5_31 at 0 range 5 .. 31; end record; subtype SM1_INSTR_SM1_INSTR_Field is HAL.UInt16; -- Instruction currently being executed by state machine 1\n Write to -- execute an instruction immediately (including jumps) and then resume -- execution. type SM1_INSTR_Register is record SM1_INSTR : SM1_INSTR_SM1_INSTR_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SM1_INSTR_Register use record SM1_INSTR at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype SM1_PINCTRL_OUT_BASE_Field is HAL.UInt5; subtype SM1_PINCTRL_SET_BASE_Field is HAL.UInt5; subtype SM1_PINCTRL_SIDESET_BASE_Field is HAL.UInt5; subtype SM1_PINCTRL_IN_BASE_Field is HAL.UInt5; subtype SM1_PINCTRL_OUT_COUNT_Field is HAL.UInt6; subtype SM1_PINCTRL_SET_COUNT_Field is HAL.UInt3; subtype SM1_PINCTRL_SIDESET_COUNT_Field is HAL.UInt3; -- State machine pin control type SM1_PINCTRL_Register is record -- The virtual pin corresponding to OUT bit 0 OUT_BASE : SM1_PINCTRL_OUT_BASE_Field := 16#0#; -- The virtual pin corresponding to SET bit 0 SET_BASE : SM1_PINCTRL_SET_BASE_Field := 16#0#; -- The virtual pin corresponding to delay field bit 0 SIDESET_BASE : SM1_PINCTRL_SIDESET_BASE_Field := 16#0#; -- The virtual pin corresponding to IN bit 0 IN_BASE : SM1_PINCTRL_IN_BASE_Field := 16#0#; -- The number of pins asserted by an OUT. Value of 0 -> 32 pins OUT_COUNT : SM1_PINCTRL_OUT_COUNT_Field := 16#0#; -- The number of pins asserted by a SET. Max of 5 SET_COUNT : SM1_PINCTRL_SET_COUNT_Field := 16#5#; -- The number of delay bits co-opted for side-set. Inclusive of the -- enable bit, if present. SIDESET_COUNT : SM1_PINCTRL_SIDESET_COUNT_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SM1_PINCTRL_Register use record OUT_BASE at 0 range 0 .. 4; SET_BASE at 0 range 5 .. 9; SIDESET_BASE at 0 range 10 .. 14; IN_BASE at 0 range 15 .. 19; OUT_COUNT at 0 range 20 .. 25; SET_COUNT at 0 range 26 .. 28; SIDESET_COUNT at 0 range 29 .. 31; end record; subtype SM2_CLKDIV_FRAC_Field is HAL.UInt8; subtype SM2_CLKDIV_INT_Field is HAL.UInt16; -- Clock divider register for state machine 2\n Frequency = clock freq / -- (CLKDIV_INT + CLKDIV_FRAC / 256) type SM2_CLKDIV_Register is record -- unspecified Reserved_0_7 : HAL.UInt8 := 16#0#; -- Fractional part of clock divider FRAC : SM2_CLKDIV_FRAC_Field := 16#0#; -- Effective frequency is sysclk/int.\n Value of 0 is interpreted as max -- possible value INT : SM2_CLKDIV_INT_Field := 16#1#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SM2_CLKDIV_Register use record Reserved_0_7 at 0 range 0 .. 7; FRAC at 0 range 8 .. 15; INT at 0 range 16 .. 31; end record; subtype SM2_EXECCTRL_STATUS_N_Field is HAL.UInt4; -- Comparison used for the MOV x, STATUS instruction. type SM2_EXECCTRL_STATUS_SEL_Field is (-- All-ones if TX FIFO level < N, otherwise all-zeroes Txlevel, -- All-ones if RX FIFO level < N, otherwise all-zeroes Rxlevel) with Size => 1; for SM2_EXECCTRL_STATUS_SEL_Field use (Txlevel => 0, Rxlevel => 1); subtype SM2_EXECCTRL_WRAP_BOTTOM_Field is HAL.UInt5; subtype SM2_EXECCTRL_WRAP_TOP_Field is HAL.UInt5; subtype SM2_EXECCTRL_OUT_EN_SEL_Field is HAL.UInt5; subtype SM2_EXECCTRL_JMP_PIN_Field is HAL.UInt5; -- Execution/behavioural settings for state machine 2 type SM2_EXECCTRL_Register is record -- Comparison level for the MOV x, STATUS instruction STATUS_N : SM2_EXECCTRL_STATUS_N_Field := 16#0#; -- Comparison used for the MOV x, STATUS instruction. STATUS_SEL : SM2_EXECCTRL_STATUS_SEL_Field := RP_SVD.PIO1.Txlevel; -- unspecified Reserved_5_6 : HAL.UInt2 := 16#0#; -- After reaching wrap_top, execution is wrapped to this address. WRAP_BOTTOM : SM2_EXECCTRL_WRAP_BOTTOM_Field := 16#0#; -- After reaching this address, execution is wrapped to wrap_bottom.\n -- If the instruction is a jump, and the jump condition is true, the -- jump takes priority. WRAP_TOP : SM2_EXECCTRL_WRAP_TOP_Field := 16#1F#; -- Continuously assert the most recent OUT/SET to the pins OUT_STICKY : Boolean := False; -- If 1, use a bit of OUT data as an auxiliary write enable\n When used -- in conjunction with OUT_STICKY, writes with an enable of 0 will\n -- deassert the latest pin write. This can create useful -- masking/override behaviour\n due to the priority ordering of state -- machine pin writes (SM0 < SM1 < ...) INLINE_OUT_EN : Boolean := False; -- Which data bit to use for inline OUT enable OUT_EN_SEL : SM2_EXECCTRL_OUT_EN_SEL_Field := 16#0#; -- The GPIO number to use as condition for JMP PIN. Unaffected by input -- mapping. JMP_PIN : SM2_EXECCTRL_JMP_PIN_Field := 16#0#; -- Side-set data is asserted to pin OEs instead of pin values SIDE_PINDIR : Boolean := False; -- If 1, the delay MSB is used as side-set enable, rather than a\n -- side-set data bit. This allows instructions to perform side-set -- optionally,\n rather than on every instruction. SIDE_EN : Boolean := False; -- Read-only. An instruction written to SMx_INSTR is stalled, and -- latched by the\n state machine. Will clear once the instruction -- completes. EXEC_STALLED : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SM2_EXECCTRL_Register use record STATUS_N at 0 range 0 .. 3; STATUS_SEL at 0 range 4 .. 4; Reserved_5_6 at 0 range 5 .. 6; WRAP_BOTTOM at 0 range 7 .. 11; WRAP_TOP at 0 range 12 .. 16; OUT_STICKY at 0 range 17 .. 17; INLINE_OUT_EN at 0 range 18 .. 18; OUT_EN_SEL at 0 range 19 .. 23; JMP_PIN at 0 range 24 .. 28; SIDE_PINDIR at 0 range 29 .. 29; SIDE_EN at 0 range 30 .. 30; EXEC_STALLED at 0 range 31 .. 31; end record; subtype SM2_SHIFTCTRL_PUSH_THRESH_Field is HAL.UInt5; subtype SM2_SHIFTCTRL_PULL_THRESH_Field is HAL.UInt5; -- Control behaviour of the input/output shift registers for state machine -- 2 type SM2_SHIFTCTRL_Register is record -- unspecified Reserved_0_15 : HAL.UInt16 := 16#0#; -- Push automatically when the input shift register is filled AUTOPUSH : Boolean := False; -- Pull automatically when the output shift register is emptied AUTOPULL : Boolean := False; -- 1 = shift input shift register to right (data enters from left). 0 = -- to left. IN_SHIFTDIR : Boolean := True; -- 1 = shift out of output shift register to right. 0 = to left. OUT_SHIFTDIR : Boolean := True; -- Number of bits shifted into RXSR before autopush or conditional -- push.\n Write 0 for value of 32. PUSH_THRESH : SM2_SHIFTCTRL_PUSH_THRESH_Field := 16#0#; -- Number of bits shifted out of TXSR before autopull or conditional -- pull.\n Write 0 for value of 32. PULL_THRESH : SM2_SHIFTCTRL_PULL_THRESH_Field := 16#0#; -- When 1, TX FIFO steals the RX FIFO's storage, and becomes twice as -- deep.\n RX FIFO is disabled as a result (always reads as both full -- and empty).\n FIFOs are flushed when this bit is changed. FJOIN_TX : Boolean := False; -- When 1, RX FIFO steals the TX FIFO's storage, and becomes twice as -- deep.\n TX FIFO is disabled as a result (always reads as both full -- and empty).\n FIFOs are flushed when this bit is changed. FJOIN_RX : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SM2_SHIFTCTRL_Register use record Reserved_0_15 at 0 range 0 .. 15; AUTOPUSH at 0 range 16 .. 16; AUTOPULL at 0 range 17 .. 17; IN_SHIFTDIR at 0 range 18 .. 18; OUT_SHIFTDIR at 0 range 19 .. 19; PUSH_THRESH at 0 range 20 .. 24; PULL_THRESH at 0 range 25 .. 29; FJOIN_TX at 0 range 30 .. 30; FJOIN_RX at 0 range 31 .. 31; end record; subtype SM2_ADDR_SM2_ADDR_Field is HAL.UInt5; -- Current instruction address of state machine 2 type SM2_ADDR_Register is record -- Read-only. SM2_ADDR : SM2_ADDR_SM2_ADDR_Field; -- unspecified Reserved_5_31 : HAL.UInt27; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SM2_ADDR_Register use record SM2_ADDR at 0 range 0 .. 4; Reserved_5_31 at 0 range 5 .. 31; end record; subtype SM2_INSTR_SM2_INSTR_Field is HAL.UInt16; -- Instruction currently being executed by state machine 2\n Write to -- execute an instruction immediately (including jumps) and then resume -- execution. type SM2_INSTR_Register is record SM2_INSTR : SM2_INSTR_SM2_INSTR_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SM2_INSTR_Register use record SM2_INSTR at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype SM2_PINCTRL_OUT_BASE_Field is HAL.UInt5; subtype SM2_PINCTRL_SET_BASE_Field is HAL.UInt5; subtype SM2_PINCTRL_SIDESET_BASE_Field is HAL.UInt5; subtype SM2_PINCTRL_IN_BASE_Field is HAL.UInt5; subtype SM2_PINCTRL_OUT_COUNT_Field is HAL.UInt6; subtype SM2_PINCTRL_SET_COUNT_Field is HAL.UInt3; subtype SM2_PINCTRL_SIDESET_COUNT_Field is HAL.UInt3; -- State machine pin control type SM2_PINCTRL_Register is record -- The virtual pin corresponding to OUT bit 0 OUT_BASE : SM2_PINCTRL_OUT_BASE_Field := 16#0#; -- The virtual pin corresponding to SET bit 0 SET_BASE : SM2_PINCTRL_SET_BASE_Field := 16#0#; -- The virtual pin corresponding to delay field bit 0 SIDESET_BASE : SM2_PINCTRL_SIDESET_BASE_Field := 16#0#; -- The virtual pin corresponding to IN bit 0 IN_BASE : SM2_PINCTRL_IN_BASE_Field := 16#0#; -- The number of pins asserted by an OUT. Value of 0 -> 32 pins OUT_COUNT : SM2_PINCTRL_OUT_COUNT_Field := 16#0#; -- The number of pins asserted by a SET. Max of 5 SET_COUNT : SM2_PINCTRL_SET_COUNT_Field := 16#5#; -- The number of delay bits co-opted for side-set. Inclusive of the -- enable bit, if present. SIDESET_COUNT : SM2_PINCTRL_SIDESET_COUNT_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SM2_PINCTRL_Register use record OUT_BASE at 0 range 0 .. 4; SET_BASE at 0 range 5 .. 9; SIDESET_BASE at 0 range 10 .. 14; IN_BASE at 0 range 15 .. 19; OUT_COUNT at 0 range 20 .. 25; SET_COUNT at 0 range 26 .. 28; SIDESET_COUNT at 0 range 29 .. 31; end record; subtype SM3_CLKDIV_FRAC_Field is HAL.UInt8; subtype SM3_CLKDIV_INT_Field is HAL.UInt16; -- Clock divider register for state machine 3\n Frequency = clock freq / -- (CLKDIV_INT + CLKDIV_FRAC / 256) type SM3_CLKDIV_Register is record -- unspecified Reserved_0_7 : HAL.UInt8 := 16#0#; -- Fractional part of clock divider FRAC : SM3_CLKDIV_FRAC_Field := 16#0#; -- Effective frequency is sysclk/int.\n Value of 0 is interpreted as max -- possible value INT : SM3_CLKDIV_INT_Field := 16#1#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SM3_CLKDIV_Register use record Reserved_0_7 at 0 range 0 .. 7; FRAC at 0 range 8 .. 15; INT at 0 range 16 .. 31; end record; subtype SM3_EXECCTRL_STATUS_N_Field is HAL.UInt4; -- Comparison used for the MOV x, STATUS instruction. type SM3_EXECCTRL_STATUS_SEL_Field is (-- All-ones if TX FIFO level < N, otherwise all-zeroes Txlevel, -- All-ones if RX FIFO level < N, otherwise all-zeroes Rxlevel) with Size => 1; for SM3_EXECCTRL_STATUS_SEL_Field use (Txlevel => 0, Rxlevel => 1); subtype SM3_EXECCTRL_WRAP_BOTTOM_Field is HAL.UInt5; subtype SM3_EXECCTRL_WRAP_TOP_Field is HAL.UInt5; subtype SM3_EXECCTRL_OUT_EN_SEL_Field is HAL.UInt5; subtype SM3_EXECCTRL_JMP_PIN_Field is HAL.UInt5; -- Execution/behavioural settings for state machine 3 type SM3_EXECCTRL_Register is record -- Comparison level for the MOV x, STATUS instruction STATUS_N : SM3_EXECCTRL_STATUS_N_Field := 16#0#; -- Comparison used for the MOV x, STATUS instruction. STATUS_SEL : SM3_EXECCTRL_STATUS_SEL_Field := RP_SVD.PIO1.Txlevel; -- unspecified Reserved_5_6 : HAL.UInt2 := 16#0#; -- After reaching wrap_top, execution is wrapped to this address. WRAP_BOTTOM : SM3_EXECCTRL_WRAP_BOTTOM_Field := 16#0#; -- After reaching this address, execution is wrapped to wrap_bottom.\n -- If the instruction is a jump, and the jump condition is true, the -- jump takes priority. WRAP_TOP : SM3_EXECCTRL_WRAP_TOP_Field := 16#1F#; -- Continuously assert the most recent OUT/SET to the pins OUT_STICKY : Boolean := False; -- If 1, use a bit of OUT data as an auxiliary write enable\n When used -- in conjunction with OUT_STICKY, writes with an enable of 0 will\n -- deassert the latest pin write. This can create useful -- masking/override behaviour\n due to the priority ordering of state -- machine pin writes (SM0 < SM1 < ...) INLINE_OUT_EN : Boolean := False; -- Which data bit to use for inline OUT enable OUT_EN_SEL : SM3_EXECCTRL_OUT_EN_SEL_Field := 16#0#; -- The GPIO number to use as condition for JMP PIN. Unaffected by input -- mapping. JMP_PIN : SM3_EXECCTRL_JMP_PIN_Field := 16#0#; -- Side-set data is asserted to pin OEs instead of pin values SIDE_PINDIR : Boolean := False; -- If 1, the delay MSB is used as side-set enable, rather than a\n -- side-set data bit. This allows instructions to perform side-set -- optionally,\n rather than on every instruction. SIDE_EN : Boolean := False; -- Read-only. An instruction written to SMx_INSTR is stalled, and -- latched by the\n state machine. Will clear once the instruction -- completes. EXEC_STALLED : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SM3_EXECCTRL_Register use record STATUS_N at 0 range 0 .. 3; STATUS_SEL at 0 range 4 .. 4; Reserved_5_6 at 0 range 5 .. 6; WRAP_BOTTOM at 0 range 7 .. 11; WRAP_TOP at 0 range 12 .. 16; OUT_STICKY at 0 range 17 .. 17; INLINE_OUT_EN at 0 range 18 .. 18; OUT_EN_SEL at 0 range 19 .. 23; JMP_PIN at 0 range 24 .. 28; SIDE_PINDIR at 0 range 29 .. 29; SIDE_EN at 0 range 30 .. 30; EXEC_STALLED at 0 range 31 .. 31; end record; subtype SM3_SHIFTCTRL_PUSH_THRESH_Field is HAL.UInt5; subtype SM3_SHIFTCTRL_PULL_THRESH_Field is HAL.UInt5; -- Control behaviour of the input/output shift registers for state machine -- 3 type SM3_SHIFTCTRL_Register is record -- unspecified Reserved_0_15 : HAL.UInt16 := 16#0#; -- Push automatically when the input shift register is filled AUTOPUSH : Boolean := False; -- Pull automatically when the output shift register is emptied AUTOPULL : Boolean := False; -- 1 = shift input shift register to right (data enters from left). 0 = -- to left. IN_SHIFTDIR : Boolean := True; -- 1 = shift out of output shift register to right. 0 = to left. OUT_SHIFTDIR : Boolean := True; -- Number of bits shifted into RXSR before autopush or conditional -- push.\n Write 0 for value of 32. PUSH_THRESH : SM3_SHIFTCTRL_PUSH_THRESH_Field := 16#0#; -- Number of bits shifted out of TXSR before autopull or conditional -- pull.\n Write 0 for value of 32. PULL_THRESH : SM3_SHIFTCTRL_PULL_THRESH_Field := 16#0#; -- When 1, TX FIFO steals the RX FIFO's storage, and becomes twice as -- deep.\n RX FIFO is disabled as a result (always reads as both full -- and empty).\n FIFOs are flushed when this bit is changed. FJOIN_TX : Boolean := False; -- When 1, RX FIFO steals the TX FIFO's storage, and becomes twice as -- deep.\n TX FIFO is disabled as a result (always reads as both full -- and empty).\n FIFOs are flushed when this bit is changed. FJOIN_RX : Boolean := False; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SM3_SHIFTCTRL_Register use record Reserved_0_15 at 0 range 0 .. 15; AUTOPUSH at 0 range 16 .. 16; AUTOPULL at 0 range 17 .. 17; IN_SHIFTDIR at 0 range 18 .. 18; OUT_SHIFTDIR at 0 range 19 .. 19; PUSH_THRESH at 0 range 20 .. 24; PULL_THRESH at 0 range 25 .. 29; FJOIN_TX at 0 range 30 .. 30; FJOIN_RX at 0 range 31 .. 31; end record; subtype SM3_ADDR_SM3_ADDR_Field is HAL.UInt5; -- Current instruction address of state machine 3 type SM3_ADDR_Register is record -- Read-only. SM3_ADDR : SM3_ADDR_SM3_ADDR_Field; -- unspecified Reserved_5_31 : HAL.UInt27; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SM3_ADDR_Register use record SM3_ADDR at 0 range 0 .. 4; Reserved_5_31 at 0 range 5 .. 31; end record; subtype SM3_INSTR_SM3_INSTR_Field is HAL.UInt16; -- Instruction currently being executed by state machine 3\n Write to -- execute an instruction immediately (including jumps) and then resume -- execution. type SM3_INSTR_Register is record SM3_INSTR : SM3_INSTR_SM3_INSTR_Field := 16#0#; -- unspecified Reserved_16_31 : HAL.UInt16 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SM3_INSTR_Register use record SM3_INSTR at 0 range 0 .. 15; Reserved_16_31 at 0 range 16 .. 31; end record; subtype SM3_PINCTRL_OUT_BASE_Field is HAL.UInt5; subtype SM3_PINCTRL_SET_BASE_Field is HAL.UInt5; subtype SM3_PINCTRL_SIDESET_BASE_Field is HAL.UInt5; subtype SM3_PINCTRL_IN_BASE_Field is HAL.UInt5; subtype SM3_PINCTRL_OUT_COUNT_Field is HAL.UInt6; subtype SM3_PINCTRL_SET_COUNT_Field is HAL.UInt3; subtype SM3_PINCTRL_SIDESET_COUNT_Field is HAL.UInt3; -- State machine pin control type SM3_PINCTRL_Register is record -- The virtual pin corresponding to OUT bit 0 OUT_BASE : SM3_PINCTRL_OUT_BASE_Field := 16#0#; -- The virtual pin corresponding to SET bit 0 SET_BASE : SM3_PINCTRL_SET_BASE_Field := 16#0#; -- The virtual pin corresponding to delay field bit 0 SIDESET_BASE : SM3_PINCTRL_SIDESET_BASE_Field := 16#0#; -- The virtual pin corresponding to IN bit 0 IN_BASE : SM3_PINCTRL_IN_BASE_Field := 16#0#; -- The number of pins asserted by an OUT. Value of 0 -> 32 pins OUT_COUNT : SM3_PINCTRL_OUT_COUNT_Field := 16#0#; -- The number of pins asserted by a SET. Max of 5 SET_COUNT : SM3_PINCTRL_SET_COUNT_Field := 16#5#; -- The number of delay bits co-opted for side-set. Inclusive of the -- enable bit, if present. SIDESET_COUNT : SM3_PINCTRL_SIDESET_COUNT_Field := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for SM3_PINCTRL_Register use record OUT_BASE at 0 range 0 .. 4; SET_BASE at 0 range 5 .. 9; SIDESET_BASE at 0 range 10 .. 14; IN_BASE at 0 range 15 .. 19; OUT_COUNT at 0 range 20 .. 25; SET_COUNT at 0 range 26 .. 28; SIDESET_COUNT at 0 range 29 .. 31; end record; -- INTR_SM array type INTR_SM_Field_Array is array (0 .. 3) of Boolean with Component_Size => 1, Size => 4; -- Type definition for INTR_SM type INTR_SM_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SM as a value Val : HAL.UInt4; when True => -- SM as an array Arr : INTR_SM_Field_Array; end case; end record with Unchecked_Union, Size => 4; for INTR_SM_Field use record Val at 0 range 0 .. 3; Arr at 0 range 0 .. 3; end record; -- Raw Interrupts type INTR_Register is record -- Read-only. SM0_RXNEMPTY : Boolean; -- Read-only. SM1_RXNEMPTY : Boolean; -- Read-only. SM2_RXNEMPTY : Boolean; -- Read-only. SM3_RXNEMPTY : Boolean; -- Read-only. SM0_TXNFULL : Boolean; -- Read-only. SM1_TXNFULL : Boolean; -- Read-only. SM2_TXNFULL : Boolean; -- Read-only. SM3_TXNFULL : Boolean; -- Read-only. SM : INTR_SM_Field; -- unspecified Reserved_12_31 : HAL.UInt20; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for INTR_Register use record SM0_RXNEMPTY at 0 range 0 .. 0; SM1_RXNEMPTY at 0 range 1 .. 1; SM2_RXNEMPTY at 0 range 2 .. 2; SM3_RXNEMPTY at 0 range 3 .. 3; SM0_TXNFULL at 0 range 4 .. 4; SM1_TXNFULL at 0 range 5 .. 5; SM2_TXNFULL at 0 range 6 .. 6; SM3_TXNFULL at 0 range 7 .. 7; SM at 0 range 8 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; -- IRQ0_INTE_SM array type IRQ0_INTE_SM_Field_Array is array (0 .. 3) of Boolean with Component_Size => 1, Size => 4; -- Type definition for IRQ0_INTE_SM type IRQ0_INTE_SM_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SM as a value Val : HAL.UInt4; when True => -- SM as an array Arr : IRQ0_INTE_SM_Field_Array; end case; end record with Unchecked_Union, Size => 4; for IRQ0_INTE_SM_Field use record Val at 0 range 0 .. 3; Arr at 0 range 0 .. 3; end record; -- Interrupt Enable for irq0 type IRQ0_INTE_Register is record SM0_RXNEMPTY : Boolean := False; SM1_RXNEMPTY : Boolean := False; SM2_RXNEMPTY : Boolean := False; SM3_RXNEMPTY : Boolean := False; SM0_TXNFULL : Boolean := False; SM1_TXNFULL : Boolean := False; SM2_TXNFULL : Boolean := False; SM3_TXNFULL : Boolean := False; SM : IRQ0_INTE_SM_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for IRQ0_INTE_Register use record SM0_RXNEMPTY at 0 range 0 .. 0; SM1_RXNEMPTY at 0 range 1 .. 1; SM2_RXNEMPTY at 0 range 2 .. 2; SM3_RXNEMPTY at 0 range 3 .. 3; SM0_TXNFULL at 0 range 4 .. 4; SM1_TXNFULL at 0 range 5 .. 5; SM2_TXNFULL at 0 range 6 .. 6; SM3_TXNFULL at 0 range 7 .. 7; SM at 0 range 8 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; -- IRQ0_INTF_SM array type IRQ0_INTF_SM_Field_Array is array (0 .. 3) of Boolean with Component_Size => 1, Size => 4; -- Type definition for IRQ0_INTF_SM type IRQ0_INTF_SM_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SM as a value Val : HAL.UInt4; when True => -- SM as an array Arr : IRQ0_INTF_SM_Field_Array; end case; end record with Unchecked_Union, Size => 4; for IRQ0_INTF_SM_Field use record Val at 0 range 0 .. 3; Arr at 0 range 0 .. 3; end record; -- Interrupt Force for irq0 type IRQ0_INTF_Register is record SM0_RXNEMPTY : Boolean := False; SM1_RXNEMPTY : Boolean := False; SM2_RXNEMPTY : Boolean := False; SM3_RXNEMPTY : Boolean := False; SM0_TXNFULL : Boolean := False; SM1_TXNFULL : Boolean := False; SM2_TXNFULL : Boolean := False; SM3_TXNFULL : Boolean := False; SM : IRQ0_INTF_SM_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for IRQ0_INTF_Register use record SM0_RXNEMPTY at 0 range 0 .. 0; SM1_RXNEMPTY at 0 range 1 .. 1; SM2_RXNEMPTY at 0 range 2 .. 2; SM3_RXNEMPTY at 0 range 3 .. 3; SM0_TXNFULL at 0 range 4 .. 4; SM1_TXNFULL at 0 range 5 .. 5; SM2_TXNFULL at 0 range 6 .. 6; SM3_TXNFULL at 0 range 7 .. 7; SM at 0 range 8 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; -- IRQ0_INTS_SM array type IRQ0_INTS_SM_Field_Array is array (0 .. 3) of Boolean with Component_Size => 1, Size => 4; -- Type definition for IRQ0_INTS_SM type IRQ0_INTS_SM_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SM as a value Val : HAL.UInt4; when True => -- SM as an array Arr : IRQ0_INTS_SM_Field_Array; end case; end record with Unchecked_Union, Size => 4; for IRQ0_INTS_SM_Field use record Val at 0 range 0 .. 3; Arr at 0 range 0 .. 3; end record; -- Interrupt status after masking & forcing for irq0 type IRQ0_INTS_Register is record -- Read-only. SM0_RXNEMPTY : Boolean; -- Read-only. SM1_RXNEMPTY : Boolean; -- Read-only. SM2_RXNEMPTY : Boolean; -- Read-only. SM3_RXNEMPTY : Boolean; -- Read-only. SM0_TXNFULL : Boolean; -- Read-only. SM1_TXNFULL : Boolean; -- Read-only. SM2_TXNFULL : Boolean; -- Read-only. SM3_TXNFULL : Boolean; -- Read-only. SM : IRQ0_INTS_SM_Field; -- unspecified Reserved_12_31 : HAL.UInt20; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for IRQ0_INTS_Register use record SM0_RXNEMPTY at 0 range 0 .. 0; SM1_RXNEMPTY at 0 range 1 .. 1; SM2_RXNEMPTY at 0 range 2 .. 2; SM3_RXNEMPTY at 0 range 3 .. 3; SM0_TXNFULL at 0 range 4 .. 4; SM1_TXNFULL at 0 range 5 .. 5; SM2_TXNFULL at 0 range 6 .. 6; SM3_TXNFULL at 0 range 7 .. 7; SM at 0 range 8 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; -- IRQ1_INTE_SM array type IRQ1_INTE_SM_Field_Array is array (0 .. 3) of Boolean with Component_Size => 1, Size => 4; -- Type definition for IRQ1_INTE_SM type IRQ1_INTE_SM_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SM as a value Val : HAL.UInt4; when True => -- SM as an array Arr : IRQ1_INTE_SM_Field_Array; end case; end record with Unchecked_Union, Size => 4; for IRQ1_INTE_SM_Field use record Val at 0 range 0 .. 3; Arr at 0 range 0 .. 3; end record; -- Interrupt Enable for irq1 type IRQ1_INTE_Register is record SM0_RXNEMPTY : Boolean := False; SM1_RXNEMPTY : Boolean := False; SM2_RXNEMPTY : Boolean := False; SM3_RXNEMPTY : Boolean := False; SM0_TXNFULL : Boolean := False; SM1_TXNFULL : Boolean := False; SM2_TXNFULL : Boolean := False; SM3_TXNFULL : Boolean := False; SM : IRQ1_INTE_SM_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for IRQ1_INTE_Register use record SM0_RXNEMPTY at 0 range 0 .. 0; SM1_RXNEMPTY at 0 range 1 .. 1; SM2_RXNEMPTY at 0 range 2 .. 2; SM3_RXNEMPTY at 0 range 3 .. 3; SM0_TXNFULL at 0 range 4 .. 4; SM1_TXNFULL at 0 range 5 .. 5; SM2_TXNFULL at 0 range 6 .. 6; SM3_TXNFULL at 0 range 7 .. 7; SM at 0 range 8 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; -- IRQ1_INTF_SM array type IRQ1_INTF_SM_Field_Array is array (0 .. 3) of Boolean with Component_Size => 1, Size => 4; -- Type definition for IRQ1_INTF_SM type IRQ1_INTF_SM_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SM as a value Val : HAL.UInt4; when True => -- SM as an array Arr : IRQ1_INTF_SM_Field_Array; end case; end record with Unchecked_Union, Size => 4; for IRQ1_INTF_SM_Field use record Val at 0 range 0 .. 3; Arr at 0 range 0 .. 3; end record; -- Interrupt Force for irq1 type IRQ1_INTF_Register is record SM0_RXNEMPTY : Boolean := False; SM1_RXNEMPTY : Boolean := False; SM2_RXNEMPTY : Boolean := False; SM3_RXNEMPTY : Boolean := False; SM0_TXNFULL : Boolean := False; SM1_TXNFULL : Boolean := False; SM2_TXNFULL : Boolean := False; SM3_TXNFULL : Boolean := False; SM : IRQ1_INTF_SM_Field := (As_Array => False, Val => 16#0#); -- unspecified Reserved_12_31 : HAL.UInt20 := 16#0#; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for IRQ1_INTF_Register use record SM0_RXNEMPTY at 0 range 0 .. 0; SM1_RXNEMPTY at 0 range 1 .. 1; SM2_RXNEMPTY at 0 range 2 .. 2; SM3_RXNEMPTY at 0 range 3 .. 3; SM0_TXNFULL at 0 range 4 .. 4; SM1_TXNFULL at 0 range 5 .. 5; SM2_TXNFULL at 0 range 6 .. 6; SM3_TXNFULL at 0 range 7 .. 7; SM at 0 range 8 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; -- IRQ1_INTS_SM array type IRQ1_INTS_SM_Field_Array is array (0 .. 3) of Boolean with Component_Size => 1, Size => 4; -- Type definition for IRQ1_INTS_SM type IRQ1_INTS_SM_Field (As_Array : Boolean := False) is record case As_Array is when False => -- SM as a value Val : HAL.UInt4; when True => -- SM as an array Arr : IRQ1_INTS_SM_Field_Array; end case; end record with Unchecked_Union, Size => 4; for IRQ1_INTS_SM_Field use record Val at 0 range 0 .. 3; Arr at 0 range 0 .. 3; end record; -- Interrupt status after masking & forcing for irq1 type IRQ1_INTS_Register is record -- Read-only. SM0_RXNEMPTY : Boolean; -- Read-only. SM1_RXNEMPTY : Boolean; -- Read-only. SM2_RXNEMPTY : Boolean; -- Read-only. SM3_RXNEMPTY : Boolean; -- Read-only. SM0_TXNFULL : Boolean; -- Read-only. SM1_TXNFULL : Boolean; -- Read-only. SM2_TXNFULL : Boolean; -- Read-only. SM3_TXNFULL : Boolean; -- Read-only. SM : IRQ1_INTS_SM_Field; -- unspecified Reserved_12_31 : HAL.UInt20; end record with Volatile_Full_Access, Object_Size => 32, Bit_Order => System.Low_Order_First; for IRQ1_INTS_Register use record SM0_RXNEMPTY at 0 range 0 .. 0; SM1_RXNEMPTY at 0 range 1 .. 1; SM2_RXNEMPTY at 0 range 2 .. 2; SM3_RXNEMPTY at 0 range 3 .. 3; SM0_TXNFULL at 0 range 4 .. 4; SM1_TXNFULL at 0 range 5 .. 5; SM2_TXNFULL at 0 range 6 .. 6; SM3_TXNFULL at 0 range 7 .. 7; SM at 0 range 8 .. 11; Reserved_12_31 at 0 range 12 .. 31; end record; ----------------- -- Peripherals -- ----------------- -- Programmable IO block type PIO1_Peripheral is record -- PIO control register CTRL : aliased CTRL_Register; -- FIFO status register FSTAT : aliased FSTAT_Register; -- FIFO debug register FDEBUG : aliased FDEBUG_Register; -- FIFO levels FLEVEL : aliased FLEVEL_Register; -- Direct write access to the TX FIFO for this state machine. Each write -- pushes one word to the FIFO. TXF0 : aliased HAL.UInt32; -- Direct write access to the TX FIFO for this state machine. Each write -- pushes one word to the FIFO. TXF1 : aliased HAL.UInt32; -- Direct write access to the TX FIFO for this state machine. Each write -- pushes one word to the FIFO. TXF2 : aliased HAL.UInt32; -- Direct write access to the TX FIFO for this state machine. Each write -- pushes one word to the FIFO. TXF3 : aliased HAL.UInt32; -- Direct read access to the RX FIFO for this state machine. Each read -- pops one word from the FIFO. RXF0 : aliased HAL.UInt32; -- Direct read access to the RX FIFO for this state machine. Each read -- pops one word from the FIFO. RXF1 : aliased HAL.UInt32; -- Direct read access to the RX FIFO for this state machine. Each read -- pops one word from the FIFO. RXF2 : aliased HAL.UInt32; -- Direct read access to the RX FIFO for this state machine. Each read -- pops one word from the FIFO. RXF3 : aliased HAL.UInt32; -- Interrupt request register. Write 1 to clear IRQ : aliased IRQ_Register; -- Writing a 1 to each of these bits will forcibly assert the -- corresponding IRQ.\n Note this is different to the INTF register: -- writing here affects PIO internal\n state. INTF just asserts the -- processor-facing IRQ signal for testing ISRs,\n and is not visible to -- the state machines. IRQ_FORCE : aliased IRQ_FORCE_Register; -- There is a 2-flipflop synchronizer on each GPIO input, which -- protects\n PIO logic from metastabilities. This increases input -- delay, and for fast\n synchronous IO (e.g. SPI) these synchronizers -- may need to be bypassed.\n Each bit in this register corresponds to -- one GPIO.\n 0 -> input is synchronized (default)\n 1 -> synchronizer -- is bypassed\n If in doubt, leave this register as all zeroes. INPUT_SYNC_BYPASS : aliased HAL.UInt32; -- Read to sample the pad output values PIO is currently driving to the -- GPIOs. DBG_PADOUT : aliased HAL.UInt32; -- Read to sample the pad output enables (direction) PIO is currently -- driving to the GPIOs. DBG_PADOE : aliased HAL.UInt32; -- The PIO hardware has some free parameters that may vary between chip -- products.\n These should be provided in the chip datasheet, but are -- also exposed here. DBG_CFGINFO : aliased DBG_CFGINFO_Register; -- Write-only access to instruction memory location 0 INSTR_MEM0 : aliased INSTR_MEM0_Register; -- Write-only access to instruction memory location 1 INSTR_MEM1 : aliased INSTR_MEM1_Register; -- Write-only access to instruction memory location 2 INSTR_MEM2 : aliased INSTR_MEM2_Register; -- Write-only access to instruction memory location 3 INSTR_MEM3 : aliased INSTR_MEM3_Register; -- Write-only access to instruction memory location 4 INSTR_MEM4 : aliased INSTR_MEM4_Register; -- Write-only access to instruction memory location 5 INSTR_MEM5 : aliased INSTR_MEM5_Register; -- Write-only access to instruction memory location 6 INSTR_MEM6 : aliased INSTR_MEM6_Register; -- Write-only access to instruction memory location 7 INSTR_MEM7 : aliased INSTR_MEM7_Register; -- Write-only access to instruction memory location 8 INSTR_MEM8 : aliased INSTR_MEM8_Register; -- Write-only access to instruction memory location 9 INSTR_MEM9 : aliased INSTR_MEM9_Register; -- Write-only access to instruction memory location 10 INSTR_MEM10 : aliased INSTR_MEM10_Register; -- Write-only access to instruction memory location 11 INSTR_MEM11 : aliased INSTR_MEM11_Register; -- Write-only access to instruction memory location 12 INSTR_MEM12 : aliased INSTR_MEM12_Register; -- Write-only access to instruction memory location 13 INSTR_MEM13 : aliased INSTR_MEM13_Register; -- Write-only access to instruction memory location 14 INSTR_MEM14 : aliased INSTR_MEM14_Register; -- Write-only access to instruction memory location 15 INSTR_MEM15 : aliased INSTR_MEM15_Register; -- Write-only access to instruction memory location 16 INSTR_MEM16 : aliased INSTR_MEM16_Register; -- Write-only access to instruction memory location 17 INSTR_MEM17 : aliased INSTR_MEM17_Register; -- Write-only access to instruction memory location 18 INSTR_MEM18 : aliased INSTR_MEM18_Register; -- Write-only access to instruction memory location 19 INSTR_MEM19 : aliased INSTR_MEM19_Register; -- Write-only access to instruction memory location 20 INSTR_MEM20 : aliased INSTR_MEM20_Register; -- Write-only access to instruction memory location 21 INSTR_MEM21 : aliased INSTR_MEM21_Register; -- Write-only access to instruction memory location 22 INSTR_MEM22 : aliased INSTR_MEM22_Register; -- Write-only access to instruction memory location 23 INSTR_MEM23 : aliased INSTR_MEM23_Register; -- Write-only access to instruction memory location 24 INSTR_MEM24 : aliased INSTR_MEM24_Register; -- Write-only access to instruction memory location 25 INSTR_MEM25 : aliased INSTR_MEM25_Register; -- Write-only access to instruction memory location 26 INSTR_MEM26 : aliased INSTR_MEM26_Register; -- Write-only access to instruction memory location 27 INSTR_MEM27 : aliased INSTR_MEM27_Register; -- Write-only access to instruction memory location 28 INSTR_MEM28 : aliased INSTR_MEM28_Register; -- Write-only access to instruction memory location 29 INSTR_MEM29 : aliased INSTR_MEM29_Register; -- Write-only access to instruction memory location 30 INSTR_MEM30 : aliased INSTR_MEM30_Register; -- Write-only access to instruction memory location 31 INSTR_MEM31 : aliased INSTR_MEM31_Register; -- Clock divider register for state machine 0\n Frequency = clock freq / -- (CLKDIV_INT + CLKDIV_FRAC / 256) SM0_CLKDIV : aliased SM0_CLKDIV_Register; -- Execution/behavioural settings for state machine 0 SM0_EXECCTRL : aliased SM0_EXECCTRL_Register; -- Control behaviour of the input/output shift registers for state -- machine 0 SM0_SHIFTCTRL : aliased SM0_SHIFTCTRL_Register; -- Current instruction address of state machine 0 SM0_ADDR : aliased SM0_ADDR_Register; -- Instruction currently being executed by state machine 0\n Write to -- execute an instruction immediately (including jumps) and then resume -- execution. SM0_INSTR : aliased SM0_INSTR_Register; -- State machine pin control SM0_PINCTRL : aliased SM0_PINCTRL_Register; -- Clock divider register for state machine 1\n Frequency = clock freq / -- (CLKDIV_INT + CLKDIV_FRAC / 256) SM1_CLKDIV : aliased SM1_CLKDIV_Register; -- Execution/behavioural settings for state machine 1 SM1_EXECCTRL : aliased SM1_EXECCTRL_Register; -- Control behaviour of the input/output shift registers for state -- machine 1 SM1_SHIFTCTRL : aliased SM1_SHIFTCTRL_Register; -- Current instruction address of state machine 1 SM1_ADDR : aliased SM1_ADDR_Register; -- Instruction currently being executed by state machine 1\n Write to -- execute an instruction immediately (including jumps) and then resume -- execution. SM1_INSTR : aliased SM1_INSTR_Register; -- State machine pin control SM1_PINCTRL : aliased SM1_PINCTRL_Register; -- Clock divider register for state machine 2\n Frequency = clock freq / -- (CLKDIV_INT + CLKDIV_FRAC / 256) SM2_CLKDIV : aliased SM2_CLKDIV_Register; -- Execution/behavioural settings for state machine 2 SM2_EXECCTRL : aliased SM2_EXECCTRL_Register; -- Control behaviour of the input/output shift registers for state -- machine 2 SM2_SHIFTCTRL : aliased SM2_SHIFTCTRL_Register; -- Current instruction address of state machine 2 SM2_ADDR : aliased SM2_ADDR_Register; -- Instruction currently being executed by state machine 2\n Write to -- execute an instruction immediately (including jumps) and then resume -- execution. SM2_INSTR : aliased SM2_INSTR_Register; -- State machine pin control SM2_PINCTRL : aliased SM2_PINCTRL_Register; -- Clock divider register for state machine 3\n Frequency = clock freq / -- (CLKDIV_INT + CLKDIV_FRAC / 256) SM3_CLKDIV : aliased SM3_CLKDIV_Register; -- Execution/behavioural settings for state machine 3 SM3_EXECCTRL : aliased SM3_EXECCTRL_Register; -- Control behaviour of the input/output shift registers for state -- machine 3 SM3_SHIFTCTRL : aliased SM3_SHIFTCTRL_Register; -- Current instruction address of state machine 3 SM3_ADDR : aliased SM3_ADDR_Register; -- Instruction currently being executed by state machine 3\n Write to -- execute an instruction immediately (including jumps) and then resume -- execution. SM3_INSTR : aliased SM3_INSTR_Register; -- State machine pin control SM3_PINCTRL : aliased SM3_PINCTRL_Register; -- Raw Interrupts INTR : aliased INTR_Register; -- Interrupt Enable for irq0 IRQ0_INTE : aliased IRQ0_INTE_Register; -- Interrupt Force for irq0 IRQ0_INTF : aliased IRQ0_INTF_Register; -- Interrupt status after masking & forcing for irq0 IRQ0_INTS : aliased IRQ0_INTS_Register; -- Interrupt Enable for irq1 IRQ1_INTE : aliased IRQ1_INTE_Register; -- Interrupt Force for irq1 IRQ1_INTF : aliased IRQ1_INTF_Register; -- Interrupt status after masking & forcing for irq1 IRQ1_INTS : aliased IRQ1_INTS_Register; end record with Volatile; for PIO1_Peripheral use record CTRL at 16#0# range 0 .. 31; FSTAT at 16#4# range 0 .. 31; FDEBUG at 16#8# range 0 .. 31; FLEVEL at 16#C# range 0 .. 31; TXF0 at 16#10# range 0 .. 31; TXF1 at 16#14# range 0 .. 31; TXF2 at 16#18# range 0 .. 31; TXF3 at 16#1C# range 0 .. 31; RXF0 at 16#20# range 0 .. 31; RXF1 at 16#24# range 0 .. 31; RXF2 at 16#28# range 0 .. 31; RXF3 at 16#2C# range 0 .. 31; IRQ at 16#30# range 0 .. 31; IRQ_FORCE at 16#34# range 0 .. 31; INPUT_SYNC_BYPASS at 16#38# range 0 .. 31; DBG_PADOUT at 16#3C# range 0 .. 31; DBG_PADOE at 16#40# range 0 .. 31; DBG_CFGINFO at 16#44# range 0 .. 31; INSTR_MEM0 at 16#48# range 0 .. 31; INSTR_MEM1 at 16#4C# range 0 .. 31; INSTR_MEM2 at 16#50# range 0 .. 31; INSTR_MEM3 at 16#54# range 0 .. 31; INSTR_MEM4 at 16#58# range 0 .. 31; INSTR_MEM5 at 16#5C# range 0 .. 31; INSTR_MEM6 at 16#60# range 0 .. 31; INSTR_MEM7 at 16#64# range 0 .. 31; INSTR_MEM8 at 16#68# range 0 .. 31; INSTR_MEM9 at 16#6C# range 0 .. 31; INSTR_MEM10 at 16#70# range 0 .. 31; INSTR_MEM11 at 16#74# range 0 .. 31; INSTR_MEM12 at 16#78# range 0 .. 31; INSTR_MEM13 at 16#7C# range 0 .. 31; INSTR_MEM14 at 16#80# range 0 .. 31; INSTR_MEM15 at 16#84# range 0 .. 31; INSTR_MEM16 at 16#88# range 0 .. 31; INSTR_MEM17 at 16#8C# range 0 .. 31; INSTR_MEM18 at 16#90# range 0 .. 31; INSTR_MEM19 at 16#94# range 0 .. 31; INSTR_MEM20 at 16#98# range 0 .. 31; INSTR_MEM21 at 16#9C# range 0 .. 31; INSTR_MEM22 at 16#A0# range 0 .. 31; INSTR_MEM23 at 16#A4# range 0 .. 31; INSTR_MEM24 at 16#A8# range 0 .. 31; INSTR_MEM25 at 16#AC# range 0 .. 31; INSTR_MEM26 at 16#B0# range 0 .. 31; INSTR_MEM27 at 16#B4# range 0 .. 31; INSTR_MEM28 at 16#B8# range 0 .. 31; INSTR_MEM29 at 16#BC# range 0 .. 31; INSTR_MEM30 at 16#C0# range 0 .. 31; INSTR_MEM31 at 16#C4# range 0 .. 31; SM0_CLKDIV at 16#C8# range 0 .. 31; SM0_EXECCTRL at 16#CC# range 0 .. 31; SM0_SHIFTCTRL at 16#D0# range 0 .. 31; SM0_ADDR at 16#D4# range 0 .. 31; SM0_INSTR at 16#D8# range 0 .. 31; SM0_PINCTRL at 16#DC# range 0 .. 31; SM1_CLKDIV at 16#E0# range 0 .. 31; SM1_EXECCTRL at 16#E4# range 0 .. 31; SM1_SHIFTCTRL at 16#E8# range 0 .. 31; SM1_ADDR at 16#EC# range 0 .. 31; SM1_INSTR at 16#F0# range 0 .. 31; SM1_PINCTRL at 16#F4# range 0 .. 31; SM2_CLKDIV at 16#F8# range 0 .. 31; SM2_EXECCTRL at 16#FC# range 0 .. 31; SM2_SHIFTCTRL at 16#100# range 0 .. 31; SM2_ADDR at 16#104# range 0 .. 31; SM2_INSTR at 16#108# range 0 .. 31; SM2_PINCTRL at 16#10C# range 0 .. 31; SM3_CLKDIV at 16#110# range 0 .. 31; SM3_EXECCTRL at 16#114# range 0 .. 31; SM3_SHIFTCTRL at 16#118# range 0 .. 31; SM3_ADDR at 16#11C# range 0 .. 31; SM3_INSTR at 16#120# range 0 .. 31; SM3_PINCTRL at 16#124# range 0 .. 31; INTR at 16#128# range 0 .. 31; IRQ0_INTE at 16#12C# range 0 .. 31; IRQ0_INTF at 16#130# range 0 .. 31; IRQ0_INTS at 16#134# range 0 .. 31; IRQ1_INTE at 16#138# range 0 .. 31; IRQ1_INTF at 16#13C# range 0 .. 31; IRQ1_INTS at 16#140# range 0 .. 31; end record; -- Programmable IO block PIO1_Periph : aliased PIO1_Peripheral with Import, Address => PIO1_Base; end RP_SVD.PIO1;
-- package pc_2_coeff_20 -- -- Predictor_Rule : Integration_Rule renames Predictor_32_20; -- -- Corrector_Rule : Integration_Rule renames Corrector_33_20; -- -- Final_Step_Corrector : Real renames Final_Step_Corrector_33_20; generic type Real is digits <>; package pc_2_coeff_20 is subtype PC_Rule_Range is Integer range 0..31; type Integration_Rule is array(PC_Rule_Range) of Real; Starting_Id_of_First_Deriv_of_Y : constant PC_Rule_Range := 15; -- Center_Integration Rule, applied to (d/dt)**2 Y, takes a dY/dt here, and -- Integrates it one indice forward. Extrap_Factor: constant Real := 1.0 / 18.4; --using 20 order center integr. Corrector_33_20 : constant Integration_Rule := ( -8.55174773365542810125247903441564880E-4, 1.08799020509215653999792415002138806E-2, -5.98807243948632167226495496188008202E-2, 1.81488244958372219606123531287673514E-1, -3.09797512122888357321010504493372402E-1, 2.34403050273857971510590645531000542E-1, 9.79330522148025227287594602166299163E-2, -2.77633074988893655940917386903055705E-1, -1.68140788180143672682016210371683483E-2, 2.74388089831285514600129857755410670E-1, 2.42092847609618613267021265005431658E-2, -2.66016510267988522967136454952130358E-1, -7.82198779500683939243870921110280431E-2, 2.30528604881633225444771511001426156E-1, 1.32752900227021806218154527276514406E-1, -1.08633881162194363314746581547842899E-1, 1.88212765588327200749334042985019967E-1, 9.95407129402333404744846988537650387E-1, 1.45715395435233336079808363815157167E+0, 1.08867569153654151597403791053467495E+0, 5.68803773336973771436036563831289386E-1, 7.90282029197709581840721356274557683E-1, 1.41312770198894658653930470398104117E+0, 1.30251010240006755023323114993325085E+0, 5.60116554132292653591867459376320719E-1, 6.69718155148611411378976413930281279E-1, 1.59160406112984439522301118168937892E+0, 1.14338340854186182605157194557314430E+0, 1.28871618852683062320854062951279782E-1, 1.89739203673310992720763368551517101E+0, 4.93612805842445046458910141101008804E-1, 1.08617699811391691117663539822936064E+0 ); Final_Step_Corrector_33_20 : constant Real := 5.62189189814215277089068949024263372E-2; Predictor_31_20 : constant Integration_Rule := ( 0.0, 3.71108727678097765120276726234553336E-2, -5.06038283780681331759837219918580977E-1, 3.03190033247460216356241305150918101E+0, -1.02624653725186416859975775449901825E+1, 2.06141703499560139778153446612572425E+1, -2.19764888153009101002691735643159697E+1, 3.13103774290675475015870359794024959E+0, 1.93912629451531651643560470483880988E+1, -1.20519587833962811897580363143414478E+1, -1.62152600610790555528930054173145064E+1, 1.44034717082396648519595462951296246E+1, 1.62644082542022744526141395569760920E+1, -1.39480178119209560443676610096029311E+1, -1.85973168657304870015791067712523361E+1, 1.16857820996661055425682810828858984E+1, 2.22125383601620792778873230835801331E+1, -7.09700161239051889272953492931020167E+0, -2.37739076860647447532838799110126126E+1, 5.25733965636968199667570737237860034E+0, 2.87371707883292842124818226417648031E+1, -1.10196084133390662939033673460655251E+0, -3.01058675313311579880796252087668176E+1, 5.85282658159192545881160005723940358E+0, 3.59569294918921372966362335168302678E+1, -1.84771402800733597472621108139022118E+1, -2.90750967868685422705864101221125547E+1, 5.52922950325299794199805546971515784E+1, -4.06384245478824130835629088322035513E+1, 2.00982837254447949145367808103200651E+1, -4.52219057730644796527546378915980965E+0, 1.88260791529183098023814303683557297E+0 ); Center_Integration_32_20 : constant Integration_Rule := ( 3.15713968194170133919540213875143917E-5, -4.68054008955732353100985646310188096E-4, 3.07872579249862231519513009405313968E-3, -1.15997994611621236175002511977323250E-2, 2.65427741706869908147987953876501056E-2, -3.41143206815192906544786599038747983E-2, 1.20645063820463013734131783866792169E-2, 2.94493218168506239920090546327231263E-2, -3.18445717486473259824967360646315308E-2, -2.50397085225343097687547550717275702E-2, 4.76987615793932385807965774292440943E-2, 3.07886851486023175023595502260427314E-2, -7.38315319596948536351414208989101596E-2, -6.07773034846435767063660851642605318E-2, 1.69131632098663497836012986946412281E-1, 4.18889311481596203289861666823254893E-1, 4.18889311481596203289861666823254893E-1, 1.69131632098663497836012986946412281E-1, -6.07773034846435767063660851642605318E-2, -7.38315319596948536351414208989101596E-2, 3.07886851486023175023595502260427314E-2, 4.76987615793932385807965774292440943E-2, -2.50397085225343097687547550717275702E-2, -3.18445717486473259824967360646315308E-2, 2.94493218168506239920090546327231263E-2, 1.20645063820463013734131783866792169E-2, -3.41143206815192906544786599038747983E-2, 2.65427741706869908147987953876501056E-2, -1.15997994611621236175002511977323250E-2, 3.07872579249862231519513009405313968E-3, -4.68054008955732353100985646310188096E-4, 3.15713968194170133919540213875143917E-5 ); Center_Integration_32_22 : constant Integration_Rule := ( -5.48186298516234652810704051430422655E-6, 9.83867415088779031208187158666710319E-5, -8.07566491514156651234056438130100106E-4, 3.97340757417976466081704231342063697E-3, -1.28356892096129410337836800376618841E-2, 2.76864991077874453604989378001785406E-2, -3.73245825355348862199480292460505598E-2, 2.12653218023217359291463822190892211E-2, 2.13745306335366393296921989209611924E-2, -4.56656788294881115637614729100805322E-2, 3.89437307673685355200946981995831816E-3, 6.22684247056539251232690828593738376E-2, -3.61385003611128933128201417801336908E-2, -9.55657510587708441101932722470146491E-2, 1.33596784912141525960540060966517392E-1, 4.54185521795152227419174766084219910E-1, 4.54185521795152227419174766084219910E-1, 1.33596784912141525960540060966517392E-1, -9.55657510587708441101932722470146491E-2, -3.61385003611128933128201417801336908E-2, 6.22684247056539251232690828593738376E-2, 3.89437307673685355200946981995831816E-3, -4.56656788294881115637614729100805322E-2, 2.13745306335366393296921989209611924E-2, 2.12653218023217359291463822190892211E-2, -3.73245825355348862199480292460505598E-2, 2.76864991077874453604989378001785406E-2, -1.28356892096129410337836800376618841E-2, 3.97340757417976466081704231342063697E-3, -8.07566491514156651234056438130100106E-4, 9.83867415088779031208187158666710319E-5, -5.48186298516234652810704051430422655E-6 ); Center_to_End_Integration_32_20 : constant Integration_Rule := ( -2.86386061369796720288602153765466086E-3, 3.77465669564208701988194199064386183E-2, -2.16918716521626019186490223558167110E-1, 6.95426774390568532091465095269529112E-1, -1.29019469338161323733227504692181277E+0, 1.17298162653774707488654908953634099E+0, 1.37888543617482416082540041836111787E-1, -1.23211215373380283866528411256821590E+0, 3.14045424246911795127273180916596717E-1, 1.17432311655916972040956457499680797E+0, -3.64763399153107025837257593340386960E-1, -1.21280637011119196098904355440304660E+0, 1.82342156243146214443817819223431585E-1, 1.26500802055743604130463842953293533E+0, 2.04988866876595023257807452491015192E-1, -8.92041637190838025750940136713437543E-1, 3.67258034718844737504853759591653078E-1, 2.41065548250948746044603686271139350E+0, 2.01624831177845769971589032829444510E+0, -2.17574984937012348001512229695676207E-1, -3.84187387520669853052532264096051345E-1, 2.08730620069194768113347525743331340E+0, 2.67001607108536140451921505467397790E+0, -2.23523291208105397640505219542850802E-1, -8.00131026645121829127853190651542875E-1, 3.00262104565864983476416014660867486E+0, 2.15056777830019161263448757485324027E+0, -2.61092517941099763297880878634545940E+0, 4.40625889845489387749214282954584149E+0, -9.31878416636917660438034239401347078E-1, 1.82120219150496018217931474409591347E+0, 2.63036006376429618011370957257988852E-1 ); Center_to_End_Integration : Integration_Rule renames Center_to_End_Integration_32_20; Predictor_Rule : Integration_Rule renames Predictor_31_20; Corrector_Rule : Integration_Rule renames Corrector_33_20; Center_Integration : Integration_Rule renames Center_Integration_32_20; Final_Step_Corrector : Real renames Final_Step_Corrector_33_20; end pc_2_coeff_20;
-- { dg-do compile } -- { dg-final { scan-assembler-not "elabs" } } package OCONST6 is type Sequence is array (1 .. 1) of Natural; type Message is record Data : Sequence; end record; for Message'Alignment use 1; pragma PACK (Message); ACK : Message := (Data => (others => 1)); end;
generic type Value_T(<>) is private; package My_Env_Versioned_Value_Set_G is generic with function Updated_Entity (Value : Value_T) return Boolean is <>; package Update_G is end; end;
-- Copyright 2018-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 Enum_With_Gap is type Enum_With_Gaps is ( LIT0, LIT1, LIT2, LIT3, LIT4 ); for Enum_With_Gaps use ( LIT0 => 3, LIT1 => 5, LIT2 => 8, LIT3 => 13, LIT4 => 21 ); for Enum_With_Gaps'size use 16; type Enum_Subrange is new Enum_With_Gaps range Lit1 .. Lit3; type MyWord is range 0 .. 16#FFFF# ; for MyWord'Size use 16; type AR is array (Enum_With_Gaps range <>) of MyWord; type AR_Access is access AR; type String_Access is access String; procedure Do_Nothing (E : AR_Access); procedure Do_Nothing (E : String_Access); end Enum_With_Gap;
with Interfaces.C; with Interfaces.C.Strings; with Ada.Exceptions; package body GDNative.Context is package IC renames Interfaces.C; package ICS renames Interfaces.C.Strings; package AE renames Ada.Exceptions; ------------------------ -- GDNative Initalize -- ------------------------ procedure GDNative_Initialize (p_options : access Thin.godot_gdnative_init_options) is Cursor : Thin.GDnative_Api_Struct_Pointers.Pointer; begin pragma Assert (not Core_Initialized, "Cannot initialize Core twice"); Core_Api := p_options.api_struct; Core_Initialized := True; Core_Api.godot_variant_new_nil (Nil_Godot_Variant'access); Cursor := Core_Api.extensions; for I in 1 .. Core_Api.num_extensions loop case Cursor.all.c_type is when Thin.GDNATIVE_EXT_NATIVESCRIPT => Nativescript_Api := Thin.To_Api_Struct_Ptr (Cursor.all); when Thin.GDNATIVE_EXT_PLUGINSCRIPT => Pluginscript_Api := Thin.To_Api_Struct_Ptr (Cursor.all); when Thin.GDNATIVE_EXT_ANDROID => Android_Api := Thin.To_Api_Struct_Ptr (Cursor.all); when Thin.GDNATIVE_EXT_ARVR => Arvr_Api := Thin.To_Api_Struct_Ptr (Cursor.all); when Thin.GDNATIVE_EXT_VIDEODECODER => Videodecoder_Api := Thin.To_Api_Struct_Ptr (Cursor.all); when Thin.GDNATIVE_EXT_NET => Net_Api := Thin.To_Api_Struct_Ptr (Cursor.all); when others => null; end case; Thin.GDnative_Api_Struct_Pointers.Increment (Cursor); end loop; exception when Error: others => declare C_Error_Info : ICS.chars_ptr := ICS.New_String (AE.Exception_Information (Error)); begin p_options.report_loading_error (p_options.gd_native_library, C_Error_Info); ICS.Free (C_Error_Info); end; end; ----------------------- -- GDNative Finalize -- ----------------------- procedure GDNative_Finalize (p_options : access Thin.godot_gdnative_terminate_options) is begin pragma Assert (Core_Initialized, "Finalizing without Initializing Core"); pragma Assert (Nativescript_Initialized, "Finalizing without Initializing Nativescript"); Core_Initialized := False; Nativescript_Initialized := False; Core_Api := null; Nativescript_Api := null; Nativescript_Ptr := Thin.Null_Handle; Pluginscript_Api := null; Android_Api := null; Arvr_Api := null; Videodecoder_Api := null; Net_Api := null; end; ----------------------------- -- Nativescript Initialize -- ----------------------------- procedure Nativescript_Initialize (p_handle : in Thin.Nativescript_Handle) is begin pragma Assert (not Nativescript_Initialized, "Cannot intialize Nativescript twice"); Nativescript_Ptr := p_handle; Nativescript_Initialized := True; end; end;
-- WORDS, a Latin dictionary, by Colonel William Whitaker (USAF, Retired) -- -- Copyright William A. Whitaker (1936–2010) -- -- This is a free program, which means it is proper to copy it and pass -- it on to your friends. Consider it a developmental item for which -- there is no charge. However, just for form, it is Copyrighted -- (c). Permission is hereby freely given for any and all use of program -- and data. You can sell it as your own, but at least tell me. -- -- This version is distributed without obligation, but the developer -- would appreciate comments and suggestions. -- -- All parts of the WORDS system, source code and data files, are made freely -- available to anyone who wishes to use them, for whatever purpose. with Latin_Utils.Inflections_Package; use Latin_Utils.Inflections_Package; procedure Weed (W : in out String; Pofs : in Part_Of_Speech_Type) is -- In contrast to the Latin phase where the prioritization takes -- is at runtime for the English most of the work is done beforehand -- both the setting of a priority class for each entry in the scan -- of DICTLINE and the WEEDing/TRIMming done herein -- There may not be much reason to WEED -- If there are a hundred "the", does it matter. No one should Input "the" -- But it is a matter of logic and secondary effects (special on "the") Kill : Boolean := False; begin -- Conjunctions if (Pofs /= Conj) and then (W = "and" or W = "or" or W = "but" or W = "if") then Kill := True; end if; -- Prepositions if (Pofs /= Prep) and then (W = "of" or W = "to" or W = "in" or W = "into" or W = "with" or W = "w" or W = "without" or W = "for" or W = "per" or W = "on" or W = "upon" or W = "by" or W = "from" or W = "between" or W = "at" or W = "towards" or W = "under" or W = "before" or W = "against" or W = "around" or W = "through" or W = "after" or W = "like" or W = "similar" or W = "than" or W = "as") then Kill := True; end if; if (Pofs /= N) and then (-- General nouns W = "person" or W = "man" or W = "men" or W = "woman" or W = "member" or W = "species" or W = "instrument" or W = "word" or W = "words" or --W = "shape" or W = "parts" or W = "title" or W = "office" or W = "thing" or W = "day" or W = "land" or W = "plant" or W = "plants" or W = "tree" or W = "fish" or W = "stone" or W = "stones" or W = "gem" or W = "vessel" or W = "pieces" or W = "animal" or W = "bird" or W = "measure" or W = "inhabitant" or W = "place" or W = "tribe" or W = "group" or W = "official" or W = "thing" or W = "things" or W = "something" or --W = "matter" or W = "law") then Kill := True; end if; if W = "something" or W = "quality" or W = "heap" or W = "amount" or W = "money" or W = "part" or W = "front" or W = "preparation" or W = "purpose" or W = "bit" or W = "way" or W = "maker" or W = "material" or W = "action" or W = "act" or W = "form" or W = "point" or W = "right" or W = "order" or W = "area" or W = "rest" or W = "cover" or -- Common nouns W = "Rome" or W = "rome" or W = "praenomen" or W = "gens" or W = "offering" or W = "note" or W = "water" or W = "ear" or W = "end" or W = "ritual" or W = "rite" or W = "hair" or W = "time" or W = "charactistic" or W = "building" or W = "sea" or W = "ship" then Kill := True; end if; if (Pofs /= Adj) and then (--Adjectives W = "some" or W = "several" or W = "another" or W = "male" or W = "legal" or W = "female" or W = "official" or W = "no" or W = "wild" or W = "dark" or W = "sacred" or W = "Roman" or W = "roman" or W = "precious" or W = "short" or W = "long" or W = "low" or W = "young" or W = "old" or W = "large" or W = "light" or W = "round" or W = "high" or W = "near" or W = "little" or W = "small") then Kill := True; end if; if (Pofs /= Adj) and then (--More Adjectives W = "more" or W = "military" or W = "many" or W = "suitable" or W = "hot" or W = "used" or W = "joint" or W = "proper" or W = "great" or -- great-great uncle W = "full" or W = "sexual" or W = "public" or W = "white" or W = "secret" or W = "hard" or W = "good" or W = "fine" or W = "common" ) then Kill := True; end if; if (Pofs /= Adv) and then ( W = "up" or W = "out" or --W = "away" or W = "over" or W = "down" or W = "back" or W = "forth" or W = "foward" or W = "about" or W = "together" or W = "off" or --Adverbs (pure) W = "much" or W = "throughly" or W = "closly" or W = "well" or W = "very" or W = "not" or W = "too" or W = "also" or W = "when" or W = "where" or W = "then" or W = "there" or W = "so") then Kill := True; end if; if (Pofs /= Pron) and then (Pofs /= Pack) and then ( -- Pronouns and indefinites W = "one" or W = "ones" or W = "he" or W = "any" or W = "anyone" or W = "anything" or W = "each" or W = "every" or W = "other" or W = "you" or W = "who" or W = "whatever" or W = "oneself" or W = "self" or W = "all" or W = "it" or W = "this" or W = "she" or W = "such" or W = "what" or W = "which" or W = "that" or W = "same") then Kill := True; end if; if W = "kind" or W = "manner" or W = "variety" or -- Posessives W = "its" or W = "own" or W = "his" or W = "ones" or W = "one's" or W = "pertaining" or W = "belonging" or W = "containing" or W = "consisting" or W = "relating" or W = "resembling" or W = "abounding" or W = "concerned" or W = "producing" or W = "connected" or W = "made" or W = "used" or W = "having" then Kill := True; end if; if (Pofs /= V) and then (-- Verbs W = "take" or W = "make" or W = "go" or -- !! W = "bring" or W = "cut" or W = "Put" or W = "set" or W = "grow" or W = "give" or W = "cause" or W = "turn" or W = "fall" or W = "hold" or W = "keep" or W = "construct" or W = "throw" or W = "lay" or W = "remove" or W = "produce" or W = "use" or W = "order" or W = "provide" or W = "being" or W = "making" or W = "lacking") then Kill := True; end if; if -- Compounding verbs W = "have" or W = "has" or W = "had" or W = "was" or W = "be" or W = "become" or W = "can" or W = "do" or W = "may" or W = "must" or W = "let" or -- Supporting verbs W = "is" or W = "been" or --W = "attempt" or W = "begin" --or then Kill := True; end if; if Kill then for I in W'Range loop W (I) := '\'; end loop; end if; end Weed;
----------------------------------------------------------------------- -- html -- ASF HTML Components -- Copyright (C) 2009, 2010, 2011, 2012 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Exceptions; with EL.Objects; with ASF.Components.Core; with ASF.Utils; package body ASF.Components.Html.Text is use EL.Objects; TEXT_ATTRIBUTE_NAMES : Util.Strings.String_Set.Set; LABEL_ATTRIBUTE_NAMES : Util.Strings.String_Set.Set; -- ------------------------------ -- Get the local value of the component without evaluating -- the associated Value_Expression. -- ------------------------------ overriding function Get_Local_Value (UI : in UIOutput) return EL.Objects.Object is begin return UI.Value; end Get_Local_Value; -- ------------------------------ -- Get the value to write on the output. -- ------------------------------ overriding function Get_Value (UI : in UIOutput) return EL.Objects.Object is begin if not EL.Objects.Is_Null (UI.Value) then return UI.Value; else return UI.Get_Attribute (UI.Get_Context.all, "value"); end if; end Get_Value; -- ------------------------------ -- Set the value to write on the output. -- ------------------------------ overriding procedure Set_Value (UI : in out UIOutput; Value : in EL.Objects.Object) is begin UI.Value := Value; end Set_Value; -- ------------------------------ -- Get the converter that is registered on the component. -- ------------------------------ overriding function Get_Converter (UI : in UIOutput) return ASF.Converters.Converter_Access is begin return UI.Converter; end Get_Converter; -- ------------------------------ -- Set the converter to be used on the component. -- ------------------------------ overriding procedure Set_Converter (UI : in out UIOutput; Converter : in ASF.Converters.Converter_Access) is use type ASF.Converters.Converter_Access; begin if Converter = null then UI.Converter := null; else UI.Converter := Converter.all'Unchecked_Access; end if; end Set_Converter; -- ------------------------------ -- Get the value of the component and apply the converter on it if there is one. -- ------------------------------ function Get_Formatted_Value (UI : in UIOutput; Context : in Faces_Context'Class) return String is Value : constant EL.Objects.Object := UIOutput'Class (UI).Get_Value; begin return UIOutput'Class (UI).Get_Formatted_Value (Value, Context); end Get_Formatted_Value; -- ------------------------------ -- Format the value by appling the To_String converter on it if there is one. -- ------------------------------ function Get_Formatted_Value (UI : in UIOutput; Value : in Util.Beans.Objects.Object; Context : in Contexts.Faces.Faces_Context'Class) return String is use type ASF.Converters.Converter_Access; begin if UI.Converter /= null then return UI.Converter.To_String (Context => Context, Component => UI, Value => Value); else declare Converter : constant access ASF.Converters.Converter'Class := UI.Get_Converter (Context); begin if Converter /= null then return Converter.To_String (Context => Context, Component => UI, Value => Value); elsif not Is_Null (Value) then return EL.Objects.To_String (Value); else return ""; end if; end; end if; -- If the converter raises an exception, report an error in the logs. -- At this stage, we know the value and we can report it in this log message. -- We must queue the exception in the context, so this is done later. exception when E : others => UI.Log_Error ("Error when converting value '{0}': {1}: {2}", Util.Beans.Objects.To_String (Value), Ada.Exceptions.Exception_Name (E), Ada.Exceptions.Exception_Message (E)); raise; end Get_Formatted_Value; procedure Write_Output (UI : in UIOutput; Context : in out Faces_Context'Class; Value : in String) is Writer : constant Response_Writer_Access := Context.Get_Response_Writer; Escape : constant Object := UI.Get_Attribute (Context, "escape"); begin Writer.Start_Optional_Element ("span"); UI.Render_Attributes (Context, TEXT_ATTRIBUTE_NAMES, Writer); if Is_Null (Escape) or To_Boolean (Escape) then Writer.Write_Text (Value); else Writer.Write_Raw (Value); end if; Writer.End_Optional_Element ("span"); end Write_Output; procedure Encode_Begin (UI : in UIOutput; Context : in out Faces_Context'Class) is begin if UI.Is_Rendered (Context) then UI.Write_Output (Context => Context, Value => UIOutput'Class (UI).Get_Formatted_Value (Context)); end if; -- Queue any block converter exception that could be raised. exception when E : others => Context.Queue_Exception (E); end Encode_Begin; -- ------------------------------ -- Label Component -- ------------------------------ procedure Encode_Begin (UI : in UIOutputLabel; Context : in out Faces_Context'Class) is Writer : Response_Writer_Access; begin if UI.Is_Rendered (Context) then Writer := Context.Get_Response_Writer; Writer.Start_Element ("label"); UI.Render_Attributes (Context, LABEL_ATTRIBUTE_NAMES, Writer); declare Value : Util.Beans.Objects.Object := UI.Get_Attribute (Name => "for", Context => Context); begin if not Util.Beans.Objects.Is_Null (Value) then Writer.Write_Attribute ("for", Value); end if; Value := UIOutputLabel'Class (UI).Get_Value; if not Util.Beans.Objects.Is_Null (Value) then declare S : constant String := UIOutputLabel'Class (UI).Get_Formatted_Value (Value, Context); begin if UI.Get_Attribute (Name => "escape", Context => Context, Default => True) then Writer.Write_Text (S); else Writer.Write_Raw (S); end if; end; end if; -- Queue and block any converter exception that could be raised. exception when E : others => Context.Queue_Exception (E); end; end if; end Encode_Begin; procedure Encode_End (UI : in UIOutputLabel; Context : in out Faces_Context'Class) is Writer : Response_Writer_Access; begin if UI.Is_Rendered (Context) then Writer := Context.Get_Response_Writer; Writer.End_Element ("label"); end if; end Encode_End; -- ------------------------------ -- OutputFormat Component -- ------------------------------ procedure Encode_Begin (UI : in UIOutputFormat; Context : in out Faces_Context'Class) is use ASF.Components.Core; use ASF.Utils; begin if not UI.Is_Rendered (Context) then return; end if; declare Params : constant UIParameter_Access_Array := Get_Parameters (UI); Values : Object_Array (Params'Range); Result : Ada.Strings.Unbounded.Unbounded_String; Fmt : constant String := EL.Objects.To_String (UI.Get_Value); begin -- Get the values associated with the parameters. for I in Params'Range loop Values (I) := Params (I).Get_Value (Context); end loop; Formats.Format (Fmt, Values, Result); UI.Write_Output (Context => Context, Value => To_String (Result)); end; end Encode_Begin; begin Utils.Set_Text_Attributes (TEXT_ATTRIBUTE_NAMES); Utils.Set_Text_Attributes (LABEL_ATTRIBUTE_NAMES); Utils.Set_Interactive_Attributes (LABEL_ATTRIBUTE_NAMES); end ASF.Components.Html.Text;
----------------------------------------------------------------------- -- are-generator-go -- Generator for Go -- Copyright (C) 2021 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Text_IO; with Ada.Calendar.Conversions; with Interfaces.C; with Util.Log.Loggers; with Util.Strings.Transforms; package body Are.Generator.Go is use Ada.Text_IO; use Ada.Strings.Unbounded; function To_File_Name (Name : in String) return String; Log : constant Util.Log.Loggers.Logger := Util.Log.Loggers.Create ("Are.Generator.Go"); -- ------------------------------ -- Generate the Go code for the resources that have been collected. -- ------------------------------ overriding procedure Generate (Generator : in out Generator_Type; Resources : in Resource_List; Context : in out Are.Context_Type'Class) is Resource : Resource_Access := Resources.Head; begin while Resource /= null loop if Context.Name_Index then Resource.Collect_Names (Context.Ignore_Case, Generator.Names); end if; Generator.Generate_Source (Resource.all, Context); Generator.Names.Clear; Resource := Resource.Next; end loop; end Generate; -- ------------------------------ -- Given a package name, return the file name that correspond. -- ------------------------------ function To_File_Name (Name : in String) return String is Result : String (Name'Range); begin for J in Name'Range loop if Name (J) in 'A' .. 'Z' then Result (J) := Character'Val (Character'Pos (Name (J)) - Character'Pos ('A') + Character'Pos ('a')); elsif Name (J) = '.' then Result (J) := '-'; else Result (J) := Name (J); end if; end loop; return Result; end To_File_Name; -- ------------------------------ -- Generate the package body. -- ------------------------------ procedure Generate_Source (Generator : in out Generator_Type; Resource : in Are.Resource_Type; Context : in out Are.Context_Type'Class) is use Util.Strings.Transforms; procedure Generate_Keyword_Table (Into : in out Ada.Text_IO.File_Type; Names : in Util.Strings.Vectors.Vector); procedure Write_Content (Into : in out Ada.Text_IO.File_Type; Content : in Are.Stream_Element_Access); Name : constant String := To_String (Resource.Name); Basename : constant String := To_File_Name (Name); Filename : constant String := Basename & ".go"; Path : constant String := Context.Get_Output_Path (Basename); Def_Func : constant String := "Get_content"; Type_Name : constant String := Resource.Get_Type_Name (Context, "content"); Func_Name : constant String := Resource.Get_Function_Name (Context, Def_Func); Count : constant Natural := Natural (Resource.Files.Length); File : Ada.Text_IO.File_Type; function List_Names return String is (if Context.List_Content then "Names" else "names"); -- ------------------------------ -- Generate the keyword table. -- ------------------------------ procedure Generate_Keyword_Table (Into : in out Ada.Text_IO.File_Type; Names : in Util.Strings.Vectors.Vector) is Index : Integer := 0; begin New_Line (Into); Put (Into, "var "); Put (Into, List_Names); Put_Line (Into, "= []string {"); for Name of Names loop Put (Into, " """); Put (Into, Name); Put_Line (Into, ""","); Index := Index + 1; end loop; New_Line (Into); Put_Line (Into, "}"); New_Line (Into); end Generate_Keyword_Table; procedure Write_Content (Into : in out Ada.Text_IO.File_Type; Content : in Are.Stream_Element_Access) is use type Ada.Streams.Stream_Element; Conversion : constant String (1 .. 16) := "0123456789abcdef"; Col : Natural := 0; Ch : Character; begin for C of Content.all loop if Col > 50 then Put_Line (Into, """ +"); Put (Into, """"); Col := 0; end if; Ch := Character'Val (C); case Ch is when 'a' .. 'z' | 'A' .. 'Z' | ' ' | '0' .. '9' | '!' | '#' | '$' | '%' | '&' | '(' | ')' | ''' | '*' | '+' | ',' | '-' | '.' | '/' | ':' | ';' | '<' | '=' | '>' | '?' | '@' | '[' | ']' | '^' | '_' | '{' | '|' | '}' | '~' => Put (Into, Ch); when ASCII.LF => Put (Into, "\n"); when others => Put (Into, "\x"); Put (Into, Conversion (1 + Natural (C / 16))); Put (Into, Conversion (1 + Natural (C mod 16))); end case; Col := Col + 1; end loop; end Write_Content; begin Log.Info ("Writing resource {0} in {1}", Name, Path); if not Ada.Directories.Exists (Path) then Ada.Directories.Create_Path (Path); end if; Ada.Text_IO.Create (File => File, Mode => Ada.Text_IO.Out_File, Name => Ada.Directories.Compose (Path, Filename)); Put (File, "// "); Put_Line (File, Get_Title); Put (File, "package "); Put_Line (File, Name); New_Line (File); if Context.Name_Index then Put_Line (File, "import ("); Put_Line (File, " ""strings"""); if Count > 1 then Put_Line (File, " ""sort"""); end if; Put_Line (File, ")"); end if; New_Line (File); Put (File, "type "); Put (File, Capitalize (Type_Name)); Put_Line (File, " struct {"); Put (File, " "); Put (File, Capitalize (Resource.Get_Member_Content_Name (Context, "content"))); Put_Line (File, " []byte"); Put (File, " "); Put (File, Capitalize (Resource.Get_Member_Length_Name (Context, "size"))); Put_Line (File, " int64"); Put (File, " "); Put (File, Capitalize (Resource.Get_Member_Modtime_Name (Context, "modtime"))); Put_Line (File, " int64"); Put (File, " "); Put (File, Capitalize (Resource.Get_Member_Format_Name (Context, "format"))); Put_Line (File, " int"); Put_Line (File, "}"); New_Line (File); -- Generate_Resource_Contents (Resource, File, Context.Declare_Var); if Context.Name_Index then Generate_Keyword_Table (File, Generator.Names); end if; if Count >= 1 then Log.Debug ("Writing struct {0} contents[] with {1} entries", Type_Name, Util.Strings.Image (Count)); New_Line (File); Put (File, "var contents = []"); Put (File, Capitalize (Type_Name)); Put_Line (File, " {"); for Content in Resource.Files.Iterate loop Put (File, " { []byte("""); declare use Ada.Calendar.Conversions; Data : constant File_Info := File_Maps.Element (Content); begin Write_Content (File, Data.Content); Put_Line (File, """),"); Put (File, " "); Put (File, Ada.Directories.File_Size'Image (Data.Length)); Put (File, ", "); Put (File, Interfaces.C.long'Image (To_Unix_Time (Data.Modtime))); end; Put_Line (File, ", 0,"); Put_Line (File, " }, "); end loop; Put_Line (File, "}"); New_Line (File); end if; if Context.Name_Index then Log.Debug ("Writing {0} implementation", Func_Name); Put_Line (File, "// Returns the data stream with the given name or null."); Put (File, "func "); Put (File, Func_Name); Put (File, "(name string) (*Content) {"); New_Line (File); if Count > 1 then Put (File, " i := sort.Search("); Put (File, Util.Strings.Image (Count)); Put_Line (File, ", func(i int) bool {"); Put (File, " return strings.Compare("); Put (File, List_Names); Put_Line (File, "[i], name) >= 0"); Put_Line (File, " })"); Put (File, " if i < "); Put (File, Util.Strings.Image (Count)); Put (File, " && strings.Compare("); Put (File, List_Names); Put_Line (File, "[i], name) == 0 {"); Put (File, " return "); Put_Line (File, "&contents[i]"); Put_Line (File, " }"); Put_Line (File, " return nil"); else Put (File, " r := strings.Compare("); Put (File, List_Names); Put_Line (File, "[0], name)"); Put_Line (File, " if r == 0 {"); Put_Line (File, " return &contents[0]"); Put_Line (File, " }"); Put_Line (File, " return nil"); end if; Put_Line (File, "}"); New_Line (File); end if; Close (File); end Generate_Source; end Are.Generator.Go;
-- Copyright 2016,2017 Steven Stewart-Gallus -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or -- implied. See the License for the specific language governing -- permissions and limitations under the License. with Linted.Errors; with Linted.KOs; with Linted.Update; with Linted.Triggers; package Linted.Update_Reader is pragma Elaborate_Body; type Event is record Data : Update.Packet; Err : Errors.Error := 0; end record; type Future is limited private with Preelaborable_Initialization; function Is_Live (F : Future) return Boolean; procedure Read (Object : KOs.KO; Signaller : Triggers.Signaller; F : out Future) with Post => Is_Live (F); procedure Read_Wait (F : in out Future; E : out Event) with Pre => Is_Live (F), Post => not Is_Live (F); procedure Read_Poll (F : in out Future; E : out Event; Init : out Boolean) with Pre => Is_Live (F), Post => (if Init then not Is_Live (F) else Is_Live (F)); private Max_Nodes : constant := 2; type Future is range 0 .. Max_Nodes + 1 with Default_Value => 0; end Linted.Update_Reader;
-- Tiny Text -- Copyright 2020 Jeremy Grosser -- See LICENSE for details with Interfaces; use Interfaces; package body Tiny_Text is procedure Initialize (This : in out Text_Buffer; Bitmap : Any_Bitmap_Buffer; Width : Natural; Height : Natural) is begin This.Width := Width; This.Height := Height; This.Bitmap := Bitmap; This.Default_Cursor := (This.Width - Font_Width - 1, 0); This.Clear; end Initialize; procedure Clear (This : in out Text_Buffer) is begin This.Bitmap.Set_Source (White); This.Bitmap.Fill; This.Cursor := This.Default_Cursor; This.Bitmap.Set_Source (Black); end Clear; procedure New_Line (This : in out Text_Buffer) is begin This.Cursor.X := This.Width - Font_Width - 1; This.Cursor.Y := This.Cursor.Y + Font_Height + 1; if This.Cursor.Y >= This.Height then This.Cursor.Y := 0; This.Clear; end if; end New_Line; procedure Advance (This : in out Text_Buffer) is begin This.Cursor.X := This.Cursor.X - Font_Width - 1; if This.Cursor.X = 0 then This.New_Line; end if; end Advance; procedure Put (This : in out Text_Buffer; Location : Point; Char : Character; Foreground : Bitmap_Color; Background : Bitmap_Color) is P : Point; FC : constant Unsigned_32 := Unsigned_32 (Font_Data (Char)); Pixel : Unsigned_32; begin for X in 0 .. (Font_Width - 1) loop for Y in 0 .. (Font_Height - 1) loop P.X := Location.X + X; P.Y := Location.Y + Y; Pixel := Shift_Right (FC, (Font_Width * Font_Height) - (Y * 3) + X) and 1; if Pixel = 1 then This.Bitmap.Set_Pixel (P, Foreground); else This.Bitmap.Set_Pixel (P, Background); end if; end loop; end loop; end Put; procedure Put (This : in out Text_Buffer; Char : Character) is begin if Char = ASCII.LF then This.New_Line; else This.Put (This.Cursor, Char, Black, White); This.Advance; end if; end Put; procedure Put (This : in out Text_Buffer; Str : String) is begin for Char of Str loop This.Put (Char); end loop; end Put; procedure Put_Line (This : in out Text_Buffer; Str : String) is begin This.Put (Str); This.Put (ASCII.LF); end Put_Line; end Tiny_Text;
-- Copyright (c) 2019 Maxim Reznik <reznikmm@gmail.com> -- -- SPDX-License-Identifier: MIT -- License-Filename: LICENSE ------------------------------------------------------------- with Slim.Message_Visiters; with Slim.Messages.BUTN; with Slim.Messages.SETD; with Slim.Messages.STAT; package Slim.Players.Idle_State_Visiters is type Visiter (Player : not null access Players.Player) is new Slim.Message_Visiters.Visiter with null record; overriding procedure BUTN (Self : in out Visiter; Message : not null access Slim.Messages.BUTN.BUTN_Message); overriding procedure SETD (Self : in out Visiter; Message : not null access Slim.Messages.SETD.SETD_Message); overriding procedure STAT (Self : in out Visiter; Message : not null access Slim.Messages.STAT.STAT_Message); end Slim.Players.Idle_State_Visiters;
with float_Math, ada.Strings.unbounded; package Collada -- -- Provides a namespace and core types for the Collada package family. -- is ------- -- Text -- subtype Text is ada.Strings.unbounded.unbounded_String; function to_Text (From : in String) return Text renames ada.Strings.unbounded.To_unbounded_String; function to_String (From : in Text) return String renames ada.Strings.unbounded.To_String; type Text_array is array (Positive range <>) of Text; ------- -- Math -- -- Collada matrices use column vectors, so the translation vector is the 4th column. package Math renames float_Math; subtype Float_array is math.Vector; subtype Int_array is math.Integers; subtype Vector_3 is math.Vector_3; subtype Vector_4 is math.Vector_4; subtype Matrix_3x3 is math.Matrix_3x3; subtype Matrix_4x4 is math.Matrix_4x4; type Matrix_4x4_array is array (Positive range <>) of Matrix_4x4; Identity_4x4 : constant math.Matrix_4x4; function matrix_Count (From : in Float_array) return Natural; function get_Matrix (From : in Float_array; Which : in Positive) return Matrix_4x4; Error : exception; private Identity_4x4 : constant math.Matrix_4x4 := ((1.0, 0.0, 0.0, 0.0), (0.0, 1.0, 0.0, 0.0), (0.0, 0.0, 1.0, 0.0), (0.0, 0.0, 0.0, 1.0)); end Collada;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME LIBRARY (GNARL) COMPONENTS -- -- -- -- S Y S T E M . T A S K I N G . Q U E U I N G -- -- -- -- B o d y -- -- -- -- Copyright (C) 1992-2020, Free Software Foundation, Inc. -- -- -- -- GNARL is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 3, or (at your option) any later ver- -- -- sion. 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/>. -- -- -- -- GNARL was developed by the GNARL team at Florida State University. -- -- Extensive contributions were provided by Ada Core Technologies, Inc. -- -- -- ------------------------------------------------------------------------------ -- This version of the body implements queueing policy according to the policy -- specified by the pragma Queuing_Policy. When no such pragma is specified -- FIFO policy is used as default. with System.Task_Primitives.Operations; with System.Tasking.Initialization; package body System.Tasking.Queuing is use Task_Primitives.Operations; use Protected_Objects; use Protected_Objects.Entries; -- Entry Queues implemented as doubly linked list Queuing_Policy : Character; pragma Import (C, Queuing_Policy, "__gl_queuing_policy"); Priority_Queuing : constant Boolean := Queuing_Policy = 'P'; procedure Send_Program_Error (Self_ID : Task_Id; Entry_Call : Entry_Call_Link); -- Raise Program_Error in the caller of the specified entry call function Check_Queue (E : Entry_Queue) return Boolean; -- Check the validity of E. -- Return True if E is valid, raise Assert_Failure if assertions are -- enabled and False otherwise. ----------------------------- -- Broadcast_Program_Error -- ----------------------------- procedure Broadcast_Program_Error (Self_ID : Task_Id; Object : Protection_Entries_Access; Pending_Call : Entry_Call_Link) is Entry_Call : Entry_Call_Link; begin if Pending_Call /= null then Send_Program_Error (Self_ID, Pending_Call); end if; for E in Object.Entry_Queues'Range loop Dequeue_Head (Object.Entry_Queues (E), Entry_Call); while Entry_Call /= null loop pragma Assert (Entry_Call.Mode /= Conditional_Call); Send_Program_Error (Self_ID, Entry_Call); Dequeue_Head (Object.Entry_Queues (E), Entry_Call); end loop; end loop; end Broadcast_Program_Error; ----------------- -- Check_Queue -- ----------------- function Check_Queue (E : Entry_Queue) return Boolean is Valid : Boolean := True; C, Prev : Entry_Call_Link; begin if E.Head = null then if E.Tail /= null then Valid := False; pragma Assert (Valid); end if; else if E.Tail = null or else E.Tail.Next /= E.Head then Valid := False; pragma Assert (Valid); else C := E.Head; loop Prev := C; C := C.Next; if C = null then Valid := False; pragma Assert (Valid); exit; end if; if Prev /= C.Prev then Valid := False; pragma Assert (Valid); exit; end if; exit when C = E.Head; end loop; if Prev /= E.Tail then Valid := False; pragma Assert (Valid); end if; end if; end if; return Valid; end Check_Queue; ------------------- -- Count_Waiting -- ------------------- -- Return number of calls on the waiting queue of E function Count_Waiting (E : Entry_Queue) return Natural is Count : Natural; Temp : Entry_Call_Link; begin pragma Assert (Check_Queue (E)); Count := 0; if E.Head /= null then Temp := E.Head; loop Count := Count + 1; exit when E.Tail = Temp; Temp := Temp.Next; end loop; end if; return Count; end Count_Waiting; ------------- -- Dequeue -- ------------- -- Dequeue call from entry_queue E procedure Dequeue (E : in out Entry_Queue; Call : Entry_Call_Link) is begin pragma Assert (Check_Queue (E)); pragma Assert (Call /= null); -- If empty queue, simply return if E.Head = null then return; end if; pragma Assert (Call.Prev /= null); pragma Assert (Call.Next /= null); Call.Prev.Next := Call.Next; Call.Next.Prev := Call.Prev; if E.Head = Call then -- Case of one element if E.Tail = Call then E.Head := null; E.Tail := null; -- More than one element else E.Head := Call.Next; end if; elsif E.Tail = Call then E.Tail := Call.Prev; end if; -- Successfully dequeued Call.Prev := null; Call.Next := null; pragma Assert (Check_Queue (E)); end Dequeue; ------------------ -- Dequeue_Call -- ------------------ procedure Dequeue_Call (Entry_Call : Entry_Call_Link) is Called_PO : Protection_Entries_Access; begin pragma Assert (Entry_Call /= null); if Entry_Call.Called_Task /= null then Dequeue (Entry_Call.Called_Task.Entry_Queues (Task_Entry_Index (Entry_Call.E)), Entry_Call); else Called_PO := To_Protection (Entry_Call.Called_PO); Dequeue (Called_PO.Entry_Queues (Protected_Entry_Index (Entry_Call.E)), Entry_Call); end if; end Dequeue_Call; ------------------ -- Dequeue_Head -- ------------------ -- Remove and return the head of entry_queue E procedure Dequeue_Head (E : in out Entry_Queue; Call : out Entry_Call_Link) is Temp : Entry_Call_Link; begin pragma Assert (Check_Queue (E)); -- If empty queue, return null pointer if E.Head = null then Call := null; return; end if; Temp := E.Head; -- Case of one element if E.Head = E.Tail then E.Head := null; E.Tail := null; -- More than one element else pragma Assert (Temp /= null); pragma Assert (Temp.Next /= null); pragma Assert (Temp.Prev /= null); E.Head := Temp.Next; Temp.Prev.Next := Temp.Next; Temp.Next.Prev := Temp.Prev; end if; -- Successfully dequeued Temp.Prev := null; Temp.Next := null; Call := Temp; pragma Assert (Check_Queue (E)); end Dequeue_Head; ------------- -- Enqueue -- ------------- -- Enqueue call at the end of entry_queue E, for FIFO queuing policy. -- Enqueue call priority ordered, FIFO at same priority level, for -- Priority queuing policy. procedure Enqueue (E : in out Entry_Queue; Call : Entry_Call_Link) is Temp : Entry_Call_Link := E.Head; begin pragma Assert (Check_Queue (E)); pragma Assert (Call /= null); -- Priority Queuing if Priority_Queuing then if Temp = null then Call.Prev := Call; Call.Next := Call; E.Head := Call; E.Tail := Call; else loop -- Find the entry that the new guy should precede exit when Call.Prio > Temp.Prio; Temp := Temp.Next; if Temp = E.Head then Temp := null; exit; end if; end loop; if Temp = null then -- Insert at tail Call.Prev := E.Tail; Call.Next := E.Head; E.Tail := Call; else Call.Prev := Temp.Prev; Call.Next := Temp; -- Insert at head if Temp = E.Head then E.Head := Call; end if; end if; pragma Assert (Call.Prev /= null); pragma Assert (Call.Next /= null); Call.Prev.Next := Call; Call.Next.Prev := Call; end if; pragma Assert (Check_Queue (E)); return; end if; -- FIFO Queuing if E.Head = null then E.Head := Call; else E.Tail.Next := Call; Call.Prev := E.Tail; end if; E.Head.Prev := Call; E.Tail := Call; Call.Next := E.Head; pragma Assert (Check_Queue (E)); end Enqueue; ------------------ -- Enqueue_Call -- ------------------ procedure Enqueue_Call (Entry_Call : Entry_Call_Link) is Called_PO : Protection_Entries_Access; begin pragma Assert (Entry_Call /= null); if Entry_Call.Called_Task /= null then Enqueue (Entry_Call.Called_Task.Entry_Queues (Task_Entry_Index (Entry_Call.E)), Entry_Call); else Called_PO := To_Protection (Entry_Call.Called_PO); Enqueue (Called_PO.Entry_Queues (Protected_Entry_Index (Entry_Call.E)), Entry_Call); end if; end Enqueue_Call; ---------- -- Head -- ---------- -- Return the head of entry_queue E function Head (E : Entry_Queue) return Entry_Call_Link is begin pragma Assert (Check_Queue (E)); return E.Head; end Head; ------------- -- Onqueue -- ------------- -- Return True if Call is on any entry_queue at all function Onqueue (Call : Entry_Call_Link) return Boolean is begin pragma Assert (Call /= null); -- Utilize the fact that every queue is circular, so if Call -- is on any queue at all, Call.Next must NOT be null. return Call.Next /= null; end Onqueue; -------------------------------- -- Requeue_Call_With_New_Prio -- -------------------------------- procedure Requeue_Call_With_New_Prio (Entry_Call : Entry_Call_Link; Prio : System.Any_Priority) is begin pragma Assert (Entry_Call /= null); -- Perform a queue reordering only when the policy being used is the -- Priority Queuing. if Priority_Queuing then if Onqueue (Entry_Call) then Dequeue_Call (Entry_Call); Entry_Call.Prio := Prio; Enqueue_Call (Entry_Call); end if; end if; end Requeue_Call_With_New_Prio; --------------------------------- -- Select_Protected_Entry_Call -- --------------------------------- -- Select an entry of a protected object. Selection depends on the -- queuing policy being used. procedure Select_Protected_Entry_Call (Self_ID : Task_Id; Object : Protection_Entries_Access; Call : out Entry_Call_Link) is Entry_Call : Entry_Call_Link; Temp_Call : Entry_Call_Link; Entry_Index : Protected_Entry_Index := Null_Entry; -- stop warning begin Entry_Call := null; begin -- Priority queuing case if Priority_Queuing then for J in Object.Entry_Queues'Range loop Temp_Call := Head (Object.Entry_Queues (J)); if Temp_Call /= null and then Object.Entry_Bodies (Object.Find_Body_Index (Object.Compiler_Info, J)). Barrier (Object.Compiler_Info, J) then if Entry_Call = null or else Entry_Call.Prio < Temp_Call.Prio then Entry_Call := Temp_Call; Entry_Index := J; end if; end if; end loop; -- FIFO queueing case else for J in Object.Entry_Queues'Range loop Temp_Call := Head (Object.Entry_Queues (J)); if Temp_Call /= null and then Object.Entry_Bodies (Object.Find_Body_Index (Object.Compiler_Info, J)). Barrier (Object.Compiler_Info, J) then Entry_Call := Temp_Call; Entry_Index := J; exit; end if; end loop; end if; exception when others => Broadcast_Program_Error (Self_ID, Object, null); end; -- If a call was selected, dequeue it and return it for service if Entry_Call /= null then Temp_Call := Entry_Call; Dequeue_Head (Object.Entry_Queues (Entry_Index), Entry_Call); pragma Assert (Temp_Call = Entry_Call); end if; Call := Entry_Call; end Select_Protected_Entry_Call; ---------------------------- -- Select_Task_Entry_Call -- ---------------------------- -- Select an entry for rendezvous. Selection depends on the queuing policy -- being used. procedure Select_Task_Entry_Call (Acceptor : Task_Id; Open_Accepts : Accept_List_Access; Call : out Entry_Call_Link; Selection : out Select_Index; Open_Alternative : out Boolean) is Entry_Call : Entry_Call_Link; Temp_Call : Entry_Call_Link; Entry_Index : Task_Entry_Index := Task_Entry_Index'First; Temp_Entry : Task_Entry_Index; begin Open_Alternative := False; Entry_Call := null; Selection := No_Rendezvous; if Priority_Queuing then -- Priority queueing case for J in Open_Accepts'Range loop Temp_Entry := Open_Accepts (J).S; if Temp_Entry /= Null_Task_Entry then Open_Alternative := True; Temp_Call := Head (Acceptor.Entry_Queues (Temp_Entry)); if Temp_Call /= null and then (Entry_Call = null or else Entry_Call.Prio < Temp_Call.Prio) then Entry_Call := Head (Acceptor.Entry_Queues (Temp_Entry)); Entry_Index := Temp_Entry; Selection := J; end if; end if; end loop; else -- FIFO Queuing case for J in Open_Accepts'Range loop Temp_Entry := Open_Accepts (J).S; if Temp_Entry /= Null_Task_Entry then Open_Alternative := True; Temp_Call := Head (Acceptor.Entry_Queues (Temp_Entry)); if Temp_Call /= null then Entry_Call := Head (Acceptor.Entry_Queues (Temp_Entry)); Entry_Index := Temp_Entry; Selection := J; exit; end if; end if; end loop; end if; if Entry_Call /= null then Dequeue_Head (Acceptor.Entry_Queues (Entry_Index), Entry_Call); -- Guard is open end if; Call := Entry_Call; end Select_Task_Entry_Call; ------------------------ -- Send_Program_Error -- ------------------------ procedure Send_Program_Error (Self_ID : Task_Id; Entry_Call : Entry_Call_Link) is Caller : Task_Id; begin Caller := Entry_Call.Self; Entry_Call.Exception_To_Raise := Program_Error'Identity; Write_Lock (Caller); Initialization.Wakeup_Entry_Caller (Self_ID, Entry_Call, Done); Unlock (Caller); end Send_Program_Error; end System.Tasking.Queuing;
with Ada.Text_IO, Ada.Strings.Fixed, Ada.Containers.Indefinite_Vectors; use Ada.Text_IO, Ada.Strings.Fixed, Ada.Containers; procedure tokenize is package String_Vector is new Indefinite_Vectors (Natural,String); use String_Vector; procedure Parse (s : String; v : in out Vector) is i : Integer := Index (s,","); begin if s'Length > 0 then if i < s'First then v.Append (s); else v.Append (s (s'First..i-1)); Parse ( s(i+1..s'Last), v); end if; end if; end Parse; v : Vector; begin Parse ("Hello,How,Are,You,Today,,",v); for s of v loop put(s&"."); end loop; end tokenize;
pragma Ada_2012; package body Finite_State_Scanners is ---------------- -- Add_Branch -- ---------------- procedure Add_Branch (Table : in out Automata_Table; From : State_Type; On : Ada.Strings.Maps.Character_Set; To : State_Type) is use Ada.Strings.Maps; Set : constant Character_Sequence := To_Sequence (On); begin for C of Set loop Table.Transitions (From, C) := (Class => To_State, Destination => To); end loop; end Add_Branch; ----------------- -- Add_Default -- ----------------- procedure Add_Default (Table : in out Automata_Table; From : State_Type; To : State_Type) is begin for C in Character loop if Table.Transitions (From, C).Class = Empty then Table.Transitions (From, C) := (Class => To_State, Destination => To); end if; end loop; end Add_Default; --------------- -- Add_Final -- --------------- procedure Add_Final (Table : in out Automata_Table; From : State_Type; On : Ada.Strings.Maps.Character_Set; Result : Token_Type) is begin for C of Ada.Strings.Maps.To_Sequence (On) loop Table.Transitions (From, C) := (Class => To_Final, Result => Result); end loop; end Add_Final; --------------- -- Add_Final -- --------------- procedure Add_Shortcut (Table : in out Automata_Table; From : State_Type; On : String; Result : Token_Type) is begin Table.Shortcuts (From).Append ((Length => On'Length, Shortcut => On, Result => Result)); end Add_Shortcut; ----------------- -- Add_Default -- ----------------- procedure Add_Default (Table : in out Automata_Table; From : State_Type; Result : Token_Type) is begin for C in Character loop if Table.Transitions (From, C).Class = Empty then Table.Transitions (From, C) := (Class => To_Final, Result => Result); end if; end loop; end Add_Default; ---------- -- Scan -- ---------- function Scan (Input : String; Automa : Automata_Table; Skip : String := " ") return Token_List is use Ada.Strings.Maps; Cursor : Positive := Input'First; Result : Token_List; Current_State : State_Type; Image_First : Positive; Spaces : constant Character_Set := To_Set (Skip); function End_Of_Input return Boolean is (Cursor > Input'Last); function Current_Char return Character is (if End_Of_Input then Character'Val (0) else Input (Cursor)); procedure Next_Char is begin if not End_Of_Input then Cursor := Cursor + 1; end if; end Next_Char; procedure Skip_Spaces is begin while Is_In (Current_Char, Spaces) loop Next_Char; end loop; end Skip_Spaces; procedure Start_New_Token is begin Current_State := Start_State; Skip_Spaces; Image_First := Cursor; end Start_New_Token; procedure Append_Token (To : in out Token_List; Token : Token_Type) is Image : constant String := Input (Image_First .. Cursor - 1); begin To.L.Append (Token_Descriptor'(Length => Image'Length, Token => Token, Image => Image)); end Append_Token; begin Start_New_Token; while not End_Of_Input loop case Automa.Transitions (Current_State, Current_Char).Class is when Empty => for Shortcut of Automa.Shortcuts (Current_State) loop raise Program_Error with "Shortcuts not implemented yet"; pragma Compile_Time_Warning (True, "Shortcuts not implemented"); end loop; raise Constraint_Error; when To_State => Current_State := Automa.Transitions (Current_State, Current_Char).Destination; Next_Char; when To_Final => Append_Token (Result, Automa.Transitions (Current_State, Current_Char).Result); Next_Char; Start_New_Token; end case; end loop; return Result; end Scan; end Finite_State_Scanners;
------------------------------------------------------------------------------ -- -- -- GNAT COMPILER COMPONENTS -- -- -- -- S E M _ C A T -- -- -- -- B o d y -- -- -- -- $Revision$ -- -- -- Copyright (C) 1992-2001, Free Software Foundation, Inc. -- -- -- -- GNAT is free software; you can redistribute it and/or modify it under -- -- terms of the GNU General Public License as published by the Free Soft- -- -- ware Foundation; either version 2, or (at your option) any later ver- -- -- sion. GNAT is distributed in the hope that it will be useful, but WITH- -- -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY -- -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -- -- for more details. You should have received a copy of the GNU General -- -- Public License distributed with GNAT; see file COPYING. If not, write -- -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, -- -- MA 02111-1307, USA. -- -- -- -- GNAT was originally developed by the GNAT team at New York University. -- -- Extensive contributions were provided by Ada Core Technologies Inc. -- -- -- ------------------------------------------------------------------------------ with Atree; use Atree; with Debug; use Debug; with Einfo; use Einfo; with Elists; use Elists; with Errout; use Errout; with Exp_Tss; use Exp_Tss; with Fname; use Fname; with Lib; use Lib; with Nlists; use Nlists; with Sem; use Sem; with Sem_Util; use Sem_Util; with Sinfo; use Sinfo; with Snames; use Snames; with Stand; use Stand; package body Sem_Cat is ----------------------- -- Local Subprograms -- ----------------------- procedure Check_Categorization_Dependencies (Unit_Entity : Entity_Id; Depended_Entity : Entity_Id; Info_Node : Node_Id; Is_Subunit : Boolean); -- This procedure checks that the categorization of a lib unit and that -- of the depended unit satisfy dependency restrictions. -- The depended_entity can be the entity in a with_clause item, in which -- case Info_Node denotes that item. The depended_entity can also be the -- parent unit of a child unit, in which case Info_Node is the declaration -- of the child unit. The error message is posted on Info_Node, and is -- specialized if Is_Subunit is true. procedure Check_Non_Static_Default_Expr (Type_Def : Node_Id; Obj_Decl : Node_Id); -- Iterate through the component list of a record definition, check -- that no component is declared with a nonstatic default value. -- If a nonstatic default exists, report an error on Obj_Decl. -- Iterate through the component list of a record definition, check -- that no component is declared with a non-static default value. function Missing_Read_Write_Attributes (E : Entity_Id) return Boolean; -- Return True if the entity or one of its subcomponent is an access -- type which does not have user-defined Read and Write attribute. function In_RCI_Declaration (N : Node_Id) return Boolean; -- Determines if a declaration is within the visible part of a Remote -- Call Interface compilation unit, for semantic checking purposes only, -- (returns false within an instance and within the package body). function In_RT_Declaration return Boolean; -- Determines if current scope is within a Remote Types compilation unit, -- for semantic checking purposes. function Is_Non_Remote_Access_Type (E : Entity_Id) return Boolean; -- Returns true if the entity is a non-remote access type function In_Shared_Passive_Unit return Boolean; -- Determines if current scope is within a Shared Passive compilation unit function Static_Discriminant_Expr (L : List_Id) return Boolean; -- Iterate through the list of discriminants to check if any of them -- contains non-static default expression, which is a violation in -- a preelaborated library unit. procedure Validate_Remote_Access_Object_Type_Declaration (T : Entity_Id); -- Check validity of declaration if RCI unit. It should not contain -- the declaration of an access-to-object type unless it is a -- general access type that designates a class-wide limited -- private type. There are also constraints about the primitive -- subprograms of the class-wide type. RM E.2 (9, 13, 14) function Is_Recursively_Limited_Private (E : Entity_Id) return Boolean; -- Return True if E is a limited private type, or if E is a private -- extension of a type whose parent verifies this property (hence the -- recursive keyword). --------------------------------------- -- Check_Categorization_Dependencies -- --------------------------------------- procedure Check_Categorization_Dependencies (Unit_Entity : Entity_Id; Depended_Entity : Entity_Id; Info_Node : Node_Id; Is_Subunit : Boolean) is N : Node_Id := Info_Node; type Categorization is (Pure, Shared_Passive, Remote_Types, Remote_Call_Interface, Pre_Elaborated, Normal); Unit_Category : Categorization; With_Category : Categorization; function Get_Categorization (E : Entity_Id) return Categorization; -- Check categorization flags from entity, and return in the form -- of a corresponding enumeration value. function Get_Categorization (E : Entity_Id) return Categorization is begin if Is_Preelaborated (E) then return Pre_Elaborated; elsif Is_Pure (E) then return Pure; elsif Is_Shared_Passive (E) then return Shared_Passive; elsif Is_Remote_Types (E) then return Remote_Types; elsif Is_Remote_Call_Interface (E) then return Remote_Call_Interface; else return Normal; end if; end Get_Categorization; -- Start of processing for Check_Categorization_Dependencies begin -- Intrinsic subprograms are preelaborated, so do not impose any -- categorization dependencies. if Is_Intrinsic_Subprogram (Depended_Entity) then return; end if; Unit_Category := Get_Categorization (Unit_Entity); With_Category := Get_Categorization (Depended_Entity); if With_Category > Unit_Category then if (Unit_Category = Remote_Types or else Unit_Category = Remote_Call_Interface) and then In_Package_Body (Unit_Entity) then null; elsif Is_Subunit then Error_Msg_NE ("subunit cannot depend on&" & " (parent has wrong categorization)", N, Depended_Entity); else Error_Msg_NE ("current unit cannot depend on&" & " (wrong categorization)", N, Depended_Entity); end if; end if; end Check_Categorization_Dependencies; ----------------------------------- -- Check_Non_Static_Default_Expr -- ----------------------------------- procedure Check_Non_Static_Default_Expr (Type_Def : Node_Id; Obj_Decl : Node_Id) is Recdef : Node_Id; Component_Decl : Node_Id; begin if Nkind (Type_Def) = N_Derived_Type_Definition then Recdef := Record_Extension_Part (Type_Def); if No (Recdef) then return; end if; else Recdef := Type_Def; end if; -- Check that component declarations do not involve: -- a. a non-static default expression, where the object is -- declared to be default initialized. -- b. a dynamic Itype (discriminants and constraints) if Null_Present (Recdef) then return; else Component_Decl := First (Component_Items (Component_List (Recdef))); end if; while Present (Component_Decl) and then Nkind (Component_Decl) = N_Component_Declaration loop if Present (Expression (Component_Decl)) and then Nkind (Expression (Component_Decl)) /= N_Null and then not Is_Static_Expression (Expression (Component_Decl)) then Error_Msg_Sloc := Sloc (Component_Decl); Error_Msg_N ("object in preelaborated unit has nonstatic default#", Obj_Decl); -- Fix this later ??? -- elsif Has_Dynamic_Itype (Component_Decl) then -- Error_Msg_N -- ("dynamic type discriminant," & -- " constraint in preelaborated unit", -- Component_Decl); end if; Next (Component_Decl); end loop; end Check_Non_Static_Default_Expr; --------------------------- -- In_Preelaborated_Unit -- --------------------------- function In_Preelaborated_Unit return Boolean is Unit_Entity : constant Entity_Id := Current_Scope; Unit_Kind : constant Node_Kind := Nkind (Unit (Cunit (Current_Sem_Unit))); begin -- There are no constraints on body of remote_call_interface or -- remote_types packages.. return (Unit_Entity /= Standard_Standard) and then (Is_Preelaborated (Unit_Entity) or else Is_Pure (Unit_Entity) or else Is_Shared_Passive (Unit_Entity) or else ((Is_Remote_Types (Unit_Entity) or else Is_Remote_Call_Interface (Unit_Entity)) and then Ekind (Unit_Entity) = E_Package and then Unit_Kind /= N_Package_Body and then not In_Package_Body (Unit_Entity) and then not In_Instance)); end In_Preelaborated_Unit; ------------------ -- In_Pure_Unit -- ------------------ function In_Pure_Unit return Boolean is begin return Is_Pure (Current_Scope); end In_Pure_Unit; ------------------------ -- In_RCI_Declaration -- ------------------------ function In_RCI_Declaration (N : Node_Id) return Boolean is Unit_Entity : constant Entity_Id := Current_Scope; Unit_Kind : constant Node_Kind := Nkind (Unit (Cunit (Current_Sem_Unit))); begin -- There are no restrictions on the private part or body -- of an RCI unit. return Is_Remote_Call_Interface (Unit_Entity) and then (Ekind (Unit_Entity) = E_Package or else Ekind (Unit_Entity) = E_Generic_Package) and then Unit_Kind /= N_Package_Body and then List_Containing (N) = Visible_Declarations (Specification (Unit_Declaration_Node (Unit_Entity))) and then not In_Package_Body (Unit_Entity) and then not In_Instance; end In_RCI_Declaration; ----------------------- -- In_RT_Declaration -- ----------------------- function In_RT_Declaration return Boolean is Unit_Entity : constant Entity_Id := Current_Scope; Unit_Kind : constant Node_Kind := Nkind (Unit (Cunit (Current_Sem_Unit))); begin -- There are no restrictions on the body of a Remote Types unit. return Is_Remote_Types (Unit_Entity) and then (Ekind (Unit_Entity) = E_Package or else Ekind (Unit_Entity) = E_Generic_Package) and then Unit_Kind /= N_Package_Body and then not In_Package_Body (Unit_Entity) and then not In_Instance; end In_RT_Declaration; ---------------------------- -- In_Shared_Passive_Unit -- ---------------------------- function In_Shared_Passive_Unit return Boolean is Unit_Entity : constant Entity_Id := Current_Scope; begin return Is_Shared_Passive (Unit_Entity); end In_Shared_Passive_Unit; --------------------------------------- -- In_Subprogram_Task_Protected_Unit -- --------------------------------------- function In_Subprogram_Task_Protected_Unit return Boolean is E : Entity_Id; K : Entity_Kind; begin -- The following is to verify that a declaration is inside -- subprogram, generic subprogram, task unit, protected unit. -- Used to validate if a lib. unit is Pure. RM 10.2.1(16). -- Use scope chain to check successively outer scopes E := Current_Scope; loop K := Ekind (E); if K = E_Procedure or else K = E_Function or else K = E_Generic_Procedure or else K = E_Generic_Function or else K = E_Task_Type or else K = E_Task_Subtype or else K = E_Protected_Type or else K = E_Protected_Subtype then return True; elsif E = Standard_Standard then return False; end if; E := Scope (E); end loop; end In_Subprogram_Task_Protected_Unit; ------------------------------- -- Is_Non_Remote_Access_Type -- ------------------------------- function Is_Non_Remote_Access_Type (E : Entity_Id) return Boolean is begin return Is_Access_Type (E) and then not Is_Remote_Access_To_Class_Wide_Type (E) and then not Is_Remote_Access_To_Subprogram_Type (E); end Is_Non_Remote_Access_Type; ------------------------------------ -- Is_Recursively_Limited_Private -- ------------------------------------ function Is_Recursively_Limited_Private (E : Entity_Id) return Boolean is P : constant Node_Id := Parent (E); begin if Nkind (P) = N_Private_Type_Declaration and then Is_Limited_Record (E) then return True; elsif Nkind (P) = N_Private_Extension_Declaration then return Is_Recursively_Limited_Private (Etype (E)); elsif Nkind (P) = N_Formal_Type_Declaration and then Ekind (E) = E_Record_Type_With_Private and then Is_Generic_Type (E) and then Is_Limited_Record (E) then return True; else return False; end if; end Is_Recursively_Limited_Private; ---------------------------------- -- Missing_Read_Write_Attribute -- ---------------------------------- function Missing_Read_Write_Attributes (E : Entity_Id) return Boolean is Component : Entity_Id; Component_Type : Entity_Id; function Has_Read_Write_Attributes (E : Entity_Id) return Boolean; -- Return True if entity has Read and Write attributes ------------------------------- -- Has_Read_Write_Attributes -- ------------------------------- function Has_Read_Write_Attributes (E : Entity_Id) return Boolean is Rep_Item : Node_Id := First_Rep_Item (E); Read_Attribute : Boolean := False; Write_Attribute : Boolean := False; begin -- We start from the declaration node and then loop until the end -- of the list until we find those two attribute definition clauses. while Present (Rep_Item) loop if Chars (Rep_Item) = Name_Read then Read_Attribute := True; elsif Chars (Rep_Item) = Name_Write then Write_Attribute := True; end if; if Read_Attribute and Write_Attribute then return True; end if; Next_Rep_Item (Rep_Item); end loop; return False; end Has_Read_Write_Attributes; -- Start of processing for Missing_Read_Write_Attributes begin if Has_Read_Write_Attributes (E) then return False; elsif Is_Non_Remote_Access_Type (E) then return True; end if; if Is_Record_Type (E) then Component := First_Entity (E); while Present (Component) loop Component_Type := Etype (Component); if (Is_Non_Remote_Access_Type (Component_Type) or else Is_Record_Type (Component_Type)) and then Missing_Read_Write_Attributes (Component_Type) then return True; end if; Next_Entity (Component); end loop; end if; return False; end Missing_Read_Write_Attributes; ------------------------------------- -- Set_Categorization_From_Pragmas -- ------------------------------------- procedure Set_Categorization_From_Pragmas (N : Node_Id) is P : constant Node_Id := Parent (N); S : constant Entity_Id := Current_Scope; procedure Set_Parents (Visibility : Boolean); -- If this is a child instance, the parents are not immediately -- visible during analysis. Make them momentarily visible so that -- the argument of the pragma can be resolved properly, and reset -- afterwards. procedure Set_Parents (Visibility : Boolean) is Par : Entity_Id := Scope (S); begin while Present (Par) and then Par /= Standard_Standard loop Set_Is_Immediately_Visible (Par, Visibility); Par := Scope (Par); end loop; end Set_Parents; begin -- Deal with categorization pragmas in Pragmas of Compilation_Unit. -- The purpose is to set categorization flags before analyzing the -- unit itself, so as to diagnose violations of categorization as -- we process each declaration, even though the pragma appears after -- the unit. if Nkind (P) /= N_Compilation_Unit then return; end if; declare PN : Node_Id := First (Pragmas_After (Aux_Decls_Node (P))); begin if Is_Child_Unit (S) and then Is_Generic_Instance (S) then Set_Parents (True); end if; while Present (PN) loop -- Skip implicit types that may have been introduced by -- previous analysis. if Nkind (PN) = N_Pragma then case Get_Pragma_Id (Chars (PN)) is when Pragma_All_Calls_Remote | Pragma_Preelaborate | Pragma_Pure | Pragma_Remote_Call_Interface | Pragma_Remote_Types | Pragma_Shared_Passive => Analyze (PN); when others => null; end case; end if; Next (PN); end loop; if Is_Child_Unit (S) and then Is_Generic_Instance (S) then Set_Parents (False); end if; end; end Set_Categorization_From_Pragmas; ------------------------------ -- Static_Discriminant_Expr -- ------------------------------ function Static_Discriminant_Expr (L : List_Id) return Boolean is Discriminant_Spec : Node_Id; begin Discriminant_Spec := First (L); while Present (Discriminant_Spec) loop if Present (Expression (Discriminant_Spec)) and then not Is_Static_Expression (Expression (Discriminant_Spec)) then return False; end if; Next (Discriminant_Spec); end loop; return True; end Static_Discriminant_Expr; -------------------------------------- -- Validate_Access_Type_Declaration -- -------------------------------------- procedure Validate_Access_Type_Declaration (T : Entity_Id; N : Node_Id) is Def : constant Node_Id := Type_Definition (N); begin case Nkind (Def) is when N_Access_To_Subprogram_Definition => -- A pure library_item must not contain the declaration of a -- named access type, except within a subprogram, generic -- subprogram, task unit, or protected unit (RM 10.2.1(16)). if Comes_From_Source (T) and then In_Pure_Unit and then not In_Subprogram_Task_Protected_Unit then Error_Msg_N ("named access type not allowed in pure unit", T); end if; when N_Access_To_Object_Definition => if Comes_From_Source (T) and then In_Pure_Unit and then not In_Subprogram_Task_Protected_Unit then Error_Msg_N ("named access type not allowed in pure unit", T); end if; -- Check for RCI unit type declaration. It should not contain -- the declaration of an access-to-object type unless it is a -- general access type that designates a class-wide limited -- private type. There are also constraints about the primitive -- subprograms of the class-wide type. Validate_Remote_Access_Object_Type_Declaration (T); -- Check for shared passive unit type declaration. It should -- not contain the declaration of access to class wide type, -- access to task type and access to protected type with entry. Validate_SP_Access_Object_Type_Decl (T); when others => null; end case; -- Set Categorization flag of package on entity as well, to allow -- easy checks later on for required validations of RCI units. This -- is only done for entities that are in the original source. if Comes_From_Source (T) then if Is_Remote_Call_Interface (Scope (T)) and then not In_Package_Body (Scope (T)) then Set_Is_Remote_Call_Interface (T); end if; if Is_Remote_Types (Scope (T)) and then not In_Package_Body (Scope (T)) then Set_Is_Remote_Types (T); end if; end if; end Validate_Access_Type_Declaration; ---------------------------- -- Validate_Ancestor_Part -- ---------------------------- procedure Validate_Ancestor_Part (N : Node_Id) is A : constant Node_Id := Ancestor_Part (N); T : Entity_Id := Entity (A); begin if In_Preelaborated_Unit and then not In_Subprogram_Or_Concurrent_Unit and then (not Inside_A_Generic or else Present (Enclosing_Generic_Body (N))) then -- We relax the restriction of 10.2.1(9) within GNAT -- units to allow packages such as Ada.Strings.Unbounded -- to be implemented (i.p., Null_Unbounded_String). -- (There are ACVC tests that check that the restriction -- is enforced, but note that AI-161, once approved, -- will relax the restriction prohibiting default- -- initialized objects of private and controlled -- types.) if Is_Private_Type (T) and then not Is_Internal_File_Name (Unit_File_Name (Get_Source_Unit (N))) then Error_Msg_N ("private ancestor type not allowed in preelaborated unit", A); elsif Is_Record_Type (T) then if Nkind (Parent (T)) = N_Full_Type_Declaration then Check_Non_Static_Default_Expr (Type_Definition (Parent (T)), A); end if; end if; end if; end Validate_Ancestor_Part; ---------------------------------------- -- Validate_Categorization_Dependency -- ---------------------------------------- procedure Validate_Categorization_Dependency (N : Node_Id; E : Entity_Id) is K : constant Node_Kind := Nkind (N); P : Node_Id := Parent (N); U : Entity_Id := E; Is_Subunit : constant Boolean := Nkind (P) = N_Subunit; begin -- Only validate library units and subunits. For subunits, checks -- concerning withed units apply to the parent compilation unit. if Is_Subunit then P := Parent (P); U := Scope (E); while Present (U) and then not Is_Compilation_Unit (U) and then not Is_Child_Unit (U) loop U := Scope (U); end loop; end if; if Nkind (P) /= N_Compilation_Unit then return; end if; -- Body of RCI unit does not need validation. if Is_Remote_Call_Interface (E) and then (Nkind (N) = N_Package_Body or else Nkind (N) = N_Subprogram_Body) then return; end if; -- Process with clauses declare Item : Node_Id; Entity_Of_Withed : Entity_Id; begin Item := First (Context_Items (P)); while Present (Item) loop if Nkind (Item) = N_With_Clause and then not Implicit_With (Item) then Entity_Of_Withed := Entity (Name (Item)); Check_Categorization_Dependencies (U, Entity_Of_Withed, Item, Is_Subunit); end if; Next (Item); end loop; end; -- Child depends on parent; therefore parent should also -- be categorized and satify the dependency hierarchy. -- Check if N is a child spec. if (K in N_Generic_Declaration or else K in N_Generic_Instantiation or else K in N_Generic_Renaming_Declaration or else K = N_Package_Declaration or else K = N_Package_Renaming_Declaration or else K = N_Subprogram_Declaration or else K = N_Subprogram_Renaming_Declaration) and then Present (Parent_Spec (N)) then declare Parent_Lib_U : constant Node_Id := Parent_Spec (N); Parent_Kind : constant Node_Kind := Nkind (Unit (Parent_Lib_U)); Parent_Entity : Entity_Id; begin if Parent_Kind = N_Package_Instantiation or else Parent_Kind = N_Procedure_Instantiation or else Parent_Kind = N_Function_Instantiation or else Parent_Kind = N_Package_Renaming_Declaration or else Parent_Kind in N_Generic_Renaming_Declaration then Parent_Entity := Defining_Entity (Unit (Parent_Lib_U)); else Parent_Entity := Defining_Entity (Specification (Unit (Parent_Lib_U))); end if; Check_Categorization_Dependencies (E, Parent_Entity, N, False); -- Verify that public child of an RCI library unit -- must also be an RCI library unit (RM E.2.3(15)). if Is_Remote_Call_Interface (Parent_Entity) and then not Private_Present (P) and then not Is_Remote_Call_Interface (E) then Error_Msg_N ("public child of rci unit must also be rci unit", N); return; end if; end; end if; end Validate_Categorization_Dependency; -------------------------------- -- Validate_Controlled_Object -- -------------------------------- procedure Validate_Controlled_Object (E : Entity_Id) is begin -- For now, never apply this check for internal GNAT units, since we -- have a number of cases in the library where we are stuck with objects -- of this type, and the RM requires Preelaborate. -- For similar reasons, we only do this check for source entities, since -- we generate entities of this type in some situations. -- Note that the 10.2.1(9) restrictions are not relevant to us anyway. -- We have to enforce them for RM compatibility, but we have no trouble -- accepting these objects and doing the right thing. Note that there is -- no requirement that Preelaborate not actually generate any code! if In_Preelaborated_Unit and then not Debug_Flag_PP and then Comes_From_Source (E) and then not Is_Internal_File_Name (Unit_File_Name (Get_Source_Unit (E))) and then (not Inside_A_Generic or else Present (Enclosing_Generic_Body (E))) and then not Is_Protected_Type (Etype (E)) then Error_Msg_N ("library level controlled object not allowed in " & "preelaborated unit", E); end if; end Validate_Controlled_Object; -------------------------------------- -- Validate_Null_Statement_Sequence -- -------------------------------------- procedure Validate_Null_Statement_Sequence (N : Node_Id) is Item : Node_Id; begin if In_Preelaborated_Unit then Item := First (Statements (Handled_Statement_Sequence (N))); while Present (Item) loop if Nkind (Item) /= N_Label and then Nkind (Item) /= N_Null_Statement then Error_Msg_N ("statements not allowed in preelaborated unit", Item); exit; end if; Next (Item); end loop; end if; end Validate_Null_Statement_Sequence; --------------------------------- -- Validate_Object_Declaration -- --------------------------------- procedure Validate_Object_Declaration (N : Node_Id) is Id : constant Entity_Id := Defining_Identifier (N); E : constant Node_Id := Expression (N); Odf : constant Node_Id := Object_Definition (N); T : constant Entity_Id := Etype (Id); begin -- Verify that any access to subprogram object does not have in its -- subprogram profile access type parameters or limited parameters -- without Read and Write attributes (E.2.3(13)). Validate_RCI_Subprogram_Declaration (N); -- Check that if we are in preelaborated elaboration code, then we -- do not have an instance of a default initialized private, task or -- protected object declaration which would violate (RM 10.2.1(9)). -- Note that constants are never default initialized (and the test -- below also filters out deferred constants). A variable is default -- initialized if it does *not* have an initialization expression. -- Filter out cases that are not declaration of a variable from source if Nkind (N) /= N_Object_Declaration or else Constant_Present (N) or else not Comes_From_Source (Id) then return; end if; -- Exclude generic specs from the checks (this will get rechecked -- on instantiations). if Inside_A_Generic and then not Present (Enclosing_Generic_Body (Id)) then return; end if; -- Required checks for declaration that is in a preelaborated -- package and is not within some subprogram. if In_Preelaborated_Unit and then not In_Subprogram_Or_Concurrent_Unit then -- Check for default initialized variable case. Note that in -- accordance with (RM B.1(24)) imported objects are not -- subject to default initialization. if No (E) and then not Is_Imported (Id) then declare Ent : Entity_Id := T; begin -- An array whose component type is a record with nonstatic -- default expressions is a violation, so we get the array's -- component type. if Is_Array_Type (Ent) then declare Comp_Type : Entity_Id := Component_Type (Ent); begin while Is_Array_Type (Comp_Type) loop Comp_Type := Component_Type (Comp_Type); end loop; Ent := Comp_Type; end; end if; -- Object decl. that is of record type and has no default expr. -- should check if there is any non-static default expression -- in component decl. of the record type decl. if Is_Record_Type (Ent) then if Nkind (Parent (Ent)) = N_Full_Type_Declaration then Check_Non_Static_Default_Expr (Type_Definition (Parent (Ent)), N); elsif Nkind (Odf) = N_Subtype_Indication and then not Is_Array_Type (T) and then not Is_Private_Type (T) then Check_Non_Static_Default_Expr (Type_Definition (Parent (Entity (Subtype_Mark (Odf)))), N); end if; end if; -- We relax the restriction of 10.2.1(9) within GNAT -- units. (There are ACVC tests that check that the -- restriction is enforced, but note that AI-161, -- once approved, will relax the restriction prohibiting -- default-initialized objects of private types, and -- will recommend a pragma for marking private types.) if (Is_Private_Type (Ent) or else Depends_On_Private (Ent)) and then not Is_Internal_File_Name (Unit_File_Name (Get_Source_Unit (N))) then Error_Msg_N ("private object not allowed in preelaborated unit", N); return; -- Access to Task or Protected type elsif Is_Entity_Name (Odf) and then Present (Etype (Odf)) and then Is_Access_Type (Etype (Odf)) then Ent := Designated_Type (Etype (Odf)); elsif Is_Entity_Name (Odf) then Ent := Entity (Odf); elsif Nkind (Odf) = N_Subtype_Indication then Ent := Etype (Subtype_Mark (Odf)); elsif Nkind (Odf) = N_Constrained_Array_Definition then Ent := Component_Type (T); -- else -- return; end if; if Is_Task_Type (Ent) or else (Is_Protected_Type (Ent) and then Has_Entries (Ent)) then Error_Msg_N ("concurrent object not allowed in preelaborated unit", N); return; end if; end; end if; -- Non-static discriminant not allowed in preelaborayted unit if Is_Record_Type (Etype (Id)) then declare ET : constant Entity_Id := Etype (Id); EE : constant Entity_Id := Etype (Etype (Id)); PEE : Node_Id; begin if Has_Discriminants (ET) and then Present (EE) then PEE := Parent (EE); if Nkind (PEE) = N_Full_Type_Declaration and then not Static_Discriminant_Expr (Discriminant_Specifications (PEE)) then Error_Msg_N ("non-static discriminant in preelaborated unit", PEE); end if; end if; end; end if; end if; -- A pure library_item must not contain the declaration of any -- variable except within a subprogram, generic subprogram, task -- unit or protected unit (RM 10.2.1(16)). if In_Pure_Unit and then not In_Subprogram_Task_Protected_Unit then Error_Msg_N ("declaration of variable not allowed in pure unit", N); -- The visible part of an RCI library unit must not contain the -- declaration of a variable (RM E.1.3(9)) elsif In_RCI_Declaration (N) then Error_Msg_N ("declaration of variable not allowed in rci unit", N); -- The visible part of a Shared Passive library unit must not contain -- the declaration of a variable (RM E.2.2(7)) elsif In_RT_Declaration then Error_Msg_N ("variable declaration not allowed in remote types unit", N); end if; end Validate_Object_Declaration; -------------------------------- -- Validate_RCI_Declarations -- -------------------------------- procedure Validate_RCI_Declarations (P : Entity_Id) is E : Entity_Id; begin E := First_Entity (P); while Present (E) loop if Comes_From_Source (E) then if Is_Limited_Type (E) then Error_Msg_N ("Limited type not allowed in rci unit", Parent (E)); elsif Ekind (E) = E_Generic_Function or else Ekind (E) = E_Generic_Package or else Ekind (E) = E_Generic_Procedure then Error_Msg_N ("generic declaration not allowed in rci unit", Parent (E)); elsif (Ekind (E) = E_Function or else Ekind (E) = E_Procedure) and then Has_Pragma_Inline (E) then Error_Msg_N ("inlined subprogram not allowed in rci unit", Parent (E)); -- Inner packages that are renamings need not be checked. -- Generic RCI packages are subject to the checks, but -- entities that come from formal packages are not part of the -- visible declarations of the package and are not checked. elsif Ekind (E) = E_Package then if Present (Renamed_Entity (E)) then null; elsif Ekind (P) /= E_Generic_Package or else List_Containing (Unit_Declaration_Node (E)) /= Generic_Formal_Declarations (Unit_Declaration_Node (P)) then Validate_RCI_Declarations (E); end if; end if; end if; Next_Entity (E); end loop; end Validate_RCI_Declarations; ----------------------------------------- -- Validate_RCI_Subprogram_Declaration -- ----------------------------------------- procedure Validate_RCI_Subprogram_Declaration (N : Node_Id) is K : Node_Kind := Nkind (N); Profile : List_Id; Id : Node_Id; Param_Spec : Node_Id; Param_Type : Entity_Id; Base_Param_Type : Entity_Id; Type_Decl : Node_Id; Error_Node : Node_Id := N; begin -- There are two possible cases in which this procedure is called: -- 1. called from Analyze_Subprogram_Declaration. -- 2. called from Validate_Object_Declaration (access to subprogram). if not In_RCI_Declaration (N) then return; end if; if K = N_Subprogram_Declaration then Profile := Parameter_Specifications (Specification (N)); else pragma Assert (K = N_Object_Declaration); Id := Defining_Identifier (N); if Nkind (Id) = N_Defining_Identifier and then Nkind (Parent (Etype (Id))) = N_Full_Type_Declaration and then Ekind (Etype (Id)) = E_Access_Subprogram_Type then Profile := Parameter_Specifications (Type_Definition (Parent (Etype (Id)))); else return; end if; end if; -- Iterate through the parameter specification list, checking that -- no access parameter and no limited type parameter in the list. -- RM E.2.3 (14) if Present (Profile) then Param_Spec := First (Profile); while Present (Param_Spec) loop Param_Type := Etype (Defining_Identifier (Param_Spec)); Type_Decl := Parent (Param_Type); if Ekind (Param_Type) = E_Anonymous_Access_Type then if K = N_Subprogram_Declaration then Error_Node := Param_Spec; end if; -- Report error only if declaration is in source program. if Comes_From_Source (Defining_Entity (Specification (N))) then Error_Msg_N ("subprogram in rci unit cannot have access parameter", Error_Node); end if; -- For limited private type parameter, we check only the -- private declaration and ignore full type declaration, -- unless this is the only declaration for the type, eg. -- as a limited record. elsif Is_Limited_Type (Param_Type) and then (Nkind (Type_Decl) = N_Private_Type_Declaration or else (Nkind (Type_Decl) = N_Full_Type_Declaration and then not (Has_Private_Declaration (Param_Type)) and then Comes_From_Source (N))) then -- A limited parameter is legal only if user-specified -- Read and Write attributes exist for it. -- second part of RM E.2.3 (14) if No (Full_View (Param_Type)) and then Ekind (Param_Type) /= E_Record_Type then -- type does not have completion yet, so if declared in -- in the current RCI scope it is illegal, and will be -- flagged subsequently. return; end if; Base_Param_Type := Base_Type (Underlying_Type (Param_Type)); if No (TSS (Base_Param_Type, Name_uRead)) or else No (TSS (Base_Param_Type, Name_uWrite)) then if K = N_Subprogram_Declaration then Error_Node := Param_Spec; end if; Error_Msg_N ("limited parameter in rci unit " & "must have read/write attributes ", Error_Node); end if; end if; Next (Param_Spec); end loop; end if; end Validate_RCI_Subprogram_Declaration; ---------------------------------------------------- -- Validate_Remote_Access_Object_Type_Declaration -- ---------------------------------------------------- procedure Validate_Remote_Access_Object_Type_Declaration (T : Entity_Id) is Direct_Designated_Type : Entity_Id; Desig_Type : Entity_Id; Primitive_Subprograms : Elist_Id; Subprogram : Elmt_Id; Subprogram_Node : Node_Id; Profile : List_Id; Param_Spec : Node_Id; Param_Type : Entity_Id; Limited_Type_Decl : Node_Id; begin -- We are called from Analyze_Type_Declaration, and the Nkind -- of the given node is N_Access_To_Object_Definition. if not Comes_From_Source (T) or else (not In_RCI_Declaration (Parent (T)) and then not In_RT_Declaration) then return; end if; -- An access definition in the private part of a Remote Types package -- may be legal if it has user-defined Read and Write attributes. This -- will be checked at the end of the package spec processing. if In_RT_Declaration and then In_Private_Part (Scope (T)) then return; end if; -- Check RCI unit type declaration. It should not contain the -- declaration of an access-to-object type unless it is a -- general access type that designates a class-wide limited -- private type. There are also constraints about the primitive -- subprograms of the class-wide type (RM E.2.3(14)). if Ekind (T) /= E_General_Access_Type or else Ekind (Designated_Type (T)) /= E_Class_Wide_Type then if In_RCI_Declaration (Parent (T)) then Error_Msg_N ("access type in Remote_Call_Interface unit must be " & "general access", T); else Error_Msg_N ("access type in Remote_Types unit must be " & "general access", T); end if; Error_Msg_N ("\to class-wide type", T); return; end if; Direct_Designated_Type := Designated_Type (T); Desig_Type := Etype (Direct_Designated_Type); if not Is_Recursively_Limited_Private (Desig_Type) then Error_Msg_N ("error in designated type of remote access to class-wide type", T); Error_Msg_N ("\must be tagged limited private or private extension of type", T); return; end if; Primitive_Subprograms := Primitive_Operations (Desig_Type); Subprogram := First_Elmt (Primitive_Subprograms); while Subprogram /= No_Elmt loop Subprogram_Node := Node (Subprogram); if not Comes_From_Source (Subprogram_Node) then goto Next_Subprogram; end if; Profile := Parameter_Specifications (Parent (Subprogram_Node)); -- Profile must exist, otherwise not primitive operation Param_Spec := First (Profile); while Present (Param_Spec) loop -- Now find out if this parameter is a controlling parameter Param_Type := Parameter_Type (Param_Spec); if (Nkind (Param_Type) = N_Access_Definition and then Etype (Subtype_Mark (Param_Type)) = Desig_Type) or else (Nkind (Param_Type) /= N_Access_Definition and then Etype (Param_Type) = Desig_Type) then -- It is a controlling parameter, so specific checks below -- do not apply. null; elsif Nkind (Param_Type) = N_Access_Definition then -- From RM E.2.2(14), no access parameter other than -- controlling ones may be used. Error_Msg_N ("non-controlling access parameter", Param_Spec); elsif Is_Limited_Type (Etype (Defining_Identifier (Param_Spec))) then -- Not a controlling parameter, so type must have Read -- and Write attributes. -- ??? I suspect this to be dead code because any violation -- should be caught before in sem_attr.adb (with the message -- "limited type ... used in ... has no stream attr."). ST if Nkind (Param_Type) in N_Has_Etype and then Nkind (Parent (Etype (Param_Type))) = N_Private_Type_Declaration then Param_Type := Etype (Param_Type); Limited_Type_Decl := Parent (Param_Type); if No (TSS (Param_Type, Name_uRead)) or else No (TSS (Param_Type, Name_uWrite)) then Error_Msg_N ("limited formal must have Read and Write attributes", Param_Spec); end if; end if; end if; -- Check next parameter in this subprogram Next (Param_Spec); end loop; <<Next_Subprogram>> Next_Elmt (Subprogram); end loop; -- Now this is an RCI unit access-to-class-wide-limited-private type -- declaration. Set the type entity to be Is_Remote_Call_Interface to -- optimize later checks by avoiding tree traversal to find out if this -- entity is inside an RCI unit. Set_Is_Remote_Call_Interface (T); end Validate_Remote_Access_Object_Type_Declaration; ----------------------------------------------- -- Validate_Remote_Access_To_Class_Wide_Type -- ----------------------------------------------- procedure Validate_Remote_Access_To_Class_Wide_Type (N : Node_Id) is K : constant Node_Kind := Nkind (N); PK : constant Node_Kind := Nkind (Parent (N)); E : Entity_Id; begin -- This subprogram enforces the checks in (RM E.2.2(8)) for -- certain uses of class-wide limited private types. -- Storage_Pool and Storage_Size are not defined for such types -- -- The expected type of allocator must not not be such a type. -- The actual parameter of generic instantiation must not -- be such a type if the formal parameter is of an access type. -- On entry, there are five cases -- 1. called from sem_attr Analyze_Attribute where attribute -- name is either Storage_Pool or Storage_Size. -- 2. called from exp_ch4 Expand_N_Allocator -- 3. called from sem_ch12 Analyze_Associations -- 4. called from sem_ch4 Analyze_Explicit_Dereference -- 5. called from sem_res Resolve_Actuals if K = N_Attribute_Reference then E := Etype (Prefix (N)); if Is_Remote_Access_To_Class_Wide_Type (E) then Error_Msg_N ("incorrect attribute of remote operand", N); return; end if; elsif K = N_Allocator then E := Etype (N); if Is_Remote_Access_To_Class_Wide_Type (E) then Error_Msg_N ("incorrect expected remote type of allocator", N); return; end if; elsif K in N_Has_Entity then E := Entity (N); if Is_Remote_Access_To_Class_Wide_Type (E) then Error_Msg_N ("incorrect remote type generic actual", N); return; end if; -- This subprogram also enforces the checks in E.2.2(13). -- A value of such type must not be dereferenced unless as a -- controlling operand of a dispatching call. elsif K = N_Explicit_Dereference and then (Comes_From_Source (N) or else (Nkind (Original_Node (N)) = N_Selected_Component and then Comes_From_Source (Original_Node (N)))) then E := Etype (Prefix (N)); -- If the class-wide type is not a remote one, the restrictions -- do not apply. if not Is_Remote_Access_To_Class_Wide_Type (E) then return; end if; -- If we have a true dereference that comes from source and that -- is a controlling argument for a dispatching call, accept it. if K = N_Explicit_Dereference and then Is_Actual_Parameter (N) and then Is_Controlling_Actual (N) then return; end if; -- If we are just within a procedure or function call and the -- dereference has not been analyzed, return because this -- procedure will be called again from sem_res Resolve_Actuals. if Is_Actual_Parameter (N) and then not Analyzed (N) then return; end if; -- The following is to let the compiler generated tags check -- pass through without error message. This is a bit kludgy -- isn't there some better way of making this exclusion ??? if (PK = N_Selected_Component and then Present (Parent (Parent (N))) and then Nkind (Parent (Parent (N))) = N_Op_Ne) or else (PK = N_Unchecked_Type_Conversion and then Present (Parent (Parent (N))) and then Nkind (Parent (Parent (N))) = N_Selected_Component) then return; end if; -- The following code is needed for expansion of RACW Write -- attribute, since such expressions can appear in the expanded -- code. if not Comes_From_Source (N) and then (PK = N_In or else PK = N_Attribute_Reference or else (PK = N_Type_Conversion and then Present (Parent (N)) and then Present (Parent (Parent (N))) and then Nkind (Parent (Parent (N))) = N_Selected_Component)) then return; end if; Error_Msg_N ("incorrect remote type dereference", N); end if; end Validate_Remote_Access_To_Class_Wide_Type; ----------------------------------------------- -- Validate_Remote_Access_To_Subprogram_Type -- ----------------------------------------------- procedure Validate_Remote_Access_To_Subprogram_Type (N : Node_Id) is Type_Def : constant Node_Id := Type_Definition (N); Current_Parameter : Node_Id; begin if Present (Parameter_Specifications (Type_Def)) then Current_Parameter := First (Parameter_Specifications (Type_Def)); while Present (Current_Parameter) loop if Nkind (Parameter_Type (Current_Parameter)) = N_Access_Definition then Error_Msg_N ("remote access to subprogram type declaration contains", Current_Parameter); Error_Msg_N ("\parameter of an anonymous access type", Current_Parameter); end if; Current_Parameter := Next (Current_Parameter); end loop; end if; end Validate_Remote_Access_To_Subprogram_Type; ------------------------------------------ -- Validate_Remote_Type_Type_Conversion -- ------------------------------------------ procedure Validate_Remote_Type_Type_Conversion (N : Node_Id) is S : constant Entity_Id := Etype (N); E : constant Entity_Id := Etype (Expression (N)); begin -- This test is required in the case where a conversion appears -- inside a normal package, it does not necessarily have to be -- inside an RCI, Remote_Types unit (RM E.2.2(9,12)). if Is_Remote_Access_To_Subprogram_Type (E) and then not Is_Remote_Access_To_Subprogram_Type (S) then Error_Msg_N ("incorrect conversion of remote operand", N); return; elsif Is_Remote_Access_To_Class_Wide_Type (E) and then not Is_Remote_Access_To_Class_Wide_Type (S) then Error_Msg_N ("incorrect conversion of remote operand", N); return; end if; -- If a local access type is converted into a RACW type, then the -- current unit has a pointer that may now be exported to another -- partition. if Is_Remote_Access_To_Class_Wide_Type (S) and then not Is_Remote_Access_To_Class_Wide_Type (E) then Set_Has_RACW (Current_Sem_Unit); end if; end Validate_Remote_Type_Type_Conversion; ------------------------------- -- Validate_RT_RAT_Component -- ------------------------------- procedure Validate_RT_RAT_Component (N : Node_Id) is Spec : constant Node_Id := Specification (N); Name_U : constant Entity_Id := Defining_Entity (Spec); Typ : Entity_Id; First_Priv_Ent : constant Entity_Id := First_Private_Entity (Name_U); In_Visible_Part : Boolean := True; begin if not Is_Remote_Types (Name_U) then return; end if; Typ := First_Entity (Name_U); while Present (Typ) loop if In_Visible_Part and then Typ = First_Priv_Ent then In_Visible_Part := False; end if; if Comes_From_Source (Typ) and then Is_Type (Typ) and then (In_Visible_Part or else Has_Private_Declaration (Typ)) then if Missing_Read_Write_Attributes (Typ) then if Is_Non_Remote_Access_Type (Typ) then Error_Msg_N ("non-remote access type without user-defined Read " & "and Write attributes", Typ); else Error_Msg_N ("record type containing a component of a " & "non-remote access", Typ); Error_Msg_N ("\type without Read and Write attributes " & "('R'M E.2.2(8))", Typ); end if; end if; end if; Next_Entity (Typ); end loop; end Validate_RT_RAT_Component; ----------------------------------------- -- Validate_SP_Access_Object_Type_Decl -- ----------------------------------------- procedure Validate_SP_Access_Object_Type_Decl (T : Entity_Id) is Direct_Designated_Type : Entity_Id; function Has_Entry_Declarations (E : Entity_Id) return Boolean; -- Return true if the protected type designated by T has -- entry declarations. function Has_Entry_Declarations (E : Entity_Id) return Boolean is Ety : Entity_Id; begin if Nkind (Parent (E)) = N_Protected_Type_Declaration then Ety := First_Entity (E); while Present (Ety) loop if Ekind (Ety) = E_Entry then return True; end if; Next_Entity (Ety); end loop; end if; return False; end Has_Entry_Declarations; -- Start of processing for Validate_SP_Access_Object_Type_Decl begin -- We are called from Sem_Ch3.Analyze_Type_Declaration, and the -- Nkind of the given entity is N_Access_To_Object_Definition. if not Comes_From_Source (T) or else not In_Shared_Passive_Unit or else In_Subprogram_Task_Protected_Unit then return; end if; -- Check Shared Passive unit. It should not contain the declaration -- of an access-to-object type whose designated type is a class-wide -- type, task type or protected type with entry (RM E.2.1(7)). Direct_Designated_Type := Designated_Type (T); if Ekind (Direct_Designated_Type) = E_Class_Wide_Type then Error_Msg_N ("invalid access-to-class-wide type in shared passive unit", T); return; elsif Ekind (Direct_Designated_Type) in Task_Kind then Error_Msg_N ("invalid access-to-task type in shared passive unit", T); return; elsif Ekind (Direct_Designated_Type) in Protected_Kind and then Has_Entry_Declarations (Direct_Designated_Type) then Error_Msg_N ("invalid access-to-protected type in shared passive unit", T); return; end if; end Validate_SP_Access_Object_Type_Decl; --------------------------------- -- Validate_Static_Object_Name -- --------------------------------- procedure Validate_Static_Object_Name (N : Node_Id) is E : Entity_Id; function Is_Primary (N : Node_Id) return Boolean; -- Determine whether node is syntactically a primary in an expression. function Is_Primary (N : Node_Id) return Boolean is K : constant Node_Kind := Nkind (Parent (N)); begin case K is when N_Op | N_In | N_Not_In => return True; when N_Aggregate | N_Component_Association | N_Index_Or_Discriminant_Constraint => return True; when N_Attribute_Reference => return Attribute_Name (Parent (N)) /= Name_Address and then Attribute_Name (Parent (N)) /= Name_Access and then Attribute_Name (Parent (N)) /= Name_Unchecked_Access and then Attribute_Name (Parent (N)) /= Name_Unrestricted_Access; when N_Indexed_Component => return (N /= Prefix (Parent (N)) or else Is_Primary (Parent (N))); when N_Qualified_Expression | N_Type_Conversion => return Is_Primary (Parent (N)); when N_Assignment_Statement | N_Object_Declaration => return (N = Expression (Parent (N))); when N_Selected_Component => return Is_Primary (Parent (N)); when others => return False; end case; end Is_Primary; -- Start of processing for Validate_Static_Object_Name begin if not In_Preelaborated_Unit or else not Comes_From_Source (N) or else In_Subprogram_Or_Concurrent_Unit or else Ekind (Current_Scope) = E_Block then return; -- Filter out cases where primary is default in a component -- declaration, discriminant specification, or actual in a record -- type initialization call. -- Initialization call of internal types. elsif Nkind (Parent (N)) = N_Procedure_Call_Statement then if Present (Parent (Parent (N))) and then Nkind (Parent (Parent (N))) = N_Freeze_Entity then return; end if; if Nkind (Name (Parent (N))) = N_Identifier and then not Comes_From_Source (Entity (Name (Parent (N)))) then return; end if; end if; -- Error if the name is a primary in an expression. The parent must not -- be an operator, or a selected component or an indexed component that -- is itself a primary. Entities that are actuals do not need to be -- checked, because the call itself will be diagnosed. if Is_Primary (N) and then (not Inside_A_Generic or else Present (Enclosing_Generic_Body (N))) then if Ekind (Entity (N)) = E_Variable then Error_Msg_N ("non-static object name in preelaborated unit", N); -- We take the view that a constant defined in another preelaborated -- unit is preelaborable, even though it may have a private type and -- thus appear non-static in a client. This must be the intent of -- the language, but currently is an RM gap. elsif Ekind (Entity (N)) = E_Constant and then not Is_Static_Expression (N) then E := Entity (N); if Is_Internal_File_Name (Unit_File_Name (Get_Source_Unit (N))) and then Enclosing_Lib_Unit_Node (N) /= Enclosing_Lib_Unit_Node (E) and then (Is_Preelaborated (Scope (E)) or else Is_Pure (Scope (E)) or else (Present (Renamed_Object (E)) and then Is_Entity_Name (Renamed_Object (E)) and then (Is_Preelaborated (Scope (Renamed_Object (E))) or else Is_Pure (Scope (Renamed_Object (E)))))) then null; else Error_Msg_N ("non-static constant in preelaborated unit", N); end if; end if; end if; end Validate_Static_Object_Name; end Sem_Cat;
with Ada.Containers.Vectors; with WPs; with Partners; package Projects is use type WPs.WP_Type; use type Partners.Partner_Type; package WP_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => WPs.WP_Type); package Partner_Vectors is new Ada.Containers.Vectors (Index_Type => Positive, Element_Type => Partners.Partner_Type); type Project_Type is record Partner_List : Partner_Vectors.Vector; WP_List : WP_Vectors.Vector; end record; end Projects;
package body converters with SPARK_Mode is function double_to_speed (d : double) return Types.speed is temp : Types.Speed; begin if (d <= double(-80.0)) then temp := Types.Speed(-79.0); return temp; end if; if (d >= double(80.0)) then temp := Types.Speed(79.0); return temp; end if; temp := Types.Speed(d); return temp; end double_to_speed; function point_to_cart_x (p : point_3d) return Types.Cartesian_Coordinate is temp : Types.Cartesian_Coordinate; begin temp := Types.Cartesian_Coordinate(p.x); return temp; end point_to_cart_x; function point_to_cart_y (p : point_3d) return Types.Cartesian_Coordinate is temp : Types.Cartesian_Coordinate; begin temp := Types.Cartesian_Coordinate(p.y); return temp; end point_to_cart_y; function point_to_cart_z (p : point_3d) return Types.Cartesian_Coordinate is temp : Types.Cartesian_Coordinate; begin temp := Types.Cartesian_Coordinate(p.z); return temp; end point_to_cart_z; function speed_ada_to_speed (s : speed_ada) return Types.speed is temp : Types.speed; begin temp := double_to_speed(s.speed); return temp; end speed_ada_to_speed; end converters;
package Address_Null_Init is type Acc is access Integer; A : Acc := new Integer'(123); B : Acc; -- Variable must be set to null (and A overwritten by null) for B'Address use A'Address; end Address_Null_Init;
pragma Ada_2012; with Ada.Unchecked_Conversion; with GNAT.Byte_Swapping; with System; package body SHA2_Generic_64 is function Initialize return Context is ((State => <>, Count => 0, Buffer => (others => <>))); procedure Initialize (Ctx : out Context) is begin Ctx := Initialize; end Initialize; procedure Update (Ctx : in out Context; Input : String) is Buffer : Element_Array (Index (Input'First) .. Index (Input'Last)); for Buffer'Address use Input'Address; pragma Import (Ada, Buffer); begin Update (Ctx, Buffer); end Update; procedure Update (Ctx : in out Context; Input : Element_Array) is Current : Index := Input'First; begin while Current <= Input'Last loop declare Buffer_Index : constant Index := Ctx.Count rem Block_Length; Bytes_To_Copy : constant Index := Index'Min (Input'Length - (Current - Input'First), Block_Length); begin Ctx.Buffer (Buffer_Index .. Buffer_Index + Bytes_To_Copy - 1) := Input (Current .. Current + Bytes_To_Copy - 1); Current := Current + Bytes_To_Copy; Ctx.Count := Ctx.Count + Bytes_To_Copy; if Ctx.Buffer'Last < Buffer_Index + Bytes_To_Copy then Transform (Ctx); end if; end; end loop; end Update; function Finalize (Ctx : Context) return Digest is Result : Digest; begin Finalize (Ctx, Result); return Result; end Finalize; procedure Finalize (Ctx : Context; Output : out Digest) is use GNAT.Byte_Swapping; use System; Final_Count : constant Index := Ctx.Count; Ctx_Copy : Context := Ctx; begin -- Insert padding Update (Ctx_Copy, Element_Array'(0 => 16#80#)); if Ctx_Copy.Buffer'Last - (Ctx_Copy.Count rem Block_Length) < 16 then -- In case not enough space is left in the buffer we fill it up Update (Ctx_Copy, Element_Array' (0 .. (Ctx_Copy.Buffer'Last - (Ctx_Copy.Count rem Block_Length)) => 0)); end if; -- Fill rest of the data with zeroes Update (Ctx_Copy, Element_Array' (0 .. (Ctx_Copy.Buffer'Last - (Ctx_Copy.Count rem Block_Length) - 16) => 0)); declare -- Shift_Left(X, 3) is equivalent to multiplyng by 8 Byte_Length_1 : Unsigned_64 := Shift_Right (Unsigned_64 (Final_Count), 61); Byte_Length_2 : Unsigned_64 := Shift_Left (Unsigned_64 (Final_Count), 3); Byte_Length_1_Buffer : Element_Array (0 .. 7); for Byte_Length_1_Buffer'Address use Byte_Length_1'Address; pragma Import (Ada, Byte_Length_1_Buffer); Byte_Length_2_Buffer : Element_Array (0 .. 7); for Byte_Length_2_Buffer'Address use Byte_Length_2'Address; pragma Import (Ada, Byte_Length_2_Buffer); begin if Default_Bit_Order /= High_Order_First then Swap8 (Byte_Length_1_Buffer'Address); Swap8 (Byte_Length_2_Buffer'Address); end if; Update (Ctx_Copy, Byte_Length_1_Buffer); Update (Ctx_Copy, Byte_Length_2_Buffer); end; declare Buffer : Element_Array (0 .. 63); Current : Index := Buffer'First; begin for H of Ctx_Copy.State loop declare Inner_Buffer : Element_Array (0 .. 7); for Inner_Buffer'Address use H'Address; pragma Import (Ada, Inner_Buffer); begin if Default_Bit_Order /= High_Order_First then Swap8 (Inner_Buffer'Address); end if; Buffer (Current + 0 .. Current + 7) := Inner_Buffer; Current := Current + 8; exit when Current >= Digest_Length; end; end loop; Output := Buffer (0 .. Output'Length - 1); end; end Finalize; function Hash (Input : String) return Digest is Ctx : Context := Initialize; begin Update (Ctx, Input); return Finalize (Ctx); end Hash; function Hash (Input : Element_Array) return Digest is Ctx : Context := Initialize; begin Update (Ctx, Input); return Finalize (Ctx); end Hash; procedure Transform (Ctx : in out Context) is type Words is array (Natural range <>) of Unsigned_64; W : Words (0 .. 79); A : Unsigned_64 := Ctx.State (0); B : Unsigned_64 := Ctx.State (1); C : Unsigned_64 := Ctx.State (2); D : Unsigned_64 := Ctx.State (3); E : Unsigned_64 := Ctx.State (4); F : Unsigned_64 := Ctx.State (5); G : Unsigned_64 := Ctx.State (6); H : Unsigned_64 := Ctx.State (7); Temporary_1, Temporary_2 : Unsigned_64; begin declare use GNAT.Byte_Swapping; use System; Buffer_Words : Words (0 .. 15); for Buffer_Words'Address use Ctx.Buffer'Address; pragma Import (Ada, Buffer_Words); begin W (0 .. 15) := Buffer_Words; if Default_Bit_Order /= High_Order_First then -- Take care of endianess for I in Buffer_Words'Range loop Swap8 (W (I)'Address); end loop; end if; end; for I in 16 .. 79 loop W (I) := S_1 (W (I - 2)) + W (I - 7) + S_0 (W (I - 15)) + W (I - 16); end loop; for I in 0 .. 79 loop Temporary_1 := H + Sigma_1 (E) + Ch (E, F, G) + K (I) + W (I); Temporary_2 := Sigma_0 (A) + Maj (A, B, C); H := G; G := F; F := E; E := D + Temporary_1; D := C; C := B; B := A; A := Temporary_1 + Temporary_2; end loop; Ctx.State (0) := Ctx.State (0) + A; Ctx.State (1) := Ctx.State (1) + B; Ctx.State (2) := Ctx.State (2) + C; Ctx.State (3) := Ctx.State (3) + D; Ctx.State (4) := Ctx.State (4) + E; Ctx.State (5) := Ctx.State (5) + F; Ctx.State (6) := Ctx.State (6) + G; Ctx.State (7) := Ctx.State (7) + H; end Transform; function Ch (X, Y, Z : Unsigned_64) return Unsigned_64 is ((X and Y) xor ((not X) and Z)); function Maj (X, Y, Z : Unsigned_64) return Unsigned_64 is ((X and Y) xor (X and Z) xor (Y and Z)); function Sigma_0 (X : Unsigned_64) return Unsigned_64 is (Rotate_Right (X, 28) xor Rotate_Right (X, 34) xor Rotate_Right (X, 39)); function Sigma_1 (X : Unsigned_64) return Unsigned_64 is (Rotate_Right (X, 14) xor Rotate_Right (X, 18) xor Rotate_Right (X, 41)); function S_0 (X : Unsigned_64) return Unsigned_64 is (Rotate_Right (X, 1) xor Rotate_Right (X, 8) xor Shift_Right (X, 7)); function S_1 (X : Unsigned_64) return Unsigned_64 is (Rotate_Right (X, 19) xor Rotate_Right (X, 61) xor Shift_Right (X, 6)); end SHA2_Generic_64;
------------------------------------------------------------------------------ -- -- -- P G A D A . D A T A B A S E -- -- -- -- S p e c -- -- -- -- Copyright (c) Samuel Tardieu 2000 -- -- All rights reserved. -- -- -- -- Redistribution and use in source and binary forms, with or without -- -- modification, are permitted provided that the following conditions -- -- are met: -- -- 1. Redistributions of source code must retain the above copyright -- -- notice, this list of conditions and the following disclaimer. -- -- 2. Redistributions in binary form must reproduce the above copyright -- -- notice, this list of conditions and the following disclaimer in -- -- the documentation and/or other materials provided with the -- -- distribution. -- -- 3. Neither the name of Samuel Tardieu 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 SAMUEL TARDIEU 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 SAMUEL -- -- TARDIEU 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.Finalization; with PGAda.Errors; with PGAda.Thin; package PGAda.Database is pragma Preelaborate; PG_Error : exception; type Connection_t is new Ada.Finalization.Limited_Controlled with private; subtype Error_Field is PGAda.Thin.Error_Field; procedure Set_DB_Login (Connection : in out Connection_t; Host : in String := ""; Port : in Natural := 0; Options : in String := ""; TTY : in String := ""; DB_Name : in String := ""; Login : in String := ""; Password : in String := ""); -- Connect to a database function DB (Connection : Connection_t) return String; function Host (Connection : Connection_t) return String; function Port (Connection : Connection_t) return Positive; function Options (Connection : Connection_t) return String; -- Query characteristics of an open connection type Connection_Status_t is (Connection_OK, Connection_Bad); function Status (Connection : Connection_t) return Connection_Status_t; function Error_Message (Connection : Connection_t) return String; procedure Finish (Connection : in out Connection_t); procedure Reset (Connection : in Connection_t); type Result_t is new Ada.Finalization.Controlled with private; type Exec_Status_t is (Empty_Query, Command_OK, Tuples_OK, Copy_Out, Copy_In, Bad_Response, Non_Fatal_Error, Fatal_Error); procedure Exec (Connection : in Connection_t'Class; Query : in String; Result : out Result_t; Status : out Exec_Status_t); procedure Exec (Connection : in Connection_t'Class; Query : in String; Result : out Result_t); -- Note: the Connection parameter is of type Connection_t'Class -- because this function cannot be a primitive operation of several -- tagged types. function Error_Message (Result : Result_t) return String; function Exec (Connection : Connection_t'Class; Query : String) return Result_t; -- Function form of the subprogram procedure Exec (Connection : in Connection_t'Class; Query : in String); -- This procedure executes the query but does not test the result. It -- can be used for queries that do not require a result and cannot fail. function Result_Status (Result : Result_t) return Exec_Status_t; function Error_Code (Result : Result_t) return PGAda.Errors.Error_Value_t; function Result_Error_Field (Result : Result_t; Field : Error_Field) return String; function Nbr_Tuples (Result : Result_t) return Natural; function Number_Of_Tuples (Result : Result_t) return Natural renames Nbr_Tuples; function Nbr_Fields (Result : Result_t) return Natural; function Number_Of_Fields (Result : Result_t) return Natural renames Nbr_Fields; function Field_Name (Result : Result_t; Field_Index : Positive) return String; function Get_Value (Result : Result_t; Tuple_Index : Positive; Field_Index : Positive) return String; function Get_Value (Result : Result_t; Tuple_Index : Positive; Field_Name : String) return String; function Get_Value (Result : Result_t; Tuple_Index : Positive; Field_Index : Positive) return Integer; function Get_Value (Result : Result_t; Tuple_Index : Positive; Field_Name : String) return Integer; function Get_Value (Result : Result_t; Tuple_Index : Positive; Field_Index : Positive) return Long_Integer; function Get_Value (Result : Result_t; Tuple_Index : Positive; Field_Name : String) return Long_Integer; function Get_Value (Result : Result_t; Tuple_Index : Positive; Field_Index : Positive) return Long_Long_Integer; function Get_Value (Result : Result_t; Tuple_Index : Positive; Field_Name : String) return Long_Long_Integer; function Get_Length (Result : Result_t; Tuple_Index : Positive; Field_Index : Positive) return Natural; function Is_Null (Result : Result_t; Tuple_Index : Positive; Field_Index : Positive) return Boolean; function Command_Status (Result : Result_t) return String; function Command_Tuples (Result : Result_t) return String; function OID_Status (Result : Result_t) return String; procedure Clear (Result : in out Result_t); private type Connection_t is new Ada.Finalization.Limited_Controlled with record Actual : Thin.PG_Conn_Access_t; end record; procedure Finalize (Connection : in out Connection_t); type Natural_Access_t is access Natural; type Result_t is new Ada.Finalization.Controlled with record Actual : Thin.PG_Result_Access_t; Ref_Count : Natural_Access_t := new Integer'(1); end record; procedure Adjust (Result : in out Result_t); procedure Finalize (Result : in out Result_t); end PGAda.Database;
-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr> -- MIT license. Please refer to the LICENSE file. package Apsepp.Output_Class.Quiet is type Output_Quiet is limited new Output_Interfa with private; private type Output_Quiet is limited new Output_Interfa with null record; end Apsepp.Output_Class.Quiet;
-- Abstract : -- -- See spec. -- -- Copyright (C) 2018 - 2019 Free Software Foundation, Inc. -- -- This library is free software; you can redistribute it and/or modify it -- under terms of the GNU General Public License as published by the Free -- Software Foundation; either version 3, or (at your option) any later -- version. This library is distributed in the hope that it will be useful, -- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- -- TABILITY or FITNESS FOR A PARTICULAR PURPOSE. -- As a special exception under Section 7 of GPL version 3, you are granted -- additional permissions described in the GCC Runtime Library Exception, -- version 3.1, as published by the Free Software Foundation. pragma License (Modified_GPL); package body WisiToken.Parse is function Next_Grammar_Token (Parser : in out Base_Parser) return Token_ID is use all type Syntax_Trees.User_Data_Access; Token : Base_Token; Error : Boolean; begin loop Error := Parser.Lexer.Find_Next (Token); -- We don't handle Error until later; we assume it was recovered. if Parser.User_Data /= null then Parser.User_Data.Lexer_To_Augmented (Token, Parser.Lexer); end if; if Token.Line /= Invalid_Line_Number then -- Some lexers don't support line numbers. if Parser.Lexer.First then Parser.Line_Begin_Token.Set_Length (Ada.Containers.Count_Type (Token.Line)); Parser.Line_Begin_Token (Token.Line) := Parser.Terminals.Last_Index + (if Token.ID >= Parser.Trace.Descriptor.First_Terminal then 1 else 0); elsif Token.ID = Parser.Trace.Descriptor.EOI_ID then Parser.Line_Begin_Token.Set_Length (Ada.Containers.Count_Type (Token.Line + 1)); Parser.Line_Begin_Token (Token.Line + 1) := Parser.Terminals.Last_Index + 1; end if; end if; if Trace_Parse > Lexer_Debug then Parser.Trace.Put_Line (Image (Token, Parser.Trace.Descriptor.all)); end if; exit when Token.ID >= Parser.Trace.Descriptor.First_Terminal; end loop; Parser.Terminals.Append (Token); if Error then declare Error : WisiToken.Lexer.Error renames Parser.Lexer.Errors.Reference (Parser.Lexer.Errors.Last); begin if Error.Recover_Char (1) /= ASCII.NUL then Error.Recover_Token := Parser.Terminals.Last_Index; end if; end; end if; return Token.ID; end Next_Grammar_Token; procedure Lex_All (Parser : in out Base_Parser) is EOF_ID : constant Token_ID := Parser.Trace.Descriptor.EOI_ID; begin Parser.Lexer.Errors.Clear; Parser.Terminals.Clear; Parser.Line_Begin_Token.Clear; loop exit when EOF_ID = Next_Grammar_Token (Parser); end loop; if Trace_Parse > Outline then Parser.Trace.Put_Line (Token_Index'Image (Parser.Terminals.Last_Index) & " tokens lexed"); end if; end Lex_All; end WisiToken.Parse;
package body types with spark_mode => on is function to_bit (u : unsigned_8) return types.bit is pragma warnings (off); function conv is new ada.unchecked_conversion (unsigned_8, bit); pragma warnings (on); begin if u > 1 then raise program_error; end if; return conv (u); end to_bit; function to_bit (u : unsigned_32) return types.bit is pragma warnings (off); function conv is new ada.unchecked_conversion (unsigned_32, bit); pragma warnings (on); begin if u > 1 then raise program_error; end if; return conv (u); end to_bit; end types;
----------------------------------------------------------------------- -- awa-storages-modules-tests -- Unit tests for storage service -- Copyright (C) 2012, 2013, 2016, 2019, 2020 Stephane Carrez -- Written by Stephane Carrez (Stephane.Carrez@gmail.com) -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. ----------------------------------------------------------------------- with Ada.Strings.Unbounded; with Util.Test_Caller; with Security.Contexts; with ASF.Tests; with ASF.Requests.Mockup; with ASF.Responses.Mockup; with Servlet.Responses; with AWA.Services.Contexts; with AWA.Tests.Helpers.Users; with AWA.Images.Modules; with AWA.Storages.Beans; with AWA.Storages.Services; with AWA.Storages.Modules; package body AWA.Images.Modules.Tests is use type AWA.Storages.Services.Storage_Service_Access; package Caller is new Util.Test_Caller (Test, "Images.Modules"); procedure Add_Tests (Suite : in Util.Tests.Access_Test_Suite) is begin Caller.Add_Test (Suite, "Test AWA.Images.Modules.Create_Image", Test_Create_Image'Access); Caller.Add_Test (Suite, "Test AWA.Images.Modules.Get_Sizes", Test_Get_Sizes'Access); Caller.Add_Test (Suite, "Test AWA.Images.Modules.Scale", Test_Scale'Access); Caller.Add_Test (Suite, "Test AWA.Images.Modules.On_Create", Test_Store_Image'Access); end Add_Tests; -- ------------------------------ -- Test creation of a storage object -- ------------------------------ procedure Test_Create_Image (T : in out Test) is Sec_Ctx : Security.Contexts.Security_Context; Context : AWA.Services.Contexts.Service_Context; Source : constant String := Util.Tests.Get_Path ("regtests/files/images/bast-12.jpg"); Thumb : constant String := Util.Tests.Get_Test_Path ("regtests/result/bast-12-thumb.jpg"); Width : Natural := 64; Height : Natural := 64; begin AWA.Tests.Helpers.Users.Login (Context, Sec_Ctx, "test-storage@test.com"); T.Manager := AWA.Images.Modules.Get_Image_Module; T.Manager.Create_Thumbnail (Source, Thumb, Width, Height); Util.Tests.Assert_Equals (T, 1720, Width, "Invalid image width"); Util.Tests.Assert_Equals (T, 1098, Height, "Invalid image height"); end Test_Create_Image; -- ------------------------------ -- Test the Get_Sizes operation. -- ------------------------------ procedure Test_Get_Sizes (T : in out Test) is Width : Natural; Height : Natural; begin AWA.Images.Modules.Get_Sizes ("default", Width, Height); Util.Tests.Assert_Equals (T, 800, Width, "Default width should be 800"); Util.Tests.Assert_Equals (T, 0, Height, "Default height should be 0"); AWA.Images.Modules.Get_Sizes ("123x456", Width, Height); Util.Tests.Assert_Equals (T, 123, Width, "Invalid width"); Util.Tests.Assert_Equals (T, 456, Height, "Invalid height"); AWA.Images.Modules.Get_Sizes ("x56", Width, Height); Util.Tests.Assert_Equals (T, 0, Width, "Invalid width"); Util.Tests.Assert_Equals (T, 56, Height, "Invalid height"); AWA.Images.Modules.Get_Sizes ("123x", Width, Height); Util.Tests.Assert_Equals (T, 123, Width, "Invalid width"); Util.Tests.Assert_Equals (T, 0, Height, "Invalid height"); AWA.Images.Modules.Get_Sizes ("123xtoto", Width, Height); Util.Tests.Assert_Equals (T, 123, Width, "Invalid width"); Util.Tests.Assert_Equals (T, 0, Height, "Invalid height"); AWA.Images.Modules.Get_Sizes ("xtoto", Width, Height); Util.Tests.Assert_Equals (T, 0, Width, "Invalid width"); Util.Tests.Assert_Equals (T, 0, Height, "Invalid height"); AWA.Images.Modules.Get_Sizes ("original", Width, Height); Util.Tests.Assert_Equals (T, Natural'Last, Width, "Invalid width"); Util.Tests.Assert_Equals (T, Natural'Last, Height, "Invalid height"); end Test_Get_Sizes; -- ------------------------------ -- Test the Scale operation. -- ------------------------------ procedure Test_Scale (T : in out Test) is Width : Natural; Height : Natural; begin Width := 0; Height := 0; AWA.Images.Modules.Scale (123, 456, Width, Height); Util.Tests.Assert_Equals (T, 123, Width, "Invalid width"); Util.Tests.Assert_Equals (T, 456, Height, "Invalid height"); Width := 100; Height := 0; AWA.Images.Modules.Scale (10000, 2000, Width, Height); Util.Tests.Assert_Equals (T, 100, Width, "Invalid width"); Util.Tests.Assert_Equals (T, 20, Height, "Invalid height"); Width := 0; Height := 200; AWA.Images.Modules.Scale (10000, 2000, Width, Height); Util.Tests.Assert_Equals (T, 1000, Width, "Invalid width"); Util.Tests.Assert_Equals (T, 200, Height, "Invalid height"); end Test_Scale; -- ------------------------------ -- Test the creation of an image through the storage service. -- ------------------------------ procedure Test_Store_Image (T : in out Test) is Sec_Ctx : Security.Contexts.Security_Context; Context : AWA.Services.Contexts.Service_Context; Folder : AWA.Storages.Beans.Folder_Bean; Store : AWA.Storages.Models.Storage_Ref; Mgr : AWA.Storages.Services.Storage_Service_Access; Outcome : Ada.Strings.Unbounded.Unbounded_String; Path : constant String := Util.Tests.Get_Path ("regtests/files/images/Ada-Lovelace.jpg"); begin AWA.Tests.Helpers.Users.Login (Context, Sec_Ctx, "test-storage@test.com"); Mgr := AWA.Storages.Modules.Get_Storage_Manager; T.Assert (Mgr /= null, "Null storage manager"); -- Make a storage folder. Folder.Module := AWA.Storages.Modules.Get_Storage_Module; Folder.Set_Name ("Image folder"); Folder.Save (Outcome); Store.Set_Folder (Folder); Store.Set_Mime_Type ("image/jpg"); Store.Set_Name ("Ada-Lovelace.jpg"); Mgr.Save (Store, Path, AWA.Storages.Models.FILE); declare Request : ASF.Requests.Mockup.Request; Reply : ASF.Responses.Mockup.Response; Id : constant String := ADO.Identifier'Image (Store.Get_Id); begin AWA.Tests.Helpers.Users.Login ("test-storage@test.com", Request); ASF.Tests.Do_Get (Request, Reply, "/storages/images/" & Id (Id'First + 1 .. Id'Last) & "/view/Ada-Lovelace.jpg", "image-get-Ada-Lovelace.jpg"); ASF.Tests.Assert_Header (T, "Content-Type", "image/jpg", Reply); Util.Tests.Assert_Equals (T, Servlet.Responses.SC_OK, Reply.Get_Status, "Invalid response for image"); -- Try to get an invalid image ASF.Tests.Do_Get (Request, Reply, "/storages/images/plop" & "/view/Ada-Lovelace.jpg", "image-get-plop.jpg"); Util.Tests.Assert_Equals (T, Servlet.Responses.SC_NOT_FOUND, Reply.Get_Status, "Invalid response for image"); end; end Test_Store_Image; end AWA.Images.Modules.Tests;
------------------------------------------------------------------------------ -- -- -- GNAT RUN-TIME COMPONENTS -- -- -- -- A D A . T A G S -- -- -- -- S p e c -- -- -- -- Copyright (C) 1992-2005, Free Software Foundation, Inc. -- -- -- -- This specification is derived from the Ada Reference Manual for use with -- -- GNAT. The copyright notice above, and the license provisions that follow -- -- apply solely to the contents of the part following the private keyword. -- -- -- -- 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 System; with System.Storage_Elements; with Unchecked_Conversion; package Ada.Tags is pragma Preelaborate_05; -- In accordance with Ada 2005 AI-362 type Tag is private; No_Tag : constant Tag; function Expanded_Name (T : Tag) return String; function External_Tag (T : Tag) return String; function Internal_Tag (External : String) return Tag; function Descendant_Tag (External : String; Ancestor : Tag) return Tag; pragma Ada_05 (Descendant_Tag); function Is_Descendant_At_Same_Level (Descendant : Tag; Ancestor : Tag) return Boolean; pragma Ada_05 (Is_Descendant_At_Same_Level); function Parent_Tag (T : Tag) return Tag; pragma Ada_05 (Parent_Tag); Tag_Error : exception; function Wide_Expanded_Name (T : Tag) return Wide_String; pragma Ada_05 (Wide_Expanded_Name); function Wide_Wide_Expanded_Name (T : Tag) return Wide_Wide_String; pragma Ada_05 (Wide_Wide_Expanded_Name); private -- The following subprogram specifications are placed here instead of -- the package body to see them from the frontend through rtsfind. --------------------------------------------------------------- -- Abstract Procedural Interface For The GNAT Dispatch Table -- --------------------------------------------------------------- -- GNAT's Dispatch Table format is customizable in order to match the -- format used in another language. GNAT supports programs that use two -- different dispatch table formats at the same time: the native format -- that supports Ada 95 tagged types and which is described in Ada.Tags, -- and a foreign format for types that are imported from some other -- language (typically C++) which is described in Interfaces.CPP. The -- runtime information kept for each tagged type is separated into two -- objects: the Dispatch Table and the Type Specific Data record. These -- two objects are allocated statically using the constants: -- DT Size = DT_Prologue_Size + Nb_Prim * DT_Entry_Size -- TSD Size = TSD_Prologue_Size + (1 + Idepth) * TSD_Entry_Size -- where Nb_prim is the number of primitive operations of the given -- type and Idepth its inheritance depth. -- In order to set or retrieve information from the Dispatch Table or -- the Type Specific Data record, GNAT generates calls to Set_XXX or -- Get_XXX routines, where XXX is the name of the field of interest. type Dispatch_Table; type Tag is access all Dispatch_Table; type Interface_Tag is access all Dispatch_Table; No_Tag : constant Tag := null; type Interface_Data (Nb_Ifaces : Positive); type Interface_Data_Ptr is access all Interface_Data; -- Table of abstract interfaces used to give support to backward interface -- conversions and also to IW_Membership. type Object_Specific_Data (Nb_Prim : Positive); type Object_Specific_Data_Ptr is access all Object_Specific_Data; -- Information associated with the secondary dispatch table of tagged-type -- objects implementing abstract interfaces. type Select_Specific_Data (Nb_Prim : Positive); type Select_Specific_Data_Ptr is access all Select_Specific_Data; -- A table used to store the primitive operation kind and entry index of -- primitive subprograms of a type that implements a limited interface. -- The Select Specific Data table resides in the Type Specific Data of a -- type. This construct is used in the handling of dispatching triggers -- in select statements. type Type_Specific_Data; type Type_Specific_Data_Ptr is access all Type_Specific_Data; -- Primitive operation kinds. These values differentiate the kinds of -- callable entities stored in the dispatch table. Certain kinds may -- not be used, but are added for completeness. type Prim_Op_Kind is (POK_Function, POK_Procedure, POK_Protected_Entry, POK_Protected_Function, POK_Protected_Procedure, POK_Task_Entry, POK_Task_Function, POK_Task_Procedure); -- Tagged type kinds with respect to concurrency and limitedness type Tagged_Kind is (TK_Abstract_Limited_Tagged, TK_Abstract_Tagged, TK_Limited_Tagged, TK_Protected, TK_Tagged, TK_Task); type Tagged_Kind_Ptr is access all Tagged_Kind; Default_Prim_Op_Count : constant Positive := 15; -- Number of predefined primitive operations added by the Expander for a -- tagged type (must match Exp_Disp.Default_Prim_Op_Count). type Signature_Kind is (Unknown, Valid_Signature, Primary_DT, Secondary_DT, Abstract_Interface); for Signature_Kind'Size use 8; -- Kind of signature found in the header of the dispatch table. These -- signatures are generated by the frontend and are used by the Check_XXX -- routines to ensure that the kind of dispatch table managed by each of -- the routines in this package is correct. This additional check is only -- performed with this run-time package is compiled with assertions enabled -- The signature is a sequence of two bytes. The first byte must have the -- value Valid_Signature, and the second byte must have a value in the -- range Primary_DT .. Abstract_Interface. The Unknown value is used by -- the Check_XXX routines to indicate that the signature is wrong. package SSE renames System.Storage_Elements; function CW_Membership (Obj_Tag : Tag; Typ_Tag : Tag) return Boolean; -- Given the tag of an object and the tag associated to a type, return -- true if Obj is in Typ'Class. function IW_Membership (This : System.Address; T : Tag) return Boolean; -- Ada 2005 (AI-251): General routine that checks if a given object -- implements a tagged type. Its common usage is to check if Obj is in -- Iface'Class, but it is also used to check if a class-wide interface -- implements a given type (Iface_CW_Typ in T'Class). For example: -- -- type I is interface; -- type T is tagged ... -- -- function Test (O : in I'Class) is -- begin -- return O in T'Class. -- end Test; function Displace (This : System.Address; T : Tag) return System.Address; -- (Ada 2005 (AI-251): Displace "This" to point to the secondary dispatch -- table of T. function Get_Access_Level (T : Tag) return Natural; -- Given the tag associated with a type, returns the accessibility level -- of the type. function Get_Entry_Index (T : Tag; Position : Positive) return Positive; -- Return a primitive operation's entry index (if entry) given a dispatch -- table T and a position of a primitive operation in T. function Get_External_Tag (T : Tag) return System.Address; -- Retrieve the address of a null terminated string containing -- the external name. function Get_Offset_Index (T : Tag; Position : Positive) return Positive; -- Given a pointer to a secondary dispatch table (T) and a position of an -- operation in the DT, retrieve the corresponding operation's position in -- the primary dispatch table from the Offset Specific Data table of T. function Get_Predefined_Prim_Op_Address (T : Tag; Position : Positive) return System.Address; -- Given a pointer to a dispatch table (T) and a position in the DT -- this function returns the address of the virtual function stored -- in it (used for dispatching calls). function Get_Prim_Op_Address (T : Tag; Position : Positive) return System.Address; -- Given a pointer to a dispatch table (T) and a position in the DT -- this function returns the address of the virtual function stored -- in it (used for dispatching calls). function Get_Prim_Op_Kind (T : Tag; Position : Positive) return Prim_Op_Kind; -- Return a primitive operation's kind given a dispatch table T and a -- position of a primitive operation in T. function Get_RC_Offset (T : Tag) return SSE.Storage_Offset; -- Return the Offset of the implicit record controller when the object -- has controlled components. O otherwise. pragma Export (Ada, Get_RC_Offset, "ada__tags__get_rc_offset"); -- This procedure is used in s-finimp to compute the deep routines -- it is exported manually in order to avoid changing completely the -- organization of the run time. function Get_Remotely_Callable (T : Tag) return Boolean; -- Return the value previously set by Set_Remotely_Callable function Get_Tagged_Kind (T : Tag) return Tagged_Kind; -- Given a pointer to either a primary or a secondary dispatch table, -- return the tagged kind of a type in the context of concurrency and -- limitedness. procedure Inherit_DT (Old_T : Tag; New_T : Tag; Entry_Count : Natural); -- Entry point used to initialize the DT of a type knowing the tag -- of the direct ancestor and the number of primitive ops that are -- inherited (Entry_Count). procedure Inherit_TSD (Old_Tag : Tag; New_Tag : Tag); -- Initialize the TSD of a type knowing the tag of the direct ancestor function Offset_To_Top (This : System.Address) return System.Storage_Elements.Storage_Offset; -- Returns the current value of the offset_to_top component available in -- the prologue of the dispatch table. If the parent of the tagged type -- has discriminants this value is stored in a record component just -- immediately after the tag component. function OSD (T : Tag) return Object_Specific_Data_Ptr; -- Ada 2005 (AI-251): Given a pointer T to a secondary dispatch table, -- retrieve the address of the record containing the Objet Specific -- Data table. function Parent_Size (Obj : System.Address; T : Tag) return SSE.Storage_Count; -- Computes the size the ancestor part of a tagged extension object whose -- address is 'obj' by calling indirectly the ancestor _size function. The -- ancestor is the parent of the type represented by tag T. This function -- assumes that _size is always in slot one of the dispatch table. pragma Export (Ada, Parent_Size, "ada__tags__parent_size"); -- This procedure is used in s-finimp and is thus exported manually procedure Register_Interface_Tag (T : Tag; Interface_T : Tag; Position : Positive); -- Ada 2005 (AI-251): Used to initialize the table of interfaces -- implemented by a type. Required to give support to backward interface -- conversions and also to IW_Membership. procedure Register_Tag (T : Tag); -- Insert the Tag and its associated external_tag in a table for the -- sake of Internal_Tag procedure Set_Access_Level (T : Tag; Value : Natural); -- Sets the accessibility level of the tagged type associated with T -- in its TSD. procedure Set_Entry_Index (T : Tag; Position : Positive; Value : Positive); -- Set the entry index of a primitive operation in T's TSD table indexed -- by Position. procedure Set_Expanded_Name (T : Tag; Value : System.Address); -- Set the address of the string containing the expanded name -- in the Dispatch table. procedure Set_External_Tag (T : Tag; Value : System.Address); -- Set the address of the string containing the external tag -- in the Dispatch table. procedure Set_Interface_Table (T : Tag; Value : System.Address); -- Ada 2005 (AI-251): Given a pointer T to a dispatch Table, stores the -- pointer to the table of interfaces. procedure Set_Num_Prim_Ops (T : Tag; Value : Natural); -- Set the number of primitive operations in the dispatch table of T. This -- is used for debugging purposes. procedure Set_Offset_Index (T : Tag; Position : Positive; Value : Positive); -- Set the offset value of a primitive operation in a secondary dispatch -- table denoted by T, indexed by Position. procedure Set_Offset_To_Top (This : System.Address; Interface_T : Tag; Is_Static : Boolean; Offset_Value : System.Storage_Elements.Storage_Offset; Offset_Func : System.Address); -- Ada 2005 (AI-251): Initialize the Offset_To_Top field in the prologue of -- the dispatch table. In primary dispatch tables the value of "This" is -- not required (and the compiler passes always the Null_Address value) and -- the Offset_Value is always cero; in secondary dispatch tables "This" -- points to the object, Interface_T is the interface for which the -- secondary dispatch table is being initialized, and Offset_Value is the -- distance from "This" to the object component containing the tag of the -- secondary dispatch table. procedure Set_OSD (T : Tag; Value : System.Address); -- Given a pointer T to a secondary dispatch table, store the pointer to -- the record containing the Object Specific Data generated by GNAT. procedure Set_Predefined_Prim_Op_Address (T : Tag; Position : Positive; Value : System.Address); -- Given a pointer to a dispatch Table (T) and a position in the dispatch -- table associated with a predefined primitive operation, put the address -- of the virtual function in it (used for overriding). procedure Set_Prim_Op_Address (T : Tag; Position : Positive; Value : System.Address); -- Given a pointer to a dispatch Table (T) and a position in the dispatch -- Table put the address of the virtual function in it (used for -- overriding). procedure Set_Prim_Op_Kind (T : Tag; Position : Positive; Value : Prim_Op_Kind); -- Set the kind of a primitive operation in T's TSD table indexed by -- Position. procedure Set_RC_Offset (T : Tag; Value : SSE.Storage_Offset); -- Sets the Offset of the implicit record controller when the object -- has controlled components. Set to O otherwise. procedure Set_Remotely_Callable (T : Tag; Value : Boolean); -- Set to true if the type has been declared in a context described -- in E.4 (18). procedure Set_Signature (T : Tag; Value : Signature_Kind); -- Given a pointer T to a dispatch table, store the signature id procedure Set_SSD (T : Tag; Value : System.Address); -- Given a pointer T to a dispatch Table, stores the pointer to the record -- containing the Select Specific Data generated by GNAT. procedure Set_Tagged_Kind (T : Tag; Value : Tagged_Kind); -- Set the tagged kind of a type in either a primary or a secondary -- dispatch table denoted by T. procedure Set_TSD (T : Tag; Value : System.Address); -- Given a pointer T to a dispatch Table, stores the address of the record -- containing the Type Specific Data generated by GNAT. function SSD (T : Tag) return Select_Specific_Data_Ptr; -- Given a pointer T to a dispatch Table, retrieves the address of the -- record containing the Select Specific Data in T's TSD. function TSD (T : Tag) return Type_Specific_Data_Ptr; -- Given a pointer T to a dispatch Table, retrieves the address of the -- record containing the Type Specific Data generated by GNAT. DT_Prologue_Size : constant SSE.Storage_Count := SSE.Storage_Count ((Default_Prim_Op_Count + 4) * (Standard'Address_Size / System.Storage_Unit)); -- Size of the hidden part of the dispatch table. It contains the table of -- predefined primitive operations plus the C++ ABI header. DT_Signature_Size : constant SSE.Storage_Count := SSE.Storage_Count (1 * (Standard'Address_Size / System.Storage_Unit)); -- Size of the Signature field of the dispatch table DT_Tagged_Kind_Size : constant SSE.Storage_Count := SSE.Storage_Count (1 * (Standard'Address_Size / System.Storage_Unit)); -- Size of the Tagged_Type_Kind field of the dispatch table DT_Offset_To_Top_Size : constant SSE.Storage_Count := SSE.Storage_Count (1 * (Standard'Address_Size / System.Storage_Unit)); -- Size of the Offset_To_Top field of the Dispatch Table DT_Typeinfo_Ptr_Size : constant SSE.Storage_Count := SSE.Storage_Count (1 * (Standard'Address_Size / System.Storage_Unit)); -- Size of the Typeinfo_Ptr field of the Dispatch Table DT_Entry_Size : constant SSE.Storage_Count := SSE.Storage_Count (1 * (Standard'Address_Size / System.Storage_Unit)); -- Size of each primitive operation entry in the Dispatch Table Tag_Size : constant SSE.Storage_Count := SSE.Storage_Count (1 * (Standard'Address_Size / System.Storage_Unit)); -- Size of each tag TSD_Prologue_Size : constant SSE.Storage_Count := SSE.Storage_Count (10 * (Standard'Address_Size / System.Storage_Unit)); -- Size of the first part of the type specific data TSD_Entry_Size : constant SSE.Storage_Count := SSE.Storage_Count (1 * (Standard'Address_Size / System.Storage_Unit)); -- Size of each ancestor tag entry in the TSD type Address_Array is array (Natural range <>) of System.Address; pragma Suppress (Index_Check, On => Address_Array); -- The reason we suppress index checks is that in the body, objects -- of this type are declared with a dummy size of 1, the actual size -- depending on the number of primitive operations. -- Unchecked Conversions type Addr_Ptr is access System.Address; type Tag_Ptr is access Tag; type Signature_Values is array (1 .. DT_Signature_Size) of Signature_Kind; -- Type used to see the signature as a sequence of Signature_Kind values type Signature_Values_Ptr is access all Signature_Values; function To_Addr_Ptr is new Unchecked_Conversion (System.Address, Addr_Ptr); function To_Type_Specific_Data_Ptr is new Unchecked_Conversion (System.Address, Type_Specific_Data_Ptr); function To_Address is new Unchecked_Conversion (Interface_Tag, System.Address); function To_Address is new Unchecked_Conversion (Tag, System.Address); function To_Address is new Unchecked_Conversion (Type_Specific_Data_Ptr, System.Address); function To_Interface_Data_Ptr is new Unchecked_Conversion (System.Address, Interface_Data_Ptr); function To_Object_Specific_Data_Ptr is new Unchecked_Conversion (System.Address, Object_Specific_Data_Ptr); function To_Select_Specific_Data_Ptr is new Unchecked_Conversion (System.Address, Select_Specific_Data_Ptr); function To_Signature_Values is new Unchecked_Conversion (System.Storage_Elements.Storage_Offset, Signature_Values); function To_Signature_Values_Ptr is new Unchecked_Conversion (System.Address, Signature_Values_Ptr); function To_Tag is new Unchecked_Conversion (System.Address, Tag); function To_Tag_Ptr is new Unchecked_Conversion (System.Address, Tag_Ptr); function To_Tagged_Kind_Ptr is new Unchecked_Conversion (System.Address, Tagged_Kind_Ptr); -- Primitive dispatching operations are always inlined, to facilitate -- use in a minimal/no run-time environment for high integrity use. pragma Inline_Always (CW_Membership); pragma Inline_Always (Displace); pragma Inline_Always (IW_Membership); pragma Inline_Always (Get_Access_Level); pragma Inline_Always (Get_Entry_Index); pragma Inline_Always (Get_Offset_Index); pragma Inline_Always (Get_Predefined_Prim_Op_Address); pragma Inline_Always (Get_Prim_Op_Address); pragma Inline_Always (Get_Prim_Op_Kind); pragma Inline_Always (Get_RC_Offset); pragma Inline_Always (Get_Remotely_Callable); pragma Inline_Always (Get_Tagged_Kind); pragma Inline_Always (Inherit_DT); pragma Inline_Always (Inherit_TSD); pragma Inline_Always (OSD); pragma Inline_Always (Register_Interface_Tag); pragma Inline_Always (Register_Tag); pragma Inline_Always (Set_Access_Level); pragma Inline_Always (Set_Entry_Index); pragma Inline_Always (Set_Expanded_Name); pragma Inline_Always (Set_External_Tag); pragma Inline_Always (Set_Interface_Table); pragma Inline_Always (Set_Num_Prim_Ops); pragma Inline_Always (Set_Offset_Index); pragma Inline_Always (Set_Offset_To_Top); pragma Inline_Always (Set_Predefined_Prim_Op_Address); pragma Inline_Always (Set_Prim_Op_Address); pragma Inline_Always (Set_Prim_Op_Kind); pragma Inline_Always (Set_RC_Offset); pragma Inline_Always (Set_Remotely_Callable); pragma Inline_Always (Set_Signature); pragma Inline_Always (Set_OSD); pragma Inline_Always (Set_SSD); pragma Inline_Always (Set_TSD); pragma Inline_Always (Set_Tagged_Kind); pragma Inline_Always (SSD); pragma Inline_Always (TSD); end Ada.Tags;
-- -- Copyright 2018 The wookey project team <wookey@ssi.gouv.fr> -- - Ryad Benadjila -- - Arnauld Michelizza -- - Mathieu Renard -- - Philippe Thierry -- - Philippe Trebuchet -- -- Licensed under the Apache License, Version 2.0 (the "License"); -- you may not use this file except in compliance with the License. -- You may obtain a copy of the License at -- -- http://www.apache.org/licenses/LICENSE-2.0 -- -- Unless required by applicable law or agreed to in writing, software -- distributed under the License is distributed on an "AS IS" BASIS, -- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -- See the License for the specific language governing permissions and -- limitations under the License. -- -- with ewok.tasks; use ewok.tasks; with ewok.tasks_shared; use ewok.tasks_shared; with ewok.sched; with ewok.sanitize; with ewok.syscalls.cfg.dev; with ewok.syscalls.cfg.gpio; with ewok.syscalls.gettick; with ewok.syscalls.init; with ewok.syscalls.ipc; with ewok.syscalls.lock; with ewok.syscalls.log; with ewok.syscalls.reset; with ewok.syscalls.rng; with ewok.syscalls.sleep; with ewok.syscalls.yield; with ewok.syscalls.exiting; with ewok.exported.interrupts; use type ewok.exported.interrupts.t_interrupt_config_access; with ewok.debug; #if CONFIG_KERNEL_DMA_ENABLE with ewok.syscalls.dma; #end if; with m4.cpu.instructions; package body ewok.syscalls.handler with spark_mode => off is type t_task_access is access all ewok.tasks.t_task; function svc_handler (frame_a : t_stack_frame_access) return t_stack_frame_access is current_id : constant t_task_id := ewok.sched.current_task_id; current_a : constant t_task_access := ewok.tasks.tasks_list(current_id)'access; svc_params_a : t_parameters_access := NULL; svc : t_svc; begin -- -- We must save the frame pointer because synchronous syscall don't refer -- to the parameters on the stack indexed by 'frame_a' but to -- 'current_a' (they access 'frame_a' via 'current_a.all.ctx.frame_a' -- or 'current_a.all.isr_ctx.frame_a') -- if current_a.all.mode = TASK_MODE_MAINTHREAD then current_a.all.ctx.frame_a := frame_a; else current_a.all.isr_ctx.frame_a := frame_a; end if; -- -- Getting the svc number from the SVC instruction -- declare inst : m4.cpu.instructions.t_svc_instruction with import, address => to_address (frame_a.all.PC - 2); begin if not inst.opcode'valid then raise program_error; end if; declare svc_type : t_svc with address => inst.svc_num'address; begin if not svc_type'valid then ewok.tasks.set_state (current_id, TASK_MODE_MAINTHREAD, TASK_STATE_FAULT); set_return_value (current_id, current_a.all.mode, SYS_E_DENIED); return frame_a; end if; svc := svc_type; end; end; -- -- Getting svc parameters from caller's stack -- if ewok.sanitize.is_range_in_data_slot (frame_a.all.R0, t_parameters'size/8, current_id, current_a.all.mode) then svc_params_a := to_parameters_access (frame_a.all.R0); else if svc /= SVC_EXIT and svc /= SVC_YIELD and svc /= SVC_RESET and svc /= SVC_INIT_DONE and svc /= SVC_LOCK_ENTER and svc /= SVC_LOCK_EXIT and svc /= SVC_PANIC then -- R0 points outside the caller's data area pragma DEBUG (debug.log (debug.ERROR, current_a.all.name & "svc_handler(): invalid @parameters: " & unsigned_32'image (frame_a.all.R0))); ewok.tasks.set_state (current_id, TASK_MODE_MAINTHREAD, TASK_STATE_RUNNABLE); set_return_value (current_id, current_a.all.mode, SYS_E_DENIED); return frame_a; end if; end if; ------------------- -- Managing SVCs -- ------------------- case svc is when SVC_EXIT => ewok.syscalls.exiting.svc_exit (current_id, current_a.all.mode); return ewok.sched.do_schedule (frame_a); when SVC_YIELD => ewok.syscalls.yield.svc_yield (current_id, current_a.all.mode); return frame_a; when SVC_GET_TIME => ewok.syscalls.gettick.svc_gettick (current_id, svc_params_a.all, current_a.all.mode); return frame_a; when SVC_RESET => ewok.syscalls.reset.svc_reset (current_id, current_a.all.mode); return frame_a; when SVC_SLEEP => ewok.syscalls.sleep.svc_sleep (current_id, svc_params_a.all, current_a.all.mode); return frame_a; when SVC_GET_RANDOM => ewok.syscalls.rng.svc_get_random (current_id, svc_params_a.all, current_a.all.mode); return frame_a; when SVC_LOG => ewok.syscalls.log.svc_log (current_id, svc_params_a.all, current_a.all.mode); return frame_a; when SVC_REGISTER_DEVICE => ewok.syscalls.init.svc_register_device (current_id, svc_params_a.all, current_a.all.mode); return frame_a; when SVC_REGISTER_DMA => #if CONFIG_KERNEL_DMA_ENABLE ewok.syscalls.dma.svc_register_dma (current_id, svc_params_a.all, current_a.all.mode); #else set_return_value (current_id, current_a.all.mode, SYS_E_DENIED); #end if; return frame_a; when SVC_REGISTER_DMA_SHM => #if CONFIG_KERNEL_DMA_ENABLE ewok.syscalls.dma.svc_register_dma_shm (current_id, svc_params_a.all, current_a.all.mode); #else set_return_value (current_id, current_a.all.mode, SYS_E_DENIED); #end if; return frame_a; when SVC_GET_TASKID => ewok.syscalls.init.svc_get_taskid (current_id, svc_params_a.all, current_a.all.mode); return frame_a; when SVC_INIT_DONE => ewok.syscalls.init.svc_init_done (current_id, current_a.all.mode); return frame_a; when SVC_IPC_RECV_SYNC => ewok.syscalls.ipc.svc_ipc_do_recv (current_id, svc_params_a.all, true, current_a.all.mode); return ewok.sched.do_schedule (frame_a); when SVC_IPC_SEND_SYNC => ewok.syscalls.ipc.svc_ipc_do_send (current_id, svc_params_a.all, true, current_a.all.mode); return ewok.sched.do_schedule (frame_a); when SVC_IPC_RECV_ASYNC => ewok.syscalls.ipc.svc_ipc_do_recv (current_id, svc_params_a.all, false, current_a.all.mode); return ewok.sched.do_schedule (frame_a); when SVC_IPC_SEND_ASYNC => ewok.syscalls.ipc.svc_ipc_do_send (current_id, svc_params_a.all, false, current_a.all.mode); return ewok.sched.do_schedule (frame_a); when SVC_GPIO_SET => ewok.syscalls.cfg.gpio.svc_gpio_set (current_id, svc_params_a.all, current_a.all.mode); return frame_a; when SVC_GPIO_GET => ewok.syscalls.cfg.gpio.svc_gpio_get (current_id, svc_params_a.all, current_a.all.mode); return frame_a; when SVC_GPIO_UNLOCK_EXTI => ewok.syscalls.cfg.gpio.svc_gpio_unlock_exti (current_id, svc_params_a.all, current_a.all.mode); return frame_a; when SVC_DMA_RECONF => #if CONFIG_KERNEL_DMA_ENABLE ewok.syscalls.dma.svc_dma_reconf (current_id, svc_params_a.all, current_a.all.mode); #else set_return_value (current_id, current_a.all.mode, SYS_E_DENIED); #end if; return frame_a; when SVC_DMA_RELOAD => #if CONFIG_KERNEL_DMA_ENABLE ewok.syscalls.dma.svc_dma_reload (current_id, svc_params_a.all, current_a.all.mode); #else set_return_value (current_id, current_a.all.mode, SYS_E_DENIED); #end if; return frame_a; when SVC_DMA_DISABLE => #if CONFIG_KERNEL_DMA_ENABLE ewok.syscalls.dma.svc_dma_disable (current_id, svc_params_a.all, current_a.all.mode); #else set_return_value (current_id, current_a.all.mode, SYS_E_DENIED); #end if; return frame_a; when SVC_DEV_MAP => ewok.syscalls.cfg.dev.svc_dev_map (current_id, svc_params_a.all, current_a.all.mode); return frame_a; when SVC_DEV_UNMAP => ewok.syscalls.cfg.dev.svc_dev_unmap (current_id, svc_params_a.all, current_a.all.mode); return frame_a; when SVC_DEV_RELEASE => ewok.syscalls.cfg.dev.svc_dev_release (current_id, svc_params_a.all, current_a.all.mode); return frame_a; when SVC_LOCK_ENTER => ewok.syscalls.lock.svc_lock_enter (current_id, current_a.all.mode); return frame_a; when SVC_LOCK_EXIT => ewok.syscalls.lock.svc_lock_exit (current_id, current_a.all.mode); return frame_a; when SVC_PANIC => ewok.syscalls.exiting.svc_panic (current_id); return ewok.sched.do_schedule (frame_a); end case; end svc_handler; end ewok.syscalls.handler;
with Ada.Characters.Latin_1; use Ada.Characters.Latin_1; with Encodings.Line_Endings.Generic_Add_CR; package Encodings.Line_Endings.Add_CR is new Generic_Add_CR( Character_Type => Character, String_Type => String, Carriage_Return => CR, Line_Feed => LF, Coder_Base => Coder_Base );
-- { dg-do run } procedure Check_Displace_Generation is package Stuff is type Base_1 is interface; function F_1 (X : Base_1) return Integer is abstract; type Base_2 is interface; function F_2 (X : Base_2) return Integer is abstract; type Concrete is new Base_1 and Base_2 with null record; function F_1 (X : Concrete) return Integer; function F_2 (X : Concrete) return Integer; end Stuff; package body Stuff is function F_1 (X : Concrete) return Integer is begin return 1; end F_1; function F_2 (X : Concrete) return Integer is begin return 2; end F_2; end Stuff; use Stuff; function Make_Concrete return Concrete is C : Concrete; begin return C; end Make_Concrete; B_1 : Base_1'Class := Make_Concrete; B_2 : Base_2'Class := Make_Concrete; begin if B_1.F_1 /= 1 then raise Program_Error with "bad B_1.F_1 call"; end if; if B_2.F_2 /= 2 then raise Program_Error with "bad B_2.F_2 call"; end if; end Check_Displace_Generation;