content stringlengths 23 1.05M |
|---|
-- CC3007B.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT THE NAMES IN A GENERIC INSTANTIATION ARE STATICALLY
-- IDENTIFIED (I.E., BOUND) AT THE TEXTUAL POINT OF THE INSTANTIA-
-- TION, AND ARE BOUND BEFORE BEING "SUBSTITUTED" FOR THE COR-
-- RESPONDING GENERIC FORMAL PARAMETERS IN THE SPECIFICATION AND
-- BODY TEMPLATES.
--
-- SEE AI-00365/05-BI-WJ.
-- HISTORY:
-- EDWARD V. BERARD, 15 AUGUST 1990
-- DAS 08 OCT 90 CHANGED INSTANTIATIONS TO USE VARIABLES
-- M1 AND M2 IN THE FIRST_BLOCK INSTANTIA-
-- TION AND TO ASSIGN THIRD_DATE AND
-- FOURTH_DATE VALUES BEFORE AND AFTER THE
-- SECOND_BLOCK INSTANTIATION.
WITH REPORT;
PROCEDURE CC3007B IS
INCREMENTED_VALUE : NATURAL := 0;
TYPE MONTH_TYPE IS (JAN, FEB, MAR, APR, MAY, JUN, JUL, AUG,
SEP, OCT, NOV, DEC);
TYPE DAY_TYPE IS RANGE 1 .. 31;
TYPE YEAR_TYPE IS RANGE 1904 .. 2050;
TYPE DATE IS RECORD
MONTH : MONTH_TYPE;
DAY : DAY_TYPE;
YEAR : YEAR_TYPE;
END RECORD;
TYPE DATE_ACCESS IS ACCESS DATE;
TODAY : DATE := (MONTH => AUG,
DAY => 8,
YEAR => 1990);
CHRISTMAS : DATE := (MONTH => DEC,
DAY => 25,
YEAR => 1948);
WALL_DATE : DATE := (MONTH => NOV,
DAY => 9,
YEAR => 1989);
BIRTH_DATE : DATE := (MONTH => OCT,
DAY => 3,
YEAR => 1949);
FIRST_DUE_DATE : DATE := (MONTH => JAN,
DAY => 23,
YEAR => 1990);
LAST_DUE_DATE : DATE := (MONTH => DEC,
DAY => 20,
YEAR => 1990);
THIS_MONTH : MONTH_TYPE := AUG;
STORED_RECORD : DATE := TODAY;
STORED_INDEX : MONTH_TYPE := AUG;
FIRST_DATE : DATE_ACCESS := NEW DATE'(WALL_DATE);
SECOND_DATE : DATE_ACCESS := FIRST_DATE;
THIRD_DATE : DATE_ACCESS := NEW DATE'(BIRTH_DATE);
FOURTH_DATE : DATE_ACCESS := NEW DATE'(CHRISTMAS);
TYPE DUE_DATES IS ARRAY (MONTH_TYPE RANGE JAN .. DEC) OF DATE;
REPORT_DATES : DUE_DATES := ((JAN, 23, 1990), (FEB, 23, 1990),
(MAR, 23, 1990), (APR, 23, 1990),
(MAY, 23, 1990), (JUN, 22, 1990),
(JUL, 23, 1990), (AUG, 23, 1990),
(SEP, 24, 1990), (OCT, 23, 1990),
(NOV, 23, 1990), (DEC, 20, 1990));
GENERIC
NATURALLY : IN NATURAL;
FIRST_RECORD : IN OUT DATE;
SECOND_RECORD : IN OUT DATE;
TYPE RECORD_POINTER IS ACCESS DATE;
POINTER : IN OUT RECORD_POINTER;
TYPE ARRAY_TYPE IS ARRAY (MONTH_TYPE) OF DATE;
THIS_ARRAY : IN OUT ARRAY_TYPE;
FIRST_ARRAY_ELEMENT : IN OUT DATE;
SECOND_ARRAY_ELEMENT : IN OUT DATE;
INDEX_ELEMENT : IN OUT MONTH_TYPE;
POINTER_TEST : IN OUT DATE;
ANOTHER_POINTER_TEST : IN OUT DATE;
PACKAGE TEST_ACTUAL_PARAMETERS IS
PROCEDURE EVALUATE_FUNCTION;
PROCEDURE CHECK_RECORDS;
PROCEDURE CHECK_ACCESS;
PROCEDURE CHECK_ARRAY;
PROCEDURE CHECK_ARRAY_ELEMENTS;
PROCEDURE CHECK_SCALAR;
PROCEDURE CHECK_POINTERS;
END TEST_ACTUAL_PARAMETERS;
PACKAGE BODY TEST_ACTUAL_PARAMETERS IS
PROCEDURE EVALUATE_FUNCTION IS
BEGIN -- EVALUATE_FUNCTION
IF (INCREMENTED_VALUE = 0) OR
(NATURALLY /= INCREMENTED_VALUE) THEN
REPORT.FAILED ("PROBLEMS EVALUATING FUNCTION " &
"PARAMETER.");
END IF;
END EVALUATE_FUNCTION;
PROCEDURE CHECK_RECORDS IS
STORE : DATE;
BEGIN -- CHECK_RECORDS
IF STORED_RECORD /= FIRST_RECORD THEN
REPORT.FAILED ("PROBLEM WITH RECORD TYPES");
ELSE
STORED_RECORD := SECOND_RECORD;
STORE := FIRST_RECORD;
FIRST_RECORD := SECOND_RECORD;
SECOND_RECORD := STORE;
END IF;
END CHECK_RECORDS;
PROCEDURE CHECK_ACCESS IS
BEGIN -- CHECK_ACCESS
IF ((INCREMENTED_VALUE / 2) * 2) /= INCREMENTED_VALUE
THEN
IF POINTER.ALL /= DATE'(WALL_DATE) THEN
REPORT.FAILED ("PROBLEM WITH ACCESS TYPES " &
"- 1");
ELSE
POINTER.ALL := DATE'(BIRTH_DATE);
END IF;
ELSE
IF POINTER.ALL /= DATE'(BIRTH_DATE) THEN
REPORT.FAILED ("PROBLEM WITH ACCESS TYPES " &
"- 2");
ELSE
POINTER.ALL := DATE'(WALL_DATE);
END IF;
END IF;
END CHECK_ACCESS;
PROCEDURE CHECK_ARRAY IS
STORE : DATE;
BEGIN -- CHECK_ARRAY
IF ((INCREMENTED_VALUE / 2) * 2) /= INCREMENTED_VALUE
THEN
IF THIS_ARRAY (THIS_ARRAY'FIRST) /= FIRST_DUE_DATE
THEN
REPORT.FAILED ("PROBLEM WITH ARRAY TYPES - 1");
ELSE
THIS_ARRAY (THIS_ARRAY'FIRST) := LAST_DUE_DATE;
THIS_ARRAY (THIS_ARRAY'LAST) := FIRST_DUE_DATE;
END IF;
ELSE
IF THIS_ARRAY (THIS_ARRAY'FIRST) /= LAST_DUE_DATE
THEN
REPORT.FAILED ("PROBLEM WITH ARRAY TYPES - 2");
ELSE
THIS_ARRAY (THIS_ARRAY'FIRST) :=
FIRST_DUE_DATE;
THIS_ARRAY (THIS_ARRAY'LAST) := LAST_DUE_DATE;
END IF;
END IF;
END CHECK_ARRAY;
PROCEDURE CHECK_ARRAY_ELEMENTS IS
STORE : DATE;
BEGIN -- CHECK_ARRAY_ELEMENTS
IF ((INCREMENTED_VALUE / 2) * 2) /= INCREMENTED_VALUE
THEN
IF (FIRST_ARRAY_ELEMENT.MONTH /= MAY) OR
(SECOND_ARRAY_ELEMENT.DAY /= 22) THEN
REPORT.FAILED ("PROBLEM WITH ARRAY ELEMENTS " &
"- 1");
ELSE
STORE := FIRST_ARRAY_ELEMENT;
FIRST_ARRAY_ELEMENT := SECOND_ARRAY_ELEMENT;
SECOND_ARRAY_ELEMENT := STORE;
END IF;
ELSE
IF (FIRST_ARRAY_ELEMENT.MONTH /= JUN) OR
(SECOND_ARRAY_ELEMENT.DAY /= 23) THEN
REPORT.FAILED ("PROBLEM WITH ARRAY ELEMENTS " &
"- 2");
ELSE
STORE := FIRST_ARRAY_ELEMENT;
FIRST_ARRAY_ELEMENT := SECOND_ARRAY_ELEMENT;
SECOND_ARRAY_ELEMENT := STORE;
END IF;
END IF;
END CHECK_ARRAY_ELEMENTS;
PROCEDURE CHECK_SCALAR IS
BEGIN -- CHECK_SCALAR
IF ((INCREMENTED_VALUE / 2) * 2) /= INCREMENTED_VALUE
THEN
IF INDEX_ELEMENT /= STORED_INDEX THEN
REPORT.FAILED ("PROBLEM WITH INDEX TYPES - 1");
ELSE
INDEX_ELEMENT :=
MONTH_TYPE'SUCC(INDEX_ELEMENT);
STORED_INDEX := INDEX_ELEMENT;
END IF;
ELSE
IF INDEX_ELEMENT /= STORED_INDEX THEN
REPORT.FAILED ("PROBLEM WITH INDEX TYPES - 2");
ELSE
INDEX_ELEMENT :=
MONTH_TYPE'PRED (INDEX_ELEMENT);
STORED_INDEX := INDEX_ELEMENT;
END IF;
END IF;
END CHECK_SCALAR;
PROCEDURE CHECK_POINTERS IS
STORE : DATE;
BEGIN -- CHECK_POINTERS
IF ((INCREMENTED_VALUE / 2) * 2) /= INCREMENTED_VALUE
THEN
IF (POINTER_TEST /= DATE'(OCT, 3, 1949)) OR
(ANOTHER_POINTER_TEST /= DATE'(DEC, 25, 1948))
THEN
REPORT.FAILED ("PROBLEM WITH POINTER TEST " &
"- 1");
ELSE
STORE := POINTER_TEST;
POINTER_TEST := ANOTHER_POINTER_TEST;
ANOTHER_POINTER_TEST := STORE;
END IF;
ELSE
IF (POINTER_TEST /= DATE'(DEC, 25, 1948)) OR
(ANOTHER_POINTER_TEST /= DATE'(OCT, 3, 1949))
THEN
REPORT.FAILED ("PROBLEM WITH POINTER TEST " &
"- 2");
ELSE
STORE := POINTER_TEST;
POINTER_TEST := ANOTHER_POINTER_TEST;
ANOTHER_POINTER_TEST := STORE;
END IF;
END IF;
END CHECK_POINTERS;
END TEST_ACTUAL_PARAMETERS;
FUNCTION INC RETURN NATURAL IS
BEGIN -- INC
INCREMENTED_VALUE := NATURAL'SUCC (INCREMENTED_VALUE);
RETURN INCREMENTED_VALUE;
END INC;
BEGIN -- CC3007B
REPORT.TEST ("CC3007B", "CHECK THAT THE NAMES IN A GENERIC " &
"INSTANTIATION ARE STAICALLY IDENTIFIED (I.E., " &
"BOUND) AT THE TEXTUAL POINT OF THE INSTANTIATION" &
", AND ARE BOUND BEFORE BEING SUBSTITUTED FOR " &
"THE CORRESPONDING GENERIC FORMAL PARAMETERS IN " &
"THE SPECIFICATION AND BODY TEMPLATES. " &
"SEE AI-00365/05-BI-WJ.");
FIRST_BLOCK:
DECLARE
M1 : MONTH_TYPE := MAY;
M2 : MONTH_TYPE := JUN;
PACKAGE NEW_TEST_ACTUAL_PARAMETERS IS
NEW TEST_ACTUAL_PARAMETERS (
NATURALLY => INC,
FIRST_RECORD => TODAY,
SECOND_RECORD => CHRISTMAS,
RECORD_POINTER => DATE_ACCESS,
POINTER => SECOND_DATE,
ARRAY_TYPE => DUE_DATES,
THIS_ARRAY => REPORT_DATES,
FIRST_ARRAY_ELEMENT => REPORT_DATES (M1),
SECOND_ARRAY_ELEMENT => REPORT_DATES (M2),
INDEX_ELEMENT => THIS_MONTH,
POINTER_TEST => THIRD_DATE.ALL,
ANOTHER_POINTER_TEST => FOURTH_DATE.ALL);
BEGIN -- FIRST_BLOCK
REPORT.COMMENT ("ENTERING FIRST BLOCK");
NEW_TEST_ACTUAL_PARAMETERS.EVALUATE_FUNCTION;
NEW_TEST_ACTUAL_PARAMETERS.CHECK_SCALAR;
M1 := SEP;
M2 := OCT;
-- NEW_TEST_ACTUAL_PARAMETERS SHOULD USE THE PREVIOUS
-- VALUES OF MAY AND JUN.
NEW_TEST_ACTUAL_PARAMETERS.CHECK_ARRAY;
NEW_TEST_ACTUAL_PARAMETERS.CHECK_ARRAY_ELEMENTS;
NEW_TEST_ACTUAL_PARAMETERS.CHECK_ACCESS;
NEW_TEST_ACTUAL_PARAMETERS.CHECK_RECORDS;
NEW_TEST_ACTUAL_PARAMETERS.CHECK_POINTERS;
END FIRST_BLOCK;
SECOND_BLOCK:
DECLARE
SAVE_THIRD_DATE : DATE_ACCESS := THIRD_DATE;
SAVE_FOURTH_DATE : DATE_ACCESS := FOURTH_DATE;
PACKAGE NEW_TEST_ACTUAL_PARAMETERS IS
NEW TEST_ACTUAL_PARAMETERS (
NATURALLY => INC,
FIRST_RECORD => TODAY,
SECOND_RECORD => CHRISTMAS,
RECORD_POINTER => DATE_ACCESS,
POINTER => SECOND_DATE,
ARRAY_TYPE => DUE_DATES,
THIS_ARRAY => REPORT_DATES,
FIRST_ARRAY_ELEMENT => REPORT_DATES (MAY),
SECOND_ARRAY_ELEMENT => REPORT_DATES (JUN),
INDEX_ELEMENT => THIS_MONTH,
POINTER_TEST => THIRD_DATE.ALL,
ANOTHER_POINTER_TEST => FOURTH_DATE.ALL);
BEGIN -- SECOND_BLOCK
REPORT.COMMENT ("ENTERING SECOND BLOCK");
NEW_TEST_ACTUAL_PARAMETERS.EVALUATE_FUNCTION;
NEW_TEST_ACTUAL_PARAMETERS.CHECK_SCALAR;
NEW_TEST_ACTUAL_PARAMETERS.CHECK_ARRAY;
NEW_TEST_ACTUAL_PARAMETERS.CHECK_ARRAY_ELEMENTS;
NEW_TEST_ACTUAL_PARAMETERS.CHECK_ACCESS;
NEW_TEST_ACTUAL_PARAMETERS.CHECK_RECORDS;
THIRD_DATE := NEW DATE'(JUL, 13, 1951);
FOURTH_DATE := NEW DATE'(JUL, 4, 1976);
NEW_TEST_ACTUAL_PARAMETERS.CHECK_POINTERS;
THIRD_DATE := SAVE_THIRD_DATE;
FOURTH_DATE := SAVE_FOURTH_DATE;
END SECOND_BLOCK;
REPORT.RESULT;
END CC3007B;
|
GLOBAL {
-- # define yySetPosition Attribute.Position.Line := yyLineCount; \
-- Attribute.Position.Column := yyChBufferIndex - yyLineStart - TokenLength;
-- Int_Io.Put (Text_Io.Standard_Output, yyOffset (TokenIndex));
-- Text_Io.New_Line (Text_Io.Standard_Output);
package Int_Io is new Text_Io.Integer_IO (Integer); use Int_Io;
procedure ErrorAttribute (Token: Integer; Attribute: out tScanAttribute) is
begin
null;
end ErrorAttribute;
}
DEFAULT {
WritePosition (Text_Io.Standard_Output, Attribute.Position);
Text_Io.Put (Text_Io.Standard_Output, ": illegal character: ");
yyEcho;
Text_Io.New_Line (Text_Io.Standard_Output);
}
EOF {
if yyStartState = Comment then
WritePosition (Text_Io.Standard_Output, Attribute.Position);
Text_Io.Put (Text_Io.Standard_Output, ": unclosed comment");
Text_Io.New_Line (Text_Io.Standard_Output);
end if;
}
DEFINE
digit = {0-9} .
letter = {a-z A-Z} .
CmtCh = - {*(\t\n} .
START Comment
RULE
#STD, Comment# "(*" :- {yyPush (Comment);}
#Comment# "*)" :- {yyPop;}
#Comment# "(" | "*" | CmtCh + :- {}
#STD# digit + ,
#STD# digit + / ".." : {return 1;}
#STD# {0-7} + B : {return 2;}
#STD# {0-7} + C : {return 3;}
#STD# digit {0-9 A-F} * H : {return 4;}
#STD# digit + "." digit * (E {+\-} ? digit +) ? : {return 5;}
#STD# ' - {\n'} * ' |
\" - {\n"} * \" : {return 6;}
#STD# "#" : {return 7;}
#STD# "&" : {return 8;}
#STD# "(" : {return 9;}
#STD# ")" : {return 10;}
#STD# "*" : {return 11;}
#STD# "+" : {return 12;}
#STD# "," : {return 13;}
#STD# "-" : {return 14;}
#STD# "." : {return 15;}
#STD# ".." : {return 16;}
#STD# "/" : {return 17;}
#STD# ":" : {return 18;}
#STD# ":=" : {return 19;}
#STD# ";" : {return 20;}
#STD# "<" : {return 21;}
#STD# "<=" : {return 22;}
#STD# "<>" : {return 23;}
#STD# "=" : {return 24;}
#STD# ">" : {return 25;}
#STD# ">=" : {return 26;}
#STD# "[" : {return 27;}
#STD# "]" : {return 28;}
#STD# "^" : {return 29;}
#STD# "{" : {return 30;}
#STD# "|" : {return 31;}
#STD# "}" : {return 32;}
#STD# "~" : {return 33;}
#STD# AND : {return 34;}
#STD# ARRAY : {return 35;}
#STD# BEGIN : {return 36;}
#STD# BY : {return 37;}
#STD# CASE : {return 38;}
#STD# CONST : {return 39;}
#STD# DEFINITION : {return 40;}
#STD# DIV : {return 41;}
#STD# DO : {return 42;}
#STD# ELSE : {return 43;}
#STD# ELSIF : {return 44;}
#STD# END : {return 45;}
#STD# EXIT : {return 46;}
#STD# EXPORT : {return 47;}
#STD# FOR : {return 48;}
#STD# FROM : {return 49;}
#STD# IF : {return 50;}
#STD# IMPLEMENTATION : {return 51;}
#STD# IMPORT : {return 52;}
#STD# IN : {return 53;}
#STD# LOOP : {return 54;}
#STD# MOD : {return 55;}
#STD# MODULE : {return 56;}
#STD# \NOT : {return 57;}
#STD# OF : {return 58;}
#STD# OR : {return 59;}
#STD# POINTER : {return 60;}
#STD# PROCEDURE : {return 61;}
#STD# QUALIFIED : {return 62;}
#STD# RECORD : {return 63;}
#STD# REPEAT : {return 64;}
#STD# RETURN : {return 65;}
#STD# SET : {return 66;}
#STD# THEN : {return 67;}
#STD# TO : {return 68;}
#STD# TYPE : {return 69;}
#STD# UNTIL : {return 70;}
#STD# VAR : {return 71;}
#STD# WHILE : {return 72;}
#STD# WITH : {return 73;}
#STD# letter (letter | digit) * : {return 74;}
|
-----------------------------------------------------------------------
-- Jason.Tickets.Models -- Jason.Tickets.Models
-----------------------------------------------------------------------
-- File generated by ada-gen DO NOT MODIFY
-- Template used: templates/model/package-body.xhtml
-- Ada Generator: https://ada-gen.googlecode.com/svn/trunk Revision 1095
-----------------------------------------------------------------------
-- Copyright (C) 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.Unchecked_Deallocation;
with Util.Beans.Objects.Time;
with ASF.Events.Faces.Actions;
package body Jason.Tickets.Models is
use type ADO.Objects.Object_Record_Access;
use type ADO.Objects.Object_Ref;
pragma Warnings (Off, "formal parameter * is not referenced");
function Ticket_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => TICKET_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Ticket_Key;
function Ticket_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => TICKET_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Ticket_Key;
function "=" (Left, Right : Ticket_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Ticket_Ref'Class;
Impl : out Ticket_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Ticket_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
procedure Allocate (Object : in out Ticket_Ref) is
Impl : Ticket_Access;
begin
Impl := new Ticket_Impl;
Impl.Version := 0;
Impl.Ident := 0;
Impl.Create_Date := ADO.DEFAULT_TIME;
Impl.Priority := 0;
Impl.Status := Jason.Tickets.Models.Status_Type'First;
Impl.Update_Date := ADO.DEFAULT_TIME;
Impl.Ticket_Type := Jason.Tickets.Models.Ticket_Type'First;
Impl.Duration := 0;
Impl.Progress := 0;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Ticket
-- ----------------------------------------
procedure Set_Id (Object : in out Ticket_Ref;
Value : in ADO.Identifier) is
Impl : Ticket_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value);
end Set_Id;
function Get_Id (Object : in Ticket_Ref)
return ADO.Identifier is
Impl : constant Ticket_Access
:= Ticket_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
function Get_Version (Object : in Ticket_Ref)
return Integer is
Impl : constant Ticket_Access
:= Ticket_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Version;
end Get_Version;
procedure Set_Summary (Object : in out Ticket_Ref;
Value : in String) is
Impl : Ticket_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 3, Impl.Summary, Value);
end Set_Summary;
procedure Set_Summary (Object : in out Ticket_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Ticket_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 3, Impl.Summary, Value);
end Set_Summary;
function Get_Summary (Object : in Ticket_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Summary);
end Get_Summary;
function Get_Summary (Object : in Ticket_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Ticket_Access
:= Ticket_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Summary;
end Get_Summary;
procedure Set_Ident (Object : in out Ticket_Ref;
Value : in Integer) is
Impl : Ticket_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Integer (Impl.all, 4, Impl.Ident, Value);
end Set_Ident;
function Get_Ident (Object : in Ticket_Ref)
return Integer is
Impl : constant Ticket_Access
:= Ticket_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Ident;
end Get_Ident;
procedure Set_Create_Date (Object : in out Ticket_Ref;
Value : in Ada.Calendar.Time) is
Impl : Ticket_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Time (Impl.all, 5, Impl.Create_Date, Value);
end Set_Create_Date;
function Get_Create_Date (Object : in Ticket_Ref)
return Ada.Calendar.Time is
Impl : constant Ticket_Access
:= Ticket_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Create_Date;
end Get_Create_Date;
procedure Set_Priority (Object : in out Ticket_Ref;
Value : in Integer) is
Impl : Ticket_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Integer (Impl.all, 6, Impl.Priority, Value);
end Set_Priority;
function Get_Priority (Object : in Ticket_Ref)
return Integer is
Impl : constant Ticket_Access
:= Ticket_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Priority;
end Get_Priority;
procedure Set_Status (Object : in out Ticket_Ref;
Value : in Jason.Tickets.Models.Status_Type) is
procedure Set_Field_Enum is
new ADO.Objects.Set_Field_Operation (Status_Type);
Impl : Ticket_Access;
begin
Set_Field (Object, Impl);
Set_Field_Enum (Impl.all, 7, Impl.Status, Value);
end Set_Status;
function Get_Status (Object : in Ticket_Ref)
return Jason.Tickets.Models.Status_Type is
Impl : constant Ticket_Access
:= Ticket_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Status;
end Get_Status;
procedure Set_Description (Object : in out Ticket_Ref;
Value : in String) is
Impl : Ticket_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 8, Impl.Description, Value);
end Set_Description;
procedure Set_Description (Object : in out Ticket_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Ticket_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 8, Impl.Description, Value);
end Set_Description;
function Get_Description (Object : in Ticket_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Description);
end Get_Description;
function Get_Description (Object : in Ticket_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Ticket_Access
:= Ticket_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Description;
end Get_Description;
procedure Set_Update_Date (Object : in out Ticket_Ref;
Value : in Ada.Calendar.Time) is
Impl : Ticket_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Time (Impl.all, 9, Impl.Update_Date, Value);
end Set_Update_Date;
function Get_Update_Date (Object : in Ticket_Ref)
return Ada.Calendar.Time is
Impl : constant Ticket_Access
:= Ticket_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Update_Date;
end Get_Update_Date;
procedure Set_Ticket_Type (Object : in out Ticket_Ref;
Value : in Jason.Tickets.Models.Ticket_Type) is
procedure Set_Field_Enum is
new ADO.Objects.Set_Field_Operation (Ticket_Type);
Impl : Ticket_Access;
begin
Set_Field (Object, Impl);
Set_Field_Enum (Impl.all, 10, Impl.Ticket_Type, Value);
end Set_Ticket_Type;
function Get_Ticket_Type (Object : in Ticket_Ref)
return Jason.Tickets.Models.Ticket_Type is
Impl : constant Ticket_Access
:= Ticket_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Ticket_Type;
end Get_Ticket_Type;
procedure Set_Duration (Object : in out Ticket_Ref;
Value : in Integer) is
Impl : Ticket_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Integer (Impl.all, 11, Impl.Duration, Value);
end Set_Duration;
function Get_Duration (Object : in Ticket_Ref)
return Integer is
Impl : constant Ticket_Access
:= Ticket_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Duration;
end Get_Duration;
procedure Set_Progress (Object : in out Ticket_Ref;
Value : in Integer) is
Impl : Ticket_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Integer (Impl.all, 12, Impl.Progress, Value);
end Set_Progress;
function Get_Progress (Object : in Ticket_Ref)
return Integer is
Impl : constant Ticket_Access
:= Ticket_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Progress;
end Get_Progress;
procedure Set_Project (Object : in out Ticket_Ref;
Value : in Jason.Projects.Models.Project_Ref'Class) is
Impl : Ticket_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 13, Impl.Project, Value);
end Set_Project;
function Get_Project (Object : in Ticket_Ref)
return Jason.Projects.Models.Project_Ref'Class is
Impl : constant Ticket_Access
:= Ticket_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Project;
end Get_Project;
procedure Set_Creator (Object : in out Ticket_Ref;
Value : in AWA.Users.Models.User_Ref'Class) is
Impl : Ticket_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 14, Impl.Creator, Value);
end Set_Creator;
function Get_Creator (Object : in Ticket_Ref)
return AWA.Users.Models.User_Ref'Class is
Impl : constant Ticket_Access
:= Ticket_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Creator;
end Get_Creator;
-- Copy of the object.
procedure Copy (Object : in Ticket_Ref;
Into : in out Ticket_Ref) is
Result : Ticket_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Ticket_Access
:= Ticket_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Ticket_Access
:= new Ticket_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Version := Impl.Version;
Copy.Summary := Impl.Summary;
Copy.Ident := Impl.Ident;
Copy.Create_Date := Impl.Create_Date;
Copy.Priority := Impl.Priority;
Copy.Status := Impl.Status;
Copy.Description := Impl.Description;
Copy.Update_Date := Impl.Update_Date;
Copy.Ticket_Type := Impl.Ticket_Type;
Copy.Duration := Impl.Duration;
Copy.Progress := Impl.Progress;
Copy.Project := Impl.Project;
Copy.Creator := Impl.Creator;
end;
end if;
Into := Result;
end Copy;
procedure Find (Object : in out Ticket_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Ticket_Access := new Ticket_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Ticket_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Ticket_Access := new Ticket_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Ticket_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Ticket_Access := new Ticket_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
procedure Save (Object : in out Ticket_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Ticket_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
procedure Delete (Object : in out Ticket_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
procedure Destroy (Object : access Ticket_Impl) is
type Ticket_Impl_Ptr is access all Ticket_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Ticket_Impl, Ticket_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Ticket_Impl_Ptr := Ticket_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
procedure Find (Object : in out Ticket_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, TICKET_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Ticket_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
procedure Save (Object : in out Ticket_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (TICKET_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_1_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (3) then
Stmt.Save_Field (Name => COL_2_1_NAME, -- summary
Value => Object.Summary);
Object.Clear_Modified (3);
end if;
if Object.Is_Modified (4) then
Stmt.Save_Field (Name => COL_3_1_NAME, -- ident
Value => Object.Ident);
Object.Clear_Modified (4);
end if;
if Object.Is_Modified (5) then
Stmt.Save_Field (Name => COL_4_1_NAME, -- create_date
Value => Object.Create_Date);
Object.Clear_Modified (5);
end if;
if Object.Is_Modified (6) then
Stmt.Save_Field (Name => COL_5_1_NAME, -- priority
Value => Object.Priority);
Object.Clear_Modified (6);
end if;
if Object.Is_Modified (7) then
Stmt.Save_Field (Name => COL_6_1_NAME, -- status
Value => Integer (Status_Type'Pos (Object.Status)));
Object.Clear_Modified (7);
end if;
if Object.Is_Modified (8) then
Stmt.Save_Field (Name => COL_7_1_NAME, -- description
Value => Object.Description);
Object.Clear_Modified (8);
end if;
if Object.Is_Modified (9) then
Stmt.Save_Field (Name => COL_8_1_NAME, -- update_date
Value => Object.Update_Date);
Object.Clear_Modified (9);
end if;
if Object.Is_Modified (10) then
Stmt.Save_Field (Name => COL_9_1_NAME, -- ticket_type
Value => Integer (Ticket_Type'Pos (Object.Ticket_Type)));
Object.Clear_Modified (10);
end if;
if Object.Is_Modified (11) then
Stmt.Save_Field (Name => COL_10_1_NAME, -- duration
Value => Object.Duration);
Object.Clear_Modified (11);
end if;
if Object.Is_Modified (12) then
Stmt.Save_Field (Name => COL_11_1_NAME, -- progress
Value => Object.Progress);
Object.Clear_Modified (12);
end if;
if Object.Is_Modified (13) then
Stmt.Save_Field (Name => COL_12_1_NAME, -- project_id
Value => Object.Project);
Object.Clear_Modified (13);
end if;
if Object.Is_Modified (14) then
Stmt.Save_Field (Name => COL_13_1_NAME, -- creator_id
Value => Object.Creator);
Object.Clear_Modified (14);
end if;
if Stmt.Has_Save_Fields then
Object.Version := Object.Version + 1;
Stmt.Save_Field (Name => "version",
Value => Object.Version);
Stmt.Set_Filter (Filter => "id = ? and version = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Add_Param (Value => Object.Version - 1);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
else
raise ADO.Objects.LAZY_LOCK;
end if;
end if;
end;
end if;
end Save;
procedure Create (Object : in out Ticket_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (TICKET_DEF'Access);
Result : Integer;
begin
Object.Version := 1;
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_0_1_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_1_1_NAME, -- version
Value => Object.Version);
Query.Save_Field (Name => COL_2_1_NAME, -- summary
Value => Object.Summary);
Query.Save_Field (Name => COL_3_1_NAME, -- ident
Value => Object.Ident);
Query.Save_Field (Name => COL_4_1_NAME, -- create_date
Value => Object.Create_Date);
Query.Save_Field (Name => COL_5_1_NAME, -- priority
Value => Object.Priority);
Query.Save_Field (Name => COL_6_1_NAME, -- status
Value => Integer (Status_Type'Pos (Object.Status)));
Query.Save_Field (Name => COL_7_1_NAME, -- description
Value => Object.Description);
Query.Save_Field (Name => COL_8_1_NAME, -- update_date
Value => Object.Update_Date);
Query.Save_Field (Name => COL_9_1_NAME, -- ticket_type
Value => Integer (Ticket_Type'Pos (Object.Ticket_Type)));
Query.Save_Field (Name => COL_10_1_NAME, -- duration
Value => Object.Duration);
Query.Save_Field (Name => COL_11_1_NAME, -- progress
Value => Object.Progress);
Query.Save_Field (Name => COL_12_1_NAME, -- project_id
Value => Object.Project);
Query.Save_Field (Name => COL_13_1_NAME, -- creator_id
Value => Object.Creator);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
procedure Delete (Object : in out Ticket_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (TICKET_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Ticket_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Ticket_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Ticket_Impl (Obj.all)'Access;
if Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
elsif Name = "summary" then
return Util.Beans.Objects.To_Object (Impl.Summary);
elsif Name = "ident" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Ident));
elsif Name = "create_date" then
return Util.Beans.Objects.Time.To_Object (Impl.Create_Date);
elsif Name = "priority" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Priority));
elsif Name = "status" then
return Jason.Tickets.Models.Status_Type_Objects.To_Object (Impl.Status);
elsif Name = "description" then
return Util.Beans.Objects.To_Object (Impl.Description);
elsif Name = "update_date" then
return Util.Beans.Objects.Time.To_Object (Impl.Update_Date);
elsif Name = "ticket_type" then
return Jason.Tickets.Models.Ticket_Type_Objects.To_Object (Impl.Ticket_Type);
elsif Name = "duration" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Duration));
elsif Name = "progress" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (Impl.Progress));
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
procedure List (Object : in out Ticket_Vector;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, TICKET_DEF'Access);
begin
Stmt.Execute;
Ticket_Vectors.Clear (Object);
while Stmt.Has_Elements loop
declare
Item : Ticket_Ref;
Impl : constant Ticket_Access := new Ticket_Impl;
begin
Impl.Load (Stmt, Session);
ADO.Objects.Set_Object (Item, Impl.all'Access);
Object.Append (Item);
end;
Stmt.Next;
end loop;
end List;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Ticket_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.Set_Key_Value (Stmt.Get_Identifier (0));
Object.Summary := Stmt.Get_Unbounded_String (2);
Object.Ident := Stmt.Get_Integer (3);
Object.Create_Date := Stmt.Get_Time (4);
Object.Priority := Stmt.Get_Integer (5);
Object.Status := Status_Type'Val (Stmt.Get_Integer (6));
Object.Description := Stmt.Get_Unbounded_String (7);
Object.Update_Date := Stmt.Get_Time (8);
Object.Ticket_Type := Ticket_Type'Val (Stmt.Get_Integer (9));
Object.Duration := Stmt.Get_Integer (10);
Object.Progress := Stmt.Get_Integer (11);
if not Stmt.Is_Null (12) then
Object.Project.Set_Key_Value (Stmt.Get_Identifier (12), Session);
end if;
if not Stmt.Is_Null (13) then
Object.Creator.Set_Key_Value (Stmt.Get_Identifier (13), Session);
end if;
Object.Version := Stmt.Get_Integer (1);
ADO.Objects.Set_Created (Object);
end Load;
function Attribute_Key (Id : in ADO.Identifier) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => ATTRIBUTE_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Attribute_Key;
function Attribute_Key (Id : in String) return ADO.Objects.Object_Key is
Result : ADO.Objects.Object_Key (Of_Type => ADO.Objects.KEY_INTEGER,
Of_Class => ATTRIBUTE_DEF'Access);
begin
ADO.Objects.Set_Value (Result, Id);
return Result;
end Attribute_Key;
function "=" (Left, Right : Attribute_Ref'Class) return Boolean is
begin
return ADO.Objects.Object_Ref'Class (Left) = ADO.Objects.Object_Ref'Class (Right);
end "=";
procedure Set_Field (Object : in out Attribute_Ref'Class;
Impl : out Attribute_Access) is
Result : ADO.Objects.Object_Record_Access;
begin
Object.Prepare_Modify (Result);
Impl := Attribute_Impl (Result.all)'Access;
end Set_Field;
-- Internal method to allocate the Object_Record instance
procedure Allocate (Object : in out Attribute_Ref) is
Impl : Attribute_Access;
begin
Impl := new Attribute_Impl;
Impl.Version := 0;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Allocate;
-- ----------------------------------------
-- Data object: Attribute
-- ----------------------------------------
procedure Set_Id (Object : in out Attribute_Ref;
Value : in ADO.Identifier) is
Impl : Attribute_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Key_Value (Impl.all, 1, Value);
end Set_Id;
function Get_Id (Object : in Attribute_Ref)
return ADO.Identifier is
Impl : constant Attribute_Access
:= Attribute_Impl (Object.Get_Object.all)'Access;
begin
return Impl.Get_Key_Value;
end Get_Id;
procedure Set_Value (Object : in out Attribute_Ref;
Value : in String) is
Impl : Attribute_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_String (Impl.all, 2, Impl.Value, Value);
end Set_Value;
procedure Set_Value (Object : in out Attribute_Ref;
Value : in Ada.Strings.Unbounded.Unbounded_String) is
Impl : Attribute_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Unbounded_String (Impl.all, 2, Impl.Value, Value);
end Set_Value;
function Get_Value (Object : in Attribute_Ref)
return String is
begin
return Ada.Strings.Unbounded.To_String (Object.Get_Value);
end Get_Value;
function Get_Value (Object : in Attribute_Ref)
return Ada.Strings.Unbounded.Unbounded_String is
Impl : constant Attribute_Access
:= Attribute_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Value;
end Get_Value;
function Get_Version (Object : in Attribute_Ref)
return Integer is
Impl : constant Attribute_Access
:= Attribute_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Version;
end Get_Version;
procedure Set_Definition (Object : in out Attribute_Ref;
Value : in Jason.Projects.Models.Attribute_Definition_Ref'Class) is
Impl : Attribute_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 4, Impl.Definition, Value);
end Set_Definition;
function Get_Definition (Object : in Attribute_Ref)
return Jason.Projects.Models.Attribute_Definition_Ref'Class is
Impl : constant Attribute_Access
:= Attribute_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Definition;
end Get_Definition;
procedure Set_Ticket (Object : in out Attribute_Ref;
Value : in Jason.Tickets.Models.Ticket_Ref'Class) is
Impl : Attribute_Access;
begin
Set_Field (Object, Impl);
ADO.Objects.Set_Field_Object (Impl.all, 5, Impl.Ticket, Value);
end Set_Ticket;
function Get_Ticket (Object : in Attribute_Ref)
return Jason.Tickets.Models.Ticket_Ref'Class is
Impl : constant Attribute_Access
:= Attribute_Impl (Object.Get_Load_Object.all)'Access;
begin
return Impl.Ticket;
end Get_Ticket;
-- Copy of the object.
procedure Copy (Object : in Attribute_Ref;
Into : in out Attribute_Ref) is
Result : Attribute_Ref;
begin
if not Object.Is_Null then
declare
Impl : constant Attribute_Access
:= Attribute_Impl (Object.Get_Load_Object.all)'Access;
Copy : constant Attribute_Access
:= new Attribute_Impl;
begin
ADO.Objects.Set_Object (Result, Copy.all'Access);
Copy.Copy (Impl.all);
Copy.Value := Impl.Value;
Copy.Version := Impl.Version;
Copy.Definition := Impl.Definition;
Copy.Ticket := Impl.Ticket;
end;
end if;
Into := Result;
end Copy;
procedure Find (Object : in out Attribute_Ref;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Impl : constant Attribute_Access := new Attribute_Impl;
begin
Impl.Find (Session, Query, Found);
if Found then
ADO.Objects.Set_Object (Object, Impl.all'Access);
else
ADO.Objects.Set_Object (Object, null);
Destroy (Impl);
end if;
end Find;
procedure Load (Object : in out Attribute_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier) is
Impl : constant Attribute_Access := new Attribute_Impl;
Found : Boolean;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
raise ADO.Objects.NOT_FOUND;
end if;
ADO.Objects.Set_Object (Object, Impl.all'Access);
end Load;
procedure Load (Object : in out Attribute_Ref;
Session : in out ADO.Sessions.Session'Class;
Id : in ADO.Identifier;
Found : out Boolean) is
Impl : constant Attribute_Access := new Attribute_Impl;
Query : ADO.SQL.Query;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Impl.Find (Session, Query, Found);
if not Found then
Destroy (Impl);
else
ADO.Objects.Set_Object (Object, Impl.all'Access);
end if;
end Load;
procedure Save (Object : in out Attribute_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl = null then
Impl := new Attribute_Impl;
ADO.Objects.Set_Object (Object, Impl);
end if;
if not ADO.Objects.Is_Created (Impl.all) then
Impl.Create (Session);
else
Impl.Save (Session);
end if;
end Save;
procedure Delete (Object : in out Attribute_Ref;
Session : in out ADO.Sessions.Master_Session'Class) is
Impl : constant ADO.Objects.Object_Record_Access := Object.Get_Object;
begin
if Impl /= null then
Impl.Delete (Session);
end if;
end Delete;
-- --------------------
-- Free the object
-- --------------------
procedure Destroy (Object : access Attribute_Impl) is
type Attribute_Impl_Ptr is access all Attribute_Impl;
procedure Unchecked_Free is new Ada.Unchecked_Deallocation
(Attribute_Impl, Attribute_Impl_Ptr);
pragma Warnings (Off, "*redundant conversion*");
Ptr : Attribute_Impl_Ptr := Attribute_Impl (Object.all)'Access;
pragma Warnings (On, "*redundant conversion*");
begin
Unchecked_Free (Ptr);
end Destroy;
procedure Find (Object : in out Attribute_Impl;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class;
Found : out Boolean) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, ATTRIBUTE_DEF'Access);
begin
Stmt.Execute;
if Stmt.Has_Elements then
Object.Load (Stmt, Session);
Stmt.Next;
Found := not Stmt.Has_Elements;
else
Found := False;
end if;
end Find;
overriding
procedure Load (Object : in out Attribute_Impl;
Session : in out ADO.Sessions.Session'Class) is
Found : Boolean;
Query : ADO.SQL.Query;
Id : constant ADO.Identifier := Object.Get_Key_Value;
begin
Query.Bind_Param (Position => 1, Value => Id);
Query.Set_Filter ("id = ?");
Object.Find (Session, Query, Found);
if not Found then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
procedure Save (Object : in out Attribute_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Update_Statement
:= Session.Create_Statement (ATTRIBUTE_DEF'Access);
begin
if Object.Is_Modified (1) then
Stmt.Save_Field (Name => COL_0_2_NAME, -- id
Value => Object.Get_Key);
Object.Clear_Modified (1);
end if;
if Object.Is_Modified (2) then
Stmt.Save_Field (Name => COL_1_2_NAME, -- value
Value => Object.Value);
Object.Clear_Modified (2);
end if;
if Object.Is_Modified (4) then
Stmt.Save_Field (Name => COL_3_2_NAME, -- definition_id
Value => Object.Definition);
Object.Clear_Modified (4);
end if;
if Object.Is_Modified (5) then
Stmt.Save_Field (Name => COL_4_2_NAME, -- ticket_id
Value => Object.Ticket);
Object.Clear_Modified (5);
end if;
if Stmt.Has_Save_Fields then
Object.Version := Object.Version + 1;
Stmt.Save_Field (Name => "version",
Value => Object.Version);
Stmt.Set_Filter (Filter => "id = ? and version = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Add_Param (Value => Object.Version - 1);
declare
Result : Integer;
begin
Stmt.Execute (Result);
if Result /= 1 then
if Result /= 0 then
raise ADO.Objects.UPDATE_ERROR;
else
raise ADO.Objects.LAZY_LOCK;
end if;
end if;
end;
end if;
end Save;
procedure Create (Object : in out Attribute_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Query : ADO.Statements.Insert_Statement
:= Session.Create_Statement (ATTRIBUTE_DEF'Access);
Result : Integer;
begin
Object.Version := 1;
Session.Allocate (Id => Object);
Query.Save_Field (Name => COL_0_2_NAME, -- id
Value => Object.Get_Key);
Query.Save_Field (Name => COL_1_2_NAME, -- value
Value => Object.Value);
Query.Save_Field (Name => COL_2_2_NAME, -- version
Value => Object.Version);
Query.Save_Field (Name => COL_3_2_NAME, -- definition_id
Value => Object.Definition);
Query.Save_Field (Name => COL_4_2_NAME, -- ticket_id
Value => Object.Ticket);
Query.Execute (Result);
if Result /= 1 then
raise ADO.Objects.INSERT_ERROR;
end if;
ADO.Objects.Set_Created (Object);
end Create;
procedure Delete (Object : in out Attribute_Impl;
Session : in out ADO.Sessions.Master_Session'Class) is
Stmt : ADO.Statements.Delete_Statement
:= Session.Create_Statement (ATTRIBUTE_DEF'Access);
begin
Stmt.Set_Filter (Filter => "id = ?");
Stmt.Add_Param (Value => Object.Get_Key);
Stmt.Execute;
end Delete;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Attribute_Ref;
Name : in String) return Util.Beans.Objects.Object is
Obj : ADO.Objects.Object_Record_Access;
Impl : access Attribute_Impl;
begin
if From.Is_Null then
return Util.Beans.Objects.Null_Object;
end if;
Obj := From.Get_Load_Object;
Impl := Attribute_Impl (Obj.all)'Access;
if Name = "id" then
return ADO.Objects.To_Object (Impl.Get_Key);
elsif Name = "value" then
return Util.Beans.Objects.To_Object (Impl.Value);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
procedure List (Object : in out Attribute_Vector;
Session : in out ADO.Sessions.Session'Class;
Query : in ADO.SQL.Query'Class) is
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Query, ATTRIBUTE_DEF'Access);
begin
Stmt.Execute;
Attribute_Vectors.Clear (Object);
while Stmt.Has_Elements loop
declare
Item : Attribute_Ref;
Impl : constant Attribute_Access := new Attribute_Impl;
begin
Impl.Load (Stmt, Session);
ADO.Objects.Set_Object (Item, Impl.all'Access);
Object.Append (Item);
end;
Stmt.Next;
end loop;
end List;
-- ------------------------------
-- Load the object from current iterator position
-- ------------------------------
procedure Load (Object : in out Attribute_Impl;
Stmt : in out ADO.Statements.Query_Statement'Class;
Session : in out ADO.Sessions.Session'Class) is
begin
Object.Set_Key_Value (Stmt.Get_Identifier (0));
Object.Value := Stmt.Get_Unbounded_String (1);
if not Stmt.Is_Null (3) then
Object.Definition.Set_Key_Value (Stmt.Get_Identifier (3), Session);
end if;
if not Stmt.Is_Null (4) then
Object.Ticket.Set_Key_Value (Stmt.Get_Identifier (4), Session);
end if;
Object.Version := Stmt.Get_Integer (2);
ADO.Objects.Set_Created (Object);
end Load;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in List_Info;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id));
elsif Name = "ident" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Ident));
elsif Name = "summary" then
return Util.Beans.Objects.To_Object (From.Summary);
elsif Name = "priority" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Priority));
elsif Name = "create_date" then
return Util.Beans.Objects.Time.To_Object (From.Create_Date);
elsif Name = "update_date" then
return Util.Beans.Objects.Time.To_Object (From.Update_Date);
elsif Name = "status" then
return Jason.Tickets.Models.Status_Type_Objects.To_Object (From.Status);
elsif Name = "ticket_type" then
return Jason.Tickets.Models.Ticket_Type_Objects.To_Object (From.Ticket_Type);
elsif Name = "duration" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Duration));
elsif Name = "progress" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Progress));
elsif Name = "creator" then
return Util.Beans.Objects.To_Object (From.Creator);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out List_Info;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "id" then
Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "ident" then
Item.Ident := Util.Beans.Objects.To_Integer (Value);
elsif Name = "summary" then
Item.Summary := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "priority" then
Item.Priority := Util.Beans.Objects.To_Integer (Value);
elsif Name = "create_date" then
Item.Create_Date := Util.Beans.Objects.Time.To_Time (Value);
elsif Name = "update_date" then
Item.Update_Date := Util.Beans.Objects.Time.To_Time (Value);
elsif Name = "status" then
Item.Status := Jason.Tickets.Models.Status_Type_Objects.To_Value (Value);
elsif Name = "ticket_type" then
Item.Ticket_Type := Jason.Tickets.Models.Ticket_Type_Objects.To_Value (Value);
elsif Name = "duration" then
Item.Duration := Util.Beans.Objects.To_Integer (Value);
elsif Name = "progress" then
Item.Progress := Util.Beans.Objects.To_Integer (Value);
elsif Name = "creator" then
Item.Creator := Util.Beans.Objects.To_Unbounded_String (Value);
end if;
end Set_Value;
-- --------------------
-- Run the query controlled by <b>Context</b> and append the list in <b>Object</b>.
-- --------------------
procedure List (Object : in out List_Info_List_Bean'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
begin
List (Object.List, Session, Context);
end List;
-- --------------------
-- The list of tickets.
-- --------------------
procedure List (Object : in out List_Info_Vector;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
procedure Read (Into : in out List_Info);
Stmt : ADO.Statements.Query_Statement
:= Session.Create_Statement (Context);
Pos : Positive := 1;
procedure Read (Into : in out List_Info) is
begin
Into.Id := Stmt.Get_Identifier (0);
Into.Ident := Stmt.Get_Integer (1);
Into.Summary := Stmt.Get_Unbounded_String (2);
Into.Priority := Stmt.Get_Integer (3);
Into.Create_Date := Stmt.Get_Time (4);
Into.Update_Date := Stmt.Get_Time (5);
Into.Status := Jason.Tickets.Models.Status_Type'Val (Stmt.Get_Integer (6));
Into.Ticket_Type := Jason.Tickets.Models.Ticket_Type'Val (Stmt.Get_Integer (7));
Into.Duration := Stmt.Get_Integer (8);
Into.Progress := Stmt.Get_Integer (9);
Into.Creator := Stmt.Get_Unbounded_String (10);
end Read;
begin
Stmt.Execute;
List_Info_Vectors.Clear (Object);
while Stmt.Has_Elements loop
Object.Insert_Space (Before => Pos);
Object.Update_Element (Index => Pos, Process => Read'Access);
Pos := Pos + 1;
Stmt.Next;
end loop;
end List;
procedure Op_Load (Bean : in out Ticket_Info;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load (Bean : in out Ticket_Info;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Ticket_Info'Class (Bean).Load (Outcome);
end Op_Load;
package Binding_Ticket_Info_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Ticket_Info,
Method => Op_Load,
Name => "load");
Binding_Ticket_Info_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Ticket_Info_1.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Ticket_Info)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Ticket_Info_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Ticket_Info;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Id));
elsif Name = "ident" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Ident));
elsif Name = "summary" then
return Util.Beans.Objects.To_Object (From.Summary);
elsif Name = "description" then
return Util.Beans.Objects.To_Object (From.Description);
elsif Name = "priority" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Priority));
elsif Name = "create_date" then
return Util.Beans.Objects.Time.To_Object (From.Create_Date);
elsif Name = "update_date" then
return Util.Beans.Objects.Time.To_Object (From.Update_Date);
elsif Name = "status" then
return Jason.Tickets.Models.Status_Type_Objects.To_Object (From.Status);
elsif Name = "project_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Project_Id));
elsif Name = "project_name" then
return Util.Beans.Objects.To_Object (From.Project_Name);
elsif Name = "creator" then
return Util.Beans.Objects.To_Object (From.Creator);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Ticket_Info;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "id" then
Item.Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "ident" then
Item.Ident := Util.Beans.Objects.To_Integer (Value);
elsif Name = "summary" then
Item.Summary := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "description" then
Item.Description := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "priority" then
Item.Priority := Util.Beans.Objects.To_Integer (Value);
elsif Name = "create_date" then
Item.Create_Date := Util.Beans.Objects.Time.To_Time (Value);
elsif Name = "update_date" then
Item.Update_Date := Util.Beans.Objects.Time.To_Time (Value);
elsif Name = "status" then
Item.Status := Jason.Tickets.Models.Status_Type_Objects.To_Value (Value);
elsif Name = "project_id" then
Item.Project_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "project_name" then
Item.Project_Name := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "creator" then
Item.Creator := Util.Beans.Objects.To_Unbounded_String (Value);
end if;
end Set_Value;
-- --------------------
-- Read in the object the data from the query result and prepare to read the next row.
-- If there is no row, raise the ADO.NOT_FOUND exception.
-- --------------------
procedure Read (Into : in out Ticket_Info;
Stmt : in out ADO.Statements.Query_Statement'Class) is
begin
if not Stmt.Has_Elements then
raise ADO.Objects.NOT_FOUND;
end if;
Into.Id := Stmt.Get_Identifier (0);
Into.Ident := Stmt.Get_Integer (1);
Into.Summary := Stmt.Get_Unbounded_String (2);
Into.Description := Stmt.Get_Unbounded_String (3);
Into.Priority := Stmt.Get_Integer (4);
Into.Create_Date := Stmt.Get_Time (5);
Into.Update_Date := Stmt.Get_Time (6);
Into.Status := Jason.Tickets.Models.Status_Type'Val (Stmt.Get_Integer (7));
Into.Project_Id := Stmt.Get_Identifier (8);
Into.Project_Name := Stmt.Get_Unbounded_String (9);
Into.Creator := Stmt.Get_Unbounded_String (10);
Stmt.Next;
end Read;
-- --------------------
-- Run the query controlled by <b>Context</b> and load the result in <b>Object</b>.
-- --------------------
procedure Load (Object : in out Ticket_Info'Class;
Session : in out ADO.Sessions.Session'Class;
Context : in out ADO.Queries.Context'Class) is
Stmt : ADO.Statements.Query_Statement := Session.Create_Statement (Context);
begin
Stmt.Execute;
Read (Object, Stmt);
if Stmt.Has_Elements then
raise ADO.Objects.NOT_FOUND;
end if;
end Load;
procedure Op_Load (Bean : in out Ticket_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load (Bean : in out Ticket_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Ticket_Bean'Class (Bean).Load (Outcome);
end Op_Load;
package Binding_Ticket_Bean_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Ticket_Bean,
Method => Op_Load,
Name => "load");
procedure Op_Create (Bean : in out Ticket_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Create (Bean : in out Ticket_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Ticket_Bean'Class (Bean).Create (Outcome);
end Op_Create;
package Binding_Ticket_Bean_2 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Ticket_Bean,
Method => Op_Create,
Name => "create");
procedure Op_Save (Bean : in out Ticket_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Save (Bean : in out Ticket_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Ticket_Bean'Class (Bean).Save (Outcome);
end Op_Save;
package Binding_Ticket_Bean_3 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Ticket_Bean,
Method => Op_Save,
Name => "save");
procedure Op_Save_Status (Bean : in out Ticket_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Save_Status (Bean : in out Ticket_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Ticket_Bean'Class (Bean).Save_Status (Outcome);
end Op_Save_Status;
package Binding_Ticket_Bean_4 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Ticket_Bean,
Method => Op_Save_Status,
Name => "save_status");
Binding_Ticket_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Ticket_Bean_1.Proxy'Access,
2 => Binding_Ticket_Bean_2.Proxy'Access,
3 => Binding_Ticket_Bean_3.Proxy'Access,
4 => Binding_Ticket_Bean_4.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Ticket_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Ticket_Bean_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Ticket_Bean;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "comment" then
return Util.Beans.Objects.To_Object (From.Comment);
end if;
return Jason.Tickets.Models.Ticket_Ref (From).Get_Value (Name);
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Ticket_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "comment" then
Item.Comment := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "summary" then
Item.Set_Summary (Util.Beans.Objects.To_String (Value));
elsif Name = "ident" then
Item.Set_Ident (Util.Beans.Objects.To_Integer (Value));
elsif Name = "create_date" then
Item.Set_Create_Date (Util.Beans.Objects.Time.To_Time (Value));
elsif Name = "priority" then
Item.Set_Priority (Util.Beans.Objects.To_Integer (Value));
elsif Name = "status" then
Item.Set_Status (Status_Type_Objects.To_Value (Value));
elsif Name = "description" then
Item.Set_Description (Util.Beans.Objects.To_String (Value));
elsif Name = "update_date" then
Item.Set_Update_Date (Util.Beans.Objects.Time.To_Time (Value));
elsif Name = "ticket_type" then
Item.Set_Ticket_Type (Ticket_Type_Objects.To_Value (Value));
elsif Name = "duration" then
Item.Set_Duration (Util.Beans.Objects.To_Integer (Value));
elsif Name = "progress" then
Item.Set_Progress (Util.Beans.Objects.To_Integer (Value));
end if;
end Set_Value;
procedure Op_Load (Bean : in out Ticket_List_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load (Bean : in out Ticket_List_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Ticket_List_Bean'Class (Bean).Load (Outcome);
end Op_Load;
package Binding_Ticket_List_Bean_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Ticket_List_Bean,
Method => Op_Load,
Name => "load");
Binding_Ticket_List_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Ticket_List_Bean_1.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Ticket_List_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Ticket_List_Bean_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Ticket_List_Bean;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "project_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Project_Id));
elsif Name = "page" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page));
elsif Name = "count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Count));
elsif Name = "tag" then
return Util.Beans.Objects.To_Object (From.Tag);
elsif Name = "page_size" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Page_Size));
elsif Name = "sort" then
return Util.Beans.Objects.To_Object (From.Sort);
elsif Name = "status" then
return Status_Type_Objects.To_Object (From.Status);
elsif Name = "priority" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Priority));
elsif Name = "ticket_kind" then
return Ticket_Type_Objects.To_Object (From.Ticket_Kind);
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Ticket_List_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "project_id" then
Item.Project_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
elsif Name = "page" then
Item.Page := Util.Beans.Objects.To_Integer (Value);
elsif Name = "count" then
Item.Count := Util.Beans.Objects.To_Integer (Value);
elsif Name = "tag" then
Item.Tag := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "page_size" then
Item.Page_Size := Util.Beans.Objects.To_Integer (Value);
elsif Name = "sort" then
Item.Sort := Util.Beans.Objects.To_Unbounded_String (Value);
elsif Name = "status" then
Item.Status := Status_Type_Objects.To_Value (Value);
elsif Name = "priority" then
Item.Priority := Util.Beans.Objects.To_Integer (Value);
elsif Name = "ticket_kind" then
Item.Ticket_Kind := Ticket_Type_Objects.To_Value (Value);
end if;
end Set_Value;
procedure Op_Load (Bean : in out Ticket_Info_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load (Bean : in out Ticket_Info_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Ticket_Info_Bean'Class (Bean).Load (Outcome);
end Op_Load;
package Binding_Ticket_Info_Bean_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Ticket_Info_Bean,
Method => Op_Load,
Name => "load");
Binding_Ticket_Info_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Ticket_Info_Bean_1.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Ticket_Info_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Ticket_Info_Bean_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Ticket_Info_Bean;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "ticket_id" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Ticket_Id));
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Ticket_Info_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "ticket_id" then
Item.Ticket_Id := ADO.Identifier (Util.Beans.Objects.To_Long_Long_Integer (Value));
end if;
end Set_Value;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Stat_Bean;
Name : in String) return Util.Beans.Objects.Object is
begin
if Name = "kind" then
return Ticket_Type_Objects.To_Object (From.Kind);
elsif Name = "priority" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Priority));
elsif Name = "count" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Count));
elsif Name = "time" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Time));
elsif Name = "remain" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Remain));
elsif Name = "done" then
return Util.Beans.Objects.To_Object (Long_Long_Integer (From.Done));
end if;
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Stat_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
if Name = "kind" then
Item.Kind := Ticket_Type_Objects.To_Value (Value);
elsif Name = "priority" then
Item.Priority := Util.Beans.Objects.To_Integer (Value);
elsif Name = "count" then
Item.Count := Util.Beans.Objects.To_Integer (Value);
elsif Name = "time" then
Item.Time := Util.Beans.Objects.To_Integer (Value);
elsif Name = "remain" then
Item.Remain := Util.Beans.Objects.To_Integer (Value);
elsif Name = "done" then
Item.Done := Util.Beans.Objects.To_Integer (Value);
end if;
end Set_Value;
procedure Op_Load (Bean : in out Report_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String);
procedure Op_Load (Bean : in out Report_Bean;
Outcome : in out Ada.Strings.Unbounded.Unbounded_String) is
begin
Report_Bean'Class (Bean).Load (Outcome);
end Op_Load;
package Binding_Report_Bean_1 is
new ASF.Events.Faces.Actions.Action_Method.Bind (Bean => Report_Bean,
Method => Op_Load,
Name => "load");
Binding_Report_Bean_Array : aliased constant Util.Beans.Methods.Method_Binding_Array
:= (1 => Binding_Report_Bean_1.Proxy'Access
);
-- ------------------------------
-- This bean provides some methods that can be used in a Method_Expression.
-- ------------------------------
overriding
function Get_Method_Bindings (From : in Report_Bean)
return Util.Beans.Methods.Method_Binding_Array_Access is
pragma Unreferenced (From);
begin
return Binding_Report_Bean_Array'Access;
end Get_Method_Bindings;
-- ------------------------------
-- Get the bean attribute identified by the name.
-- ------------------------------
overriding
function Get_Value (From : in Report_Bean;
Name : in String) return Util.Beans.Objects.Object is
begin
return Util.Beans.Objects.Null_Object;
end Get_Value;
-- ------------------------------
-- Set the value identified by the name
-- ------------------------------
overriding
procedure Set_Value (Item : in out Report_Bean;
Name : in String;
Value : in Util.Beans.Objects.Object) is
begin
null;
end Set_Value;
end Jason.Tickets.Models;
|
-- This test is check control data out with a fake class request
with USB_Testing; use USB_Testing;
with USB_Testing.UDC_Stub; use USB_Testing.UDC_Stub;
with USB_Testing.UDC_Scenarios;
with HAL; use HAL;
with USB; use USB;
with USB.Device; use USB.Device;
with USB.HAL.Device; use USB.HAL.Device;
procedure Main is
Scenario : aliased constant UDC_Stub.Stub_Scenario :=
UDC_Scenarios.Enumeration (Verbose => False) &
Stub_Scenario'(1 => (Kind => Set_Verbose, Verbose => True),
2 => (Kind => UDC_Event_E,
Evt => (Kind => Setup_Request,
-- Use an invalid request to trigger a stall
-- after the data transfer.
Req => ((Dev, 0, Class, Host_To_Device),
42, 0, 0, 16),
Req_EP => 0)),
3 => (Kind => UDC_Event_E,
Evt => (Kind => Transfer_Complete,
EP => (0, EP_Out),
BCNT => 16)
)
);
RX_Data : aliased constant UInt8_Array := (1 .. 16 => 42);
begin
USB_Testing.UDC_Scenarios.Basic_UDC_Test (Scenario, RX_Data);
end Main;
|
package body Ada.Containers.Weak_Access_Holders is
procedure Add_Weak (Item : Weak_Holder_Access) is
begin
Item.Previous := null;
Item.Next := Item.Data.Weak_List;
if Item.Next /= null then
Item.Next.Previous := Item;
end if;
Item.Data.Weak_List := Item;
end Add_Weak;
procedure Remove_Weak (Item : Weak_Holder_Access) is
begin
if Item.Previous /= null then
pragma Assert (Item.Previous.Next = Item);
Item.Previous.Next := Item.Next;
else
pragma Assert (Item.Data.Weak_List = Item);
Item.Data.Weak_List := Item.Next;
end if;
if Item.Next /= null then
pragma Assert (Item.Next.Previous = Item);
Item.Next.Previous := Item.Previous;
end if;
end Remove_Weak;
procedure Clear_Weaks (
List : in out Data;
Null_Data : not null Data_Access)
is
I : Weak_Holder_Access := List.Weak_List;
begin
while I /= null loop
declare
Next : constant Weak_Holder_Access := I.Next;
begin
I.Data := Null_Data;
I.Previous := null;
I.Next := null;
I := Next;
end;
end loop;
end Clear_Weaks;
end Ada.Containers.Weak_Access_Holders;
|
-------------------------------------------------------------------------------
-- LSE -- L-System Editor
-- Author: Heziode
--
-- License:
-- MIT License
--
-- Copyright (c) 2018 Quentin Dauprat (Heziode) <Heziode@protonmail.com>
--
-- 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.Containers.Hashed_Maps;
with LSE.Utils.Angle;
with LSE.Model.Grammar.Symbol_Utils;
with LSE.Model.L_System.Growth_Rule;
use Ada.Containers;
use LSE.Utils.Angle;
use LSE.Model.Grammar.Symbol_Utils.P_List;
use LSE.Model.Grammar.Symbol_Utils.Ptr;
-- @description
-- This package provides a factory for making a L-System.
--
package LSE.Model.L_System.Factory is
-- Make an axiom
-- @param Value String to convert to a list of Symbol
-- @return Return the list created
function Make_Axiom (Value : String)
return LSE.Model.Grammar.Symbol_Utils.P_List.List;
-- Make an angle
-- @param Value String to convert to an angle
-- @return Return the angle created
function Make_Angle (Value : String) return LSE.Utils.Angle.Angle;
-- Make a growth rule
-- @param Value String to convert to a growth rule
-- @return Return the growth rule created
function Make_Rule (Head : Character; Rule : String)
return Growth_Rule.Instance;
private
-- Get hash of a character
-- @param Key Character to get hash
-- @return Return the hash corresponding to character
function ID_Hashed (Key : Character) return Hash_Type;
package Know_Symbol is new Ada.Containers.Hashed_Maps
(Key_Type => Character,
Element_Type => Holder,
Hash => ID_Hashed,
Equivalent_Keys => "=");
-- List of static symbol (optimized to prevent RAM overflow)
Symbol_List : Know_Symbol.Map;
-- Get the symbol corresponding to the character
-- @param Key Character used to get corresponding symbol
-- @return Return a pointer to the corresponding symbol
function Get_Symbol (Key : Character) return Holder;
-- Create a list of symbol
-- @param Value String to convert to symbol list
-- @return Return the list of symbol created
function Make_Symbol_List (Value : String)
return LSE.Model.Grammar.Symbol_Utils.P_List.List;
end LSE.Model.L_System.Factory;
|
-- The Village of Vampire by YT, このソースコードはNYSLです
with Tabula;
pragma Unreferenced (Tabula);
package Vampire is
pragma Pure;
use Tabula;
end Vampire;
|
with Ada.Text_IO; use Ada.Text_IO;
with Quaternions;
procedure Test_Quaternion is
package Float_Quaternion is new Quaternions (Float);
use Float_Quaternion;
q : Quaternion := (1.0, 2.0, 3.0, 4.0);
q1 : Quaternion := (2.0, 3.0, 4.0, 5.0);
q2 : Quaternion := (3.0, 4.0, 5.0, 6.0);
r : Float := 7.0;
begin
Put_Line ("q = " & Image (q));
Put_Line ("q1 = " & Image (q1));
Put_Line ("q2 = " & Image (q2));
Put_Line ("r =" & Float'Image (r));
Put_Line ("abs q =" & Float'Image (abs q));
Put_Line ("abs q1 =" & Float' Image (abs q1));
Put_Line ("abs q2 =" & Float' Image (abs q2));
Put_Line ("-q = " & Image (-q));
Put_Line ("conj q = " & Image (Conj (q)));
Put_Line ("q1 + q2 = " & Image (q1 + q2));
Put_Line ("q2 + q1 = " & Image (q2 + q1));
Put_Line ("q * r = " & Image (q * r));
Put_Line ("r * q = " & Image (r * q));
Put_Line ("q1 * q2 = " & Image (q1 * q2));
Put_Line ("q2 * q1 = " & Image (q2 * q1));
end Test_Quaternion;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2015-2016, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of STMicroelectronics nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
-- --
-- This file is based on: --
-- --
-- @file lis3dsh.c --
-- @author MCD Application Team --
-- @version V1.1.0 --
-- @date 19-June-2014 --
-- @brief This file provides a set of functions needed to manage the --
-- LIS3DSH MEMS Accelerometer. --
-- --
-- COPYRIGHT(c) 2014 STMicroelectronics --
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
with System;
with Interfaces; use Interfaces;
package body LIS3DSH is
Full_Scale_Selection_Mask : constant UInt8 := 2#0011_1000#;
-- bits 3..5 of CTRL5
Data_Rate_Selection_Mask : constant UInt8 := 2#0111_0000#;
-- bits 4..6 of CTRL4
procedure Loc_IO_Write
(This : in out Three_Axis_Accelerometer;
Value : UInt8;
WriteAddr : Register_Address)
with Inline_Always;
procedure Loc_IO_Read
(This : Three_Axis_Accelerometer;
Value : out UInt8;
ReadAddr : Register_Address)
with Inline_Always;
------------------
-- Loc_IO_Write --
------------------
procedure Loc_IO_Write
(This : in out Three_Axis_Accelerometer;
Value : UInt8;
WriteAddr : Register_Address)
is
begin
IO_Write (Three_Axis_Accelerometer'Class (This),
Value,
WriteAddr);
end Loc_IO_Write;
-----------------
-- Loc_IO_Read --
-----------------
procedure Loc_IO_Read
(This : Three_Axis_Accelerometer;
Value : out UInt8;
ReadAddr : Register_Address)
is
begin
IO_Read (Three_Axis_Accelerometer'Class (This),
Value,
ReadAddr);
end Loc_IO_Read;
----------------
-- Configured --
----------------
function Configured (This : Three_Axis_Accelerometer) return Boolean is
(This.Device_Configured);
-----------------------
-- Get_Accelerations --
-----------------------
procedure Get_Accelerations
(This : Three_Axis_Accelerometer;
Axes : out Axes_Accelerations)
is
Buffer : array (0 .. 5) of UInt8 with Alignment => 2, Size => 48;
Scaled : Float;
type Integer16_Pointer is access all Integer_16
with Storage_Size => 0;
function As_Pointer is new Ada.Unchecked_Conversion
(Source => System.Address, Target => Integer16_Pointer);
-- So that we can treat the address of a UInt8 as a pointer to a two-UInt8
-- sequence representing a signed Integer_16 quantity
begin
This.Loc_IO_Read (Buffer (0), OUT_X_L);
This.Loc_IO_Read (Buffer (1), OUT_X_H);
This.Loc_IO_Read (Buffer (2), OUT_Y_L);
This.Loc_IO_Read (Buffer (3), OUT_Y_H);
This.Loc_IO_Read (Buffer (4), OUT_Z_L);
This.Loc_IO_Read (Buffer (5), OUT_Z_H);
Get_X : declare
Raw : Integer_16 renames As_Pointer (Buffer (0)'Address).all;
begin
Scaled := Float (Raw) * This.Sensitivity;
Axes.X := Axis_Acceleration (Scaled);
end Get_X;
Get_Y : declare
Raw : Integer_16 renames As_Pointer (Buffer (2)'Address).all;
begin
Scaled := Float (Raw) * This.Sensitivity;
Axes.Y := Axis_Acceleration (Scaled);
end Get_Y;
Get_Z : declare
Raw : Integer_16 renames As_Pointer (Buffer (4)'Address).all;
begin
Scaled := Float (Raw) * This.Sensitivity;
Axes.Z := Axis_Acceleration (Scaled);
end Get_Z;
end Get_Accelerations;
---------------
-- Configure --
---------------
procedure Configure
(This : in out Three_Axis_Accelerometer;
Output_DataRate : Data_Rate_Power_Mode_Selection;
Axes_Enable : Direction_XYZ_Selection;
SPI_Wire : SPI_Serial_Interface_Mode_Selection;
Self_Test : Self_Test_Selection;
Full_Scale : Full_Scale_Selection;
Filter_BW : Anti_Aliasing_Filter_Bandwidth)
is
Temp : UInt16;
Value : UInt8;
begin
Temp := Output_DataRate'Enum_Rep or
Axes_Enable'Enum_Rep or
SPI_Wire'Enum_Rep or
Self_Test'Enum_Rep or
Full_Scale'Enum_Rep or
Filter_BW'Enum_Rep;
Value := UInt8 (Temp); -- the low UInt8 of the half-word
This.Loc_IO_Write (Value, CTRL_REG4);
Value := UInt8 (Shift_Right (Temp, 8)); -- the high UInt8
This.Loc_IO_Write (Value, CTRL_REG5);
case Full_Scale is
when Fullscale_2g =>
This.Sensitivity := Sensitivity_0_06mg;
when Fullscale_4g =>
This.Sensitivity := Sensitivity_0_12mg;
when Fullscale_6g =>
This.Sensitivity := Sensitivity_0_18mg;
when Fullscale_8g =>
This.Sensitivity := Sensitivity_0_24mg;
when Fullscale_16g =>
This.Sensitivity := Sensitivity_0_73mg;
end case;
This.Device_Configured := True;
end Configure;
---------------
-- Device_Id --
---------------
function Device_Id (This : Three_Axis_Accelerometer) return UInt8 is
Response : UInt8;
begin
This.Loc_IO_Read (Response, WHO_AM_I);
return Response;
end Device_Id;
------------
-- Reboot --
------------
procedure Reboot (This : in out Three_Axis_Accelerometer) is
Value : UInt8;
Force_Reboot : constant UInt8 := 2#1000_0000#;
begin
This.Loc_IO_Read (Value, CTRL_REG6);
Value := Value or Force_Reboot;
This.Loc_IO_Write (Value, CTRL_REG6);
end Reboot;
--------------------------
-- Configure_Interrupts --
--------------------------
procedure Configure_Interrupts
(This : in out Three_Axis_Accelerometer;
Interrupt_Request : Interrupt_Request_Selection;
Interrupt_Selection_Enable : Interrupt_Selection_Enablers;
Interrupt_Signal : Interrupt_Signal_Active_Selection;
State_Machine1_Enable : Boolean;
State_Machine1_Interrupt : State_Machine_Routed_Interrupt;
State_Machine2_Enable : Boolean;
State_Machine2_Interrupt : State_Machine_Routed_Interrupt)
is
CTRL : UInt8;
begin
CTRL := Interrupt_Selection_Enable'Enum_Rep or
Interrupt_Request'Enum_Rep or
Interrupt_Signal'Enum_Rep;
This.Loc_IO_Write (CTRL, CTRL_REG3);
-- configure State Machine 1
CTRL := State_Machine1_Enable'Enum_Rep or
State_Machine1_Interrupt'Enum_Rep;
This.Loc_IO_Write (CTRL, CTRL_REG1);
-- configure State Machine 2
CTRL := State_Machine2_Enable'Enum_Rep or
State_Machine2_Interrupt'Enum_Rep;
This.Loc_IO_Write (CTRL, CTRL_REG2);
end Configure_Interrupts;
-------------------------------
-- Configure_Click_Interrupt --
-------------------------------
procedure Configure_Click_Interrupt
(This : in out Three_Axis_Accelerometer)
is
begin
Configure_Interrupts
(This,
Interrupt_Request => Interrupt_Request_Latched,
Interrupt_Selection_Enable => Interrupt_2_Enable,
Interrupt_Signal => Interrupt_Signal_High,
State_Machine1_Enable => False,
State_Machine1_Interrupt => SM_INT1, -- Ignored
State_Machine2_Enable => True,
State_Machine2_Interrupt => SM_INT1);
-- configure state machines
This.Loc_IO_Write (3, TIM2_1_L);
This.Loc_IO_Write (16#C8#, TIM1_1_L);
This.Loc_IO_Write (16#45#, THRS2_1);
This.Loc_IO_Write (16#FC#, MASK1_A);
This.Loc_IO_Write (16#A1#, SETT1);
This.Loc_IO_Write (16#1#, PR1);
This.Loc_IO_Write (16#1#, SETT2);
-- configure State Machine 2 to detect single click
This.Loc_IO_Write (16#1#, ST2_1);
This.Loc_IO_Write (16#6#, ST2_2);
This.Loc_IO_Write (16#28#, ST2_3);
This.Loc_IO_Write (16#11#, ST2_4);
end Configure_Click_Interrupt;
-------------------
-- Set_Low_Power --
-------------------
procedure Set_Low_Power
(This : in out Three_Axis_Accelerometer;
Mode : Data_Rate_Power_Mode_Selection)
is
Value : UInt8;
begin
This.Loc_IO_Read (Value, CTRL_REG4);
Value := Value and (not Data_Rate_Selection_Mask); -- clear bits
Value := Value or Mode'Enum_Rep;
This.Loc_IO_Write (Value, CTRL_REG4);
end Set_Low_Power;
-------------------
-- Set_Data_Rate --
-------------------
procedure Set_Data_Rate
(This : in out Three_Axis_Accelerometer;
DataRate : Data_Rate_Power_Mode_Selection)
is
Value : UInt8;
begin
This.Loc_IO_Read (Value, CTRL_REG4);
Value := Value and (not Data_Rate_Selection_Mask); -- clear bits
Value := Value or DataRate'Enum_Rep;
This.Loc_IO_Write (Value, CTRL_REG4);
end Set_Data_Rate;
--------------------
-- Set_Full_Scale --
--------------------
procedure Set_Full_Scale
(This : in out Three_Axis_Accelerometer;
Scale : Full_Scale_Selection)
is
Value : UInt8;
begin
This.Loc_IO_Read (Value, CTRL_REG5);
Value := Value and (not Full_Scale_Selection_Mask); -- clear bits
Value := Value or Scale'Enum_Rep;
This.Loc_IO_Write (Value, CTRL_REG5);
end Set_Full_Scale;
-------------------
-- As_Full_Scale --
-------------------
function As_Full_Scale is new Ada.Unchecked_Conversion
(Source => UInt8, Target => Full_Scale_Selection);
--------------------------
-- Selected_Sensitivity --
--------------------------
function Selected_Sensitivity (This : Three_Axis_Accelerometer)
return Float
is
CTRL5 : UInt8;
begin
This.Loc_IO_Read (CTRL5, CTRL_REG5);
case As_Full_Scale (CTRL5 and Full_Scale_Selection_Mask) is
when Fullscale_2g =>
return Sensitivity_0_06mg;
when Fullscale_4g =>
return Sensitivity_0_12mg;
when Fullscale_6g =>
return Sensitivity_0_18mg;
when Fullscale_8g =>
return Sensitivity_0_24mg;
when Fullscale_16g =>
return Sensitivity_0_73mg;
end case;
end Selected_Sensitivity;
-----------------
-- Temperature --
-----------------
function Temperature (This : Three_Axis_Accelerometer) return UInt8 is
Result : UInt8;
begin
This.Loc_IO_Read (Result, Out_T);
return Result;
end Temperature;
end LIS3DSH;
|
pragma Ada_2012;
with Hide.Value;
package body Hide.BMP is
MAX_TEXT_LENGTH : constant := 1024;
------------
-- Encode --
------------
type Bit_Vector is array (Natural range <>) of Boolean with Pack => True;
function Encode (Src : Pixel_ARGB32; As : Boolean ) return Pixel_ARGB32 with Inline_Always;
Chanel : Chanels := Chanels'First;
Terminator : constant Character := ASCII.Nul;
procedure NEXT is
begin
Chanel := (case Chanel is
when Alpha => Red,
when Red => Gren,
when Gren => Blue,
when Blue => Red);
end NEXT;
-- Store a boolean value in a Pixel.
function Encode (Src : Pixel_ARGB32; As : Boolean ) return Pixel_ARGB32 is
begin
return Ret : Pixel_ARGB32 := Src do
Ret (Chanel) (8) := As;
pragma Debug (Posix.Put (if As then "1" else "0"));
Next;
end return;
end;
-- Store an ASCII string in the image and termiat the string
-- with the Terminator character
procedure Encode
(Image : in out Image_ARGB32;
Text : in String)
is
type mod8 is mod 8;
Src : constant String := Text & Terminator;
Source_Bits : Bit_Vector (1 .. Src'Length * Character'Size) with
Import => True,
Address => Src'Address;
Cursor : Natural := Image'First;
M : mod8 := 0;
begin
if Image'Length < Source_Bits'Length then
Put_Line ("Fail");
raise Constraint_Error;
end if;
for Bit of Source_Bits loop
Image (Cursor) := Encode (Image (Cursor), Bit);
Cursor := Cursor + 1;
M := M + 1;
if M = 0 then
pragma Debug (Put_Line (""));
end if;
end loop;
end Encode;
-- Stores an integer as an ASCII string in the Image.
procedure Encode
(Image : in out Image_ARGB32;
Data : in Integer)
is
S : constant String := Data'Img;
begin
Encode (Image, S (S'First + 1 .. S'Last));
end Encode;
procedure Encode
(Image_Info : Info;
Image : in out Image_ARGB32;
Offset : Natural;
Text : in String)
is
pragma Unreferenced (Image_Info);
begin
pragma Debug (Posix.Put_Line ("Encode"));
-- Reset The chanel
Chanel := Chanels'First;
-- Store the index to the string in the beginning of the image.
Encode (Image, Offset);
-- Finally store the string at index.
Encode (Image (Offset .. Image'Last), Text);
end Encode;
------------
-- Decode --
------------
-- =========================================================================
-- Read the boolean value stored in the pixel
-- And step to next channel.
function Decode
(Image : in Pixel_ARGB32) return Boolean is
begin
return Ret : constant Boolean := Image (Chanel) (8) do
pragma Debug (Posix.Put (if Ret then "1" else "0"));
Next;
end return;
end;
-- =========================================================================
-- Read the null terminated string stored in the begining of the pixel-vector
--
function Decode
(Image : in Image_ARGB32)
return String is
Output_Buffer : String (1 .. MAX_TEXT_LENGTH);
Output_Cursor : Natural := Output_Buffer'First;
Input_Cursor : Natural := Image'First;
type Character_Bit_Vector (Part : Boolean := False) is record
case Part is
when True => As_Character : Character;
when False => As_Bit_Vector : Bit_Vector (1 .. Character'Size);
end case;
end record with
Unchecked_Union => True;
Input : Character_Bit_Vector;
begin
pragma Debug (Posix.Put_Line ("Decode"));
loop
-- Read 8 consecutive bits to form one byte
-- and exit when the String termination charrater is found.
for I in Input.As_Bit_Vector'Range loop
Input.As_Bit_Vector (I) := Decode (Image (Input_Cursor));
Input_Cursor := Input_Cursor + 1;
end loop;
exit when Input.As_Character = Terminator;
pragma Debug (Posix.Put_Line (""));
Output_Buffer (Output_Cursor) := Input.As_Character;
Output_Cursor := Output_Cursor + 1;
end loop;
Output_Cursor := Output_Cursor - 1;
pragma Debug (Posix.Put_Line(""));
pragma Debug (Posix.Put_Line (Output_Buffer (Output_Buffer'First .. Output_Cursor)));
return Output_Buffer (Output_Buffer'First .. Output_Cursor);
end;
function Decode
(Image : in Image_ARGB32)
return Natural is
begin
return value(Decode (Image));
end;
-- ========================================================================
-- Read a string stored in the Pixel-array by first
-- reading a string contanit the offset to the real data
-- and then return the real data.
function Decode
(Image_Info : Info;
Image : in Image_ARGB32)
return String
is
pragma Unreferenced (Image_Info);
begin
-- Reset the channel.
Chanel := Chanels'First;
-- get the index to where the actual string is stored and then
-- Return the string.
return Decode (Image (Decode (Image) .. Image'Last));
end Decode;
-- Convinient image function.
function Image ( Item : Info ) return String is
begin
return
"Struct_Size => " & Item.Struct_Size'Img & ASCII.LF & "," &
"Width => " & Item.Width'Img & ASCII.LF & "," &
"Height => " & Item.Height'Img & ASCII.LF & "," &
"Planes => " & Item.Planes'Img & ASCII.LF & "," &
"Pixel_Size => " & Item.Pixel_Size'Img & ASCII.LF & "," &
"Compression => " & Item.Compression'Img & ASCII.LF & "," &
"Image_Size => " & Item.Image_Size'Img & ASCII.LF & "," &
"PPMX => " & Item.PPMX'Img & ASCII.LF & "," &
"PPMY => " & Item.PPMY'Img & ASCII.LF & "," &
"Palette_Size => " & Item.Palette_Size'Img & ASCII.LF & "," &
"Important => " & Item.Important'Img;
end;
end Hide.BMP;
|
package body ACO.Utils.DS.Generic_Collection is
procedure Initialize
(C : in out Collection)
is
begin
Clear (C);
end Initialize;
procedure Clear
(C : in out Collection)
is
begin
C.Start := 1;
C.Size := 0;
end Clear;
function Is_Full
(C : Collection)
return Boolean
is
(C.Size >= C.Max_Size);
function Is_Empty
(C : Collection)
return Boolean
is
(C.Size = 0);
function Is_Valid_Index
(C : Collection;
Index : Positive)
return Boolean
is
(Index <= C.Size);
function Available
(C : Collection)
return Natural
is
(C.Max_Size - C.Size);
function Length
(C : Collection)
return Natural
is
(C.Size);
function First
(C : Collection)
return Item_Type
is
(C.Items (C.Start));
function Last
(C : Collection)
return Item_Type
is
(C.Items (((C.Start - 1 + C.Size - 1) mod C.Max_Size) + 1));
procedure Insert
(C : in out Collection;
Item : in Item_Type)
is
begin
C.Start := ((C.Start - 2) mod C.Max_Size) + 1;
C.Size := C.Size + 1;
C.Items (C.Start) := Item;
end Insert;
procedure Insert
(C : in out Collection;
Item : in Item_Type;
Before : in Positive)
is
begin
if C.Size = 0 or else Before = 1 then
Insert (C, Item);
else
-- We are inserting in the middle.
--
-- In the comments below, 'left' means the part of Items
-- before the Itement which the new entry is to be inserted
-- before (indexed by Actual), 'right' means the part after.
declare
Start : Item_Index renames C.Start;
Actual : constant Item_Index :=
((Start - 1 + Before - 1) mod C.Max_Size) + 1;
Last : constant Item_Index :=
((Start - 1 + C.Size - 1) mod C.Max_Size) + 1;
begin
if Start = 1 or else Start > Actual then
-- the left part is wedged, shift the right part up
C.Items (Actual + 1 .. Last + 1) := C.Items (Actual .. Last);
C.Items (Actual) := Item;
elsif Last = C.Items'Last or else Last < Actual then
-- the right part is wedged, shift the left part down
C.Items (Start - 1 .. Actual - 2) :=
C.Items (Start .. Actual - 1);
Start := Start - 1;
C.Items (Actual - 1) := Item;
elsif Before < C.Size / 2 then
-- the left part is shorter, shift it down
C.Items (Start - 1 .. Actual - 2) :=
C.Items (Start .. Actual - 1);
Start := Start - 1;
C.Items (Actual - 1) := Item;
else
-- the right part is shorter, shift it up
C.Items (Actual + 1 .. Last + 1) := C.Items (Actual .. Last);
C.Items (Actual) := Item;
end if;
C.Size := C.Size + 1;
end;
end if;
end Insert;
procedure Append
(C : in out Collection;
Item : in Item_Type)
is
begin
C.Size := C.Size + 1;
C.Items (((C.Start - 1 + C.Size - 1) mod C.Max_Size) + 1) := Item;
end Append;
procedure Append
(C : in out Collection;
Item : in Item_Type;
After : in Positive)
is
begin
if C.Size = 0 or else After = C.Size then
Append (C, Item);
else
Insert (C, Item, Before => After + 1);
end if;
end Append;
procedure Remove
(C : in out Collection;
From : in Positive)
is
begin
if C.Size = 1 then
Clear (C);
elsif From = 1 then
C.Start := (C.Start mod C.Max_Size) + 1;
C.Size := C.Size - 1;
elsif From = C.Size then
C.Size := C.Size - 1;
else
-- We are removing from the middle.
--
-- In the comments below, 'left' means the part of Items
-- before the Itement to be removed (indexed by Actual),
-- 'right' means the part after.
declare
Start : Item_Index renames C.Start;
Actual : constant Item_Index :=
((Start - 1 + From - 1) mod C.Max_Size) + 1;
Last : constant Item_Index :=
((Start - 1 + C.Size - 1) mod C.Max_Size) + 1;
begin
if Start > Actual then
-- the left part wraps round; shift the right part down
C.Items (Actual .. Last - 1) := C.Items (Actual + 1 .. Last);
elsif Actual > Last then
-- the right part wraps round; shift the left part up
C.Items (Start + 1 .. Actual) := C.Items (Start .. Actual - 1);
Start := Start + 1;
elsif C.Max_Size > 1 and then From < C.Size / 2 then
-- the left part is shorter
C.Items (Start + 1 .. Actual) := C.Items (Start .. Actual - 1);
Start := Start + 1;
else
-- the right part is shorter
C.Items (Actual .. Last - 1) := C.Items (Actual + 1 .. Last);
end if;
C.Size := C.Size - 1;
end;
end if;
end Remove;
procedure Replace
(C : in out Collection;
Index : in Positive;
Item : in Item_Type)
is
begin
C.Items (((C.Start - 1 + Index - 1) mod C.Max_Size) + 1) := Item;
end Replace;
function Item_At
(C : Collection;
Index : Positive)
return Item_Type
is
(C.Items (((C.Start - 1 + Index - 1) mod C.Max_Size) + 1));
function Location
(C : Collection;
Item : Item_Type;
Start : Positive := 1)
return Natural
is
begin
if C.Size = 0 then
return No_Index;
end if;
for I in Start .. C.Size loop
if C.Items (((C.Start - 1 + I - 1) mod C.Max_Size) + 1) = Item then
return I;
end if;
end loop;
return No_Index;
end Location;
end ACO.Utils.DS.Generic_Collection;
|
with Gtk.Main;
with Gtk.Window; use Gtk.Window;
with Gtk.Widget; use Gtk.Widget;
with Gtk.Handlers; use Gtk.Handlers;
with Glib; use Glib;
with Gtk.Extra.Plot; use Gtk.Extra.Plot;
with Gtk.Extra.Plot_Data; use Gtk.Extra.Plot_Data;
with Gtk.Extra.Plot_Canvas; use Gtk.Extra.Plot_Canvas;
with Gtk.Extra.Plot_Canvas.Plot; use Gtk.Extra.Plot_Canvas.Plot;
procedure PlotCoords is
package Handler is new Callback (Gtk_Widget_Record);
Window : Gtk_Window;
Plot : Gtk_Plot;
PCP : Gtk_Plot_Canvas_Plot;
Canvas : Gtk_Plot_Canvas;
PlotData : Gtk_Plot_Data;
x, y, dx, dy : Gdouble_Array_Access;
procedure ExitMain (Object : access Gtk_Widget_Record'Class) is
begin
Destroy (Object); Gtk.Main.Main_Quit;
end ExitMain;
begin
x := new Gdouble_Array'(0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0);
y := new Gdouble_Array'(2.7, 2.8, 31.4, 38.1, 58.0, 76.2, 100.5, 130.0, 149.3, 180.0);
Gtk.Main.Init;
Gtk_New (Window);
Set_Title (Window, "Plot coordinate pairs with GtkAda");
Gtk_New (PlotData);
Set_Points (PlotData, x, y, dx, dy);
Gtk_New (Plot);
Add_Data (Plot, PlotData);
Autoscale (Plot); Show (PlotData);
Hide_Legends (Plot);
Gtk_New (PCP, Plot); Show (Plot);
Gtk_New (Canvas, 500, 500); Show (Canvas);
Put_Child (Canvas, PCP, 0.15, 0.15, 0.85, 0.85);
Add (Window, Canvas);
Show_All (Window);
Handler.Connect (Window, "destroy",
Handler.To_Marshaller (ExitMain'Access));
Gtk.Main.Main;
end PlotCoords;
|
-- Copyright (C) 2019 Thierry Rascle <thierr26@free.fr>
-- MIT license. Please refer to the LICENSE file.
generic
with function Allocate return Fixture_Type_Access
is Default_Allocator;
Just_Pretend : Boolean := False;
package Apsepp.Generic_Fixture.Creator is
function Has_Actually_Created return Boolean;
end Apsepp.Generic_Fixture.Creator;
|
with Ada.Strings.Hash;
with Ada.Containers.Hashed_Maps;
with Ada.Text_Io;
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
procedure Hash_Map_Test is
function Equivalent_Key (Left, Right : Unbounded_String) return Boolean is
begin
return Left = Right;
end Equivalent_Key;
function Hash_Func(Key : Unbounded_String) return Ada.Containers.Hash_Type is
begin
return Ada.Strings.Hash(To_String(Key));
end Hash_Func;
package My_Hash is new Ada.Containers.Hashed_Maps(Key_Type => Unbounded_String,
Element_Type => Unbounded_String,
Hash => Hash_Func,
Equivalent_Keys => Equivalent_Key);
type String_Array is array(Positive range <>) of Unbounded_String;
Hash : My_Hash.Map;
Key_List : String_Array := (To_Unbounded_String("foo"),
To_Unbounded_String("bar"),
To_Unbounded_String("val"));
Element_List : String_Array := (To_Unbounded_String("little"),
To_Unbounded_String("miss"),
To_Unbounded_String("muffet"));
begin
for I in Key_List'range loop
Hash.Insert(Key => (Key_List(I)),
New_Item => (Element_List(I)));
end loop;
for I in Key_List'range loop
Ada.Text_Io.Put_Line(To_String(Key_List(I)) & " => " &
To_String(Hash.Element(Key_List(I))));
end loop;
end Hash_Map_Test;
|
with Globals_Example1;
with Md_Example4;
package Md_Example5 is
type T is new Md_Example4.T with record
Child_Attribute : Globals_Example1.Itype;
end record;
procedure Display_It (The_T : T);
end Md_Example5;
|
with PP_F_Elementary;
package body Riemann is
function erf_Riemann(x : Float; n : Integer) return Float
is
partitionSize : Integer;
stepSize : Float;
stepStart : Float;
valueStart : Float;
result : Float;
step : Integer;
begin
partitionSize := 2 ** n;
stepSize := x/Float(partitionSize);
result := 0.0;
step := 0;
while step < partitionSize loop -- for step = 0..((2^n)-1) loop
stepStart := stepSize * Float(step);
--# assert
--# PP_F_Exact.Contained_In(
--# result
--# ,
--# PP_F_Exact.Integral
--# (0.0, stepStart,
--# PP_F_Exact.Exp(-PP_F_Exact.Integration_Variable**2)
--# )
--# +
--# PP_F_Exact.Interval(
--# - c*Float(step+1)
--# ,
--# (1.0-PP_F_Exact.Exp(-(x * Float(step)/Float(partitionSize))**2))*x/Float(partitionSize)
--# + c*Float(step+1)
--# )
--# )
--# and PP_F_Exact.Is_Range(result,-10, 100.0)
--# and PP_Integer.Is_Range(n, 1, 10)
--# and PP_Integer.Is_Range(step, 0, partitionSize-1)
--# and partitionSize = 2 ** n
--# and stepStart = PP_F_Rounded.Multiply(6, stepSize, Float(step))
--# and stepSize = PP_F_Rounded.Divide(6, x, Float(partitionSize));
valueStart :=
PP_F_Elementary.Exp(-(stepStart * stepStart));
result :=
result + stepSize * valueStart;
step := step + 1;
end loop;
return result;
end erf_Riemann;
end Riemann;
|
with Zstandard.Functions; use Zstandard.Functions;
with Ada.Command_line; use Ada.Command_Line;
with Ada.Directories; use Ada.Directories;
with Ada.Text_IO; use Ada.Text_IO;
procedure Demo_Ada is
begin
if Argument_Count < 2 then
Put_Line ("Zstandard version: " & Zstd_Version);
Put_Line ("usage:");
Put_Line (Command_Name & " <file#1> [additional files] <dictionary>");
return;
end if;
for z in 1 .. Argument_Count loop
if not Exists (Argument (z)) then
Put_Line ("File '" & Argument (z) & "' does not exist, aborting.");
return;
end if;
end loop;
declare
dictionary : String renames Argument (Argument_Count);
srcsize : Zstandard.Functions.File_Size;
dstsize : Zstandard.Functions.File_Size;
goodcomp : Boolean;
gooddict : Boolean;
units : Natural;
tenths : Natural;
tenthstr : String (1 .. 2);
digest : Compression_Dictionary;
begin
digest := Create_Compression_Dictionary_From_File (sample_file => dictionary,
quality => 3,
successful => gooddict);
if not gooddict then
Put_Line ("Failed to load dictionary");
return;
end if;
for z in 1 .. Argument_Count - 1 loop
declare
orig_file : String renames Argument (z);
dest_file : String := orig_file & ".zst";
error_msg : String := Compress_File (source_file => orig_file,
output_file => dest_file,
digest => digest,
source_size => srcsize,
output_size => dstsize,
successful => goodcomp);
begin
if goodcomp then
units := Natural (100 * dstsize / srcsize);
tenths := (Natural (10 * dstsize / srcsize)) mod 10;
tenthstr := tenths'Img;
Put_Line ("");
Put_Line (" original file size:" & srcsize'Img);
Put_Line (" compressed file size:" & dstsize'Img);
Put_Line ("percentage compressed:" & units'Img & "." & tenthstr (2 ..2));
Put_Line (" new file: " & dest_file);
else
Put_Line (error_msg);
end if;
end;
end loop;
Destroy_Compression_Dictionary (digest);
end;
end Demo_Ada;
|
-----------------------------------------------------------------------
-- time_manager -- NTP Client instance
-- Copyright (C) 2017 Stephane Carrez
-- Written by Stephane Carrez (Stephane.Carrez@gmail.com)
--
-- Licensed under the Apache License, Version 2.0 (the "License");
-- you may not use this file except in compliance with the License.
-- You may obtain a copy of the License at
--
-- http://www.apache.org/licenses/LICENSE-2.0
--
-- Unless required by applicable law or agreed to in writing, software
-- distributed under the License is distributed on an "AS IS" BASIS,
-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-- See the License for the specific language governing permissions and
-- limitations under the License.
-----------------------------------------------------------------------
with Demos;
package body Time_Manager is
-- ------------------------------
-- Save the answer received from the DNS server. This operation is called for each answer
-- found in the DNS response packet. The Index is incremented at each answer. For example
-- a DNS server can return a CNAME_RR answer followed by an A_RR: the operation is called
-- two times.
--
-- This operation can be overriden to implement specific actions when an answer is received.
-- ------------------------------
overriding
procedure Answer (Request : in out Client_Type;
Status : in Net.DNS.Status_Type;
Response : in Net.DNS.Response_Type;
Index : in Natural) is
use type Net.DNS.Status_Type;
use type Net.DNS.RR_Type;
use type Net.Uint16;
begin
if Status = Net.DNS.NOERROR and then Response.Of_Type = Net.DNS.A_RR then
Request.Server.Initialize (Demos.Ifnet'Access, Response.Ip, Request.Port);
end if;
end Answer;
end Time_Manager;
|
package body Mat is
function Lnko ( A, B : Positive ) return Positive is
X: Positive := A;
Y: Positive := B;
begin
while X /= Y loop
if X > Y then
X := X - Y;
else
Y := Y - X;
end if;
end loop;
return X;
end Lnko;
function Faktorialis( N: Natural ) return Positive is
Fakt : Positive := 1;
begin
for I in 1..N loop
Fakt := Fakt * I;
end loop;
return Fakt;
end Faktorialis;
end Mat;
|
------------------------------------------------------------------------------
-- --
-- GNAT ncurses Binding Samples --
-- --
-- ncurses --
-- --
-- B O D Y --
-- --
------------------------------------------------------------------------------
-- Copyright (c) 2000-2008,2009 Free Software Foundation, Inc. --
-- --
-- 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, distribute with modifications, 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 ABOVE 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. --
-- --
-- Except as contained in this notice, the name(s) of the above copyright --
-- holders shall not be used in advertising or otherwise to promote the --
-- sale, use or other dealings in this Software without prior written --
-- authorization. --
------------------------------------------------------------------------------
-- Author: Eugene V. Melaragno <aldomel@ix.netcom.com> 2000
-- Version Control
-- $Revision: 1.8 $
-- $Date: 2009/12/26 17:38:58 $
-- Binding Version 01.00
------------------------------------------------------------------------------
-- Character input test
-- test the keypad feature
with ncurses2.util; use ncurses2.util;
with Terminal_Interface.Curses; use Terminal_Interface.Curses;
with Terminal_Interface.Curses.Mouse; use Terminal_Interface.Curses.Mouse;
with Ada.Characters.Handling;
with Ada.Strings.Bounded;
with ncurses2.genericPuts;
procedure ncurses2.getch_test is
use Int_IO;
function mouse_decode (ep : Mouse_Event) return String;
function mouse_decode (ep : Mouse_Event) return String is
Y : Line_Position;
X : Column_Position;
Button : Mouse_Button;
State : Button_State;
package BS is new Ada.Strings.Bounded.Generic_Bounded_Length (200);
use BS;
buf : Bounded_String := To_Bounded_String ("");
begin
-- Note that these bindings do not allow
-- two button states,
-- The C version can print {click-1, click-3} for example.
-- They also don't have the 'id' or z coordinate.
Get_Event (ep, Y, X, Button, State);
-- TODO Append (buf, "id "); from C version
Append (buf, "at (");
Append (buf, Column_Position'Image (X));
Append (buf, ", ");
Append (buf, Line_Position'Image (Y));
Append (buf, ") state");
Append (buf, Mouse_Button'Image (Button));
Append (buf, " = ");
Append (buf, Button_State'Image (State));
return To_String (buf);
end mouse_decode;
buf : String (1 .. 1024); -- TODO was BUFSIZE
n : Integer;
c : Key_Code;
blockflag : Timeout_Mode := Blocking;
firsttime : Boolean := True;
tmp2 : Event_Mask;
tmp6 : String (1 .. 6);
tmp20 : String (1 .. 20);
x : Column_Position;
y : Line_Position;
tmpx : Integer;
incount : Integer := 0;
begin
Refresh;
tmp2 := Start_Mouse (All_Events);
Add (Str => "Delay in 10ths of a second (<CR> for blocking input)? ");
Set_Echo_Mode (SwitchOn => True);
Get (Str => buf);
Set_Echo_Mode (SwitchOn => False);
Set_NL_Mode (SwitchOn => False);
if Ada.Characters.Handling.Is_Digit (buf (1)) then
Get (Item => n, From => buf, Last => tmpx);
Set_Timeout_Mode (Mode => Delayed, Amount => n * 100);
blockflag := Delayed;
end if;
c := Character'Pos ('?');
Set_Raw_Mode (SwitchOn => True);
loop
if not firsttime then
Add (Str => "Key pressed: ");
Put (tmp6, Integer (c), 8);
Add (Str => tmp6);
Add (Ch => ' ');
if c = Key_Mouse then
declare
event : Mouse_Event;
begin
event := Get_Mouse;
Add (Str => "KEY_MOUSE, ");
Add (Str => mouse_decode (event));
Add (Ch => newl);
end;
elsif c >= Key_Min then
Key_Name (c, tmp20);
Add (Str => tmp20);
-- I used tmp and got bitten by the length problem:->
Add (Ch => newl);
elsif c > 16#80# then -- TODO fix, use constant if possible
declare
c2 : constant Character := Character'Val (c mod 16#80#);
begin
if Ada.Characters.Handling.Is_Graphic (c2) then
Add (Str => "M-");
Add (Ch => c2);
else
Add (Str => "M-");
Add (Str => Un_Control ((Ch => c2,
Color => Color_Pair'First,
Attr => Normal_Video)));
end if;
Add (Str => " (high-half character)");
Add (Ch => newl);
end;
else
declare
c2 : constant Character := Character'Val (c mod 16#80#);
begin
if Ada.Characters.Handling.Is_Graphic (c2) then
Add (Ch => c2);
Add (Str => " (ASCII printable character)");
Add (Ch => newl);
else
Add (Str => Un_Control ((Ch => c2,
Color => Color_Pair'First,
Attr => Normal_Video)));
Add (Str => " (ASCII control character)");
Add (Ch => newl);
end if;
end;
end if;
-- TODO I am not sure why this was in the C version
-- the delay statement scroll anyway.
Get_Cursor_Position (Line => y, Column => x);
if y >= Lines - 1 then
Move_Cursor (Line => 0, Column => 0);
end if;
Clear_To_End_Of_Line;
end if;
firsttime := False;
if c = Character'Pos ('g') then
declare
package p is new ncurses2.genericPuts (1024);
use p;
use p.BS;
timedout : Boolean := False;
boundedbuf : Bounded_String;
begin
Add (Str => "getstr test: ");
Set_Echo_Mode (SwitchOn => True);
-- Note that if delay mode is set
-- Get can raise an exception.
-- The C version would print the string it had so far
-- also TODO get longer length string, like the C version
declare begin
myGet (Str => boundedbuf);
exception when Curses_Exception =>
Add (Str => "Timed out.");
Add (Ch => newl);
timedout := True;
end;
-- note that the Ada Get will stop reading at 1024.
if not timedout then
Set_Echo_Mode (SwitchOn => False);
Add (Str => " I saw '");
myAdd (Str => boundedbuf);
Add (Str => "'.");
Add (Ch => newl);
end if;
end;
elsif c = Character'Pos ('s') then
ShellOut (True);
elsif c = Character'Pos ('x') or c = Character'Pos ('q') or
(c = Key_None and blockflag = Blocking) then
exit;
elsif c = Character'Pos ('?') then
Add (Str => "Type any key to see its keypad value. Also:");
Add (Ch => newl);
Add (Str => "g -- triggers a getstr test");
Add (Ch => newl);
Add (Str => "s -- shell out");
Add (Ch => newl);
Add (Str => "q -- quit");
Add (Ch => newl);
Add (Str => "? -- repeats this help message");
Add (Ch => newl);
end if;
loop
c := Getchar;
exit when c /= Key_None;
if blockflag /= Blocking then
Put (tmp6, incount); -- argh string length!
Add (Str => tmp6);
Add (Str => ": input timed out");
Add (Ch => newl);
else
Put (tmp6, incount);
Add (Str => tmp6);
Add (Str => ": input error");
Add (Ch => newl);
exit;
end if;
incount := incount + 1;
end loop;
end loop;
End_Mouse (tmp2);
Set_Timeout_Mode (Mode => Blocking, Amount => 0); -- amount is ignored
Set_Raw_Mode (SwitchOn => False);
Set_NL_Mode (SwitchOn => True);
Erase;
End_Windows;
end ncurses2.getch_test;
|
-- Copyright 2020 Free Software Foundation, Inc.
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 3 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see <http://www.gnu.org/licenses/>.
with Pck; use Pck;
procedure Pkg is
R, Q : Rec_Type;
ST1 : constant Second_Type := (I => -4, One => 1, X => 2);
ST2 : constant Second_Type := (I => 99, One => 1, Y => 77);
NAV1 : constant Nested_And_Variable := (One => 0, Two => 93,
Str => (others => 'z'));
NAV2 : constant Nested_And_Variable := (One => 3, OneValue => 33,
Str => (others => 'z'),
Str2 => (others => 'q'),
Two => 0);
NAV3 : constant Nested_And_Variable := (One => 3, OneValue => 33,
Str => (others => 'z'),
Str2 => (others => 'q'),
Two => 7, TwoValue => 88);
begin
R := (C => 'd');
Q := (C => Character'First, X_First => 27);
null; -- STOP
end Pkg;
|
------------------------------------------------------------------------------
-- --
-- THIS IS AN AUTOMATICALLY GENERATED FILE! DO NOT EDIT! --
-- --
-- WAVEFILES --
-- --
-- Wavefile data I/O operations --
-- --
-- The MIT License (MIT) --
-- --
-- Copyright (c) 2015 -- 2021 Gustavo A. Hoffmann --
-- --
-- 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. --
------------------------------------------------------------------------------
#if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then
package body Audio.Wavefiles.Generic_Float_Wav_IO is
#else
package body Audio.Wavefiles.Generic_Fixed_Wav_IO is
#end if;
#if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then
#else
procedure Read_Wav_Sample_Bytes
(File_Access : Ada.Streams.Stream_IO.Stream_Access;
Sample : out Wav_Sample)
with Inline;
procedure Write_Wav_Sample_Bytes
(File_Access : Ada.Streams.Stream_IO.Stream_Access;
Sample : Wav_Sample)
with Inline;
#end if;
procedure Read_Wav_MC_Sample (WF : in out Wavefile;
Wav : out Wav_MC_Sample)
with Inline;
procedure Write_Wav_MC_Sample (WF : in out Wavefile;
Wav : Wav_MC_Sample)
with Inline;
#if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then
#else
---------------------------
-- Read_Wav_Sample_Bytes --
---------------------------
procedure Read_Wav_Sample_Bytes
(File_Access : Ada.Streams.Stream_IO.Stream_Access;
Sample : out Wav_Sample)
is
Bytes : Byte_Array (1 .. Sample'Size / 8)
with Address => Sample'Address, Import, Volatile;
Last_Valid_Byte : constant Long_Integer := Wav_Sample'Size / 8;
use type Byte;
begin
Byte_Array'Read (File_Access,
Bytes (1 .. Wav_Sample'Size / 8));
-- Account for sign bit in internal representation,
-- which might not match the wavefile representation.
if Sample'Size > Wav_Sample'Size then
Bytes (Last_Valid_Byte + 1 .. Bytes'Last) :=
(others => (if Bytes (Last_Valid_Byte) >= 16#80#
then 16#FF# else 16#00#));
end if;
end Read_Wav_Sample_Bytes;
----------------------------
-- Write_Wav_Sample_Bytes --
----------------------------
procedure Write_Wav_Sample_Bytes
(File_Access : Ada.Streams.Stream_IO.Stream_Access;
Sample : Wav_Sample)
is
Bytes : Byte_Array (1 .. Wav_Sample'Size / 8)
with Address => Sample'Address, Import, Volatile;
begin
Byte_Array'Write (File_Access, Bytes);
end Write_Wav_Sample_Bytes;
#end if;
------------------------
-- Read_Wav_MC_Sample --
------------------------
procedure Read_Wav_MC_Sample
(WF : in out Wavefile;
Wav : out Wav_MC_Sample)
is
N_Ch : constant Positive := Number_Of_Channels (WF);
Sample : Wav_Sample;
use Ada.Streams.Stream_IO;
Prev_File_Index : constant Positive_Count := Index (WF.File)
with Ghost;
Expected_Byte_IO : constant Positive_Count
:= Positive_Count
(To_Positive (WF.Wave_Format.Bits_Per_Sample) * N_Ch / 8)
with Ghost;
begin
for J in Wav'Range loop
#if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then
Wav_Sample'Read (WF.File_Access, Sample);
#else
-- Patch for 24-bit wavefiles
if Wav_Sample'Size = 24 then
Read_Wav_Sample_Bytes (WF.File_Access, Sample);
else
Wav_Sample'Read (WF.File_Access, Sample);
end if;
#end if;
Wav (J) := Sample;
if Ada.Streams.Stream_IO.End_Of_File (WF.File) and then
J < Wav'Last
then
-- Cannot read data for all channels
WF.Set_Error (Wavefile_Error_File_Too_Short);
end if;
end loop;
WF.Sample_Pos.Current := WF.Sample_Pos.Current + 1;
pragma Assert (Ada.Streams.Stream_IO.Index (WF.File) =
Prev_File_Index + Expected_Byte_IO);
end Read_Wav_MC_Sample;
-------------------------
-- Write_Wav_MC_Sample --
-------------------------
procedure Write_Wav_MC_Sample
(WF : in out Wavefile;
Wav : Wav_MC_Sample)
is
N_Ch : constant Positive := Number_Of_Channels (WF);
use Ada.Streams.Stream_IO;
Prev_File_Index : constant Positive_Count := Index (WF.File)
with Ghost;
Expected_Byte_IO : constant Positive_Count
:= Positive_Count
(To_Positive (WF.Wave_Format.Bits_Per_Sample) * N_Ch / 8)
with Ghost;
begin
#if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then
Wav_MC_Sample'Write (WF.File_Access, Wav);
#else
if Wav_Sample'Size = 24 then
for Sample of Wav loop
Write_Wav_Sample_Bytes (WF.File_Access, Sample);
end loop;
else
Wav_MC_Sample'Write (WF.File_Access, Wav);
end if;
#end if;
WF.Sample_Pos := (Total => WF.Sample_Pos.Total + 1,
Current => WF.Sample_Pos.Current + 1);
pragma Assert (Ada.Streams.Stream_IO.Index (WF.File) =
Prev_File_Index + Expected_Byte_IO);
end Write_Wav_MC_Sample;
---------
-- Get --
---------
function Get (WF : in out Wavefile) return Wav_MC_Sample
is
N_Ch : constant Positive := Number_Of_Channels (WF);
Channel_Range_Valid_Last : constant Channel_Range :=
Channel_Range'Val (N_Ch - 1
+ Channel_Range'Pos (Channel_Range'First));
subtype Valid_Channel_Range is Channel_Range range
Channel_Range'First .. Channel_Range_Valid_Last;
begin
return Wav : Wav_MC_Sample (Valid_Channel_Range) do
Read_Wav_MC_Sample (WF, Wav);
end return;
end Get;
---------
-- Get --
---------
procedure Get (WF : in out Wavefile;
Wav : out Wav_MC_Sample) is
begin
Read_Wav_MC_Sample (WF, Wav);
end Get;
---------
-- Put --
---------
procedure Put (WF : in out Wavefile;
Wav : Wav_MC_Sample) is
begin
Write_Wav_MC_Sample (WF, Wav);
end Put;
#if NUM_TYPE'Defined and then (NUM_TYPE = "FLOAT") then
end Audio.Wavefiles.Generic_Float_Wav_IO;
#else
end Audio.Wavefiles.Generic_Fixed_Wav_IO;
#end if;
|
with Ada.Containers.Ordered_Maps;
with Ada.Containers.Vectors;
package Intcode is
subtype Element is Long_Long_Integer;
subtype Index is Element range 0 .. Element'Last;
package Opcode_Vectors is new Ada.Containers.Ordered_Maps
(Key_Type => Index,
Element_Type => Element);
package Instances is
package Data_Vectors is new Ada.Containers.Vectors
(Index_Type => Index,
Element_Type => Element);
type State is (Not_Started, Running, Need_Input, Halted);
type Instance is tagged limited record
Opcodes : Opcode_Vectors.Map;
Inputs : Data_Vectors.Vector := Data_Vectors.Empty_Vector;
Outputs : Data_Vectors.Vector := Data_Vectors.Empty_Vector;
IP : Index := 0;
S : State := Not_Started;
Relative_Base : Element := 0;
end record;
procedure Run (I : in out Instance);
end Instances;
package Compilers is
type Compiler is tagged limited private;
procedure Compile (C : in out Compiler; Filename : String);
function Instantiate (C : Compiler) return Instances.Instance;
private
type Compiler is tagged limited record
Opcodes : Opcode_Vectors.Map := Opcode_Vectors.Empty_Map;
end record;
procedure Compile_From_String (C : in out Compiler; S : String);
end Compilers;
end Intcode;
|
pragma Style_Checks (Off);
-- This spec has been automatically generated from STM32H743x.svd
pragma Restrictions (No_Elaboration_Code);
with HAL;
with System;
package STM32_SVD.SWPMI is
pragma Preelaborate;
---------------
-- Registers --
---------------
-- SWPMI Configuration/Control register
type CR_Register is record
-- Reception DMA enable
RXDMA : Boolean := False;
-- Transmission DMA enable
TXDMA : Boolean := False;
-- Reception buffering mode
RXMODE : Boolean := False;
-- Transmission buffering mode
TXMODE : Boolean := False;
-- Loopback mode enable
LPBK : Boolean := False;
-- Single wire protocol master interface activate
SWPACT : Boolean := False;
-- unspecified
Reserved_6_9 : HAL.UInt4 := 16#0#;
-- Single wire protocol master interface deactivate
DEACT : Boolean := False;
-- Single wire protocol master transceiver enable
SWPTEN : Boolean := False;
-- unspecified
Reserved_12_31 : HAL.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for CR_Register use record
RXDMA at 0 range 0 .. 0;
TXDMA at 0 range 1 .. 1;
RXMODE at 0 range 2 .. 2;
TXMODE at 0 range 3 .. 3;
LPBK at 0 range 4 .. 4;
SWPACT at 0 range 5 .. 5;
Reserved_6_9 at 0 range 6 .. 9;
DEACT at 0 range 10 .. 10;
SWPTEN at 0 range 11 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype BRR_BR_Field is HAL.UInt8;
-- SWPMI Bitrate register
type BRR_Register is record
-- Bitrate prescaler
BR : BRR_BR_Field := 16#1#;
-- unspecified
Reserved_8_31 : HAL.UInt24 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for BRR_Register use record
BR at 0 range 0 .. 7;
Reserved_8_31 at 0 range 8 .. 31;
end record;
-- SWPMI Interrupt and Status register
type ISR_Register is record
-- Read-only. Receive buffer full flag
RXBFF : Boolean;
-- Read-only. Transmit buffer empty flag
TXBEF : Boolean;
-- Read-only. Receive CRC error flag
RXBERF : Boolean;
-- Read-only. Receive overrun error flag
RXOVRF : Boolean;
-- Read-only. Transmit underrun error flag
TXUNRF : Boolean;
-- Read-only. Receive data register not empty
RXNE : Boolean;
-- Read-only. Transmit data register empty
TXE : Boolean;
-- Read-only. Transfer complete flag
TCF : Boolean;
-- Read-only. Slave resume flag
SRF : Boolean;
-- Read-only. SUSPEND flag
SUSP : Boolean;
-- Read-only. DEACTIVATED flag
DEACTF : Boolean;
-- Read-only. transceiver ready flag
RDYF : Boolean;
-- unspecified
Reserved_12_31 : HAL.UInt20;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ISR_Register use record
RXBFF at 0 range 0 .. 0;
TXBEF at 0 range 1 .. 1;
RXBERF at 0 range 2 .. 2;
RXOVRF at 0 range 3 .. 3;
TXUNRF at 0 range 4 .. 4;
RXNE at 0 range 5 .. 5;
TXE at 0 range 6 .. 6;
TCF at 0 range 7 .. 7;
SRF at 0 range 8 .. 8;
SUSP at 0 range 9 .. 9;
DEACTF at 0 range 10 .. 10;
RDYF at 0 range 11 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
-- SWPMI Interrupt Flag Clear register
type ICR_Register is record
-- Write-only. Clear receive buffer full flag
CRXBFF : Boolean := False;
-- Write-only. Clear transmit buffer empty flag
CTXBEF : Boolean := False;
-- Write-only. Clear receive CRC error flag
CRXBERF : Boolean := False;
-- Write-only. Clear receive overrun error flag
CRXOVRF : Boolean := False;
-- Write-only. Clear transmit underrun error flag
CTXUNRF : Boolean := False;
-- unspecified
Reserved_5_6 : HAL.UInt2 := 16#0#;
-- Write-only. Clear transfer complete flag
CTCF : Boolean := False;
-- Write-only. Clear slave resume flag
CSRF : Boolean := False;
-- unspecified
Reserved_9_10 : HAL.UInt2 := 16#0#;
-- Write-only. Clear transceiver ready flag
CRDYF : Boolean := False;
-- unspecified
Reserved_12_31 : HAL.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for ICR_Register use record
CRXBFF at 0 range 0 .. 0;
CTXBEF at 0 range 1 .. 1;
CRXBERF at 0 range 2 .. 2;
CRXOVRF at 0 range 3 .. 3;
CTXUNRF at 0 range 4 .. 4;
Reserved_5_6 at 0 range 5 .. 6;
CTCF at 0 range 7 .. 7;
CSRF at 0 range 8 .. 8;
Reserved_9_10 at 0 range 9 .. 10;
CRDYF at 0 range 11 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
-- SWPMI Interrupt Enable register
type IER_Register is record
-- Receive buffer full interrupt enable
RXBFIE : Boolean := False;
-- Transmit buffer empty interrupt enable
TXBEIE : Boolean := False;
-- Receive CRC error interrupt enable
RXBERIE : Boolean := False;
-- Receive overrun error interrupt enable
RXOVRIE : Boolean := False;
-- Transmit underrun error interrupt enable
TXUNRIE : Boolean := False;
-- Receive interrupt enable
RIE : Boolean := False;
-- Transmit interrupt enable
TIE : Boolean := False;
-- Transmit complete interrupt enable
TCIE : Boolean := False;
-- Slave resume interrupt enable
SRIE : Boolean := False;
-- unspecified
Reserved_9_10 : HAL.UInt2 := 16#0#;
-- Transceiver ready interrupt enable
RDYIE : Boolean := False;
-- unspecified
Reserved_12_31 : HAL.UInt20 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for IER_Register use record
RXBFIE at 0 range 0 .. 0;
TXBEIE at 0 range 1 .. 1;
RXBERIE at 0 range 2 .. 2;
RXOVRIE at 0 range 3 .. 3;
TXUNRIE at 0 range 4 .. 4;
RIE at 0 range 5 .. 5;
TIE at 0 range 6 .. 6;
TCIE at 0 range 7 .. 7;
SRIE at 0 range 8 .. 8;
Reserved_9_10 at 0 range 9 .. 10;
RDYIE at 0 range 11 .. 11;
Reserved_12_31 at 0 range 12 .. 31;
end record;
subtype RFL_RFL_Field is HAL.UInt5;
-- SWPMI Receive Frame Length register
type RFL_Register is record
-- Read-only. Receive frame length
RFL : RFL_RFL_Field;
-- unspecified
Reserved_5_31 : HAL.UInt27;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for RFL_Register use record
RFL at 0 range 0 .. 4;
Reserved_5_31 at 0 range 5 .. 31;
end record;
-- SWPMI Option register
type OR_Register is record
-- SWP transceiver bypass
SWP_TBYP : Boolean := False;
-- SWP class selection
SWP_CLASS : Boolean := False;
-- unspecified
Reserved_2_31 : HAL.UInt30 := 16#0#;
end record
with Volatile_Full_Access, Object_Size => 32,
Bit_Order => System.Low_Order_First;
for OR_Register use record
SWP_TBYP at 0 range 0 .. 0;
SWP_CLASS at 0 range 1 .. 1;
Reserved_2_31 at 0 range 2 .. 31;
end record;
-----------------
-- Peripherals --
-----------------
-- Single Wire Protocol Master Interface
type SWPMI_Peripheral is record
-- SWPMI Configuration/Control register
CR : aliased CR_Register;
-- SWPMI Bitrate register
BRR : aliased BRR_Register;
-- SWPMI Interrupt and Status register
ISR : aliased ISR_Register;
-- SWPMI Interrupt Flag Clear register
ICR : aliased ICR_Register;
-- SWPMI Interrupt Enable register
IER : aliased IER_Register;
-- SWPMI Receive Frame Length register
RFL : aliased RFL_Register;
-- SWPMI Transmit data register
TDR : aliased HAL.UInt32;
-- SWPMI Receive data register
RDR : aliased HAL.UInt32;
-- SWPMI Option register
OR_k : aliased OR_Register;
end record
with Volatile;
for SWPMI_Peripheral use record
CR at 16#0# range 0 .. 31;
BRR at 16#4# range 0 .. 31;
ISR at 16#C# range 0 .. 31;
ICR at 16#10# range 0 .. 31;
IER at 16#14# range 0 .. 31;
RFL at 16#18# range 0 .. 31;
TDR at 16#1C# range 0 .. 31;
RDR at 16#20# range 0 .. 31;
OR_k at 16#24# range 0 .. 31;
end record;
-- Single Wire Protocol Master Interface
SWPMI_Periph : aliased SWPMI_Peripheral
with Import, Address => SWPMI_Base;
end STM32_SVD.SWPMI;
|
-- This code is from Rosettacode.org
-- http://rosettacode.org/wiki/FizzBuzz
-- This program will run fizz buzz 100 times with if-else strategy.
with Ada.Text_IO; use Ada.Text_IO;
procedure Fizzbuzz is
begin
for I in 1..100 loop
if I mod 15 = 0 then
Put_Line("FizzBuzz");
elsif I mod 5 = 0 then
Put_Line("Buzz");
elsif I mod 3 = 0 then
Put_Line("Fizz");
else
Put_Line(Integer'Image(I));
end if;
end loop;
end Fizzbuzz;
|
------------------------------------------------------------------------------
-- reporter.ads
--
-- A plain package for serializing the output of messages to standard output.
------------------------------------------------------------------------------
with Ada.Strings.Unbounded;
use Ada.Strings.Unbounded;
package Reporter is
procedure Report (Message: String);
procedure Report (Message: Unbounded_String);
end Reporter;
|
-- Ada regular expression library
-- (c) Kristian Klomsten Skordal 2020 <kristian.skordal@wafflemail.net>
-- Report bugs and issues on <https://github.com/skordal/ada-regex>
with AUnit.Test_Fixtures;
package Utilities_Test_Cases is
type Test_Fixture is new AUnit.Test_Fixtures.Test_Fixture with null record;
procedure Test_Empty_Set (T : in out Test_Fixture);
procedure Test_Basic_Ops (T : in out Test_Fixture);
procedure Test_Assignment (T : in out Test_Fixture);
procedure Test_Ordering (T : in out Test_Fixture);
end Utilities_Test_Cases;
|
-- part of OpenGLAda, (c) 2017 Felix Krause
-- released under the terms of the MIT license, see the file "COPYING"
-- Autogenerated by Generate, do not edit
package GL.API.Ints is
pragma Preelaborate;
Uniform1 : T8;
Uniform1v : T9;
Uniform2 : T10;
Uniform2v : T11;
Uniform3 : T12;
Uniform3v : T13;
Uniform4 : T14;
Uniform4v : T15;
Uniform_Matrix2 : T16;
Uniform_Matrix3 : T17;
Uniform_Matrix4 : T18;
Vertex_Attrib1 : T19;
Vertex_Attrib2 : T20;
Vertex_Attrib2v : T21;
Vertex_Attrib3 : T22;
Vertex_Attrib3v : T23;
Vertex_Attrib4 : T24;
Vertex_Attrib4v : T25;
end GL.API.Ints;
|
pragma Ada_2012;
pragma Style_Checks (Off);
with Interfaces.C; use Interfaces.C;
with sys_utypes_usize_t_h;
with System;
package heapq_h is
TCOD_HEAP_DEFAULT_CAPACITY : constant := 256; -- heapq.h:40
TCOD_HEAP_MAX_NODE_SIZE : constant := 256; -- heapq.h:41
-- BSD 3-Clause License
-- *
-- * Copyright © 2008-2021, Jice and the libtcod contributors.
-- * All rights reserved.
-- *
-- * Redistribution and use in source and binary forms, with or without
-- * modification, are permitted provided that the following conditions are met:
-- *
-- * 1. Redistributions of source code must retain the above copyright notice,
-- * this list of conditions and the following disclaimer.
-- *
-- * 2. Redistributions in binary form must reproduce the above copyright notice,
-- * this list of conditions and the following disclaimer in the documentation
-- * and/or other materials provided with the distribution.
-- *
-- * 3. Neither the name of the copyright holder nor the names of its
-- * contributors may be used to endorse or promote products derived from
-- * this software without specific prior written permission.
-- *
-- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
-- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
-- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
-- * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
-- * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
-- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
-- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
-- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
-- * POSSIBILITY OF SUCH DAMAGE.
--
type anon2260_array2262 is array (0 .. 0) of aliased unsigned_char;
type TCOD_HeapNode is record
priority : aliased int; -- heapq.h:49
data : aliased anon2260_array2262; -- heapq.h:51
end record
with Convention => C_Pass_By_Copy; -- heapq.h:48
type TCOD_Heap is record
heap : access TCOD_HeapNode; -- heapq.h:60
size : aliased int; -- heapq.h:61
capacity : aliased int; -- heapq.h:62
node_size : aliased sys_utypes_usize_t_h.size_t; -- heapq.h:63
data_size : aliased sys_utypes_usize_t_h.size_t; -- heapq.h:64
end record
with Convention => C_Pass_By_Copy; -- heapq.h:59
function TCOD_heap_init (heap : access TCOD_Heap; data_size : sys_utypes_usize_t_h.size_t) return int -- heapq.h:70
with Import => True,
Convention => C,
External_Name => "TCOD_heap_init";
procedure TCOD_heap_uninit (heap : access TCOD_Heap) -- heapq.h:71
with Import => True,
Convention => C,
External_Name => "TCOD_heap_uninit";
procedure TCOD_heap_clear (heap : access TCOD_Heap) -- heapq.h:73
with Import => True,
Convention => C,
External_Name => "TCOD_heap_clear";
function TCOD_minheap_push
(minheap : access TCOD_Heap;
priority : int;
data : System.Address) return int -- heapq.h:75
with Import => True,
Convention => C,
External_Name => "TCOD_minheap_push";
procedure TCOD_minheap_pop (minheap : access TCOD_Heap; c_out : System.Address) -- heapq.h:76
with Import => True,
Convention => C,
External_Name => "TCOD_minheap_pop";
procedure TCOD_minheap_heapify (minheap : access TCOD_Heap) -- heapq.h:77
with Import => True,
Convention => C,
External_Name => "TCOD_minheap_heapify";
-- extern "C"
end heapq_h;
|
-- simple.adb: simple example of array declarations and access
procedure Simple is
-- Array type declarations:
-- * index range can be any discrete type
-- * lower and upper bound can be arbitrary
-- * components can have any type
type AT1 is array (1..50) of Integer;
type AT2 is array (4..457) of Integer;
type AT3 is array (0..9) of Boolean;
-- type AT4 is array (0..9) of String(1..5);
type Complex is
record
X, Y: Float;
end record;
type AT5 is array (0..9) of Complex;
type AT6 is array (1..8) of AT4;
type AT7 is array (Character range 'A'..'Z') of Float;
type Color is (Red, Orange, Yellow, Green, Blue, Violet);
type AT8 is array (Orange..Blue) of Boolean;
type AT9 is array (Color'Range) of Character;
A:AT1; B:AT2; C:AT3; D:AT4; E:AT5; F:AT6; G:AT7; H:AT8; I:AT9;
N : constant Integer := 1;
begin
A(2*N+5) := 4_567;
B(N+4) := 4_567;
C(N) := True;
D(3*N) := "ABCDE";
E(0) := Complex' (X=>6.7, Y=>5.6);
F(3) := AT4' (AT4'Range => "XXXXX");
F(3)(1)(5) := 'E';
G(Character'Succ('E')) := 2.9;
H(Color'Pred(Yellow)) := True;
I(Red) := 'Q';
end Simple;
|
with DOM.Core;
with Ada.Finalization;
package XML_Scanners is
--
-- As well knnown, an XML document is a tree. An XML_Scanner is
-- an object associated to a tree of the node that allows to
-- iterate over the node children. At every time there is a
-- "current child." The function Scan returns the current child
-- and "consumes" it.
--
type XML_Scanner (<>) is
new Ada.Finalization.Limited_Controlled
with
private;
function Create_Child_Scanner (Parent : DOM.Core.Node) return XML_Scanner;
-- Return true if all the children have been used
function No_More_Children (Scanner : XML_Scanner) return Boolean;
-- Return the number of children still to be used
function Remaining_Children (Scanner : XML_Scanner) return Natural;
-- Return the current node, but do not consume it
function Peek_Node (Scanner : XML_Scanner) return DOM.Core.Node;
-- Raise Unexpected_Node unless the current node has the given name.
-- Do not consume the node.
procedure Expect (Scanner : XML_Scanner; Name : String);
-- Raise Unexpected_Node unless all the children have been used.
procedure Expect_End_Of_Children (Scanner : XML_Scanner);
--
-- Expect that current node has the specified name and it is a
-- "pure text" node, that is, a node whose only children is text.
-- If everything is OK, it consumes the node and returns the node content,
-- otherwise raises Unexpected_Node.
--
function Parse_Text_Node (Scanner : XML_Scanner;
Name : String)
return String;
No_Limit : constant Natural;
--
-- Expect a sequence of nodes with the given name. For every node
-- calls the given callback. Unexpected_Node is raised if the
-- number of nodes is not within the specified limits
--
procedure Parse_Sequence
(Scanner : in out XML_Scanner;
Name : in String;
Callback : not null access procedure (N : DOM.Core.Node);
Min_Length : in Natural := 1;
Max_Length : in Natural := No_Limit);
-- Like Parse_Sequence with min=0, max=1
procedure Parse_Optional
(Scanner : in out XML_Scanner;
Name : in String;
Callback : not null access procedure (N : DOM.Core.Node));
-- Like Parse_Sequence with min=max=1
procedure Parse_Single_Node
(Scanner : in out XML_Scanner;
Name : in String;
Callback : not null access procedure (N : DOM.Core.Node));
No_Name : constant String;
function Peek_Name (Scanner : XML_Scanner)
return String;
function Scan (Scanner : XML_Scanner)
return DOM.Core.Node;
Unexpected_Node : exception;
type Abstract_Node_Processor is interface;
procedure Process (Processor : in out Abstract_Node_Processor;
Node : in DOM.Core.Node)
is abstract;
procedure Process_Sequence
(Scanner : in out XML_Scanner;
Name : in String;
Processor : in out Abstract_Node_Processor'Class;
Min_Length : in Natural := 1;
Max_Length : in Natural := No_Limit);
private
No_Name : constant String := "";
No_Limit : constant Natural := Natural'Last;
type XML_Scanner_Data is
record
Nodes : DOM.Core.Node_List;
Cursor : Natural;
end record;
type XML_Scanner_Data_Access is access XML_Scanner_Data;
type XML_Scanner is
new Ada.Finalization.Limited_Controlled with
record
Acc : XML_Scanner_Data_Access;
end record;
overriding
procedure Finalize (Object : in out XML_Scanner);
end XML_Scanners;
|
-- generated parser support file.
-- command line: wisitoken-bnf-generate.exe --generate LR1 Ada_Emacs re2c PROCESS text_rep ada.wy
--
-- Copyright (C) 2013 - 2019 Free Software Foundation, Inc.
-- This program is free software; you can redistribute it and/or
-- modify it under the terms of the GNU General Public License as
-- published by the Free Software Foundation; either version 3, or (at
-- your option) any later version.
--
-- This software 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 GNU Emacs. If not, see <http://www.gnu.org/licenses/>.
with Ada_Process_Actions; use Ada_Process_Actions;
with WisiToken.Lexer.re2c;
with ada_re2c_c;
package body Ada_Process_LR1_Main is
package Lexer is new WisiToken.Lexer.re2c
(ada_re2c_c.New_Lexer,
ada_re2c_c.Free_Lexer,
ada_re2c_c.Reset_Lexer,
ada_re2c_c.Next_Token);
procedure Create_Parser
(Parser : out WisiToken.Parse.LR.Parser.Parser;
Language_Fixes : in WisiToken.Parse.LR.Parser.Language_Fixes_Access;
Language_Matching_Begin_Tokens : in WisiToken.Parse.LR.Parser.Language_Matching_Begin_Tokens_Access;
Language_String_ID_Set : in WisiToken.Parse.LR.Parser.Language_String_ID_Set_Access;
Trace : not null access WisiToken.Trace'Class;
User_Data : in WisiToken.Syntax_Trees.User_Data_Access;
Text_Rep_File_Name : in String)
is
use WisiToken.Parse.LR;
McKenzie_Param : constant McKenzie_Param_Type :=
(First_Terminal => 3,
Last_Terminal => 108,
First_Nonterminal => 109,
Last_Nonterminal => 333,
Insert =>
(4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4, 4, 4, 3, 4, 4, 4, 4, 4, 4, 4, 2, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4),
Delete =>
(4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,
4, 4, 1, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4),
Push_Back =>
(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2),
Undo_Reduce =>
(2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 0, 0, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
2, 2, 2, 2, 2, 2, 2, 2, 2),
Minimal_Complete_Cost_Delta => -3,
Fast_Forward => 2,
Matching_Begin => 3,
Ignore_Check_Fail => 2,
Task_Count => 0,
Check_Limit => 4,
Check_Delta_Limit => 100,
Enqueue_Limit => 58000);
function Actions return WisiToken.Parse.LR.Semantic_Action_Array_Arrays.Vector
is begin
return Acts : WisiToken.Parse.LR.Semantic_Action_Array_Arrays.Vector do
Acts.Set_First_Last (109, 333);
Acts (113).Set_First_Last (0, 0);
Acts (113)(0) := (abstract_subprogram_declaration_0'Access, null);
Acts (114).Set_First_Last (0, 1);
Acts (114)(0) := (accept_statement_0'Access, accept_statement_0_check'Access);
Acts (114)(1) := (accept_statement_1'Access, null);
Acts (115).Set_First_Last (0, 2);
Acts (115)(0) := (access_definition_0'Access, null);
Acts (115)(1) := (access_definition_1'Access, null);
Acts (115)(2) := (access_definition_2'Access, null);
Acts (116).Set_First_Last (0, 1);
Acts (116)(0) := (actual_parameter_part_0'Access, null);
Acts (116)(1) := (actual_parameter_part_1'Access, null);
Acts (118).Set_First_Last (0, 5);
Acts (118)(0) := (aggregate_0'Access, null);
Acts (118)(1) := (aggregate_1'Access, null);
Acts (118)(3) := (aggregate_3'Access, null);
Acts (118)(4) := (aggregate_4'Access, null);
Acts (118)(5) := (aggregate_5'Access, null);
Acts (121).Set_First_Last (0, 1);
Acts (121)(0) := (array_type_definition_0'Access, null);
Acts (121)(1) := (array_type_definition_1'Access, null);
Acts (122).Set_First_Last (0, 3);
Acts (122)(0) := (aspect_clause_0'Access, null);
Acts (123).Set_First_Last (0, 1);
Acts (123)(0) := (aspect_specification_opt_0'Access, null);
Acts (124).Set_First_Last (0, 0);
Acts (124)(0) := (assignment_statement_0'Access, null);
Acts (125).Set_First_Last (0, 6);
Acts (125)(0) := (association_opt_0'Access, null);
Acts (125)(2) := (association_opt_2'Access, null);
Acts (125)(3) := (association_opt_3'Access, null);
Acts (125)(4) := (association_opt_4'Access, null);
Acts (125)(5) := (association_opt_5'Access, null);
Acts (127).Set_First_Last (0, 0);
Acts (127)(0) := (asynchronous_select_0'Access, null);
Acts (128).Set_First_Last (0, 0);
Acts (128)(0) := (at_clause_0'Access, null);
Acts (132).Set_First_Last (0, 0);
Acts (132)(0) := (block_label_0'Access, block_label_0_check'Access);
Acts (133).Set_First_Last (0, 1);
Acts (133)(0) := (null, block_label_opt_0_check'Access);
Acts (133)(1) := (null, null);
Acts (134).Set_First_Last (0, 1);
Acts (134)(0) := (block_statement_0'Access, block_statement_0_check'Access);
Acts (134)(1) := (block_statement_1'Access, block_statement_1_check'Access);
Acts (137).Set_First_Last (0, 0);
Acts (137)(0) := (case_expression_0'Access, null);
Acts (138).Set_First_Last (0, 0);
Acts (138)(0) := (case_expression_alternative_0'Access, null);
Acts (139).Set_First_Last (0, 1);
Acts (139)(0) := (case_expression_alternative_list_0'Access, null);
Acts (140).Set_First_Last (0, 0);
Acts (140)(0) := (case_statement_0'Access, null);
Acts (141).Set_First_Last (0, 0);
Acts (141)(0) := (case_statement_alternative_0'Access, null);
Acts (142).Set_First_Last (0, 1);
Acts (142)(0) := (case_statement_alternative_list_0'Access, null);
Acts (143).Set_First_Last (0, 4);
Acts (143)(2) := (compilation_unit_2'Access, null);
Acts (144).Set_First_Last (0, 1);
Acts (144)(0) := (compilation_unit_list_0'Access, null);
Acts (144)(1) := (compilation_unit_list_1'Access, compilation_unit_list_1_check'Access);
Acts (145).Set_First_Last (0, 0);
Acts (145)(0) := (component_clause_0'Access, null);
Acts (147).Set_First_Last (0, 1);
Acts (147)(0) := (component_declaration_0'Access, null);
Acts (147)(1) := (component_declaration_1'Access, null);
Acts (150).Set_First_Last (0, 4);
Acts (150)(4) := (component_list_4'Access, null);
Acts (153).Set_First_Last (0, 0);
Acts (153)(0) := (conditional_entry_call_0'Access, null);
Acts (158).Set_First_Last (0, 16);
Acts (158)(9) := (declaration_9'Access, null);
Acts (162).Set_First_Last (0, 1);
Acts (162)(0) := (delay_statement_0'Access, null);
Acts (162)(1) := (delay_statement_1'Access, null);
Acts (163).Set_First_Last (0, 1);
Acts (163)(0) := (derived_type_definition_0'Access, null);
Acts (163)(1) := (derived_type_definition_1'Access, null);
Acts (170).Set_First_Last (0, 2);
Acts (170)(1) := (discriminant_part_opt_1'Access, null);
Acts (173).Set_First_Last (0, 0);
Acts (173)(0) := (elsif_expression_item_0'Access, null);
Acts (174).Set_First_Last (0, 1);
Acts (174)(0) := (elsif_expression_list_0'Access, null);
Acts (175).Set_First_Last (0, 0);
Acts (175)(0) := (elsif_statement_item_0'Access, null);
Acts (176).Set_First_Last (0, 1);
Acts (176)(0) := (elsif_statement_list_0'Access, null);
Acts (177).Set_First_Last (0, 0);
Acts (177)(0) := (entry_body_0'Access, entry_body_0_check'Access);
Acts (178).Set_First_Last (0, 1);
Acts (178)(0) := (entry_body_formal_part_0'Access, null);
Acts (180).Set_First_Last (0, 1);
Acts (180)(0) := (entry_declaration_0'Access, null);
Acts (180)(1) := (entry_declaration_1'Access, null);
Acts (183).Set_First_Last (0, 0);
Acts (183)(0) := (enumeration_representation_clause_0'Access, null);
Acts (184).Set_First_Last (0, 0);
Acts (184)(0) := (enumeration_type_definition_0'Access, null);
Acts (187).Set_First_Last (0, 0);
Acts (187)(0) := (exception_declaration_0'Access, null);
Acts (188).Set_First_Last (0, 1);
Acts (188)(0) := (exception_handler_0'Access, null);
Acts (188)(1) := (exception_handler_1'Access, null);
Acts (189).Set_First_Last (0, 2);
Acts (189)(0) := (exception_handler_list_0'Access, null);
Acts (191).Set_First_Last (0, 1);
Acts (191)(0) := (exit_statement_0'Access, null);
Acts (191)(1) := (exit_statement_1'Access, null);
Acts (194).Set_First_Last (0, 0);
Acts (194)(0) := (expression_function_declaration_0'Access, null);
Acts (195).Set_First_Last (0, 1);
Acts (195)(0) := (extended_return_object_declaration_0'Access, null);
Acts (195)(1) := (extended_return_object_declaration_1'Access, null);
Acts (197).Set_First_Last (0, 1);
Acts (197)(0) := (extended_return_statement_0'Access, null);
Acts (197)(1) := (extended_return_statement_1'Access, null);
Acts (199).Set_First_Last (0, 3);
Acts (199)(0) := (formal_object_declaration_0'Access, null);
Acts (199)(1) := (formal_object_declaration_1'Access, null);
Acts (199)(2) := (formal_object_declaration_2'Access, null);
Acts (199)(3) := (formal_object_declaration_3'Access, null);
Acts (200).Set_First_Last (0, 0);
Acts (200)(0) := (formal_part_0'Access, null);
Acts (201).Set_First_Last (0, 3);
Acts (201)(0) := (formal_subprogram_declaration_0'Access, null);
Acts (201)(1) := (formal_subprogram_declaration_1'Access, null);
Acts (201)(2) := (formal_subprogram_declaration_2'Access, null);
Acts (201)(3) := (formal_subprogram_declaration_3'Access, null);
Acts (202).Set_First_Last (0, 2);
Acts (202)(0) := (formal_type_declaration_0'Access, null);
Acts (202)(1) := (formal_type_declaration_1'Access, null);
Acts (202)(2) := (formal_type_declaration_2'Access, null);
Acts (204).Set_First_Last (0, 1);
Acts (204)(0) := (formal_derived_type_definition_0'Access, null);
Acts (204)(1) := (formal_derived_type_definition_1'Access, null);
Acts (205).Set_First_Last (0, 0);
Acts (205)(0) := (formal_package_declaration_0'Access, null);
Acts (207).Set_First_Last (0, 2);
Acts (207)(0) := (full_type_declaration_0'Access, null);
Acts (208).Set_First_Last (0, 0);
Acts (208)(0) := (function_specification_0'Access, function_specification_0_check'Access);
Acts (211).Set_First_Last (0, 1);
Acts (211)(0) := (generic_formal_part_0'Access, null);
Acts (211)(1) := (generic_formal_part_1'Access, null);
Acts (214).Set_First_Last (0, 2);
Acts (214)(0) := (generic_instantiation_0'Access, null);
Acts (214)(1) := (generic_instantiation_1'Access, null);
Acts (214)(2) := (generic_instantiation_2'Access, null);
Acts (215).Set_First_Last (0, 0);
Acts (215)(0) := (generic_package_declaration_0'Access, null);
Acts (216).Set_First_Last (0, 2);
Acts (216)(0) := (generic_renaming_declaration_0'Access, null);
Acts (216)(1) := (generic_renaming_declaration_1'Access, null);
Acts (216)(2) := (generic_renaming_declaration_2'Access, null);
Acts (217).Set_First_Last (0, 0);
Acts (217)(0) := (generic_subprogram_declaration_0'Access, null);
Acts (218).Set_First_Last (0, 0);
Acts (218)(0) := (goto_label_0'Access, null);
Acts (219).Set_First_Last (0, 1);
Acts (219)(0) := (handled_sequence_of_statements_0'Access, null);
Acts (220).Set_First_Last (0, 1);
Acts (220)(0) := (identifier_list_0'Access, null);
Acts (220)(1) := (identifier_list_1'Access, null);
Acts (221).Set_First_Last (0, 1);
Acts (221)(0) := (null, identifier_opt_0_check'Access);
Acts (221)(1) := (null, null);
Acts (222).Set_First_Last (0, 3);
Acts (222)(0) := (if_expression_0'Access, null);
Acts (222)(1) := (if_expression_1'Access, null);
Acts (222)(2) := (if_expression_2'Access, null);
Acts (222)(3) := (if_expression_3'Access, null);
Acts (223).Set_First_Last (0, 3);
Acts (223)(0) := (if_statement_0'Access, null);
Acts (223)(1) := (if_statement_1'Access, null);
Acts (223)(2) := (if_statement_2'Access, null);
Acts (223)(3) := (if_statement_3'Access, null);
Acts (224).Set_First_Last (0, 1);
Acts (224)(0) := (incomplete_type_declaration_0'Access, null);
Acts (224)(1) := (incomplete_type_declaration_1'Access, null);
Acts (225).Set_First_Last (0, 0);
Acts (225)(0) := (index_constraint_0'Access, null);
Acts (228).Set_First_Last (0, 1);
Acts (228)(0) := (interface_list_0'Access, null);
Acts (228)(1) := (interface_list_1'Access, null);
Acts (230).Set_First_Last (0, 1);
Acts (230)(0) := (iteration_scheme_0'Access, null);
Acts (230)(1) := (iteration_scheme_1'Access, null);
Acts (231).Set_First_Last (0, 5);
Acts (231)(2) := (iterator_specification_2'Access, null);
Acts (231)(5) := (iterator_specification_5'Access, null);
Acts (233).Set_First_Last (0, 1);
Acts (233)(0) := (loop_statement_0'Access, loop_statement_0_check'Access);
Acts (233)(1) := (loop_statement_1'Access, loop_statement_1_check'Access);
Acts (240).Set_First_Last (0, 8);
Acts (240)(0) := (name_0'Access, null);
Acts (240)(1) := (name_1'Access, null);
Acts (240)(2) := (null, name_2_check'Access);
Acts (240)(3) := (null, null);
Acts (240)(4) := (null, null);
Acts (240)(5) := (name_5'Access, name_5_check'Access);
Acts (240)(6) := (null, null);
Acts (240)(7) := (null, name_7_check'Access);
Acts (240)(8) := (null, null);
Acts (241).Set_First_Last (0, 1);
Acts (241)(0) := (null, name_opt_0_check'Access);
Acts (241)(1) := (null, null);
Acts (243).Set_First_Last (0, 3);
Acts (243)(0) := (null_exclusion_opt_name_type_0'Access, null);
Acts (243)(1) := (null_exclusion_opt_name_type_1'Access, null);
Acts (243)(2) := (null_exclusion_opt_name_type_2'Access, null);
Acts (243)(3) := (null_exclusion_opt_name_type_3'Access, null);
Acts (244).Set_First_Last (0, 0);
Acts (244)(0) := (null_procedure_declaration_0'Access, null);
Acts (245).Set_First_Last (0, 7);
Acts (245)(0) := (object_declaration_0'Access, null);
Acts (245)(1) := (object_declaration_1'Access, null);
Acts (245)(2) := (object_declaration_2'Access, null);
Acts (245)(3) := (object_declaration_3'Access, null);
Acts (245)(4) := (object_declaration_4'Access, null);
Acts (245)(5) := (object_declaration_5'Access, null);
Acts (246).Set_First_Last (0, 2);
Acts (246)(0) := (object_renaming_declaration_0'Access, null);
Acts (246)(1) := (object_renaming_declaration_1'Access, null);
Acts (246)(2) := (object_renaming_declaration_2'Access, null);
Acts (247).Set_First_Last (0, 2);
Acts (247)(0) := (overriding_indicator_opt_0'Access, null);
Acts (247)(1) := (overriding_indicator_opt_1'Access, null);
Acts (248).Set_First_Last (0, 1);
Acts (248)(0) := (package_body_0'Access, package_body_0_check'Access);
Acts (248)(1) := (package_body_1'Access, package_body_1_check'Access);
Acts (249).Set_First_Last (0, 0);
Acts (249)(0) := (package_body_stub_0'Access, null);
Acts (250).Set_First_Last (0, 0);
Acts (250)(0) := (package_declaration_0'Access, null);
Acts (251).Set_First_Last (0, 0);
Acts (251)(0) := (package_renaming_declaration_0'Access, null);
Acts (252).Set_First_Last (0, 1);
Acts (252)(0) := (package_specification_0'Access, package_specification_0_check'Access);
Acts (252)(1) := (package_specification_1'Access, package_specification_1_check'Access);
Acts (253).Set_First_Last (0, 1);
Acts (253)(0) := (parameter_and_result_profile_0'Access, null);
Acts (255).Set_First_Last (0, 4);
Acts (255)(0) := (parameter_specification_0'Access, null);
Acts (255)(1) := (parameter_specification_1'Access, null);
Acts (255)(2) := (parameter_specification_2'Access, null);
Acts (255)(3) := (parameter_specification_3'Access, null);
Acts (257).Set_First_Last (0, 1);
Acts (257)(0) := (paren_expression_0'Access, null);
Acts (258).Set_First_Last (0, 2);
Acts (258)(0) := (pragma_g_0'Access, null);
Acts (258)(1) := (pragma_g_1'Access, null);
Acts (258)(2) := (pragma_g_2'Access, null);
Acts (259).Set_First_Last (0, 4);
Acts (259)(0) := (primary_0'Access, null);
Acts (259)(2) := (primary_2'Access, null);
Acts (259)(4) := (primary_4'Access, null);
Acts (260).Set_First_Last (0, 0);
Acts (260)(0) := (private_extension_declaration_0'Access, null);
Acts (261).Set_First_Last (0, 0);
Acts (261)(0) := (private_type_declaration_0'Access, null);
Acts (262).Set_First_Last (0, 0);
Acts (262)(0) := (procedure_call_statement_0'Access, null);
Acts (263).Set_First_Last (0, 0);
Acts (263)(0) := (procedure_specification_0'Access, procedure_specification_0_check'Access);
Acts (265).Set_First_Last (0, 0);
Acts (265)(0) := (protected_body_0'Access, protected_body_0_check'Access);
Acts (266).Set_First_Last (0, 0);
Acts (266)(0) := (protected_body_stub_0'Access, null);
Acts (267).Set_First_Last (0, 1);
Acts (267)(0) := (protected_definition_0'Access, protected_definition_0_check'Access);
Acts (267)(1) := (protected_definition_1'Access, protected_definition_1_check'Access);
Acts (272).Set_First_Last (0, 1);
Acts (272)(0) := (protected_type_declaration_0'Access, protected_type_declaration_0_check'Access);
Acts (272)(1) := (protected_type_declaration_1'Access, protected_type_declaration_1_check'Access);
Acts (273).Set_First_Last (0, 0);
Acts (273)(0) := (qualified_expression_0'Access, null);
Acts (274).Set_First_Last (0, 0);
Acts (274)(0) := (quantified_expression_0'Access, null);
Acts (276).Set_First_Last (0, 1);
Acts (276)(0) := (raise_expression_0'Access, null);
Acts (277).Set_First_Last (0, 2);
Acts (277)(0) := (raise_statement_0'Access, null);
Acts (277)(1) := (raise_statement_1'Access, null);
Acts (277)(2) := (raise_statement_2'Access, null);
Acts (278).Set_First_Last (0, 2);
Acts (278)(0) := (range_g_0'Access, null);
Acts (281).Set_First_Last (0, 1);
Acts (281)(0) := (record_definition_0'Access, null);
Acts (282).Set_First_Last (0, 0);
Acts (282)(0) := (record_representation_clause_0'Access, null);
Acts (291).Set_First_Last (0, 1);
Acts (291)(0) := (requeue_statement_0'Access, null);
Acts (291)(1) := (requeue_statement_1'Access, null);
Acts (292).Set_First_Last (0, 1);
Acts (292)(0) := (result_profile_0'Access, null);
Acts (292)(1) := (result_profile_1'Access, null);
Acts (294).Set_First_Last (0, 3);
Acts (294)(0) := (selected_component_0'Access, selected_component_0_check'Access);
Acts (294)(1) := (selected_component_1'Access, null);
Acts (294)(2) := (selected_component_2'Access, selected_component_2_check'Access);
Acts (294)(3) := (selected_component_3'Access, null);
Acts (295).Set_First_Last (0, 1);
Acts (295)(0) := (selective_accept_0'Access, null);
Acts (295)(1) := (selective_accept_1'Access, null);
Acts (296).Set_First_Last (0, 5);
Acts (296)(0) := (select_alternative_0'Access, null);
Acts (296)(1) := (select_alternative_1'Access, null);
Acts (296)(2) := (select_alternative_2'Access, null);
Acts (296)(4) := (select_alternative_4'Access, null);
Acts (297).Set_First_Last (0, 1);
Acts (297)(0) := (select_alternative_list_0'Access, null);
Acts (297)(1) := (select_alternative_list_1'Access, null);
Acts (303).Set_First_Last (0, 0);
Acts (303)(0) := (simple_return_statement_0'Access, null);
Acts (304).Set_First_Last (0, 10);
Acts (304)(0) := (simple_statement_0'Access, null);
Acts (304)(3) := (simple_statement_3'Access, null);
Acts (304)(8) := (simple_statement_8'Access, null);
Acts (305).Set_First_Last (0, 1);
Acts (305)(0) := (single_protected_declaration_0'Access, single_protected_declaration_0_check'Access);
Acts (305)(1) := (single_protected_declaration_1'Access, single_protected_declaration_1_check'Access);
Acts (306).Set_First_Last (0, 2);
Acts (306)(0) := (single_task_declaration_0'Access, single_task_declaration_0_check'Access);
Acts (306)(1) := (single_task_declaration_1'Access, single_task_declaration_1_check'Access);
Acts (306)(2) := (single_task_declaration_2'Access, null);
Acts (308).Set_First_Last (0, 0);
Acts (308)(0) := (subprogram_body_0'Access, subprogram_body_0_check'Access);
Acts (309).Set_First_Last (0, 0);
Acts (309)(0) := (subprogram_body_stub_0'Access, null);
Acts (310).Set_First_Last (0, 0);
Acts (310)(0) := (subprogram_declaration_0'Access, null);
Acts (311).Set_First_Last (0, 2);
Acts (311)(0) := (subprogram_default_0'Access, null);
Acts (312).Set_First_Last (0, 0);
Acts (312)(0) := (subprogram_renaming_declaration_0'Access, null);
Acts (313).Set_First_Last (0, 1);
Acts (313)(0) := (null, subprogram_specification_0_check'Access);
Acts (313)(1) := (null, subprogram_specification_1_check'Access);
Acts (314).Set_First_Last (0, 0);
Acts (314)(0) := (subtype_declaration_0'Access, null);
Acts (315).Set_First_Last (0, 3);
Acts (315)(0) := (subtype_indication_0'Access, null);
Acts (315)(1) := (subtype_indication_1'Access, null);
Acts (315)(2) := (subtype_indication_2'Access, null);
Acts (315)(3) := (subtype_indication_3'Access, null);
Acts (316).Set_First_Last (0, 0);
Acts (316)(0) := (subunit_0'Access, null);
Acts (317).Set_First_Last (0, 0);
Acts (317)(0) := (task_body_0'Access, task_body_0_check'Access);
Acts (318).Set_First_Last (0, 0);
Acts (318)(0) := (task_body_stub_0'Access, null);
Acts (319).Set_First_Last (0, 1);
Acts (319)(0) := (task_definition_0'Access, null);
Acts (319)(1) := (task_definition_1'Access, null);
Acts (320).Set_First_Last (0, 2);
Acts (320)(0) := (task_type_declaration_0'Access, task_type_declaration_0_check'Access);
Acts (320)(1) := (task_type_declaration_1'Access, task_type_declaration_1_check'Access);
Acts (320)(2) := (task_type_declaration_2'Access, null);
Acts (324).Set_First_Last (0, 0);
Acts (324)(0) := (timed_entry_call_0'Access, null);
Acts (328).Set_First_Last (0, 0);
Acts (328)(0) := (variant_part_0'Access, null);
Acts (329).Set_First_Last (0, 1);
Acts (329)(0) := (variant_list_0'Access, null);
Acts (330).Set_First_Last (0, 0);
Acts (330)(0) := (variant_0'Access, null);
Acts (332).Set_First_Last (0, 2);
Acts (332)(0) := (use_clause_0'Access, null);
Acts (332)(1) := (use_clause_1'Access, null);
Acts (332)(2) := (use_clause_2'Access, null);
Acts (333).Set_First_Last (0, 3);
Acts (333)(0) := (with_clause_0'Access, null);
Acts (333)(1) := (with_clause_1'Access, null);
Acts (333)(2) := (with_clause_2'Access, null);
Acts (333)(3) := (with_clause_3'Access, null);
end return;
end Actions;
Table : constant Parse_Table_Ptr := Get_Text_Rep
(Text_Rep_File_Name, McKenzie_Param, Actions);
begin
WisiToken.Parse.LR.Parser.New_Parser
(Parser,
Trace,
Lexer.New_Lexer (Trace.Descriptor),
Table,
Language_Fixes,
Language_Matching_Begin_Tokens,
Language_String_ID_Set,
User_Data,
Max_Parallel => 15,
Terminate_Same_State => True);
end Create_Parser;
end Ada_Process_LR1_Main;
|
with System;
package STM32F4.FMC is
FMC_Bank1_SDRAM : constant := 16#00000000#;
FMC_Bank2_SDRAM : constant := 16#00000001#;
FMC_Bank1_NORSRAM1 : constant := 16#00000000#;
FMC_Bank1_NORSRAM2 : constant := 16#00000002#;
FMC_Bank1_NORSRAM3 : constant := 16#00000004#;
FMC_Bank1_NORSRAM4 : constant := 16#00000006#;
FMC_Bank2_NAND : constant := 16#00000010#;
FMC_Bank3_NAND : constant := 16#00000100#;
FMC_Bank4_PCCARD : constant := 16#00001000#;
FMC_RowBits_Number_11b : constant := 16#00000000#;
FMC_RowBits_Number_12b : constant := 16#00000004#;
FMC_RowBits_Number_13b : constant := 16#00000008#;
FMC_ColumnBits_Number_8b : constant := 16#0000_0000#;
FMC_ColumnBits_Number_9b : constant := 16#0000_0001#;
FMC_ColumnBits_Number_10b : constant := 16#0000_0002#;
FMC_ColumnBits_Number_11b : constant := 16#0000_0003#;
FMC_SDMemory_Width_8b : constant := 16#0000_0000#;
FMC_SDMemory_Width_16b : constant := 16#0000_0010#;
FMC_SDMemory_Width_32b : constant := 16#0000_0020#;
FMC_InternalBank_Number_2 : constant := 16#0000_0000#;
FMC_InternalBank_Number_4 : constant := 16#0000_0040#;
FMC_CAS_Latency_1 : constant := 16#0000_0080#;
FMC_CAS_Latency_2 : constant := 16#0000_0100#;
FMC_CAS_Latency_3 : constant := 16#0000_0180#;
FMC_Write_Protection_Disable : constant := 16#0000_0000#;
FMC_Write_Protection_Enable : constant := 16#0000_0200#;
FMC_SDClock_Disable : constant := 16#0000_0000#;
FMC_SDClock_Period_2 : constant := 16#0000_0800#;
FMC_SDClock_Period_3 : constant := 16#0000_0C00#;
FMC_Read_Burst_Disable : constant := 16#0000_0000#;
FMC_Read_Burst_Enable : constant := 16#0000_1000#;
FMC_ReadPipe_Delay_0 : constant := 16#0000_0000#;
FMC_ReadPipe_Delay_1 : constant := 16#0000_2000#;
FMC_ReadPipe_Delay_2 : constant := 16#0000_4000#;
FMC_Command_Mode_Normal : constant := 16#0000_0000#;
FMC_Command_Mode_CLK_Enabled : constant := 16#0000_0001#;
FMC_Command_Mode_PALL : constant := 16#0000_0002#;
FMC_Command_Mode_AutoRefresh : constant := 16#0000_0003#;
FMC_Command_Mode_LoadMode : constant := 16#0000_0004#;
FMC_Command_Mode_Selfrefresh : constant := 16#0000_0005#;
FMC_Command_Mode_PowerDown : constant := 16#0000_0006#;
FMC_Command_Target_Bank2 : constant := 16#0000_0008#;
FMC_Command_Target_Bank1 : constant := 16#0000_0010#;
FMC_Command_Target_Bank1_2 : constant := 16#0000_0018#;
FMC_NormalMode_Status : constant := 16#0000_0000#;
-- FMC_SelfRefreshMode_Status : constant := FMC_SDSR_MODES1_0;
-- FMC_PowerDownMode_Status : constant := FMC_SDSR_MODES1_1;
FMC_IT_RisingEdge : constant := 16#0000_0008#;
FMC_IT_Level : constant := 16#0000_0010#;
FMC_IT_FallingEdge : constant := 16#0000_0020#;
FMC_IT_Refresh : constant := 16#0000_4000#;
FMC_FLAG_RisingEdge : constant := 16#0000_0001#;
FMC_FLAG_Level : constant := 16#0000_0002#;
FMC_FLAG_FallingEdge : constant := 16#0000_0004#;
FMC_FLAG_FEMPT : constant := 16#0000_0040#;
FMC_FLAG_Refresh : constant := 16#0000_0001#;
FMC_FLAG_Busy : constant := 16#0000_0020#;
type Word_x2 is array (0 .. 1) of Word with Pack, Size => 2 * 32;
FMC_Base : constant := 16#A000_0000#;
FMC_Bank1_R_BASE : constant := FMC_BASE + 16#0000#;
FMC_Bank1E_R_BASE : constant := FMC_BASE + 16#0104#;
FMC_Bank2_R_BASE : constant := FMC_BASE + 16#0060#;
FMC_Bank3_R_BASE : constant := FMC_BASE + 16#0080#;
FMC_Bank4_R_BASE : constant := FMC_BASE + 16#00A0#;
FMC_Bank5_6_R_BASE : constant := FMC_BASE + 16#0140#;
type FMC_Bank1_Registers is array (1 .. 8) of Word with Pack;
Bank1 : FMC_Bank1_Registers
with Volatile, Address => System'To_Address (FMC_Bank1_R_BASE);
type FMC_Bank1E_Registers is array (1 .. 7) of Word with Pack;
Bank1E : FMC_Bank1E_Registers
with Volatile, Address => System'To_Address (FMC_Bank1E_R_BASE);
type FMC_Bank2_3_Registers is record
PCR : Word;
SR : Word;
PMEM : Word;
PATT : Word;
Reserved : Word;
ECCR : Word;
end record with Pack, Size => 6 * 32;
Bank2 : FMC_Bank2_3_Registers
with Volatile, Address => System'To_Address (FMC_Bank2_R_BASE);
Bank3 : FMC_Bank2_3_Registers
with Volatile, Address => System'To_Address (FMC_Bank3_R_BASE);
type FMC_Bank4_Registers is record
PCR : Word;
SR : Word;
PMEM : Word;
PATT : Word;
PIO : Word;
end record with Pack, Size => 5 * 32;
Bank4 : FMC_Bank4_Registers
with Volatile, Address => System'To_Address (FMC_Bank4_R_BASE);
type FMC_Bank5_6_Registers is record
SDCR : Word_x2;
SDTR : Word_x2;
SDCMR : Word;
SDRTR : Word;
SDSR : Word;
end record with Pack, Size => 7 * 32;
Bank5_6 : FMC_Bank5_6_Registers
with Volatile, Address => System'To_Address (FMC_Bank5_6_R_BASE);
type FMC_SDRAM_TimingInit_Config is record
LoadToActiveDelay : Word;
ExitSelfRefreshDelay : Word;
SelfRefreshTime : Word;
RowCycleDelay : Word;
WriteRecoveryTime : Word;
RPDelay : Word;
RCDDelay : Word;
end record;
type FMC_SDRAM_Init_Config is record
Bank : Integer;
ColumnBitsNumber : Word;
RowBitsNumber : Word;
SDMemoryDataWidth : Word;
InternalBankNumber : Word;
CASLatency : Word;
WriteProtection : Word;
SDClockPeriod : Word;
ReadBurst : Word;
ReadPipeDelay : Word;
Timing_Conf : FMC_SDRAM_TimingInit_Config;
end record;
type FMC_SDRAM_Cmd_Conf is record
CommandMode : Word;
CommandTarget : Word;
AutoRefreshNumber : Word;
ModeRegisterDefinition : Word;
end record;
procedure FMC_SDRAM_Init (SDRAM_Conf : FMC_SDRAM_Init_Config);
procedure FMC_SDRAM_Cmd (Cmd : FMC_SDRAM_Cmd_Conf);
function FMC_Get_Flag (Bank : Word; Flag : Word) return Boolean;
procedure FMC_Set_Refresh_Count (Cnt : Word);
end STM32F4.FMC;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Szoroz is
pragma Suppress(Range_Check);
pragma Suppress(Overflow_Check);
I: Integer range 1..10000 := 1;
begin
for J in 1..100 loop
Put_Line(Integer'Image(I));
I := I * 10;
end loop;
end;
|
procedure Hello is
x: Integer := 1;
begin
get(x);
end Hello; |
-- --
-- package Copyright (c) Dmitry A. Kazakov --
-- Strings_Edit.Time_Conversions Luebeck --
-- Implementation Summer, 2016 --
-- --
-- Last revision : 13:13 14 Sep 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. --
--____________________________________________________________________--
with Ada.Exceptions; use Ada.Exceptions;
with Ada.IO_Exceptions; use Ada.IO_Exceptions;
with Strings_Edit.Integers; use Strings_Edit.Integers;
package body Strings_Edit.Time_Conversions is
procedure Check_Spelling (Name : String) is
begin
null;
end Check_Spelling;
function Check_Matched
( Source : String;
Pointer : Integer
) return Boolean is
begin
case Source (Pointer) is
when '0'..'9' | 'A'..'Z' | 'a'..'z' =>
return False;
when others =>
return True;
end case;
end Check_Matched;
function To_String (Date : Time) return String is
Year : Year_Number;
Month : Month_Number;
Day : Day_Number;
Seconds : Day_Duration;
function Day_Of_Week return String is
begin
case Day_Of_Week (Date) is
when Monday => return "Mon";
when Tuesday => return "Tue";
when Wednesday => return "Wed";
when Thursday => return "Thu";
when Friday => return "Fri";
when Saturday => return "Sat";
when Sunday => return "Sun";
end case;
end Day_Of_Week;
function Month_Name return String is
begin
case Month is
when 1 => return "Jan";
when 2 => return "Feb";
when 3 => return "Mar";
when 4 => return "Apr";
when 5 => return "May";
when 6 => return "Jun";
when 7 => return "Jul";
when 8 => return "Aug";
when 9 => return "Sep";
when 10 => return "Oct";
when 11 => return "Nov";
when 12 => return "Dec";
end case;
end Month_Name;
function Zone return String is
begin
declare
Offset : Time_Offset := UTC_Time_Offset (Date);
Pointer : Integer := 2;
Text : String (1..5);
begin
if Offset >= 0 then
Text (1) := '+';
else
Offset := -Offset;
Text (1) := '-';
end if;
Put
( Destination => Text,
Pointer => Pointer,
Value => Integer (Offset / 60),
Field => 2,
Justify => Right,
Fill => '0'
);
Put
( Destination => Text,
Pointer => Pointer,
Value => Integer (Offset rem 60),
Field => 2,
Justify => Right,
Fill => '0'
);
return Text;
end;
exception
when Unknown_Zone_Error =>
return "GMT";
end Zone;
begin
Split (Date, Year, Month, Day, Seconds);
return
( Day_Of_Week
& ", "
& Image (Integer (Day))
& ' '
& Month_Name
& ' '
& Image (Integer (Year))
& ' '
& Image (Duration (Seconds))
& ' '
& Zone
);
end To_String;
function To_Time (Date : String) return Time is
Year : Year_Number;
Month : Month_Number;
Day : Day_Number;
Week_Day : Day_Name;
Hour : Hour_Number;
Minute : Minute_Number;
Second : Second_Number;
Zone : Time_Zones.Time_Offset;
Got_It : Boolean;
Pointer : Integer := Date'First;
procedure Get_Year (Expand : Boolean) is
Value : Integer;
begin
Get (Date, Pointer, Value);
if Expand then
if Value < 50 then
Year := Year_Number (Value + 2000);
elsif Value < 100 then
Year := Year_Number (Value + 1900);
end if;
else
Year := Year_Number (Value);
end if;
exception
when others =>
Raise_Exception
( Data_Error'Identity,
"Wrong or missing year number"
);
end Get_Year;
procedure Get_Day is
begin
Get (Date, Pointer, Integer (Day));
exception
when others =>
Raise_Exception
( Data_Error'Identity,
"Wrong or missing day number"
);
end Get_Day;
procedure Get_Month is
begin
Get (Date, Pointer, Months, Month, Got_It);
if not Got_It then
Raise_Exception
( Data_Error'Identity,
"Wrong or missing month name"
);
end if;
end Get_Month;
procedure Get_Time is
begin
begin
Get (Date, Pointer, Integer (Hour));
exception
when others =>
Raise_Exception
( Data_Error'Identity,
"Wrong or missing hour number"
);
end;
if Date (Pointer) = ':' then
Pointer := Pointer + 1;
else
Raise_Exception (Data_Error'Identity, "Colon is expected");
end if;
begin
Get (Date, Pointer, Integer (Minute));
exception
when others =>
Raise_Exception
( Data_Error'Identity,
"Wrong or missing minute number"
);
end;
if Date (Pointer) = ':' then
Pointer := Pointer + 1;
else
Raise_Exception (Data_Error'Identity, "Colon is expected");
end if;
begin
Get (Date, Pointer, Integer (Second));
exception
when others =>
Raise_Exception
( Data_Error'Identity,
"Wrong or missing second number"
);
end;
end Get_Time;
procedure Get_Zone is
procedure Get_Offset is
begin
Zone :=
Time_Offset
( Integer'(Value (Date (Pointer - 3..Pointer - 3)))
+ Integer'(Value (Date (Pointer - 2..Pointer - 1)))
);
if Date (Pointer - 4) = '-' then
Zone := -Zone;
end if;
exception
when others =>
Raise_Exception
( Data_Error'Identity,
"Wrong time zone offset"
);
end Get_Offset;
begin
Get (Date, Pointer, Zones, Zone, Got_It);
if not Got_It then
if Pointer + 4 < Date'Last then
Raise_Exception
( Data_Error'Identity,
"Wrong time zone offset"
);
end if;
if Date (Pointer) = '+' or else Date (Pointer) = '-' then
Pointer := Pointer + 5;
Get_Offset;
else
Raise_Exception
( Data_Error'Identity,
"Missing sign of time zone offset"
);
end if;
end if;
end Get_Zone;
begin
Get (Date, Pointer, Week_Days, Week_Day, Got_It);
if not Got_It then
Raise_Exception
( Data_Error'Identity,
"Wrong or missing week day: " & Date (Pointer..Date'Last)
);
end if;
if Date (Pointer) = ',' then
Pointer := Pointer + 1;
end if;
Get (Date, Pointer);
Get (Date, Pointer, Months, Month, Got_It); -- Dec 31 23:59:59
if Got_It then
Get (Date, Pointer);
Get_Day;
else -- No month
Get_Day;
if Date (Pointer) = '-' then -- 31-Dec-99 23:59:59 GMT
Pointer := Pointer + 1;
Get_Month;
if Date (Pointer) = '-' then
Pointer := Pointer + 1;
else
Raise_Exception
( Data_Error'Identity,
"Hyphen is expected after the month name"
);
end if;
Get_Year (True);
else -- 31 Dec 1999 23:59:59 GMT
Get (Date, Pointer);
Get_Month;
Get (Date, Pointer);
Get_Year (False);
end if;
Get (Date, Pointer);
Get_Time;
Get (Date, Pointer);
Get_Zone;
end if;
return
Time_Of
( Year => Year,
Month => Month,
Day => Day,
Hour => Hour,
Minute => Minute,
Second => Second,
Time_Zone => Zone
);
exception
when Time_Error =>
Raise_Exception
( Data_Error'Identity,
"Illegal date specification"
);
end To_Time;
begin
Add (Week_Days, "Fri", Friday);
Add (Week_Days, "Friday", Friday);
Add (Week_Days, "Mon", Monday);
Add (Week_Days, "Monday", Monday);
Add (Week_Days, "Sat", Saturday);
Add (Week_Days, "Saturday", Saturday);
Add (Week_Days, "Sun", Sunday);
Add (Week_Days, "Sunday", Sunday);
Add (Week_Days, "Thu", Thursday);
Add (Week_Days, "Thursday", Thursday);
Add (Week_Days, "Tue", Tuesday);
Add (Week_Days, "Tuesday", Tuesday);
Add (Week_Days, "Wed", Wednesday);
Add (Week_Days, "Wednesday", Wednesday);
Add (Months, "Apr", 4);
Add (Months, "April", 4);
Add (Months, "Aug", 8);
Add (Months, "August", 8);
Add (Months, "Dec", 12);
Add (Months, "December", 12);
Add (Months, "Feb", 2);
Add (Months, "February", 2);
Add (Months, "Jan", 1);
Add (Months, "January", 1);
Add (Months, "Jul", 7);
Add (Months, "July", 7);
Add (Months, "Jun", 6);
Add (Months, "June", 6);
Add (Months, "Mar", 3);
Add (Months, "March", 3);
Add (Months, "May", 5);
Add (Months, "Nov", 11);
Add (Months, "November", 11);
Add (Months, "Oct", 10);
Add (Months, "October", 10);
Add (Months, "Sep", 9);
Add (Months, "September", 9);
Add (Zones, "UT", 0);
Add (Zones, "GMT", 0);
Add (Zones, "EDT", -4*60);
Add (Zones, "EST", -5*60);
Add (Zones, "CDT", -5*60);
Add (Zones, "CST", -6*60);
Add (Zones, "MDT", -6*60);
Add (Zones, "MST", -7*60);
Add (Zones, "PDT", -7*60);
Add (Zones, "PST", -8*60);
Add (Zones, "Z", 0);
Add (Zones, "A", -1*60);
Add (Zones, "M", -12*60);
Add (Zones, "N", 1*60);
Add (Zones, "Y", 12*60);
end Strings_Edit.Time_Conversions;
|
-- The Beer-Ware License (revision 42)
--
-- Jacob Sparre Andersen <jacob@jacob-sparre.dk> wrote this. As long as you
-- retain this notice you can do whatever you want with this stuff. If we meet
-- some day, and you think this stuff is worth it, you can buy me a beer in
-- return.
--
-- Jacob Sparre Andersen
private with Sound.ALSA;
package Sound.Mono is
type Line_Type is private;
type Frame is range -(2 ** 15) .. (2 ** 15) - 1;
for Frame'Size use 16;
type Frame_Array is array (Integer range <>) of aliased Frame;
pragma Convention (C, Frame_Array);
procedure Open (Line : in out Line_Type;
Mode : in Line_Mode;
Resolution : in out Sample_Frequency;
Buffer_Size : in out Duration;
Period : in out Duration);
function Is_Open (Line : in Line_Type) return Boolean;
procedure Close (Line : in out Line_Type);
procedure Read (Line : in Line_Type;
Item : out Frame_Array;
Last : out Natural);
procedure Write (Line : in Line_Type;
Item : in Frame_Array;
Last : out Natural);
private
type Line_Type is new Sound.ALSA.snd_pcm_t_ptr;
end Sound.Mono;
|
with Common_Formal_Containers; use Common_Formal_Containers;
package AFRL.CMASI.AutomationResponse.SPARK_Boundary with SPARK_Mode is
pragma Annotate (GNATprove, Terminating, SPARK_Boundary);
function Get_WaypointEntity_Set
(Response : AutomationResponse) return Int64_Set
with Global => null;
end AFRL.CMASI.AutomationResponse.SPARK_Boundary;
|
with SiFive.UART; use SiFive.UART;
with System; use System;
with SiFive.SPI; use SiFive.SPI;
with SiFive.PWM; use SiFive.PWM;
with SiFive.GPIO; use SiFive.GPIO;
package SiFive.Device is
-- GPIO0 --
GPIO0 : aliased GPIO_Controller (268828672);
P00 : aliased GPIO_Point (GPIO0'Access, 0);
P01 : aliased GPIO_Point (GPIO0'Access, 1);
P02 : aliased GPIO_Point (GPIO0'Access, 2);
P03 : aliased GPIO_Point (GPIO0'Access, 3);
P04 : aliased GPIO_Point (GPIO0'Access, 4);
P05 : aliased GPIO_Point (GPIO0'Access, 5);
P06 : aliased GPIO_Point (GPIO0'Access, 6);
P07 : aliased GPIO_Point (GPIO0'Access, 7);
P08 : aliased GPIO_Point (GPIO0'Access, 8);
P09 : aliased GPIO_Point (GPIO0'Access, 9);
P010 : aliased GPIO_Point (GPIO0'Access, 10);
P011 : aliased GPIO_Point (GPIO0'Access, 11);
P012 : aliased GPIO_Point (GPIO0'Access, 12);
P013 : aliased GPIO_Point (GPIO0'Access, 13);
P014 : aliased GPIO_Point (GPIO0'Access, 14);
P015 : aliased GPIO_Point (GPIO0'Access, 15);
-- QSPI0 --
QSPI0 : aliased SPI_Controller (268697600);
-- QSPI1 --
QSPI1 : aliased SPI_Controller (268701696);
-- QSPI2 --
QSPI2 : aliased SPI_Controller (268763136);
-- PWM0 --
PWM0_Internal : aliased SiFive.PWM.Internal_PWM
with Import, Address => System'To_Address (268566528);
PWM0 : aliased SiFive.PWM.PWM_Device (PWM0_Internal'Access);
-- PWM1 --
PWM1_Internal : aliased SiFive.PWM.Internal_PWM
with Import, Address => System'To_Address (268570624);
PWM1 : aliased SiFive.PWM.PWM_Device (PWM1_Internal'Access);
-- UART0 --
UART0 : aliased SiFive.UART.UART_Device (268500992);
-- UART1 --
UART1 : aliased SiFive.UART.UART_Device (268505088);
end SiFive.Device;
|
-- Standard Ada library specification
-- Copyright (c) 2004-2016 AXE Consultants
-- Copyright (c) 2004, 2005, 2006 Ada-Europe
-- Copyright (c) 2000 The MITRE Corporation, Inc.
-- Copyright (c) 1992, 1993, 1994, 1995 Intermetrics, Inc.
-- SPDX-License-Identifier: BSD-3-Clause and LicenseRef-AdaReferenceManual
---------------------------------------------------------------------------
package System.Storage_Pools.Subpools is
pragma Preelaborate (Subpools);
type Root_Storage_Pool_With_Subpools is
abstract new Root_Storage_Pool with private;
type Root_Subpool is abstract tagged limited private;
type Subpool_Handle is access all Root_Subpool'Class;
for Subpool_Handle'Storage_Size use 0;
function Create_Subpool (Pool : in out Root_Storage_Pool_With_Subpools)
return not null Subpool_Handle is abstract;
-- The following operations are intended for pool implementers:
function Pool_of_Subpool (Subpool : not null Subpool_Handle)
return access Root_Storage_Pool_With_Subpools'Class;
procedure Set_Pool_of_Subpool (
Subpool : in not null Subpool_Handle;
To : in out Root_Storage_Pool_With_Subpools'Class);
procedure Allocate_From_Subpool (
Pool : in out Root_Storage_Pool_With_Subpools;
Storage_Address : out Address;
Size_In_Storage_Elements : in Storage_Elements.Storage_Count;
Alignment : in Storage_Elements.Storage_Count;
Subpool : in not null Subpool_Handle) is abstract
with Pre'Class => Pool_of_Subpool(Subpool) = Pool'Access;
procedure Deallocate_Subpool (
Pool : in out Root_Storage_Pool_With_Subpools;
Subpool : in out Subpool_Handle) is abstract
with Pre'Class => Pool_of_Subpool(Subpool) = Pool'Access;
function Default_Subpool_for_Pool (
Pool : in out Root_Storage_Pool_With_Subpools)
return not null Subpool_Handle;
overriding
procedure Allocate (
Pool : in out Root_Storage_Pool_With_Subpools;
Storage_Address : out Address;
Size_In_Storage_Elements : in Storage_Elements.Storage_Count;
Alignment : in Storage_Elements.Storage_Count);
overriding
procedure Deallocate (
Pool : in out Root_Storage_Pool_With_Subpools;
Storage_Address : in Address;
Size_In_Storage_Elements : in Storage_Elements.Storage_Count;
Alignment : in Storage_Elements.Storage_Count) is null;
overriding
function Storage_Size (Pool : Root_Storage_Pool_With_Subpools)
return Storage_Elements.Storage_Count
is (Storage_Elements.Storage_Count'Last);
private
-- not specified by the language
end System.Storage_Pools.Subpools;
|
with Interfaces;
with SPARKNaCl;
package Random
with SPARK_Mode => On,
Abstract_State => (Entropy with External => Async_Writers)
is
--===========================
-- Exported subprograms
--===========================
function Random_Byte return Interfaces.Unsigned_8
with Global => Entropy,
Volatile_Function;
procedure Random_Bytes (R : out SPARKNaCl.Byte_Seq)
with Global => Entropy;
end Random;
|
-----------------------------------------------------------------------
-- pschema - Print the database schema
-- Copyright (C) 2009, 2010, 2011, 2012, 2015 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 ADO;
with ADO.Drivers;
with ADO.Configs;
with ADO.Sessions;
with ADO.Sessions.Factory;
with ADO.Schemas;
with Ada.Text_IO;
with Ada.Exceptions;
with Ada.Command_Line;
with Util.Strings.Transforms;
with Util.Log.Loggers;
procedure Pschema is
use ADO;
use Ada;
use ADO.Schemas;
use Util.Strings.Transforms;
function To_Model_Type (Kind : in ADO.Schemas.Column_Type) return String;
function To_Model_Type (Kind : in ADO.Schemas.Column_Type) return String is
begin
case Kind is
when T_BOOLEAN =>
return "boolean";
when T_TINYINT | T_SMALLINT | T_INTEGER =>
return "integer";
when T_LONG_INTEGER =>
return "long";
when T_TIME | T_DATE_TIME | T_TIMESTAMP =>
return "datetime";
when T_DATE =>
return "date";
when T_BLOB =>
return "blob";
when T_VARCHAR =>
return "string";
when others =>
return "?";
end case;
end To_Model_Type;
Factory : ADO.Sessions.Factory.Session_Factory;
begin
Util.Log.Loggers.Initialize ("samples.properties");
-- Initialize the database drivers.
ADO.Drivers.Initialize ("samples.properties");
-- Initialize the session factory to connect to the
-- database defined by 'ado.database' property.
if Ada.Command_Line.Argument_Count < 1 then
Ada.Text_IO.Put_Line ("Usage: pschema connection");
Ada.Text_IO.Put_Line ("Example: pschema mysql://localhost:3306/test");
Ada.Command_Line.Set_Exit_Status (2);
return;
end if;
Factory.Create (Ada.Command_Line.Argument (1));
declare
DB : constant ADO.Sessions.Master_Session := Factory.Get_Master_Session;
Schema : ADO.Schemas.Schema_Definition;
Iter : Table_Cursor;
begin
DB.Load_Schema (Schema);
-- Dump the database schema using SQL create table forms.
Iter := Get_Tables (Schema);
while Has_Element (Iter) loop
declare
Table : constant Table_Definition := Element (Iter);
Table_Iter : Column_Cursor := Get_Columns (Table);
begin
-- Ada.Text_IO.Put_Line ("create table " & Get_Name (Table) & " (");
Ada.Text_IO.Put_Line (Get_Name (Table) & ":");
Ada.Text_IO.Put_Line (" type: entity");
Ada.Text_IO.Put (" table: ");
Ada.Text_IO.Put_Line (Get_Name (Table));
Ada.Text_IO.Put_Line (" id:");
while Has_Element (Table_Iter) loop
declare
Col : constant Column_Definition := Element (Table_Iter);
begin
if Is_Primary (Col) then
Ada.Text_IO.Put (" ");
Ada.Text_IO.Put (To_Lower_Case (Get_Name (Col)));
Ada.Text_IO.Put_Line (":");
Ada.Text_IO.Put (" type: ");
if Get_Type (Col) in T_INTEGER | T_LONG_INTEGER then
Ada.Text_IO.Put_Line ("identifier");
else
Ada.Text_IO.Put_Line (To_Model_Type (Get_Type (Col)));
Ada.Text_IO.Put (" length:");
Ada.Text_IO.Put_Line (Natural'Image (Get_Size (Col)));
end if;
Ada.Text_IO.Put (" column: ");
Ada.Text_IO.Put (Get_Name (Col));
Ada.Text_IO.Put (" not-null: ");
Ada.Text_IO.Put_Line ((if Is_Null (Col) then "true" else "false"));
end if;
end;
Next (Table_Iter);
end loop;
Ada.Text_IO.Put_Line (" fields:");
Table_Iter := Get_Columns (Table);
while Has_Element (Table_Iter) loop
declare
Col : constant Column_Definition := Element (Table_Iter);
begin
if not Is_Primary (Col) then
Ada.Text_IO.Put (" ");
Ada.Text_IO.Put (To_Lower_Case (Get_Name (Col)));
Ada.Text_IO.Put_Line (":");
Ada.Text_IO.Put (" type: ");
Ada.Text_IO.Put_Line (To_Model_Type (Get_Type (Col)));
if Get_Size (Col) > 0 then
Ada.Text_IO.Put (" length:");
Ada.Text_IO.Put_Line (Natural'Image (Get_Size (Col)));
end if;
Ada.Text_IO.Put (" column: ");
Ada.Text_IO.Put_Line (Get_Name (Col));
Ada.Text_IO.Put (" not-null: ");
Ada.Text_IO.Put_Line ((if Is_Null (Col) then "true" else "false"));
end if;
end;
Next (Table_Iter);
end loop;
-- Ada.Text_IO.Put_Line (");");
end;
Next (Iter);
end loop;
end;
exception
when E : ADO.Sessions.Connection_Error =>
Ada.Text_IO.Put_Line ("Cannot connect to database: "
& Ada.Exceptions.Exception_Message (E));
end Pschema;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- P A R . C H 1 3 --
-- --
-- B o d y --
-- --
-- Copyright (C) 1992-2015, Free Software Foundation, Inc. --
-- --
-- GNAT is free software; you can redistribute it and/or modify it under --
-- terms of the GNU General Public License as published by the Free Soft- --
-- ware Foundation; either version 3, or (at your option) any later ver- --
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
-- for more details. You should have received a copy of the GNU General --
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
-- http://www.gnu.org/licenses for a complete copy of the license. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
pragma Style_Checks (All_Checks);
-- Turn off subprogram body ordering check. Subprograms are in order
-- by RM section rather than alphabetical
separate (Par)
package body Ch13 is
-- Local functions, used only in this chapter
function P_Component_Clause return Node_Id;
function P_Mod_Clause return Node_Id;
-----------------------------------
-- Aspect_Specifications_Present --
-----------------------------------
function Aspect_Specifications_Present
(Strict : Boolean := Ada_Version < Ada_2012) return Boolean
is
Scan_State : Saved_Scan_State;
Result : Boolean;
function Possible_Misspelled_Aspect return Boolean;
-- Returns True, if Token_Name is a misspelling of some aspect name
function With_Present return Boolean;
-- Returns True if WITH is present, indicating presence of aspect
-- specifications. Also allows incorrect use of WHEN in place of WITH.
--------------------------------
-- Possible_Misspelled_Aspect --
--------------------------------
function Possible_Misspelled_Aspect return Boolean is
begin
for J in Aspect_Id_Exclude_No_Aspect loop
if Is_Bad_Spelling_Of (Token_Name, Aspect_Names (J)) then
return True;
end if;
end loop;
return False;
end Possible_Misspelled_Aspect;
------------------
-- With_Present --
------------------
function With_Present return Boolean is
begin
if Token = Tok_With then
return True;
-- Check for WHEN used in place of WITH
elsif Token = Tok_When then
declare
Scan_State : Saved_Scan_State;
begin
Save_Scan_State (Scan_State);
Scan; -- past WHEN
if Token = Tok_Identifier
and then Get_Aspect_Id (Token_Name) /= No_Aspect
then
Error_Msg_SC ("WHEN should be WITH");
Restore_Scan_State (Scan_State);
return True;
else
Restore_Scan_State (Scan_State);
return False;
end if;
end;
else
return False;
end if;
end With_Present;
-- Start of processing for Aspect_Specifications_Present
begin
-- Definitely must have WITH to consider aspect specs to be present
-- Note that this means that if we have a semicolon, we immediately
-- return False. There is a case in which this is not optimal, namely
-- something like
-- type R is new Integer;
-- with bla bla;
-- where the semicolon is redundant, but scanning forward for it would
-- be too expensive. Instead we pick up the aspect specifications later
-- as a bogus declaration, and diagnose the semicolon at that point.
if not With_Present then
return False;
end if;
-- Have a WITH or some token that we accept as a legitimate bad attempt
-- at writing WITH. See if it looks like an aspect specification
Save_Scan_State (Scan_State);
Scan; -- past WITH (or WHEN or other bad keyword)
-- If no identifier, then consider that we definitely do not have an
-- aspect specification.
if Token /= Tok_Identifier then
Result := False;
-- This is where we pay attention to the Strict mode. Normally when
-- we are in Ada 2012 mode, Strict is False, and we consider that we
-- have an aspect specification if the identifier is an aspect name
-- or a likely misspelling of one (even if not followed by =>) or
-- the identifier is not an aspect name but is followed by =>, by
-- a comma, or by a semicolon. The last two cases correspond to
-- (misspelled) Boolean aspects with a defaulted value of True.
-- P_Aspect_Specifications will generate messages if the aspect
-- specification is ill-formed.
elsif not Strict then
if Get_Aspect_Id (Token_Name) /= No_Aspect
or else Possible_Misspelled_Aspect
then
Result := True;
else
Scan; -- past identifier
Result := Token = Tok_Arrow or else
Token = Tok_Comma or else
Token = Tok_Semicolon;
end if;
-- If earlier than Ada 2012, check for valid aspect identifier (possibly
-- completed with 'CLASS) followed by an arrow, and consider that this
-- is still an aspect specification so we give an appropriate message.
else
if Get_Aspect_Id (Token_Name) = No_Aspect then
Result := False;
else
Scan; -- past aspect name
Result := False;
if Token = Tok_Arrow then
Result := True;
-- The identifier may be the name of a boolean aspect with a
-- defaulted True value. Further checks when analyzing aspect
-- specification, which may include further aspects.
elsif Token = Tok_Comma or else Token = Tok_Semicolon then
Result := True;
elsif Token = Tok_Apostrophe then
Scan; -- past apostrophe
if Token = Tok_Identifier
and then Token_Name = Name_Class
then
Scan; -- past CLASS
if Token = Tok_Arrow then
Result := True;
end if;
end if;
end if;
if Result then
Restore_Scan_State (Scan_State);
Error_Msg_Ada_2012_Feature ("|aspect specification", Token_Ptr);
return True;
end if;
end if;
end if;
Restore_Scan_State (Scan_State);
return Result;
end Aspect_Specifications_Present;
-------------------------------
-- Get_Aspect_Specifications --
-------------------------------
function Get_Aspect_Specifications
(Semicolon : Boolean := True) return List_Id
is
A_Id : Aspect_Id;
Aspect : Node_Id;
Aspects : List_Id;
OK : Boolean;
Opt : Boolean;
-- True if current aspect takes an optional argument
begin
Aspects := Empty_List;
-- Check if aspect specification present
if not Aspect_Specifications_Present then
if Semicolon then
TF_Semicolon;
end if;
return Aspects;
end if;
Scan; -- past WITH (or possible WHEN after error)
Aspects := Empty_List;
-- Loop to scan aspects
loop
OK := True;
-- The aspect mark is not an identifier
if Token /= Tok_Identifier then
Error_Msg_SC ("aspect identifier expected");
-- Skip the whole aspect specification list
if Semicolon then
Resync_Past_Semicolon;
end if;
return Aspects;
end if;
A_Id := Get_Aspect_Id (Token_Name);
Aspect :=
Make_Aspect_Specification (Token_Ptr,
Identifier => Token_Node);
-- The aspect mark is not recognized
if A_Id = No_Aspect then
Error_Msg_N ("& is not a valid aspect identifier", Token_Node);
OK := False;
-- Check bad spelling
for J in Aspect_Id_Exclude_No_Aspect loop
if Is_Bad_Spelling_Of (Token_Name, Aspect_Names (J)) then
Error_Msg_Name_1 := Aspect_Names (J);
Error_Msg_N -- CODEFIX
("\possible misspelling of%", Token_Node);
exit;
end if;
end loop;
Scan; -- past incorrect identifier
if Token = Tok_Apostrophe then
Scan; -- past apostrophe
Scan; -- past presumably CLASS
end if;
-- Attempt to parse the aspect definition by assuming it is an
-- expression.
if Token = Tok_Arrow then
Scan; -- past arrow
Set_Expression (Aspect, P_Expression);
-- If we have a correct terminator (comma or semicolon, or a
-- reasonable likely missing comma), then just proceed.
elsif Token = Tok_Comma or else
Token = Tok_Semicolon or else
Token = Tok_Identifier
then
null;
-- Otherwise the aspect contains a junk definition
else
if Semicolon then
Resync_Past_Semicolon;
end if;
return Aspects;
end if;
-- Aspect mark is OK
else
Scan; -- past identifier
Opt := Aspect_Argument (A_Id) = Optional_Expression
or else
Aspect_Argument (A_Id) = Optional_Name;
-- Check for 'Class present
if Token = Tok_Apostrophe then
if Class_Aspect_OK (A_Id) then
Scan; -- past apostrophe
if Token = Tok_Identifier
and then Token_Name = Name_Class
then
Scan; -- past CLASS
Set_Class_Present (Aspect);
else
Error_Msg_SC ("Class attribute expected here");
OK := False;
if Token = Tok_Identifier then
Scan; -- past identifier not CLASS
end if;
end if;
-- The aspect does not allow 'Class
else
Error_Msg_Node_1 := Identifier (Aspect);
Error_Msg_SC ("aspect& does not permit attribute here");
OK := False;
Scan; -- past apostrophe
Scan; -- past presumably CLASS
end if;
end if;
-- Check for a missing aspect definition. Aspects with optional
-- definitions are not considered.
if Token = Tok_Comma or else Token = Tok_Semicolon then
if not Opt then
Error_Msg_Node_1 := Identifier (Aspect);
Error_Msg_AP ("aspect& requires an aspect definition");
OK := False;
end if;
-- Here we do not have a comma or a semicolon, we are done if we
-- do not have an arrow and the aspect does not need an argument
elsif Opt and then Token /= Tok_Arrow then
null;
-- Here we have either an arrow, or an aspect that definitely
-- needs an aspect definition, and we will look for one even if
-- no arrow is preseant.
-- Otherwise we have an aspect definition
else
if Token = Tok_Arrow then
Scan; -- past arrow
else
T_Arrow;
OK := False;
end if;
-- Detect a common error where the non-null definition of
-- aspect Depends, Global, Refined_Depends, Refined_Global
-- or Refined_State lacks enclosing parentheses.
if Token /= Tok_Left_Paren and then Token /= Tok_Null then
-- [Refined_]Depends
if A_Id = Aspect_Depends
or else
A_Id = Aspect_Refined_Depends
then
Error_Msg_SC -- CODEFIX
("missing ""(""");
Resync_Past_Malformed_Aspect;
-- Return when the current aspect is the last in the list
-- of specifications and the list applies to a body.
if Token = Tok_Is then
return Aspects;
end if;
-- [Refined_]Global
elsif A_Id = Aspect_Global
or else
A_Id = Aspect_Refined_Global
then
declare
Scan_State : Saved_Scan_State;
begin
Save_Scan_State (Scan_State);
Scan; -- past item or mode_selector
-- Emit an error when the aspect has a mode_selector
-- as the moded_global_list must be parenthesized:
-- with Global => Output => Item
if Token = Tok_Arrow then
Restore_Scan_State (Scan_State);
Error_Msg_SC -- CODEFIX
("missing ""(""");
Resync_Past_Malformed_Aspect;
-- Return when the current aspect is the last in
-- the list of specifications and the list applies
-- to a body.
if Token = Tok_Is then
return Aspects;
end if;
elsif Token = Tok_Comma then
Scan; -- past comma
-- An item followed by a comma does not need to
-- be parenthesized if the next token is a valid
-- aspect name:
-- with Global => Item,
-- Aspect => ...
if Token = Tok_Identifier
and then Get_Aspect_Id (Token_Name) /= No_Aspect
then
Restore_Scan_State (Scan_State);
-- Otherwise this is a list of items in which case
-- the list must be parenthesized.
else
Restore_Scan_State (Scan_State);
Error_Msg_SC -- CODEFIX
("missing ""(""");
Resync_Past_Malformed_Aspect;
-- Return when the current aspect is the last
-- in the list of specifications and the list
-- applies to a body.
if Token = Tok_Is then
return Aspects;
end if;
end if;
-- The definition of [Refined_]Global does not need to
-- be parenthesized.
else
Restore_Scan_State (Scan_State);
end if;
end;
-- Refined_State
elsif A_Id = Aspect_Refined_State then
if Token = Tok_Identifier then
declare
Scan_State : Saved_Scan_State;
begin
Save_Scan_State (Scan_State);
Scan; -- past state
-- The refinement contains a constituent, the whole
-- argument of Refined_State must be parenthesized.
-- with Refined_State => State => Constit
if Token = Tok_Arrow then
Restore_Scan_State (Scan_State);
Error_Msg_SC -- CODEFIX
("missing ""(""");
Resync_Past_Malformed_Aspect;
-- Return when the current aspect is the last
-- in the list of specifications and the list
-- applies to a body.
if Token = Tok_Is then
return Aspects;
end if;
-- The refinement lacks constituents. Do not flag
-- this case as the error would be misleading. The
-- diagnostic is left to the analysis.
-- with Refined_State => State
else
Restore_Scan_State (Scan_State);
end if;
end;
end if;
end if;
end if;
-- Note if inside Depends aspect
if A_Id = Aspect_Depends then
Inside_Depends := True;
end if;
-- Parse the aspect definition depening on the expected
-- argument kind.
if Aspect_Argument (A_Id) = Name
or else Aspect_Argument (A_Id) = Optional_Name
then
Set_Expression (Aspect, P_Name);
else
pragma Assert
(Aspect_Argument (A_Id) = Expression
or else
Aspect_Argument (A_Id) = Optional_Expression);
Set_Expression (Aspect, P_Expression);
end if;
-- Unconditionally reset flag for Inside_Depends
Inside_Depends := False;
end if;
-- Add the aspect to the resulting list only when it was properly
-- parsed.
if OK then
Append (Aspect, Aspects);
end if;
end if;
-- Merge here after good or bad aspect (we should be at a comma
-- or a semicolon, but there might be other possible errors).
-- The aspect specification list contains more than one aspect
if Token = Tok_Comma then
Scan; -- past comma
goto Continue;
-- Check for a missing comma between two aspects. Emit an error
-- and proceed to the next aspect.
elsif Token = Tok_Identifier
and then Get_Aspect_Id (Token_Name) /= No_Aspect
then
declare
Scan_State : Saved_Scan_State;
begin
Save_Scan_State (Scan_State);
Scan; -- past identifier
-- Attempt to detect ' or => following a potential aspect
-- mark.
if Token = Tok_Apostrophe or else Token = Tok_Arrow then
Restore_Scan_State (Scan_State);
Error_Msg_AP -- CODEFIX
("|missing "",""");
goto Continue;
-- The construct following the current aspect is not an
-- aspect.
else
Restore_Scan_State (Scan_State);
end if;
end;
-- Check for a mistyped semicolon in place of a comma between two
-- aspects. Emit an error and proceed to the next aspect.
elsif Token = Tok_Semicolon then
declare
Scan_State : Saved_Scan_State;
begin
Save_Scan_State (Scan_State);
Scan; -- past semicolon
if Token = Tok_Identifier
and then Get_Aspect_Id (Token_Name) /= No_Aspect
then
Scan; -- past identifier
-- Attempt to detect ' or => following potential aspect mark
if Token = Tok_Apostrophe or else Token = Tok_Arrow then
Restore_Scan_State (Scan_State);
Error_Msg_SC -- CODEFIX
("|"";"" should be "",""");
Scan; -- past semicolon
goto Continue;
end if;
end if;
-- Construct following the current aspect is not an aspect
Restore_Scan_State (Scan_State);
end;
end if;
-- Require semicolon if caller expects to scan this out
if Semicolon then
T_Semicolon;
end if;
exit;
<<Continue>>
null;
end loop;
return Aspects;
end Get_Aspect_Specifications;
--------------------------------------------
-- 13.1 Representation Clause (also I.7) --
--------------------------------------------
-- REPRESENTATION_CLAUSE ::=
-- ATTRIBUTE_DEFINITION_CLAUSE
-- | ENUMERATION_REPRESENTATION_CLAUSE
-- | RECORD_REPRESENTATION_CLAUSE
-- | AT_CLAUSE
-- ATTRIBUTE_DEFINITION_CLAUSE ::=
-- for LOCAL_NAME'ATTRIBUTE_DESIGNATOR use EXPRESSION;
-- | for LOCAL_NAME'ATTRIBUTE_DESIGNATOR use NAME;
-- Note: in Ada 83, the expression must be a simple expression
-- AT_CLAUSE ::= for DIRECT_NAME use at EXPRESSION;
-- Note: in Ada 83, the expression must be a simple expression
-- ENUMERATION_REPRESENTATION_CLAUSE ::=
-- for first_subtype_LOCAL_NAME use ENUMERATION_AGGREGATE;
-- ENUMERATION_AGGREGATE ::= ARRAY_AGGREGATE
-- RECORD_REPRESENTATION_CLAUSE ::=
-- for first_subtype_LOCAL_NAME use
-- record [MOD_CLAUSE]
-- {COMPONENT_CLAUSE}
-- end record;
-- Note: for now we allow only a direct name as the local name in the
-- above constructs. This probably needs changing later on ???
-- The caller has checked that the initial token is FOR
-- Error recovery: cannot raise Error_Resync, if an error occurs,
-- the scan is repositioned past the next semicolon.
function P_Representation_Clause return Node_Id is
For_Loc : Source_Ptr;
Name_Node : Node_Id;
Prefix_Node : Node_Id;
Attr_Name : Name_Id;
Identifier_Node : Node_Id;
Rep_Clause_Node : Node_Id;
Expr_Node : Node_Id;
Record_Items : List_Id;
begin
For_Loc := Token_Ptr;
Scan; -- past FOR
-- Note that the name in a representation clause is always a simple
-- name, even in the attribute case, see AI-300 which made this so.
Identifier_Node := P_Identifier (C_Use);
-- Check case of qualified name to give good error message
if Token = Tok_Dot then
Error_Msg_SC
("representation clause requires simple name!");
loop
exit when Token /= Tok_Dot;
Scan; -- past dot
Discard_Junk_Node (P_Identifier);
end loop;
end if;
-- Attribute Definition Clause
if Token = Tok_Apostrophe then
-- Allow local names of the form a'b'.... This enables
-- us to parse class-wide streams attributes correctly.
Name_Node := Identifier_Node;
while Token = Tok_Apostrophe loop
Scan; -- past apostrophe
Identifier_Node := Token_Node;
Attr_Name := No_Name;
if Token = Tok_Identifier then
Attr_Name := Token_Name;
-- Note that the parser must complain in case of an internal
-- attribute name that comes from source since internal names
-- are meant to be used only by the compiler.
if not Is_Attribute_Name (Attr_Name)
and then (not Is_Internal_Attribute_Name (Attr_Name)
or else Comes_From_Source (Token_Node))
then
Signal_Bad_Attribute;
end if;
if Style_Check then
Style.Check_Attribute_Name (False);
end if;
-- Here for case of attribute designator is not an identifier
else
if Token = Tok_Delta then
Attr_Name := Name_Delta;
elsif Token = Tok_Digits then
Attr_Name := Name_Digits;
elsif Token = Tok_Access then
Attr_Name := Name_Access;
else
Error_Msg_AP ("attribute designator expected");
raise Error_Resync;
end if;
if Style_Check then
Style.Check_Attribute_Name (True);
end if;
end if;
-- Here we have an OK attribute scanned, and the corresponding
-- Attribute identifier node is stored in Ident_Node.
Prefix_Node := Name_Node;
Name_Node := New_Node (N_Attribute_Reference, Prev_Token_Ptr);
Set_Prefix (Name_Node, Prefix_Node);
Set_Attribute_Name (Name_Node, Attr_Name);
Scan;
-- Check for Address clause which needs to be marked for use in
-- optimizing performance of Exp_Util.Following_Address_Clause.
if Attr_Name = Name_Address
and then Nkind (Prefix_Node) = N_Identifier
then
Set_Name_Table_Boolean1 (Chars (Prefix_Node), True);
end if;
end loop;
Rep_Clause_Node := New_Node (N_Attribute_Definition_Clause, For_Loc);
Set_Name (Rep_Clause_Node, Prefix_Node);
Set_Chars (Rep_Clause_Node, Attr_Name);
T_Use;
Expr_Node := P_Expression_No_Right_Paren;
Check_Simple_Expression_In_Ada_83 (Expr_Node);
Set_Expression (Rep_Clause_Node, Expr_Node);
else
TF_Use;
Rep_Clause_Node := Empty;
-- AT follows USE (At Clause)
if Token = Tok_At then
Scan; -- past AT
Rep_Clause_Node := New_Node (N_At_Clause, For_Loc);
Set_Identifier (Rep_Clause_Node, Identifier_Node);
Expr_Node := P_Expression_No_Right_Paren;
Check_Simple_Expression_In_Ada_83 (Expr_Node);
Set_Expression (Rep_Clause_Node, Expr_Node);
-- Mark occurrence of address clause (used to optimize performance
-- of Exp_Util.Following_Address_Clause).
Set_Name_Table_Boolean1 (Chars (Identifier_Node), True);
-- RECORD follows USE (Record Representation Clause)
elsif Token = Tok_Record then
Record_Items := P_Pragmas_Opt;
Rep_Clause_Node :=
New_Node (N_Record_Representation_Clause, For_Loc);
Set_Identifier (Rep_Clause_Node, Identifier_Node);
Push_Scope_Stack;
Scope.Table (Scope.Last).Etyp := E_Record;
Scope.Table (Scope.Last).Ecol := Start_Column;
Scope.Table (Scope.Last).Sloc := Token_Ptr;
Scan; -- past RECORD
Record_Items := P_Pragmas_Opt;
-- Possible Mod Clause
if Token = Tok_At then
Set_Mod_Clause (Rep_Clause_Node, P_Mod_Clause);
Set_Pragmas_Before (Mod_Clause (Rep_Clause_Node), Record_Items);
Record_Items := P_Pragmas_Opt;
end if;
if No (Record_Items) then
Record_Items := New_List;
end if;
Set_Component_Clauses (Rep_Clause_Node, Record_Items);
-- Loop through component clauses
loop
if Token not in Token_Class_Name then
exit when Check_End;
end if;
Append (P_Component_Clause, Record_Items);
P_Pragmas_Opt (Record_Items);
end loop;
-- Left paren follows USE (Enumeration Representation Clause)
elsif Token = Tok_Left_Paren then
Rep_Clause_Node :=
New_Node (N_Enumeration_Representation_Clause, For_Loc);
Set_Identifier (Rep_Clause_Node, Identifier_Node);
Set_Array_Aggregate (Rep_Clause_Node, P_Aggregate);
-- Some other token follows FOR (invalid representation clause)
else
Error_Msg_SC ("invalid representation clause");
raise Error_Resync;
end if;
end if;
TF_Semicolon;
return Rep_Clause_Node;
exception
when Error_Resync =>
Resync_Past_Semicolon;
return Error;
end P_Representation_Clause;
----------------------
-- 13.1 Local Name --
----------------------
-- Local name is always parsed by its parent. In the case of its use in
-- pragmas, the check for a local name is handled in Par.Prag and allows
-- all the possible forms of local name. For the uses in chapter 13, we
-- currently only allow a direct name, but this should probably change???
---------------------------
-- 13.1 At Clause (I.7) --
---------------------------
-- Parsed by P_Representation_Clause (13.1)
---------------------------------------
-- 13.3 Attribute Definition Clause --
---------------------------------------
-- Parsed by P_Representation_Clause (13.1)
--------------------------------
-- 13.1 Aspect Specification --
--------------------------------
-- ASPECT_SPECIFICATION ::=
-- with ASPECT_MARK [=> ASPECT_DEFINITION] {,
-- ASPECT_MARK [=> ASPECT_DEFINITION] }
-- ASPECT_MARK ::= aspect_IDENTIFIER['Class]
-- ASPECT_DEFINITION ::= NAME | EXPRESSION
-- Error recovery: cannot raise Error_Resync
procedure P_Aspect_Specifications
(Decl : Node_Id;
Semicolon : Boolean := True)
is
Aspects : List_Id;
Ptr : Source_Ptr;
begin
-- Aspect Specification is present
Ptr := Token_Ptr;
-- Here we have an aspect specification to scan, note that we don't
-- set the flag till later, because it may turn out that we have no
-- valid aspects in the list.
Aspects := Get_Aspect_Specifications (Semicolon);
-- Here if aspects present
if Is_Non_Empty_List (Aspects) then
-- If Decl is Empty, we just ignore the aspects (the caller in this
-- case has always issued an appropriate error message).
if Decl = Empty then
null;
-- If Decl is Error, we ignore the aspects, and issue a message
elsif Decl = Error then
Error_Msg ("aspect specifications not allowed here", Ptr);
-- Here aspects are allowed, and we store them
else
Set_Parent (Aspects, Decl);
Set_Aspect_Specifications (Decl, Aspects);
end if;
end if;
end P_Aspect_Specifications;
---------------------------------------------
-- 13.4 Enumeration Representation Clause --
---------------------------------------------
-- Parsed by P_Representation_Clause (13.1)
---------------------------------
-- 13.4 Enumeration Aggregate --
---------------------------------
-- Parsed by P_Representation_Clause (13.1)
------------------------------------------
-- 13.5.1 Record Representation Clause --
------------------------------------------
-- Parsed by P_Representation_Clause (13.1)
------------------------------
-- 13.5.1 Mod Clause (I.8) --
------------------------------
-- MOD_CLAUSE ::= at mod static_EXPRESSION;
-- Note: in Ada 83, the expression must be a simple expression
-- The caller has checked that the initial Token is AT
-- Error recovery: cannot raise Error_Resync
-- Note: the caller is responsible for setting the Pragmas_Before field
function P_Mod_Clause return Node_Id is
Mod_Node : Node_Id;
Expr_Node : Node_Id;
begin
Mod_Node := New_Node (N_Mod_Clause, Token_Ptr);
Scan; -- past AT
T_Mod;
Expr_Node := P_Expression_No_Right_Paren;
Check_Simple_Expression_In_Ada_83 (Expr_Node);
Set_Expression (Mod_Node, Expr_Node);
TF_Semicolon;
return Mod_Node;
end P_Mod_Clause;
------------------------------
-- 13.5.1 Component Clause --
------------------------------
-- COMPONENT_CLAUSE ::=
-- COMPONENT_CLAUSE_COMPONENT_NAME at POSITION
-- range FIRST_BIT .. LAST_BIT;
-- COMPONENT_CLAUSE_COMPONENT_NAME ::=
-- component_DIRECT_NAME
-- | component_DIRECT_NAME'ATTRIBUTE_DESIGNATOR
-- | FIRST_SUBTYPE_DIRECT_NAME'ATTRIBUTE_DESIGNATOR
-- POSITION ::= static_EXPRESSION
-- Note: in Ada 83, the expression must be a simple expression
-- FIRST_BIT ::= static_SIMPLE_EXPRESSION
-- LAST_BIT ::= static_SIMPLE_EXPRESSION
-- Note: the AARM V2.0 grammar has an error at this point, it uses
-- EXPRESSION instead of SIMPLE_EXPRESSION for FIRST_BIT and LAST_BIT
-- Error recovery: cannot raise Error_Resync
function P_Component_Clause return Node_Id is
Component_Node : Node_Id;
Comp_Name : Node_Id;
Expr_Node : Node_Id;
begin
Component_Node := New_Node (N_Component_Clause, Token_Ptr);
Comp_Name := P_Name;
if Nkind (Comp_Name) = N_Identifier
or else Nkind (Comp_Name) = N_Attribute_Reference
then
Set_Component_Name (Component_Node, Comp_Name);
else
Error_Msg_N
("component name must be direct name or attribute", Comp_Name);
Set_Component_Name (Component_Node, Error);
end if;
Set_Sloc (Component_Node, Token_Ptr);
T_At;
Expr_Node := P_Expression_No_Right_Paren;
Check_Simple_Expression_In_Ada_83 (Expr_Node);
Set_Position (Component_Node, Expr_Node);
T_Range;
Expr_Node := P_Expression_No_Right_Paren;
Check_Simple_Expression_In_Ada_83 (Expr_Node);
Set_First_Bit (Component_Node, Expr_Node);
T_Dot_Dot;
Expr_Node := P_Expression_No_Right_Paren;
Check_Simple_Expression_In_Ada_83 (Expr_Node);
Set_Last_Bit (Component_Node, Expr_Node);
TF_Semicolon;
return Component_Node;
end P_Component_Clause;
----------------------
-- 13.5.1 Position --
----------------------
-- Parsed by P_Component_Clause (13.5.1)
-----------------------
-- 13.5.1 First Bit --
-----------------------
-- Parsed by P_Component_Clause (13.5.1)
----------------------
-- 13.5.1 Last Bit --
----------------------
-- Parsed by P_Component_Clause (13.5.1)
--------------------------
-- 13.8 Code Statement --
--------------------------
-- CODE_STATEMENT ::= QUALIFIED_EXPRESSION
-- On entry the caller has scanned the SUBTYPE_MARK (passed in as the
-- single argument, and the scan points to the apostrophe.
-- Error recovery: can raise Error_Resync
function P_Code_Statement (Subtype_Mark : Node_Id) return Node_Id is
Node1 : Node_Id;
begin
Scan; -- past apostrophe
-- If left paren, then we have a possible code statement
if Token = Tok_Left_Paren then
Node1 := New_Node (N_Code_Statement, Sloc (Subtype_Mark));
Set_Expression (Node1, P_Qualified_Expression (Subtype_Mark));
TF_Semicolon;
return Node1;
-- Otherwise we have an illegal range attribute. Note that P_Name
-- ensures that Token = Tok_Range is the only possibility left here.
else
Error_Msg_SC ("RANGE attribute illegal here!");
raise Error_Resync;
end if;
end P_Code_Statement;
end Ch13;
|
with Ada.Strings.Unbounded; use Ada.Strings.Unbounded;
with Ada.Text_IO, Ada.Characters.Latin_1;
procedure Longest_String_Challenge is
function "+"(S: String) return Unbounded_String renames To_Unbounded_String;
function "-"(U: Unbounded_String) return String renames To_String;
Separator: constant Character := Ada.Characters.Latin_1.NUL;
procedure Funny_Stuff(B, L: in out Unbounded_String;
N: Unbounded_String;
S, T: String) is
C: Character;
begin
C:= T(T'First); -- (1) raises Constraint_Error if T is empty
begin
C := S(S'First); -- (2) raises Constraint_Error if S is empty
-- at this point, we know that neither S nor T are empty
Funny_Stuff(B,L,N,S(S'First+1 .. S'Last), T(T'First+1..T'Last));
exception
when Constraint_Error => -- come from (2), S is empty, T is not empty!
B := N;
L := N;
end;
exception
when Constraint_Error => -- come from (1), T is empty
begin
C := S(S'First); -- (3) raises Constraint_Error if S is empty
-- at this point, we know that T is empty and S isn't
null;
exception
when Constraint_Error => -- come from (3); both S and T are empty
B := B & Separator & N;
end;
end Funny_Stuff;
Buffer: Unbounded_String := +"";
Longest: Unbounded_String := +"";
Next: Unbounded_String;
begin
while True loop
Next := + Ada.Text_IO.Get_Line;
-- (4) raises exception when trying to read beyond end of file
Funny_Stuff(Buffer, Longest, Next, -Longest, -Next);
end loop;
exception
when others => -- come from (4)
for I in To_String(Buffer)'Range loop
if To_String(Buffer)(I) = Separator then
Ada.Text_IO.New_Line;
else
Ada.Text_IO.Put(To_String(Buffer)(I));
end if;
end loop;
end Longest_String_Challenge;
|
-- Abstract :
--
-- Grammar semantic check routines.
--
-- Copyright (C) 2017 - 2019 Free Software Foundation, Inc.
--
-- This library is free software; you can redistribute it and/or modify it
-- under terms of the GNU General Public License as published by the Free
-- Software Foundation; either version 3, or (at your option) any later
-- version. This library is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-
-- TABILITY or FITNESS FOR A PARTICULAR PURPOSE.
-- As a special exception under Section 7 of GPL version 3, you are granted
-- additional permissions described in the GCC Runtime Library Exception,
-- version 3.1, as published by the Free Software Foundation.
pragma License (Modified_GPL);
with WisiToken.Lexer;
package WisiToken.Semantic_Checks is
type Check_Status_Label is
(Ok,
Missing_Name_Error, -- block start has name, required block end name missing
Extra_Name_Error, -- block start has no name, end has one
Match_Names_Error); -- both names present, but don't match
subtype Error is Check_Status_Label range Check_Status_Label'Succ (Ok) .. Check_Status_Label'Last;
type Check_Status (Label : Check_Status_Label := Ok) is record
case Label is
when Ok =>
null;
when Error =>
Begin_Name : Recover_Token;
End_Name : Recover_Token;
end case;
end record;
subtype Error_Check_Status is Check_Status
with Dynamic_Predicate => Error_Check_Status.Label /= Ok;
function Image (Item : in Check_Status; Descriptor : WisiToken.Descriptor) return String;
type Semantic_Check is access function
(Lexer : access constant WisiToken.Lexer.Instance'Class;
Nonterm : in out Recover_Token;
Tokens : in Recover_Token_Array;
Recover_Active : in Boolean)
return Check_Status;
-- Called during parsing and error recovery to implement higher level
-- checks, such as block name matching in Ada.
Null_Check : constant Semantic_Check := null;
function Match_Names
(Lexer : access constant WisiToken.Lexer.Instance'Class;
Descriptor : in WisiToken.Descriptor;
Tokens : in Recover_Token_Array;
Start_Index : in Positive_Index_Type;
End_Index : in Positive_Index_Type;
End_Optional : in Boolean)
return Check_Status;
-- Check that buffer text at Tokens (Start_Index).Name matches buffer
-- text at Tokens (End_Index).Name. Comparison is controlled by
-- Descriptor.Case_Insensitive.
function Propagate_Name
(Nonterm : in out Recover_Token;
Tokens : in Recover_Token_Array;
Name_Index : in Positive_Index_Type)
return Check_Status;
function Merge_Names
(Nonterm : in out Recover_Token;
Tokens : in Recover_Token_Array;
Name_Index : in Positive_Index_Type)
return Check_Status
renames Propagate_Name;
-- Set Nonterm.Name to Tokens (Name_Index).Name, or .Byte_Region, if
-- .Name is Null_Buffer_Region. Return Ok.
function Merge_Names
(Nonterm : in out Recover_Token;
Tokens : in Recover_Token_Array;
First_Index : in Positive_Index_Type;
Last_Index : in Positive_Index_Type)
return Check_Status;
-- Then set Nonterm.Name to the merger of Tokens (First_Index ..
-- Last_Index).Name, return Ok.
--
-- If Tokens (Last_Index).Name is Null_Buffer_Region, use Tokens
-- (Last_Index).Byte_Region instead.
function Terminate_Partial_Parse
(Partial_Parse_Active : in Boolean;
Partial_Parse_Byte_Goal : in Buffer_Pos;
Recover_Active : in Boolean;
Nonterm : in Recover_Token)
return Check_Status;
pragma Inline (Terminate_Partial_Parse);
-- If Active, raise Wisitoken.Partial_Parse; otherwise return Ok.
end WisiToken.Semantic_Checks;
|
------------------------------------------------------------------------------
-- --
-- Copyright (C) 2020, AdaCore --
-- --
-- Redistribution and use in source and binary forms, with or without --
-- modification, are permitted provided that the following conditions are --
-- met: --
-- 1. Redistributions of source code must retain the above copyright --
-- notice, this list of conditions and the following disclaimer. --
-- 2. Redistributions in binary form must reproduce the above copyright --
-- notice, this list of conditions and the following disclaimer in --
-- the documentation and/or other materials provided with the --
-- distribution. --
-- 3. Neither the name of the copyright holder nor the names of its --
-- contributors may be used to endorse or promote products derived --
-- from this software without specific prior written permission. --
-- --
-- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS --
-- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT --
-- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR --
-- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT --
-- HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, --
-- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT --
-- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, --
-- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY --
-- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT --
-- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE --
-- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. --
-- --
------------------------------------------------------------------------------
package body SAM.SERCOM.I2C is
---------------
-- Configure --
---------------
procedure Configure (This : in out I2C_Device;
Baud : UInt8)
is
CTRLB : SERCOM_CTRLB_SERCOM_I2CM_Register;
begin
This.Reset;
This.Periph.SERCOM_I2CM.CTRLA.MODE := 5;
This.Wait_Sync;
This.Periph.SERCOM_I2CM.BAUD := (BAUD => Baud,
BAUDLOW => 0,
HSBAUD => Baud,
HSBAUDLOW => 0);
CTRLB := This.Periph.SERCOM_I2CM.CTRLB;
CTRLB.SMEN := False; -- Smart mode
This.Periph.SERCOM_I2CM.CTRLB := CTRLB;
This.Wait_Sync;
This.Periph.SERCOM_I2CM.STATUS.BUSSTATE := 1; -- Set to IDLE
This.Wait_Sync;
This.Config_Done := True;
end Configure;
------------------
-- Data_Address --
------------------
function Data_Address (This : I2C_Device) return System.Address
is (This.Periph.SERCOM_I2CM.Data'Address);
---------------------
-- Master_Transmit --
---------------------
overriding
procedure Master_Transmit
(This : in out I2C_Device;
Addr : I2C_Address;
Data : I2C_Data;
Status : out I2C_Status;
Timeout : Natural := 1000)
is
begin
-- Address is shifted to the left to use bit 0 as read/write mode
Status := This.Send_Addr (UInt11 (Addr) * 2);
if Status /= Ok then
This.Cmd_Stop;
return;
end if;
for Elt of Data loop
This.Periph.SERCOM_I2CM.DATA := UInt32 (Elt);
This.Wait_Bus;
Status := This.Bus_Status;
exit when Status /= Ok;
end loop;
if This.Do_Stop_Sequence then
This.Cmd_Stop;
end if;
end Master_Transmit;
--------------------
-- Master_Receive --
--------------------
overriding
procedure Master_Receive
(This : in out I2C_Device;
Addr : I2C_Address;
Data : out I2C_Data;
Status : out I2C_Status;
Timeout : Natural := 1000)
is
begin
if Data'Length = 0 then
Status := Ok;
return;
end if;
-- Address is shifted to the left to use bit 0 as read/write mode
Status := This.Send_Addr ((UInt11 (Addr) * 2) or 1);
if Status /= Ok then
This.Cmd_Stop;
return;
end if;
-- Get the first byte
Data (Data'First) := UInt8 (This.Periph.SERCOM_I2CM.DATA);
for Index in Data'First + 1 .. Data'Last loop
This.Cmd_Read;
This.Wait_Bus;
Status := This.Bus_Status;
exit when Status /= Ok;
Data (Index) := UInt8 (This.Periph.SERCOM_I2CM.DATA);
end loop;
This.Cmd_Nack;
This.Cmd_Stop;
end Master_Receive;
---------------
-- Mem_Write --
---------------
overriding
procedure Mem_Write
(This : in out I2C_Device;
Addr : I2C_Address;
Mem_Addr : UInt16;
Mem_Addr_Size : I2C_Memory_Address_Size;
Data : I2C_Data;
Status : out I2C_Status;
Timeout : Natural := 1000)
is
begin
This.Do_Stop_Sequence := False;
case Mem_Addr_Size is
when Memory_Size_8b =>
This.Master_Transmit (Addr => Addr,
Data => (0 => UInt8 (Mem_Addr)),
Status => Status,
Timeout => Timeout);
when Memory_Size_16b =>
This.Master_Transmit (Addr => Addr,
Data => (UInt8 (Shift_Right (Mem_Addr, 8)),
UInt8 (Mem_Addr and 16#FF#)),
Status => Status,
Timeout => Timeout);
end case;
This.Do_Stop_Sequence := True;
if Status /= Ok then
This.Cmd_Stop;
return;
end if;
This.Master_Transmit (Addr => Addr,
Data => Data,
Status => Status,
Timeout => Timeout);
end Mem_Write;
--------------
-- Mem_Read --
--------------
overriding
procedure Mem_Read
(This : in out I2C_Device;
Addr : I2C_Address;
Mem_Addr : UInt16;
Mem_Addr_Size : I2C_Memory_Address_Size;
Data : out I2C_Data;
Status : out I2C_Status;
Timeout : Natural := 1000)
is
begin
This.Do_Stop_Sequence := False;
case Mem_Addr_Size is
when Memory_Size_8b =>
This.Master_Transmit (Addr => Addr,
Data => (0 => UInt8 (Mem_Addr)),
Status => Status,
Timeout => Timeout);
when Memory_Size_16b =>
This.Master_Transmit (Addr => Addr,
Data => (UInt8 (Shift_Right (Mem_Addr, 8)),
UInt8 (Mem_Addr and 16#FF#)),
Status => Status,
Timeout => Timeout);
end case;
This.Do_Stop_Sequence := True;
if Status /= Ok then
This.Cmd_Stop;
return;
end if;
This.Master_Receive (Addr => Addr,
Data => Data,
Status => Status,
Timeout => Timeout);
end Mem_Read;
---------------
-- Wait_Sync --
---------------
procedure Wait_Sync (This : in out I2C_Device) is
begin
while This.Periph.SERCOM_I2CM.SYNCBUSY.SYSOP loop
null;
end loop;
end Wait_Sync;
--------------
-- Wait_Bus --
--------------
procedure Wait_Bus (This : in out I2C_Device) is
INTFLAG : SERCOM_INTFLAG_SERCOM_I2CM_Register;
begin
loop
INTFLAG := This.Periph.SERCOM_I2CM.INTFLAG;
exit when INTFLAG.MB or else INTFLAG.SB or else INTFLAG.ERROR;
end loop;
end Wait_Bus;
---------------
-- Send_Addr --
---------------
function Send_Addr (This : in out I2C_Device;
Addr : UInt11)
return I2C_Status
is
Reg : SERCOM_ADDR_SERCOM_I2CM_Register;
begin
Reg := This.Periph.SERCOM_I2CM.ADDR;
Reg.ADDR := Addr;
Reg.TENBITEN := False;
Reg.HS := False; -- High-speed transfer
Reg.LENEN := False; -- Automatic transfer length
This.Periph.SERCOM_I2CM.ADDR := Reg;
This.Wait_Sync;
This.Wait_Bus;
return This.Bus_Status;
end Send_Addr;
--------------
-- Cmd_Stop --
--------------
procedure Cmd_Stop (This : in out I2C_Device) is
begin
This.Periph.SERCOM_I2CM.CTRLB.CMD := 3;
This.Wait_Sync;
end Cmd_Stop;
--------------
-- Cmd_Nack --
--------------
procedure Cmd_Nack (This : in out I2C_Device) is
begin
This.Periph.SERCOM_I2CM.CTRLB.ACKACT := True;
This.Wait_Sync;
end Cmd_Nack;
--------------
-- Cmd_Read --
--------------
procedure Cmd_Read (This : in out I2C_Device) is
CTRLB : SERCOM_CTRLB_SERCOM_I2CM_Register;
begin
CTRLB := This.Periph.SERCOM_I2CM.CTRLB;
CTRLB.CMD := 2; -- Read command
CTRLB.ACKACT := False; -- False means send ack
This.Periph.SERCOM_I2CM.CTRLB := CTRLB;
This.Wait_Sync;
end Cmd_Read;
----------------
-- Bus_Status --
----------------
function Bus_Status (This : I2C_Device) return I2C_Status is
begin
if This.Periph.SERCOM_I2CM.STATUS.RXNACK
or else
This.Periph.SERCOM_I2CM.STATUS.BUSERR
then
return HAL.I2C.Err_Error; -- We should have an addr nack status value
elsif This.Periph.SERCOM_I2CM.STATUS.ARBLOST then
return HAL.I2C.Busy;
else
return HAL.I2C.Ok;
end if;
end Bus_Status;
end SAM.SERCOM.I2C;
|
-- Abstract :
--
-- See spec.
--
-- Copyright (C) 2002 - 2005, 2008 - 2015, 2017 - 2019 Free Software Foundation, Inc.
--
-- This file is part of the WisiToken package.
--
-- The WisiToken package 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. The WisiToken package 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 distributed with the WisiToken package;
-- see file GPL.txt. If not, write to the Free Software Foundation,
-- 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.
pragma License (Modified_GPL);
with Ada.Exceptions;
package body WisiToken.Parse.LR.Parser_No_Recover is
procedure Reduce_Stack_1
(Current_Parser : in Parser_Lists.Cursor;
Action : in Reduce_Action_Rec;
Nonterm : out WisiToken.Syntax_Trees.Valid_Node_Index;
Trace : in out WisiToken.Trace'Class)
is
Parser_State : Parser_Lists.Parser_State renames Current_Parser.State_Ref.Element.all;
Children_Tree : Syntax_Trees.Valid_Node_Index_Array (1 .. SAL.Base_Peek_Type (Action.Token_Count));
-- for Set_Children.
begin
for I in reverse Children_Tree'Range loop
Children_Tree (I) := Parser_State.Stack.Pop.Token;
end loop;
Nonterm := Parser_State.Tree.Add_Nonterm
(Action.Production, Children_Tree, Action.Action, Default_Virtual => False);
-- Computes Nonterm.Byte_Region
if Trace_Parse > Detail then
Trace.Put_Line (Parser_State.Tree.Image (Nonterm, Trace.Descriptor.all, Include_Children => True));
end if;
end Reduce_Stack_1;
procedure Do_Action
(Action : in Parse_Action_Rec;
Current_Parser : in Parser_Lists.Cursor;
Shared_Parser : in Parser)
is
Parser_State : Parser_Lists.Parser_State renames Current_Parser.State_Ref;
Trace : WisiToken.Trace'Class renames Shared_Parser.Trace.all;
Nonterm : WisiToken.Syntax_Trees.Valid_Node_Index;
begin
if Trace_Parse > Detail then
Trace.Put
(Integer'Image (Current_Parser.Label) & ": " &
Trimmed_Image (Parser_State.Stack.Peek.State) & ": " &
Parser_State.Tree.Image (Parser_State.Current_Token, Trace.Descriptor.all) & " : ");
Put (Trace, Action);
Trace.New_Line;
end if;
case Action.Verb is
when Shift =>
Current_Parser.Set_Verb (Shift);
Parser_State.Stack.Push ((Action.State, Parser_State.Current_Token));
Parser_State.Tree.Set_State (Parser_State.Current_Token, Action.State);
when Reduce =>
Current_Parser.Set_Verb (Reduce);
declare
New_State : constant Unknown_State_Index := Goto_For
(Table => Shared_Parser.Table.all,
State => Parser_State.Stack (SAL.Base_Peek_Type (Action.Token_Count) + 1).State,
ID => Action.Production.LHS);
begin
if New_State = Unknown_State then
-- This is due to a bug in the LALR parser generator (see
-- lalr_generator_bug_01.wy); we treat it as a syntax error.
Current_Parser.Set_Verb (Error);
if Trace_Parse > Detail then
Trace.Put_Line (" ... error");
end if;
else
Reduce_Stack_1 (Current_Parser, Action, Nonterm, Trace);
Parser_State.Stack.Push ((New_State, Nonterm));
Parser_State.Tree.Set_State (Nonterm, New_State);
if Trace_Parse > Detail then
Trace.Put_Line (" ... goto state " & Trimmed_Image (New_State));
end if;
end if;
end;
when Accept_It =>
Current_Parser.Set_Verb (Accept_It);
Reduce_Stack_1
(Current_Parser,
(Reduce, Action.Production, Action.Action, Action.Check, Action.Token_Count),
Nonterm, Trace);
Parser_State.Tree.Set_Root (Nonterm);
when Error =>
Current_Parser.Set_Verb (Action.Verb);
-- We don't raise Syntax_Error here; another parser may be able to
-- continue.
declare
Expecting : constant Token_ID_Set := LR.Expecting
(Shared_Parser.Table.all, Current_Parser.State_Ref.Stack.Peek.State);
begin
Parser_State.Errors.Append
((Label => LR.Action,
First_Terminal => Trace.Descriptor.First_Terminal,
Last_Terminal => Trace.Descriptor.Last_Terminal,
Error_Token => Parser_State.Current_Token,
Expecting => Expecting,
Recover => (others => <>)));
if Trace_Parse > Outline then
Put
(Trace,
Integer'Image (Current_Parser.Label) & ": expecting: " &
Image (Expecting, Trace.Descriptor.all));
Trace.New_Line;
end if;
end;
end case;
end Do_Action;
-- Return the type of parser cycle to execute.
--
-- Accept : all Parsers.Verb return Accept - done parsing.
--
-- Shift : some Parsers.Verb return Shift.
--
-- Reduce : some Parsers.Verb return Reduce.
--
-- Error : all Parsers.Verb return Error.
procedure Parse_Verb
(Shared_Parser : in out Parser;
Verb : out All_Parse_Action_Verbs)
is
Shift_Count : SAL.Base_Peek_Type := 0;
Accept_Count : SAL.Base_Peek_Type := 0;
Error_Count : SAL.Base_Peek_Type := 0;
begin
for Parser_State of Shared_Parser.Parsers loop
case Parser_State.Verb is
when Shift =>
Shift_Count := Shift_Count + 1;
when Reduce =>
Verb := Reduce;
return;
when Accept_It =>
Accept_Count := Accept_Count + 1;
when Error =>
Error_Count := Error_Count + 1;
when Pause =>
-- This is parser_no_recover
raise SAL.Programmer_Error;
end case;
end loop;
if Shared_Parser.Parsers.Count = Accept_Count then
Verb := Accept_It;
elsif Shared_Parser.Parsers.Count = Error_Count then
Verb := Error;
elsif Shift_Count > 0 then
Verb := Shift;
else
raise SAL.Programmer_Error;
end if;
end Parse_Verb;
----------
-- Public subprograms, declaration order
overriding procedure Finalize (Object : in out Parser)
is begin
Free_Table (Object.Table);
end Finalize;
procedure New_Parser
(Parser : out LR.Parser_No_Recover.Parser;
Trace : not null access WisiToken.Trace'Class;
Lexer : in WisiToken.Lexer.Handle;
Table : in Parse_Table_Ptr;
User_Data : in WisiToken.Syntax_Trees.User_Data_Access;
Max_Parallel : in SAL.Base_Peek_Type := Default_Max_Parallel;
First_Parser_Label : in Integer := 1;
Terminate_Same_State : in Boolean := True)
is
use all type Syntax_Trees.User_Data_Access;
begin
Parser.Lexer := Lexer;
Parser.Trace := Trace;
Parser.Table := Table;
Parser.User_Data := User_Data;
Parser.Max_Parallel := Max_Parallel;
Parser.First_Parser_Label := First_Parser_Label;
Parser.Terminate_Same_State := Terminate_Same_State;
if User_Data /= null then
User_Data.Set_Lexer_Terminals (Lexer, Parser.Terminals'Unchecked_Access);
end if;
end New_Parser;
overriding procedure Parse (Shared_Parser : aliased in out Parser)
is
use all type Syntax_Trees.User_Data_Access;
Trace : WisiToken.Trace'Class renames Shared_Parser.Trace.all;
Current_Verb : All_Parse_Action_Verbs;
Current_Parser : Parser_Lists.Cursor;
Action : Parse_Action_Node_Ptr;
procedure Check_Error (Check_Parser : in out Parser_Lists.Cursor)
is begin
if Check_Parser.Verb = Error then
-- This parser errored on last input. This is how grammar conflicts
-- are resolved when the input text is valid, so we terminate this
-- parser.
if Shared_Parser.Parsers.Count = 1 then
raise Syntax_Error;
else
Shared_Parser.Parsers.Terminate_Parser
(Check_Parser, "", Shared_Parser.Trace.all, Shared_Parser.Terminals);
end if;
else
Check_Parser.Next;
end if;
end Check_Error;
begin
if Shared_Parser.User_Data /= null then
Shared_Parser.User_Data.Reset;
end if;
Shared_Parser.Lex_All;
Shared_Parser.Shared_Tree.Clear;
Shared_Parser.Parsers := Parser_Lists.New_List
(Shared_Tree => Shared_Parser.Shared_Tree'Unchecked_Access);
Shared_Parser.Parsers.First.State_Ref.Stack.Push ((Shared_Parser.Table.State_First, others => <>));
Main_Loop :
loop
-- exit on Accept_It action or syntax error.
Parse_Verb (Shared_Parser, Current_Verb);
case Current_Verb is
when Shift =>
-- All parsers just shifted a token; get the next token
for Parser_State of Shared_Parser.Parsers loop
Parser_State.Shared_Token := Parser_State.Shared_Token + 1;
Parser_State.Current_Token := Parser_State.Tree.Add_Terminal
(Parser_State.Shared_Token, Shared_Parser.Terminals);
end loop;
when Accept_It =>
-- All parsers accepted.
declare
Count : constant SAL.Base_Peek_Type := Shared_Parser.Parsers.Count;
begin
if Count = 1 then
-- Nothing more to do
if Trace_Parse > Outline then
Trace.Put_Line (Integer'Image (Shared_Parser.Parsers.First.Label) & ": succeed");
end if;
exit Main_Loop;
else
-- More than one parser is active; ambiguous parse.
declare
Token : Base_Token renames Shared_Parser.Terminals (Shared_Parser.Terminals.Last_Index);
begin
raise WisiToken.Parse_Error with Error_Message
(Shared_Parser.Lexer.File_Name, Token.Line, Token.Column,
"Ambiguous parse:" & SAL.Base_Peek_Type'Image (Count) & " parsers active.");
end;
end if;
end;
when Reduce =>
null;
when Error =>
-- All parsers errored; terminate with error. Semantic_State has all
-- the required info (recorded by Error in Do_Action), so we just
-- raise the exception.
raise Syntax_Error;
when Pause =>
-- This is parser_no_recover
raise SAL.Programmer_Error;
end case;
-- We don't use 'for Parser_State of Parsers loop' here,
-- because terminate on error and spawn on conflict require
-- changing the parser list.
Current_Parser := Shared_Parser.Parsers.First;
loop
exit when Current_Parser.Is_Done;
if Shared_Parser.Terminate_Same_State and
Current_Verb = Shift
then
Shared_Parser.Parsers.Duplicate_State
(Current_Parser, Shared_Parser.Trace.all, Shared_Parser.Terminals);
-- If Duplicate_State terminated Current_Parser, Current_Parser now
-- points to the next parser. Otherwise it is unchanged.
end if;
exit when Current_Parser.Is_Done;
if Trace_Parse > Extra then
Trace.Put_Line
("current_verb: " & Parse_Action_Verbs'Image (Current_Verb) &
"," & Integer'Image (Current_Parser.Label) &
".verb: " & Parse_Action_Verbs'Image (Current_Parser.Verb));
end if;
-- Each branch of the following 'if' calls either Current_Parser.Free
-- (which advances to the next parser) or Current_Parser.Next.
if Current_Parser.Verb = Current_Verb then
if Trace_Parse > Extra then
Parser_Lists.Put_Top_10 (Trace, Current_Parser);
end if;
declare
State : Parser_Lists.Parser_State renames Current_Parser.State_Ref.Element.all;
begin
Action := Action_For
(Table => Shared_Parser.Table.all,
State => State.Stack.Peek.State,
ID => State.Tree.ID (State.Current_Token));
end;
declare
Conflict : Parse_Action_Node_Ptr := Action.Next;
begin
loop
exit when Conflict = null;
-- Spawn a new parser (before modifying Current_Parser stack).
if Shared_Parser.Parsers.Count = Shared_Parser.Max_Parallel then
declare
Parser_State : Parser_Lists.Parser_State renames Current_Parser.State_Ref;
Token : Base_Token renames Shared_Parser.Terminals (Parser_State.Shared_Token);
begin
raise WisiToken.Parse_Error with Error_Message
(Shared_Parser.Lexer.File_Name, Token.Line, Token.Column,
": too many parallel parsers required in grammar state" &
State_Index'Image (Parser_State.Stack.Peek.State) &
"; simplify grammar, or increase max-parallel (" &
SAL.Base_Peek_Type'Image (Shared_Parser.Max_Parallel) & ")");
end;
else
if Trace_Parse > Outline then
declare
Parser_State : Parser_Lists.Parser_State renames Current_Parser.State_Ref;
begin
Trace.Put_Line
(Integer'Image (Current_Parser.Label) & ": " &
Trimmed_Image (Parser_State.Stack.Peek.State) & ": " &
Parser_State.Tree.Image (Parser_State.Current_Token, Trace.Descriptor.all) & " : " &
"spawn" & Integer'Image (Shared_Parser.Parsers.Last_Label + 1) & ", (" &
Trimmed_Image (1 + Integer (Shared_Parser.Parsers.Count)) & " active)");
end;
end if;
Shared_Parser.Parsers.Prepend_Copy (Current_Parser);
Do_Action (Conflict.Item, Shared_Parser.Parsers.First, Shared_Parser);
declare
Temp : Parser_Lists.Cursor := Shared_Parser.Parsers.First;
begin
Check_Error (Temp);
end;
end if;
Conflict := Conflict.Next;
end loop;
end;
Do_Action (Action.Item, Current_Parser, Shared_Parser);
Check_Error (Current_Parser);
else
-- Current parser is waiting for others to catch up
Current_Parser.Next;
end if;
end loop;
end loop Main_Loop;
-- We don't raise Syntax_Error for lexer errors, since they are all
-- recovered, either by inserting a quote, or by ignoring the
-- character.
end Parse;
overriding procedure Execute_Actions (Parser : in out LR.Parser_No_Recover.Parser)
is
use all type Syntax_Trees.User_Data_Access;
procedure Process_Node
(Tree : in out Syntax_Trees.Tree;
Node : in Syntax_Trees.Valid_Node_Index)
is
use all type Syntax_Trees.Node_Label;
begin
if Tree.Label (Node) /= Nonterm then
return;
end if;
declare
use all type Syntax_Trees.Semantic_Action;
Tree_Children : constant Syntax_Trees.Valid_Node_Index_Array := Tree.Children (Node);
begin
Parser.User_Data.Reduce (Tree, Node, Tree_Children);
if Tree.Action (Node) /= null then
begin
Tree.Action (Node) (Parser.User_Data.all, Tree, Node, Tree_Children);
exception
when E : others =>
declare
Token : Base_Token renames Parser.Terminals (Tree.Min_Terminal_Index (Node));
begin
raise WisiToken.Parse_Error with Error_Message
(Parser.Lexer.File_Name, Token.Line, Token.Column,
"action raised exception " & Ada.Exceptions.Exception_Name (E) & ": " &
Ada.Exceptions.Exception_Message (E));
end;
end;
end if;
end;
end Process_Node;
begin
if Parser.User_Data /= null then
if Parser.Parsers.Count > 1 then
raise Syntax_Error with "ambiguous parse; can't execute actions";
end if;
declare
Parser_State : Parser_Lists.Parser_State renames Parser.Parsers.First_State_Ref.Element.all;
begin
Parser.User_Data.Initialize_Actions (Parser_State.Tree);
Parser_State.Tree.Process_Tree (Process_Node'Access);
end;
end if;
end Execute_Actions;
overriding function Tree (Parser : in LR.Parser_No_Recover.Parser) return Syntax_Trees.Tree
is begin
if Parser.Parsers.Count > 1 then
raise WisiToken.Parse_Error with "ambigous parse";
else
return Parser.Parsers.First_State_Ref.Tree;
end if;
end Tree;
overriding function Any_Errors (Parser : in LR.Parser_No_Recover.Parser) return Boolean
is
use all type Ada.Containers.Count_Type;
Parser_State : Parser_Lists.Parser_State renames Parser.Parsers.First_Constant_State_Ref;
begin
pragma Assert (Parser_State.Tree.Flushed);
return Parser.Parsers.Count > 1 or Parser_State.Errors.Length > 0 or Parser.Lexer.Errors.Length > 0;
end Any_Errors;
overriding procedure Put_Errors (Parser : in LR.Parser_No_Recover.Parser)
is
use Ada.Text_IO;
Parser_State : Parser_Lists.Parser_State renames Parser.Parsers.First_Constant_State_Ref;
Descriptor : WisiToken.Descriptor renames Parser.Trace.Descriptor.all;
begin
for Item of Parser.Lexer.Errors loop
Put_Line
(Current_Error,
Parser.Lexer.File_Name & ":0:0: lexer unrecognized character at" & Buffer_Pos'Image (Item.Char_Pos));
end loop;
for Item of Parser_State.Errors loop
case Item.Label is
when Action =>
declare
Token : Base_Token renames Parser.Terminals (Parser_State.Tree.Min_Terminal_Index (Item.Error_Token));
begin
Put_Line
(Current_Error,
Error_Message
(Parser.Lexer.File_Name, Token.Line, Token.Column,
"syntax error: expecting " & Image (Item.Expecting, Descriptor) &
", found '" & Parser.Lexer.Buffer_Text (Token.Byte_Region) & "'"));
end;
when Check =>
null;
when Message =>
Put_Line (Current_Error, -Item.Msg);
end case;
end loop;
end Put_Errors;
end WisiToken.Parse.LR.Parser_No_Recover;
|
-- This file is covered by the Internet Software Consortium (ISC) License
-- Reference: ../License.txt
package Ravenports is
-- Provides information to user via standard out to determine if newer version of Ravenports
-- (as compared to what is installed) is available.
procedure check_version_available;
-- If a new version of Ravenports is available, this first retrieves the tarball and
-- then installs the set (replacing an old set if necessary).
procedure retrieve_latest_ravenports;
private
remote_version : constant String :=
"https://raw.githubusercontent.com/jrmarino/Ravenports/master/Mk/Misc/latest_release.txt";
conspiracy_version : constant String := "/Mk/Misc/latest_release.txt";
temporary_ver_loc : constant String := "/tmp/rp_latest_version.txt";
github_archive : constant String := "https://github.com/jrmarino/Ravenports/archive/";
-- Returns True if the latest Ravenports version information was successfully retrieved
function fetch_latest_version_info (tmp_location : String) return Boolean;
-- Returns True if the latest Ravenports tarball was successfully retrieved
function fetch_latest_tarball (latest_version : String) return Boolean;
-- Returns True if there's a version to install
function later_version_available (available : out Boolean) return String;
-- Returns True if mv command from conspiracy to conspiracy.old was successful
function relocate_existing_ravenports return Boolean;
-- Return true if successful at creating new, fully populated conspiracy directory
function explode_tarball_into_conspiracy (latest_version : String) return Boolean;
-- Try removing conspiracy.old and downloaded tarball
procedure clean_up (latest_version : String);
end Ravenports;
|
package gl.Binding
--
-- Provides functions common to all openGL profiles.
--
is
procedure glActiveTexture (Texture : in GLenum);
procedure glBindTexture (Target : in GLenum;
Texture : in GLuint);
procedure glBlendFunc (sFactor : in GLenum;
dFactor : in GLenum);
procedure glClear (Mask : in GLbitfield);
procedure glClearColor (Red : in GLclampf;
Green : in GLclampf;
Blue : in GLclampf;
Alpha : in GLclampf);
procedure glClearDepthf (Depth : in GLclampf);
procedure glClearStencil (S : in GLint);
procedure glColorMask (Red : in GLboolean;
Green : in GLboolean;
Blue : in GLboolean;
Alpha : in GLboolean);
procedure glCullFace (Mode : in GLenum);
procedure glDepthFunc (Func : in GLenum);
procedure glDepthMask (Flag : in GLboolean);
procedure glDepthRangef (zNear : in GLclampf;
zFar : in GLclampf);
procedure glDisable (Cap : in GLenum);
procedure glDrawArrays (Mode : in GLenum;
First : in GLint;
Count : in GLsizei);
procedure glDrawElements (Mode : in GLenum;
Count : in GLsizei;
the_Type : in GLenum;
Indices : access GLvoid);
procedure glEnable (Cap : in GLenum);
procedure glFinish;
procedure glFlush;
procedure glFrontFace (Mode : in GLenum);
procedure glGenTextures (N : in GLsizei;
Textures : access GLuint);
function glGetError return GLenum;
procedure glGetBooleanv (pName : in GLenum;
Params : access GLboolean);
procedure glGetFloatv (pName : in GLenum;
Params : access GLfloat);
procedure glGetIntegerv (pName : in GLenum;
Params : access GLint);
function glGetString (Name : in GLenum) return access GLubyte;
procedure glGetTexParameteriv
(Target : in GLenum;
pName : in GLenum;
Params : access GLint);
procedure glHint (Target : in GLenum;
Mode : in GLenum);
function glIsEnabled (Cap : in GLenum) return GLboolean;
procedure glLineWidth (Width : in GLfloat);
procedure glPixelStorei (pName : in GLenum;
Param : in GLint);
procedure glPolygonOffset (Factor : in GLfloat;
Units : in GLfloat);
procedure glReadPixels (X : in GLint;
Y : in GLint;
Width : in GLsizei;
Height : in GLsizei;
Format : in GLenum;
the_Type : in GLenum;
Pixels : access GLvoid);
procedure glScissor (X : in GLint;
Y : in GLint;
Width : in GLsizei;
Height : in GLsizei);
procedure glStencilFunc (Func : in GLenum;
Ref : in GLint;
Mask : in GLuint);
procedure glStencilMask (Mask : in GLuint);
procedure glStencilOp (Fail : in GLenum;
zFail : in GLenum;
zPass : in GLenum);
procedure glTexImage2D (Target : in GLenum;
Level : in GLint;
internalFormat
: in GLenum;
Width : in GLsizei;
Height : in GLsizei;
Border : in GLint;
Format : in GLenum;
the_Type : in GLenum;
Pixels : access GLvoid);
procedure glTexSubImage2D (Target : in GLenum;
Level : in GLint;
xOffset : in GLint;
yOffset : in GLint;
Width : in GLsizei;
Height : in GLsizei;
Format : in GLenum;
the_Type : in GLenum;
Pixels : access GLvoid);
procedure glTexParameteri (Target : in GLenum;
pName : in GLenum;
Param : in GLint);
procedure glViewport (X : in GLint;
Y : in GLint;
Width : in GLsizei;
Height : in GLsizei);
private
pragma Import (StdCall, glActiveTexture, "glActiveTexture");
pragma Import (Stdcall, glBindTexture, "glBindTexture");
pragma Import (Stdcall, glBlendFunc, "glBlendFunc");
pragma Import (Stdcall, glClear, "glClear");
pragma Import (Stdcall, glClearColor, "glClearColor");
pragma Import (Stdcall, glClearDepthf, "glClearDepthf");
pragma Import (Stdcall, glClearStencil, "glClearStencil");
pragma Import (Stdcall, glColorMask, "glColorMask");
pragma Import (Stdcall, glCullFace, "glCullFace");
pragma Import (Stdcall, glDepthFunc, "glDepthFunc");
pragma Import (Stdcall, glDepthMask, "glDepthMask");
pragma Import (Stdcall, glDepthRangef, "glDepthRangef");
pragma Import (Stdcall, glDisable, "glDisable");
pragma Import (Stdcall, glDrawArrays, "glDrawArrays");
pragma Import (Stdcall, glDrawElements, "glDrawElements");
pragma Import (Stdcall, glEnable, "glEnable");
pragma Import (Stdcall, glFinish, "glFinish");
pragma Import (Stdcall, glFlush, "glFlush");
pragma Import (Stdcall, glFrontFace, "glFrontFace");
pragma Import (Stdcall, glGenTextures, "glGenTextures");
pragma Import (Stdcall, glGetError, "glGetError");
pragma Import (StdCall, glGetBooleanv, "glGetBooleanv");
pragma Import (StdCall, glGetFloatv, "glGetFloatv");
pragma Import (StdCall, glGetIntegerv, "glGetIntegerv");
pragma Import (StdCall, glGetString, "glGetString");
pragma Import (StdCall, glGetTexParameteriv, "glGetTexParameteriv");
pragma Import (Stdcall, glHint, "glHint");
pragma Import (Stdcall, glIsEnabled, "glIsEnabled");
pragma Import (Stdcall, glLineWidth, "glLineWidth");
pragma Import (Stdcall, glPixelStorei, "glPixelStorei");
pragma Import (Stdcall, glPolygonOffset, "glPolygonOffset");
pragma Import (StdCall, glReadPixels, "glReadPixels");
pragma Import (Stdcall, glScissor, "glScissor");
pragma Import (Stdcall, glStencilFunc, "glStencilFunc");
pragma Import (Stdcall, glStencilMask, "glStencilMask");
pragma Import (Stdcall, glStencilOp, "glStencilOp");
pragma Import (StdCall, glTexImage2D, "glTexImage2D");
pragma Import (StdCall, glTexSubImage2D, "glTexSubImage2D");
pragma Import (Stdcall, glTexParameteri, "glTexParameteri");
pragma Import (Stdcall, glViewport, "glViewport");
end gl.Binding;
|
pragma License (Unrestricted);
-- implementation unit specialized for Darwin
with Ada.Directories.Volumes;
package System.Native_Directories.File_Names is
-- compare file names with normalization and case-insensitive, if HFS+
function Equal_File_Names (
FS : Ada.Directories.Volumes.File_System;
Left, Right : String)
return Boolean;
function Less_File_Names (
FS : Ada.Directories.Volumes.File_System;
Left, Right : String)
return Boolean;
end System.Native_Directories.File_Names;
|
with Ada.Text_IO; use Ada.Text_IO;
procedure Test is begin put('a' + 'b'); end;
|
package debug1 is
type Vector is array (Natural range <>) of Natural;
type Vector_Access is access Vector;
type Data_Line is record
Length : Vector (1 .. 1);
Line : Vector_Access;
end record;
type Data_Block is array (1 .. 5) of Data_Line;
type Data_Block_Access is access Data_Block;
type Vector_Ptr is access Vector;
type Meta_Data is record
Vector_View : Vector_Ptr;
Block_View : Data_Block_Access;
end record;
end;
|
-- Ada Standard Libraries
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with Ada.Numerics.Float_Random; use Ada.Numerics.Float_Random;
-- TJa. Libraries
with TJa.Keyboard; use TJa.Keyboard;
with TJa.Window.Elementary; use TJa.Window.Elementary;
package logic is
--------------------------------------------------------------------------------
type Random_Array_Type is
array (1..2) of Integer;
type Position_Type is
array (1..2) of Integer;
type Snake_Position_Type is
array(Positive Range <>) of Position_Type;
type Coordinate is
array(1..2) of Integer;
type Coordinate_Matrix is
array (Positive Range <>, Positive Range <>) of Coordinate;
type Score_Type is
record
Name : String(1..3);
Score : Integer;
end record;
type Highscore_List_Type is
array(1..3) of Score_Type;
--------------------------------------------------------------------------------
dx, dy : Integer := 0;
--------------------------------------------------------------------------------
procedure Update_Position(X_Pos, Y_Pos : in out Integer);
procedure Update_Direction(Key : in Key_Type);
procedure Init_Snake(Snake : in out Snake_Position_Type);
procedure Check_Snake_Intersection(Length : in Integer; Snake : in Snake_Position_Type; Running : in out Boolean);
procedure Check_Exit_Game(Key : in Key_Type; Running : out Boolean);
procedure Fill_Matrix(X, Y, Size_X, Size_Y : in Integer; Matrix : out Coordinate_Matrix);
procedure Put_Highscore(X_Placement, Y_Placement : in Integer; Highscore_List : in Highscore_List_Type);
procedure Read_Highscore(File_Name : in String; Highscore_List : out Highscore_List_Type);
procedure Add_Score(New_Name : in String; New_Score : in Integer; Highscore_List : out Highscore_List_Type);
procedure Write_Highscore(File_Name : in String; Highscore_List : in Highscore_List_Type);
procedure Swap_Scores(New_Score, Old_Score : in out Score_Type);
procedure Sort_Scores(Highscore_List : in out Highscore_List_Type);
--------------------------------------------------------------------------------
function Check_Fruit(X_Pos, Y_pos, Snake_X, Snake_Y, Fruit_X, Fruit_Y : in Integer; Fruit_Pos : in Random_Array_Type)
return Boolean;
function Random_Coordinate(StartX, StartY, Width, Height, Size_Of_Water : in Integer)
return Random_Array_Type;
--------------------------------------------------------------------------------
private
end logic;
|
-- $Id: Sets.mi,v 1.8 1994/07/14 10:22:29 grosch rel $
-- $Log: Sets.mi,v $
-- Ich, Doktor Josef Grosch, Informatiker, Sept. 1994
with DynArray, General, Text_Io; use General, Text_Io;
package body Sets is
package Int_Io is new Integer_IO (Integer); use Int_Io;
NoCard : constant Integer := -1;
procedure MakeSet (Set: in out tSet; MaxSize: Integer) is
begin
MakeArray (Set.BitsetPtr, MaxSize + 1);
Set.MaxElmt := MaxSize;
AssignEmpty (Set);
end MakeSet;
procedure ResizeSet (Set: in out tSet; MaxSize: Integer) is
NewBitsetPtr : Bool_DA.FlexArray;
j : Integer := Min (MaxSize, Set.MaxElmt);
begin
MakeArray (NewBitsetPtr, MaxSize + 1);
NewBitsetPtr (0 .. j) := Set.BitsetPtr (0 .. j);
if j < MaxSize then
NewBitsetPtr (j + 1 .. MaxSize) := (j + 1 .. MaxSize => False);
end if;
ReleaseArray (Set.BitsetPtr, Set.MaxElmt);
Set.MaxElmt := MaxSize;
Set.BitsetPtr := NewBitsetPtr;
end ResizeSet;
procedure ReleaseSet (Set: in out tSet) is
begin
ReleaseArray (Set.BitsetPtr, Set.MaxElmt + 1);
end ReleaseSet;
procedure Union (Set1: in out tSet; Set2: tSet) is
begin
Set1.BitsetPtr.all := Set1.BitsetPtr.all or Set2.BitsetPtr.all;
Set1.Card := NoCard;
Set1.FirstElmt := Min (Set1.FirstElmt, Set2.FirstElmt);
Set1.LastElmt := Max (Set1.LastElmt, Set2.LastElmt);
end Union;
procedure Difference (Set1: in out tSet; Set2: tSet) is
begin
Set1.BitsetPtr.all := (Set1.BitsetPtr.all xor Set2.BitsetPtr.all) and Set1.BitsetPtr.all;
Set1.Card := NoCard;
end Difference;
procedure Intersection (Set1: in out tSet; Set2: tSet) is
begin
Set1.BitsetPtr.all := Set1.BitsetPtr.all and Set2.BitsetPtr.all;
Set1.Card := NoCard;
Set1.FirstElmt := Max (Set1.FirstElmt, Set2.FirstElmt);
Set1.LastElmt := Min (Set1.LastElmt, Set2.LastElmt);
end Intersection;
procedure SymDiff (Set1: in out tSet; Set2: tSet) is
begin
Set1.BitsetPtr.all := Set1.BitsetPtr.all xor Set2.BitsetPtr.all;
Set1.Card := NoCard;
Set1.FirstElmt := Min (Set1.FirstElmt, Set2.FirstElmt);
Set1.LastElmt := Max (Set1.LastElmt, Set2.LastElmt);
end SymDiff;
procedure Complement (Set: in out tSet) is
begin
Set.BitsetPtr.all := not Set.BitsetPtr.all;
if Set.Card /= NoCard then
Set.Card := Set.MaxElmt + 1 - Set.Card;
end if;
Set.FirstElmt := 0;
Set.LastElmt := Set.MaxElmt;
end Complement;
procedure Include (Set: in out tSet; Elmt: Integer) is
begin
Set.BitsetPtr (Elmt) := True;
Set.Card := NoCard;
-- Set.FirstElmt := Min (Set.FirstElmt, Elmt);
-- Set.LastElmt := Max (Set.LastElmt, Elmt);
if Set.FirstElmt > Elmt then Set.FirstElmt := Elmt; end if;
if Set.LastElmt < Elmt then Set.LastElmt := Elmt; end if;
end Include;
procedure Exclude (Set: in out tSet; Elmt: Integer) is
begin
Set.BitsetPtr (Elmt) := False;
Set.Card := NoCard;
if (Elmt = Set.FirstElmt) and (Elmt < Set.MaxElmt) then
Set.FirstElmt := Set.FirstElmt + 1;
end if;
if (Elmt = Set.LastElmt) and (Elmt > 0) then
Set.LastElmt := Set.LastElmt - 1;
end if;
end Exclude;
procedure Card (Set: in out tSet; Result: out Integer) is
begin
if Set.Card /= NoCard then Result := Set.Card; return; end if;
Result := 0;
for i in Set.FirstElmt .. Set.LastElmt loop
if IsElement (i, Set) then Result := Result + 1; end if;
end loop;
Set.Card := Result;
end Card;
function Size (Set: tSet) return Integer is
begin
return Set.MaxElmt;
end Size;
procedure Minimum (Set: in out tSet; Result: out Integer) is
begin
Result := Set.FirstElmt;
while Result <= Set.LastElmt loop
if IsElement (Result, Set) then
Set.FirstElmt := Result;
return;
end if;
Result := Result + 1;
end loop;
Result := 0;
end Minimum;
procedure Maximum (Set: in out tSet; Result: out Integer) is
begin
Result := Set.LastElmt;
while Result >= Set.FirstElmt loop
if IsElement (Result, Set) then
Set.LastElmt := Result;
return;
end if;
Result := Result - 1;
end loop;
Result := 0;
end Maximum;
procedure rSelect (Set: in out tSet; Result: out Integer) is
begin
Minimum (Set, Result);
end rSelect;
procedure Extract (Set: in out tSet; Result: out Integer) is
begin
Minimum (Set, Result);
Exclude (Set, Result);
end Extract;
function IsSubset (Set1, Set2: tSet) return Boolean is
begin
return (Set1.BitsetPtr.all and Set2.BitsetPtr.all) = Set1.BitsetPtr.all;
end IsSubset;
function IsStrictSubset(Set1, Set2: tSet) return Boolean is
begin
return IsSubset (Set1, Set2) and IsNotEqual (Set1, Set2);
end IsStrictSubset;
function IsEqual (Set1, Set2: tSet) return Boolean is
begin
return Set1.BitsetPtr.all = Set2.BitsetPtr.all;
end IsEqual;
function IsNotEqual (Set1, Set2: tSet) return Boolean is
begin
return not IsEqual (Set1, Set2);
end IsNotEqual;
function IsElement (Elmt: Integer; Set: tSet) return Boolean is
begin
return Set.BitsetPtr (Elmt);
end IsElement;
function IsEmpty (Set: tSet) return Boolean is
begin
return Set.BitsetPtr.all = (0 .. Set.MaxElmt => False);
end IsEmpty;
function Forall (Set: tSet) return Boolean is
begin
for i in Set.FirstElmt .. Set.LastElmt loop
if IsElement (i, Set) and not ProcOfCardToBool (i) then return False; end if;
end loop;
return True;
end Forall;
function Exists (Set: tSet) return Boolean is
begin
for i in Set.FirstElmt .. Set.LastElmt loop
if IsElement (i, Set) and ProcOfCardToBool (i) then return True; end if;
end loop;
return False;
end Exists;
function Exists1 (Set: tSet) return Boolean is
n : Integer := 0;
begin
for i in Set.FirstElmt .. Set.LastElmt loop
if IsElement (i, Set) and ProcOfCardToBool (i) then n := n + 1; end if;
end loop;
return n = 1;
end Exists1;
procedure Assign (Set1: out tSet; Set2: tSet) is
begin
Set1.BitsetPtr.all := Set2.BitsetPtr.all;
Set1.Card := Set2.Card;
Set1.FirstElmt := Set2.FirstElmt;
Set1.LastElmt := Set2.LastElmt;
end Assign;
procedure AssignElmt (Set: out tSet; Elmt: Integer) is
begin
AssignEmpty (Set);
Include (Set, Elmt);
Set.Card := 1;
Set.FirstElmt := Elmt;
Set.LastElmt := Elmt;
end AssignElmt;
procedure AssignEmpty (Set: in out tSet) is
begin
Set.BitsetPtr.all := (0 .. Set.MaxElmt => False);
Set.Card := 0;
Set.FirstElmt := Set.MaxElmt;
Set.LastElmt := 0;
end AssignEmpty;
procedure ForallDo (Set: tSet) is
begin
for i in Set.FirstElmt .. Set.LastElmt loop
if IsElement (i, Set) then ProcOfCard (i); end if;
end loop;
end ForallDo;
procedure ReadSet (f: File_Type; Set: out tSet) is
ch : Character;
i : Integer;
n : Integer := 0;
begin
loop Get (f, ch); if ch = '{' then exit; end if; end loop;
AssignEmpty (Set);
loop
Get (f, ch);
if ch = '}' then exit; end if;
Get (f, i);
Include (Set, i);
n := n + 1;
end loop;
Set.Card := n;
end ReadSet;
procedure WriteSet (f: File_Type; Set: tSet) is
procedure WriteElmt (Elmt: Integer) is
begin
Put (f, ' ');
Put (f, Elmt, 0);
end WriteElmt;
procedure WriteAll is new ForallDo (WriteElmt);
begin
Put (f, '{');
WriteAll (Set);
Put (f, '}');
end WriteSet;
end Sets;
|
with AdaBase;
with Connect;
with CommonText;
with Ada.Text_IO;
with AdaBase.Results.Sets;
procedure Autocommit is
package CON renames Connect;
package TIO renames Ada.Text_IO;
package ARS renames AdaBase.Results.Sets;
package CT renames CommonText;
insX : constant String := "INSERT INTO fruits (id, fruit, color, calories)";
ins1 : constant String := insX & " VALUES (100,'cucumber','green',16)";
ins2 : constant String := insX & " VALUES (101,'kumquat','yellow',71)";
ins3 : constant String := insX & " VALUES (102,'persimmon','orange',127)";
sel : constant String := "SELECT * FROM fruits WHERE id > 99";
del : constant String := "DELETE FROM fruits WHERE id > 99";
procedure clear_table;
procedure test_uno (expected : Natural; version2 : Boolean);
procedure test_dos (expected : Natural; version2 : Boolean);
procedure test_tres (expected : Natural);
procedure expect (impacted, expected : Natural);
procedure show_results (expected : Natural);
procedure expect (impacted, expected : Natural) is
begin
TIO.Put_Line ("Rows expected:" & expected'Img);
TIO.Put_Line ("Rows returned:" & impacted'Img);
if impacted = expected then
TIO.Put_Line ("=== PASSED ===");
else
TIO.Put_Line ("=== FAILED === <<----------------------------");
end if;
TIO.Put_Line ("");
end expect;
procedure show_results (expected : Natural) is
begin
CON.connect_database;
declare
stmt : CON.Stmt_Type := CON.DR.query (sel);
row : ARS.Datarow;
NR : Natural := 0;
begin
loop
row := stmt.fetch_next;
exit when row.data_exhausted;
NR := NR + 1;
end loop;
expect (NR, expected);
end;
CON.DR.disconnect;
end show_results;
procedure test_uno (expected : Natural; version2 : Boolean) is
AR : AdaBase.Affected_Rows;
begin
CON.connect_database;
AR := CON.DR.execute (ins1);
AR := CON.DR.execute (ins2);
if version2 then
CON.DR.commit;
end if;
CON.DR.disconnect;
show_results (expected);
end test_uno;
procedure test_dos (expected : Natural; version2 : Boolean)
is
AR : AdaBase.Affected_Rows;
begin
CON.connect_database;
AR := CON.DR.execute (ins1);
CON.DR.set_trait_autocommit (True);
AR := CON.DR.execute (ins2);
CON.DR.set_trait_autocommit (False);
AR := CON.DR.execute (ins3);
if version2 then
CON.DR.commit;
end if;
CON.DR.disconnect;
show_results (expected);
end test_dos;
procedure test_tres (expected : Natural)
is
AR : AdaBase.Affected_Rows;
begin
CON.connect_database;
AR := CON.DR.execute (ins1);
CON.DR.set_trait_autocommit (True);
CON.DR.disconnect;
show_results (expected);
end test_tres;
procedure clear_table
is
AR : AdaBase.Affected_Rows;
begin
CON.connect_database;
AR := CON.DR.execute (del);
if not CON.DR.trait_autocommit then
CON.DR.commit;
end if;
CON.DR.disconnect;
end clear_table;
begin
clear_table;
TIO.Put_Line ("=== PRECONNECT AUTOCOMMIT => OFF (DEFAULT) ===");
CON.DR.set_trait_autocommit (False);
test_uno (0, False);
clear_table;
TIO.Put_Line ("=== PRECONNECT AUTOCOMMIT => ON ===");
CON.DR.set_trait_autocommit (True);
test_uno (2, False);
clear_table;
TIO.Put_Line ("=== CONNECT AC=0, INS, AC=1, INS, AC=0, INS ===");
CON.DR.set_trait_autocommit (False);
test_dos (2, False);
clear_table;
TIO.Put_Line ("=== IMPLICIT COMMIT (AC/OFF => ON) ===");
CON.DR.set_trait_autocommit (False);
test_tres (1);
clear_table;
TIO.Put_Line ("=== PRECONNECT AUTOCOMMIT => OFF WITH COMMIT ===");
CON.DR.set_trait_autocommit (False);
test_uno (2, True);
clear_table;
TIO.Put_Line ("=== PRECONNECT AUTOCOMMIT => ON WITH COMMIT (NO-OP) ===");
CON.DR.set_trait_autocommit (True);
test_uno (2, True);
clear_table;
TIO.Put_Line ("=== CONNECT AC=0, INS, AC=1, INS, AC=0, INS COMMIT ===");
CON.DR.set_trait_autocommit (False);
test_dos (3, True);
clear_table;
end Autocommit;
|
with Ada.Float_Text_IO; use Ada.Float_Text_IO;
with Ada.Numerics.Elementary_Functions;
use Ada.Numerics.Elementary_Functions;
procedure calcrms is
type float_arr is array(1..10) of Float;
function rms(nums : float_arr) return Float is
sum : Float := 0.0;
begin
for p in nums'Range loop
sum := sum + nums(p)**2;
end loop;
return sqrt(sum/Float(nums'Length));
end rms;
list : float_arr;
begin
list := (1.0,2.0,3.0,4.0,5.0,6.0,7.0,8.0,9.0,10.0);
put( rms(list) , Exp=>0);
end calcrms;
|
-- -----------------------------------------------------------------------------
-- smk, the smart make (http://lionel.draghi.free.fr/smk/)
-- © 2018, 2019 Lionel Draghi <lionel.draghi@free.fr>
-- SPDX-License-Identifier: APSL-2.0
-- -----------------------------------------------------------------------------
-- 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 Smk.Files; use Smk.Files;
with Smk.Runs.Strace_Analyzer; use Smk.Runs.Strace_Analyzer;
with Ada.Command_Line;
with Ada.Strings.Equal_Case_Insensitive;
with Ada.Text_IO; use Ada.Text_IO;
procedure Smk.Runs.Strace_Analyzer.Test_Strace_Analysis is
Failure_Count : Natural := 0;
-- --------------------------------------------------------------------------
procedure New_Test (Title : String; Line : String) is
begin
New_Line;
Put_Line ("## " & Title);
Put_Line (" Line: " & Line);
end New_Test;
-- --------------------------------------------------------------------------
procedure Check (Title : String;
Result : String;
Expected : String) is
begin
Put (" - Expected " & Title & ": ");
Put ("""" & Expected & """");
if Ada.Strings.Equal_Case_Insensitive (Result, Expected) then
Put_Line (", OK");
else
Put_Line (", got """ & Result & """, " & "**Failed**");
Failure_Count := Failure_Count + 1;
end if;
end Check;
Test_Data : Ada.Text_IO.File_Type;
begin
-- --------------------------------------------------------------------------
New_Line;
Put_Line ("# Analyze_Line unit tests");
New_Line;
Open (File => Test_Data,
Name => "test_data.txt",
Mode => In_File);
-- Smk.Settings.Verbosity := Debug;
while not End_Of_File (Test_Data) loop
declare
Title : constant String := Get_Line (Test_Data);
Line : constant String := Get_Line (Test_Data);
Call : constant String := Get_Line (Test_Data);
Read_File_Name : constant String := Get_Line (Test_Data);
Write_File_Name : constant String := Get_Line (Test_Data);
Operation : Operation_Type;
begin
New_Test (Title, Line);
Smk.Runs.Strace_Analyzer.Analyze_Line (Line, Operation);
case Operation.Kind is
when None =>
Check (Title => "Call_Type",
Result => "Ignored",
Expected => Call);
when Read =>
Check (Title => "Read file",
Result => +Operation.Name,
Expected => Read_File_Name);
when Write | Delete =>
Check (Title => "Write file",
Result => +Operation.Name,
Expected => Write_File_Name);
when Move =>
Check (Title => "Source file",
Result => +Operation.Source_Name,
Expected => Read_File_Name);
Check (Title => "Target file",
Result => +Operation.Target_Name,
Expected => Write_File_Name);
end case;
end;
end loop;
Close (File => Test_Data);
-- To Add To data_test when unfinished line processing is implemented:
-- Unfinished
-- 6911 openat(AT_FDCWD, "/etc/ld.so.cache", \
-- O_RDONLY|O_CLOEXEC <unfinished ...>
-- Ignored
--
--
-- --------------------------------------------------------------------------
New_Line;
if Failure_Count /= 0 then
Put_Line (Natural'Image (Failure_Count)
& " tests fails [Failed](tests_status.md#failed)");
Ada.Command_Line.Set_Exit_Status (Ada.Command_Line.Failure);
else
Put_Line ("All tests OK [Successful](tests_status.md#successful)");
end if;
end Smk.Runs.Strace_Analyzer.Test_Strace_Analysis;
|
generic
Modulo : Integer;
type T_Element is private;
-- Un registre est une table de hachage.
package Registre is
type T_Registre is limited private;
Cle_Absente_Exception : exception;
-- Renvoie vrai si le registre est entièrement vide.
function Est_Vide (Registre : T_Registre) return Boolean;
-- Initialiser un registre vide.
procedure Initialiser (Registre : out T_Registre) with
Post => Est_Vide (Registre);
-- Renvoie vrai si la clé est presente dans le registre.
function Existe (Registre : T_Registre; Cle : Integer) return Boolean;
-- Insère ou modifie un élément dans le registre.
procedure Attribuer
(Registre : in out T_Registre; Cle : in Integer; Element : in T_Element);
-- Renvoie un élément du registre.
-- Lance Cle_Absente_Exception si la clé n'est pas trouvee.
function Acceder (Registre : T_Registre; Cle : Integer) return T_Element;
-- Applique une procédure P sur tous les éléments du registre.
generic
with procedure P (Cle : in Integer; Element : in T_Element);
procedure Appliquer_Sur_Tous (Registre : in T_Registre);
-- Supprime un élément du registre.
procedure Supprimer (Registre : in out T_Registre; Cle : in Integer);
-- Supprime tous les éléments du registre.
procedure Detruire (Registre : in out T_Registre) with
Post => Est_Vide (Registre);
private
-- On choisit de representer un registre par un tableau de pointeurs.
-- Une case de ce tableau contient une chaîne de tous les elements dont
-- la valeur de la clé par la fonction de hachage est la même.
type T_Maillon;
type T_Pointeur_Sur_Maillon is access T_Maillon;
type T_Maillon is record
Cle : Integer;
Element : T_Element;
Suivant : T_Pointeur_Sur_Maillon;
end record;
type T_Registre is array (1 .. Modulo) of T_Pointeur_Sur_Maillon;
end Registre;
|
package body Bits is
function Bit_Count (Bitmap : Unsigned_32) return Natural is
Count : Unsigned_32 := Bitmap;
begin
Count := Count - ((Shift_Right (Count, 1)) and 16#55555555#);
Count := (Count and 16#33333333#) + (Shift_Right (Count, 2) and 16#33333333#);
Count := (Count + Shift_Right (Count, 4)) and 16#0F0F0F0F#;
Count := Count + (Shift_Right (Count, 8));
Count := Count + (Shift_Right (Count, 16));
-- Return count in range 0 to 31.
return Natural (Count and 16#3F#);
end Bit_Count;
-- ------------------------------------------------------------------------
function Highest_One_Bit (Bitmap : Unsigned_32) return Natural is
begin
return 32 - Number_Of_Leading_Zero_Bits (Bitmap);
end Highest_One_Bit;
-- ------------------------------------------------------------------------
function Lowest_One_Bit (Bitmap : Unsigned_32) return Natural is
begin
return Number_Of_Trailing_Zero_Bits (Bitmap);
end Lowest_One_Bit;
-- -----------------------------------------------------------------------
function Number_Of_Leading_Zero_Bits (Bitmap : Unsigned_32) return Natural is
Num : Unsigned_32 := Bitmap;
begin
Num := Num or Shift_Right (Num, 1);
Num := Num or Shift_Right (Num, 2);
Num := Num or Shift_Right (Num, 4);
Num := Num or Shift_Right (Num, 8);
Num := Num or Shift_Right (Num, 16);
return Bit_Count (Not Num);
end Number_Of_Leading_Zero_Bits;
-- ------------------------------------------------------------------------
function Number_Of_Trailing_Zero_Bits (Bitmap : Unsigned_32) return Natural is
begin
return Bit_Count ((not Bitmap) and (Bitmap - 1));
end Number_Of_Trailing_Zero_Bits;
-- ------------------------------------------------------------------------
end Bits;
|
with System.Formatting.Literals.Float;
with System.Value_Errors;
package body System.Val_Real is
function Value_Real (Str : String) return Long_Long_Float is
Last : Natural := Str'First - 1;
Result : Long_Long_Float;
Error : Boolean;
begin
Formatting.Literals.Float.Get_Literal (Str, Last, Result, Error);
if not Error then
Formatting.Literals.Check_Last (Str, Last, Error);
if not Error then
return Result;
end if;
end if;
Value_Errors.Raise_Value_Failure ("Float", Str);
end Value_Real;
end System.Val_Real;
|
with OpenGL.Thin;
package body OpenGL.View is
--
-- Viewport specification.
--
procedure Depth_Range
(Near : in OpenGL.Types.Clamped_Double_t;
Far : in OpenGL.Types.Clamped_Double_t) is
begin
Thin.Depth_Range
(Near_Value => Thin.Double_t (Near),
Far_Value => Thin.Double_t (Far));
end Depth_Range;
procedure Viewport
(Left : in Natural;
Bottom : in Natural;
Width : in Positive;
Height : in Positive) is
begin
Thin.Viewport
(X => Thin.Integer_t (Left),
Y => Thin.Integer_t (Bottom),
Width => Thin.Size_t (Width),
Height => Thin.Size_t (Height));
end Viewport;
end OpenGL.View;
|
--
-- Jan & Uwe R. Zimmer, Australia, July 2011
--
with Vectors_xD_I; pragma Elaborate_All (Vectors_xD_I);
package Vectors_2D_P is
type xy_Coordinates is (x, y);
package Vectors_2Di is new Vectors_xD_I (Positive, xy_Coordinates);
subtype Vector_2D_P is Vectors_2Di.Vector_xD_I;
Zero_Vector_2D_P : constant Vector_2D_P := Vectors_2Di.Zero_Vector_xD;
function Image (V : Vector_2D_P) return String renames Vectors_2Di.Image;
function Norm (V : Vector_2D_P) return Vector_2D_P renames Vectors_2Di.Norm;
function "*" (Scalar : Float; V : Vector_2D_P) return Vector_2D_P renames Vectors_2Di."*";
function "*" (V : Vector_2D_P; Scalar : Float) return Vector_2D_P renames Vectors_2Di."*";
function "/" (V : Vector_2D_P; Scalar : Float) return Vector_2D_P renames Vectors_2Di."/";
function "*" (V_Left, V_Right : Vector_2D_P) return Float renames Vectors_2Di."*";
function Angle_Between (V_Left, V_Right : Vector_2D_P) return Float renames Vectors_2Di.Angle_Between;
function "+" (V_Left, V_Right : Vector_2D_P) return Vector_2D_P renames Vectors_2Di."+";
function "-" (V_Left, V_Right : Vector_2D_P) return Vector_2D_P renames Vectors_2Di."-";
function "abs" (V : Vector_2D_P) return Float renames Vectors_2Di."abs";
end Vectors_2D_P;
|
pragma License (Restricted);
--
-- Copyright (C) 2020 Jesper Quorning All Rights Reserved.
--
-- The author disclaims copyright to this source code. In place of
-- a legal notice, here is a blessing:
--
-- May you do good and not evil.
-- May you find forgiveness for yourself and forgive others.
-- May you share freely, not taking more than you give.
--
with Ada.Text_IO;
with Ada.Exceptions;
with Setup;
with Command_Line;
with Database.Jobs;
with SQL_Database;
with Parser;
-- with Web_Server;
with Terminal_IO;
with Interactive;
with Navigate;
with Files;
procedure iDoNu_Program
is
Config : Setup.Configuration;
begin
Terminal_IO.Put_Banner;
declare
List : Files.Collection_List;
begin
Files.Append_Collections (List, ".");
Files.Append_Collections (List, "..");
Files.Append_Collections (List, "/Users/jquorning/");
Files.Append_Collections (List, "/Users/jquorning/var/");
end;
Command_Line.Parse (Config);
Interactive.Initialize;
SQL_Database.Open;
-- Web_Server.Startup;
Ada.Text_IO.New_Line;
Ada.Text_IO.Put_Line ("List:");
Navigate.Build_Path (Database.Jobs.Get_Current_Job);
Terminal_IO.Put_Path;
Navigate.Refresh_List;
Terminal_IO.Put_Jobs;
loop
Parser.Parse_Input (Interactive.Get_Line);
exit when Parser.Exit_Program;
end loop;
-- Web_Server.Shutdown;
Interactive.Finalize;
Command_Line.Set_Exit_Status (Command_Line.Success);
exception
when Command_Line.Terminate_Program =>
null;
when Occurrence : others =>
declare
use Ada.Exceptions;
Message : String renames Exception_Message (Occurrence);
begin
if Message = "" then
raise;
else
Ada.Text_IO.Put_Line (Ada.Text_IO.Standard_Error, Message);
end if;
end;
end iDoNu_Program;
|
package body UxAS.Comms.Transport.Receiver is
------------------------------
-- Add_Subscription_Address --
------------------------------
procedure Add_Subscription_Address
(This : in out Transport_Receiver_Base;
Address : String;
Result : out Boolean)
is
Target : constant Subscription_Address := Instance (Subscription_Address_Max_Length, Address);
use Subscription_Addresses; -- a hashed map
C : Cursor;
begin
C := Find (This.Subscriptions, Target);
if C = No_Element then -- didn't find it
Insert (This.Subscriptions, Target);
Add_Subscription_Address_To_Socket (Transport_Receiver_Base'Class (This), Address, Result); -- dispatching
end if;
end Add_Subscription_Address;
---------------------------------
-- Remove_Subscription_Address --
---------------------------------
procedure Remove_Subscription_Address
(This : in out Transport_Receiver_Base;
Address : String;
Result : out Boolean)
is
Target : constant Subscription_Address := Instance (Subscription_Address_Max_Length, Address);
use Subscription_Addresses; -- a hashed map
C : Cursor;
begin
C := Find (This.Subscriptions, Target);
if C /= No_Element then -- found it
Delete (This.Subscriptions, C);
Remove_Subscription_Address_From_Socket (Transport_Receiver_Base'Class (This), Address, Result); -- dispatching
end if;
end Remove_Subscription_Address;
---------------------------------------
-- Remove_All_Subscription_Addresses --
---------------------------------------
procedure Remove_All_Subscription_Addresses
(This : in out Transport_Receiver_Base;
Result : out Boolean)
is
begin
for Target of This.Subscriptions loop
Remove_Subscription_Address_From_Socket (Transport_Receiver_Base'Class (This), Value (Target), Result); -- dispatching
end loop;
Subscription_Addresses.Clear (This.Subscriptions);
Result := Subscription_Addresses.Is_Empty (This.Subscriptions);
end Remove_All_Subscription_Addresses;
end UxAS.Comms.Transport.Receiver;
|
-- --
-- package Copyright (c) Francois Fabien --
-- AdaPcre --
-- Interface --
-- --
-- Last revision : 15 Oct 2012 --
-- --
-- comments to <fabien@lorgelog.com>
--
----------------------------------------------------------------------------
-- Permission to use, copy, modify, and distribute this software for any
-- purpose with or without fee is hereby granted, provided that the above
-- copyright notice and this permission notice appear in all copies.
--
-- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-- WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-- MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-- ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-- WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-- ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-- OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--
----------------------------------------------------------------------------
-- Ada interface to PCRE
--
-- partial binding : substring extraction is not implemented.
--
-- Gnat specific for memory allocation routines
-----------------------------------------------------------------------
with System;
with Interfaces;
package AdaPcre is
pragma Elaborate_Body;
type Version_Number is delta 0.01 range 0.0 .. 100.0;
-- The value is assigned during elaboration of the body
Version : Version_Number;
-- PCRE version and release date (e.g. "7.0 18-Dec-2006").
function Pcre_Version return String;
-- Options. Some are compile-time only, some are run-time only,
-- and some are both, so we keep them all distinct. However, almost
-- all the bits in the options word are now used.
-- In the long run, we may have to re-use some of the compile-time
-- only bits for runtime options, or vice versa.
type Options is new Interfaces.Unsigned_32;
PCRE_CASELESS : constant Options := 16#0000_0001#; -- Compile
PCRE_MULTILINE : constant Options := 16#0000_0002#; -- Compile
PCRE_DOTALL : constant Options := 16#0000_0004#; -- Compile
PCRE_EXTENDED : constant Options := 16#0000_0008#; -- Compile
PCRE_ANCHORED : constant Options := 16#0000_0010#; -- Com, Ex, DFA
PCRE_DOLLAR_ENDONLY : constant Options := 16#0000_0020#; -- Compile
PCRE_EXTRA : constant Options := 16#0000_0040#; -- Compile
PCRE_NOTBOL : constant Options := 16#0000_0080#; -- Exec, DFA
PCRE_NOTEOL : constant Options := 16#0000_0100#; -- Exec, DFA
PCRE_UNGREEDY : constant Options := 16#0000_0200#; -- Compile
PCRE_NOTEMPTY : constant Options := 16#0000_0400#; -- Exec, DFA
PCRE_UTF8 : constant Options := 16#0000_0800#; -- Compile
PCRE_NO_AUTO_CAPTURE : constant Options := 16#0000_1000#; -- Compile
PCRE_NO_UTF8_CHECK : constant Options := 16#0000_2000#; -- Co, exec,DFA
PCRE_AUTO_CALLOUT : constant Options := 16#0000_4000#; -- Compile
PCRE_PARTIAL_SOFT : constant Options := 16#0000_8000#; -- Exec, DFA
PCRE_PARTIAL : constant Options := 16#0000_8000#; -- Backwards
PCRE_DFA_SHORTEST : constant Options := 16#0001_0000#; -- DFA exec
PCRE_DFA_RESTART : constant Options := 16#0002_0000#; -- DFA exec
PCRE_FIRSTLINE : constant Options := 16#0004_0000#; -- Compile
PCRE_DUPNAMES : constant Options := 16#0008_0000#; -- Compile
PCRE_NEWLINE_CR : constant Options := 16#0010_0000#; -- C, exec,DFA
PCRE_NEWLINE_LF : constant Options := 16#0020_0000#; -- C, exec,DFA
PCRE_NEWLINE_CRLF : constant Options := 16#0030_0000#; -- C, exec,DFA
PCRE_NEWLINE_ANY : constant Options := 16#0040_0000#; -- C, exec,DFA
PCRE_NEWLINE_ANYCRLF : constant Options := 16#0050_0000#; -- C, exec,DFA
PCRE_BSR_ANYCRLF : constant Options := 16#0080_0000#; -- C, exec,DFA
PCRE_BSR_UNICODE : constant Options := 16#0100_0000#; -- C, exec,DFA
PCRE_JAVASCRIPT_COMPAT : constant Options := 16#0200_0000#; -- Compile
PCRE_NO_START_OPTIMIZE : constant Options := 16#0400_0000#; -- C, exec,DFA
PCRE_NO_START_OPTIMISE : constant Options := 16#0400_0000#; -- Synonym
PCRE_PARTIAL_HARD : constant Options := 16#0800_0000#; -- Exec, DFA
PCRE_NOTEMPTY_ATSTART : constant Options := 16#1000_0000#; -- Exec, DFA
PCRE_UCP : constant Options := 16#2000_0000#; -- Compile
-- Exec-time and get/set-time error codes
PCRE_ERROR_NOMATCH : constant Integer := -1;
PCRE_ERROR_NULL : constant Integer := -2;
PCRE_ERROR_BADOPTION : constant Integer := -3;
PCRE_ERROR_BADMAGIC : constant Integer := -4;
PCRE_ERROR_UNKNOWN_OPCODE : constant Integer := -5;
PCRE_ERROR_NOMEMORY : constant Integer := -6;
PCRE_ERROR_NOSUBSTRING : constant Integer := -7;
PCRE_ERROR_MATCHLIMIT : constant Integer := -8;
PCRE_ERROR_BADUTF8 : constant Integer := -10;
PCRE_ERROR_BADUTF8_OFFSET : constant Integer := -11;
PCRE_ERROR_PARTIAL : constant Integer := -12;
PCRE_ERROR_BADPARTIAL : constant Integer := -13;
PCRE_ERROR_INTERNAL : constant Integer := -14;
PCRE_ERROR_BADCOUNT : constant Integer := -15;
PCRE_ERROR_DFA_UITEM : constant Integer := -16;
PCRE_ERROR_DFA_UCOND : constant Integer := -17;
PCRE_ERROR_DFA_UMLIMIT : constant Integer := -18;
PCRE_ERROR_DFA_WSSIZE : constant Integer := -19;
PCRE_ERROR_DFA_RECURSE : constant Integer := -20;
PCRE_ERROR_RECURSIONLIMIT : constant Integer := -21;
PCRE_ERROR_BADNEWLINE : constant Integer := -23;
PCRE_ERROR_BADOFFSET : constant Integer := -24;
PCRE_ERROR_SHORTUTF8 : constant Integer := -25;
type Pcre_Type is private;
type Extra_type is private;
Null_Pcre : constant Pcre_Type;
Null_Extra : constant Extra_type;
type Table_Type is private;
Null_Table : constant Table_Type;
function Pcre_Maketables return Table_Type;
-- output strings for error message; normally size of 80 should be enough
subtype Message is String (1 .. 80);
procedure Compile
(Matcher : out Pcre_Type; Pattern : String; Error_Msg : out Message;
Last_Msg : out Natural; Error_Offset : out Natural;
Option : Options := 0; Table : Table_Type := Null_Table);
procedure Free (T : Table_Type);
procedure Free (M : Pcre_Type);
-- if you are using version 8.20 or later, you can modify the body and
-- consider interfacing to pcre_free_study
procedure Free (M : Extra_type);
-- return info to speed up/ null on error or if no optimization is
-- possible.
procedure Study
(Matcher_Extra : out Extra_type; Code : Pcre_Type;
Error_Msg : out Message; Last_Msg : out Natural; Option : Options := 0);
-----------------
-- Match_Array --
-----------------
-- Result of matches : same output as PCRE
-- size must be a multiple of 3 x (nbr of parentheses + 1)
-- For top-level, range should be 0 .. 2
-- For N parentheses, range should be 0 .. 3*(N+1) -1
-- If the dimension of Match_Array is insufficient, Result of Match is 0.
--
type Match_Array is array (Natural range <>) of Natural;
procedure Match
(Result : out Integer; Match_Vec : out Match_Array; Matcher : Pcre_Type;
Extra : Extra_type := Null_Extra; Subject : String; Length : Natural;
Startoffset : Natural := 0; Option : Options := 0);
-- Request types for pcre_fullinfo()
subtype Info is Integer range 0 .. 15;
PCRE_INFO_OPTIONS : constant Info := 0;
PCRE_INFO_SIZE : constant Info := 1;
PCRE_INFO_CAPTURECOUNT : constant Info := 2;
PCRE_INFO_BACKREFMAX : constant Info := 3;
PCRE_INFO_FIRSTBYTE : constant Info := 4;
PCRE_INFO_FIRSTTABLE : constant Info := 5;
PCRE_INFO_LASTLITERAL : constant Info := 6;
PCRE_INFO_NAMEENTRYSIZE : constant Info := 7;
PCRE_INFO_NAMECOUNT : constant Info := 8;
PCRE_INFO_NAMETABLE : constant Info := 9;
PCRE_INFO_STUDYSIZE : constant Info := 10;
PCRE_INFO_DEFAULT_TABLES : constant Info := 11;
PCRE_INFO_OKPARTIAL : constant Info := 12;
PCRE_INFO_JCHANGED : constant Info := 13;
PCRE_INFO_HASCRORLF : constant Info := 14;
PCRE_INFO_MINLENGTH : constant Info := 15;
function Fullinfo
(Code : Pcre_Type; Extra : Extra_type; What : Info;
Output_Addr : System.Address) return Integer;
subtype Configuration is Integer range 0 .. 8;
PCRE_CONFIG_UTF8 : constant Configuration := 0;
PCRE_CONFIG_NEWLINE : constant Configuration := 1;
PCRE_CONFIG_LINK_SIZE : constant Configuration := 2;
PCRE_CONFIG_POSIX_MALLOC_THRESHOLD : constant Configuration := 3;
PCRE_CONFIG_MATCH_LIMIT : constant Configuration := 4;
PCRE_CONFIG_STACKRECURSE : constant Configuration := 5;
PCRE_CONFIG_UNICODE_PROPERTIES : constant Configuration := 6;
PCRE_CONFIG_MATCH_LIMIT_RECURSION : constant Configuration := 7;
PCRE_CONFIG_BSR : constant Configuration := 8;
function Config
(What : Configuration; Output_Addr : System.Address) return Integer;
private
type Pcre_Type is new System.Address;
type Extra_type is new System.Address;
Null_Pcre : constant Pcre_Type := Pcre_Type (System.Null_Address);
Null_Extra : constant Extra_type := Extra_type (System.Null_Address);
type Table_Type is new System.Address;
Null_Table : constant Table_Type := Table_Type (System.Null_Address);
pragma Import (C, Pcre_Maketables, "pcre_maketables");
pragma Import (C, Fullinfo, "pcre_fullinfo");
pragma Import (C, Config, "pcre_config");
end AdaPcre;
|
with Ada.Characters.Latin_1;
with GNAT.Spitbol;
with Bitmaps.RGB;
package body Bitmaps.IO is
procedure Write_PPM_P6
(To : not null access Ada.Streams.Root_Stream_Type'Class;
Source : in Bitmaps.RGB.Image)
is
begin
-- Write P6 PPM type marker.
String'Write (To, "P6");
Character'Write (To, Ada.Characters.Latin_1.LF);
-- Write image dimensions.
String'Write (To, GNAT.Spitbol.S (Source.Width));
Character'Write (To, Ada.Characters.Latin_1.Space);
String'Write (To, GNAT.Spitbol.S (Source.Height));
Character'Write (To, Ada.Characters.Latin_1.LF);
-- Write maximum luminance value.
String'Write (To, GNAT.Spitbol.S (Integer (Luminance'Last)));
Character'Write (To, Ada.Characters.Latin_1.LF);
-- RGB component-wise output.
for Y in 0 .. Bitmaps.RGB.Max_Y (Source) loop
for X in 0 .. Bitmaps.RGB.Max_X (Source) loop
declare
Pxy : Bitmaps.RGB.Pixel := Bitmaps.RGB.Get_Pixel (Source, X, Y);
begin
Character'Write (To, Character'Val (Pxy.R));
Character'Write (To, Character'Val (Pxy.G));
Character'Write (To, Character'Val (Pxy.B));
end;
end loop;
end loop;
Character'Write (To, Ada.Characters.Latin_1.LF);
end Write_PPM_P6;
end Bitmaps.IO;
|
with Ada.Text_IO;
with GMP;
with MPFR;
with MPC;
procedure versions is
begin
Ada.Text_IO.Put_Line ("GMP: " & GMP.Version);
Ada.Text_IO.Put_Line ("MPFR: " & MPFR.Version);
Ada.Text_IO.Put_Line ("MPC: " & MPC.Version);
end versions;
|
-- Project: MART - Modular Airborne Real-Time Testbed
-- System: Emergency Recovery System
-- Authors: Markus Neumair (Original C-Code)
-- Emanuel Regnath (emanuel.regnath@tum.de) (Ada Port)
--
-- Module Description:
-- @summary Top-level driver for the Barometer HMC5883L-01BA03
package HMC5883L with SPARK_Mode is
end HMC5883L;
|
pragma License (Unrestricted);
-- implementation unit required by compiler
with System.Storage_Elements;
package System.Tasking is
pragma Preelaborate;
-- required for local tagged types by compiler (s-taskin.ads)
subtype Master_Level is Integer;
subtype Master_ID is Master_Level;
Foreign_Task_Level : constant Master_Level := 0;
Environment_Task_Level : constant Master_Level := 1;
Independent_Task_Level : constant Master_Level := 2;
Library_Task_Level : constant Master_Level := 3;
-- required for task by compiler (s-taskin.ads)
type Task_Procedure_Access is access procedure (Params : Address);
-- required for task by compiler (s-taskin.ads)
subtype Task_Id is Address; -- same as System.Tasks.Task_Id
-- required for task by compiler (s-taskin.ads)
-- "limited" is important to force pass-by-reference for Stages.Create_Task
type Activation_Chain is limited record
Data : Address := Null_Address;
end record;
for Activation_Chain'Size use Standard'Address_Size;
-- required for built-in-place of task by compiler (s-taskin.ads)
type Activation_Chain_Access is access all Activation_Chain;
for Activation_Chain_Access'Storage_Size use 0;
pragma No_Strict_Aliasing (Activation_Chain_Access);
-- required for task by compiler (s-taskin.ads)
Unspecified_Priority : constant Integer := Priority'First - 1;
Unspecified_CPU : constant := -1;
-- required for entry of task by compiler (s-taskin.ads)
Interrupt_Entry : constant := -2;
Cancelled_Entry : constant := -1;
Null_Entry : constant := 0;
Max_Entry : constant := Integer'Last;
subtype Entry_Index is Integer range Interrupt_Entry .. Max_Entry;
subtype Task_Entry_Index is Entry_Index range Null_Entry .. Max_Entry;
-- required for select when or by compiler (s-taskin.ads)
Null_Task_Entry : constant := Null_Entry;
-- required for protected entry by compiler (s-taskin.ads)
-- compiler may crash if Call_Modes is not declared as enum
type Call_Modes is (
Simple_Call, -- 0
Conditional_Call, -- 1
Asynchronous_Call); -- 2
-- Timed_Call); -- 3
pragma Discard_Names (Call_Modes);
-- required for slective accept by compiler (s-taskin.ads)
type Select_Modes is (Simple_Mode, Else_Mode, Terminate_Mode, Delay_Mode);
pragma Discard_Names (Select_Modes);
-- required for slective accept by compiler (s-taskin.ads)
No_Rendezvous : constant := 0;
-- required for slective accept by compiler (s-taskin.ads)
subtype Select_Index is Natural;
type Accept_Alternative is record
Null_Body : Boolean;
S : Task_Entry_Index;
end record;
pragma Suppress_Initialization (Accept_Alternative);
-- required for slective accept by compiler (s-taskin.ads)
type Accept_List is array (Positive range <>) of Accept_Alternative;
pragma Suppress_Initialization (Accept_List);
-- required for abort statement by compiler (s-taskin.ads)
type Task_List is array (Positive range <>) of Task_Id;
pragma Suppress_Initialization (Task_List);
-- required for abort statement by compiler (s-taskin.ads)
function Self return Task_Id
with Import, Convention => Ada, External_Name => "__drake_current_task";
type Storage_Size_Handler is access function (T : Task_Id)
return Storage_Elements.Storage_Count;
-- System.Parameters.Size_Type ???
pragma Favor_Top_Level (Storage_Size_Handler);
pragma Suppress (Access_Check, Storage_Size_Handler);
-- required for 'Storage_Size by compiler (s-taskin.ads)
Storage_Size : Storage_Size_Handler := null;
pragma Suppress (Access_Check, Storage_Size);
-- equivalent to String_Access (s-taskin.ads)
type Entry_Name_Access is access all String;
-- dispatching domain (s-taskin.ads)
type Dispatching_Domain is
array (Positive range <>) of Boolean;
-- array (Multiprocessors.CPU range <>) of Boolean
pragma Suppress_Initialization (Dispatching_Domain);
type Dispatching_Domain_Access is access Dispatching_Domain;
-- GDB knows below names, but hard to implement.
-- type Ada_Task_Control_Block;
-- type Common_ATCB;
-- type Entry_Call_Record;
-- Debug.Known_Tasks : array (0 .. 999) of Task_Id;
-- Debug.First_Task : ???
-- procedure Restricted.Stages.Task_Wrapper (Self_ID : Task_Id);
-- type System.Task_Primitives.Private_Data;
end System.Tasking;
|
-- SPDX-FileCopyrightText: 2010-2021 Max Reznik <reznikmm@gmail.com>
--
-- SPDX-License-Identifier: MIT
-------------------------------------------------------------
with Ada.Characters.Wide_Wide_Latin_1;
package body WebIDL.String_Sources is
--------------
-- Get_Next --
--------------
overriding function Get_Next
(Self : not null access String_Source)
return WebIDL.Abstract_Sources.Code_Unit_32
is
begin
if Self.Cursor.Has_Element then
return Result : WebIDL.Abstract_Sources.Code_Unit_32 do
Result := Wide_Wide_Character'Pos
(Self.Cursor.Element);
Self.Cursor.Next;
end return;
elsif Self.Index < Self.Vector.Length then
Self.Index := Self.Index + 1;
Self.Line := Self.Vector (Self.Index);
Self.Cursor.First (Self.Line);
return Wide_Wide_Character'Pos (Ada.Characters.Wide_Wide_Latin_1.LF);
elsif Self.Index = Self.Vector.Length then
Self.Index := Self.Index + 1;
return Wide_Wide_Character'Pos (Ada.Characters.Wide_Wide_Latin_1.LF);
else
return WebIDL.Abstract_Sources.End_Of_Input;
end if;
end Get_Next;
-----------------------
-- Set_String_Vector --
-----------------------
procedure Set_String_Vector
(Self : out String_Source;
Value : League.String_Vectors.Universal_String_Vector) is
begin
Self.Vector := Value;
Self.Index := 1;
Self.Line := Value (Self.Index);
Self.Cursor.First (Self.Line);
end Set_String_Vector;
end WebIDL.String_Sources;
|
------------------------------------------------------------------------------
-- --
-- ASIS-for-GNAT IMPLEMENTATION COMPONENTS --
-- --
-- A S I S . D A T A _ D E C O M P O S I T I O N . A U X --
-- --
-- S p e c --
-- --
-- Copyright (c) 1995-2005, 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). --
-- --
------------------------------------------------------------------------------
-- This package contains auxiliary routines needed by queries from
-- Asis.Data_Decomposition.
with Snames; use Snames;
private package Asis.Data_Decomposition.Aux is
-- If the documentation of a function which works on ASIS Element does
-- not contain an explicit list of appropriate Element Kinds, this means,
-- that the functon does not check the kind of its actual, and a caller
-- is responsible for proving the correct argument.
function Subtype_Model_Kind (S : Element) return Type_Model_Kinds;
-- Defines Type_Model_Kind for A_Subtype_Indication Element.
-- The current approach is:
--
-- - if the model kind of the type mark of S is A_Complex_Dynamic_Model
-- or Not_A_Type_Model the result is also A_Complex_Dynamic_Model or
-- Not_A_Type_Model respectively, regardless of the constraint imposed
-- by S (if any); ???
-- - if S does not contain an explicit constraint, its model kind is the
-- same as of its type mark;
--
-- - if S contains an explicit constraint, then:
-- o if the constraint is static, the result is A_Simple_Static_Model;
--
-- o if the constraint is dynamic, but the only dynamic components
-- in this constraint are discriminants from the enclosing record
-- type definition, then the result is A_Simple_Dynamic_Model;
--
-- o otherwise the result is A_Complex_Dynamic_Model;
type Constraint_Model_Kinds is (
Not_A_Constraint_Model,
-- non-defined
Static_Constraint,
-- constraint is defined by static expressions
Discriminated,
-- all the dynamic expressions in the constrain are discriminants of
-- the enclosing record type definition
External);
-- the constraint contains external dynamic expressions
function Constraint_Model_Kind (C : Element) return Constraint_Model_Kinds;
-- Supposing that C is either index or discriminant constraint element,
-- this function checks the model kind of this constraint.
function Record_Model_Kind (R : Element) return Type_Model_Kinds;
-- Provided that R is of A_Record_Type_Definition kind, defines
-- the type model kind for it.
function Type_Definition_From_Subtype_Mark (S : Element) return Element;
-- Taking an Element which is a subtype mark defining a given component,
-- this query computes the type definition for the (base) type denoted
-- by this type mark.
function Discriminant_Part_From_Type_Definition
(T : Element)
return Element;
-- Provided that T is A_Type_Definition Element, it returns its
-- known_discriminant_part (Nil_Element if there is no
-- known_discriminant_part). In case of a derived type,
-- known_discriminant_part of the parent type is returned in case if
-- the declaration of this derived type does not have its own
-- known_discriminant_part
function Is_Derived_From_Record (TD : Element) return Boolean;
function Is_Derived_From_Array (TD : Element) return Boolean;
-- Check if TD is A_Derived_Type_Definition element defining a type which
-- is (directly or undirectly) derived from a record/array type.
function Root_Record_Definition (Type_Def : Element) return Element;
function Root_Array_Definition (Type_Def : Element) return Element;
-- If Is_Derived_From_Record/Is_Derived_From_Array (Type_Def), then this
-- function returns the definition of a record type/array from which this
-- type is derived (directly or indirectly). Otherwise it returns its
-- argument unchanged.
function Component_Type_Definition (E : Element) return Element;
-- Provided that E is of A_Component_Declaration (Record_Component
-- case) or A_Subtype_Indication (Array_Component case) kind (the function
-- does not check this, a caller is responsible for providing the right
-- argument), this function returns the type definition for this component
-- (it unwinds all the subtypings, but not derivations)
function Subtype_Entity (E : Element) return Entity_Id;
-- Given E as A_Subtype_Indication element, this function computes the
-- Entity Id of the corresponding type or subtype (which may be an
-- implicit type created by the compiler as well)
function Linear_Index
(Inds : Dimension_Indexes;
Ind_Lengths : Dimention_Length;
Conv : Convention_Id := Convention_Ada)
return Asis.ASIS_Natural;
function De_Linear_Index
(Index : Asis.ASIS_Natural;
D : ASIS_Natural;
Ind_Lengths : Dimention_Length;
Conv : Convention_Id := Convention_Ada)
return Dimension_Indexes;
-- These two functions perform index linearizetion-delinearization
-- for DDA queries working with array componnets and indexes
-- D is the number of dimention of an array componnet, Ind_Lengths is a
-- list of lengths for each dimention, both these parameters should come
-- from the caller, they should be extracted from the corresponding array
-- component. The length of Dimension_Indexes returned by De_Linear_Index
-- is D.
--
-- ??? What about checks that indexes and length are in right ranges???
-- ??? Or should it be done in the calling context???
function Max_Len (Component : Array_Component) return Asis.ASIS_Natural;
-- Computes linearized length of array componnet
function Wrong_Indexes
(Component : Array_Component;
Indexes : Dimension_Indexes)
return Boolean;
-- Supposing that Componnet is not-null, this function checks if Indexes
-- are in the expected ranges for this component (this check starts from
-- checking that the dimentions are the same). Returns True if Indexes
-- are NOT the appropriate indexes for the component, because this
-- function is supposed to use as a check to detect an inappropriate
-- argument of a query
function Build_Discrim_List_If_Data_Presented
(Rec : Entity_Id;
Data : Asis.Data_Decomposition.Portable_Data;
Ignore_Discs : Boolean := False)
return Discrim_List;
-- This is a wrapper function for A4G.DDA_Aux.Build_Discrim_List.
-- In case is Data is not Nil_Portable_Data, it behaves as
-- A4G.DDA_Aux.Build_Discrim_List, otherwise if Ignore_Discs is not set
-- ON, it tries to get the discriminant data from the discriminant
-- constraint or default discriminant values, otherwise it returns
-- Null_Discrims,
end Asis.Data_Decomposition.Aux;
|
with Loop_Optimization7_Pkg; use Loop_Optimization7_Pkg;
package Loop_Optimization7 is
type Arr is array (1..8) of Rec;
function Conv (A : Arr) return Arr;
end Loop_Optimization7;
|
generic
HSE_Value : HSE_Range := 8_000_000;
PLL_Source : PLL_Source_Type := HSI;
SYSCLK_Source : SYSCLK_Source_Type := HSI;
RTC_Source : RTC_Source_Type := LSI;
PLL_Prediv : PLL_Prediv_Range := 1;
PLL_Mul : PLL_Mul_Range := 1;
AHB_Prescaler : AHB_Prescaler_Type := DIV1;
APB_Prescaler : APB_Prescaler_Type := DIV1;
LSI_Enabled : Boolean := True;
LSE_Enabled : Boolean := False;
package STM32GD.Clock.Tree is
pragma Preelaborate;
PLL_Value : constant Integer := (
case PLL_Source is
when HSI => HSI_Value / 2,
when HSE => HSE_Value / PLL_Prediv);
PLL_Output_Value : constant Integer := (PLL_Value / PLL_Prediv) * PLL_Mul;
SYSCLK : constant Integer := (
case SYSCLK_Source is
when HSI => HSI_Value,
when PLL => PLL_Output_Value,
when HSE => HSE_Value);
HCLK : constant Integer := (
case AHB_Prescaler is
when DIV1 => SYSCLK,
when DIV2 => SYSCLK / 2,
when DIV4 => SYSCLK / 4,
when DIV8 => SYSCLK / 8,
when DIV16 => SYSCLK / 16,
when DIV64 => SYSCLK / 64,
when DIV128 => SYSCLK / 128,
when DIV256 => SYSCLK / 256,
when DIV512 => SYSCLK / 512);
PCLK : constant Integer := (
case APB_Prescaler is
when DIV1 => HCLK,
when DIV2 => HCLK / 2,
when DIV4 => HCLK / 4,
when DIV8 => HCLK / 8,
when DIV16 => HCLK / 16);
RTCCLK : constant Integer := (
case RTC_Source is
when LSI => LSI_Value,
when LSE => LSE_Value,
when HSE => HSE_Value / 128);
function Frequency (Clock : Clock_Type) return Integer;
procedure Init;
end STM32GD.Clock.Tree;
|
-- --
-- package Copyright (c) Dmitry A. Kazakov --
-- GNAT.Sockets.Connection_State_Machine. Luebeck --
-- Terminated_Strings Winter, 2012 --
-- Implementation --
-- Last revision : 16:04 08 Jun 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. --
--____________________________________________________________________--
with Ada.Exceptions; use Ada.Exceptions;
with Ada.IO_Exceptions; use Ada.IO_Exceptions;
with Strings_Edit.Integers; use Strings_Edit.Integers;
with Ada.Unchecked_Deallocation;
package body GNAT.Sockets.Connection_State_Machine.Terminated_Strings is
procedure Free is
new Ada.Unchecked_Deallocation (String, String_Ptr);
procedure Feed
( Item : in out String_Data_Item;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset;
Client : in out State_Machine'Class;
State : in out Stream_Element_Offset
) is
This : Character;
begin
if State = 0 then
Item.Last := 0;
State := 1;
end if;
while Pointer <= Data'Last loop
This := Character'Val (Data (Pointer));
if This = Item.Terminator then
Pointer := Pointer + 1;
State := 0;
return;
elsif Item.Last = Item.Value'Last then
Raise_Exception
( Data_Error'Identity,
( "Terminated string length exceeds "
& Image (Item.Size)
& " characters"
) );
else
Item.Last := Item.Last + 1;
Item.Value (Item.Last) := This;
Pointer := Pointer + 1;
end if;
end loop;
end Feed;
procedure Feed
( Item : in out Dynamic_String_Data_Item;
Data : Stream_Element_Array;
Pointer : in out Stream_Element_Offset;
Client : in out State_Machine'Class;
State : in out Stream_Element_Offset
) is
This : Character;
begin
if Item.Value = null then
Raise_Exception
( Data_Error'Identity,
"Terminated string length exceeds 0 characters"
);
end if;
if State = 0 then
Item.Last := 0;
State := 1;
end if;
while Pointer <= Data'Last loop
This := Character'Val (Data (Pointer));
if This = Item.Terminator then
Pointer := Pointer + 1;
State := 0;
return;
elsif Item.Last = Item.Value'Last then
Raise_Exception
( Data_Error'Identity,
( "Terminated string length exceeds "
& Image (Integer'(Item.Value'Length))
& " characters"
) );
else
Item.Last := Item.Last + 1;
Item.Value (Item.Last) := This;
Pointer := Pointer + 1;
end if;
end loop;
end Feed;
procedure Finalize (Item : in out Dynamic_String_Data_Item) is
begin
Finalize (Data_Item (Item));
Free (Item.Value);
end Finalize;
function Get
( Data : Stream_Element_Array;
Pointer : access Stream_Element_Offset;
Terminator : Character
) return String is
Next : Stream_Element_Offset := Pointer.all;
begin
if ( Next < Data'First
or else
( Next > Data'Last
and then
Next > Data'Last + 1
) )
then
Raise_Exception (Layout_Error'Identity, Out_Of_Bounds);
end if;
while Next <= Data'Last loop
if Character'Val (Data (Next)) = Terminator then
declare
Result : String (1..Natural (Next - Pointer.all));
begin
Next := Pointer.all;
for Index in Result'Range loop
Result (Index) := Character'Val (Data (Next));
Next := Next + 1;
end loop;
Pointer.all := Next + 1;
return Result;
end;
else
Next := Next + 1;
end if;
end loop;
Raise_Exception
( End_Error'Identity,
"Missing string terminator"
);
end Get;
function Get_Maximum_Size
( Item : Dynamic_String_Data_Item
) return Natural is
begin
if Item.Value = null then
return 0;
else
return Item.Value'Length;
end if;
end Get_Maximum_Size;
function Get_Value (Item : String_Data_Item) return String is
begin
return Item.Value (1..Item.Last);
end Get_Value;
function Get_Value
( Item : Dynamic_String_Data_Item
) return String is
begin
if Item.Value = null then
return "";
else
return Item.Value (1..Item.Last);
end if;
end Get_Value;
procedure Put
( Data : in out Stream_Element_Array;
Pointer : in out Stream_Element_Offset;
Value : String;
Terminator : Character
) is
begin
if ( Pointer < Data'First
or else
( Pointer > Data'Last
and then
Pointer - 1 > Data'Last
) )
then
Raise_Exception (Layout_Error'Identity, Out_Of_Bounds);
elsif Data'Last - Pointer < Value'Length then
Raise_Exception (End_Error'Identity, No_Room);
end if;
for Index in Value'Range loop
if Value (Index) = Terminator then
Raise_Exception
( Data_Error'Identity,
"The string body contains the terminator"
);
end if;
end loop;
for Index in Value'Range loop
Data (Pointer) := Character'Pos (Value (Index));
Pointer := Pointer + 1;
end loop;
Data (Pointer) := Character'Pos (Terminator);
Pointer := Pointer + 1;
end Put;
procedure Set_Maximum_Size
( Item : in out Dynamic_String_Data_Item;
Size : Positive
) is
begin
if Item.Value = null then
Item.Value := new String (1..Size);
Item.Last := 0;
elsif Item.Value'Length < Size then
Free (Item.Value);
Item.Value := new String (1..Size);
Item.Last := 0;
end if;
end Set_Maximum_Size;
end GNAT.Sockets.Connection_State_Machine.Terminated_Strings;
|
with
physics.Object;
package body gel.any_Joint
is
use Math;
---------
-- Forge
--
procedure define (Self : access Item; in_Space : in std_physics.Space.view;
Sprite_A, Sprite_B : access gel.Sprite.item'Class;
Frame_A, Frame_B : in Matrix_4x4)
is
A_Frame : aliased constant Matrix_4x4 := Frame_A;
B_Frame : aliased constant Matrix_4x4 := Frame_B;
type Joint_cast is access all gel.Joint.Item;
sprite_A_Solid,
sprite_B_Solid : std_Physics.Object.view;
begin
if Sprite_A /= null then sprite_A_Solid := std_Physics.Object.view (Sprite_A.Solid); end if;
if Sprite_B /= null then sprite_B_Solid := std_Physics.Object.view (Sprite_B.Solid); end if;
Joint.define (Joint_cast (Self), Sprite_A, Sprite_B); -- Define base class.
Self.Physics := in_Space.new_DoF6_Joint (sprite_A_Solid,
sprite_B_Solid,
A_Frame,
B_Frame);
end define;
procedure define (Self : access Item; in_Space : in std_physics.Space.view;
Sprite_A, Sprite_B : access gel.Sprite.item'Class;
pivot_Anchor : in Vector_3;
pivot_Axis : in Matrix_3x3)
is
use linear_Algebra_3D;
pivot_in_A : constant Vector_3 := Inverse (Sprite_A.Spin) * (pivot_Anchor - Sprite_A.Site);
pivot_in_B : constant Vector_3 := Inverse (Sprite_B.Spin) * (pivot_Anchor - Sprite_B.Site);
axis_in_A : constant Matrix_3x3 := Sprite_A.Spin * pivot_Axis;
axis_in_B : constant Matrix_3x3 := Sprite_B.Spin * pivot_Axis;
Frame_A : constant Matrix_4x4 := to_transform_Matrix (axis_in_A, pivot_in_A);
Frame_B : constant Matrix_4x4 := to_transform_Matrix (axis_in_B, pivot_in_B);
begin
Self.define (in_Space,
Sprite_A, Sprite_B,
Frame_A, Frame_B);
end define;
overriding
procedure destroy (Self : in out Item)
is
begin
raise Error with "TODO";
end destroy;
--------------
--- Attributes
--
overriding
function Frame_A (Self : in Item) return Matrix_4x4
is
begin
return Self.Physics.Frame_A;
end Frame_A;
overriding
function Frame_B (Self : in Item) return Matrix_4x4
is
begin
return Self.Physics.Frame_B;
end Frame_B;
overriding
procedure Frame_A_is (Self : in out Item; Now : in Matrix_4x4)
is
begin
Self.Physics.Frame_A_is (Now);
end Frame_A_is;
overriding
procedure Frame_B_is (Self : in out Item; Now : in Matrix_4x4)
is
begin
Self.Physics.Frame_B_is (Now);
end Frame_B_is;
overriding
function Physics (Self : in Item) return gel.joint.Physics_view
is
begin
return gel.joint.Physics_view (Self.Physics);
end Physics;
overriding
function Degrees_of_freedom (Self : in Item) return Joint.Degree_of_freedom
is
pragma unreferenced (Self);
begin
return 6;
end Degrees_of_freedom;
-- Bounds - limits the range of motion for a degree of freedom.
--
-- TODO: Use Radians type for angular bounds.
overriding
function is_Bound (Self : in Item; for_Degree : in joint.Degree_of_freedom) return Boolean
is
begin
if for_Degree in Sway .. Surge then
return False;
end if;
return Self.Physics.is_Limited (for_Degree);
end is_Bound;
overriding
function low_Bound (Self : access Item; for_Degree : in joint.Degree_of_freedom) return Real
is
begin
case for_Degree
is
when Sway .. Surge =>
raise Error with "Unhandled degree of freedom:" & for_Degree'Image;
when Pitch .. Roll =>
return Self.Physics.lower_Limit (for_Degree);
end case;
end low_Bound;
overriding
procedure low_Bound_is (Self : access Item; for_Degree : in Joint.Degree_of_freedom;
Now : in Real)
is
begin
Self.Physics.lower_Limit_is (Now, for_Degree);
end low_Bound_is;
overriding
function high_Bound (Self : access Item; for_Degree : in Joint.Degree_of_freedom) return Real
is
begin
case for_Degree
is
when Sway .. Surge =>
raise Error with "Unhandled degree of freedom:" & for_Degree'Image;
when Pitch .. Roll =>
return Self.Physics.upper_Limit (for_Degree);
end case;
end high_Bound;
overriding
procedure high_Bound_is (Self : access Item; for_Degree : in Joint.Degree_of_freedom;
Now : in Real)
is
begin
Self.Physics.upper_Limit_is (Now, for_Degree);
end high_Bound_is;
----------
-- Extent
--
overriding
function Extent (Self : in Item; for_Degree : in Joint.Degree_of_freedom) return Real
is
begin
if for_Degree in Sway .. Surge
then
raise Error with "Unhandled degree of freedom:" & for_Degree'Image;
end if;
return Self.Physics.Extent (for_Degree);
end Extent;
------------------
-- Motor Velocity
--
overriding
procedure Velocity_is (Self : in Item; for_Degree : in Joint.Degree_of_freedom;
Now : in Real)
is
begin
Self.Physics.Velocity_is (Now, for_Degree);
end Velocity_is;
end gel.any_Joint;
|
-- MIT License
--
-- Copyright (c) 2020 Max Reznik
--
-- 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 League.String_Vectors;
with Compiler.File_Descriptors;
package body Compiler.Context is
function "+" (Text : Wide_Wide_String)
return League.Strings.Universal_String
renames League.Strings.To_Universal_String;
Reserved : String_Sets.Set;
---------
-- "+" --
---------
function "+"
(Self : Ada_Type_Name) return League.Strings.Universal_String
is
use type League.Strings.Universal_String;
begin
if Self.Package_Name.Is_Empty then
return Self.Type_Name;
else
return Self.Package_Name & "." & Self.Type_Name;
end if;
end "+";
-------------------
-- Compound_Name --
-------------------
function Compound_Name
(Self : Ada_Type_Name;
Current_Package : League.Strings.Universal_String)
return League.Strings.Universal_String
is
use type League.Strings.Universal_String;
Result : League.Strings.Universal_String := +Self;
begin
Result := Relative_Name (Result, Current_Package);
return Result.Split ('.', League.Strings.Skip_Empty).Join ("_");
end Compound_Name;
--------------
-- Get_File --
--------------
function Get_File
(Request : Google.Protobuf.Compiler.Plugin.Code_Generator_Request;
Name : League.Strings.Universal_String)
return Google.Protobuf.Descriptor.File_Descriptor_Proto
is
use type League.Strings.Universal_String;
begin
for J in 1 .. Request.Proto_File.Length loop
declare
Result : constant Google.Protobuf.Descriptor.File_Descriptor_Proto
:= Request.Proto_File (J);
begin
if Result.Name.Is_Set and then Result.Name.Value = Name then
return Result;
end if;
end;
end loop;
raise Constraint_Error;
end Get_File;
----------------------
-- Is_Reserved_Word --
----------------------
function Is_Reserved_Word
(Name : League.Strings.Universal_String) return Boolean is
begin
return Reserved.Contains (Name.To_Lowercase);
end Is_Reserved_Word;
----------
-- Join --
----------
function Join
(Prefix : League.Strings.Universal_String;
Name : PB_Support.Universal_String_Vectors.Option)
return League.Strings.Universal_String
is
Result : League.Strings.Universal_String := Prefix;
begin
Result.Append (".");
if Name.Is_Set then
Result.Append (Name.Value);
end if;
return Result;
end Join;
-------------------
-- New_Type_Name --
-------------------
function New_Type_Name
(Name : PB_Support.Universal_String_Vectors.Option;
Default : League.Strings.Universal_String;
Prefix : League.Strings.Universal_String;
Local : Compiler.Context.Named_Type_Maps.Map;
Used : Compiler.Context.String_Sets.Set)
return League.Strings.Universal_String
is
use type League.Strings.Universal_String;
Result : constant League.Strings.Universal_String :=
(if Name.Is_Set
then Compiler.Context.To_Ada_Name (Name.Value)
else Default);
begin
if not Used.Contains (Result) then
return Result;
elsif Named_Types.Contains (Prefix) then
return Named_Types (Prefix).Ada_Type.Type_Name & "_" & Result;
elsif Local.Contains (Prefix) then
return Local (Prefix).Ada_Type.Type_Name & "_" & Result;
else
return Result;
end if;
end New_Type_Name;
--------------------------
-- Populate_Named_Types --
--------------------------
procedure Populate_Named_Types
(Request : Google.Protobuf.Compiler.Plugin.Code_Generator_Request;
Map : in out Compiler.Context.Named_Type_Maps.Map) is
begin
for J in 1 .. Request.Proto_File.Length loop
Compiler.File_Descriptors.Populate_Named_Types
(Request.Proto_File (J), Map);
end loop;
end Populate_Named_Types;
-------------------
-- Relative_Name --
-------------------
function Relative_Name
(Full_Name : League.Strings.Universal_String;
Current_Package : League.Strings.Universal_String)
return League.Strings.Universal_String
is
use type League.Strings.Universal_String;
FN : constant League.String_Vectors.Universal_String_Vector :=
Full_Name.Split ('.');
CP : constant League.String_Vectors.Universal_String_Vector :=
Current_Package.Split ('.');
begin
for J in 1 .. FN.Length - 1 loop
declare
Prefix : constant League.Strings.Universal_String :=
FN.Element (J);
Ok : Boolean := True;
begin
for K in J + 1 .. CP.Length loop
Ok := Prefix /= CP.Element (K);
exit when not Ok;
end loop;
if Ok then
declare
Result : League.String_Vectors.Universal_String_Vector;
begin
for K in J .. FN.Length loop
Result.Append (FN.Element (K));
end loop;
return Result.Join ('.');
end;
end if;
end;
end loop;
return FN.Element (FN.Length);
end Relative_Name;
-----------------
-- To_Ada_Name --
-----------------
function To_Ada_Name
(Text : League.Strings.Universal_String)
return League.Strings.Universal_String
is
use type League.Strings.Universal_String;
Allow_Underscore : Boolean := False;
Force_Upper : Boolean := True;
Last_Was_Upper : Boolean := True;
Result : League.Strings.Universal_String;
begin
if Reserved.Contains (Text.To_Lowercase) then
return To_Ada_Name ("PB_" & Text);
elsif Text.Ends_With ("_") then
return To_Ada_Name (Text.Head (Text.Length - 1));
end if;
for J in 1 .. Text.Length loop
if Text.Element (J).To_Wide_Wide_Character = '_' then
if Allow_Underscore then
Result.Append (Text.Element (J));
end if;
Force_Upper := True;
elsif Force_Upper then
Result.Append (Text.Slice (J, J).To_Uppercase);
Force_Upper := False;
Last_Was_Upper := True;
elsif Text.Slice (J, J).To_Uppercase /= Text.Slice (J, J) then
Last_Was_Upper := False;
Result.Append (Text.Element (J));
elsif not Last_Was_Upper then
Last_Was_Upper := True;
Result.Append ("_");
Result.Append (Text.Element (J));
else
Result.Append (Text.Element (J));
end if;
Allow_Underscore := Text.Element (J).To_Wide_Wide_Character /= '_';
end loop;
return Result;
end To_Ada_Name;
--------------------------
-- To_Selected_Ada_Name --
--------------------------
function To_Selected_Ada_Name
(Text : League.Strings.Universal_String)
return League.Strings.Universal_String
is
List : League.String_Vectors.Universal_String_Vector := Text.Split ('.');
begin
for J in 1 .. List.Length loop
List.Replace (J, To_Ada_Name (List (J)));
end loop;
return List.Join ('.');
end To_Selected_Ada_Name;
begin
Reserved.Insert (+"abort");
Reserved.Insert (+"abs");
Reserved.Insert (+"abstract");
Reserved.Insert (+"accept");
Reserved.Insert (+"access");
Reserved.Insert (+"aliased");
Reserved.Insert (+"all");
Reserved.Insert (+"and");
Reserved.Insert (+"array");
Reserved.Insert (+"at");
Reserved.Insert (+"begin");
Reserved.Insert (+"body");
Reserved.Insert (+"case");
Reserved.Insert (+"constant");
Reserved.Insert (+"declare");
Reserved.Insert (+"delay");
Reserved.Insert (+"delta");
Reserved.Insert (+"digits");
Reserved.Insert (+"do");
Reserved.Insert (+"else");
Reserved.Insert (+"elsif");
Reserved.Insert (+"end");
Reserved.Insert (+"entry");
Reserved.Insert (+"exception");
Reserved.Insert (+"exit");
Reserved.Insert (+"for");
Reserved.Insert (+"function");
Reserved.Insert (+"generic");
Reserved.Insert (+"goto");
Reserved.Insert (+"if");
Reserved.Insert (+"in");
Reserved.Insert (+"interface");
Reserved.Insert (+"is");
Reserved.Insert (+"limited");
Reserved.Insert (+"loop");
Reserved.Insert (+"mod");
Reserved.Insert (+"new");
Reserved.Insert (+"not");
Reserved.Insert (+"null");
Reserved.Insert (+"of");
Reserved.Insert (+"or");
Reserved.Insert (+"others");
Reserved.Insert (+"out");
Reserved.Insert (+"overriding");
Reserved.Insert (+"package");
Reserved.Insert (+"pragma");
Reserved.Insert (+"private");
Reserved.Insert (+"procedure");
Reserved.Insert (+"protected");
Reserved.Insert (+"raise");
Reserved.Insert (+"range");
Reserved.Insert (+"record");
Reserved.Insert (+"rem");
Reserved.Insert (+"renames");
Reserved.Insert (+"requeue");
Reserved.Insert (+"return");
Reserved.Insert (+"reverse");
Reserved.Insert (+"select");
Reserved.Insert (+"separate");
Reserved.Insert (+"some");
Reserved.Insert (+"subtype");
Reserved.Insert (+"synchronized");
Reserved.Insert (+"tagged");
Reserved.Insert (+"task");
Reserved.Insert (+"terminate");
Reserved.Insert (+"then");
Reserved.Insert (+"type");
Reserved.Insert (+"until");
Reserved.Insert (+"use");
Reserved.Insert (+"when");
Reserved.Insert (+"while");
Reserved.Insert (+"with");
Reserved.Insert (+"xor");
end Compiler.Context;
|
-- class package: ${self.name}
-- description: self.description
.if ( "" != domain_types_package_name )
with ${domain_types_package_name};
.end if
package ${root_package.name}.${domain_package.name}.${self.name} is
--************** Object ${self.long_name} Information **************
Object_String : String := "${self.name}";
${record_body}
end ${root_package.name}.${domain_package.name}.${self.name};
|
with STM32.Device;
with STM32.CORDIC.Polling;
package body Inverter_PWM is
-----------------------
-- Initialize_CORDIC --
-----------------------
procedure Initialize_CORDIC is
use STM32.Device;
begin
Enable_Clock (CORDIC_Unit);
Configure_CORDIC_Coprocessor
(CORDIC_Unit,
Operation => Sine,
Precision => Iteration_12,
Data_Size => Data_16_Bit);
end Initialize_CORDIC;
--------------------
-- Initialize_PWM --
--------------------
procedure Initialize_PWM (Frequency : Frequency_Hz;
Deadtime : Deadtime_Range;
Alignment : PWM_Alignment)
is
Counter_Mode : constant Timer_Counter_Alignment_Mode :=
(case Alignment is
when Edge => Up,
when Center => Center_Aligned2);
begin
Configure_PWM_Timer (Generator => PWM_Timer_Ref,
Frequency => UInt32 (Frequency));
Set_Counter_Mode (This => PWM_Timer_Ref.all,
Value => Counter_Mode);
Configure_Deadtime (This => PWM_Timer_Ref.all,
Time => Deadtime);
Set_BDTR_Lock (This => PWM_Timer_Ref.all,
Lock => Level_1);
for P in PWM_Phase'Range loop
Modulators (P).Attach_PWM_Channel
(Generator => PWM_Timer_Ref,
Channel => Gate_Phase_Settings (P).Channel,
Point => Gate_Phase_Settings (P).Pin_H,
Complementary_Point => Gate_Phase_Settings (P).Pin_L,
PWM_AF => Gate_Phase_Settings (P).Pin_AF,
Polarity => High,
Idle_State => Disable,
Complementary_Polarity => High,
Complementary_Idle_State => Disable);
Set_Output_Preload_Enable (This => PWM_Timer_Ref.all,
Channel => Gate_Phase_Settings (P).Channel,
Enabled => True);
end loop;
Initialized := True;
end Initialize_PWM;
------------------
-- Enable_Phase --
------------------
procedure Enable_Phase (This : PWM_Phase) is
begin
Modulators (This).Enable_Output;
Modulators (This).Enable_Complementary_Output;
end Enable_Phase;
-------------------
-- Disable_Phase --
-------------------
procedure Disable_Phase (This : PWM_Phase) is
begin
Modulators (This).Disable_Output;
Modulators (This).Disable_Complementary_Output;
end Disable_Phase;
---------------
-- Start_PWM --
---------------
procedure Start_PWM is
begin
Reset_Sine_Step;
for P in PWM_Phase'Range loop
Set_Duty_Cycle (This => P,
Value => 0.0);
Enable_Phase (P);
end loop;
Enable_Interrupt (This => PWM_Timer_Ref.all,
Source => Timer_Update_Interrupt);
end Start_PWM;
--------------
-- Stop_PWM --
--------------
procedure Stop_PWM is
begin
Disable_Interrupt (This => PWM_Timer_Ref.all,
Source => Timer_Update_Interrupt);
for P in PWM_Phase'Range loop
Disable_Phase (P);
Set_Duty_Cycle (This => P,
Value => 0.0);
end loop;
Reset_Sine_Step;
end Stop_PWM;
-------------------------
-- Get_Duty_Resolution --
-------------------------
function Get_Duty_Resolution return Duty_Cycle is
begin
return Duty_Cycle (100.0 / Float (Current_Autoreload (PWM_Timer_Ref.all)));
end Get_Duty_Resolution;
--------------------
-- Set_Duty_Cycle --
--------------------
procedure Set_Duty_Cycle (This : PWM_Phase;
Value : Duty_Cycle)
is
Pulse : UInt16;
begin
Pulse := UInt16 (Value * Float (Current_Autoreload (PWM_Timer_Ref.all)) / 100.0);
Set_Compare_Value
(This => PWM_Timer_Ref.all,
Channel => Gate_Phase_Settings (This).Channel,
Value => Pulse);
end Set_Duty_Cycle;
--------------------
-- Set_Duty_Cycle --
--------------------
procedure Set_Duty_Cycle (This : PWM_Phase;
Amplitude : Sine_Range;
Gain : Gain_Range)
is
Pulse : UInt16;
begin
Pulse := UInt16 (Gain * Amplitude *
Float (Current_Autoreload (PWM_Timer_Ref.all)));
Set_Compare_Value
(This => PWM_Timer_Ref.all,
Channel => Gate_Phase_Settings (This).Channel,
Value => Pulse);
end Set_Duty_Cycle;
------------------------
-- Set_PWM_Gate_Power --
------------------------
-- This depends on the driver electronic circuit. Actually it is
-- programmed to turn ON the gates driver with a low level.
procedure Set_PWM_Gate_Power (Enabled : in Boolean) is
begin
if Enabled then
PWM_Gate_Power.Clear;
else
PWM_Gate_Power.Set;
end if;
end Set_PWM_Gate_Power;
---------------------
-- Reset_Sine_Step --
---------------------
procedure Reset_Sine_Step is
begin
Sine_Step := Sine_Step_Range'First;
end Reset_Sine_Step;
----------------
-- Safe_State --
----------------
procedure Safe_State is
begin
Set_PWM_Gate_Power (Enabled => False);
Stop_PWM;
end Safe_State;
--------------------
-- Is_Initialized --
--------------------
function Is_Initialized
return Boolean is (Initialized);
-----------------
-- PWM_Handler --
-----------------
protected body PWM_Handler is
---------------------
-- PWM_ISR_Handler --
---------------------
procedure PWM_ISR_Handler is
use STM32.Device;
begin
if Status (PWM_Timer, Timer_Update_Indicated) then
if Interrupt_Enabled (PWM_Timer, Timer_Update_Interrupt) then
Clear_Pending_Interrupt (PWM_Timer, Timer_Update_Interrupt);
-- Calculate sine function
Polling.Calculate_CORDIC_Function
(CORDIC_Unit,
Argument => Data_In,
Result => Data_Out);
Sine_Amplitude := Float (UInt16_To_Q1_15 (Data_Out (1)));
if not Semi_Senoid then -- First half cycle
Set_Duty_Cycle (This => A,
Amplitude => Sine_Amplitude,
Gain => Sine_Gain);
-- Not necessary because the last value of B amplitude was 0
-- Set_Duty_Cycle (This => B,
-- Amplitude => Sine_Range'Last, -- Value 0
-- Gain => Gain_Range'First); -- Value 0
else -- Second half cycle
Set_Duty_Cycle (This => B,
Amplitude => Sine_Amplitude,
Gain => Sine_Gain);
-- Not necessary because the last value of A amplitude was 0
-- Set_Duty_Cycle (This => A,
-- Amplitude => Sine_Range'Last, -- Value 0
-- Gain => Gain_Range'First); -- Value 0
end if;
-- We need to test if [Sine_Step - Increment] is lower then
-- Sine_Step_Range'First before decrementing Angle, to not get
-- overflow.
if (Sine_Step - Increment) < Sine_Step_Range'First then
Sine_Step := Initial_Step;
Semi_Senoid := not Semi_Senoid;
else
Sine_Step := Sine_Step - Increment;
end if;
-- Write the new angle value into the first position of the buffer.
Data_In (1) := Q1_15_To_UInt16 (Sine_Step);
-- Testing the 30 kHz output with 1 Hz LED blinking.
-- if Counter = 15_000 then
-- Set_Toggle (Green_LED);
-- Counter := 0;
-- end if;
-- Counter := Counter + 1;
end if;
end if;
end PWM_ISR_Handler;
end PWM_Handler;
end Inverter_PWM;
|
package body ACO.Utils.Generic_Pubsub is
function Nof_Subscribers
(This : in out Pub)
return Natural
is
S : ACO.Utils.Scope_Locks.Scope_Lock (This.Mutex'Access);
pragma Unreferenced (S);
begin
return This.Subscribers.Length;
end Nof_Subscribers;
function Get_Subscribers
(This : in out Pub)
return Sub_Array
is
S : ACO.Utils.Scope_Locks.Scope_Lock (This.Mutex'Access);
pragma Unreferenced (S);
begin
declare
L : constant Natural := This.Subscribers.Length;
Subscribers : Sub_Array (1 .. L);
begin
for I in Subscribers'Range loop
Subscribers (I) := This.Subscribers.Item_At (I);
end loop;
return Subscribers;
end;
end Get_Subscribers;
procedure Update
(This : in out Pub;
Data : in Item_Type)
is
Subscribers : constant Sub_Array := This.Get_Subscribers;
begin
-- Subscriber notification must be unprotected (no seized mutex)
-- otherwise a call to e.g. Detach by the subscriber would cause deadlock
for Subscriber of Subscribers loop
Subscriber.Update (Data);
end loop;
end Update;
procedure Attach
(This : in out Pub;
Subscriber : in Sub_Access)
is
S : ACO.Utils.Scope_Locks.Scope_Lock (This.Mutex'Access);
pragma Unreferenced (S);
begin
This.Subscribers.Append (Subscriber);
end Attach;
procedure Detach
(This : in out Pub;
Subscriber : in Sub_Access)
is
S : ACO.Utils.Scope_Locks.Scope_Lock (This.Mutex'Access);
pragma Unreferenced (S);
I : Positive;
begin
I := This.Subscribers.Location (Subscriber);
This.Subscribers.Remove (I);
end Detach;
end ACO.Utils.Generic_Pubsub;
|
generic
type Float_type is digits <>;
slot_Count : standard.Positive;
package cached_Trigonometry
--
-- Caches trig functions for speed at the cost of precision.
--
is
pragma Optimize (Time);
function Cos (Angle : in Float_type) return Float_type;
function Sin (Angle : in Float_type) return Float_type;
procedure get (Angle : in Float_type; the_Cos : out Float_type;
the_Sin : out Float_type);
-- TODO: tan, arccos, etc
private
pragma Inline_Always (Cos);
pragma Inline_Always (Sin);
pragma Inline_Always (Get);
end cached_Trigonometry;
|
-- { dg-do link }
-- { dg-options "-gnat12" }
with Constant4_Pkg; use Constant4_Pkg;
procedure Constant4 is
Sum : Counter := 0;
begin
for Count of Steals loop
Sum := Sum + Count;
end loop;
end;
|
------------------------------------------------------------------------------
-- --
-- Matreshka Project --
-- --
-- Ada Modeling Framework --
-- --
-- Runtime Library Component --
-- --
------------------------------------------------------------------------------
-- --
-- Copyright © 2012, 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$
------------------------------------------------------------------------------
-- This file is generated, don't edit it.
------------------------------------------------------------------------------
with AMF.DG.Holders.Close_Paths;
with AMF.DG.Holders.Cubic_Curve_Tos;
with AMF.DG.Holders.Elliptical_Arc_Tos;
with AMF.DG.Holders.Gradient_Stops;
with AMF.DG.Holders.Line_Tos;
with AMF.DG.Holders.Matrixs;
with AMF.DG.Holders.Move_Tos;
with AMF.DG.Holders.Path_Commands;
with AMF.DG.Holders.Quadratic_Curve_Tos;
with AMF.DG.Holders.Rotates;
with AMF.DG.Holders.Scales;
with AMF.DG.Holders.Skews;
with AMF.DG.Holders.Transforms;
with AMF.DG.Holders.Translates;
package body AMF.DG.Holders is
-------------
-- Element --
-------------
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Close_Path is
begin
if not League.Holders.Has_Tag
(Holder, AMF.DG.Holders.Close_Paths.Value_Tag)
then
raise Constraint_Error;
end if;
if League.Holders.Is_Empty (Holder) then
return (Is_Empty => True);
else
return (False, AMF.DG.Holders.Close_Paths.Element (Holder));
end if;
end Element;
-------------
-- Element --
-------------
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Cubic_Curve_To is
begin
if not League.Holders.Has_Tag
(Holder, AMF.DG.Holders.Cubic_Curve_Tos.Value_Tag)
then
raise Constraint_Error;
end if;
if League.Holders.Is_Empty (Holder) then
return (Is_Empty => True);
else
return (False, AMF.DG.Holders.Cubic_Curve_Tos.Element (Holder));
end if;
end Element;
-------------
-- Element --
-------------
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Elliptical_Arc_To is
begin
if not League.Holders.Has_Tag
(Holder, AMF.DG.Holders.Elliptical_Arc_Tos.Value_Tag)
then
raise Constraint_Error;
end if;
if League.Holders.Is_Empty (Holder) then
return (Is_Empty => True);
else
return (False, AMF.DG.Holders.Elliptical_Arc_Tos.Element (Holder));
end if;
end Element;
-------------
-- Element --
-------------
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Gradient_Stop is
begin
if not League.Holders.Has_Tag
(Holder, AMF.DG.Holders.Gradient_Stops.Value_Tag)
then
raise Constraint_Error;
end if;
if League.Holders.Is_Empty (Holder) then
return (Is_Empty => True);
else
return (False, AMF.DG.Holders.Gradient_Stops.Element (Holder));
end if;
end Element;
-------------
-- Element --
-------------
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Line_To is
begin
if not League.Holders.Has_Tag
(Holder, AMF.DG.Holders.Line_Tos.Value_Tag)
then
raise Constraint_Error;
end if;
if League.Holders.Is_Empty (Holder) then
return (Is_Empty => True);
else
return (False, AMF.DG.Holders.Line_Tos.Element (Holder));
end if;
end Element;
-------------
-- Element --
-------------
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Matrix is
begin
if not League.Holders.Has_Tag
(Holder, AMF.DG.Holders.Matrixs.Value_Tag)
then
raise Constraint_Error;
end if;
if League.Holders.Is_Empty (Holder) then
return (Is_Empty => True);
else
return (False, AMF.DG.Holders.Matrixs.Element (Holder));
end if;
end Element;
-------------
-- Element --
-------------
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Move_To is
begin
if not League.Holders.Has_Tag
(Holder, AMF.DG.Holders.Move_Tos.Value_Tag)
then
raise Constraint_Error;
end if;
if League.Holders.Is_Empty (Holder) then
return (Is_Empty => True);
else
return (False, AMF.DG.Holders.Move_Tos.Element (Holder));
end if;
end Element;
-------------
-- Element --
-------------
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Path_Command is
begin
if not League.Holders.Has_Tag
(Holder, AMF.DG.Holders.Path_Commands.Value_Tag)
then
raise Constraint_Error;
end if;
if League.Holders.Is_Empty (Holder) then
return (Is_Empty => True);
else
return (False, AMF.DG.Holders.Path_Commands.Element (Holder));
end if;
end Element;
-------------
-- Element --
-------------
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Quadratic_Curve_To is
begin
if not League.Holders.Has_Tag
(Holder, AMF.DG.Holders.Quadratic_Curve_Tos.Value_Tag)
then
raise Constraint_Error;
end if;
if League.Holders.Is_Empty (Holder) then
return (Is_Empty => True);
else
return (False, AMF.DG.Holders.Quadratic_Curve_Tos.Element (Holder));
end if;
end Element;
-------------
-- Element --
-------------
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Rotate is
begin
if not League.Holders.Has_Tag
(Holder, AMF.DG.Holders.Rotates.Value_Tag)
then
raise Constraint_Error;
end if;
if League.Holders.Is_Empty (Holder) then
return (Is_Empty => True);
else
return (False, AMF.DG.Holders.Rotates.Element (Holder));
end if;
end Element;
-------------
-- Element --
-------------
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Scale is
begin
if not League.Holders.Has_Tag
(Holder, AMF.DG.Holders.Scales.Value_Tag)
then
raise Constraint_Error;
end if;
if League.Holders.Is_Empty (Holder) then
return (Is_Empty => True);
else
return (False, AMF.DG.Holders.Scales.Element (Holder));
end if;
end Element;
-------------
-- Element --
-------------
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Skew is
begin
if not League.Holders.Has_Tag
(Holder, AMF.DG.Holders.Skews.Value_Tag)
then
raise Constraint_Error;
end if;
if League.Holders.Is_Empty (Holder) then
return (Is_Empty => True);
else
return (False, AMF.DG.Holders.Skews.Element (Holder));
end if;
end Element;
-------------
-- Element --
-------------
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Transform is
begin
if not League.Holders.Has_Tag
(Holder, AMF.DG.Holders.Transforms.Value_Tag)
then
raise Constraint_Error;
end if;
if League.Holders.Is_Empty (Holder) then
return (Is_Empty => True);
else
return (False, AMF.DG.Holders.Transforms.Element (Holder));
end if;
end Element;
-------------
-- Element --
-------------
function Element
(Holder : League.Holders.Holder)
return AMF.DG.Optional_DG_Translate is
begin
if not League.Holders.Has_Tag
(Holder, AMF.DG.Holders.Translates.Value_Tag)
then
raise Constraint_Error;
end if;
if League.Holders.Is_Empty (Holder) then
return (Is_Empty => True);
else
return (False, AMF.DG.Holders.Translates.Element (Holder));
end if;
end Element;
---------------
-- To_Holder --
---------------
function To_Holder
(Element : AMF.DG.Optional_DG_Close_Path)
return League.Holders.Holder is
begin
return Result : League.Holders.Holder do
League.Holders.Set_Tag
(Result, AMF.DG.Holders.Close_Paths.Value_Tag);
if not Element.Is_Empty then
AMF.DG.Holders.Close_Paths.Replace_Element
(Result, Element.Value);
end if;
end return;
end To_Holder;
---------------
-- To_Holder --
---------------
function To_Holder
(Element : AMF.DG.Optional_DG_Cubic_Curve_To)
return League.Holders.Holder is
begin
return Result : League.Holders.Holder do
League.Holders.Set_Tag
(Result, AMF.DG.Holders.Cubic_Curve_Tos.Value_Tag);
if not Element.Is_Empty then
AMF.DG.Holders.Cubic_Curve_Tos.Replace_Element
(Result, Element.Value);
end if;
end return;
end To_Holder;
---------------
-- To_Holder --
---------------
function To_Holder
(Element : AMF.DG.Optional_DG_Elliptical_Arc_To)
return League.Holders.Holder is
begin
return Result : League.Holders.Holder do
League.Holders.Set_Tag
(Result, AMF.DG.Holders.Elliptical_Arc_Tos.Value_Tag);
if not Element.Is_Empty then
AMF.DG.Holders.Elliptical_Arc_Tos.Replace_Element
(Result, Element.Value);
end if;
end return;
end To_Holder;
---------------
-- To_Holder --
---------------
function To_Holder
(Element : AMF.DG.Optional_DG_Gradient_Stop)
return League.Holders.Holder is
begin
return Result : League.Holders.Holder do
League.Holders.Set_Tag
(Result, AMF.DG.Holders.Gradient_Stops.Value_Tag);
if not Element.Is_Empty then
AMF.DG.Holders.Gradient_Stops.Replace_Element
(Result, Element.Value);
end if;
end return;
end To_Holder;
---------------
-- To_Holder --
---------------
function To_Holder
(Element : AMF.DG.Optional_DG_Line_To)
return League.Holders.Holder is
begin
return Result : League.Holders.Holder do
League.Holders.Set_Tag
(Result, AMF.DG.Holders.Line_Tos.Value_Tag);
if not Element.Is_Empty then
AMF.DG.Holders.Line_Tos.Replace_Element
(Result, Element.Value);
end if;
end return;
end To_Holder;
---------------
-- To_Holder --
---------------
function To_Holder
(Element : AMF.DG.Optional_DG_Matrix)
return League.Holders.Holder is
begin
return Result : League.Holders.Holder do
League.Holders.Set_Tag
(Result, AMF.DG.Holders.Matrixs.Value_Tag);
if not Element.Is_Empty then
AMF.DG.Holders.Matrixs.Replace_Element
(Result, Element.Value);
end if;
end return;
end To_Holder;
---------------
-- To_Holder --
---------------
function To_Holder
(Element : AMF.DG.Optional_DG_Move_To)
return League.Holders.Holder is
begin
return Result : League.Holders.Holder do
League.Holders.Set_Tag
(Result, AMF.DG.Holders.Move_Tos.Value_Tag);
if not Element.Is_Empty then
AMF.DG.Holders.Move_Tos.Replace_Element
(Result, Element.Value);
end if;
end return;
end To_Holder;
---------------
-- To_Holder --
---------------
function To_Holder
(Element : AMF.DG.Optional_DG_Path_Command)
return League.Holders.Holder is
begin
return Result : League.Holders.Holder do
League.Holders.Set_Tag
(Result, AMF.DG.Holders.Path_Commands.Value_Tag);
if not Element.Is_Empty then
AMF.DG.Holders.Path_Commands.Replace_Element
(Result, Element.Value);
end if;
end return;
end To_Holder;
---------------
-- To_Holder --
---------------
function To_Holder
(Element : AMF.DG.Optional_DG_Quadratic_Curve_To)
return League.Holders.Holder is
begin
return Result : League.Holders.Holder do
League.Holders.Set_Tag
(Result, AMF.DG.Holders.Quadratic_Curve_Tos.Value_Tag);
if not Element.Is_Empty then
AMF.DG.Holders.Quadratic_Curve_Tos.Replace_Element
(Result, Element.Value);
end if;
end return;
end To_Holder;
---------------
-- To_Holder --
---------------
function To_Holder
(Element : AMF.DG.Optional_DG_Rotate)
return League.Holders.Holder is
begin
return Result : League.Holders.Holder do
League.Holders.Set_Tag
(Result, AMF.DG.Holders.Rotates.Value_Tag);
if not Element.Is_Empty then
AMF.DG.Holders.Rotates.Replace_Element
(Result, Element.Value);
end if;
end return;
end To_Holder;
---------------
-- To_Holder --
---------------
function To_Holder
(Element : AMF.DG.Optional_DG_Scale)
return League.Holders.Holder is
begin
return Result : League.Holders.Holder do
League.Holders.Set_Tag
(Result, AMF.DG.Holders.Scales.Value_Tag);
if not Element.Is_Empty then
AMF.DG.Holders.Scales.Replace_Element
(Result, Element.Value);
end if;
end return;
end To_Holder;
---------------
-- To_Holder --
---------------
function To_Holder
(Element : AMF.DG.Optional_DG_Skew)
return League.Holders.Holder is
begin
return Result : League.Holders.Holder do
League.Holders.Set_Tag
(Result, AMF.DG.Holders.Skews.Value_Tag);
if not Element.Is_Empty then
AMF.DG.Holders.Skews.Replace_Element
(Result, Element.Value);
end if;
end return;
end To_Holder;
---------------
-- To_Holder --
---------------
function To_Holder
(Element : AMF.DG.Optional_DG_Transform)
return League.Holders.Holder is
begin
return Result : League.Holders.Holder do
League.Holders.Set_Tag
(Result, AMF.DG.Holders.Transforms.Value_Tag);
if not Element.Is_Empty then
AMF.DG.Holders.Transforms.Replace_Element
(Result, Element.Value);
end if;
end return;
end To_Holder;
---------------
-- To_Holder --
---------------
function To_Holder
(Element : AMF.DG.Optional_DG_Translate)
return League.Holders.Holder is
begin
return Result : League.Holders.Holder do
League.Holders.Set_Tag
(Result, AMF.DG.Holders.Translates.Value_Tag);
if not Element.Is_Empty then
AMF.DG.Holders.Translates.Replace_Element
(Result, Element.Value);
end if;
end return;
end To_Holder;
end AMF.DG.Holders;
|
-- C43106A.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 BOTH NAMED AND POSITIONAL NOTATIONS ARE PERMITTED
-- WITHIN THE SAME RECORD AGGREGATE, (PROVIDED THAT ALL POSITIONAL
-- ASSOCIATIONS APPEAR BEFORE ANY NAMED ASSOCIATION).
-- HISTORY:
-- DHH 08/10/88 CREATED ORIGIANL TEST.
WITH REPORT; USE REPORT;
PROCEDURE C43106A IS
TYPE REC IS
RECORD
A : INTEGER;
B : CHARACTER;
C : BOOLEAN;
D, E, F, G : INTEGER;
H, I, J, K : CHARACTER;
L, M, N, O : BOOLEAN;
P, Q, R, S : STRING(1 .. 3);
T, U, V, W, X, Y, Z : BOOLEAN;
END RECORD;
AGG : REC := (12, 'A', TRUE, 1, 2, 3, 4, 'B', 'C', 'D', 'E',
P|R => "ABC", S|Q => "DEF", L|X|O|U => TRUE,
OTHERS => FALSE);
FUNCTION IDENT_CHAR(X : CHARACTER) RETURN CHARACTER IS
BEGIN
IF EQUAL(3, 3) THEN
RETURN X;
ELSE
RETURN 'Z';
END IF;
END IDENT_CHAR;
BEGIN
TEST("C43106A", "CHECK THAT BOTH NAMED AND POSITIONAL NOTATIONS " &
"ARE PERMITTED WITHIN THE SAME RECORD " &
"AGGREGATE, (PROVIDED THAT ALL POSITIONAL " &
"ASSOCIATIONS APPEAR BEFORE ANY NAMED " &
"ASSOCIATION)");
IF NOT IDENT_BOOL(AGG.C) OR NOT IDENT_BOOL(AGG.L) OR
NOT IDENT_BOOL(AGG.X) OR NOT IDENT_BOOL(AGG.O) OR
NOT IDENT_BOOL(AGG.U) OR IDENT_BOOL(AGG.M) OR
IDENT_BOOL(AGG.N) OR IDENT_BOOL(AGG.T) OR
IDENT_BOOL(AGG.V) OR IDENT_BOOL(AGG.W) OR
IDENT_BOOL(AGG.Y) OR IDENT_BOOL(AGG.Z) THEN
FAILED("BOOLEANS NOT INITIALIZED TO AGGREGATE VALUES");
END IF;
IF IDENT_STR(AGG.P) /= IDENT_STR(AGG.R) OR
IDENT_STR(AGG.Q) /= IDENT_STR(AGG.S) THEN
FAILED("STRINGS NOT INITIALIZED CORRECTLY");
END IF;
IF IDENT_CHAR(AGG.B) /= IDENT_CHAR('A') OR
IDENT_CHAR(AGG.H) /= IDENT_CHAR('B') OR
IDENT_CHAR(AGG.I) /= IDENT_CHAR('C') OR
IDENT_CHAR(AGG.J) /= IDENT_CHAR('D') OR
IDENT_CHAR(AGG.K) /= IDENT_CHAR('E') THEN
FAILED("CHARACTERS NOT INITIALIZED CORRECTLY");
END IF;
RESULT;
END C43106A;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- C O M P E R R --
-- --
-- S p e c --
-- --
-- $Revision$
-- --
-- Copyright (C) 1992-2002 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. --
-- --
------------------------------------------------------------------------------
-- This package contains the routine called when a fatal internal compiler
-- error is detected. Calls to this routines cause termination of the
-- current compilation with appropriate error output.
package Comperr is
procedure Compiler_Abort
(X : String;
Code : Integer := 0);
-- Signals an internal compiler error. Never returns control. Depending
-- on processing may end up raising Unrecoverable_Error, or exiting
-- directly. The message output is a "bug box" containing the
-- string passed as an argument. The node in Current_Error_Node is used
-- to provide the location where the error should be signalled. The
-- message includes the node id, and the code parameter if it is positive.
-- Note that this is only used at the outer level (to handle constraint
-- errors or assert errors etc.) In the normal logic of the compiler we
-- always use pragma Assert to check for errors, and if necessary an
-- explicit abort is achieved by pragma Assert (False). Code is positive
-- for a gigi abort (giving the gigi abort code), zero for a front
-- end exception (with possible message stored in TSD.Current_Excep,
-- and negative (an unused value) for a GCC abort.
------------------------------
-- Use of gnat_bug.box File --
------------------------------
-- When comperr generates the "bug box". The first two lines contain
-- information on the version number, type of abort, and source location.
-- Normally the remaining text is of the following form:
-- Please submit bug a report, see http://gcc.gnu.org/bugs.html.
-- Include the entire contents of this bug box in the report.
-- Include the exact gcc or gnatmake command that you entered.
-- Also include sources listed below in gnatchop format
-- concatenated together with no headers between files.
-- However, an alternative mechanism exists for easily substituting
-- different text for this message. Compiler_Abort checks for the
-- existence of the file "gnat_bug.box" in the current source path.
-- Most typically this file, if present, will be in the directory
-- containing the run-time sources.
-- If this file is present, then it is a plain ASCII file, whose
-- contents replace the above quoted paragraphs. The lines in this
-- file should be 72 characters or less to avoid misformatting the
-- right boundary of the box. Note that the file does not contain
-- the vertical bar characters or any leading spaces in lines.
end Comperr;
|
package body vole_lex_io is
-- gets input and stuffs it into 'buf'. number of characters read, or YY_NULL,
-- is returned in 'result'.
procedure YY_INPUT(buf: out unbounded_character_array; result: out integer; max_size: in integer) is
c : character;
i : integer := 1;
loc : integer := buf'first;
begin
if (is_open(user_input_file)) then
while ( i <= max_size ) loop
if (end_of_line(user_input_file)) then -- Ada ate our newline, put it back on the end.
buf(loc) := ASCII.LF;
skip_line(user_input_file, 1);
else
-- UCI CODES CHANGED:
-- The following codes are modified. Previous codes is commented out.
-- The purpose of doing this is to make it possible to set Temp_Line
-- in Ayacc-extension specific codes. Definitely, we can read the character
-- into the Temp_Line and then set the buf. But Temp_Line will only
-- be used in Ayacc-extension specific codes which makes this approach impossible.
get(user_input_file, c);
buf(loc) := c;
-- get(user_input_file, buf(loc));
end if;
loc := loc + 1;
i := i + 1;
end loop;
else
while ( i <= max_size ) loop
if (end_of_line) then -- Ada ate our newline, put it back on the end.
buf(loc) := ASCII.LF;
skip_line(1);
else
-- The following codes are modified. Previous codes is commented out.
-- The purpose of doing this is to make it possible to set Temp_Line
-- in Ayacc-extension specific codes. Definitely, we can read the character
-- into the Temp_Line and then set the buf. But Temp_Line will only
-- be used in Ayacc-extension specific codes which makes this approach impossible.
get(c);
buf(loc) := c;
-- get(buf(loc));
end if;
loc := loc + 1;
i := i + 1;
end loop;
end if; -- for input file being standard input
result := i - 1;
exception
when END_ERROR => result := i - 1;
-- when we hit EOF we need to set yy_eof_has_been_seen
yy_eof_has_been_seen := true;
end YY_INPUT;
-- yy_get_next_buffer - try to read in new buffer
--
-- returns a code representing an action
-- EOB_ACT_LAST_MATCH -
-- EOB_ACT_RESTART_SCAN - restart the scanner
-- EOB_ACT_END_OF_FILE - end of file
function yy_get_next_buffer return eob_action_type is
dest : integer := 0;
source : integer := yytext_ptr - 1; -- copy prev. char, too
number_to_move : integer;
ret_val : eob_action_type;
num_to_read : integer;
begin
if ( yy_c_buf_p > yy_n_chars + 1 ) then
raise NULL_IN_INPUT;
end if;
-- try to read more data
-- first move last chars to start of buffer
number_to_move := yy_c_buf_p - yytext_ptr;
for i in 0..number_to_move - 1 loop
yy_ch_buf(dest) := yy_ch_buf(source);
dest := dest + 1;
source := source + 1;
end loop;
if ( yy_eof_has_been_seen ) then
-- don't do the read, it's not guaranteed to return an EOF,
-- just force an EOF
yy_n_chars := 0;
else
num_to_read := YY_BUF_SIZE - number_to_move - 1;
if ( num_to_read > YY_READ_BUF_SIZE ) then
num_to_read := YY_READ_BUF_SIZE;
end if;
-- read in more data
YY_INPUT( yy_ch_buf(number_to_move..yy_ch_buf'last), yy_n_chars, num_to_read );
end if;
if ( yy_n_chars = 0 ) then
if ( number_to_move = 1 ) then
ret_val := EOB_ACT_END_OF_FILE;
else
ret_val := EOB_ACT_LAST_MATCH;
end if;
yy_eof_has_been_seen := true;
else
ret_val := EOB_ACT_RESTART_SCAN;
end if;
yy_n_chars := yy_n_chars + number_to_move;
yy_ch_buf(yy_n_chars) := YY_END_OF_BUFFER_CHAR;
yy_ch_buf(yy_n_chars + 1) := YY_END_OF_BUFFER_CHAR;
-- yytext begins at the second character in
-- yy_ch_buf; the first character is the one which
-- preceded it before reading in the latest buffer;
-- it needs to be kept around in case it's a
-- newline, so yy_get_previous_state() will have
-- with '^' rules active
yytext_ptr := 1;
return ret_val;
end yy_get_next_buffer;
procedure yyunput( c : character; yy_bp: in out integer ) is
number_to_move : integer;
dest : integer;
source : integer;
tmp_yy_cp : integer;
begin
tmp_yy_cp := yy_c_buf_p;
yy_ch_buf(tmp_yy_cp) := yy_hold_char; -- undo effects of setting up yytext
if ( tmp_yy_cp < 2 ) then
-- need to shift things up to make room
number_to_move := yy_n_chars + 2; -- +2 for EOB chars
dest := YY_BUF_SIZE + 2;
source := number_to_move;
while ( source > 0 ) loop
dest := dest - 1;
source := source - 1;
yy_ch_buf(dest) := yy_ch_buf(source);
end loop;
tmp_yy_cp := tmp_yy_cp + dest - source;
yy_bp := yy_bp + dest - source;
yy_n_chars := YY_BUF_SIZE;
if ( tmp_yy_cp < 2 ) then
raise PUSHBACK_OVERFLOW;
end if;
end if;
if ( tmp_yy_cp > yy_bp and then yy_ch_buf(tmp_yy_cp-1) = ASCII.LF ) then
yy_ch_buf(tmp_yy_cp-2) := ASCII.LF;
end if;
tmp_yy_cp := tmp_yy_cp - 1;
yy_ch_buf(tmp_yy_cp) := c;
-- Note: this code is the text of YY_DO_BEFORE_ACTION, only
-- here we get different yy_cp and yy_bp's
yytext_ptr := yy_bp;
yy_hold_char := yy_ch_buf(tmp_yy_cp);
yy_ch_buf(tmp_yy_cp) := ASCII.NUL;
yy_c_buf_p := tmp_yy_cp;
end yyunput;
procedure unput(c : character) is
begin
yyunput( c, yy_bp );
end unput;
function input return character is
c : character;
yy_cp : integer := yy_c_buf_p;
begin
yy_ch_buf(yy_cp) := yy_hold_char;
if ( yy_ch_buf(yy_c_buf_p) = YY_END_OF_BUFFER_CHAR ) then
-- need more input
yytext_ptr := yy_c_buf_p;
yy_c_buf_p := yy_c_buf_p + 1;
case yy_get_next_buffer is
-- this code, unfortunately, is somewhat redundant with
-- that above
when EOB_ACT_END_OF_FILE =>
if ( yywrap ) then
yy_c_buf_p := yytext_ptr;
return ASCII.NUL;
end if;
yy_ch_buf(0) := ASCII.LF;
yy_n_chars := 1;
yy_ch_buf(yy_n_chars) := YY_END_OF_BUFFER_CHAR;
yy_ch_buf(yy_n_chars + 1) := YY_END_OF_BUFFER_CHAR;
yy_eof_has_been_seen := false;
yy_c_buf_p := 1;
yytext_ptr := yy_c_buf_p;
yy_hold_char := yy_ch_buf(yy_c_buf_p);
return ( input );
when EOB_ACT_RESTART_SCAN =>
yy_c_buf_p := yytext_ptr;
when EOB_ACT_LAST_MATCH =>
raise UNEXPECTED_LAST_MATCH;
when others => null;
end case;
end if;
c := yy_ch_buf(yy_c_buf_p);
yy_c_buf_p := yy_c_buf_p + 1;
yy_hold_char := yy_ch_buf(yy_c_buf_p);
return c;
end input;
procedure output(c : character) is
begin
if (is_open(user_output_file)) then
text_io.put(user_output_file, c);
else
text_io.put(c);
end if;
end output;
-- default yywrap function - always treat EOF as an EOF
function yywrap return boolean is
begin
return true;
end yywrap;
procedure Open_Input(fname : in String) is
begin
yy_init := true;
open(user_input_file, in_file, fname);
end Open_Input;
procedure Create_Output(fname : in String := "") is
begin
if (fname /= "") then
create(user_output_file, out_file, fname);
end if;
end Create_Output;
procedure Close_Input is
begin
if (is_open(user_input_file)) then
text_io.close(user_input_file);
end if;
end Close_Input;
procedure Close_Output is
begin
if (is_open(user_output_file)) then
text_io.close(user_output_file);
end if;
end Close_Output;
end vole_lex_io;
|
procedure Step_Up is
begin
while not Step loop
Step_Up;
end loop;
end Step_Up;
|
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Characters.Conversions; use Ada.Characters.Conversions;
with Langkit_Support.Text;
package body Offmt_Lib.Detection is
--------------------------
-- Check_Defmt_Log_Call --
--------------------------
function Check_Defmt_Log_Call (Node : LAL.Call_Stmt'Class;
Call : out LAL.Call_Expr)
return Boolean
is
begin
Put_Line ("Node.Image: " & Node.Image);
Put_Line ("Node.Children_Count: " & Node.Children_Count'Img);
if Node.Children_Count /= 1 then
return False;
end if;
Call := Node.Child (1).As_Call_Expr;
declare
S : constant LAL.Ada_Node := Call.F_Suffix;
Designated_Type : constant LAL.Base_Type_Decl :=
Call.F_Name.P_Name_Designated_Type;
begin
if not Designated_Type.Is_Null
or else not Call.P_Is_Direct_Call
or else S.Is_Null
or else S.Children_Count /= 1
then
return False;
end if;
declare
use Langkit_Support.Text;
Spec : constant LAL.Subp_Spec :=
Call.P_Called_Subp_Spec.As_Subp_Spec;
Decl : constant LAL.Basic_Decl := Spec.P_Parent_Basic_Decl;
Txt : constant Text_Type := Decl.P_Fully_Qualified_Name;
Str : constant String := Image (Txt);
begin
Put_Line ("Fully qualified name: '" & Str & "'");
return Str = To_String (Offmt_Lib.Log_Root_Pkg) & ".Log";
end;
end;
end Check_Defmt_Log_Call;
end Offmt_Lib.Detection;
|
with Ada.Text_Io; use Ada.Text_Io;
procedure Exceptions_From_Nested_Calls is
U0 : exception;
U1 : exception;
Baz_Count : Natural := 0;
procedure Baz is
begin
Baz_Count := Baz_Count + 1;
if Baz_Count = 1 then
raise U0;
else
raise U1;
end if;
end Baz;
procedure Bar is
begin
Baz;
end Bar;
procedure Foo is
begin
Bar;
exception
when U0 =>
Put_Line("Procedure Foo caught exception U0");
end Foo;
begin
for I in 1..2 loop
Foo;
end loop;
end Exceptions_From_Nested_Calls;
|
-- { dg-do compile }
-- { dg-options "-O" }
package body Array29 is
procedure Copy (Src : in Matrix; Dst : out Matrix) is
begin
for I in Src'Range (1) loop
for J in Src'Range (2) loop
Dst (I, J) := Src (I, J);
end loop;
end loop;
end;
procedure Proc is
N : constant := 2;
FM1 : constant Matrix (1 .. N, 1 .. N) := ((1.0, 2.0), (3.0, 4.0));
FM2 : constant Matrix (1 .. N, 1 .. N) := ((1.0, 2.0), (3.0, 4.0));
A : constant array (1 .. 2) of Matrix (1 .. N, 1 .. N)
:= (Matrix (FM1), Matrix (FM2));
Final : Matrix (1 .. N, 1 .. N);
begin
Copy (Src => A (1), Dst => Final);
end;
end Array29;
|
package body gel.Dolly.simple
is
overriding
procedure define (Self : in out Item)
is
begin
null;
end define;
overriding
procedure destroy (Self : in out Item)
is
begin
null;
end destroy;
--------------
-- Operations
--
overriding
procedure freshen (Self : in out Item)
is
use Math,
linear_Algebra_3D;
Speed : constant Real := Self.Speed * Self.Multiplier;
rotate_Factor : constant Real := 0.04;
orbit_Factor : constant Real := 0.08;
initial_Site : constant Vector_3 := Self.Cameras.first_Element.Site;
initial_Spin : constant Matrix_3x3 := Self.Cameras.first_Element.world_Rotation;
new_Site : Vector_3;
new_Spin : Matrix_3x3;
site_Updated : Boolean := False;
spin_Updated : Boolean := False;
procedure update_Site (To : in Vector_3)
is
begin
new_Site := To;
site_Updated := True;
end update_Site;
procedure update_Spin (To : in math.Matrix_3x3)
is
begin
new_Spin := To;
spin_Updated := True;
end update_Spin;
begin
-- Linear Motion
--
if Self.Motion (Forward) then update_Site (initial_Site - forward_Direction (initial_Spin) * Speed); end if;
if Self.Motion (Backward) then update_Site (initial_Site + forward_Direction (initial_Spin) * Speed); end if;
if Self.Motion (Left) then update_Site (initial_Site - right_Direction (initial_Spin) * Speed); end if;
if Self.Motion (Right) then update_Site (initial_Site + right_Direction (initial_Spin) * Speed); end if;
if Self.Motion (Up) then update_Site (initial_Site + up_Direction (initial_Spin) * Speed); end if;
if Self.Motion (Down) then update_Site (initial_Site - up_Direction (initial_Spin) * Speed); end if;
-- Angular Spin
--
if Self.Spin (Left) then update_Spin (initial_Spin * y_Rotation_from (-rotate_Factor)); end if;
if Self.Spin (Right) then update_Spin (initial_Spin * y_Rotation_from ( rotate_Factor)); end if;
if Self.Spin (Forward) then update_Spin (initial_Spin * x_Rotation_from ( rotate_Factor)); end if;
if Self.Spin (Backward) then update_Spin (initial_Spin * x_Rotation_from (-rotate_Factor)); end if;
if Self.Spin (Up) then update_Spin (initial_Spin * z_Rotation_from (-rotate_Factor)); end if;
if Self.Spin (Down) then update_Spin (initial_Spin * z_Rotation_from ( rotate_Factor)); end if;
-- Orbit
--
if Self.Orbit (Left)
then
update_Site (initial_Site * y_Rotation_from (orbit_Factor * Speed));
update_Spin (initial_Spin * y_Rotation_from (orbit_Factor * Speed));
end if;
if Self.Orbit (Right)
then
update_Site (initial_Site * y_Rotation_from (-orbit_Factor * Speed));
update_Spin (initial_Spin * y_Rotation_from (-orbit_Factor * Speed));
end if;
if Self.Orbit (Forward)
then
update_Site (initial_Site * x_Rotation_from (-orbit_Factor * Speed));
update_Spin (initial_Spin * x_Rotation_from (-orbit_Factor * Speed));
end if;
if Self.Orbit (Backward)
then
update_Site (initial_Site * x_Rotation_from (orbit_Factor * Speed));
update_Spin (initial_Spin * x_Rotation_from (orbit_Factor * Speed));
end if;
if Self.Orbit (Up)
then
update_Site (initial_Site * z_Rotation_from (-orbit_Factor * Speed));
update_Spin (initial_Spin * z_Rotation_from (-orbit_Factor * Speed));
end if;
if Self.Orbit (Down)
then
update_Site (initial_Site * z_Rotation_from (orbit_Factor * Speed));
update_Spin (initial_Spin * z_Rotation_from (orbit_Factor * Speed));
end if;
-- Update each camera with new site and spin.
--
declare
use camera_Vectors;
the_Camera : gel.Camera.view;
Cursor : camera_Vectors.Cursor := Self.Cameras.First;
begin
while has_Element (Cursor)
loop
the_Camera := Element (Cursor);
if site_Updated
then
the_Camera.Site_is (new_Site);
end if;
if spin_Updated
then
the_Camera.world_Rotation_is (new_Spin);
end if;
next (Cursor);
end loop;
end;
end freshen;
end gel.Dolly.simple;
|
-- { dg-do compile }
-- { dg-options "-gnatI" }
package gnati is
type j is range 1 .. 50;
for j'size use 1;
type n is new integer;
for n'alignment use -99;
type e is (a, b);
for e use (1, 1);
type r is record x : integer; end record;
for r use record x at 0 range 0 .. 0; end record;
end gnati;
|
with
aIDE.Editor,
-- AdaM.Source,
AdaM.Entity,
Gtk.Widget,
Gtk.Button,
Gtk.Window;
private
with
Gtk.Frame;
package aIDE.Palette.of_source_entities
is
type Item is new Palette.item with private;
type View is access all Item'Class;
-- Forge
--
function to_source_entities_Palette return View;
-- Attributes
--
function top_Widget (Self : in Item) return gtk.Widget.Gtk_Widget;
-- Operations
--
type Filter is (declare_Region, begin_Region);
procedure show (Self : in out Item; Invoked_by : in aIDE.Editor.view;
-- Target : in AdaM.Source.Entities_view;
Target : in AdaM.Entity.Entities_view;
Allowed : in Filter);
procedure freshen (Self : in out Item);
private
use gtk.Window,
gtk.Frame,
gtk.Button;
type Item is new Palette.item with
record
Invoked_by : aIDE.Editor.view;
-- Target : AdaM.Source.Entities_View;
Target : AdaM.Entity.Entities_View;
Top : gtk_Window;
new_type_Frame : gtk_Frame;
raw_source_Button : Gtk_Button;
comment_Button : Gtk_Button;
enumeration_type_Button : Gtk_Button;
close_Button : gtk_Button;
end record;
end aIDE.Palette.of_source_entities;
|
--
-- Simple tests of Extended_Real. Search for catastrophic
-- errors or portability problems.
--
with Extended_Real;
with text_io; use text_io;
procedure e_real_tst_1 is
type Real is digits 15;
package Extend is new Extended_Real (Real);
use Extend;
package rio is new Text_IO.float_io(Real);
use rio;
package iio is new Text_IO.Integer_io(E_Integer);
use iio;
Radix : constant Real := E_Real_Machine_Radix;
Radix_Minus_1 : constant Real := Radix - 1.0;
Radix_Minus_1_Squ : constant Real := Radix_Minus_1 * Radix_Minus_1;
Z1, Z2, Z3, Z4 : E_Real;
-- Attempt to make Junk constants of order one with non-zero's all over.
Junk1 : constant E_Real := One / (+3.0);
Junk2 : constant E_Real := (+17.0) / (+19.0);
Test_Vector_Seed : Real;
--**********************************************************************
procedure Test_Rem (Test_Vector_Seed : Real) is
Dig, Digit : Real;
Min, DeltaExp : E_Integer;
Difference1 : E_Real;
Z1, Z2 : E_Real := Zero;
Z4 : E_Real;
begin
Min := E_Integer'Last;
Dig := 0.0;
new_line;
for I in 1..100 loop
Z1 := Z1 + Junk1;
Z2 := Z2 + (+Test_Vector_Seed) * Junk2;
-- try to reproduce Z1:
Z4 := Remainder (Z1, Z2) + Z2 * Unbiased_Rounding (Z1 / Z2);
-- Z4 should equal Z1.
Difference1 := (Z4 - Z1) / Z4;
--put (Make_Real (Remainder (Z1, Z2) / Z2)); new_line;
-- should always be in range [-0.5..0.5]
--put (Make_Real ((Z2*Unbiased_Rounding (Z1 / Z2)) / Z1)); New_Line;
IF Are_Not_Equal (Difference1, Zero) THEN
DeltaExp := Exponent(Difference1);
Digit := Make_Real (Fraction (Leading_Part (Difference1,1)));
IF Abs(DeltaExp) < Abs(Min) THEN
Min := DeltaExp;
Dig := Digit;
END IF;
END IF;
end loop;
IF Min = E_Integer'Last THEN
Dig := 0.0;
Min := -E_Integer'Last + 1;
END IF;
-- The above uses the normalized Exponent, which assumes a fractional 1st
-- Digit. Below we (effectively) multiply the first non-zero digit by Radix,
-- and subtract 1 from the "power of Radix" exponent.
put ("Approximate error =");
put (Dig*Radix); put (" * Radix**("); put (E_Integer'Image(Min-1)); put(")");
new_line;
end Test_Rem;
procedure Test_Digit_Mult_and_Div (Test_Vector_Seed : Real) is
Dig, Digit : Real;
Min, DeltaExp : E_Integer;
Difference1 : E_Real;
Real_Digit : Real := Radix + 1999.0;
Digit1 : E_Digit;
Z1, Z2 : E_Real := Zero;
begin
Min := E_Integer'Last;
Z1 := (+Test_Vector_Seed) * Junk1;
for I in 1..1000 loop
Real_Digit := Real_Digit - 2000.0;
Digit1 := Make_E_Digit (Real_Digit);
Z2 := Digit1 * (Z1 / Digit1);
Difference1 := (Z1 - Z2) / Z1;
IF Are_Not_Equal (Difference1, Zero) THEN
DeltaExp := Exponent(Difference1);
Digit := Make_Real (Fraction (Leading_Part (Difference1,1)));
IF Abs(DeltaExp) < Abs(Min) THEN
Min := DeltaExp;
Dig := Digit;
END IF;
END IF;
end loop;
IF Min = E_Integer'Last THEN
Dig := 0.0;
Min := -E_Integer'Last + 1;
END IF;
-- The above uses the normalized Exponent, which assumes a fractional 1st
-- Digit. Below we (effectively) multiply the first non-zero digit by Radix,
-- and subtract 1 from the "power of Radix" exponent.
put ("Approximate error =");
put (Dig*Radix); put (" * Radix**("); put (E_Integer'Image(Min-1)); put(")");
new_line;
end Test_Digit_Mult_and_Div;
-----------------------
-- Test_Mult_and_Add --
-----------------------
-- uses Newton's method to calculate 1/(X). Square and invert to
-- compare with X; square and multiply with with X to compare w. 1.0.
procedure Test_Mult_and_Add (Test_Vector_Seed : Real) is
Dig, Digit : Real;
Min, DeltaExp : E_Integer;
Difference1 : E_Real;
--
function Reciprocal (X : E_Real) return E_Real is
X_isqr : E_Real;
X_start : constant Real := 1.0 / Make_Real(X);
Iterations : constant Integer := 9;
begin
X_isqr := Make_Extended (X_Start);
for I in 1..Iterations loop
X_isqr := X_isqr + (One - X * X_isqr) * X_isqr;
end loop;
return X_isqr;
end Reciprocal;
begin
Min := E_Integer'Last;
Dig := 0.0;
Z1 := Zero;
for I in 1..20 loop
Z1 := Z1 + (+Test_Vector_Seed) * Junk1;
Z2 := Reciprocal (Z1);
Difference1 := One - Z1 * Z2;
IF Are_Not_Equal (Difference1, Zero) THEN
DeltaExp := Exponent(Difference1);
Digit := Make_Real (Fraction (Leading_Part (Difference1,1)));
IF Abs(DeltaExp) < Abs(Min) THEN
Min := DeltaExp;
Dig := Digit;
END IF;
END IF;
end loop;
IF Min = E_Integer'Last THEN
Dig := 0.0;
Min := -E_Integer'Last + 1;
END IF;
put ("Approximate error =");
put (Dig*Radix); put (" * Radix**("); put (E_Integer'Image(Min-1)); put(")");
new_line;
end Test_Mult_and_Add;
--**********************************************************************
procedure Test_Mult_And_Div (Test_Vector_Seed : Real) is
Dig, Digit : Real;
Min, DeltaExp : E_Integer;
Difference : E_Real;
begin
Min := E_Integer'Last;
Dig := 0.0;
for I in 1 .. 10_000 loop
Z1 := Z1 + Junk2 * (+Test_Vector_Seed);
Z2 := (Z1 * (One / Z1));
Difference := One - Z2;
DeltaExp := Exponent(Difference);
Digit := Make_Real (Fraction (Leading_Part (Difference,1)));
IF Abs(DeltaExp) < Abs(Min) THEN
Min := DeltaExp;
Dig := Digit;
END IF;
end loop;
put ("Approximate error =");
put (Dig*Radix); put (" * Radix**("); put (E_Integer'Image(Min-1)); put(")");
new_line;
end Test_Mult_And_Div;
--**********************************************************************
procedure Test_Make_Extended (Test_Vector_Seed : Real) is
Max : Real;
Difference : Real;
Junk1, Junk2 : Real;
begin
Junk1 := 0.0;
Max := 0.0;
for I in 1..1000 loop
Junk1 := Junk1 + Test_Vector_Seed;
Junk2 := Make_Real (Make_Extended (Junk1));
Difference := Junk2 - Junk1;
IF Abs(Difference) > Max THEN
Max := Difference;
END IF;
end loop;
put ("Max error in (X - Make_Real (Make_Extended(X))) = ");
put (Max);
new_line;
end Test_Make_Extended;
--**********************************************************************
begin
-- Simple test of "*" and "-":
Z1 := Make_Extended (Radix_Minus_1);
Z2 := Z1 * Z1;
Z3 := Z1 * Z2;
Z4 := Z2 - Make_Extended (Radix_Minus_1_Squ);
put(" Simple test of * and - : "); new_line;
put(Make_Real(Z1)); put(" This should be Radix - 1."); new_line;
put(Make_Real(Z2)); put(" This should be Radix - 1 squared."); new_line;
put(Make_Real(Z3)); put(" This should be Radix - 1 cubed."); new_line;
put(Make_Real(Z4)); put(" This should be near zero, but not quite."); new_line;
new_line;
new_line;
put(" Simple test of Remainder:");
new_line;
Test_Vector_Seed := 1.2345678912345678E+77;
Test_Rem (Test_Vector_Seed);
Test_Vector_Seed := 1.2345678912345678E+14;
Test_Rem (Test_Vector_Seed);
Test_Vector_Seed := 1.2345678912345678E+8;
Test_Rem (Test_Vector_Seed);
Test_Vector_Seed := 1.2345678912345678E-8;
Test_Rem (Test_Vector_Seed);
Test_Vector_Seed := 1.2345678912345678E-14;
Test_Rem (Test_Vector_Seed);
Test_Vector_Seed := 1.2345678912345678E-35;
Test_Rem (Test_Vector_Seed);
Test_Vector_Seed := 1.2345678912345678E-77;
Test_Rem (Test_Vector_Seed);
Test_Vector_Seed := 1.2345678912345678E-123;
Test_Rem (Test_Vector_Seed);
Test_Vector_Seed := 1.2345678912345678E-171;
Test_Rem (Test_Vector_Seed);
Test_Vector_Seed := 1.2345678912345678E-201;
Test_Rem (Test_Vector_Seed);
Test_Vector_Seed := 1.2345678912345678E-231;
Test_Rem (Test_Vector_Seed);
Test_Vector_Seed := 1.2345678912345678E-271;
Test_Rem (Test_Vector_Seed);
new_line;
put(" Simple test of mixed digit, extended operations:");
new_line;
Test_Vector_Seed := 1.2345678912345678E+8;
Test_Digit_Mult_and_Div (Test_Vector_Seed);
new_line;
put(" Simple test of + and *:");
new_line;
Test_Vector_Seed := 1.2345678912345678E+131;
Test_Mult_and_Add (Test_Vector_Seed);
Test_Vector_Seed := 1.2345678912345678E+81;
Test_Mult_and_Add (Test_Vector_Seed);
Test_Vector_Seed := 1.2345678912345678E+31;
Test_Mult_and_Add (Test_Vector_Seed);
Test_Vector_Seed := 1.2345678912345678E+8;
Test_Mult_and_Add (Test_Vector_Seed);
Test_Vector_Seed := 1.2345678912345678E-8;
Test_Mult_and_Add (Test_Vector_Seed);
Test_Vector_Seed := 1.2345678912345678E-31;
Test_Mult_and_Add (Test_Vector_Seed);
Test_Vector_Seed := 1.2345678912345678E-81;
Test_Mult_and_Add (Test_Vector_Seed);
Test_Vector_Seed := 1.2345678912345678E-131;
Test_Mult_and_Add (Test_Vector_Seed);
--**********************************************************************
new_line; put ("Maximum available number of Digits is: ");
put (e_Real_Machine_Mantissa); new_line;
new_line(2); put ("Some tests of +,*: "); new_line;
Test_Vector_Seed := 1.2345678912345678E-4;
for I in 1..10 loop
Test_Vector_Seed := Test_Vector_Seed + 1.2345678912345678E-4;
Test_Mult_and_Add (Test_Vector_Seed);
end loop;
Test_Vector_Seed := 1.2345678912345678E+4;
for I in 1..10 loop
Test_Vector_Seed := Test_Vector_Seed * 1.2345678912345678E+4;
Test_Mult_and_Add (Test_Vector_Seed);
end loop;
new_line(2); put ("Some tests of /,*: "); new_line;
Test_Vector_Seed := 1.2345678912345678E-4;
for I in 1..10 loop
Test_Vector_Seed := Test_Vector_Seed + 1.2345678912345678E-4;
Test_Mult_and_Div (Test_Vector_Seed);
end loop;
Test_Vector_Seed := 1.2345678912345678E+4;
for I in 1..10 loop
Test_Vector_Seed := Test_Vector_Seed * 1.2345678912345678E+4;
Test_Mult_and_Div (Test_Vector_Seed);
end loop;
new_line(2); put ("Some tests of Make_Extended: "); new_line;
Test_Vector_Seed := 1.2345678912345678E-4;
for I in 1..10 loop
Test_Vector_Seed := Test_Vector_Seed + 1.2345678912345678E-4;
Test_Make_Extended (Test_Vector_Seed);
end loop;
Test_Vector_Seed := 1.2345678912345678E+4;
for I in 1..10 loop
Test_Vector_Seed := Test_Vector_Seed * 1.2345678912345678E+4;
Test_Make_Extended (Test_Vector_Seed);
end loop;
--**********************************************************************
new_line;
put(" Simple test of /:");
new_line;
Test_Vector_Seed := 1.2345678912345678E+31;
Test_Mult_And_Div (Test_Vector_Seed);
Test_Vector_Seed := 1.2345678912345678E+8;
Test_Mult_And_Div (Test_Vector_Seed);
Test_Vector_Seed := 1.2345678912345678E-8;
Test_Mult_And_Div (Test_Vector_Seed);
Test_Vector_Seed := 1.2345678912345678E-31;
Test_Mult_And_Div (Test_Vector_Seed);
new_line;
put(" Simple test of Make_Extended:");
new_line;
Test_Vector_Seed := 1.234567891234567891E+31;
Test_Make_Extended (Test_Vector_Seed);
Test_Vector_Seed := 1.234567891234567891E+8;
Test_Make_Extended (Test_Vector_Seed);
Test_Vector_Seed := 1.234567891234567891E-8;
Test_Make_Extended (Test_Vector_Seed);
Test_Vector_Seed := 1.234567891234567891E-31;
Test_Make_Extended (Test_Vector_Seed);
--**********************************************************************
new_line;
put(" Simple test of exponentiation:"); new_line;
Z1 := (Make_Extended (7.2345)) ** (-277);
put (Make_Real(Z1)); put(" should be: "); put (7.2345**(-277)); new_line;
Z1 := (Make_Extended (7.2345)) ** 277;
put (Make_Real(Z1)); put(" should be: "); put (7.2345**277); new_line;
Z1 := (Make_Extended (1.2345)) ** 177;
put (Make_Real(Z1)); put(" should be: "); put (1.2345**177); new_line;
Z1 := (One + One + One) ** 97;
put (Make_Real(Z1)); put(" should be: "); put (3.0**97); new_line;
Z1 := (One + One) ** 67;
put (Make_Real(Z1)); put(" should be: "); put (2.0**67); new_line;
Z1 := (One + One) ** (-67);
put (Make_Real(Z1)); put(" should be: "); put (2.0**(-67)); new_line;
Z1 := (One + One) ** (0);
put (Make_Real(Z1)); put(" should be: "); put (2.0**(0)); new_line(1);
new_line;
put(" Quick test of Machine (rounds away smallest guard digit) and Model_Epsilon:");
new_line;
Z1 := (One + e_Real_Model_Epsilon) - One;
Z1 := Z1 / e_Real_Model_Epsilon;
put(" should be 1.0:"); put (Make_Real(Z1)); new_line;
Z1 := Machine (One + e_Real_Machine_Epsilon) - One;
put(" should be 0.0:"); put (Make_Real(Z1)); new_line;
Z2 := Make_Extended(0.99999999999999);
Z1 := Machine (Z2 + e_Real_Model_Epsilon) - Z2;
Z1 := Z1 / e_Real_Model_Epsilon;
put(" should be 1.0:"); put (Make_Real(Z1)); new_line;
end;
|
with HK_Data; use HK_Data;
with TTC_Data; use TTC_Data;
package TTC is
procedure Receive (Data : out Sensor_Reading);
function Next_TM return TM_Message;
end TTC;
|
with ACO.OD;
with ACO.States;
private with ACO.Events;
private with ACO.Log;
private with Interfaces;
package ACO.Protocols.Network_Management is
NMT_CAN_Id : constant ACO.Messages.Id_Type := 0;
type NMT
(Id : ACO.Messages.Node_Nr;
Od : not null access ACO.OD.Object_Dictionary'Class)
is abstract new Protocol with private;
overriding
function Is_Valid
(This : in out NMT;
Msg : in ACO.Messages.Message)
return Boolean;
procedure Message_Received
(This : in out NMT;
Msg : in ACO.Messages.Message)
with Pre => This.Is_Valid (Msg);
function Is_Allowed_Transition
(Current : ACO.States.State;
Next : ACO.States.State)
return Boolean;
procedure Set
(This : in out NMT;
State : in ACO.States.State)
with Pre => Is_Allowed_Transition (This.Od.Get_Node_State, State);
function Get
(This : NMT)
return ACO.States.State;
private
procedure NMT_Log
(This : in out NMT;
Level : in ACO.Log.Log_Level;
Message : in String);
package NMT_Commands is
type Cmd_Spec_Type is new Interfaces.Unsigned_8;
type NMT_Command (As_Raw : Boolean := False) is record
case As_Raw is
when True =>
Raw : ACO.Messages.Data_Array (0 .. 1);
when False =>
Command_Specifier : Cmd_Spec_Type;
Node_Id : ACO.Messages.Node_Nr;
end case;
end record
with Unchecked_Union, Size => 16;
for NMT_Command use record
Raw at 0 range 0 .. 15;
Command_Specifier at 0 range 0 .. 7;
Node_Id at 0 range 8 .. 15;
end record;
Start : constant := 1;
Stop : constant := 2;
Pre_Op : constant := 128;
Reset_Node : constant := 129;
Reset_Communication : constant := 130;
function Is_Valid_Cmd_Spec (Cmd : Cmd_Spec_Type) return Boolean is
(Cmd = Start or else
Cmd = Stop or else
Cmd = Pre_Op or else
Cmd = Reset_Node or else
Cmd = Reset_Communication);
To_CMD_Spec : constant array (ACO.States.State) of Cmd_Spec_Type :=
(ACO.States.Initializing | ACO.States.Unknown_State => Reset_Node,
ACO.States.Pre_Operational => Pre_Op,
ACO.States.Operational => Start,
ACO.States.Stopped => Stop);
function To_NMT_Command (Msg : ACO.Messages.Message) return NMT_Command is
((As_Raw => True,
Raw => Msg.Data (0 .. 1)));
function To_Msg (Cmd : NMT_Command) return ACO.Messages.Message is
(ACO.Messages.Create (CAN_Id => NMT_CAN_Id,
RTR => False,
Data => Cmd.Raw));
function Is_Valid_Command (Msg : ACO.Messages.Message) return Boolean is
((Msg.Length = NMT_Command'Size / 8) and then
Is_Valid_Cmd_Spec (To_NMT_Command (Msg).Command_Specifier));
end NMT_Commands;
type Node_State_Change_Subscriber
(Ref : not null access NMT)
is new ACO.Events.Event_Listener (ACO.Events.State_Transition)
with null record;
overriding
procedure On_Event
(This : in out Node_State_Change_Subscriber;
Data : in ACO.Events.Event_Data);
type NMT
(Id : ACO.Messages.Node_Nr;
Od : not null access ACO.OD.Object_Dictionary'Class)
is abstract new Protocol (Od) with record
State_Change : aliased Node_State_Change_Subscriber (NMT'Access);
end record;
overriding
procedure Initialize (This : in out NMT);
overriding
procedure Finalize (This : in out NMT);
procedure On_NMT_Command
(This : in out NMT;
Msg : in ACO.Messages.Message);
end ACO.Protocols.Network_Management;
|
------------------------------------------------------------------------------
-- --
-- GNAT RUN-TIME COMPONENTS --
-- --
-- S Y S T E M . M E M O R Y _ M O V E --
-- --
-- B o d y --
-- --
-- Copyright (C) 2006-2014, 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. --
-- --
-- --
-- --
-- --
-- --
-- You should have received a copy of the GNU General Public License and --
-- a copy of the GCC Runtime Library Exception along with this program; --
-- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
-- <http://www.gnu.org/licenses/>. --
-- --
-- GNAT was originally developed by the GNAT team at New York University. --
-- Extensive contributions were provided by Ada Core Technologies Inc. --
-- --
------------------------------------------------------------------------------
with Ada.Unchecked_Conversion;
with Interfaces.C; use Interfaces.C;
package body System.Memory_Move is
type IA is mod System.Memory_Size;
-- The type used to provide the actual desired operations
function To_IA is new Ada.Unchecked_Conversion (Address, IA);
-- The operations are implemented by unchecked conversion to type IA,
-- followed by doing the intrinsic operation on the IA values, followed
-- by converting the result back to type Address.
type Byte is mod 2 ** 8;
for Byte'Size use 8;
-- Byte is the storage unit
type Byte_Ptr is access Byte;
-- Access to a byte
function To_Byte_Ptr is new Ada.Unchecked_Conversion (IA, Byte_Ptr);
-- Conversion between an integer address and access to byte
Byte_Size : constant := 1;
-- Number of storage unit in a byte
type Word is mod 2 ** System.Word_Size;
for Word'Size use System.Word_Size;
-- Word is efficiently loaded and stored by the processor, but has
-- alignment constraints.
type Word_Ptr is access Word;
-- Access to a word.
function To_Word_Ptr is new Ada.Unchecked_Conversion (IA, Word_Ptr);
-- Conversion from an integer adddress to word access
Word_Size : constant := Word'Size / Storage_Unit;
-- Number of storage unit per word
-------------
-- memmove --
-------------
function memmove
(Dest : Address; Src : Address; N : size_t) return Address is
D : IA := To_IA (Dest);
S : IA := To_IA (Src);
C : IA := IA (N);
begin
-- Return immediately if no bytes to copy.
if N = 0 then
return Dest;
end if;
-- This function must handle overlapping memory regions
-- for the source and destination. If the Dest buffer is
-- located past the Src buffer then we use backward copying,
-- and forward copying otherwise.
if D > S and then D < S + C then
D := D + C;
S := S + C;
while C /= 0 loop
D := D - Byte_Size;
S := S - Byte_Size;
To_Byte_Ptr (D).all := To_Byte_Ptr (S).all;
C := C - Byte_Size;
end loop;
else
-- Try to copy per word, if alignment constraints are respected
if ((D or S) and (Word'Alignment - 1)) = 0 then
while C >= Word_Size loop
To_Word_Ptr (D).all := To_Word_Ptr (S).all;
D := D + Word_Size;
S := S + Word_Size;
C := C - Word_Size;
end loop;
end if;
-- Copy the remaining byte per byte
while C > 0 loop
To_Byte_Ptr (D).all := To_Byte_Ptr (S).all;
D := D + Byte_Size;
S := S + Byte_Size;
C := C - Byte_Size;
end loop;
end if;
return Dest;
end memmove;
end System.Memory_Move;
|
-----------------------------------------------------------------------
-- wiki -- Ada Wiki Engine
-- Copyright (C) 2015, 2016, 2020, 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.
-----------------------------------------------------------------------
-- = Wiki =
-- The Wiki engine parses a Wiki text in several Wiki syntax such as `MediaWiki`,
-- `Creole`, `Markdown`, `Dotclear` and renders the result either in HTML, text or into
-- another Wiki format. The Wiki engine is used in two steps:
--
-- * The Wiki text is parsed according to its syntax to produce a Wiki Document instance.
-- * The Wiki document is then rendered by a renderer to produce the final HTML, text.
--
-- Through this process, it is possible to insert filters and plugins to customize the
-- parsing and the rendering.
--
-- [images/ada-wiki.png]
--
-- The Ada Wiki engine is organized in several packages:
--
-- * The [Wiki Streams](#wiki-streams) packages define the interface, types and operations
-- for the Wiki engine to read the Wiki or HTML content and for the Wiki renderer to generate
-- the HTML or text outputs.
-- * The [Wiki parser](#wiki-parsers) is responsible for parsing HTML or Wiki content
-- according to a selected Wiki syntax. It builds the final Wiki document through filters
-- and plugins.
-- * The [Wiki Filters](#wiki-filters) provides a simple filter framework that allows to plug
-- specific filters when a Wiki document is parsed and processed. Filters are used for the
-- table of content generation, for the HTML filtering, to collect words or links
-- and so on.
-- * The [Wiki Plugins](#wiki-plugins) defines the plugin interface that is used
-- by the Wiki engine to provide pluggable extensions in the Wiki. Plugins are used
-- for the Wiki template support, to hide some Wiki text content when it is rendered
-- or to interact with other systems.
-- * The Wiki documents and attributes are used for the representation of the Wiki
-- document after the Wiki content is parsed.
-- * The [Wiki renderers](@wiki-render) are the last packages which are used for the rendering
-- of the Wiki document to produce the final HTML or text.
--
-- @include-doc docs/Tutorial.md
-- @include wiki-documents.ads
-- @include wiki-attributes.ads
-- @include wiki-parsers.ads
-- @include wiki-filters.ads
-- @include wiki-plugins.ads
-- @include wiki-render.ads
-- @include wiki-streams.ads
package Wiki is
pragma Preelaborate;
-- Defines the possible wiki syntax supported by the parser.
type Wiki_Syntax
is (
-- Google wiki syntax http://code.google.com/p/support/wiki/WikiSyntax
SYNTAX_GOOGLE,
-- Creole wiki syntax http://www.wikicreole.org/wiki/Creole1.0
SYNTAX_CREOLE,
-- Dotclear syntax http://dotclear.org/documentation/2.0/usage/syntaxes
SYNTAX_DOTCLEAR,
-- PhpBB syntax http://wiki.phpbb.com/Help:Formatting
SYNTAX_PHPBB,
-- MediaWiki syntax http://www.mediawiki.org/wiki/Help:Formatting
SYNTAX_MEDIA_WIKI,
-- Markdown
SYNTAX_MARKDOWN,
-- A mix of the above
SYNTAX_MIX,
-- The input is plain possibly incorrect HTML.
SYNTAX_HTML);
-- Defines the possible text formats.
type Format_Type is (BOLD, ITALIC, CODE, SUPERSCRIPT, SUBSCRIPT, STRIKEOUT, PREFORMAT);
type Format_Map is array (Format_Type) of Boolean;
-- The possible HTML tags as described in HTML5 specification.
type Html_Tag is
(
-- Section 4.1 The root element
ROOT_HTML_TAG,
-- Section 4.2 Document metadata
HEAD_TAG, TITLE_TAG, BASE_TAG, LINK_TAG, META_TAG, STYLE_TAG,
-- Section 4.3 Sections
BODY_TAG, ARTICLE_TAG, SECTION_TAG, NAV_TAG, ASIDE_TAG,
H1_TAG, H2_TAG, H3_TAG, H4_TAG, H5_TAG, H6_TAG,
HEADER_TAG, FOOTER_TAG,
ADDRESS_TAG,
-- Section 4.4 Grouping content
P_TAG, HR_TAG, PRE_TAG, BLOCKQUOTE_TAG,
OL_TAG, UL_TAG, LI_TAG,
DL_TAG, DT_TAG, DD_TAG,
FIGURE_TAG, FIGCAPTION_TAG,
DIV_TAG, MAIN_TAG,
-- Section 4.5 Text-level semantics
A_TAG, EM_TAG, STRONG_TAG, SMALL_TAG,
S_TAG, CITE_TAG, Q_TAG, DFN_TAG, ABBR_TAG,
DATA_TAG, TIME_TAG, CODE_TAG, VAR_TAG, SAMP_TAG,
KBD_TAG, SUB_TAG, SUP_TAG,
I_TAG, B_TAG, U_TAG,
MARK_TAG, RUBY_TAG, RB_TAG, RT_TAG, RTC_TAG,
RP_TAG, BDI_TAG, BDO_TAG, SPAN_TAG,
BR_TAG, WBR_TAG,
-- Section 4.6 Edits
INS_TAG, DEL_TAG,
-- Section 4.7 Embedded content
IMG_TAG,
IFRAME_TAG,
EMBED_TAG,
OBJECT_TAG,
PARAM_TAG,
VIDEO_TAG,
AUDIO_TAG,
SOURCE_TAG,
TRACK_TAG,
MAP_TAG,
AREA_TAG,
-- Section 4.9 Tabular data
TABLE_TAG, CAPTION_TAG, COLGROUP_TAG, COL_TAG,
TBODY_TAG, THEAD_TAG, TFOOT_TAG,
TR_TAG, TD_TAG, TH_TAG,
-- Section 4.10 Forms
FORM_TAG, LABEL_TAG, INPUT_TAG,
BUTTON_TAG, SELECT_TAG, DATALIST_TAG, OPTGROUP_TAG,
OPTION_TAG, TEXTAREA_TAG, KEYGEN_TAG, OUTPUT_TAG,
PROGRESS_TAG, METER_TAG, FIELDSET_TAG, LEGEND_TAG,
-- Section 4.11 Scripting
SCRIPT_TAG, NOSCRIPT_TAG,
TEMPLATE_TAG, CANVAS_TAG,
-- Deprecated tags but still used widely
TT_TAG,
-- Unknown tags
UNKNOWN_TAG
);
-- Find the tag from the tag name.
function Find_Tag (Name : in Wide_Wide_String) return Html_Tag;
type String_Access is access constant String;
-- Get the HTML tag name.
function Get_Tag_Name (Tag : in Html_Tag) return String_Access;
type Tag_Boolean_Array is array (Html_Tag) of Boolean;
No_End_Tag : constant Tag_Boolean_Array :=
(
BASE_TAG => True,
LINK_TAG => True,
META_TAG => True,
IMG_TAG => True,
HR_TAG => True,
BR_TAG => True,
WBR_TAG => True,
INPUT_TAG => True,
KEYGEN_TAG => True,
others => False);
Tag_Omission : constant Tag_Boolean_Array :=
(
-- Section 4.4 Grouping content
LI_TAG => True,
DT_TAG => True,
DD_TAG => True,
-- Section 4.5 Text-level semantics
RB_TAG => True,
RT_TAG => True,
RTC_TAG => True,
RP_TAG => True,
-- Section 4.9 Tabular data
TH_TAG => True,
TD_TAG => True,
TR_TAG => True,
TBODY_TAG => True,
THEAD_TAG => True,
TFOOT_TAG => True,
OPTGROUP_TAG => True,
OPTION_TAG => True,
others => False);
end Wiki;
|
-- Shoot'n'loot
-- Copyright (c) 2020 Fabien Chouteau
with HAL; use HAL;
with GESTE;
with GESTE.Tile_Bank;
with GESTE.Sprite.Animated;
with GESTE_Config;
with GESTE.Maths_Types; use GESTE.Maths_Types;
with GESTE.Physics;
with Game_Assets;
with Game_Assets.Tileset;
with Game_Assets.Misc_Objects;
with PyGamer.Screen;
with Projectile;
with Monsters;
with Sound;
package body Player is
package Item renames Game_Assets.Misc_Objects.Item;
Fire_Animation : aliased constant GESTE.Sprite.Animated.Animation_Array :=
((Item.P2.Tile_Id, 1),
(Item.P3.Tile_Id, 1),
(Item.P4.Tile_Id, 1),
(Item.P5.Tile_Id, 1),
(Item.P6.Tile_Id, 2),
(Item.P7.Tile_Id, 2),
(Item.P8.Tile_Id, 2),
(Item.P9.Tile_Id, 2),
(Item.P10.Tile_Id, 2),
(Item.P11.Tile_Id, 2),
(Item.P12.Tile_Id, 2),
(Item.P13.Tile_Id, 2));
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.Animated.Instance (Bank, Init_Frame);
Alive : Boolean := True;
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, Item.P1.Tile_Id);
Max_Jump_Frame : constant := 1;
Jumping : Boolean := False;
Do_Jump : Boolean := False;
Jump_Cnt : Natural := 0;
Going_Left : Boolean := False;
Going_Right : Boolean := False;
Firing : Boolean := False;
Grabing_Wall : Boolean := False;
Facing_Left : Boolean := False;
type Collision_Points is array (Natural range <>) of GESTE.Pix_Point;
-- Bounding Box points
BB_Top : constant Collision_Points :=
((-1, -4), (1, -4));
BB_Bottom : constant Collision_Points :=
((-1, 3), (1, 3));
BB_Left : constant Collision_Points :=
((-3, 1), (-3, -1));
BB_Right : constant Collision_Points :=
((2, 1), (2, -1));
Bounding_Box : constant Collision_Points :=
BB_Top & BB_Bottom & BB_Right & BB_Left;
Left_Wall : constant Collision_Points :=
(0 => (-4, 1));
Right_Wall : constant Collision_Points :=
(0 => (4, 1));
Grounded : Boolean := False;
Projs : array (1 .. 5) of Projectile.Instance
(Tile_Bank'Access, Item.Bullet.Tile_Id);
Show_Collision_Points : constant Boolean := False;
function Collides (Points : Collision_Points) return Boolean;
function Check_Monster_Collision return Boolean;
--------------
-- Collides --
--------------
function Collides (Points : Collision_Points) return Boolean is
X : constant Integer := Integer (P.Position.X);
Y : constant Integer := Integer (P.Position.Y);
begin
for Pt of Points loop
if Show_Collision_Points then
declare
Data : aliased HAL.UInt16_Array := (0 => 0);
begin
PyGamer.Screen.Set_Address (UInt16 (X + Pt.X),
UInt16 (X + Pt.X),
UInt16 (Y + Pt.Y),
UInt16 (Y + Pt.Y));
PyGamer.Screen.Start_Pixel_TX;
PyGamer.Screen.Push_Pixels (Data'Address, Data'Length);
PyGamer.Screen.End_Pixel_TX;
end;
end if;
if
X + Pt.X not in 0 .. PyGamer.Screen.Width - 1
or else
Y + Pt.Y not in 0 .. PyGamer.Screen.Height - 1
or else
GESTE.Collides ((X + Pt.X, Y + Pt.Y))
then
return True;
end if;
end loop;
return False;
end Collides;
-----------------------------
-- Check_Monster_Collision --
-----------------------------
function Check_Monster_Collision return Boolean is
X : constant Integer := Integer (P.Position.X);
Y : constant Integer := Integer (P.Position.Y);
begin
for Pt of Bounding_Box loop
if Monsters.Check_Hit ((X + Pt.X,
Y + Pt.Y),
Lethal => False)
then
return True;
end if;
end loop;
return False;
end Check_Monster_Collision;
-----------
-- Spawn --
-----------
procedure Spawn is
begin
P.Alive := True;
P.Set_Mass (Value (90.0));
P.Sprite.Flip_Vertical (False);
P.Set_Speed ((0.0, 0.0));
GESTE.Add (P.Sprite'Access, 3);
P.Sprite.Flip_Horizontal (True);
for Prj of Projs loop
Prj.Init;
end loop;
end Spawn;
----------
-- Move --
----------
procedure Move (Pt : GESTE.Pix_Point) is
begin
P.Set_Position (GESTE.Maths_Types.Point'(Value (Pt.X), Value (Pt.Y)));
P.Sprite.Move ((Integer (P.Position.X) - 4,
Integer (P.Position.Y) - 4));
end Move;
--------------
-- Position --
--------------
function Position return GESTE.Pix_Point
is ((Integer (P.Position.X), Integer (P.Position.Y)));
--------------
-- Is_Alive --
--------------
function Is_Alive return Boolean
is (P.Alive);
------------
-- Update --
------------
procedure Update is
Old : constant Point := P.Position;
Elapsed : constant Value := Value (1.0 / 60.0);
Collision_To_Fix : Boolean;
begin
-- Check collision with monsters
if Check_Monster_Collision then
P.Sprite.Flip_Vertical (True);
P.Alive := False;
end if;
if Going_Right then
Facing_Left := False;
P.Sprite.Flip_Horizontal (True);
elsif Going_Left then
Facing_Left := True;
P.Sprite.Flip_Horizontal (False);
end if;
-- Lateral movements
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 on the floor
P.Apply_Force (
(Value (Value (-2000.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;
end if;
-- Gavity
if not Grounded then
P.Apply_Gravity (Value (-500.0));
end if;
-- Wall grab
if not Grounded
and then
P.Speed.Y > 0.0 -- Going down
and then
-- Pushing against a wall
((Collides (Right_Wall))
or else
(Collides (Left_Wall)))
then
-- Friction against the wall
P.Apply_Force ((0.0, -4_0000.0));
Grabing_Wall := True;
else
Grabing_Wall := False;
end if;
-- Jump
if Do_Jump then
declare
Jmp_X : Value := 0.0;
begin
if Grabing_Wall then
-- Wall jump
Jmp_X := 215_000.0;
if Collides (Right_Wall) then
Jmp_X := -Jmp_X;
end if;
end if;
P.Apply_Force ((Jmp_X, -900_000.0));
Grounded := False;
Jumping := True;
Sound.Play_Jump;
end;
end if;
P.Step (Elapsed);
Grounded := False;
Collision_To_Fix := False;
if P.Speed.Y < 0.0 then
-- Going up
if Collides (BB_Top) then
Collision_To_Fix := True;
-- Cannot jump after touching a roof
Jump_Cnt := Max_Jump_Frame + 1;
-- Touching a roof, kill vertical speed
P.Set_Speed ((P.Speed.X, Value (0.0)));
-- Going back to previous Y coord
P.Set_Position ((P.Position.X, Old.Y));
end if;
elsif P.Speed.Y > 0.0 then
-- Going down
if Collides (BB_Bottom) then
Collision_To_Fix := True;
Grounded := True;
-- Can start jumping
Jump_Cnt := 0;
-- Touching a roof, kill vertical speed
P.Set_Speed ((P.Speed.X, Value (0.0)));
-- Going back to previous Y coord
P.Set_Position ((P.Position.X, Old.Y));
end if;
end if;
if P.Speed.X > 0.0 then
-- Going right
if Collides (BB_Right) then
Collision_To_Fix := True;
-- Touching a wall, kill horizontal speed
P.Set_Speed ((Value (0.0), P.Speed.Y));
-- Going back to previos X coord
P.Set_Position ((Old.X, P.Position.Y));
end if;
elsif P.Speed.X < 0.0 then
-- Going left
if Collides (BB_Left) then
Collision_To_Fix := True;
-- Touching a wall, kill horizontal speed
P.Set_Speed ((Value (0.0), P.Speed.Y));
-- Going back to previous X coord
P.Set_Position ((Old.X, P.Position.Y));
end if;
end if;
-- Fix the collisions, one pixel at a time
while Collision_To_Fix loop
Collision_To_Fix := False;
if Collides (BB_Top) then
Collision_To_Fix := True;
-- Try a new Y coord that do not collides
P.Set_Position ((P.Position.X, P.Position.Y + 1.0));
elsif Collides (BB_Bottom) then
Collision_To_Fix := True;
-- Try a new Y coord that do not collides
P.Set_Position ((P.Position.X, P.Position.Y - 1.0));
end if;
if Collides (BB_Right) then
Collision_To_Fix := True;
-- Try to find X coord that do not collides
P.Set_Position ((P.Position.X - 1.0, P.Position.Y));
elsif Collides (BB_Left) then
Collision_To_Fix := True;
-- Try to find X coord that do not collides
P.Set_Position ((P.Position.X + 1.0, P.Position.Y));
end if;
end loop;
Jumping := Jumping and not Grounded;
P.Sprite.Signal_Frame;
P.Sprite.Move ((Integer (P.Position.X) - 4,
Integer (P.Position.Y) - 4));
if Firing then
Fire_Projectile :
for Proj of Projs loop
if not Proj.Alive then
if Facing_Left then
Proj.Set_Speed ((-120.0 + P.Speed.X, 0.0));
else
Proj.Set_Speed ((120.0 + P.Speed.X, 0.0));
end if;
Proj.Spawn (Pos => P.Position,
Time_To_Live => 2.0,
Priority => 2);
P.Sprite.Set_Animation (Fire_Animation'Access,
Looping => False);
Sound.Play_Gun;
exit Fire_Projectile;
end if;
end loop Fire_Projectile;
end if;
for Proj of Projs loop
Proj.Update (Elapsed);
if Proj.Alive
and then
(Monsters.Check_Hit (Proj.Position, Lethal => True)
or else
GESTE.Collides (Proj.Position)
)
then
Proj.Remove;
end if;
end loop;
Do_Jump := False;
Going_Left := False;
Going_Right := False;
Firing := False;
end Update;
----------
-- Jump --
----------
procedure Jump is
begin
if Grounded
or else
Grabing_Wall
or else
(Jump_Cnt < Max_Jump_Frame)
then
Do_Jump := True;
Jump_Cnt := Jump_Cnt + 1;
end if;
end Jump;
----------
-- Fire --
----------
procedure Fire is
begin
Firing := True;
end Fire;
---------------
-- 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;
end Player;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- S Y S T E M . V A L _ E N U M --
-- --
-- S p e c --
-- --
-- $Revision: 2 $ --
-- --
-- Copyright (c) 1992,1993,1994 NYU, All Rights Reserved --
-- --
-- The GNAT library is free software; you can redistribute it and/or modify --
-- it under terms of the GNU Library General Public License as published by --
-- the Free Software Foundation; either version 2, or (at your option) any --
-- later version. The GNAT library is distributed in the hope that it will --
-- be useful, but WITHOUT ANY WARRANTY; without even the implied warranty --
-- of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU --
-- Library General Public License for more details. You should have --
-- received a copy of the GNU Library General Public License along with --
-- the GNAT library; see the file COPYING.LIB. If not, write to the Free --
-- Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. --
-- --
------------------------------------------------------------------------------
package System.Val_Enum is
pragma Pure (Val_Enum);
function Value_Enumeration
(A : Address;
Last_Pos : Natural;
Str : String)
return Natural;
-- Used in computing Enum'Value (Str) where Enum is some enumeration type
-- other thanBoolean or Character. A is the address of the Lit_Name_Table,
-- which is the table of access to strings, generated by Gigi for each
-- enumeration type. The table is an array whose index values are 'Pos
-- values and whose values are access to strings which are are the 'Image
-- values. Last_Pos is the last index in the table for the enumeration
-- type. This function will search the table looking for a match against
-- Str, and if one is found the position number in the table is returned.
-- If not, Constraint_Error is raised. Str may have leading and trailing
-- spaces and may be in upper or lower case.
end System.Val_Enum;
|
------------------------------------------------------------------------------
-- --
-- GNAT COMPILER COMPONENTS --
-- --
-- G N A T . A L T I V E C . V E C T O R _ V I E W S --
-- --
-- S p e c --
-- --
-- Copyright (C) 2005-2009, 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. --
-- --
-- --
-- --
-- --
-- --
-- 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 unit provides public 'View' data types from/to which private vector
-- representations can be converted via Altivec.Conversions. This allows
-- convenient access to individual vector elements and provides a simple way
-- to initialize vector objects.
-- Accessing vector contents with direct memory overlays should be avoided
-- because actual vector representations may vary across configurations, for
-- instance to accommodate different target endianness.
-- The natural representation of a vector is an array indexed by vector
-- component number, which is materialized by the Varray type definitions
-- below. The 16byte alignment constraint is unfortunately sometimes not
-- properly honored for constant array aggregates, so the View types are
-- actually records enclosing such arrays.
package GNAT.Altivec.Vector_Views is
---------------------
-- char components --
---------------------
type Vchar_Range is range 1 .. 16;
type Varray_unsigned_char is array (Vchar_Range) of unsigned_char;
for Varray_unsigned_char'Alignment use VECTOR_ALIGNMENT;
type VUC_View is record
Values : Varray_unsigned_char;
end record;
type Varray_signed_char is array (Vchar_Range) of signed_char;
for Varray_signed_char'Alignment use VECTOR_ALIGNMENT;
type VSC_View is record
Values : Varray_signed_char;
end record;
type Varray_bool_char is array (Vchar_Range) of bool_char;
for Varray_bool_char'Alignment use VECTOR_ALIGNMENT;
type VBC_View is record
Values : Varray_bool_char;
end record;
----------------------
-- short components --
----------------------
type Vshort_Range is range 1 .. 8;
type Varray_unsigned_short is array (Vshort_Range) of unsigned_short;
for Varray_unsigned_short'Alignment use VECTOR_ALIGNMENT;
type VUS_View is record
Values : Varray_unsigned_short;
end record;
type Varray_signed_short is array (Vshort_Range) of signed_short;
for Varray_signed_short'Alignment use VECTOR_ALIGNMENT;
type VSS_View is record
Values : Varray_signed_short;
end record;
type Varray_bool_short is array (Vshort_Range) of bool_short;
for Varray_bool_short'Alignment use VECTOR_ALIGNMENT;
type VBS_View is record
Values : Varray_bool_short;
end record;
--------------------
-- int components --
--------------------
type Vint_Range is range 1 .. 4;
type Varray_unsigned_int is array (Vint_Range) of unsigned_int;
for Varray_unsigned_int'Alignment use VECTOR_ALIGNMENT;
type VUI_View is record
Values : Varray_unsigned_int;
end record;
type Varray_signed_int is array (Vint_Range) of signed_int;
for Varray_signed_int'Alignment use VECTOR_ALIGNMENT;
type VSI_View is record
Values : Varray_signed_int;
end record;
type Varray_bool_int is array (Vint_Range) of bool_int;
for Varray_bool_int'Alignment use VECTOR_ALIGNMENT;
type VBI_View is record
Values : Varray_bool_int;
end record;
----------------------
-- float components --
----------------------
type Vfloat_Range is range 1 .. 4;
type Varray_float is array (Vfloat_Range) of C_float;
for Varray_float'Alignment use VECTOR_ALIGNMENT;
type VF_View is record
Values : Varray_float;
end record;
----------------------
-- pixel components --
----------------------
type Vpixel_Range is range 1 .. 8;
type Varray_pixel is array (Vpixel_Range) of pixel;
for Varray_pixel'Alignment use VECTOR_ALIGNMENT;
type VP_View is record
Values : Varray_pixel;
end record;
end GNAT.Altivec.Vector_Views;
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.